@dropins/storefront-quote-management 0.0.1-alpha30 → 0.0.1-alpha32

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 (68) hide show
  1. package/api/duplicateNegotiableQuote/duplicateNegotiableQuote.d.ts +1 -0
  2. package/api/getQuoteTemplates/graphql/getQuoteTemplates.d.ts +1 -1
  3. package/api/graphql/NegotiableQuoteTemplateFragment.d.ts +1 -1
  4. package/api.js +1 -1
  5. package/chunks/AttachedFilesList.js +1 -1
  6. package/chunks/AttachedFilesList.js.map +1 -1
  7. package/chunks/CheckWithCircle.js +4 -0
  8. package/chunks/CheckWithCircle.js.map +1 -0
  9. package/chunks/ItemsQuoted.js +1 -1
  10. package/chunks/ItemsQuoted.js.map +1 -1
  11. package/chunks/ItemsQuotedTemplate.js +1 -1
  12. package/chunks/ItemsQuotedTemplate.js.map +1 -1
  13. package/chunks/LineItemNoteModal.js +1 -1
  14. package/chunks/LineItemNoteModal.js.map +1 -1
  15. package/chunks/NegotiableQuoteTemplateFragment.js +148 -6
  16. package/chunks/NegotiableQuoteTemplateFragment.js.map +1 -1
  17. package/chunks/ShippingAddressDisplay.js +1 -1
  18. package/chunks/ShippingAddressDisplay.js.map +1 -1
  19. package/chunks/WarningFilled.js +1 -1
  20. package/chunks/WarningFilled.js.map +1 -1
  21. package/chunks/addQuoteTemplateLineItemNote.js +1 -1
  22. package/chunks/addQuoteTemplateLineItemNote.js.map +1 -1
  23. package/chunks/duplicateNegotiableQuote.js +8 -8
  24. package/chunks/duplicateNegotiableQuote.js.map +1 -1
  25. package/chunks/getQuoteTemplates.js +13 -11
  26. package/chunks/getQuoteTemplates.js.map +1 -1
  27. package/chunks/negotiableQuotes.js +1 -1
  28. package/chunks/transform-quote-template.js +1 -1
  29. package/chunks/transform-quote-template.js.map +1 -1
  30. package/chunks/transform-quote.js +1 -1
  31. package/chunks/transform-quote.js.map +1 -1
  32. package/components/LineItemNoteModal/LineItemNoteModal.d.ts +2 -2
  33. package/components/ProductListTable/ProductListTable.d.ts +5 -49
  34. package/containers/ItemsQuoted/ItemsQuoted.d.ts +7 -7
  35. package/containers/ItemsQuoted.js +1 -1
  36. package/containers/ItemsQuotedTemplate/ItemsQuotedTemplate.d.ts +3 -3
  37. package/containers/ItemsQuotedTemplate.js +1 -1
  38. package/containers/ManageNegotiableQuote/ManageNegotiableQuote.d.ts +3 -4
  39. package/containers/ManageNegotiableQuote.js +1 -1
  40. package/containers/ManageNegotiableQuote.js.map +1 -1
  41. package/containers/ManageNegotiableQuoteTemplate.js +2 -2
  42. package/containers/ManageNegotiableQuoteTemplate.js.map +1 -1
  43. package/containers/QuoteSummaryList/QuoteSummaryList.d.ts +1 -1
  44. package/containers/QuoteSummaryList.js +1 -1
  45. package/containers/QuoteSummaryList.js.map +1 -1
  46. package/containers/QuoteTemplatesListTable.js +1 -1
  47. package/containers/QuoteTemplatesListTable.js.map +1 -1
  48. package/containers/QuotesListTable.js +1 -1
  49. package/containers/QuotesListTable.js.map +1 -1
  50. package/containers/RequestNegotiableQuoteForm.js +1 -1
  51. package/containers/RequestNegotiableQuoteForm.js.map +1 -1
  52. package/containers/ShippingAddressDisplay.js +1 -1
  53. package/data/models/__fixtures__/negotiableQuoteModel.d.ts +5 -5
  54. package/data/models/negotiable-quote-model.d.ts +2 -2
  55. package/data/models/negotiable-quote-template-model.d.ts +3 -39
  56. package/data/transforms/__fixtures__/negotiableQuoteData.d.ts +5 -0
  57. package/data/transforms/__fixtures__/negotiableQuoteTemplateData.d.ts +561 -75
  58. package/data/transforms/transform-history.d.ts +15 -0
  59. package/data/transforms/transform-quote-items.d.ts +15 -0
  60. package/hooks/useItemsQuotedTemplate.d.ts +3 -4
  61. package/hooks/useRemoveTemplateItems.d.ts +3 -3
  62. package/hooks/useUpdateTemplateQuantities.d.ts +2 -2
  63. package/i18n/en_US.json.d.ts +24 -5
  64. package/lib/itemFormatters.d.ts +1 -1
  65. package/lib/priceCalculators.d.ts +1 -1
  66. package/package.json +1 -1
  67. package/render.js +2 -2
  68. package/render.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"duplicateNegotiableQuote.js","sources":["/@dropins/storefront-quote-management/src/api/getQuoteData/graphql/QuoteDataQuery.ts","/@dropins/storefront-quote-management/src/api/getQuoteData/getQuoteData.ts","/@dropins/storefront-quote-management/src/api/deleteQuote/graphql/DeleteQuoteMutation.ts","/@dropins/storefront-quote-management/src/api/deleteQuote/deleteQuote.ts","/@dropins/storefront-quote-management/src/api/sendForReview/graphql/SendNegotiableQuoteForReviewMutation.ts","/@dropins/storefront-quote-management/src/api/sendForReview/sendForReview.ts","/@dropins/storefront-quote-management/src/api/closeNegotiableQuote/graphql/CloseNegotiableQuoteMutation.ts","/@dropins/storefront-quote-management/src/api/closeNegotiableQuote/closeNegotiableQuote.ts","/@dropins/storefront-quote-management/src/api/createQuoteTemplate/graphql/createQuoteTemplate.ts","/@dropins/storefront-quote-management/src/api/createQuoteTemplate/createQuoteTemplate.ts","/@dropins/storefront-quote-management/src/api/renameNegotiableQuote/graphql/RenameNegotiableQuoteMutation.ts","/@dropins/storefront-quote-management/src/api/renameNegotiableQuote/renameNegotiableQuote.ts","/@dropins/storefront-quote-management/src/api/duplicateNegotiableQuote/graphql/duplicateNegotiableQuoteMutation.ts","/@dropins/storefront-quote-management/src/api/duplicateNegotiableQuote/duplicateNegotiableQuote.ts"],"sourcesContent":["import { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const QUOTE_DATA_QUERY = `\n query QUOTE_DATA_QUERY(\n $quoteId: ID!\n ) {\n negotiableQuote(\n uid: $quoteId\n ) {\n ...NegotiableQuoteFragment\n }\n }\n\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api/';\nimport { QUOTE_DATA_QUERY } from './graphql/QuoteDataQuery';\nimport { transformQuote } from '@/quote-management/data/transforms';\nimport { state } from '@/quote-management/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const getQuoteData = async (quoteId: string) => { \n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n if (!state.permissions.editQuote) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n try {\n const results: any = await fetchGraphQl(QUOTE_DATA_QUERY, {\n variables: {\n quoteId\n }\n });\n\n const transformedQuote = transformQuote(results?.data?.negotiableQuote);\n\n if (!transformedQuote) {\n throw new Error('Failed to transform quote data');\n }\n\n events.emit('quote-management/quote-data', {\n quote: transformedQuote,\n permissions: state.permissions,\n });\n \n return transformedQuote;\n } catch (error) {\n return Promise.reject(error);\n }\n}\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nexport const DELETE_QUOTE_MUTATION = `\n mutation DELETE_QUOTE_MUTATION($quoteUids: [ID!]!) {\n deleteNegotiableQuotes(\n input: {\n quote_uids: $quoteUids\n }\n ) {\n result_status\n operation_results {\n __typename\n ... on NegotiableQuoteUidOperationSuccess {\n quote_uid\n }\n ... on DeleteNegotiableQuoteOperationFailure {\n quote_uid\n errors {\n __typename\n ... on ErrorInterface {\n message\n }\n ... on NoSuchEntityUidError {\n uid\n message\n }\n ... on NegotiableQuoteInvalidStateError {\n message\n }\n }\n }\n }\n }\n }\n`;\n\n\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n \nimport { fetchGraphQl } from '@/quote-management/api';\nimport { state } from '@/quote-management/lib/state';\nimport { DELETE_QUOTE_MUTATION } from '@/quote-management/api/deleteQuote/graphql/DeleteQuoteMutation';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport interface DeleteQuoteSuccessResult {\n __typename: 'NegotiableQuoteUidOperationSuccess';\n quoteUid: string;\n}\n\nexport interface DeleteQuoteFailureError {\n __typename: string;\n message?: string;\n uid?: string;\n}\n\nexport interface DeleteQuoteFailureResult {\n __typename: 'DeleteNegotiableQuoteOperationFailure';\n quoteUid: string;\n errors: DeleteQuoteFailureError[];\n}\n\nexport interface DeleteQuoteOutput {\n resultStatus: string;\n operationResults: Array<DeleteQuoteSuccessResult | DeleteQuoteFailureResult>;\n}\n\nexport const deleteQuote = async ( quoteUids: string[] | string ): Promise<DeleteQuoteOutput> => {\n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n const quoteUidsArray = Array.isArray(quoteUids) ? quoteUids : [quoteUids];\n\n try {\n const response: any = await fetchGraphQl(DELETE_QUOTE_MUTATION, {\n variables: {\n quoteUids: quoteUidsArray,\n },\n });\n\n const { errors } = response || {};\n if (errors && errors.length) {\n const errorMessages = errors.map((e: any) => e?.message).filter(Boolean).join('; ');\n throw new Error(errorMessages || 'Failed to delete negotiable quotes');\n }\n\n const raw = response?.data?.deleteNegotiableQuotes;\n if (!raw) {\n throw new Error('No delete result returned');\n }\n\n const transformed: DeleteQuoteOutput = {\n resultStatus: raw.result_status,\n operationResults: (raw.operation_results || []).map((result: any) => {\n const typename = result?.__typename;\n if (typename === 'NegotiableQuoteUidOperationSuccess') {\n const success: DeleteQuoteSuccessResult = {\n __typename: 'NegotiableQuoteUidOperationSuccess',\n quoteUid: result?.quote_uid,\n };\n return success;\n }\n const failure: DeleteQuoteFailureResult = {\n __typename: 'DeleteNegotiableQuoteOperationFailure',\n quoteUid: result?.quote_uid,\n errors: (result?.errors || []).map((err: any) => ({\n __typename: err?.__typename,\n message: err?.message,\n uid: err?.uid,\n })),\n };\n return failure;\n }),\n };\n\n // Emit event with successfully deleted quote UIDs\n const deletedUids = transformed.operationResults\n .filter((res) => res.__typename === 'NegotiableQuoteUidOperationSuccess')\n .map((res) => (res as DeleteQuoteSuccessResult).quoteUid);\n\n if (deletedUids.length > 0) {\n events.emit('quote-management/negotiable-quote-deleted', {\n deletedQuoteUids: deletedUids,\n resultStatus: transformed.resultStatus,\n });\n }\n\n return transformed;\n } catch (error) {\n // Emit error event for integration layer\n events.emit('quote-management/negotiable-quote-delete-error', {\n error: error instanceof Error ? error : new Error(String(error)),\n attemptedQuoteUids: quoteUidsArray,\n });\n return Promise.reject(error);\n }\n};\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION = `\n mutation SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION(\n $quoteUid: ID!\n $comment: NegotiableQuoteCommentInput\n ) {\n sendNegotiableQuoteForReview(\n input: {\n quote_uid: $quoteUid\n comment: $comment\n }\n ) {\n quote {\n ...NegotiableQuoteFragment\n }\n }\n }\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport { SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION } from './graphql/SendNegotiableQuoteForReviewMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\n\nexport interface SendForReviewInput {\n quoteUid: string;\n comment?: string;\n attachments?: { key: string }[];\n}\n\nexport const sendForReview = async (\n input: SendForReviewInput\n): Promise<NegotiableQuoteModel | null> => {\n const { quoteUid, comment, attachments } = input;\n\n if (!quoteUid) {\n throw new Error('Quote UID is required');\n }\n\n // Build the comment object with attachments if provided\n const commentInput = attachments?.length \n ? { comment: comment || '', attachments } \n : comment \n ? { comment } \n : null;\n\n return fetchGraphQl(SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION, {\n variables: {\n quoteUid,\n comment: commentInput,\n },\n }).then((response) => {\n const { errors } = response;\n\n if (errors) {\n // Provide more detailed error information\n const errorMessages = errors.map((error) => error.message).join('; ');\n throw new Error(`Failed to send quote for review: ${errorMessages}`);\n }\n\n // Transform the quote data\n const quoteData = transformQuote(\n response.data?.sendNegotiableQuoteForReview?.quote\n );\n\n if (!quoteData) {\n throw new Error(\n 'Failed to transform quote data: Invalid response structure'\n );\n }\n\n // Emit event with transformed quote data on success\n events.emit('quote-management/quote-sent-for-review', {\n quote: quoteData,\n input: { quoteUid, comment, attachments },\n });\n\n return quoteData;\n });\n};\n\n","export const CLOSE_NEGOTIABLE_QUOTE_MUTATION = `\n mutation CLOSE_NEGOTIABLE_QUOTE_MUTATION(\n $quoteUids: [ID!]!\n ) {\n closeNegotiableQuotes(input: { quote_uids: $quoteUids }) {\n result_status\n operation_results {\n ... on NegotiableQuoteUidOperationSuccess {\n __typename\n quote_uid\n }\n ... on CloseNegotiableQuoteOperationFailure {\n __typename\n quote_uid\n errors {\n __typename\n ... on ErrorInterface {\n message\n }\n ... on NoSuchEntityUidError {\n uid\n }\n ... on NegotiableQuoteInvalidStateError {\n message\n }\n }\n }\n }\n }\n }\n`;","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api';\nimport { state } from '@/quote-management/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\nimport { CLOSE_NEGOTIABLE_QUOTE_MUTATION } from './graphql/CloseNegotiableQuoteMutation';\n\nexport interface CloseNegotiableQuoteInput {\n quoteUids: string[];\n}\n\nexport interface CloseNegotiableQuoteSuccessResult {\n __typename: 'NegotiableQuoteUidOperationSuccess';\n quoteUid: string;\n}\n\nexport interface CloseNegotiableQuoteFailureError {\n __typename: string;\n message?: string;\n uid?: string;\n}\n\nexport interface CloseNegotiableQuoteFailureResult {\n __typename: 'CloseNegotiableQuoteOperationFailure';\n quoteUid: string;\n errors: CloseNegotiableQuoteFailureError[];\n}\n\nexport interface CloseNegotiableQuoteResult {\n resultStatus: string;\n operationResults: Array<CloseNegotiableQuoteSuccessResult | CloseNegotiableQuoteFailureResult>;\n}\n\nexport const closeNegotiableQuote = async (input: CloseNegotiableQuoteInput): Promise<CloseNegotiableQuoteResult> => { \n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n const { quoteUids } = input;\n\n if (!quoteUids || quoteUids.length === 0) {\n throw new Error('Quote UIDs are required');\n }\n\n try {\n const response: any = await fetchGraphQl(CLOSE_NEGOTIABLE_QUOTE_MUTATION, {\n variables: {\n quoteUids,\n },\n });\n\n const { errors } = response || {};\n if (errors && errors.length) {\n const errorMessages = errors\n .map((e: any) => e?.message)\n .filter(Boolean)\n .join('; ');\n throw new Error(errorMessages || 'Failed to close negotiable quotes');\n }\n\n const raw = response?.data?.closeNegotiableQuotes;\n if (!raw) {\n throw new Error('No close result returned');\n }\n\n const transformed: CloseNegotiableQuoteResult = {\n resultStatus: raw.result_status,\n operationResults: (raw.operation_results || []).map((result: any) => {\n const typename = result?.__typename;\n if (typename === 'NegotiableQuoteUidOperationSuccess') {\n const success: CloseNegotiableQuoteSuccessResult = {\n __typename: 'NegotiableQuoteUidOperationSuccess',\n quoteUid: result?.quote_uid,\n };\n return success;\n }\n const failure: CloseNegotiableQuoteFailureResult = {\n __typename: 'CloseNegotiableQuoteOperationFailure',\n quoteUid: result?.quote_uid,\n errors: (result?.errors || []).map((err: any) => ({\n __typename: err?.__typename,\n message: err?.message,\n uid: err?.uid,\n })),\n };\n return failure;\n }),\n };\n\n // Check for operation failures\n const failures = transformed.operationResults\n .filter(\n (res) => res.__typename === 'CloseNegotiableQuoteOperationFailure'\n )\n .map((res) => res as CloseNegotiableQuoteFailureResult);\n\n if (failures.length > 0) {\n // Create error message from failures\n const failureMessages = failures\n .map((failure) => {\n if (failure.errors && failure.errors.length > 0) {\n return failure.errors\n .map(\n (err) =>\n err.message || `Failed to close quote ${failure.quoteUid}`\n )\n .join(', ');\n }\n return `Failed to close quote ${failure.quoteUid}`;\n })\n .join('; ');\n\n throw new Error(failureMessages);\n }\n\n // Emit success event with closed quote UIDs\n const closedUids = transformed.operationResults\n .filter((res) => res.__typename === 'NegotiableQuoteUidOperationSuccess')\n .map((res) => (res as CloseNegotiableQuoteSuccessResult).quoteUid);\n\n if (closedUids.length > 0) {\n events.emit('quote-management/negotiable-quote-closed', {\n closedQuoteUids: closedUids,\n resultStatus: transformed.resultStatus,\n });\n }\n\n return transformed;\n } catch (error) {\n // Emit error event for integration layer\n events.emit('quote-management/negotiable-quote-close-error', {\n error: error instanceof Error ? error : new Error(String(error)),\n attemptedQuoteUids: quoteUids,\n });\n return Promise.reject(error);\n }\n}\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_TEMPLATE_FRAGMENT } from \"../../graphql/NegotiableQuoteTemplateFragment\";\n\nexport const CREATE_QUOTE_TEMPLATE_MUTATION = /* GraphQL */ `\n mutation CREATE_QUOTE_TEMPLATE_MUTATION($cartId: ID!) {\n requestNegotiableQuoteTemplateFromQuote(input: { cart_id: $cartId }) {\n ...NegotiableQuoteTemplateFragment\n }\n }\n\n ${NEGOTIABLE_QUOTE_TEMPLATE_FRAGMENT}\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { events } from '@adobe-commerce/event-bus';\nimport { fetchGraphQl } from '@/quote-management/api/';\nimport { CREATE_QUOTE_TEMPLATE_MUTATION } from './graphql/createQuoteTemplate';\nimport { state } from '@/quote-management/lib/state';\nimport { transformQuoteTemplate } from '@/quote-management/data/transforms';\nimport { NegotiableQuoteTemplateModel } from '@/quote-management/data/models/negotiable-quote-template-model';\n\nexport const createQuoteTemplate = async (\n quoteId: string\n): Promise<NegotiableQuoteTemplateModel | null> => {\n if (!state.authenticated) {\n throw new Error('Unauthorized');\n }\n\n if (!quoteId) {\n throw new Error('Cart ID is required');\n }\n\n try {\n const results: any = await fetchGraphQl(CREATE_QUOTE_TEMPLATE_MUTATION, {\n variables: {\n cartId: quoteId,\n },\n });\n\n if (!results?.data?.requestNegotiableQuoteTemplateFromQuote) {\n throw new Error('Failed to create quote template');\n }\n\n const transformedQuoteTemplate = transformQuoteTemplate(\n results.data.requestNegotiableQuoteTemplateFromQuote\n );\n\n if (!transformedQuoteTemplate) {\n throw new Error('Failed to transform quote template data');\n }\n\n events.emit('quote-management/quote-template-data', {\n quoteTemplate: transformedQuoteTemplate,\n permissions: state.permissions,\n });\n\n events.emit('quote-management/quote-template-created', {\n quoteTemplate: transformedQuoteTemplate,\n input: {\n quoteUid: quoteId,\n },\n });\n\n return transformedQuoteTemplate;\n } catch (error) {\n return Promise.reject(error);\n }\n};\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const RENAME_NEGOTIABLE_QUOTE_MUTATION = `\n mutation renameNegotiableQuote($input: RenameNegotiableQuoteInput!) {\n renameNegotiableQuote(input: $input) {\n quote {\n ...NegotiableQuoteFragment\n }\n }\n }\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`;\n\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport { RENAME_NEGOTIABLE_QUOTE_MUTATION } from './graphql/RenameNegotiableQuoteMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\n\nexport interface RenameNegotiableQuoteInput {\n quoteUid: string;\n quoteName: string;\n quoteComment?: string;\n}\n\nexport const renameNegotiableQuote = async (\n input: RenameNegotiableQuoteInput\n): Promise<NegotiableQuoteModel | null> => {\n const { quoteUid, quoteName, quoteComment } = input;\n\n if (!quoteUid) {\n throw new Error('Quote UID is required');\n }\n\n if (!quoteName) {\n throw new Error('Quote name is required');\n }\n\n // Backend requires quote_comment to be present (even if empty string)\n const mutationInput = {\n quote_uid: quoteUid,\n quote_name: quoteName,\n quote_comment: quoteComment || '', // Always include, use empty string if not provided\n };\n\n return fetchGraphQl(RENAME_NEGOTIABLE_QUOTE_MUTATION, {\n variables: {\n input: mutationInput,\n },\n }).then((response) => {\n const { errors } = response;\n\n if (errors) {\n // Provide more detailed error information\n const errorMessages = errors.map((error) => error.message).join('; ');\n throw new Error(`Failed to rename quote: ${errorMessages}`);\n }\n\n // Transform the quote data\n const quoteData = transformQuote(\n response.data?.renameNegotiableQuote?.quote\n );\n\n if (!quoteData) {\n throw new Error(\n 'Failed to transform quote data: Invalid response structure'\n );\n }\n\n // Emit event with transformed quote data on success\n events.emit('quote-management/quote-renamed', {\n quote: quoteData,\n input: { quoteUid, quoteName, quoteComment },\n });\n\n return quoteData;\n });\n};\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const DUPLICATE_NEGOTIABLE_QUOTE_MUTATION = `\n mutation DUPLICATE_NEGOTIABLE_QUOTE_MUTATION($quoteUid: ID!, $duplicatedQuoteUid: ID!) {\n duplicateNegotiableQuote(input: { quote_uid: $quoteUid, duplicated_quote_uid: $duplicatedQuoteUid }) {\n quote {\n ...NegotiableQuoteFragment\n }\n }\n }\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport { DUPLICATE_NEGOTIABLE_QUOTE_MUTATION } from './graphql/duplicateNegotiableQuoteMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\nimport { state } from '@/quote-management/lib/state';\n\nexport interface DuplicateQuoteInput {\n quoteUid: string;\n duplicatedQuoteUid: string;\n}\n\nexport const duplicateQuote = async (\n input: DuplicateQuoteInput\n): Promise<NegotiableQuoteModel | null> => {\n\n if (!state.authenticated) {\n throw new Error('Unauthorized');\n }\n\n const { quoteUid, duplicatedQuoteUid } = input;\n\n if (!quoteUid || !quoteUid.trim()) {\n throw new Error('Quote UID is required');\n }\n\n if (!duplicatedQuoteUid || !duplicatedQuoteUid.trim()) {\n throw new Error('Duplicated Quote UID is required');\n }\n\n return fetchGraphQl(DUPLICATE_NEGOTIABLE_QUOTE_MUTATION, {\n variables: { quoteUid, duplicatedQuoteUid },\n }).then((response) => {\n const { errors } = response;\n\n if (errors) {\n const errorMessages = errors.map((error) => error.message).join('; ');\n throw new Error(`Failed to duplicate quote: ${errorMessages}`);\n }\n\n const quoteData = transformQuote(\n response.data?.duplicateNegotiableQuote?.quote\n );\n\n if (!quoteData) {\n throw new Error(\n 'Failed to transform quote data: Invalid response structure'\n );\n }\n\n events.emit('quote-management/quote-duplicated', {\n quote: quoteData,\n input: { quoteUid, duplicatedQuoteUid },\n });\n\n return quoteData;\n });\n};\n"],"names":["QUOTE_DATA_QUERY","NEGOTIABLE_QUOTE_FRAGMENT","getQuoteData","quoteId","state","results","fetchGraphQl","transformedQuote","transformQuote","_a","events","error","DELETE_QUOTE_MUTATION","deleteQuote","quoteUids","quoteUidsArray","response","errors","errorMessages","e","raw","transformed","result","err","deletedUids","res","SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION","sendForReview","input","quoteUid","comment","attachments","commentInput","quoteData","_b","CLOSE_NEGOTIABLE_QUOTE_MUTATION","closeNegotiableQuote","failures","failureMessages","failure","closedUids","CREATE_QUOTE_TEMPLATE_MUTATION","NEGOTIABLE_QUOTE_TEMPLATE_FRAGMENT","createQuoteTemplate","transformedQuoteTemplate","transformQuoteTemplate","RENAME_NEGOTIABLE_QUOTE_MUTATION","renameNegotiableQuote","quoteName","quoteComment","DUPLICATE_NEGOTIABLE_QUOTE_MUTATION","duplicateQuote","duplicatedQuoteUid"],"mappings":"gSAEO,MAAMA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAW1BC,CAAyB;AAAA,ECElBC,EAAe,MAAOC,GAAoB,OACnD,GAAI,CAACC,EAAM,cACP,OAAO,QAAQ,OAAO,IAAI,MAAM,cAAc,CAAC,EAGnD,GAAI,CAACA,EAAM,YAAY,UACnB,OAAO,QAAQ,OAAO,IAAI,MAAM,cAAc,CAAC,EAGnD,G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S,OAAT,YAAAP,EAAe,2BAAf,YAAAyB,EAAyC,KAAA,EAG3C,GAAI,CAACD,EACH,MAAM,IAAI,MACR,4DAAA,EAIJ,OAAAvB,EAAO,KAAK,oCAAqC,CAC/C,MAAOuB,EACP,MAAO,CAAE,SAAAJ,EAAU,mBAAAuB,CAAA,CAAmB,CACvC,EAEMnB,CACT,CAAC,CACH"}
1
+ {"version":3,"file":"duplicateNegotiableQuote.js","sources":["/@dropins/storefront-quote-management/src/api/getQuoteData/graphql/QuoteDataQuery.ts","/@dropins/storefront-quote-management/src/api/getQuoteData/getQuoteData.ts","/@dropins/storefront-quote-management/src/api/deleteQuote/graphql/DeleteQuoteMutation.ts","/@dropins/storefront-quote-management/src/api/deleteQuote/deleteQuote.ts","/@dropins/storefront-quote-management/src/api/sendForReview/graphql/SendNegotiableQuoteForReviewMutation.ts","/@dropins/storefront-quote-management/src/api/sendForReview/sendForReview.ts","/@dropins/storefront-quote-management/src/api/closeNegotiableQuote/graphql/CloseNegotiableQuoteMutation.ts","/@dropins/storefront-quote-management/src/api/closeNegotiableQuote/closeNegotiableQuote.ts","/@dropins/storefront-quote-management/src/api/createQuoteTemplate/graphql/createQuoteTemplate.ts","/@dropins/storefront-quote-management/src/api/createQuoteTemplate/createQuoteTemplate.ts","/@dropins/storefront-quote-management/src/api/renameNegotiableQuote/graphql/RenameNegotiableQuoteMutation.ts","/@dropins/storefront-quote-management/src/api/renameNegotiableQuote/renameNegotiableQuote.ts","/@dropins/storefront-quote-management/src/api/duplicateNegotiableQuote/graphql/duplicateNegotiableQuoteMutation.ts","/@dropins/storefront-quote-management/src/api/duplicateNegotiableQuote/duplicateNegotiableQuote.ts"],"sourcesContent":["import { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const QUOTE_DATA_QUERY = `\n query QUOTE_DATA_QUERY(\n $quoteId: ID!\n ) {\n negotiableQuote(\n uid: $quoteId\n ) {\n ...NegotiableQuoteFragment\n }\n }\n\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api/';\nimport { QUOTE_DATA_QUERY } from './graphql/QuoteDataQuery';\nimport { transformQuote } from '@/quote-management/data/transforms';\nimport { state } from '@/quote-management/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const getQuoteData = async (quoteId: string) => { \n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n if (!state.permissions.editQuote) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n try {\n const results: any = await fetchGraphQl(QUOTE_DATA_QUERY, {\n variables: {\n quoteId\n }\n });\n\n const transformedQuote = transformQuote(results?.data?.negotiableQuote);\n\n if (!transformedQuote) {\n throw new Error('Failed to transform quote data');\n }\n\n events.emit('quote-management/quote-data', {\n quote: transformedQuote,\n permissions: state.permissions,\n });\n \n return transformedQuote;\n } catch (error) {\n return Promise.reject(error);\n }\n}\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nexport const DELETE_QUOTE_MUTATION = `\n mutation DELETE_QUOTE_MUTATION($quoteUids: [ID!]!) {\n deleteNegotiableQuotes(\n input: {\n quote_uids: $quoteUids\n }\n ) {\n result_status\n operation_results {\n __typename\n ... on NegotiableQuoteUidOperationSuccess {\n quote_uid\n }\n ... on DeleteNegotiableQuoteOperationFailure {\n quote_uid\n errors {\n __typename\n ... on ErrorInterface {\n message\n }\n ... on NoSuchEntityUidError {\n uid\n message\n }\n ... on NegotiableQuoteInvalidStateError {\n message\n }\n }\n }\n }\n }\n }\n`;\n\n\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n \nimport { fetchGraphQl } from '@/quote-management/api';\nimport { state } from '@/quote-management/lib/state';\nimport { DELETE_QUOTE_MUTATION } from '@/quote-management/api/deleteQuote/graphql/DeleteQuoteMutation';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport interface DeleteQuoteSuccessResult {\n __typename: 'NegotiableQuoteUidOperationSuccess';\n quoteUid: string;\n}\n\nexport interface DeleteQuoteFailureError {\n __typename: string;\n message?: string;\n uid?: string;\n}\n\nexport interface DeleteQuoteFailureResult {\n __typename: 'DeleteNegotiableQuoteOperationFailure';\n quoteUid: string;\n errors: DeleteQuoteFailureError[];\n}\n\nexport interface DeleteQuoteOutput {\n resultStatus: string;\n operationResults: Array<DeleteQuoteSuccessResult | DeleteQuoteFailureResult>;\n}\n\nexport const deleteQuote = async ( quoteUids: string[] | string ): Promise<DeleteQuoteOutput> => {\n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n const quoteUidsArray = Array.isArray(quoteUids) ? quoteUids : [quoteUids];\n\n try {\n const response: any = await fetchGraphQl(DELETE_QUOTE_MUTATION, {\n variables: {\n quoteUids: quoteUidsArray,\n },\n });\n\n const { errors } = response || {};\n if (errors && errors.length) {\n const errorMessages = errors.map((e: any) => e?.message).filter(Boolean).join('; ');\n throw new Error(errorMessages || 'Failed to delete negotiable quotes');\n }\n\n const raw = response?.data?.deleteNegotiableQuotes;\n if (!raw) {\n throw new Error('No delete result returned');\n }\n\n const transformed: DeleteQuoteOutput = {\n resultStatus: raw.result_status,\n operationResults: (raw.operation_results || []).map((result: any) => {\n const typename = result?.__typename;\n if (typename === 'NegotiableQuoteUidOperationSuccess') {\n const success: DeleteQuoteSuccessResult = {\n __typename: 'NegotiableQuoteUidOperationSuccess',\n quoteUid: result?.quote_uid,\n };\n return success;\n }\n const failure: DeleteQuoteFailureResult = {\n __typename: 'DeleteNegotiableQuoteOperationFailure',\n quoteUid: result?.quote_uid,\n errors: (result?.errors || []).map((err: any) => ({\n __typename: err?.__typename,\n message: err?.message,\n uid: err?.uid,\n })),\n };\n return failure;\n }),\n };\n\n // Emit event with successfully deleted quote UIDs\n const deletedUids = transformed.operationResults\n .filter((res) => res.__typename === 'NegotiableQuoteUidOperationSuccess')\n .map((res) => (res as DeleteQuoteSuccessResult).quoteUid);\n\n if (deletedUids.length > 0) {\n events.emit('quote-management/negotiable-quote-deleted', {\n deletedQuoteUids: deletedUids,\n resultStatus: transformed.resultStatus,\n });\n }\n\n return transformed;\n } catch (error) {\n // Emit error event for integration layer\n events.emit('quote-management/negotiable-quote-delete-error', {\n error: error instanceof Error ? error : new Error(String(error)),\n attemptedQuoteUids: quoteUidsArray,\n });\n return Promise.reject(error);\n }\n};\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION = `\n mutation SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION(\n $quoteUid: ID!\n $comment: NegotiableQuoteCommentInput\n ) {\n sendNegotiableQuoteForReview(\n input: {\n quote_uid: $quoteUid\n comment: $comment\n }\n ) {\n quote {\n ...NegotiableQuoteFragment\n }\n }\n }\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport { SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION } from './graphql/SendNegotiableQuoteForReviewMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\n\nexport interface SendForReviewInput {\n quoteUid: string;\n comment?: string;\n attachments?: { key: string }[];\n}\n\nexport const sendForReview = async (\n input: SendForReviewInput\n): Promise<NegotiableQuoteModel | null> => {\n const { quoteUid, comment, attachments } = input;\n\n if (!quoteUid) {\n throw new Error('Quote UID is required');\n }\n\n // Build the comment object with attachments if provided\n const commentInput = attachments?.length \n ? { comment: comment || '', attachments } \n : comment \n ? { comment } \n : null;\n\n return fetchGraphQl(SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION, {\n variables: {\n quoteUid,\n comment: commentInput,\n },\n }).then((response) => {\n const { errors } = response;\n\n if (errors) {\n // Provide more detailed error information\n const errorMessages = errors.map((error) => error.message).join('; ');\n throw new Error(`Failed to send quote for review: ${errorMessages}`);\n }\n\n // Transform the quote data\n const quoteData = transformQuote(\n response.data?.sendNegotiableQuoteForReview?.quote\n );\n\n if (!quoteData) {\n throw new Error(\n 'Failed to transform quote data: Invalid response structure'\n );\n }\n\n // Emit event with transformed quote data on success\n events.emit('quote-management/quote-sent-for-review', {\n quote: quoteData,\n input: { quoteUid, comment, attachments },\n });\n\n return quoteData;\n });\n};\n\n","export const CLOSE_NEGOTIABLE_QUOTE_MUTATION = `\n mutation CLOSE_NEGOTIABLE_QUOTE_MUTATION(\n $quoteUids: [ID!]!\n ) {\n closeNegotiableQuotes(input: { quote_uids: $quoteUids }) {\n result_status\n operation_results {\n ... on NegotiableQuoteUidOperationSuccess {\n __typename\n quote_uid\n }\n ... on CloseNegotiableQuoteOperationFailure {\n __typename\n quote_uid\n errors {\n __typename\n ... on ErrorInterface {\n message\n }\n ... on NoSuchEntityUidError {\n uid\n }\n ... on NegotiableQuoteInvalidStateError {\n message\n }\n }\n }\n }\n }\n }\n`;","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api';\nimport { state } from '@/quote-management/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\nimport { CLOSE_NEGOTIABLE_QUOTE_MUTATION } from './graphql/CloseNegotiableQuoteMutation';\n\nexport interface CloseNegotiableQuoteInput {\n quoteUids: string[];\n}\n\nexport interface CloseNegotiableQuoteSuccessResult {\n __typename: 'NegotiableQuoteUidOperationSuccess';\n quoteUid: string;\n}\n\nexport interface CloseNegotiableQuoteFailureError {\n __typename: string;\n message?: string;\n uid?: string;\n}\n\nexport interface CloseNegotiableQuoteFailureResult {\n __typename: 'CloseNegotiableQuoteOperationFailure';\n quoteUid: string;\n errors: CloseNegotiableQuoteFailureError[];\n}\n\nexport interface CloseNegotiableQuoteResult {\n resultStatus: string;\n operationResults: Array<CloseNegotiableQuoteSuccessResult | CloseNegotiableQuoteFailureResult>;\n}\n\nexport const closeNegotiableQuote = async (input: CloseNegotiableQuoteInput): Promise<CloseNegotiableQuoteResult> => { \n if (!state.authenticated) {\n return Promise.reject(new Error('Unauthorized'));\n }\n\n const { quoteUids } = input;\n\n if (!quoteUids || quoteUids.length === 0) {\n throw new Error('Quote UIDs are required');\n }\n\n try {\n const response: any = await fetchGraphQl(CLOSE_NEGOTIABLE_QUOTE_MUTATION, {\n variables: {\n quoteUids,\n },\n });\n\n const { errors } = response || {};\n if (errors && errors.length) {\n const errorMessages = errors\n .map((e: any) => e?.message)\n .filter(Boolean)\n .join('; ');\n throw new Error(errorMessages || 'Failed to close negotiable quotes');\n }\n\n const raw = response?.data?.closeNegotiableQuotes;\n if (!raw) {\n throw new Error('No close result returned');\n }\n\n const transformed: CloseNegotiableQuoteResult = {\n resultStatus: raw.result_status,\n operationResults: (raw.operation_results || []).map((result: any) => {\n const typename = result?.__typename;\n if (typename === 'NegotiableQuoteUidOperationSuccess') {\n const success: CloseNegotiableQuoteSuccessResult = {\n __typename: 'NegotiableQuoteUidOperationSuccess',\n quoteUid: result?.quote_uid,\n };\n return success;\n }\n const failure: CloseNegotiableQuoteFailureResult = {\n __typename: 'CloseNegotiableQuoteOperationFailure',\n quoteUid: result?.quote_uid,\n errors: (result?.errors || []).map((err: any) => ({\n __typename: err?.__typename,\n message: err?.message,\n uid: err?.uid,\n })),\n };\n return failure;\n }),\n };\n\n // Check for operation failures\n const failures = transformed.operationResults\n .filter(\n (res) => res.__typename === 'CloseNegotiableQuoteOperationFailure'\n )\n .map((res) => res as CloseNegotiableQuoteFailureResult);\n\n if (failures.length > 0) {\n // Create error message from failures\n const failureMessages = failures\n .map((failure) => {\n if (failure.errors && failure.errors.length > 0) {\n return failure.errors\n .map(\n (err) =>\n err.message || `Failed to close quote ${failure.quoteUid}`\n )\n .join(', ');\n }\n return `Failed to close quote ${failure.quoteUid}`;\n })\n .join('; ');\n\n throw new Error(failureMessages);\n }\n\n // Emit success event with closed quote UIDs\n const closedUids = transformed.operationResults\n .filter((res) => res.__typename === 'NegotiableQuoteUidOperationSuccess')\n .map((res) => (res as CloseNegotiableQuoteSuccessResult).quoteUid);\n\n if (closedUids.length > 0) {\n events.emit('quote-management/negotiable-quote-closed', {\n closedQuoteUids: closedUids,\n resultStatus: transformed.resultStatus,\n });\n }\n\n return transformed;\n } catch (error) {\n // Emit error event for integration layer\n events.emit('quote-management/negotiable-quote-close-error', {\n error: error instanceof Error ? error : new Error(String(error)),\n attemptedQuoteUids: quoteUids,\n });\n return Promise.reject(error);\n }\n}\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_TEMPLATE_FRAGMENT } from \"../../graphql/NegotiableQuoteTemplateFragment\";\n\nexport const CREATE_QUOTE_TEMPLATE_MUTATION = /* GraphQL */ `\n mutation CREATE_QUOTE_TEMPLATE_MUTATION($cartId: ID!) {\n requestNegotiableQuoteTemplateFromQuote(input: { cart_id: $cartId }) {\n ...NegotiableQuoteTemplateFragment\n }\n }\n\n ${NEGOTIABLE_QUOTE_TEMPLATE_FRAGMENT}\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { events } from '@adobe-commerce/event-bus';\nimport { fetchGraphQl } from '@/quote-management/api/';\nimport { CREATE_QUOTE_TEMPLATE_MUTATION } from './graphql/createQuoteTemplate';\nimport { state } from '@/quote-management/lib/state';\nimport { transformQuoteTemplate } from '@/quote-management/data/transforms';\nimport { NegotiableQuoteTemplateModel } from '@/quote-management/data/models/negotiable-quote-template-model';\n\nexport const createQuoteTemplate = async (\n quoteId: string\n): Promise<NegotiableQuoteTemplateModel | null> => {\n if (!state.authenticated) {\n throw new Error('Unauthorized');\n }\n\n if (!quoteId) {\n throw new Error('Cart ID is required');\n }\n\n try {\n const results: any = await fetchGraphQl(CREATE_QUOTE_TEMPLATE_MUTATION, {\n variables: {\n cartId: quoteId,\n },\n });\n\n if (!results?.data?.requestNegotiableQuoteTemplateFromQuote) {\n throw new Error('Failed to create quote template');\n }\n\n const transformedQuoteTemplate = transformQuoteTemplate(\n results.data.requestNegotiableQuoteTemplateFromQuote\n );\n\n if (!transformedQuoteTemplate) {\n throw new Error('Failed to transform quote template data');\n }\n\n events.emit('quote-management/quote-template-data', {\n quoteTemplate: transformedQuoteTemplate,\n permissions: state.permissions,\n });\n\n return transformedQuoteTemplate;\n } catch (error) {\n return Promise.reject(error);\n }\n};\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const RENAME_NEGOTIABLE_QUOTE_MUTATION = `\n mutation renameNegotiableQuote($input: RenameNegotiableQuoteInput!) {\n renameNegotiableQuote(input: $input) {\n quote {\n ...NegotiableQuoteFragment\n }\n }\n }\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`;\n\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport { RENAME_NEGOTIABLE_QUOTE_MUTATION } from './graphql/RenameNegotiableQuoteMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\n\nexport interface RenameNegotiableQuoteInput {\n quoteUid: string;\n quoteName: string;\n quoteComment?: string;\n}\n\nexport const renameNegotiableQuote = async (\n input: RenameNegotiableQuoteInput\n): Promise<NegotiableQuoteModel | null> => {\n const { quoteUid, quoteName, quoteComment } = input;\n\n if (!quoteUid) {\n throw new Error('Quote UID is required');\n }\n\n if (!quoteName) {\n throw new Error('Quote name is required');\n }\n\n // Backend requires quote_comment to be present (even if empty string)\n const mutationInput = {\n quote_uid: quoteUid,\n quote_name: quoteName,\n quote_comment: quoteComment || '', // Always include, use empty string if not provided\n };\n\n return fetchGraphQl(RENAME_NEGOTIABLE_QUOTE_MUTATION, {\n variables: {\n input: mutationInput,\n },\n }).then((response) => {\n const { errors } = response;\n\n if (errors) {\n // Provide more detailed error information\n const errorMessages = errors.map((error) => error.message).join('; ');\n throw new Error(`Failed to rename quote: ${errorMessages}`);\n }\n\n // Transform the quote data\n const quoteData = transformQuote(\n response.data?.renameNegotiableQuote?.quote\n );\n\n if (!quoteData) {\n throw new Error(\n 'Failed to transform quote data: Invalid response structure'\n );\n }\n\n // Emit event with transformed quote data on success\n events.emit('quote-management/quote-renamed', {\n quote: quoteData,\n input: { quoteUid, quoteName, quoteComment },\n });\n\n return quoteData;\n });\n};\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { NEGOTIABLE_QUOTE_FRAGMENT } from '@/quote-management/api/graphql/NegotiableQuoteFragment';\n\nexport const DUPLICATE_NEGOTIABLE_QUOTE_MUTATION = `\n mutation DUPLICATE_NEGOTIABLE_QUOTE_MUTATION($quoteUid: ID!, $duplicatedQuoteUid: ID!) {\n duplicateNegotiableQuote(input: { quote_uid: $quoteUid, duplicated_quote_uid: $duplicatedQuoteUid }) {\n quote {\n ...NegotiableQuoteFragment\n }\n }\n }\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api';\nimport { events } from '@adobe-commerce/event-bus';\nimport { DUPLICATE_NEGOTIABLE_QUOTE_MUTATION } from './graphql/duplicateNegotiableQuoteMutation';\nimport { NegotiableQuoteModel } from '@/quote-management/data/models/negotiable-quote-model';\nimport { transformQuote } from '@/quote-management/data/transforms';\nimport { state } from '@/quote-management/lib/state';\n\nexport interface DuplicateQuoteInput {\n quoteUid: string;\n duplicatedQuoteUid: string;\n hasOutOfStockItems?: boolean;\n}\n\nexport const duplicateQuote = async (\n input: DuplicateQuoteInput\n): Promise<NegotiableQuoteModel | null> => {\n\n if (!state.authenticated) {\n throw new Error('Unauthorized');\n }\n\n const { quoteUid, duplicatedQuoteUid, hasOutOfStockItems } = input;\n\n if (!quoteUid || !quoteUid.trim()) {\n throw new Error('Quote UID is required');\n }\n\n if (!duplicatedQuoteUid || !duplicatedQuoteUid.trim()) {\n throw new Error('Duplicated Quote UID is required');\n }\n\n return fetchGraphQl(DUPLICATE_NEGOTIABLE_QUOTE_MUTATION, {\n variables: { quoteUid, duplicatedQuoteUid },\n }).then((response) => {\n const { errors } = response;\n\n if (errors) {\n const errorMessages = errors.map((error) => error.message).join('; ');\n throw new Error(`Failed to duplicate quote: ${errorMessages}`);\n }\n\n const quoteData = transformQuote(\n response.data?.duplicateNegotiableQuote?.quote\n );\n\n if (!quoteData) {\n throw new Error(\n 'Failed to transform quote data: Invalid response structure'\n );\n }\n\n events.emit('quote-management/quote-duplicated', {\n quote: quoteData,\n input: { quoteUid, duplicatedQuoteUid },\n hasOutOfStockItems,\n });\n\n return quoteData;\n });\n};\n"],"names":["QUOTE_DATA_QUERY","NEGOTIABLE_QUOTE_FRAGMENT","getQuoteData","quoteId","state","results","fetchGraphQl","transformedQuote","transformQuote","_a","events","error","DELETE_QUOTE_MUTATION","deleteQuote","quoteUids","quoteUidsArray","response","errors","errorMessages","e","raw","transformed","result","err","deletedUids","res","SEND_NEGOTIABLE_QUOTE_FOR_REVIEW_MUTATION","sendForReview","input","quoteUid","comment","attachments","commentInput","quoteData","_b","CLOSE_NEGOTIABLE_QUOTE_MUTATION","closeNegotiableQuote","failures","failureMessages","failure","closedUids","CREATE_QUOTE_TEMPLATE_MUTATION","NEGOTIABLE_QUOTE_TEMPLATE_FRAGMENT","createQuoteTemplate","transformedQuoteTemplate","transformQuoteTemplate","RENAME_NEGOTIABLE_QUOTE_MUTATION","renameNegotiableQuote","quoteName","quoteComment","DUPLICATE_NEGOTIABLE_QUOTE_MUTATION","duplicateQuote","duplicatedQuoteUid","hasOutOfStockItems"],"mappings":"gSAEO,MAAMA,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAW1BC,CAAyB;AAAA,ECElBC,EAAe,MAAOC,GAAoB,OACnD,GAAI,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AAM,8BAA8BO,CAAa,EAAE,CAC/D,CAEA,MAAMe,EAAYzB,GAChB0B,GAAAzB,EAAAO,EAAS,OAAT,YAAAP,EAAe,2BAAf,YAAAyB,EAAyC,KAAA,EAG3C,GAAI,CAACD,EACH,MAAM,IAAI,MACR,4DAAA,EAIJ,OAAAvB,EAAO,KAAK,oCAAqC,CAC/C,MAAOuB,EACP,MAAO,CAAE,SAAAJ,EAAU,mBAAAuB,CAAA,EACnB,mBAAAC,CAAA,CACD,EAEMpB,CACT,CAAC,CACH"}
@@ -1,6 +1,6 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{events as n}from"@dropins/tools/event-bus.js";import{t as s}from"./transform-quote-template.js";import{s as o}from"./state.js";import{f as i}from"./transform-quote.js";const l=`
3
+ import{events as s}from"@dropins/tools/event-bus.js";import{t as n}from"./transform-quote-template.js";import{s as o}from"./state.js";import{f as i}from"./transform-quote.js";const l=`
4
4
  query QUOTE_TEMPLATES_QUERY(
5
5
  $filter: NegotiableQuoteTemplateFilterInput
6
6
  $pageSize: Int
@@ -14,22 +14,24 @@ import{events as n}from"@dropins/tools/event-bus.js";import{t as s}from"./transf
14
14
  sort: $sort
15
15
  ) {
16
16
  items {
17
- # uid
17
+ uid
18
18
  template_id
19
19
  name
20
- # created_at
21
- # updated_at
22
- # last_ordered_at
20
+ created_at
21
+ updated_at
22
+ last_ordered_at
23
23
  status
24
24
  state
25
25
  min_negotiated_grand_total
26
26
  last_shared_at
27
- # expiration_date
27
+ expiration_date
28
28
  orders_placed
29
- # grand_total {
30
- # currency
31
- # value
32
- # }
29
+ prices {
30
+ grand_total {
31
+ currency
32
+ value
33
+ }
34
+ }
33
35
  }
34
36
  page_info {
35
37
  current_page
@@ -46,5 +48,5 @@ import{events as n}from"@dropins/tools/event-bus.js";import{t as s}from"./transf
46
48
  }
47
49
  }
48
50
  }
49
- `;var u=(e=>(e.ACTIVE="ACTIVE",e.IN_REVIEW="IN_REVIEW",e.INACTIVE="INACTIVE",e))(u||{}),E=(e=>(e.NAME="NAME",e.CREATED_AT="CREATED_AT",e.UPDATED_AT="UPDATED_AT",e))(E||{}),_=(e=>(e.ASC="ASC",e.DESC="DESC",e))(_||{});const T=async(e={})=>{var r;if(!o.authenticated)throw new Error("Unauthorized");try{const t=await i(l,{variables:{filter:e.filter||null,pageSize:e.pageSize||20,currentPage:e.currentPage||1,sort:e.sort||null}});if(!((r=t==null?void 0:t.data)!=null&&r.negotiableQuoteTemplates))throw new Error("No quote templates data received");const a=s(t.data.negotiableQuoteTemplates);if(!a)throw new Error("Failed to transform quote templates data");return n.emit("quote-management/quote-templates-data",{quoteTemplates:a,permissions:o.permissions}),a}catch(t){return Promise.reject(t)}};export{u as Q,_ as S,E as a,T as g};
51
+ `;var u=(e=>(e.ACTIVE="ACTIVE",e.IN_REVIEW="IN_REVIEW",e.INACTIVE="INACTIVE",e))(u||{}),p=(e=>(e.NAME="NAME",e.CREATED_AT="CREATED_AT",e.UPDATED_AT="UPDATED_AT",e))(p||{}),E=(e=>(e.ASC="ASC",e.DESC="DESC",e))(E||{});const c=async(e={})=>{var r;if(!o.authenticated)throw new Error("Unauthorized");try{const t=await i(l,{variables:{filter:e.filter||null,pageSize:e.pageSize||20,currentPage:e.currentPage||1,sort:e.sort||null}});if(!((r=t==null?void 0:t.data)!=null&&r.negotiableQuoteTemplates))throw new Error("No quote templates data received");const a=n(t.data.negotiableQuoteTemplates);if(!a)throw new Error("Failed to transform quote templates data");return s.emit("quote-management/quote-templates-data",{quoteTemplates:a,permissions:o.permissions}),a}catch(t){return Promise.reject(t)}};export{u as Q,E as S,p as a,c as g};
50
52
  //# sourceMappingURL=getQuoteTemplates.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getQuoteTemplates.js","sources":["/@dropins/storefront-quote-management/src/api/getQuoteTemplates/graphql/getQuoteTemplates.ts","/@dropins/storefront-quote-management/src/api/getQuoteTemplates/getQuoteTemplates.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nexport const QUOTE_TEMPLATES_QUERY = /* GraphQL */ `\n query QUOTE_TEMPLATES_QUERY(\n $filter: NegotiableQuoteTemplateFilterInput\n $pageSize: Int\n $currentPage: Int\n $sort: NegotiableQuoteTemplateSortInput\n ) {\n negotiableQuoteTemplates(\n filter: $filter\n pageSize: $pageSize\n currentPage: $currentPage\n sort: $sort\n ) {\n items {\n # uid\n template_id\n name\n # created_at\n # updated_at\n # last_ordered_at\n status\n state\n min_negotiated_grand_total\n last_shared_at\n # expiration_date\n orders_placed\n # grand_total {\n # currency\n # value\n # }\n }\n page_info {\n current_page\n page_size\n total_pages\n }\n total_count\n sort_fields {\n default\n options {\n label\n value\n }\n }\n }\n }\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api';\nimport { QUOTE_TEMPLATES_QUERY } from './graphql/getQuoteTemplates';\nimport { transformQuoteTemplatesList } from '@/quote-management/data/transforms';\nimport { NegotiableQuoteTemplatesListModel } from '@/quote-management/data/models/negotiable-quote-template-model';\nimport { state } from '@/quote-management/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport enum QuoteTemplateFilterStatus {\n ACTIVE = 'ACTIVE',\n IN_REVIEW = 'IN_REVIEW',\n INACTIVE = 'INACTIVE',\n}\n\nexport interface QuoteTemplateFilterInput {\n status?: QuoteTemplateFilterStatus[];\n name?: {\n match?: string;\n };\n}\n\nexport enum QuoteTemplateSortField {\n NAME = 'NAME',\n CREATED_AT = 'CREATED_AT',\n UPDATED_AT = 'UPDATED_AT',\n}\n\nexport enum SortDirection {\n ASC = 'ASC',\n DESC = 'DESC',\n}\n\nexport interface QuoteTemplateSortInput {\n sortField: QuoteTemplateSortField;\n sortDirection: SortDirection;\n}\n\nexport interface GetQuoteTemplatesParams {\n filter?: QuoteTemplateFilterInput;\n pageSize?: number;\n currentPage?: number;\n sort?: QuoteTemplateSortInput;\n}\n\nexport const getQuoteTemplates = async (\n params: GetQuoteTemplatesParams = {}\n): Promise<NegotiableQuoteTemplatesListModel> => {\n if (!state.authenticated) {\n throw new Error('Unauthorized');\n }\n\n try {\n const results: any = await fetchGraphQl(QUOTE_TEMPLATES_QUERY, {\n variables: {\n filter: params.filter || null,\n pageSize: params.pageSize || 20,\n currentPage: params.currentPage || 1,\n sort: params.sort || null,\n },\n });\n\n if (!results?.data?.negotiableQuoteTemplates) {\n throw new Error('No quote templates data received');\n }\n\n const transformedData = transformQuoteTemplatesList(results.data.negotiableQuoteTemplates);\n\n if (!transformedData) {\n throw new Error('Failed to transform quote templates data');\n }\n\n events.emit('quote-management/quote-templates-data', {\n quoteTemplates: transformedData,\n permissions: state.permissions,\n });\n\n return transformedData;\n } catch (error) {\n return Promise.reject(error);\n }\n};"],"names":["QUOTE_TEMPLATES_QUERY","QuoteTemplateFilterStatus","QuoteTemplateSortField","SortDirection","getQuoteTemplates","params","state","results","fetchGraphQl","_a","transformedData","transformQuoteTemplatesList","events","error"],"mappings":"+KASO,MAAMA,EAAsC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECO5C,IAAKC,GAAAA,IACVA,EAAA,OAAS,SACTA,EAAA,UAAY,YACZA,EAAA,SAAW,WAHDA,IAAAA,GAAA,CAAA,CAAA,EAaAC,GAAAA,IACVA,EAAA,KAAO,OACPA,EAAA,WAAa,aACbA,EAAA,WAAa,aAHHA,IAAAA,GAAA,CAAA,CAAA,EAMAC,GAAAA,IACVA,EAAA,IAAM,MACNA,EAAA,KAAO,OAFGA,IAAAA,GAAA,CAAA,CAAA,EAiBL,MAAMC,EAAoB,MAC/BC,EAAkC,KACa,OAC/C,GAAI,CAACC,EAAM,cACT,MAAM,IAAI,MAAM,cAAc,EAGhC,GAAI,CACF,MAAMC,EAAe,MAAMC,EAAaR,EAAuB,CAC7D,UAAW,CACT,OAAQK,EAAO,QAAU,KACzB,SAAUA,EAAO,UAAY,GAC7B,YAAaA,EAAO,aAAe,EACnC,KAAMA,EAAO,MAAQ,IAAA,CACvB,CACD,EAED,GAAI,GAACI,EAAAF,GAAA,YAAAA,EAAS,OAAT,MAAAE,EAAe,0BAClB,MAAM,IAAI,MAAM,kCAAkC,EAGpD,MAAMC,EAAkBC,EAA4BJ,EAAQ,KAAK,wBAAwB,EAEzF,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,0CAA0C,EAG5D,OAAAE,EAAO,KAAK,wCAAyC,CACnD,eAAgBF,EAChB,YAAaJ,EAAM,WAAA,CACpB,EAEMI,CACT,OAASG,EAAO,CACd,OAAO,QAAQ,OAAOA,CAAK,CAC7B,CACF"}
1
+ {"version":3,"file":"getQuoteTemplates.js","sources":["/@dropins/storefront-quote-management/src/api/getQuoteTemplates/graphql/getQuoteTemplates.ts","/@dropins/storefront-quote-management/src/api/getQuoteTemplates/getQuoteTemplates.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nexport const QUOTE_TEMPLATES_QUERY = /* GraphQL */ `\n query QUOTE_TEMPLATES_QUERY(\n $filter: NegotiableQuoteTemplateFilterInput\n $pageSize: Int\n $currentPage: Int\n $sort: NegotiableQuoteTemplateSortInput\n ) {\n negotiableQuoteTemplates(\n filter: $filter\n pageSize: $pageSize\n currentPage: $currentPage\n sort: $sort\n ) {\n items {\n uid\n template_id\n name\n created_at\n updated_at\n last_ordered_at\n status\n state\n min_negotiated_grand_total\n last_shared_at\n expiration_date\n orders_placed\n prices {\n grand_total {\n currency\n value\n }\n }\n }\n page_info {\n current_page\n page_size\n total_pages\n }\n total_count\n sort_fields {\n default\n options {\n label\n value\n }\n }\n }\n }\n`;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { fetchGraphQl } from '@/quote-management/api';\nimport { QUOTE_TEMPLATES_QUERY } from './graphql/getQuoteTemplates';\nimport { transformQuoteTemplatesList } from '@/quote-management/data/transforms';\nimport { NegotiableQuoteTemplatesListModel } from '@/quote-management/data/models/negotiable-quote-template-model';\nimport { state } from '@/quote-management/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport enum QuoteTemplateFilterStatus {\n ACTIVE = 'ACTIVE',\n IN_REVIEW = 'IN_REVIEW',\n INACTIVE = 'INACTIVE',\n}\n\nexport interface QuoteTemplateFilterInput {\n status?: QuoteTemplateFilterStatus[];\n name?: {\n match?: string;\n };\n}\n\nexport enum QuoteTemplateSortField {\n NAME = 'NAME',\n CREATED_AT = 'CREATED_AT',\n UPDATED_AT = 'UPDATED_AT',\n}\n\nexport enum SortDirection {\n ASC = 'ASC',\n DESC = 'DESC',\n}\n\nexport interface QuoteTemplateSortInput {\n sortField: QuoteTemplateSortField;\n sortDirection: SortDirection;\n}\n\nexport interface GetQuoteTemplatesParams {\n filter?: QuoteTemplateFilterInput;\n pageSize?: number;\n currentPage?: number;\n sort?: QuoteTemplateSortInput;\n}\n\nexport const getQuoteTemplates = async (\n params: GetQuoteTemplatesParams = {}\n): Promise<NegotiableQuoteTemplatesListModel> => {\n if (!state.authenticated) {\n throw new Error('Unauthorized');\n }\n\n try {\n const results: any = await fetchGraphQl(QUOTE_TEMPLATES_QUERY, {\n variables: {\n filter: params.filter || null,\n pageSize: params.pageSize || 20,\n currentPage: params.currentPage || 1,\n sort: params.sort || null,\n },\n });\n\n if (!results?.data?.negotiableQuoteTemplates) {\n throw new Error('No quote templates data received');\n }\n\n const transformedData = transformQuoteTemplatesList(results.data.negotiableQuoteTemplates);\n\n if (!transformedData) {\n throw new Error('Failed to transform quote templates data');\n }\n\n events.emit('quote-management/quote-templates-data', {\n quoteTemplates: transformedData,\n permissions: state.permissions,\n });\n\n return transformedData;\n } catch (error) {\n return Promise.reject(error);\n }\n};"],"names":["QUOTE_TEMPLATES_QUERY","QuoteTemplateFilterStatus","QuoteTemplateSortField","SortDirection","getQuoteTemplates","params","state","results","fetchGraphQl","_a","transformedData","transformQuoteTemplatesList","events","error"],"mappings":"+KASO,MAAMA,EAAsC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECO5C,IAAKC,GAAAA,IACVA,EAAA,OAAS,SACTA,EAAA,UAAY,YACZA,EAAA,SAAW,WAHDA,IAAAA,GAAA,CAAA,CAAA,EAaAC,GAAAA,IACVA,EAAA,KAAO,OACPA,EAAA,WAAa,aACbA,EAAA,WAAa,aAHHA,IAAAA,GAAA,CAAA,CAAA,EAMAC,GAAAA,IACVA,EAAA,IAAM,MACNA,EAAA,KAAO,OAFGA,IAAAA,GAAA,CAAA,CAAA,EAiBL,MAAMC,EAAoB,MAC/BC,EAAkC,KACa,OAC/C,GAAI,CAACC,EAAM,cACT,MAAM,IAAI,MAAM,cAAc,EAGhC,GAAI,CACF,MAAMC,EAAe,MAAMC,EAAaR,EAAuB,CAC7D,UAAW,CACT,OAAQK,EAAO,QAAU,KACzB,SAAUA,EAAO,UAAY,GAC7B,YAAaA,EAAO,aAAe,EACnC,KAAMA,EAAO,MAAQ,IAAA,CACvB,CACD,EAED,GAAI,GAACI,EAAAF,GAAA,YAAAA,EAAS,OAAT,MAAAE,EAAe,0BAClB,MAAM,IAAI,MAAM,kCAAkC,EAGpD,MAAMC,EAAkBC,EAA4BJ,EAAQ,KAAK,wBAAwB,EAEzF,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,0CAA0C,EAG5D,OAAAE,EAAO,KAAK,wCAAyC,CACnD,eAAgBF,EAChB,YAAaJ,EAAM,WAAA,CACpB,EAEMI,CACT,OAASG,EAAO,CACd,OAAO,QAAQ,OAAOA,CAAK,CAC7B,CACF"}
@@ -1,6 +1,6 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import"@dropins/tools/event-bus.js";import{f as n,b as s}from"./transform-quote.js";import{s as i}from"./state.js";const u=`
3
+ import"@dropins/tools/event-bus.js";import{f as n,d as s}from"./transform-quote.js";import{s as i}from"./state.js";const u=`
4
4
  fragment NegotiableQuoteListFragment on NegotiableQuote {
5
5
  uid
6
6
  name
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{a as y}from"./transform-quote.js";var i=(r=>(r.ACTIVE="Active",r.IN_REVIEW="In Review",r.INACTIVE="Inactive",r.SUBMITTED="Submitted",r.PENDING="Pending",r.CLOSED="Closed",r.OPEN="Open",r.UPDATED="Updated",r.EDITED="Edited",r.NEW="New",r.DRAFT="Draft",r.DECLINED="Declined",r.CANCELED="Canceled",r.EXPIRED="Expired",r))(i||{});function v(r){var o,_,s,c,l,t;return r?{id:r.template_id,uid:r.uid,name:r.name,createdAt:r.created_at,updatedAt:r.updated_at,expirationDate:r.expiration_date,status:r.status,salesRepName:r.sales_rep_name,buyer:{firstname:r.buyer.firstname,lastname:r.buyer.lastname},comments:(o=r.comments)==null?void 0:o.map(n=>{var d;return{uid:n.uid,createdAt:n.created_at,author:{firstname:n.author.firstname,lastname:n.author.lastname},text:n.text,attachments:(d=n.attachments)==null?void 0:d.map(a=>({name:a.name,url:a.url}))}}),prices:r.prices&&{subtotalExcludingTax:r.prices.subtotal_excluding_tax&&{value:r.prices.subtotal_excluding_tax.value,currency:r.prices.subtotal_excluding_tax.currency},subtotalIncludingTax:r.prices.subtotal_including_tax&&{value:r.prices.subtotal_including_tax.value,currency:r.prices.subtotal_including_tax.currency},subtotalWithDiscountExcludingTax:r.prices.subtotal_with_discount_excluding_tax&&{value:r.prices.subtotal_with_discount_excluding_tax.value,currency:r.prices.subtotal_with_discount_excluding_tax.currency},appliedTaxes:(_=r.prices.applied_taxes)==null?void 0:_.map(n=>({amount:{value:n.amount.value,currency:n.amount.currency},label:n.label})),grandTotal:r.prices.grand_total&&{value:r.prices.grand_total.value,currency:r.prices.grand_total.currency}},history:(s=r.history)==null?void 0:s.map(n=>({uid:n.uid,createdAt:n.created_at,author:{firstname:n.author.firstname,lastname:n.author.lastname},changeType:n.change_type,changes:n.changes})),items:((c=r.items)==null?void 0:c.map(n=>{var d,a,g,p,E,f;return{uid:n.uid,product:{uid:n.product.uid,sku:n.product.sku,name:n.product.name},quantity:n.quantity,prices:{originalItemPrice:{value:n.prices.original_item_price.value,currency:n.prices.original_item_price.currency},rowTotal:{value:n.prices.row_total.value,currency:n.prices.row_total.currency}},catalogDiscount:n.prices.catalog_discount&&{amountOff:n.prices.catalog_discount.amount_off,percentOff:n.prices.catalog_discount.percent_off},discounts:(a=(d=n.prices)==null?void 0:d.discounts)==null?void 0:a.map(e=>({label:e.label,value:e.value,amount:{value:e.amount.value,currency:e.amount.currency}})),noteFromBuyer:(g=n.note_from_buyer)==null?void 0:g.map(e=>({createdAt:e.created_at,creatorId:e.creator_id,creatorType:e.creator_type,negotiableQuoteItemUid:e.negotiable_quote_template_item_uid,note:e.note,noteUid:e.note_uid})),noteFromSeller:(p=n.note_from_seller)==null?void 0:p.map(e=>({createdAt:e.created_at,creatorId:e.creator_id,creatorType:e.creator_type,negotiableQuoteItemUid:e.negotiable_quote_template_item_uid,note:e.note,noteUid:e.note_uid})),configurableOptions:(E=n.configurable_options)==null?void 0:E.map(e=>({optionLabel:e.option_label,valueLabel:e.value_label})),bundleOptions:(f=n.bundle_options)==null?void 0:f.map(e=>({label:e.label,values:e.values.map(u=>({label:u.label,quantity:u.quantity,originalPrice:{value:u.original_price.value,currency:u.original_price.currency},price:{value:u.priceV2.value,currency:u.priceV2.currency}}))}))}}))||[],shippingAddresses:(l=r.shipping_addresses)==null?void 0:l.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:(t=r.reference_document_links)==null?void 0:t.map(n=>({uid:n.link_id,name:n.document_name,identifier:n.document_identifier,url:n.reference_document_url})),canAccept:[i.SUBMITTED,i.PENDING,i.OPEN].includes(r.status),canDelete:r.status===i.DRAFT,canReopen:[i.DECLINED,i.CANCELED,i.EXPIRED].includes(r.status),canCancel:[i.SUBMITTED,i.PENDING,i.OPEN,i.ACTIVE,i.EDITED].includes(r.status),canSendForReview:[i.OPEN,i.DRAFT,i.NEW,i.EDITED].includes(r.status),canGenerateQuoteFromTemplate:[i.ACTIVE].includes(r.status),canEditTemplateItems:[i.SUBMITTED,i.DRAFT,i.OPEN,i.EDITED].includes(r.status)}:null}function b(r){var s;if(!r)return null;const o={items:((s=r.items)==null?void 0:s.map(c=>({id:c.template_id,uid:"TBD",name:c.name,createdAt:"0000-00-00 00:00:00",updatedAt:"0000-00-00 00:00:00",status:c.status,state:c.state,prices:{grandTotal:{value:0,currency:"USD"},minNegotiatedGrandTotal:{value:c.min_negotiated_grand_total,currency:"USD"}},lastSharedAt:c.last_shared_at,lastOrderedAt:"0000-00-00 00:00:00",expirationDate:"0000-00-00 00:00:00",ordersPlaced:c.orders_placed,canGenerateQuoteFromTemplate:[i.ACTIVE].includes(c.status)})))||[],pageInfo:{currentPage:r.page_info.current_page,pageSize:r.page_info.page_size,totalPages:r.page_info.total_pages},totalCount:r.total_count,sortFields:r.sort_fields?{default:r.sort_fields.default,options:r.sort_fields.options}:void 0},_=y(o);return{...o,paginationInfo:_||void 0}}export{i as N,v as a,b as t};
3
+ import{a as _,b as E,c as f}from"./transform-quote.js";var i=(n=>(n.ACTIVE="Active",n.IN_REVIEW="In Review",n.INACTIVE="Inactive",n.SUBMITTED="Submitted",n.PENDING="Pending",n.CLOSED="Closed",n.OPEN="Open",n.UPDATED="Updated",n.EDITED="Edited",n.NEW="New",n.DRAFT="Draft",n.DECLINED="Declined",n.CANCELED="Canceled",n.EXPIRED="Expired",n))(i||{});function l(n){var u,e,s,c;return n?{id:n.template_id,uid:n.uid,name:n.name,createdAt:n.created_at,updatedAt:n.updated_at,expirationDate:n.expiration_date,status:n.status,salesRepName:n.sales_rep_name,buyer:{firstname:n.buyer.firstname,lastname:n.buyer.lastname},comments:(u=n.comments)==null?void 0:u.map(r=>{var o;return{uid:r.uid,createdAt:r.created_at,author:{firstname:r.author.firstname,lastname:r.author.lastname},text:r.text,attachments:(o=r.attachments)==null?void 0:o.map(d=>({name:d.name,url:d.url}))}}),prices:n.prices&&{subtotalExcludingTax:n.prices.subtotal_excluding_tax&&{value:n.prices.subtotal_excluding_tax.value,currency:n.prices.subtotal_excluding_tax.currency},subtotalIncludingTax:n.prices.subtotal_including_tax&&{value:n.prices.subtotal_including_tax.value,currency:n.prices.subtotal_including_tax.currency},subtotalWithDiscountExcludingTax:n.prices.subtotal_with_discount_excluding_tax&&{value:n.prices.subtotal_with_discount_excluding_tax.value,currency:n.prices.subtotal_with_discount_excluding_tax.currency},appliedTaxes:(e=n.prices.applied_taxes)==null?void 0:e.map(r=>({amount:{value:r.amount.value,currency:r.amount.currency},label:r.label})),grandTotal:n.prices.grand_total&&{value:n.prices.grand_total.value,currency:n.prices.grand_total.currency}},history:E(n.history),items:_(n.items),shippingAddresses:(s=n.shipping_addresses)==null?void 0:s.map(r=>({uid:r.uid,firstname:r.firstname,lastname:r.lastname,company:r.company,street:r.street,city:r.city,postcode:r.postcode,country:{code:r.country.code,label:r.country.label},telephone:r.telephone,region:r.region?{code:r.region.code,label:r.region.label,regionId:r.region.region_id}:void 0})),referenceDocuments:(c=n.reference_document_links)==null?void 0:c.map(r=>({uid:r.link_id,name:r.document_name,identifier:r.document_identifier,url:r.reference_document_url})),canAccept:[i.SUBMITTED,i.PENDING,i.OPEN].includes(n.status),canDelete:n.status===i.DRAFT,canReopen:[i.DECLINED,i.CANCELED,i.EXPIRED].includes(n.status),canCancel:[i.SUBMITTED,i.PENDING,i.OPEN,i.ACTIVE,i.EDITED].includes(n.status),canSendForReview:[i.OPEN,i.DRAFT,i.NEW,i.EDITED].includes(n.status),canGenerateQuoteFromTemplate:[i.ACTIVE].includes(n.status),canEditTemplateItems:[i.SUBMITTED,i.DRAFT,i.OPEN,i.EDITED].includes(n.status)}:null}function I(n){var s;if(!n)return null;const u={items:((s=n.items)==null?void 0:s.map(c=>{var r,o,d;return{id:c.template_id,uid:c.uid,name:c.name,createdAt:c.created_at,updatedAt:c.updated_at,status:c.status,state:c.state,prices:{grandTotal:(r=c.prices)!=null&&r.grand_total?{value:c.prices.grand_total.value,currency:c.prices.grand_total.currency}:{value:0,currency:"USD"},minNegotiatedGrandTotal:{value:c.min_negotiated_grand_total,currency:((d=(o=c.prices)==null?void 0:o.grand_total)==null?void 0:d.currency)||"USD"}},lastSharedAt:c.last_shared_at,lastOrderedAt:c.last_ordered_at,expirationDate:c.expiration_date,ordersPlaced:c.orders_placed,canGenerateQuoteFromTemplate:[i.ACTIVE].includes(c.status)}}))||[],pageInfo:{currentPage:n.page_info.current_page,pageSize:n.page_info.page_size,totalPages:n.page_info.total_pages},totalCount:n.total_count,sortFields:n.sort_fields?{default:n.sort_fields.default,options:n.sort_fields.options}:void 0},e=f(u);return{...u,paginationInfo:e||void 0}}export{i as N,l as a,I as t};
4
4
  //# sourceMappingURL=transform-quote-template.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transform-quote-template.js","sources":["/@dropins/storefront-quote-management/src/data/models/negotiable-quote-template-model.ts","/@dropins/storefront-quote-management/src/data/transforms/transform-quote-template.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport {\n Currency,\n ItemNote,\n PaginationInfo,\n ShippingAddress,\n ConfigurableOption,\n BundleOption,\n} from './negotiable-quote-model';\n\nexport interface NegotiableQuoteTemplateModel {\n id: string;\n uid: string;\n name: string;\n createdAt: string;\n updatedAt: string;\n expirationDate?: string;\n status: NegotiableQuoteTemplateStatus;\n salesRepName: string;\n buyer: {\n firstname: string;\n lastname: string;\n };\n comments?: QuoteTemplateComment[];\n history?: QuoteTemplateHistoryEntry[];\n prices: {\n subtotalExcludingTax?: Currency;\n subtotalIncludingTax?: Currency;\n subtotalWithDiscountExcludingTax?: Currency;\n grandTotal?: Currency;\n appliedTaxes?: {\n amount: Currency;\n label: string;\n }[];\n };\n items: QuoteTemplateCartItem[];\n shippingAddresses?: ShippingAddress[];\n referenceDocuments?: {\n uid: string;\n name: string;\n identifier?: string;\n url: string;\n }[];\n // Template-specific fields\n quantityThresholds?: {\n min?: number;\n max?: number;\n };\n canAccept: boolean;\n canDelete: boolean;\n canReopen: boolean;\n canCancel: boolean;\n canSendForReview: boolean;\n canGenerateQuoteFromTemplate: boolean;\n canEditTemplateItems: boolean;\n}\n\nexport enum NegotiableQuoteTemplateStatus {\n ACTIVE = 'Active',\n IN_REVIEW = 'In Review',\n INACTIVE = 'Inactive',\n SUBMITTED = 'Submitted',\n PENDING = 'Pending',\n CLOSED = 'Closed',\n OPEN = 'Open',\n UPDATED = 'Updated',\n EDITED = 'Edited',\n NEW = 'New',\n DRAFT = 'Draft',\n DECLINED = 'Declined',\n CANCELED = 'Canceled',\n EXPIRED = 'Expired',\n}\n\nexport interface QuoteTemplateCartItem {\n uid?: string;\n product: {\n uid: string;\n sku: string;\n name: string;\n };\n quantity: number;\n prices: {\n originalItemPrice: Currency;\n rowTotal: Currency;\n };\n catalogDiscount?: {\n amountOff: number;\n percentOff: number;\n };\n discounts?: {\n label: string;\n value: string;\n amount: Currency;\n }[];\n noteFromBuyer?: ItemNote[];\n noteFromSeller?: ItemNote[];\n configurableOptions?: ConfigurableOption[];\n bundleOptions?: BundleOption[];\n}\n\nexport interface QuoteTemplateComment {\n uid: string;\n createdAt: string;\n author: {\n firstname: string;\n lastname: string;\n };\n text: string;\n attachments?: {\n name: string;\n url: string;\n }[];\n}\n\nexport interface QuoteTemplateHistoryEntry {\n uid: string;\n createdAt: string;\n author: {\n firstname: string;\n lastname: string;\n };\n changeType: string;\n changes: any; // Similar structure to NegotiableQuoteHistoryEntry\n}\n\n// List model for getQuoteTemplates\nexport interface NegotiableQuoteTemplatesListModel {\n items: NegotiableQuoteTemplateListEntry[];\n pageInfo: {\n currentPage: number;\n pageSize: number;\n totalPages: number;\n };\n totalCount: number;\n paginationInfo?: PaginationInfo;\n sortFields?: {\n default: string;\n options: Array<{\n label: string;\n value: string;\n }>;\n };\n}\n\nexport interface NegotiableQuoteTemplateListEntry {\n id: string;\n uid: string;\n name: string;\n createdAt: string;\n updatedAt: string;\n status: NegotiableQuoteTemplateStatus;\n state: 'active' | 'inactive' | 'in_review';\n lastSharedAt: string;\n lastOrderedAt: string;\n expirationDate: string;\n ordersPlaced: number;\n prices: {\n grandTotal: Currency;\n minNegotiatedGrandTotal: Currency;\n };\n canGenerateQuoteFromTemplate?: boolean;\n}\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport {\n NegotiableQuoteTemplateModel,\n NegotiableQuoteTemplatesListModel,\n NegotiableQuoteTemplateStatus,\n} from '../models/negotiable-quote-template-model';\nimport { transformPaginationInfo } from './transform-quote';\n\nexport function transformQuoteTemplate(\n templateData: any\n): NegotiableQuoteTemplateModel | null {\n if (!templateData) {\n return null;\n }\n\n return {\n id: templateData.template_id,\n uid: templateData.uid,\n name: templateData.name,\n createdAt: templateData.created_at,\n updatedAt: templateData.updated_at,\n expirationDate: templateData.expiration_date,\n status: templateData.status,\n salesRepName: templateData.sales_rep_name,\n buyer: {\n firstname: templateData.buyer.firstname,\n lastname: templateData.buyer.lastname,\n },\n comments: templateData.comments?.map((comment: any) => ({\n uid: comment.uid,\n createdAt: comment.created_at,\n author: {\n firstname: comment.author.firstname,\n lastname: comment.author.lastname,\n },\n text: comment.text,\n attachments: comment.attachments?.map((a: any) => ({\n name: a.name,\n url: a.url,\n })),\n })),\n prices: templateData.prices && {\n subtotalExcludingTax: templateData.prices.subtotal_excluding_tax && {\n value: templateData.prices.subtotal_excluding_tax.value,\n currency: templateData.prices.subtotal_excluding_tax.currency,\n },\n subtotalIncludingTax: templateData.prices.subtotal_including_tax && {\n value: templateData.prices.subtotal_including_tax.value,\n currency: templateData.prices.subtotal_including_tax.currency,\n },\n subtotalWithDiscountExcludingTax: templateData.prices\n .subtotal_with_discount_excluding_tax && {\n value: templateData.prices.subtotal_with_discount_excluding_tax.value,\n currency:\n templateData.prices.subtotal_with_discount_excluding_tax.currency,\n },\n appliedTaxes: templateData.prices.applied_taxes?.map((tax: any) => ({\n amount: { value: tax.amount.value, currency: tax.amount.currency },\n label: tax.label,\n })),\n grandTotal: templateData.prices.grand_total && {\n value: templateData.prices.grand_total.value,\n currency: templateData.prices.grand_total.currency,\n },\n },\n history: templateData.history?.map((h: any) => ({\n uid: h.uid,\n createdAt: h.created_at,\n author: {\n firstname: h.author.firstname,\n lastname: h.author.lastname,\n },\n changeType: h.change_type,\n changes: h.changes,\n })),\n items:\n templateData.items?.map((item: any) => ({\n uid: item.uid,\n product: {\n uid: item.product.uid,\n sku: item.product.sku,\n name: item.product.name,\n },\n quantity: item.quantity,\n prices: {\n originalItemPrice: {\n value: item.prices.original_item_price.value,\n currency: item.prices.original_item_price.currency,\n },\n rowTotal: {\n value: item.prices.row_total.value,\n currency: item.prices.row_total.currency,\n },\n },\n catalogDiscount: item.prices.catalog_discount && {\n amountOff: item.prices.catalog_discount.amount_off,\n percentOff: item.prices.catalog_discount.percent_off,\n },\n discounts: item.prices?.discounts?.map((discount: any) => ({\n label: discount.label,\n value: discount.value,\n amount: {\n value: discount.amount.value,\n currency: discount.amount.currency,\n },\n })),\n noteFromBuyer: item.note_from_buyer?.map((note: any) => ({\n createdAt: note.created_at,\n creatorId: note.creator_id,\n creatorType: note.creator_type,\n negotiableQuoteItemUid: note.negotiable_quote_template_item_uid,\n note: note.note,\n noteUid: note.note_uid,\n })),\n noteFromSeller: item.note_from_seller?.map((note: any) => ({\n createdAt: note.created_at,\n creatorId: note.creator_id,\n creatorType: note.creator_type,\n negotiableQuoteItemUid: note.negotiable_quote_template_item_uid,\n note: note.note,\n noteUid: note.note_uid,\n })),\n configurableOptions: item.configurable_options?.map((option: any) => ({\n optionLabel: option.option_label,\n valueLabel: option.value_label,\n })),\n bundleOptions: item.bundle_options?.map((option: any) => ({\n label: option.label,\n values: option.values.map((value: any) => ({\n label: value.label,\n quantity: value.quantity,\n originalPrice: {\n value: value.original_price.value,\n currency: value.original_price.currency,\n },\n price: {\n value: value.priceV2.value,\n currency: value.priceV2.currency,\n },\n })),\n })),\n })) || [],\n shippingAddresses: templateData.shipping_addresses?.map((address: any) => ({\n uid: address.uid,\n firstname: address.firstname,\n lastname: address.lastname,\n company: address.company,\n street: address.street,\n city: address.city,\n postcode: address.postcode,\n country: {\n code: address.country.code,\n label: address.country.label,\n },\n telephone: address.telephone,\n region: address.region\n ? {\n code: address.region.code,\n label: address.region.label,\n regionId: address.region.region_id,\n }\n : undefined,\n })),\n referenceDocuments: templateData.reference_document_links?.map((doc: any) => ({\n uid: doc.link_id,\n name: doc.document_name,\n identifier: doc.document_identifier,\n url: doc.reference_document_url,\n })),\n // Calculate permissions based on status\n canAccept: [\n NegotiableQuoteTemplateStatus.SUBMITTED,\n NegotiableQuoteTemplateStatus.PENDING,\n NegotiableQuoteTemplateStatus.OPEN,\n ].includes(templateData.status),\n canDelete: templateData.status === NegotiableQuoteTemplateStatus.DRAFT,\n canReopen: [\n NegotiableQuoteTemplateStatus.DECLINED,\n NegotiableQuoteTemplateStatus.CANCELED,\n NegotiableQuoteTemplateStatus.EXPIRED,\n ].includes(templateData.status),\n canCancel: [\n NegotiableQuoteTemplateStatus.SUBMITTED,\n NegotiableQuoteTemplateStatus.PENDING,\n NegotiableQuoteTemplateStatus.OPEN,\n NegotiableQuoteTemplateStatus.ACTIVE,\n NegotiableQuoteTemplateStatus.EDITED,\n ].includes(templateData.status),\n canSendForReview: [\n NegotiableQuoteTemplateStatus.OPEN,\n NegotiableQuoteTemplateStatus.DRAFT,\n NegotiableQuoteTemplateStatus.NEW,\n NegotiableQuoteTemplateStatus.EDITED,\n ].includes(templateData.status),\n canGenerateQuoteFromTemplate: [\n NegotiableQuoteTemplateStatus.ACTIVE,\n ].includes(templateData.status),\n canEditTemplateItems: [\n NegotiableQuoteTemplateStatus.SUBMITTED,\n NegotiableQuoteTemplateStatus.DRAFT,\n NegotiableQuoteTemplateStatus.OPEN,\n NegotiableQuoteTemplateStatus.EDITED,\n ].includes(templateData.status),\n };\n}\n\nexport function transformQuoteTemplatesList(\n templatesData: any\n): NegotiableQuoteTemplatesListModel | null {\n if (!templatesData) {\n return null;\n }\n\n const transformedModel = {\n items:\n templatesData.items?.map((template: any) => ({\n id: template.template_id,\n uid: 'TBD',\n name: template.name,\n createdAt: '0000-00-00 00:00:00', // TODO: missing from GraphQL API\n updatedAt: '0000-00-00 00:00:00', // TODO: missing from GraphQL API\n status: template.status,\n state: template.state,\n prices: {\n grandTotal: {\n value: 0, // TODO: missing from GraphQL API\n currency: 'USD', // TODO: missing from GraphQL API\n },\n minNegotiatedGrandTotal: {\n value: template.min_negotiated_grand_total,\n currency: 'USD', // TODO: use the same from grand total when available\n },\n },\n lastSharedAt: template.last_shared_at,\n lastOrderedAt: '0000-00-00 00:00:00', // TODO: missing from GraphQL API\n expirationDate: '0000-00-00 00:00:00', // TODO: broken in GraphQL API\n ordersPlaced: template.orders_placed,\n canGenerateQuoteFromTemplate: [\n NegotiableQuoteTemplateStatus.ACTIVE,\n ].includes(template.status),\n })) || [],\n pageInfo: {\n currentPage: templatesData.page_info.current_page,\n pageSize: templatesData.page_info.page_size,\n totalPages: templatesData.page_info.total_pages,\n },\n totalCount: templatesData.total_count,\n sortFields: templatesData.sort_fields\n ? {\n default: templatesData.sort_fields.default,\n options: templatesData.sort_fields.options,\n }\n : undefined,\n };\n\n // Calculate pagination info\n const paginationInfo = transformPaginationInfo(transformedModel);\n\n return {\n ...transformedModel,\n paginationInfo: paginationInfo || undefined,\n };\n}\n"],"names":["NegotiableQuoteTemplateStatus","transformQuoteTemplate","templateData","_a","comment","_b","tax","_c","h","_d","item","discount","note","_e","option","_f","value","address","doc","transformQuoteTemplatesList","templatesData","transformedModel","template","paginationInfo","transformPaginationInfo"],"mappings":"yCAiEO,IAAKA,GAAAA,IACVA,EAAA,OAAS,SACTA,EAAA,UAAY,YACZA,EAAA,SAAW,WACXA,EAAA,UAAY,YACZA,EAAA,QAAU,UACVA,EAAA,OAAS,SACTA,EAAA,KAAO,OACPA,EAAA,QAAU,UACVA,EAAA,OAAS,SACTA,EAAA,IAAM,MACNA,EAAA,MAAQ,QACRA,EAAA,SAAW,WACXA,EAAA,SAAW,WACXA,EAAA,QAAU,UAdAA,IAAAA,GAAA,CAAA,CAAA,ECjDL,SAASC,EACdC,EACqC,iBACrC,OAAKA,EAIE,C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["/@dropins/storefront-quote-management/src/data/models/negotiable-quote-template-model.ts","/@dropins/storefront-quote-management/src/data/transforms/transform-quote-template.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport {\n Currency,\n PaginationInfo,\n ShippingAddress,\n NegotiableQuoteHistoryEntry,\n CartItemModel,\n} from './negotiable-quote-model';\n\nexport interface NegotiableQuoteTemplateModel {\n id: string;\n uid: string;\n name: string;\n createdAt: string;\n updatedAt: string;\n expirationDate?: string;\n status: NegotiableQuoteTemplateStatus;\n salesRepName: string;\n buyer: {\n firstname: string;\n lastname: string;\n };\n comments?: QuoteTemplateComment[];\n history?: NegotiableQuoteHistoryEntry[];\n prices: {\n subtotalExcludingTax?: Currency;\n subtotalIncludingTax?: Currency;\n subtotalWithDiscountExcludingTax?: Currency;\n grandTotal?: Currency;\n appliedTaxes?: {\n amount: Currency;\n label: string;\n }[];\n };\n items: CartItemModel[];\n shippingAddresses?: ShippingAddress[];\n referenceDocuments?: {\n uid: string;\n name: string;\n identifier?: string;\n url: string;\n }[];\n // Template-specific fields\n quantityThresholds?: {\n min?: number;\n max?: number;\n };\n canAccept: boolean;\n canDelete: boolean;\n canReopen: boolean;\n canCancel: boolean;\n canSendForReview: boolean;\n canGenerateQuoteFromTemplate: boolean;\n canEditTemplateItems: boolean;\n}\n\nexport enum NegotiableQuoteTemplateStatus {\n ACTIVE = 'Active',\n IN_REVIEW = 'In Review',\n INACTIVE = 'Inactive',\n SUBMITTED = 'Submitted',\n PENDING = 'Pending',\n CLOSED = 'Closed',\n OPEN = 'Open',\n UPDATED = 'Updated',\n EDITED = 'Edited',\n NEW = 'New',\n DRAFT = 'Draft',\n DECLINED = 'Declined',\n CANCELED = 'Canceled',\n EXPIRED = 'Expired',\n}\n\n\nexport interface QuoteTemplateComment {\n uid: string;\n createdAt: string;\n author: {\n firstname: string;\n lastname: string;\n };\n text: string;\n attachments?: {\n name: string;\n url: string;\n }[];\n}\n\n// List model for getQuoteTemplates\nexport interface NegotiableQuoteTemplatesListModel {\n items: NegotiableQuoteTemplateListEntry[];\n pageInfo: {\n currentPage: number;\n pageSize: number;\n totalPages: number;\n };\n totalCount: number;\n paginationInfo?: PaginationInfo;\n sortFields?: {\n default: string;\n options: Array<{\n label: string;\n value: string;\n }>;\n };\n}\n\nexport interface NegotiableQuoteTemplateListEntry {\n id: string;\n uid: string;\n name: string;\n createdAt: string;\n updatedAt: string;\n status: NegotiableQuoteTemplateStatus;\n state: 'active' | 'inactive' | 'in_review';\n lastSharedAt: string;\n lastOrderedAt: string;\n expirationDate: string;\n ordersPlaced: number;\n prices: {\n grandTotal: Currency;\n minNegotiatedGrandTotal: Currency;\n };\n canGenerateQuoteFromTemplate?: boolean;\n}\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport {\n NegotiableQuoteTemplateModel,\n NegotiableQuoteTemplatesListModel,\n NegotiableQuoteTemplateStatus,\n} from '../models/negotiable-quote-template-model';\nimport { transformPaginationInfo } from './transform-quote';\nimport { transformHistory } from './transform-history';\nimport { transformQuoteItems } from './transform-quote-items';\n\nexport function transformQuoteTemplate(\n templateData: any\n): NegotiableQuoteTemplateModel | null {\n if (!templateData) {\n return null;\n }\n\n return {\n id: templateData.template_id,\n uid: templateData.uid,\n name: templateData.name,\n createdAt: templateData.created_at,\n updatedAt: templateData.updated_at,\n expirationDate: templateData.expiration_date,\n status: templateData.status,\n salesRepName: templateData.sales_rep_name,\n buyer: {\n firstname: templateData.buyer.firstname,\n lastname: templateData.buyer.lastname,\n },\n comments: templateData.comments?.map((comment: any) => ({\n uid: comment.uid,\n createdAt: comment.created_at,\n author: {\n firstname: comment.author.firstname,\n lastname: comment.author.lastname,\n },\n text: comment.text,\n attachments: comment.attachments?.map((a: any) => ({\n name: a.name,\n url: a.url,\n })),\n })),\n prices: templateData.prices && {\n subtotalExcludingTax: templateData.prices.subtotal_excluding_tax && {\n value: templateData.prices.subtotal_excluding_tax.value,\n currency: templateData.prices.subtotal_excluding_tax.currency,\n },\n subtotalIncludingTax: templateData.prices.subtotal_including_tax && {\n value: templateData.prices.subtotal_including_tax.value,\n currency: templateData.prices.subtotal_including_tax.currency,\n },\n subtotalWithDiscountExcludingTax: templateData.prices\n .subtotal_with_discount_excluding_tax && {\n value: templateData.prices.subtotal_with_discount_excluding_tax.value,\n currency:\n templateData.prices.subtotal_with_discount_excluding_tax.currency,\n },\n appliedTaxes: templateData.prices.applied_taxes?.map((tax: any) => ({\n amount: { value: tax.amount.value, currency: tax.amount.currency },\n label: tax.label,\n })),\n grandTotal: templateData.prices.grand_total && {\n value: templateData.prices.grand_total.value,\n currency: templateData.prices.grand_total.currency,\n },\n },\n history: transformHistory(templateData.history),\n items: transformQuoteItems(templateData.items),\n shippingAddresses: templateData.shipping_addresses?.map((address: any) => ({\n uid: address.uid,\n firstname: address.firstname,\n lastname: address.lastname,\n company: address.company,\n street: address.street,\n city: address.city,\n postcode: address.postcode,\n country: {\n code: address.country.code,\n label: address.country.label,\n },\n telephone: address.telephone,\n region: address.region\n ? {\n code: address.region.code,\n label: address.region.label,\n regionId: address.region.region_id,\n }\n : undefined,\n })),\n referenceDocuments: templateData.reference_document_links?.map((doc: any) => ({\n uid: doc.link_id,\n name: doc.document_name,\n identifier: doc.document_identifier,\n url: doc.reference_document_url,\n })),\n // Calculate permissions based on status\n canAccept: [\n NegotiableQuoteTemplateStatus.SUBMITTED,\n NegotiableQuoteTemplateStatus.PENDING,\n NegotiableQuoteTemplateStatus.OPEN,\n ].includes(templateData.status),\n canDelete: templateData.status === NegotiableQuoteTemplateStatus.DRAFT,\n canReopen: [\n NegotiableQuoteTemplateStatus.DECLINED,\n NegotiableQuoteTemplateStatus.CANCELED,\n NegotiableQuoteTemplateStatus.EXPIRED,\n ].includes(templateData.status),\n canCancel: [\n NegotiableQuoteTemplateStatus.SUBMITTED,\n NegotiableQuoteTemplateStatus.PENDING,\n NegotiableQuoteTemplateStatus.OPEN,\n NegotiableQuoteTemplateStatus.ACTIVE,\n NegotiableQuoteTemplateStatus.EDITED,\n ].includes(templateData.status),\n canSendForReview: [\n NegotiableQuoteTemplateStatus.OPEN,\n NegotiableQuoteTemplateStatus.DRAFT,\n NegotiableQuoteTemplateStatus.NEW,\n NegotiableQuoteTemplateStatus.EDITED,\n ].includes(templateData.status),\n canGenerateQuoteFromTemplate: [\n NegotiableQuoteTemplateStatus.ACTIVE,\n ].includes(templateData.status),\n canEditTemplateItems: [\n NegotiableQuoteTemplateStatus.SUBMITTED,\n NegotiableQuoteTemplateStatus.DRAFT,\n NegotiableQuoteTemplateStatus.OPEN,\n NegotiableQuoteTemplateStatus.EDITED,\n ].includes(templateData.status),\n };\n}\n\nexport function transformQuoteTemplatesList(\n templatesData: any\n): NegotiableQuoteTemplatesListModel | null {\n if (!templatesData) {\n return null;\n }\n\n const transformedModel = {\n items:\n templatesData.items?.map((template: any) => ({\n id: template.template_id,\n uid: template.uid,\n name: template.name,\n createdAt: template.created_at,\n updatedAt: template.updated_at,\n status: template.status,\n state: template.state,\n prices: {\n grandTotal: template.prices?.grand_total\n ? {\n value: template.prices.grand_total.value,\n currency: template.prices.grand_total.currency,\n }\n : {\n value: 0,\n currency: 'USD',\n },\n minNegotiatedGrandTotal: {\n value: template.min_negotiated_grand_total,\n currency: template.prices?.grand_total?.currency || 'USD',\n },\n },\n lastSharedAt: template.last_shared_at,\n lastOrderedAt: template.last_ordered_at,\n expirationDate: template.expiration_date,\n ordersPlaced: template.orders_placed,\n canGenerateQuoteFromTemplate: [\n NegotiableQuoteTemplateStatus.ACTIVE,\n ].includes(template.status),\n })) || [],\n pageInfo: {\n currentPage: templatesData.page_info.current_page,\n pageSize: templatesData.page_info.page_size,\n totalPages: templatesData.page_info.total_pages,\n },\n totalCount: templatesData.total_count,\n sortFields: templatesData.sort_fields\n ? {\n default: templatesData.sort_fields.default,\n options: templatesData.sort_fields.options,\n }\n : undefined,\n };\n\n // Calculate pagination info\n const paginationInfo = transformPaginationInfo(transformedModel);\n\n return {\n ...transformedModel,\n paginationInfo: paginationInfo || undefined,\n };\n}\n"],"names":["NegotiableQuoteTemplateStatus","transformQuoteTemplate","templateData","_a","comment","a","_b","tax","transformHistory","transformQuoteItems","_c","address","_d","doc","transformQuoteTemplatesList","templatesData","transformedModel","template","paginationInfo","transformPaginationInfo"],"mappings":"uDAgEO,IAAKA,GAAAA,IACVA,EAAA,OAAS,SACTA,EAAA,UAAY,YACZA,EAAA,SAAW,WACXA,EAAA,UAAY,YACZA,EAAA,QAAU,UACVA,EAAA,OAAS,SACTA,EAAA,KAAO,OACPA,EAAA,QAAU,UACVA,EAAA,OAAS,SACTA,EAAA,IAAM,MACNA,EAAA,MAAQ,QACRA,EAAA,SAAW,WACXA,EAAA,SAAW,WACXA,EAAA,QAAU,UAdAA,IAAAA,GAAA,CAAA,CAAA,EC9CL,SAASC,EACdC,EACqC,aACrC,OAAKA,EAIE,CACL,GAAIA,EAAa,YACjB,IAAKA,EAAa,IAClB,KAAMA,EAAa,KACnB,UAAWA,EAAa,WACxB,UAAWA,EAAa,WACxB,eAAgBA,EAAa,gBAC7B,OAAQA,EAAa,OACrB,aAAcA,EAAa,eAC3B,MAAO,CACL,UAAWA,EAAa,MAAM,UAC9B,SAAUA,EAAa,MAAM,QAAA,EAE/B,UAAUC,EAAAD,EAAa,WAAb,YAAAC,EAAuB,IAAKC,GAAA,OAAkB,OACtD,IAAKA,EAAQ,IACb,UAAWA,EAAQ,WACnB,OAAQ,CACN,UAAWA,EAAQ,OAAO,UAC1B,SAAUA,EAAQ,OAAO,QAAA,EAE3B,KAAMA,EAAQ,KACd,aAAaD,EAAAC,EAAQ,cAAR,YAAAD,EAAqB,IAAKE,IAAY,CACjD,KAAMA,EAA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AiB,cAAjB,YAAAI,EAA8B,WAAY,KAAA,CACtD,EAEF,aAAcO,EAAS,eACvB,cAAeA,EAAS,gBACxB,eAAgBA,EAAS,gBACzB,aAAcA,EAAS,cACvB,6BAA8B,CAC5BjB,EAA8B,MAAA,EAC9B,SAASiB,EAAS,MAAM,CAAA,MACrB,CAAA,EACT,SAAU,CACR,YAAaF,EAAc,UAAU,aACrC,SAAUA,EAAc,UAAU,UAClC,WAAYA,EAAc,UAAU,WAAA,EAEtC,WAAYA,EAAc,YAC1B,WAAYA,EAAc,YACtB,CACE,QAASA,EAAc,YAAY,QACnC,QAASA,EAAc,YAAY,OAAA,EAErC,MAAA,EAIAG,EAAiBC,EAAwBH,CAAgB,EAE/D,MAAO,CACL,GAAGA,EACH,eAAgBE,GAAkB,MAAA,CAEtC"}
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{FetchGraphQL as I}from"@dropins/tools/fetch-graphql.js";import{s as g}from"./state.js";var x=(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))(x||{});const{setEndpoint:M,setFetchGraphQlHeader:B,removeFetchGraphQlHeader:G,setFetchGraphQlHeaders:z,fetchGraphQl:W,getConfig:H}=new I().getMethods(),b=["DRAFT","UPDATED","DECLINED","EXPIRED","NEW","OPEN"];function P(e){if(!e.items)return 0;const r=g.config;return(r==null?void 0:r.quoteSummaryDisplayTotal)===0?e.items.length:(r==null?void 0:r.quoteSummaryDisplayTotal)===1?e.total_quantity:e.items.length}function w(e){var n,c,i,l;const r=g.config;return{src:r!=null&&r.useConfigurableParentThumbnail?e.product.thumbnail.url:((c=(n=e.configured_variant)==null?void 0:n.thumbnail)==null?void 0:c.url)||e.product.thumbnail.url,alt:r!=null&&r.useConfigurableParentThumbnail?e.product.thumbnail.label:((l=(i=e.configured_variant)==null?void 0:i.thumbnail)==null?void 0:l.label)||e.product.thumbnail.label}}function C(e){var r;return((r=e.links)==null?void 0:r.length)>0?{count:e.links.length,result:e.links.map(n=>n.title).join(", ")}:null}function T(e,r){return e!=null&&e.length&&[...e].sort((c,i)=>i.quantity-c.quantity).find(c=>r>=c.quantity)||null}function A(e){var s,o;const r=e.quantity,n=e.__typename==="ConfigurableCartItem",c=n?(s=e.configured_variant)==null?void 0:s.price_tiers:e.product.price_tiers,i=n?(o=e.configured_variant)==null?void 0:o.price_range:e.product.price_range,l=T(c,r);return l?l.discount.amount_off>0:(i==null?void 0:i.maximum_price.discount.amount_off)>0}function O(e){var i,l,s,o,d,a,u,p;const r=e.quantity,n=T(e.product.price_tiers,r);if(n)return Math.round(n.discount.percent_off);let c;if(e.__typename==="ConfigurableCartItem")c=(o=(s=(l=(i=e==null?void 0:e.configured_variant)==null?void 0:i.price_range)==null?void 0:l.maximum_price)==null?void 0:s.discount)==null?void 0:o.percent_off;else{if(e.__typename==="BundleCartItem")return;c=(p=(u=(a=(d=e==null?void 0:e.product)==null?void 0:d.price_range)==null?void 0:a.maximum_price)==null?void 0:u.discount)==null?void 0:p.percent_off}if(c!==0)return Math.round(c)}function R(e){var r,n,c,i;return e.__typename==="ConfigurableCartItem"?{value:(n=(r=e.configured_variant)==null?void 0:r.price_range)==null?void 0:n.maximum_price.regular_price.value,currency:(i=(c=e.configured_variant)==null?void 0:c.price_range)==null?void 0:i.maximum_price.regular_price.currency}:{value:e.prices.original_item_price.value,currency:e.prices.original_item_price.currency}}function N(e){var c,i,l,s,o,d;let r,n;if(r=((i=(c=e==null?void 0:e.prices)==null?void 0:c.original_row_total)==null?void 0:i.value)-((s=(l=e==null?void 0:e.prices)==null?void 0:l.row_total)==null?void 0:s.value),n=(d=(o=e==null?void 0:e.prices)==null?void 0:o.row_total)==null?void 0:d.currency,r!==0)return{value:r,currency:n}}function S(e){var n,c,i,l,s,o,d;const r=D(e);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,expirationDate:e.expiration_date,status:r?x.NEW:e.status,isVirtual:!!e.is_virtual,salesRepName:e.sales_rep_name,buyer:{firstname:e.buyer.firstname,lastname:e.buyer.lastname},templateName:e.template_name,totalQuantity:P(e),comments:(n=e.comments)==null?void 0:n.map(a=>{const u={uid:a.uid,createdAt:a.created_at,author:{firstname:a.author.firstname,lastname:a.author.lastname},text:a.text};return Array.isArray(a.attachments)&&a.attachments.length>0&&(u.attachments=a.attachments.map(p=>({name:p.name,url:p.url}))),u}),prices:e.prices&&{appliedDiscounts:(c=e.prices.discounts)==null?void 0:c.map(a=>({amount:{value:a.amount.value,currency:a.amount.currency},label:a.label,coupon:a.coupon})),appliedTaxes:(i=e.prices.applied_taxes)==null?void 0:i.map(a=>({amount:{value:a.amount.value,currency:a.amount.currency},label:a.label})),discount:e.prices.discounts&&e.prices.grand_total&&E(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},...F(e),totalTax:e.prices.applied_taxes&&e.prices.grand_total&&E(e.prices.applied_taxes,e.prices.grand_total.currency)},history:(l=e.history)==null?void 0:l.map(a=>{var u,p,f,m,v,y,h;return{uid:a.uid,createdAt:a.created_at,author:{firstname:a.author.firstname,lastname:a.author.lastname},changeType:a.change_type,changes:{commentAdded:((u=a.changes)==null?void 0:u.comment_added)&&{comment:a.changes.comment_added.comment},customChanges:((p=a.changes)==null?void 0:p.custom_changes)&&{new_value:a.changes.custom_changes.new_value,old_value:a.changes.custom_changes.old_value,title:a.changes.custom_changes.title},expiration:((f=a.changes)==null?void 0:f.expiration)&&{newExpiration:a.changes.expiration.new_expiration,oldExpiration:a.changes.expiration.old_expiration},productsRemoved:((m=a.changes)==null?void 0:m.products_removed)&&{productsRemovedFromCatalog:a.changes.products_removed.products_removed_from_catalog||[],productsRemovedFromQuote:a.changes.products_removed.products_removed_from_quote||[]},statuses:((v=a.changes)==null?void 0:v.statuses)&&{changes:((y=a.changes.statuses.changes)==null?void 0:y.map(t=>({newStatus:t.new_status,oldStatus:t.old_status})))||[]},total:((h=a.changes)==null?void 0:h.total)&&a.changes.total.new_price&&a.changes.total.old_price&&{newPrice:{value:a.changes.total.new_price.value,currency:a.changes.total.new_price.currency},oldPrice:{value:a.changes.total.old_price.value,currency:a.changes.total.old_price.currency}}}}}),items:((s=e.items)==null?void 0:s.map(a=>{var u,p,f,m,v,y,h;return{itemType:a.__typename,uid:a.uid,product:{uid:a.product.uid,sku:a.product.sku,name:a.product.name,priceRange:{maximumPrice:{regularPrice:{value:a.product.price_range.maximum_price.regular_price.value,currency:a.product.price_range.maximum_price.regular_price.currency}}}},image:w(a),links:C(a),discounted:A(a),discountedTotal:{value:a.prices.row_total.value,currency:a.prices.row_total.currency},catalogDiscount:{amountOff:a.prices.catalog_discount.amount_off,percentOff:a.prices.catalog_discount.percent_off},discounts:((p=(u=a.prices)==null?void 0:u.discounts)==null?void 0:p.map(t=>({label:t.label,value:t.value,amount:{value:t.amount.value,currency:t.amount.currency}})))??[],discountPercentage:O(a),insufficientQuantity:(a.__typename==="ConfigurableCartItem"?a.configured_variant:a.product).stock_status==="IN_STOCK"&&!a.is_available,outOfStock:a.product.stock_status==="OUT_OF_STOCK",stockStatus:a.product.stock_status,quantity:a.quantity,prices:{regularPrice:R(a),priceIncludingTax:{value:a.prices.price_including_tax.value,currency:a.prices.price_including_tax.currency},originalItemPrice:{value:a.prices.original_item_price.value,currency:a.prices.original_item_price.currency},originalRowTotal:{value:a.prices.original_row_total.value,currency:a.prices.original_row_total.currency},rowTotal:{value:a.prices.row_total.value,currency:a.prices.row_total.currency},rowTotalIncludingTax:{value:a.prices.row_total_including_tax.value,currency:a.prices.row_total_including_tax.currency}},savingsAmount:N(a),noteFromBuyer:(f=a.note_from_buyer)==null?void 0:f.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_item_uid,note:t.note,noteUid:t.note_uid})),noteFromSeller:(m=a.note_from_seller)==null?void 0:m.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_item_uid,note:t.note,noteUid:t.note_uid})),configurableOptions:(v=a.configurable_options)==null?void 0:v.map(t=>({optionLabel:t.option_label,valueLabel:t.value_label})),bundleOptions:(y=a.bundle_options)==null?void 0:y.map(t=>({label:t.label,values:t.values.map(_=>({label:_.label,quantity:_.quantity,originalPrice:{value:_.original_price.value,currency:_.original_price.currency},price:{value:_.priceV2.value,currency:_.priceV2.currency}}))})),customizableOptions:(h=a.customizable_options)==null?void 0:h.map(t=>({type:t.type,label:t.label,values:t.values.map(_=>({label:_.label,value:_.value}))}))}}))||[],shippingAddresses:(o=e.shipping_addresses)==null?void 0:o.map(a=>{const u={uid:a.uid,firstname:a.firstname,lastname:a.lastname,company:a.company,street:a.street,city:a.city,postcode:a.postcode,country:{code:a.country.code,label:a.country.label},telephone:a.telephone};return a.region&&(u.region={code:a.region.code,label:a.region.label,regionId:a.region.region_id}),u}),canCheckout:["UPDATED","DECLINED","OPEN"].includes(e.status)&&g.permissions.checkoutQuote&&((d=e.shipping_addresses)==null?void 0:d.length)>0,canSendForReview:(r||b.includes(e.status))&&g.permissions.editQuote,canUpdateQuote:(r||b.includes(e.status))&&g.permissions.editQuote,canDelete:!["PENDING","SUBMITTED","ORDERED"].includes(e.status)&&g.permissions.deleteQuote,canClose:e.status?!["DRAFT","CLOSED","ORDERED","OPEN"].includes(e.status):!1,readOnly:!r&&["ORDERED","SUBMITTED","CLOSED","PENDING"].includes(e.status)||!g.permissions.editQuote}}function V(e){return e?S(e):null}function D(e){return e.status==="SUBMITTED"&&!(e.history??[]).some(r=>{var n,c;return r.change_type==="UPDATED"&&(((c=(n=r.changes)==null?void 0:n.statuses)==null?void 0:c.changes)??[]).length>0})}function U(e){const r=D(e);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,status:r?x.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 X(e){var c;if(!e)return null;const r={items:((c=e.items)==null?void 0:c.filter(i=>i==null?void 0:i.uid).map(U))||[],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},n=Q(r);return{...r,paginationInfo:n||void 0}}function Q(e){if(!(e!=null&&e.pageInfo)||!e.totalCount)return null;const{currentPage:r,pageSize:n,totalPages:c}=e.pageInfo,{totalCount:i}=e,l=i>0?(r-1)*n+1:0,s=Math.min(r*n,i);return{currentPage:r,totalCount:i,pageSize:n,startItem:l,endItem:s,totalPages:c,pageSizeOptions:[20,30,50,100,200]}}const K=()=>[20,30,50,100,200];function E(e,r){return e!=null&&e.length?e.reduce((n,c)=>({value:n.value+c.amount.value,currency:c.amount.currency}),{value:0,currency:r}):{value:0,currency:r}}function F(e){var c;if(!e||!((c=e.shipping_addresses)!=null&&c.length))return{};const n=e.shipping_addresses[0].selected_shipping_method;return n?{shippingIncludingTax:n.price_incl_tax&&{value:n.price_incl_tax.value,currency:n.price_incl_tax.currency},shippingExcludingTax:n.price_excl_tax&&{value:n.price_excl_tax.value,currency:n.price_excl_tax.currency}}:{}}export{Q as a,X as b,B as c,z as d,H as e,W as f,K as g,G as r,M as s,V as t};
3
+ import{FetchGraphQL as x}from"@dropins/tools/fetch-graphql.js";import{s as p}from"./state.js";var _=(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))(_||{});const{setEndpoint:F,setFetchGraphQlHeader:L,removeFetchGraphQlHeader:M,setFetchGraphQlHeaders:B,fetchGraphQl:G,getConfig:z}=new x().getMethods();function b(e){var a,n,c,i,u,l,s;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:((n=e.changes)==null?void 0:n.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:((c=e.changes)==null?void 0:c.expiration)&&{newExpiration:e.changes.expiration.new_expiration,oldExpiration:e.changes.expiration.old_expiration},productsRemoved:((i=e.changes)==null?void 0:i.products_removed)&&{productsRemovedFromCatalog:e.changes.products_removed.products_removed_from_catalog||[],productsRemovedFromQuote:e.changes.products_removed.products_removed_from_quote||[]},statuses:((u=e.changes)==null?void 0:u.statuses)&&{changes:((l=e.changes.statuses.changes)==null?void 0:l.map(r=>({newStatus:r==null?void 0:r.new_status,oldStatus:r==null?void 0:r.old_status})))||[]},total:((s=e.changes)==null?void 0:s.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 h(e){if(e)return e.map(b)}function m(e,a){return e!=null&&e.length&&[...e].sort((c,i)=>i.quantity-c.quantity).find(c=>a>=c.quantity)||null}function y(e){var n,c,i,u;const a=p.config;return{src:a!=null&&a.useConfigurableParentThumbnail?e.product.thumbnail.url:((c=(n=e.configured_variant)==null?void 0:n.thumbnail)==null?void 0:c.url)||e.product.thumbnail.url,alt:a!=null&&a.useConfigurableParentThumbnail?e.product.thumbnail.label:((u=(i=e.configured_variant)==null?void 0:i.thumbnail)==null?void 0:u.label)||e.product.thumbnail.label}}function T(e){var a;return((a=e.links)==null?void 0:a.length)>0?{count:e.links.length,result:e.links.map(n=>n.title).join(", ")}:null}function I(e){var l,s,r,t;const a=e.quantity,n=e.__typename==="ConfigurableCartItem",c=n?(l=e.configured_variant)==null?void 0:l.price_tiers:e.product.price_tiers,i=n?(s=e.configured_variant)==null?void 0:s.price_range:e.product.price_range,u=m(c,a);return u?u.discount.amount_off>0:(((t=(r=i==null?void 0:i.maximum_price)==null?void 0:r.discount)==null?void 0:t.amount_off)??0)>0}function D(e){var i,u,l,s,r,t,o,d;const a=e.quantity,n=m(e.product.price_tiers,a);if(n)return Math.round(n.discount.percent_off);let c;if(e.__typename==="ConfigurableCartItem")c=(s=(l=(u=(i=e==null?void 0:e.configured_variant)==null?void 0:i.price_range)==null?void 0:u.maximum_price)==null?void 0:l.discount)==null?void 0:s.percent_off;else{if(e.__typename==="BundleCartItem")return;c=(d=(o=(t=(r=e==null?void 0:e.product)==null?void 0:r.price_range)==null?void 0:t.maximum_price)==null?void 0:o.discount)==null?void 0:d.percent_off}if(c!==0)return Math.round(c)}function E(e){var a,n,c,i;return e.__typename==="ConfigurableCartItem"?{value:(n=(a=e.configured_variant)==null?void 0:a.price_range)==null?void 0:n.maximum_price.regular_price.value,currency:(i=(c=e.configured_variant)==null?void 0:c.price_range)==null?void 0:i.maximum_price.regular_price.currency}:{value:e.prices.original_item_price.value,currency:e.prices.original_item_price.currency}}function P(e){var c,i,u,l,s,r;let a,n;if(a=((i=(c=e==null?void 0:e.prices)==null?void 0:c.original_row_total)==null?void 0:i.value)-((l=(u=e==null?void 0:e.prices)==null?void 0:u.row_total)==null?void 0:l.value),n=(r=(s=e==null?void 0:e.prices)==null?void 0:s.row_total)==null?void 0:r.currency,a!==0)return{value:a,currency:n}}function w(e){var a,n,c,i,u,l,s,r;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:y(e),links:T(e),discounted:I(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},discounts:((n=(a=e.prices)==null?void 0:a.discounts)==null?void 0:n.map(t=>({label:t.label,value:t.value,amount:{value:t.amount.value,currency:t.amount.currency}})))??[],discountPercentage:D(e),insufficientQuantity:(e.__typename==="ConfigurableCartItem"?((c=e.configured_variant)==null?void 0:c.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:E(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:P(e),noteFromBuyer:(i=e.note_from_buyer)==null?void 0:i.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_item_uid,note:t.note,noteUid:t.note_uid})),noteFromSeller:(u=e.note_from_seller)==null?void 0:u.map(t=>({createdAt:t.created_at,creatorId:t.creator_id,creatorType:t.creator_type,negotiableQuoteItemUid:t.negotiable_quote_item_uid,note:t.note,noteUid:t.note_uid})),configurableOptions:(l=e.configurable_options)==null?void 0:l.map(t=>({optionLabel:t.option_label,valueLabel:t.value_label})),bundleOptions:(s=e.bundle_options)==null?void 0:s.map(t=>({label:t.label,values:t.values.map(o=>({label:o.label,quantity:o.quantity,originalPrice:{value:o.original_price.value,currency:o.original_price.currency},price:{value:o.priceV2.value,currency:o.priceV2.currency}}))})),customizableOptions:(r=e.customizable_options)==null?void 0:r.map(t=>({type:t.type,label:t.label,values:t.values.map(o=>({label:o.label,value:o.value}))}))}}function C(e){return e?e.map(w):[]}const g=["DRAFT","UPDATED","DECLINED","EXPIRED","NEW","OPEN"];function A(e){if(!e.items)return 0;const a=p.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 O(e){return e.every(a=>!a.outOfStock&&!a.insufficientQuantity)}function R(e){var c,i,u,l,s;const a=v(e),n=C(e.items);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,expirationDate:e.expiration_date,status:a?_.NEW:e.status,isVirtual:!!e.is_virtual,salesRepName:e.sales_rep_name,buyer:{firstname:e.buyer.firstname,lastname:e.buyer.lastname},templateName:e.template_name,totalQuantity:A(e),comments:(c=e.comments)==null?void 0:c.map(r=>{const t={uid:r.uid,createdAt:r.created_at,author:{firstname:r.author.firstname,lastname:r.author.lastname},text:r.text};return Array.isArray(r.attachments)&&r.attachments.length>0&&(t.attachments=r.attachments.map(o=>({name:o.name,url:o.url}))),t}),prices:e.prices&&{appliedDiscounts:(i=e.prices.discounts)==null?void 0:i.map(r=>({amount:{value:r.amount.value,currency:r.amount.currency},label:r.label,coupon:r.coupon})),appliedTaxes:(u=e.prices.applied_taxes)==null?void 0:u.map(r=>({amount:{value:r.amount.value,currency:r.amount.currency},label:r.label})),discount:e.prices.discounts&&e.prices.grand_total&&f(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},...k(e),totalTax:e.prices.applied_taxes&&e.prices.grand_total&&f(e.prices.applied_taxes,e.prices.grand_total.currency)},history:h(e.history),items:n,shippingAddresses:(l=e.shipping_addresses)==null?void 0:l.map(r=>{const t={uid:r.uid,firstname:r.firstname,lastname:r.lastname,company:r.company,street:r.street,city:r.city,postcode:r.postcode,country:{code:r.country.code,label:r.country.label},telephone:r.telephone};return r.region&&(t.region={code:r.region.code,label:r.region.label,regionId:r.region.region_id}),t}),canCheckout:["UPDATED","DECLINED"].includes(e.status)&&p.permissions.checkoutQuote&&((s=e.shipping_addresses)==null?void 0:s.length)>0&&O(n),canSendForReview:(a||g.includes(e.status))&&p.permissions.editQuote,canUpdateQuote:(a||g.includes(e.status))&&p.permissions.editQuote,canDelete:!["PENDING","SUBMITTED","ORDERED"].includes(e.status)&&p.permissions.deleteQuote,canClose:e.status?!["DRAFT","CLOSED","ORDERED","OPEN"].includes(e.status):!1,readOnly:!a&&["ORDERED","SUBMITTED","CLOSED","PENDING"].includes(e.status)||!p.permissions.editQuote}}function H(e){return e?R(e):null}function v(e){return e.status==="SUBMITTED"&&!(e.history??[]).some(a=>{var n,c;return a.change_type==="UPDATED"&&(((c=(n=a.changes)==null?void 0:n.statuses)==null?void 0:c.changes)??[]).length>0})}function S(e){const a=v(e);return{uid:e.uid,name:e.name,createdAt:e.created_at,updatedAt:e.updated_at,status:a?_.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 W(e){var c;if(!e)return null;const a={items:((c=e.items)==null?void 0:c.filter(i=>i==null?void 0:i.uid).map(S))||[],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},n=N(a);return{...a,paginationInfo:n||void 0}}function N(e){if(!(e!=null&&e.pageInfo)||!e.totalCount)return null;const{currentPage:a,pageSize:n,totalPages:c}=e.pageInfo,{totalCount:i}=e,u=i>0?(a-1)*n+1:0,l=Math.min(a*n,i);return{currentPage:a,totalCount:i,pageSize:n,startItem:u,endItem:l,totalPages:c,pageSizeOptions:[20,30,50,100,200]}}const V=()=>[20,30,50,100,200];function f(e,a){return e!=null&&e.length?e.reduce((n,c)=>({value:n.value+c.amount.value,currency:c.amount.currency}),{value:0,currency:a}):{value:0,currency:a}}function k(e){var c;if(!e||!((c=e.shipping_addresses)!=null&&c.length))return{};const n=e.shipping_addresses[0].selected_shipping_method;return n?{shippingIncludingTax:n.price_incl_tax&&{value:n.price_incl_tax.value,currency:n.price_incl_tax.currency},shippingExcludingTax:n.price_excl_tax&&{value:n.price_excl_tax.value,currency:n.price_excl_tax.currency}}:{}}export{C as a,h as b,N as c,W as d,L as e,G as f,V as g,B as h,z as i,M as r,F as s,H as t};
4
4
  //# sourceMappingURL=transform-quote.js.map