import{B as Q,a as je,b as S,c as z,d as y,e as _,f as x}from"./chunk-IMPYW7JA.js";import{c as Le}from"./chunk-SMQVT23C.js";import{a as p,b as Ae,d as Ee,f as Re,g as De}from"./chunk-I4IMW3RO.js";import{c as Ue}from"./chunk-QAF4RSZW.js";import{f as ze}from"./chunk-FD3QQVVQ.js";import{c as Be,e as Ne}from"./chunk-ZWOB5ADW.js";import{Jb as we}from"./chunk-GYYYM227.js";import{a as ke,b as Fe}from"./chunk-P5AZT3GX.js";import{C as Me,G as _e,H as xe,U as J}from"./chunk-YFWLORNM.js";import{m as Te,o as K}from"./chunk-DAYGRJHR.js";import{D as u,a as ye,b as Ce,c as T,s as Oe}from"./chunk-VYUKN3XQ.js";import{f as Pe}from"./chunk-BRIVAFG5.js";import{Da as oe,Ga as F,Hc as E,Ic as R,Jc as Se,K as k,M as de,Na as M,Qa as me,Ta as d,Tc as q,Vb as G,Wd as n,Xd as ve,Yd as X,_a as he,a as I,b as v,ca as se,fc as fe,fd as U,hb as pe,hd as ne,id as be,m as C,od as Ie,p as re,pb as ge,rb as V,t as ue}from"./chunk-XNQ3RS5P.js";var We={title:"Protejeaz\u0103-\u021Bi deviceul cu o asigurare",description:"Po\u021Bi alege \xEEntre dou\u0103 tipuri de asigurare: Basic sau Premium \u0219i po\u021Bi activa asigurarea, oric\xE2nd, \xEEn primele 120 de zile calendaristice de la data achizi\u021Biei. Costul lunar al acesteia \u0219i valoarea asigurat\u0103 depind de pre\u021Bul standard al dispozitivului cump\u0103rat.",secondDescription:"\u021Aine cont c\u0103 asigurarea nu este purt\u0103toare de TVA, astfel c\u0103, tariful asigur\u0103rii alese, va fi inclus pe factura ta Orange lunar\u0103.",authBannerDescription:"Pentru a verifica dac\u0103 ai deviceuri ce pot fi asigurate, te rug\u0103m s\u0103 te autentifici.",errorMessage:"Ne pare r\u0103u dar a intervenit o eroare, te rug\u0103m revii mai t\xE2rziu.",emptyStateTitle:"Nu sunt disponibile oferte de asigur\u0103ri",emptyStateMessage:"\xCEn prezent, nu exist\u0103 oferte de asigurare disponibile. Te rug\u0103m s\u0103 revino mai t\xE2rziu."},et=["telefon","tableta","smartwatch","obiect-conectat"];var Ye=t=>{switch(t){case _.Phone:return y.Phone;case _.Tablet:return y.Tablet;case _.Smartwatch:return y.Smartwatch;case _.ConnectedObject:return y.ConnectedObject}};var Ze={items:[],selectedItem:null,category:[],selectedCategoryItem:null,status:u.initial,selection:{selectedSlug:null,activeTab:S.Basic,products:[],selectedOption:null,imei:"",orderId:void 0,deviceOaCode:void 0,status:u.initial},insuranceProductCustomDetails:{categoryMappedProducts:null,notSellableReason:null},insurableProducts:null,product:null,error:null},ae=new me("InsuranceState",{factory:()=>Ze});function Z(t,o){var l;o!=null&&o.injector||pe(Z);let w=(l=o==null?void 0:o.injector)!=null?l:d(ge),e=w.get(V),i=new ue,r=t(i).subscribe();e.onDestroy(()=>r.unsubscribe());let a=c=>{let m;fe(c)?m=Ce(c,{injector:w}):de(c)?m=c:m=k(c);let P=m.subscribe(h=>i.next(h));return r.add(P),P};return a.unsubscribe=r.unsubscribe.bind(r),a}var $e=t=>t.replace(" ","-").toLowerCase();var A="https://storage.googleapis.com/orangero-assets/orange-eshop/insurance",L={phone:"".concat(A,"/phones-insurance.svg"),tablet:"".concat(A,"/tablet-insurance.svg"),watch:"".concat(A,"/watch-insurance.svg"),connectedObjects:"".concat(A,"/connected-object-insurance.svg")},W={phone:"".concat(A,"/phones-insurance-imei.svg"),tablet:"".concat(A,"/tablet-insurance-imei.svg"),watch:"".concat(A,"/watch-insurance-imei.svg"),connectedObjects:"".concat(A,"/connected-object-insurance-imei.svg")};var He=t=>{switch(t){case y.Phone:return L.phone;case y.Tablet:return L.tablet;case y.Smartwatch:return L.watch;case y.ConnectedObject:return L.connectedObjects}},Ve=t=>{switch(t){case y.Phone:return W.phone;case y.Tablet:return W.tablet;case y.Smartwatch:return W.watch;case y.ConnectedObject:return W.connectedObjects}};var ce=t=>({categoryId:t.categoryId,slug:$e(t.title),icon:He(t.title),imeiIcon:Ve(t.title),subTitle:t.subTitle,title:t.title,startingPrice:t.startingPrice});var Ge=(()=>{let o=class o{checkImeiAndInitiatePurchase(e,i){return C(this,null,function*(){var r;try{let a=this.findInsurableProductByImei(e,i);return a?this.canInitiatePurchase(a)?this.getAvailableOption(a)?!0:(console.warn("No available purchase options for IMEI:",e),!1):(console.warn("Cannot initiate purchase for IMEI:",{imei:e,productState:a.state,availableOptions:((r=a.options)==null?void 0:r.filter(c=>(c==null?void 0:c.state)==="CAN_BUY").length)||0}),!1):(console.log("Current IMEI not found in processed data"),!1)}catch(a){throw console.error("Error in checkImeiAndInitiatePurchase:",{currentImei:e,error:a instanceof Error?a.message:"Unknown error"}),a}})}extractInsurableProductByImei(e,i){var r,a,l;if(!(e!=null&&e.trim()))return console.warn("No current IMEI provided for extraction"),null;if(!((r=i==null?void 0:i.categoryMappedProducts)!=null&&r.length))return console.warn("No category mapped products available for extraction"),null;for(let c of i.categoryMappedProducts){if(!((l=(a=c==null?void 0:c.product)==null?void 0:a.insurableProducts)!=null&&l.length))continue;let m=c==null?void 0:c.product.insurableProducts.find(P=>P.imei===e);if(m)return m}return null}findInsurableProductByImei(e,i){var r,a;if(!e||!(i!=null&&i.categoryMappedProducts))return null;for(let l of i.categoryMappedProducts){let c=(a=(r=l.product)==null?void 0:r.insurableProducts)==null?void 0:a.find(m=>m.imei===e);if(c)return c}return null}canInitiatePurchase(e){var i;return!!(e.state==="CAN_BUY"&&((i=e.options)!=null&&i.some(r=>(r==null?void 0:r.state)==="CAN_BUY")))}getAvailableOption(e){var i;return((i=e.options)==null?void 0:i.find(r=>(r==null?void 0:r.state)==="CAN_BUY"))||null}};o.\u0275fac=function(i){return new(i||o)},o.\u0275prov=M({token:o,factory:o.\u0275fac,providedIn:"root"});let t=o;return t})();var qe=Ae({providedIn:"root"},De(()=>d(ae)),Ee(({items:t,selection:o,insuranceProductCustomDetails:w})=>{let e=n(()=>o().selectedSlug),i=n(()=>{let s=e();return s?Ye(s):null}),r=n(()=>{let s=i();return t().find(g=>g.title===s)}),a=n(()=>{let s=r();return s?ce(s):null}),l=n(()=>{var s;return((s=w())==null?void 0:s.categoryMappedProducts)||[]}),c=n(()=>{var b,f;let s=r();if(!s)return null;let g=(f=(b=l())==null?void 0:b.find(O=>(O==null?void 0:O.categoryId)===(s==null?void 0:s.categoryId)))==null?void 0:f.product;return g||null}),m=n(()=>{let s=c(),g=s==null?void 0:s.insurableProducts;return g||null}),P=n(()=>t().map(s=>ce(s))),h=n(()=>{let s=w();if(!s)return null;let g=(s.categoryMappedProducts||[]).filter(f=>f!=null),b=g.filter(f=>f.state===je.CanBuy);return{categoryMappedProducts:g,notSellableReason:s.notSellableReason||null,isAvailable:b.length>0&&!s.notSellableReason,availableProducts:b}}),D=n(()=>{let s=h();return(s==null?void 0:s.notSellableReason)||null}),Y=n(()=>D()!==null),ie=n(()=>{let s=D();if(!s)return null;if(s.message)return s.message;switch(s.reason){case z.RequestedTierNotAvailableForPurchase:return"Nu s-a g\u0103sit nici o asigurare, pentru acest tip de asigurare.";case z.NoInsuranceFound:return"Nu s-a g\u0103sit nici o asigurare";default:return"A intervenit o eroare"}}),j=n(()=>{let s=h();return(s==null?void 0:s.availableProducts)||[]}),$=n(()=>j().length>0),B=n(()=>{var g,b;let s=r();return s?!!(s&&((g=s.options)!=null&&g.BASIC)&&s.options.BASIC.length>0||s&&((b=s.children)!=null&&b.some(f=>{var O;return((O=f==null?void 0:f.options)==null?void 0:O.BASIC)&&f.options.BASIC.length>0}))):!1}),N=n(()=>{var g,b;let s=r();return s?!!(s&&((g=s.options)!=null&&g.PREMIUM)&&s.options.PREMIUM.length>0||s&&((b=s.children)!=null&&b.some(f=>{var O;return((O=f==null?void 0:f.options)==null?void 0:O.PREMIUM)&&f.options.PREMIUM.length>0}))):!1}),H=n(()=>[B()?S.Basic:null,N()?S.Premium:null]);return{selectedItem:r,selectedCategoryItem:a,product:c,category:P,insurableProducts:m,selectedSlug:e,processedProductDetails:h,notSellableReason:D,isNotSellable:Y,notSellableMessage:ie,availableProducts:j,hasAvailableProducts:$,availableTiers:H,hasBasicTier:B,hasPremiumTier:N}}),Re((t,o=d(Q),w=d(Ge),e=d(K),i=T(e.getWithSelector(J)))=>({loadCategoryOfferings:Z(re(F(()=>p(t,{status:u.loading,error:null})),oe(()=>o.fetchCategoryOfferings().pipe(F({next:r=>{if(!r)throw new Error("Empty response received from server");let a=r.items;if(a.length===0){p(t,{items:[],status:u.success});return}p(t,{items:a,status:u.success,error:null})},error:r=>{p(t,{error:r,status:u.error})}}),se(r=>{let a={message:We.errorMessage||"Unable to load insurance offerings. Please try again.",code:"LOAD_OFFERINGS_FAILED",timestamp:new Date().toISOString()};return p(t,{error:a,status:u.error}),k(null)}))))),loadProductCustomDetails:Z(re(F(r=>{p(t,{selection:v(I({},t.selection()),{status:u.loading}),error:null})}),oe(r=>o.getInsuranceProductCustomDetails(r).pipe(F({next:a=>C(void 0,null,function*(){var j,$,B,N,H,s,g;if(!a.success){let b=(($=(j=a.errors)==null?void 0:j[0])==null?void 0:$.message)||"Failed to load product details";p(t,{selection:v(I({},t.selection()),{status:u.error}),error:{message:b,code:((N=(B=a.errors)==null?void 0:B[0])==null?void 0:N.code)||"API_ERROR",timestamp:new Date().toISOString()},status:u.error});return}let l=(H=a.data)==null?void 0:H.getInsuranceProductCustomDetails,c=o.processInsuranceProductDetails(l),m=t.selection().imei,P=t.selection().selectedOption===x.Custom,h=(s=t.insuranceProductCustomDetails())==null?void 0:s.categoryMappedProducts,D=l==null?void 0:l.categoryMappedProducts,Y=o.getCategoryMappedProducts(P,h,D),ie=Y||l!=null&&l.notSellableReason?{categoryMappedProducts:Y,notSellableReason:l==null?void 0:l.notSellableReason}:void 0;if(p(t,{selection:v(I({},t.selection()),{status:u.success}),error:null,status:t.status()===u.loading?u.success:t.status(),insuranceProductCustomDetails:ie}),P&&m&&c)try{if(yield w.checkImeiAndInitiatePurchase(m,c)){let f=w.extractInsurableProductByImei(m,l);o.addInsurance(t.selection().selectedOption,f,i(),m,((g=t.selection().selectedSlug)==null?void 0:g.toLowerCase())==="smartwatch"?S.Premium:t.selection().activeTab)}}catch(b){console.error("Auto-purchase failed:",b)}c.notSellableReason&&console.warn("\u26A0\uFE0F Product not sellable:",{reason:c.notSellableReason.reason,message:c.notSellableReason.message})}),error:a=>{var c,m,P,h;console.error("Failed to load product details:",a);let l=((m=(c=a.errors)==null?void 0:c[0])==null?void 0:m.message)||"Unable to load product details. Please try again.";p(t,{selection:v(I({},t.selection()),{status:u.error}),error:{message:l,code:((h=(P=a.errors)==null?void 0:P[0])==null?void 0:h.code)||"LOAD_FAILED",timestamp:new Date().toISOString()},status:u.error})}}),se(a=>(console.error("Unhandled error in loadProductCustomDetails:",a),p(t,{selection:v(I({},t.selection()),{status:u.error}),error:{message:"A ap\u0103rut o eroare nea\u0219teptat\u0103. Te rug\u0103m s\u0103 \xEEncerci din nou.",code:"UNEXPECTED_ERROR",timestamp:new Date().toISOString()},status:u.error}),k(null))))))),setSelectedCategorySlug(r){p(t,{selection:v(I({},t.selection()),{selectedSlug:r})})},setActiveTab(r){p(t,{selection:v(I({},t.selection()),{activeTab:r})})},setSelectedOption(r){p(t,{selection:v(I({},t.selection()),{selectedOption:r})})},setImei(r){p(t,{selection:v(I({},t.selection()),{imei:r})})},setOrderId(r){p(t,{selection:v(I({},t.selection()),{orderId:r})})},setDeviceOaCodeId(r){p(t,{selection:v(I({},t.selection()),{deviceOaCode:r})})},goWithBasic(){p(t,{selection:v(I({},t.selection()),{activeTab:S.Basic})})},clearError:()=>p(t,{error:null}),resetStore:()=>{let r=d(ae);p(t,r)}})));var le=t=>t.length>=15&&t.length<=20,Xe=t=>t.length>=5&&t.length<=20;var Ke=(()=>{let o=class o{constructor(){this.dialogRef=d(Be),this.domSanitizer=d(Pe),this.matIconRegistry=d(ke),this.facade=d(Je),this.InsuranceTier=S,this.loadIcons()}confirm(){this.dialogRef.close({action:"confirm"})}cancel(){this.dialogRef.close({action:"cancel"})}loadIcons(){this.matIconRegistry.addSvgIconLiteral("ico_close_icon",this.domSanitizer.bypassSecurityTrustHtml(Ue))}};o.\u0275fac=function(i){return new(i||o)},o.\u0275cmp=he({type:o,selectors:[["oro-premium-option-unavailable-modal"]],standalone:!0,features:[Ie],decls:14,vars:4,consts:[[1,"premium-option-unavailable"],[1,"premium-option-unavailable__header"],[1,"premium-option-unavailable__title"],["aria-label","Close",1,"premium-option-unavailable__close",3,"click"],["aria-hidden","false","svgIcon","ico_close_icon",1,"premium-option-unavailable__close-icon"],[1,"premium-option-unavailable__body"],[1,"premium-option-unavailable__text"],[1,"premium-option-unavailable__action"],[1,"premium-option-unavailable__action-button",3,"click"],[1,"premium-option-unavailable__action-button","premium-option-unavailable__action-button--primary",3,"click"]],template:function(i,r){i&1&&(E(0,"div",0)(1,"div",1)(2,"h3",2),U(3),R(),E(4,"button",3),q("click",function(){return r.cancel()}),Se(5,"mat-icon",4),R()(),E(6,"div",5)(7,"p",6),U(8),R()(),E(9,"div",7)(10,"button",8),q("click",function(){return r.cancel()}),U(11," \xCEnchide "),R(),E(12,"button",9),q("click",function(){return r.confirm()}),U(13),R()()()),i&2&&(G(3),ne(" Planul ",r.facade.activeTab()===r.InsuranceTier.Basic?"Basic":"Premium"," nu este disponibil "),G(5),be(" Pentru acest produs planul ",r.facade.activeTab()===r.InsuranceTier.Basic?"Basic":"Premium"," nu este disponibil. Po\u021Bi s\u0103 mergi mai departe folosind planul ",r.facade.activeTab()===r.InsuranceTier.Basic?"Premium":"Basic",". "),G(5),ne(" Continu\u0103 cu ",r.facade.activeTab()===r.InsuranceTier.Basic?"Premium":"Basic"," "))},dependencies:[Fe],styles:[".premium-option-unavailable[_ngcontent-%COMP%]{display:flex;flex-direction:column}.premium-option-unavailable__header[_ngcontent-%COMP%]{border-bottom:1px solid rgb(224,224,224);display:flex;justify-content:space-between;align-items:center;padding-bottom:1rem}.premium-option-unavailable__title[_ngcontent-%COMP%]{color:#000;font-size:21px;font-weight:700;letter-spacing:-.26px;margin:0}.premium-option-unavailable__close[_ngcontent-%COMP%]{display:flex;justify-content:center;align-items:center;max-width:40px;max-height:40px;padding:0;margin:0;border:none;background:transparent}.premium-option-unavailable__close-icon[_ngcontent-%COMP%]{height:20px!important;width:20px!important}.premium-option-unavailable__body[_ngcontent-%COMP%]{border-bottom:1px solid rgb(224,224,224);padding:1rem 0}@media screen and (min-width: 768px){.premium-option-unavailable__body[_ngcontent-%COMP%]{padding:20px 0}}.premium-option-unavailable__text[_ngcontent-%COMP%]{font-size:17px;font-weight:400;letter-spacing:-.21px;margin:0}.premium-option-unavailable__number-wrap[_ngcontent-%COMP%]{display:flex;justify-content:center;align-items:center;gap:7px;padding:1rem 0;margin:0;list-style:none}.premium-option-unavailable__number[_ngcontent-%COMP%]{border-radius:100%;background:#d8d8d8;text-align:center;width:43px;height:43px;display:flex;justify-content:center;align-items:center;color:#000;font-size:40px;font-weight:700;letter-spacing:-.5px}.premium-option-unavailable__action[_ngcontent-%COMP%]{display:flex;justify-content:center;align-items:center;flex-direction:column;padding-top:1rem;margin-top:auto;gap:1rem}@media screen and (min-width: 768px){.premium-option-unavailable__action[_ngcontent-%COMP%]{flex-direction:row}}.premium-option-unavailable__action-button[_ngcontent-%COMP%]{display:flex;justify-content:center;align-items:center;border:2px solid rgb(0,0,0);font-size:14px;font-weight:700;text-align:center;line-height:32px;width:100%;padding:0 2rem;max-width:210px;background:#fff}.premium-option-unavailable__action-button--primary[_ngcontent-%COMP%]{border-color:#ff7900;background:#ff7900;color:#fff}.premium-option-unavailable__action-button--primary[_ngcontent-%COMP%]:hover{border-color:#f16e00;background:#f16e00}"]});let t=o;return t})();var te=(()=>{let o=class o{constructor(){this.STORAGE_KEY="insurance_selection",this.EXPIRY_DURATION=24*60*60*1e3}saveSelection(e){var i,r,a,l;try{let c={selectedSlug:(i=e.selectedSlug)!=null?i:null,activeTab:(r=e.activeTab)!=null?r:S.Basic,selectedOption:(a=e.selectedOption)!=null?a:null,imei:(l=e.imei)!=null?l:"",orderId:e.orderId,deviceOaCode:e.deviceOaCode,timestamp:Date.now()};localStorage.setItem(this.STORAGE_KEY,JSON.stringify(c))}catch(c){console.warn(this.getErrorMessage("save"),c)}}loadSelection(){try{let e=localStorage.getItem(this.STORAGE_KEY);if(!e)return null;let i=JSON.parse(e);return this.isExpired(i.timestamp)?(this.clearSelection(),null):this.isValidSelection(i)?i:(this.clearSelection(),null)}catch(e){return console.warn(this.getErrorMessage("load"),e),this.clearSelection(),null}}clearSelection(){try{localStorage.removeItem(this.STORAGE_KEY)}catch(e){console.warn(this.getErrorMessage("clear"),e)}}shouldPersistSelection(e){return!!(e!=null&&e.selectedSlug||e!=null&&e.selectedOption||e!=null&&e.imei&&e.imei.length>0)}updatePartialSelection(e){let i=this.loadSelection();if(!i&&this.shouldPersistSelection(e))return;let r=v(I(I({},i),e),{timestamp:Date.now()});this.saveSelection(r)}isExpired(e){return Date.now()-e>this.EXPIRY_DURATION}isValidSelection(e){return e&&typeof e=="object"&&typeof e.timestamp=="number"&&(e.activeTab===S.Basic||e.activeTab===S.Premium)}getErrorMessage(e){switch(e){case"save":return"Failed to save insurance selection to localStorage:";case"load":return"Failed to load insurance selection from localStorage:";case"clear":return"Failed to clear insurance selection from localStorage:";default:return"Insurance localStorage error"}}};o.\u0275fac=function(i){return new(i||o)},o.\u0275prov=M({token:o,factory:o.\u0275fac,providedIn:"root"});let t=o;return t})();var Qe=(()=>{let o=class o{constructor(){this.persistenceService=d(te)}restorePersistedSelection(e){let i=this.persistenceService.loadSelection();if(!i)return!1;try{return ve(()=>{i.selectedSlug&&e.setSelectedCategorySlug(i.selectedSlug),i.activeTab&&e.setActiveTab(i.activeTab),i.selectedOption&&e.setSelectedOption(i.selectedOption),i.imei&&e.setImei(i.imei),i.orderId&&e.setOrderId(i.orderId),i.deviceOaCode&&e.setDeviceOaCodeId(i.deviceOaCode)}),!0}catch(r){return console.error("Failed to restore persisted insurance selection:",r),this.persistenceService.clearSelection(),!1}}persistCurrentSelection(e){this.persistenceService.saveSelection(e)}clearPersistedData(){this.persistenceService.clearSelection()}};o.\u0275fac=function(i){return new(i||o)},o.\u0275prov=M({token:o,factory:o.\u0275fac,providedIn:"root"});let t=o;return t})();var Je=(()=>{let o=class o{constructor(){this.store=d(Oe),this.storeSelector=d(K),this.insuranceStore=d(qe),this.dialog=d(Ne),this.destroyRef=d(V),this.snackBar=d(ze),this.insuranceService=d(Q),this.selectionSyncService=d(Qe),this.persistenceService=d(te),this.isAuthenticated=T(this.storeSelector.getWithSelector(Te)),this.cartIsLoading=T(this.storeSelector.getWithSelector(we)),this.activeMsisdn=T(this.storeSelector.getWithSelector(J)),this.activeProfileIsAdmin=T(this.storeSelector.getWithSelector(Me)),this.activeProfileIsPrepay=T(this.storeSelector.getWithSelector(_e)),this.activeProfileIsExplorer=T(this.storeSelector.getWithSelector(xe)),this.items=this.insuranceStore.items,this.status=this.insuranceStore.status,this.error=this.insuranceStore.error,this.isInitial=n(()=>this.status()===u.initial),this.isLoading=n(()=>this.status()===u.loading),this.hasError=n(()=>this.status()===u.error),this.isSuccess=n(()=>this.status()===u.success),this.isPhonePage=n(()=>this.selectedItemCategoryId()===1),this.isSmartWatchCategory=n(()=>this.selectedSlug()===_.Smartwatch),this.isConnectedObjectCategory=n(()=>this.selectedSlug()===_.ConnectedObject),this.hasAvailableCategoryOfferings=n(()=>this.categoryOfferings().length>0),this.shouldShowEmptyState=n(()=>this.isSuccess()&&!this.hasError()&&this.items().length===0),this.selection=this.insuranceStore.selection,this.selectedSlug=this.insuranceStore.selectedSlug,this.selectionStatus=this.insuranceStore.selection.status,this.activeTab=n(()=>this.isSmartWatchCategory()?S.Premium:this.selection().activeTab),this.selectedOption=n(()=>this.selection().selectedOption),this.imei=n(()=>this.selection().imei),this.orderId=n(()=>this.selection().orderId),this.deviceOaCode=n(()=>this.selection().deviceOaCode),this.selectionIsInitial=n(()=>this.selectionStatus()===u.initial),this.selectionIsLoading=n(()=>this.selectionStatus()===u.loading),this.selectionHasError=n(()=>this.selectionStatus()===u.error),this.selectionIsSuccess=n(()=>this.selectionStatus()===u.success),this.showFromPrice=n(()=>this.selectedOption()===null||this.selectedOption()===x.Custom),this.selectedItem=this.insuranceStore.selectedItem,this.selectedItemCategoryId=n(()=>{var e;return(e=this.selectedItem())==null?void 0:e.categoryId}),this.selectedCategoryItem=this.insuranceStore.selectedCategoryItem,this.product=this.insuranceStore.product,this.categoryOfferings=this.insuranceStore.category,this.insurableProducts=this.insuranceStore.insurableProducts,this.selectedInsurableProduct=n(()=>{var e;return((e=this.insurableProducts())==null?void 0:e.find(i=>i.oaCode===this.selectedOption()))||null}),this.insuranceProductCustomDetails=this.insuranceStore.insuranceProductCustomDetails,this.categoryMappedProducts=n(()=>{var e;return((e=this.insuranceProductCustomDetails())==null?void 0:e.categoryMappedProducts)||[]}),this.notSellableReason=this.insuranceStore.notSellableReason,this.reason=n(()=>{var e;return((e=this.notSellableReason())==null?void 0:e.reason)||null}),this.canViewDetails=n(()=>!!this.isAuthenticated()),this.isNotSellable=this.insuranceStore.isNotSellable,this.notSellableMessage=this.insuranceStore.notSellableMessage,this.availableProducts=this.insuranceStore.availableProducts,this.hasAvailableProducts=this.insuranceStore.hasAvailableProducts,this.availableTiers=this.insuranceStore.availableTiers,this.hasPremiumTier=this.insuranceStore.hasPremiumTier,this.hasBasicTier=this.insuranceStore.hasBasicTier,this.isTierNotAvailable=n(()=>this.isConnectedObjectCategory()&&this.selectedOption()===x.Custom&&this.reason()===z.RequestedTierNotAvailableForPurchase),this.isCurrentTierAvailable=n(()=>{let e=this.activeTab();return this.availableTiers().includes(e)}),this.shouldShowOtyPassword=n(()=>!this.activeProfileIsAdmin()&&!this.activeProfileIsPrepay()&&!this.activeProfileIsExplorer()),this.canNotProceedWithPurchase=n(()=>!!(this.isAuthenticated()&&this.selectedOption()===null||this.isAuthenticated()&&this.selectedOption()===x.Custom&&this.isPhonePage()&&!le(this.imei())||this.isAuthenticated()&&this.selectedOption()===x.Custom&&!this.isPhonePage()&&!Xe(this.imei())||this.cartIsLoading())),this.purchaseBlockedReason=n(()=>this.isNotSellable()?this.selectedOption()?this.imei().length===0?"Te rug\u0103m s\u0103 introduci ".concat(this.isPhonePage()?"IMEI-ul":"SM-ul"," dispozitivului"):null:"Te rug\u0103m s\u0103 selectezi o op\u021Biune de asigurare":this.notSellableMessage()),this.persistSelectionEffect=X(()=>{let e=this.selection(),i={selectedSlug:this.selectedSlug(),activeTab:e.activeTab,selectedOption:e.selectedOption,imei:e.imei,orderId:e.orderId,deviceOaCode:e.deviceOaCode};this.persistenceService.shouldPersistSelection(i)&&this.persistenceService.saveSelection(i)},{allowSignalWrites:!0}),this.tierNotAvailableEffect=X(()=>{this.isTierNotAvailable()&&this.showTierNotAvailableAlert()}),this.autoClearErrorEffect=X(()=>{let e=this.isSuccess(),i=this.hasError();e&&i&&setTimeout(()=>{this.clearError()},3e3)})}initializeLoadInsuranceItems(){return C(this,null,function*(){try{this.restorePersistedSelection(),yield this.loadInsuranceItems()}catch(e){throw console.error("Failed to initialize Insurance Facade:",e),e}})}restorePersistedSelection(){return this.selectionSyncService.restorePersistedSelection(this.insuranceStore)}clearPersistedSelection(){this.selectionSyncService.clearPersistedData()}loadInsuranceItems(){return C(this,null,function*(){try{this.insuranceStore.loadCategoryOfferings()}catch(e){throw console.error("Failed to initiate insurance offerings load:",e),e}})}selectCategory(e){this.insuranceStore.setSelectedCategorySlug(e)}selectTier(e){if(!this.availableTiers().includes(e)){this.showTierNotAvailableAlert();return}this.insuranceStore.setActiveTab(e)}selectOption(e){this.insuranceStore.setSelectedOption(e)}setDeviceImei(e){this.insuranceStore.setImei(e)}setOrderId(e){this.insuranceStore.setOrderId(e)}setDeviceOaCode(e){this.insuranceStore.setDeviceOaCodeId(e)}selectBasicTier(){this.selectTier(S.Basic)}initiatePurchase(){return C(this,null,function*(){try{this.insuranceService.addInsurance(this.selectedOption(),this.selectedInsurableProduct(),this.activeMsisdn(),this.imei(),this.activeTab()),this.clearPersistedSelection()}catch(e){throw console.error("Purchase failed:",e),e}})}clearError(){this.insuranceStore.clearError()}resetSelection(){this.insuranceStore.setSelectedCategorySlug(null),this.insuranceStore.setActiveTab(S.Basic),this.insuranceStore.setSelectedOption(null),this.insuranceStore.setImei(""),this.insuranceStore.setOrderId(void 0),this.clearPersistedSelection()}initializeLoadProductDetails(){return C(this,null,function*(){try{this.restorePersistedSelection(),yield this.loadProductDetails()}catch(e){throw console.error("Failed to initialize Product Details Facade:",e),e}})}loadProductDetails(){return C(this,null,function*(){let e=this.selectedOption(),i=this.activeMsisdn(),r=this.selectedItemCategoryId(),a=this.activeTab(),l=this.imei(),c=this.deviceOaCode(),m=this.orderId();if(!a){console.warn("Cannot load product details: missing required parameters");return}let P={selectedOption:e,msisdn:i,deviceCategoryId:r,tier:a,imei:l,deviceOaCode:c,orderId:m};if(!this.canViewDetails()){let h=new Error("Insufficient permissions to view product details");throw console.warn("Permission denied for loading product details:",h),h}try{this.validateProductDetailsParams(P)}catch(h){throw console.error("Parameter validation failed:",h),h}try{let h=this.insuranceService.buildInsuranceProductDetailsRequest(e,i,r,a,l,c,m);this.insuranceStore.loadProductCustomDetails(h)}catch(h){throw console.error("Failed to load product details:",h),h}})}retryLoadProductDetails(){return C(this,null,function*(){try{yield this.loadProductDetails()}catch(e){throw e}})}preparePurchaseData(){return{deviceCategoryId:void 0,tier:this.activeTab(),deviceImei:void 0,imei:this.imei(),orderId:this.orderId(),userId:void 0}}showTierNotAvailableAlert(){this.store.dispatch(Le.premiumPlanUnavailablePopupShown()),this.dialog.open(Ke,{autoFocus:!1,disableClose:!1,minHeight:"170px",maxWidth:"650px"}).afterClosed().pipe(ye(this.destroyRef)).subscribe(i=>{(i==null?void 0:i.action)==="confirm"&&(this.selectOption(null),this.selectBasicTier(),this.loadProductDetails())})}showErrorAlert(e){this.snackBar.open(e,"Close",{duration:5e3,panelClass:["error-snackbar"]})}showSuccessAlert(e){this.snackBar.open(e,"Close",{duration:3e3,panelClass:["success-snackbar"]})}validateProductDetailsParams(e){if(e.selectedOption===x.Custom&&e.imei&&this.isPhonePage()&&!le(e.imei))throw new Error("Invalid IMEI format for phone device")}};o.\u0275fac=function(i){return new(i||o)},o.\u0275prov=M({token:o,factory:o.\u0275fac,providedIn:"root"});let t=o;return t})();export{We as a,et as b,W as c,Ye as d,Je as e};