@restaround/react 1.3.28 → 1.3.30

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.
@@ -0,0 +1,6 @@
1
+ export declare const CATEGORY_SELECTED = "digital_menu_category_select";
2
+ export declare const CATEGORY_SCROLLED = "digital_menu_category_scroll";
3
+ export declare const PRODUCT_DETAILS = "digital_menu_product_details";
4
+ export declare const PRODUCT_ADD_ORDER = "digital_menu_product_add_cart";
5
+ export declare const PRODUCT_VIEW_CHANGED = "digital_menu_product_view_changed";
6
+ export declare const GOALS: string[];
@@ -0,0 +1 @@
1
+ export declare const BASE_API_URL = "https://api.restaround.co/api/v1";
@@ -0,0 +1,3 @@
1
+ export * from "./analytics";
2
+ export * from "../modules/feature/constants";
3
+ export * from "../modules/view/constants";
@@ -0,0 +1,8 @@
1
+ import { PricingPlans } from "src/models/pricing";
2
+ export declare const PRICING: PricingPlans;
3
+ export declare const PRICING_BENEFITS: {
4
+ title: string;
5
+ appetizer: boolean;
6
+ mainCourse: boolean;
7
+ chefsSpecial: boolean;
8
+ }[];
@@ -1,2 +1,3 @@
1
1
  export * from "./analytics";
2
2
  export * from "../modules/feature/constants";
3
+ export * from "../modules/view/constants";
@@ -0,0 +1,2 @@
1
+ const A="digital_menu",_=`${A}_category_select`,e=`${A}_category_scroll`,D=`${A}_product_details`,t=`${A}_product_add_cart`,o=`${A}_product_view_changed`,r=[_,e,D,t];var c,n;!function(A){A.ORDER="feature_order"}(c||(c={})),function(A){A.ALPHA="ALPHA",A.BETA="BETA",A.ALL="ALL"}(n||(n={}));const a={[n.ALPHA]:[],[n.BETA]:[],[n.ALL]:[c.ORDER]},E={ADD_UPDATE_NOTES:"ADD_UPDATE_NOTES",AUTH:"AUTH",ADD_UPDATE_ADDRESS:"ADD_UPDATE_ADDRESS"},d=["en","az","nl","et","tr","ru"],T="en",L="AZN",u=[{name:"Azerbaijan",code:"AZ",phoneCode:"+994"}];export{e as CATEGORY_SCROLLED,_ as CATEGORY_SELECTED,L as DEFAULT_CURRENCY,T as DEFAULT_LANGUAGE,a as FEATURES_LIST,r as GOALS,E as MODALS,t as PRODUCT_ADD_ORDER,D as PRODUCT_DETAILS,o as PRODUCT_VIEW_CHANGED,u as SUPPORTED_COUNTRIES,d as SUPPORTED_LOCALES};
2
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../../src/constants/analytics.ts","../../../src/modules/feature/models.ts","../../../src/modules/feature/constants.ts","../../../src/modules/view/constants.ts"],"sourcesContent":["const GOAL_BASE_NAME = \"digital_menu\";\n\nexport const CATEGORY_SELECTED = `${GOAL_BASE_NAME}_category_select`;\nexport const CATEGORY_SCROLLED = `${GOAL_BASE_NAME}_category_scroll`;\nexport const PRODUCT_DETAILS = `${GOAL_BASE_NAME}_product_details`;\nexport const PRODUCT_ADD_ORDER = `${GOAL_BASE_NAME}_product_add_cart`;\nexport const PRODUCT_VIEW_CHANGED = `${GOAL_BASE_NAME}_product_view_changed`;\n\nexport const GOALS = [CATEGORY_SELECTED, CATEGORY_SCROLLED, PRODUCT_DETAILS, PRODUCT_ADD_ORDER];\n","export enum Feature {\n\tORDER = \"feature_order\",\n}\nexport enum FeatureSegment {\n\tALPHA = \"ALPHA\",\n\tBETA = \"BETA\",\n\tALL = \"ALL\",\n}\n","import { Feature, FeatureSegment } from \"./models\";\n\nexport const FEATURES_LIST: { [key in FeatureSegment]: Feature[] } = {\n\t[FeatureSegment.ALPHA]: [],\n\t[FeatureSegment.BETA]: [],\n\t[FeatureSegment.ALL]: [Feature.ORDER],\n};\n","export const MODALS = {\n\tADD_UPDATE_NOTES: \"ADD_UPDATE_NOTES\",\n\tAUTH: \"AUTH\",\n\tADD_UPDATE_ADDRESS: \"ADD_UPDATE_ADDRESS\",\n};\n\nexport const SUPPORTED_LOCALES = [\"en\", \"az\", \"nl\", \"et\", \"tr\", \"ru\"];\nexport const DEFAULT_LANGUAGE = \"en\";\nexport const DEFAULT_CURRENCY = \"AZN\";\nexport const SUPPORTED_COUNTRIES = [\n\t{\n\t\tname: \"Azerbaijan\",\n\t\tcode: \"AZ\",\n\t\tphoneCode: \"+994\",\n\t},\n];\n"],"names":["GOAL_BASE_NAME","CATEGORY_SELECTED","CATEGORY_SCROLLED","PRODUCT_DETAILS","PRODUCT_ADD_ORDER","PRODUCT_VIEW_CHANGED","GOALS","Feature","FeatureSegment","FEATURES_LIST","ALPHA","BETA","ALL","ORDER","MODALS","ADD_UPDATE_NOTES","AUTH","ADD_UPDATE_ADDRESS","SUPPORTED_LOCALES","DEFAULT_LANGUAGE","DEFAULT_CURRENCY","SUPPORTED_COUNTRIES","name","code","phoneCode"],"mappings":"AAAA,MAAMA,EAAiB,eAEVC,EAAoB,GAAGD,oBACvBE,EAAoB,GAAGF,oBACvBG,EAAkB,GAAGH,oBACrBI,EAAoB,GAAGJ,qBACvBK,EAAuB,GAAGL,yBAE1BM,EAAQ,CAACL,EAAmBC,EAAmBC,EAAiBC,GCR7E,IAAYG,EAGAC,GAHZ,SAAYD,GACXA,EAAA,MAAA,eACA,CAFD,CAAYA,IAAAA,EAEX,CAAA,IACD,SAAYC,GACXA,EAAA,MAAA,QACAA,EAAA,KAAA,OACAA,EAAA,IAAA,KACA,CAJD,CAAYA,IAAAA,EAIX,CAAA,ICLY,MAAAC,EAAwD,CACpE,CAACD,EAAeE,OAAQ,GACxB,CAACF,EAAeG,MAAO,GACvB,CAACH,EAAeI,KAAM,CAACL,EAAQM,QCLnBC,EAAS,CACrBC,iBAAkB,mBAClBC,KAAM,OACNC,mBAAoB,sBAGRC,EAAoB,CAAC,KAAM,KAAM,KAAM,KAAM,KAAM,MACnDC,EAAmB,KACnBC,EAAmB,MACnBC,EAAsB,CAClC,CACCC,KAAM,aACNC,KAAM,KACNC,UAAW"}
@@ -0,0 +1,2 @@
1
+ "use strict";const A="digital_menu",_=`${A}_category_select`,D=`${A}_category_scroll`,E=`${A}_product_details`,e=`${A}_product_add_cart`,t=`${A}_product_view_changed`,r=[_,D,E,e];var o,T;!function(A){A.ORDER="feature_order"}(o||(o={})),function(A){A.ALPHA="ALPHA",A.BETA="BETA",A.ALL="ALL"}(T||(T={}));const L={[T.ALPHA]:[],[T.BETA]:[],[T.ALL]:[o.ORDER]};exports.CATEGORY_SCROLLED=D,exports.CATEGORY_SELECTED=_,exports.DEFAULT_CURRENCY="AZN",exports.DEFAULT_LANGUAGE="en",exports.FEATURES_LIST=L,exports.GOALS=r,exports.MODALS={ADD_UPDATE_NOTES:"ADD_UPDATE_NOTES",AUTH:"AUTH",ADD_UPDATE_ADDRESS:"ADD_UPDATE_ADDRESS"},exports.PRODUCT_ADD_ORDER=e,exports.PRODUCT_DETAILS=E,exports.PRODUCT_VIEW_CHANGED=t,exports.SUPPORTED_COUNTRIES=[{name:"Azerbaijan",code:"AZ",phoneCode:"+994"}],exports.SUPPORTED_LOCALES=["en","az","nl","et","tr","ru"];
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/constants/analytics.ts","../../../src/modules/feature/models.ts","../../../src/modules/feature/constants.ts","../../../src/modules/view/constants.ts"],"sourcesContent":["const GOAL_BASE_NAME = \"digital_menu\";\n\nexport const CATEGORY_SELECTED = `${GOAL_BASE_NAME}_category_select`;\nexport const CATEGORY_SCROLLED = `${GOAL_BASE_NAME}_category_scroll`;\nexport const PRODUCT_DETAILS = `${GOAL_BASE_NAME}_product_details`;\nexport const PRODUCT_ADD_ORDER = `${GOAL_BASE_NAME}_product_add_cart`;\nexport const PRODUCT_VIEW_CHANGED = `${GOAL_BASE_NAME}_product_view_changed`;\n\nexport const GOALS = [CATEGORY_SELECTED, CATEGORY_SCROLLED, PRODUCT_DETAILS, PRODUCT_ADD_ORDER];\n","export enum Feature {\n\tORDER = \"feature_order\",\n}\nexport enum FeatureSegment {\n\tALPHA = \"ALPHA\",\n\tBETA = \"BETA\",\n\tALL = \"ALL\",\n}\n","import { Feature, FeatureSegment } from \"./models\";\n\nexport const FEATURES_LIST: { [key in FeatureSegment]: Feature[] } = {\n\t[FeatureSegment.ALPHA]: [],\n\t[FeatureSegment.BETA]: [],\n\t[FeatureSegment.ALL]: [Feature.ORDER],\n};\n","export const MODALS = {\n\tADD_UPDATE_NOTES: \"ADD_UPDATE_NOTES\",\n\tAUTH: \"AUTH\",\n\tADD_UPDATE_ADDRESS: \"ADD_UPDATE_ADDRESS\",\n};\n\nexport const SUPPORTED_LOCALES = [\"en\", \"az\", \"nl\", \"et\", \"tr\", \"ru\"];\nexport const DEFAULT_LANGUAGE = \"en\";\nexport const DEFAULT_CURRENCY = \"AZN\";\nexport const SUPPORTED_COUNTRIES = [\n\t{\n\t\tname: \"Azerbaijan\",\n\t\tcode: \"AZ\",\n\t\tphoneCode: \"+994\",\n\t},\n];\n"],"names":["GOAL_BASE_NAME","CATEGORY_SELECTED","CATEGORY_SCROLLED","PRODUCT_DETAILS","PRODUCT_ADD_ORDER","PRODUCT_VIEW_CHANGED","GOALS","Feature","FeatureSegment","FEATURES_LIST","ALPHA","BETA","ALL","ORDER","ADD_UPDATE_NOTES","AUTH","ADD_UPDATE_ADDRESS","name","code","phoneCode"],"mappings":"aAAA,MAAMA,EAAiB,eAEVC,EAAoB,GAAGD,oBACvBE,EAAoB,GAAGF,oBACvBG,EAAkB,GAAGH,oBACrBI,EAAoB,GAAGJ,qBACvBK,EAAuB,GAAGL,yBAE1BM,EAAQ,CAACL,EAAmBC,EAAmBC,EAAiBC,GCR7E,IAAYG,EAGAC,GAHZ,SAAYD,GACXA,EAAA,MAAA,eACA,CAFD,CAAYA,IAAAA,EAEX,CAAA,IACD,SAAYC,GACXA,EAAA,MAAA,QACAA,EAAA,KAAA,OACAA,EAAA,IAAA,KACA,CAJD,CAAYA,IAAAA,EAIX,CAAA,ICLY,MAAAC,EAAwD,CACpE,CAACD,EAAeE,OAAQ,GACxB,CAACF,EAAeG,MAAO,GACvB,CAACH,EAAeI,KAAM,CAACL,EAAQM,yFCGA,+BADA,4DAPV,CACrBC,iBAAkB,mBAClBC,KAAM,OACNC,mBAAoB,uIAMc,CAClC,CACCC,KAAM,aACNC,KAAM,KACNC,UAAW,mCAPoB,CAAC,KAAM,KAAM,KAAM,KAAM,KAAM"}
@@ -0,0 +1,17 @@
1
+ export declare enum PlanType {
2
+ APPETIZER = "appetizer",
3
+ MAIN_COURSE = "mainCourse",
4
+ CHEFS_SPECIAL = "chefsSpecial"
5
+ }
6
+ export interface PricingPlan {
7
+ title: string;
8
+ price: {
9
+ monthly: number;
10
+ annually: number;
11
+ };
12
+ discountedPrice?: number;
13
+ }
14
+ export interface PricingPlans {
15
+ [key: string]: PricingPlan;
16
+ }
17
+ export type PricingInterval = "monthly" | "annually";
@@ -0,0 +1,4 @@
1
+ import { Feature, FeatureSegment } from "./models";
2
+ export declare const FEATURES_LIST: {
3
+ [key in FeatureSegment]: Feature[];
4
+ };
@@ -0,0 +1,8 @@
1
+ export declare enum Feature {
2
+ ORDER = "feature_order"
3
+ }
4
+ export declare enum FeatureSegment {
5
+ ALPHA = "ALPHA",
6
+ BETA = "BETA",
7
+ ALL = "ALL"
8
+ }
@@ -0,0 +1,13 @@
1
+ export declare const MODALS: {
2
+ ADD_UPDATE_NOTES: string;
3
+ AUTH: string;
4
+ ADD_UPDATE_ADDRESS: string;
5
+ };
6
+ export declare const SUPPORTED_LOCALES: string[];
7
+ export declare const DEFAULT_LANGUAGE = "en";
8
+ export declare const DEFAULT_CURRENCY = "AZN";
9
+ export declare const SUPPORTED_COUNTRIES: {
10
+ name: string;
11
+ code: string;
12
+ phoneCode: string;
13
+ }[];
@@ -7,4 +7,5 @@ export * from "../modules/product/utils";
7
7
  export * from "../modules/order/utils";
8
8
  export * from "../modules/customer/utils";
9
9
  export * from "../modules/feature/utils";
10
+ export * from "../modules/view/utils";
10
11
  export * from "./url";
@@ -1,2 +1,2 @@
1
- import{isEmpty as t,priceFormatter as r,sortNumbers as n,checkIsValidEmail as o,getQueryParam as e}from"@sorocraft/js-utils";import{HourglassHalf as i,FileCheck as a,Chef as l,Delivery as s,BagCheck as d,Check as u}from"@sorocraft/ui/icons";const c=(t,r)=>{var n,o;return(null===(o=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.find)||void 0===o?void 0:o.call(n,(t=>t.language===r)))||{}},E=(r,n,o)=>{var e;const i=null===(e=null==n?void 0:n.find)||void 0===e?void 0:e.call(n,(({id:t})=>t===r));if(t(i))return"";const{name:a}=c(i,o);return a},v=(t=0,r=1,n=0)=>t*r*(1+n/100),A="https://images.restaround.co",p=t=>t?t.includes("base64")||t.startsWith("https://")?t:`${A}/${t}`:"",R=t=>t?t.includes("base64")||t.startsWith("https://")?t:`${A}/${t}`:"https://images.restaround.co/no-photo-128.webp",f=t=>t?t.includes("base64")||t.startsWith("https://")?t:`${A}/${t}`:"https://images.restaround.co/restaround-doodle.webp",I="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",L=(t,r,n)=>I.charAt(t>>2)+I.charAt((3&t)<<4|r>>4)+I.charAt((15&r)<<2|n>>6)+I.charAt(63&n),D=(t,r,n)=>`data:image/gif;base64,R0lGODlhAQABAPAA${L(0,t,r)+L(n,255,255)}/yH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==`,P=(t,r)=>{const n=r.reduce(((t,r)=>{if(!r.visible)return t;const n=Number(r.categoryId);return t[n]||(t[n]=[]),t[n].push(r),t}),{});return t.map((t=>Object.assign(Object.assign({},t),{products:n[Number(t.id)]||[]}))).filter((t=>{var r;return(null===(r=null==t?void 0:t.products)||void 0===r?void 0:r.length)>0}))},T=(t,r)=>{var n,o;return(null===(o=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.find)||void 0===o?void 0:o.call(n,(t=>t.language===r)))||{}},m=(t,r)=>{var n,o;return(null===(o=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.find)||void 0===o?void 0:o.call(n,(t=>t.language===r)))||{}},N=({option:t,currency:n="USD",language:o="en"})=>{const{price:e}=t||{};return{totalPrice:e,formattedTotalPrice:r(e,n,o)}},g=(t,r)=>{var n;return(null===(n=((null==t?void 0:t.options)||[]).find((({id:t})=>t===r)))||void 0===n?void 0:n.price)||0},h=(t,r,n)=>{var o;if(Array.isArray(r))return t.filter((({id:t})=>r.includes(t))).map((({translations:t})=>{var r;return(null===(r=t.find((t=>t.language===n)))||void 0===r?void 0:r.title)||""})).filter(Boolean).join(", ");{const e=t.find((({id:t})=>t===r));return(null===(o=null==e?void 0:e.translations.find((t=>t.language===n)))||void 0===o?void 0:o.title)||""}},O=(t,r)=>{var n,o,e;return(null===(e=null===(o=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.find)||void 0===o?void 0:o.call(n,(t=>t.language===r)))||void 0===e?void 0:e.title)||""};var b;!function(t){t.SINGLE="SINGLE",t.MULTIPLE="MULTIPLE"}(b||(b={}));const y=(t,r)=>{var n,o;return(null===(o=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.find)||void 0===o?void 0:o.call(n,(t=>t.language===r)))||{}},C=(t,r=1)=>{const{price:n=0,vat:o=0}=t||{};return v(n,r,o)},V=(t,n,o,e=1)=>{const i=C(t,e);return{totalPrice:i,formattedTotalPrice:r(i,n,o)}},$=(t,r)=>{var n,o;return(null===(o=null===(n=null==t?void 0:t.variants)||void 0===n?void 0:n.find)||void 0===o?void 0:o.call(n,(t=>t.id===r)))||{}},M=(t,r={},n)=>((null==t?void 0:t.addons)||[]).filter((t=>Object.prototype.hasOwnProperty.call(r,t.id))).reduce(((t,n)=>{const{id:o,selectType:e}=n;if(e===b.SINGLE){const e=r[o];return t+g(n,e)}return t+(r[o]||[]).reduce(((t,r)=>t+g(n,r)),0)}),0)*n,j=(t,r,n)=>{const o=$(r,t),{vat:e}=r||{},{price:i}=o||{};return v(i,n,e)},U=({variantId:t,currency:n="USD",language:o="en",product:e,quantity:i=1})=>{const a=j(t,e,i);return{totalPrice:a,formattedTotalPrice:r(a,n,o)}},_=(t,r)=>{var n,o;return(null===(o=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.find)||void 0===o?void 0:o.call(n,(t=>t.language===r)))||{}},B=({product:r,variantId:n,quantity:o=1,selectedAddons:e,noVat:i=!1})=>{if(t(r))return{price:0,optionsPrice:0,total:0};const a=Object.assign(Object.assign({},r),{vat:i?0:r.vat}),l=M(a,e,o),s=n?j(n,a,o):C(a,o);return{price:s,optionsPrice:l,total:s+l}},G=({product:t,variantId:n,quantity:o=1,currency:e,language:i,selectedAddons:a,noVat:l=!1})=>{const{total:s}=B({product:t,variantId:n,quantity:o,selectedAddons:a,noVat:l});return{totalPrice:s,formattedTotalPrice:r(s,e,i)}},F=(t,r)=>((null==t?void 0:t.addons)||[]).find((({id:t})=>t===r))||{};var H,S,W,x,Y;!function(t){t.DINE_IN="DINE_IN",t.PICK_UP="PICK_UP",t.DELIVERY="DELIVERY"}(H||(H={})),function(t){t.DRAFT="DRAFT",t.PENDING="PENDING",t.CONFIRMED="CONFIRMED",t.PREPARING="PREPARING",t.READY="READY",t.OUT_FOR_DELIVERY="OUT_FOR_DELIVERY",t.DELIVERED="DELIVERED",t.COMPLETED="COMPLETED",t.CANCELLED="CANCELLED",t.FAILED="FAILED"}(S||(S={})),function(t){t.PENDING="PENDING",t.PREPARING="PREPARING",t.READY="READY",t.SERVED="SERVED"}(W||(W={})),function(t){t.CASH="CASH",t.CARD="CARD",t.WALLET="WALLET",t.TERMINAL="TERMINAL"}(x||(x={})),function(t){t.CART="CART",t.DETAILS="DETAILS",t.COMPLETED="COMPLETED"}(Y||(Y={}));const w=t=>t.options.reduce(((t,r)=>t+r.price),0);function q(t=[],r=1){return r*t.reduce(((t,r)=>t+w(r)),0)}const Q=(t,n,o)=>{let e=0,i=0;for(const r of t.items){const n=(a=r.price,l=r.quantity,s=r.addons,l*a+q(s,l));e+=n,void 0===t.vat&&r.vat&&(i+=n*r.vat/100)}var a,l,s;void 0!==t.vat&&(i=e*t.vat/100);const d=e+i;return{totalWithoutTax:e,totalWithoutTaxFormatted:r(e,n,o),totalTax:i,totalTaxFormatted:r(i,n,o),totalWithTax:d,totalWithTaxFormatted:r(d,n,o)}},z=(t,r,o)=>{if(!t)throw new Error("Product ID is required");let e=`${t}`;r&&(e+=`-${r}`);const i=Object.entries(o||{}).map((([t,r])=>{if(!t||!r)return null;const o=Array.isArray(r)?n(r).filter(Boolean).join("-"):`${r}`;return o?`${t}-${o}`:null})).filter(Boolean).join("-");return i&&(e+=`-${i}`),e},K=t=>{var r;const{price:n,variant:o,addons:e,quantity:i,vat:a}=t||{},l=null!==(r=null==o?void 0:o.price)&&void 0!==r?r:n,s=l+q(e,1),d=l*(a/100),u=s+d;return{totalGross:u*i,totalNet:s*i,totalTax:d*i,itemGrossPrice:u,itemNetPrice:s,itemTax:d}},k=t=>{const r={};for(const{addonId:n,options:o=[]}of t.addons||[]){const t=o.map((({optionId:t})=>t));r[n]=1===t.length?t[0]:t}return r},J=t=>{switch(t){case S.COMPLETED:return u;case S.DELIVERED:return d;case S.OUT_FOR_DELIVERY:return s;case S.PREPARING:return l;case S.CONFIRMED:return a;case S.PENDING:default:return i}},X=(r=[],n={})=>Object.entries(n).map((([n,o])=>{const e=Number(n),i=Array.isArray(o)?o:[o],a=r.find((t=>t.id===e));if(t(a))return{addonId:e,options:[]};const l=(a.options||[]).filter((t=>i.includes(t.id))).map((t=>({optionId:t.id,price:t.price})));return{addonId:e,options:l}})),Z={994:t=>{const r=["50","51","10","55","99","70","77","60"];return new RegExp(`^(${r.join("|")})\\d{7}$`).test(t)?{isValid:!0}:{isValid:!1,error:`Azerbaijani numbers must be 9 digits and start with ${r.join(", ")}`}},31:t=>/^\d{9}$/.test(t)?{isValid:!0}:{isValid:!1,error:"Dutch numbers must be exactly 9 digits"}};function tt(t){if(!t)return{isValid:!1,error:"FIELD_REQUIRED"};const r=t.replace(/\D/g,""),n=r.startsWith("994")?"994":r.startsWith("31")?"31":null;if(!n)return{isValid:!1,error:"Unsupported country code"};const o=r.slice(n.length);return(0,Z[n])(o)}var rt,nt;!function(t){t.PHONE="PHONE",t.OTP="OTP",t.EMAIL="EMAIL"}(rt||(rt={})),function(t){t.HOME="HOME",t.WORK="WORK",t.TRAVEL="TRAVEL"}(nt||(nt={}));const ot=t=>`${t.countryCode}${t.phoneNumber}`.replaceAll("+",""),et=(t,r)=>{const n={},{phoneNumber:e,email:i,otp:a}=t||{};switch(r){case rt.PHONE:{const{isValid:t,error:r}=tt(e);t||(n.phoneNumber=r);break}case rt.OTP:{const{isValid:t,error:r}=tt(e);t||(n.phoneNumber=r),a&&6===a.length||(n.otp="Invalid OTP");break}case rt.EMAIL:i&&o(i)||(n.email="Invalid Email Address")}return n},it=t=>{const r={},{countryCode:n,cityName:o,street:e,houseNumber:i}=t||{};return n||(r.countryCode="COUNTRY_REQUIRED"),o||(r.cityName="CITY_REQUIRED"),e||(r.street="STREET_REQUIRED"),i||(r.houseNumber="STREET_NUMBER_REQUIRED"),r},at=t=>(t||[]).filter(Boolean).join(", "),lt=(t,r,n)=>[t,[r,n].filter(Boolean).join("/")].filter(Boolean).join(" ");var st,dt;!function(t){t.ORDER="feature_order"}(st||(st={})),function(t){t.ALPHA="ALPHA",t.BETA="BETA",t.ALL="ALL"}(dt||(dt={}));const ut={[dt.ALPHA]:[],[dt.BETA]:[],[dt.ALL]:[st.ORDER]},ct=(t,r)=>{if("1"===e(t))return!0;return(r===dt.ALPHA?[dt.ALPHA,dt.BETA,dt.ALL]:r===dt.BETA?[dt.BETA,dt.ALL]:[dt.ALL]).some((r=>{var n;return null===(n=ut[r])||void 0===n?void 0:n.includes(t)}))},Et="restaround.co",vt=[Et,"restaround.az","restaround.ee","restaround.nl"],At=(t,r)=>{const n=vt.includes(t)?t:Et;return{url:`https://${n}/${r||"en"}`,domain:n}},pt=t=>"az"===t?"az":"co",Rt=(t,r)=>`https://app.restaround.${pt(t)}/auth/register?lang=${t}&utm_source=${r}`;export{A as IMAGE_BASE_URL,X as buildSelectedAddonsPayload,w as calculatSingleAddonTotalPrice,q as calculateTotalAddonPrice,v as calculateTotalPrice,lt as formatAddressLine,at as formatCityLine,z as generateOrderItemsId,g as getAddonOptionRawPrice,m as getAddonOptionTranslation,O as getAddonTitle,T as getAddonTranslation,At as getBaseUrl,E as getCategoryNameById,c as getCategoryTranslation,f as getCoverImageSource,p as getImageSource,ct as getIsFeatureActive,R as getLogoImageSource,N as getOptionPrice,h as getOptionTitles,K as getOrderItemPrice,Q as getOrderPrice,F as getProductAddon,G as getProductOrderPrice,B as getProductOrderRawPrice,V as getProductPrice,C as getProductRawPrice,y as getProductTranslation,$ as getProductVariant,U as getProductVariantPrice,j as getProductVariantRawPrice,_ as getProductVariantTranslation,Rt as getRegisterUrl,k as getSelectedAddonsFromOrderItems,M as getSelectedOptionsTotalPrice,J as getStatusIcon,pt as getTLD,P as prepareCategoryAndProductMap,ot as preparePhoneNumber,D as rgbDataURL,it as validateAddressForm,et as validateForm};
1
+ import{isEmpty as t,priceFormatter as r,sortNumbers as n,checkIsValidEmail as o,getQueryParam as e}from"@sorocraft/js-utils";import{HourglassHalf as i,FileCheck as a,Chef as l,Delivery as s,BagCheck as d,Check as u}from"@sorocraft/ui/icons";const c=(t,r)=>{var n,o;return(null===(o=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.find)||void 0===o?void 0:o.call(n,(t=>t.language===r)))||{}},E=(r,n,o)=>{var e;const i=null===(e=null==n?void 0:n.find)||void 0===e?void 0:e.call(n,(({id:t})=>t===r));if(t(i))return"";const{name:a}=c(i,o);return a},v=(t=0,r=1,n=0)=>t*r*(1+n/100),A="https://images.restaround.co",p=t=>t?t.includes("base64")||t.startsWith("https://")?t:`${A}/${t}`:"",R=t=>t?t.includes("base64")||t.startsWith("https://")?t:`${A}/${t}`:"https://images.restaround.co/no-photo-128.webp",f=t=>t?t.includes("base64")||t.startsWith("https://")?t:`${A}/${t}`:"https://images.restaround.co/restaround-doodle.webp",I="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",L=(t,r,n)=>I.charAt(t>>2)+I.charAt((3&t)<<4|r>>4)+I.charAt((15&r)<<2|n>>6)+I.charAt(63&n),D=(t,r,n)=>`data:image/gif;base64,R0lGODlhAQABAPAA${L(0,t,r)+L(n,255,255)}/yH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==`,P=(t,r)=>{const n=r.reduce(((t,r)=>{if(!r.visible)return t;const n=Number(r.categoryId);return t[n]||(t[n]=[]),t[n].push(r),t}),{});return t.map((t=>Object.assign(Object.assign({},t),{products:n[Number(t.id)]||[]}))).filter((t=>{var r;return(null===(r=null==t?void 0:t.products)||void 0===r?void 0:r.length)>0}))},T=(t,r)=>{var n,o;return(null===(o=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.find)||void 0===o?void 0:o.call(n,(t=>t.language===r)))||{}},m=(t,r)=>{var n,o;return(null===(o=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.find)||void 0===o?void 0:o.call(n,(t=>t.language===r)))||{}},N=({option:t,currency:n="USD",language:o="en"})=>{const{price:e}=t||{};return{totalPrice:e,formattedTotalPrice:r(e,n,o)}},g=(t,r)=>{var n;return(null===(n=((null==t?void 0:t.options)||[]).find((({id:t})=>t===r)))||void 0===n?void 0:n.price)||0},h=(t,r,n)=>{var o;if(Array.isArray(r))return t.filter((({id:t})=>r.includes(t))).map((({translations:t})=>{var r;return(null===(r=t.find((t=>t.language===n)))||void 0===r?void 0:r.title)||""})).filter(Boolean).join(", ");{const e=t.find((({id:t})=>t===r));return(null===(o=null==e?void 0:e.translations.find((t=>t.language===n)))||void 0===o?void 0:o.title)||""}},O=(t,r)=>{var n,o,e;return(null===(e=null===(o=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.find)||void 0===o?void 0:o.call(n,(t=>t.language===r)))||void 0===e?void 0:e.title)||""};var b;!function(t){t.SINGLE="SINGLE",t.MULTIPLE="MULTIPLE"}(b||(b={}));const y=(t,r)=>{var n,o;return(null===(o=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.find)||void 0===o?void 0:o.call(n,(t=>t.language===r)))||{}},C=(t,r=1)=>{const{price:n=0,vat:o=0}=t||{};return v(n,r,o)},V=(t,n,o,e=1)=>{const i=C(t,e);return{totalPrice:i,formattedTotalPrice:r(i,n,o)}},$=(t,r)=>{var n,o;return(null===(o=null===(n=null==t?void 0:t.variants)||void 0===n?void 0:n.find)||void 0===o?void 0:o.call(n,(t=>t.id===r)))||{}},M=(t,r={},n)=>((null==t?void 0:t.addons)||[]).filter((t=>Object.prototype.hasOwnProperty.call(r,t.id))).reduce(((t,n)=>{const{id:o,selectType:e}=n;if(e===b.SINGLE){const e=r[o];return t+g(n,e)}return t+(r[o]||[]).reduce(((t,r)=>t+g(n,r)),0)}),0)*n,j=(t,r,n)=>{const o=$(r,t),{vat:e}=r||{},{price:i}=o||{};return v(i,n,e)},U=({variantId:t,currency:n="USD",language:o="en",product:e,quantity:i=1})=>{const a=j(t,e,i);return{totalPrice:a,formattedTotalPrice:r(a,n,o)}},_=(t,r)=>{var n,o;return(null===(o=null===(n=null==t?void 0:t.translations)||void 0===n?void 0:n.find)||void 0===o?void 0:o.call(n,(t=>t.language===r)))||{}},B=({product:r,variantId:n,quantity:o=1,selectedAddons:e,noVat:i=!1})=>{if(t(r))return{price:0,optionsPrice:0,total:0};const a=Object.assign(Object.assign({},r),{vat:i?0:r.vat}),l=M(a,e,o),s=n?j(n,a,o):C(a,o);return{price:s,optionsPrice:l,total:s+l}},G=({product:t,variantId:n,quantity:o=1,currency:e,language:i,selectedAddons:a,noVat:l=!1})=>{const{total:s}=B({product:t,variantId:n,quantity:o,selectedAddons:a,noVat:l});return{totalPrice:s,formattedTotalPrice:r(s,e,i)}},F=(t,r)=>((null==t?void 0:t.addons)||[]).find((({id:t})=>t===r))||{};var H,S,W,x,Y;!function(t){t.DINE_IN="DINE_IN",t.PICK_UP="PICK_UP",t.DELIVERY="DELIVERY"}(H||(H={})),function(t){t.DRAFT="DRAFT",t.PENDING="PENDING",t.CONFIRMED="CONFIRMED",t.PREPARING="PREPARING",t.READY="READY",t.OUT_FOR_DELIVERY="OUT_FOR_DELIVERY",t.DELIVERED="DELIVERED",t.COMPLETED="COMPLETED",t.CANCELLED="CANCELLED",t.FAILED="FAILED"}(S||(S={})),function(t){t.PENDING="PENDING",t.PREPARING="PREPARING",t.READY="READY",t.SERVED="SERVED"}(W||(W={})),function(t){t.CASH="CASH",t.CARD="CARD",t.WALLET="WALLET",t.TERMINAL="TERMINAL"}(x||(x={})),function(t){t.CART="CART",t.DETAILS="DETAILS",t.COMPLETED="COMPLETED"}(Y||(Y={}));const w=t=>t.options.reduce(((t,r)=>t+r.price),0);function q(t=[],r=1){return r*t.reduce(((t,r)=>t+w(r)),0)}const Q=(t,n,o)=>{let e=0,i=0;for(const r of t.items){const n=(a=r.price,l=r.quantity,s=r.addons,l*a+q(s,l));e+=n,void 0===t.vat&&r.vat&&(i+=n*r.vat/100)}var a,l,s;void 0!==t.vat&&(i=e*t.vat/100);const d=e+i;return{totalWithoutTax:e,totalWithoutTaxFormatted:r(e,n,o),totalTax:i,totalTaxFormatted:r(i,n,o),totalWithTax:d,totalWithTaxFormatted:r(d,n,o)}},z=(t,r,o)=>{if(!t)throw new Error("Product ID is required");let e=`${t}`;r&&(e+=`-${r}`);const i=Object.entries(o||{}).map((([t,r])=>{if(!t||!r)return null;const o=Array.isArray(r)?n(r).filter(Boolean).join("-"):`${r}`;return o?`${t}-${o}`:null})).filter(Boolean).join("-");return i&&(e+=`-${i}`),e},K=t=>{var r;const{price:n,variant:o,addons:e,quantity:i,vat:a}=t||{},l=null!==(r=null==o?void 0:o.price)&&void 0!==r?r:n,s=l+q(e,1),d=l*(a/100),u=s+d;return{totalGross:u*i,totalNet:s*i,totalTax:d*i,itemGrossPrice:u,itemNetPrice:s,itemTax:d}},k=t=>{const r={};for(const{addonId:n,options:o=[]}of t.addons||[]){const t=o.map((({optionId:t})=>t));r[n]=1===t.length?t[0]:t}return r},J=t=>{switch(t){case S.COMPLETED:return u;case S.DELIVERED:return d;case S.OUT_FOR_DELIVERY:return s;case S.PREPARING:return l;case S.CONFIRMED:return a;case S.PENDING:default:return i}},X=(r=[],n={})=>Object.entries(n).map((([n,o])=>{const e=Number(n),i=Array.isArray(o)?o:[o],a=r.find((t=>t.id===e));if(t(a))return{addonId:e,options:[]};const l=(a.options||[]).filter((t=>i.includes(t.id))).map((t=>({optionId:t.id,price:t.price})));return{addonId:e,options:l}})),Z={994:t=>{const r=["50","51","10","55","99","70","77","60"];return new RegExp(`^(${r.join("|")})\\d{7}$`).test(t)?{isValid:!0}:{isValid:!1,error:`Azerbaijani numbers must be 9 digits and start with ${r.join(", ")}`}},31:t=>/^\d{9}$/.test(t)?{isValid:!0}:{isValid:!1,error:"Dutch numbers must be exactly 9 digits"}};function tt(t){if(!t)return{isValid:!1,error:"FIELD_REQUIRED"};const r=t.replace(/\D/g,""),n=r.startsWith("994")?"994":r.startsWith("31")?"31":null;if(!n)return{isValid:!1,error:"Unsupported country code"};const o=r.slice(n.length);return(0,Z[n])(o)}var rt,nt;!function(t){t.PHONE="PHONE",t.OTP="OTP",t.EMAIL="EMAIL"}(rt||(rt={})),function(t){t.HOME="HOME",t.WORK="WORK",t.TRAVEL="TRAVEL"}(nt||(nt={}));const ot=t=>`${t.countryCode}${t.phoneNumber}`.replaceAll("+",""),et=(t,r)=>{const n={},{phoneNumber:e,email:i,otp:a}=t||{};switch(r){case rt.PHONE:{const{isValid:t,error:r}=tt(e);t||(n.phoneNumber=r);break}case rt.OTP:{const{isValid:t,error:r}=tt(e);t||(n.phoneNumber=r),a&&6===a.length||(n.otp="Invalid OTP");break}case rt.EMAIL:i&&o(i)||(n.email="Invalid Email Address")}return n},it=t=>{const r={},{countryCode:n,cityName:o,street:e,houseNumber:i}=t||{};return n||(r.countryCode="COUNTRY_REQUIRED"),o||(r.cityName="CITY_REQUIRED"),e||(r.street="STREET_REQUIRED"),i||(r.houseNumber="STREET_NUMBER_REQUIRED"),r},at=t=>(t||[]).filter(Boolean).join(", "),lt=(t,r,n)=>[t,[r,n].filter(Boolean).join("/")].filter(Boolean).join(" ");var st,dt;!function(t){t.ORDER="feature_order"}(st||(st={})),function(t){t.ALPHA="ALPHA",t.BETA="BETA",t.ALL="ALL"}(dt||(dt={}));const ut={[dt.ALPHA]:[],[dt.BETA]:[],[dt.ALL]:[st.ORDER]},ct=(t,r)=>{if("1"===e(t))return!0;return(r===dt.ALPHA?[dt.ALPHA,dt.BETA,dt.ALL]:r===dt.BETA?[dt.BETA,dt.ALL]:[dt.ALL]).some((r=>{var n;return null===(n=ut[r])||void 0===n?void 0:n.includes(t)}))},Et="restaround.co",vt=[Et,"restaround.az","restaround.ee","restaround.nl"],At=(t,r)=>{const n=vt.includes(t)?t:Et;return{url:`https://${n}/${r||"en"}`,domain:n}},pt=t=>"az"===t?"az":"co",Rt=(t,r)=>`https://app.restaround.${pt(t)}/auth/register?lang=${t}&utm_source=${r}`;export{A as IMAGE_BASE_URL,X as buildSelectedAddonsPayload,w as calculatSingleAddonTotalPrice,q as calculateTotalAddonPrice,v as calculateTotalPrice,lt as formatAddressLine,at as formatCityLine,z as generateOrderItemsId,g as getAddonOptionRawPrice,m as getAddonOptionTranslation,O as getAddonTitle,T as getAddonTranslation,At as getBaseUrl,E as getCategoryNameById,c as getCategoryTranslation,f as getCoverImageSource,p as getImageSource,ct as getIsFeatureActive,R as getLogoImageSource,N as getOptionPrice,h as getOptionTitles,K as getOrderItemPrice,Q as getOrderPrice,F as getProductAddon,G as getProductOrderPrice,B as getProductOrderRawPrice,V as getProductPrice,C as getProductRawPrice,y as getProductTranslation,$ as getProductVariant,U as getProductVariantPrice,j as getProductVariantRawPrice,_ as getProductVariantTranslation,Rt as getRegisterUrl,k as getSelectedAddonsFromOrderItems,M as getSelectedOptionsTotalPrice,J as getStatusIcon,pt as getTLD,P as prepareCategoryAndProductMap,ot as preparePhoneNumber,D as rgbDataURL,it as validateAddressForm,et as validateForm,tt as validatePhoneNumber};
2
2
  //# sourceMappingURL=index.esm.js.map
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("@sorocraft/js-utils"),r=require("@sorocraft/ui/icons");const e=(t,r)=>{var e,o;return(null===(o=null===(e=null==t?void 0:t.translations)||void 0===e?void 0:e.find)||void 0===o?void 0:o.call(e,(t=>t.language===r)))||{}},o=(t=0,r=1,e=0)=>t*r*(1+e/100),n="https://images.restaround.co",i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=(t,r,e)=>i.charAt(t>>2)+i.charAt((3&t)<<4|r>>4)+i.charAt((15&r)<<2|e>>6)+i.charAt(63&e),s=(t,r)=>{var e;return(null===(e=((null==t?void 0:t.options)||[]).find((({id:t})=>t===r)))||void 0===e?void 0:e.price)||0};var d;!function(t){t.SINGLE="SINGLE",t.MULTIPLE="MULTIPLE"}(d||(d={}));const l=(t,r=1)=>{const{price:e=0,vat:n=0}=t||{};return o(e,r,n)},u=(t,r)=>{var e,o;return(null===(o=null===(e=null==t?void 0:t.variants)||void 0===e?void 0:e.find)||void 0===o?void 0:o.call(e,(t=>t.id===r)))||{}},c=(t,r={},e)=>((null==t?void 0:t.addons)||[]).filter((t=>Object.prototype.hasOwnProperty.call(r,t.id))).reduce(((t,e)=>{const{id:o,selectType:n}=e;if(n===d.SINGLE){const n=r[o];return t+s(e,n)}return t+(r[o]||[]).reduce(((t,r)=>t+s(e,r)),0)}),0)*e,p=(t,r,e)=>{const n=u(r,t),{vat:i}=r||{},{price:a}=n||{};return o(a,e,i)},E=({product:r,variantId:e,quantity:o=1,selectedAddons:n,noVat:i=!1})=>{if(t.isEmpty(r))return{price:0,optionsPrice:0,total:0};const a=Object.assign(Object.assign({},r),{vat:i?0:r.vat}),s=c(a,n,o),d=e?p(e,a,o):l(a,o);return{price:d,optionsPrice:s,total:d+s}};var A,v,g,P,I;!function(t){t.DINE_IN="DINE_IN",t.PICK_UP="PICK_UP",t.DELIVERY="DELIVERY"}(A||(A={})),function(t){t.DRAFT="DRAFT",t.PENDING="PENDING",t.CONFIRMED="CONFIRMED",t.PREPARING="PREPARING",t.READY="READY",t.OUT_FOR_DELIVERY="OUT_FOR_DELIVERY",t.DELIVERED="DELIVERED",t.COMPLETED="COMPLETED",t.CANCELLED="CANCELLED",t.FAILED="FAILED"}(v||(v={})),function(t){t.PENDING="PENDING",t.PREPARING="PREPARING",t.READY="READY",t.SERVED="SERVED"}(g||(g={})),function(t){t.CASH="CASH",t.CARD="CARD",t.WALLET="WALLET",t.TERMINAL="TERMINAL"}(P||(P={})),function(t){t.CART="CART",t.DETAILS="DETAILS",t.COMPLETED="COMPLETED"}(I||(I={}));const R=t=>t.options.reduce(((t,r)=>t+r.price),0);function m(t=[],r=1){return r*t.reduce(((t,r)=>t+R(r)),0)}const f={994:t=>{const r=["50","51","10","55","99","70","77","60"];return new RegExp(`^(${r.join("|")})\\d{7}$`).test(t)?{isValid:!0}:{isValid:!1,error:`Azerbaijani numbers must be 9 digits and start with ${r.join(", ")}`}},31:t=>/^\d{9}$/.test(t)?{isValid:!0}:{isValid:!1,error:"Dutch numbers must be exactly 9 digits"}};function L(t){if(!t)return{isValid:!1,error:"FIELD_REQUIRED"};const r=t.replace(/\D/g,""),e=r.startsWith("994")?"994":r.startsWith("31")?"31":null;if(!e)return{isValid:!1,error:"Unsupported country code"};const o=r.slice(e.length);return(0,f[e])(o)}var T,D;!function(t){t.PHONE="PHONE",t.OTP="OTP",t.EMAIL="EMAIL"}(T||(T={})),function(t){t.HOME="HOME",t.WORK="WORK",t.TRAVEL="TRAVEL"}(D||(D={}));var x,N;!function(t){t.ORDER="feature_order"}(x||(x={})),function(t){t.ALPHA="ALPHA",t.BETA="BETA",t.ALL="ALL"}(N||(N={}));const O={[N.ALPHA]:[],[N.BETA]:[],[N.ALL]:[x.ORDER]},h="restaround.co",y=[h,"restaround.az","restaround.ee","restaround.nl"],C=t=>"az"===t?"az":"co";exports.IMAGE_BASE_URL=n,exports.buildSelectedAddonsPayload=(r=[],e={})=>Object.entries(e).map((([e,o])=>{const n=Number(e),i=Array.isArray(o)?o:[o],a=r.find((t=>t.id===n));if(t.isEmpty(a))return{addonId:n,options:[]};const s=(a.options||[]).filter((t=>i.includes(t.id))).map((t=>({optionId:t.id,price:t.price})));return{addonId:n,options:s}})),exports.calculatSingleAddonTotalPrice=R,exports.calculateTotalAddonPrice=m,exports.calculateTotalPrice=o,exports.formatAddressLine=(t,r,e)=>[t,[r,e].filter(Boolean).join("/")].filter(Boolean).join(" "),exports.formatCityLine=t=>(t||[]).filter(Boolean).join(", "),exports.generateOrderItemsId=(r,e,o)=>{if(!r)throw new Error("Product ID is required");let n=`${r}`;e&&(n+=`-${e}`);const i=Object.entries(o||{}).map((([r,e])=>{if(!r||!e)return null;const o=Array.isArray(e)?t.sortNumbers(e).filter(Boolean).join("-"):`${e}`;return o?`${r}-${o}`:null})).filter(Boolean).join("-");return i&&(n+=`-${i}`),n},exports.getAddonOptionRawPrice=s,exports.getAddonOptionTranslation=(t,r)=>{var e,o;return(null===(o=null===(e=null==t?void 0:t.translations)||void 0===e?void 0:e.find)||void 0===o?void 0:o.call(e,(t=>t.language===r)))||{}},exports.getAddonTitle=(t,r)=>{var e,o,n;return(null===(n=null===(o=null===(e=null==t?void 0:t.translations)||void 0===e?void 0:e.find)||void 0===o?void 0:o.call(e,(t=>t.language===r)))||void 0===n?void 0:n.title)||""},exports.getAddonTranslation=(t,r)=>{var e,o;return(null===(o=null===(e=null==t?void 0:t.translations)||void 0===e?void 0:e.find)||void 0===o?void 0:o.call(e,(t=>t.language===r)))||{}},exports.getBaseUrl=(t,r)=>{const e=y.includes(t)?t:h;return{url:`https://${e}/${r||"en"}`,domain:e}},exports.getCategoryNameById=(r,o,n)=>{var i;const a=null===(i=null==o?void 0:o.find)||void 0===i?void 0:i.call(o,(({id:t})=>t===r));if(t.isEmpty(a))return"";const{name:s}=e(a,n);return s},exports.getCategoryTranslation=e,exports.getCoverImageSource=t=>t?t.includes("base64")||t.startsWith("https://")?t:`${n}/${t}`:"https://images.restaround.co/restaround-doodle.webp",exports.getImageSource=t=>t?t.includes("base64")||t.startsWith("https://")?t:`${n}/${t}`:"",exports.getIsFeatureActive=(r,e)=>{if("1"===t.getQueryParam(r))return!0;return(e===N.ALPHA?[N.ALPHA,N.BETA,N.ALL]:e===N.BETA?[N.BETA,N.ALL]:[N.ALL]).some((t=>{var e;return null===(e=O[t])||void 0===e?void 0:e.includes(r)}))},exports.getLogoImageSource=t=>t?t.includes("base64")||t.startsWith("https://")?t:`${n}/${t}`:"https://images.restaround.co/no-photo-128.webp",exports.getOptionPrice=({option:r,currency:e="USD",language:o="en"})=>{const{price:n}=r||{};return{totalPrice:n,formattedTotalPrice:t.priceFormatter(n,e,o)}},exports.getOptionTitles=(t,r,e)=>{var o;if(Array.isArray(r))return t.filter((({id:t})=>r.includes(t))).map((({translations:t})=>{var r;return(null===(r=t.find((t=>t.language===e)))||void 0===r?void 0:r.title)||""})).filter(Boolean).join(", ");{const n=t.find((({id:t})=>t===r));return(null===(o=null==n?void 0:n.translations.find((t=>t.language===e)))||void 0===o?void 0:o.title)||""}},exports.getOrderItemPrice=t=>{var r;const{price:e,variant:o,addons:n,quantity:i,vat:a}=t||{},s=null!==(r=null==o?void 0:o.price)&&void 0!==r?r:e,d=s+m(n,1),l=s*(a/100),u=d+l;return{totalGross:u*i,totalNet:d*i,totalTax:l*i,itemGrossPrice:u,itemNetPrice:d,itemTax:l}},exports.getOrderPrice=(r,e,o)=>{let n=0,i=0;for(const t of r.items){const e=(a=t.price,s=t.quantity,d=t.addons,s*a+m(d,s));n+=e,void 0===r.vat&&t.vat&&(i+=e*t.vat/100)}var a,s,d;void 0!==r.vat&&(i=n*r.vat/100);const l=n+i;return{totalWithoutTax:n,totalWithoutTaxFormatted:t.priceFormatter(n,e,o),totalTax:i,totalTaxFormatted:t.priceFormatter(i,e,o),totalWithTax:l,totalWithTaxFormatted:t.priceFormatter(l,e,o)}},exports.getProductAddon=(t,r)=>((null==t?void 0:t.addons)||[]).find((({id:t})=>t===r))||{},exports.getProductOrderPrice=({product:r,variantId:e,quantity:o=1,currency:n,language:i,selectedAddons:a,noVat:s=!1})=>{const{total:d}=E({product:r,variantId:e,quantity:o,selectedAddons:a,noVat:s});return{totalPrice:d,formattedTotalPrice:t.priceFormatter(d,n,i)}},exports.getProductOrderRawPrice=E,exports.getProductPrice=(r,e,o,n=1)=>{const i=l(r,n);return{totalPrice:i,formattedTotalPrice:t.priceFormatter(i,e,o)}},exports.getProductRawPrice=l,exports.getProductTranslation=(t,r)=>{var e,o;return(null===(o=null===(e=null==t?void 0:t.translations)||void 0===e?void 0:e.find)||void 0===o?void 0:o.call(e,(t=>t.language===r)))||{}},exports.getProductVariant=u,exports.getProductVariantPrice=({variantId:r,currency:e="USD",language:o="en",product:n,quantity:i=1})=>{const a=p(r,n,i);return{totalPrice:a,formattedTotalPrice:t.priceFormatter(a,e,o)}},exports.getProductVariantRawPrice=p,exports.getProductVariantTranslation=(t,r)=>{var e,o;return(null===(o=null===(e=null==t?void 0:t.translations)||void 0===e?void 0:e.find)||void 0===o?void 0:o.call(e,(t=>t.language===r)))||{}},exports.getRegisterUrl=(t,r)=>`https://app.restaround.${C(t)}/auth/register?lang=${t}&utm_source=${r}`,exports.getSelectedAddonsFromOrderItems=t=>{const r={};for(const{addonId:e,options:o=[]}of t.addons||[]){const t=o.map((({optionId:t})=>t));r[e]=1===t.length?t[0]:t}return r},exports.getSelectedOptionsTotalPrice=c,exports.getStatusIcon=t=>{switch(t){case v.COMPLETED:return r.Check;case v.DELIVERED:return r.BagCheck;case v.OUT_FOR_DELIVERY:return r.Delivery;case v.PREPARING:return r.Chef;case v.CONFIRMED:return r.FileCheck;case v.PENDING:default:return r.HourglassHalf}},exports.getTLD=C,exports.prepareCategoryAndProductMap=(t,r)=>{const e=r.reduce(((t,r)=>{if(!r.visible)return t;const e=Number(r.categoryId);return t[e]||(t[e]=[]),t[e].push(r),t}),{});return t.map((t=>Object.assign(Object.assign({},t),{products:e[Number(t.id)]||[]}))).filter((t=>{var r;return(null===(r=null==t?void 0:t.products)||void 0===r?void 0:r.length)>0}))},exports.preparePhoneNumber=t=>`${t.countryCode}${t.phoneNumber}`.replaceAll("+",""),exports.rgbDataURL=(t,r,e)=>`data:image/gif;base64,R0lGODlhAQABAPAA${a(0,t,r)+a(e,255,255)}/yH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==`,exports.validateAddressForm=t=>{const r={},{countryCode:e,cityName:o,street:n,houseNumber:i}=t||{};return e||(r.countryCode="COUNTRY_REQUIRED"),o||(r.cityName="CITY_REQUIRED"),n||(r.street="STREET_REQUIRED"),i||(r.houseNumber="STREET_NUMBER_REQUIRED"),r},exports.validateForm=(r,e)=>{const o={},{phoneNumber:n,email:i,otp:a}=r||{};switch(e){case T.PHONE:{const{isValid:t,error:r}=L(n);t||(o.phoneNumber=r);break}case T.OTP:{const{isValid:t,error:r}=L(n);t||(o.phoneNumber=r),a&&6===a.length||(o.otp="Invalid OTP");break}case T.EMAIL:i&&t.checkIsValidEmail(i)||(o.email="Invalid Email Address")}return o};
1
+ "use strict";var t=require("@sorocraft/js-utils"),r=require("@sorocraft/ui/icons");const e=(t,r)=>{var e,o;return(null===(o=null===(e=null==t?void 0:t.translations)||void 0===e?void 0:e.find)||void 0===o?void 0:o.call(e,(t=>t.language===r)))||{}},o=(t=0,r=1,e=0)=>t*r*(1+e/100),n="https://images.restaround.co",i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=(t,r,e)=>i.charAt(t>>2)+i.charAt((3&t)<<4|r>>4)+i.charAt((15&r)<<2|e>>6)+i.charAt(63&e),s=(t,r)=>{var e;return(null===(e=((null==t?void 0:t.options)||[]).find((({id:t})=>t===r)))||void 0===e?void 0:e.price)||0};var d;!function(t){t.SINGLE="SINGLE",t.MULTIPLE="MULTIPLE"}(d||(d={}));const l=(t,r=1)=>{const{price:e=0,vat:n=0}=t||{};return o(e,r,n)},u=(t,r)=>{var e,o;return(null===(o=null===(e=null==t?void 0:t.variants)||void 0===e?void 0:e.find)||void 0===o?void 0:o.call(e,(t=>t.id===r)))||{}},c=(t,r={},e)=>((null==t?void 0:t.addons)||[]).filter((t=>Object.prototype.hasOwnProperty.call(r,t.id))).reduce(((t,e)=>{const{id:o,selectType:n}=e;if(n===d.SINGLE){const n=r[o];return t+s(e,n)}return t+(r[o]||[]).reduce(((t,r)=>t+s(e,r)),0)}),0)*e,p=(t,r,e)=>{const n=u(r,t),{vat:i}=r||{},{price:a}=n||{};return o(a,e,i)},E=({product:r,variantId:e,quantity:o=1,selectedAddons:n,noVat:i=!1})=>{if(t.isEmpty(r))return{price:0,optionsPrice:0,total:0};const a=Object.assign(Object.assign({},r),{vat:i?0:r.vat}),s=c(a,n,o),d=e?p(e,a,o):l(a,o);return{price:d,optionsPrice:s,total:d+s}};var A,v,g,P,I;!function(t){t.DINE_IN="DINE_IN",t.PICK_UP="PICK_UP",t.DELIVERY="DELIVERY"}(A||(A={})),function(t){t.DRAFT="DRAFT",t.PENDING="PENDING",t.CONFIRMED="CONFIRMED",t.PREPARING="PREPARING",t.READY="READY",t.OUT_FOR_DELIVERY="OUT_FOR_DELIVERY",t.DELIVERED="DELIVERED",t.COMPLETED="COMPLETED",t.CANCELLED="CANCELLED",t.FAILED="FAILED"}(v||(v={})),function(t){t.PENDING="PENDING",t.PREPARING="PREPARING",t.READY="READY",t.SERVED="SERVED"}(g||(g={})),function(t){t.CASH="CASH",t.CARD="CARD",t.WALLET="WALLET",t.TERMINAL="TERMINAL"}(P||(P={})),function(t){t.CART="CART",t.DETAILS="DETAILS",t.COMPLETED="COMPLETED"}(I||(I={}));const m=t=>t.options.reduce(((t,r)=>t+r.price),0);function R(t=[],r=1){return r*t.reduce(((t,r)=>t+m(r)),0)}const f={994:t=>{const r=["50","51","10","55","99","70","77","60"];return new RegExp(`^(${r.join("|")})\\d{7}$`).test(t)?{isValid:!0}:{isValid:!1,error:`Azerbaijani numbers must be 9 digits and start with ${r.join(", ")}`}},31:t=>/^\d{9}$/.test(t)?{isValid:!0}:{isValid:!1,error:"Dutch numbers must be exactly 9 digits"}};function L(t){if(!t)return{isValid:!1,error:"FIELD_REQUIRED"};const r=t.replace(/\D/g,""),e=r.startsWith("994")?"994":r.startsWith("31")?"31":null;if(!e)return{isValid:!1,error:"Unsupported country code"};const o=r.slice(e.length);return(0,f[e])(o)}var T,D;!function(t){t.PHONE="PHONE",t.OTP="OTP",t.EMAIL="EMAIL"}(T||(T={})),function(t){t.HOME="HOME",t.WORK="WORK",t.TRAVEL="TRAVEL"}(D||(D={}));var x,N;!function(t){t.ORDER="feature_order"}(x||(x={})),function(t){t.ALPHA="ALPHA",t.BETA="BETA",t.ALL="ALL"}(N||(N={}));const O={[N.ALPHA]:[],[N.BETA]:[],[N.ALL]:[x.ORDER]},h="restaround.co",y=[h,"restaround.az","restaround.ee","restaround.nl"],b=t=>"az"===t?"az":"co";exports.IMAGE_BASE_URL=n,exports.buildSelectedAddonsPayload=(r=[],e={})=>Object.entries(e).map((([e,o])=>{const n=Number(e),i=Array.isArray(o)?o:[o],a=r.find((t=>t.id===n));if(t.isEmpty(a))return{addonId:n,options:[]};const s=(a.options||[]).filter((t=>i.includes(t.id))).map((t=>({optionId:t.id,price:t.price})));return{addonId:n,options:s}})),exports.calculatSingleAddonTotalPrice=m,exports.calculateTotalAddonPrice=R,exports.calculateTotalPrice=o,exports.formatAddressLine=(t,r,e)=>[t,[r,e].filter(Boolean).join("/")].filter(Boolean).join(" "),exports.formatCityLine=t=>(t||[]).filter(Boolean).join(", "),exports.generateOrderItemsId=(r,e,o)=>{if(!r)throw new Error("Product ID is required");let n=`${r}`;e&&(n+=`-${e}`);const i=Object.entries(o||{}).map((([r,e])=>{if(!r||!e)return null;const o=Array.isArray(e)?t.sortNumbers(e).filter(Boolean).join("-"):`${e}`;return o?`${r}-${o}`:null})).filter(Boolean).join("-");return i&&(n+=`-${i}`),n},exports.getAddonOptionRawPrice=s,exports.getAddonOptionTranslation=(t,r)=>{var e,o;return(null===(o=null===(e=null==t?void 0:t.translations)||void 0===e?void 0:e.find)||void 0===o?void 0:o.call(e,(t=>t.language===r)))||{}},exports.getAddonTitle=(t,r)=>{var e,o,n;return(null===(n=null===(o=null===(e=null==t?void 0:t.translations)||void 0===e?void 0:e.find)||void 0===o?void 0:o.call(e,(t=>t.language===r)))||void 0===n?void 0:n.title)||""},exports.getAddonTranslation=(t,r)=>{var e,o;return(null===(o=null===(e=null==t?void 0:t.translations)||void 0===e?void 0:e.find)||void 0===o?void 0:o.call(e,(t=>t.language===r)))||{}},exports.getBaseUrl=(t,r)=>{const e=y.includes(t)?t:h;return{url:`https://${e}/${r||"en"}`,domain:e}},exports.getCategoryNameById=(r,o,n)=>{var i;const a=null===(i=null==o?void 0:o.find)||void 0===i?void 0:i.call(o,(({id:t})=>t===r));if(t.isEmpty(a))return"";const{name:s}=e(a,n);return s},exports.getCategoryTranslation=e,exports.getCoverImageSource=t=>t?t.includes("base64")||t.startsWith("https://")?t:`${n}/${t}`:"https://images.restaround.co/restaround-doodle.webp",exports.getImageSource=t=>t?t.includes("base64")||t.startsWith("https://")?t:`${n}/${t}`:"",exports.getIsFeatureActive=(r,e)=>{if("1"===t.getQueryParam(r))return!0;return(e===N.ALPHA?[N.ALPHA,N.BETA,N.ALL]:e===N.BETA?[N.BETA,N.ALL]:[N.ALL]).some((t=>{var e;return null===(e=O[t])||void 0===e?void 0:e.includes(r)}))},exports.getLogoImageSource=t=>t?t.includes("base64")||t.startsWith("https://")?t:`${n}/${t}`:"https://images.restaround.co/no-photo-128.webp",exports.getOptionPrice=({option:r,currency:e="USD",language:o="en"})=>{const{price:n}=r||{};return{totalPrice:n,formattedTotalPrice:t.priceFormatter(n,e,o)}},exports.getOptionTitles=(t,r,e)=>{var o;if(Array.isArray(r))return t.filter((({id:t})=>r.includes(t))).map((({translations:t})=>{var r;return(null===(r=t.find((t=>t.language===e)))||void 0===r?void 0:r.title)||""})).filter(Boolean).join(", ");{const n=t.find((({id:t})=>t===r));return(null===(o=null==n?void 0:n.translations.find((t=>t.language===e)))||void 0===o?void 0:o.title)||""}},exports.getOrderItemPrice=t=>{var r;const{price:e,variant:o,addons:n,quantity:i,vat:a}=t||{},s=null!==(r=null==o?void 0:o.price)&&void 0!==r?r:e,d=s+R(n,1),l=s*(a/100),u=d+l;return{totalGross:u*i,totalNet:d*i,totalTax:l*i,itemGrossPrice:u,itemNetPrice:d,itemTax:l}},exports.getOrderPrice=(r,e,o)=>{let n=0,i=0;for(const t of r.items){const e=(a=t.price,s=t.quantity,d=t.addons,s*a+R(d,s));n+=e,void 0===r.vat&&t.vat&&(i+=e*t.vat/100)}var a,s,d;void 0!==r.vat&&(i=n*r.vat/100);const l=n+i;return{totalWithoutTax:n,totalWithoutTaxFormatted:t.priceFormatter(n,e,o),totalTax:i,totalTaxFormatted:t.priceFormatter(i,e,o),totalWithTax:l,totalWithTaxFormatted:t.priceFormatter(l,e,o)}},exports.getProductAddon=(t,r)=>((null==t?void 0:t.addons)||[]).find((({id:t})=>t===r))||{},exports.getProductOrderPrice=({product:r,variantId:e,quantity:o=1,currency:n,language:i,selectedAddons:a,noVat:s=!1})=>{const{total:d}=E({product:r,variantId:e,quantity:o,selectedAddons:a,noVat:s});return{totalPrice:d,formattedTotalPrice:t.priceFormatter(d,n,i)}},exports.getProductOrderRawPrice=E,exports.getProductPrice=(r,e,o,n=1)=>{const i=l(r,n);return{totalPrice:i,formattedTotalPrice:t.priceFormatter(i,e,o)}},exports.getProductRawPrice=l,exports.getProductTranslation=(t,r)=>{var e,o;return(null===(o=null===(e=null==t?void 0:t.translations)||void 0===e?void 0:e.find)||void 0===o?void 0:o.call(e,(t=>t.language===r)))||{}},exports.getProductVariant=u,exports.getProductVariantPrice=({variantId:r,currency:e="USD",language:o="en",product:n,quantity:i=1})=>{const a=p(r,n,i);return{totalPrice:a,formattedTotalPrice:t.priceFormatter(a,e,o)}},exports.getProductVariantRawPrice=p,exports.getProductVariantTranslation=(t,r)=>{var e,o;return(null===(o=null===(e=null==t?void 0:t.translations)||void 0===e?void 0:e.find)||void 0===o?void 0:o.call(e,(t=>t.language===r)))||{}},exports.getRegisterUrl=(t,r)=>`https://app.restaround.${b(t)}/auth/register?lang=${t}&utm_source=${r}`,exports.getSelectedAddonsFromOrderItems=t=>{const r={};for(const{addonId:e,options:o=[]}of t.addons||[]){const t=o.map((({optionId:t})=>t));r[e]=1===t.length?t[0]:t}return r},exports.getSelectedOptionsTotalPrice=c,exports.getStatusIcon=t=>{switch(t){case v.COMPLETED:return r.Check;case v.DELIVERED:return r.BagCheck;case v.OUT_FOR_DELIVERY:return r.Delivery;case v.PREPARING:return r.Chef;case v.CONFIRMED:return r.FileCheck;case v.PENDING:default:return r.HourglassHalf}},exports.getTLD=b,exports.prepareCategoryAndProductMap=(t,r)=>{const e=r.reduce(((t,r)=>{if(!r.visible)return t;const e=Number(r.categoryId);return t[e]||(t[e]=[]),t[e].push(r),t}),{});return t.map((t=>Object.assign(Object.assign({},t),{products:e[Number(t.id)]||[]}))).filter((t=>{var r;return(null===(r=null==t?void 0:t.products)||void 0===r?void 0:r.length)>0}))},exports.preparePhoneNumber=t=>`${t.countryCode}${t.phoneNumber}`.replaceAll("+",""),exports.rgbDataURL=(t,r,e)=>`data:image/gif;base64,R0lGODlhAQABAPAA${a(0,t,r)+a(e,255,255)}/yH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==`,exports.validateAddressForm=t=>{const r={},{countryCode:e,cityName:o,street:n,houseNumber:i}=t||{};return e||(r.countryCode="COUNTRY_REQUIRED"),o||(r.cityName="CITY_REQUIRED"),n||(r.street="STREET_REQUIRED"),i||(r.houseNumber="STREET_NUMBER_REQUIRED"),r},exports.validateForm=(r,e)=>{const o={},{phoneNumber:n,email:i,otp:a}=r||{};switch(e){case T.PHONE:{const{isValid:t,error:r}=L(n);t||(o.phoneNumber=r);break}case T.OTP:{const{isValid:t,error:r}=L(n);t||(o.phoneNumber=r),a&&6===a.length||(o.otp="Invalid OTP");break}case T.EMAIL:i&&t.checkIsValidEmail(i)||(o.email="Invalid Email Address")}return o},exports.validatePhoneNumber=L;
2
2
  //# sourceMappingURL=index.js.map
@@ -7,4 +7,5 @@ export * from "../modules/product/utils";
7
7
  export * from "../modules/order/utils";
8
8
  export * from "../modules/customer/utils";
9
9
  export * from "../modules/feature/utils";
10
+ export * from "../modules/view/utils";
10
11
  export * from "./url";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restaround/react",
3
- "version": "1.3.28",
3
+ "version": "1.3.30",
4
4
  "description": "React Library by restaround.co",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -25,6 +25,11 @@
25
25
  "import": "./dist/models/index.esm.js",
26
26
  "types": "./dist/models/index.d.ts"
27
27
  },
28
+ "./constants": {
29
+ "require": "./dist/constants/index.js",
30
+ "import": "./dist/constants/index.esm.js",
31
+ "types": "./dist/constants/index.d.ts"
32
+ },
28
33
  "./styles/ui.css": "./dist/styles/ui.css"
29
34
  },
30
35
  "typesVersions": {
@@ -34,6 +39,9 @@
34
39
  ],
35
40
  "models": [
36
41
  "dist/models/index.d.ts"
42
+ ],
43
+ "constants": [
44
+ "dist/constants/index.d.ts"
37
45
  ]
38
46
  }
39
47
  },
@@ -59,28 +67,28 @@
59
67
  "@rollup/plugin-node-resolve": "^16.0.1",
60
68
  "@rollup/plugin-terser": "^0.4.4",
61
69
  "@rollup/plugin-typescript": "^12.1.4",
62
- "@testing-library/jest-dom": "^6.6.4",
70
+ "@testing-library/jest-dom": "^6.8.0",
63
71
  "@testing-library/react": "^16.3.0",
64
72
  "@types/google.maps": "^3.58.1",
65
73
  "@types/jest": "^30.0.0",
66
- "@types/react": "^19.1.9",
67
- "@types/react-dom": "^19.1.7",
74
+ "@types/react": "^19.1.12",
75
+ "@types/react-dom": "^19.1.9",
68
76
  "autoprefixer": "^10.4.21",
69
- "eslint": "^9.32.0",
77
+ "eslint": "^9.34.0",
70
78
  "eslint-plugin-react": "^7.37.5",
71
79
  "eslint-plugin-react-hooks": "^5.2.0",
72
80
  "eslint-plugin-unicorn": "^60.0.0",
73
- "jest": "^30.0.5",
74
- "jest-environment-jsdom": "^30.0.5",
81
+ "jest": "^30.1.1",
82
+ "jest-environment-jsdom": "^30.1.1",
75
83
  "rimraf": "^6.0.1",
76
84
  "rollup-plugin-copy": "^3.5.0",
77
85
  "rollup-plugin-peer-deps-external": "^2.2.4",
78
86
  "rollup-plugin-postcss": "^4.0.2",
79
- "sass": "^1.90.0",
87
+ "sass": "^1.91.0",
80
88
  "ts-jest": "^29.4.1",
81
89
  "ts-node": "^10.9.2",
82
90
  "tslib": "^2.8.1",
83
91
  "typescript": "^5.9.2",
84
- "typescript-eslint": "^8.39.0"
92
+ "typescript-eslint": "^8.41.0"
85
93
  }
86
94
  }