@restaround/react 1.3.29 → 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.
@@ -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.29",
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",