import{a as i,d as n}from"./chunk-XXHI3I2Z.js";import{a as c,u as y}from"./chunk-HMS3LRP2.js";import{a as s}from"./chunk-JWAFQ6PQ.js";import{a as V}from"./chunk-OW53KNUD.js";import{a as C}from"./chunk-MTSPOHEH.js";import{A as S,B as m,e as p,f as d,v as f,x as g}from"./chunk-QYQ7WNYU.js";import{b as u}from"./chunk-W73LR43Y.js";import{a as l,b as a,g as E}from"./chunk-HC2G7LSI.js";var P=d({source:"User Preferences",events:{setUserPreferences:p()}});var t=E(V());var O=e=>e?e.type===c.PREPAY:!1,q=e=>e?e.type===c.POSTPAY:!1;var r={showVatSelection:"showVatSelection",showVatSelectionSme:"showVatSelectionSme",currencySelection:"currencySelection",lastSelectedCurrency:"lastSelectedCurrency",lastVisitedCategory:"lastVisitedCategory",sellingOption:"sellingOption",togglePrice:"togglePrice",showProductDefaults:"showProductDefaults",selectedTabs:"selectedTabs",selectedOrangeSubscriptionPeriod:"selectedOrangeSubscriptionPeriod"},h=t.get(r.lastVisitedCategory),w=s.RON;function T(e){let o=t.get(e);return o?o===s.RON?s.RON:s.EUR:w}function R(e){return e&&(e.profiles===null||e.profiles.length===0)}function k(e,o){return e===void 0?!o||R(o.profile)?{acquisition:i.AcquisitionPortIn,installment:n.None,isTbi:!1,isNoSubsidy:!1}:O(o.activeSubscriber)?{acquisition:i.AcquisitionPrepayToPostpaid,installment:n.None,isTbi:!1,isNoSubsidy:!0}:{acquisition:i.Loyalty,installment:n.Oro,isTbi:!1,isNoSubsidy:!1}:e}var A=function(){return{showVatSelection:!(t.get(r.showVatSelection)&&t.get(r.showVatSelection)==="false"),showVatSelectionSme:t.get(r.showVatSelectionSme)==="true",currencySelection:T(r.currencySelection),lastSelectedCurrency:T(r.lastSelectedCurrency),lastVisitedCategory:h?parseInt(h,10):C.phones,sellingOption:t.getJSON(r.sellingOption),togglePrice:t.get(r.togglePrice),showProductDefaults:!0,selectedTabs:t.getJSON(r.selectedTabs),selectedOrangeSubscriptionPeriod:t.getJSON(r.selectedOrangeSubscriptionPeriod)||36}}(),K=g({name:"userPreferences",reducer:m(A,S(P.setUserPreferences,(e,{key:o,value:N})=>a(l({},e),{[o]:N}))),extraSelectors:({selectSellingOption:e,selectTogglePrice:o})=>({selectSellingOption:f(e,y,k),selectTogglePrice:u.hasFeatureFlag("B2CTogglePhoneCreditAndOtyPrice")?o:()=>"default"})});export{P as a,q as b,r as c,K as d};