{"version":3,"file":"color-535e3a04.js","sources":["../../../app/javascript/services/order_service.ts","../../../app/javascript/utils/color.ts"],"sourcesContent":["import { Configuration } from '@/stores/admin/configuration'\nimport { Order, PaginatedCollection } from '@/types'\n\nimport ApiService from './api_service'\n\nexport default {\n async index(): Promise {\n const response = await ApiService.get(`/shopify-app/${Configuration().shopifyShopId}/orders`)\n return response.data\n },\n\n async cancelByCustomer(id: number | string): Promise {\n const response = await ApiService.post(`/shopify-app/${Configuration().shopifyShopId}/orders/${id}/cancel`)\n return response.data\n },\n\n async get(id: number | string): Promise {\n const response = await ApiService.get(`/shopify-app/${Configuration().shopifyShopId}/orders/${id}`)\n return response.data\n },\n\n async checkout(orderId: number | string, orderKey: number | string): Promise {\n const response = await ApiService.get(`/orders/${orderId}/${orderKey}/checkout`)\n return response.data\n },\n\n async cancelCheckout(orderId: number | string, orderKey: number | string): Promise {\n const response = await ApiService.post(`/orders/${orderId}/${orderKey}/cancel`)\n return response.data\n },\n\n async completeCheckout(orderId: number | string, orderKey: number | string): Promise {\n const response = await ApiService.get(`/orders/${orderId}/${orderKey}/complete`)\n return response.data\n }\n}\n","function hexToHL(hexColor) {\n const { r, g, b } = hexToRgb(hexColor)\n\n const max = Math.max(r, g, b)\n const min = Math.min(r, g, b)\n const delta = max - min\n\n const lightness = (max + min) / 2\n\n let hue\n\n if (delta < 0.1) {\n hue = 0\n } else {\n switch (max) {\n case r:\n hue = (g - b) / delta + (g < b ? 6 : 0)\n break\n case g:\n hue = (b - r) / delta + 2\n break\n case b:\n hue = (r - g) / delta + 4\n break\n }\n }\n\n return {\n hue,\n lightness\n }\n}\n\nexport function variantColorSort(x, y) {\n const a = hexToHL(x.hex_color)\n const b = hexToHL(y.hex_color)\n\n if (a.hue == b.hue) {\n return a.lightness - b.lightness\n } else {\n return a.hue - b.hue\n }\n}\n\nfunction hexToRgb(hexColor) {\n hexColor = hexColor.replace(/^#/, '')\n\n if (hexColor.length === 3) {\n hexColor = hexColor\n .split('')\n .map((char) => char + char)\n .join('')\n }\n\n return {\n r: parseInt(hexColor.substring(0, 2), 16) / 255,\n g: parseInt(hexColor.substring(2, 4), 16) / 255,\n b: parseInt(hexColor.substring(4, 6), 16) / 255\n }\n}\n\nfunction luminance({ r, g, b }) {\n return r * 0.299 + g * 0.587 + b * 0.114\n}\n\nexport function textColorForBackground(hexColor, lightColor = '#ddd', darkColor = '#333') {\n const rgb = hexToRgb(hexColor)\n\n return luminance(rgb) > 0.7 ? darkColor : lightColor\n}\n"],"names":["OrderService","ApiService","Configuration","id","orderId","orderKey","hexToHL","hexColor","r","g","b","hexToRgb","max","min","delta","lightness","hue","variantColorSort","x","y","a","char","luminance","textColorForBackground","lightColor","darkColor","rgb"],"mappings":"yDAKA,MAAeA,EAAA,CACb,MAAM,OAA0B,CAE9B,OADiB,MAAMC,EAAW,IAAI,gBAAgBC,IAAgB,sBAAsB,GAC5E,IAClB,EAEA,MAAM,iBAAiBC,EAAqC,CAE1D,OADiB,MAAMF,EAAW,KAAK,gBAAgBC,EAAc,EAAE,wBAAwBC,UAAW,GAC1F,IAClB,EAEA,MAAM,IAAIA,EAAqC,CAE7C,OADiB,MAAMF,EAAW,IAAI,gBAAgBC,EAAc,EAAE,wBAAwBC,GAAI,GAClF,IAClB,EAEA,MAAM,SAASC,EAA0BC,EAAyC,CAEhF,OADiB,MAAMJ,EAAW,IAAI,WAAWG,KAAWC,YAAmB,GAC/D,IAClB,EAEA,MAAM,eAAeD,EAA0BC,EAA2C,CAExF,OADiB,MAAMJ,EAAW,KAAK,WAAWG,KAAWC,UAAiB,GAC9D,IAClB,EAEA,MAAM,iBAAiBD,EAA0BC,EAA2C,CAE1F,OADiB,MAAMJ,EAAW,IAAI,WAAWG,KAAWC,YAAmB,GAC/D,IAClB,CACF,ECnCA,SAASC,EAAQC,EAAU,CACzB,KAAM,CAAE,EAAAC,EAAG,EAAAC,EAAG,EAAAC,CAAE,EAAIC,EAASJ,CAAQ,EAE/BK,EAAM,KAAK,IAAIJ,EA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