import{k as q}from"./chunk-W7Q3ZR5P.js";import{c as E}from"./chunk-VRHLKWSG.js";import{a as l,e as f,f as d,g as h}from"./chunk-RTZH3MOC.js";import{e as T}from"./chunk-F24Q3MRY.js";import{v as r,w as b}from"./chunk-VYUKN3XQ.js";var u=function(e){return e[e.FIX=0]="FIX",e[e.PERCENTAGE=1]="PERCENTAGE",e}(u||{});var s=b("subscriptions"),L=r(s,e=>e.selectedAcquisitionType),w=r(s,e=>e.exchangeRate),D=r(s,e=>e.xhrStatus),U=r(s,e=>e.errors),z=(e,t,i,o)=>r(s,c=>F(V(e,o,c.packages),t,i,c.selectedAcquisitionType)),H=e=>r(s,t=>{var i;return(i=t.packages.find(o=>o.package.ref===e))==null?void 0:i.package}),B=r(s,e=>e.selectedAcquisitionType),J=r(s,e=>{var t,i;return((t=e.notifications)==null?void 0:t.length)===1&&((i=e.notifications)==null?void 0:i.includes(E.notInActivePortfolio))||!1}),K=r(s,e=>e.enableBuyButton),Y=r(s,e=>{var t,i,o;return{isPpy2PpdSupported:!!((t=e.supportedSellingOptions)!=null&&t.find(c=>c.acquisition===l.AcquisitionPrepayToPostpaid)),isPortInSupported:!!((i=e.supportedSellingOptions)!=null&&i.find(c=>c.acquisition===l.AcquisitionPortIn)),isAcquisitionSupported:!!((o=e.supportedSellingOptions)!=null&&o.find(c=>c.acquisition===l.Acquisition))}}),Z=r(s,e=>{var t,i;return((i=(t=e.supportedSellingOptions)==null?void 0:t.find(o=>o.acquisition===e.selectedAcquisitionType))==null?void 0:i.actions)||[]}),_=r(s,e=>{var t;return(t=e.notifications)!=null&&t.length?e.notifications:[]}),$=r(s,e=>{var t;return(t=e.notificationsFromQueryParams)!=null&&t.length?e.notificationsFromQueryParams:[]}),M=r(s,e=>e.selectedPeriod),ee=r(s,e=>e.isShowBusiness),te=r(s,e=>e.displayedOptions),ie=r(s,e=>e.isEligibleForSubscription),N=e=>r(s,t=>t.packagesDetails[e.pkg.ref]),v=(e,t)=>r(N(e),i=>i?i[t]:void 0),re=(e,t,i)=>({selector:v(e,t),action:()=>q({modalData:e,flow:t,price:i}),shouldDispatch:o=>!o||!!o.agreementTerm&&o.agreementTerm!==e.agreementTerm||!!o.finalPrice&&o.finalPrice!==i});function F(e,t,i,o){if(o===d.Acquisition&&!t){let c=e.filter(a=>{var p;return(p=a.labels)==null?void 0:p.includes(f.Private)}),n=e.filter(a=>{var p;return(p=a.labels)==null?void 0:p.includes(f.Business)});return i?n:c}return e}function I(e){if(e)return{type:e.type===h.Fix?u.FIX:u.PERCENTAGE,percentageValue:e.percentageValue,fixValue:e.fixValue,offerName:e.offerName,period:e.period,periodType:e.periodType}}function V(e,t,i){let o=[];return i.forEach(c=>{var g,P,m,S,y,x,k,A;let n=c.package,a=((g=n.agrTermPrices)!=null?g:[]).find(O=>O.term===e);if(!a)return;let p={name:n.displayName?n.displayName:"",icons:[...n.icons],pkgBenefits:[...n.pkgBenefits],termSalePackageBenefits:[...n.termSalePackageBenefits],ref:n.ref,price:!t&&((P=a.price)!=null&&P.valueWithoutVat)?(m=a.price)==null?void 0:m.valueWithoutVat:(S=a.price)!=null&&S.displayValue?Number((y=a.price)==null?void 0:y.displayValue):0,refPrice:!t&&((x=n.price)!=null&&x.valueWithoutVat)?(k=n.price)==null?void 0:k.valueWithoutVat:(A=n.price)==null?void 0:A.value,discount:I(a.discount),labels:n.labels,isCurrentPackage:c.isCurrentPackage,period:e,displayOrder:a.displayOrder};o.push(p)}),o.sort((c,n)=>c.isCurrentPackage?-1:typeof c.displayOrder=="number"&&typeof n.displayOrder=="number"?c.displayOrder-n.displayOrder:c.price>n.price?1:-1),o}var oe=r(B,e=>e===d.Loyalty?1:0),se=r(s,e=>e.periods),{selectQueryParam:ce,selectUrl:ne}=T();export{L as a,w as b,D as c,U as d,z as e,H as f,B as g,J as h,K as i,Y as j,Z as k,_ as l,$ as m,M as n,ee as o,te as p,ie as q,re as r,oe as s,se as t,ce as u,ne as v};