JezK
Edit File: index-d602bc13.js.map
{"file":"index-d602bc13.js","mappings":";;;;AAIA,MAAM,IAAI,GAAG,0BAA0B,CAAC;AAExC;MACa,kBAAkB,GAAG,CAAC,OAAwB,MAAM,KAC/D,QAAQ,CAAC;IACP,IAAI,EAAE,YAAY,CAAC,IAAI,EAAE;QACvB,IAAI;QACJ,MAAM,EAAE,CAAC,kBAAkB,EAAE,iBAAiB,CAAC;KAChD,CAAC;CACH,EAA8B;AAEjC;AACA;AACA,MAAM,sBAAsB,GAAyB,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;AAElH;AACA;AACA;AACA,MAAM,mBAAmB,GAAyB,CAAC,GAAG,sBAAsB,EAAE,SAAS,CAAC,CAAC;AAEzF;MACa,cAAc,GAAG,CAAC,OAA4C;IACzE,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1B,OAAO,sBAAsB,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5D,EAAE;AAEF;MACa,cAAc,GAAG,CAAC,KAA+C;IAC5E,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACjD,OAAO,mBAAmB,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AACvD;;;;","names":[],"sources":["src/services/customer-address/index.ts"],"sourcesContent":["import { Address, Customer } from '../../types';\nimport apiFetch from '../../functions/fetch';\nimport { addQueryArgs } from '@wordpress/url';\n\nconst path = 'surecart/v1/customers/me';\n\n/** Fetch the current user's customer record. Resolves to `null` when no customer is linked. */\nexport const getCurrentCustomer = (mode: 'live' | 'test' = 'live') =>\n apiFetch({\n path: addQueryArgs(path, {\n mode,\n expand: ['shipping_address', 'billing_address'],\n }),\n }) as Promise<Customer | null>;\n\n// Content fields only. Country is excluded here because it's IP-detected and pushed before\n// autofill runs — it must not make the checkout's address look \"non-empty\" and block autofill.\nconst ADDRESS_CONTENT_FIELDS: Array<keyof Address> = ['name', 'line_1', 'line_2', 'city', 'state', 'postal_code'];\n\n// Fields that count as the customer having a saved address worth autofilling. Country is\n// included here: a customer may have only a saved country (and no street/city yet), and we\n// still want that country carried into the checkout.\nconst ADDRESS_DATA_FIELDS: Array<keyof Address> = [...ADDRESS_CONTENT_FIELDS, 'country'];\n\n/** True when the address has no meaningful content fields set (country ignored — see above). */\nexport const isAddressEmpty = (address: Partial<Address> | null | undefined): boolean => {\n if (!address) return true;\n return ADDRESS_CONTENT_FIELDS.every(key => !address[key]);\n};\n\n/** True when the value carries any saved address data, including a country-only address. API returns `[]` for \"none\" — treat as empty. */\nexport const hasAddressData = (value: Partial<Address> | [] | null | undefined): value is Partial<Address> => {\n if (!value || Array.isArray(value)) return false;\n return ADDRESS_DATA_FIELDS.some(key => !!value[key]);\n};\n"],"version":3}