export const hasAnyRuleGroupPassed=(e,r)=>(e||[]).some((({rules:e})=>hasRulesPassed(e,r)));export const hasRulesPassed=(e,{checkout:r,processor:o})=>e.map((e=>{var t,l;const u=Array.isArray(null==e?void 0:e.value)?(null==e?void 0:e.value).map((e=>(null==e?void 0:e.value)||e)):null==e?void 0:e.value;switch(null==e?void 0:e.condition){case"total":return compareNumberValues(parseFloat(r.total_amount),parseFloat(u),null==e?void 0:e.operator);case"products":return compareObjectValues(getCartProductIds(r),u,null==e?void 0:e.operator);case"coupons":return compareObjectValues(getCartCouponIds(r),u,null==e?void 0:e.operator);case"shipping_country":return compareObjectValues([null===(t=null==r?void 0:r.shipping_address)||void 0===t?void 0:t.country],u,null==e?void 0:e.operator);case"billing_country":return compareObjectValues([null===(l=null==r?void 0:r.billing_address)||void 0===l?void 0:l.country],u,null==e?void 0:e.operator);case"processors":return compareObjectValues([o],u,null==e?void 0:e.operator);default:return!1}})).every((e=>e));export const getCartProductIds=e=>{var r;return((null===(r=null==e?void 0:e.line_items)||void 0===r?void 0:r.data)||[]).map((({price:e})=>{var r;return null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.id}))};export const getCartCouponIds=e=>{var r,o,t,l;return(null===(o=null===(r=null==e?void 0:e.discount)||void 0===r?void 0:r.coupon)||void 0===o?void 0:o.id)?[null===(l=null===(t=null==e?void 0:e.discount)||void 0===t?void 0:t.coupon)||void 0===l?void 0:l.id]:[]};export const compareObjectValues=(e,r,o)=>{switch(o){case"all":return r.filter((r=>e.some((e=>r==e)))).length===r.length;case"any":return e.filter((e=>r.some((r=>e==r)))).length>=1;case"none":return 0===e.filter((e=>r.some((r=>e==r)))).length;case"exist":return e.length>=1;case"not_exist":return 0===e.length;default:return!1}};export const compareNumberValues=(e,r,o)=>{switch(o){case"==":return e===r;case"!=":return e!==r;case">":return e>r;case"<":return e<r;case"<=":return e<=r;case">=":return e>=r}return!1};