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