var localesCs={messages:{app:{today:"Dnes",tommorow:"Zítra",etc:"atd.",freeOfCharge:"Zdarma",dayCount:function(n){return n<2?"den":n<5?"dny":"dnů"},sessionExpired:"Z důvodu dlouhé nečinnosti Vaše sezení vypršelo.",loyaltyPoints:"bodů",loyaltyPointsSum:"bodů celkem",months:["Leden","Únor","Březen","Duben","Květen","Červen","Červenec","Srpen","Září","Říjen","Listopad","Prosinec"],redirectUrlTitleDefaultParams:"Výchozí nastavení",close:"Beru na vědomí",cancel:"Storno",yes:"Ano"},validation:{requiredItem:"Povinný údaj.",errorIKNumber:"Zadejte platné číslo In Karty.",errorIKNumberDigits:"Hodnota může být pouze číslo (bez písmen a speciálních znaků).",errorBirthdate:"Zadejte platné datum narození.",errorPhone:"Zadejte platné telefonní číslo.",errorCZMobileNumber:"Zadané telefonní číslo není číslem mobilního telefonu.",errorZipCode:"Zadejte platné PSČ.",errorCompanyOrName:"Zadejte název firmy nebo jméno a příjmení.",errorEmail:"Zadejte platný e-mail.",errorTransactionCode:"Zadejte platný kód transakce.",errorTooLargeText:"Zadaný text je příliš dlouhý",errorAuthorizationCode:"Zadejte platný kód autorizace platby",errorCreditCardCode:"Zadejte platné číslo platební karty",errorCarRegistration:"Neplatný formát SPZ",errorNumberWidth:"Zadejte rozměr mezi 1 a 200 cm",errorNumberHeight:"Zadejte rozměr mezi 80 a 200 cm",errorCreditAccount:"Zadejte platné číslo kreditního účtu.",errorInvalidChars:"Položka obsahuje nepovolené znaky.",errorStationEmpty:"Zadejte stanici.",errorStationNotExists:"Chybně zadaná nebo neexistující stanice.",errorStationAmbiguous:"Nejednoznačně zadaná stanice.",errorExistedNickname:"Zadejte jinou přezdívku, tato je již použita.",errorCodeLength:"Zadaný kód nebo jeho formát není platný.",errorNicknameLength:"Minimální počet znaků je 3.",errorCardName:"Zadejte jméno i příjmení.",errorCardNameLength:"Maximální délka je 50 znaků.",errorPensionerIdent:"Zadejte číslo Rozhodnutí o přiznání důchodu pro potvrzení nároku na slevu.",errorNSNotExists:"Chybně zadané nebo neexistující nákladové středisko.",errorNSAmbiguous:"Nejednoznačně zadané nákladové středisko.",errorDiscountNumber:"Zadaná hodnota není v rozsahu 0 až 100.",errorSJTNumber:"Číslo jízdenky OneTicket není platné.",errorVegaTourMobileNumber:"Zadejte číslo mobilního telefonu s mezinárodní předvolbou."},connection:{onlyDirectConnections:"Pouze přímá spojení",onlyConnWithoutRes:"Pouze vlaky bez povinné rezervace",maximum:"Maximálně",maxChanges:function(n){var t=parseInt(n);return t<2?"přestup":t<5?"přestupy":"přestupů"},onlyCD:"Pouze vlaky Českých drah",onlyCDPartners:"Vlaky Českých drah a smluvních partnerů",deltaPMax:"Maximální odchylka od nejkratší trasy:",useBeds:"Použít lůžkové a lehátkové vozy",noBeds:"Nepoužít lůžkové a lehátkové vozy",trainTypes:"Dopravní prostředky",historyTrain:"nezahrnovat zvláštní a historické vlaky",except:"mimo",only:"jen",and:"a",psgOwnTicket:"Pro každého cestujícího vlastní jízdenku",addServices:"Doplňkové služby",addServiceReservation:"rezervace místa",addServiceDog:"přeprava psa",addServiceBike:"přeprava kola",addServiceSMS:"SMS infoservis",inTime:"VČAS",delaylessthan10:"+ do 10 min",delay:"ZPOŽDĚNÍ",min:"min",arr:"PŘÍJEZD",dep:"ODJEZD",depShortCut:"Odj.",arrShortCut:"Příj.",waitInStat:"čekání ve stanici",linkDist:"Doba na přesun",linkDistTitle:"Přesun",linkDistMain:"Přesun asi",standardChange:"Běžná doba na přestup",standardChangeTitle:"Přestup",shift:"Přesun",withoutDiscountCard:"Bez slevového průkazu",excs:"OMEZENÍ NA TRASE",noExcs:"BEZ OMEZENÍ NA TRASE",section:"úsek",selConn:"Výběr spojení pro cestu tam",selConnReturn:"Výběr spojení pro cestu zpět",connectionsByTicket:"Spojení podle jízdenky",price:"cena",selectAndContinue:"Zvolit a pokračovat","continue":"Pokračovat",errorIKNumberBirthdate:"Zadejte platnou kombinaci čísla In Karty a data narození.",errorIKNumberCompanyName:"Zadejte platnou kombinaci čísla In Karty a názvu společnosti.",errorDateReturn:"Datum a čas pro zpáteční cestu nesmí být dříve než datum a čas příjezdu cesty tam.",calendarTitle:"Datum a čas jízdy",calendarTitleReturn:"Datum a čas jízdy zpět",changeIn:"Přestup v",withoutChange:"Bez přestupu",ticketThere:"CESTA TAM",ticketBack:"CESTA ZPĚT",czechCurrency:"Kč",priceFrom:"od",cashDeskPrice:"U pokladny",reservationOnly:"Chci jen místenku",reservationOnlyTitle:"Nákup doplňkových služeb bez jízdenky",points:function(n){return n<2?"bod":n<5?"body":"bodů"},hasRes:"Včetně rezervace",hasBusinessRes:"Včetně Business",cashDeskReservation:"Místenka od 35 Kč",incompletePrice:"neúplná cena",loyaltyBonusPoint:"dvojnásobek bodů",priceInNextStep:"Cena v dalším kroku",free:"Zdarma",askForPrice:"Zjistit cenu",askForPricePhone:"+420 221 111 122",askForPriceEmail:"E-mailem",askForPriceCashDesk:"U pokladny ČD",cantBuyInEshop:"Nelze koupit v eShopu ČD",freeRes:"Místenka zdarma",withoutLimit:"bez omezení",delayTitle:"Zpoždění vlaku",legend:"Použité symboly na stránce",filterRes:"Filtrovat výsledky",filterClose:"Zavřít filtr",exDefault:"Jiné opatření",exDelay:"Zpoždění vlaku",exCancellation:"Odřeknutí vlaku",exReplacement:"Náhradní autobusová doprava",exDiversion:"Odklon vlaku",exTimetable:"Výlukový jízdní řád",uploadImgErr:"Obrázek se nepodařilo nahrát.",loaderSearchConnection:"HLEDÁM SPOJENÍ",generatePDF:"Generování PDF",andBack:"a zpět",sendMailConnTitle:"Zaslat spojení e-mailem",psgCount:"Počet osob",prevText:"Novější",nextText:"Starší",prevText2:"Předchozí",nextText2:"Další",loaderLoadTickets:"NAČÍTÁM MOJE JÍZDENKY",checkReservation:"ZJIŠŤUJI DOSTUPNOST REZERVACE",facebookShareConnectionsDescription:function(n,t,i){return"Spojení "+n+" – "+t+". Odjezd "+i},facebookShareConnectionDescription:"Spoj {0} – {1}. Odjezd {2}, Příjezd: {3}, Vlak č. {4}",facebookShareTicketDescription:function(n,t,i){return"Jízdenka "+n+" – "+t+" za "+i+" Kč."},facebookShareTicketWithNameDescription:function(n,t){return"Jízdenka "+n+" za "+t+" Kč."},prevPageText:"Předchozí",nextPageText:"Další",changeTitle:"Přestup",viaTitle:"Přes",favConnsMaxLimit:function(n){return"Do oblíbených spojení si lze uložit maximálně "+n+" spojení. Chcete-li přesto nové spojení přidat, odeberte níže některý z již uložených."},osobu:"osobu",osoby:"osoby",osob:"osob","for":"pro",askForRemoveOwnImage:"Chcete odebrat vybraný vlastní obrázek?",favPassengersRequestTooLarge:"Nezdařilo se zapsat oblíbené cestující, zkuste, prosím, zmenšit požadavek na zápis.",favPassengersError:"Nezdařilo se zapsat oblíbené cestující, zkuste, prosím, zápis provést znovu později.",favPassengersMaxLimit:function(n){return"K oblíbeným cestujícím lze uložit maximálně "+n+" cestujících."},favPassengersMaxLimitAfterRequestConflict:function(n){return"K oblíbeným cestujícím lze uložit maximálně "+n+" cestujících. Chcete-li přesto nového cestujícího přidat, odeberte níže některého z již uložených."},favPassengerWithoutCard:"Bez slevového poukazu",fastBuy:"Koupit zrychleně",fastBuyTitle:"Zrychlený nákup jízdního dokladu",fastBuyModalTitle:"Podmínky pro zrychlený nákup",fastBuyModalText:function(n){return"<ul><li "+((n&ShopCart.FAST_BUY_CONDITIONS.NOT_REGISTERED_OR_LOGGED)==0?"":'class="red"')+">Zaregistrujte se a přihlaste se<\/li>\n                    <li "+((n&ShopCart.FAST_BUY_CONDITIONS.HASNT_FAVOURITE_PASSENGER)==0?"":'class="red"')+">Vytvořte si alespoň jednoho oblíbeného cestujícího<\/li>\n                    <li "+((n&ShopCart.FAST_BUY_CONDITIONS.NOT_ID_OR_IK)==0?"":'class="red"')+">Rychlý nákup lze využít pouze pro oblíbené cestující s vyplněným osobním průkazem / In Kartou<\/li>\n                    <li "+((n&ShopCart.FAST_BUY_CONDITIONS.CD_KREDIT)==0?"":'class="red"')+">Aktivujte si službu ČD Kredit a nabijte dostatečným kreditem<\/li>\n                    "+((n&ShopCart.FAST_BUY_CONDITIONS.CART_GRATIS)==0?"":'<li class="red">Cena nákupu musí být vyšší než 0 Kč<\/li>')+"\n                    "+((n&ShopCart.FAST_BUY_CONDITIONS.CART_NOT_EMPTY)==0?"":'<li class="red">Mějte prázdný nákupní košík<\/li>')+"\n                    "+((n&ShopCart.FAST_BUY_CONDITIONS.PSG_OWN_TICKET)==0?"":'<li class="red">Nakupujte bez zapnuté volby "Pro každého cestujícího vlastní jízdenka"<\/li>')+"<\/ul>\n                    <br />*Zrychlený nákup je možný pouze pro oblíbené cestující a cestu bez doplňkových služeb, rezervace."},buy:"Koupit",priceLabel:"Cena",stationLabel:"Stanice",timeLabel:"Čas",connInfoLabel:"Informace o spojení",arrShort:"příj.",depShort:"odj.",contactFormUrl:"https://www.cd.cz/kontaktni-formular/spoj",soldOut:"Vyprodáno",notGuaranteedTransfer:"Negarantovaný přestup!",eshopCantSell:"Jízdenku není možné koupit v e-shopu ČD. Jízdenku zakoupíte u pokladny nebo u průvodčího.",eshopCantSellCashDesk:"U pokladny nebo u průvodčího zakoupíte jízdenku Integrovaného dopravního systému.",corporateEditAccept:"Nákup v e-shop bude proveden s následujícím nastavením korporátní slevy a SAP:",corporateCompanySAPAccept:"Nákup v e-shop bude proveden s následujícím nastavením SAP. Po potvrzení nebude možné SAP změnit.",corporateCompanySAPDiscountFirst:"Musí být nejprve aplikována firemní sleva.",corporateCompanySAPEditCombination:"Není možné kombinovat firemní a korporátní slevu.",corporateCompanySAPNotFound:"Hodnota SAP nenalezena.",corporateCompanySAPUnknownError:"Neznámá chyba při ukládání SAP.",corporateCompanySAPAcceptError:"Nebylo potrvzeno SAP.",uwsError:"Chyba volání služby UWS.",uwsErrorNotFound:"Litujeme, ale Vámi zadané IČ se nepodařilo ověřit ve veřejně dostupných registrech."},priceSelection:{section:"V úseku"},addServices:{dogTransfer:"přeprava psa",errorCoachNumber:"Zadejte platné číslo vozu.",errorSeatNumber:"Zadejte platné číslo místa. Při zadávání více míst oddělujte jednotlivá místa čárkou.",errorSeatPersonNumber:"Počet míst musí odpovídat počtu osob.",errorDogCompartment:"V rezervovaných oddílech není umožněna přeprava psa.",errorDogSJT:"Zvolenou doplňkovou službu není možno realizovat v případě, kdy je zvolena Rezervace k jízdence OneTicket.",luggageInfo:"přeprava spoluzavazadel",bikeServiceError:"Pro zadanou kombinaci požadovaných služeb není možné vystavit potřebné doklady. Změňte prosím zadání požadovaných služeb.",parkingInfo:'Vozidlo <span class="bl">{0}<\/span> s platností od {1} do {2} ve stanici {3}.',parkingConfirmError:"Pro rezervaci parkovacího místa je nutné potvrdit, že jste byl seznámen s podmínkami prodeje rezervace.",selectService:"Zvolte službu",packagesInvalidCount:"Chybný počet balíčku. Celkový počet balíčků musí odpovídat počtu cestujících.",top:"nahoře",middle:"střed",bottom:"dole",male:"muž",female:"žena",priceFrom:"od",errorOnlyReservations:"Vyberte alespoň jednu doplňkovou službu mimo SMS servis, který je poskytován zdarma pouze při současném nákupu jakéhokoliv dokladu.",compartment:"oddíl",reservation:"Místenky",reservationFree:"Místenky zdarma",berth:"Lůžka",couchette:"Lehátka",packages:"Balíčky služeb",parkingVoucher:"Parkovací voucher",luggageAndBikes:"Kola a zavazadla",dogs:"Přeprava psů",smsInfo:"SMS info zdarma",autoTrain:"Autovlak",catering:"Občerstvení",minCountForObligatory:"Do vlaku(ů) {0} je vyžadována povinná rezervace, přejete si přesto pokračovat?"},userIdentity:{validFrom:"Platnost: od",validTo:"do",valid:"Platnost:",mustPrintTicket:"Chystáte se zakoupit doklady, které musí být před cestou vytištěny ve formátu A4. Jiná forma předložení nebude ve vlaku akceptována.",errorVegaTourConditionsAgreement:"Proveďte souhlas s obchodními podmínkami."},shopCart:{paymentAgreement:"Pro pokračování v platbě musíte potvrdit souhlas s pravidly pro nákup v eShop ČD.",errorPIN:"Zadejte platný PIN pro ověření platby.",errorDiscountCode:"Zadejte platný slevový kód.",validity:"Platnost",inKarta:"In Karta",idCard:"Osobní průkaz",cardHolderName:function(n){return"Osobní průkaz na jméno "+n},inCardNumber:function(n,t){return"In Karta č. "+n+" / "+t},paymentAgreement1_Anonymous:"Pro pokračování v platbě musíte potvrdit souhlas s Podmínkami provozu využívání portálu osobní přepravy Českých drah, a.s. a Pravidly pro nákup v e-shopu ČD.",paymentAgreement2_Anonymous:"Pro pokračování v platbě musíte potvrdit seznámení se s podmínkami Ochrany osobních údajů.",paymentAgreement0:"Pro pokračování v platbě musíte potvrdit souhlas s Pravidly pro nákup v e-shopu ČD.",paymentAgreement4:"Pro pokračování v platbě musíte potvrdit souhlas s Podmínkami provozu využívání portálu osobní přepravy Českých drah, a.s..",paymentAgreement5:"Pro pokračování v platbě musíte potvrdit seznámení se s podmínkami Ochrany osobních údajů.",voucherAdded:"1x Voucher / dobropis ",withoutDiscount:"Bez slevy"},ticketRefund:{toPay:"Částka k vyplacení ",loaderProcessing:"ZPRACOVÁVÁM",toBeRefunded:"Bude vráceno ",toRefund:"K vrácení ",requestForRefund:"Žádost o vrácení ",maxFileSize:"Maximální velikost přílohy je 2MB",disabledExtension:"Povolené typy souborů jsou .JPG, .JPEG, .PNG, .PDF",allSelected:"Pokud chcete vrátit celý doklad, zvolte možnost Vrátit jízdenku",selectReason:"Vyberte důvod",selectReasonError:"Vyberte důvod vrácení dokladu.",reasonTextAttachmentError:"Upřesněte důvod vrácení dokladu nebo vložte přílohu.",fee:"Srážka ",refund:"Uznaná částka "},inKarta:{periodSuffixNew:"(na novou In Kartu)",periodSuffixDuplicate:"(na duplikát In Karty)",periodSuffixPurchase:"(na stávající In Kartu)",railwayTicketPriceInfo:"cena za traťovou jízdenku v dalším kroku",photoSizeTooLarge:"Velikost fotografie je příliš velká.",errorSurnameNameMaxLength:"Délka jména a příjmení nesmí přesáhnout 39 znaků.",errorDOBApp:"Váš věk neodpovídá zvolené aplikaci.",errorLR18:"Zákoný zástupce musí být starší 18 let.",errorPhoneEmail:"Zadejte jeden z údajů: číslo telefonu nebo e-mail.",errorConditionsAgreement:"Proveďte souhlas s obchodními podmínkami a poskytnutím osobních údajů.",errorRechargeEPPrice:"Zadejte platnou částku pro dobití o minimální hodnotě {0}.",errorRechargeEPPriceMax:"Zadaná částka musí být mezi {0} a {1}.",errorCARechargeAmount:"Zadaná částka musí být mezi {0} a {1}.",errorRechargeEPMaxAmount:"Dobití prostředků nelze provést. Prostředky elektronické peněženky dosahují výše jejího limitu.",disabledPhotoExtension:"Povolené typy souborů jsou .JPG, .JPEG, .PNG, .GIF, .SVG, .BMP",surchargeInvoice:"fakturu hradí zaměstnavatel",prolongFormTitle:"Prolongace zaměstnaneckého jízdného",surchargeFormTitle:"Časové příplatky",errorConditionsAgreement_6:"Proveďte souhlas Podmínkami pro vydávání a používání In Karty.",errorConditionsAgreement_7:"Potvrďte seznámení s podmínkami Ochrany osobních údajů.",cardPrice:"poplatek za duplikát",railwayTicketBuyInfo:"Traťovou jízdenku lze zakoupit pouze současně s In Kartou. Pokud nepožadujete In Kartu, nákup samostatné traťové jízdenky musíte provést v osobní pokladně.",idsInfo:"Jízdenku není možné koupit v e-shopu ČD. Jízdenku zakoupíte u pokladny nebo u průvodčího.",prolongFormTitleYear:"pro rok"},otCheck:{notValid:"Doklad zadaného čísla nebyl nalezen",reclamation:"Neplatný doklad - v reklamaci",valid:"Platný",expired:"Expirovaný",notYetValid:"Před začátkem platnosti"}}},localesEn={messages:{app:{today:"Today",tommorow:"Tomorrow",etc:"etc.",freeOfCharge:"Free of charge",dayCount:function(n){return n<2?"day":(n<5,"days")},sessionExpired:"Your session has expired due to a long period of inactivity.",loyaltyPoints:"points",loyaltyPointsSum:"total points",months:["January","February","March","April","May","June","July","August","September","October","November","December"],redirectUrlTitleDefaultParams:"Default settings",close:"I take note",cancel:"Storno",yes:"Yes"},validation:{requiredItem:"Required item.",errorIKNumber:"Please enter a valid In Karta card number.",errorIKNumberDigits:"The value can only be a number (without letters or special characters).",errorBirthdate:"Please enter a valid date of birth.",errorPhone:"Please enter a valid telephone number.",errorCZMobileNumber:"The telephone number entered is not a mobile telephone number.",errorZipCode:"Please enter a valid postal code.",errorCompanyOrName:"Please enter the company name, or the given name and surname.",errorEmail:"Please enter a valid e-mail address.",errorTransactionCode:"Please enter a valid transaction code.",errorTooLargeText:"The text entered is too long.",errorAuthorizationCode:"Please enter a valid payment authorisation code.",errorCreditCardCode:"Please enter a valid payment card number.",errorCarRegistration:"Invalid vehicle registration plate format",errorNumberWidth:"Please enter a dimension between 1 and 200 cm.",errorNumberHeight:"Please enter a dimension between 80 and 200 cm.",errorCreditAccount:"Please enter a valid credit account number.",errorInvalidChars:"The item contains impermissible characters.",errorStationEmpty:"Please enter a station.",errorStationNotExists:"Misspelled or non-existent station.",errorStationAmbiguous:"Ambiguous station name.",errorExistedNickname:"Please enter a different alias; this one is already in use.",errorCodeLength:"Invalid code or code format.",errorNicknameLength:"The minimum number of characters is 3.",errorCardName:"Please enter your name and surname.",errorCardNameLength:"The maximum length is 50 characters.",errorPensionerIdent:"Please enter the number of the Decision on the Granting of a Pension to confirm your eligibility for the discount.",errorNSNotExists:"Misspelled or non-existent cost centre.",errorNSAmbiguous:"Ambiguous cost centre.",errorDiscountNumber:"The value entered is not in the range 0 to 100.",errorSJTNumber:"The OneTicket number is not valid.",errorVegaTourMobileNumber:"Zadejte číslo mobilního telefonu s mezinárodní předvolbou."},connection:{onlyDirectConnections:"Only direct connections",onlyConnWithoutRes:"Only trains without required reservations",maximum:"At most",maxChanges:function(n){var t=parseInt(n);return t<2?"transfer":(t<5,"transfers")},onlyCD:"Only ČD trains",onlyCDPartners:"Trains operated by ČD trains or contractual partners",deltaPMax:"Maximum divergence from the shortest route:",useBeds:"Use sleeper and couchette carriages",noBeds:"Do not use sleeper and couchette carriages",trainTypes:"Transport means",historyTrain:"exclude special and historic trains",except:"except",only:"only",and:"and",psgOwnTicket:"Separate ticket for each passenger",addServices:"Additional services",addServiceReservation:"seat reservation",addServiceDog:"transport a dog",addServiceBike:"transport a bicycle",addServiceSMS:"SMS information service",inTime:"ON TIME",delaylessthan10:"+ less that 10 min.",delay:"DELAY",min:"min.",arr:"ARRIVAL",dep:"DEPARTURE",depShortCut:"Dep.",arrShortCut:"Arr.",waitInStat:"wait time at the station",linkDist:"Transfer time:",linkDistTitle:"Walk",linkDistMain:"Transfer time: approx.",standardChange:"Normal time to transfer",standardChangeTitle:"Transfer",shift:"Walk",withoutDiscountCard:"No discount card",excs:"RESTRICTIONS ON THE ROUTE",noExcs:"NO RESTRICTIONS ON THE ROUTE",section:"segment",selConn:"Select a connection for the outbound journey",selConnReturn:"Select a connection for the return journey",connectionsByTicket:"Connections by ticket",price:"price",selectAndContinue:"Select and continue","continue":"Continue",errorIKNumberBirthdate:"Please enter a valid combination of an In Karta card number and a date of birth.",errorIKNumberCompanyName:"Please enter a valid combination of an In Karta card number and a company name.",errorDateReturn:"The date and time of the return journey must not ve earlier than the date and time of arrival of the outbound journey.",calendarTitle:"Date and time of journey",calendarTitleReturn:"Date and time of the return journey",changeIn:"Transfer at",withoutChange:"No transfers",ticketThere:"OUTBOUND JOURNEY",ticketBack:"RETURN JOURNEY",czechCurrency:"CZK",priceFrom:"from",cashDeskPrice:"In the ticket office",reservationOnly:"I want a reservation only",reservationOnlyTitle:"Purchase additional services without a ticket",points:function(n){return n<2?"point":(n<5,"points")},hasRes:"Including reservation",hasBusinessRes:"Including Business reservation",cashDeskReservation:"Reservation from CZK 35",incompletePrice:"incomplete price",loyaltyBonusPoint:"double points",priceInNextStep:"Price in the next step",free:"Free",askForPrice:"Check price",askForPricePhone:"+420 221 111 122",askForPriceEmail:"By e-mail",askForPriceCashDesk:"In a ČD ticket office",cantBuyInEshop:"Cannot be purchased in the ČD e-shop",freeRes:"Free reservation",withoutLimit:"without restrictions",delayTitle:"Train delay",legend:"Legend",filterRes:"Filter results",filterClose:"Close filter",exDefault:"Other measure",exDelay:"Train delay",exCancellation:"Train cancellation",exReplacement:"Rail replacement bus service",exDiversion:"Train detour",exTimetable:"Closure timetable",uploadImgErr:"Failed to upload image.",loaderSearchConnection:"SEARCHING CONNECTIONS",generatePDF:"Generate PDF",andBack:"and return",sendMailConnTitle:"Send connections by e-mail",psgCount:"Number of persons",prevText:"Newer",nextText:"Older",prevText2:"Previous",nextText2:"Next",loaderLoadTickets:"LOADING MY TICKETS",checkReservation:"CHECKING RESERVATION AVAILABILITY",facebookShareConnectionsDescription:function(n,t,i){return"Connection "+n+" – "+t+". Departure "+i},facebookShareConnectionDescription:"Connection {0} – {1}. Departure {2}, Arrival: {3}, Train no. {4}",facebookShareTicketDescription:function(n,t,i){return"Ticket "+n+" – "+t+" for CZK "+i+"."},facebookShareTicketWithNameDescription:function(n,t){return"Ticket "+n+" for CZK "+t+"."},prevPageText:"Previous",nextPageText:"Next",changeTitle:"Transfer",viaTitle:"Via",favConnsMaxLimit:function(n){return"It is possible to save at most "+n+" connections in favourite connections. If you want to add a new connection anyway, please remove one of the saved ones below."},osobu:"person",osoby:"persons",osob:"persons","for":"for",askForRemoveOwnImage:"Would you like to remove this picture?",favPassengersRequestTooLarge:"Failed to save favourite passengers. Please try to reduce the number of requests.",favPassengersError:"Failed to save favourite passengers. Please try again later.",favPassengersMaxLimit:function(n){return"It is possible to save at most "+n+" passengers in favourite passengers."},favPassengersMaxLimitAfterRequestConflict:function(n){return"It is possible to save at most "+n+" passengers in favourite passengers. If you want to add a new passenger anyway, please remove one of the saved ones below."},favPassengerWithoutCard:"No discount card",fastBuy:"Fast purchase",fastBuyTitle:"Quick travel document purchase",fastBuyModalTitle:"Terms and conditions for fast purchases",fastBuyModalText:function(n){return"<ul><li "+((n&ShopCart.FAST_BUY_CONDITIONS.NOT_REGISTERED_OR_LOGGED)==0?"":'class="red"')+">Register and log in<\/li>\n                    <li "+((n&ShopCart.FAST_BUY_CONDITIONS.HASNT_FAVOURITE_PASSENGER)==0?"":'class="red"')+">Create at least one favourite passenger<\/li>\n                    <li "+((n&ShopCart.FAST_BUY_CONDITIONS.NOT_ID_OR_IK)==0?"":'class="red"')+">A fast purchase can only be made by preferred passengers who have entered their personal information or use an In Karta card<\/li>\n                    <li "+((n&ShopCart.FAST_BUY_CONDITIONS.CD_KREDIT)==0?"":'class="red"')+">Activate the ČD Credit service and recharge your account with a sufficient amount of credit<\/li>\n                    "+((n&ShopCart.FAST_BUY_CONDITIONS.CART_GRATIS)==0?"":'<li class="red">Cena nákupu musí být vyšší než 0 Kč<\/li>')+"\n                    "+((n&ShopCart.FAST_BUY_CONDITIONS.CART_NOT_EMPTY)==0?"":'<li class="red">Make sure your shopping cart is empty<\/li>')+"\n                    "+((n&ShopCart.FAST_BUY_CONDITIONS.PSG_OWN_TICKET)==0?"":'<li class="red">Make your purchase without activating the "Separate ticket for each passenger" option.<\/li>')+"<\/ul>\n                    <br />*A fast purchase can only be made by preferred passengers for journeys without additional services or reservations."},buy:"Buy",priceLabel:"Price",stationLabel:"Station",timeLabel:"Time",connInfoLabel:"Connection information",arrShort:"arr.",depShort:"dep.",contactFormUrl:"https://www.cd.cz/en/kontaktni-formular/spoj",soldOut:"Sold out",notGuaranteedTransfer:"An unguaranteed transfer!",eshopCantSell:"The ticket cannot be purchased in the ČD e-shop. You can purchase the ticket in a ticket office or from a conductor on the train.",eshopCantSellCashDesk:"You can purchase an Integrated Transport System (IDS) ticket in a ticket office or from a conductor on the train.",corporateEditAccept:"Purchases in the ČD e-shop will be made with the following corporate discount settings and SAP ID:",corporateCompanySAPAccept:"Purchases in the ČD e-shop will be made with the following SAP settings. After confirmation it will not be possible to change the SAP ID.",corporateCompanySAPDiscountFirst:"The company discount must be applied first.",corporateCompanySAPEditCombination:"It is not possible to combine company and corporate discounts.",corporateCompanySAPNotFound:"SAP value not found.",corporateCompanySAPUnknownError:"An unknown error occurred while saving the SAP ID.",corporateCompanySAPAcceptError:"Failed to confirm SAP.",uwsError:"An error occurred while calling the UWS service.",uwsErrorNotFound:"We’re sorry, but the ID No. you have entered could not be verified in the publicly accessible registries."},priceSelection:{section:"In the segment"},addServices:{dogTransfer:"transport a dog",errorCoachNumber:"Please enter a valid carriage number.",errorSeatNumber:"Please enter a valid seat number. Separate multiple places by a comma.",errorSeatPersonNumber:"The number of seats must match the number of persons.",errorDogCompartment:"It is not possible to transport a dog in reserved compartments.",errorDogSJT:"Zvolenou doplňkovou službu není možno realizovat v případě, kdy je zvolena Rezervace k jízdence OneTicket.",luggageInfo:"transport oversized luggage",bikeServiceError:"It is not possible to issue the necessary documents for the requested combination of services. Please change your requested services.",parkingInfo:'Vehicle <span class="bl">{0}<\/span> valid from {1} until {2} in the station {3}.',parkingConfirmError:"In order to reserve a parking space, you must confirm that you have been acquainted with the terms and conditions of reservation sales.",selectService:"Select a service",packagesInvalidCount:"Incorrect number of packages. The total number of packages must match the number of passengers.",top:"top",middle:"middle",bottom:"bottom",male:"male",female:"female",priceFrom:"from",errorOnlyReservations:"Please select at least one additional service other than the SMS service, which is provided free of charge with the concurrent purchase of any document.",compartment:"compartment",reservation:"Seat reservations",reservationFree:"Free reservations",berth:"Sleeper berths",couchette:"Couchette berths",packages:"Packages of services",parkingVoucher:"Parking voucher",luggageAndBikes:"Bicycles and luggage",dogs:"Transport for dogs",smsInfo:"Free SMS information",autoTrain:"Automobile train",catering:"Refreshments",minCountForObligatory:"Do vlaku(ů) {0} je vyžadována povinná rezervace, přejete si přesto pokračovat?"},userIdentity:{validFrom:"Validity: from",validTo:"until",valid:"Validity:",mustPrintTicket:"You are about to purchase travel documents which must be printed out in A4 format prior to commencing your journey. Other forms of presenting your travel documents on the train will not be accepted.",errorVegaTourConditionsAgreement:"Proveďte souhlas s obchodními podmínkami."},shopCart:{paymentAgreement:"To continue with your payment, you must confirm that you agree to the Rules for Shopping in the ČD e-shop.",errorPIN:"Please enter a valid PIN to verify the payment.",errorDiscountCode:"Please enter a valid discount code.",validity:"Validity",inKarta:"In Karta",idCard:"Personal identification",cardHolderName:function(n){return"Personal ID card for name "+n},inCardNumber:function(n,t){return"In Karta no. "+n+" / "+t},paymentAgreement1_Anonymous:"To continue with your payment, you must confirm that you agree to the Terms and Conditions of Operation and Use of the ČD Passenger Transport Portal, and with the Rules for Shopping in the ČD E-shop.",paymentAgreement2_Anonymous:"To continue with you payment, you must confirm that you have familiarised yourself with the terms and conditions of Personal Data Protection.",paymentAgreement0:"To continue with your payment, you must confirm that you agree to the Rules for Shopping in the ČD E-shop.",paymentAgreement4:"To continue with your payment, you must confirm that you agree to the Terms and Conditions of Operation and Use of the ČD Passenger Transport Portal.",paymentAgreement5:"To continue with your payment, you must confirm that you have familiarised yourself with the terms and conditions of Personal Data Protection.",voucherAdded:"1x Voucher / credit note ",withoutDiscount:"No discount"},ticketRefund:{toPay:"Amount to be paid out ",loaderProcessing:"PROCESSING",toBeRefunded:"Will be returned ",toRefund:"To be returned ",requestForRefund:"Request for a refund ",maxFileSize:"The maximum attachment size is 2MB",disabledExtension:"The supported file types are .JPG, .JPEG, .PNG and .PDF",allSelected:"If you would like to return the entire travel document, please select the “Return ticket” option.",selectReason:"Please select a reason",selectReasonError:"Please select a reason for returning the document.",reasonTextAttachmentError:"Please specify the reason for returning the document or attach a file.",fee:"Service charge ",refund:"Recognised sum "},inKarta:{periodSuffixNew:"(for a new In Karta card)",periodSuffixDuplicate:"(for a duplicate In Karta card)",periodSuffixPurchase:"(for an existing In Karta card)",railwayTicketPriceInfo:"price for a commuter ticket in the next step",photoSizeTooLarge:"The photo is too large.",errorSurnameNameMaxLength:"The length of the name and surname must not exceed 39 characters.",errorDOBApp:"Your age does not meet the conditions of the selected application.",errorLR18:"The statutory representative must be 18 years of age or older.",errorPhoneEmail:"Please enter one of the following: your telephone number or e-mail address.",errorConditionsAgreement:"Please consent to the general terms and conditions and to the processing of personal information.",errorRechargeEPPrice:"Please enter a valid recharge amount with a minimum value of {0}.",errorRechargeEPPriceMax:"The amount must be between {0} and {1}.",errorCARechargeAmount:"The amount must be between {0} and {1}.",errorRechargeEPMaxAmount:"The recharge cannot be executed. The funds in the electronic wallet are approaching their limit.",disabledPhotoExtension:"Permitted file types are .JPG, .JPEG, .PNG, .GIF, .SVG, .BMP",surchargeInvoice:"the invoice will be paid by the employer",prolongFormTitle:"Extension of an employee fare",surchargeFormTitle:"Time upgrades",errorConditionsAgreement_6:"Please consent to the Terms and Conditions for the Issue and Use of In Karta Cards.",errorConditionsAgreement_7:"Please confirm that you have familiarised yourself with the terms and conditions of Personal Data Protection.",cardPrice:"fee for a duplicate",railwayTicketBuyInfo:"A commuter ticket can only be purchased concurrently with an In Karta card. If you do not require an In Karta card, you must purchase commuter tickets at a ticket counter.",idsInfo:"The ticket cannot be purchased in the ČD e-shop. You can purchase the ticket in a ticket office or from a conductor on the train.",prolongFormTitleYear:"pro rok"},otCheck:{notValid:"No document was found matching the number entered",reclamation:"Not valid - returned ticket",valid:"Valid ticket",expired:"Expired ticket",notYetValid:"Ticket not yet valid"}}},localesDe={messages:{app:{today:"Heute",tommorow:"Morgen",etc:"etc.",freeOfCharge:"Kostenfrei",dayCount:function(n){return n<2?"Tag":(n<5,"Tage")},sessionExpired:"Wegen längerer Untätigkeit ist Ihre Sitzung abgelaufen.",loyaltyPoints:"Punkte",loyaltyPointsSum:"Punkte insgesamt",months:["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],redirectUrlTitleDefaultParams:"Primäre Einstellungen",close:"Ich nehme dies zur Kenntnis",cancel:"Storno",yes:"Ja"},validation:{requiredItem:"Obligatorische Angabe.",errorIKNumber:"Geben Sie die gültige Nummer der In Karta ein.",errorIKNumberDigits:"Der Wert darf nur eine Zahl sein (ohne Buchstaben und Sonderzeichen).",errorBirthdate:"Geben Sie das gültige Geburtsdatum ein.",errorPhone:"Geben Sie eine gültige Telefonnummer ein.",errorCZMobileNumber:"Die eingegebene Telefonnummer ist keine Mobilfunknummer.",errorZipCode:"Gegen Sie eine gültige PLZ ein.",errorCompanyOrName:"Geben Sie den Namen der Firma oder den Namen und Zunamen ein.",errorEmail:"Geben Sie eine gültige E-Mail ein.",errorTransactionCode:"Geben Sie einen gültigen Transaktionscode ein.",errorTooLargeText:"Der eingegebene Text ist zu lang",errorAuthorizationCode:" Geben Sie einen gültigen Code zur Autorisierung der Zahlung ein",errorCreditCardCode:" Geben Sie eine gültige Nummer einer Zahlungskarte ein",errorCarRegistration:"Ungültiges Format des amtlichen Kennzeichens",errorNumberWidth:"Geben Sie ein Maß zwischen 1 und 200 cm ein",errorNumberHeight:"Geben Sie ein Maß zwischen 80 und 200 cm ein",errorCreditAccount:" Geben Sie die gültige Nummer des Kreditkontos ein.",errorInvalidChars:"Der Eintrag umfasst nichtzulässige Zeichen.",errorStationEmpty:"Geben Sie einen Bahnhof ein.",errorStationNotExists:"Fehlerhaft eingegebener oder nicht existierender Bahnhof.",errorStationAmbiguous:"Nicht eindeutig eingegebener Bahnhof.",errorExistedNickname:"Geben Sie einen anderen Nickname ein, dieser wird bereits verwendet.",errorCodeLength:"Der eingegebene Code oder sein Format sind nicht gültig.",errorNicknameLength:"Die Mindestanzahl an Zeichen beträgt 3.",errorCardName:"Geben Sie Name und Zuname ein.",errorCardNameLength:"Die maximale Länge beträgt 50 Zeichen.",errorPensionerIdent:"Geben Sie zur Bestätigung des Anspruchs auf eine Ermäßigung die Nummer der Entscheidung über die Zuerkennung einer Rente ein.",errorNSNotExists:"Fehlerhaft eingegebene oder nicht existente Kostenstelle.",errorNSAmbiguous:"Nicht eindeutig eingegebene Kostenstelle.",errorDiscountNumber:"Der eingegebene Wert liegt nicht zwischen 0 bis 100.",errorSJTNumber:"Nummer des OneTickets nicht gültig.",errorVegaTourMobileNumber:"Zadejte číslo mobilního telefonu s mezinárodní předvolbou."},connection:{onlyDirectConnections:"Nur Direktverbindungen",onlyConnWithoutRes:"Nur Züge ohne Reservierungspflicht",maximum:"Maximal",maxChanges:function(n){var t=parseInt(n);return t<2?"Umstieg":(t<5,"Umstiege")},onlyCD:"Nur Züge der Gesellschaft České dráhy, a.s.",onlyCDPartners:"Züge der Gesellschaft České dráhy a.s. und ihrer Vertragspartner",deltaPMax:"Maximale Abweichung von der kürzesten Strecke:",useBeds:"Schlaf- und Liegewagen nutzen",noBeds:"Keine Schlaf- und Liegewagen nutzen",trainTypes:"Verkehrsmittel",historyTrain:"Keine Sonderzüge und historischen Züge einbeziehen",except:"außer",only:"nur",and:"und",psgOwnTicket:"Für jeden Reisenden eine gesonderte Fahrkarte",addServices:"Ergänzende Leistungen",addServiceReservation:"Platzreservierung",addServiceDog:"Beförderung eines Hundes",addServiceBike:"Beförderung eines Fahrrades",addServiceSMS:"SMS-Infoservice",inTime:"FAHRPLANMÄSSIG",delaylessthan10:"+ bis zu 10 Min.",delay:"VERSPÄTUNG",min:"Min.",arr:"ANKUNFT",dep:"ABFAHRT",depShortCut:"Abf.",arrShortCut:"Ank.",waitInStat:"Warten auf dem Bahnhof",linkDist:"Fußweg:",linkDistTitle:"Fußweg",linkDistMain:"Transfer ca.",standardChange:"Übliche Zeit für Umstieg",standardChangeTitle:"Umstieg",shift:"Fußweg",withoutDiscountCard:"Ohne Ermäßigungsausweis",excs:"EINSCHRÄNKUNGEN AUF DER STRECKE",noExcs:"OHNE EINSCHRÄNKUNGEN",section:"Abschnitt",selConn:"Auswahl der Verbindung für die Hinfahrt",selConnReturn:"Auswahl der Verbindung für die Rückfahrt",connectionsByTicket:"Verbindung gemäß Fahrkarte",price:"Preis",selectAndContinue:"Wählen und weiter","continue":"Weiter",errorIKNumberBirthdate:"Geben Sie eine gültige Kombination der Nummer der In Karta und des Geburtsdatums ein.",errorIKNumberCompanyName:"Geben Sie eine gültige Kombination der Nummer der In Karta und der Bezeichnung der Gesellschaft ein.",errorDateReturn:"Datum und Uhrzeit für die Rückfahrt dürfen nicht vor Datum und Uhrzeit der Ankunft für die Hinfahrt liegen.",calendarTitle:"Datum und Uhrzeit der Fahrt",calendarTitleReturn:"Datum und Uhrzeit der Rückfahrt",changeIn:"Umstieg in",withoutChange:"Ohne Umstieg",ticketThere:"HINFAHRT",ticketBack:"RÜCKFAHRT",czechCurrency:"CZK",priceFrom:"ab",cashDeskPrice:"An Kassenschalter",reservationOnly:"Ich wünsche nur eine Platzkarte",reservationOnlyTitle:"Kauf von ergänzenden Leistungen ohne Fahrkarte",points:function(n){return n<2?"Punkt":(n<5,"Punkte")},hasRes:"Incl. Reservierung",hasBusinessRes:"Incl. Business",cashDeskReservation:"Platzkarte ab 35 CZK",incompletePrice:"unvollständiger Preis",loyaltyBonusPoint:"doppelte Punktzahl",priceInNextStep:"Preis im weiteren Schritt",free:"Kostenfrei",askForPrice:"Preis ermitteln",askForPricePhone:"+420 221 111 122",askForPriceEmail:"per E-Mail",askForPriceCashDesk:"An Kassenschalter der ČD",cantBuyInEshop:"Kann nicht im e-shop der ČD gekauft werden",freeRes:"Platzkarte kostenfrei",withoutLimit:"ohne Einschränkungen",delayTitle:"Verspätung des Zuges",legend:"Auf der Seite verwendete Symbole",filterRes:"Ergebnisse filtern",filterClose:"Filter schließen",exDefault:"Sonstige Maßnahmen",exDelay:"Verspätung des Zuge",exCancellation:"Ausfall des Zuges",exReplacement:"Schienenersatzverkehr mit Bussen",exDiversion:"Umleitung des Zuges",exTimetable:"Fahrplan für Verkehrsbeeinträchtigungen",uploadImgErr:"Bild konnte nicht geladen werden.",loaderSearchConnection:"VERBINDUNG SUCHEN",generatePDF:"PDF generieren",andBack:"und zurück",sendMailConnTitle:"Verbindung per E-Mail senden",psgCount:"Anzahl der Personen",prevText:"Neuer",nextText:"Älter",prevText2:"Vorherige",nextText2:"Weitere",loaderLoadTickets:"ICH LESE MEINE FAHRKARTEN EIN",checkReservation:"ICH STELLE ZUGÄNGLICHKEIT VON RESERVIERUNGEN FEST",facebookShareConnectionsDescription:function(n,t,i){return"Verbindung "+n+" – "+t+". Abfahrt "+i},facebookShareConnectionDescription:"Verbindung {0} – {1}. Abfahrt {2}, Ankunft: {3}, Zug Nr. {4}",facebookShareTicketDescription:function(n,t,i){return"Fahrkarte "+n+" – "+t+" für "+i+" CZK."},facebookShareTicketWithNameDescription:function(n,t){return"Fahrkarte "+n+" für "+t+" CZK."},prevPageText:"Vorherige",nextPageText:"Weiter",changeTitle:"Umstieg",viaTitle:"Über",favConnsMaxLimit:function(n){return"Unter den bevorzugten Verbindungen können maximal "+n+" Verbindungen gespeichert werden. Falls Sie trotzdem eine Verbindung hinzufügen möchten, löschen Sie eine der bereits gespeicherten Verbindungen."},osobu:"Person",osoby:"Personen",osob:"Personen","for":"für",askForRemoveOwnImage:"Möchten Sie das ausgewählte eigene Bild entfernen?",favPassengersRequestTooLarge:"Die Favoriten konnten nicht gespeichert werden. Verringern Sie bitte ihre Anforderung auf Speicherung.",favPassengersError:"Die Favoriten konnten nicht gespeichert werden. Versuchen Sie den Vorgang bitte später noch einmal.",favPassengersMaxLimit:function(n){return"Zu den Favoriten können maximal "+n+" Reisende hinzugefügt werden."},favPassengersMaxLimitAfterRequestConflict:function(n){return"Zu den Favoriten können maximal "+n+" Reisende hinzugefügt werden. Falls Sie trotzdem einen neuen Reisenden hinzufügen möchten, löschen Sie einen der bereits gespeicherten Favoriten."},favPassengerWithoutCard:"Ohne Ermäßigungsausweis",fastBuy:"Expresskauf",fastBuyTitle:"Expresskauf eines Fahrausweises",fastBuyModalTitle:"Bedingungen für einen Expresskauf",fastBuyModalText:function(n){return"<ul><li "+((n&ShopCart.FAST_BUY_CONDITIONS.NOT_REGISTERED_OR_LOGGED)==0?"":'class="red"')+">Registrieren Sie sich und melden Sie sich an<\/li>\n                    <li "+((n&ShopCart.FAST_BUY_CONDITIONS.HASNT_FAVOURITE_PASSENGER)==0?"":'class="red"')+">Richten Sie mindestens einen bevorzugten Passagier ein<\/li>\n                    <li "+((n&ShopCart.FAST_BUY_CONDITIONS.NOT_ID_OR_IK)==0?"":'class="red"')+">Einen Schnellkauf können nur bevorzugte Reisende mit ausgefüllten Personaldaten laut Personalausweis / In Karta nutzen<\/li>\n                    <li "+((n&ShopCart.FAST_BUY_CONDITIONS.CD_KREDIT)==0?"":'class="red"')+">Aktivieren Sie die Leistung ČD Kredit und laden Sie sich hinreichend Kredit auf<\/li>\n                    "+((n&ShopCart.FAST_BUY_CONDITIONS.CART_GRATIS)==0?"":'<li class="red">Cena nákupu musí být vyšší než 0 Kč<\/li>')+"\n                    "+((n&ShopCart.FAST_BUY_CONDITIONS.CART_NOT_EMPTY)==0?"":'<li class="red">Achten Sie auf einen leeren Einkaufskorb<\/li>')+"\n                    "+((n&ShopCart.FAST_BUY_CONDITIONS.PSG_OWN_TICKET)==0?"":'<li class="red">Tätigen Sie Käufe ohne die Funktion "Für jeden Reisenden eine eigene Fahrkarte"<\/li>')+"<\/ul>\n                    <br />*Ein Schnellkauf ist nur für bevorzugte Reisende und eine Fahrt ohne zusätzliche Leistungen oder Reservierungen möglich."},buy:"Kaufen",priceLabel:"Preis",stationLabel:"Bahnhof",timeLabel:"Zeit",connInfoLabel:"Verbindungsinformationen",arrShort:"ank.",depShort:"abf.",contactFormUrl:"https://www.cd.cz/de/kontaktni-formular/spoj",soldOut:"Ausverkauft",notGuaranteedTransfer:"Eine nicht garantierte Überweisung!",eshopCantSell:"Diese Fahrkarte kann nicht im e-shop der ČD gekauft werden. Die Fahrkarte können Sie an einem Kassenschalter oder beim Zugbegleitpersonal erwerben.",eshopCantSellCashDesk:"An einem Kassenschalter oder beim Zugbegleitpersonal können Sie eine Fahrkarte des Integrierten Verkehrssystems erwerben.",corporateEditAccept:"Der Kauf im e-shop erfolgt mit folgender Einstellung einer Firmenermäßigung und SAP ID:",corporateCompanySAPAccept:"Der Kauf im e-shop erfolgt mit folgender SAP-Einstellung. Nach Bestätigung kann die SAP ID nicht geändert werden.",corporateCompanySAPDiscountFirst:"Zuerst muss eine Partnerermäßigung Anwendung finden.",corporateCompanySAPEditCombination:"Eine Kombinierung von Partner- und Firmenermäßigungen ist nicht möglich.",corporateCompanySAPNotFound:"SAP ID nicht gefunden.",corporateCompanySAPUnknownError:"Unbekannter Fehler beim Speichern von SAP ID.",corporateCompanySAPAcceptError:"SAP ID wurde nicht bestätigt.",uwsError:"Fehler bei Kontaktierung der Leistung UWS.",uwsErrorNotFound:"Die Ihrerseits eingegebene ID konnte nicht in öffentlich zugänglichen Registern überprüft werden."},priceSelection:{section:"Im Abschnitt"},addServices:{dogTransfer:"Beförderung eines Hundes",errorCoachNumber:"Geben Sie die gültige Nummer des Wagens ein.",errorSeatNumber:"Geben Sie die gültige Nummer des Platzes ein. Trennen Sie mehrere Plätze durch ein Komma.",errorSeatPersonNumber:"Die Anzahl der Plätze muss der Anzahl der Personen entsprechen.",errorDogCompartment:"In den reservierten Abteilen ist keine Beförderung eines Hundes möglich.",errorDogSJT:"Zvolenou doplňkovou službu není možno realizovat v případě, kdy je zvolena Rezervace k jízdence OneTicket.",luggageInfo:"Beförderung von Sondergepäck",bikeServiceError:"Für die eingegebene Kombination an gewünschten Leistungen können die erforderlichen Fahrausweise bzw. Belege nicht ausgestellt werden. Ändern Sie bitte die Anforderung an die gewünschten Leistungen.",parkingInfo:'Fahrzeug <span class="bl">{0}<\/span> mit einer Gültigkeit vom {1} bis {2} im Bahnhof {3}.',parkingConfirmError:"Für die Reservierung eines Fahrzeugstellplatzes muss bestätigt werden, dass Sie sich mit den Bedingungen für einen Verkauf der Reservierung bekannt gemacht haben.",selectService:"Leistungen wählen",packagesInvalidCount:"Fehlerhafte Anzahl an Paketen. Die Gesamtzahl an Pakten muss der Anzahl der Reisenden entsprechen.",top:"oben",middle:"Mitte",bottom:"unten",male:"Mann",female:"Dame",priceFrom:"ab",errorOnlyReservations:"Wählen Sie mindestens eine ergänzende Leistung außer einem SMS-Service, der nur bei dem gleichzeitigen Kauf eines jedweden Beleges kostenfrei erbracht wird.",compartment:"Abteil",reservation:"Platzkarten",reservationFree:"Platzkarten kostenfrei",berth:"Schlafplätze",couchette:"Liegeplätze",packages:"Leistungpaket",parkingVoucher:"Parkingvoucher",luggageAndBikes:"Fahrräder und Gepäck",dogs:"Beförderung von Hunden",smsInfo:"SMS-Info kostenfrei",autoTrain:"Autoreisezug",catering:"Imbiss/Erfrischung",minCountForObligatory:"Do vlaku(ů) {0} je vyžadována povinná rezervace, přejete si přesto pokračovat?"},userIdentity:{validFrom:"Gültigkeit: von",validTo:"bis",valid:"Gültigkeit:",mustPrintTicket:"Sie kaufen Belege, die vor der Reise im Format A4 ausgedruckt werden müssen. Eine Vorlage in anderer Form wird im Zug nicht akzeptiert.",errorVegaTourConditionsAgreement:"Proveďte souhlas s obchodními podmínkami."},shopCart:{paymentAgreement:"Zur Fortsetzung der Zahlung müssen Sie Ihre Zustimmung zu den Regeln für einen Einkauf im e-shop der ČD erklären.",errorPIN:"Geben Sie eine gültige PIN zur Prüfung der Zahlung ein.",errorDiscountCode:"Geben Sie einen gültigen Ermäßigungscode ein.",validity:"Gültigkeit",inKarta:"In Karta",idCard:"Identitätsausweis",cardHolderName:function(n){return"Persönliche ID für "+n},inCardNumber:function(n,t){return"In Karta no. "+n+" / "+t},paymentAgreement1_Anonymous:"Für eine Fortsetzung der Zahlung müssen Sie Ihre Zustimmung zu den Bedingungen für die Nutzung des Portals für den Personenverkehr der Gesellschaft České dráhy, a.s. und zu den Regeln für einen Einkauf im e-shop der ČD erklären.",paymentAgreement2_Anonymous:"Für eine Fortsetzung der Zahlung müssen Sie bestätigen, dass Sie sich mit den Datenschutzbedingungen vertraut gemacht haben.",paymentAgreement0:"Für eine Fortsetzung der Zahlung müssen Sie Ihre Zustimmung zu den Regeln für einen Einkauf im e-shop der ČD erklären.",paymentAgreement4:"Für eine Fortsetzung der Zahlung müssen Sie Ihre Zustimmung zu den Bedingungen für die Nutzung des Portals für den Personenverkehr der Gesellschaft České dráhy, a.s. erklären.",paymentAgreement5:"Für eine Fortsetzung der Zahlung müssen Sie bestätigen, dass Sie sich mit den Datenschutzbedingungen vertraut gemacht haben.",voucherAdded:"1x Voucher / Gutschrift ",withoutDiscount:"Ohne Ermäßigung"},ticketRefund:{toPay:"Betrag zur Auszahlung ",loaderProcessing:"WIRD BEARBEITET",toBeRefunded:"Wird erstattet ",toRefund:"Zur Erstattung ",requestForRefund:"Antrag auf Erstattung ",maxFileSize:"Die maximale Größe der Anlage beträgt 2 MB",disabledExtension:"Zulässige Dateiformate sind .JPG, .JPEG, .PNG, .PDF",allSelected:"Falls Sie den gesamten Beleg zurückgeben möchten, wählen Sie die Möglichkeit Rückgabe einer Fahrkarte",selectReason:"Wählen Sie den Grund",selectReasonError:"Wählen Sie den Grund für die Rückgabe des Fahrausweises.",reasonTextAttachmentError:"Konkretisieren Sie den Grund für die Rückgabe des Fahrausweises oder fügen Sie eine Anlage an.",fee:"Abzug ",refund:"Zuerkannter Betrag "},inKarta:{periodSuffixNew:"(auf neue In Karta)",periodSuffixDuplicate:"(auf das Duplikat der In Karta)",periodSuffixPurchase:"(auf bisherige In Karta)",railwayTicketPriceInfo:"Preis für die Streckenfahrkarte im weiteren Schritt",photoSizeTooLarge:"Größe der Fotografie zu groß.",errorSurnameNameMaxLength:"Die Länge des Namens und des Zunamens darf 39 Zeichen nicht überschreiten.",errorDOBApp:"Ihr Alter entspricht nicht der gewählten Applikation.",errorLR18:"Der gesetzliche Vertreter muss älter sein als 18 Jahre.",errorPhoneEmail:"Geben Sie nur eine der Angaben ein: Telefonnummer oder E-Mail.",errorConditionsAgreement:"Erklären Sie Ihre Zustimmung zu den Geschäftsbedingungen und zu der Gewährung personenbezogener Daten.",errorRechargeEPPrice:"Geben Sie einen gültigen Betrag zum Aufladen über mindestens {0} ein.",errorRechargeEPPriceMax:"Der eingegebene Betrag muss zwischen {0} und {1} betragen.",errorCARechargeAmount:"Der eingegebene Betrag muss zwischen {0} und {1} betragen.",errorRechargeEPMaxAmount:"Das Aufladen kann nicht erfolgen. Die Mittel der elektronischen Geldbörse haben ihr Limit erreicht.",disabledPhotoExtension:"Zulässige Dateitypen sind .JPG, .JPEG, .PNG, .GIF, .SVG, .BMP",surchargeInvoice:"die Rechnung bezahlt der Arbeitgeber",prolongFormTitle:"Verlängerung eines Arbeitnehmerfahrpreises",surchargeFormTitle:"Zeitgebundene Zuschläge",errorConditionsAgreement_6:"Bitte stimmen Sie den Geschäftsbedingungen für die Ausgabe und die Nutzung einer In Karta zu.",errorConditionsAgreement_7:"Bitte bestätigen Sie die Datenschutzbedingungen.",cardPrice:"Gebühr für ein Duplikat",railwayTicketBuyInfo:"Eine Streckenfahrkarte kann nur zusammen mit einer In Karta gekauft werden. Falls Sie keine In Karta wünschen, müssen Sie den Kauf einer gesonderten Streckenfahrkarte an einem Kassenschalter vornehmen.",idsInfo:"Diese Fahrkarte kann nicht im e-shop der ČD gekauft werden. Die Fahrkarte können Sie an einem Kassenschalter oder beim Zugbegleitpersonal erwerben.",prolongFormTitleYear:"pro rok"},otCheck:{notValid:"Ein Fahrausweis mit der eingegebenen Nummer wurde nicht gefunden",reclamation:"Ungültiger Fahrausweis/Beleg - reklamiert",valid:"Gültig",expired:"Fahrkarten mit abgelaufener Gültigkeitsdauer",notYetValid:"Fahrkarte noch nicht gültig"}}},LogSection,ttCombination,OTCheck,BONUSSERVICES_ICONS,BonusServiceInfo,ConnectionBonusServiceModal,CONN_PAGE_TYPE,SEARCHTYPE,ErrorType,EXCEPTIONEXCLUSION_RULETYPE,CONN_FILTER_PRICE_TYPE,AddServices,UserIdentity,InKarta,ShopCart,Groups,SearchForm,CreditAccout,PriceSelectionNet,Travelpass,__extends,TicketRefund;(function(n){n[n.addServices=0]="addServices"})(LogSection||(LogSection={})),function(n){n[n.CDTIP=7]="CDTIP";n[n.CDAUTO=19]="CDAUTO"}(ttCombination||(ttCombination={}));var Support=function(){function n(){}return n.parseBool=function(n){return!/^(false|0)$/i.test(n)&&!!n},n.padWithZero=function(n,t){return(1e15+n+"").slice(-t)},n.checkValueInInterval=function(n,t,i){return n<t&&(n=t),n>i&&(n=i),n},n.stringIsEmpty=function(n){return!n||n.length==0||!n.trim()},n.formatTimeSubstract=function(t,i){var r="",u=Math.floor(t/60),f=t-u*60;return i?(u>0&&(r=u+" hod."),f>0&&(r=n.append(r,f+" min."," "))):(r=u.toString(),r=n.append(r,n.padWithZero(f.toString(),2),":")),r},n.append=function(n,t,i){return t&&t!=""&&(n&&n!=""?n+=i+t:n=t),n},n.formatMoney=function(n,t,i){if(t===void 0&&(t=!1),i===void 0&&(i=!1),n==-1)return"";var r;return r=n%100==0?i?this.separeteThousands(n/100,0):(n/100).toFixed(0):i?this.separeteThousands(n/100,2):(n/100).toFixed(2),t&&(r=r+" "+App.messages.connection.czechCurrency),r},n.separeteThousands=function(n,t){return n.toFixed(t).replace(/./g,function(n,t,i){return t>0&&n!=="."&&(i.length-t)%3==0?" "+n:n})},n.formatMoneyFree=function(t,i,r){return(i===void 0&&(i=!1),r===void 0&&(r=!0),t==0)?r&&App.messages.app.freeOfCharge||n.formatMoney(t,i):n.formatMoney(t,i)},n.formatPhoneNumber=function(n){return n||(n=""),n=n.replace(/ /g,"").replace(/\+/g,""),n.length==9&&(n=n.replace(/(\d{3})(\d{3})(\d{3})/,"$1 $2 $3")),n.length==12&&(n=n.replace(/(\d{3})(\d{3})(\d{3})(\d{3})/,"+$1 $2 $3 $4")),n.length==14&&(n=n.replace(/(\d{5})(\d{3})(\d{3})(\d{3})/,"$1 $2 $3 $4")),n},n.unifyPhoneNumber=function(n){return n||(n=""),n=n.replace(/ /g,"").replace(/\+/g,""),n=="420"&&(n=""),n.length==9&&(n="+420"+n),n.length==12&&(n="+"+n),n.length==14&&(n="+"+n.substring(2)),n},n.unifyPhoneNumberVegaTour=function(t){return n.stringIsEmpty(t)?"":(t=t.replace(/ /g,"").replace(/\+/g,"").replace(/^0{2}/,""),t.length==11||t.length==12)?"+"+t:""},n.isTouchDevice=function(){return"ontouchstart"in document.documentElement},n.getFirstWord=function(n){return n.split(" ")[0]},n.removeFirstWord=function(n){return n.substr(n.indexOf(" ")+1)},n.isIE9OrBelow=function(){return/MSIE\s/.test(navigator.userAgent)&&parseFloat(navigator.appVersion.split("MSIE")[1])<10},n.formatLoyaltyPoints=function(n,t,i){if(t===void 0&&(t=!1),i===void 0&&(i=!0),n<=0)return"";t&&(n=this.separeteThousands(n,0));var r="+ ";return i||(r=""),r+n+" "+App.messages.app.loyaltyPoints},n.formatLoyaltyPointsSum=function(n,t){return(t===void 0&&(t=!1),n<=0)?"":(t&&(n=this.separeteThousands(n,0)),"+ "+n+" "+App.messages.app.loyaltyPointsSum)},n.randomString=function(n){var t,i,r;for(n===void 0&&(n=20),t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz".split(""),i="",r=0;r<n;r++)i+=t[Math.floor(Math.random()*t.length)];return i},n.getVehicleIcon=function(n,t){n===void 0&&(n=0);t===void 0&&(t=!1);switch(n){case 1:return t?"vehicle-icon-train-g":"vehicle-icon-train-b";case 2:return t?"vehicle-icon-bus-g":"vehicle-icon-bus-b";case 6:return t?"vehicle-icon-boat-g":"vehicle-icon-boat-b";case 9:return t?"vehicle-icon-cableway-g":"vehicle-icon-cableway-b";default:return t?"vehicle-icon-train-g":"vehicle-icon-train-b"}},n.hasPhone=function(t){return n.stringIsEmpty(t)?!1:!n.stringIsEmpty(t.replace(" ","").replace("+420",""))},n.formatIKNumber=function(n){return(n||(n=""),n=n.replace(/ /g,"").replace(/\+/g,""),n.length==18)?n.replace(/(\d{1})(\d{3})(\d{4})(\d{3})(\d{3})(\d{3})(\d{1})/,"$1 $2 $3 $4 $5 $6 $7"):n.length==10?n.replace(/(\d+)(\d{3})(\d{3})(\d{3})/,"$1 $2 $3 $4"):n.length>6&&n.length<10?n.replace(/(\d+)(\d{3})(\d{3})/,"$1 $2 $3"):n},n}(),DateTimeHelper=function(){function n(){}return n.formatDate=function(n,t){var i=moment(n).locale(App.locale).format("D.M.YYYY"),r=moment(n).locale(App.locale).format("ddd");return i&&r&&(i+=" "+r.substring(0,1).toUpperCase()+r.substring(1).toLowerCase()),t&&(this.isToday(n)?i=App.messages.app.today+", "+i:this.isTomorrow(n)&&(i=App.messages.app.tommorow+", "+i)),i},n.formatDateBase=function(n){return moment(n).locale(App.locale).format("D.M.YYYY")},n.toJSDate=function(n){return moment(n).format("D.M.YYYY")},n.toJSDateTime=function(n){return moment(n).format("D.M.YYYY HH:mm")},n.today=function(){return moment().startOf("day").toDate()},n.tomorrow=function(){return moment().startOf("day").add(1,"days").toDate()},n.isToday=function(n){var t=new Date;return this.compareDate(n,t)},n.isTomorrow=function(n){var t=moment(new Date).add(1,"days").toDate();return this.compareDate(n,t)},n.compareDate=function(n,t){return n==null&&t==null?!0:n==null||t==null?!1:n.getDate()==t.getDate()&&n.getMonth()==t.getMonth()&&n.getFullYear()==t.getFullYear()},n.parseDate=function(n){var t=moment(n,["DD.MM.YYYY ddd","DD.MM.YYYY","D.M.YYYY ddd","D.M.YYYY"]);return t.isValid()?t.toDate():new Date},n.parseDateTime=function(n){var t,r,u,i;return n&&n!=""&&(t=n.split(" "),t&&t.length==2&&(r=moment(t[0],["DD.MM.YYYY ddd","DD.MM.YYYY","D.M.YYYY ddd","D.M.YYYY"]),r.isValid()))?(u=t[1].split(":"),i=r.toDate(),new Date(i.getFullYear(),i.getMonth(),i.getDate(),Number(u[0]),Number(u[1]),0,0)):new Date},n.isValidDate=function(n){if(Support.stringIsEmpty(n))return!0;var t=moment(n,["DD.MM.YYYY ddd","DD.MM.YYYY","D.M.YYYY ddd","D.M.YYYY"]);return t.isValid()},n.getDateTime=function(t,i){var u="0",f="0",r;return i&&i!=""&&(r=i.split(":"),r&&r.length>1&&(u=r[0],f=r[1])),n.getDateTimeCore(t,u,f)},n.getDateTimeCore=function(n,t,i){return new Date(n.getFullYear(),n.getMonth(),n.getDate(),Number(t),Number(i),0,0)},n.parseDateSerialized=function(n){return moment(n).startOf("day").toDate()},n.addInterval=function(n,t){var i=parseInt(t);if(t.endsWith("D"))return moment(n).add(i,"days").toDate();if(t.endsWith("M"))return moment(n).add(i,"months").toDate();if(t.endsWith("Y"))return moment(n).add(i,"years").toDate();if(t.endsWith("m"))return moment(n).add(i,"minutes").toDate();if(t.endsWith("H"))return moment(n).add(i,"hours").toDate();throw"invalid interval value "+t;},n.addIntervalDays=function(t,i){if(moment().toDate()<n.parseDate("12.12.2021"))return this.addInterval(t,i);var r=parseInt(i);if(i.endsWith("D"))return moment(t).add(r,"days").toDate();if(i.endsWith("M"))return moment(t).add(r*30,"days").toDate();if(i.endsWith("Y"))return moment(t).add(r*365,"days").toDate();if(i.endsWith("m"))return moment(t).add(r,"minutes").toDate();if(i.endsWith("H"))return moment(t).add(r,"hours").toDate();throw"invalid interval value "+i;},n.formatTime=function(n){if(n<0)return"";if(n===1440)return"24:00";var t=Math.floor(n/60),i=n-t*60;return(t>9?t:"0"+t)+":"+(i>9?i:"0"+i)},n.nextDayDate=function(n,t){var i=new Date;return i.setDate(n.getDate()+(t+(7-n.getDay()))%7),i},n.daysBetweenTwoDates=function(n,t){return Math.round(Math.abs((n.getTime()-t.getTime())/864e5))},n}(),ValidationHelper=function(){function n(){}return n.getNumber=function(n){return n=n.replace(/ /g,""),parseInt(n)},n.isNumber=function(n,t){if(t===void 0&&(t=!1),Support.stringIsEmpty(n))return!t;n=n.replace(/ /g,"");var i=parseInt(n);return isNaN(i)?!1:n===String(i)},n.isNumberMin=function(t,i,r){if(r===void 0&&(r=!1),!n.isNumber(t,r))return!1;t=t.replace(/ /g,"");var u=parseInt(t);return i<=u},n.isNumberRange=function(t,i,r,u){if(u===void 0&&(u=!1),!n.isNumber(t,u))return!1;t=t.replace(/ /g,"");var f=parseInt(t);return i<=f&&f<=r},n.isPhoneNumber=function(n,t,i){var r;return(t===void 0&&(t=""),i===void 0&&(i=!1),Support.stringIsEmpty(n))?!0:(n=n.replace(/ /g,""),t.length>0&&t==n)?!0:i?(r=/^((\+|00)[0-9]{3})?[0-9]+$/,r.test(n)):(r=/^((\+|00)[0-9]{3})?[0-9]{9}$/,r.test(n))},n.isVegaTourMobileNumber=function(n){var t=Support.unifyPhoneNumberVegaTour(n);return t.length<12||t.length>13?!1:this.isCZMobileNumber(t)||this.isSKMobileNumber(t)||this.isPLMobileNumber(t)},n.isCZMobileNumber=function(n){var t,i,r;if(Support.stringIsEmpty(n))return!0;if(n=n.replace(/ /g,""),n.length==14&&n.indexOf("00420")==0&&(n=n.substring(5)),n.length==13&&n.indexOf("+420")==0&&(n=n.substring(4)),n.length!=9)return!1;for(t=0,i=["601","602","603","604","605","606","607","608","702","703","704","705","71","72","73","77","79"];t<i.length;t++)if(r=i[t],n.indexOf(r)==0)return!0;return!1},n.isSKMobileNumber=function(n){var t,i,r;if(Support.stringIsEmpty(n))return!0;if(n=n.replace(/ /g,""),n.length==14&&n.indexOf("00421")==0&&(n=n.substring(5)),n.length==13&&n.indexOf("+421")==0&&(n=n.substring(4)),n.length!=9)return!1;for(t=0,i=["90","91","92","93","94","95","96"];t<i.length;t++)if(r=i[t],n.indexOf(r)==0)return!0;return!1},n.isPLMobileNumber=function(n){var t,i,r;if(Support.stringIsEmpty(n))return!0;if(n=n.replace(/ /g,""),n.length==13&&n.indexOf("0048")==0&&(n=n.substring(4)),n.length==12&&n.indexOf("+48")==0&&(n=n.substring(3)),n.length!=9)return!1;for(t=0,i=["5","6","8"];t<i.length;t++)if(r=i[t],n.indexOf(r)==0)return!0;return!1},n.isEmail=function(n){if(Support.stringIsEmpty(n))return!0;return/^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/.test(n)},n.isIKNumber=function(n){if(Support.stringIsEmpty(n))return!0;n=n.replace(/ /g,"");return/^([0-9]{7,10}|[0-9]{18})$/.test(n)},n.isIKNumberLength=function(n){if(Support.stringIsEmpty(n))return!0;n=n.replace(/ /g,"");return/^(.{7,10}|.{18})$/.test(n)},n.isIKNumberDigits=function(n){if(Support.stringIsEmpty(n))return!0;n=n.replace(/ /g,"");return/^([0-9]+)$/.test(n)},n.isCardNumberID=function(n){if(Support.stringIsEmpty(n))return!0;if(n.length<6||n.length>18)return!1;for(var t=0;t<n.length;t++)if(!this.isLetter(n[t])&&!this.isDigit(n[t]))return!1;return!0},n.isCardNumberIDImproved=function(n){if(Support.stringIsEmpty(n))return!0;var t=/0123|1234|2345|3456|4567|5678|6789|7890|0987|9876|8765|7654|6543|5432|4321|3210/;return t.test(n)?!1:(t=/([0-9])\1{3,}/,t.test(n))?!1:!0},n.isDiscountCode=function(n){if(Support.stringIsEmpty(n))return!0;n=n.replace(/ /g,"");return/^[a-zA-Z0-9]{4}(-)?[a-zA-Z0-9]{4}(-)?[a-zA-Z0-9]{4}$/.test(n)},n.isLetter=function(n){return n.toLowerCase()!=n.toUpperCase()},n.isDigit=function(n){return/^[0-9]$/.test(n)},n.isDigitAll=function(n){return/^[0-9]+$/.test(n)},n.checkRange=function(n,t,i,r){if(r===void 0&&(r=!1),Support.stringIsEmpty(n))return!r;var u=Number(n);return isNaN(u)?!1:t<=u&&u<=i},n.checkRangeNumbers=function(t,i,r,u,f){var e,o,s;if(u===void 0&&(u=!1),f===void 0&&(f=","),Support.stringIsEmpty(t))return!u;for(e=0,o=t.split(f);e<o.length;e++)if(s=o[e],!n.checkRange(s,i,r,u))return!1;return!0},n.checkDate=function(n){var t=moment(n,["D.M.YYYY","DD.MM.YYYY"],App.locale,!1);return t.isValid()},n.checkZipCode=function(n,t){return(t===void 0&&(t=!1),Support.stringIsEmpty(n))?!t:(n=n.replace(" ",""),/^[0-9]{5}$/.test(n))},n.checkIKChars=function(n,t,i){for(var r=0;r<n.length;r++){if(this.isDigit(n[r])){if(!t)return!1;continue}if(!n[r].match(/^[a-zA-ZĚěŠšČčŘřŽžŤťĎďŇňÝýÁáÍíÉéÚúÓóôöÖĹĺĽľůŮüÜäÄ '-]*$/)&&i.indexOf(n[r])==-1)return!1}return!0},n.checkMinLength=function(n,t){return Support.stringIsEmpty(n)?!1:(n=n.replace(/ /g,""),n.length>=t)},n.checkMaxLength=function(n,t){return Support.stringIsEmpty(n)?!0:(n=n.replace(/ /g,""),n.length<=t)},n.isCardName=function(n){return Support.stringIsEmpty(n)?!1:/[!@#$%\^&*(){}[\]<>\/\?|\\=+_]{1,}/.test(n)?!1:/[0-9]{1,}/.test(n)?!1:/[a-zá-ž]{2,} [a-zá-ž]{2,}/ig.test(n)?!0:!1},n.isValidInput=function(n,t){if(Support.stringIsEmpty(n))return!0;if(!Support.stringIsEmpty(t)){var i=new RegExp("["+t+"]","gi");n=n.replace(i,"")}return/[!@#$%\^&*(){}[\]<>\/\?|\\=+_]{1,}/.test(n)?!1:!0},n.isSJTNumber=function(n){var r,u,t;if(Support.stringIsEmpty(n))return!0;if((n=n.replace(/ /g,""),n=n.toUpperCase(),n.length!=14)||(r=["AD","AV","AZ","CD","CE","DL","GV","GW","JD","JH","KC","KZ","LT","MB","RC","RJ","RP","RU","TX","UK"],u=n.substring(0,2),!r.some(function(n){return n==u}))||(t=/[A-Z0-9.]$/,!t.test(n)))return!1;var f=n.match(/[.]/gi),i=0;return(f&&(i=f.length),i>1)?!1:i==1&&n.substring(7,8)!="."?!1:i==1&&(t=/^([A-Z]{2}[0-9]{5}[.P]{1}[A-NP-Z0-9]{6})$/,!t.test(n))?!1:!0},n}(),AjaxHelper=function(){function n(){}return n.initAjaxCalls=function(){$.ajaxSetup({cache:!1});$(document).ajaxError(function(){n.AjaxWaitHide()})},n.AjaxWaitShow=function(n){$("#loader .is-loader-text").html(n);$("body").addClass("wait");window.showLoader("loader")},n.AjaxWaitHide=function(){$("body").removeClass("wait");window.hideLoader("loader")},n}(),DownloadFileWithLoader=function(){function n(){}return n.download=function(t,i,r){try{$("#downloadForm").length<=0&&$('<form id="downloadForm"><input type="hidden" id="download_token_value_id" name="download_token_value_id" /><\/form>').appendTo(t);n.downloadStart(r);var u=document.getElementById("downloadForm");u.action=i;u.submit()}catch(f){AjaxHelper.AjaxWaitHide()}},n.downloadStart=function(t){try{if(!navigator.cookieEnabled)return;AjaxHelper.AjaxWaitShow(t);var i=(new Date).getTime();$("#download_token_value_id").val(String(i));n.fileDownloadCheckTimer=window.setInterval(function(){var t=Cookies.getJSON("downloadwithloader");t&&t.timestamp==i&&n.downloadEnd()},200)}catch(r){AjaxHelper.AjaxWaitHide()}},n.downloadEnd=function(){AjaxHelper.AjaxWaitHide();try{window.clearInterval(n.fileDownloadCheckTimer);Cookies.remove("downloadwithloader")}catch(t){}},n}(),App=function(){function n(){}return n.init=function(t,i,r){t.endsWith("/")||(t+="/");this.urlContext=t;this.ip4AzakDataWS=r;this.initLocales(i);this.initKnockoutValidation();AjaxHelper.initAjaxCalls();n.checkSessionExpiration();this.initBackHandler();ko.applyBindings({},document.getElementById("pageFooter"))},n.initLocales=function(n){switch(n){case"czech":this.locale="cs";this.locales=localesCs;break;case"english":this.locale="en";this.locales=localesEn;break;case"german":this.locale="de";this.locales=localesDe}this.messages=this.locales.messages},n.initKnockoutValidation=function(){ko.validation&&ko.validation.init({insertMessages:!1,decorateInputElement:!0,errorElementClass:"cd-input-danger"})},n.getUrlAction=function(n){return n==""?this.urlContext:(n.endsWith("/")||(n+="/"),this.urlContext+n)},n.getEshopUrlAction=function(n){if(this.urlContext.indexOf("/eshop/")>=0)return this.getUrlAction(n);var t=this.urlContext.replace("/spojeni-a-jizdenka/","/eshop/");return n==""?t:(n.endsWith("/")||(n+="/"),t+n)},n.loadHtml=function(n,t){var i=$.Deferred();return document.getElementById(t)?i.resolve(!1):$.get(n,function(n){$("body").append(n);i.resolve(!0)}),i},n.checkSessionExpiration=function(){var t=Cookies.getJSON("SessionExpired");!t||t.handleLocal||t.handled||(ErrorHandler.showAdvancedError("",n.messages.app.sessionExpired),t.handled=!0,Cookies.set("SessionExpired",t))},n.log=function(n,t){n==LogSection.addServices&&this.logAddServices&&console.log(t)},n.initBackHandler=function(){window.addEventListener("popstate",function(n){n.state=="shopcart"&&(history.replaceState(null,document.title,document.URL),setTimeout(function(){location.reload()},0))})},n.goUrlWithWaitModal=function(t){AjaxHelper.AjaxWaitShow(n.messages.connection.loaderSearchConnection);window.location.href=t},n.GetAntiForgeryToken=function(){return $('input[name="__RequestVerificationToken"]').val()},n.GetAntiForgeryTokenHeader=function(){var n={};return n["X-RequestToken-CD"]=this.GetAntiForgeryToken(),n},n.logAddServices=!1,n}();ko.bindingHandlers.textAfter={update:function(n,t){var i=ko.unwrap(t());$(n).after(i)}};ko.bindingHandlers.canValidate={init:function(n,t){ko.utils.registerEventHandler(n,"blur",function(){t().canValidate()||(t().canValidate(!0),t().notifySubscribers())})}};ko.bindingHandlers.sliderValue={init:function(n,t){ko.utils.registerEventHandler(n,"change",function(n){t()(n.value.newValue)})},update:function(n,t){var i=ko.unwrap(t());i!=undefined&&$(n).slider("setValue",i)}};ko.bindingHandlers.readOnly={update:function(n,t){var i=ko.utils.unwrapObservable(t());i?$(n).attr("readonly","readonly"):$(n).removeAttr("readonly")}};ko.bindingHandlers.masked={init:function(n,t,i){var r=i().mask||{},u,f;u=function(n){var t=0;return(n.selectionStart||n.selectionStart==="0")&&(t=n.selectionStart),t};f=function(n,t){var i;n.setSelectionRange?(n.focus(),n.setSelectionRange(t,t)):n.createTextRange&&(i=n.createTextRange(),i.collapse(!0),i.moveEnd("character",t),i.moveStart("character",t),i.select())};r=i().mask||{};$(n).mask(r);ko.utils.registerEventHandler(n,"blur",function(){var i=t();i($(n).val())});ko.utils.registerEventHandler(n,"keyup",function(){var r=t(),i;i=u(this);r($(n).val());f(this,i)});ko.utils.registerEventHandler(n,"change",function(){})},update:function(n,t){var i=ko.utils.unwrapObservable(t());$(n).val(i)}};ko.bindingHandlers.executeOnEnter={init:function(n,t,i,r){var u=t();$(n).keypress(function(n){var t=n.which?n.which:n.keyCode;return t===13?(u.call(r),!1):!0})}};ko.extenders.canValidate=function(n,t){return n.canValidate=ko.observable(t),n};ko.extenders.inputPattern=function(n,t){var i=ko.pureComputed({read:n,write:function(i){var u=n(),r=i.replace(t,"");r!==u?n(r):i!==u&&n.notifySubscribers(r)}}).extend({notify:"always"});return i(n()),i};String.prototype.endsWith=function(n){return this.length>=n.length&&this.substr(this.length-n.length)==n};String.prototype.format=function(){for(var t=this,i,n=0;n<arguments.length;n++)i=new RegExp("\\{"+n+"\\}","gm"),t=t.replace(i,arguments[n]);return t};var CheckBoxListItem=function(){function n(n,t,i){this.name=ko.observable();this.value=ko.observable();this.checked=ko.observable(!0);this.name(n);this.value(t);this.checked(i)}return n}(),ErrorAdvancedInfo=function(){function n(){this.title=ko.observable("");this.content=ko.observable("");this.buttonAuxUrl=ko.observable("");this.isInfoModal=ko.observable(!1);this.buttonAuxTitle=ko.observable("");this.buttonMainTitle=ko.observable("");this.buttonMainUrl=ko.observable("");this.defaultParams=ko.observable(!1);this.isLoggedUser=ko.observable(!1)}return n.prototype.gotoUrl=function(){var t=this,n;this.defaultParams()?this.isLoggedUser()?(n=new SearchForm.StoreParamsModel,n.params=null,n.services=null,$.post(App.getUrlAction("SaveConnectionParams"),{__RequestVerificationToken:App.GetAntiForgeryToken(),connParams:n},function(n){ErrorHandler.checkErrorsWithInfo(n,t)||(window.location.href=t.buttonAuxUrl())})):(n=new SearchForm.StoreParamsModel,n.clear(),window.location.href=this.buttonAuxUrl()):window.location.href=this.buttonAuxUrl()},n}(),ErrorInfo=function(){function n(n){var t=this;this.message=ko.observable("");this.isVisible=ko.pureComputed(function(){return t.message().length>0},this);this.name=n}return n}(),ErrorHandler=function(){function n(){}return n.getErrorInfoItems=function(n){var i=[],t,r;for(t in n)if(ko.isObservable(n[t]))if(n[t]()instanceof ErrorInfo)i.push(n[t]());else if(n[t]()instanceof Array)for(r=0;r<n[t]().length;r++)this.getErrorInfoItems(n[t]()[r]).forEach(function(n){return i.push(n)});else this.getErrorInfoItems(n[t]()).forEach(function(n){return i.push(n)});return i},n.checkErrors=function(n){return n.sessionExpireRedirectUrl?(window.location.href=n.sessionExpireRedirectUrl,!0):n.isErrorAdvancedModel?(this.showAdvancedError(n.title,n.content,n.isInfoModal,n.buttonAuxTitle,n.buttonAuxUrl,n.buttonMainTitle,n.buttonMainUrl,n.defaultParams,n.isLoggedUser),!0):!1},n.checkErrorsWithInfo=function(n,t){var f,r,e,u,o,i,s;if(n.sessionExpireRedirectUrl)return window.location.href=n.sessionExpireRedirectUrl,!0;for(f=this.getErrorInfoItems(t),r=0,e=f;r<e.length;r++)i=e[r],i.message("");if(n.isErrorAdvancedModel)return this.showAdvancedError(n.title,n.content,n.isInfoModal,n.buttonAuxTitle,n.buttonAuxUrl,n.buttonMainTitle,n.buttonMainUrl,n.defaultParams,n.isLoggedUser),!0;if(n.isErrorModel){for(u=0,o=f;u<o.length;u++)i=o[u],s=n.errors.filter(function(n){return n.name==i.name&&!Support.stringIsEmpty(n.message)}),s.length>0&&i.message(s[0].message);return this.focusFirstError(),!0}return!1},n.focusFirstError=function(){var n=$("*[data-error-focus]").filter(":visible").first(),t;n.length>0&&(t=n.data("error-focus"),$.scrollTo($(t),100))},n.checkSessionExpiration=function(n){n.sessionExpireRedirectUrl&&(window.location.href=n.sessionExpireRedirectUrl)},n.showAdvancedError=function(n,t,i,r,u,f,e,o,s){var h=this,c;i===void 0&&(i=!1);r===void 0&&(r="");u===void 0&&(u="");f===void 0&&(f="");e===void 0&&(e="");o===void 0&&(o=!1);s===void 0&&(s=!1);c=App.getUrlAction("ErrorAdvancedModal");App.loadHtml(c,"errorAdvancedModal").done(function(c){c&&ko.applyBindings(h.errorAdvancedInfo,document.getElementById("errorAdvancedModal"));h.errorAdvancedInfo().title(n);h.errorAdvancedInfo().content(t);$("#errorAdvancedModal").modal("show");h.errorAdvancedInfo().isInfoModal(i);h.errorAdvancedInfo().buttonAuxUrl(u);h.errorAdvancedInfo().defaultParams(o);Support.stringIsEmpty(r)&&(r=App.messages.app.redirectUrlTitleDefaultParams);h.errorAdvancedInfo().buttonAuxTitle(r);h.errorAdvancedInfo().buttonMainUrl(e);Support.stringIsEmpty(f)&&(f=App.messages.app.close);h.errorAdvancedInfo().buttonMainTitle(f);h.errorAdvancedInfo().isLoggedUser(s)})},n.errorAdvancedInfo=ko.observable(new ErrorAdvancedInfo),n}(),InvoiceForm=function(){function n(n,t,i,r){var u=this,f;this.ident=ko.observable();this.isInvoiceSelected=ko.observable(!1);this.isInvoiceDenied=ko.observable(!1);this.company=ko.observable();this.name=ko.observable();this.streetAndNum=ko.observable();this.city=ko.observable();this.zipCode=ko.observable();this.country=ko.observable();this.ic=ko.observable();this.dic=ko.observable();this.dicEnabled=ko.observable(!0);this.vatStates=ko.observableArray();this.vatState=ko.observable();this.sapCustomer=ko.observable();this.error=ko.observable(new ErrorInfo(""));this.doneTimeout=null;this.doneTimeoutShow=2e3;this.isInvoiceSelected(n);this.model=t;this.ident(String(i));this.company(t.company);this.name(t.name);this.streetAndNum(t.streetAndNum);this.city(t.city);this.zipCode(t.zipCode);this.country(t.country);this.ic(t.ic);this.dic(t.dic);this.sapCustomer(t.sapCustomer);this.isInvoiceDenied(r);t.vatStatesList.forEach(function(n){u.vatStates.push(n)});Support.stringIsEmpty(this.dic())||this.dicEnabled(!1);f=!0;this.vatState.subscribe(function(n){if(f&&Support.stringIsEmpty(u.dic())&&$("#invoiceDIC_"+u.ident()).prop("disabled")==!1){u.dic(u.vatStates()[n].stateNameShort);f=!1;return}if(f&&!Support.stringIsEmpty(u.dic())){f=!1;return}(f||$("#invoiceDIC_"+u.ident()).prop("disabled")==!1)&&(u.dic(u.vatStates()[n].stateNameShort),f=!1)});this.vatStates().length>0&&this.vatState(4);this.setValidation();this.errors=ko.validation.group(this);this.error().message("")}return n.prototype.setValidation=function(){var n=this;this.company.extend({canValidate:!1,validation:{onlyIf:function(){return n.company.canValidate()},validator:function(){return n.checkCompanyAndName()},message:App.messages.validation.errorCompanyOrName}});this.name.extend({canValidate:!1,validation:{onlyIf:function(){return n.name.canValidate()},validator:function(){return n.checkCompanyAndName()},message:App.messages.validation.errorCompanyOrName}});this.streetAndNum.extend({canValidate:!1,required:{onlyIf:function(){return n.streetAndNum.canValidate()},message:App.messages.validation.requiredItem}});this.city.extend({canValidate:!1,required:{onlyIf:function(){return n.city.canValidate()},message:App.messages.validation.requiredItem}});this.zipCode.extend({canValidate:!1,required:{onlyIf:function(){return n.zipCode.canValidate()},message:App.messages.validation.requiredItem},validation:{onlyIf:function(){return n.zipCode.canValidate()},validator:function(n){return ValidationHelper.checkZipCode(n)},message:App.messages.validation.errorZipCode}});this.dic.extend({canValidate:!1,required:{onlyIf:function(){return n.dic.canValidate()},message:App.messages.validation.requiredItem}});this.ic.extend({canValidate:!1,required:{onlyIf:function(){return n.ic.canValidate()},message:App.messages.validation.requiredItem}})},n.prototype.checkCompanyAndName=function(){return!Support.stringIsEmpty(this.company())||ValidationHelper.isCardName(this.name())},n.prototype.canSubmit=function(){return!this.isInvoiceDenied()&&(this.company.canValidate(!0),this.name.canValidate(!0),this.streetAndNum.canValidate(!0),this.city.canValidate(!0),this.zipCode.canValidate(!0),this.dic.canValidate(!0),this.errors().length>0)?(this.errors.showAllMessages(),!1):!0},n.prototype.getFormData=function(){var n={},t,i,r;for(n.company=this.company(),n.name=this.name(),n.streetAndNum=this.streetAndNum(),n.city=this.city(),n.zipCode=this.zipCode(),n.country=this.country(),n.ic=this.ic(),n.dic=this.dic(),n.sapCustomer=this.sapCustomer(),n.vatStatesList=[],t=0,i=this.vatStates();t<i.length;t++)r=i[t],n.vatStatesList.push(r);return n.sjt=this.model.sjt,n},n.prototype.checkIC=function(){var i=this,t,n;if(this.error().message(""),this.doneTimeout&&clearTimeout(this.doneTimeout),this.doneTimeout=setTimeout(function(){AjaxHelper.AjaxWaitShow(App.messages.ticketRefund.loaderProcessing)},this.doneTimeoutShow),t=this.dic(),n=!$("#invoiceIC_"+this.ident()).prop("disabled"),n&&(t=this.ic()),!this.validateIC(t,n)){this.doneTimeout&&clearTimeout(this.doneTimeout);AjaxHelper.AjaxWaitHide();return}this.disableInputs();this.clearInputs(n,!1);$.ajax({url:App.getUrlAction("")+"in-karta/checkCustomerInfo?ic="+t+"&isICO="+n+"&checkSAP=false",type:"GET",success:function(t){i.doneTimeout&&clearTimeout(i.doneTimeout);AjaxHelper.AjaxWaitHide();i.setFormData(t,n)}})},n.prototype.setFormData=function(n,t){if(n!=undefined){if(Support.stringIsEmpty(n.errorMessage)||this.error().message(n.errorMessage),n.badVATFormat){this.disableInputs();this.dicEnabled(!0);$("#invoiceIC_"+this.ident()).prop("disabled",!0);return}if(n.notFound){t?(this.ic.canValidate(!1),this.disableInputs(),this.dicEnabled(!0),this.model.sjt?this.clearInputs(t,!1):this.clearInputs(t,!0),this.isInvoiceDenied(!0)):(this.dicEnabled(!1),$("#invoiceIC_"+this.ident()).prop("disabled",!1),this.isInvoiceDenied(!1));return}this.company(n.invoice.company);this.name(n.invoice.name);this.streetAndNum(n.invoice.streetAndNum);this.city(n.invoice.city);this.zipCode(n.invoice.zipCode);this.country(n.invoice.country);this.sapCustomer(n.invoice.sapCustomer);t?this.dic(n.invoice.dic):this.ic(n.invoice.ic);this.enableEmptyInputs(n.hasARESAddress);this.isInvoiceDenied(!1)}},n.prototype.enableEmptyInputs=function(n){var t=!1,i,r;Support.stringIsEmpty(this.ic())&&($("#invoiceIC_"+this.ident()).prop("disabled",!1),t=!0);Support.stringIsEmpty(this.company())&&($("#invoiceCompany_"+this.ident()).prop("disabled",!1),t=!0);i=/\d+/;r=this.streetAndNum();(Support.stringIsEmpty(this.streetAndNum())||r.match(i)==undefined||n)&&($("#invoiceStreetAndNum_"+this.ident()).prop("disabled",!1),t=!0);Support.stringIsEmpty(this.city())&&($("#invoiceCity_"+this.ident()).prop("disabled",!1),t=!0);Support.stringIsEmpty(this.zipCode())&&($("#invoiceZipCode_"+this.ident()).prop("disabled",!1),t=!0);Support.stringIsEmpty(this.country())&&($("#invoiceCountry_"+this.ident()).prop("disabled",!1),t=!0);Support.stringIsEmpty(this.name())&&t&&$("#invoiceName_"+this.ident()).prop("disabled",!1)},n.prototype.disableInputs=function(){this.dicEnabled(!1);$("#invoiceIC_"+this.ident()).prop("disabled",!0);$("#invoiceCompany_"+this.ident()).prop("disabled",!0);$("#invoiceName_"+this.ident()).prop("disabled",!0);$("#invoiceStreetAndNum_"+this.ident()).prop("disabled",!0);$("#invoiceCity_"+this.ident()).prop("disabled",!0);$("#invoiceZipCode_"+this.ident()).prop("disabled",!0);$("#invoiceCountry_"+this.ident()).prop("disabled",!0)},n.prototype.enableInputs=function(){$("#invoiceCompany_"+this.ident()).prop("disabled",!1);$("#invoiceName_"+this.ident()).prop("disabled",!1);$("#invoiceStreetAndNum_"+this.ident()).prop("disabled",!1);$("#invoiceCity_"+this.ident()).prop("disabled",!1);$("#invoiceZipCode_"+this.ident()).prop("disabled",!1);$("#invoiceCountry_"+this.ident()).prop("disabled",!1)},n.prototype.clearInputs=function(n,t){t&&(this.dic(""),this.ic(""));n?this.dic(""):this.ic("");this.city("");this.company("");this.country("");this.name("");this.zipCode("");this.streetAndNum("");this.sapCustomer("")},n.prototype.validateIC=function(n,t){return(t?(this.ic.canValidate(!0),this.dic.canValidate(!1)):(this.dic.canValidate(!0),this.ic.canValidate(!1)),this.company.canValidate(!1),this.name.canValidate(!1),this.streetAndNum.canValidate(!1),this.city.canValidate(!1),this.zipCode.canValidate(!1),this.errors().length>0)?(this.errors.showAllMessages(),!1):!0},n}(),SearchForm;(function(n){var f=function(){function n(){this.date=ko.observable(new Date);this.dateText=ko.observable().extend({validatable:!0});this.arrDep=ko.observable("dep");this.hour=ko.observable();this.minute=ko.observable();this.todayLinkVisible=ko.observable(!0);this.tomorrowLinkVisible=ko.observable(!0);this.modalTitle=ko.observable();this.ignoreCalendarChange=!1;this.selectTimeVisible=ko.observable(!0);this.errors=ko.validation.group(this)}return n.prototype.show=function(n,i){var f=this,u,r;this.model=n;u=this.model.getDatePickerOptions();u!=null?this.setDatepicker(u):this.initDatepicker();r=new t;n.getCalendarParams(r);this.setDate(r.date,!1,!0);this.hour(r.hour);this.minute(r.minute);this.arrDep(r.isDeparture?"dep":"arr");this.modalTitle(r.isReturn?App.messages.connection.calendarTitleReturn:App.messages.connection.calendarTitle);this.minDateTime=DateTimeHelper.getDateTimeCore(this.model.firstValidDate(),r.hour,r.minute);this.todayLinkVisible(this.model.firstValidDate()<=DateTimeHelper.today());this.tomorrowLinkVisible(this.model.firstValidDate()<=DateTimeHelper.tomorrow());this.model.checkMinDateModal()&&(this.hour.subscribe(function(){f.checkminDate()}),this.minute.subscribe(function(){f.checkminDate()}),this.checkminDate());this.selectTimeVisible(i);$(".is-time-plugin-static .is-time-hour").val(this.hour()).trigger("change");$(".is-time-plugin-static .is-time-minute").val(this.minute()).trigger("change")},n.prototype.checkminDate=function(){this.dateText.clearError();var n=new Date(this.date().getFullYear(),this.date().getMonth(),this.date().getDate(),Number(this.hour()),Number(this.minute()),0,0);this.minDateTime>n&&(this.dateText.setError(App.messages.connection.errorDateReturn),this.dateText.isModified(!0))},n.prototype.dateChange=function(){var n=DateTimeHelper.parseDate(this.dateText());this.setDate(n,!1,!0)},n.prototype.indDecDate=function(n,t){t.which===38?this.setDate(moment(this.date()).add(1,"days").toDate(),!1,!0):t.which===40&&this.setDate(moment(this.date()).add(-1,"days").toDate(),!1,!0)},n.prototype.setNow=function(){this.setDate(moment().toDate(),!0,!0)},n.prototype.setInAnHour=function(){this.setDate(moment().add(1,"hours").toDate(),!0,!0)},n.prototype.setInTwoHours=function(){this.setDate(moment().add(2,"hours").toDate(),!0,!0)},n.prototype.setTomorrow=function(){this.setDate(moment().add(1,"days").toDate(),!0,!0)},n.prototype.setDate=function(n,t,i){if(n<this.model.firstValidDate()&&(n=this.model.firstValidDate()),n>this.model.lastValidDate()&&(n=this.model.lastValidDate()),this.date(moment(n).startOf("day").toDate()),this.dateText(DateTimeHelper.formatDate(this.date(),!0)),i){this.ignoreCalendarChange=!0;var r=DateTimeHelper.formatDate(this.date(),!1);$("#calendarModal .cd-datepicker").datepicker("setDate",r)}t&&(this.hour(Support.padWithZero(n.getHours().toString(),2)),this.minute(Support.padWithZero(n.getMinutes().toString(),2)),$(".is-time-plugin-static .is-time-hour").val(this.hour()).trigger("change"),$(".is-time-plugin-static .is-time-minute").val(this.minute()).trigger("change"));this.model.checkMinDateModal()&&this.checkminDate()},n.prototype.done=function(){if(!this.model.checkMinDateModal()||!(this.errors().length>0)){var n=new t;n.date=this.date();n.hour=this.hour();n.minute=this.minute();n.isDeparture=this.arrDep()=="dep";this.model.setCalendarParams(n);$("#calendarModal").modal("hide")}},n.prototype.isDateEnabled=function(n){return this.model.firstValidDate()<=n&&n<=this.model.lastValidDate()},n.prototype.initDatepicker=function(){var n=this,t;$("#calendarModal .cd-datepicker").datepicker("remove");t={language:App.locale,orientation:"top left",autoclose:!0,format:"dd.mm.yyyy D",beforeShowDay:function(t){return{enabled:n.isDateEnabled(t)}},todayHighlight:!0};$("#calendarModal .cd-datepicker").datepicker(t).on("changeDate",function(t){n.ignoreCalendarChange?n.ignoreCalendarChange=!1:n.setDate(t.date,!1,!1)})},n.prototype.setDatepicker=function(n){var t=this;$("#calendarModal .cd-datepicker").datepicker("remove");$("#calendarModal .cd-datepicker").datepicker(n).on("changeDate",function(n){t.ignoreCalendarChange?t.ignoreCalendarChange=!1:t.setDate(n.date,!1,!1)})},n}(),t,i,r,u;n.CalendarModal=f;t=function(){function n(){}return n}();n.DateTimeData=t;i=function(){function n(n,t,i,r,u,f){var e=this,o;this.date=ko.observable();this.isDeparture=ko.observable(!0);this.day=ko.observable("");this.hour=ko.observable();this.minute=ko.observable();this.hasFocus=ko.observable();this.dateText=ko.pureComputed(function(){return DateTimeHelper.formatDate(e.date(),!0)},this);this.dateTextVisible=ko.pureComputed(function(){var n=e.date();return!DateTimeHelper.isToday(n)&&!DateTimeHelper.isTomorrow(n)},this);this.todayEnabled=ko.pureComputed(function(){return DateTimeHelper.today()>=e.firstValidDate()},this);this.parentModel=n;this.selectTimeVisible=f;this.date(DateTimeHelper.parseDate(t));o=i.split(":");this.hour(Support.padWithZero(o[0],2));this.minute(Support.padWithZero(o[1],2));this.isDeparture(r);this.resolveDay();this.day.subscribe(function(n){e.checkDayChange(n)});u&&(this.prevPart=u,this.prevPart.date.subscribe(function(n){e.date()<n&&(e.date(n),e.resolveDay())}))}return n.prototype.setDeparture=function(n){this.isDeparture(n)},n.prototype.showCalendar=function(){this.parentModel.calendarModal.show(this,this.selectTimeVisible)},n.prototype.firstValidDate=function(){return this.prevPart!=null?this.prevPart.date():this.parentModel.firstValidDate},n.prototype.lastValidDate=function(){return this.parentModel.lastValidDate},n.prototype.getCalendarParams=function(n){n.date=this.date();n.hour=this.hour();n.minute=this.minute();n.isDeparture=this.isDeparture();n.isReturn=this.prevPart!=null},n.prototype.setCalendarParams=function(n){this.date(n.date);this.hour(n.hour);this.minute(n.minute);this.isDeparture(n.isDeparture);this.resolveDay()},n.prototype.checkMinDateModal=function(){return!1},n.prototype.checkDayChange=function(){var n=this.date();DateTimeHelper.isToday(n)||this.day()!="today"||this.date(DateTimeHelper.today());DateTimeHelper.isTomorrow(n)||this.day()!="tomorrow"||this.date(DateTimeHelper.tomorrow())},n.prototype.resolveDay=function(){var n=this.date();DateTimeHelper.isToday(n)?this.day("today"):DateTimeHelper.isTomorrow(n)?this.day("tomorrow"):this.day("")},n.prototype.setDatePickerOptions=function(n){this.datePickerOptions=n},n.prototype.getDatePickerOptions=function(){return this.datePickerOptions},n}();n.DateTimePart=i;r=function(){function t(t,r,u,f){var o=this,e;this.dateThere=ko.observable();this.dateBack=ko.observable();this.dateBackVisible=ko.observable(!0);this.isReturn=ko.observable(!1);this.error=ko.observable(new ErrorInfo("DateTime"));this.selectTimeVisible=ko.observable(!0);this.journeyBack=function(){o.isReturn(!0);o.dateBack().hasFocus(!0)};this.cancelJourneyBack=function(){o.error().message("");o.isReturn(!1);o.dateThere().hasFocus(!0)};e=t;this.calendarModal=u;this.isReturn(e.isReturn);this.firstValidDate=DateTimeHelper.parseDate(e.firstValidDate);this.lastValidDate=DateTimeHelper.parseDate(e.lastValidDate);this.dateBackVisible(r!=n.SearchFormType.Disabled&&r!=n.SearchFormType.Groups&&r!=n.SearchFormType.Travelpass&&r!=n.SearchFormType.Travelpass_Int);this.selectTimeVisible(f);this.dateThere(new i(this,e.date,e.time,e.isDeparture,null,f));this.dateBack(new i(this,e.dateReturn,e.timeReturn,e.isDepartureReturn,this.dateThere(),f))}return t.prototype.updateModel=function(n){n.isReturn=this.isReturn();n.date=DateTimeHelper.toJSDate(this.dateThere().date());n.time=this.dateThere().hour()+":"+this.dateThere().minute();n.isDeparture=this.dateThere().isDeparture();n.dateReturn=DateTimeHelper.toJSDate(this.dateBack().date());n.timeReturn=this.dateBack().hour()+":"+this.dateBack().minute();n.isDepartureReturn=this.dateBack().isDeparture()},t}();n.DateTime=r;u=function(){function n(n){var t=this;this.date=ko.observable();this.dateText=ko.pureComputed(function(){return t.date()?DateTimeHelper.formatDate(t.date(),!0):""},this);this.id=ko.observable("");this.isInitialized=!1;this.setDate=function(n){n==null&&$("#"+t.id()).val("");t.date(n)};this.id(Support.randomString(20));this.setDateCallback=n}return n.prototype.init=function(){var n=this,t={language:App.locale,orientation:"bottom left",autoclose:!0,format:"DD d. MM yyyy",todayHighlight:!0};$("#"+this.id()).datepicker("remove").datepicker(t).on("changeDate",function(t){n.setDateCallback(t.date)})},n.prototype.openCalendar=function(){this.isInitialized||(this.isInitialized=!0,this.init());$("#"+this.id()).datepicker("update",this.date());$("#"+this.id()).datepicker("show")},n}();n.SelectDateInput=u})(SearchForm||(SearchForm={})),function(n){var r,t,i;(function(n){n[n.NoLimit=0]="NoLimit";n[n.UseBeds=1]="UseBeds";n[n.NoBeds=2]="NoBeds"})(r=n.ConnectionBeds||(n.ConnectionBeds={}));t=function(){function n(n,t,i){var r=this,u,e,f,o;for(this.selectedTab=ko.observable("connection"),this.tabChanges=ko.observableArray([0,0,0,0,0]),this.onlyDirectConnections=ko.observable(),this.onlyConnWithoutRes=ko.observable(),this.useBed=ko.observable(),this.deltaPMax=ko.observable(),this.deltaPMaxOptions=ko.observableArray(),this.maxChanges=ko.observable(),this.minChangeTime=ko.observable(),this.maxChangeTime=ko.observable(),this.minChangeTimeOptions=ko.observableArray(),this.maxChangeTimeOptions=ko.observableArray(),this.carrier=ko.observable("cdNonCom"),this.trainTypes=ko.observableArray(),this.historyTrain=ko.observable(),this.psgOwnTicket=ko.observable(),this.psgOwnTicketVisible=ko.observable(),this.addServiceReservation=ko.observable(),this.addServiceDog=ko.observable(),this.addServiceBike=ko.observable(),this.addServiceSMS=ko.observable(),this.changeTimeChange=function(n){var i=parseInt(r.minChangeTime()),u=parseInt(r.maxChangeTime()),t;i>u&&(n?(t=r.maxChangeTimeOptions().filter(function(n){return parseInt(n.value)>=i}),r.maxChangeTime(t[0].value)):(t=r.minChangeTimeOptions().filter(function(n){return parseInt(n.value)<=u}),r.minChangeTime(t[t.length-1].value)),$("#connectionParamsModal .cd-select").refreshNiceSelect());r.setTabChanges()},this.setTabChanges=function(){var t=r.parentModel.defaultParams,n=0;return r.onlyDirectConnections()!=t.onlyDirectConnections&&(n+=1),r.onlyConnWithoutRes()!=t.onlyConnWithoutRes&&(n+=1),r.useBed()!=t.useBed&&(n+=1),r.deltaPMax()!=t.deltaPMax&&(n+=1),r.tabChanges()[0]=n,n=0,r.maxChanges()!=t.maxChanges&&(n+=1),r.minChangeTime()!=t.minChangeTime&&(n+=1),r.maxChangeTime()!=t.maxChangeTime&&(n+=1),r.tabChanges()[1]=n,n=0,t.onlyCD&&r.carrier()!="onlyCD"&&(n+=1),t.onlyCDPartners&&r.carrier()!="onlyCDPartners"&&(n+=1),t.cdNonCom&&r.carrier()!="cdNonCom"&&(n+=1),r.tabChanges()[2]=n,n=0,r.trainTypes().forEach(function(t){t.checked()||(n+=1)}),r.historyTrain()||(n+=1),r.tabChanges()[3]=n,n=0,r.psgOwnTicket()!=t.psgOwnTicket&&(n+=1),r.psgOwnTicketVisible()!=t.psgOwnTicketVisible&&(n+=1),r.addServiceReservation()!=t.addServiceReservation&&(n+=1),r.addServiceDog()!=t.addServiceDog&&(n+=1),r.addServiceBike()!=t.addServiceBike&&(n+=1),r.addServiceSMS()!=t.addServiceSMS&&(n+=1),r.tabChanges()[4]=n,r.tabChanges.notifySubscribers(),!0},this.parentModel=n,this.connFilter=t,this.searchForm=i,u=this.parentModel.params,e=this.parentModel.defaultParams,this.deltaPMaxOptions().push({name:App.messages.connection.withoutLimit,value:"-1"}),f=0;f<=100;f+=10)o={name:f+" %",value:f.toString()},this.deltaPMaxOptions().push(o);this.minChangeTimeOptions(u.minChangeTimeOptions);this.maxChangeTimeOptions(u.maxChangeTimeOptions);u.trainTypeItems&&u.trainTypeItems.forEach(function(n){var t=new CheckBoxListItem(n.name,n.value,!0);r.trainTypes().push(t)});this.onlyDirectConnections.subscribe(function(n){n?r.maxChanges("0"):r.maxChanges(e.maxChanges)});this.maxChanges.subscribe(function(){r.setMaxChanges(0)})}return n.prototype.show=function(n,t){this.onlyDirectConnections(n.onlyDirectConnections);this.onlyConnWithoutRes(n.onlyConnWithoutRes);this.useBed(n.useBed);this.deltaPMax(n.deltaPMax);this.maxChanges(n.maxChanges);this.minChangeTime(n.minChangeTime);this.maxChangeTime(n.maxChangeTime);this.carrier(n.onlyCD?"onlyCD":n.onlyCDPartners?"onlyCDPartners":"cdNonCom");this.trainTypes().forEach(function(t){t.checked(n.trainTypes.length==0||n.trainTypes.indexOf(t.value())>=0)});this.historyTrain(n.historyTrain);this.psgOwnTicket(n.psgOwnTicket);this.psgOwnTicketVisible(n.psgOwnTicketVisible);this.addServiceReservation(n.addServiceReservation);this.addServiceDog(n.addServiceDog);this.addServiceBike(n.addServiceBike);this.addServiceSMS(n.addServiceSMS);this.setTabChanges();t&&t!=""&&this.selectedTab(t);$("#connectionParamsModal .cd-select").refreshNiceSelect()},n.prototype.setDefaultParams=function(){this.show(this.parentModel.defaultParams,null);this.setTabChanges()},n.prototype.done=function(){var n=this.parentModel.params;n.onlyDirectConnections=this.onlyDirectConnections();n.onlyConnWithoutRes=this.onlyConnWithoutRes();n.useBed=this.useBed();n.deltaPMax=this.deltaPMax();n.maxChanges=this.maxChanges();n.minChangeTime=this.minChangeTime();n.maxChangeTime=this.maxChangeTime();n.onlyCD=this.carrier()=="onlyCD";n.onlyCDPartners=this.carrier()=="onlyCDPartners";n.cdNonCom=this.carrier()=="cdNonCom";n.trainTypes=this.trainTypes().filter(function(n){return n.checked()}).map(function(n){return n.value()});n.trainTypes.length==this.trainTypes().length&&(n.trainTypes=[]);n.historyTrain=this.historyTrain();n.psgOwnTicket=this.psgOwnTicket();n.psgOwnTicketVisible=this.psgOwnTicketVisible();n.addServiceReservation=this.addServiceReservation();n.addServiceDog=this.addServiceDog();n.addServiceBike=this.addServiceBike();n.addServiceSMS=this.addServiceSMS();this.parentModel.setDescription();this.connFilter&&this.connFilter.filterModal();this.searchForm!=null&&this.searchForm.storeParams2Container()},n.prototype.changeTab=function(n){this.selectedTab(n)},n.prototype.setMaxChanges=function(n){var t=parseInt(this.maxChanges());isNaN(t)&&(t=parseInt(this.parentModel.defaultParams.maxChanges));t+=n;t=Support.checkValueInInterval(t,0,10);this.onlyDirectConnections(t==0);this.maxChanges(t.toString());this.setTabChanges()},n.prototype.incDecMaxChanges=function(n,t){t.which===38?this.setMaxChanges(1):t.which===40&&this.setMaxChanges(-1)},n}();n.ParamsModal=t;i=function(){function n(n,i,r,u,f){var e=this;this.paramsDescription=ko.observable("");this.showParams=function(){e.paramsModal.show(e.params,e.selectedTab)};this.params=n;this.defaultParams=i;this.paramsModal=new t(this,r,f);this.selectedTab=u;this.setDescription();ko.applyBindings(this.paramsModal,document.getElementById("connectionParamsModal"))}return n.prototype.setDescription=function(){var n=this.getDescription();this.paramsDescription(n)},n.prototype.getDescription=function(){var t=[],n=this.params,e,o,s,i,f,u,r;return n.onlyDirectConnections&&t.push(App.messages.connection.onlyDirectConnections),n.onlyConnWithoutRes&&t.push(App.messages.connection.onlyConnWithoutRes),n.useBed=="UseBeds"?t.push(App.messages.connection.useBeds):n.useBed=="NoBeds"&&t.push(App.messages.connection.noBeds),n.deltaPMax!=this.defaultParams.deltaPMax&&(this.paramsModal.deltaPMaxOptions().filter(function(t){return t.value==n.deltaPMax}).length<1&&(n.deltaPMax=this.defaultParams.deltaPMax),e=this.paramsModal.deltaPMaxOptions().filter(function(t){return t.value==n.deltaPMax})[0].name,t.push(App.messages.connection.deltaPMax+" "+e)),(n.maxChanges!=this.defaultParams.maxChanges||n.maxChangeTime!=this.defaultParams.maxChangeTime||n.minChangeTime!=this.defaultParams.minChangeTime)&&(n.onlyDirectConnections||(n.minChangeTimeOptions.filter(function(t){return t.value==n.minChangeTime}).length<1&&(n.minChangeTime=this.defaultParams.minChangeTime),n.maxChangeTimeOptions.filter(function(t){return t.value==n.maxChangeTime}).length<1&&(n.maxChangeTime=this.defaultParams.maxChangeTime),o=n.minChangeTimeOptions.filter(function(t){return t.value==n.minChangeTime})[0].name,s=n.maxChangeTimeOptions.filter(function(t){return t.value==n.maxChangeTime})[0].name,t.push(App.messages.connection.maximum+" "+n.maxChanges+" "+App.messages.connection.maxChanges(n.maxChanges)+" ("+o+" - "+s+")"))),n.onlyCD&&t.push(App.messages.connection.onlyCD),n.onlyCDPartners&&t.push(App.messages.connection.onlyCDPartners),(!n.historyTrain||n.trainTypes.length>0)&&(i="",n.trainTypes.length>0&&(f=n.trainTypeItems.filter(function(t){return n.trainTypes.indexOf(t.value)>=0}).map(function(n){return n.name}),u=n.trainTypeItems.filter(function(t){return n.trainTypes.indexOf(t.value)==-1}).map(function(n){return n.name}),u.length<=2&&u.length>0?i=this.joinTrainTypeNames(App.messages.connection.except,u):f.length>0&&(i=this.joinTrainTypeNames(App.messages.connection.only,f))),n.historyTrain||(i.length>0&&(i+=", "),i+=App.messages.connection.historyTrain),Support.stringIsEmpty(i)||t.push(App.messages.connection.trainTypes+": "+i)),n.psgOwnTicket&&t.push(App.messages.connection.psgOwnTicket),r=[],n.addServiceReservation&&r.push(App.messages.connection.addServiceReservation),n.addServiceDog&&r.push(App.messages.connection.addServiceDog),n.addServiceBike&&r.push(App.messages.connection.addServiceBike),n.addServiceSMS&&r.push(App.messages.connection.addServiceSMS),r.length>0&&t.push(App.messages.connection.addServices+": "+r.join(", ")),t.join(",<br/>")},n.prototype.joinTrainTypeNames=function(n,t){if(t.length==1)return n+" "+t[0];var i=t.pop();return t[t.length-1]=t[t.length-1]+" "+App.messages.connection.and+" "+i,n+" "+t.join(", ")},n.prototype.updateModel=function(n){n.onlyDirectConnections=this.params.onlyDirectConnections;n.onlyConnWithoutRes=this.params.onlyConnWithoutRes;n.useBed=this.params.useBed;n.deltaPMax=this.params.deltaPMax;n.maxChanges=this.params.maxChanges;n.minChangeTime=this.params.minChangeTime;n.maxChangeTime=this.params.maxChangeTime;n.onlyCD=this.params.onlyCD;n.onlyCDPartners=this.params.onlyCDPartners;n.cdNonCom=this.params.cdNonCom;n.trainTypes=this.params.trainTypes;n.historyTrain=this.params.historyTrain;n.psgOwnTicket=this.params.psgOwnTicket;n.addServiceReservation=this.params.addServiceReservation;n.addServiceDog=this.params.addServiceDog;n.addServiceBike=this.params.addServiceBike;n.addServiceSMS=this.params.addServiceSMS},n.prototype.update=function(n,t){(n.onlyDirectConnections!==undefined||t)&&(this.params.onlyDirectConnections=n.onlyDirectConnections);(n.onlyConnWithoutRes!==undefined||t)&&(this.params.onlyConnWithoutRes=n.onlyConnWithoutRes);(n.useBed!==undefined||t)&&(this.params.useBed=n.useBed);(n.deltaPMax!==undefined||t)&&(this.params.deltaPMax=n.deltaPMax);(n.maxChanges!==undefined||t)&&(this.params.maxChanges=n.maxChanges);(n.minChangeTime!==undefined||t)&&(this.params.minChangeTime=n.minChangeTime);(n.maxChangeTime!==undefined||t)&&(this.params.maxChangeTime=n.maxChangeTime);(n.onlyCD!==undefined||t)&&(this.params.onlyCD=n.onlyCD);(n.onlyCDPartners!==undefined||t)&&(this.params.onlyCDPartners=n.onlyCDPartners);(n.cdNonCom!==undefined||t)&&(this.params.cdNonCom=n.cdNonCom);(n.trainTypes!==undefined||t)&&(this.params.trainTypes=n.trainTypes);(n.historyTrain!==undefined||t)&&(this.params.historyTrain=n.historyTrain);(n.psgOwnTicket!==undefined||t)&&(this.params.psgOwnTicket=n.psgOwnTicket);(n.addServiceReservation!==undefined||t)&&(this.params.addServiceReservation=n.addServiceReservation);(n.addServiceDog!==undefined||t)&&(this.params.addServiceDog=n.addServiceDog);(n.addServiceBike!==undefined||t)&&(this.params.addServiceBike=n.addServiceBike);(n.addServiceSMS!==undefined||t)&&(this.params.addServiceSMS=n.addServiceSMS)},n}();n.Params=i}(SearchForm||(SearchForm={})),function(n){var t=function(){function n(){var n=this.load();n!=null&&(this.params=n.params,this.services=n.services)}return n.prototype.getLocalStorageKey=function(){return"searchFormParams"},n.prototype.isLocalStorageSupported=function(){return typeof window.localStorage!="undefined"&&window.localStorage!=null},n.prototype.save=function(n,t){if(this.isLocalStorageSupported){n!=null&&(this.params=n);t!=null&&(this.services=t);var i=JSON.stringify(this);localStorage.setItem(this.getLocalStorageKey(),i)}},n.prototype.load=function(){if(this.isLocalStorageSupported){var n=localStorage.getItem(this.getLocalStorageKey());if(n!=null&&n.length>0)return JSON.parse(n)}return null},n.prototype.clear=function(){if(this.isLocalStorageSupported)var n=localStorage.removeItem(this.getLocalStorageKey());return null},n}();n.StoreParamsModel=t}(SearchForm||(SearchForm={})),function(n){var t=function(){function n(n,t,i){var r=this;this.typeID=ko.observable();this.count=ko.observable();this.age=ko.observable();this.cardIDs=Array();this.isFavourite=ko.observable();this.isDefault=ko.observable();this.isSelected=ko.observable();this.nickname=ko.observable();this.phone=ko.observable();this.cardTypeID=ko.observable();this.ikNumber=ko.observable();this.fullname=ko.observable();this.birthdate=ko.observable();this.companyName=ko.observable();this.hasAvatar=ko.observable();this.avatar=ko.observable();this.image=ko.observable();this.personTypeInfo=ko.observable();this.cardsInfo=ko.observable();this.showPhotoModal=function(){r.allPassengers.showPhotoModal(r)};this.mapData=n;this.deserialize(t);this.setPersonTypeAndCardsInfo();this.allPassengers=i;this.checkHasAvatar()}return Object.defineProperty(n.prototype,"typeName",{get:function(){var t=this,n;return this.mapData?(n=this.mapData.passengers.filter(function(n){return n.id==t.typeID()})[0],n.name):""},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"countName",{get:function(){return this.count()?this.count()+"x":""},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cardNames",{get:function(){var n=this,t,i;return this.mapData?(t=this.mapData.passengers.filter(function(t){return t.id==n.typeID()})[0],i=t.cards.filter(function(t){return n.cardIDs.indexOf(t.id)>=0}).map(function(n){return n.name}),i.join(", ")):""},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"getCardNumber",{get:function(){if(this.cardTypeID()==1)return this.ikNumber()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"getCardNames",{get:function(){var n=this,t,i;return this.mapData?(t=this.mapData.passengers.filter(function(t){return t.id==n.typeID()})[0],i=t.cards.filter(function(t){return n.cardIDs.indexOf(t.id)>=0}).map(function(n){return n.name}),i):[]},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"getAvatar",{get:function(){return this.image()&&this.image()!==""?this.image():this.avatar()&&this.avatar()!==""?this.allPassengers.avatars.imagePath+this.avatar():void 0},enumerable:!0,configurable:!0}),n.prototype.setPersonTypeAndCardsInfo=function(){var n=[],t;this.nickname()?(n.push(this.nickname()),n.push(this.typeName)):n.push(this.countName+" "+this.typeName);this.personTypeInfo(n.join(", "));t=this.cardNames;this.cardsInfo(t.length>0?t:App.messages.connection.withoutDiscountCard)},n.prototype.deserialize=function(n){return this.id=n.id,this.typeID(n.typeID),this.count(n.count),this.age(n.age.toString()),this.ageState=n.ageState,this.cardIDs=n.cardIDs||[],this.isFavourite(n.isFavourite),this.isDefault(n.isDefault),this.isSelected(n.isSelected),this.nickname(n.nickname),this.phone(n.phone),this.cardTypeID(n.cardTypeID),this.fullname(n.fullname),n.cardTypeID==1&&this.ikNumber(n.cardNumber),this.birthdate(n.birthdate),this.avatar(n.avatar),this.image(n.image),this.companyName(n.companyName),this},n.prototype.serialize=function(){var n={};return n.id=this.id,n.typeID=this.typeID(),n.count=this.count(),n.age=parseInt(this.age()),n.ageState=this.ageState,n.cardIDs=this.cardIDs,n.isFavourite=this.isFavourite(),n.isDefault=this.isDefault(),n.isSelected=this.isSelected(),n.nickname=this.nickname(),n.phone=this.phone(),n.cardTypeID=this.cardTypeID(),n.fullname=this.fullname(),n.cardTypeID==1&&(n.cardNumber=this.ikNumber()),n.birthdate=this.birthdate(),n.avatar=this.avatar(),n.image=this.image(),n.companyName=this.companyName(),n},n.prototype.checkHasAvatar=function(){this.hasAvatar(this.image()&&this.image()!==""||this.avatar()&&this.avatar()!=="")},n}(),i,r;n.Passenger=t;i=function(){function i(t,i,r,u,f,e,o,s,h){var c=this;this.isVisible=ko.observable(!0);this.passengers=ko.observableArray();this.passengerId=1;this.error=ko.observable(new ErrorInfo("Passengers"));this.addPassenger=function(){c.passengersModal.show(c);c.allPassengers.filter(function(n){return n.isFavourite}).length===0&&c.passengersModal.addPassenger()};this.showModal=function(){c.passengersModal.show(c)};this.showAgeModal=function(n,t){c.passengersAgeModal.show(n,t,c)};this.showPhotoModal=function(n){c.passengersPhotoModal.show(n,c)};this.setPassengerId=function(n){n.id=c.passengerId;c.passengerId++};this.parentModel=r;this.avatars=t.avatars;u.init(this);f.init(this,s);e.init(this);o.init(this);this.params=h;r.areModalsInited=!0;t.passengers.forEach(function(n){c.setPassengerId(n)});this.mapData=t.mapData;this.allPassengers=t.passengers;this.defaultPassenger=t.defaultPassenger;this.isVisible(i!=n.SearchFormType.Disabled&&i!=n.SearchFormType.Groups);this.showPassengers();this.passengersModal=u;this.passengersFavouriteModal=f;this.passengersAgeModal=e;this.passengersPhotoModal=o}return i.prototype.showPassengers=function(){var n=this;this.passengers.removeAll();this.allPassengers.forEach(function(i){if(i.isSelected){var r=new t(n.mapData,i,n);n.passengers.push(r)}})},i.prototype.updatePassengers=function(n){var t=this;this.allPassengers=[];n.forEach(function(n){return t.allPassengers.push(n)});this.showPassengers()},i.prototype.updateModel=function(n,t){n.passengers=t?this.allPassengers:this.allPassengers.filter(function(n){return n.isSelected})},i}();n.Passengers=i;r=function(){function n(){var n=this;this.selectedAvatar=ko.observable();this.isImageSelected=ko.observable();this.uploadErr=ko.observable();this.canUploadImage=ko.observable();this.hasPassengerImage=ko.observable();this.selectedImage=ko.observable();this.selectAvatar=function(t){if(n.isImageSelected()||n.hasPassengerImage())if(confirm(App.messages.connection.askForRemoveOwnImage)){n.isImageSelected(!1);n.canUploadImage(!1);n.hasPassengerImage(!1);n.selectedImage("");n.passenger.image("");n.resetImage();var i=n;n.uploadCrop.croppie("bind",{url:i.parentModel.avatars.defaultAvatarPath})}else return;n.selectedAvatar(t)};this.show=function(t,i){n.parentModel=i;n.passenger=t;n.hasPassengerImage(n.passenger&&n.passenger.image()&&n.passenger.image()!=="");n.selectedImage(n.hasPassengerImage()?n.passenger.image():"");n.hasPassengerImage()?n.selectedAvatar(""):n.selectedAvatar(n.passenger&&n.passenger.avatar()&&n.passenger.avatar()!==""?n.passenger.avatar():"");n.isImageSelected(!1);n.canUploadImage(!1);n.resetImage()};this.done=function(){n.isImageSelected()?n.getImage(n.saveImageCallback):n.selectedAvatar()!==""&&(n.passenger.avatar(n.selectedAvatar()),n.passenger.hasAvatar(!0));$("#passengersPhotoModal").on("hidden.bs.modal",function(){$("body").addClass("modal-open")})};this.showUpload=function(){n.canUploadImage(!0);n.initImgUpload()};this.saveImageCallback=function(t){if(t.length>24e5){n.uploadErr(App.messages.inKarta.photoSizeTooLarge);return}n.selectedImage(t);n.passenger.image(t);n.passenger.avatar("");n.passenger.hasAvatar(!0);n.uploadErr("");n.canUploadImage(!1);n.resetImage();var i=n;n.uploadCrop.croppie("bind",{url:i.parentModel.avatars.defaultAvatarPath})};this.getImage=function(n){$("#upload-div").croppie("result",{type:"canvas",size:{height:134,width:134},format:"png"}).then(function(t){n(t)})};this.resetImage=function(){$("#upload").val("")}}return n.prototype.init=function(n){this.parentModel=n;this.canUploadImage(!1);this.isImageSelected(!1);this.hasPassengerImage(!1);this.uploadErr("")},n.prototype.checkInitializedImgUpload=function(){$("#upload-div").croppie("destroy")},n.prototype.initImgUpload=function(){if(this.checkInitializedImgUpload(),this.uploadErr(""),!Support.isIE9OrBelow()){var n=this;this.uploadCrop=$("#upload-div").croppie({viewport:{width:120,height:120,type:"circle"},boundary:{width:150,height:150},url:n.parentModel.avatars.defaultAvatarPath});$("#upload").on("change",function(){n.readFile(this)})}},n.prototype.readFile=function(n){if(n.files&&n.files[0]){var i=new FileReader,t=this;i.onload=function(n){t.uploadCrop.croppie("bind",{url:n.target.result});t.selectedAvatar("");t.passenger.hasAvatar(!1);t.isImageSelected(!0);t.uploadErr("")};i.readAsDataURL(n.files[0])}else this.canUploadImage()&&this.uploadErr(App.messages.connection.uploadImgErr)},n}();n.PassengersPhotoModal=r}(SearchForm||(SearchForm={}));__extends=this&&this.__extends||function(){var n=function(t,i){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i])},n(t,i)};return function(t,i){function r(){this.constructor=t}n(t,i);t.prototype=i===null?Object.create(i):(r.prototype=i.prototype,new r)}}(),function(n){var r=function(n){function t(t,i,r,u){var f=n.call(this,t,i,r)||this;return f.countryOption=u,f}return __extends(t,n),t.prototype.addCardCount=function(n){var t=n.checked()?1:-1;return this.countryOption.cardCount(this.countryOption.cardCount()+t),!0},t}(CheckBoxListItem),i,t,u;n.PassengerCardOption=r;i=function(){function n(n,t){var i=this;this.name=ko.observable();this.cardCount=ko.observable(0);this.cardOptions=Array();this.setCardsStart=function(n){i.cardCount(0);i.cardOptions.forEach(function(t){var i=n.indexOf(parseInt(t.value()))>=0;t.checked(i);i&&t.countryOption.cardCount(t.countryOption.cardCount()+1)})};this.setCardsDone=function(n){i.cardOptions.filter(function(n){return n.checked()}).forEach(function(t){return n.push(parseInt(t.value()))})};this.parent=n;this.name(t);this.cardOptions=[]}return n}();n.PassengerCountryOption=i;t=function(n){function t(t,i,r){var u=n.call(this,t,i,r.parentModel)||this;return u.addToFavourites=ko.observable(),u.typeOptions=ko.observableArray(),u.countryOptions=ko.observableArray(),u.selectedCountry=ko.observable(),u.firstChange=!0,u.changeCountry=function(n){u.selectedCountry(n)},u.setCardsStart=function(){u.countryOptions().forEach(function(n){n.setCardsStart(u.cardIDs)})},u.setCardsDone=function(){u.cardIDs=u.getSelectedCardsIDs();u.setPersonTypeAndCardsInfo();window.closeDropdown("psgDropdown"+u.id,"psgDropdownToggle"+u.id)},u.parent=r,t.passengers.forEach(function(n){var t={name:n.name,value:n.id.toString()};u.typeOptions.push(t)}),u.setCountriesAndCards(),u.typeID.subscribe(function(){if(u.firstChange){u.firstChange=!1;return}u.cardIDs=[];u.setPersonTypeAndCardsInfo();u.setCountriesAndCards()}),u}return __extends(t,n),t.prototype.getSelectedCardsIDs=function(){var n=[];return this.countryOptions().forEach(function(t){t.setCardsDone(n)}),n},t.prototype.setCountriesAndCards=function(){var n=this,u=this.mapData.passengers.filter(function(t){return t.id==n.typeID()})[0],t=Array();this.countryOptions.removeAll();u.cards.forEach(function(u){var f,e,o;t[u.country]||(f=new i(n,u.country),t[u.country]=f,n.countryOptions.push(f));e=t[u.country];o=new r(u.name,u.id.toString(),!1,e);e.cardOptions.push(o)});this.selectedCountry(this.countryOptions()[0])},t.prototype.setCount=function(n){var i=this.parent.maxPassengersCount-this.parent.totalCount()+this.count(),t=this.count()+n;t=Support.checkValueInInterval(t,1,i);t>1&&this.addToFavourites(!1);this.count(t);this.parent.checkPassengersCount()},t.prototype.addToFavourite=function(){this.addToFavourites(!0)},t.prototype.removeFromFavourite=function(){this.addToFavourites(!1)},t}(n.Passenger);n.PassengerEdit=t;u=function(){function n(){var n=this;this.favourite=ko.observableArray();this.favouriteSelected=ko.observableArray();this.favouriteNotSelected=ko.observableArray();this.anonymous=ko.observableArray();this.canAddPassenger=ko.observable(!1);this.maxPassengersCount=36;this.psgOwnTicket=ko.observable(!1);this.psgOwnTicketVisible=ko.observable(!1);this.canRemovePassenger=ko.computed(function(){return n.anonymous().length==0&&n.favouriteSelected().length==1?!0:n.favouriteSelected().length+n.anonymous().length>1},this);this.addToFavourites=ko.computed(function(){return n.anonymous().filter(function(n){return n.addToFavourites()}).length>0},this);this.addPassenger=function(){var i=new t(n.parentModel.mapData,n.parentModel.defaultPassenger,n);n.parentModel.setPassengerId(i);n.anonymous.push(i);$("#passengersModal .cd-select").refreshNiceSelect();$(".cd-drop-form").cd_drop_form();n.checkPassengersCount()};this.removePassenger=function(t){n.anonymous.remove(t);n.checkPassengersCount()};this.selectFavourite=function(t){t.isSelected(!0);n.favouriteNotSelected.remove(t);n.favouriteSelected.push(t);n.checkPassengersCount()};this.deselectFavourite=function(t){t.isSelected(!1);n.favouriteSelected.remove(t);n.favouriteNotSelected.push(t);n.favouriteSelected().length==0&&n.anonymous().length==0&&n.addPassenger();n.checkPassengersCount()};this.done=function(){var t=n.getAllPassengers(),i;t.allPassengers.forEach(function(n){return n.age=-1});n.parentModel.allPassengers=t.allPassengers;n.parentModel.params!=null&&(i=n.psgOwnTicket()&&n.totalCount()>1,n.parentModel.params.params.psgOwnTicket=i,n.parentModel.params.setDescription());n.parentModel.showPassengers()};this.showFavourites=function(){var t=n.getAllPassengers();n.parentModel.passengersFavouriteModal.show(t.allPassengers,t.addToFavourites,n.parentModel)};this.setDefaultPassengers=function(){n.setDefaultPassengersSettings()}}return n.prototype.init=function(n){this.parentModel=n;this.checkPassengersCount()},n.prototype.show=function(n){var i=this;this.parentModel=n;this.checkPassengersCount();this.favourite.removeAll();this.favouriteSelected.removeAll();this.favouriteNotSelected.removeAll();this.anonymous.removeAll();this.parentModel.allPassengers.forEach(function(n){var r=new t(i.parentModel.mapData,n,i);i.parentModel.setPassengerId(r);n.isFavourite?(n.isSelected?i.favouriteSelected.push(r):i.favouriteNotSelected.push(r),i.favourite.push(r)):n.isSelected&&i.anonymous.push(r);$("#passengersModal .cd-select").refreshNiceSelect();$(".cd-drop-form").cd_drop_form()});n.params!=null&&(this.psgOwnTicket(n.params.params.psgOwnTicket),this.psgOwnTicketVisible(n.params.params.psgOwnTicketVisible));this.checkPassengersCount()},n.prototype.totalCount=function(){var n=0;return this.favouriteSelected().forEach(function(t){return n+=t.count()}),this.anonymous().forEach(function(t){return n+=t.count()}),n},n.prototype.checkPassengersCount=function(){this.canAddPassenger(this.totalCount()<this.maxPassengersCount)},n.prototype.getAllPassengers=function(){var i=this,n=[],t=[];return this.favourite().forEach(function(t){return n.push(t.serialize())}),this.anonymous().forEach(function(r){i.splitFavouritePassengers(n,t,r)}),{allPassengers:n,addToFavourites:t}},n.prototype.splitFavouritePassengers=function(n,t,i){var u,r;if(i.addToFavourites())for(u=0;u<i.count();u++)r=i.serialize(),r.count=1,u>0&&this.parentModel.setPassengerId(r),t.push(r),n.push(r);else n.push(i.serialize())},n.prototype.setDefaultPassengersSettings=function(){var n=this;this.favourite.removeAll();this.favouriteSelected.removeAll();this.favouriteNotSelected.removeAll();this.anonymous.removeAll();this.parentModel.allPassengers.forEach(function(i){var r=new t(n.parentModel.mapData,i,n);i.isFavourite&&(n.parentModel.setPassengerId(r),i.isDefault?(r.isSelected(!0),n.favouriteSelected.push(r)):(r.isSelected(!1),n.favouriteNotSelected.push(r)),n.favourite.push(r),$("#passengersModal .cd-select").refreshNiceSelect(),$(".cd-drop-form").cd_drop_form())});this.parentModel.allPassengers.some(function(n){return n.isDefault&&n.isFavourite})||this.addPassenger()},n}();n.PassengersModal=u}(SearchForm||(SearchForm={}));__extends=this&&this.__extends||function(){var n=function(t,i){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i])},n(t,i)};return function(t,i){function r(){this.constructor=t}n(t,i);t.prototype=i===null?Object.create(i):(r.prototype=i.prototype,new r)}}(),function(n){var t=function(n){function t(t,i,r){var u=n.call(this,t,i,r)||this;return u.age.subscribe(function(){u.setAge(0)}),u}return __extends(t,n),t.prototype.incDecAge=function(n,t){t.which===38?this.setAge(1):t.which===40&&this.setAge(-1)},t.prototype.setAge=function(n){var r=this,i=this.mapData.passengers.filter(function(n){return n.id==r.typeID()})[0],t=parseInt(this.age());isNaN(t)&&(t=i.ageFrom);t+=n;t=Support.checkValueInInterval(t,i.ageFrom,i.ageTo);this.age(t.toString())},t}(n.Passenger),i;n.PassengerAge=t;i=function(){function n(){var n=this;this.passengers=ko.observableArray();this.done=function(){var i=n.passengers().map(function(n){return n.id}),t=[];n.parentModel.allPassengers.forEach(function(n){i.indexOf(n.id)==-1&&t.push(n)});n.passengers().forEach(function(n){t.push(n.serialize())});n.parentModel.allPassengers=t;n.parentModel.showPassengers();AjaxHelper.AjaxWaitShow(App.messages.connection.loaderSearchConnection);n.parentModel.parentModel.searchConnections()}}return n.prototype.init=function(n){this.parentModel=n},n.prototype.show=function(n,i,r){var u=this;this.parentModel=r;this.passengers.removeAll();this.parentModel.allPassengers.forEach(function(r){var e,f;if(n.indexOf(r.id)>=0)for(e=0;e<r.count;e++)f=new t(u.parentModel.mapData,r,u.parentModel),f.count(1),f.setAge(0),f.setPersonTypeAndCardsInfo(),e>0&&u.parentModel.setPassengerId(f),f.ageState=i,u.passengers.push(f)});$("#passengersAgeModal").modal("show")},n}();n.PassengersAgeModal=i}(SearchForm||(SearchForm={}));__extends=this&&this.__extends||function(){var n=function(t,i){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i])},n(t,i)};return function(t,i){function r(){this.constructor=t}n(t,i);t.prototype=i===null?Object.create(i):(r.prototype=i.prototype,new r)}}(),function(n){var t=function(n){function t(t,i,r,u){var f=n.call(this,i,r,t.parentModel)||this,e;return f.birthdateValue=ko.observable(),f.isINB=ko.observable(!1),f.ikCardHolderValue=ko.observable(),f.ikCardBusinessNameTO=null,f.ikCardBusinessNameTimeout=1e3,f.toggleIsDefault=function(){var n=!f.isDefault();n&&f.parentModel.passengers().forEach(function(n){f!==n&&n.isDefault(!1)});f.isDefault(n)},f.parentModel=t,f.cardTypeID(0),f.dobIdSufix=String(u),f.dobErrTop=!1,f.dob=new DOBPicker(f),f.setValidation(),f.errors=ko.validation.group(f),f.nicknameErrors=ko.validation.group(f.nickname),f.isValidating=!1,f.birthdateValue.subscribe(function(n){Support.stringIsEmpty(f.ikNumber())||f.isINB()?f.birthdate(n):(f.ikNumber.valueHasMutated(),f.birthdate(n))}),f.companyName.subscribe(function(n){n&&n!=""||f.ikCardHolderValue("");f.ikCardBusinessNameTO&&clearTimeout(f.ikCardBusinessNameTO);f.ikCardBusinessNameTO=setTimeout(function(){Support.stringIsEmpty(f.ikNumber())||f.isValidating||f.ikNumber.valueHasMutated()},f.ikCardBusinessNameTimeout)}),!f.hasAvatar()&&f.parentModel.parentModel.avatars.images.length>0&&(e=Math.floor(Math.random()*f.parentModel.parentModel.avatars.images.length),f.avatar(f.parentModel.parentModel.avatars.images[e]),f.hasAvatar(!0)),f.phone("+420 "),f}return __extends(t,n),t.prototype.setValidation=function(){var n=this;this.nickname.extend({canValidate:!1,required:{onlyIf:function(){return n.nickname.canValidate()},message:App.messages.validation.requiredItem},validation:[{onlyIf:function(){return n.nickname.canValidate()},validator:function(t){return!n.checkNicknameUsing(t,n)},message:App.messages.validation.errorExistedNickname},{onlyIf:function(){return n.nickname.canValidate()},validator:function(n){return ValidationHelper.checkMinLength(n,3)},message:App.messages.validation.errorNicknameLength},{onlyIf:function(){return n.nickname.canValidate()},validator:function(n){return ValidationHelper.isValidInput(n,"_()!")},message:App.messages.validation.errorInvalidChars}]});this.ikNumber.extend({canValidate:!1,required:{onlyIf:function(){return n.ikNumber.canValidate()&&n.cardTypeID()==1&&!Support.stringIsEmpty(n.ikNumber())},message:App.messages.validation.requiredItem},validation:[{onlyIf:function(){return n.ikNumber.canValidate()&&n.cardTypeID()==1&&!Support.stringIsEmpty(n.ikNumber())},validator:function(n){return ValidationHelper.isIKNumberDigits(n)},message:App.messages.validation.errorIKNumberDigits},{onlyIf:function(){return n.ikNumber.canValidate()&&n.cardTypeID()==1&&!Support.stringIsEmpty(n.ikNumber())},validator:function(n){return ValidationHelper.isIKNumberLength(n)},message:App.messages.validation.errorIKNumber},{async:!0,onlyIf:function(t){return n.ikNumber.canValidate()&&n.cardTypeID()==1&&!Support.stringIsEmpty(n.ikNumber())&&ValidationHelper.isIKNumberLength(t)},validator:function(t,i,r){if(n.isValidating==!0||t=="undefined"||n.isINB()&&!Support.stringIsEmpty(n.companyName())&&n.companyName()!="undefined"||!n.isINB()&&n.dob.canSubmit()&&n.birthdateValue.canValidate()&&n.birthdateValue.isValid()&&!Support.stringIsEmpty(n.birthdateValue())&&n.birthdateValue()!="Invalid date"&&n.birthdateValue()!="undefined")return r(!0);n.isValidating=!0;$.ajax({url:App.getUrlAction("CheckCardNumberIK")+"?cardNumber="+n.ikNumber(),type:"GET",success:function(t){n.ikCardBusinessNameTO=null;n.isValidating=!1;n.ikCardHolderValue("");n.isINB(t.isINB);r(!0)}})}},{async:!0,onlyIf:function(t){return n.ikNumber.canValidate()&&n.cardTypeID()==1&&!Support.stringIsEmpty(n.ikNumber())&&ValidationHelper.isIKNumberLength(t)},validator:function(t,i,r){if(n.isValidating==!0||n.isINB()&&(Support.stringIsEmpty(n.companyName())||n.companyName()=="undefined")||!n.isINB()&&(!n.dob.canSubmit()||!n.birthdateValue.canValidate()||!n.birthdateValue.isValid()||n.birthdateValue()=="Invalid date"||n.birthdateValue()=="undefined"))return r(!0);n.companyName()!=null&&n.companyName(n.companyName().trim());n.isValidating=!0;$.ajax({url:App.getUrlAction("CheckCardNumberIK")+"?cardNumber="+n.ikNumber()+"&dob="+n.birthdateValue()+"&companyName="+encodeURIComponent(n.companyName()),type:"GET",success:function(t){n.ikCardBusinessNameTO=null;n.isValidating=!1;n.ikCardHolderValue(t.info);n.isINB(t.isINB);t.result==!0&&n.ikNumber(t.checkedCardNumber);r(t.result)}})},message:function(){return n.isValidating=!1,n.ikCardBusinessNameTO=null,n.ikCardHolderValue(""),n.isINB()?App.messages.connection.errorIKNumberCompanyName:App.messages.connection.errorIKNumberBirthdate}}]});this.birthdateValue.extend({canValidate:!0,required:{onlyIf:function(){return n.birthdateValue.canValidate()&&n.cardTypeID()==1&&!n.isINB()&&!Support.stringIsEmpty(n.ikNumber())},message:App.messages.validation.requiredItem}});this.fullname.extend({canValidate:!1,required:{onlyIf:function(){return n.fullname.canValidate()&&n.cardTypeID()!=1&&!Support.stringIsEmpty(n.fullname())},message:App.messages.validation.requiredItem},validation:{onlyIf:function(){return n.fullname.canValidate()&&n.cardTypeID()!=1&&!Support.stringIsEmpty(n.fullname())},validator:function(n){return ValidationHelper.isCardName(n)},message:function(){return App.messages.validation.errorCardName}}});this.phone.extend({canValidate:!1,validation:[{onlyIf:function(){return n.phone.canValidate()},validator:function(n){return ValidationHelper.isPhoneNumber(n,"+420")},message:App.messages.validation.errorCZMobileNumber},{onlyIf:function(){return n.phone.canValidate()},validator:function(n){return n=n.replace(" ","").replace("+420",""),ValidationHelper.isCZMobileNumber(n)},message:App.messages.validation.errorCZMobileNumber}]})},t.prototype.hasPhone=function(){return Support.hasPhone(this.phone())},t.prototype.checkErrors=function(){this.nickname.canValidate(!0);this.ikNumber.canValidate(!0);this.isINB()||this.birthdateValue.canValidate(!0);this.fullname.canValidate(!0);this.phone.canValidate(this.hasPhone());var n=!0;return(this.isINB()||(n=this.cardTypeID()==1&&!Support.stringIsEmpty(this.ikNumber())?this.dob.canSubmit():!0),this.errors().length>0)?(this.errors.showAllMessages(),!1):n&&!this.ikCardBusinessNameTO&&!this.isValidating},t.prototype.dobFirstValidDate=function(){return moment().add(-100,"year").toDate()},t.prototype.dobLastValidDate=function(){return new Date},t.prototype.setDOBDate=function(n){this.birthdateValue(DateTimeHelper.formatDateBase(n))},t.prototype.setExtraValidation=function(){return!0},t.prototype.checkNicknameUsing=function(n,t){return n&&n!==""&&this.parentModel.passengers().some(function(i){return i!==t&&i.nickname()===n})},t}(n.Passenger),i,r;n.PassengerFavouriteEdit=t;i=function(){function n(){var n=this;this.passengers=ko.observableArray();this.done=function(){var t=!0;(n.passengers().forEach(function(n){n.checkErrors()||(t=!1)}),t)&&n.saveFavPassengersToAzak()}}return n.prototype.init=function(n,t){this.parentModel=n;t.init(this.parentModel.avatars.imagePath);this.favouritePassengersRemoveModal=t},n.prototype.show=function(n,i,r){var u=this,f;this.parentModel=r;this.allPassengers=n;this.favPassengers=n.filter(function(n){return n.isFavourite});this.existsDefaultFavPassenger=this.favPassengers.some(function(n){return n.isDefault});this.passengers.removeAll();f=0;i.forEach(function(n){var i=new t(u,u.parentModel.mapData,n,f);u.passengers.push(i);f++});this.passengers().forEach(function(n){n.dob.initComponents()});$("#passengersFavouriteModal .og-datepicker").ogDatePicker()},n.prototype.saveFavPassengersToAzak=function(){var t=this,n=this.getPassengersInfoModel(this.passengers());if(n.aoPassengers.length>0){if(n.aoPassengers.length>this.favouritePassengersRemoveModal.maxPassLimit){alert(App.messages.connection.favPassengersMaxLimit(this.favouritePassengersRemoveModal.maxPassLimit));return}$.post(App.getUrlAction("oblibeni-cestujici/true/"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(i){ErrorHandler.checkErrors(i)||(i?i.azakErrorCode===ErrorType.REQUEST_CONFLICT?(t.favouritePassengersRemoveModal.show(i.favouritePassengers,!1,"favPassToRemPaging",t,n.aoPassengers.length,i.maxFavCount),$("#passengersFavouriteRemoveModal").modal("show")):i.azakErrorCode===ErrorType.REQUEST_TOO_LARGE?alert(App.messages.connection.favPassengersRequestTooLarge):alert(App.messages.connection.favPassengersError):t.hideModal())})}else this.hideModal()},n.prototype.hideModal=function(){for(var r=[],i,n,u,t=0;t<this.allPassengers.length;t++)i=this.allPassengers[t],n=i.nickname&&i.nickname!==""?this.passengers().filter(function(n){return n.nickname()&&n.nickname()!==""&&n.nickname()==i.nickname}):[],n.length==0?n=this.passengers().filter(function(n){return n.id==i.id}):(r.push(n[0].id),n[0].id=i.id),n.length>0&&(this.allPassengers[t]=n[0].serialize());for(t=0;t<r.length;t++)n=this.allPassengers.filter(function(n){return n.id==r[t]}),n.length>0&&(u=this.allPassengers.indexOf(n[0],0),u>-1&&this.allPassengers.splice(u,1));this.parentModel.allPassengers=this.allPassengers;this.parentModel.showPassengers();$("#passengersFavouriteModal").modal("hide")},n.prototype.getPassengersInfoModel=function(n){var u=[],i,r,t;if(n)for(i=0,r=n;i<r.length;i++)t=r[i],t.nickname()&&t.nickname()!=""&&(t.isFavourite(!0),u.push(this.getPassengerInfoModel(t)));return{aoPassengers:u}},n.prototype.getPassengerInfoModel=function(n){return{bDefault:n.isDefault(),iCount:n.count(),sAlias:n.nickname(),iTypeID:n.typeID(),sTypeID:n.typeName,aiReductionID:n.cardIDs,asReductionID:n.getCardNames,sAvatar:n.avatar(),sImage:n.image(),bFav:!0,oCard:this.getCardInfoModel(n)}},n.prototype.getCardInfoModel=function(n){return Support.hasPhone(n.phone())?n.phone(Support.unifyPhoneNumber(n.phone())):n.phone(""),n.companyName()!=null&&n.companyName(n.companyName().trim()),{sName:n.fullname(),sCardID:n.getCardNumber,iType:n.cardTypeID()==1?1:0,sPhone:n.phone(),_Date:n.birthdate(),sCompanyName:n.companyName()}},n.prototype.removePassengerByNickname=function(n){var i=this.allPassengers.filter(function(t){return t.nickname==n}),t;i.length>0&&(t=this.allPassengers.indexOf(i[0],0),t>-1&&this.allPassengers.splice(t,1))},n}();n.PassengersFavouriteModal=i;r=function(){function n(n,t,i){var r=this;this.showPassenger=ko.observable();this.hasAvatar=ko.observable();this.basicInfo=ko.observable();this.cardsInfo=ko.observable();this.deleteFavPassenger=function(){$.post(App.getUrlAction("oblibeni-cestujici/false/"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:r.getAjaxModel({passengers:[r.model]})},function(n){ErrorHandler.checkErrors(n)||r.favPassengersModal.updateAfterRemove(r.model)})};this.model=n;this.favPassengersModal=t;this.avatarsImagePath=i;this.showPassenger(this.model.fav);this.fillBasicInfo();this.fillCardsInfo();this.hasAvatar(this.model.img&&this.model.img!==""||this.model.av&&this.model.av!=="")}return n.prototype.fillBasicInfo=function(){this.basicInfo(this.model.alias+", "+this.model.nameTypeId+", ")},n.prototype.fillCardsInfo=function(){var n="",t,i,r;if(this.model.nameReducId)for(t=0,i=this.model.nameReducId;t<i.length;t++)r=i[t],Support.append(n,r,", ");n.length==0&&(n=App.messages.connection.favPassengerWithoutCard);this.cardsInfo(n)},Object.defineProperty(n.prototype,"getAvatar",{get:function(){return this.model.img&&this.model.img!==""?this.model.img:this.model.av&&this.model.av!==""?this.avatarsImagePath+this.model.av:void 0},enumerable:!0,configurable:!0}),n.prototype.getAjaxModel=function(n){return{aoPassengers:this.getAjaxPassengerInfoArrayModel(n.passengers)}},n.prototype.getAjaxPassengerInfoModel=function(n){return{iCount:n.count,sAlias:n.alias,iTypeID:n.typeID,sTypeID:n.nameTypeId,aiReductionID:n.reducId,asReductionID:n.nameReducId,sAvatar:n.av,sImage:n.img,oCard:this.getAjaxCardInfoModel(n.card),bDefault:n.def,bFav:n.fav}},n.prototype.getAjaxCardInfoModel=function(n){var t;return n?(n.phone=Support.hasPhone(n.phone)?Support.unifyPhoneNumber(n.phone):"",n.companyName!=null&&(n.companyName=n.companyName.trim()),n&&(t={sName:n.name,sCardID:n.id,iType:n.type,sPhone:n.phone,_Date:n.date,sCompanyName:n.companyName}),t):t},n.prototype.getAjaxPassengerInfoArrayModel=function(n){var r=[],t,i,u;if(n)for(t=0,i=n;t<i.length;t++)u=i[t],r.push(this.getAjaxPassengerInfoModel(u));return r},n}();n.PassengerInfoForModal=r}(SearchForm||(SearchForm={})),function(n){var t=function(){function t(){var n=this;this.visibleFavPassengers=ko.observableArray();this.enableAddFavourite=ko.observable();this.hasPassengers=ko.observable();this.pagingDiv=ko.observable();this.maxPassLimitMessage=ko.observable();this.pageSize=4;this.addFavouriteClick=function(){n.favModal.done();$("#passengersFavouriteRemoveModal").modal("hide")}}return t.prototype.init=function(n){this.avatarsImagePath=n},t.prototype.show=function(n,t,i,r,u,f){this.model=n;this.favModal=r;this.pagingDiv(i);this.actualPageNumber=1;this.newFavPassengersCount=u;this.maxPassLimit=f;this.enableAddFavourite(!1);this.hasPassengers(!1);var e={passengers:this.model.passengers.slice(0,this.pageSize)};this.showData(e,!0);this.maxPassLimitMessage(App.messages.connection.favPassengersMaxLimitAfterRequestConflict(this.maxPassLimit));t&&ko.applyBindings(this,document.getElementById(i))},t.prototype.paging=function(n){(this.model.passengers.length/this.pageSize<n-1||n<1)&&(n=1);this.model.passengers.length>0&&this.model.passengers.length/this.pageSize<=n-1&&(n--,$("#"+this.pagingDiv()).pagination("selectPage",n));this.actualPageNumber=n;var t={passengers:this.model.passengers.slice(n*this.pageSize-this.pageSize,n*this.pageSize)};this.showData(t,!1)},t.prototype.removeItemFromModel=function(n){var t=this.model.passengers.indexOf(n);t>-1&&this.model.passengers.splice(t,1);this.favModal.removePassengerByNickname(n.alias)},t.prototype.getSimplePaginationOptions=function(){var t=this,n={};return n.items=this.model.passengers.length,n.itemsOnPage=this.pageSize,n.prevText=App.messages.connection.prevPageText,n.nextText=App.messages.connection.nextPageText,n.displayedPages=3,n.onPageClick=function(n,i){t.paging(n);i.preventDefault()},n},t.prototype.showData=function(t,i){var r=this;if(!t||!t.passengers){$("#"+this.pagingDiv()).hide();return}this.visibleFavPassengers.removeAll();t.passengers.forEach(function(t){r.visibleFavPassengers.push(new n.PassengerInfoForModal(t,r,r.avatarsImagePath))});i?$("#"+this.pagingDiv()).pagination(this.getSimplePaginationOptions()):$("#"+this.pagingDiv()).pagination("updateItems",this.model.passengers.length);$("#"+this.pagingDiv()).pagination("getPagesCount")<2?$("#"+this.pagingDiv()).hide():$("#"+this.pagingDiv()).show();this.hasPassengers(t.passengers.length>0)},t.prototype.updateAfterRemove=function(n){this.removeItemFromModel(n);this.paging(this.actualPageNumber);this.maxPassLimit-this.model.passengers.length>=this.newFavPassengersCount&&this.enableAddFavourite(!0)},t}();n.FavouritePassengersRemoveModal=t}(SearchForm||(SearchForm={})),function(n){var u,t,i,r;(function(n){n[n.Class1=0]="Class1";n[n.Class2=1]="Class2";n[n.ClassBusiness=2]="ClassBusiness"})(u=n.ServiceClass||(n.ServiceClass={}));t=function(){function n(){var n=this;this.bike=ko.observable(!1);this.children=ko.observable(!1);this.wheelChair=ko.observable(!1);this.refreshment=ko.observable(!1);this.carTrain=ko.observable(!1);this.silentComp=ko.observable(!1);this.ladiesComp=ko.observable(!1);this.powerSupply=ko.observable(!1);this.wiFi=ko.observable(!1);this.beds=ko.observable(!1);this.anySelected=ko.computed(function(){return n.bike()||n.children()||n.wheelChair()||n.refreshment()||n.carTrain()||n.silentComp()||n.ladiesComp()||n.powerSupply()||n.wiFi()||n.beds()},this)}return n.prototype.deserialize=function(n){return this.bike(n.bike),this.children(n.children),this.wheelChair(n.wheelChair),this.refreshment(n.refreshment),this.carTrain(n.carTrain),this.silentComp(n.silentComp),this.ladiesComp(n.ladiesComp),this.powerSupply(n.powerSupply),this.wiFi(n.wiFi),n.beds!==undefined&&this.beds(n.beds),this},n.prototype.serialize=function(){var n={};return n.bike=this.bike(),n.children=this.children(),n.wheelChair=this.wheelChair(),n.refreshment=this.refreshment(),n.carTrain=this.carTrain(),n.silentComp=this.silentComp(),n.ladiesComp=this.ladiesComp(),n.powerSupply=this.powerSupply(),n.wiFi=this.wiFi(),n.beds=this.beds(),n},n}();n.ServicesIcons=t;i=function(){function n(n,i){var r=this;this.icons=ko.observable();this.clear=function(){r.icons(new t)};this.done=function(){var n=r.icons().serialize();r.parentModel.icons().deserialize(n);r.searchForm!=null&&r.searchForm.storeParams2Container()};this.parentModel=n;this.searchForm=i;this.icons(new t)}return n.prototype.show=function(){var n=this.parentModel.icons().serialize();this.icons().deserialize(n)},n}();n.ServicesModal=i;r=function(){function n(n,r){var f=this,u;this.serviceClass=ko.observable();this.class1Visible=ko.observable();this.class2Visible=ko.observable();this.classBusinessVisible=ko.observable();this.icons=ko.observable();this.showServices=function(){f.servicesModal.show()};u=n.services;this.serviceClass(u.serviceClass);this.class1Visible(u.class1Visible);this.class2Visible(u.class2Visible);this.classBusinessVisible(u.classBusinessVisible);this.icons((new t).deserialize(u));this.servicesModal=new i(this,r);ko.applyBindings(this.servicesModal,document.getElementById("servicesModal"))}return n.prototype.updateModel=function(n){var t=this.icons().serialize();$.extend(n,t);n.serviceClass=this.serviceClass()},n.prototype.update=function(n,t){(n.bike!==undefined||t)&&this.icons().bike(n.bike);(n.carTrain!==undefined||t)&&this.icons().carTrain(n.carTrain);(n.children!==undefined||t)&&this.icons().children(n.children);(n.ladiesComp!==undefined||t)&&this.icons().ladiesComp(n.ladiesComp);(n.powerSupply!==undefined||t)&&this.icons().powerSupply(n.powerSupply);(n.refreshment!==undefined||t)&&this.icons().refreshment(n.refreshment);(n.silentComp!==undefined||t)&&this.icons().silentComp(n.silentComp);(n.wheelChair!==undefined||t)&&this.icons().wheelChair(n.wheelChair);(n.wiFi!==undefined||t)&&this.icons().wiFi(n.wiFi);(n.beds!==undefined||t)&&this.icons().beds(n.beds);(n.serviceClass!==undefined||t)&&this.serviceClass(n.serviceClass)},n}();n.Services=r}(SearchForm||(SearchForm={})),function(n){var t=function(){function n(n,t,i,r,u){var f=this;this.id=ko.observable("");this.name=ko.observable("");this.selectedValue=ko.observable("");this.error=ko.observable(new ErrorInfo(""));this.allowChange=!1;this.isEditable=ko.observable(!0);this.inputHasFocus=ko.observable(!1);this.linkHasFocus=ko.observable(!1);this.allowEdit=function(){f.isEditable(!0);f.setFocus()};this.clearError=function(){return f.error().message(""),!0};this.id(i);this.allowChange=n;this.isEditable(t);this.error().name=r;this.selectedValue.extend({notify:"always"});u&&(this.name(u.name),this.selectedValue(u.name+"%"+u.listID));this.selectedValue.subscribe(function(){f.allowChange&&(f.isEditable(!1),f.setFocus())});this.name.subscribe(function(){f.clearError()})}return n.prototype.setFocus=function(){this.isEditable()?this.inputHasFocus(!0):this.linkHasFocus(!0)},n.prototype.isEmpty=function(){return this.name()==null||this.name().length==0},n.prototype.serialize=function(){var n={listID:0,name:this.name(),errorName:this.error().name},t=this.selectedValue().split("%");return t.length==2&&t[0]==n.name&&(n.listID=parseInt(t[1])),n},n}(),i;n.Station=t;i=function(){function n(n){var i=this,r,u,f;if(this.from=ko.observable(),this.to=ko.observable(),this.vias=ko.observableArray(),this.isViaChange=ko.observable(!1),this.viaIndex=1,this.addVia=function(){if(i.vias().length<3){var n=new t(!0,!0,"Via"+i.viaIndex,"Via["+i.viaIndex+"]",null);i.vias.push(n);n.setFocus();i.viaIndex+=1}},this.deleteVia=function(n){i.vias.remove(n);var t=i.vias().length;t>0?i.vias()[t-1].setFocus():i.to().setFocus()},this.swithFromTo=function(){var t=i.from().name(),n;i.from().name(i.to().name());i.to().name(t);n=i.from().selectedValue();i.from().selectedValue(i.to().selectedValue());i.to().selectedValue(n)},this.viaAdded=function(n){$(n).find(".og-autocomplete").OGAutocomplete()},this.from(new t(!1,!0,"From","From",n.stations?n.stations.from:null)),this.from().setFocus(),this.to(new t(!1,!0,"To","To",n.stations?n.stations.to:null)),n.stations&&n.stations.vias&&n.stations.vias.length>0){for(r=0,u=n.stations.vias;r<u.length;r++)f=u[r],this.vias.push(new t(!0,!1,"Via"+this.viaIndex,"Via["+this.viaIndex+"]",f)),this.viaIndex+=1;this.isViaChange(n.stations.isViaChange)}}return n.prototype.setViaChange=function(n){this.isViaChange(n)},n.prototype.updateModel=function(n){n.from=this.from().serialize();n.to=this.to().serialize();n.vias=this.vias().filter(function(n){return!n.isEmpty()}).map(function(n){return n.serialize()});n.isViaChange=this.isViaChange()},n.prototype.update=function(n){var i,r,u;if(this.from(new t(!1,!0,"From","From",n.from)),this.to(new t(!1,!0,"To","To",n.to)),this.vias.removeAll(),n.vias&&n.vias.length>0){for(i=0,r=n.vias;i<r.length;i++)u=r[i],this.vias.push(new t(!0,!1,"Via"+this.viaIndex,"Via["+this.viaIndex+"]",u)),this.viaIndex+=1;this.isViaChange(n.isViaChange)}},n}();n.Stations=i}(SearchForm||(SearchForm={})),function(n){var t=function(){function n(n,t,i,r){var u=this;this.id=ko.observable("");this.selectedValue=ko.observable();this.stations=ko.observableArray();this.error=ko.observable(new ErrorInfo(""));this.stationChange=function(){u.error().message("")};this.id(n);this.error().name=t;this.selectedValue(i.ident.toString());r.forEach(function(n){return u.stations.push(n)})}return n.prototype.serialize=function(){var t=this,n=this.stations().filter(function(n){return n.ident==parseInt(t.selectedValue())})[0];return n.errorName=this.error().name,n},n}(),i;n.StationStatic=t;i=function(){function n(n){var i=this;this.from=ko.observable();this.to=ko.observable();this.swithFromTo=function(){var t=i.from().serialize(),r=i.to().serialize(),n=i.from().stations().filter(function(n){return n.ident==r.ident});n.length!=0&&(n=i.to().stations().filter(function(n){return n.ident==t.ident}),n.length!=0)&&(i.from().selectedValue(r.ident.toString()),i.to().selectedValue(t.ident.toString()),$("#fromto .cd-select").refreshNiceSelect())};this.from(new t("From","From",n.from,n.stationsFrom));this.to(new t("To","To",n.to,n.stationsTo))}return n.prototype.updateModel=function(n){n.from=this.from().serialize();n.to=this.to().serialize()},n}();n.StationsStatic=i}(SearchForm||(SearchForm={})),function(n){var e,i,o,u,r,t,f;(function(n){n[n.ISSUEDATE=0]="ISSUEDATE";n[n.VALIDFROM=1]="VALIDFROM"})(e=n.USER_HISTORY_ORDER||(n.USER_HISTORY_ORDER={})),function(n){n[n.ALL=0]="ALL";n[n.VALIDONLY=1]="VALIDONLY";n[n.EXPIRED=2]="EXPIRED";n[n.INRECLAMATION=3]="INRECLAMATION";n[n.NONVALID=4]="NONVALID"}(i=n.USER_HISTORY_TICKET_STATUS||(n.USER_HISTORY_TICKET_STATUS={})),function(n){n[n.ESHOPMAIN=0]="ESHOPMAIN";n[n.ESHOPFULL=1]="ESHOPFULL";n[n.MYTRAVEL=2]="MYTRAVEL";n[n.PROFILE=3]="PROFILE";n[n.UPPS=4]="UPPS"}(o=n.USER_HISTORY_TARGET||(n.USER_HISTORY_TARGET={}));u=function(){function n(n,t,i){var r=this,u;if(this.items=ko.observableArray(),this.isEmpty=ko.observable(!0),this.pagingDiv=ko.observable(),this.orderTypes=ko.observableArray(),this.selectedOrderType=ko.observable(),this.pageNumber=ko.observable(),this.allEmpty=ko.observable(!1),this.ticketStatus=ko.observable(0),this.isInitOnly=ko.observable(),this.getTypeData=function(n){if(r.model&&!r.allEmpty()){if(r.filter&&(r.model.filter.showFilter=r.filter.showFilter(),r.filter.getFilter(r.model.filter),r.model.filter.enableFilter&&!r.filter.checkErrors())){r.filter.showFilter(!0);r.model.filter.showFilter=!0;return}r.model.filter.ticketStatus=n;r.model.filter.order=r.selectedOrderType();r.model.pageNumber=0;r.pageNumber(r.model.pageNumber);r.getData(!0)}},this.getFilterData=function(){r.model&&(r.filter&&(r.model.filter=r.filter.updateFilter(r.model.filter),r.model.filter.enableFilter&&!r.filter.checkErrors())||(r.model.pageNumber=0,r.pageNumber(r.model.pageNumber),r.getData(!0)))},n!=null&&(this.initPassengers=n.initPassengers),n&&(n.items&&n.items.length>0||n.initOnly)){for(u in n.orderTypes)this.orderTypes().push(n.orderTypes[u]);this.selectedOrderType(n.filter.order);this.pageNumber(n.pageNumber)}this.pagingDiv(i);this.filter=n&&n.filter?new f(n.filter,this):null;this.showData(n,!0);this.documentConditionsModal=new UserIdentity.DocumentConditionsModal;i!="refund"&&ko.applyBindings(this.documentConditionsModal,document.getElementById("documentConditionsModal"));t&&ko.applyBindings(this,document.getElementById(i));$("#main .cd-select").refreshNiceSelect();this.selectedOrderType.subscribe(function(){r.getSortedData(r.selectedOrderType())});this.model&&this.model.initOnly&&i!="eshop-userHistory"&&this.getData(!0)}return n.prototype.getSimplePaginationOptions=function(){var t=this,n={};return n.items=this.model.allItemsCount,n.itemsOnPage=this.model.pageSize,this.pagingDiv()==="refund"?(n.prevText=App.messages.connection.nextText2,n.nextText=App.messages.connection.prevText2):(n.prevText=App.messages.connection.prevText,n.nextText=App.messages.connection.nextText),n.displayedPages=3,n.onPageClick=function(n,i){t.paging(n);i.preventDefault()},n},n.prototype.paging=function(n){(this.model.allItemsCount/this.model.pageSize<n-1||n<1)&&(n=1);var t=this.GetUserHistoryPaging(n);this.pageNumber(t.pageNumber);this.model.pageNumber=this.pageNumber();this.getData(!1)},n.prototype.GetUserHistoryPaging=function(n){var t={};return t.pageNumber=n-1,t.pageSize=this.model.pageSize,t},n.prototype.showData=function(n,t){var u,f,e;if(this.model=n,$(".extramenu.uhfull a").removeClass("active"),this.model&&this.model.filter?($(".extramenu.uhfull .ticket_"+this.model.filter.ticketStatus).addClass("active"),this.ticketStatus(this.model.filter.ticketStatus),this.isInitOnly(this.model.initOnly)):this.ticketStatus(0),this.isEmpty(!0),!this.model||!this.model.items||this.model.items.length===0){this.model&&this.ticketStatus()==i.ALL&&(this.model.allEmpty=!0,this.allEmpty(!0));return}for(this.ticketStatus()==i.ALL&&(this.model.allEmpty=!1,this.allEmpty(!1)),this.items.removeAll(),this.isEmpty(!1),u=0,f=this.model.items;u<f.length;u++)e=f[u],this.items.push(new r(this,e));t?$("#"+this.pagingDiv()+" .paging").pagination(this.getSimplePaginationOptions()):$("#"+this.pagingDiv()+" .paging").pagination("updateItems",this.model.allItemsCount);this.pagingDiv()==="refund"&&(this.model.pageNumber===1&&$("#"+this.pagingDiv()+" .paging ul li .prev").addClass("hide"),this.model.pageNumber===Math.ceil(this.model.allItemsCount/this.model.pageSize)&&$("#"+this.pagingDiv()+" .paging ul li .next").addClass("hide"));$("body").animate({scrollTop:0},600)},n.prototype.updateModel=function(n){n.allItemsCount=this.model.allItemsCount;n.buyAgainCartItemID=this.model.buyAgainCartItemID;n.pageSize=this.model.pageSize;n.items=this.model.items;n.initPassengers=this.initPassengers;this.filter&&(n.filter=this.filter.updateFilter(this.model.filter));n.initOnly=this.model.initOnly;n.orderTypes=this.model.orderTypes;n.pageNumber=this.model.pageNumber;n.allEmpty=this.model.allEmpty},n.prototype.getUserHistoryModel=function(){return this.model},n.prototype.buyAgainClick=function(n){n.buyAgainUrl!=null&&n.buyAgainUrl!="ticket"&&(window.location.href=n.buyAgainUrl)},n.prototype.getSortedData=function(n){if(this.model){if(this.filter&&(this.model.filter.showFilter=this.filter.showFilter(),this.filter.getFilter(this.model.filter),this.model.filter.enableFilter&&!this.filter.checkErrors())){this.filter.showFilter(!0);this.model.filter.showFilter=!0;return}this.model.filter.order=n;this.model.pageNumber=0;this.pageNumber(this.model.pageNumber);this.getData(!0)}},n.prototype.getData=function(n){var t=this;this.model.initOnly=!1;AjaxHelper.AjaxWaitShow(App.messages.connection.loaderLoadTickets);$.post(App.getUrlAction("GetUserHistoryData"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:this.model},function(i){(AjaxHelper.AjaxWaitHide(),ErrorHandler.checkErrors(i))||t.showData(i,n)})},n}();n.UserHistory=u;r=function(){function n(n,i){var r=this,f,o,e,s,u;if(this.stationInfo=null,this.trainsThere=[],this.trainsBack=[],this.buyTicket=function(){return!0},this.facebookShareClick=function(){var n="",t;n=r.model.stationFrom&&r.model.stationTo&&r.model.stationFrom!==""&&r.model.stationTo!==""?App.messages.connection.facebookShareTicketDescription(r.model.stationFrom,r.model.stationTo,Math.round(r.model.price/100).toString()):App.messages.connection.facebookShareTicketWithNameDescription(r.model.docName,Math.round(r.model.price/100).toString());t=r.model.azakAppBackUrl+"/eshop/";FB.ui({method:"share_open_graph",action_type:"og.shares",action_properties:JSON.stringify({object:{"og:url":t,"og:title":"E-shop ČD","og:description":n,"og:image":"http://m.cd.cz/spojeni/ogres/img/cd-logo-og.png"}})})},this.documentConditionsOpen=function(){var n=r.model;$.post(App.getUrlAction("GetDocumentConditionsHistory"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(n){ErrorHandler.checkErrorsWithInfo(n,r)||($("#documentConditionsModal").modal("show"),r.parent.documentConditionsModal.show(n))})},this.model=i,this.parent=n,Support.stringIsEmpty(i.stationFrom)||Support.stringIsEmpty(i.stationTo)||(this.stationInfo=i.stationFrom+" - "+i.stationTo,i.isReturn&&(this.stationInfo+=" "+App.messages.connection.andBack)),this.model.trainsThere!=null&&this.model.trainsThere.length>0)for(f=0,o=this.model.trainsThere;f<o.length;f++)u=o[f],this.trainsThere.push(new t(u));if(this.model.trainsBack!=null&&this.model.trainsBack.length>0)for(e=0,s=this.model.trainsBack;e<s.length;e++)u=s[e],this.trainsBack.push(new t(u))}return n.prototype.docInfo=function(){var n="";return Support.stringIsEmpty(this.model.docName)||(n=Support.append(n,this.model.docName," / ")),this.model.person>0&&(n=Support.append(n,App.messages.connection.for+" "+this.model.person+" "+this.getPersonTextForm(this.model.person)," ")),n},n.prototype.getValidity=function(){return Support.stringIsEmpty(this.model.validity)?"":this.model.validity+" "},n.prototype.getPersonTextForm=function(n){return n===1?App.messages.connection.osobu:n>1&&n<5?App.messages.connection.osoby:App.messages.connection.osob},n.prototype.getPDFUrl=function(n){return this.model.pdfUrl+n},n.prototype.getAztecImageUrl=function(n){return this.model.aztecImageUrl+n},n.prototype.getReclResultUrl=function(n){return this.model.reclamationResultUrl+n+"/"+this.model.cartItemStatus},n}();n.UserHistoryItem=r;t=function(){function n(n){this.model=n}return n.prototype.desc=function(){return this.model.train+", "+this.model.stationFrom+" > "+this.model.stationTo},n}();n.UserHistoryTrain=t;f=function(){function t(t,i){var r=this;this.showFilter=ko.observable(!1);this.enableFilter=ko.observable();this.issueDate=ko.observable();this.validFrom=ko.observable();this.name=ko.observable();this.transactionCode=ko.observable();this.corporateNSEnabled=ko.observable();this.corporateNSList=ko.observableArray();this.corporateNS=ko.observable();this.lastCorporateNS="-";this.setValidFrom=function(n){r.validFrom().setDate(n)};this.setIssueDate=function(n){r.issueDate().setDate(n)};this.selectNS=function(n){r.corporateNSList.removeAll();r.corporateNSList.push(n);r.lastCorporateNS=n;r.corporateNS(n)};this.corporateNSChange=function(n){(n===void 0&&(n=!0),r.corporateNSEnabled())&&r.lastCorporateNS!=r.corporateNS()&&(r.lastCorporateNS=r.corporateNS(),$.post(App.getUrlAction("FindCorporateNS"),{__RequestVerificationToken:App.GetAntiForgeryToken(),prefix:r.corporateNS()},function(t){if(!ErrorHandler.checkErrors(t)){r.corporateNSList.removeAll();var i=t;i.forEach(function(n){return r.corporateNSList.push(n)});n&&!Support.parseBool($("#nsList").attr("aria-expanded"))&&$("#nsList").dropdown("toggle")}}))};this.parent=i;this.issueDate(new n.SelectDateInput(this.setIssueDate));this.setIssueDate(DateTimeHelper.today());this.validFrom(new n.SelectDateInput(this.setValidFrom));this.setValidFrom(DateTimeHelper.today());this.getFilter(t);this.setValidation();this.errors=ko.validation.group(this);this.corporateNSEnabled(t.corporateNSEnabled);this.corporateNSChange(!1);this.corporateNS.subscribe(function(){clearTimeout(r.corporateNSHandle);r.corporateNSHandle=setTimeout(function(){r.corporateNSChange()},200)})}return t.prototype.clearFilter=function(){this.setIssueDate(null);this.setValidFrom(null);this.name("");this.transactionCode("");this.corporateNS("")},t.prototype.getFilter=function(n){var t,i;this.enableFilter(n.enableFilter);this.showFilter(n.showFilter);t=Support.stringIsEmpty(n.filterIssueDate)?null:DateTimeHelper.parseDateTime(n.filterIssueDate);t!=null&&t.toString()=="0001-01-01T00:00:00"&&(t=null);this.setIssueDate(t);i=Support.stringIsEmpty(n.filterValidFromDate)?null:DateTimeHelper.parseDateTime(n.filterValidFromDate);i!=null&&i.toString()=="0001-01-01T00:00:00"&&(i=null);this.setValidFrom(i);this.name(n.filterName);this.transactionCode(n.filterTransactionCode);this.corporateNS(n.filterCorporateNS)},t.prototype.updateFilter=function(n){if(n.enableFilter=this.enableFilter(),n.showFilter=this.showFilter(),n.enableFilter){if(!this.checkErrors())return this.showFilter(!0),n.showFilter=!0,n;n.filterIssueDate=this.issueDate().date()==null?null:DateTimeHelper.toJSDate(this.issueDate().date());n.filterValidFromDate=this.validFrom().date()==null?null:DateTimeHelper.toJSDate(this.validFrom().date());n.filterName=this.name();n.filterTransactionCode=this.transactionCode();n.filterCorporateNS=this.corporateNS()}return n},t.prototype.toggleFilter=function(){this.showFilter()?this.showFilter(!1):this.showFilter(!0)},t.prototype.filter=function(){this.checkErrors()&&this.parent.getFilterData()},t.prototype.setCanValidate=function(n){this.name.canValidate(n);this.transactionCode.canValidate(n);this.corporateNS.canValidate(n)},t.prototype.checkErrors=function(){return(this.setCanValidate(!0),this.errors().length>0)?(this.errors.showAllMessages(),!1):!0},t.prototype.setValidation=function(){var n=this;this.name.extend({canValidate:!0,validation:[{onlyIf:function(){return n.name.canValidate()&&!Support.stringIsEmpty(n.name())},validator:function(n){return ValidationHelper.isValidInput(n,"%[]^_")},message:function(){return App.messages.validation.errorInvalidChars}}]});this.transactionCode.extend({canValidate:!0,validation:{onlyIf:function(){return n.transactionCode.canValidate()&&!Support.stringIsEmpty(n.transactionCode())},validator:function(n){return n.length<7&&ValidationHelper.isValidInput(n,"")},message:function(){return App.messages.validation.errorCodeLength}}});this.corporateNS.extend({canValidate:!0,validation:{onlyIf:function(){return n.corporateNS.canValidate()&&!Support.stringIsEmpty(n.corporateNS())},validator:function(n){return ValidationHelper.isValidInput(n,"%[]^_")},message:function(){return App.messages.validation.errorNSNotExists}}})},t}()}(SearchForm||(SearchForm={})),function(n){var u,t,i,r;(function(n){n[n.Fast=1]="Fast";n[n.International=3]="International";n[n.Travelpass=8]="Travelpass";n[n.Travelpass_Int=9]="Travelpass_Int";n[n.Disabled=10]="Disabled";n[n.Groups=11]="Groups"})(u=n.SearchFormType||(n.SearchFormType={})),function(n){n[n.WHEELCHAIR=1]="WHEELCHAIR";n[n.CHILDREN=2]="CHILDREN";n[n.BIKE=3]="BIKE";n[n.CD=4]="CD";n[n.NOT_HISTORICAL=5]="NOT_HISTORICAL";n[n.CD_ONLY=6]="CD_ONLY";n[n.NOT_RESERVE=7]="NOT_RESERVE";n[n.NOT_SPECIAL=8]="NOT_SPECIAL";n[n.FIRST_CLASS=9]="FIRST_CLASS";n[n.REFRESHMENT=10]="REFRESHMENT";n[n.CAR_TRAIN=11]="CAR_TRAIN";n[n.SILENT_COMP=12]="SILENT_COMP";n[n.POWER_SUPPLY=13]="POWER_SUPPLY";n[n.WIFI=14]="WIFI";n[n.LADIES_COMP=15]="LADIES_COMP";n[n.CD_AND_NONCOM_ONLY=17]="CD_AND_NONCOM_ONLY";n[n.BEDS=26]="BEDS"}(t=n.FCS||(n.FCS={}));i=function(){function i(t,i){var u=this,f,l;this.stations=ko.observable();this.dateTime=ko.observable();this.services=ko.observable();this.params=ko.observable();this.passengers=ko.observable();this.userHistory=ko.observable();this.buyAgain=ko.observable();this.corporateEdit=ko.observable();this.isUserHistoryActive=ko.observable(!1);this.search=function(){if(u.corporateEdit().visible()&&u.corporateEdit().enabled()){if(!u.corporateEdit().canSubmit(!0))return;AjaxHelper.AjaxWaitShow(App.messages.ticketRefund.loaderProcessing);$.ajax({url:App.getUrlAction("")+"in-karta/checkCustomerInfo?ic="+u.corporateEdit().ic()+"&isICO=true&checkSAP=true",type:"GET",success:function(n){if(ErrorHandler.checkErrorsWithInfo(n,u)){AjaxHelper.AjaxWaitHide();return}AjaxHelper.AjaxWaitHide();u.setCustomerInfoData(n)}})}else AjaxHelper.AjaxWaitShow(App.messages.connection.loaderSearchConnection),u.searchConnections()};this.searchFavourite=function(n){AjaxHelper.AjaxWaitShow(App.messages.connection.loaderSearchConnection);u.updateSearchParamsForFavouriteConnections(n);u.searchConnections()};this.setActive=function(){u.myHistoryActive||(u.myHistoryActive=!0,u.userHistory()&&u.userHistory().isInitOnly()&&u.userHistory().getData(!0))};this.storeParams=new n.StoreParamsModel;t.noHistory==!1&&(history.state?t=history.state:t.userHistory==undefined&&this.mergeParams(t,this.storeParams));this.model=t;this.stations(new n.Stations(t));f=new n.CalendarModal;this.dateTime(new n.DateTime(t.dateTime,t.formType,f,!0));this.services(new n.Services(t,this));this.params(new n.Params(t.params,t.defaultParams,null,null,this));t.showParams&&(this.params().showParams(),$("#connectionParamsModal").modal("show"));var e=new n.PassengersModal,o=new n.PassengersFavouriteModal,s=new n.PassengersAgeModal,h=new n.PassengersPhotoModal,c=new n.FavouritePassengersRemoveModal;this.areModalsInited=!1;this.passengers(new n.Passengers(t.passengers,t.formType,this,e,o,s,h,c,this.params()));this.userHistory(new n.UserHistory(t.userHistory,!1,"eshop-userHistory"));this.corporateEdit(new n.CorporateEdit(t.corporateEdit,this,null,null,null));t.userHistory!=null&&(this.isUserHistoryActive(t.userHistory.isActive),this.myHistoryActive=this.isUserHistoryActive(),this.userHistory()&&this.userHistory().isInitOnly()&&this.isUserHistoryActive()&&this.userHistory().getData(!0),this.buyAgain(new n.BuyAgain(this,t,f,new n.Passengers(t.userHistory.initPassengers,t.formType,this,e,o,s,h,c,null),this.corporateEdit())));this.myConnections=new MyFavourites.MyConnections(i,this);t.errors&&ErrorHandler.checkErrorsWithInfo(t.errors,this);ko.applyBindings(e,document.getElementById("passengersModal"));ko.applyBindings(o,document.getElementById("passengersFavouriteModal"));ko.applyBindings(s,document.getElementById("passengersAgeModal"));ko.applyBindings(h,document.getElementById("passengersPhotoModal"));ko.applyBindings(c,document.getElementById("passengersFavouriteRemoveModal"));ko.applyBindings(f,document.getElementById("calendarModal"));ko.applyBindings(this,document.getElementById("main"));this.sessionExpiredModal=new r(this);l=this.sessionExpiredModal.check();t.doSearch&&!l&&this.search()}return i.prototype.updateSearchParamsForFavouriteConnections=function(i){var f={from:{name:i.from.name,listID:i.from.listId,errorName:""},to:{name:i.to.name,listID:i.to.listId,errorName:""}},e,l,o,s,a,h,u,r,c,v,y;if(i.change){for(f.vias=[],e=0,l=i.change;e<l.length;e++)o=l[e],o&&f.vias.push({name:o.name,listID:o.listId,errorName:""});f.isViaChange=!0}else if(i.via)for(f.vias=[],s=0,a=i.via;s<a.length;s++)h=a[s],h&&f.vias.push({name:h.name,listID:h.listId,errorName:""});if(this.stations().update(f),u={deltaPMax:i.deltaPMax!=null?i.deltaPMax.toString():"-1",maxChangeTime:i.maxTime!=null?i.maxTime.toString():null,minChangeTime:i.minTime!=null?i.minTime.toString():null,maxChanges:i.maxChange!=null?i.maxChange.toString():null,trainTypes:i.trTypeId!=null?i.trTypeId.map(String):[],useBed:i.useBeds!=null?n.ConnectionBeds[i.useBeds]:n.ConnectionBeds[0],onlyCD:!1,onlyCDPartners:!1,cdNonCom:!0,historyTrain:!1,onlyConnWithoutRes:!1},r={bike:!1,carTrain:!1,children:!1,ladiesComp:!1,powerSupply:!1,serviceClass:n.ServiceClass[n.ServiceClass.Class2],wheelChair:!1,wiFi:!1,silentComp:!1,beds:!1},i.fcSearchId)for(c=0,v=i.fcSearchId;c<v.length;c++){y=v[c];switch(y){case t.CD:u.onlyCD=!0;u.onlyCDPartners=!1;u.cdNonCom=!1;break;case t.CD_ONLY:u.onlyCD=!1;u.onlyCDPartners=!0;u.cdNonCom=!1;break;case t.CD_AND_NONCOM_ONLY:u.onlyCD=!1;u.onlyCDPartners=!1;u.cdNonCom=!0;break;case t.NOT_HISTORICAL:u.historyTrain=!0;break;case t.NOT_RESERVE:u.onlyConnWithoutRes=!0;break;case t.REFRESHMENT:r.refreshment=!0;break;case t.BIKE:r.bike=!0;break;case t.CAR_TRAIN:r.carTrain=!0;break;case t.CHILDREN:r.children=!0;break;case t.LADIES_COMP:r.ladiesComp=!0;break;case t.POWER_SUPPLY:r.powerSupply=!0;break;case t.FIRST_CLASS:r.serviceClass=n.ServiceClass[n.ServiceClass.Class1];break;case t.WHEELCHAIR:r.wheelChair=!0;break;case t.WIFI:r.wiFi=!0;break;case t.SILENT_COMP:r.silentComp=!0;break;case t.BEDS:r.beds=!0}}this.params().update(u,!1);r&&this.services().update(r,!1)},i.prototype.storeParams2Container=function(){var r=this,t=this.createEmptyModel(),i;this.updateModel(t,!1);this.model.userHistory==undefined?this.storeParams.save(t.params,t.services):(i=new n.StoreParamsModel,i.params=t.params,i.services=t.services,$.post(App.getUrlAction("SaveConnectionParams"),{__RequestVerificationToken:App.GetAntiForgeryToken(),connParams:i},function(n){ErrorHandler.checkErrorsWithInfo(n,r)}))},i.prototype.searchConnections=function(){var i=this,t=this.createEmptyModel(),r;this.updateModel(t,!1);this.model.userHistory==undefined?this.storeParams.save(t.params,t.services):(r=new n.StoreParamsModel,r.params=t.params,r.services=t.services,$.post(App.getUrlAction("SaveConnectionParams"),{__RequestVerificationToken:App.GetAntiForgeryToken(),connParams:r},function(n){if(ErrorHandler.checkErrorsWithInfo(n,i)){AjaxHelper.AjaxWaitHide();return}}));$.ajax({url:App.getUrlAction(""),type:"POST",headers:App.GetAntiForgeryTokenHeader(),data:JSON.stringify(t),dataType:"json",contentType:"application/json; charset=utf-8",success:function(n){var r,u;if(ErrorHandler.checkErrorsWithInfo(n,i)){AjaxHelper.AjaxWaitHide();return}if(r=n,r.passengersToSpecifyAge&&r.passengersToSpecifyAge.length>0){AjaxHelper.AjaxWaitHide();i.passengers().showAgeModal(r.passengersToSpecifyAge,r.passengersToSpecifyAgeState);return}u=$.extend({},i.model);i.updateModel(u,!0);history.pushState(u,null,"#hledej");window.location.href=App.getUrlAction(t.isReturnOnly?"spojeni-zpet":"spojeni-tam")+r.guid}})},i.prototype.setCustomerInfoData=function(n){n==undefined||n.notFound||!Support.stringIsEmpty(n.errorMessage)?n==undefined||Support.stringIsEmpty(n.errorMessage)?this.corporateEdit().errorUWS(App.messages.connection.uwsError):n.notFound?this.corporateEdit().errorUWS(App.messages.connection.uwsErrorNotFound):this.corporateEdit().errorUWS(n.errorMessage):(this.corporateEdit().errorUWS(""),this.corporateEdit().sap(Number(n.invoice.sapCustomer)),this.corporateEdit().name(n.invoice.company));this.corporateEdit().showModal()},i.prototype.createEmptyModel=function(){return{ttCombination:this.model.ttCombination,formType:this.model.formType,isReturnOnly:this.model.isReturnOnly,stations:{},services:{},dateTime:{},params:{},passengers:{},corporateEdit:{}}},i.prototype.updateModel=function(n,t){this.stations().updateModel(n.stations);this.services().updateModel(n.services);this.dateTime().updateModel(n.dateTime);this.params().updateModel(n.params);this.passengers().updateModel(n.passengers,t);this.corporateEdit().updateModel(n.corporateEdit)},i.prototype.mergeParams=function(n,t){t!=null&&t.params!=null&&t.services!=null&&(n.services.serviceClass=t.services.serviceClass,n.params.onlyDirectConnections=n.params.onlyDirectConnections||t.params.onlyDirectConnections,n.params.onlyConnWithoutRes=n.params.onlyConnWithoutRes||t.params.onlyConnWithoutRes,n.params.useBed=t.params.useBed,n.params.deltaPMax=t.params.deltaPMax,n.params.maxChanges=t.params.maxChanges,n.params.minChangeTime=t.params.minChangeTime,n.params.maxChangeTime=t.params.maxChangeTime,n.params.onlyCD=t.params.onlyCD,n.params.onlyCDPartners=t.params.onlyCDPartners,n.params.cdNonCom=t.params.cdNonCom,t.params.trainTypes!=null&&t.params.trainTypes.length>0&&(n.params.trainTypes=t.params.trainTypes),n.params.historyTrain=n.params.historyTrain||t.params.historyTrain,n.params.psgOwnTicketVisible&&(n.params.psgOwnTicket=n.params.psgOwnTicket||t.params.psgOwnTicket),n.params.addServiceReservation=n.params.addServiceReservation||t.params.addServiceReservation,n.params.addServiceDog=n.params.addServiceDog||t.params.addServiceDog,n.params.addServiceBike=n.params.addServiceBike||t.params.addServiceBike,n.params.addServiceSMS=n.params.addServiceSMS||t.params.addServiceSMS,n.services.bike=n.services.bike||t.services.bike,n.services.carTrain=n.services.carTrain||t.services.carTrain,n.services.children=n.services.children||t.services.children,n.services.ladiesComp=n.services.ladiesComp||t.services.ladiesComp,n.services.powerSupply=n.services.powerSupply||t.services.powerSupply,n.services.refreshment=n.services.refreshment||t.services.refreshment,n.services.silentComp=n.services.silentComp||t.services.silentComp,n.services.wheelChair=n.services.wheelChair||t.services.wheelChair,n.services.wiFi=n.services.wiFi||t.services.wiFi,n.services.beds=n.services.beds||t.services.beds)},i}();n.SearchForm=i;r=function(){function n(n){var t=this;this.content=ko.observable("");this.canRepeatSearch=ko.observable();this.check=function(){var n=Cookies.getJSON("SessionExpired");return n&&!n.handled?(t.show(),n.handled=!0,Cookies.set("SessionExpired",n),!0):!1};this.show=function(){var n=App.getUrlAction("SearchForm/SessionExpiredModal");App.loadHtml(n,"sessionExpiredModal").done(function(n){n&&ko.applyBindings(t,document.getElementById("sessionExpiredModal"));$("#sessionExpiredModal").modal("show")})};this.repeatSearch=function(){var n=JSON.parse(localStorage.getItem("SearchFormModel"));n.className=="SearchFormModel"?t.searchConnection(n):t.searchConnectionAutotrain(n)};this.searchConnection=function(n){AjaxHelper.AjaxWaitShow(App.messages.connection.loaderSearchConnection);$.ajax({url:App.getUrlAction(""),type:"POST",headers:App.GetAntiForgeryTokenHeader(),data:JSON.stringify(n),dataType:"json",contentType:"application/json; charset=utf-8",success:function(n){if(ErrorHandler.checkErrorsWithInfo(n,t)){AjaxHelper.AjaxWaitHide();return}var i=n;i.guid&&(window.location.href=App.getUrlAction("spojeni-tam")+i.guid)}})};this.searchConnectionAutotrain=function(n){AjaxHelper.AjaxWaitShow(App.messages.connection.loaderSearchConnection);$.post(App.getUrlAction("autovlak"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(n){if(ErrorHandler.checkErrorsWithInfo(n,t)){AjaxHelper.AjaxWaitHide();return}var i=n;i.guid&&(window.location.href=App.getUrlAction("spojeni-tam")+i.guid)})};this.parent=n;this.content(App.messages.app.sessionExpired);this.canRepeatSearch(!Support.stringIsEmpty(localStorage.getItem("SearchFormModel")))}return n}()}(SearchForm||(SearchForm={})),function(n){var t=function(){function t(t){var i=this,r;this.stations=ko.observable();this.dateTime=ko.observable();this.passengers=ko.observable();this.corporateEdit=ko.observable();this.search=function(){if(i.corporateEdit().visible()&&i.corporateEdit().enabled()){if(!i.corporateEdit().canSubmit(!0))return;AjaxHelper.AjaxWaitShow(App.messages.ticketRefund.loaderProcessing);$.ajax({url:App.getUrlAction("")+"in-karta/checkCustomerInfo?ic="+i.corporateEdit().ic()+"&isICO=true&checkSAP=true",type:"GET",success:function(n){if(ErrorHandler.checkErrorsWithInfo(n,i)){AjaxHelper.AjaxWaitHide();return}AjaxHelper.AjaxWaitHide();i.setCustomerInfoData(n)}})}else AjaxHelper.AjaxWaitShow(App.messages.connection.loaderSearchConnection),i.searchConnections()};t=history.state?history.state:t;this.model=t;this.stations(new n.StationsStatic(t.stations));r=new n.CalendarModal;this.dateTime(new n.DateTime(t.dateTime,n.SearchFormType.International,r,!0));this.corporateEdit(new n.CorporateEdit(t.corporateEdit,null,this,null,null));var u=new n.PassengersModal,f=new n.PassengersFavouriteModal,e=new n.PassengersAgeModal,o=new n.PassengersPhotoModal,s=new n.FavouritePassengersRemoveModal;this.areModalsInited=!1;this.passengers(new n.Passengers(t.passengers,n.SearchFormType.International,this,u,f,e,o,s,null));ko.applyBindings(u,document.getElementById("passengersModal"));ko.applyBindings(f,document.getElementById("passengersFavouriteModal"));ko.applyBindings(e,document.getElementById("passengersAgeModal"));ko.applyBindings(o,document.getElementById("passengersPhotoModal"));ko.applyBindings(s,document.getElementById("passengersFavouriteRemoveModal"));ko.applyBindings(r,document.getElementById("calendarModal"));ko.applyBindings(this,document.getElementById("main"));$("#main .cd-select").refreshNiceSelect()}return t.prototype.searchConnections=function(){var n=this,t=this.createEmptyModel();this.updateModel(t,!1);$.post(App.getUrlAction("autovlak"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:t},function(t){var i,r;if(ErrorHandler.checkErrorsWithInfo(t,n)){AjaxHelper.AjaxWaitHide();return}if(i=t,i.passengersToSpecifyAge&&i.passengersToSpecifyAge.length>0){AjaxHelper.AjaxWaitHide();n.passengers().showAgeModal(i.passengersToSpecifyAge,i.passengersToSpecifyAgeState);return}r=$.extend({},n.model);n.updateModel(r,!0);history.pushState(r,null,"#hledej");window.location.href=App.getUrlAction("spojeni-tam")+i.guid})},t.prototype.createEmptyModel=function(){return{stations:{},dateTime:{},params:this.model.params,passengers:{},corporateEdit:{}}},t.prototype.updateModel=function(n,t){this.stations().updateModel(n.stations);this.dateTime().updateModel(n.dateTime);this.passengers().updateModel(n.passengers,t);this.corporateEdit().updateModel(n.corporateEdit)},t.prototype.setCustomerInfoData=function(n){n==undefined||n.notFound||!Support.stringIsEmpty(n.errorMessage)?n==undefined||Support.stringIsEmpty(n.errorMessage)?this.corporateEdit().errorUWS(App.messages.connection.uwsError):n.notFound?this.corporateEdit().errorUWS(App.messages.connection.uwsErrorNotFound):this.corporateEdit().errorUWS(n.errorMessage):(this.corporateEdit().errorUWS(""),this.corporateEdit().sap(Number(n.invoice.sapCustomer)),this.corporateEdit().name(n.invoice.company));this.corporateEdit().showModal()},t}();n.SearchFormAutoTrain=t}(SearchForm||(SearchForm={})),function(n){var t=function(){function t(t){var i=this,r;this.stations=ko.observable();this.dateTime=ko.observable();this.passengers=ko.observable();this.corporateEdit=ko.observable();this.search=function(){if(i.corporateEdit().visible()&&i.corporateEdit().enabled()){if(!i.corporateEdit().canSubmit(!0))return;AjaxHelper.AjaxWaitShow(App.messages.ticketRefund.loaderProcessing);$.ajax({url:App.getUrlAction("")+"in-karta/checkCustomerInfo?ic="+i.corporateEdit().ic()+"&isICO=true&checkSAP=true",type:"GET",success:function(n){if(ErrorHandler.checkErrorsWithInfo(n,i)){AjaxHelper.AjaxWaitHide();return}AjaxHelper.AjaxWaitHide();i.setCustomerInfoData(n)}})}else AjaxHelper.AjaxWaitShow(App.messages.connection.loaderSearchConnection),i.searchConnections()};t=history.state?history.state:t;this.model=t;this.stations(new n.StationsStatic(t.stations));r=new n.CalendarModal;this.dateTime(new n.DateTime(t.dateTime,n.SearchFormType.International,r,!0));this.corporateEdit(new n.CorporateEdit(t.corporateEdit,null,null,this,null));var u=new n.PassengersModal,f=new n.PassengersFavouriteModal,e=new n.PassengersAgeModal,o=new n.PassengersPhotoModal,s=new n.FavouritePassengersRemoveModal;this.areModalsInited=!1;this.passengers(new n.Passengers(t.passengers,n.SearchFormType.International,this,u,f,e,o,s,null));ko.applyBindings(u,document.getElementById("passengersModal"));ko.applyBindings(f,document.getElementById("passengersFavouriteModal"));ko.applyBindings(e,document.getElementById("passengersAgeModal"));ko.applyBindings(o,document.getElementById("passengersPhotoModal"));ko.applyBindings(s,document.getElementById("passengersFavouriteRemoveModal"));ko.applyBindings(r,document.getElementById("calendarModal"));ko.applyBindings(this,document.getElementById("main"));$("#main .cd-select").refreshNiceSelect()}return t.prototype.searchConnections=function(){var n=this,t=this.createEmptyModel();this.updateModel(t,!1);$.post(App.getUrlAction("cdtip"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:t},function(t){var i,r;if(ErrorHandler.checkErrorsWithInfo(t,n)){AjaxHelper.AjaxWaitHide();return}if(i=t,i.passengersToSpecifyAge&&i.passengersToSpecifyAge.length>0){AjaxHelper.AjaxWaitHide();n.passengers().showAgeModal(i.passengersToSpecifyAge,i.passengersToSpecifyAgeState);return}r=$.extend({},n.model);n.updateModel(r,!0);history.pushState(r,null,"#hledej");window.location.href=App.getUrlAction("spojeni-tam")+i.guid})},t.prototype.createEmptyModel=function(){return{stations:{},dateTime:{},params:this.model.params,passengers:{},corporateEdit:{}}},t.prototype.updateModel=function(n,t){this.stations().updateModel(n.stations);this.dateTime().updateModel(n.dateTime);this.passengers().updateModel(n.passengers,t);this.corporateEdit().updateModel(n.corporateEdit)},t.prototype.setCustomerInfoData=function(n){n==undefined||n.notFound||!Support.stringIsEmpty(n.errorMessage)?n==undefined||Support.stringIsEmpty(n.errorMessage)?this.corporateEdit().errorUWS(App.messages.connection.uwsError):n.notFound?this.corporateEdit().errorUWS(App.messages.connection.uwsErrorNotFound):this.corporateEdit().errorUWS(n.errorMessage):(this.corporateEdit().errorUWS(""),this.corporateEdit().sap(Number(n.invoice.sapCustomer)),this.corporateEdit().name(n.invoice.company));this.corporateEdit().showModal()},t}();n.SearchFormCDTip=t}(SearchForm||(SearchForm={})),function(n){var t=function(){function t(t,i){var r=this;this.passengers=ko.observable();this.serviceClass=ko.observable();this.search=function(){AjaxHelper.AjaxWaitShow(App.messages.connection.loaderSearchConnection);var n=r.createEmptyModel();r.updateModel(n);$.post(App.getUrlAction("upresneni-cestujicich"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(n){var t,i;if(ErrorHandler.checkErrorsWithInfo(n,r)){AjaxHelper.AjaxWaitHide();return}if(t=n,t.passengersToSpecifyAge&&t.passengersToSpecifyAge.length>0){AjaxHelper.AjaxWaitHide();r.passengers().showAgeModal(t.passengersToSpecifyAge,t.passengersToSpecifyAgeState);return}i=$.extend({},r.model);r.updateModel(i);history.pushState(i,null,"#hledej");window.location.href=App.getUrlAction("spojeni-tam")+n.guid})};t=history.state?history.state:t;this.model=t;var u=new n.PassengersModal,f=new n.PassengersFavouriteModal,e=new n.PassengersAgeModal,o=new n.PassengersPhotoModal,s=new n.FavouritePassengersRemoveModal;this.areModalsInited=!1;this.passengers(new n.Passengers(t.passengers,n.SearchFormType.Fast,this,u,f,e,o,s,null));this.serviceClass(t.serviceClass);this.myTicket=new MyTicket(i);ko.applyBindings(u,document.getElementById("passengersModal"));ko.applyBindings(f,document.getElementById("passengersFavouriteModal"));ko.applyBindings(e,document.getElementById("passengersAgeModal"));ko.applyBindings(o,document.getElementById("passengersPhotoModal"));ko.applyBindings(s,document.getElementById("passengersFavouriteRemoveModal"));ko.applyBindings(this,document.getElementById("main"))}return t.prototype.searchConnections=function(){this.search()},t.prototype.createEmptyModel=function(){return{guid:"",passengers:{},serviceClass:""}},t.prototype.updateModel=function(n){n.guid=this.model.guid;this.passengers().updateModel(n.passengers,!1);n.serviceClass=this.serviceClass()},t}();n.TransitionPage=t}(SearchForm||(SearchForm={})),function(n){var t,i,r,u;(function(n){n[n.NotValid=1]="NotValid";n[n.Reclamation=2]="Reclamation";n[n.Valid=3]="Valid";n[n.Expired=4]="Expired";n[n.NotYetValid=5]="NotYetValid"})(t=n.OTTicketStatus||(n.OTTicketStatus={}));i=function(){function n(n){var i=this,r;this.transactionCode=ko.observable();this.language=ko.observable(0);this.showSearchResults=ko.observable(!1);this.ticketStatus=ko.observable();this.tickets=ko.observableArray();this.searchEnabled=ko.observable(!0);this.doneTimeout=null;this.doneTimeoutShow=2e3;this.clear=function(){i.showSearchResults(!1);i.transactionCode("");$("#transCodeInput").focus()};this.search=function(){if(i.showSearchResults(!1),!Support.stringIsEmpty(i.transactionCode())){i.doneTimeout&&clearTimeout(i.doneTimeout);i.doneTimeout=setTimeout(function(){AjaxHelper.AjaxWaitShow(App.messages.ticketRefund.loaderProcessing)},i.doneTimeoutShow);i.searchEnabled(!1);var n=i.createEmptyModel();$.post(App.getUrlAction("otcheck"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(n){if(ErrorHandler.checkErrorsWithInfo(n,i)){i.searchEnabled(!0);i.doneTimeout&&clearTimeout(i.doneTimeout);AjaxHelper.AjaxWaitHide();return}i.updateSearch(n)})}};this.showLanguageModal=function(){$("#LanguageModal").modal("show")};this.languageIcon=ko.computed(function(){var n="ot-flag-cs";return i.language()==1&&(n="ot-flag-en"),i.language()==2&&(n="ot-flag-de"),n},this);this.stateText=ko.computed(function(){var n="";return i.ticketStatus()==t.NotValid&&(n=App.messages.otCheck.notValid),i.ticketStatus()==t.Reclamation&&(n=App.messages.otCheck.reclamation),i.ticketStatus()==t.Valid&&(n=App.messages.otCheck.valid),i.ticketStatus()==t.Expired&&(n=App.messages.otCheck.expired),i.ticketStatus()==t.NotYetValid&&(n=App.messages.otCheck.notYetValid),n},this);this.showBaseState=ko.computed(function(){return i.ticketStatus()<t.Valid},this);this.stateStyle=ko.computed(function(){var n="";return i.ticketStatus()==t.NotValid&&(n="ot-notValid"),i.ticketStatus()==t.Reclamation&&(n="ot-reclamation"),n},this);this.model=n;this.language(this.model.language);this.transactionCode(this.model.transactionCode);r=new u(this);ko.applyBindings(this,document.getElementById("main"));ko.applyBindings(r,document.getElementById("LanguageModal"));Support.stringIsEmpty(this.transactionCode())||this.search()}return n.prototype.createEmptyModel=function(){return{language:this.language(),transactionCode:this.transactionCode().trim()}},n.prototype.updateSearch=function(n){var t=this;this.language(n.language);this.ticketStatus(n.ticketStatus);this.tickets.removeAll();n.tickets.forEach(function(n){return t.tickets.push(new r(n))});this.tickets.valueHasMutated();this.showSearchResults(!0);this.searchEnabled(!0);this.doneTimeout&&clearTimeout(this.doneTimeout);AjaxHelper.AjaxWaitHide()},n.prototype.changeLanguage=function(n){var i="?lang=cs",t;n==1&&(i="?lang=en");n==2&&(i="?lang=de");t=this.transactionCode();t=Support.stringIsEmpty(t)?"":t.trim()+"/";window.location.href="/eshop/otcheck/"+t+i},n}();n.OTCheck=i;r=function(){function n(n){var u=this,i,r;this.coachAndPlace=ko.observableArray();this.issueDate=n.issueDate;this.ticketName=n.ticketName;this.fromTo=n.fromTo;this.ticketValidity=n.ticketValidity;this.transactionCode=n.transactionCode;this.ticketStatus=n.ticketStatus;n.coachAndPlace.forEach(function(n){return u.coachAndPlace.push(n)});this.trainName=n.trainName;i="";r="";this.ticketStatus==t.NotValid&&(i=App.messages.otCheck.notValid,r="ot-notValid");this.ticketStatus==t.Reclamation&&(i=App.messages.otCheck.reclamation,r="ot-reclamation");this.ticketStatus==t.Valid&&(i=App.messages.otCheck.valid,r="ot-valid");this.ticketStatus==t.Expired&&(i=App.messages.otCheck.expired,r="ot-expired");this.ticketStatus==t.NotYetValid&&(i=App.messages.otCheck.notYetValid,r="ot-notYetValid");this.ticketStatusText=i;this.ticketStatusStyle=r}return n}();u=function(){function n(n){var t=this;this.done=function(n){$("#LanguageModal").modal("hide");t.parent.language()!=n&&t.parent.changeLanguage(n)};this.parent=n}return n}()}(OTCheck||(OTCheck={})),function(n){var i=function(){function n(n,i,r,u,f){var e=this;this.visible=ko.observable(!1);this.enabled=ko.observable(!1);this.discount=ko.observable(0);this.ic=ko.observable("");this.sap=ko.observable(0);this.name=ko.observable("");this.errorUWS=ko.observable("");this.sideBuy=ko.observable(!1);this.specialTrains=ko.observable(!1);this.error=ko.observable(new ErrorInfo("CorporateEdit"));this.searchUWS=function(){(e.error().message(""),e.canSubmit(!1))&&(AjaxHelper.AjaxWaitShow(App.messages.ticketRefund.loaderProcessing),$.ajax({url:App.getUrlAction("")+"in-karta/checkCustomerInfo?ic="+e.ic()+"&isICO=true&checkSAP=true",type:"GET",success:function(n){if(ErrorHandler.checkErrorsWithInfo(n,e)){AjaxHelper.AjaxWaitHide();return}AjaxHelper.AjaxWaitHide();e.setCustomerInfoData(n)}}))};this.showModal=function(){e.corporateEditModal.show()};this.sapValue=ko.pureComputed(function(){return e.sap()>0?e.sap().toString():""},this);this.saveSAP=function(){if(e.error().message(""),!Support.stringIsEmpty(e.errorUWS())){e.error().message(e.errorUWS());$("#corporateEditModal").modal("hide");return}if(e.sap()<0){e.error().message(App.messages.connection.corporateCompanySAPNotFound);$("#corporateEditModal").modal("hide");return}AjaxHelper.AjaxWaitShow(App.messages.ticketRefund.loaderProcessing);$.ajax({url:App.getUrlAction("")+"ApplyCustomerSAP?SAP="+e.sap()+"&IC="+e.ic()+"&company="+e.name(),type:"GET",success:function(n){if($("#corporateEditModal").modal("hide"),ErrorHandler.checkErrorsWithInfo(n,e)){AjaxHelper.AjaxWaitHide();return}if(AjaxHelper.AjaxWaitHide(),n.sapError)e.error().message(n.sapError);else if(e.shopCart!=null){var t=n;e.shopCart.setModel(t,!1);e.enabled(!1)}}})};this.model=n;this.visible(this.model.visible);this.enabled(this.model.enabled);this.discount(this.model.discount);this.ic(this.model.ic);this.sap(this.model.sap);this.name(this.model.company);this.sideBuy(this.model.sideBuy!=null&&this.model.sideBuy.menuContext>0);this.specialTrains(this.model.specialTrains!=null&&this.model.specialTrains.docId>-1);this.shopCart=f;(i!=null||r!=null||u!=null||this.sideBuy()||this.specialTrains()||this.shopCart!=null)&&(this.corporateEditModal=this.shopCart!=null?this.shopCart.corporateEditModal:new t,this.corporateEditModal.init(this,i,r,u));this.setValidation();this.errors=ko.validation.group(this);this.ic.subscribe(function(){e.sap(0);e.name("")});this.discount.subscribe(function(){e.sap(0);e.name("")});(i!=null||r!=null||u!=null||this.sideBuy()||this.specialTrains())&&ko.applyBindings(this.corporateEditModal,document.getElementById("corporateEditModal"));(this.sideBuy()||this.specialTrains())&&ko.applyBindings(this,document.getElementById("main"))}return n.prototype.canSubmit=function(n){return(this.ic.canValidate(!0),this.discount.canValidate(n),this.errors().length>0)?(this.errors().length>0&&this.errors.showAllMessages(),!1):!0},n.prototype.done=function(){var n=this;this.canSubmit(!0)&&(this.enabled()?(AjaxHelper.AjaxWaitShow(App.messages.ticketRefund.loaderProcessing),$.ajax({url:App.getUrlAction("")+"in-karta/checkCustomerInfo?ic="+this.ic()+"&isICO=true&checkSAP=true",type:"GET",success:function(t){if(ErrorHandler.checkErrorsWithInfo(t,n)){AjaxHelper.AjaxWaitHide();return}AjaxHelper.AjaxWaitHide();n.setCustomerInfoData(t)}})):this.corporateEditModal.done())},n.prototype.showModalBuyAgain=function(n,t){this.corporateEditModal.setBuyAgain(n,t);this.corporateEditModal.show()},n.prototype.showModalShopCart=function(n){this.corporateEditModal.setShopCart(n);this.corporateEditModal.show()},n.prototype.updateModel=function(n){n.visible=this.visible();n.enabled=this.enabled();n.discount=this.discount();n.ic=this.ic();n.sap=this.sap();n.company=this.name();n.sideBuy=this.model.sideBuy;n.specialTrains=this.model.specialTrains},n.prototype.setValidation=function(){var n=this;this.discount.extend({canValidate:!1,required:{onlyIf:function(){return n.discount.canValidate()},message:App.messages.validation.requiredItem},validation:[{onlyIf:function(){return n.discount.canValidate()},validator:function(n){return n>=0&&n<=100},message:App.messages.validation.errorDiscountNumber}]});this.ic.extend({canValidate:!1,required:{onlyIf:function(){return n.ic.canValidate()},message:App.messages.validation.requiredItem},validation:[{onlyIf:function(){return n.ic.canValidate()},validator:function(n){return!Support.stringIsEmpty(n)&&ValidationHelper.isIKNumberDigits(n)},message:function(){return App.messages.validation.errorIKNumberDigits}}]})},n.prototype.setCustomerInfoData=function(n){n==undefined||n.notFound||!Support.stringIsEmpty(n.errorMessage)?n==undefined||Support.stringIsEmpty(n.errorMessage)?this.errorUWS(App.messages.connection.uwsError):n.notFound?this.errorUWS(App.messages.connection.uwsErrorNotFound):this.errorUWS(n.errorMessage):(this.errorUWS(""),this.sap(Number(n.invoice.sapCustomer)),this.name(n.invoice.company));this.shopCart!=null?this.showModalShopCart(this.shopCart):this.showModal()},n}(),t;n.CorporateEdit=i;t=function(){function n(){var n=this;this.content=ko.observable();this.discount=ko.observable();this.ic=ko.observable();this.sap=ko.observable();this.company=ko.observable();this.hasError=ko.observable();this.done=function(){if(n.shopCart!=null)n.parentModel.saveSAP();else if(n.parentModel.sideBuy()||n.parentModel.specialTrains()){AjaxHelper.AjaxWaitShow(App.messages.ticketRefund.loaderProcessing);var t={};n.parentModel.updateModel(t);$.post(App.getUrlAction("corporate-edit"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:t},function(t){if(ErrorHandler.checkErrorsWithInfo(t,n)){AjaxHelper.AjaxWaitHide();return}window.location.href=t.url})}else{if(AjaxHelper.AjaxWaitShow(App.messages.connection.loaderSearchConnection),n.buyAgain!=null){n.buyAgainNetTicket&&n.buyAgain.searchNetTicket();n.buyAgainNetTicket||n.buyAgain.searchConnections();return}n.searchForm!=null&&n.searchForm.searchConnections();n.searchFormAutoTrain!=null&&n.searchFormAutoTrain.searchConnections();n.searchFormCDTip!=null&&n.searchFormCDTip.searchConnections()}}}return n.prototype.init=function(n,t,i,r){this.parentModel=n;this.searchForm=t;this.searchFormAutoTrain=i;this.searchFormCDTip=r},n.prototype.setBuyAgain=function(n,t){this.buyAgain=n;this.buyAgainNetTicket=t},n.prototype.setShopCart=function(n){this.shopCart=n},n.prototype.show=function(){this.hasError(!Support.stringIsEmpty(this.parentModel.errorUWS()));this.hasError()?this.content(this.parentModel.errorUWS()):(this.discount(this.parentModel.discount()+""),this.ic(this.parentModel.ic()),this.company(this.parentModel.name()),this.sap(this.parentModel.sapValue()),this.content(App.messages.connection.corporateEditAccept),this.shopCart!=null&&(this.discount(""),this.content(App.messages.connection.corporateCompanySAPAccept)));$("#corporateEditModal").modal("show")},n}();n.CorporateEditModal=t}(SearchForm||(SearchForm={})),function(n){n[n.EMPTY=0]="EMPTY";n[n.FREEWELCOMEDRINK=1]="FREEWELCOMEDRINK";n[n.FREEWATER=2]="FREEWATER";n[n.FREEPRESS=3]="FREEPRESS";n[n.FREESNACK=4]="FREESNACK";n[n.EORDERSNACK=5]="EORDERSNACK";n[n.SNACKDELIVERY=6]="SNACKDELIVERY"}(BONUSSERVICES_ICONS||(BONUSSERVICES_ICONS={}));BonusServiceInfo=function(){function n(n){this.title=n.title;this.text=n.text;switch(n.icon){case BONUSSERVICES_ICONS.EMPTY:this.iconImage="";break;case BONUSSERVICES_ICONS.FREEWELCOMEDRINK:this.iconImage="ico-cafe-g.svg";break;case BONUSSERVICES_ICONS.FREEWATER:this.iconImage="ico-watter-g.svg";break;case BONUSSERVICES_ICONS.FREEPRESS:this.iconImage="ico-newspapper-g.svg";break;case BONUSSERVICES_ICONS.FREESNACK:this.iconImage="ico-fastfood-g.svg";break;case BONUSSERVICES_ICONS.EORDERSNACK:this.iconImage="ico-cafemat-g.svg";break;case BONUSSERVICES_ICONS.SNACKDELIVERY:this.iconImage="ico-lunch-g.svg"}}return n}();ConnectionBonusServiceModal=function(){function n(){this.trainModel=ko.observable();this.selectedBonusServices=ko.observableArray();this.activeClass=ko.observable();this.classBusiness="Business";this.class1St="1";this.class2Nd="2";this.sectionFrom=ko.observable();this.sectionTo=ko.observable()}return n.prototype.show=function(n){this.trainModel(n);this.containsClass(this.classBusiness)?this.selectClass(this.classBusiness):this.containsClass(this.class1St)?this.selectClass(this.class1St):this.containsClass(this.class2Nd)&&this.selectClass(this.class2Nd)},n.prototype.fromTo=function(){var t=this.trainModel().from,n;return Support.stringIsEmpty(this.sectionFrom())||(t=this.sectionFrom()),n=this.trainModel().to,Support.stringIsEmpty(this.sectionTo())||(n=this.sectionTo()),t+" - "+n},n.prototype.containsClass=function(n){for(var t in this.trainModel().bonusServices)if(this.trainModel().bonusServices[t].class===n)return!0;return!1},n.prototype.selectClass=function(n){var i=this,t;for(t in this.trainModel().bonusServices)this.trainModel().bonusServices[t].class===n&&(this.activeClass(n),this.sectionFrom(this.trainModel().bonusServices[t].sectionFrom),this.sectionTo(this.trainModel().bonusServices[t].sectionTo),this.selectedBonusServices.removeAll(),this.trainModel().bonusServices[t].services.forEach(function(n){i.selectedBonusServices.push(new BonusServiceInfo(n))}))},n}(),function(n){n[n.THERE=0]="THERE";n[n.THERE_WITH_BACK=1]="THERE_WITH_BACK";n[n.BACK=2]="BACK"}(CONN_PAGE_TYPE||(CONN_PAGE_TYPE={})),function(n){n[n.ACTUAL=0]="ACTUAL";n[n.PREV=1]="PREV";n[n.NEXT=2]="NEXT";n[n.NEXTMORE=3]="NEXTMORE"}(SEARCHTYPE||(SEARCHTYPE={})),function(n){n[n.INIT_DATA_INCORRECT=1]="INIT_DATA_INCORRECT";n[n.AUTH_DATA_INCORRECT=2]="AUTH_DATA_INCORRECT";n[n.REQUEST_FORBIDDEN=3]="REQUEST_FORBIDDEN";n[n.REQUEST_CONFLICT=4]="REQUEST_CONFLICT";n[n.REQUEST_TOO_LARGE=5]="REQUEST_TOO_LARGE";n[n.WAIT_TIMEOUT=6]="WAIT_TIMEOUT"}(ErrorType||(ErrorType={}));var ConnectionList=function(){function n(n,t,i){i===void 0&&(i=!1);var r=this;this.connList=ko.observableArray();this.allowPrev=ko.observable();this.allowNext=ko.observable();this.searchDateWarning=ko.observable();this.businessWarning=ko.observable();this.isFavorite=ko.observable();this.onlyForOneConnection=ko.observable();this.isAnyConnectionSelected=ko.observable();this.pdfClick=function(){var n=r.isBack()?"seznam-zpet/pdf":"seznam-tam/pdf",t=r.getSelectedConnection(),i=""+App.getUrlAction(n)+r.model.guid+"/"+t.join("|");DownloadFileWithLoader.download("#main",i,App.messages.connection.generatePDF)};this.sendMailClick=function(){var n=r.getDataSendMail();$.fn.OGSendMail(n)};this.facebookShareClick=function(){var n=App.messages.connection.facebookShareConnectionsDescription(r.model.searchFrom,r.model.searchTo,r.model.searchDateTime),t=r.azakAppBackUrl+"/"+r.eshopContextUrlPart+"/";FB.ui({method:"share_open_graph",action_type:"og.shares",action_properties:JSON.stringify({object:{"og:url":t,"og:title":"E-shop ČD","og:description":n,"og:image":"http://m.cd.cz/spojeni/ogres/img/cd-logo-og.png"}})})};this.favIconClick=function(){var n=(r.isBack()?"oblibene-spojeni-nastaveni/true/":"oblibene-spojeni-nastaveni/false/")+!r.isFavorite()+"/"+r.model.guid+"/";$.post(App.getUrlAction(n),{__RequestVerificationToken:App.GetAntiForgeryToken()},function(n){ErrorHandler.checkErrors(n)||(n?n.azakErrorCode===ErrorType.REQUEST_CONFLICT?(r.favoritesModal.show(n.favouriteConnections,!1,"favoritesPaging",r.model.guid,r,n.maxFavCount),$("#favoritesModal").modal("show")):alert("Nezdařilo se zapsat oblíbené spojení, zkuste, prosím, provést zápis později."):r.isFavorite(!r.isFavorite()))})};this.unselectAllConnections=function(){for(var n in r.connList())r.connList()[n].connectionSelected(!1)};this.model=n;this.serverDateTime=DateTimeHelper.parseDateTime(n.serverDateTime);this.calendarModal=new SearchForm.CalendarModal;this.filter=new ConnectionFilter(n.filter,this);this.legend=new ConnectionListLegend;this.isLoggedUser=i;this.fillConnList(n);this.excsModal=new ConnectionExcsModal;this.connectionBonusServicesModal=new ConnectionBonusServiceModal;this.favoritesModal=new FavouriteConnectionsModal;this.myTicket=new MyTicket(t);this.searchDate=DateTimeHelper.parseDate(n.searchDate);this.onlyForOneConnection(n.onlyForOneConnection);this.isBikeOrder=n.isBikeOrder;this.azakAppBackUrl=n.azakAppBackUrl;this.eshopContextUrlPart=n.eshopContextUrlPart;this.isChangeReservation=n.isChangeReservation;this.isAnyConnectionSelected=ko.pureComputed(function(){for(var n in this.connList())if(this.connList()[n].connectionSelected())return!0;return!1},this);this.checkSort();this.onlyForOneConnection()&&(this.model.pageType==CONN_PAGE_TYPE.THERE||this.model.pageType==CONN_PAGE_TYPE.THERE_WITH_BACK)?(this.connectionParams=new SearchForm.Params(n.connectionDefaultParamsModel,n.connectionDefaultParamsModel,this.filter,"trainTypes",null),this.filter.enableFilter(!1)):(this.connectionParams=new SearchForm.Params(n.connectionParamsModel,n.connectionDefaultParamsModel,this.filter,"trainTypes",null),this.filter.enableFilter(!0));n.errors&&ErrorHandler.checkErrorsWithInfo(n.errors,this);ko.applyBindings(this,document.getElementById("main"));ko.applyBindings(this.excsModal,document.getElementById("excsModal"));ko.applyBindings(this.connectionBonusServicesModal,document.getElementById("connectionBonusServicesModal"));ko.applyBindings(this.favoritesModal,document.getElementById("favoritesModal"));this.model.pageType==CONN_PAGE_TYPE.THERE&&ko.applyBindings(this.calendarModal,document.getElementById("calendarModal"));this.initTouchTooltip("")}return n.prototype.initTouchTooltip=function(n){Support.isTouchDevice()&&$(n+" .tooltip-item").tooltip({placement:"bottom"})},n.prototype.initTouchLegendTrainDelay=function(n,t,i){return!n&&!t&&i.model.delay>-1&&(t=new FixedCodeModel,t.text=i.delayText(),t.css=i.delayCss(),t.title=App.messages.connection.delayTitle.toLowerCase()),t},n.prototype.initTouchLegendPlatform=function(n,t){if(!n)for(var i in t)t[i].css=="platform"&&(n=new FixedCodeModel,n.text=t[i].text,n.css="stroke tooltip-item",n.title=t[i].title);return n},n.prototype.isBack=function(){return this.model.pageType==CONN_PAGE_TYPE.BACK},n.prototype.head=function(){return this.isBack()||this.model.isReturnOnly?App.messages.connection.selConnReturn:this.model.fromConnByTicket?App.messages.connection.connectionsByTicket:App.messages.connection.selConn},n.prototype.hideDetails=function(){for(var n in this.connList())this.connList()[n].detailVisible(!1),this.connList()[n].connThere&&this.connList()[n].connThere.detailVisible(!1)},n.prototype.activeTabBack=function(n){for(var t in this.connList())this.connList()[t].activeTabBack(n)},n.prototype.prev=function(){this.getConnList(SEARCHTYPE.PREV)},n.prototype.next=function(){this.getConnList(SEARCHTYPE.NEXT)},n.prototype.nextMore=function(){this.getConnList(SEARCHTYPE.NEXTMORE)},n.prototype.getConnList=function(n){var i=this,t=new ConnectionGetModel;t.guid=this.model.guid;t.SearchType=n;t.pageType=this.model.pageType;this.setPaging(t);t.priceType=Number(this.filter.priceTypeAct);t.sortType=Number(this.filter.sortTypeAct);n===SEARCHTYPE.ACTUAL&&(t.connParams=this.model.connectionParamsModel);AjaxHelper.AjaxWaitShow(App.messages.connection.loaderSearchConnection);$.post(App.getUrlAction("getconnectionlist"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:t},function(t){(AjaxHelper.AjaxWaitHide(),ErrorHandler.checkErrors(t))||(i.fillConnList(t,n),i.filter.showFilter(!1),i.checkSort(),n!=SEARCHTYPE.NEXTMORE&&(location.hash="#connectionlistanchor"))})},n.prototype.checkSort=function(){this.filter.sortType()!=CONN_FILTER_SORT_TYPE.DEP.toString()&&this.filter.sort()},n.prototype.fillConnList=function(n,t){var i,r;for(t===void 0&&(t=SEARCHTYPE.NEXT),t!=SEARCHTYPE.NEXTMORE&&this.connList.removeAll(),i=0;i<n.list.length;i++)(t!=SEARCHTYPE.NEXTMORE||i!=0)&&(r=null,this.isBack()&&!this.model.isReturnOnly&&(r=new ConnectionInfo(n.connThere,this,null,n.hasLoyaltyAccount,this.isLoggedUser)),this.connList.push(new ConnectionInfo(n.list[i],this,r,n.hasLoyaltyAccount,this.isLoggedUser)));this.allowPrev(n.allowPrev);this.allowNext(n.allowNext);this.ttFirstValidDate=DateTimeHelper.parseDate(n.ttFirstValidDate);this.ttLastValidDate=DateTimeHelper.parseDate(n.ttLastValidDate);this.lastValidDate=DateTimeHelper.parseDate(n.lastValidDate);this.searchDateWarning(n.searchDateWarning);this.businessWarning(n.businessWarning);this.legend.init(this.connList);this.isFavorite(n.isFavorite)},n.prototype.setPaging=function(n){n.refreshID=this.connList()[0].id;this.connList().length<=2?(n.prevID=this.connList()[0].id,n.nextID=this.connList()[0].id):(n.prevID=this.connList()[1].id,n.nextID=this.connList()[this.connList().length-2].id)},n.prototype.getDataSendMail=function(){var n=this.model.dataSendEmail,t;return n.ogLang=App.locale,n.winTitle=App.messages.connection.sendMailConnTitle,n.ajaxUrl=App.getUrlAction("SendTrainPdfMail"),n.pdfGeneratorParams=new DataPdfGeneratorParams,n.pdfGeneratorParams.guid=this.model.guid,n.pdfGeneratorParams.back=this.isBack(),t=this.getSelectedConnection(),n.pdfGeneratorParams.listId=t.join("|"),n},n.prototype.getSelectedConnection=function(){var t=[],i=[],n;for(n in this.connList())this.connList()[n].connectionSelected()&&t.push(this.connList()[n].id),i.push(this.connList()[n].id);return t.length>0?t:i},n}(),DateLimitsCalParams=function(){function n(){}return n}(),DateLimitsCalData=function(){function n(){}return n}(),__extends=this&&this.__extends||function(){var n=function(t,i){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i])},n(t,i)};return function(t,i){function r(){this.constructor=t}n(t,i);t.prototype=i===null?Object.create(i):(r.prototype=i.prototype,new r)}}(),DataSendEmailBase=function(){function n(){}return n}(),DataSendEmailShared=function(){function n(){}return n}(),DataSendEmailForKlient=function(n){function t(){return n!==null&&n.apply(this,arguments)||this}return __extends(t,n),t}(DataSendEmailBase),DataSendEmailForServer=function(n){function t(){return n!==null&&n.apply(this,arguments)||this}return __extends(t,n),t}(DataSendEmailBase),DataPdfGeneratorParams=function(){function n(){}return n}(),EXC_TYPE;(function(n){n[n.EXCLUSION=0]="EXCLUSION";n[n.EXCEPTION=1]="EXCEPTION"})(EXC_TYPE||(EXC_TYPE={})),function(n){n[n.DEFAULT=1]="DEFAULT";n[n.DELAY=2]="DELAY";n[n.CANCELLATION=3]="CANCELLATION";n[n.REPLACEMENT=4]="REPLACEMENT";n[n.DIVERSION=5]="DIVERSION";n[n.TIMETABLE=6]="TIMETABLE";n[n.REPLACEMENT_TIMETABLE=7]="REPLACEMENT_TIMETABLE";n[n.FREE=8]="FREE"}(EXCEPTIONEXCLUSION_RULETYPE||(EXCEPTIONEXCLUSION_RULETYPE={}));var ExceptionRuleType=function(){function n(n,t,i){this.type=t;this.desc=TrainExc.addRuleTypesDesc("",t);i&&this.desc!=null&&this.desc!==""&&(this.desc=this.desc.toLocaleLowerCase());this.imgRootUrl=n;this.icoSrc=TrainExc.getIcoSrc(n,t);this.isLegend=i;i&&(this.desc1=Support.getFirstWord(this.desc),this.desc2=Support.removeFirstWord(this.desc))}return n}(),ConnectionExcsModal=function(){function n(){this.excs=ko.observableArray();this.isTrain=ko.observable()}return n.prototype.show=function(n,t){this.excs.removeAll();for(var i in n)this.excs.push(n[i]);this.isTrain(t)},n}(),TrainExc=function(){function n(n,t){this.excsRuleType=Array();this.model=n;this.initRuleTypes(n.ruleType.sort());this.trainName=t}return n.prototype.initRuleTypes=function(n){for(var t in n)this.excsRuleType.push(new ExceptionRuleType(this.model.imgRootUrl,n[t],!1))},n.prototype.showDesc=function(){return this.trainName+": "+App.messages.connection.section+" "+this.model.section},n.prototype.ruleTypesDesc=function(){var t="",i;if(this.excsRuleType!=null&&this.excsRuleType.length>0)for(i in this.excsRuleType)t=n.addRuleTypesDesc(t,this.excsRuleType[i].type);return Support.append(t,this.model.description,", ")},n.addRuleTypesDesc=function(n,t){return t===EXCEPTIONEXCLUSION_RULETYPE.DEFAULT||t===EXCEPTIONEXCLUSION_RULETYPE.FREE?n=Support.append(n,App.messages.connection.exDefault,", "):t===EXCEPTIONEXCLUSION_RULETYPE.DELAY?n=Support.append(n,App.messages.connection.exDelay,", "):t===EXCEPTIONEXCLUSION_RULETYPE.CANCELLATION?n=Support.append(n,App.messages.connection.exCancellation,", "):t===EXCEPTIONEXCLUSION_RULETYPE.REPLACEMENT||t===EXCEPTIONEXCLUSION_RULETYPE.REPLACEMENT_TIMETABLE?n=Support.append(n,App.messages.connection.exReplacement,", "):t===EXCEPTIONEXCLUSION_RULETYPE.DIVERSION?n=Support.append(n,App.messages.connection.exDiversion,", "):t===EXCEPTIONEXCLUSION_RULETYPE.TIMETABLE&&(n=Support.append(n,App.messages.connection.exTimetable,", ")),n},n.getIcoSrc=function(n,t){var i="";return t===EXCEPTIONEXCLUSION_RULETYPE.DEFAULT||t===EXCEPTIONEXCLUSION_RULETYPE.FREE?i=n+"ico-question-orange.svg":t===EXCEPTIONEXCLUSION_RULETYPE.DELAY?i=n+"ico-time-orange.svg":t===EXCEPTIONEXCLUSION_RULETYPE.CANCELLATION?i=n+"ico-train-orange.svg":t===EXCEPTIONEXCLUSION_RULETYPE.REPLACEMENT||t===EXCEPTIONEXCLUSION_RULETYPE.REPLACEMENT_TIMETABLE?i=n+"ico-train-orange2.svg":t===EXCEPTIONEXCLUSION_RULETYPE.DIVERSION?i=n+"ico-arrow-orange.svg":t===EXCEPTIONEXCLUSION_RULETYPE.TIMETABLE&&(i=n+"ico-pdf-orange.svg"),i},n.constainEx=function(t,i){return n.getExIndex(t,i)===-1?i===EXCEPTIONEXCLUSION_RULETYPE.DEFAULT&&n.getExIndex(t,EXCEPTIONEXCLUSION_RULETYPE.FREE)>-1?!0:i===EXCEPTIONEXCLUSION_RULETYPE.FREE&&n.getExIndex(t,EXCEPTIONEXCLUSION_RULETYPE.DEFAULT)>-1?!0:!1:!0},n.getExIndex=function(n,t){for(var i in n)if(n[i].type===t)return parseInt(i);return-1},n}(),FavouriteConnectionsModal=function(){function n(){var n=this;this.visibleFavConns=ko.observableArray();this.enableAddFavourite=ko.observable();this.hasRelations=ko.observable();this.pagingDiv=ko.observable();this.maxConnLimit=ko.observable();this.pageSize=4;this.addFavouriteClick=function(){n.connList.favIconClick();$("#favoritesModal").modal("hide")}}return n.prototype.show=function(n,t,i,r,u,f){this.model=n;this.connList=u;this.pagingDiv(i);this.guid=r;this.actualPageNumber=1;this.enableAddFavourite(!1);this.hasRelations(!1);this.maxFavCount=f;var e={rel:this.model.rel.slice(0,this.pageSize)};this.showData(e,!0);this.maxConnLimit(App.messages.connection.favConnsMaxLimit(this.maxFavCount));t&&ko.applyBindings(this,document.getElementById(i))},n.prototype.paging=function(n){(this.model.rel.length/this.pageSize<n-1||n<1)&&(n=1);this.model.rel.length>0&&this.model.rel.length/this.pageSize<=n-1&&(n--,$("#"+this.pagingDiv()).pagination("selectPage",n));this.actualPageNumber=n;var t={rel:this.model.rel.slice(n*this.pageSize-this.pageSize,n*this.pageSize)};this.showData(t,!1)},n.prototype.removeItemFromModel=function(n){var t=this.model.rel.indexOf(n);t>-1&&this.model.rel.splice(t,1)},n.prototype.getSimplePaginationOptions=function(){var t=this,n={};return n.items=this.model.rel.length,n.itemsOnPage=this.pageSize,n.prevText=App.messages.connection.prevPageText,n.nextText=App.messages.connection.nextPageText,n.displayedPages=3,n.onPageClick=function(n,i){t.paging(n);i.preventDefault()},n},n.prototype.showData=function(n,t){var i=this;if(!n||!n.rel){$("#"+this.pagingDiv()).hide();return}this.visibleFavConns.removeAll();n.rel.forEach(function(n){i.visibleFavConns.push(new MyFavourites.RelationInfoForModal(n,i))});t?$("#"+this.pagingDiv()).pagination(this.getSimplePaginationOptions()):$("#"+this.pagingDiv()).pagination("updateItems",this.model.rel.length);$("#"+this.pagingDiv()).pagination("getPagesCount")<2?$("#"+this.pagingDiv()).hide():$("#"+this.pagingDiv()).show();this.hasRelations(n.rel.length>0)},n}(),__extends=this&&this.__extends||function(){var n=function(t,i){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i])},n(t,i)};return function(t,i){function r(){this.constructor=t}n(t,i);t.prototype=i===null?Object.create(i):(r.prototype=i.prototype,new r)}}(),CONN_FILTER_SORT_TYPE;(function(n){n[n.DEP=0]="DEP";n[n.ARR=1]="ARR";n[n.PRICE=2]="PRICE";n[n.TIME=3]="TIME";n[n.CHANGE=4]="CHANGE"})(CONN_FILTER_SORT_TYPE||(CONN_FILTER_SORT_TYPE={})),function(n){n[n.ALL=0]="ALL";n[n.ESHOP=1]="ESHOP";n[n.UNIPOK=2]="UNIPOK"}(CONN_FILTER_PRICE_TYPE||(CONN_FILTER_PRICE_TYPE={}));var ConnectionTraintypeAnchor=function(n){function t(t,i,r,u,f){var e=n.call(this,t,i,r)||this;return e.connList=u,e.hide=f,e}return __extends(t,n),t.prototype.change=function(){this.checked(!this.checked())},t}(CheckBoxListItem),ConnectionFilter=function(){function n(n,t){this.sortType=ko.observable(CONN_FILTER_SORT_TYPE.DEP.toString());this.priceType=ko.observable(CONN_FILTER_PRICE_TYPE.ALL.toString());this.trainTypes=ko.observableArray();this.showFilter=ko.observable(!1);this.enableFilter=ko.observable();this.connList=t;this.sortType(n.sortType+"");this.priceType(n.priceType+"");this.sortTypeAct=this.sortType();this.priceTypeAct=this.priceType();this.trainTypesAct=this.connList.model.connectionParamsModel.trainTypes;this.initTrainTypes()}return n.prototype.storeActValues=function(){this.sortTypeAct=this.sortType();this.priceTypeAct=this.priceType();this.storeTrainTypes()},n.prototype.storeTrainTypes=function(){for(var u=!0,n,i,t=0,r=this.trainTypes();t<r.length;t++)n=r[t],i=this.trainTypesAct.indexOf(n.value()),n.checked()?i==-1&&this.trainTypesAct.push(n.value()):(this.trainTypesAct.indexOf(n.value())>-1&&this.trainTypesAct.splice(i,i+1),u=!1);u&&(this.trainTypesAct=[])},n.prototype.initTrainTypes=function(){var u=[],t,f,i,e,r,o,n,s;if(this.trainTypesAct&&this.trainTypesAct.length>0)for(t=0,f=this.trainTypesAct;t<f.length;t++)n=f[t],u.push(n);if(this.trainTypes.removeAll(),i=this.connList.model.connectionParamsModel,i.trainTypeItems&&i.trainTypeItems.length>0)for(e=0,r=0,o=i.trainTypeItems;r<o.length;r++)n=o[r],s=new ConnectionTraintypeAnchor(n.shortName,n.value,u.length==0||u.indexOf(n.value)>-1,this.connList.model,e>=4),this.trainTypes.push(s),e++},n.prototype.toggleFilter=function(){var n,t,i;if(this.showFilter())this.showFilter(!1);else{if(!this.connList.model.connectionParamsModel.trainTypes||this.connList.model.connectionParamsModel.trainTypes.length==0)for(n=0,t=this.trainTypes();n<t.length;n++)i=t[n],i.checked(!0);this.sortType(this.sortTypeAct);this.priceType(this.priceTypeAct);this.initTrainTypes();this.showFilter(!0)}},n.prototype.filter=function(){var t=this,n;this.filterOverServer()?(this.storeActValues(),this.connList.model.connectionParamsModel.trainTypes=this.trainTypesAct,this.connList.isLoggedUser?(n=new SearchForm.StoreParamsModel,n.params=this.connList.model.connectionParamsModel,n.services=null,$.post(App.getUrlAction("SaveConnectionParams"),{__RequestVerificationToken:App.GetAntiForgeryToken(),connParams:n},function(n){ErrorHandler.checkErrorsWithInfo(n,t)||t.connList.getConnList(SEARCHTYPE.ACTUAL)})):(n=new SearchForm.StoreParamsModel,n.save(this.connList.model.connectionParamsModel,null),this.connList.getConnList(SEARCHTYPE.ACTUAL))):(this.storeActValues(),this.sort())},n.prototype.filterModal=function(){var t=this,n;this.trainTypesAct=this.connList.model.connectionParamsModel.trainTypes;this.initTrainTypes();this.connList.isLoggedUser?(n=new SearchForm.StoreParamsModel,n.params=this.connList.model.connectionParamsModel,n.services=null,$.post(App.getUrlAction("SaveConnectionParams"),{__RequestVerificationToken:App.GetAntiForgeryToken(),connParams:n},function(n){ErrorHandler.checkErrorsWithInfo(n,t)||t.connList.getConnList(SEARCHTYPE.ACTUAL)})):(n=new SearchForm.StoreParamsModel,n.save(this.connList.model.connectionParamsModel,null),this.connList.getConnList(SEARCHTYPE.ACTUAL))},n.prototype.filterOverServer=function(){var i,n,r,t,u,f;if(this.priceType()!=this.priceTypeAct)return!0;for(i="",this.connList.model.connectionParamsModel.trainTypes&&this.connList.model.connectionParamsModel.trainTypes.length>0&&(i=this.connList.model.connectionParamsModel.trainTypes.join("_")),n="",r=!0,t=0,u=this.trainTypes();t<u.length;t++)f=u[t],f.checked()?n=Support.append(n,f.value(),"_"):r=!1;return r&&(n=""),n!=i},n.prototype.sort=function(){this.connList.hideDetails();this.connList.activeTabBack(this.connList.isBack());switch(Number(this.sortType())){case CONN_FILTER_SORT_TYPE.ARR:this.sortArr();break;case CONN_FILTER_SORT_TYPE.PRICE:this.sortPrice();break;case CONN_FILTER_SORT_TYPE.TIME:this.sortTime();break;case CONN_FILTER_SORT_TYPE.CHANGE:this.sortChange();break;default:this.sortDep()}this.showFilter(!1)},n.prototype.sortDep=function(){var n=this;this.connList.connList.sort(function(t,i){var r=t.trains[0].trainDep(),u=i.trains[0].trainDep();return r.getTime()==u.getTime()?n.compareConnId(t,i):r.getTime()<u.getTime()?-1:1})},n.prototype.sortArr=function(){var n=this;this.connList.connList.sort(function(t,i){var r=t.trains[t.trains.length-1].trainArr(),u=i.trains[i.trains.length-1].trainArr();return r.getTime()==u.getTime()?n.compareConnId(t,i):r.getTime()<u.getTime()?-1:1})},n.prototype.sortPrice=function(){var n=this;this.connList.connList.sort(function(t,i){var r=t.priceInfo,u=i.priceInfo;return!r.model&&!u.model||r.model&&u.model&&r.price()==u.price()?n.compareConnId(t,i):r.price()<u.price()?-1:1})},n.prototype.sortTime=function(){var n=this;this.connList.connList.sort(function(t,i){var r=t.connLength(),u=i.connLength();return r==u?n.compareConnId(t,i):r<u?-1:1})},n.prototype.sortChange=function(){var n=this;this.connList.connList.sort(function(t,i){return t.trainCount()==i.trainCount()?n.compareConnId(t,i):t.trainCount()<i.trainCount()?-1:1})},n.prototype.compareConnId=function(n,t){return n.id==t.id?0:n.id<t.id?-1:1},n.prototype.showParams=function(){this.storeTrainTypes();this.connList.model.connectionParamsModel.trainTypes=this.trainTypesAct;this.connList.connectionParams.showParams()},n}(),ConnectionInfo=function(){function n(n,t,i,r,u){var f=this,e,o;this.trains=Array();this.activeTabBack=ko.observable(!1);this.detailVisible=ko.observable(!1);this.excs=[];this.excsRuleType=Array();this.connectionSelected=ko.observable();this.showBuyLabel=ko.observable();this.selectionInProgress=!1;this.hasHistoryTrain=ko.observable();this.reservationOnlyClick=function(){f.isChangeReservation?f.selectConnection(!0,!1,!1,""+App.getUrlAction("doplnkove-sluzby")+f.connList.model.guid):f.selectConnection(!1,!1,!0,""+App.getUrlAction("doplnkove-sluzby")+f.connList.model.guid)};this.fastBuyClick=function(){if(f.priceInfo.showFastBuy())f.selectConnection(!0,!0,!1,"");else{var n={isErrorAdvancedModel:!0,title:App.messages.connection.fastBuyModalTitle,content:App.messages.connection.fastBuyModalText(f.priceInfo.model.canFastBuy),resetUrl:null,isInfoModal:!0};ErrorHandler.checkErrors(n)}};this.sendMailClick=function(){var n=f.getDataSendMail();$.fn.OGSendMail(n)};this.buyOnlyReservationClick=function(){f.selectConnection(!1,!1,!0,""+App.getUrlAction("doplnkove-sluzby")+f.connList.model.guid)};this.buyOnlyServicesClick=function(){f.selectConnection(!1,!1,!1,""+App.getUrlAction("doplnkove-sluzby")+f.connList.model.guid)};this.facebookShareClick=function(){var n=App.messages.connection.facebookShareConnectionDescription.format(f.trains[0].model.from,f.trains[f.trains.length-1].model.to,f.trains[0].model.depDate+" "+f.trains[0].model.depTime,f.trains[f.trains.length-1].model.arrTime,f.trains[0].model.trainNum),t=f.connList.azakAppBackUrl+"/"+f.connList.eshopContextUrlPart+"/upresneni-cestujicich?data="+f.auxDesc;FB.ui({method:"share_open_graph",action_type:"og.shares",action_properties:JSON.stringify({object:{"og:url":t,"og:title":"E-shop ČD","og:description":n,"og:image":"http://m.cd.cz/spojeni/ogres/img/cd-logo-og.png"}})})};this.connList=t;this.connThere=i;for(e in n.trains)this.trains.push(new ConnectionTrain(n.trains[e],parseInt(e),this));this.handle=n.handle;this.id=n.id;this.distance=n.distance;this.timeLength=n.timeLength;this.change=n.change;this.trainTypes=n.trainTypes;this.changesCount=n.changesCount;this.priceInfo=new ConnectionPriceInfo(n.price,r,u);this.preVozUrl=n.preVozUrl;this.groupUrl=n.groupUrl;this.add2CalParams=n.add2CalParams;this.remarks=n.remarks;this.there=n.there;this.activeTabBack(!this.there&&(t.model.pageType==CONN_PAGE_TYPE.BACK||this.groupsOrDisabled));this.detailVisible(!1);this.auxDesc=n.auxDesc;o=this.trains.some(function(n){return n.historyTrain});this.hasHistoryTrain(o);this.initExcs()}return Object.defineProperty(n.prototype,"groupsOrDisabled",{get:function(){return this.connList.model.formType==SearchForm.SearchFormType.Disabled||this.connList.model.formType==SearchForm.SearchFormType.Groups},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isTravelPass",{get:function(){return this.connList.model.formType==SearchForm.SearchFormType.Travelpass||this.connList.model.formType==SearchForm.SearchFormType.Travelpass_Int},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isCDTip",{get:function(){return this.connList.model.ttCombination==ttCombination.CDTIP},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"groupsOrDisabledUrl",{get:function(){return this.connList.model.formType==SearchForm.SearchFormType.Disabled?this.preVozUrl:this.connList.model.formType==SearchForm.SearchFormType.Groups?this.groupUrl:null},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isChangeReservation",{get:function(){return this.connList.isChangeReservation},enumerable:!0,configurable:!0}),n.prototype.from=function(n){return n.model.from.replace(/(,(?=\S))/g,", ")},n.prototype.to=function(n){return n.model.to.replace(/(,(?=\S))/g,", ")},n.prototype.fromSr70=function(n){return n.model.fromSR70},n.prototype.isFromNAD=function(n){return n.model.isFromNAD},n.prototype.toSr70=function(n){return n.model.toSr70},n.prototype.isToNAD=function(n){return n.model.isToNAD},n.prototype.depDateText=function(n){return n.depDateText()},n.prototype.depDateCss=function(n){return n.depDateCss()},n.prototype.arrDateText=function(n){return n.arrDateText()},n.prototype.arrDateCss=function(n){return n.arrDateCss()},n.prototype.depTime=function(n){return n.model.depTime},n.prototype.arrTime=function(n){return n.model.arrTime},n.prototype.middleStationTrains=function(){return this.trains.length>1?this.trains.slice(1,this.trains.length):[]},n.prototype.hasMiddleStationTrains=function(){return this.trains.length>1},n.prototype.firstTrain=function(){return this.trains[0]},n.prototype.lastTrain=function(){return this.trains[this.trains.length-1]},n.prototype.prevTrain=function(n){return n()>=0?this.trains[n()]:null},n.prototype.isFstTrainOnConn=function(n){return this.trains[0].trainDep(n)<=this.connList.serverDateTime},n.prototype.isTrainOnConnOne=function(){return this.trains.length==1?this.trains[0].trainDep(!0)<=this.connList.serverDateTime:this.trains[0].trainDep(!1)<=this.connList.serverDateTime},n.prototype.isConnectionFinished=function(){return this.trains[this.trains.length-1].trainArr(!0)<this.connList.serverDateTime},n.prototype.delayText=function(t){return n.delayTextCore(t.model.delay)},n.delayTextCore=function(n){return n>-1?n==0?App.messages.connection.inTime:" + "+n+" "+App.messages.connection.min:""},n.prototype.delayCss=function(t){return n.delayCssCore(t.model.delay)},n.delayCssCore=function(n){return n>-1?n==0?"stroke-green":"stroke-orange":"stroke-orange stroke-grey"},n.prototype.trainNameAndDelay=function(n){return n.model.trainTypeAndNum+" "+this.delayText(n)},n.prototype.trainTooltip=function(n){return""+n.model.tooltipTitle+(n.model.delay>0?" - "+App.messages.connection.delayTitle:"")},n.prototype.changeText=function(){return this.change&&this.change!=""?this.changesCount+"x "+App.messages.connection.changeIn+" "+this.change+" "+this.trainTypes:App.messages.connection.withoutChange+" "+this.trainTypes},n.prototype.fromStandFx=function(){return this.trains[0].model.fromStandFx},n.prototype.toStandFx=function(){return this.trains[this.trains.length-1].model.toStandFx},n.prototype.getStandFxCss=function(t){return n.getStandFxCssCore(t)},n.getStandFxCssCore=function(n){return n.indexOf("platform")>-1?"stroke-blue "+n:"stroke dibmtmr "+n},n.prototype.toggleDetail=function(){var n=this.detailVisible();this.connList.hideDetails();n||(this.detailVisible(!0),this.trainOrderInit())},n.prototype.trainOrderInit=function(){this.connList.initTouchTooltip(".traindetail");$("div[og-data-connid="+this.id+"]").OGTrainOrder({sOrderUrl:this.connList.model.orderUrl,sLang:App.locale,sClient:"eShopCD",sTrainDetalUrl:this.connList.model.trainDetailUrl})},n.prototype.trainCount=function(){return this.trains.length},n.prototype.initExcs=function(){var n,t,i;for(n in this.trains)if(this.trains[n].excs){for(t in this.trains[n].excs)this.trains[n].excs[t]&&(this.excs[this.excs.length]=this.trains[n].excs[t]);if(this.trains[n].excsRuleType!=null&&this.trains[n].excsRuleType.length>0){for(i in this.trains[n].excsRuleType)TrainExc.constainEx(this.excsRuleType,this.trains[n].excsRuleType[i].type)||this.excsRuleType.push(this.trains[n].excsRuleType[i]);this.excsRuleType.sort()}}},n.prototype.showExcs=function(){return this.excs&&this.excs.length>0},n.prototype.showExcsModal=function(){var t=[],n,i;for(n in this.trains)if(this.trains[n].excs)for(i in this.trains[n].excs)this.trains[n].excs[i]&&(t[t.length]=this.trains[n].excs[i]);this.connList.excsModal.show(t,!1)},n.prototype.moreExcs=function(){return this.excs&&this.excs.length>1},n.prototype.firstExcsUrl=function(){return this.excs&&this.excs.length>0?this.excs[0].model.url:""},n.prototype.showBasket=function(){return this.connList.model.pageType!=CONN_PAGE_TYPE.THERE_WITH_BACK&&!this.groupsOrDisabled&&this.priceInfo&&!this.priceInfo.showPriceInNextStep()&&!this.priceInfo.cashDeskPrice()&&this.priceInfo.price()>0&&!this.priceInfo.soldOut()},n.prototype.buyBtnCss=function(){return this.connList.model.pageType==CONN_PAGE_TYPE.THERE_WITH_BACK||this.priceInfo.cashDeskPrice()?"buybut blue":"buybut green"},n.prototype.resNotPossible=function(){return!this.priceInfo.canProceed()&&!this.priceInfo.showResOnly()},n.prototype.cantBuyVisible=function(){return!this.selectButtonVisible()&&!this.priceInfo.canProceed()&&!(this.there&&this.connList.isBack())&&!this.isTrainOnConnOne()&&!this.connList.isBikeOrder&&!this.priceInfo.noPrice()||this.eshopCantSell()},n.prototype.eshopCantSell=function(){return this.priceInfo.eshopCantSell()},n.prototype.eshopCantSellText=function(){return Number(this.connList.filter.priceTypeAct)==CONN_FILTER_PRICE_TYPE.UNIPOK||this.priceInfo.cashDeskPrice()?App.messages.connection.eshopCantSellCashDesk:App.messages.connection.eshopCantSell},n.prototype.continueButtonVisible=function(){return this.connList.isBikeOrder&&this.priceInfo.canProceed()||this.isChangeReservation&&this.priceInfo.canProceed()},n.prototype.selectButtonVisible=function(){return this.connList.model.pageType==CONN_PAGE_TYPE.THERE_WITH_BACK&&!this.isTrainOnConnOne()&&this.priceInfo.canProceed()||this.connList.model.pageType==CONN_PAGE_TYPE.THERE_WITH_BACK&&!this.isTrainOnConnOne()&&!this.resNotPossible()||this.groupsOrDisabled&&this.groupsOrDisabledUrl!=null||this.connList.model.ttCombination==ttCombination.CDAUTO?!0:!1},n.prototype.selectButtonClick=function(){if(this.connList.model.ttCombination==ttCombination.CDAUTO)if(this.connList.model.pageType==CONN_PAGE_TYPE.THERE_WITH_BACK)this.saveFilterSettings();else{if(this.selectionInProgress)return;this.selectionInProgress=!0;this.selectConnection(!1,!1,!1,""+App.getUrlAction("specifikace-vozidla")+this.connList.model.guid)}else this.groupsOrDisabled?window.location.href=this.groupsOrDisabledUrl:this.connList.model.pageType==CONN_PAGE_TYPE.THERE_WITH_BACK&&this.saveFilterSettings()},n.prototype.saveFilterSettings=function(){var t=this,n=new ConnectionGetModel;n.guid=this.connList.model.guid;n.priceType=Number(this.connList.filter.priceTypeAct);n.sortType=Number(this.connList.filter.sortTypeAct);AjaxHelper.AjaxWaitShow(App.messages.connection.loaderSearchConnection);$.post(App.getUrlAction("saveFilterSettings"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(n){if(ErrorHandler.checkErrors(n)){AjaxHelper.AjaxWaitHide();return}n==t.connList.model.guid?window.location.href=t.backUrl():AjaxHelper.AjaxWaitHide()})},n.prototype.buyButtonVisible=function(){return!this.selectButtonVisible()&&this.priceInfo.canProceed()&&!this.connList.isBikeOrder&&!(this.connList.model.pageType==CONN_PAGE_TYPE.THERE_WITH_BACK&&this.isTrainOnConnOne())&&!this.isChangeReservation},n.prototype.buyButtonText=function(){return this.buyButtonVisible()?this.priceInfo.canProceed()?this.priceInfo.soldOut()?App.messages.connection.soldOut:this.priceInfo.price()==0?this.priceInfo.showPriceInNextStep()?App.messages.connection.priceInNextStep:(this.showBuyLabel(!0),App.messages.connection.free):this.priceInfo.showPriceInNextStep()?App.messages.connection.priceInNextStep:(this.showBuyLabel(!0),this.priceInfo.formatMoney()):App.messages.connection.cantBuyInEshop:null},n.prototype.buyButtonClick=function(){this.priceInfo.canProceed()&&!this.priceInfo.soldOut()&&this.selectConnection(!0,!1,!1,""+App.getUrlAction("volba-ceny")+this.connList.model.guid)},n.prototype.selectConnection=function(n,t,i,r){var f=this,u=new ConnectionSelectModel;u.guid=this.connList.model.guid;u.pageType=this.connList.model.pageType;u.connID=this.id;u.there=this.there;u.priceSelect=n;u.isFastBuy=t;u.isBuyOnlyReservation=i;u.price=this.priceInfo.price();u.isChangeReservation=this.isChangeReservation;$.post(App.getUrlAction("selectconnection"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:u},function(n){if(ErrorHandler.checkErrors(n)){f.selectionInProgress=!1;return}window.location.href=u.isFastBuy?""+App.getUrlAction("zrychleny-nakup")+f.connList.model.guid:r})},n.prototype.backUrl=function(){return""+App.getUrlAction("spojeni-zpet")+this.connList.model.guid+"/"+this.id},n.prototype.showAddBack=function(){return this.connList.model.pageType==CONN_PAGE_TYPE.THERE&&!this.groupsOrDisabled&&!this.isTravelPass&&!this.isTrainOnConnOne()&&!this.isChangeReservation&&!this.isCDTip&&this.priceInfo.canProceed()||this.connList.model.pageType==CONN_PAGE_TYPE.THERE&&!this.groupsOrDisabled&&!this.isTravelPass&&!this.isTrainOnConnOne()&&!this.isChangeReservation&&!this.isCDTip&&!this.resNotPossible()||this.connList.model.pageType==CONN_PAGE_TYPE.THERE&&this.connList.model.ttCombination==ttCombination.CDAUTO},n.prototype.isTabThereLastTab=function(){return this.connList.model.pageType==CONN_PAGE_TYPE.THERE_WITH_BACK||this.groupsOrDisabled},n.prototype.tabClick=function(n){var t=!1;t=this.activeTabBack()?this.detailVisible():this.connThere.detailVisible();this.connList.hideDetails();this.connList.activeTabBack(!0);this.activeTabBack(n);t&&(this.detailVisible(t),this.trainOrderInit(),this.connThere&&(this.connThere.detailVisible(t),this.connThere.trainOrderInit()))},n.prototype.addBack=function(){this.connList.calendarModal.show(this,!0)},n.prototype.getCalendarParams=function(n){var i,t;n.date=this.firstValidDate();n.isDeparture=!0;n.hour="";n.minute="";i=this.trains[this.trains.length-1].model.arrTime;i&&i!=""&&(t=i.split(":"),t&&t.length==2&&(n.hour=t[0],n.minute=t[1]));n.isReturn=!0},n.prototype.setCalendarParams=function(n){var i=this,t=new ConnectionGetModel;t.guid=this.connList.model.guid;t.priceType=Number(this.connList.filter.priceTypeAct);t.sortType=Number(this.connList.filter.sortTypeAct);$.post(App.getUrlAction("saveFilterSettings"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:t},function(t){var r,u;ErrorHandler.checkErrors(t)||t==i.connList.model.guid&&(AjaxHelper.AjaxWaitShow(App.messages.connection.loaderSearchConnection),r=$(document.createElement("form")),$("body").append(r),$(r).attr("action",i.backUrl()),$(r).attr("method","POST"),u=$("<input>").attr("type","hidden").attr("name","Date").attr("id","Date").val(DateTimeHelper.formatDate(n.date,!1)),$(r).append($(u)),u=$("<input>").attr("type","hidden").attr("name","Time").attr("id","Time").val(n.hour+":"+n.minute),$(r).append($(u)),u=$("<input>").attr("type","hidden").attr("name","IsDeparture").attr("id","IsDeparture").val(""+n.isDeparture),$(r).append($(u)),u=$("<input>").attr("type","hidden").attr("name","__RequestVerificationToken").attr("id","VerifToken").val(""+App.GetAntiForgeryToken()),$(r).append($(u)),$(r).submit())})},n.prototype.firstValidDate=function(){return this.trains[this.trains.length-1].arrDate},n.prototype.lastValidDate=function(){return this.connList.lastValidDate},n.prototype.checkMinDateModal=function(){return!0},n.prototype.connLength=function(){return this.trains[this.trains.length-1].trainArr().getTime()-this.trains[0].trainDep().getTime()},n.prototype.add2CalUrl=function(){return App.getUrlAction("kalendar")+"?"+this.add2CalParams},n.prototype.add2PocketTTUrl=function(){return this.connList.model.pocketTTUrl.format(this.fromSr70(this.firstTrain()).toString().substring(2),this.toSr70(this.lastTrain()).toString().substring(2))},n.prototype.isVisiblePocketTT=function(){return this.fromSr70(this.firstTrain()).toString().substring(0,2)==="54"&&this.toSr70(this.lastTrain()).toString().substring(0,2)==="54"},n.prototype.dateLimitsCal=function(){var n=new DateLimitsCalParams;n.guid=this.connList.model.guid;n.handle=this.handle;n.id=this.id;n.trainIndex=-1;$.fn.OGDateLimitsCal({sUrl:App.getUrlAction("GetDateLimitsCal"),oDateLimitsCalParams:n,sOGLang:App.locale,sTrain:null,sFrom:this.trains[0].model.from,sTo:this.trains[this.trains.length-1].model.to,bFromConn:!0,sValidFrom:this.connList.ttFirstValidDate,sValidTo:this.connList.ttLastValidDate})},n.prototype.pdfClick=function(){var n=this.connList.isBack()?"spojeni-zpet/pdf":"spojeni-tam/pdf",t=""+App.getUrlAction(n)+this.connList.model.guid+"/"+this.id;DownloadFileWithLoader.download("#main",t,App.messages.connection.generatePDF)},n.prototype.getDataSendMail=function(){var n=this.connList.model.dataSendEmail;return n.ogLang=App.locale,n.winTitle=App.messages.connection.sendMailConnTitle,n.ajaxUrl=App.getUrlAction("SendTrainPdfMail"),n.pdfGeneratorParams=new DataPdfGeneratorParams,n.pdfGeneratorParams.guid=this.connList.model.guid,n.pdfGeneratorParams.back=this.connList.isBack(),n.pdfGeneratorParams.listId=this.id.toString(),n},n.prototype.canHaveStatHref=function(n,t){var i=n.toString();return i.length>2&&this.connList.model.stationDetailUrl!==""&&i.substring(0,2)==="54"&&i.substring(0,3)!=="548"&&!t},n.prototype.getStatHref=function(n,t){var i="";return this.canHaveStatHref(n,t)&&(i=this.connList.model.stationDetailUrl.replace("{0}",n.toString())),i},n.prototype.getDatePickerOptions=function(){return null},n.prototype.openFormClick=function(){var t=this.connList.isBack()?"spojeni-zpet/pdf":"spojeni-tam/pdf",n=""+App.getUrlAction(t)+this.connList.model.guid+"/"+this.id;$.ajax({url:App.getUrlAction("getPDFDownloadUrl"),type:"POST",data:{__RequestVerificationToken:App.GetAntiForgeryToken(),url:n},async:!1,success:function(t){if(!ErrorHandler.checkErrors(t)){var r=window.open("about:blank","_blank"),i="<form method='POST' id='kontaktForm' action='"+App.messages.connection.contactFormUrl+"' >\n";i+="<input type='hidden' name='SpojID' value='"+n+"/"+t+"'><\/input>";i+="<\/form>";i+="<script>document.getElementById('kontaktForm').submit();<\/script>";r.document.write("<!doctype html><html><head> <meta charset='utf-8'><\/head><body>"+i+"<\/html><\/body>")}}})},n.prototype.printConnection=function(){this.connList.unselectAllConnections();this.connectionSelected(!0);window.print()},n}(),LegendItem=function(){function n(){}return n}(),ConnectionListLegend=function(){function n(){this.standFx=ko.observableArray();this.trainFx=ko.observableArray();this.excsRuleType=ko.observableArray()}return n.prototype.init=function(n){this.standFx.removeAll();this.trainFx.removeAll();this.excsRuleType.removeAll();for(var t in n())this.initConn(n()[t]),n()[t].connThere!=null&&this.initConn(n()[t].connThere)},n.prototype.initConn=function(n){var i,t;for(i in n.trains)t=n.trains[i],this.initStandFx(t.model),this.initTrainFx(t.model);this.initTrainEx(n)},n.prototype.initStandFx=function(n){var r,i,t;for(r in n.fromStandFx)i=n.fromStandFx[r],i.css==="platform"||this.constain(this.standFx,null,i.css)||(t=new LegendItem,t.css=i.css,t.desc=i.text==null||i.text===""?i.title:i.text,t.desc!==""&&(t.desc1=Support.getFirstWord(t.desc),t.desc2=Support.removeFirstWord(t.desc)),t.imgSrc=null,this.addItem(this.standFx,t))},n.prototype.initTrainFx=function(n){var r,i,t;for(r in n.trainFx)i=n.trainFx[r],this.constain(this.trainFx,null,i.css)||(t=new LegendItem,t.css=i.css,t.desc=i.text==null||i.text===""?i.title:i.text,t.desc!==""&&(t.desc1=Support.getFirstWord(t.desc),t.desc2=t.desc.indexOf(" ")>-1?Support.removeFirstWord(t.desc):""),t.imgSrc=null,this.addItem(this.trainFx,t))},n.prototype.initTrainEx=function(n){if(n.excsRuleType!=null&&n.excsRuleType.length>0){for(var t in n.excsRuleType)TrainExc.constainEx(this.excsRuleType(),n.excsRuleType[t].type)||this.excsRuleType.push(new ExceptionRuleType(n.excsRuleType[t].imgRootUrl,n.excsRuleType[t].type,!0));this.excsRuleType.sort()}},n.prototype.constain=function(n,t,i){for(var r in n())if(n()[r].imgSrc===t&&n()[r].css===i)return!0;return!1},n.prototype.addItem=function(n,t){n.push(t)},n}(),ConnectionPriceInfo=function(){function n(n,t,i){this.model=n;this.HasLoyaltyAccount=t;this.IsLoggedUser=i}return n.prototype.formatMoney=function(){return this.model?this.model.priceFrom?App.messages.connection.priceFrom+" "+Support.formatMoney(this.model.price,!0):Support.formatMoney(this.model.price,!0):null},n.prototype.price=function(){return this.model?this.model.price:0},n.prototype.cashDeskPrice=function(){return this.model?this.model.cashDeskPrice:!1},n.prototype.cashDeskReservation=function(){return this.model?this.model.cashDeskPrice&&!this.model.hasRes&&!this.model.hasBusinessRes&&this.model.canRes:!1},n.prototype.canProceed=function(){return this.model?this.model.canProceed:!1},n.prototype.showLoyaltyPoint=function(){return this.model?this.model.loyaltyPoint>0:!1},n.prototype.loyaltyPoint=function(){return this.model?this.model.loyaltyPoint+this.model.loyaltyBonusPoint+" "+App.messages.connection.points(this.model.loyaltyPoint+this.model.loyaltyBonusPoint):null},n.prototype.showHasRes=function(){return this.model?this.model.hasRes:!1},n.prototype.showHasBusinessRes=function(){return this.model?this.model.hasBusinessRes:!1},n.prototype.showPriceInNextStep=function(){return this.model?this.model.priceInNextStep:!1},n.prototype.showLoyaltyBonusPoint=function(){return this.model?this.model.loyaltyBonusPoint>0:!1},n.prototype.showFreeRes=function(){return this.model?this.model.freeRes:!1},n.prototype.showResOnly=function(){return this.model?!this.model.cashDeskPrice&&this.model.canRes:!1},n.prototype.showAddedServicesOnly=function(){return this.model?!this.model.cashDeskPrice&&this.model.canAddedServices:!1},n.prototype.showFastBuy=function(){return this.model?(this.model.canFastBuy&ShopCart.FAST_BUY_CONDITIONS.NOT_REGISTERED_OR_LOGGED)==0&&(this.model.canFastBuy&ShopCart.FAST_BUY_CONDITIONS.HASNT_FAVOURITE_PASSENGER)==0&&(this.model.canFastBuy&ShopCart.FAST_BUY_CONDITIONS.NOT_ID_OR_IK)==0&&(this.model.canFastBuy&ShopCart.FAST_BUY_CONDITIONS.CD_KREDIT)==0&&(this.model.canFastBuy&ShopCart.FAST_BUY_CONDITIONS.CART_NOT_EMPTY)==0&&(this.model.canFastBuy&ShopCart.FAST_BUY_CONDITIONS.CART_GRATIS)==0&&(this.model.canFastBuy&ShopCart.FAST_BUY_CONDITIONS.PSG_OWN_TICKET)==0&&(this.model.canFastBuy&ShopCart.FAST_BUY_CONDITIONS.CANNOT_USE_CD_KREDIT)==0:!1},n.prototype.fastBuyVisible=function(){return this.model?this.model.showFastBuy:!1},n.prototype.stationInfoLink=function(){return this.model?this.model.stationInfoLink:null},n.prototype.noPrice=function(){return this.model?this.model.noPrice:!1},n.prototype.soldOut=function(){return this.model?this.model.soldOut:!1},n.prototype.eshopCantSell=function(){return this.model?this.model.eshopCantSell:!1},n}(),ConnectionTrain=function(){function n(n,t,i){this.excs=Array();this.excsRuleType=Array();this.model=n;this.depDate=DateTimeHelper.parseDate(n.depDate);this.arrDate=DateTimeHelper.parseDate(n.arrDate);this.trainIndex=t;this.conn=i;this.initExcs(n);this.tooltipTitle=this.model.tooltipTitle;this.vehicleIcon=Support.getVehicleIcon(n.trainTypeID,!0);this.historyTrain=this.model.historyTrain;this.prevTrain=this;t>0&&(this.prevTrain=i.trains[t-1])}return n.prototype.initExcs=function(n){var t,i;if(n.excs&&n.excs.length>0)for(t in n.excs)if(this.excs.push(new TrainExc(n.excs[t],this.model.trainName)),n.excs[t].ruleType!=null&&n.excs[t].ruleType.length>0){for(i in n.excs[t].ruleType)TrainExc.constainEx(this.excsRuleType,n.excs[t].ruleType[i])||this.excsRuleType.push(new ExceptionRuleType(n.excs[t].imgRootUrl,n.excs[t].ruleType[i],!1));this.excsRuleType.sort()}},n.prototype.depDateText=function(){return App.messages.connection.dep+" <br />"+DateTimeHelper.formatDate(this.depDate,!1)},n.prototype.arrDateText=function(){return App.messages.connection.arr+" <br />"+DateTimeHelper.formatDate(this.arrDate,!1)},n.prototype.delayText=function(){return ConnectionInfo.delayTextCore(this.model.delay)},n.prototype.delayCss=function(){return ConnectionInfo.delayCssCore(this.model.delay)},n.prototype.firstTrain=function(){return this.trainIndex==0},n.prototype.lastTrain=function(){return this.conn.trainCount()-1==this.trainIndex},n.prototype.waitTimeText=function(){return this.notGuaranteedTransfer?App.messages.connection.notGuaranteedTransfer:this.model.waitTime>0?Support.formatTimeSubstract(this.model.waitTime,!0)+" "+App.messages.connection.waitInStat+" "+this.conn.trains[this.trainIndex+1].model.from:""},n.prototype.timeDistText=function(){return this.model.linkDist>0?App.messages.connection.linkDist+" "+Support.formatTimeSubstract(this.model.linkDist,!0):this.model.standardChange>0?App.messages.connection.standardChange+" "+Support.formatTimeSubstract(this.model.standardChange,!0):this.model.isShift?App.messages.connection.shift:""},n.prototype.isOnlyLinkDist=function(){return(this.model.linkDist>0||this.model.isShift)&&this.model.standardChange<1},n.prototype.timeDistTitle=function(){return this.model.standardChange>0?App.messages.connection.standardChangeTitle:App.messages.connection.linkDistTitle},n.prototype.timeDistTextMain=function(){return this.model.linkDist>0?App.messages.connection.linkDistMain+" "+Support.formatTimeSubstract(this.model.linkDist,!0):this.model.isShift?App.messages.connection.shift:""},n.prototype.showExcs=function(){return this.excs&&this.excs.length>0},n.prototype.showExcsModal=function(){this.conn.connList.excsModal.show(this.excs,!0)},n.prototype.moreExcs=function(){return this.excs&&this.excs.length>1},n.prototype.firstExcsUrl=function(){return this.excs&&this.excs.length>0?this.excs[0].model.url:""},n.prototype.trainDep=function(n){n===void 0&&(n=!1);var t=DateTimeHelper.getDateTime(this.depDate,this.model.depTime);return n&&this.model.delay>0?moment(t).add(this.model.delay,"minutes").toDate():t},n.prototype.trainArr=function(n){n===void 0&&(n=!1);var t=DateTimeHelper.getDateTime(this.arrDate,this.model.arrTime);return n&&this.model.delay>0?moment(t).add(this.model.delay,"minutes").toDate():t},n.prototype.depDateCss=function(){return this.getDateCss(this.depDate)},n.prototype.arrDateCss=function(){return this.getDateCss(this.arrDate)},n.prototype.getDateCss=function(n){return(this.conn.there&&this.conn.connList.model.pageType!=CONN_PAGE_TYPE.BACK||!this.conn.there&&this.conn.connList.model.pageType==CONN_PAGE_TYPE.BACK)&&!DateTimeHelper.compareDate(n,this.conn.connList.searchDate)?"red":null},n.prototype.dateLimitsCal=function(){var n=new DateLimitsCalParams;n.guid=this.conn.connList.model.guid;n.handle=this.conn.handle;n.id=this.conn.id;n.trainIndex=this.trainIndex;$.fn.OGDateLimitsCal({sUrl:App.getUrlAction("GetDateLimitsCal"),oDateLimitsCalParams:n,sOGLang:App.locale,sTrain:this.model.trainName,sFrom:this.model.from,sTo:this.model.to,bFromConn:!0,sValidFrom:this.conn.connList.ttFirstValidDate,sValidTo:this.conn.connList.ttLastValidDate})},n.prototype.showBonusServicesModal=function(){this.conn.connList.connectionBonusServicesModal.show(this.model)},n.prototype.canHaveStatHref=function(n,t){var i=n.toString();return i.length>2&&this.conn.connList.model.stationDetailUrl!==""&&i.substring(0,2)==="54"&&i.substring(0,3)!=="548"&&!t},n.prototype.getStatHref=function(n,t){var i="";return this.canHaveStatHref(n,t)&&(i=this.conn.connList.model.stationDetailUrl.replace("{0}",n.toString())),i},n.prototype.getStandFxCss=function(n){return ConnectionInfo.getStandFxCssCore(n)},Object.defineProperty(n.prototype,"notGuaranteedTransfer",{get:function(){return this.model.waitTime<this.model.standardChange},enumerable:!0,configurable:!0}),n}(),FixedCodeModel=function(){function n(){}return n}(),ConnectionGetModel=function(){function n(){}return n}(),ConnectionSelectModel=function(){function n(){}return n}(),MyTicketType;(function(n){n[n.Ticket=1]="Ticket";n[n.Reservation=2]="Reservation";n[n.TicketAndReservation=3]="TicketAndReservation";n[n.AutoTrain=4]="AutoTrain";n[n.LuggageAndBike=5]="LuggageAndBike";n[n.Dog=6]="Dog";n[n.Packages=7]="Packages";n[n.Parking=8]="Parking";n[n.Sms=9]="Sms";n[n.Catering=10]="Catering"})(MyTicketType||(MyTicketType={}));var MyTicket=function(){function n(n){this.passengers=[];this.connThere=null;this.connBack=null;this.tickets=ko.observableArray();this.validTickets=ko.observableArray();this.ticketSums=ko.observableArray();this.validTicketSums=ko.observableArray();this.passengers=n.passengers;n.connThere&&(this.connThere=new MyTicketConn(n.connThere));n.connBack&&(this.connBack=new MyTicketConn(n.connBack));this.tickets(!n.tickets||n.tickets.length==0?[]:n.tickets);this.validTickets(!n.tickets||n.tickets.length==0?[]:n.tickets);this.ticketSums(!n.ticketSums||n.ticketSums.length==0?[]:n.ticketSums);this.validTicketSums(!n.ticketSums||n.ticketSums.length==0?[]:n.ticketSums);this.sortTickets();this.sortTicketSums()}return n.prototype.withoutDiscountCard=function(){return App.messages.connection.withoutDiscountCard},n.prototype.wholeTicketSumsPrice=function(){if(this.validTicketSums()&&this.validTicketSums().length!=0){var n=0;return this.validTicketSums().forEach(function(t){return n+=t.price}),Support.formatMoney(n,!0)}return""},n.prototype.addTicket=function(n){this.tickets.push(n);this.sortTickets();this.hasPackages()?this.validTickets(this.tickets().filter(function(n){return n.type!=MyTicketType.Ticket&&n.type!=MyTicketType.TicketAndReservation})):this.validTickets(this.tickets())},n.prototype.removeTicket=function(n){this.tickets.remove(n);this.validTickets.remove(n);this.hasPackages()?this.validTickets(this.tickets().filter(function(n){return n.type!=MyTicketType.Ticket&&n.type!=MyTicketType.TicketAndReservation})):this.validTickets(this.tickets())},n.prototype.updateTicket=function(n,t){this.tickets.replace(n,t);this.hasPackages()?this.validTickets(this.tickets().filter(function(n){return n.type!=MyTicketType.Ticket&&n.type!=MyTicketType.TicketAndReservation})):this.validTickets(this.tickets())},n.prototype.addTicketSumPrice=function(n){this.ticketSums.push(n);this.sortTicketSums();this.hasPackages()?this.validTicketSums(this.ticketSums().filter(function(n){return n.type!=MyTicketType.Ticket&&n.type!=MyTicketType.TicketAndReservation})):this.validTicketSums(this.ticketSums())},n.prototype.updateTicketSumPrice=function(n,t){this.ticketSums.replace(n,t);this.sortTicketSums();this.hasPackages()?this.validTicketSums(this.ticketSums().filter(function(n){return n.type!=MyTicketType.Ticket&&n.type!=MyTicketType.TicketAndReservation})):this.validTicketSums(this.ticketSums())},n.prototype.removeTicketSumPrice=function(n){this.ticketSums.remove(n);this.validTicketSums.remove(n);this.hasPackages()?this.validTicketSums(this.ticketSums().filter(function(n){return n.type!=MyTicketType.Ticket&&n.type!=MyTicketType.TicketAndReservation})):this.validTicketSums(this.ticketSums())},n.prototype.sortTickets=function(){this.tickets.sort(function(n,t){return n.type==t.type?0:n.type<t.type?-1:1})},n.prototype.sortTicketSums=function(){this.ticketSums.sort(function(n,t){return n.type==t.type?0:n.type<t.type?-1:1})},n.prototype.hasPackages=function(){return this.ticketSums().filter(function(n){return n.type==MyTicketType.Packages}).length>0},n}(),MyTicketConn=function(){function n(n){this.trains=[];this.searched=n.searched;for(var t in n.trains)this.trains.push(new MyTicketTrain(n.trains[t]))}return n}(),MyTicketTrain=function(){function n(n){this.openSchema=function(n){if(!Support.stringIsEmpty(n)){var t=700,i=960,r=(window.screen.width-(i+60))/2,u=(window.screen.height-(t+80))/2,f="/eshop/schema-vlaku/?sui="+n,e=window.open(f,"Schema","height="+t+", width="+i+", left="+r+", top="+u+", location=no, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes",!0);e.focus()}};this.from=n.from;this.to=n.to;this.depDate=DateTimeHelper.parseDate(n.depDate);this.depTime=n.depTime;this.minSubtract=n.minSubtract;this.train=n.train;this.coachAndPlace=n.coachAndPlace;this.vehicleIcon=Support.getVehicleIcon(n.trainTypeID,!1);this.isDeparture=n.isDeparture}return n.prototype.dep=function(){return this.isDeparture?App.messages.connection.depShortCut+" "+DateTimeHelper.formatDate(this.depDate,!1)+" / "+this.depTime:App.messages.connection.arrShortCut+" "+DateTimeHelper.formatDate(this.depDate,!1)+" / "+this.depTime},n.prototype.timeLength=function(){return Support.formatTimeSubstract(this.minSubtract,!1)},n.prototype.coachAndPlaceLength=function(){return this.coachAndPlace.length>0},n}(),MyFavourites;(function(n){var o=function(){function n(n,i){this.favouriteConnections=null;this.connectionsByTicket=null;n&&(n.favouriteConnections&&(this.favouriteConnections=new t(n.favouriteConnections,i)),n.connectionsByTicket&&(this.connectionsByTicket=new r(n.connectionsByTicket,i)))}return n.prototype.hasFavouriteConnections=function(){return this.favouriteConnections!=null&&this.favouriteConnections.relations!=null&&this.favouriteConnections.relations.length>0},n.prototype.hasConnectionsByTicket=function(){return this.connectionsByTicket!=null&&this.connectionsByTicket.connections!=null&&this.connectionsByTicket.connections.length>0},n}(),t,i,e,r,u,f;n.MyConnections=o;t=function(){function n(n,t){var r=this;n.rel&&(this.relations=[],n.rel.forEach(function(n){r.relations.push(new i(n,t))}))}return n}();n.RelationsInfo=t;i=function(){function n(n,t){var i=this;this.search=function(){i.searchForm.searchFavourite(i.model)};this.model=n;this.searchForm=t}return n.prototype.changesToString=function(){var u=App.messages.connection.changeTitle,t="",i=[],n,r,f;for(this.hasChanges()?i=this.model.change:this.hasVias()&&(i=this.model.via,u=App.messages.connection.viaTitle),n=0,r=i;n<r.length;n++)f=r[n],t=Support.append(t,f.name,", ");return u+" "+t},n.prototype.hasChanges=function(){return this.model.change!=null&&this.model.change.length>0},n.prototype.hasVias=function(){return this.model.via!=null&&this.model.via.length>0},n}();n.RelationInfo=i;e=function(){function n(n,t){var i=this;this.showRelation=ko.observable();this.deleteFavConn=function(){$.post(App.getUrlAction("oblibene-spojeni-odebrani/"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:i.getAjaxModel(i.model)},function(n){ErrorHandler.checkErrors(n)||(n?alert("Nezdařilo se odebrání oblíbeného spojení, zkuste, prosím, provést odebrání později."):(i.favConnsModal.enableAddFavourite(!0),i.favConnsModal.removeItemFromModel(i.model),i.favConnsModal.paging(i.favConnsModal.actualPageNumber)))})};this.model=n;this.favConnsModal=t;this.showRelation(this.model.fav)}return n.prototype.getAjaxModel=function(n){return{oFrom:this.getAjaxObjectInfoModel(n.from),oTo:this.getAjaxObjectInfoModel(n.to),aoVia:this.getAjaxObjectInfoArrayModel(n.via),aoChange:this.getAjaxObjectInfoArrayModel(n.change),iMaxChange:n.maxChange,iMaxTime:n.maxTime,iMinTime:n.minTime,iUseBeds:n.useBeds,iDeltaPMax:n.deltaPMax,aiFcSearchId:n.fcSearchId,aiTrTypeId:n.trTypeId,bFav:n.fav}},n.prototype.getAjaxObjectInfoModel=function(n){return{sName:n.name,bFav:n.fav,sSpec:n.spec,sDesc:n.desc,iListId:n.listId}},n.prototype.getAjaxObjectInfoArrayModel=function(n){var r=[],t,i,u;if(n)for(t=0,i=n;t<i.length;t++)u=i[t],r.push(this.getAjaxObjectInfoModel(u));return r},n}();n.RelationInfoForModal=e;r=function(){function n(n,t){var i=this;n.conns&&(this.connections=[],n.conns.forEach(function(n){i.connections.push(new u(n,t))}))}return n}();n.ConnectionsInfo=r;u=function(){function n(n,t){var i=this;this.search=function(){i.searchConnByTicket(i.model)};this.trains=[];n.trains.forEach(function(n){i.trains.push(new f(n))});this.searchForm=t;this.model=n;this.fillConnectionInfo()}return n.prototype.fillConnectionInfo=function(){var t=this.model.trains.length,n;if(this.connectionModel={fromTime:this.model.trains[0].fromTime,from:{name:this.model.trains[0].fromName,key:this.model.trains[0].fromKey},to:{name:this.model.trains[this.model.trains.length-1].toName,key:this.model.trains[this.model.trains.length-1].toKey}},t>1)for(this.connectionModel.changes=[],n=0;n<t-1;n++)this.connectionModel.changes.push({name:this.model.trains[n].toName,key:this.model.trains[n].toKey})},n.prototype.changesToString=function(){for(var t="",r,n=0,i=this.connectionModel.changes;n<i.length;n++)r=i[n],t=Support.append(t,r.name,", ");return App.messages.connection.changeTitle+" "+t},n.prototype.hasChanges=function(){return this.connectionModel.changes!=null&&this.connectionModel.changes.length>0},n.prototype.getDateTimeFrom=function(){return DateTimeHelper.formatDateBase(this.trains[0].date)+" "+DateTimeHelper.formatTime(this.trains[0].model.fromTime)},n.prototype.searchConnByTicket=function(n){var t=this;AjaxHelper.AjaxWaitShow(App.messages.connection.loaderSearchConnection);$.post(App.getUrlAction("spojeni-podle-jizdenky/"),this.getAjaxModel(n),function(n){if(ErrorHandler.checkErrorsWithInfo(n,t)){AjaxHelper.AjaxWaitHide();return}window.location.href=App.getUrlAction("spojeni-tam")+n})},n.prototype.getAjaxModel=function(n){return{aoPassengers:this.getAjaxPassengerInfoArrayModel(n.passengers),aoTrains:this.getAjaxTrainInfoArrayModel(n.trains),iClass:n.class}},n.prototype.getAjaxPassengerInfoModel=function(n){return{iCount:n.count,iAge:n.age,aiReductionID:n.reductionId,iTypeID:n.typeId}},n.prototype.getAjaxTrainInfoModel=function(n){return{sName:n.name,sDate:n.date,sType:n.type,sNumber:n.number,iFromKey:n.fromKey,sFromName:n.fromName,iFromTime:n.fromTime,sToName:n.toName,iToTime:n.toTime,iToKey:n.toKey,bFav:n.fav}},n.prototype.getAjaxPassengerInfoArrayModel=function(n){var r=[],t,i,u;if(n)for(t=0,i=n;t<i.length;t++)u=i[t],r.push(this.getAjaxPassengerInfoModel(u));return r},n.prototype.getAjaxTrainInfoArrayModel=function(n){var r=[],t,i,u;if(n)for(t=0,i=n;t<i.length;t++)u=i[t],r.push(this.getAjaxTrainInfoModel(u));return r},n}();n.TrainsInfo=u;f=function(){function n(n){this.date=DateTimeHelper.parseDate(n.date);this.model=n}return n}();n.TrainInfo=f})(MyFavourites||(MyFavourites={}));var SelectOfferModel=function(){function n(){}return n}(),PriceSelection=function(){function n(n,t){var i=this,r;this.priceTypes=ko.observableArray();this.selectedPriceType=ko.observable();this.simpleList=ko.observable();this.selectTimeout=null;this.selectTimeoutShow=2e3;this.setWait=function(){i.selectTimeout&&clearTimeout(i.selectTimeout);i.selectTimeout=setTimeout(function(){AjaxHelper.AjaxWaitShow(App.messages.ticketRefund.loaderProcessing)},i.selectTimeoutShow)};this.clearWait=function(){i.selectTimeout&&clearTimeout(i.selectTimeout);AjaxHelper.AjaxWaitHide()};this.selectAndContinue=function(n){var t=new SelectOfferModel;t.guid=i.guid;t.index=n;i.setWait();$.post(App.getUrlAction("selectoffer"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:t},function(n){if(ErrorHandler.checkErrors(n)){i.clearWait();return}window.location.href=App.getUrlAction("doplnkove-sluzby")+i.guid})};this.selectAndGoIn=function(n,t){var r=new SelectOfferModel;r.guid=t+"|"+i.guid;r.index=-2e3;i.setWait();$.post(App.getUrlAction("selectoffer"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:r},function(t){if(ErrorHandler.checkErrors(t)){i.clearWait();return}window.location.href=App.getEshopUrlAction("in-karta")+n})};this.selectAndGo=function(n,t){var r=new SelectOfferModel;r.guid=t;r.index=-1e3;i.setWait();$.post(App.getUrlAction("selectoffer"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:r},function(t){if(ErrorHandler.checkErrors(t)){i.clearWait();return}window.location.href=App.getEshopUrlAction("in-karta")+n})};this.selectAndGoOrderGroup=function(n){window.location.href=n};this.myTicket=new MyTicket(t);this.guid=n.guid;this.model=n;for(r in n.priceTypes)this.priceTypes().push(n.priceTypes[r]);this.selectedPriceType(n.selectedPriceType);this.simpleList(n.simpleList);this.bonusServices4FirstClass=n.bonusServices4FirstClass;this.priceSelectionBonusServicesModal=new PriceSelectionBonusServiceModal;this.documentConditionsModal=new UserIdentity.DocumentConditionsModal;n.errors&&ErrorHandler.checkErrorsWithInfo(n.errors,this);ko.applyBindings(this,document.getElementById("main"));ko.applyBindings(this.priceSelectionBonusServicesModal,document.getElementById("priceSelectionBonusServicesModal"));ko.applyBindings(this.documentConditionsModal,document.getElementById("documentConditionsModal"));$("#main .cd-select").refreshNiceSelect();this.selectedPriceType.subscribe(function(){i.priceTypeChange(n.guid)})}return n.prototype.priceTypeChange=function(n){var t=this,i={guid:n,selectedPriceType:this.selectedPriceType()};$.post(App.getUrlAction("pricetypechange"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:i},function(n){ErrorHandler.checkErrors(n)||($(".ticket-offers-nav").html(n),ko.cleanNode(document.getElementById("content_left")),ko.applyBindings(t,document.getElementById("content_left")))})},n.prototype.showBonusServicesModal=function(n,t){this.priceSelectionBonusServicesModal.Show(this.bonusServices4FirstClass,n,t)},n.prototype.showSimpleList=function(n){this.simpleList(n)},n.prototype.documentConditionsOpen=function(n){var i=JSON.parse(n),t={};t.list=i;$("#documentConditionsModal").modal("show");this.documentConditionsModal.show(t)},n}(),PriceSelectionBonusServiceModal=function(){function n(){var n=this;this.bonusServices=ko.observableArray();this.section=ko.observable();this.selectedBonusServices=ko.observableArray();this.activeTrain=ko.observable();this.price=ko.observable();this.loyaltyPoint=ko.observable();this.selectTrain=function(t){for(var i in n.bonusServices())n.bonusServices()[i].train===t&&(n.activeTrain(t),n.section(n.bonusServices()[i].section),n.selectedBonusServices.removeAll(),n.bonusServices()[i].services.forEach(function(t){n.selectedBonusServices.push(new BonusServiceInfo(t))}))}}return n.prototype.Show=function(n,t,i){this.price(t);this.loyaltyPoint(i);this.bonusServices(n);n!=null&&this.selectTrain(this.bonusServices()[0].train)},n}(),ShopCart;(function(n){var t=function(){function n(n,t){var i=this;this.code=ko.observable("");this.description=ko.observable("");this.priceChange=ko.observable(0);this.value=ko.observable(0);this.isEdit=ko.observable(!1);this.error=ko.observable(new ErrorInfo(""));this.update=function(n){i.code(n.code);i.description(n.description);i.priceChange(n.priceChange);i.value(n.value);i.isEdit(!1);i.error().message("")};this.checkCode=function(){if(i.checkErrors()){i.isEdit(!1);var n=App.getUrlAction("CheckDiscountCode");$.post(n,{__RequestVerificationToken:App.GetAntiForgeryToken(),code:i.code()},function(n){if(!ErrorHandler.checkErrors(n))if(n.discountCodeError)i.isEdit(!0),i.error().message(n.discountCodeError);else{var t=n;i.parent.parent.setModel(t,!1)}})}};this.parent=n;this.isEdit(t==null);this.isEdit()||this.update(t);this.setValidation();this.errors=ko.validation.group(this)}return n.prototype.setValidation=function(){var n=this;this.code.extend({canValidate:!1,required:{onlyIf:function(){return n.code.canValidate()},message:App.messages.shopCart.errorDiscountCode},validation:{onlyIf:function(){return n.code.canValidate()},validator:function(t){return n.error().message(""),ValidationHelper.isDiscountCode(t)},message:App.messages.shopCart.errorDiscountCode}})},n.prototype.checkErrors=function(){return(this.code.canValidate(!0),this.errors().length>0)?(this.errors.showAllMessages(),!1):!0},n}(),i;n.DiscountItem=t;i=function(){function n(n,i){var r=this;this.canAddItem=ko.observable(!0);this.canRemove=ko.observable(!1);this.totalDiscount=ko.observable("");this.items=ko.observableArray();this.voucherAdded=ko.observable("");this.addItem=function(){r.items.push(new t(r,null))};this.update=function(n){r.items().forEach(function(t){if(!t.isEdit()){var i=n.items.filter(function(n){return n.code==t.code()});i.length==0?r.items.remove(t):t.update(i[0])}});r.updateModelBase(n)};this.updateModelBase=function(n){var u,t,i;r.canAddItem(n.canAddItem);u=r.items().filter(function(n){return n.isEdit()}).length;r.canRemove(u==r.items().length);t=0;r.items().forEach(function(n){return t+=n.priceChange()});r.totalDiscount(t==0?"":Support.formatMoney(-1*t,!0));i=0;r.items().forEach(function(n){return i+=n.value()});r.voucherAdded(i-t<=0?"":App.messages.shopCart.voucherAdded+Support.formatMoney(i-t,!0))};this.remove=function(){r.items.removeAll();r.parent.companyDiscounts().showDiscountBox(!1)};this.parent=n;i.items.forEach(function(n){r.items.push(new t(r,n))});this.updateModelBase(i)}return n}();n.Discounts=i})(ShopCart||(ShopCart={})),function(n){var t=function(){function n(n,t){var i=this;this.selectedDiscount=ko.observable("");this.companyDiscounts=ko.observableArray();this.showDiscountBox=ko.observable(!1);this.error=ko.observable(new ErrorInfo(""));this.updatePrice=function(){if(!i.firstShow){var n=App.getUrlAction("ApplyCompanyDiscount");i.selectedDiscount()!=undefined&&i.selectedDiscount()!=App.messages.shopCart.withoutDiscount&&(i.firstShow=!0,$.post(n,{__RequestVerificationToken:App.GetAntiForgeryToken(),discount:i.selectedDiscount()},function(n){if(!ErrorHandler.checkErrors(n))if(n.withoutDiscount==!0)i.error().message("");else if(n.discountError)i.error().message(n.discountError),i.companyDiscounts().length>1&&i.selectedDiscount(App.messages.shopCart.withoutDiscount);else{var t=n;i.parent.setModel(t,!1)}$(".cd-select").refreshNiceSelect();i.firstShow=!1}))}};this.model=t;this.firstShow=!0;this.parent=n;this.model.showDiscountBox&&n.discounts().canAddItem()&&n.discounts().addItem();this.showDiscountBox(t.showDiscountBox);this.selectedDiscount(t.selectedDiscount);t.discounts!=undefined&&t.discounts.forEach(function(n){i.companyDiscounts.push(n)});$(".cd-select").refreshNiceSelect();this.firstShow=!1}return n}();n.CompanyDiscounts=t}(ShopCart||(ShopCart={})),function(n){var t=function(){function t(n,t){var i=this;this.totalPrice=ko.observable("");this.loyaltyPoints=ko.observable("");this.isPaymentAllowed=ko.observable();this.caPaymentAllowed=ko.observable();this.caActivated=ko.observable();this.caBlocked=ko.observable();this.paymentMethod=ko.observable("");this.paymentAgreement1_Anonymous=ko.observable();this.paymentAgreement2_Anonymous=ko.observable();this.paymentAgreement0=ko.observable();this.paymentAgreement1=ko.observable();this.paymentAgreement1Visible=ko.observable();this.paymentAgreement4=ko.observable();this.paymentAgreement4Visible=ko.observable();this.paymentAgreement5=ko.observable();this.paymentAgreement5Visible=ko.observable();this.pin1=ko.observable("").extend({inputPattern:/[^0-9]+/g});this.pin2=ko.observable("").extend({inputPattern:/[^0-9]+/g});this.pin3=ko.observable("").extend({inputPattern:/[^0-9]+/g});this.pin4=ko.observable("").extend({inputPattern:/[^0-9]+/g});this.pin=ko.computed(function(){return i.pin1()+i.pin2()+i.pin3()+i.pin4()},this);this.pinFocus=ko.observable("1");this.isAnonymousUser=ko.observable();this.loggedUserWithoutLoyalty=ko.observable();this.email=ko.observable("");this.showEmailInfo=ko.observable(!1);this.paymentStarted=ko.observable(!1);this.amexVisible=ko.observable();this.googlePayVisible=ko.observable();this.error=ko.observable(new ErrorInfo(""));this.commonError=ko.observable("");this.corporateNSEnabled=ko.observable();this.corporateNSList=ko.observableArray();this.corporateNS=ko.observable();this.lastCorporateNS="-";this.NSError=ko.observable(new ErrorInfo("nsList"));this.corporateEdit=ko.observable();this.pay=function(){i.checkNS().done(function(){if(i.checkErrors()){i.paymentStarted(!0);i.updateModel(i.model);var n=App.getUrlAction("kosik");$.post(n,{__RequestVerificationToken:App.GetAntiForgeryToken(),paymentModel:i.model},function(n){if(ErrorHandler.checkErrors(n)){i.paymentStarted(!1);return}n.paymentRedirectUrl?window.location.href=n.paymentRedirectUrl:(i.paymentStarted(!1),i.parent.setModel(n))})}})};this.getCurrentModel=function(){return{paymentMethod:parseInt(i.paymentMethod()),pin:i.pin(),email:i.email(),corporateNS:i.corporateNS()}};this.selectNS=function(n){i.NSError().message("");$.post(App.getUrlAction("FindCorporateNS"),{__RequestVerificationToken:App.GetAntiForgeryToken(),prefix:""},function(n){if(!ErrorHandler.checkErrors(n)){i.corporateNSList.removeAll();var t=n;t.forEach(function(n){return i.corporateNSList.push(n)})}});i.lastCorporateNS=n;i.corporateNS(n)};this.corporateNSChange=function(n){(n===void 0&&(n=!0),i.corporateNSEnabled())&&i.lastCorporateNS!=i.corporateNS()&&(i.lastCorporateNS=i.corporateNS(),$.post(App.getUrlAction("FindCorporateNS"),{__RequestVerificationToken:App.GetAntiForgeryToken(),prefix:i.corporateNS()},function(t){if(!ErrorHandler.checkErrors(t)){i.corporateNSList.removeAll();var r=t;r.forEach(function(n){return i.corporateNSList.push(n)});n&&!Support.parseBool($("#nsList").attr("aria-expanded"))&&$("#nsList").dropdown("toggle")}}))};this.checkNS=function(){var n=$.Deferred(),t=i.corporateNS();return!i.corporateNSEnabled()||Support.stringIsEmpty(t)?(i.NSError().message(""),n.resolve()):$.post(App.getUrlAction("FindCorporateNS"),{__RequestVerificationToken:App.GetAntiForgeryToken(),prefix:t},function(r){if(!ErrorHandler.checkErrors(r)){var u=r;u=u.filter(function(n){return n.toLowerCase()==t.toLowerCase()});u.length==0?i.NSError().message(App.messages.validation.errorNSNotExists):u.length>1&&i.NSError().message(App.messages.validation.errorNSAmbiguous);n.resolve()}}),n};this.loginUser=function(){window.location.href="/profil-uzivatele/auth/login"};this.registerUser=function(){window.location.href="/profil-uzivatele/registrace/"};this.activateAccount=function(){};this.parent=n;this.model=t;this.totalPrice(Support.formatMoney(t.totalPrice,!0));this.loyaltyPoints(Support.formatLoyaltyPoints(t.loyaltyPoints));this.isPaymentAllowed(t.isPaymentAllowed);this.caPaymentAllowed(t.caPaymentAllowed);this.caActivated(t.caActivated);this.caBlocked(t.caBlocked);this.paymentMethod(t.paymentMethod.toString());this.amexVisible(t.amexVisible);this.googlePayVisible(t.googlePayVisible);this.setValidation();this.errors=ko.validation.group(this);this.paymentAgreement1Visible(t.paymentAgreement1Visible);this.paymentAgreement4Visible(t.paymentAgreement4Visible);this.paymentAgreement5Visible(t.paymentAgreement5Visible);this.model.agreements==undefined&&(this.model.agreements=[]);t.pinError&&(this.pin.setError(t.pinError),this.pin.isModified(!0),this.paymentAgreement1_Anonymous(!0),this.paymentAgreement1_Anonymous(!0),this.paymentAgreement0(!1),this.paymentAgreement1(!1),this.paymentAgreement4(!1),this.paymentAgreement5(!1));t.paymentError&&this.error().message(t.paymentError);this.pin1.subscribe(function(n){i.pinFocus(n.length==1?"2":"1")});this.pin2.subscribe(function(n){i.pinFocus(n.length==1?"3":"2")});this.pin3.subscribe(function(n){i.pinFocus(n.length==1?"4":"3")});this.isAnonymousUser(t.isAnonymousUser);this.loggedUserWithoutLoyalty(t.loggedUserWithoutLoyalty);this.email(t.email||"");this.email.subscribe(function(n){if(i.email.canValidate()&&i.email.isValid()){var t=n||i.email();$.ajax({url:App.getUrlAction("CheckEmailDomain")+"?email="+t,type:"GET",success:function(n){i.showEmailInfo(!n.result)}})}});this.corporateNSEnabled(t.corporateNSEnabled);this.corporateNSChange(!1);Support.stringIsEmpty(this.model.corporateNS)||this.corporateNS(this.model.corporateNS);this.corporateNS.subscribe(function(){i.NSError().message("");clearTimeout(i.corporateNSHandle);i.corporateNSHandle=setTimeout(function(){i.corporateNSChange()},200)});this.corporateEdit(new SearchForm.CorporateEdit(t.corporateEdit,null,null,null,n));this.commonError(this.model.commonError);this.model.commonError=""}return t.prototype.setValidation=function(){var t=this;this.pin.extend({canValidate:!1,validation:{onlyIf:function(){return t.pin.canValidate()&&parseInt(t.paymentMethod())==n.PaymentMethod.CA},validator:function(n){return n.length==4&&ValidationHelper.checkRange(n,0,9999,!1)},message:App.messages.shopCart.errorPIN}});this.paymentAgreement1_Anonymous.extend({canValidate:!1,equal:{onlyIf:function(){return t.paymentAgreement1_Anonymous.canValidate()&&parseInt(t.paymentMethod())!=n.PaymentMethod.MOTO&&t.isAnonymousUser()},params:!0,message:App.messages.shopCart.paymentAgreement1_Anonymous}});this.paymentAgreement2_Anonymous.extend({canValidate:!1,equal:{onlyIf:function(){return t.paymentAgreement2_Anonymous.canValidate()&&parseInt(t.paymentMethod())!=n.PaymentMethod.MOTO&&t.isAnonymousUser()},params:!0,message:App.messages.shopCart.paymentAgreement2_Anonymous}});this.paymentAgreement0.extend({canValidate:!1,equal:{onlyIf:function(){return t.paymentAgreement0.canValidate()&&parseInt(t.paymentMethod())!=n.PaymentMethod.MOTO&&!t.isAnonymousUser()},params:!0,message:App.messages.shopCart.paymentAgreement0}});this.paymentAgreement5.extend({canValidate:!1,equal:{onlyIf:function(){return t.paymentAgreement5Visible()&&parseInt(t.paymentMethod())!=n.PaymentMethod.MOTO&&!t.isAnonymousUser()},params:!0,message:App.messages.shopCart.paymentAgreement5}});this.email.extend({canValidate:!1,required:{onlyIf:function(){return t.email.canValidate()&&t.isAnonymousUser()},message:App.messages.validation.requiredItem},validation:{onlyIf:function(){return t.email.canValidate()&&t.isAnonymousUser()},validator:function(n){return ValidationHelper.isEmail(n)},message:App.messages.validation.errorEmail}})},t.prototype.checkErrors=function(){return(this.pin.canValidate(!0),this.isAnonymousUser()?(this.paymentAgreement1_Anonymous.canValidate(!0),this.paymentAgreement2_Anonymous.canValidate(!0)):(this.paymentAgreement0.canValidate(!0),this.paymentAgreement5.canValidate(!0)),this.email.canValidate(!0),this.parent.companyDiscounts()!=null&&this.parent.companyDiscounts().model.isUsed&&this.corporateEdit().enabled()&&this.corporateEdit().sap()<1)?(this.error().message(App.messages.connection.corporateCompanySAPAcceptError),!1):this.errors().length>0?(this.errors.showAllMessages(),!1):this.parent.items().filter(function(n){return n.error().isVisible()}).length>0?!1:this.NSError().isVisible()?!1:!0},t.prototype.updateModel=function(t){var i,r,u,f;t.paymentMethod=parseInt(this.paymentMethod());t.pin=this.pin();t.email=this.email();t.paymentError="";t.pinError="";t.corporateNS=this.corporateNS();!this.isAnonymousUser()&&t.agreements!=undefined&&t.agreements.length>0&&t.paymentMethod!=n.PaymentMethod.MOTO&&(i=t.agreements.filter(function(n){return n.agreementTypeID==0}),i.length>0&&(i[0].agree=this.paymentAgreement0()),this.paymentAgreement4Visible&&(r=t.agreements.filter(function(n){return n.agreementTypeID==4}),r.length>0&&(r[0].agree=this.paymentAgreement4())),this.paymentAgreement5Visible&&(u=t.agreements.filter(function(n){return n.agreementTypeID==5}),u.length>0&&(u[0].agree=this.paymentAgreement5())),this.paymentAgreement1Visible&&(f=t.agreements.filter(function(n){return n.agreementTypeID==1}),f.length>0&&(f[0].agree=this.paymentAgreement1())))},t.updateNewModel=function(t,i){(t.isAnonymousUser&&Support.stringIsEmpty(t.email)&&(t.email=i.email),t.corporateNS=i.corporateNS,t.paymentMethod!=n.PaymentMethod.MOTO&&t.paymentMethod!=n.PaymentMethod.NOPAYMENT)&&(i.paymentMethod==n.PaymentMethod.CA&&t.caPaymentAllowed&&(t.paymentMethod=n.PaymentMethod.CA,t.pin=i.pin),i.paymentMethod!=n.PaymentMethod.CA&&(t.paymentMethod=i.paymentMethod))},t}();n.PaymentInfo=t}(ShopCart||(ShopCart={})),function(n){var t=function(){function n(n,t,i){i===void 0&&(i=!1);this.goHome=function(){window.location.href=App.getUrlAction("")};this.goExternalUrl=function(n){window.open(n,"_blank")};this.isLoggedUser=i;this.videoId=n;this.isLoggedUser?this.videoSetting=t:this.loadVideoSetting();ko.applyBindings(this,document.getElementById("main"))}return n.prototype.confirmVideoPlayed=function(){var n=this;return!this.videoSetting||!this.videoSetting.confirmVideoPlayed?!1:this.videoSetting.confirmVideoPlayed.some(function(t){return t==n.videoId})},n.prototype.setConfirmVideoPlayed=function(){var n=this;if(this.videoSetting&&this.videoSetting.confirmVideoPlayed){if(this.videoSetting.confirmVideoPlayed.some(function(t){return t==n.videoId}))return;this.videoSetting.confirmVideoPlayed.push(this.videoId)}else this.videoSetting={confirmVideoPlayed:[this.videoId]};this.isLoggedUser?$.post(App.getUrlAction("SaveVideoSetting"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:this.videoSetting},function(t){ErrorHandler.checkErrorsWithInfo(t,n)}):this.saveVideoSetting()},Object.defineProperty(n.prototype,"getVideoSettingLocalStorageKey",{get:function(){return"videoSettingData"},enumerable:!0,configurable:!0}),n.prototype.loadVideoSetting=function(){var n=localStorage.getItem(this.getVideoSettingLocalStorageKey);if(n==null||n.length==0)return!1;this.videoSetting=JSON.parse(n)},n.prototype.saveVideoSetting=function(){localStorage.setItem(this.getVideoSettingLocalStorageKey,JSON.stringify(this.videoSetting))},n}();n.ShopCartConfirmation=t}(ShopCart||(ShopCart={})),function(n){var t,u,f,e,i,r;(function(n){n[n.ticket=1]="ticket";n[n.inKarta=2]="inKarta";n[n.voucher=3]="voucher";n[n.netticket=4]="netticket";n[n.rechargeEP=5]="rechargeEP";n[n.prolongation=6]="prolongation";n[n.rechargeCA=7]="rechargeCA";n[n.parking=8]="parking";n[n.reclamation=9]="reclamation"})(t=n.ShopCartItemType||(n.ShopCartItemType={})),function(n){n[n.PAYMUZO=0]="PAYMUZO";n[n.MOTO=1]="MOTO";n[n.PAYSEC=2]="PAYSEC";n[n.MASTERPASS=3]="MASTERPASS";n[n.CA=4]="CA";n[n.CSOBAPI=5]="CSOBAPI";n[n.MASTERPASSCSOB=7]="MASTERPASSCSOB";n[n.AMEX=8]="AMEX";n[n.NOPAYMENT=99]="NOPAYMENT"}(u=n.PaymentMethod||(n.PaymentMethod={})),function(n){n[n.booked=2]="booked";n[n.bookedExpired=9]="bookedExpired"}(f=n.ShopCartItemStatus||(n.ShopCartItemStatus={})),function(n){n[n.NOT_REGISTERED_OR_LOGGED=1]="NOT_REGISTERED_OR_LOGGED";n[n.HASNT_FAVOURITE_PASSENGER=2]="HASNT_FAVOURITE_PASSENGER";n[n.NOT_ID_OR_IK=4]="NOT_ID_OR_IK";n[n.CD_KREDIT=8]="CD_KREDIT";n[n.CART_NOT_EMPTY=16]="CART_NOT_EMPTY";n[n.PSG_OWN_TICKET=32]="PSG_OWN_TICKET";n[n.CANNOT_USE_CD_KREDIT=64]="CANNOT_USE_CD_KREDIT";n[n.CART_GRATIS=128]="CART_GRATIS"}(e=n.FAST_BUY_CONDITIONS||(n.FAST_BUY_CONDITIONS={}));i=function(){function n(n,i){var r=this;this.canDelete=ko.observable(!0);this.totalPrice=ko.observable();this.loyaltyPoints=ko.observable();this.error=ko.observable(new ErrorInfo(""));this.deleteItem=function(){$.ajax({url:App.getUrlAction("DeleteShopCartItem"),type:"POST",headers:App.GetAntiForgeryTokenHeader(),data:JSON.stringify({id:r.model.id}),dataType:"json",contentType:"application/json; charset=utf-8",success:function(n){ErrorHandler.checkErrors(n)||(window.location.href=App.getUrlAction("kosik"))}})};this.templateName=function(){switch(r.model.type){case t.ticket:return"shopCart-ticket";case t.inKarta:return"shopCart-inKarta";case t.voucher:return"shopCart-voucher";case t.netticket:return"shopCart-netticket";case t.rechargeEP:return"shopCart-rechargeEP";case t.prolongation:return"shopCart-prolongation";case t.rechargeCA:return"shopCart-rechargeCA";case t.parking:return"shopCart-parking";case t.reclamation:return"shopCart-reclamation"}};this.documentConditionsOpen=function(){var n=r.getDocumentConditionsData();$.post(App.getUrlAction("GetDocumentConditionsCart"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(n){ErrorHandler.checkErrorsWithInfo(n,r)||($("#documentConditionsModal").modal("show"),r.parent.documentConditionsModal.show(n))})};this.parent=n;this.model=i;this.totalPrice(Support.formatMoney(i.totalPrice,!0));this.loyaltyPoints(Support.formatLoyaltyPoints(i.loyaltyPoints));this.canDelete(i.canDelete);this.error().message(i.error||"")}return n.prototype.getDocumentConditionsData=function(){var n={};return n.guid="",n.cartItemID=this.model.id,n},n}();n.ShopCartItem=i;r=function(){function t(n){var t=this;this.isEmpty=ko.observable();this.canDelete=ko.observable(!0);this.items=ko.observableArray();this.discounts=ko.observable();this.loyalty=ko.observable();this.companyDiscounts=ko.observable();this.payment=ko.observable();this.deleteCart=function(){$.ajax({url:App.getUrlAction("DeleteShopCart"),type:"POST",headers:App.GetAntiForgeryTokenHeader(),dataType:"json",contentType:"application/json; charset=utf-8",success:function(n){if(!ErrorHandler.checkErrors(n)){var i=n;i.isEmpty?window.location.href=App.getUrlAction("kosik"):t.setModel(i)}}})};this.nextBuy=function(){window.location.href=App.getUrlAction("")};this.applyLoyalty=function(){$.ajax({url:App.getUrlAction("ApplyLoyaltyPoints"),type:"POST",headers:App.GetAntiForgeryTokenHeader(),dataType:"json",contentType:"application/json; charset=utf-8",success:function(n){if(!ErrorHandler.checkErrors(n)){var i=n;n.loyaltyCodeError?ErrorHandler.showAdvancedError("",n.loyaltyCodeError):t.setModel(i,!1)}}})};this.openSchema=function(n){if(!Support.stringIsEmpty(n)){var t=700,i=960,r=(window.screen.width-(i+60))/2,u=(window.screen.height-(t+80))/2,f="/eshop/schema-vlaku/?sui="+n,e=window.open(f,"Schema","height="+t+", width="+i+", left="+r+", top="+u+", location=no, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes",!0);e.focus()}};this.corporateEditModal=new SearchForm.CorporateEditModal;this.setModel(n,!1,!0);this.documentConditionsModal=new UserIdentity.DocumentConditionsModal;ko.applyBindings(this.documentConditionsModal,document.getElementById("documentConditionsModal"));ko.applyBindings(this.corporateEditModal,document.getElementById("corporateEditModal"));ko.applyBindings(this,document.getElementById("main"));$("#main .cd-select").refreshNiceSelect()}return t.prototype.setModel=function(t,r,u){var f=this,e;r===void 0&&(r=!0);u===void 0&&(u=!1);t.items||(t.items=[]);this.isEmpty(t.isEmpty);this.items.removeAll();t.items.forEach(function(n){f.items.push(new i(f,n))});this.canDelete(this.items().filter(function(n){return n.canDelete()}).length>0);this.discounts(new n.Discounts(this,t.discounts));this.companyDiscounts(new n.CompanyDiscounts(this,t.companyDiscounts));this.loyalty(t.loyaltyPoints);this.loyalty().isUsed&&($("#useLoyaltyPoints").prop("checked",!0),$("#useLoyaltyPoints").prop("disabled",!0));Support.stringIsEmpty(this.loyalty().points)||(this.loyalty().points=this.loyalty().isUsed?this.loyalty().points:this.loyalty().points+" "+App.messages.app.loyaltyPoints);(this.loyalty().isUsed||this.loyalty().showBox)&&t.discounts.items.length<1&&this.discounts().addItem();u?this.payment(new n.PaymentInfo(this,t.payment)):(e=this.payment().getCurrentModel(),n.PaymentInfo.updateNewModel(t.payment,e),this.payment(new n.PaymentInfo(this,t.payment)));t.paymentError&&ErrorHandler.showAdvancedError("",t.paymentError);r&&ErrorHandler.focusFirstError()},t}();n.ShopCart=r}(ShopCart||(ShopCart={}));var DOBPicker=function(){function n(n){this.dobIdSufix=ko.observable();this.day=ko.observable("");this.month=ko.observable("");this.year=ko.observable("");this.error=ko.observable();this.doesntChange=!0;this.dateBeforeInit=null;this.isInitialized=!1;this.canValidate=!1;this.canSubmitDOB=!1;this.enabled=!0;this.model=n;this.dobIdSufix(n.dobIdSufix);this.setSubsribe();this.setValidation();this.error(new ErrorInfo("item_"+this.model.dobIdSufix))}return n.prototype.initDatepicker=function(){var n=this,t=DateTimeHelper.formatDateBase(this.model.dobFirstValidDate()),i=DateTimeHelper.formatDateBase(this.model.dobLastValidDate()),r={language:App.locale,orientation:"bottom left",autoclose:!0,format:"dd.mm.yyyy",startDate:t,endDate:i,todayHighlight:!0,startView:2,defaultViewDate:{year:1980}};$(".dobpicker #dob_date_"+this.model.dobIdSufix).datepicker("remove").datepicker(r).on("changeDate",function(t){n.setDOBFromDate(t.date);n.model.setDOBDate(t.date)});this.isInitialized=!0},n.prototype.setSubsribe=function(){var n=this;this.year.subscribe(function(t){n.setDOB(t,n.month(),n.day())});this.month.subscribe(function(t){n.setDOB(n.year(),t,n.day())});this.day.subscribe(function(t){n.setDOB(n.year(),n.month(),t)})},n.prototype.setDOB=function(n,t,i,r){if(r===void 0&&(r=!1),typeof n!="undefined"&&typeof t!="undefined"&&typeof i!="undefined"){if(n!==""&&String(n).length===4&&t!==""&&i!==""){var u=moment(i+"."+t+"."+n,["DD.MM.YYYY","D.M.YYYY"]);if(u.isValid()){this.canValidate=!0;r&&(this.year(n),this.month(t),this.day(i),$(".dobpicker #dob_month_"+this.model.dobIdSufix).refreshNiceSelect());$(".dobpicker #dob_date_"+this.model.dobIdSufix).datepicker("update",u.toDate());this.model.setDOBDate(u.toDate());this.error().message("");return}this.canValidate=!1}else this.canValidate=!1;this.canSubmitDOB&&(this.model.setDOBDate(null),this.error().message(App.messages.validation.errorBirthdate))}},n.prototype.setInitialDOB=function(n,t,i){this.doesntChange=!1;this.setDOB(n,t,i,!0);this.doesntChange=!0},n.prototype.setDOBFromDate=function(n){if(!this.isInitialized){this.dateBeforeInit=n;return}this.setInitialDOB(String(n.getFullYear()),String(n.getMonth()+1),String(n.getDate()))},n.prototype.setValidation=function(){var n=this;this.year.extend({canValidate:!1,required:{onlyIf:function(){return n.model.setExtraValidation()&&n.canValidate&&n.year.canValidate()},message:function(){return n.error().message(App.messages.validation.errorBirthdate),App.messages.validation.requiredItem}}});this.day.extend({canValidate:!1,required:{onlyIf:function(){return n.model.setExtraValidation()&&n.canValidate&&n.day.canValidate()},message:function(){return n.error().message(App.messages.validation.errorBirthdate),App.messages.validation.requiredItem}}})},n.prototype.openCalendar=function(){$(".dobpicker #dob_date_"+this.model.dobIdSufix).datepicker("show")},n.prototype.initComponents=function(){this.initDatepicker();this.error().message("");this.dateBeforeInit!=null?this.setDOBFromDate(this.dateBeforeInit):$(".dobpicker #dob_month_"+this.model.dobIdSufix).refreshNiceSelect()},n.prototype.canSubmit=function(){return this.canSubmitDOB=!0,this.setDOB(this.year(),this.month(),this.day()),this.canSubmitDOB=!1,this.error().message()===""},n}(),DOBPickerDefaultParams=function(){function n(){this.dobIdSufix="dob";this.dobErrTop=!1;this.disabled=!1;this.dobFirstValidDate=new Date(1900,0,1);this.dobLastValidDate=new Date}return n.prototype.setDOBDate=function(){},n.prototype.validate=function(){return""},n}(),DOBPicker2=function(){function n(n){var t=this;this.dobIdSufix=ko.observable();this.day=ko.observable("");this.month=ko.observable("");this.year=ko.observable("");this.disabled=ko.observable(!1);this.canValidate=!1;this.error=ko.observable();this.isSetDate=!1;this.dateBeforeInit=null;this.isInitialized=!1;this.validate=function(){var n,i;if(t.day.canValidate()&&t.year.canValidate()&&!Support.stringIsEmpty(t.month())&&(t.canValidate=!0),t.canValidate){if(n=t.getDate(),n==null){t.error().message(App.messages.validation.errorBirthdate);return}if(n<t.model.dobFirstValidDate||n>t.model.dobLastValidDate){t.error().message(App.messages.validation.errorBirthdate);return}if(i=t.model.validate(n),!Support.stringIsEmpty(i)){t.error().message(i);return}t.error().message("")}};this.setDate=function(n){if(!t.isInitialized){t.dateBeforeInit=n;return}$(".dobpicker #dob_date_"+t.model.dobIdSufix).datepicker("update",n);t.isSetDate=!0;t.day(n.getDate().toString());t.month((n.getMonth()+1).toString());t.year(n.getFullYear().toString());$(".dobpicker #dob_month_"+t.model.dobIdSufix).refreshNiceSelect();t.isSetDate=!1;t.canValidate=!0;t.validate()};this.getDate=function(){if(Support.stringIsEmpty(t.day())||Support.stringIsEmpty(t.month())||Support.stringIsEmpty(t.year())||!ValidationHelper.checkRange(t.day(),1,31)||!ValidationHelper.checkRange(t.year(),1e3,9999))return null;var n=moment(t.day()+"."+t.month()+"."+t.year(),["DD.MM.YYYY","D.M.YYYY"]);return n.isValid()?n.toDate():null};this.isValid=function(){return t.getDate()!=null&&!t.error().isVisible()};this.model=new DOBPickerDefaultParams;this.model=$.extend(this.model,n);this.dobIdSufix(this.model.dobIdSufix);this.disabled(this.model.disabled);this.setSubscribe();this.setValidation();this.errors=ko.validation.group(this);this.error(new ErrorInfo("item_"+this.model.dobIdSufix))}return n.prototype.initDatepicker=function(){var n=this,t=DateTimeHelper.formatDateBase(this.model.dobFirstValidDate),i=DateTimeHelper.formatDateBase(this.model.dobLastValidDate),r={language:App.locale,orientation:"bottom auto",autoclose:!0,format:"dd.mm.yyyy",startDate:t,endDate:i,todayHighlight:!0,startView:2,defaultViewDate:{year:1980}};$(".dobpicker #dob_date_"+this.model.dobIdSufix).datepicker("remove").datepicker(r).on("changeDate",function(t){n.setDate(t.date);n.model.setDOBDate(t.date)})},n.prototype.setSubscribe=function(){var n=this;this.year.subscribe(function(){n.textInputChange()});this.month.subscribe(function(){n.textInputChange()});this.day.subscribe(function(){n.textInputChange()})},n.prototype.textInputChange=function(){if(!this.isSetDate){var n=this.getDate();n!=null&&$(".dobpicker #dob_date_"+this.model.dobIdSufix).datepicker("update",n);this.validate();this.model.setDOBDate(n)}},n.prototype.setValidation=function(){var n=this;this.day.extend({canValidate:!1,validation:{onlyIf:function(){return n.day.canValidate()},validator:function(n){return ValidationHelper.checkRange(n,1,31,!0)},message:function(){return n.error().message(App.messages.validation.errorBirthdate),App.messages.validation.requiredItem}}});this.year.extend({canValidate:!1,validation:{onlyIf:function(){return n.year.canValidate()},validator:function(n){return ValidationHelper.checkRange(n,1e3,9999,!0)},message:function(){return n.error().message(App.messages.validation.errorBirthdate),App.messages.validation.requiredItem}}})},n.prototype.openCalendar=function(){$(".dobpicker #dob_date_"+this.model.dobIdSufix).datepicker("show")},n.prototype.init=function(){this.initDatepicker();this.isInitialized=!0;this.dateBeforeInit!=null?this.setDate(this.dateBeforeInit):$(".dobpicker #dob_month_"+this.model.dobIdSufix).refreshNiceSelect()},n.prototype.checkErrors=function(){return(this.day.canValidate(!0),this.year.canValidate(!0),this.errors().length>0)?(this.errors.showAllMessages(),!1):(this.validate(),this.isValid())},n}(),FromToCalendar=function(){function n(n){var t=this;this.validFrom=ko.observable();this.validTo=ko.observable();this.validFromDay=ko.observable("");this.validFromText=ko.pureComputed(function(){return t.validFrom()?DateTimeHelper.formatDate(t.validFrom(),!0):""},this);this.validToText=ko.pureComputed(function(){return t.validTo()?DateTimeHelper.formatDate(t.validTo(),!0):""},this);this.enabledDates=[];this.id=ko.observable("");this.isInitialized=!1;this.setEnabledDates=function(n){t.enabledDates=n};this.beforeShowDay=function(n){return t.enabledDates.length==0?!0:t.enabledDates.filter(function(t){return t.from<=n&&n<=t.to}).length>0};this.setValidFrom=function(n){t.validFrom(n);t.resolveDay()};this.setValidTo=function(n){t.validTo(n)};this.id(Support.randomString(20));this.validFromDay.subscribe(function(n){t.checkDayChange(n)});this.setValidFromCallback=n}return n.prototype.init=function(){var n=this,t={language:App.locale,orientation:"bottom left",autoclose:!0,format:"dd.mm.yyyy",todayHighlight:!0,beforeShowDay:this.beforeShowDay};$("#"+this.id()).datepicker("remove").datepicker(t).on("changeDate",function(t){n.setValidFromCallback(t.date)})},n.prototype.openCalendar=function(){this.isInitialized||(this.isInitialized=!0,this.init());$("#"+this.id()).datepicker("update",this.validFrom());$("#"+this.id()).datepicker("show")},n.prototype.checkDayChange=function(){var n=this.validFrom();DateTimeHelper.isToday(n)||this.validFromDay()!="today"||this.setValidFromCallback(DateTimeHelper.today());DateTimeHelper.isTomorrow(n)||this.validFromDay()!="tomorrow"||this.setValidFromCallback(DateTimeHelper.tomorrow())},n.prototype.resolveDay=function(){var n=this.validFrom();DateTimeHelper.isToday(n)?this.validFromDay("today"):DateTimeHelper.isTomorrow(n)?this.validFromDay("tomorrow"):this.validFromDay("")},n}(),AddServices;(function(n){var t=function(){function t(t,i,r,u){var f=this;this.priceResult=n.ReservationPriceResult.noReservation;this.error=function(){var n="";return f.reservationPrice.error&&(n=f.reservationPrice.error),f.bikePrice&&f.bikePrice.error&&(n.length>0&&(n+=" "),n+=f.bikePrice.error),n};this.setInvalidPrice=function(){f.reservationPrice={price:0,error:"",serviceDogDisabled:!1,placeInfo:null,serviceBikeLuggageDisabled:!1};f.priceResult=n.ReservationPriceResult.invalid;f.showPrice()};this.computePrice=function(t,i,r,u){clearTimeout(f.priceTimer);f.reservationPrice={price:0,error:"",serviceDogDisabled:!1,placeInfo:null,serviceBikeLuggageDisabled:!1};f.bikePrice=null;var e=f.mainForm.serviceLuggageAndBike().getTrainForReservation(t.id);f.canComputePrice(e,t)&&(u?(f.priceResult=n.ReservationPriceResult.computing,f.priceTimer=setTimeout(function(){f.computePriceStart(e,t,i,r)},n.ReservationTrain.priceComputationDelay),f.showPrice()):f.computePriceStart(e,t,i,r))};this.computePriceStart=function(t,i,r,u){App.log(LogSection.addServices,{name:"trainReservationPrice_"+i.id,bike:t,reservation:i});f.priceResult=n.ReservationPriceResult.computingStart;clearTimeout(f.priceTimer);f.showPrice();var e={guid:r,packages:u,reservation:i,bike:t};$.ajax({url:App.getUrlAction("ServiceReservationComputePrice"),type:"POST",headers:App.GetAntiForgeryTokenHeader(),data:JSON.stringify(e),dataType:"json",contentType:"application/json; charset=utf-8",success:function(t){var u,r;App.log(LogSection.addServices,{name:"trainReservationPrice_"+i.id,result:t});u=!1;ErrorHandler.checkErrorsWithInfo(t,f)||(r=t,f.bikePrice=r.bike,f.reservationPrice=r.reservation,r.bike.error=r.bike.error||"",r.reservation.error=r.reservation.error||"",u=!(r.bike.error||r.reservation.error));f.priceResult==n.ReservationPriceResult.computingStart&&(f.priceResult=u?n.ReservationPriceResult.computed:n.ReservationPriceResult.invalid);f.done(u);f.showPrice()}})};this.mainForm=t;this.showPrice=i;this.done=r;this.reservationPrice={price:0,error:"",serviceDogDisabled:!1,placeInfo:null,serviceBikeLuggageDisabled:!1};u.reservationTypeID!=n.ReservationType.none&&(this.reservationPrice.price=u.price,this.priceResult=n.ReservationPriceResult.computed)}return t.prototype.canComputePrice=function(t,i){var u=t.bikeReservationID,r=i.reservationTypeID;return u==n.BikeReservation.noReservation&&(r==n.ReservationType.none||r==n.ReservationType.disabled)?(this.priceResult=n.ReservationPriceResult.noReservation,this.done(!0),this.showPrice(),!1):!0},t}();n.ReservationPriceComputation=t})(AddServices||(AddServices={})),function(n){var i=function(){function t(t,i,r,u){var f=this;this.priceId=ko.observable("");this.from=ko.observable("");this.to=ko.observable("");this.train=ko.observable("");this.passengersCountVisible=ko.observable();this.passengersCount=ko.observable();this.supplement1T=ko.observable(!1);this.reservationTypes=ko.observableArray();this.reservationTypeID=ko.observable();this.hasSchema=ko.observable();this.coachNumberSelected=ko.observable("");this.seatNumbersSelected=ko.observable("");this.coachNumberDesignated=ko.observable("").extend({inputPattern:/[^0-9]+/g});this.seatNumbersDesignated=ko.observable("").extend({inputPattern:/[^0-9, ]+/g});this.coachNumberAdjactent=ko.observable("").extend({inputPattern:/[^0-9]+/g});this.seatNumberAdjactent=ko.observable("").extend({inputPattern:/[^0-9]+/g});this.berthInfo=ko.observable("");this.couchetteInfo=ko.observable("");this.placeInfoList=ko.observableArray();this.serviceDogDisabled=!1;this.isThere=ko.observable(!0);this.error=ko.observable();this.setDefaultReservationTypeID=function(){parseInt(f.reservationTypeID())==n.ReservationType.none&&f.reservationTypeID(f.model.reservationTypeIDs[0].toString())};this.passengersCountChange=function(){f.passengersCountChangeButton(0)};this.passengersCountChangeButton=function(n){var t=f.setPassengersCount(n);t&&(f.resetBerthInfo(),f.resetCouchetteInfo(),f.startComputePrice())};this.setPassengersCount=function(n){var t=parseInt(f.passengersCount());return(isNaN(t)&&(t=1),t=Support.checkValueInInterval(t+n,f.model.minPassengersCount,f.model.maxPassengersCount),f.passengersCount(t.toString()),t.toString()==f.passengersCountLast)?!1:(f.passengersCountLast=f.passengersCount(),!0)};this.openSchema=function(){var n=700,t=960,i=(window.screen.width-(t+60))/2,r=(window.screen.height-(n+80))/2,u="/eshop/schema-vlaku/?sui="+f.model.schemaLink+"&numItems="+f.passengersCount(),e=window.open(u,"Schema","height="+n+", width="+t+", left="+i+", top="+r+", location=no, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes",!0);e.focus()};this.setPlace=function(t,i){f.seatNumbersSelected.canValidate(!0);f.coachNumberSelected(""+t);f.seatNumbersSelected(""+i);f.reservationTypeID(n.ReservationType.seatSelected.toString());f.startComputePrice();$("#addServiceReservationModal .cd-select").refreshNiceSelect()};this.reservationTypeChange=function(){var t=parseInt(f.reservationTypeID());t==n.ReservationType.seatSelected&&f.coachNumberSelected().length==0?f.openSchema():(t==n.ReservationType.none?(f.error().message(""),f.setPlaceInfo(null)):t==n.ReservationType.berth||t==n.ReservationType.berthdeluxe?(f.setBerthToReturnTrains(f.modelCopy,t==n.ReservationType.berthdeluxe,f.isThere()),f.setBerthInfo(f.modelCopy)):t==n.ReservationType.couchette&&f.setCouchetteInfo(f.modelCopy),f.startComputePrice())};this.setBerthInfo=function(t){var i="",o=parseInt(f.reservationTypeID()),u=t.berthTogetherOnly,e=" / ",r;u&&(e="");t.berthFemaleCount>0&&(u||(i+=t.berthFemaleCount+"x "+App.messages.addServices.female),t.berthCompartments&&o==n.ReservationType.berth&&!Support.stringIsEmpty(t.berthCompartmentID)&&t.berthCompartments.forEach(function(n){n.value==t.berthCompartmentID&&(i+=e+n.name+" "+App.messages.addServices.compartment)}),t.berthDeluxeCompartments&&o==n.ReservationType.berthdeluxe&&!Support.stringIsEmpty(t.berthDeluxeCompartmentID)&&t.berthDeluxeCompartments.forEach(function(n){n.value==t.berthDeluxeCompartmentID&&(i+=e+n.name+" "+App.messages.addServices.compartment)}),r=n.ReservationPositionsModal.getPositionsInfo(t.berthFemalePositions),r.length>0&&!u&&(i+=" ("+r+")"),i+="<br />");t.berthMaleCount>0&&(u||(i+=t.berthMaleCount+"x "+App.messages.addServices.male),t.berthCompartments&&o==n.ReservationType.berth&&!Support.stringIsEmpty(t.berthCompartmentID)&&t.berthCompartments.forEach(function(n){n.value==t.berthCompartmentID&&(i+=e+n.name+" "+App.messages.addServices.compartment)}),t.berthDeluxeCompartments&&o==n.ReservationType.berthdeluxe&&!Support.stringIsEmpty(t.berthDeluxeCompartmentID)&&t.berthDeluxeCompartments.forEach(function(n){n.value==t.berthDeluxeCompartmentID&&(i+=e+n.name+" "+App.messages.addServices.compartment)}),r=n.ReservationPositionsModal.getPositionsInfo(t.berthMalePositions),r.length>0&&!u&&(i+=" ("+r+")"),i+="<br />");f.berthInfo(i)};this.resetBerthInfo=function(){f.modelCopy.berthFemaleCount=0;f.modelCopy.berthFemalePositions=null;f.modelCopy.berthMaleCount=parseInt(f.passengersCount());f.modelCopy.berthMalePositions=null;f.setBerthInfo(f.modelCopy)};this.setCouchetteInfo=function(t){var i="",r;t.couchetteCompartments&&!Support.stringIsEmpty(t.couchetteCompartmentID)&&t.couchetteCompartments.forEach(function(n){n.value==t.couchetteCompartmentID&&(i+=n.name+" "+App.messages.addServices.compartment)});r=n.ReservationPositionsModal.getPositionsInfo(t.couchettePositions);r.length>0&&(i+=" ("+r+")");f.couchetteInfo(i)};this.resetCouchetteInfo=function(){f.modelCopy.couchettePositions=null;f.setCouchetteInfo(f.modelCopy)};this.showSeatModal=function(){f.parent.seatModal.show(f)};this.showCouchetteModal=function(){f.parent.couchetteModal.show(f)};this.showBerthModal=function(){f.parent.berthModal.show(f)};this.startComputePrice=function(){if(f.parent.doneClicked=!1,f.parent.error().message(""),!f.canComputePrice()){f.price.setInvalidPrice();return}var n=f.serialize(!0),t=f.parent.parent.parent.model.guid,i=f.parent.parent.parent.servicePackages().enabled();f.price.computePrice(n,t,i,!0)};this.computePrice=function(){if(!f.canComputePrice()){f.price.setInvalidPrice();return}var n=f.serialize(!0),t=f.parent.parent.parent.model.guid,i=f.parent.parent.parent.servicePackages().enabled();f.price.computePrice(n,t,i,!1)};this.computePriceDone=function(n){f.error().message(f.price.error());n&&(f.serviceDogDisabled=f.price.reservationPrice.serviceDogDisabled,f.setPlaceInfo(f.price.reservationPrice.placeInfo));f.parent.doneClicked&&f.parent.done()};this.setBerthToReturnTrains=function(t,i,r){var h,c,e,s,o,u;if(r)for(s=void 0,s=i?f.parent.trainsBack().filter(function(t){return parseInt(t.reservationTypeID())==n.ReservationType.berthdeluxe}):f.parent.trainsBack().filter(function(t){return parseInt(t.reservationTypeID())==n.ReservationType.berth}),h=0,c=s;h<c.length;h++)e=c[h],e.train()!=f.train()&&(i?e.modelCopy.berthDeluxeCompartmentID=t.berthDeluxeCompartmentID:e.modelCopy.berthCompartmentID=t.berthCompartmentID,e.modelCopy.berthMaleCount=t.berthMaleCount,e.modelCopy.berthFemaleCount=t.berthFemaleCount,e.modelCopy.berthTogether=t.berthTogether,e.modelCopy.berthMalePositions=t.berthMalePositions,e.modelCopy.berthFemalePositions=t.berthFemalePositions,e.setBerthInfo(t),e.startComputePrice());else s=void 0,i?(o=f.parent.trainsThere().filter(function(t){return parseInt(t.reservationTypeID())==n.ReservationType.berthdeluxe&&t.modelCopy.berthReturn}),o.length>0&&(u=o[0].modelCopy,t.berthDeluxeCompartmentID=u.berthDeluxeCompartmentID,t.berthMaleCount=u.berthMaleCount,t.berthFemaleCount=u.berthFemaleCount,t.berthTogether=u.berthTogether,t.berthMalePositions=u.berthMalePositions,t.berthFemalePositions=u.berthFemalePositions,f.setBerthInfo(t),f.startComputePrice())):(o=f.parent.trainsThere().filter(function(t){return parseInt(t.reservationTypeID())==n.ReservationType.berth&&t.modelCopy.berthReturn}),o.length>0&&(u=o[0].modelCopy,t.berthCompartmentID=u.berthCompartmentID,t.berthMaleCount=u.berthMaleCount,t.berthFemaleCount=u.berthFemaleCount,t.berthTogether=u.berthTogether,t.berthMalePositions=u.berthMalePositions,t.berthFemalePositions=u.berthFemalePositions,f.setBerthInfo(t),f.startComputePrice()))};this.setCouchetteToReturnTrains=function(t){for(var e=f.parent.trainsBack().filter(function(t){return t.modelCopy.reservationTypeIDs.lastIndexOf(n.ReservationType.couchette)>-1}),i,r=0,u=e;r<u.length;r++)i=u[r],i.train()!=f.train()&&(i.modelCopy.couchetteCompartmentID=t.couchetteCompartmentID,i.modelCopy.couchettePositions=t.couchettePositions,i.setCouchetteInfo(t),i.startComputePrice())};this.parent=r;this.model=t;this.modelCopy=$.extend({},t);this.priceId(t.priceId);this.id=t.id;this.from(t.from);this.to(t.to);this.train(t.train);this.error(new ErrorInfo("ServiceReservationTrain"+t.id));t.reservationError&&this.error().message(t.reservationError);this.passengersCount(t.passengersCount.toString());this.passengersCountLast=this.passengersCount();t.supplement1TEnabled&&this.supplement1T(t.supplement1T);this.price=new n.ReservationPriceComputation(this.parent.parent.parent,this.parent.showPrice,this.computePriceDone,t);this.serviceDogDisabled=this.model.serviceDogDisabled;this.hasSchema(t.hasSchema);this.vehicleIcon=Support.getVehicleIcon(t.trainTypeID,!0);this.reservationTypeID(t.reservationTypeID.toString());t.coachNumberSelected>0&&(this.coachNumberSelected(t.coachNumberSelected.toString()),this.seatNumbersSelected(t.seatNumbersSelected.map(function(n){return n.toString()}).join(", ")));t.coachNumberDesignated>0&&(this.coachNumberDesignated(t.coachNumberDesignated.toString()),this.seatNumbersDesignated(t.seatNumbersDesignated.map(function(n){return n.toString()}).join(", ")));t.coachNumberAdjactent>0&&(this.coachNumberAdjactent(t.coachNumberAdjactent.toString()),this.seatNumberAdjactent(t.seatNumberAdjactent.toString()));this.setBerthInfo(t);this.setCouchetteInfo(t);t.reservationTypeIDs.forEach(function(n){var t=i.filter(function(t){return parseInt(t.value)==n})[0];f.reservationTypes().push(t)});this.isThere(u);this.setValidation();this.errors=ko.validation.group(this)}return t.prototype.incDecPassengersCount=function(n,t){t.which===38?this.setPassengersCount(1):t.which===40&&this.setPassengersCount(-1)},t.prototype.setValidation=function(){var t=this;this.seatNumbersSelected.extend({canValidate:!1,validation:[{onlyIf:function(){return parseInt(t.reservationTypeID())==n.ReservationType.seatSelected&&t.seatNumbersSelected.canValidate()},validator:function(n){return ValidationHelper.checkRangeNumbers(n,1,999,!0)},message:App.messages.addServices.errorSeatNumber},{onlyIf:function(){return t.parent&&parseInt(t.reservationTypeID())==n.ReservationType.seatSelected&&t.seatNumbersSelected.canValidate()},validator:function(n){return n.split(",").length==parseInt(t.passengersCount())},message:App.messages.addServices.errorSeatPersonNumber}]});this.coachNumberDesignated.extend({canValidate:!1,validation:{onlyIf:function(){return parseInt(t.reservationTypeID())==n.ReservationType.seatDesignated&&t.coachNumberDesignated.canValidate()},validator:function(n){return ValidationHelper.checkRange(n,1,999,!0)},message:App.messages.addServices.errorCoachNumber}});this.seatNumbersDesignated.extend({canValidate:!1,validation:[{onlyIf:function(){return parseInt(t.reservationTypeID())==n.ReservationType.seatDesignated&&t.seatNumbersDesignated.canValidate()},validator:function(n){return ValidationHelper.checkRangeNumbers(n,1,999,!0)},message:App.messages.addServices.errorSeatNumber},{onlyIf:function(){return t.parent&&parseInt(t.reservationTypeID())==n.ReservationType.seatDesignated&&t.seatNumbersDesignated.canValidate()},validator:function(n){return n.split(",").length==parseInt(t.passengersCount())},message:App.messages.addServices.errorSeatPersonNumber}]});this.coachNumberAdjactent.extend({canValidate:!1,validation:{onlyIf:function(){return parseInt(t.reservationTypeID())==n.ReservationType.seatAdjactent&&t.coachNumberAdjactent.canValidate()},validator:function(n){return ValidationHelper.checkRange(n,1,999,!0)},message:App.messages.addServices.errorCoachNumber}});this.seatNumberAdjactent.extend({canValidate:!1,validation:{onlyIf:function(){return parseInt(t.reservationTypeID())==n.ReservationType.seatAdjactent&&t.seatNumberAdjactent.canValidate()},validator:function(n){return ValidationHelper.checkRange(n,1,999,!0)},message:App.messages.addServices.errorSeatNumber}})},t.prototype.canComputePrice=function(){var i=parseInt(this.reservationTypeID()),t;if(this.parent.reservationSJT()&&Support.stringIsEmpty(this.parent.sjtTicketNumber()))return!1;if(i==n.ReservationType.seatSelected){if((t=this.seatNumbersSelected(),!ValidationHelper.checkRangeNumbers(t,1,999,!0))||t.split(",").length!=parseInt(this.passengersCount()))return!1}else if(i==n.ReservationType.seatDesignated){if((t=this.coachNumberDesignated(),!ValidationHelper.checkRange(t,1,999,!0))||(t=this.seatNumbersDesignated(),!ValidationHelper.checkRangeNumbers(t,1,999,!0))||t.split(",").length!=parseInt(this.passengersCount()))return!1}else if(i==n.ReservationType.seatAdjactent&&((t=this.coachNumberAdjactent(),!ValidationHelper.checkRange(t,1,999,!0))||(t=this.seatNumberAdjactent(),!ValidationHelper.checkRange(t,1,999,!0))))return!1;return!0},t.prototype.setPlaceInfo=function(t){var i=this;(this.placeInfoList.removeAll(),t!=null&&t!=undefined&&t.length!=0)&&t.forEach(function(t){var u,f;Support.stringIsEmpty(t.text)||(u=new r,u.placeInfoTitle=t.title,u.placeInfoText=t.text,f=t.icon,u.placeInfoIcon=t.icon>n.CompartmentList.none?n.CompartmentList[f].toLowerCase():"",i.placeInfoList().push(u),i.placeInfoList.valueHasMutated())})},t.prototype.checkErrors=function(){return(parseInt(this.reservationTypeID())==n.ReservationType.seatSelected&&this.seatNumbersSelected.canValidate(!0),parseInt(this.reservationTypeID())==n.ReservationType.seatDesignated&&(this.coachNumberDesignated.canValidate(!0),this.seatNumbersDesignated.canValidate(!0)),parseInt(this.reservationTypeID())==n.ReservationType.seatAdjactent&&(this.coachNumberAdjactent.canValidate(!0),this.seatNumberAdjactent.canValidate(!0)),this.errors().length>0)?(this.errors.showAllMessages(),!1):this.error().isVisible()?!1:this.parent.error().isVisible()?!1:!0},t.prototype.setReservationPrice=function(){if(this.price.bikePrice){var n=this.parent.parent.parent.serviceLuggageAndBike();n.setTrainAfterReservation(this.id,this.price.bikePrice,!1)}},t.prototype.serialize=function(t){var i=this.model;return t&&(i=$.extend({},this.model)),i.priceId=this.priceId(),i.reservationTypeID=parseInt(this.reservationTypeID()),i.passengersCount=parseInt(this.passengersCount()),i.supplement1T=this.supplement1T(),(i.reservationTypeID==n.ReservationType.seatAuto||i.reservationTypeID>1e3)&&(i.seatPositionID=this.modelCopy.seatPositionID,i.seatCompartmentID=this.modelCopy.seatCompartmentID),i.reservationTypeID==n.ReservationType.seatSelected&&(i.coachNumberSelected=parseInt(this.coachNumberSelected()),i.seatNumbersSelected=this.seatNumbersSelected().split(",").map(function(n){return parseInt(n)})),i.reservationTypeID==n.ReservationType.seatDesignated&&(i.coachNumberDesignated=parseInt(this.coachNumberDesignated()),i.seatNumbersDesignated=this.seatNumbersDesignated().split(",").map(function(n){return parseInt(n)})),i.reservationTypeID==n.ReservationType.seatAdjactent&&(i.coachNumberAdjactent=parseInt(this.coachNumberAdjactent()),i.seatNumberAdjactent=parseInt(this.seatNumberAdjactent())),i.reservationTypeID==n.ReservationType.couchette&&(i.couchetteCompartmentID=this.modelCopy.couchetteCompartmentID,i.couchettePositions=this.modelCopy.couchettePositions),i.reservationTypeID==n.ReservationType.berth&&(i.berthCompartmentID=this.modelCopy.berthCompartmentID,i.berthMaleCount=this.modelCopy.berthMaleCount,i.berthFemaleCount=this.modelCopy.berthFemaleCount,i.berthTogether=this.modelCopy.berthTogether,i.berthMalePositions=this.modelCopy.berthMalePositions,i.berthFemalePositions=this.modelCopy.berthFemalePositions),i.reservationTypeID==n.ReservationType.berthdeluxe&&(i.berthDeluxeCompartmentID=this.modelCopy.berthDeluxeCompartmentID,i.berthMaleCount=this.modelCopy.berthMaleCount,i.berthFemaleCount=this.modelCopy.berthFemaleCount,i.berthTogether=this.modelCopy.berthTogether,i.berthMalePositions=this.modelCopy.berthMalePositions,i.berthFemalePositions=this.modelCopy.berthFemalePositions),t||this.price.priceResult!=n.ReservationPriceResult.computed||(i.price=this.price.reservationPrice.price),i.serviceDogDisabled=this.serviceDogDisabled,i.reservationError=this.error().message(),i.forSjtTicket=this.parent.reservationSJT(),this.parent.reservationSJT()&&(i.sjtTicketId=this.parent.sjtTicketNumber()),i},t.prototype.anySJTRes=function(){var n=this.parent.trainsThere().filter(function(n){return n.reservationTypes().filter(function(n){return parseInt(n.value)>1e3})});return n!=null&&n.length>0?!0:(n=this.parent.trainsBack().filter(function(n){return n.reservationTypes().filter(function(n){return parseInt(n.value)>1e3})}),n!=null&&n.length>0)?!0:!1},t.priceComputationDelay=2e3,t}(),u,r,t;n.ReservationTrain=i;u=function(){function r(i){var r=this;(this.totalPrice=ko.observable(""),this.passengersCountVisible=ko.observable(),this.passengersCount=ko.observable(),this.supplement1TEnabled=ko.observable(),this.supplement1T=ko.observable(),this.trainsThere=ko.observableArray(),this.trainsBack=ko.observableArray(),this.priceId=ko.observable(""),this.reservationTypeVisible=ko.observable(!1),this.reservationSJT=ko.observable(!1),this.reservationTypeEnabled=ko.observable(!0),this.sjtTicketNumber=ko.observable(""),this.doneClicked=!1,this.error=ko.observable(),this.passengersCountChange=function(){r.passengersCountChangeButton(0)},this.passengersCountChangeButton=function(n){var t=r.setPassengersCount(n),i=r.getAllTrains();i.forEach(function(n){n.passengersCount(r.passengersCount());t&&(n.resetBerthInfo(),n.resetCouchetteInfo())});t&&r.startComputePrice()},this.setPassengersCount=function(n){var t=parseInt(r.passengersCount());return(isNaN(t)&&(t=1),t=Support.checkValueInInterval(t+n,r.minPassengersCount,r.maxPassengersCount),r.passengersCount(t.toString()),t.toString()==r.passengersCountLast)?!1:(r.passengersCountLast=r.passengersCount(),!0)},this.supplement1TChange=function(){return r.startComputePrice(),!0},this.startComputePrice=function(){if(r.reservationSJT()){if(!Support.stringIsEmpty(r.sjtTicketNumber())&&ValidationHelper.isSJTNumber(r.sjtTicketNumber())){var t=r.getAllTrains(),i=t.filter(function(t){return t.price.priceResult==n.ReservationPriceResult.computing||t.price.priceResult==n.ReservationPriceResult.computingStart});i.length==0&&t.forEach(function(n){return n.startComputePrice()})}}else r.getAllTrains().forEach(function(n){return n.startComputePrice()})},this.computePrice=function(){var t=r.getAllTrains(),i=t.filter(function(t){return t.price.priceResult==n.ReservationPriceResult.computing});i.forEach(function(n){return n.computePrice()})},this.showPrice=function(){var t=r.getAllTrains(),e=t.filter(function(t){return t.price.priceResult==n.ReservationPriceResult.invalid}),o=t.filter(function(t){return t.price.priceResult==n.ReservationPriceResult.noReservation}),u,f,i;if(e.length>0||o.length==t.length){r.totalPrice("");return}if(u=t.filter(function(t){return t.price.priceResult==n.ReservationPriceResult.computing||t.price.priceResult==n.ReservationPriceResult.computingStart}),u.length>0){r.totalPrice("...");return}f=t.filter(function(t){return t.price.priceResult==n.ReservationPriceResult.computed});i=0;f.forEach(function(n){return i+=n.price.reservationPrice.price});r.totalPrice(Support.formatMoneyFree(i,!0))},this.setReservations=function(n){var t=r;$.ajax({url:App.getUrlAction("SetServiceReservation"),type:"POST",headers:App.GetAntiForgeryTokenHeader(),data:JSON.stringify(n),dataType:"json",contentType:"application/json; charset=utf-8",success:function(t){ErrorHandler.checkErrorsWithInfo(t,r)||(r.trainsThere().forEach(function(n){return n.setReservationPrice()}),r.trainsBack().forEach(function(n){return n.setReservationPrice()}),n.serviceDogDisabled=t.serviceDogDisabled,n.serviceBikeLuggageDisabled=t.serviceBikeLuggageDisabled,r.parent.setData(n,!0,!0),$("#addServiceReservationModal").modal("hide"));r.showPrice()}})},this.done=function(){r.checkErrors()&&(r.doneClicked=!0,r.checkComputedPrice())&&r.setReservations(r.serialize())},this.reservationSJTChange=function(){r.getAllTrains().forEach(function(n){return n.error().message("")});r.startComputePrice()},this.parent=i,this.model=this.parent.model,this.priceId(this.model.priceId),this.error(new ErrorInfo("ServiceReservation")),this.setValidation(),this.model.visible)&&(this.reservationTypeVisible(this.model.resPossibilities>0),this.reservationTypeEnabled((this.model.resPossibilities&t.CD)!=0&&(this.model.resPossibilities&t.SJT_TICKET)!=0),this.reservationSJT(!this.reservationTypeEnabled()&&(this.model.resPossibilities&t.SJT_TICKET)!=0),this.seatModal=new n.ReservationSeatModal,ko.applyBindings(this.seatModal,document.getElementById("addServiceReservationSeatModal")),this.berthModal=new n.ReservationBerthModal,ko.applyBindings(this.berthModal,document.getElementById("addServiceReservationBerthModal")),this.couchetteModal=new n.ReservationCouchetteModal,ko.applyBindings(this.couchetteModal,document.getElementById("addServiceReservationCouchetteModal")),this.positionsModal=new n.ReservationPositionsModal,ko.applyBindings(this.positionsModal,document.getElementById("addServiceReservationPositionsModal")),this.supplement1T.subscribe(function(n){var t=r.getAllTrains();t.forEach(function(t){t.model.supplement1TEnabled&&t.supplement1T(n)})}),this.sjtTicketNumber.subscribe(function(t){var u=r.getAllTrains(),i;!Support.stringIsEmpty(t)&&ValidationHelper.isSJTNumber(t)&&(i=u.filter(function(t){return t.price.priceResult==n.ReservationPriceResult.computing||t.price.priceResult==n.ReservationPriceResult.computingStart}),i.length==0&&r.startComputePrice())}),this.errors=ko.validation.group(this))}return r.prototype.show=function(n,t){var r=this,u=this.model,f;this.parent.parent.clearErrors();this.error().message("");this.trainsThere.removeAll();u.trainsThere.map(function(n){return new i(n,u.reservationTypes,r,!0)}).forEach(function(n){return r.trainsThere.push(n)});this.trainsBack.removeAll();u.trainsBack.map(function(n){return new i(n,u.reservationTypes,r,!1)}).forEach(function(n){return r.trainsBack.push(n)});n&&this.setDefaultReservationType();f=this.getAllTrains();this.supplement1TEnabled(f.filter(function(n){return n.model.supplement1TEnabled}).length>0);this.supplement1T(f.filter(function(n){return n.supplement1T()}).length>0);this.initPassengers(f);$("#addServiceReservationModal .cd-select").refreshNiceSelect();(n||t)&&this.startComputePrice();this.showPrice()},r.prototype.isEnabled=function(t){var i=[];return t.trainsThere.forEach(function(n){return i.push(n)}),t.trainsBack.forEach(function(n){return i.push(n)}),i.filter(function(t){return t.reservationTypeID!=n.ReservationType.none&&t.reservationTypeID!=n.ReservationType.disabled}).length>0},r.prototype.setDefaultReservationType=function(){this.trainsThere().forEach(function(n){return n.setDefaultReservationTypeID()});this.trainsBack().forEach(function(n){return n.setDefaultReservationTypeID()})},r.prototype.initPassengers=function(t){t=t.filter(function(t){return parseInt(t.reservationTypeID())!=n.ReservationType.disabled});var i=t[0],u=t.filter(function(n){return n.model.passengersCount==i.model.passengersCount&&n.model.minPassengersCount==i.model.minPassengersCount&&n.model.maxPassengersCount==i.model.maxPassengersCount}),r=u.length==t.length;this.passengersCountVisible(r);t.forEach(function(n){return n.passengersCountVisible(!r)});r&&(this.passengersCount(i.model.passengersCount.toString()),this.passengersCountLast=this.passengersCount(),this.minPassengersCount=i.model.minPassengersCount,this.maxPassengersCount=i.model.maxPassengersCount)},r.prototype.incDecPassengersCount=function(n,t){t.which===38?this.setPassengersCount(1):t.which===40&&this.setPassengersCount(-1)},r.prototype.checkComputedPrice=function(){var i=this.getAllTrains(),t=i.filter(function(t){return t.price.priceResult==n.ReservationPriceResult.computing});return t.length>0?(t.forEach(function(n){return n.computePrice()}),!1):(t=i.filter(function(t){return t.price.priceResult==n.ReservationPriceResult.computingStart}),t.length==0)},r.prototype.serialize=function(){var n=this.model;return n.priceId=this.priceId(),n.trainsThere=this.trainsThere().map(function(n){return n.serialize(!1)}),n.trainsBack=this.trainsBack().map(function(n){return n.serialize(!1)}),n},r.prototype.checkErrors=function(){var n=!0;return this.errors().length>0?(this.errors.showAllMessages(),!1):(this.getAllTrains().forEach(function(t){t.checkErrors()||(n=!1)}),n)},r.prototype.getAllTrains=function(){var n=[];return this.trainsThere().forEach(function(t){return n.push(t)}),this.trainsBack().forEach(function(t){return n.push(t)}),n},r.prototype.setValidation=function(){var n=this;this.sjtTicketNumber.extend({canValidate:!0,required:{onlyIf:function(){return n.reservationSJT()&&n.sjtTicketNumber.canValidate()},message:function(){return App.messages.validation.requiredItem}},validation:[{onlyIf:function(){return n.reservationSJT()&&n.sjtTicketNumber.canValidate()},validator:function(n){return ValidationHelper.isSJTNumber(n)},message:App.messages.validation.errorSJTNumber}]})},r}();n.ReservationModal=u;r=function(){function n(){}return n}();n.ReservationPlaceInfo=r,function(n){n[n.None=0]="None";n[n.CD=1]="CD";n[n.SJT_TICKET=2]="SJT_TICKET"}(t=n.RESERVATION_POSSIBILITIES||(n.RESERVATION_POSSIBILITIES={}))}(AddServices||(AddServices={})),function(n){var t,r,u,f,i;(function(n){n[n.T3=0]="T3";n[n.double=1]="double";n[n.single=2]="single";n[n.T4=3]="T4"})(t||(t={}));r=function(){function n(){var n=this;this.positions=ko.observableArray();this.positionID=ko.observable();this.compartments=ko.observableArray();this.compartmentID=ko.observable();this.done=function(){var t=n.parent.modelCopy;t.seatPositionID=n.positionID();t.seatCompartmentID=n.compartmentID();n.parent.startComputePrice();$("#addServiceReservationSeatModal").modal("hide")}}return n.prototype.show=function(n){var i=this,t;this.parent=n;t=n.modelCopy;this.positions.removeAll();t.seatPositions.forEach(function(n){i.positions.push(n)});this.positionID(t.seatPositionID);this.compartments.removeAll();t.seatCompartments.forEach(function(n){i.compartments.push(n)});this.compartmentID(t.seatCompartmentID);$("#addServiceReservationSeatModal .cd-select").refreshNiceSelect()},n}();n.ReservationSeatModal=r;u=function(){function n(){var n=this;this.compartments=ko.observableArray();this.compartmentID=ko.observable();this.positionEnabled=ko.observable();this.positionsInfo=ko.observable("");this.couchetteReturn=ko.observable(!1);this.couchetteReturnEnabled=ko.observable(!1);this.setPositions=function(t){n.positions=t;t!=null&&t.bottom+t.middle+t.top!=0?(n.positions=t,n.positionsInfo(i.getPositionsInfo(t))):(n.positions=null,n.positionsInfo(""))};this.changePositions=function(){var t=parseInt(n.parent.passengersCount());n.parent.parent.positionsModal.show(n.positions,t,function(t){return n.setPositions(t)})};this.done=function(){var t=n.parent.modelCopy;t.couchetteCompartmentID=n.compartmentID();n.positionEnabled()&&(t.couchettePositions=n.positions);t.couchetteReturn=n.couchetteReturn();n.parent.setCouchetteInfo(t);t.couchetteReturn&&n.parent.setCouchetteToReturnTrains(t);n.parent.startComputePrice();$("#addServiceReservationCouchetteModal").modal("hide")}}return n.prototype.show=function(n){var i=this,t;this.parent=n;t=n.modelCopy;this.compartments.removeAll();t.couchetteCompartments.forEach(function(n){i.compartments.push(n)});this.compartmentID(t.couchetteCompartmentID);this.positionEnabled(t.couchetteBerthPositionEnabled);this.positionEnabled()&&this.setPositions(t.couchettePositions);this.couchetteReturnEnabled(t.couchetteReturnEnabled);this.couchetteReturn(t.couchetteReturnEnabled&&t.couchetteReturn);$("#addServiceReservationCouchetteModal .cd-select").refreshNiceSelect()},n}();n.ReservationCouchetteModal=u;f=function(){function r(){var r=this;this.compartments=ko.observableArray();this.compartmentID=ko.observable();this.positionEnabled=ko.observable();this.malePositionsInfo=ko.observable("");this.femalePositionsInfo=ko.observable("");this.maleCount=ko.observable();this.femaleCount=ko.observable();this.berthTogether=ko.observable(!1);this.berthTogetherDisabled=ko.observable(!1);this.berthTogetherOnly=ko.observable(!1);this.berthReturn=ko.observable(!1);this.berthReturnEnabled=ko.observable(!1);this.positionsVisible=ko.computed(function(){return!r.berthTogether()||r.femalePositionsInfo()!=""||r.malePositionsInfo()!=""},this);this.checkBerthTogetherVisible=function(){var i=parseInt(r.parent.passengersCount()),n=parseInt(r.compartmentID()),u=r.getCompartmentSize(n);r.berthTogetherDisabled(u>i||n==t.single);r.berthTogetherDisabled()&&r.berthTogether(!1);r.berthTogetherOnly()&&r.berthTogether(!0)};this.getCompartmentSize=function(n){return n==t.single?1:n==t.double?2:n==t.T3?3:n==t.T4?4:3};this.setMalePositions=function(n){r.malePositions=n;n!=null&&n.bottom+n.middle+n.top!=0?(r.malePositions=n,r.malePositionsInfo(i.getPositionsInfo(n))):(r.malePositions=null,r.malePositionsInfo(""))};this.setFemalePositions=function(n){r.femalePositions=n;n!=null&&n.bottom+n.middle+n.top!=0?(r.femalePositions=n,r.femalePositionsInfo(i.getPositionsInfo(n))):(r.femalePositions=null,r.femalePositionsInfo(""))};this.changeMalePositions=function(){r.parent.parent.positionsModal.show(r.malePositions,r.maleCount(),function(n){return r.setMalePositions(n)})};this.changeFemalePositions=function(){r.parent.parent.positionsModal.show(r.femalePositions,r.femaleCount(),function(n){return r.setFemalePositions(n)})};this.checkPassengersCount=function(n){var i=parseInt(r.parent.passengersCount()),t=r.maleCount()+r.femaleCount();isNaN(t)||(n?r.setMalePositions(null):r.setFemalePositions(null),i!=t&&(n?(r.femaleCount(r.femaleCount()-(t-i)),r.setFemalePositions(null)):(r.maleCount(r.maleCount()-(t-i)),r.setMalePositions(null))))};this.done=function(){var t=r.parent.modelCopy,i=parseInt(r.parent.reservationTypeID())==n.ReservationType.berthdeluxe;i?t.berthDeluxeCompartmentID=r.compartmentID():t.berthCompartmentID=r.compartmentID();r.positionEnabled()&&(t.berthMalePositions=r.malePositions,t.berthFemalePositions=r.femalePositions);t.berthMaleCount=r.maleCount();t.berthFemaleCount=r.femaleCount();t.berthTogether=r.berthTogether();t.berthReturn=r.berthReturn();r.parent.setBerthInfo(t);t.berthReturn&&r.parent.setBerthToReturnTrains(t,i,r.parent.isThere());r.parent.startComputePrice();$("#addServiceReservationBerthModal").modal("hide")};this.maleCount.subscribe(function(){r.checkPassengersCount(!0)});this.femaleCount.subscribe(function(){r.checkPassengersCount(!1)})}return r.prototype.show=function(t){var r=this,i;this.parent=t;i=t.modelCopy;this.compartments.removeAll();parseInt(t.reservationTypeID())==n.ReservationType.berthdeluxe?(i.berthDeluxeCompartments.forEach(function(n){r.compartments.push(n)}),this.compartmentID(i.berthDeluxeCompartmentID)):(i.berthCompartments.forEach(function(n){r.compartments.push(n)}),this.compartmentID(i.berthCompartmentID));this.positionEnabled(i.couchetteBerthPositionEnabled);this.positionEnabled()&&(this.setMalePositions(i.berthMalePositions),this.setFemalePositions(i.berthFemalePositions));this.setMaxPassengersCount();this.maleCount(i.berthMaleCount);this.femaleCount(i.berthFemaleCount);this.berthTogether(i.berthTogether);this.berthTogetherOnly(i.berthTogetherOnly);this.berthReturnEnabled(i.berthReturnEnabled);this.berthReturn(i.berthReturnEnabled&&i.berthReturn);$("#addServiceReservationBerthModal .cd-select").refreshNiceSelect()},r.prototype.setMaxPassengersCount=function(){var n=parseInt(this.parent.passengersCount());$("#berthFemaleCount").slider("setAttribute","min",0);$("#berthFemaleCount").slider("setAttribute","max",n);$("#berthMaleCount").slider("setAttribute","min",0);$("#berthMaleCount").slider("setAttribute","max",n)},r}();n.ReservationBerthModal=f;i=function(){function n(){var n=this;this.topCount=ko.observable();this.middleCount=ko.observable();this.bottomCount=ko.observable();this.checkCount=function(t){var i=n.topCount()+n.middleCount()+n.bottomCount();isNaN(i)||n.maxCount<i&&(t=="top"?n.correctCount(n.middleCount,n.bottomCount,i-n.maxCount):t=="middle"?n.correctCount(n.topCount,n.bottomCount,i-n.maxCount):n.correctCount(n.topCount,n.middleCount,i-n.maxCount))};this.correctCount=function(n,t,i){n()<i?(i=i-n(),n(0),t(t()-i)):n(n()-i)};this.reset=function(){n.topCount(0);n.middleCount(0);n.bottomCount(0)};this.done=function(){var t={top:n.topCount(),middle:n.middleCount(),bottom:n.bottomCount()};n.callback(t);$("#addServiceReservationPositionsModal").modal("hide")};this.topCount.subscribe(function(){n.checkCount("top")});this.middleCount.subscribe(function(){n.checkCount("middle")});this.bottomCount.subscribe(function(){n.checkCount("bottom")})}return n.prototype.show=function(n,t,i){n||(n={top:0,middle:0,bottom:0});this.callback=i;this.maxCount=t;this.topCount(n.top);this.middleCount(n.middle);this.bottomCount(n.bottom);this.setMaxCount()},n.prototype.setMaxCount=function(){var n=this.maxCount>1?2:1;this.maxCount==0&&(n=0);$("#positionsTopCount").slider("setAttribute","max",n);$("#positionsMiddleCount").slider("setAttribute","max",n);$("#positionsBottomCount").slider("setAttribute","max",n)},n.getPositionsInfo=function(n){if(!n)return"";var t=[];return n.top>0&&t.push(n.top+"x "+App.messages.addServices.top),n.middle>0&&t.push(n.middle+"x "+App.messages.addServices.middle),n.bottom>0&&t.push(n.bottom+"x "+App.messages.addServices.bottom),t.join(", ")},n}();n.ReservationPositionsModal=i}(AddServices||(AddServices={})),function(n){var t,i,f,r,u;(function(n){n[n.none=0]="none";n[n.disabled=1]="disabled";n[n.seatAuto=2]="seatAuto";n[n.seatSelected=3]="seatSelected";n[n.seatDesignated=4]="seatDesignated";n[n.seatAdjactent=5]="seatAdjactent";n[n.berth=6]="berth";n[n.couchette=7]="couchette";n[n.berthdeluxe=8]="berthdeluxe"})(t=n.ReservationType||(n.ReservationType={})),function(n){n[n.computed=0]="computed";n[n.computing=1]="computing";n[n.computingStart=2]="computingStart";n[n.noReservation=3]="noReservation";n[n.invalid=4]="invalid"}(i=n.ReservationPriceResult||(n.ReservationPriceResult={})),function(n){n[n.none=0]="none";n[n.bike=1]="bike";n[n.imobile=2]="imobile";n[n.silent=3]="silent";n[n.kids=4]="kids";n[n.ladies=5]="ladies";n[n.stroller=6]="stroller";n[n.rjbackup=7]="rjbackup"}(f=n.CompartmentList||(n.CompartmentList={}));r=function(){function r(i,r){var u=this;this.priceId=ko.observable("");this.from=ko.observable("");this.to=ko.observable("");this.train=ko.observable("");this.reservationTypeID=ko.observable();this.error=ko.observable();this.berthInfo=ko.observable();this.couchetteInfo=ko.observable();this.reservationTypeInfo=ko.observable();this.isCateringTrain=ko.observable();this.canDelete=function(){return u.model.reservationTypeIDs.indexOf(t.none)>=0};this.computePrice=function(){var n=u.model,t=u.parent.parent.model.guid,i=u.parent.parent.servicePackages().enabled();u.price.computePrice(n,t,i,!1)};this.computePriceDone=function(n){if(u.price.reservationPrice&&(u.error().message(u.price.reservationPrice.error),n&&(u.model.price=u.price.reservationPrice.price,u.model.serviceDogDisabled=u.price.reservationPrice.serviceDogDisabled,u.parent.parent.serviceDog().checkReservationCompartments(),u.model.serviceBikeLuggageDisabled=u.price.reservationPrice.serviceBikeLuggageDisabled,u.parent.parent.serviceLuggageAndBike().checkReservation())),u.price.bikePrice){var t=u.parent.parent.serviceLuggageAndBike();t.setTrainAfterReservation(u.model.id,u.price.bikePrice,!0)}};this.setBerthInfo=function(i){var r="",s=parseInt(u.reservationTypeID()),f=i.berthTogetherOnly,o=" / ",h,e;f&&(o="");i.berthFemaleCount>0&&(f||(r+=" - "+i.berthFemaleCount+"x "+App.messages.addServices.female),i.berthCompartments&&s==t.berth&&!Support.stringIsEmpty(i.berthCompartmentID)&&i.berthCompartments.forEach(function(n){n.value==i.berthCompartmentID&&(r+=o+n.name+" "+App.messages.addServices.compartment)}),i.berthDeluxeCompartments&&s==t.berthdeluxe&&!Support.stringIsEmpty(i.berthDeluxeCompartmentID)&&i.berthDeluxeCompartments.forEach(function(n){n.value==i.berthDeluxeCompartmentID&&(r+=o+n.name+" "+App.messages.addServices.compartment)}),e=n.ReservationPositionsModal.getPositionsInfo(i.berthFemalePositions),e.length>0&&!f&&(r+=" ("+e+")"),i.berthMaleCount>0&&!f&&(r+=", "));i.berthMaleCount>0&&!f&&(h=" - ",i.berthFemaleCount>0&&!f&&(h=""),f||(r+=h+i.berthMaleCount+"x "+App.messages.addServices.male),i.berthCompartments&&s==t.berth&&!Support.stringIsEmpty(i.berthCompartmentID)&&i.berthCompartments.forEach(function(n){n.value==i.berthCompartmentID&&(r+=o+n.name+" "+App.messages.addServices.compartment)}),i.berthDeluxeCompartments&&s==t.berthdeluxe&&!Support.stringIsEmpty(i.berthDeluxeCompartmentID)&&i.berthDeluxeCompartments.forEach(function(n){n.value==i.berthDeluxeCompartmentID&&(r+=o+n.name+" "+App.messages.addServices.compartment)}),e=n.ReservationPositionsModal.getPositionsInfo(i.berthMalePositions),e.length>0&&!f&&(r+=" ("+e+")"));u.berthInfo(r)};this.setCouchetteInfo=function(t){var i=" - ",r;t.couchetteCompartments&&!Support.stringIsEmpty(t.couchetteCompartmentID)&&t.couchetteCompartments.forEach(function(n){n.value==t.couchetteCompartmentID&&(i+=n.name+" "+App.messages.addServices.compartment)});r=n.ReservationPositionsModal.getPositionsInfo(t.couchettePositions);r.length>0&&(i+=" ("+r+")");u.couchetteInfo(i)};this.model=i;this.parent=r;this.priceId(i.priceId);this.from(i.from);this.to(i.to);this.train(i.train);this.reservationTypeID(i.reservationTypeID.toString());this.isCateringTrain(this.parent.model.cateringTrains.some(function(n){return n==u.model.id}));this.error(new ErrorInfo("ServiceReservationTrain"+i.id));i.reservationError&&this.error().message(i.reservationError);this.price=new n.ReservationPriceComputation(this.parent.parent,this.parent.showPrice,this.computePriceDone,i);this.vehicleIcon=Support.getVehicleIcon(i.trainTypeID,!0);this.setBerthInfo(i);this.setCouchetteInfo(i);this.setReservationTypeInfo()}return Object.defineProperty(r.prototype,"coachNumber",{get:function(){var n=parseInt(this.reservationTypeID());return n==t.seatSelected?this.model.coachNumberSelected.toString():n==t.seatDesignated?this.model.coachNumberDesignated.toString():n==t.seatAdjactent?this.model.coachNumberAdjactent.toString():""},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"seatNumber",{get:function(){var n=parseInt(this.reservationTypeID());return n==t.seatSelected?this.model.seatNumbersSelected.map(function(n){return n.toString()}).join(", "):n==t.seatDesignated?this.model.seatNumbersDesignated.map(function(n){return n.toString()}).join(", "):n==t.seatAdjactent?this.model.seatNumberAdjactent.toString():""},enumerable:!0,configurable:!0}),r.prototype.canSubmit=function(){return!this.error().isVisible()&&this.price.priceResult==i.computed},r.prototype.setReservationTypeInfo=function(){var n="",i=parseInt(this.reservationTypeID()),t=this.parent.model.reservationTypes.filter(function(n){return parseInt(n.value)==i})[0];t&&(n+=t.name);this.reservationTypeInfo(n)},r}();u=function(){function u(r,u){var f=this;this.priceId=ko.observable("");this.serviceDogDisabledFlag=ko.observable(!1);this.serviceBikeLuggageDisabledFlag=ko.observable(!1);this.totalPrice=ko.observable();this.visible=ko.observable(!1);this.enabled=ko.observable(!1);this.trains=ko.observableArray();this.reservationTitle=ko.observable("");this.setData=function(n,t,i){t===void 0&&(t=!1);i===void 0&&(i=!1);f.serviceDogDisabledFlag(n.serviceDogDisabled);f.serviceBikeLuggageDisabledFlag(n.serviceBikeLuggageDisabled);f.setTrains(n);f.setEnabled();f.showPrice();t&&f.parent.serviceDog().checkReservationCompartments();i&&f.parent.serviceLuggageAndBike().checkReservation()};this.setEnabled=function(){f.enabled(f.trains().length>0);f.parent.serviceCatering()!=undefined&&(f.parent.serviceCatering().trains().forEach(function(n){return n.setVisible(!1)}),f.trains().filter(function(n){return n.isCateringTrain()}).forEach(function(n){return f.parent.serviceCatering().trains().filter(function(t){return t.model.id==n.model.id})[0].setVisible(!0)}))};this.showPrice=function(){var t,r,n;if(f.isFreeTitleVisible=!1,!f.enabled()){f.totalPrice("");f.setReservationTitle(f.model);f.myTicketUpdate();return}if(t=f.trains().filter(function(n){return n.error().isVisible()}),t.length>0){f.totalPrice("");f.setReservationTitle(f.model);f.myTicketUpdate();return}if(r=f.trains().filter(function(n){return n.price.priceResult==i.computingStart}),r.length>0){f.totalPrice("...");f.setReservationTitle(f.model);f.myTicketUpdate();return}n=0;f.trains().forEach(function(t){return n+=t.model.price});f.isFreeTitleVisible=n==0;f.totalPrice(Support.formatMoneyFree(n,!0,!1));f.setReservationTitle(f.model);f.myTicketUpdate()};this.setPlace=function(n,t,i,r,u){var e=f.serviceReservationModal.trainsThere().filter(function(t){return t.id==n});e.length==0&&(e=f.serviceReservationModal.trainsBack().filter(function(t){return t.id==n}));e[0].setPlace(t,i,r,u)};this.add=function(){f.serviceReservationModal.show(!0,!f.canSubmit())};this.change=function(){f.serviceReservationModal.show(!1,!f.canSubmit())};this.deleteTrain=function(n){var t=f.trains().filter(function(t){return t.model.id==n.model.id});t.length!=0&&f.deleteTrainServer(t[0])};this.deleteAll=function(){f.trains().slice().forEach(function(n){return f.deleteTrain(n)})};this.deleteTrainServer=function(n){var r=f,i=n.model;$.ajax({url:App.getUrlAction("DeleteTrainReservation"),type:"POST",headers:App.GetAntiForgeryTokenHeader(),data:JSON.stringify(i),dataType:"json",contentType:"application/json; charset=utf-8",success:function(r){if(!ErrorHandler.checkErrorsWithInfo(r,f.parent)){i.reservationTypeID=t.none;i.supplement1T=!1;i.price=0;f.trains.remove(n);f.setEnabled();f.serviceDogDisabledFlag(r.serviceDogDisabled);f.serviceBikeLuggageDisabledFlag(r.serviceBikeLuggageDisabled);f.enabled()||f.getAllTrains().forEach(function(n){return n.passengersCount=n.defaultPassengersCount});f.showPrice();f.parent.serviceDog().checkReservationCompartments();f.parent.serviceLuggageAndBike().checkReservation();var u=f.parent.serviceLuggageAndBike();u.computeTrainPrice(i.id)}}})};this.canDeleteAll=function(){return f.trains().filter(function(n){return n.canDelete()}).length==f.trains().length};this.model=r;this.parent=u;this.priceId(r.priceId);r.trainsThere||(r.trainsThere=[]);r.trainsBack||(r.trainsBack=[]);this.serviceDogDisabledFlag(r.serviceDogDisabled);this.serviceBikeLuggageDisabledFlag(r.serviceBikeLuggageDisabled);this.visible(r.visible);this.setData(r);this.isFreeTitleVisible=!1;this.setReservationTitle(r);this.serviceReservationModal=new n.ReservationModal(this);ko.applyBindings(this.serviceReservationModal,document.getElementById("addServiceReservationModal"))}return u.prototype.setTrains=function(){var n=this;this.trains.removeAll();this.getAllTrains().filter(function(n){return n.reservationTypeID!=t.none&&n.reservationTypeID!=t.disabled}).map(function(t){return new r(t,n)}).forEach(function(t){return n.trains.push(t)})},u.prototype.getReservationTitle=function(){var i=this.getAllTrains().filter(function(n){return n.reservationTypeIDs.some(function(n){return n!=t.none&&n!=t.disabled&&n!=t.berth&&n!=t.couchette&&n!=t.berthdeluxe})}).length>0,r=this.getAllTrains().filter(function(n){return n.reservationTypeIDs.some(function(n){return n==t.berth||n==t.berthdeluxe})}).length>0,u=this.getAllTrains().filter(function(n){return n.reservationTypeIDs.some(function(n){return n==t.couchette})}).length>0,n="";return!this.parent.model.containsSLUK&&!this.parent.model.containsRailCard&&(this.totalPrice()==""&&!this.parent.model.sjt&&!this.parent.model.onlyReservation&&!this.parent.model.isInternational||this.isFreeTitleVisible)?App.messages.addServices.reservationFree:(i&&(n=App.messages.addServices.reservation),r&&(n+=n.length>0?", "+App.messages.addServices.berth.toLowerCase():App.messages.addServices.berth),u&&(n+=n.length>0?", "+App.messages.addServices.couchette.toLowerCase():App.messages.addServices.couchette),n)},u.prototype.setReservationTitle=function(){this.reservationTitle(this.getReservationTitle())},u.prototype.hasCateringTrain=function(n){return this.trains().filter(function(t){return t.model.id==n}).length>0},u.prototype.updateModel=function(n){n.priceId=this.model.priceId;n.trainsThere=this.model.trainsThere;n.trainsBack=this.model.trainsBack;n.serviceDogDisabled=this.model.serviceDogDisabled;n.serviceBikeLuggageDisabled=this.model.serviceBikeLuggageDisabled},u.prototype.getAllTrains=function(){var n=[];return this.model.trainsThere.forEach(function(t){return n.push(t)}),this.model.trainsBack.forEach(function(t){return n.push(t)}),n},u.prototype.canSubmit=function(){return this.trains().filter(function(n){return!n.canSubmit()}).length==0},u.prototype.serviceDogDisabled=function(){return this.serviceDogDisabledFlag()},u.prototype.serviceBikeLuggageDisabled=function(){return this.serviceBikeLuggageDisabledFlag()},u.prototype.getTrainForBikeReservation=function(n){var i=this.getAllTrains().filter(function(t){return t.id==n});return i.length>0?i[0]:{id:n,reservationTypeID:t.none}},u.prototype.setTrainAfterBikeReservation=function(n,t,i){var r=this.getAllTrains().filter(function(t){return t.id==n}),u;r.length>0&&(r[0].price=t.price,this.showPrice(),r[0].serviceDogDisabled=t.serviceDogDisabled,this.parent.serviceDog().checkReservationCompartments(),r[0].serviceBikeLuggageDisabled=t.serviceBikeLuggageDisabled,this.parent.serviceLuggageAndBike().checkReservation());i&&(u=this.trains().filter(function(t){return t.model.id==n}),u.length>0&&u[0].error().message(t.error))},u.prototype.computeTrainPrice=function(n){var t=this.trains().filter(function(t){return t.model.id==n});t.length>0&&t[0].computePrice()},u.prototype.computePrice=function(){var n=this.trains().forEach(function(n){return n.computePrice()})},u.prototype.computePriceDefault=function(){var n=this.trains().forEach(function(n){return n.computePrice()})},u.prototype.myTicketUpdate=function(){var n=0,t=0,i;this.trains().forEach(function(i){return i.model.isGlobalPrice?t+=i.model.price:n+=i.model.price});this.trains().some(function(n){return n.model.isGlobalPrice})&&this.parent.myTicketUpdate(MyTicketType.TicketAndReservation,null,null,t);i=this.totalPrice()=="..."?0:this.trains().filter(function(n){return!n.model.isGlobalPrice}).length;this.parent.myTicketUpdate(MyTicketType.Reservation,this.reservationTitle(),i,n)},u}();n.ServiceReservation=u}(AddServices||(AddServices={})),function(n){var i=function(){function t(t,i,r,u){var f=this;this.priceResult=n.ReservationPriceResult.noReservation;this.error=function(){var n="";return f.bikePrice.error&&(n=f.bikePrice.error),f.reservationPrice&&f.reservationPrice.error&&(n.length>0&&(n+=" "),n+=f.reservationPrice.error),n};this.computePrice=function(t,i,r,u){clearTimeout(f.priceTimer);f.bikePrice={price:0,error:""};f.reservationPrice=null;var e=f.mainForm.serviceReservation().getTrainForBikeReservation(t.id);f.canComputePrice(t,e)&&(u?(f.priceResult=n.ReservationPriceResult.computing,f.priceTimer=setTimeout(function(){f.computePriceStart(t,e,i,r)},n.ReservationTrain.priceComputationDelay),f.showPrice()):f.computePriceStart(t,e,i,r))};this.computePriceStart=function(t,i,r,u){App.log(LogSection.addServices,{name:"trainBikePrice_"+t.id,bike:t,reservation:i});f.priceResult=n.ReservationPriceResult.computingStart;clearTimeout(f.priceTimer);f.showPrice();var e={guid:r,packages:u,reservation:i,bike:t};$.ajax({url:App.getUrlAction("ServiceLuggageAndBikeComputeTrainPrice"),type:"POST",headers:App.GetAntiForgeryTokenHeader(),data:JSON.stringify(e),dataType:"json",contentType:"application/json; charset=utf-8",success:function(i){var u,r;App.log(LogSection.addServices,{name:"trainBikePrice_"+t.id,result:i});u=!1;ErrorHandler.checkErrorsWithInfo(i,f)||(r=i,f.bikePrice=r.bike,f.reservationPrice=r.reservation,r.bike.error=r.bike.error||"",r.reservation.error=r.reservation.error||"",u=!(r.bike.error||r.reservation.error));f.priceResult==n.ReservationPriceResult.computingStart&&(f.priceResult=u?n.ReservationPriceResult.computed:n.ReservationPriceResult.invalid);f.done(u);f.showPrice()}})};this.mainForm=t;this.showPrice=i;this.done=r;this.bikePrice={price:0,error:""};u.bikeReservationID!=n.BikeReservation.noReservation&&(this.bikePrice.price=u.price,this.priceResult=n.ReservationPriceResult.computed)}return t.prototype.canComputePrice=function(t,i){var u=t.bikeReservationID,r=i.reservationTypeID;return u==n.BikeReservation.noReservation&&(r==n.ReservationType.none||r==n.ReservationType.disabled)?(this.priceResult=n.ReservationPriceResult.noReservation,this.done(!0),this.showPrice(),!1):!0},t}(),t;n.BikePriceComputation=i;t=function(){function t(t,i,r){var u=this;this.priceResult=n.ReservationPriceResult.noReservation;this.setInvalidPrice=function(){u.price={price:0,error:""};u.priceResult=n.ReservationPriceResult.invalid;u.showPrice()};this.computePrice=function(t,i,r){clearTimeout(u.priceTimer);u.price={price:0,error:""};r?(u.priceResult=n.ReservationPriceResult.computing,u.priceTimer=setTimeout(function(){u.computePriceStart(t,i)},n.ReservationTrain.priceComputationDelay),u.showPrice()):u.computePriceStart(t,i)};this.computePriceStart=function(t,i){App.log(LogSection.addServices,{name:"luggagePrice",luggage:t});u.priceResult=n.ReservationPriceResult.computingStart;clearTimeout(u.priceTimer);u.showPrice();var r={guid:i,model:t};$.ajax({url:App.getUrlAction("ServiceLuggageAndBikeComputePrice"),type:"POST",headers:App.GetAntiForgeryTokenHeader(),data:JSON.stringify(r),dataType:"json",contentType:"application/json; charset=utf-8",success:function(t){App.log(LogSection.addServices,{name:"luggagePrice",result:t});var i=!1;ErrorHandler.checkErrorsWithInfo(t,u)||(u.price=t,u.price.error=u.price.error||"",i=!u.price.error);u.priceResult==n.ReservationPriceResult.computingStart&&(u.priceResult=i?n.ReservationPriceResult.computed:n.ReservationPriceResult.invalid);u.done(i);u.showPrice()}})};this.showPrice=t;this.done=i;this.price={price:r.price,error:""}}return t}();n.LuggagePriceComputation=t}(AddServices||(AddServices={})),function(n){var t=function(){function t(t,i){var r=this;this.from=ko.observable("");this.to=ko.observable("");this.train=ko.observable("");this.bikeServices=ko.observableArray();this.bikeServiceID=ko.observable();this.bikeReservations=ko.observableArray();this.bikeReservationID=ko.observable();this.error=ko.observable();this.bikeReservationsChange=!1;this.setDefaultBikeServiceID=function(){var i=[n.BikeService.luggageNoReservation.toString(),n.BikeService.luggageObligatory.toString(),n.BikeService.luggageOptional.toString()],t;parseInt(r.bikeServiceID())==n.BikeService.none&&(t=r.bikeServices().filter(function(n){return i.indexOf(n.value)>=0}),t.length>0?r.bikeServiceID(t[0].value):r.bikeServiceID(r.bikeServices()[r.bikeServices().length-1].value),r.setBikeReservations(!0))};this.bikeServiceChange=function(){r.setBikeReservations();r.parent.checkForm();r.startComputePrice();r.parent.startComputePriceLuggage()};this.bikeReservationChange=function(){r.bikeReservationsChange||(r.startComputePrice(),r.parent.startComputePriceLuggage())};this.startComputePrice=function(){if(r.parent.doneClicked=!1,!r.parent.isClientError){var n=r.serialize(!0),t=r.parent.parent.parent.model.guid,i=r.parent.parent.parent.servicePackages().enabled();r.price.computePrice(n,t,i,!0)}};this.computePrice=function(){if(!r.parent.isClientError){var n=r.serialize(!0),t=r.parent.parent.parent.model.guid,i=r.parent.parent.parent.servicePackages().enabled();r.price.computePrice(n,t,i,!1)}};this.computePriceDone=function(){r.error().message(r.price.error());r.parent.doneClicked&&r.parent.done()};this.parent=i;this.model=t;this.id=t.id;this.from(t.from);this.to(t.to);this.train(t.train);this.hasBikeReservationIDChange=t.bikeReservationChange;this.vehicleIcon=Support.getVehicleIcon(t.trainTypeID,!0);this.error(new ErrorInfo("Train"+t.id));this.bikeServiceID(t.bikeServiceID.toString());t.bikeServices.forEach(function(n){r.bikeServices.push(n)});this.bikeReservationID(t.bikeReservationID.toString());this.setBikeReservations();this.price=new n.BikePriceComputation(this.parent.parent.parent,this.parent.showPrice,this.computePriceDone,t)}return t.prototype.hasBikeService=function(){return parseInt(this.bikeServiceID())==n.BikeService.none?this.bikeServices().length>1:!0},t.prototype.setBikeReservations=function(t){var f=this;t===void 0&&(t=!1);this.bikeReservationsChange=!0;var i=parseInt(this.bikeServiceID()),u=parseInt(this.bikeReservationID()),r=[n.BikeReservation.noReservation,n.BikeReservation.bikeAndPlace,n.BikeReservation.onlyBike];i==n.BikeService.none||i==n.BikeService.luggageNoReservation||i==n.BikeService.storageNoReservation?r=[n.BikeReservation.noReservation]:i==n.BikeService.onlyReservation?r=[n.BikeReservation.bikeAndPlace,n.BikeReservation.onlyBike]:i==n.BikeService.storageOptional?r=[n.BikeReservation.noReservation,n.BikeReservation.onlyBike]:i==n.BikeService.storageObligatory?r=[n.BikeReservation.onlyBike]:i==n.BikeService.luggageOptional?r=[n.BikeReservation.noReservation,n.BikeReservation.onlyBike,n.BikeReservation.bikeAndPlace]:i==n.BikeService.luggageObligatory&&(r=[n.BikeReservation.onlyBike,n.BikeReservation.bikeAndPlace]);this.bikeReservations.removeAll();this.model.bikeReservations.forEach(function(n){r.indexOf(parseInt(n.value))>=0&&f.bikeReservations.push(n)});t||r.indexOf(u)==-1?(this.bikeReservationID(this.bikeReservations()[this.bikeReservations().length-1].value),this.hasBikeReservationIDChange&&this.bikeReservations().filter(function(t){return parseInt(t.value)==n.BikeReservation.bikeAndPlace}).length>0&&this.bikeReservationID(n.BikeReservation.bikeAndPlace.toString())):this.bikeReservationID(u.toString());$("#addServiceLuggageAndBikeModal .cd-select").refreshNiceSelect();this.bikeReservationsChange=!1},t.prototype.checkErrors=function(){return this.error().isVisible()?!1:!0},t.prototype.setReservationPrice=function(){if(this.price.reservationPrice){var n=this.parent.parent.parent.serviceReservation();n.setTrainAfterBikeReservation(this.id,this.price.reservationPrice,!1)}},t.prototype.serialize=function(t){var i=this.model;return t&&(i=$.extend({},this.model)),i.count=parseInt(this.parent.count()),i.price=0,this.parent.isLuggage()?(i.bikeServiceID=n.BikeService.none,i.bikeReservationID=n.BikeReservation.noReservation):(i.bikeServiceID=parseInt(this.bikeServiceID()),i.bikeReservationID=parseInt(this.bikeReservationID()),t||this.price.priceResult!=n.ReservationPriceResult.computed||(i.price=this.price.bikePrice.price)),i},t}(),i;n.LuggageAndBikeTrain=t;i=function(){function i(t){var i=this;(this.totalPrice=ko.observable(""),this.isLuggage=ko.observable(),this.luggageEnabled=ko.observable(),this.bikeEnabled=ko.observable(),this.count=ko.observable(),this.toTravel=ko.observable(),this.toTravelItems=ko.observableArray(),this.trainsThere=ko.observableArray(),this.trainsBack=ko.observableArray(),this.doneClicked=!1,this.formInitialized=!1,this.error=ko.observable(new ErrorInfo("LuggageAndBike")),this.isClientError=!1,this.isLuggageChange=function(){i.setCount(0);i.checkForm();i.startComputePrice()},this.toTravelChange=function(){i.startComputePriceLuggage()},this.countChange=function(){i.countChangeButton(0)},this.countChangeButton=function(n){i.setCount(n)&&i.startComputePrice()},this.setCount=function(n){var t=parseInt(i.count()),r;return(isNaN(t)&&(t=1),r=i.isLuggage()?i.model.maxLuggageCount:i.model.maxBikeCount,t=Support.checkValueInInterval(t+n,1,r),i.count(t.toString()),t.toString()==i.countLast)?!1:(i.countLast=i.count(),!0)},this.checkForm=function(){var r="",u,t;i.isLuggage()||(u=i.trainsThere().filter(function(n){return n.hasBikeService()}).length,t=i.trainsThere().filter(function(t){return parseInt(t.bikeServiceID())==n.BikeService.none&&t.hasBikeService()||parseInt(t.bikeServiceID())==n.BikeService.onlyReservation}).length,t!=0&&t!=u&&(r=App.messages.addServices.bikeServiceError),u=i.trainsBack().filter(function(n){return n.hasBikeService()}).length,t=i.trainsBack().filter(function(t){return parseInt(t.bikeServiceID())==n.BikeService.none&&t.hasBikeService()||parseInt(t.bikeServiceID())==n.BikeService.onlyReservation}).length,t!=0&&t!=u&&(r=App.messages.addServices.bikeServiceError));i.error().message(r);i.isClientError=r.length>0;r==""&&i.startComputePrice()},this.startComputePriceLuggage=function(){if(i.formInitialized){if(i.doneClicked=!1,i.isClientError){i.price.setInvalidPrice();return}var n=i.serialize(!0),t=i.parent.parent.model.guid;i.price.computePrice(n,t,!0)}},this.computePriceLuggage=function(){if(i.isClientError){i.price.setInvalidPrice();return}var n=i.serialize(!0),t=i.parent.parent.model.guid;i.price.computePrice(n,t,!1)},this.computePriceLuggageDone=function(){i.isClientError||i.error().message(i.price.price.error);i.doneClicked&&i.done()},this.startComputePrice=function(){i.formInitialized&&(i.startComputePriceLuggage(),i.getAllTrains().forEach(function(n){return n.startComputePrice()}))},this.computePrice=function(){i.price.priceResult==n.ReservationPriceResult.computing&&i.computePriceLuggage();var t=i.getAllTrains(),r=t.filter(function(t){return t.price.priceResult==n.ReservationPriceResult.computing});r.forEach(function(n){return n.computePrice()})},this.showPrice=function(){var t=i.getAllTrains(),o=t.filter(function(t){return t.price.priceResult==n.ReservationPriceResult.invalid}),u,f,e,r;if(i.isClientError||o.length>0){i.totalPrice("");return}if(u=t.filter(function(t){return t.price.priceResult==n.ReservationPriceResult.computing||t.price.priceResult==n.ReservationPriceResult.computingStart}),f=i.price.priceResult==n.ReservationPriceResult.computing||i.price.priceResult==n.ReservationPriceResult.computingStart,u.length>0||f){i.totalPrice("...");return}e=t.filter(function(t){return t.price.priceResult==n.ReservationPriceResult.computed});r=i.price.price.price;e.forEach(function(n){return r+=n.price.bikePrice.price});i.totalPrice(Support.formatMoneyFree(r,!0))},this.done=function(){if(i.checkErrors()&&(i.doneClicked=!0,i.checkComputedPrice())){i.trainsThere().forEach(function(n){return n.setReservationPrice()});i.trainsBack().forEach(function(n){return n.setReservationPrice()});var n=i.serialize(!1);i.setLuggageAndBike(n)}},this.setLuggageAndBike=function(n){var t=i;$.ajax({url:App.getUrlAction("SetServiceLuggage"),type:"POST",headers:App.GetAntiForgeryTokenHeader(),data:JSON.stringify(n),dataType:"json",contentType:"application/json; charset=utf-8",success:function(t){ErrorHandler.checkErrorsWithInfo(t,i)||(i.price.price=t,i.price.price.error=i.price.price.error||"",i.error().message(t.error),i.checkErrors()&&(i.error().message(""),n.partialTicketSection=t.partialTicketSection,n.serviceBikeLuggageDisabled=t.serviceBikeLuggageDisabled,i.parent.setData(n),$("#addServiceLuggageAndBikeModal").modal("hide")));i.showPrice()}})},this.parent=t,this.model=this.parent.model,this.model.visible)&&this.model.toTravelItems.forEach(function(n){var t={name:n.name,value:n.value};i.toTravelItems().push(t)})}return i.prototype.show=function(i,r){var f=this,u;this.formInitialized=!1;u=this.model;this.parent.parent.error().message("");this.price=new n.LuggagePriceComputation(this.showPrice,this.computePriceLuggageDone,u);this.count(u.count.toString());this.countLast=this.count();this.isLuggage(u.isLuggage);this.luggageEnabled(u.luggageEnabled);this.bikeEnabled(u.bikeEnabled);this.toTravel(u.toTravel);this.trainsThere.removeAll();u.trainsThere.map(function(n){return new t(n,f)}).forEach(function(n){return f.trainsThere.push(n)});this.trainsBack.removeAll();u.trainsBack.map(function(n){return new t(n,f)}).forEach(function(n){return f.trainsBack.push(n)});i&&u.bikeEnabled&&this.setDefaultBikeService();$("#addServiceLuggageAndBikeModal .cd-select").refreshNiceSelect();this.formInitialized=!0;(i||r)&&this.startComputePrice();this.error().message("");this.showPrice()},i.prototype.isEnabled=function(t){if(t.isLuggage)return!0;var i=[];return t.trainsThere.forEach(function(n){return i.push(n)}),t.trainsBack.forEach(function(n){return i.push(n)}),i.filter(function(t){return t.bikeServiceID!=n.BikeService.none}).length>0},i.prototype.setDefaultBikeService=function(){this.trainsThere().forEach(function(n){return n.setDefaultBikeServiceID()});this.trainsBack().forEach(function(n){return n.setDefaultBikeServiceID()})},i.prototype.incDecLuggageAndBike=function(n,t){t.which===38?this.countChangeButton(1):t.which===40&&this.countChangeButton(-1)},i.prototype.checkComputedPrice=function(){var i=!1,r,t;return(this.price.priceResult==n.ReservationPriceResult.computing&&(this.computePriceLuggage(),i=!0),r=this.getAllTrains(),t=r.filter(function(t){return t.price.priceResult==n.ReservationPriceResult.computing}),t.length>0&&(t.forEach(function(n){return n.computePrice()}),i=!0),i)?!1:(t=r.filter(function(t){return t.price.priceResult==n.ReservationPriceResult.computingStart}),t.length==0)},i.prototype.serialize=function(n){var t=this.model;return n&&(t=$.extend({},this.model)),t.isLuggage=this.isLuggage(),t.count=parseInt(this.count()),t.toTravel=this.toTravel(),t.price=this.price.price.price,t.trainsThere=this.trainsThere().map(function(t){return t.serialize(n)}),t.trainsBack=this.trainsBack().map(function(t){return t.serialize(n)}),t.enabled=this.isEnabled(t),t},i.prototype.checkErrors=function(){var n=!0;return this.error().isVisible()&&(n=!1),this.isLuggage()||this.getAllTrains().forEach(function(t){t.checkErrors()||(n=!1)}),n},i.prototype.getAllTrains=function(){var n=[];return this.trainsThere().forEach(function(t){return n.push(t)}),this.trainsBack().forEach(function(t){return n.push(t)}),n},i}();n.LuggageAndBikeModal=i}(AddServices||(AddServices={})),function(n){var t,i,r,u;(function(n){n[n.none=0]="none";n[n.onlyReservation=48]="onlyReservation";n[n.luggageObligatory=256]="luggageObligatory";n[n.luggageOptional=128]="luggageOptional";n[n.luggageNoReservation=1]="luggageNoReservation";n[n.storageObligatory=1024]="storageObligatory";n[n.storageOptional=512]="storageOptional";n[n.storageNoReservation=2]="storageNoReservation"})(t=n.BikeService||(n.BikeService={})),function(n){n[n.noReservation=0]="noReservation";n[n.bikeAndPlace=1]="bikeAndPlace";n[n.onlyBike=2]="onlyBike"}(i=n.BikeReservation||(n.BikeReservation={}));r=function(){function i(i,r){var u=this;this.from=ko.observable("");this.to=ko.observable("");this.train=ko.observable("");this.error=ko.observable();this.canDelete=function(){return u.model.bikeServiceID==t.none||u.model.bikeServiceID==t.onlyReservation};this.computePrice=function(){var n=u.model,t=u.parent.parent.model.guid,i=u.parent.parent.servicePackages().enabled();u.price.computePrice(n,t,i,!1)};this.computePriceDone=function(n){if(u.price.bikePrice&&(u.error().message(u.price.bikePrice.error),n&&(u.model.price=u.price.bikePrice.price)),u.price.reservationPrice){var t=u.parent.parent.serviceReservation();t.setTrainAfterBikeReservation(u.model.id,u.price.reservationPrice,!0)}};this.model=i;this.parent=r;this.model.count=this.parent.model.count;this.from(i.from);this.to(i.to);this.train(i.train);this.vehicleIcon=Support.getVehicleIcon(i.trainTypeID,!0);this.error(new ErrorInfo("ServiceLuggageAndBikeTrain"+i.id));this.price=new n.BikePriceComputation(this.parent.parent,this.parent.showPrice,this.computePriceDone,i)}return Object.defineProperty(i.prototype,"serviceInfo",{get:function(){var n=this;return this.model.bikeServices.filter(function(t){return parseInt(t.value)==n.model.bikeServiceID})[0].name},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"reservationInfo",{get:function(){var n=this;return this.model.bikeReservations.filter(function(t){return parseInt(t.value)==n.model.bikeReservationID})[0].name},enumerable:!0,configurable:!0}),i.prototype.canSubmit=function(){return!this.error().isVisible()&&(this.price.priceResult==n.ReservationPriceResult.computed||this.price.priceResult==n.ReservationPriceResult.noReservation)},i}();u=function(){function u(r,u){var f=this;this.totalPrice=ko.observable();this.info=ko.observable("");this.visible=ko.observable(!1);this.enabled=ko.observable(!1);this.trains=ko.observableArray();this.isLuggage=ko.observable(!1);this.error=ko.observable(new ErrorInfo("ServiceLuggageAndBike"));this.setData=function(n){f.isLuggage(n.isLuggage);f.enabled(n.enabled);f.setInfo(n);f.setTrains(n);n.enabled&&n.serviceBikeLuggageDisabled&&f.parent.serviceReservation().serviceBikeLuggageDisabledFlag(n.serviceBikeLuggageDisabled);f.checkReservation();f.showPrice()};this.computePriceLuggage=function(){var n=f.model,t=f.parent.model.guid;f.price.computePrice(n,t,!1)};this.computePriceLuggageDone=function(){f.error().message(f.price.price.error);f.model.price=f.price.price.price;f.myTicketUpdate()};this.showPrice=function(){var i,r,t;if(!f.enabled()){f.totalPrice("");f.myTicketUpdate();return}if(i=f.trains().filter(function(n){return n.error().isVisible()||n.model.price<0}),i.length>0){f.totalPrice("");f.myTicketUpdate();return}if(r=f.trains().filter(function(t){return t.price.priceResult==n.ReservationPriceResult.computingStart}),r.length>0){f.totalPrice("...");f.myTicketUpdate();return}t=f.model.price;f.trains().forEach(function(n){return t+=n.model.price});f.totalPrice(Support.formatMoneyFree(t,!0));f.myTicketUpdate()};this.add=function(){f.serviceLuggageAndBikeModal.show(!0,!f.canSubmit())};this.change=function(){var n=f.trains().filter(function(n){return n.error().isVisible()||n.model.price<0});n.length>0?f.serviceLuggageAndBikeModal.show(!0,!f.canSubmit()):f.serviceLuggageAndBikeModal.show(!1,!f.canSubmit())};this.deleteTrain=function(n){var u=f.trains().filter(function(t){return t.model.id==n.model.id}),r,e;u.length!=0&&(r=u[0].model,r.bikeServiceID=t.none,r.bikeReservationID=i.noReservation,r.count=f.model.maxBikeCount,r.price=0,f.trains.remove(u[0]),f.trains().length==0&&(f.model.count=f.model.maxBikeCount,f.model.price=0,f.model.enabled=!1),f.setData(f.model),e=f.parent.serviceReservation(),e.computeTrainPrice(r.id))};this.deleteAll=function(){f.clearLuggage(f.model)};this.clearLuggage=function(n){var t=f;$.ajax({url:App.getUrlAction("ClearServiceLuggage"),type:"POST",headers:App.GetAntiForgeryTokenHeader(),data:JSON.stringify(n),dataType:"json",contentType:"application/json; charset=utf-8",success:function(t){ErrorHandler.checkErrorsWithInfo(t,f)||(t.error?f.error().message(t.error):(f.parent.serviceReservation().serviceBikeLuggageDisabledFlag(!1),f.error().message(""),f.trains().slice().forEach(function(n){return f.deleteTrain(n)}),n.count=f.model.maxBikeCount,n.price=0,n.isLuggage=f.model.isLuggage&&!f.model.bikeEnabled,n.enabled=!1,f.setData(n)));f.showPrice()}})};this.model=r;this.parent=u;r.trainsThere||(r.trainsThere=[]);r.trainsBack||(r.trainsBack=[]);this.price=new n.LuggagePriceComputation(this.showPrice,this.computePriceLuggageDone,r);this.isBikeOrder=r.isBikeOrder;this.visible(r.visible);this.setData(r);this.serviceLuggageAndBikeModal=new n.LuggageAndBikeModal(this);ko.applyBindings(this.serviceLuggageAndBikeModal,document.getElementById("addServiceLuggageAndBikeModal"))}return u.prototype.checkReservation=function(){this.enabled()&&this.parent.serviceReservation().serviceBikeLuggageDisabled()?this.parent.serviceReservation().getAllTrains().some(function(n){return n.forSjtTicket})&&this.error().message(App.messages.addServices.errorDogSJT):this.error().message("")},u.prototype.setInfo=function(n){if(this.info(""),this.isLuggage()&&(this.enabled()||!this.isLuggage())){var t=n.count+"x "+App.messages.addServices.luggageInfo;n.partialTicketSection==null||Support.stringIsEmpty(n.partialTicketSection)||(t+="<br/>"+("("+n.partialTicketSection+")"));this.info(t)}},u.prototype.setTrains=function(){var n=this;(this.trains.removeAll(),this.isLuggage())||this.getAllTrains(!0).map(function(t){return new r(t,n)}).forEach(function(t){return n.trains.push(t)})},u.prototype.updateModel=function(n){n.enabled=this.enabled();n.count=this.model.count;n.isLuggage=this.model.isLuggage;n.toTravel=this.model.toTravel;n.price=this.model.price;n.trainsThere=this.model.trainsThere;n.trainsBack=this.model.trainsBack;n.priceId=this.model.priceId;n.partialTicketSection=this.model.partialTicketSection},u.prototype.getAllTrains=function(n){var i=[];return this.model.trainsThere.forEach(function(n){return i.push(n)}),this.model.trainsBack.forEach(function(n){return i.push(n)}),n&&(i=i.filter(function(n){return n.bikeServiceID!=t.none})),i},u.prototype.canSubmit=function(){return this.error().isVisible()?!1:this.trains().filter(function(n){return!n.canSubmit()}).length==0},u.prototype.getTrainForReservation=function(n){var r=this.getAllTrains(!0).filter(function(t){return t.id==n});return r.length>0?r[0]:{id:n,bikeServiceID:t.none,bikeReservationID:i.noReservation}},u.prototype.setTrainAfterReservation=function(n,t,i){var u=this.getAllTrains(!0).filter(function(t){return t.id==n}),r;u.length>0&&(u[0].price=t.price,this.showPrice());i&&(r=this.trains().filter(function(t){return t.model.id==n}),r.length>0&&r[0].error().message(t.error))},u.prototype.computeTrainPrice=function(n){var t=this.trains().filter(function(t){return t.model.id==n});t.length>0&&t[0].computePrice()},u.prototype.computePriceDefault=function(n){var t=this.trains().filter(function(t){return n.indexOf(t.model.id)==-1}).forEach(function(n){return n.computePrice()})},u.prototype.myTicketUpdate=function(){var i=this.trains().filter(function(n){return n.error().isVisible()||n.model.price<0}),n,t;if(i.length>0){this.parent.myTicketUpdate(MyTicketType.LuggageAndBike,App.messages.addServices.luggageAndBikes,0,0);return}n=this.model.price;this.trains().forEach(function(t){return n+=t.model.price});t=this.totalPrice()=="..."||!this.model.enabled?0:this.trains().length>0?this.trains().length:this.model.isLuggage?1:0;this.parent.myTicketUpdate(MyTicketType.LuggageAndBike,App.messages.addServices.luggageAndBikes,t,n)},u}();n.ServiceLuggageAndBike=u}(AddServices||(AddServices={})),function(n){var t=function(){function n(n){var t=this,i;this.count=ko.observable();this.toTravel=ko.observable();this.toTravelItems=ko.observableArray();this.totalPrice=ko.observable();this.hideTotalPrice=ko.observable();this.priceComputing=!1;this.countChangeTimeout=500;this.countChangeTimeoutObj=null;this.error=ko.observable(new ErrorInfo("ServiceDog"));this.toTravelChange=function(){t.toTravelLast!=t.toTravel()&&(t.toTravelLast=t.toTravel(),t.computePrice())};this.countChange=function(){t.countChangeButton(0)};this.countChangeButton=function(n){t.setCount(n)&&(t.countChangeTimeoutObj&&clearTimeout(t.countChangeTimeoutObj),t.hideTotalPrice(!0),t.priceComputing=!0,t.countChangeTimeoutObj=setTimeout(function(){t.computePrice()},t.countChangeTimeout))};this.setCount=function(n){var i=parseInt(t.count());return(isNaN(i)&&(i=1),i=Support.checkValueInInterval(i+n,1,t.parent.model.maxCount),t.count(i.toString()),i.toString()==t.countLast)?!1:(t.countLast=t.count(),!0)};this.computePrice=function(n){n===void 0&&(n=!0);t.priceComputing=!0;var i=t;$.ajax({url:App.getUrlAction("ServiceDogComputePrice")+"?count="+t.count()+"&toTravel="+t.toTravel(),type:"GET",success:function(n){ErrorHandler.checkErrorsWithInfo(n,t)||(t.error().message(""),t.totalPriceValue=n.totalPrice,t.totalPrice(Support.formatMoney(n.totalPrice,!0)));t.priceComputing=!1;t.hideTotalPrice(!1)}})};this.setDogs=function(){t.priceComputing=!0;var n=t;$.ajax({url:App.getUrlAction("SetServiceDog")+"?count="+t.count()+"&toTravel="+t.toTravel(),type:"GET",success:function(n){if(!ErrorHandler.checkErrorsWithInfo(n,t)){t.error().message("");t.hideTotalPrice(!1);var i=t.parent.model;i.count=t.count();i.toTravel=t.toTravel();i.totalPrice=t.totalPriceValue;i.enabled=!0;i.serviceDogDisabled=n.serviceDogDisabled;i.partialTicketSection=n.partialTicketSection;t.parent.setData(i);$("#addServiceDogModal").modal("hide")}t.priceComputing=!1}})};this.done=function(){t.priceComputing||t.error().isVisible()||t.setDogs()};this.parent=n;i=this.parent.model;i.toTravelItems&&i.toTravelItems.forEach(function(n){var i={name:n.name,value:n.value};t.toTravelItems().push(i)})}return n.prototype.show=function(n){var t=this.parent.model;this.parent.parent.error().message("");this.count(t.count);this.countLast=this.count();this.toTravelLast=t.toTravel;this.toTravel(t.toTravel);n?(this.error().message(""),this.computePrice(!1)):(this.totalPriceValue=t.totalPrice,this.totalPrice(Support.formatMoneyFree(t.totalPrice,!0)));$("#addServiceDogModal .cd-select").refreshNiceSelect()},n.prototype.incDecDog=function(n,t){t.which===38?this.countChangeButton(1):t.which===40&&this.countChangeButton(-1)},n}(),i;n.DogModal=t;i=function(){function n(n,i){var r=this;this.info=ko.observable("");this.visible=ko.observable(!1);this.enabled=ko.observable(!1);this.totalPrice=ko.observable();this.error=ko.observable(new ErrorInfo("ServiceDog"));this.setData=function(n){r.enabled(n.enabled);r.totalPrice(Support.formatMoney(n.totalPrice,!0));r.setInfo(n);n.enabled&&n.serviceDogDisabled&&r.parent.serviceReservation().serviceDogDisabledFlag(n.serviceDogDisabled);r.checkReservationCompartments();r.myTicketUpdate()};this.add=function(){r.serviceDogModal.show(!0)};this.change=function(){r.serviceDogModal.show(!1)};this.cancel=function(){r.clearData()};this.clearData=function(){var n=r;$.ajax({url:""+App.getUrlAction("ClearServiceDog"),type:"GET",success:function(n){ErrorHandler.checkErrorsWithInfo(n,r)||(r.parent.serviceReservation().serviceDogDisabledFlag(!1),r.error().message(""),r.model.count="1",r.model.toTravel=r.model.toTravelItems[0].value,r.model.enabled=!1,r.setData(r.model))}})};this.model=n;this.parent=i;this.visible(n.visible);this.setData(n);this.serviceDogModal=new t(this);ko.applyBindings(this.serviceDogModal,document.getElementById("addServiceDogModal"))}return n.prototype.setInfo=function(n){if(n.visible){var i=n.toTravelItems.filter(function(t){return t.value==n.toTravel})[0].name,t=n.count+"x "+App.messages.addServices.dogTransfer+" "+i;n.partialTicketSection==null||Support.stringIsEmpty(n.partialTicketSection)||(t+="<br/>"+("("+n.partialTicketSection+")"));this.info(t)}},n.prototype.updateModel=function(n){n.priceId=this.model.priceId;n.maxCount=this.model.maxCount;n.count=this.model.count;n.toTravel=this.model.toTravel;n.totalPrice=this.model.totalPrice;n.partialTicketSection=this.model.partialTicketSection;n.enabled=this.enabled()},n.prototype.checkReservationCompartments=function(){this.enabled()&&this.parent.serviceReservation().serviceDogDisabled()?this.parent.serviceReservation().getAllTrains().some(function(n){return n.forSjtTicket})?this.error().message(App.messages.addServices.errorDogSJT):this.error().message(App.messages.addServices.errorDogCompartment):this.error().message("")},n.prototype.canSubmit=function(){return!this.error().isVisible()},n.prototype.myTicketUpdate=function(){this.parent.myTicketUpdate(MyTicketType.Dog,App.messages.addServices.dogs,this.model.enabled?parseInt(this.model.count):0,this.model.totalPrice)},n}();n.ServiceDog=i}(AddServices||(AddServices={})),function(n){var t=function(){function n(n){this.time=ko.observable("");this.checked=ko.observable();this.from=ko.observable("");this.to=ko.observable("");this.train=ko.observable("");this.id=n.id;this.time(n.time.toString());this.checked(n.checked);this.from(n.from);this.to(n.to);this.train(n.train);this.vehicleIcon=Support.getVehicleIcon(n.trainTypeID,!0);this.trainTypeID=n.trainTypeID}return n.prototype.serialize=function(){var n={};return n.id=this.id,n.time=parseInt(this.time()),n.checked=this.checked(),n.from=this.from(),n.to=this.to(),n.train=this.train(),n.trainTypeID=this.trainTypeID,n},n}(),i,r;n.SMSTrain=t;i=function(){function n(n){var t=this,i;this.mobileNumber=ko.observable("");this.noDelayData=ko.observable();this.timeItems=ko.observableArray();this.trainsThere=ko.observableArray();this.trainsBack=ko.observableArray();this.done=function(){if(t.checkErrors()){var n=t.parent.model;n.mobileNumber=Support.formatPhoneNumber(t.mobileNumber());n.trainsThere=t.trainsThere().map(function(n){return n.serialize()});n.trainsBack=t.trainsBack().map(function(n){return n.serialize()});t.parent.setData(n);$("#addServiceSMSInfoModal").modal("hide")}};this.parent=n;i=this.parent.model;this.noDelayData(i.noDelayData);i.timeItems.forEach(function(n){var i={name:n.name,value:n.value};t.timeItems().push(i)});this.setValidation();this.errors=ko.validation.group(this)}return n.prototype.setValidation=function(){var n=this;this.mobileNumber.extend({canValidate:!1,required:{onlyIf:function(){return n.mobileNumber.canValidate()},message:App.messages.validation.requiredItem},validation:[{onlyIf:function(){return n.mobileNumber.canValidate()},validator:function(n){return ValidationHelper.isPhoneNumber(n)},message:App.messages.validation.errorPhone},{onlyIf:function(){return n.mobileNumber.canValidate()},validator:function(n){return ValidationHelper.isCZMobileNumber(n)},message:App.messages.validation.errorCZMobileNumber}]})},n.prototype.setCanValidate=function(n){this.mobileNumber.canValidate(n)},n.prototype.checkErrors=function(){return(this.setCanValidate(!0),this.errors().length>0)?(this.errors.showAllMessages(),!1):!0},n.prototype.show=function(n){var r=this,i=this.parent.model;this.parent.parent.error().message("");n&&this.setCanValidate(!1);Support.stringIsEmpty(i.mobileNumber)?this.mobileNumber("+420 "):this.mobileNumber(i.mobileNumber);this.trainsThere.removeAll();i.trainsThere.map(function(n){return new t(n)}).forEach(function(t){n&&t.checked(!0);r.trainsThere.push(t)});this.trainsBack.removeAll();i.trainsBack.map(function(n){return new t(n)}).forEach(function(t){n&&t.checked(!0);r.trainsBack.push(t)});$("#addServiceSMSInfoModal .cd-select").refreshNiceSelect()},n}();r=function(){function n(n,t){var r=this;this.mobileNumber=ko.observable("");this.visible=ko.observable(!1);this.enabled=ko.observable(!1);this.trains=ko.observableArray();this.setData=function(n){r.mobileNumber(n.mobileNumber);r.setTrains(n);r.setEnabled();r.myTicketUpdate()};this.setEnabled=function(){var n=r.getAllTrains().filter(function(n){return n.checked});r.enabled(n.length>0)};this.add=function(){r.serviceSMSInfoModal.show(!0)};this.change=function(){r.serviceSMSInfoModal.show(!1)};this.deleteTrain=function(n){var t=r.getAllTrains().filter(function(t){return t.id==n.id})[0];t.checked=!1;t.time=parseInt(r.model.timeItems[0].value);r.setEnabled();r.enabled()||(r.model.mobileNumber="");r.setData(r.model)};this.deleteAll=function(){r.trains().slice().forEach(function(n){return r.deleteTrain(n)})};this.model=n;this.parent=t;n.trainsThere||(n.trainsThere=[]);n.trainsBack||(n.trainsBack=[]);n.mobileNumber=Support.formatPhoneNumber(n.mobileNumber);this.visible(n.visible);this.setData(n);this.model.totalPrice=0;this.totalPrice=Support.formatMoney(this.model.totalPrice,!0);this.serviceSMSInfoModal=new i(this);ko.applyBindings(this.serviceSMSInfoModal,document.getElementById("addServiceSMSInfoModal"))}return n.prototype.setTrains=function(n){var i=this;this.trains.removeAll();n.trainsThere.filter(function(n){return n.checked}).map(function(n){return new t(n)}).forEach(function(n){return i.trains.push(n)});n.trainsBack.filter(function(n){return n.checked}).map(function(n){return new t(n)}).forEach(function(n){return i.trains.push(n)})},n.prototype.updateModel=function(n){n.mobileNumber=this.model.mobileNumber;n.trainsThere=this.model.trainsThere;n.trainsBack=this.model.trainsBack},n.prototype.getAllTrains=function(){var n=[];return this.model.trainsThere.forEach(function(t){return n.push(t)}),this.model.trainsBack.forEach(function(t){return n.push(t)}),n},n.prototype.myTicketUpdate=function(){this.parent.myTicketUpdate(MyTicketType.Sms,App.messages.addServices.smsInfo,this.trains().length,this.model.totalPrice)},n}();n.ServiceSMSInfo=r}(AddServices||(AddServices={})),function(n){var t=function(){function n(n){var t=this,i;this.carRegistration=ko.observable("");this.interval=ko.observable();this.intervalItems=ko.observableArray();this.totalPrice=ko.observable();this.conditionsAgreement=ko.observable(!1);this.daysChange=function(){t.computePrice()};this.computePrice=function(){var n=t.parent.model,i=0,r=n.intervalItems.filter(function(n){return n.value==t.interval()});r!=undefined&&(i=n.intervalItems.indexOf(r[0]));t.totalPriceValue=n.priceItems[i];t.totalPrice(Support.formatMoneyFree(t.totalPriceValue,!0))};this.done=function(){if(t.checkErrors()){var n=t.parent.model;n.carRegistration=t.carRegistration();n.interval=t.interval();n.totalPrice=t.totalPriceValue;n.enabled=!0;t.parent.error().message("");t.parent.setData(n);$("#addServiceParkingModal").modal("hide")}};this.parent=n;i=this.parent.model;this.parent.parent.error().message("");this.stationName=i.stationName;this.validFrom=DateTimeHelper.formatDateBase(DateTimeHelper.parseDate(i.validFrom));i.intervalItems&&i.intervalItems.forEach(function(n){var i={name:n.name,value:n.value};t.intervalItems().push(i)});this.setValidation();this.errors=ko.validation.group(this)}return n.prototype.setValidation=function(){var n=this;this.carRegistration.extend({canValidate:!1,required:{onlyIf:function(){return n.carRegistration.canValidate()},message:App.messages.validation.requiredItem},validation:{onlyIf:function(){return n.carRegistration.canValidate()},validator:function(n){return ValidationHelper.isValidInput(n,"")},message:App.messages.validation.errorInvalidChars}});this.conditionsAgreement.extend({canValidate:!1,equal:{onlyIf:function(){return n.conditionsAgreement.canValidate()},params:!0,message:App.messages.addServices.parkingConfirmError}})},n.prototype.setCanValidate=function(n){this.carRegistration.canValidate(n);this.conditionsAgreement.canValidate(n)},n.prototype.checkErrors=function(){return(this.setCanValidate(!0),this.errors().length>0)?(this.errors.showAllMessages(),!1):!0},n.prototype.show=function(n){var t=this.parent.model;this.carRegistration(t.carRegistration);this.interval(t.interval.toString());n?(this.setCanValidate(!1),this.computePrice(),this.conditionsAgreement(!1)):(this.totalPriceValue=t.totalPrice,this.totalPrice(Support.formatMoneyFree(t.totalPrice,!0)),this.conditionsAgreement(!0));$("#addServiceParkingModal .cd-select").refreshNiceSelect()},n}(),i;n.ParkingModal=t;i=function(){function n(n,i){var r=this;this.info=ko.observable("");this.visible=ko.observable(!1);this.enabled=ko.observable(!1);this.totalPrice=ko.observable();this.error=ko.observable(new ErrorInfo("ServiceParking"));this.setData=function(n){r.enabled(n.enabled);r.totalPrice(Support.formatMoneyFree(n.totalPrice,!0));r.setInfo(n);r.myTicketUpdate()};this.add=function(){r.serviceParkingModal.show(!0)};this.change=function(){r.serviceParkingModal.show(!1)};this.cancel=function(){r.model.carRegistration="";r.model.interval=r.model.intervalItems[0].value;r.model.enabled=!1;r.error().message("");r.setData(r.model)};this.model=n;this.parent=i;this.visible(n.visible);this.setData(n);this.serviceParkingModal=new t(this);ko.applyBindings(this.serviceParkingModal,document.getElementById("addServiceParkingModal"))}return n.prototype.setInfo=function(n){var t,i;n.visible&&(n.interval.endsWith("m")||n.interval.endsWith("H")?(t=DateTimeHelper.parseDateTime(n.validFrom),i=moment(DateTimeHelper.addInterval(t,n.interval)).toDate(),this.info(App.messages.addServices.parkingInfo.format(n.carRegistration,DateTimeHelper.toJSDateTime(t),DateTimeHelper.toJSDateTime(i),n.stationName))):(t=DateTimeHelper.parseDate(n.validFrom),i=moment(DateTimeHelper.addInterval(t,n.interval)).toDate(),this.info(App.messages.addServices.parkingInfo.format(n.carRegistration,DateTimeHelper.formatDateBase(t),DateTimeHelper.formatDateBase(i),n.stationName))))},n.prototype.updateModel=function(n){n.interval=this.model.interval;n.carRegistration=this.model.carRegistration;n.totalPrice=this.model.totalPrice;n.enabled=this.enabled()},n.prototype.checkErrors=function(){return!this.error().isVisible()},n.prototype.myTicketUpdate=function(){this.parent.myTicketUpdate(MyTicketType.Parking,App.messages.addServices.parkingVoucher,this.model.enabled?1:0,this.model.totalPrice)},n}();n.ServiceParking=i}(AddServices||(AddServices={})),function(n){var f,t,i,r,u;(function(n){n[n.none=0]="none";n[n.jasna=1]="jasna";n[n.tatry=2]="tatry";n[n.tatrySummer=3]="tatrySummer";n[n.TEZ=4]="TEZ"})(f=n.PackageMode||(n.PackageMode={}));t=function(){function n(n,t,i){var r=this,u;this.count=ko.observable();this.services=ko.observableArray();this.serviceID=ko.observable();this.serviceChange=function(){r.parent.computePrice()};this.countChange=function(){r.countChangeButton(0)};this.countChangeButton=function(n){r.setCount(n)&&(r.parent.computePrice(),r.parent.setCanAddService())};this.setCount=function(n){var t=parseInt(r.count());return(isNaN(t)&&(t=1),t=Support.checkValueInInterval(t+n,1,r.parent.getMaxPassengersCount(r.id)),r.count(t.toString()),t.toString()==r.countLast)?!1:(r.countLast=r.count(),!0)};this.parent=n;this.items=t;this.parent.lastServiceID+=1;this.id=this.parent.lastServiceID;i||(i={itemID:0,count:1});this.count(i.count.toString());this.countLast=this.count();this.serviceID(i.itemID.toString());u={name:App.messages.addServices.selectService,value:"0"};this.services.push(u);t.forEach(function(n){var t={name:n.name,value:n.id.toString()};r.services.push(t)})}return n.prototype.checked=function(){var n=parseInt(this.serviceID());return n!=0},n.prototype.serialize=function(){var t=parseInt(this.serviceID()),i,n;return t==0?null:(i=this.items.filter(function(n){return n.id==t})[0],n={},n.itemID=i.id,n.count=parseInt(this.count()),n)},n}();n.PackageService=t;i=function(){function n(n){var i=this;this.lastServiceID=0;this.totalPrice=ko.observable("");this.services=ko.observableArray();this.canAddService=ko.observable(!0);this.priceComputing=!1;this.error=ko.observable(new ErrorInfo("ServicePackages"));this.isClientError=!1;this.showClientError=!1;this.getMaxPassengersCount=function(n){var t=0;return i.services().filter(function(t){return t.id!=n}).forEach(function(n){return t+=parseInt(n.count())}),i.model.passengersCount-t};this.addService=function(){var n=new t(i,i.model.items);i.services.push(n);$("#addServicePackagesModal .cd-select").refreshNiceSelect();i.computePrice();i.setCanAddService()};this.deleteService=function(n){i.services.remove(n);i.computePrice();i.setCanAddService()};this.checkForm=function(){var n="",t=0;i.services().filter(function(n){return n.checked()}).forEach(function(n){return t+=parseInt(n.count())});t!=i.model.passengersCount&&(n=App.messages.addServices.packagesInvalidCount);i.showClientError&&i.error().message(n);i.isClientError=n.length>0};this.computePrice=function(){var n={guid:i.parent.parent.model.guid,model:i.serialize(!0)};if(i.checkForm(),i.isClientError||n.model.services.length==0){i.totalPriceValue=0;i.showPrice();return}i.priceComputing=!0;$.ajax({url:App.getUrlAction("ServicePackagesComputePrice"),type:"POST",headers:App.GetAntiForgeryTokenHeader(),data:JSON.stringify(n),dataType:"json",contentType:"application/json; charset=utf-8",success:function(n){if(!ErrorHandler.checkErrorsWithInfo(n,i)){i.error().message("");var t=n;i.totalPriceValue=t.totalPrice}i.showPrice();i.priceComputing=!1}})};this.setPackages=function(n){i.priceComputing=!0;$.ajax({url:App.getUrlAction("SetServicePackages"),type:"POST",headers:App.GetAntiForgeryTokenHeader(),data:JSON.stringify(n),dataType:"json",contentType:"application/json; charset=utf-8",success:function(n){if(!ErrorHandler.checkErrorsWithInfo(n,i)){i.error().message("");var t=i.serialize(!1);i.parent.setData(t);$("#addServicePackagesModal").modal("hide");i.parent.parent.serviceReservation().computePrice()}i.priceComputing=!1}})};this.done=function(){if(i.showClientError=!0,i.checkForm(),!i.priceComputing&&!i.error().isVisible()){var n=i.serialize(!1);i.setPackages(n)}};this.parent=n;this.model=this.parent.model;!this.model.visible}return Object.defineProperty(n.prototype,"enabled",{get:function(){return this.services().filter(function(n){return parseInt(n.serviceID())!=0}).length>0},enumerable:!0,configurable:!0}),n.prototype.show=function(n){var i=this,r=this.parent.model;this.parent.parent.error().message("");this.services.removeAll();n?(this.error().message(""),this.showClientError=!1,this.addService()):(this.model.services.forEach(function(n){var r=new t(i,i.model.items,n);i.services.push(r)}),this.totalPriceValue=r.totalPrice);this.setCanAddService();this.showPrice();$("#addServicePackagesModal .cd-select").refreshNiceSelect()},n.prototype.showPrice=function(){if(!this.enabled||this.error().isVisible()||this.isClientError){this.totalPrice("");return}this.totalPrice(Support.formatMoneyFree(this.totalPriceValue,!0))},n.prototype.setCanAddService=function(){this.canAddService(this.getMaxPassengersCount(-1)>0)},n.prototype.serialize=function(n){var t=this.model;return n&&(t={}),t.priceId=this.model.priceId,t.services=this.services().filter(function(n){return n.checked()}).map(function(n){return n.serialize()}),n||(t.totalPrice=this.totalPriceValue),t},n}();n.PackagesModal=i;r=function(){function n(n,t){this.service=t;var i=n.filter(function(n){return n.id==t.itemID})[0];this.icon=i.iconId==1?"ico-skypass.svg":"ico-summer-pack.svg";this.name=i.name;this.count=t.count}return n}();n.PackageServiceInfo=r;u=function(){function n(n,t){var u=this;this.visible=ko.observable(!1);this.enabled=ko.observable(!1);this.totalPrice=ko.observable();this.services=ko.observableArray();this.priceComputing=!1;this.error=ko.observable(new ErrorInfo("ServicePackages"));this.setData=function(n){u.services.removeAll();n.services.forEach(function(n){u.services.push(new r(u.model.items,n))});u.setEnabled(n);u.setPrice();u.myTicketUpdate()};this.setEnabled=function(n){u.enabled(n.services.length>0)};this.add=function(){u.servicePackagesModal.show(!0)};this.change=function(){u.servicePackagesModal.show(!1)};this.deleteService=function(n){var t=u.model.services.indexOf(n.service);u.model.services.splice(t,1);u.setData(u.model);u.enabled()?u.computePrice():u.parent.serviceReservation().computePrice()};this.deleteAll=function(){u.clearData(u.model)};this.clearData=function(n){$.ajax({url:App.getUrlAction("ClearServicePackages"),type:"POST",headers:App.GetAntiForgeryTokenHeader(),data:JSON.stringify(n),dataType:"json",contentType:"application/json; charset=utf-8",success:function(n){ErrorHandler.checkErrorsWithInfo(n,u)||(u.parent.serviceReservation().serviceDogDisabledFlag(!1),u.parent.serviceReservation().serviceBikeLuggageDisabledFlag(!1),u.error().message(""),u.model.services=[],u.setData(u.model),u.parent.serviceReservation().computePrice())}})};this.computePrice=function(){u.priceComputing=!0;u.setPrice();var n={guid:u.parent.model.guid,model:u.model};$.ajax({url:App.getUrlAction("ServicePackagesComputePrice"),type:"POST",headers:App.GetAntiForgeryTokenHeader(),data:JSON.stringify(n),dataType:"json",contentType:"application/json; charset=utf-8",success:function(n){if(!ErrorHandler.checkErrorsWithInfo(n,u)){var t=n;u.model.totalPrice=t.totalPrice;u.priceComputing=!1;u.setPrice()}}})};n.services||(n.services=[]);this.model=n;this.parent=t;this.visible(n.visible);n.visible&&this.setData(n);this.servicePackagesModal=new i(this);ko.applyBindings(this.servicePackagesModal,document.getElementById("addServicePackagesModal"))}return n.prototype.setPrice=function(){if(!this.enabled()||this.priceComputing){this.totalPrice("");return}this.totalPrice(Support.formatMoney(this.model.totalPrice,!0))},n.prototype.updateModel=function(n){n.priceId=this.model.priceId;n.services=this.model.services;n.totalPrice=this.model.totalPrice},n.prototype.canSubmit=function(){return this.priceComputing?!1:!this.error().isVisible()},n.prototype.myTicketUpdate=function(){this.parent.myTicketUpdate(MyTicketType.Packages,App.messages.addServices.packages,this.model.services.length,this.model.totalPrice)},n}();n.ServicePackages=u}(AddServices||(AddServices={})),function(n){var i=function(){function i(i,r){var u=this,f,e;this.serviceReservation=ko.observable();this.serviceLuggageAndBike=ko.observable();this.serviceDog=ko.observable();this.serviceSMSInfo=ko.observable();this.serviceParking=ko.observable();this.servicePackages=ko.observable();this.serviceAutoTrain=ko.observable();this.serviceCatering=ko.observable();this.doneTimeout=null;this.doneTimeoutShow=2e3;this.error=ko.observable(new ErrorInfo("addServices"));this.done=function(){if(u.serviceReservation().canSubmit()&&u.serviceLuggageAndBike().canSubmit()&&u.serviceDog().canSubmit()&&u.servicePackages().canSubmit()&&u.serviceParking().checkErrors()&&u.serviceCatering().checkErrors()&&u.checkOnlyReservation()){var n=u.warningObligatoryTrains();Support.stringIsEmpty(n)?u.doneCore():(u.addServicesInfoModal.buttonMainTitle(App.messages.app.yes),u.addServicesInfoModal.buttonAux1Title(App.messages.app.cancel),u.addServicesInfoModal.content(App.messages.addServices.minCountForObligatory.format(n)),u.addServicesInfoModal.isInfoModal(!1),$("#AddServicesInfoModal").modal("show"))}};f=history.state;f!=undefined&&f.onlyReservation==i.onlyReservation&&(i=f);this.model=i;this.serviceReservation(new n.ServiceReservation(i.serviceReservation,this));this.serviceLuggageAndBike(new n.ServiceLuggageAndBike(i.serviceLuggageAndBike,this));this.serviceDog(new n.ServiceDog(i.serviceDog,this));this.serviceSMSInfo(new n.ServiceSMSInfo(i.serviceSMSInfo,this));this.serviceParking(new n.ServiceParking(i.serviceParking,this));this.servicePackages(new n.ServicePackages(i.servicePackages,this));this.serviceAutoTrain(new n.AutoTrainSpecificationJS(i.autoTrain,r,!0,i.guid,this));this.serviceCatering(new n.ServiceCatering(i.serviceCatering,this));this.myTicket=new MyTicket(r);this.addServicesInfoModal=new t(this);this.serviceReservation().enabled()&&this.serviceReservation().computePriceDefault();this.serviceReservation().visible()&&(this.model.onlyReservation&&this.model.isBuyOnlyReservation&&!this.serviceLuggageAndBike().enabled()&&!this.serviceLuggageAndBike().isBikeOrder&&(!this.serviceReservation().enabled()||this.serviceReservation().enabled()&&!this.serviceReservation().canDeleteAll())||this.model.mustReservePossible)&&(this.serviceReservation().add(),$("#addServiceReservationModal").modal("show"));this.serviceLuggageAndBike().enabled()&&(e=this.serviceReservation().trains().map(function(n){return n.model.id}),this.serviceLuggageAndBike().computePriceDefault(e),this.serviceLuggageAndBike().computePriceLuggage());this.model.onlyReservation&&this.serviceLuggageAndBike().isBikeOrder&&(this.serviceLuggageAndBike().add(),$("#addServiceLuggageAndBikeModal").modal("show"));i.errors&&ErrorHandler.checkErrorsWithInfo(i.errors,this);ko.applyBindings(this,document.getElementById("main"));ko.applyBindings(this.addServicesInfoModal,document.getElementById("AddServicesInfoModal"));this.subscribeOnlyReservation();this.myTicketUpdateAll()}return i.prototype.doneCore=function(){var n=this,t,i;this.doneTimeout&&clearTimeout(this.doneTimeout);this.doneTimeout=setTimeout(function(){AjaxHelper.AjaxWaitShow(App.messages.ticketRefund.loaderProcessing)},this.doneTimeoutShow);t=this.createEmptyModel();this.updateModel(t);i=App.getUrlAction("doplnkove-sluzby")+this.model.guid;$.post(i,{__RequestVerificationToken:App.GetAntiForgeryToken(),model:t},function(t){if(ErrorHandler.checkErrorsWithInfo(t,n)){n.doneTimeout&&clearTimeout(n.doneTimeout);AjaxHelper.AjaxWaitHide();return}var i=$.extend({},n.model);n.updateModel(i);history.pushState(i,null,"#pokracuj");window.location.href=App.getUrlAction("identifikace-cestujiciho")+n.model.guid})},i.prototype.warningObligatoryTrains=function(){var n=[],t=this;return this.serviceReservation().getAllTrains().forEach(function(i){t.showWarning(i)&&n.push(i.train)}),n.join(", ")},i.prototype.showWarning=function(t){return t.minCountForObligatory>0&&(t.reservationTypeID==n.ReservationType.none||t.minCountForObligatory>t.passengersCount)},i.prototype.myTicketUpdate=function(n,t,i,r){var e,u,f;this.myTicket&&this.myTicket.tickets()&&(n!=MyTicketType.TicketAndReservation&&(e=this.myTicket.tickets().filter(function(t){return t.type==n}),e.length==0&&i>0?this.myTicket.addTicket({ticket:t,count:i,type:n}):e.length==1&&(u=e[0],i>0?this.myTicket.updateTicket(u,{count:i,ticket:u.ticket,type:u.type}):this.myTicket.removeTicket(u))),f=ko.utils.arrayFirst(this.myTicket.ticketSums(),function(t){return t.type==n}),f?i>0||n==MyTicketType.TicketAndReservation?this.myTicket.updateTicketSumPrice(f,{price:r,count:i,type:f.type}):this.myTicket.removeTicketSumPrice(f):(i>0||n==MyTicketType.TicketAndReservation)&&this.myTicket.addTicketSumPrice({price:r,count:i,type:n}))},i.prototype.myTicketUpdateAll=function(){this.serviceReservation().enabled()&&this.serviceReservation().myTicketUpdate();this.serviceDog().enabled()&&this.serviceDog().myTicketUpdate();this.serviceLuggageAndBike().enabled()&&this.serviceLuggageAndBike().myTicketUpdate();this.serviceParking().enabled()&&this.serviceParking().myTicketUpdate();this.servicePackages().enabled()&&this.servicePackages().myTicketUpdate();this.serviceSMSInfo().enabled()&&this.serviceSMSInfo().myTicketUpdate();this.serviceAutoTrain().enabled()&&this.serviceAutoTrain().myTicketUpdate();this.serviceCatering().visible()&&this.serviceCatering().myTicketUpdate()},i.prototype.createEmptyModel=function(){return{guid:this.model.guid,serviceReservation:{},serviceLuggageAndBike:{},serviceDog:{},serviceSMSInfo:{},serviceParking:{},servicePackages:{},autoTrain:this.model.autoTrain,serviceCatering:{},sjt:this.model.sjt}},i.prototype.updateModel=function(n){this.serviceReservation().updateModel(n.serviceReservation);this.serviceLuggageAndBike().updateModel(n.serviceLuggageAndBike);this.serviceDog().updateModel(n.serviceDog);this.serviceSMSInfo().updateModel(n.serviceSMSInfo);this.serviceParking().updateModel(n.serviceParking);this.servicePackages().updateModel(n.servicePackages);this.serviceAutoTrain().updateModel(n.autoTrain);this.serviceCatering().updateModel(n.serviceCatering)},i.prototype.subscribeOnlyReservation=function(){var n=this;this.serviceReservation().enabled.subscribe(function(){n.checkOnlyReservation()});this.serviceLuggageAndBike().enabled.subscribe(function(){n.checkOnlyReservation()});this.serviceDog().enabled.subscribe(function(){n.checkOnlyReservation()});this.serviceParking().enabled.subscribe(function(){n.checkOnlyReservation()});this.servicePackages().enabled.subscribe(function(){n.checkOnlyReservation()});this.serviceAutoTrain().enabled.subscribe(function(){n.checkOnlyReservation()})},i.prototype.checkOnlyReservation=function(){return this.model.onlyReservation?this.serviceReservation().enabled()||this.serviceLuggageAndBike().enabled()||this.serviceDog().enabled()||this.serviceParking().enabled()||this.servicePackages().enabled()||this.serviceAutoTrain().enabled()?(this.error().message(""),!0):(this.doneTimeout&&clearTimeout(this.doneTimeout),AjaxHelper.AjaxWaitHide(),this.error().message(App.messages.addServices.errorOnlyReservations),!1):!0},i.prototype.clearErrors=function(){this.serviceCatering().clearErrors();this.error().message("")},i}(),t;n.AddServicesForm=i;t=function(){function n(n){var t=this;this.isInfoModal=ko.observable(!1);this.title=ko.observable("");this.content=ko.observable("");this.buttonMainTitle=ko.observable("");this.buttonMainUrl=ko.observable("");this.buttonAux1Title=ko.observable("");this.buttonAux1Url=ko.observable("");this.done=function(){t.parentForm.doneCore()};this.parentForm=n}return n}();n.AddServicesInfoModal=t}(AddServices||(AddServices={})),function(n){var t=function(){function n(n,t,i,r,u){var f=this;this.isMotocycle=ko.observable(!1);this.isMotocycleWithSidecar=ko.observable();this.is4Moto=ko.observable();this.carType=ko.observable();this.carRegistration=ko.observable();this.carHeight=ko.observable();this.carLength=ko.observable();this.carWidth=ko.observable();this.roofSize=ko.observable();this.carDriver=ko.observable();this.carDriverPhone=ko.observable();this.carLower=ko.observable();this.guid=ko.observable();this.carCategories=ko.observableArray();this.carLengths=ko.observableArray();this.visible=ko.observable(!1);this.enabled=ko.observable(!1);this.price=ko.observable();this.totalPrice=ko.observable();this.carMetalRoof=ko.observable();this.isMotocycleState=ko.observable();this.error=ko.observable(new ErrorInfo("AutoTrainSpecificationJS"));this.conditionsAgreement=ko.observable(!1);this.setEnabled=function(){f.enabled(!Support.stringIsEmpty(f.model.carResInfo.carRegistration))};this.done=function(){f.canSubmit()&&$("#autoTrainSpecificationModal").modal("show")};this.showAddServices=function(){if($("#autoTrainSpecificationModal").modal("hide"),f.canSubmit()){AjaxHelper.AjaxWaitShow(App.messages.connection.checkReservation);f.updateModel(f.model);f.model.enabled=!0;var n=App.getUrlAction("ComputeAutoTrain");$.post(n,{__RequestVerificationToken:App.GetAntiForgeryToken(),model:f.model},function(n){if(ErrorHandler.checkErrorsWithInfo(n,f)){AjaxHelper.AjaxWaitHide();return}window.location.href=App.getUrlAction("doplnkove-sluzby")+f.guid()})}};this.change=function(){window.location.href=App.getUrlAction("specifikace-vozidla")+f.guid()};this.parent=u;this.model=n;i?(this.model.guid=r,this.initModel(this.model)):(this.guid(n.guid),n.carCategories.forEach(function(n){f.carCategories.push(n)}),n.carLengths.forEach(function(n){f.carLengths.push(n)}),this.carLengths().length>0&&this.carLength(Number(this.carLengths()[0].length)),this.visible(!0),this.price(this.model.price),this.totalPrice(Support.formatMoneyFree(this.model.price,!0)),this.carMetalRoof=ko.pureComputed({read:function(){return!this.carLower()},write:function(n){this.carLower(!n)},owner:this}),this.carHeight(this.model.carResInfo.carHeight.toString()=="0"?"":this.model.carResInfo.carHeight.toString()),this.carLength(this.model.carResInfo.carLength),this.carLower(this.model.carResInfo.carLower),this.carRegistration(this.model.carResInfo.carRegistration),this.carType(this.model.carResInfo.carType),this.carWidth(this.model.carResInfo.carWidth.toString()=="0"?"":this.model.carResInfo.carWidth.toString()),this.carDriver(this.model.carResInfo.carDriver),Support.stringIsEmpty(this.model.carResInfo.carDriverPhone)?this.carDriverPhone("+420 "):this.carDriverPhone(n.carResInfo.carDriverPhone),this.model.carResInfo.isMotocycle||this.model.carResInfo.isMotocycleWithSidecar||this.model.carResInfo.is4Moto?this.model.carResInfo.isMotocycle?this.isMotocycleState("1"):this.model.carResInfo.isMotocycleWithSidecar?this.isMotocycleState("2"):this.isMotocycleState("3"):this.isMotocycleState("0"),this.isMotocycle=ko.pureComputed({read:function(){return this.isMotocycleState()==="1"?!0:!1},write:function(n){n?this.isMotocycleState("1"):this.isMotocycleState("0")},owner:this}),this.isMotocycleWithSidecar=ko.pureComputed({read:function(){return this.isMotocycleState()==="2"?!0:!1},write:function(n){n?this.isMotocycleState("2"):this.isMotocycleState("0")},owner:this}),this.is4Moto=ko.pureComputed({read:function(){return this.isMotocycleState()==="3"?!0:!1},write:function(n){n?this.isMotocycleState("3"):this.isMotocycleState("0")},owner:this}),this.model.carResInfo.roofSize==0&&(this.model.carResInfo.roofSize=135),this.roofSize(this.model.carResInfo.roofSize),this.myTicket=new MyTicket(t),this.setValidation(),this.errors=ko.validation.group(this),this.setEnabled(),ko.applyBindings(this,document.getElementById("main")),ko.applyBindings(this,document.getElementById("autoTrainSpecificationModal")),$(".cd-select").refreshNiceSelect())}return n.prototype.canSubmit=function(){return(this.carType.canValidate(!0),this.carRegistration.canValidate(!0),this.carDriver.canValidate(!0),this.carDriverPhone.canValidate(!0),this.isMotocycle()||this.isMotocycleWithSidecar()||this.is4Moto()?(this.carHeight.canValidate(!1),this.carWidth.canValidate(!1)):(this.carHeight.canValidate(!0),this.carWidth.canValidate(!0)),this.errors().length>0)?(this.errors.showAllMessages(),!1):!0},n.prototype.updateModel=function(n){n.carCategories=this.carCategories();n.carLengths=this.carLengths();n.guid=this.guid();n.visible=this.visible();n.carResInfo.carHeight=Number(this.carHeight());n.carResInfo.carLength=this.carLength();n.carResInfo.carLower=this.carLower();n.carResInfo.carRegistration=this.carRegistration();n.carResInfo.carType=this.carType();n.carResInfo.carWidth=Number(this.carWidth());n.carResInfo.carDriver=this.carDriver();n.carResInfo.carDriverPhone=this.carDriverPhone();n.carResInfo.isMotocycle=this.isMotocycle();n.carResInfo.isMotocycleWithSidecar=this.isMotocycleWithSidecar();n.carResInfo.is4Moto=this.is4Moto();this.is4Moto()&&(n.carResInfo.carLower=!0,n.carResInfo.carHeight=155,n.carResInfo.carWidth=155,n.carResInfo.carLength=381,n.carResInfo.roofSize=135);n.carResInfo.roofSize=this.roofSize();n.enabled=this.enabled()},n.prototype.initModel=function(n){this.guid(n.guid);this.carCategories(n.carCategories);this.carHeight(n.carResInfo.carHeight.toString());this.carLength(n.carResInfo.carLength);this.carLengths(n.carLengths);this.carLower(n.carResInfo.carLower);this.carRegistration(n.carResInfo.carRegistration);this.carType(n.carResInfo.carType);this.carWidth(n.carResInfo.carWidth.toString());this.carDriver(n.carResInfo.carDriver);this.carDriverPhone(n.carResInfo.carDriverPhone);this.guid(n.guid);this.isMotocycle(n.carResInfo.isMotocycle);this.isMotocycleWithSidecar(n.carResInfo.isMotocycleWithSidecar);this.is4Moto(n.carResInfo.is4Moto);this.is4Moto()&&this.carLower(!0);this.roofSize(n.carResInfo.roofSize);this.visible(n.visible);this.price(n.price);this.totalPrice(Support.formatMoneyFree(n.price,!0));this.enabled(!Support.stringIsEmpty(this.model.carResInfo.carRegistration))},n.prototype.setValidation=function(){this.setValidationAll()},n.prototype.setValidationAll=function(){var n=this;this.carType.extend({canValidate:!1,required:{onlyIf:function(){return n.carType.canValidate()},message:App.messages.validation.requiredItem},validation:[{onlyIf:function(){return n.carType.canValidate()},validator:function(n){return n.length<=15},message:App.messages.validation.errorTooLargeText},{onlyIf:function(){return n.carType.canValidate()},validator:function(n){return ValidationHelper.isValidInput(n,"")},message:App.messages.validation.errorInvalidChars}]});this.carRegistration.extend({canValidate:!1,required:{onlyIf:function(){return n.carRegistration.canValidate()},message:App.messages.validation.requiredItem},validation:[{onlyIf:function(){return n.carRegistration.canValidate()},validator:function(n){return n.length<=10},message:App.messages.validation.errorCarRegistration},{onlyIf:function(){return n.carRegistration.canValidate()},validator:function(n){return ValidationHelper.isValidInput(n,"")},message:App.messages.validation.errorInvalidChars}]});this.carHeight.extend({canValidate:!1,required:{onlyIf:function(){return n.carHeight.canValidate()},message:App.messages.validation.requiredItem},validation:{onlyIf:function(){return n.carHeight.canValidate()},validator:function(n){return n>=80&&n<=200},message:App.messages.validation.errorNumberHeight}});this.carWidth.extend({canValidate:!1,required:{onlyIf:function(){return n.carWidth.canValidate()},message:App.messages.validation.requiredItem},validation:{onlyIf:function(){return n.carWidth.canValidate()},validator:function(n){return n>0&&n<=200},message:App.messages.validation.errorNumberWidth}});this.carDriver.extend({canValidate:!1,required:{onlyIf:function(){return n.carDriver.canValidate()},message:App.messages.validation.requiredItem},validation:[{onlyIf:function(){return n.carDriver.canValidate()},validator:function(n){return n.length<=30},message:App.messages.validation.errorTooLargeText},{onlyIf:function(){return n.carDriver.canValidate()},validator:function(n){return ValidationHelper.isCardName(n)},message:App.messages.validation.errorCardName}]});this.carDriverPhone.extend({canValidate:!1,required:{onlyIf:function(){return n.carDriverPhone.canValidate()},message:App.messages.validation.requiredItem},validation:[{onlyIf:function(){return n.carDriverPhone.canValidate()},validator:function(n){return ValidationHelper.isPhoneNumber(n,"",!0)},message:App.messages.validation.errorPhone}]})},n.prototype.myTicketUpdate=function(){this.parent.myTicketUpdate(MyTicketType.AutoTrain,App.messages.addServices.autoTrain,this.enabled()?1:0,this.model.price)},n}();n.AutoTrainSpecificationJS=t}(AddServices||(AddServices={})),function(n){var u=function(){function n(n,t){var i=this;this.trains=ko.observableArray();this.visible=ko.observable(!1);this.totalPrice=ko.observable();this.error=ko.observable(new ErrorInfo("ServiceCatering"));this.setData=function(n){i.clearErrors();i.setTrains(n);i.myTicketUpdate()};this.change=function(n){i.serviceCateringModal.show(n)};this.model=n;this.parent=t;this.visible(n.visible);this.setData(n);this.serviceCateringModal=new r(this);ko.applyBindings(this.serviceCateringModal,document.getElementById("addServiceCateringModal"))}return n.prototype.setTrains=function(){var n=this;this.trains.removeAll();this.model.trains.map(function(i){return new t(i,n)}).forEach(function(t){return n.trains.push(t)})},n.prototype.updateModel=function(n){n.maxCount=this.model.maxCount;n.visible=this.model.visible&&this.parent.serviceReservation().enabled();var t=this.trains().filter(function(n){return n.visible()});n.trains=t.map(function(n){return n.model})},n.prototype.myTicketUpdate=function(){var n=this.model.trains.reduce(function(n,t){return n+t.menu.products.reduce(function(n,t){return n+t.count},0)},0),t=this.model.trains.reduce(function(n,t){return n+t.menu.products.reduce(function(n,t){return n+t.count*t.price},0)},0);this.parent.myTicketUpdate(MyTicketType.Catering,App.messages.addServices.catering,this.model.visible?n:0,t)},n.prototype.checkErrors=function(){return!this.error().isVisible()},n.prototype.clearErrors=function(){this.error().message("")},n}(),t,i,r;n.ServiceCatering=u;t=function(){function n(n,t){var r=this;this.from=ko.observable("");this.to=ko.observable("");this.train=ko.observable();this.trainName=ko.observable("");this.runDate=ko.observable("");this.productCount=ko.observable();this.totalPrice=ko.observable(0).extend({notify:"always"});this.totalPriceText=ko.observable("");this.enabled=ko.observable();this.visible=ko.observable();this.menu=ko.observable();this.products=ko.observableArray();this.computePrice=function(){var n=r.products().reduce(function(n,t){return n+t.count()*t.price()},0);r.totalPrice(n)};this.model=n;this.parent=t;this.from(n.from);this.to(n.to);this.train(n.train);this.trainName(n.trainName);this.productCount(n.productCount);this.menu(n.menu);this.menu().products.map(function(n){return new i(n,r)}).forEach(function(n){return r.products.push(n)});this.runDate(n.runDate);this.enabled(n.enabled);this.vehicleIcon=Support.getVehicleIcon(1,!0);this.totalPrice.subscribe(function(n){n==0?r.totalPriceText(App.messages.app.freeOfCharge):r.totalPriceText(Support.formatMoney(n,!0))});this.computePrice();this.totalPrice()==0?this.totalPriceText(App.messages.app.freeOfCharge):this.totalPriceText(Support.formatMoney(this.totalPrice(),!0));this.visible(this.parent.parent.serviceReservation().hasCateringTrain(this.model.id))}return n.prototype.setVisible=function(n){this.visible(n)},n.prototype.serialize=function(){var n=this.model,t;return n.totalPrice=this.totalPrice(),t=[],this.products().forEach(function(n){return t.push(n.serialize())}),n.menu.products=t,n},n.prototype.isSelected=function(){var n=this.products().reduce(function(n,t){return n+t.count()},0);if(n>0)return!0},n}();i=function(){function n(n,t){var i=this;this.id=ko.observable();this.image=ko.observable("");this.price=ko.observable();this.count=ko.observable(0);this.title=ko.observable("");this.text=ko.observable("");this.productCountChange=function(){i.productCountChangeButton(0)};this.productCountChangeButton=function(n){var t=i.setProductCount(n);t&&i.parent.computePrice()};this.setProductCount=function(n){var t=i.count();return isNaN(t)&&(t=0),isNaN(n)&&(n=0),t=i.checkValue(Number(t)+Number(n),n,0,i.parent.productCount(),i.countSelectedProducts()),i.count(t),!0};this.model=n;this.parent=t;this.id(n.id);this.image(n.image);this.price(n.price);this.count(n.count);this.title(n.title);this.text(n.text)}return n.prototype.incDecProductCount=function(n,t){t.which===38?this.productCountChangeButton(1):t.which===40&&this.productCountChangeButton(-1)},n.prototype.checkValue=function(n,t,i,r,u){return n<i?i:t==0&&u>r?r-(u-n):t!=0&&u+t>r?n-t:n>r?r:n},n.prototype.countSelectedProducts=function(){return this.parent.products().reduce(function(n,t){return Number(n)+Number(t.count())},0)},n.prototype.serialize=function(){var n=this.model;return n.count=this.count(),n},n}();n.CateringProductInfo=i;r=function(){function n(n){var t=this;this.train=ko.observable();this.totalPrice=ko.observable();this.error=ko.observable(new ErrorInfo("ServiceCatering"));this.done=function(){t.error().isVisible()||(t.train().enabled()&&t.parent.setData(t.serialize()),$("#addServiceCateringModal").modal("hide"))};this.parent=n;this.model=this.parent.model}return n.prototype.show=function(n){var r=this,i;this.trainID=n;this.parent.parent.error().message("");i=this.model.trains.filter(function(t){return t.train==n}).map(function(n){return new t(n,r.parent)});this.train(i[0])},n.prototype.serialize=function(){var n=this,t=this.model;return this.model.trains.filter(function(t){return t.id==n.trainID})[0]=this.train().serialize(),t},n}();n.CateringModal=r}(AddServices||(AddServices={})),function(n){var t,f,i,r,u;(function(n){n[n.NONE=0]="NONE";n[n.INKARTA=1]="INKARTA";n[n.OTHER=2]="OTHER"})(t=n.CUSTOMER_CARDTYPE||(n.CUSTOMER_CARDTYPE={}));f=function(){function n(n,t){var s,f,e,o;if(this.items=ko.observableArray(),this.vegaTourAgreement=ko.observable(!1),this.openSchema=function(n){if(!Support.stringIsEmpty(n)){var t=700,i=960,r=(window.screen.width-(i+60))/2,u=(window.screen.height-(t+80))/2,f="/eshop/schema-vlaku/?sui="+n,e=window.open(f,"Schema","height="+t+", width="+i+", left="+r+", top="+u+", location=no, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes",!0);e.focus()}},this.model=n,this.model.items)for(s in this.model.items)this.items().push(new i(this.model.items[s],this));for(this.myTicket=new MyTicket(t),this.documentConditionsModal=new r,this.identityModal=new u(this),this.hasSJT=this.model.items.some(function(n){return n.hasSJT}),this.hasVegaTour=this.model.items.some(function(n){return n.isVegaTour}),this.isIDPK=this.model.items.some(function(n){return n.isIDPK}),this.setValidation(),this.errors=ko.validation.group(this),ko.applyBindings(this,document.getElementById("main")),ko.applyBindings(this.identityModal,document.getElementById("IdentityModal")),ko.applyBindings(this.documentConditionsModal,document.getElementById("documentConditionsModal")),f=0,e=this.items();f<e.length;f++)o=e[f],o.dob!=null&&o.dob.initComponents();$(".ispassenger-dd").ISPassengerCardsDD();$(".ispassenger-dd-ik").ISPassengerCardsDD();$(".cd-select").refreshNiceSelect()}return n.prototype.insert2Basket=function(){var n=this,i,r;this.canSubmit()&&(i=this.getFormData(),this.model.docIDs!=null&&this.model.docIDs.length>0&&i.formItems.length==1&&i.formItems[0].customerCardType==t.INKARTA&&!this.model.items.some(function(n){return n.isIn100})&&!this.model.items.some(function(n){return n.isInBusiness})?(r=this.model.docIDs.join("&docIDs="),$.ajax({url:App.getUrlAction("CheckApp")+"?number="+i.formItems[0].ikCardId+"&dateofbirth="+i.formItems[0].ikCardBirth+("&dateRun="+this.model.items[0].dateRun+"&dateRunReturn="+this.model.items[0].dateRunReturn)+("&docIDs="+r),type:"GET",success:function(t){t.result?(n.identityModal.buttonMainTitle(App.messages.app.close),n.identityModal.buttonAux1Title(App.messages.app.cancel),n.model.mustPrintTicket?n.identityModal.content(t.checkError+" "+App.messages.userIdentity.mustPrintTicket):n.identityModal.content(t.checkError),n.identityModal.isInfoModal(!0),$("#IdentityModal").modal("show")):n.insert2BasketCore()}})):this.insert2BasketCore())},n.prototype.insert2BasketCore=function(){this.model.mustPrintTicket?(this.identityModal.buttonMainTitle(App.messages.app.close),this.identityModal.content(App.messages.userIdentity.mustPrintTicket),this.identityModal.isInfoModal(!1),$("#IdentityModal").modal("show")):this.done()},n.prototype.done=function(){var t=this,n;this.canSubmit()&&(n=this.getFormData(),$.post(App.getUrlAction("identifikace-cestujiciho"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(n){ErrorHandler.checkErrorsWithInfo(n,t)||(window.location.href=Support.stringIsEmpty(n.url)?App.getUrlAction("kosik"):n.url)}))},n.prototype.canSubmit=function(){var t=!1,n,i,r;for(this.vegaTourAgreement.canValidate(!0),n=0,i=this.items();n<i.length;n++)r=i[n],r.canSubmit()||(t=!0);return this.errors().length>0&&(this.errors.showAllMessages(),t=!0),!t},n.prototype.getFormData=function(){var n={},t,i,r;for(n.guid=this.model.guid,n.formItems=[],t=0,i=this.items();t<i.length;t++)r=i[t],n.formItems.push(r.getFormData());return n},n.prototype.setValidation=function(){var n=this;this.vegaTourAgreement.extend({canValidate:!1,equal:{onlyIf:function(){return n.hasVegaTour&&n.vegaTourAgreement.canValidate()},params:!0,message:App.messages.userIdentity.errorVegaTourConditionsAgreement}})},n}();n.Form=f;i=function(){function n(n,i){var r=this;this.customerCardType=ko.observable();this.otherCardName=ko.observable();this.ikCardId=ko.observable();this.ikCardBirthDate=ko.observable("");this.ikCardBusinessName=ko.observable();this.ikCardHolderValue=ko.observable();this.smsTicketPhone=ko.observable();this.validity=ko.observable();this.ikerror=ko.observable();this.vegaTourTicketPhone=ko.observable();this.error=ko.observable();this.ikCardBusinessNameTimeout=1e3;this.ikCardBusinessNameTO=null;this.getVehicleIcon=function(n){return Support.getVehicleIcon(n,!0)};this.documentConditionsOpen=function(n){var t=r.getDocumentConditionsData(n);$.post(App.getUrlAction("GetDocumentConditions"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:t},function(n){ErrorHandler.checkErrorsWithInfo(n,r)||($("#documentConditionsModal").modal("show"),r.parent.documentConditionsModal.show(n))})};this.setOtherCard=function(n){var i=n.getAttribute("data-is-pc-json"),t;i!=null&&i.length>0?(t=JSON.parse(i),t.type!=1?(r.otherCardName.canValidate(!0),r.otherCardName(t.name)):t.business||(r.ikCardClick(),r.ikCardHolderValue(""),r.ikCardId.canValidate(!0),r.ikCardBirthDate.canValidate(!0),r.ikCardId(Support.formatIKNumber(t.id)),r.dob.setDOBFromDate(DateTimeHelper.parseDate(t.date)),r.otherCardName.canValidate(!1),r.otherCardName("")),r.smsTicketPhone(Support.stringIsEmpty(t.phone)?"+420 ":t.phone),r.vegaTourTicketPhone(Support.stringIsEmpty(t.phone)?"+420 ":t.phone)):r.otherCardName(n.value);n.removeAttribute("data-is-pc-json")};this.setIKCard=function(n){var i=n.getAttribute("data-is-pc-json"),t;i!=null&&i.length>0?(t=JSON.parse(i),t.type!=1?(r.model.ikOnly||(r.otherCardClick(),r.otherCardName(t.name)),r.ikCardId.canValidate(!1),r.ikCardBirthDate.canValidate(!1),r.ikCardHolderValue(""),r.ikCardId(""),r.dob.year(""),r.dob.month("0"),r.dob.day(""),$(".dobpicker #dob_month_"+r.dob.model.dobIdSufix).refreshNiceSelect(),r.dob.error().message(""),r.ikCardBusinessName("")):t.business?(r.ikCardId.canValidate(!0),r.ikCardBirthDate.canValidate(!1),r.ikCardId(Support.formatIKNumber(t.id)),r.ikCardBusinessName.canValidate(!0),r.ikCardBusinessName(t.name)):(r.ikCardId.canValidate(!0),r.ikCardBirthDate.canValidate(!0),r.ikCardId(Support.formatIKNumber(t.id)),r.dob.setDOBFromDate(DateTimeHelper.parseDate(t.date))),r.smsTicketPhone(Support.stringIsEmpty(t.phone)?"+420 ":t.phone)):r.ikCardId(n.value);n.removeAttribute("data-is-pc-json")};this.model=n;this.parent=i;this.customerCardType(n.customerCardType);this.otherCardName(n.otherCardName);this.ikCardId(n.ikCardId);this.smsTicketPhone(Support.stringIsEmpty(n.smsTicketPhone)?"+420 ":n.smsTicketPhone);this.vegaTourTicketPhone(Support.stringIsEmpty(n.vegaTourTicketPhone)?"+420 ":n.vegaTourTicketPhone);n.validity&&this.validity(App.messages.shopCart.validity+" "+n.validity);n.isInvoice&&(this.invoice=new InvoiceForm(n.isInvoiceSelected,n.invoice,n.id,n.isInvoiceDenied));this.dobIdSufix=String(this.model.id);this.dobErrTop=!0;this.dob=new DOBPicker(this);this.dob.enabled=!n.nameReadOnly;this.error(new ErrorInfo("item_"+n.id));this.setSubsribe();this.setValidation();this.errors=ko.validation.group(this);Support.stringIsEmpty(n.ikCardBirth)||n.otherOnly||(this.ikCardId.canValidate(!0),this.ikCardBirthDate.canValidate(!0),this.ikCardBirthDate(n.ikCardBirth),this.dob.setDOBFromDate(DateTimeHelper.parseDate(this.ikCardBirthDate())),this.customerCardType(t.INKARTA));Support.stringIsEmpty(n.ikCardBusinessName)||n.otherOnly||(this.ikCardId.canValidate(!0),this.ikCardBirthDate.canValidate(!1),this.ikCardBusinessName.canValidate(!0),this.ikCardBusinessName(n.ikCardBusinessName),this.customerCardType(t.INKARTA));$(".cd-select").refreshNiceSelect()}return n.prototype.setSubsribe=function(){var n=this;this.otherCardName.subscribe(function(){n.clearError()});this.ikCardHolderValue.subscribe(function(){n.clearError()});this.ikCardBusinessName.subscribe(function(t){t&&t!=""||n.ikCardHolderValue("");n.ikCardBusinessNameTO&&clearTimeout(n.ikCardBusinessNameTO);n.ikCardBusinessNameTO=setTimeout(function(){n.clearError();Support.stringIsEmpty(n.ikCardId())||n.ikCardId.valueHasMutated()},n.ikCardBusinessNameTimeout)});this.ikCardBirthDate.subscribe(function(){Support.stringIsEmpty(n.ikCardId())||n.ikCardId.valueHasMutated()})},n.prototype.clearError=function(){this.error().message("")},n.prototype.setValidation=function(){this.setValidationOtherCard();this.setValidationIkCard();this.setValidationSms();this.setValidationVegaTour()},n.prototype.setValidationOtherCard=function(){var n=this;this.otherCardName.extend({canValidate:!1,required:{onlyIf:function(){return n.otherCardName.canValidate()&&n.customerCardType()===t.OTHER},message:App.messages.validation.requiredItem},validation:[{onlyIf:function(){return n.otherCardName.canValidate()&&n.customerCardType()===t.OTHER},validator:function(n){return ValidationHelper.isCardName(n)},message:function(){return App.messages.validation.errorCardName}},{onlyIf:function(){return n.otherCardName.canValidate()&&n.customerCardType()===t.OTHER},validator:function(n){return ValidationHelper.checkMaxLength(n,50)},message:function(){return App.messages.validation.errorCardNameLength}}]})},n.prototype.setValidationIkCard=function(){var n=this;this.ikCardId.extend({canValidate:!1,required:{onlyIf:function(){return n.ikCardId.canValidate()&&n.customerCardType()===t.INKARTA},message:function(){return n.ikerror(""),n.ikCardHolderValue(""),n.getIkError(App.messages.validation.requiredItem)}},validation:[{onlyIf:function(){return n.ikCardId.canValidate()&&n.customerCardType()===t.INKARTA},validator:function(n){return ValidationHelper.isIKNumberDigits(n)},message:function(){return n.ikerror(""),n.ikCardHolderValue(""),n.getIkError(App.messages.validation.errorIKNumberDigits)}},{onlyIf:function(){return n.ikCardId.canValidate()&&n.customerCardType()===t.INKARTA},validator:function(n){return ValidationHelper.isIKNumberLength(n)},message:function(){return n.ikerror(""),n.ikCardHolderValue(""),n.getIkError(App.messages.validation.errorIKNumber)}},{async:!0,onlyIf:function(){return n.ikCardId.canValidate()&&(n.isIkUser()&&n.ikCardBirthDate()!==""||n.isIkCompany()&&n.ikCardBusinessName.canValidate())},validator:function(t,i,r){if(n.isValidating==!0||n.isIkUser()&&(!n.ikCardBirthDate.canValidate()||!n.ikCardBirthDate.isValid()||n.ikCardBirthDate()=="Invalid date")||n.isIkCompany()&&Support.stringIsEmpty(n.ikCardBusinessName()))return r(!0);n.ikerror("");n.isValidating=!0;$.ajax({url:App.getUrlAction("SearchInKartaHolder")+"?number="+n.ikCardId()+"&dateofbirth="+n.ikCardBirthDate()+("&companyname="+encodeURIComponent(n.ikCardBusinessName())+"&dateRun="+n.model.dateRun+"&dateRunReturn="+n.model.dateRunReturn)+("&isSTC=false&isIN100="+n.model.isIn100+"&isInBusiness="+n.model.isInBusiness)+("&isRailwayTicket="+n.model.isRailwayTicket+"&railwayTicketFrom="+n.model.railwayTicketFrom+"&railwayTicketTo="+n.model.railwayTicketTo),type:"GET",success:function(t){(n.ikCardBusinessNameTO=null,ErrorHandler.checkErrorsWithInfo(t.result,n))||(n.ikCardHolderValue(t.result),n.ikerror(""),Support.stringIsEmpty(t.ikerror)||n.ikerror(t.ikerror),n.isValidating=!1,r(t.result!==""&&Support.stringIsEmpty(t.ikerror)))}})},message:function(){return n.isValidating=!1,n.ikCardBusinessNameTO=null,Support.stringIsEmpty(n.ikerror())?n.model.isInBusiness?n.getIkError(App.messages.connection.errorIKNumberCompanyName):n.getIkError(App.messages.connection.errorIKNumberBirthdate):n.getIkError(n.ikerror())}}]});this.ikCardBirthDate.extend({canValidate:!0,required:{onlyIf:function(){return n.ikCardBirthDate.canValidate()&&n.isIkUser()},message:this.getIkError(App.messages.validation.requiredItem)},validation:{onlyIf:function(){return n.ikCardBirthDate.canValidate()&&n.isIkUser()},validator:function(n){return ValidationHelper.checkDate(n)},message:this.getIkError(App.messages.validation.errorBirthdate)}});this.ikCardBusinessName.extend({canValidate:!1,required:{onlyIf:function(){return n.ikCardBusinessName.canValidate()&&n.customerCardType()===t.INKARTA&&n.model.isInBusiness},message:this.getIkError(App.messages.validation.requiredItem)}})},n.prototype.isIkCompany=function(){return this.customerCardType()===t.INKARTA&&this.model.isInBusiness},n.prototype.isIkUser=function(){return this.customerCardType()===t.INKARTA&&!this.model.isInBusiness},n.prototype.getIkError=function(n){return this.ikCardHolderValue(""),n},n.prototype.setValidationSms=function(){var n=this;this.smsTicketPhone.extend({canValidate:!1,validation:[{onlyIf:function(){return n.smsTicketPhone.canValidate()},validator:function(n){return ValidationHelper.isPhoneNumber(n,"+420")},message:App.messages.validation.errorPhone},{onlyIf:function(){return n.smsTicketPhone.canValidate()},validator:function(n){return n=n.replace(" ","").replace("+420",""),ValidationHelper.isCZMobileNumber(n)},message:App.messages.validation.errorCZMobileNumber}]})},n.prototype.hasSmsTicketPhone=function(){return this.model.isSmsTicket&&Support.hasPhone(this.smsTicketPhone())},n.prototype.setValidationVegaTour=function(){var n=this;this.vegaTourTicketPhone.extend({canValidate:!1,required:{onlyIf:function(){return n.vegaTourTicketPhone.canValidate()},message:App.messages.validation.requiredItem},validation:[{onlyIf:function(){return n.vegaTourTicketPhone.canValidate()},validator:function(n){return ValidationHelper.isPhoneNumber(n,"",!0)},message:App.messages.validation.errorPhone},{onlyIf:function(){return n.vegaTourTicketPhone.canValidate()},validator:function(n){return ValidationHelper.isVegaTourMobileNumber(n)},message:App.messages.validation.errorVegaTourMobileNumber}]})},n.prototype.hasVegaTourTicketPhone=function(){return this.model.isVegaTour},n.prototype.otherCardClick=function(){this.customerCardType(t.OTHER)},n.prototype.ikCardClick=function(){this.customerCardType(t.INKARTA)},n.prototype.canSubmit=function(){this.customerCardType()===t.OTHER&&this.otherCardName.canValidate(!0);this.customerCardType()===t.INKARTA&&(this.ikCardId.canValidate(!0),this.isIkUser()&&this.ikCardBirthDate.canValidate(!0),this.isIkCompany()&&this.ikCardBusinessName.canValidate(!0));this.smsTicketPhone.canValidate(this.hasSmsTicketPhone());this.vegaTourTicketPhone.canValidate(this.hasVegaTourTicketPhone());var n=!0;return(this.model.isInvoice&&this.invoice.isInvoiceSelected()&&(n=n&&this.invoice.canSubmit()),this.customerCardType()!==t.INKARTA||this.dob===null||this.model.isInBusiness||(n=n&&this.dob.canSubmit()),this.errors().length>0||!n)?(this.errors().length>0&&this.errors.showAllMessages(),!1):!this.ikCardBusinessNameTO&&!this.isValidating},n.prototype.getFormData=function(){var n={};return n.id=this.model.id,n.customerCardType=this.customerCardType(),n.customerCardType===t.OTHER?n.otherCardName=this.otherCardName():n.customerCardType===t.INKARTA&&(n.ikCardId=this.ikCardId(),this.model.isInBusiness?n.ikCardBusinessName=this.ikCardBusinessName():n.ikCardBirth=this.ikCardBirthDate()),this.model.isSmsTicket&&this.hasSmsTicketPhone()&&(n.smsTicketPhone=Support.unifyPhoneNumber(this.smsTicketPhone())),this.model.isVegaTour&&this.hasVegaTourTicketPhone()&&(n.vegaTourTicketPhone=Support.unifyPhoneNumberVegaTour(this.vegaTourTicketPhone())),n.isInvoiceSelected=this.model.isInvoice&&this.invoice.isInvoiceSelected(),n.isInvoiceSelected&&(this.invoice.isInvoiceDenied()?(n.isInvoiceDenied=!0,this.invoice.model.sjt&&(n.invoice=this.invoice.getFormData())):n.invoice=this.invoice.getFormData()),n},n.prototype.getDocumentConditionsData=function(n){var t={};return t.guid=this.parent.model.guid,t.cartItemID=this.model.id,t.index=n,t},n.prototype.dobFirstValidDate=function(){return moment().add(-100,"year").toDate()},n.prototype.dobLastValidDate=function(){return new Date},n.prototype.setDOBDate=function(n){this.ikCardBirthDate(DateTimeHelper.formatDateBase(n))},n.prototype.setExtraValidation=function(){return!0},n}();n.CartItem=i;r=function(){function n(){var n=this;this.model=ko.observable();this.trainName4Res=function(t){var i=n.getTrain4Res(t);return i!=null?i.name:null};this.trainReservations=function(t,i){var r=n.getTrain4Res(t),e,u,o,s,h,f,c,l;if(r!=null&&r.reservations!=null&&r.reservations.length>0){for(e=[],u=0,o=r.reservations;u<o.length;u++)for(s=o[u],h=!1,f=0,c=i;f<c.length;f++)l=c[f],h||s.refNums.indexOf(l)!==-1&&(e.push(s),h=!0);return e}return null};this.getVehicleIcon=function(t){var i=n.getTrain4Res(t);if(i!=null&&i.reservations!=null&&i.reservations.length>0)return Support.getVehicleIcon(i.trainTypeID,!0);Support.getVehicleIcon(0,!0)};this.openSchema=function(n){if(!Support.stringIsEmpty(n)){var t=700,i=960,r=(window.screen.width-(i+60))/2,u=(window.screen.height-(t+80))/2,f="/eshop/schema-vlaku/?sui="+n,e=window.open(f,"Schema","height="+t+", width="+i+", left="+r+", top="+u+", location=no, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes",!0);e.focus()}}}return n.prototype.show=function(n){this.model(n)},n.prototype.getTrain4Res=function(n){for(var i,u,t=0,r=this.model().list;t<r.length;t++)if(i=r[t],i.reservations!=null&&i.reservations.length>0&&(u=this.getTrain4ItemTIcket(i,n),u!=null))return u;return null},n.prototype.getTrain4ItemTIcket=function(n,t){var i=this.getTrain4Way(n.connThere,t);return i!=null?i:this.getTrain4Way(n.connBack,t)},n.prototype.getTrain4Way=function(n,t){var i,r,u;if(n!=null&&n.trains!=null)for(i=0,r=n.trains;i<r.length;i++)if(u=r[i],u.id===t)return u;return null},n}();n.DocumentConditionsModal=r;u=function(){function n(n){var t=this;this.isInfoModal=ko.observable(!1);this.title=ko.observable("");this.content=ko.observable("");this.buttonMainTitle=ko.observable("");this.buttonMainUrl=ko.observable("");this.buttonAux1Title=ko.observable("");this.buttonAux1Url=ko.observable("");this.done=function(){t.parentForm.done()};this.parentForm=n}return n}();n.IdentityModal=u}(UserIdentity||(UserIdentity={})),function(n){var t=function(){function n(n,t){var i=this;this.totalPrice=ko.observable("");this.loyaltyPoints=ko.observable("");this.paymentAgreement0=ko.observable();this.paymentAgreement1=ko.observable();this.paymentAgreement1Visible=ko.observable();this.paymentAgreement4=ko.observable();this.paymentAgreement4Visible=ko.observable();this.paymentAgreement5=ko.observable();this.paymentAgreement5Visible=ko.observable();this.pin1=ko.observable("").extend({inputPattern:/[^0-9]+/g});this.pin2=ko.observable("").extend({inputPattern:/[^0-9]+/g});this.pin3=ko.observable("").extend({inputPattern:/[^0-9]+/g});this.pin4=ko.observable("").extend({inputPattern:/[^0-9]+/g});this.pin=ko.computed(function(){return i.pin1()+i.pin2()+i.pin3()+i.pin4()},this);this.pinFocus=ko.observable("1");this.loggedUserWithoutLoyalty=ko.observable();this.caBlocked=ko.observable(!1);this.vegaTourAgreement=ko.observable(!1);this.error=ko.observable(new ErrorInfo(""));this.pay=function(){if(i.checkErrors()){var n=App.getUrlAction("CheckCAPIN");$.post(n,{__RequestVerificationToken:App.GetAntiForgeryToken(),pin:i.pin(),price:i.model.totalPrice},function(n){ErrorHandler.checkErrors(n)||(n.pinError?(i.pin1(""),i.pin2(""),i.pin3(""),i.pin4(""),i.pinFocus("1"),i.pin.setError(n.pinError),i.caBlocked(n.caBlocked)):i.parent.pay())})}};this.payContinue=function(){var n=i.createModel(),t=App.getUrlAction("kosik");$.post(t,{__RequestVerificationToken:App.GetAntiForgeryToken(),paymentModel:n},function(n){ErrorHandler.checkErrors(n)||(window.location.href=n.paymentRedirectUrl?n.paymentRedirectUrl:App.getUrlAction("kosik"))})};this.parent=n;this.model=t;this.totalPrice(Support.formatMoney(t.totalPrice,!0));this.loyaltyPoints(Support.formatLoyaltyPoints(t.loyaltyPoints));this.setValidation();this.errors=ko.validation.group(this);this.paymentAgreement1Visible(t.paymentAgreement1Visible);this.paymentAgreement4Visible(t.paymentAgreement4Visible);this.paymentAgreement5Visible(t.paymentAgreement5Visible);this.pin1.subscribe(function(n){i.pinFocus(n.length==1?"2":"1")});this.pin2.subscribe(function(n){i.pinFocus(n.length==1?"3":"2")});this.pin3.subscribe(function(n){i.pinFocus(n.length==1?"4":"3")});this.loggedUserWithoutLoyalty(t.loggedUserWithoutLoyalty)}return n.prototype.setValidation=function(){var n=this;this.pin.extend({canValidate:!1,validation:{onlyIf:function(){return n.pin.canValidate()},validator:function(n){return n.length==4&&ValidationHelper.checkRange(n,0,9999,!1)},message:App.messages.shopCart.errorPIN}});this.paymentAgreement0.extend({canValidate:!1,equal:{onlyIf:function(){return n.paymentAgreement0.canValidate()},params:!0,message:App.messages.shopCart.paymentAgreement0}});this.paymentAgreement5.extend({canValidate:!1,equal:{onlyIf:function(){return n.paymentAgreement0.canValidate()&&n.paymentAgreement5Visible()},params:!0,message:App.messages.shopCart.paymentAgreement5}});this.vegaTourAgreement.extend({canValidate:!1,equal:{onlyIf:function(){return n.parent.model.isVegaTour&&n.vegaTourAgreement.canValidate()},params:!0,message:App.messages.userIdentity.errorVegaTourConditionsAgreement}})},n.prototype.checkErrors=function(){this.pin.canValidate(!0);this.paymentAgreement0.canValidate(!0);this.paymentAgreement5.canValidate(!0);this.vegaTourAgreement.canValidate(!0);var n=!0;return this.errors().length>0&&(this.errors.showAllMessages(),n=!1),this.parent.checkErrors()||(n=!1),n},n.prototype.createModel=function(){var n={},t,i,r,u;return n.paymentMethod=ShopCart.PaymentMethod.CA,n.pin=this.pin(),n.totalPrice=this.model.totalPrice,n.isFastBuy=!0,n.agreements=this.model.agreements,n.agreements!=undefined&&n.agreements.length>0&&(t=n.agreements.filter(function(n){return n.agreementTypeID==0}),t.length>0&&(t[0].agree=this.paymentAgreement0()),this.paymentAgreement4Visible&&(i=n.agreements.filter(function(n){return n.agreementTypeID==4}),i.length>0&&(i[0].agree=this.paymentAgreement4())),this.paymentAgreement5Visible&&(r=n.agreements.filter(function(n){return n.agreementTypeID==5}),r.length>0&&(r[0].agree=this.paymentAgreement5())),this.paymentAgreement1Visible&&(u=n.agreements.filter(function(n){return n.agreementTypeID==1}),u.length>0&&(u[0].agree=this.paymentAgreement1()))),n},n}(),i;n.FastBuyPayment=t;i=function(){function i(i,r){var u=this;this.smsTicketPhone=ko.observable();this.payment=ko.observable();this.passengers=ko.observableArray();this.selectedPassengerIndex=ko.observable();this.selectedCardName=ko.observable();this.vegaTourTicketPhone=ko.observable();this.setPassengerInfo=function(n){var i,t;for(i in n.passengers)t=n.passengers[i],u.passengers.push({passengerName:t.nickname,passengerCard:t.cardTypeID==1?App.messages.shopCart.inCardNumber(t.cardNumber,t.birthdate):t.cardTypeID==0?App.messages.shopCart.cardHolderName(t.fullname):"",avatar:Support.stringIsEmpty(t.image)?Support.stringIsEmpty(t.avatar)?"":n.avatarsImagePath+t.avatar:t.image}),t.isDefault&&u.selectedPassengerIndex(parseInt(i));u.smsTicketPhone(Support.stringIsEmpty(n.passengers[u.selectedPassengerIndex()].phone)?"+420 ":n.passengers[u.selectedPassengerIndex()].phone);u.vegaTourTicketPhone(u.smsTicketPhone())};this.pay=function(){var n=u.getUserIdentityData();$.post(App.getUrlAction("identifikace-cestujiciho"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(n){if(!ErrorHandler.checkErrors(n))if(n.isErrorModel){var t=n.errors[0].message;u.payment().error().message(t);ErrorHandler.focusFirstError()}else u.payment().payContinue()})};this.documentConditionsOpen=function(){var n=u.getDocumentConditionsData();$.post(App.getUrlAction("GetDocumentConditions"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(n){ErrorHandler.checkErrorsWithInfo(n,u)||($("#documentConditionsModal").modal("show"),u.documentConditionsModal.show(n))})};this.init=!0;this.model=i;this.smsTicketPhone("+420 ");this.vegaTourTicketPhone("+420 ");this.payment(new t(this,i.payment));this.selectedPassengerIndex(0);this.setPassengerInfo(i);this.myTicket=new MyTicket(r);this.setValidation();this.errors=ko.validation.group(this);this.documentConditionsModal=new n.DocumentConditionsModal;ko.applyBindings(this.documentConditionsModal,document.getElementById("documentConditionsModal"));ko.applyBindings(this,document.getElementById("main"));this.init=!1;this.passengerSelect(this.selectedPassengerIndex)}return i.prototype.setValidation=function(){var n=this;this.smsTicketPhone.extend({canValidate:!1,validation:[{onlyIf:function(){return n.smsTicketPhone.canValidate()},validator:function(n){return ValidationHelper.isPhoneNumber(n,"+420")},message:App.messages.validation.errorPhone},{onlyIf:function(){return n.smsTicketPhone.canValidate()},validator:function(n){return n=n.replace(" ","").replace("+420",""),ValidationHelper.isCZMobileNumber(n)},message:App.messages.validation.errorCZMobileNumber}]});this.vegaTourTicketPhone.extend({canValidate:!1,required:{onlyIf:function(){return n.vegaTourTicketPhone.canValidate()},message:App.messages.validation.requiredItem},validation:[{onlyIf:function(){return n.vegaTourTicketPhone.canValidate()},validator:function(n){return ValidationHelper.isPhoneNumber(n,"",!0)},message:App.messages.validation.errorPhone},{onlyIf:function(){return n.vegaTourTicketPhone.canValidate()},validator:function(n){return ValidationHelper.isVegaTourMobileNumber(n)},message:App.messages.validation.errorVegaTourMobileNumber}]})},i.prototype.hasSmsTicketPhone=function(){return Support.hasPhone(this.smsTicketPhone())},i.prototype.hasVegaTourTicketPhone=function(){return this.model.isVegaTour},i.prototype.checkErrors=function(){return(this.smsTicketPhone.canValidate(!0),this.vegaTourTicketPhone.canValidate(!0),this.errors().length>0)?(this.errors.showAllMessages(),!1):!0},i.prototype.getUserIdentityData=function(){var t={},i,r;return t.iD=this.model.cartItemID,i=this.model.passengers,i[this.selectedPassengerIndex()].cardTypeID==1?(t.customerCardType=n.CUSTOMER_CARDTYPE.INKARTA,Support.stringIsEmpty(i[this.selectedPassengerIndex()].birthdate)||(t.IkCardId=i[this.selectedPassengerIndex()].cardNumber,t.ikCardBirth=i[this.selectedPassengerIndex()].birthdate)):(t.customerCardType=n.CUSTOMER_CARDTYPE.OTHER,t.otherCardName=i[this.selectedPassengerIndex()].fullname),this.model.isSmsTicket&&(t.smsTicketPhone=Support.unifyPhoneNumber(this.smsTicketPhone())),this.model.isVegaTour&&(t.vegaTourTicketPhone=Support.unifyPhoneNumberVegaTour(this.vegaTourTicketPhone())),r={},r.guid=this.model.guid,r.formItems=[t],r},i.prototype.getDocumentConditionsData=function(){var n={};return n.guid=this.model.guid,n.cartItemID=this.model.cartItemID,this.model.isVegaTour&&(n.cartItemID=0),n},i.prototype.showHidePassList=function(n){n===void 0&&(n=!1);var t=$("#passengerList");!t.is(":hidden")||n?t.hide():t.show()},i.prototype.passengerSelect=function(n){if(n()!=undefined&&this.init!=!0){this.selectedPassengerIndex(n());$("#passengerList").hide();var t=this.model.passengers[n()];this.selectedCardName(t.cardTypeID==1?App.messages.shopCart.inCardNumber(t.cardNumber,t.birthdate):t.cardTypeID==0?App.messages.shopCart.cardHolderName(t.fullname):"");this.smsTicketPhone(Support.stringIsEmpty(t.phone)?"+420 ":t.phone);this.vegaTourTicketPhone(this.smsTicketPhone())}},i}();n.FastBuy=i}(UserIdentity||(UserIdentity={})),function(n){var t,i,r,f,u;(function(n){n[n.newCard=1]="newCard";n[n.duplicate=2]="duplicate";n[n.productPurchase=4]="productPurchase";n[n.noPriceDefined=8]="noPriceDefined";n[n.noApp=16]="noApp";n[n.noAppEmployee=32]="noAppEmployee";n[n.iNRT=64]="iNRT"})(t=n.AppFlag||(n.AppFlag={})),function(n){n[n.newCard=0]="newCard";n[n.duplicate=1]="duplicate";n[n.productPurchase=2]="productPurchase"}(i=n.CardAppContext||(n.CardAppContext={}));r=function(){function n(n,r,u){var f=this,e,o;this.applications=ko.observableArray();this.applicationID=ko.observable();this.categories=ko.observableArray();this.categoryID=ko.observable();this.periods=ko.observableArray();this.periodID=ko.observable();this.pensionerIdentCheck=ko.observable(!1);this.pensionerIdent=ko.observable();this.validFromTo=ko.observable();this.duplicateReasons=ko.observableArray();this.duplicateReasonID=ko.observable();this.simpleForm=ko.observable(!1);this.simpleFormNoApp=ko.observable(!1);this.isINRT=ko.observable(!1);this.price=ko.observable("");this.cardPrice=ko.observable("");this.loyaltyPoints=ko.observable("");this.hasLoyaltyAccount=ko.observable(null);this.priceInfo=ko.observable("");this.showCartInsertButton=ko.observable(!1);this.formRefresh=!1;this.refreshForm=function(n,t,i){i===void 0&&(i=null);var r=i&&i.applicationID?i.applicationID:"",u=i&&i.categoryID?i.categoryID:"",e=i&&i.periodID?i.periodID:"";f.formRefresh=!0;n&&f.setApplications(r);t&&f.setCategories(u);f.setPeriods(e);f.setValidity();f.formRefresh=!1};this.setApplications=function(n){f.applications.removeAll();f.model.apps.forEach(function(n){f.applications.push({name:n.text,value:n.ident})});var i=f.model.apps[0];Support.stringIsEmpty(n)||(i=f.model.apps.filter(function(t){return t.ident==n})[0],i==undefined&&(n.indexOf("RTM")>-1?i=f.model.apps.filter(function(n){return n.ident=="RTM"})[0]:n.indexOf("RTW")>-1?i=f.model.apps.filter(function(n){return n.ident=="RTW"})[0]:n.indexOf("RTQ")>-1&&(i=f.model.apps.filter(function(n){return n.ident=="RTQ"})[0]),i==undefined?i=f.model.apps[0]:n=""));f.applicationID(i.ident);i&&f.parent.checkExistingIKApp(i);f.duplicateReasons.removeAll();(i.flag&t.noAppEmployee)!=0&&f.model.duplicateReasons.length>0&&(f.model.duplicateReasons.forEach(function(n){return f.duplicateReasons.push(n)}),f.duplicateReasonID(f.model.duplicateReasons[0].value))};this.setCategories=function(n){var t,i;(f.categories.removeAll(),t=f.model.apps.filter(function(n){return n.ident==f.applicationID()})[0],t.categories.length!=0)&&(t.categories.forEach(function(n){f.categories.push({name:n.text,value:n.ident})}),i=t.categories.filter(function(n){return n.isDef})[0],i||(i=t.categories[0]),Support.stringIsEmpty(n)||(i=t.categories.filter(function(t){return t.ident==n})[0],i==undefined&&(i=t.categories[0])),f.categoryID(i.ident))};this.setPeriods=function(n){var t,i;(f.periods.removeAll(),f.pensionerIdentCheck(!1),t=f.model.apps.filter(function(n){return n.ident==f.applicationID()})[0],t.categories.length!=0)&&(i=t.categories.filter(function(n){return n.ident==f.categoryID()})[0],i.periods.forEach(function(n){f.periods.push({name:f.getPeriodName(n),value:n.ident})}),f.pensionerIdentCheck(i.pensionerIdentCheck),f.periodID(f.periods()[0].value),Support.stringIsEmpty(n)||f.periodID(n))};this.setValidity=function(){var n=f.model.apps.filter(function(n){return n.ident==f.applicationID()})[0];if(n.categories.length==0){f.setPrice(n,null);f.setCartInsertButton(n,null);return}var e=n.categories.filter(function(n){return n.ident==f.categoryID()})[0],u=e.periods.filter(function(n){return n.ident==f.periodID()})[0],r=f.validFromTo().validFrom(),i=u.validFromIntervals.map(function(n){return{from:DateTimeHelper.parseDateSerialized(n.from),to:DateTimeHelper.parseDateSerialized(n.to)}});f.validFromTo().setEnabledDates(i);i.filter(function(n){return n.from<=r&&r<=n.to}).length==0?f.setValidFrom(i[0].from):i[0].from!=r?f.setValidFrom(i[0].from):f.setValidFrom(r);((n.flag&t.noApp)==0||f.isNewIK)&&(n.flag&t.noAppEmployee)==0||f.setValidFrom(DateTimeHelper.today());f.setPrice(n,u);f.setCartInsertButton(n,u)};this.setPrice=function(n,i){var r=n.rtTariff.length>0,u=r&&(n.flag&t.noPriceDefined)!=0,e;i=i||{price:-1,loyaltyPoints:0};f.price(Support.formatMoney(i.price,!0,!0));f.loyaltyPoints(Support.formatLoyaltyPoints(i.loyaltyPoints,!0));r?f.priceInfo((u?"":"+ ")+App.messages.inKarta.railwayTicketPriceInfo):f.priceInfo("");i.price>0&&f.model.cardPrice>0&&f.cardPrice((Support.stringIsEmpty(f.price())?"":"+ ")+Support.formatMoney(f.model.cardPrice,!0,!0)+" "+App.messages.inKarta.cardPrice);i.price==-1&&f.model.cardPriceNoApp>0&&(f.price(Support.formatMoney(f.model.cardPriceNoApp,!0,!0)),f.cardPrice(""));f.simpleForm(u||(n.flag&t.noApp)!=0&&!f.isNewIK||(n.flag&t.noAppEmployee)!=0);f.simpleFormNoApp((n.flag&t.noApp)!=0&&f.isNewIK);f.isINRT((n.flag&t.iNRT)!=0&&f.isNewIK);f.duplicateReasons().length>0&&(e=f.duplicateReasons().filter(function(n){return n.value==f.duplicateReasonID()})[0],f.price(Support.formatMoney(e.price,!0)))};this.setCartInsertButton=function(n,i){var u=n.rtTariff.length>0,e=u&&(n.flag&t.noPriceDefined)!=0,r=i&&i.price>=f.parent.invoiceMinPrice;if(e&&!r){f.showCartInsertButton(!0);return}if(i&&(i.flag&t.productPurchase)!=0&&!r){f.showCartInsertButton(!0);return}f.showCartInsertButton(!1)};this.setValidFrom=function(n){var t,i;f.validFromTo().setValidFrom(n);Support.stringIsEmpty(f.periodID())||(t=void 0,t=f.applicationID()=="INVALID_BUY"?DateTimeHelper.addInterval(n,f.periodID()):DateTimeHelper.addIntervalDays(n,f.periodID()),i=DateTimeHelper.addInterval(t,"-1D"),f.validFromTo().setValidTo(i))};this.continueButton=function(){f.done(!1)};this.cartInsert=function(){f.done(!0)};this.done=function(n){var e,o;if(f.checkErrors()){var u=f.model.apps.filter(function(n){return n.ident==f.applicationID()})[0],s=u.rtTariff.length>0,h=s&&(u.flag&t.noPriceDefined)!=0,r={context:f.isNewIK?i.newCard:i.duplicate,applicationID:u.ident,validFrom:DateTimeHelper.toJSDate(f.validFromTo().validFrom())};h&&(r.context=i.productPurchase);u.categories.length>0&&(e=u.categories.filter(function(n){return n.ident==f.categoryID()})[0],o=e.periods.filter(function(n){return n.ident==f.periodID()})[0],r.categoryID=e.ident,r.periodID=o.ident,(o.flag&t.productPurchase)!=0&&(r.context=i.productPurchase));f.duplicateReasons().length>0&&(r.duplicateReasonID=f.duplicateReasonID());r.pensionerIdent=f.pensionerIdentCheck()?f.pensionerIdent():null;f.isINRT()?(f.parent.appsModal.buttonMainTitle(App.messages.app.close),f.parent.appsModal.content(App.messages.inKarta.railwayTicketBuyInfo),f.parent.appsModal.isInfoModal(!1),f.parent.appsModal.isCartInsert=!1,f.parent.appsModal.setAppFormData(r),$("#AppFormModal").modal("show")):f.parent.done(r,n)}};this.parent=n;this.model=r;this.isNewIK=u;this.hasLoyaltyAccount(r.hasLoyaltyAccount);this.validFromTo(new FromToCalendar(this.setValidFrom));this.setValidFrom(DateTimeHelper.today());this.refreshForm(!0,!0);e=this;this.prevApplicationId=e.applicationID();o=u?"#newIK":"#existingIK";$("body").on("close",o+" select.cd-select.applications",function(){var i=$(this).val(),n;if(e.prevApplicationId!==i){if(e.prevApplicationId=i,e.formRefresh)return;e.refreshForm(!1,!0);$("#main .cd-select").refreshNiceSelect();e.isNewIK||(n=e.model.apps.filter(function(n){return n.ident==e.applicationID()})[0],e.parent.checkExistingIKApp(n),e.duplicateReasons.removeAll(),(n.flag&t.noAppEmployee)!=0&&e.model.duplicateReasons.length>0&&(e.model.duplicateReasons.forEach(function(n){return e.duplicateReasons.push(n)}),e.duplicateReasonID(e.model.duplicateReasons[0].value)))}});this.categoryID.subscribe(function(){f.formRefresh||(f.refreshForm(!1,!1),$("#main .periods.cd-select").refreshNiceSelect())});this.periodID.subscribe(function(){f.formRefresh||f.setValidity()});this.duplicateReasonID.subscribe(function(){f.formRefresh||f.setValidity()});this.setValidation();this.errors=ko.validation.group(this)}return n.prototype.removeEvents=function(){var n=this.isNewIK?"#newIK":"#existingIK";$("body").off("close",n+" select.cd-select.applications",null)},n.prototype.setValidation=function(){var n=this;this.pensionerIdent.extend({canValidate:!1,validation:[{onlyIf:function(){return n.pensionerIdent.canValidate()&&n.pensionerIdentCheck()&&n.parent.existingTicketApp()==null},validator:function(n){return ValidationHelper.checkMinLength(n,2)},message:App.messages.validation.errorPensionerIdent}]})},n.prototype.init=function(n){this.refreshForm(!0,!0,n);$("#main .cd-select").refreshNiceSelect();this.prevApplicationId=this.applicationID();n&&(n.validFrom&&this.setValidFrom(DateTimeHelper.parseDate(n.validFrom)),n.duplicateReasonID&&this.duplicateReasonID(n.duplicateReasonID),n.pensionerIdent&&this.pensionerIdent(n.pensionerIdent))},n.prototype.getPeriodName=function(n){return(n.flag&t.newCard)!=0?n.text+" "+App.messages.inKarta.periodSuffixNew:(n.flag&t.duplicate)!=0?n.text+" "+App.messages.inKarta.periodSuffixDuplicate:(n.flag&t.productPurchase)!=0?n.text+" "+App.messages.inKarta.periodSuffixPurchase:n.text},n.prototype.checkErrors=function(){return(this.pensionerIdent.canValidate(!0),this.errors().length>0)?(this.errors.showAllMessages(),!1):!0},n.prototype.getHistoryModel=function(){return $.extend({},this.model)},n}();n.AppForm=r;f=function(){function f(f){var e=this;this.isNewIK=ko.observable(!0);this.ikSearch=ko.observable();this.newIKApp=ko.observable();this.existingIKApp=ko.observable();this.existingIKAppVisible=ko.observable(!0);this.existingTicketApp=ko.observable();this.myCards=ko.observable();this.setNewIK=function(n){e.isNewIK(n);e.ikSearch().isVisible(!n)};this.setIK=function(n){e.isNewIK(!1);e.ikSearch().isVisible(!0);e.ikSearch().setIK(n)};this.findIK=function(n,t){if(!n){e.existingIKApp()!=null&&e.existingIKApp().removeEvents();e.existingIKApp(null);return}var i=e;$.ajax({url:App.getUrlAction("in-karta/GetIKAppBuyInfo")+"?cardNumber="+n+"&dob="+t,type:"GET",success:function(n){if(ErrorHandler.checkErrorsWithInfo(n,e))i.ikSearch().cardNumber.isValid()||i.ikSearch().ikSearchError().message(""),i.ikSearch().cardInfo(""),i.existingIKApp()!=null&&i.existingIKApp().removeEvents(),i.existingIKApp(null);else{var t=n;i.existingIKApp()!=null&&i.existingIKApp().removeEvents();i.existingIKApp(new r(i,t,!1));i.existingIKApp().init(i.model.data);i.ikSearch().cardInfo(t.cardInfo.fullName);$("#main .cd-select").refreshNiceSelect()}}})};this.checkExistingIKApp=function(i){var r=i.rtTariff.length>0,u=r&&(i.flag&t.noPriceDefined)!=0;u?$.ajax({url:App.getUrlAction("in-karta/GetTicketFormModel")+"?tariffID="+i.rtTariff+"&appIdent="+i.ident,type:"GET",success:function(t){ErrorHandler.checkErrors(t)||(e.existingTicketApp(new n.TicketForm(t,e.existingIKApp())),e.existingIKAppVisible(!1))}}):(e.existingTicketApp(null),e.existingIKAppVisible(!0),setTimeout(function(){$("#main .cd-select").refreshNiceSelect()}))};this.done=function(n,t){n.context!=i.newCard&&(n.cardNumber=e.ikSearch().cardNumber(),n.dob=DateTimeHelper.toJSDate(e.ikSearch().dob.getDate()));var r=App.getUrlAction("in-karta");$.post(r,{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(i){if(!ErrorHandler.checkErrors(i)){var r=e.getHistoryModel(n);history.pushState(r,null,"#pokracovat");t?$.post(App.getUrlAction("in-karta/CartInsert"),{__RequestVerificationToken:App.GetAntiForgeryToken()},function(n){ErrorHandler.checkErrorsWithInfo(n,e)||(window.location.href=App.getUrlAction("kosik"))}):window.location.href=App.getUrlAction("in-karta/"+i.redirectUrl)}})};f=history.state?history.state:f;this.model=f;this.newIKApp(new r(this,f.newIKApp,!0));this.ikSearch(new n.IKSearch(f.cards,this.findIK));this.myCards(new n.MyCards(f.cards,this.setIK));this.documentConditionsModal=new UserIdentity.DocumentConditionsModal;this.invoiceMinPrice=this.model.invoiceMinPrice;this.appsModal=new u(this);ko.applyBindings(this,document.getElementById("main"));ko.applyBindings(this.documentConditionsModal,document.getElementById("documentConditionsModal"));ko.applyBindings(this.appsModal,document.getElementById("AppFormModal"));$("#main .cd-select").refreshNiceSelect();this.init(f)}return f.prototype.init=function(t){if(t.existingIKApp?this.ikSearch().init(!0,t.existingIKApp.cardInfo):t.showExistingIKTab?this.ikSearch().init(!0,null):this.ikSearch().init(!1,null),!t.data&&t.showExistingIKTab&&this.setNewIK(!1),t.data){var i=t.data;if(t.invalidIK){this.setIK(t.invalidIK);this.ikSearch().checkErrors();this.newIKApp().init(i);return}t.existingIKApp?(this.isNewIK(!1),this.existingIKApp()!=null&&this.existingIKApp().removeEvents(),this.existingIKApp(new r(this,t.existingIKApp,!1)),this.existingIKApp().init(i),t.ticket&&(this.existingTicketApp(new n.TicketForm(t.ticket,this.existingIKApp())),this.existingIKAppVisible(!1))):t.showExistingIKTab?this.setNewIK(!1):this.isNewIK(!0);this.newIKApp().init(i)}},f.prototype.getHistoryModel=function(n){var t=$.extend({},this.model);return t.newIKApp=this.newIKApp().getHistoryModel(),t.data=n,t.ticket=null,t.existingIKApp=null,this.isNewIK()||(t.existingIKApp=this.existingIKApp().getHistoryModel(),this.existingTicketApp()&&(t.ticket=this.existingTicketApp().getHistoryModel())),t},f}();n.AppBuyForm=f;u=function(){function n(n){var t=this;this.isInfoModal=ko.observable(!1);this.title=ko.observable("");this.content=ko.observable("");this.buttonMainTitle=ko.observable("");this.buttonMainUrl=ko.observable("");this.done=function(){t.appFormData!=undefined&&t.parentForm.done(t.appFormData,t.isCartInsert)};this.parentForm=n}return n.prototype.setAppFormData=function(n){this.appFormData=n},n}();n.AppsModal=u}(InKarta||(InKarta={})),function(n){var t=function(){function n(n,t){var i=this,r;this.from=ko.observable();this.to=ko.observable();this.vias=ko.observableArray();this.viaID=ko.observable();this.viaInfo=ko.observable("");this.viaIDS=ko.observableArray();this.validFromTo=ko.observable();this.serviceClass=ko.observable();this.hasPupilCard=ko.observable();this.pupilCardVisible=ko.observable();this.hasInApp=ko.observable();this.hasRT=ko.observable();this.ZTP_PVisible=ko.observable();this.ZTP_PRequired=ko.observable();this.hasZTP=ko.observable();this.hasZTPP=ko.observable();this.hasZTP_PCheck=ko.observable();this.hasInv3=ko.observable();this.inv3Visible=ko.observable();this.isINV3Visible=ko.observable();this.isOlder65Visible=ko.observable();this.isOlder65=ko.observable();this.isINRT=ko.observable(!1);this.price=ko.observable("");this.appPrice=ko.observable("");this.loyaltyPoints=ko.observable("");this.cardPrice=ko.observable("");this.hasLoyaltyAccount=ko.observable(null);this.documentConditions=ko.observable();this.info=ko.observable("");this.error=ko.observable(new ErrorInfo("error"));this.isAppForm=ko.observable();this.appForm=ko.observable();this.showInvoice=ko.observable(!1);this.setValidFrom=function(n){var r,u,t;i.validFromTo().setValidFrom(n);r=DateTimeHelper.addInterval(DateTimeHelper.addIntervalDays(n,i.model.period),"-1D");i.validFromTo().setValidTo(r);u=moment(DateTimeHelper.parseDate(i.model.minValidFrom));t=moment(n).diff(u,"days");i.pupilCardVisible(i.model.pupilCardVisible[t]=="1");i.hasInApp(i.model.hasInApp[t]=="1");i.model.ztP_PVisible!=undefined&&!Support.stringIsEmpty(i.model.ztP_PVisible)&&i.model.ztP_PVisible.length>t&&i.ZTP_PVisible(i.model.ztP_PVisible[t]=="1");i.model.inv3Visible!=undefined&&!Support.stringIsEmpty(i.model.inv3Visible)&&i.model.inv3Visible.length>t&&i.inv3Visible(i.model.inv3Visible[t]=="1");i.vias.removeAll();i.viaIDS.removeAll();i.resetPrice();$("#main .cd-select").refreshNiceSelect()};this.resetPrice=function(){return i.price(""),i.appPrice(""),i.loyaltyPoints(""),i.cardPrice(""),i.viaIDS().length>0&&i.viaIDS()[i.viaID()]==!0?i.error().message(App.messages.inKarta.idsInfo):i.error().message(""),i.info(""),i.viaInfo(""),i.showInvoice(!1),!0};this.stationFromChange=function(){return i.from().clearError(),i.vias.removeAll(),i.viaIDS.removeAll(),i.resetPrice(),$("#main .cd-select").refreshNiceSelect(),!0};this.stationToChange=function(){return i.to().clearError(),i.vias.removeAll(),i.viaIDS.removeAll(),i.resetPrice(),$("#main .cd-select").refreshNiceSelect(),!0};this.computePrice=function(){var n=i.updateModel({});$.ajax({url:App.getUrlAction("in-karta/ComputeRailwayTicketPrice"),type:"POST",headers:App.GetAntiForgeryTokenHeader(),data:JSON.stringify(n),dataType:"json",contentType:"application/json; charset=utf-8",success:function(n){ErrorHandler.checkErrors(n)||i.showPriceResult(n)}})};this.done=function(){i.isAppForm()?i.appForm().done(!i.showInvoice()):(history.pushState(i.getHistoryModel(),null,"#pokracovat"),window.location.href=App.getUrlAction("in-karta/fotografie"))};this.appForm(t);this.isAppForm(t!=null);this.isAppForm()||(n=history.state?history.state:n);this.model=n;this.isAppForm()?this.hasLoyaltyAccount(this.appForm().hasLoyaltyAccount()):this.hasLoyaltyAccount(n.hasLoyaltyAccount);this.documentConditionsModal=new UserIdentity.DocumentConditionsModal;this.from(new SearchForm.Station(!1,!0,"From","From",n.from));this.to(new SearchForm.Station(!1,!0,"To","To",n.to));n.vias&&(n.vias.forEach(function(n){i.vias.push(n)}),n.viaIDS.forEach(function(n){i.viaIDS.push(n)}),this.viaID(n.viaIndex.toString()));this.info("");this.isINRT(n.isINRT);this.hasPupilCard(n.hasPupilCard);this.hasRT(n.hasRT);this.ZTP_PRequired(n.ztP_PRequired);this.ZTP_PRequired()?this.hasZTP_PCheck("ztp"):this.hasZTP_PCheck("noztp");n.hasZTP&&this.hasZTP_PCheck("ztp");n.hasZTPP&&this.hasZTP_PCheck("ztpp");n.hasInv3&&this.hasZTP_PCheck("inv3");this.hasInv3(n.hasInv3);this.isINV3Visible(n.isINV3Visible);this.isOlder65(n.isOlder65);this.isOlder65Visible(n.isOlder65Visible);this.validFromTo(new FromToCalendar(this.setValidFrom));r={from:DateTimeHelper.parseDate(n.minValidFrom),to:DateTimeHelper.parseDate(n.maxValidFrom)};this.validFromTo().setEnabledDates([r]);this.setValidFrom(DateTimeHelper.parseDate(n.validFrom));this.serviceClass(n.serviceClass);this.isAppForm()||(ko.applyBindings(this.documentConditionsModal,document.getElementById("documentConditionsModal")),ko.applyBindings(this,document.getElementById("main")));setTimeout(function(){$("#main .cd-select").refreshNiceSelect();$("#main").find(".og-autocomplete").OGAutocomplete()});this.hasPupilCard.subscribe(function(){i.setValidFrom(i.validFromTo().validFrom());i.resetPrice()});this.hasZTP_PCheck.subscribe(function(){i.setValidFrom(i.validFromTo().validFrom());i.resetPrice()});this.isOlder65.subscribe(function(){i.resetPrice()});this.serviceClass.subscribe(function(){i.resetPrice()});this.viaID.subscribe(function(){i.resetPrice()});this.hasInv3.subscribe(function(){i.setValidFrom(i.validFromTo().validFrom());i.resetPrice()});n.from==null||n.to==null||Support.stringIsEmpty(n.from.name)||this.computePrice()}return n.prototype.updateModel=function(n){return n.tariffID=this.model.tariffID,n.from=this.from().serialize(),n.to=this.to().serialize(),n.validFrom=DateTimeHelper.toJSDate(this.validFromTo().validFrom()),n.serviceClass=this.serviceClass(),n.hasPupilCard=this.pupilCardVisible()&&this.hasPupilCard()||this.isINRT()&&this.hasPupilCard(),n.viaIndex=this.vias().length>0?parseInt(this.viaID()):-1,n.documentConditions=this.documentConditions(),n.hasZTP=!this.hasPupilCard()&&this.ZTP_PVisible()&&this.hasZTP_PCheck()=="ztp"&&this.serviceClass()=="Class2",n.hasZTPP=!this.hasPupilCard()&&this.ZTP_PVisible()&&this.hasZTP_PCheck()=="ztpp"&&this.serviceClass()=="Class2",n.hasInv3=!this.hasPupilCard()&&this.inv3Visible()&&this.hasZTP_PCheck()=="inv3"&&this.serviceClass()=="Class2"||this.hasInv3(),n.ztP_PRequired=this.model.ztP_PRequired,n.isOlder65=!this.hasPupilCard()&&this.isOlder65()&&this.serviceClass()=="Class2"||this.isINRT()&&this.isOlder65(),n.isINRT=this.isINRT(),n},n.prototype.showPriceResult=function(n){var i=this;this.from().error().message(n.errorFrom||"");this.to().error().message(n.errorTo||"");Support.stringIsEmpty(n.viaInfo)?this.viaInfo(""):(this.model.vias=n.vias,this.vias.removeAll(),n.vias.forEach(function(n){i.vias.push(n)}),this.model.viaIDS=n.viaIDS,this.viaIDS.removeAll(),n.viaIDS.forEach(function(n){i.viaIDS.push(n)}),this.viaID(n.vias[0].value),this.viaInfo(n.viaInfo));this.documentConditions(n.documentConditionsModel);this.info(n.info);this.error().message(n.error||"");!this.error().isVisible()&&this.viaIDS().length>0&&this.viaIDS()[this.viaID()]==!0&&this.error().message(App.messages.inKarta.idsInfo);n.priceComputed?(this.price(Support.formatMoney(n.price,!0,!0)),n.appPrice>0?(this.loyaltyPoints(Support.formatLoyaltyPointsSum(n.loyaltyPoints,!0)),this.appPrice("+ "+Support.formatMoney(n.appPrice,!0,!0)+" "+n.appPriceInfo)):this.loyaltyPoints(Support.formatLoyaltyPoints(n.loyaltyPoints,!0)),this.model.cardPrice>0&&this.cardPrice("+ "+Support.formatMoney(this.model.cardPrice,!0,!0)+" "+App.messages.inKarta.cardPrice),this.showInvoice(n.price+n.appPrice+this.model.cardPrice>=this.appForm().parent.invoiceMinPrice)):(this.loyaltyPoints(Support.formatLoyaltyPoints(n.loyaltyPoints,!0)),this.price(""),this.showInvoice(!1));$("#main .cd-select").refreshNiceSelect();var f=jQuery(window).height(),t=jQuery(".adduservalues"),r=t.offset(),e=t.height(),u=jQuery(document).scrollTop(),o=u+f;r.top>u&&r.top+e<o||$("html,body").animate({scrollTop:t.offset().top},0)},n.prototype.showConfirmModal=function(){if(Support.stringIsEmpty(this.hasRT()))this.done();else{var n=$("#RTModal");n.modal("show")}},n.prototype.getHistoryModel=function(){var n=$.extend({},this.model);return this.updateModel(n),n},n.prototype.documentConditionsOpen=function(){$("#documentConditionsModal").modal("show");this.isAppForm()?this.appForm().parent.documentConditionsModal.show(this.documentConditions()):this.documentConditionsModal.show(this.documentConditions())},n}();n.TicketForm=t}(InKarta||(InKarta={})),function(n){var i=function(){function n(){}return n}(),r,t;n.PhotoSettings=i;r=function(){function n(n){var i=this;this.photoVisible=ko.observable(!1);this.photoUrl=ko.observable("");this.canUseOldPhoto=ko.observable(!1);this.canSave=ko.observable(!1);this.error=ko.observable(new ErrorInfo("photo"));this.imageLoaded=function(){i.error().message("");i.canSave(!1);setTimeout(function(){i.crop.getImage(i.imageLoadedCheck)})};this.imageLoadedCheck=function(){i.canSave(!0)};this.done=function(){i.originalImage!=undefined&&i.saveImageCallback(i.originalImage,!0);i.crop.getImage2(i.saveImageCallback)};this.saveImageCallback=function(n,t){var r=i,u=new FormData,e=$('input[name="__RequestVerificationToken"]').val(),f;u.append("__RequestVerificationToken",e);t?u.append("data",n,"original.jpg"):(u.append("data",n,"small.jpg"),f=r.crop.getSettings(),u.append("settings",JSON.stringify(f)));$.ajax({type:"POST",url:App.getUrlAction("in-karta/UploadPhoto"),data:u,processData:!1,contentType:!1}).done(function(n){ErrorHandler.checkErrorsWithInfo(n,r)||t||(r.error().message(""),r.photoVisible(!0),r.canSave(!1),r.crop.resetImage(),r.doneUsePhoto())})};this.useOldPhoto=function(){$.post(App.getUrlAction("in-karta/UseOldPhoto"),{__RequestVerificationToken:App.GetAntiForgeryToken()},function(n){ErrorHandler.checkErrors(n)||(i.model.photoVisible=!1,history.pushState(i.model,null,"#pokracovat"),window.location.href=App.getUrlAction("in-karta/osobni-udaje"))})};n=history.state?history.state:n;this.model=n;this.photoVisible(n.photoVisible);this.canUseOldPhoto(n.canUseOldPhoto);n.photoVisible?(this.photoUrl(App.getUrlAction("in-karta/photoOriginal?t="+(new Date).getTime())),$.post(App.getUrlAction("in-karta/PhotoGetSettings"),{__RequestVerificationToken:App.GetAntiForgeryToken()},function(n){ErrorHandler.checkErrors(n)||(i.photoSettings=JSON.parse(n),i.crop=new t(i.photoUrl(),i,i.photoSettings,i.imageLoaded),i.canSave(!0))})):this.crop=new t(n.defaultImagePath,this,null,this.imageLoaded);ko.applyBindings(this,document.getElementById("main"))}return n.prototype.doneUsePhoto=function(){var n=this;$.post(App.getUrlAction("in-karta/UseNewPhoto"),{__RequestVerificationToken:App.GetAntiForgeryToken()},function(t){ErrorHandler.checkErrors(t)||(n.model.photoVisible=!0,n.continueNext())})},n.prototype.continueNext=function(){history.pushState(this.model,null,"#pokracovat");window.location.href=App.getUrlAction("in-karta/fotografie-kontrola")},n.prototype.rotateRight=function(){this.crop.rotateRight()},n.prototype.zoomOut=function(){this.crop.zoomIn()},n.prototype.zoomIn=function(){this.crop.zoomOut()},n}();n.PhotoForm=r;t=function(){function n(n,t,i,r){var u=this;if(this.getImage=function(n){u.c.result({type:"canvas",size:"original",format:"jpeg"}).then(function(t){n(t)})},this.getImage2=function(n){u.c.result({type:"blob",size:{width:276,height:354},format:"jpeg"}).then(function(t){n(t,!1)})},this.resetImage=function(){$("#filePhoto").val("")},this.loadCallback=r,this.parent=t,!Support.isIE9OrBelow()){this.c=new Croppie(document.getElementById("photoComponent"),{viewport:{width:160,height:206},boundary:{width:200,height:257},showZoomer:!0,enableOrientation:!1,enableExif:!0,enableZoom:!0});i!=null?this.c.bind({url:n,points:i.points,zoom:i.zoom,orientation:i.orientation}):this.c.bind({url:n});$("#filePhoto").on("change",function(n){u.readFile(n.target)})}}return n.prototype.readFile=function(n){var i=this,t,r,u;if(n.files&&n.files[0]){if(t=n.files[0],t.size>24e5){this.parent.error().message(App.messages.inKarta.photoSizeTooLarge);return}if(!t.type.match("image/jp.*")&&!t.type.match("image/png")&&!t.type.match("image/gif")&&!t.type.match("image/bmp")&&!t.type.match("image/svg.*")){this.parent.error().message(App.messages.inKarta.disabledPhotoExtension);return}r=new FileReader;r.onload=function(n){i.c.bind({url:n.target.result});i.loadCallback()};r.readAsDataURL(n.files[0]);u=new FileReader;u.onload=function(n){i.parent.originalImage=new Blob([new Uint8Array(n.target.result)])};u.readAsArrayBuffer(n.files[0])}},n.prototype.rotateRight=function(){this.c.rotate(90)},n.prototype.zoomIn=function(){var n=this.c.get();this.c.setZoom(n.zoom-.1)},n.prototype.zoomOut=function(){var n=this.c.get();this.c.setZoom(n.zoom+.1)},n.prototype.getSettings=function(){var t=this.c.get(),r=t.orientation,n;return t.orientation==undefined&&(r=1),n=new i,n.zoom=t.zoom,n.points=t.points,n.orientation=r,n},n}()}(InKarta||(InKarta={})),function(n){var t=function(){function n(n){var t=this;this.photoVisible=ko.observable(!1);this.photoUrl=ko.observable("");this.done=function(){history.pushState(t.model,null,"#pokracovat");window.location.href=App.getUrlAction("in-karta/osobni-udaje")};n=history.state?history.state:n;this.model=n;n.photoVisible&&this.photoUrl(App.getUrlAction("in-karta/photo?t="+(new Date).getTime()));this.photoVisible(n.photoVisible);ko.applyBindings(this,document.getElementById("main"))}return n.prototype.back=function(){window.location.href=App.getUrlAction("in-karta/fotografie")},n}();n.PhotoSummaryForm=t}(InKarta||(InKarta={})),function(n){var t=function(){function n(n){var t=this;this.name=ko.observable("");this.surname=ko.observable("");this.pob=ko.observable("");this.street=ko.observable("");this.streetNumber=ko.observable("");this.city=ko.observable("");this.zip=ko.observable("");this.state=ko.observable("");this.phone=ko.observable("");this.email=ko.observable("");this.showLR=ko.observable(!1);this.lrName=ko.observable("");this.lrSurname=ko.observable("");this.lrAddress=ko.observable("");this.isDuplicate=ko.observable(!1);this.isEmployee=ko.observable(!1);this.checkLR=function(n){var i=DateTimeHelper.parseDate(t.model.appValidFrom);n=DateTimeHelper.addInterval(n,"15Y");t.showLR(!t.isDuplicate()&&n>i)};this.validateDOB=function(n){return!Support.stringIsEmpty(t.model.minDOB)&&n<DateTimeHelper.parseDate(t.model.minDOB)?App.messages.inKarta.errorDOBApp:!Support.stringIsEmpty(t.model.maxDOB)&&n>DateTimeHelper.parseDate(t.model.maxDOB)?App.messages.inKarta.errorDOBApp:""};this.validateLRDOB=function(n){return(n=DateTimeHelper.addInterval(n,"18Y"),n>DateTimeHelper.today())?App.messages.inKarta.errorLR18:""};this.done=function(){if(t.checkErrors()){var n=t.updateModel({});$.post(App.getUrlAction("in-karta/osobni-udaje"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(n){if(!ErrorHandler.checkErrors(n)){var i=$.extend({},t.model);t.updateModel(i);history.pushState(i,null,"#pokracovat");window.location.href=App.getUrlAction("in-karta/identifikace-drzitele")}})}};n=history.state?history.state:n;this.model=n;this.dob=new DOBPicker2({dobErrTop:!1,disabled:n.isDuplicate,validate:this.validateDOB,setDOBDate:this.checkLR});this.lrdob=new DOBPicker2({dobIdSufix:"lrdob",dobErrTop:!1,validate:this.validateLRDOB});this.name(n.name);this.surname(n.surname);Support.stringIsEmpty(n.dob)||(this.dob.setDate(DateTimeHelper.parseDate(n.dob)),this.checkLR(DateTimeHelper.parseDate(n.dob)));this.pob(n.pob);this.street(n.street);this.streetNumber(n.streetNumber);this.city(n.city);this.zip(n.zip);this.state(Support.stringIsEmpty(n.state)?"ČR":n.state);this.phone(Support.stringIsEmpty(n.phone)?"+420 ":n.phone);this.email(n.email);this.lrName(n.lrName);this.lrSurname(n.lrSurname);Support.stringIsEmpty(n.lrdob)||this.lrdob.setDate(DateTimeHelper.parseDate(n.lrdob));this.lrAddress(n.lrAddress);this.isDuplicate(n.isDuplicate);this.isEmployee(n.isEmployee);n.isInvoice&&(this.invoice=new InvoiceForm(n.isInvoiceSelected,n.invoice,0,n.isInvoiceDenied));this.setValidation();this.errors=ko.validation.group(this);ko.applyBindings(this,document.getElementById("main"));this.dob.init();this.lrdob.init();$(".cd-select").refreshNiceSelect()}return n.prototype.setValidation=function(){var n=this;this.name.extend({canValidate:!1,validation:[{onlyIf:function(){return n.name.canValidate()},validator:function(n){return ValidationHelper.checkMinLength(n,2)},message:App.messages.validation.requiredItem},{onlyIf:function(){return n.name.canValidate()},validator:function(n){return ValidationHelper.checkIKChars(n,!1," -")},message:App.messages.validation.errorInvalidChars}]});this.surname.extend({canValidate:!1,validation:[{onlyIf:function(){return n.surname.canValidate()},validator:function(n){return ValidationHelper.checkMinLength(n,2)},message:App.messages.validation.requiredItem},{onlyIf:function(){return n.surname.canValidate()},validator:function(n){return ValidationHelper.checkIKChars(n,!1," -")},message:App.messages.validation.errorInvalidChars},{onlyIf:function(){return n.surname.canValidate()},validator:function(t){return ValidationHelper.checkMaxLength(t+" "+n.name(),39)},message:App.messages.inKarta.errorSurnameNameMaxLength}]});this.pob.extend({canValidate:!1,validation:[{onlyIf:function(){return n.pob.canValidate()&&!n.isDuplicate()},validator:function(n){return ValidationHelper.checkMinLength(n,2)},message:App.messages.validation.requiredItem},{onlyIf:function(){return n.pob.canValidate()&&!n.isDuplicate()},validator:function(n){return ValidationHelper.checkIKChars(n,!0," -'.()")},message:App.messages.validation.errorInvalidChars}]});this.street.extend({canValidate:!1,validation:[{onlyIf:function(){return n.street.canValidate()&&!n.isDuplicate()},validator:function(n){return ValidationHelper.checkMinLength(n,2)},message:App.messages.validation.requiredItem},{onlyIf:function(){return n.street.canValidate()&&!n.isDuplicate()},validator:function(n){return ValidationHelper.checkIKChars(n,!0," -'.(),/")},message:App.messages.validation.errorInvalidChars}]});this.streetNumber.extend({canValidate:!1,validation:[{onlyIf:function(){return n.streetNumber.canValidate()&&!n.isDuplicate()},validator:function(n){return ValidationHelper.checkMinLength(n,1)},message:App.messages.validation.requiredItem},{onlyIf:function(){return n.streetNumber.canValidate()&&!n.isDuplicate()},validator:function(n){return ValidationHelper.checkIKChars(n,!0," -'.(),/")},message:App.messages.validation.errorInvalidChars}]});this.city.extend({canValidate:!1,validation:[{onlyIf:function(){return n.city.canValidate()&&!n.isDuplicate()},validator:function(n){return ValidationHelper.checkMinLength(n,2)},message:App.messages.validation.requiredItem},{onlyIf:function(){return n.city.canValidate()&&!n.isDuplicate()},validator:function(n){return ValidationHelper.checkIKChars(n,!0," -'.(),/")},message:App.messages.validation.errorInvalidChars}]});this.zip.extend({canValidate:!1,validation:[{onlyIf:function(){return n.zip.canValidate()&&!n.isDuplicate()},validator:function(n){return ValidationHelper.checkMinLength(n,2)},message:App.messages.validation.requiredItem},{onlyIf:function(){return n.zip.canValidate()&&!n.isDuplicate()},validator:function(n){return ValidationHelper.checkZipCode(n)},message:App.messages.validation.errorZipCode}]});this.state.extend({canValidate:!1,validation:[{onlyIf:function(){return n.state.canValidate()&&!n.isDuplicate()},validator:function(n){return ValidationHelper.checkMinLength(n,1)},message:App.messages.validation.requiredItem},{onlyIf:function(){return n.state.canValidate()&&!n.isDuplicate()},validator:function(n){return ValidationHelper.checkIKChars(n,!1," -")},message:App.messages.validation.errorInvalidChars}]});this.phone.extend({canValidate:!1,validation:[{onlyIf:function(){return n.phone.canValidate()},validator:function(n){return ValidationHelper.isPhoneNumber(n,"+420")},message:App.messages.validation.errorPhone},{onlyIf:function(){return n.phone.canValidate()&&n.email.canValidate()},validator:function(t){return t=t.replace(" ","").replace("+420",""),ValidationHelper.checkMinLength(t+n.email(),1)},message:App.messages.inKarta.errorPhoneEmail}]});this.email.extend({canValidate:!1,validation:{onlyIf:function(){return n.email.canValidate()},validator:function(n){return ValidationHelper.isEmail(n)},message:App.messages.validation.errorEmail}});this.lrName.extend({canValidate:!1,validation:[{onlyIf:function(){return n.lrName.canValidate()&&n.showLR()},validator:function(n){return ValidationHelper.checkMinLength(n,2)},message:App.messages.validation.requiredItem},{onlyIf:function(){return n.lrName.canValidate()&&n.showLR()},validator:function(n){return ValidationHelper.checkIKChars(n,!1," -")},message:App.messages.validation.errorInvalidChars}]});this.lrSurname.extend({canValidate:!1,validation:[{onlyIf:function(){return n.lrSurname.canValidate()&&n.showLR()},validator:function(n){return ValidationHelper.checkMinLength(n,2)},message:App.messages.validation.requiredItem},{onlyIf:function(){return n.lrSurname.canValidate()&&n.showLR()},validator:function(n){return ValidationHelper.checkIKChars(n,!1," -")},message:App.messages.validation.errorInvalidChars}]});this.lrAddress.extend({canValidate:!1,validation:[{onlyIf:function(){return n.lrAddress.canValidate()&&n.showLR()},validator:function(n){return ValidationHelper.checkMinLength(n,2)},message:App.messages.validation.requiredItem},{onlyIf:function(){return n.lrAddress.canValidate()&&n.showLR()},validator:function(n){return ValidationHelper.checkIKChars(n,!0," -'.(),/")},message:App.messages.validation.errorInvalidChars}]})},n.prototype.checkErrors=function(){var n=!0;return this.name.canValidate(!0),this.surname.canValidate(!0),this.pob.canValidate(!0),this.street.canValidate(!0),this.streetNumber.canValidate(!0),this.city.canValidate(!0),this.zip.canValidate(!0),this.state.canValidate(!0),this.phone.canValidate(!0),this.email.canValidate(!0),this.errors().length>0&&(this.errors.showAllMessages(),n=!1),this.dob.checkErrors()||(n=!1),this.showLR()&&(this.lrName.canValidate(!0),this.lrSurname.canValidate(!0),this.lrAddress.canValidate(!0),this.lrdob.checkErrors()||(n=!1)),this.model.isInvoice&&this.invoice.isInvoiceSelected()&&(n=this.invoice.canSubmit()&&n),n},n.prototype.updateModel=function(n){return this.isDuplicate()&&this.isEmployee()||(n.name=this.name(),n.surname=this.surname()),this.isDuplicate()||(n.dob=DateTimeHelper.toJSDate(this.dob.getDate()),n.pob=this.pob(),n.street=this.street(),n.streetNumber=this.streetNumber(),n.city=this.city(),n.zip=this.zip(),n.state=this.state()),n.phone=Support.unifyPhoneNumber(this.phone()),n.email=this.email(),this.showLR()&&(n.lrName=this.lrName(),n.lrSurname=this.lrSurname(),n.lrdob=DateTimeHelper.toJSDate(this.lrdob.getDate()),n.lrAddress=this.lrAddress()),n.isInvoiceSelected=this.model.isInvoice&&this.invoice.isInvoiceSelected(),n.isInvoiceSelected&&(this.invoice.isInvoiceDenied()?(n.isInvoiceDenied=!0,this.invoice.model.sjt&&(n.invoice=this.invoice.getFormData())):n.invoice=this.invoice.getFormData()),n},n}();n.PersonalData=t}(InKarta||(InKarta={})),function(n){var t=function(){function n(n){var t=this;this.issueRegionAllowed=ko.observable(!1);this.issueStationAllowed=ko.observable(!1);this.partnerWarning=ko.observable(!1);this.issueStation=ko.observable("");this.issueStationItems=ko.observableArray();this.issueStationError=ko.observable(new ErrorInfo("IssueStation"));this.lastIssueStation="-";this.issueRegion=ko.observable(!1);this.stationIssueChange=function(n){(n===void 0&&(n=!0),t.lastIssueStation!=t.issueStation())&&(t.lastIssueStation=t.issueStation(),$.post(App.getUrlAction("in-karta/FindIssueStations"),{__RequestVerificationToken:App.GetAntiForgeryToken(),prefix:t.issueStation()},function(i){if(!ErrorHandler.checkErrors(i)){t.issueStationItems.removeAll();var r=i;r.forEach(function(n){return t.issueStationItems.push(n)});n&&!Support.parseBool($("#issueStation").attr("aria-expanded"))&&$("#issueStation").dropdown("toggle")}}))};this.selectStationIssue=function(n){t.issueStationError().message("");t.issueStationItems.removeAll();t.issueStationItems.push(n);t.lastIssueStation=n.name;t.issueStation(n.name)};this.done=function(){t.checkIssueStation().done(function(){if(t.checkErrors()){var n=t.updateModel({});$.post(App.getUrlAction("in-karta/identifikace-drzitele"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(n){if(!ErrorHandler.checkErrorsWithInfo(n,t))if(t.model.disableTerms)$.post(App.getUrlAction("in-karta/CartInsert"),{__RequestVerificationToken:App.GetAntiForgeryToken()},function(n){ErrorHandler.checkErrorsWithInfo(n,t)||(window.location.href=App.getUrlAction("kosik"))});else{var i=$.extend({},t.model);t.updateModel(i);history.pushState(i,null,"#pokracovat");window.location.href=App.getUrlAction("in-karta/podminky")}})}})};this.checkIssueStation=function(){var n=$.Deferred(),i=t.issueStation();return t.issueRegion()||!t.issueStationAllowed()?(t.issueStationError().message(""),n.resolve()):Support.stringIsEmpty(i)?(t.issueStationError().message(App.messages.validation.errorStationEmpty),n.resolve()):$.post(App.getUrlAction("in-karta/FindIssueStations"),{__RequestVerificationToken:App.GetAntiForgeryToken(),prefix:i},function(r){if(!ErrorHandler.checkErrors(r)){var u=r;u=u.filter(function(n){return n.name.toLowerCase()==i.toLowerCase()});u.length==0?t.issueStationError().message(App.messages.validation.errorStationNotExists):u.length>1&&t.issueStationError().message(App.messages.validation.errorStationAmbiguous);n.resolve()}}),n};this.model=n;this.issueRegionAllowed(n.issueRegionAllowed);this.issueStationAllowed(n.issueStationAllowed);this.partnerWarning(n.partnerWarning);this.stationIssueChange(!1);this.errors=ko.validation.group(this);ko.applyBindings(this,document.getElementById("main"));this.issueStationAllowed()&&!Support.stringIsEmpty(this.model.issueStation)&&this.issueStation(this.model.issueStation);this.issueStation.subscribe(function(){t.issueStationError().message("");clearTimeout(t.stationIssueHandle);t.stationIssueHandle=setTimeout(function(){t.stationIssueChange()},200)})}return n.prototype.checkErrors=function(){var n=!0;return this.issueStationError().isVisible()&&(n=!1),this.errors().length>0&&(this.errors.showAllMessages(),n=!1),n},n.prototype.updateModel=function(n){return n.issueStation=this.issueStation(),n.issueRegion=this.issueRegion(),this.issueStationAllowed()||(n.issueRegion=!0),n},n}();n.Identification=t}(InKarta||(InKarta={})),function(n){var t=function(){function t(t,i){var r=this;this.isVisible=ko.observable(!0);this.cardNumber=ko.observable("");this.lastCardNumber="";this.lastDOB="";this.ikSearchError=ko.observable(new ErrorInfo("ikSearch"));this.cards=ko.observableArray();this.cardInfo=ko.observable("");this.setIK=function(n){r.dob.setDate(DateTimeHelper.parseDate(n.dob));r.cardNumber(n.formattedCardNumber)};this.setIKIn=function(n){var i=n.getAttribute("data-is-pc-json"),t;i!=null&&i.length>0?(t=JSON.parse(i),t!=null&&(r.dob.setDate(DateTimeHelper.parseDate(t.date)),r.cardNumber(Support.formatIKNumber(t.id)))):r.cardNumber(n.value);n.removeAttribute("data-is-pc-json")};this.findIK=function(n){n===void 0&&(n=!1);var i=r.cardNumber(),t=r.dob.getDate()?DateTimeHelper.toJSDate(r.dob.getDate()):"";if(i!=r.lastCardNumber||t!=r.lastDOB||n){if(r.lastCardNumber=i,r.lastDOB=t,r.cardInfo(""),r.ikSearchError().message(""),!r.dob.isValid()||Support.stringIsEmpty(t)||Support.stringIsEmpty(r.cardNumber())||!r.cardNumber.isValid()||r.cardNumber.isValidating()){r.findIKCallback(null,null);return}r.findIKCallback(i,t)}};this.findIKCallback=i;t.cards&&t.cards.forEach(function(n){return r.cards.push(n)});this.dob=new DOBPicker2({dobErrTop:!0,setDOBDate:function(){r.findIK()}});this.ikDatail=new n.IKDetailModal;ko.applyBindings(this.ikDatail,document.getElementById("ikDetailModal"));this.setValidation();this.errors=ko.validation.group(this)}return t.prototype.init=function(n,t){var i=this;this.isVisible(n);t&&(t.formattedCardNumber&&(this.lastCardNumber=t.formattedCardNumber,this.cardNumber(t.formattedCardNumber)),t.dob&&(this.lastDOB=t.dob,this.dob.setDate(DateTimeHelper.parseDate(t.dob))),t.fullName&&this.cardInfo(t.fullName));this.dob.init();this.cardNumber.subscribe(function(){i.findIK()})},t.prototype.setValidation=function(){var n=this;this.cardNumber.extend({canValidate:!1,rateLimit:{method:"notifyWhenChangesStop",timeout:100},required:{onlyIf:function(){return n.cardNumber.canValidate()&&n.isVisible()},message:App.messages.validation.requiredItem},validation:[{onlyIf:function(){return n.cardNumber.canValidate()&&n.isVisible()},validator:function(n){return!Support.stringIsEmpty(n)&&ValidationHelper.isIKNumberDigits(n)},message:App.messages.validation.errorIKNumberDigits},{onlyIf:function(){return n.cardNumber.canValidate()&&n.isVisible()},validator:function(n){return!Support.stringIsEmpty(n)&&ValidationHelper.isIKNumberLength(n)},message:App.messages.validation.errorIKNumber}]})},t.prototype.showDetail=function(){this.ikDatail.show(this.cardNumber(),this.dob.getDate())},t.prototype.checkErrors=function(){this.cardNumber.canValidate(!0);var n=!0;return this.errors().length>0&&(this.errors.showAllMessages(),n=!1),this.dob.checkErrors()||(n=!1),this.ikSearchError().isVisible()&&(n=!1),n},t}();n.IKSearch=t}(InKarta||(InKarta={})),function(n){var t=function(){function n(n,t){var i=this;this.isLoggedUser=ko.observable(!1);this.cards=ko.observableArray();this.setIK=function(n){i.setIKCallback(n)};this.setIKCallback=t;this.isLoggedUser(n.isLoggedUser);n.cards&&n.cards.forEach(function(n){return i.cards.push(n)})}return n}();n.MyCards=t}(InKarta||(InKarta={})),function(n){var i=function(){function i(i){var r=this;this.ikSearch=ko.observable();this.prolongPrice=ko.observable("");this.prolongCharge=ko.observable("");this.surcharges=ko.observableArray();this.surchargeCharge=ko.observable("");this.myCards=ko.observable();this.summaryPrice=ko.observable("");this.formTitle=ko.observable(App.messages.inKarta.prolongFormTitle);this.hasProlong=ko.observable(!1);this.doneEnabled=ko.computed(function(){return r.hasProlong()||r.surcharges().length==0||r.surcharges().some(function(n){return n.isSelected()})},this);this.init=function(n){var t={formattedCardNumber:""||n.cardNumber,dob:""||n.dob};r.ikSearch().init(!0,t);n.validate&&r.ikSearch().checkErrors()&&r.ikSearch().findIK(!0)};this.formInit=function(n){n.price>0?r.prolongPrice(Support.formatMoney(n.price,!0,!0)):r.prolongPrice("");n.charge>0?r.prolongCharge(Support.formatMoney(n.charge,!0,!0)):r.prolongCharge("");r.surcharges.removeAll();n.surcharges&&n.surcharges.forEach(function(n){r.surcharges.push(new t(r,n))});r.hasProlong(n.hasProlong)};this.setIK=function(n){r.ikSearch().isVisible(!0);r.ikSearch().setIK(n)};this.findIK=function(n,t){if(!n){r.clearForm();return}$.ajax({url:App.getUrlAction("in-karta/prolongace/CreateProduct")+"?cardNumber="+n+"&dob="+t,type:"GET",success:function(n){var t,i;ErrorHandler.checkErrorsWithInfo(n,r)?r.clearForm():(t=n,r.formInit(t),r.model=t,r.hasProlong()?(i="",r.model.prolongYear>0&&(i=" "+App.messages.inKarta.prolongFormTitleYear+" "+r.model.prolongYear),r.formTitle(App.messages.inKarta.prolongFormTitle+i)):r.formTitle(App.messages.inKarta.surchargeFormTitle),r.ikSearch().cardInfo(t.cardInfo.fullName),r.summaryPrice(Support.formatMoney(r.priceSum(),!0,!0)))}})};this.clearForm=function(){r.formTitle(App.messages.inKarta.prolongFormTitle);r.summaryPrice("");r.prolongPrice("");r.prolongCharge("");r.surchargeCharge("");r.surcharges.removeAll()};this.priceSum=function(){var n=0,t=0;return n+=r.model.price,n+=r.model.charge,r.surcharges().forEach(function(i){i.isSelected()&&(i.isInvoice||(n+=i.price),i.charge>t&&(t=i.charge))}),t>0?(n+=t,r.surchargeCharge(Support.formatMoney(t,!0,!0))):r.surchargeCharge(""),n};this.getSurcharges=function(){var n=[];return r.surcharges().forEach(function(t){t.isSelected()&&n.push(t.model)}),n};this.done=function(){var n={cardNumber:r.ikSearch().cardNumber(),dob:DateTimeHelper.toJSDate(r.ikSearch().dob.getDate()),surcharges:r.getSurcharges(),hasProlong:r.hasProlong()},t=App.getUrlAction("in-karta/prolongace");$.post(t,{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(n){ErrorHandler.checkErrorsWithInfo(n,r)||(window.location.href=App.getUrlAction("kosik"))})};this.model=i;this.hasProlong(i.hasProlong);this.ikSearch(new n.IKSearch(i.cards,this.findIK));this.myCards(new n.MyCards(i.cards,this.setIK));ko.applyBindings(this,document.getElementById("main"));$("#main .cd-select").refreshNiceSelect();this.init(i)}return i}(),t;n.Prolongation=i;t=function(){function n(n,t){var i=this;this.isSelected=ko.observable(!1);this.priceFormatted=ko.observable("");this.priceFormattedStyle=ko.observable("");this.chargeFormated=ko.observable("");this.changeEnabled=ko.observable(!1);this.name=ko.observable("");this.setPrice=function(n){n?i.isInvoice?(i.priceFormatted(App.messages.inKarta.surchargeInvoice),i.priceFormattedStyle("prolongaddinfo")):(i.priceFormatted(Support.formatMoney(i.model.price,!0,!0)),i.priceFormattedStyle("price")):(i.priceFormatted(""),i.priceFormattedStyle("price"))};this.model=t;this.parent=n;this.price=t.price;this.charge=t.charge;this.typeID=t.typeID;this.isInvoice=t.isInvoice;this.changeEnabled(t.canChange);this.name(t.name);this.setPrice(t.isSet);t.charge>0?this.chargeFormated(Support.formatMoney(t.charge,!0,!0)):this.chargeFormated("");this.isSelected.subscribe(function(n){i.model.isSet=n;i.setPrice(n);i.parent.summaryPrice(Support.formatMoney(i.parent.priceSum(),!0,!0))});this.isSelected(t.isSet)}return n}();n.SurchargeItem=t}(InKarta||(InKarta={})),function(n){var t=function(){function t(t){var i=this;this.priceInput=ko.observable("");this.price=ko.computed(function(){if(!ValidationHelper.isNumberMin(i.priceInput(),0))return"";var n=ValidationHelper.getNumber(i.priceInput())*100;return Support.formatMoney(n,!0)},this);this.ikSearch=ko.observable();this.myCards=ko.observable();this.error=ko.observable(new ErrorInfo("rechargeEPInfo"));this.init=function(n){n.price&&i.priceInput((parseInt(n.price)/100).toString());var t={formattedCardNumber:""||n.cardNumber,dob:""||n.dob};i.ikSearch().init(!0,t);n.validate&&i.checkErrors()&&i.ikSearch().findIK(!0)};this.setIK=function(n){i.ikSearch().isVisible(!0);i.ikSearch().setIK(n)};this.findIK=function(n,t){if(!n){i.clearForm();return}$.ajax({url:App.getUrlAction("kredity-a-vouchery/dobiti-epik/FindIK")+"?cardNumber="+n+"&dob="+t,type:"GET",success:function(n){if(ErrorHandler.checkErrorsWithInfo(n,i))i.clearForm();else{var t=n;i.model.minPrice=t.minPrice;i.model.maxPrice=t.maxPrice;i.priceInput.notifySubscribers();i.ikSearch().cardInfo(t.cardInfo.fullName)}}})};this.clearForm=function(){i.ikSearch().cardNumber.isValid()||i.ikSearch().ikSearchError().message("");i.ikSearch().cardInfo("")};this.done=function(){if(i.checkErrors()){var n={cardNumber:i.ikSearch().cardNumber(),dob:DateTimeHelper.toJSDate(i.ikSearch().dob.getDate()),price:(ValidationHelper.getNumber(i.priceInput())*100).toString()},t=App.getUrlAction("kredity-a-vouchery/dobiti-epik");$.post(t,{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(n){ErrorHandler.checkErrorsWithInfo(n,i)||(window.location.href=App.getUrlAction("kosik"))})}};this.model=t;this.ikSearch(new n.IKSearch(t.cards,this.findIK));this.myCards(new n.MyCards(t.cards,this.setIK));this.setValidation();this.errors=ko.validation.group(this);t.rechargeError&&this.error().message(t.rechargeError);ko.applyBindings(this,document.getElementById("main"));$("#main .cd-select").refreshNiceSelect();this.init(t)}return t.prototype.setValidation=function(){var n=this;this.priceInput.extend({canValidate:!1,required:{onlyIf:function(){return n.priceInput.canValidate()},message:App.messages.validation.requiredItem},validation:[{onlyIf:function(){return n.priceInput.canValidate()},validator:function(t){return ValidationHelper.isNumberMin(t,n.model.minPrice/100)},message:App.messages.inKarta.errorRechargeEPPrice.format(Support.formatMoney(this.model.minPrice,!0))},{onlyIf:function(){return n.priceInput.canValidate()},validator:function(t){return ValidationHelper.isNumberRange(t,n.model.minPrice/100,n.model.maxPrice/100)},message:function(){return n.model.maxPrice==0?App.messages.inKarta.errorRechargeEPMaxAmount:App.messages.inKarta.errorRechargeEPPriceMax.format(Support.formatMoney(n.model.minPrice,!0),Support.formatMoney(n.model.maxPrice,!0))}}]})},t.prototype.checkErrors=function(){this.priceInput.canValidate(!0);var n=!0;return this.errors().length>0&&(this.errors.showAllMessages(),n=!1),this.ikSearch().checkErrors()||(n=!1),n},t}();n.RechargeEP=t}(InKarta||(InKarta={})),function(n){var t=function(){function n(){this.model=ko.observable()}return n.prototype.show=function(n,t){var i=this,r=t?DateTimeHelper.toJSDate(t):"";$.ajax({url:App.getUrlAction("in-karta/GetIKDetailInfo")+"?cardNumber="+n+"&dob="+r,type:"GET",success:function(n){ErrorHandler.checkErrors(n)||($("#ikDetailModal").modal("show"),i.model(n))}})},n}();n.IKDetailModal=t}(InKarta||(InKarta={})),function(n){var t=function(){function n(n){var t=this;this.conditionsAgreement=ko.observable(!1);this.done=function(){if(t.checkErrors()){var n=t.updateModel({});$.post(App.getUrlAction("in-karta/danovy-doklad"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(n){ErrorHandler.checkErrorsWithInfo(n,t)||$.post(App.getUrlAction("in-karta/CartInsert"),{__RequestVerificationToken:App.GetAntiForgeryToken()},function(n){ErrorHandler.checkErrorsWithInfo(n,t)||(window.location.href=App.getUrlAction("kosik"))})})}};n=history.state?history.state:n;this.model=n;n.isInvoice&&(this.invoice=new InvoiceForm(n.isInvoiceSelected,n.invoice,0,!1));this.setValidation();this.errors=ko.validation.group(this);ko.applyBindings(this,document.getElementById("main"));$(".cd-select").refreshNiceSelect()}return n.prototype.setValidation=function(){var n=this;this.conditionsAgreement.extend({canValidate:!1,equal:{onlyIf:function(){return n.conditionsAgreement.canValidate()},params:!0,message:App.messages.inKarta.errorConditionsAgreement}})},n.prototype.checkErrors=function(){var n=!0;return this.conditionsAgreement.canValidate(!0),this.errors().length>0&&(this.errors.showAllMessages(),n=!1),this.model.isInvoice&&this.invoice.isInvoiceSelected()&&(n=this.invoice.canSubmit()&&n),n},n.prototype.updateModel=function(n){return n.isInvoiceSelected=this.model.isInvoice&&this.invoice.isInvoiceSelected(),n.isInvoiceSelected&&(this.invoice.isInvoiceDenied()?(n.isInvoiceDenied=!0,this.invoice.model.sjt&&(n.invoice=this.invoice.getFormData())):n.invoice=this.invoice.getFormData()),n},n}();n.InvoiceData=t}(InKarta||(InKarta={})),function(n){var t=function(){function n(n){var t=this;this.conditionsAgreement_6=ko.observable(!1);this.conditionsAgreement_7=ko.observable(!1);this.isOlder16=ko.observable(!1);this.emailOffers_1=ko.observable(!1);this.profileAgreement_0=ko.observable(!1);this.checkProfile_2=ko.observable(!1);this.checkProfile_3=ko.observable(!1);this.error=ko.observable(new ErrorInfo("terms"));this.done=function(){var n,i;if(!t.checkErrors()){n=$("*[data-error-focus]").filter(":visible").first();n.length>0&&$("html,body").animate({scrollTop:n.offset().top-50},0);return}i=t.updateModel(t.model);$.post(App.getUrlAction("in-karta/podminky"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:i},function(n){ErrorHandler.checkErrorsWithInfo(n,t)||$.post(App.getUrlAction("in-karta/CartInsert"),{__RequestVerificationToken:App.GetAntiForgeryToken()},function(n){ErrorHandler.checkErrorsWithInfo(n,t)||(window.location.href=App.getUrlAction("kosik"))})})};this.model=n;this.errors=ko.validation.group(this);this.setValidation();this.isOlder16(!0);this.emailOffers_1(!0);ko.applyBindings(this,document.getElementById("main"));this.isOlder16.subscribe(function(n){t.emailOffers_1(n);t.profileAgreement_0(!1)});this.profileAgreement_0.subscribe(function(n){t.checkProfile_2(n);t.checkProfile_3(n)});this.checkProfile_2.subscribe(function(n){t.checkProfile_2()==t.checkProfile_3()&&t.profileAgreement_0(n)});this.checkProfile_3.subscribe(function(n){t.checkProfile_2()==t.checkProfile_3()&&t.profileAgreement_0(n)});this.model.termsChecked==undefined&&(this.model.termsChecked=[])}return n.prototype.setValidation=function(){var n=this;this.conditionsAgreement_6.extend({canValidate:!1,equal:{onlyIf:function(){return n.conditionsAgreement_6.canValidate()},params:!0,message:App.messages.inKarta.errorConditionsAgreement_6}});this.conditionsAgreement_7.extend({canValidate:!1,equal:{onlyIf:function(){return n.conditionsAgreement_7.canValidate()},params:!0,message:App.messages.inKarta.errorConditionsAgreement_7}})},n.prototype.checkErrors=function(){var n=!0;return this.conditionsAgreement_6.canValidate(!0),this.conditionsAgreement_7.canValidate(!0),this.errors().length>0&&(this.errors.showAllMessages(),n=!1),n},n.prototype.updateModel=function(n){for(n.termsChecked!=undefined&&(n.termsChecked=[]);n.termsChecked.length;)n.termsChecked.pop();return this.conditionsAgreement_6()&&n.termsChecked.push(6),this.conditionsAgreement_7()&&n.termsChecked.push(7),this.isOlder16()&&(this.emailOffers_1()&&n.termsChecked.push(1),this.checkProfile_2()&&n.termsChecked.push(2),this.checkProfile_3()&&n.termsChecked.push(3)),n},n}();n.Terms=t}(InKarta||(InKarta={})),function(n){var t=function(){function n(n){var t=this;this.customerEmail=ko.observable();this.cardHolderName=ko.observable();this.cardNumber=ko.observable();this.authorizationCode=ko.observable();this.cardHolderInfo=ko.observable();this.terminals=ko.observableArray();this.terminalID=ko.observable();this.error=ko.observable();this.paid=function(){if(t.canSubmit()){t.updateModel(t.model);var n=App.getUrlAction("kosik/motoPaid");$.post(n,{__RequestVerificationToken:App.GetAntiForgeryToken(),payMOTOModel:t.model},function(n){window.location.href=n.url})}};this.model=n;this.customerEmail(n.customerEmail);this.cardHolderName(n.cardHolderName);this.cardNumber(n.cardNumber);this.authorizationCode(n.authorizationCode);this.cardHolderInfo(n.cardHolderInfo);n.terminals.forEach(function(n){t.terminals.push(n)});this.terminals().length>0&&this.terminalID(this.terminals()[0].ident);this.setValidation();this.errors=ko.validation.group(this);this.error(this.model.paymentError);this.checkForErrors();ko.applyBindings(this,document.getElementById("main"));$(".cd-select").refreshNiceSelect()}return n.prototype.checkForErrors=function(){this.error()&&ErrorHandler.showAdvancedError("",this.error())},n.prototype.canSubmit=function(){return(this.customerEmail.canValidate(!0),this.cardHolderName.canValidate(!0),this.cardNumber.canValidate(!0),this.authorizationCode.canValidate(!0),this.cardHolderInfo.canValidate(!0),this.errors().length>0)?(this.errors.showAllMessages(),!1):!0},n.prototype.updateModel=function(n){n.authorizationCode=this.authorizationCode();n.cardHolderInfo=this.cardHolderInfo();n.cardHolderName=this.cardHolderName();n.cardNumber=this.cardNumber();n.customerEmail=this.customerEmail();n.terminalID=this.terminalID();n.paymentError=""},n.prototype.setValidation=function(){this.setValidationAll()},n.prototype.setValidationAll=function(){var n=this;this.customerEmail.extend({canValidate:!1,required:{onlyIf:function(){return n.customerEmail.canValidate()},message:App.messages.validation.requiredItem},validation:{onlyIf:function(){return n.customerEmail.canValidate()},validator:function(n){return ValidationHelper.isEmail(n)},message:App.messages.validation.errorEmail}});this.cardHolderName.extend({canValidate:!1,required:{onlyIf:function(){return n.cardHolderName.canValidate()},message:App.messages.validation.requiredItem},validation:{onlyIf:function(){return n.cardHolderName.canValidate()},validator:function(n){return n.length<60&&ValidationHelper.isCardName(n)},message:App.messages.validation.errorCardName}});this.cardNumber.extend({canValidate:!1,required:{onlyIf:function(){return n.cardNumber.canValidate()},message:App.messages.validation.requiredItem},validation:{onlyIf:function(){return n.cardNumber.canValidate()},validator:function(n){return ValidationHelper.isValidInput(n,"*")},message:App.messages.validation.errorCreditCardCode}});this.authorizationCode.extend({canValidate:!1,required:{onlyIf:function(){return n.authorizationCode.canValidate()},message:App.messages.validation.requiredItem},validation:{onlyIf:function(){return n.authorizationCode.canValidate()},validator:function(n){return n.length<=8&&ValidationHelper.isValidInput(n,"")},message:App.messages.validation.errorAuthorizationCode}});this.cardHolderInfo.extend({canValidate:!0,validation:{onlyIf:function(){return n.cardHolderInfo.canValidate()},validator:function(n){return ValidationHelper.isValidInput(n,"!%()?")},message:App.messages.validation.errorInvalidChars}})},n}();n.PayMOTO=t}(ShopCart||(ShopCart={})),function(n){var i=function(){function n(n){var i=this,r;if(this.code=ko.observable(),this.isShowWriteCode=ko.observable(),this.orders=ko.observableArray(),this.error=ko.observable(),this.submitCode=function(){if(i.checkErrors()){var n=i.getData();$.post(App.getUrlAction("jizdenky-pro-skupiny/vyzvednuti-jizdenky"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(t){ErrorHandler.checkErrorsWithInfo(t,i)||(window.location.href=n.isPV?App.getUrlAction("vyzvednuti-mistenky/identifikace-cestujiciho")+t.guid:App.getUrlAction("jizdenky-pro-skupiny/identifikace-cestujiciho")+t.guid)})}},this.model=n,this.model.waiting4PaymentOrders)for(r in this.model.waiting4PaymentOrders)this.orders().push(new t(this.model.waiting4PaymentOrders[r]));this.error(new ErrorInfo("GroupsForm"));this.isShowWriteCode(!n.isLoggedUser);this.setValidation();this.errors=ko.validation.group(this);this.setCanValidate(!1);this.setSubsribe();ko.applyBindings(this,document.getElementById("main"))}return n.prototype.setCanValidate=function(n){this.code.canValidate(n)},n.prototype.setSubsribe=function(){var n=this;this.code.subscribe(function(){n.clearError()})},n.prototype.clearError=function(){this.error().message("")},n.prototype.setValidation=function(){var n=this;this.code.extend({canValidate:!1,required:{onlyIf:function(){return n.code.canValidate()},message:App.messages.validation.requiredItem},validation:{onlyIf:function(){return n.code.canValidate()},validator:function(n){return n.replace("-","").length>11},message:App.messages.validation.errorCodeLength}})},n.prototype.checkErrors=function(){return(this.setCanValidate(!0),this.errors().length>0)?(this.errors.showAllMessages(),!1):!0},n.prototype.getData=function(){var n={};return n.code=this.code,n.fromText=!0,n.isPV=this.model.isPV,n},n.prototype.showWriteCode=function(){this.isShowWriteCode(!0)},n}(),t;n.Form=i;t=function(){function n(n){var t=this;this.error=ko.observable();this.submitCode=function(){var n=t.getData();$.post(App.getUrlAction("jizdenky-pro-skupiny/vyzvednuti-jizdenky"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(i){ErrorHandler.checkErrorsWithInfo(i,t)||(window.location.href=n.isPV?App.getUrlAction("vyzvednuti-mistenky/identifikace-cestujiciho")+i.guid:App.getUrlAction("jizdenky-pro-skupiny/identifikace-cestujiciho")+i.guid)})};this.model=n;this.error(new ErrorInfo("GroupsForm_"+n.code))}return n.prototype.getData=function(){var n={};return n.code=this.model.code,n.fromText=!1,n.isPV=this.model.isPV,n},n}();n.Waiting4PaymentOrder=t}(Groups||(Groups={})),function(n){var t=function(){function t(t,i,r,u,f){this.hasFocus=ko.observable();this.isReturn=ko.observable(!1);this.dateTime=ko.observable();this.stationFrom=ko.observable("");this.stationTo=ko.observable("");this.serviceClass=ko.observable("");this.class1Visible=ko.observable(!1);this.class2Visible=ko.observable(!1);this.classBusinessVisible=ko.observable(!1);this.passengers=ko.observable();this.corporateEdit=ko.observable();this.netTicket=ko.observable(!1);this.rootModel=i;this.passengers(u);this.corporateEdit(f);this.parentModel=t;this.calendarModal=r;this.dateTime(new n.DateTime(i.dateTime,i.formType,this.calendarModal,!1));this.netTicket(!1)}return t.prototype.show=function(t,i){var r,f,u;this.parentModel=t;this.item=i;this.netTicket(!1);this.item.docID>0&&this.item.tariffType>-1?(this.netTicket(!0),this.item.tariffType==205?(r=DateTimeHelper.nextDayDate(new Date,6),f={language:App.locale,orientation:"top left",autoclose:!0,format:"dd.mm.yyyy D",beforeShowDay:function(){return!0},todayHighlight:!0,daysOfWeekDisabled:[1,2,3,4,5],startDate:r},this.dateTime().firstValidDate=r,this.dateTime().dateThere().date(r),this.dateTime().dateThere().setDatePickerOptions(f)):(r=new Date,f={language:App.locale,orientation:"top left",autoclose:!0,format:"dd.mm.yyyy D",beforeShowDay:function(){return!0},todayHighlight:!0,startDate:r},this.dateTime().firstValidDate=r,this.dateTime().dateThere().date(r),u=new n.DateTimeData,u.date=r,u.hour="00",u.minute="00",u.isDeparture=!0,this.dateTime().dateThere().setCalendarParams(u),this.dateTime().dateThere().setDatePickerOptions(f))):(r=new Date,f={language:App.locale,orientation:"top left",autoclose:!0,format:"dd.mm.yyyy D",beforeShowDay:function(){return!0},todayHighlight:!0,startDate:r},this.dateTime().firstValidDate=r,this.dateTime().dateThere().date(r),u=new n.DateTimeData,u.date=r,u.hour="00",u.minute="00",u.isDeparture=!0,this.dateTime().dateThere().setCalendarParams(u),this.dateTime().dateThere().setDatePickerOptions(f));this.isReturn(this.item.isReturn);this.dateTime().isReturn(this.isReturn());this.item!=null&&(this.stationFrom(i.stationFrom),this.stationTo(i.stationTo),this.class1Visible(i.class1Visible),this.class2Visible(i.class2Visible),this.classBusinessVisible(i.classBusinessVisible),this.serviceClass(i.serviceClass),this.getMergedPassengers())},t.prototype.getMergedPassengers=function(){var t=this,n=this.parentModel.parentModel.userHistory().getUserHistoryModel();this.parentModel.parentModel.userHistory().updateModel(n);n.buyAgainCartItemID=this.item.cartItemId;$.post(App.getUrlAction("BuyAgain/GetMergedPassengers"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(n){ErrorHandler.checkErrorsWithInfo(n,t)||t.passengers().updatePassengers(n.passengers)})},t.prototype.searchPrice=function(){this.netTicket()?this.parentModel.searchNetPrice():this.parentModel.searchPrice()},t}(),i;n.BuyAgainModal=t;i=function(){function n(n,i,r,u,f){var e=this,o;this.showBuyAgain=function(n){$.post(App.getUrlAction("BuyAgain/ReloadItemModel"),{__RequestVerificationToken:App.GetAntiForgeryToken(),item:n},function(t){var i;if(!ErrorHandler.checkErrorsWithInfo(t,e)){if(i=t,i!=null){var r=e.parentModel.userHistory().getUserHistoryModel(),f=e.parentModel.userHistory().items().filter(function(n){return n.model.cartItemId==i.cartItemId})[0],u=r.items.indexOf(f.model,0);u>-1&&r.items.splice(u,1,i);e.buyAgainModal.show(e,i)}else e.buyAgainModal.show(e,n);$("#buyAgainModal").modal("show")}})};this.searchPrice=function(){if(e.buyAgainModal.corporateEdit().visible()&&e.buyAgainModal.corporateEdit().enabled()){if(!e.buyAgainModal.corporateEdit().canSubmit(!0))return;AjaxHelper.AjaxWaitShow(App.messages.ticketRefund.loaderProcessing);$.ajax({url:App.getUrlAction("")+"in-karta/checkCustomerInfo?ic="+e.buyAgainModal.corporateEdit().ic()+"&isICO=true&checkSAP=true",type:"GET",success:function(n){if(ErrorHandler.checkErrorsWithInfo(n,e)){AjaxHelper.AjaxWaitHide();return}AjaxHelper.AjaxWaitHide();e.setCustomerInfoData(n,!1)}})}else AjaxHelper.AjaxWaitShow(App.messages.connection.loaderSearchConnection),e.searchConnections()};this.searchNetPrice=function(){if(e.buyAgainModal.corporateEdit().visible()&&e.buyAgainModal.corporateEdit().enabled()){if(!e.buyAgainModal.corporateEdit().canSubmit(!0))return;AjaxHelper.AjaxWaitShow(App.messages.ticketRefund.loaderProcessing);$.ajax({url:App.getUrlAction("")+"in-karta/checkCustomerInfo?ic="+e.buyAgainModal.corporateEdit().ic()+"&isICO=true&checkSAP=true",type:"GET",success:function(n){if(ErrorHandler.checkErrorsWithInfo(n,e)){AjaxHelper.AjaxWaitHide();return}AjaxHelper.AjaxWaitHide();e.setCustomerInfoData(n,!0)}})}else AjaxHelper.AjaxWaitShow(App.messages.connection.loaderSearchConnection),e.searchNetTicket()};this.rootModel=i;this.calendarModal=r;this.parentModel=n;this.passengers=u;this.corporateEdit=f;this.rootModel.dateTime.date=moment().toDate().toDateString();this.rootModel.dateTime.dateReturn=moment().toDate().toDateString();this.buyAgainModal=new t(this,this.rootModel,this.calendarModal,this.passengers,this.corporateEdit);this.parentModel.isUserHistoryActive&&this.rootModel.userHistory.buyAgainCartItemID>0&&(o=this.rootModel.userHistory.items.filter(function(n){return n.cartItemId==e.rootModel.userHistory.buyAgainCartItemID})[0],o!=null&&(this.showBuyAgain(o),$("#buyAgainModal").modal("show")));ko.applyBindings(this.buyAgainModal,document.getElementById("buyAgainModal"))}return n.prototype.searchConnections=function(){var n=this,t=this.createEmptyModel();this.updateModel(t,!1);$("#buyAgainModal").modal("hide");$.post(App.getUrlAction("BuyAgain"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:t},function(t){if(ErrorHandler.checkErrorsWithInfo(t,n)){AjaxHelper.AjaxWaitHide();return}var i=t;if(i.guid!=null){if(i.passengersToSpecifyAge&&i.passengersToSpecifyAge.length>0){AjaxHelper.AjaxWaitHide();n.buyAgainModal.passengers().showAgeModal(i.passengersToSpecifyAge,i.passengersToSpecifyAgeState);return}window.location.href=App.getUrlAction("spojeni-tam")+i.guid}else window.location.href=App.getUrlAction("spojeni-tam")+t})},n.prototype.createEmptyModel=function(){return{ttCombination:this.rootModel.ttCombination,formType:this.rootModel.formType,isReturnOnly:this.rootModel.isReturnOnly,stations:{},services:{},dateTime:{},params:{},passengers:{},userHistory:{},corporateEdit:{}}},n.prototype.updateModel=function(n,t){n.services.serviceClass=this.buyAgainModal.serviceClass();this.buyAgainModal.dateTime().updateModel(n.dateTime);this.buyAgainModal.passengers().updateModel(n.passengers,t);this.buyAgainModal.corporateEdit().updateModel(n.corporateEdit);this.parentModel.userHistory().updateModel(n.userHistory);n.userHistory.buyAgainCartItemID=this.buyAgainModal.item.cartItemId},n.prototype.searchNetTicket=function(){var t=this,n={validity:DateTimeHelper.toJSDate(this.buyAgainModal.dateTime().dateThere().date()),docID:this.buyAgainModal.item.docID,tariffType:this.buyAgainModal.item.tariffType,corporateEdit:{}};this.buyAgainModal.corporateEdit().updateModel(n.corporateEdit);$("#buyAgainModal").modal("hide");$.post(App.getUrlAction("BuyAgainNetTicket"),{__RequestVerificationToken:App.GetAntiForgeryToken(),ntModel:n},function(n){if(ErrorHandler.checkErrorsWithInfo(n,t)){AjaxHelper.AjaxWaitHide();return}window.location.href=App.getUrlAction("volba-ceny-net")+n})},n.prototype.setCustomerInfoData=function(n,t){n==undefined||n.notFound||!Support.stringIsEmpty(n.errorMessage)?n==undefined||Support.stringIsEmpty(n.errorMessage)?this.buyAgainModal.corporateEdit().errorUWS(App.messages.connection.uwsError):n.notFound?this.buyAgainModal.corporateEdit().errorUWS(App.messages.connection.uwsErrorNotFound):this.buyAgainModal.corporateEdit().errorUWS(n.errorMessage):(this.buyAgainModal.corporateEdit().errorUWS(""),this.buyAgainModal.corporateEdit().sap(Number(n.invoice.sapCustomer)),this.buyAgainModal.corporateEdit().name(n.invoice.company));this.buyAgainModal.corporateEdit().showModalBuyAgain(this,t)},n}();n.BuyAgain=i}(SearchForm||(SearchForm={})),function(n){var t=function(){function n(n){var t=this;this.amountImput=ko.observable("");this.error=ko.observable();this.init=function(){var n=parseInt(t.model.amount);isNaN(n)||t.amountImput((n/100).toString());t.error().message(t.model.errorText)};this.submit=function(){if(t.checkErrors()){var n={amount:String(parseInt(t.amountImput())*100)};$.post(App.getUrlAction("kredity-a-vouchery/dobiti-cd-kredit"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(n){ErrorHandler.checkErrorsWithInfo(n,t)||(window.location.href=App.getUrlAction("kosik"))})}};this.activate=function(){window.location.href=t.model.activateUrl};this.model=n;this.setValidation();this.errors=ko.validation.group(this);this.setCanValidate(!0);this.setSubsribe();this.error(new ErrorInfo(n.errKey));ko.applyBindings(this,document.getElementById("main"));this.init()}return n.prototype.setCanValidate=function(n){this.amountImput.canValidate(n)},n.prototype.setSubsribe=function(){var n=this;this.amountImput.subscribe(function(){n.clearError()})},n.prototype.clearError=function(){this.error().message("")},n.prototype.setValidation=function(){var n=this;this.amountImput.extend({canValidate:!1,required:{onlyIf:function(){return n.amountImput.canValidate()},message:App.messages.validation.requiredItem},validation:{onlyIf:function(){return n.amountImput.canValidate()},validator:function(t){return ValidationHelper.isNumberRange(t,n.model.minAmount/100,n.model.maxAmount/100)},message:function(){return App.messages.inKarta.errorCARechargeAmount.format(Support.formatMoney(n.model.minAmount,!0),Support.formatMoney(n.model.maxAmount,!0))}}})},n.prototype.checkErrors=function(){return this.error().message()!=""?!1:(this.setCanValidate(!0),this.errors().length>0)?(this.errors.showAllMessages(),!1):!0},n}();n.Recharge=t}(CreditAccout||(CreditAccout={}));PriceSelectionNet=function(){function n(n,t){var i=this;this.simpleList=ko.observable();this.selectAndContinue=function(){window.location.href=App.getUrlAction("identifikace-cestujiciho")+i.guid};this.myTicket=new MyTicket(t);this.simpleList(!0);this.guid=n.guid;this.documentConditionsModal=new UserIdentity.DocumentConditionsModal;ko.applyBindings(this,document.getElementById("main"));ko.applyBindings(this.documentConditionsModal,document.getElementById("documentConditionsModal"))}return n.prototype.showSimpleList=function(n){this.simpleList(n)},n.prototype.documentConditionsOpen=function(n){var i=JSON.parse(n),t={};t.list=i;$("#documentConditionsModal").modal("show");this.documentConditionsModal.show(t)},n}(),function(n){var t=function(){function n(n){var t=this;this.code=ko.observable();this.error=ko.observable();this.submitCode=function(){if(t.checkErrors()){var n=t.getData();$.post(App.getUrlAction("uplatneni-poukazky-na-prepravu"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(n){ErrorHandler.checkErrorsWithInfo(n,t)||(window.location.href=n.redirectUrl)})}};this.model=n;this.error(new ErrorInfo(n.errorIdent));this.setValidation();this.errors=ko.validation.group(this);this.setCanValidate(!1);this.setSubsribe();ko.applyBindings(this,document.getElementById("main"));this.code(n.code);n.errorText&&this.error().message(n.errorText)}return n.prototype.setCanValidate=function(n){this.code.canValidate(n)},n.prototype.setSubsribe=function(){var n=this;this.code.subscribe(function(){n.clearError()})},n.prototype.clearError=function(){this.error().message("")},n.prototype.setValidation=function(){var n=this;this.code.extend({canValidate:!1,required:{onlyIf:function(){return n.code.canValidate()},message:App.messages.validation.requiredItem},validation:{onlyIf:function(){return n.code.canValidate()},validator:function(n){return n.replace("-","").length>11},message:App.messages.validation.errorCodeLength}})},n.prototype.checkErrors=function(){return Support.stringIsEmpty(this.error().message())?(this.setCanValidate(!0),this.errors().length>0)?(this.errors.showAllMessages(),!1):!0:!1},n.prototype.getData=function(){return{code:this.code()}},n}();n.TravelpassUse=t}(Travelpass||(Travelpass={})),function(n){var t,i;(function(n){n[n.sone=1]="sone";n[n.cdnet=2]="cdnet";n[n.summer=3]="summer";n[n.summerNet=4]="summerNet"})(t=n.NetTicketFormType||(n.NetTicketFormType={}));i=function(){function n(n){var i=this;this.runDate=ko.observable();this.submitCode=function(){var r=$("#travelpassNetTicket #ticketType .is-drop-val-left").data("value"),n="";n=i.model.type==t.sone||i.model.type==t.summerNet?"skupinova-jizdenka":"sitova-jizdenka";window.location.href="/eshop/"+n+"/"+r+"/"+i.runDate()+"/"};this.model=n;ko.applyBindings(this,document.getElementById("main"));this.runDate(n.runDate)}return n}();n.NetTicket=i}(Travelpass||(Travelpass={}));__extends=this&&this.__extends||function(){var n=function(t,i){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i])},n(t,i)};return function(t,i){function r(){this.constructor=t}n(t,i);t.prototype=i===null?Object.create(i):(r.prototype=i.prototype,new r)}}(),function(n){var i=function(n){function i(i,r,u,f){var e=n.call(this,i,r,u)||this;return e.userHistory=ko.observable(i),e.refundForm=ko.observable(f),new t({email:"",transactionCode:""},"zadani-dokladu",i.allItemsCount<1),e}return __extends(i,n),i}(SearchForm.UserHistory),t;n.TicketRefundFormHistory=i;t=function(){function n(n,t,i){var r=this;this.error=ko.observable();this.searchTicketForRefund=function(){if(r.checkErrors()){var n=r.getData();$.post(App.getUrlAction("vraceni-a-vymena"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(n){if(!ErrorHandler.checkErrorsWithInfo(n,r)){var t=$.extend({},r.model);r.updateModel(t);history.pushState(t,null,"");window.location.href=App.getUrlAction("vraceni-a-vymena/upresneni")}})}};n=history.state?history.state:n;this.model=n;this.email=ko.observable(n.email);this.transactionCode=ko.observable(n.transactionCode);this.isEmpty=ko.observable(i);this.error(new ErrorInfo("RefundError"));this.setValidation();this.errors=ko.validation.group(this);this.setCanValidate(!1);ko.applyBindings(this,document.getElementById(t))}return n.prototype.updateModel=function(n){n.transactionCode=this.transactionCode();n.email=this.email()},n.prototype.setCanValidate=function(n){this.transactionCode.canValidate(n);this.email.canValidate(n)},n.prototype.checkErrors=function(){return(this.setCanValidate(!0),this.errors().length>0)?(this.errors.showAllMessages(),!1):!0},n.prototype.getData=function(){var n={};return n.transactionCode=this.transactionCode,n.email=this.email,n},n.prototype.setValidation=function(){var n=this;this.transactionCode.extend({canValidate:!1,required:{onlyIf:function(){return n.transactionCode.canValidate()},message:App.messages.validation.requiredItem},validation:{onlyIf:function(){return n.transactionCode.canValidate()},validator:function(n){return n.length==6},message:App.messages.validation.errorTransactionCode}});this.email.extend({canValidate:!1,required:{onlyIf:function(){return n.email.canValidate()},message:App.messages.validation.requiredItem},validation:{onlyIf:function(){return n.email.canValidate()},validator:function(n){return ValidationHelper.isEmail(n)},message:App.messages.validation.errorEmail}})},n}();n.TicketRefundForm=t}(TicketRefund||(TicketRefund={})),function(n){var u,t,i,r,f,e,o;(function(n){n[n.TripCancel=0]="TripCancel";n[n.TrainNotRun=1]="TrainNotRun";n[n.TrainDelay=2]="TrainDelay";n[n.TrainNotInStation=3]="TrainNotInStation";n[n.TrainEnd=4]="TrainEnd";n[n.TrainReturn=5]="TrainReturn";n[n.TrainNot1stClass=6]="TrainNot1stClass";n[n.WithoutReservation=7]="WithoutReservation";n[n.OtherReason=8]="OtherReason"})(u=n.RefundReason||(n.RefundReason={})),function(n){n[n.ReturnTicket=0]="ReturnTicket";n[n.ReturnTicketPartial=1]="ReturnTicketPartial";n[n.ChangeReservation=2]="ChangeReservation";n[n.ChangePassengersCount=3]="ChangePassengersCount";n[n.ChangePassengerName=4]="ChangePassengerName";n[n.Return_Railway_Ticket=5]="Return_Railway_Ticket"}(t=n.RefundType||(n.RefundType={})),function(n){n[n.None=0]="None";n[n.Credit=1]="Credit";n[n.Account=2]="Account";n[n.Voucher=3]="Voucher";n[n.Accountvoucher=4]="Accountvoucher";n[n.Loyaltypoints=5]="Loyaltypoints"}(i=n.RefundPayment||(n.RefundPayment={})),function(n){n[n.DayBefore=0]="DayBefore";n[n.ToYesterday=1]="ToYesterday";n[n.ToToday=2]="ToToday"}(r||(r={}));f=function(){function n(n,t){var i=this;this.name=ko.observable("");this.data=ko.observable("");this.description=ko.observable("");this.error=ko.observable();this.isError=ko.computed(function(){return i.error()==undefined?!1:i.error().isVisible()},this);this.name(n);this.maxFileSize=t;this.error(new ErrorInfo("RefundErrorAttachment"))}return n.prototype.onFileSelectedEvent=function(n,t){var i=this,r;t!=undefined&&(r=this,ko.utils.arrayForEach(t.target.files,function(n){if(i.error().message(""),r.name(n.name),n.size>i.maxFileSize){i.error().message(App.messages.ticketRefund.maxFileSize);return}if(!n.type.match("image/jp.*")&&!n.type.match("image/png")&&!n.type.match("application/pdf")){i.error().message(App.messages.ticketRefund.disabledExtension);return}var t=new FileReader;t.onload=function(n){r.data=n.target.result};t.readAsDataURL(n)}))},n}();n.TicketRefundFile=f;e=function(){function n(n,t){var i=this;this.model=ko.observable();this.ticketItemsFormattedPrice1=ko.observable("");this.ticketItemsFormattedPrice2=ko.observable("");this.isSelected=ko.observable(!1);this.isTravelPass=ko.observable(!1);this.isInvoice=ko.observable(!1);this.isMOTO=ko.observable(!1);this.isParking=ko.observable(!1);this.isVisible=ko.observable(!0);this.model(t);this.parent=n;this.ticketRecordDataEshop=t.ticketEshop;this.ticketItemsFormattedPrice1("");this.ticketItemsFormattedPrice2("");this.price=t.refunds.price2Refund;this.loyaltyPoints=t.refunds.lP2Refund;this.vehicleIcon=Support.getVehicleIcon();this.isTravelPass(t.isTravelPass);this.isInvoice(n.model.isInvoice);this.isMOTO(n.model.isMOTO);this.isParking(t.isParking);this.isVisible(t.isVisible);this.isSelected.extend({notify:"always"});t.isSelected=!1;this.isSelected.subscribe(function(n){if(i.parent.clearError(),i.isTravelPass()||i.isMOTO()||i.isParking()){i.ticketItemsFormattedPrice1(App.messages.ticketRefund.requestForRefund);i.ticketItemsFormattedPrice2("");return}n?i.ticketItemsFormattedPrice1(App.messages.ticketRefund.toBeRefunded):i.ticketItemsFormattedPrice1(App.messages.ticketRefund.toRefund);i.loyaltyPoints>0?i.price>0?i.ticketItemsFormattedPrice2(Support.formatMoney(i.price,!0,!0)+" + "+i.ticketItemsFormattedPrice2(Support.formatLoyaltyPoints(i.loyaltyPoints,!0))):i.ticketItemsFormattedPrice2(Support.formatLoyaltyPoints(i.loyaltyPoints,!0,!1)):i.ticketItemsFormattedPrice2(Support.formatMoney(i.price,!0,!0))});this.isSelected(t.isSelected);this.parent.refundedAmount(this.parent.selectedPriceSum())}return n}();n.TicketItem=e;o=function(){function n(r){var o=this,v,y,s,l,p,a,h,w,b,c;this.reason=ko.observable("0");this.reasonList=ko.observableArray();this.refundTypeList=ko.observableArray();this.refundType=ko.observable("");this.attachment=ko.observableArray();this.isInvoice=ko.observable(!1);this.isMOTO=ko.observable(!1);this.isTravelPass=ko.observable(!1);this.moneyBackInfo=ko.observable("");this.refundedAmount=ko.observable();this.priceFee=ko.observable();this.refundAmount=ko.observable();this.loyaltyPointsFee=ko.observable();this.refundedLoyaltyPoints=ko.observable();this.refundSetup=ko.observable();this.refunds=ko.observable();this.dayOfBirth=ko.observable("");this.ikCardHolderValue=ko.observable();this.error=ko.observable();this.sendEnabledPartial=ko.observable(!0);this.sendEnabledChangeName=ko.observable(!0);this.showReasonText=ko.observable(!1);this.showAttachments=ko.observable(!1);this.showReturnTicketDate=ko.observable(!1);this.reasonOfRefundNote=ko.observable("");this.count=ko.observable();this.chngName=ko.observable(n.STANDARDNAME);this.returnTicketDate=ko.observable();this.selectedTicketDate=ko.observable(new Date);this.changeReservationDirectionList=ko.observableArray();this.changeReservationDirectionSelected=ko.observable("0");this.ticketItems=ko.observableArray();this.selectedPriceSum=ko.computed(function(){if(o.ticketItems().length>0&&o.refundType()==t.ReturnTicketPartial.toString()){if(o.clearError(),o.ticketItems().filter(function(n){return n.isVisible()}).every(function(n){return n.isSelected()==!0})||o.ticketItems().filter(function(n){return n.isVisible()}).every(function(n){return n.isSelected()==!1})?(o.sendEnabledPartial(!1),o.ticketItems().filter(function(n){return n.isVisible()}).every(function(n){return n.isSelected()==!0})&&o.error().message(App.messages.ticketRefund.allSelected)):o.sendEnabledPartial(!0),o.isMOTO())return o.refundedAmount(-1),o.refundedLoyaltyPoints(-1),o.priceFee(-1),o.refundAmount(-1),o.loyaltyPointsFee(-1),o.setMoneyBackInfo(i.None),o.getMoneyBackInfo(),-1;var n=0,r=0;return o.ticketItems().forEach(function(t){t.isSelected()&&t.isVisible()&&(n+=t.price,r+=t.loyaltyPoints)}),o.refundedAmount(n),o.refundedLoyaltyPoints(r),o.refundedAmount()<100&&o.refundedLoyaltyPoints()<=0?(o.refundedAmount(-1),o.refundedLoyaltyPoints(-1),o.priceFee(-1),o.refundAmount(-1),o.loyaltyPointsFee(-1),o.setMoneyBackInfo(),o.getMoneyBackInfo()):o.getMoneyBackInfo(),n}return o.refundedAmount()},this);this.sendEnabled=ko.computed(function(){var n=o.attachment().filter(function(n){return n.isError()});return n.length>0?!1:o.showAttachments()&&!o.canRemoveItem()&&o.showReasonText()&&Support.stringIsEmpty(o.reasonText())?!1:o.refundType()==t.ChangePassengersCount.toString()&&!o.canRemoveItem()&&Support.stringIsEmpty(o.reasonText())?!1:o.reason()=="-1"?!1:!o.sendEnabledPartial()&&o.refundType()==t.ReturnTicketPartial.toString()?!1:!o.sendEnabledChangeName()&&o.refundType()==t.ChangePassengerName.toString()?!1:!0},this);this.paymentMethodsVisible=ko.computed(function(){var n=o.refundSetup()==undefined?null:o.refundSetup().refundPaymentList;return o.refundType()==t.ReturnTicketPartial.toString()&&o.refundedAmount()<100?!1:o.refundType()==t.ChangeReservation.toString()&&o.refundedAmount()<100?!1:o.reason()==u.TrainReturn.toString()?!1:o.reason()=="-1"&&(o.refundType()==t.ReturnTicket.toString()||o.refundType()==t.Return_Railway_Ticket.toString())?!1:!(n==undefined||n.length==0)},this);this.isError=ko.computed(function(){return o.error()==undefined?!1:o.error().isVisible()},this);this.refundedAmountFormatted=ko.computed(function(){return o.refundedLoyaltyPoints()>0?o.refundedAmount()>0?Support.formatMoney(o.refundedAmount(),!0,!0)+" "+Support.formatLoyaltyPoints(o.refundedLoyaltyPoints(),!0):Support.formatLoyaltyPoints(o.refundedLoyaltyPoints(),!0,!1):Support.formatMoney(o.refundedAmount(),!0,!0)},this);this.feeFormatted=ko.computed(function(){return o.loyaltyPointsFee()>0?Support.formatLoyaltyPoints(o.loyaltyPointsFee(),!0,!1):o.priceFee()>0?Support.formatMoney(o.priceFee(),!0,!0):void 0},this);this.refundFormatted=ko.computed(function(){if(o.refundAmount()>0)return Support.formatMoney(o.refundAmount(),!0,!0)},this);this.isPaymentEnabled=ko.computed(function(){if(o.refundType()==t.ReturnTicket.toString()||o.refundType()==t.ReturnTicketPartial.toString()||o.refundType()==t.ChangePassengersCount.toString()||o.refundType()==t.Return_Railway_Ticket.toString()||o.refundType()==t.ChangeReservation.toString()){var n=o.refundSetup()==undefined?null:o.refundSetup().refundPaymentList;return Support.stringIsEmpty(o.refundedAmountFormatted())&&!o.paymentMethodsVisible()?!1:(n==undefined||n.length==0)&&Support.stringIsEmpty(o.refundedAmountFormatted())?!1:!0}return!1},this);this.addItem=function(){o.attachment().length<10&&o.attachment.push(new f(null,o.maxFileSize))};this.removeItem=function(n){o.attachment().length==1?(o.attachment.remove(n),o.addItem()):o.attachment.remove(n)};this.canRemoveItem=ko.computed(function(){return o.attachment().length>1||o.attachment().length==1&&!Support.stringIsEmpty(o.attachment()[0].name())},this);this.documentConditionsOpen=function(){$.post(App.getUrlAction("vraceni-a-vymena/GetDocumentConditions"),{__RequestVerificationToken:App.GetAntiForgeryToken()},function(n){ErrorHandler.checkErrorsWithInfo(n,o)||($("#documentConditionsModal").modal("show"),o.documentConditionsModal.show(n))})};this.sendSpecificationForm=function(){if(o.canSubmit()&&o.checkErrors()){var n=o.getData();AjaxHelper.AjaxWaitShow(App.messages.ticketRefund.loaderProcessing);$.post(App.getUrlAction("vraceni-a-vymena/upresneni"),{__RequestVerificationToken:App.GetAntiForgeryToken(),model:n},function(n){ErrorHandler.checkErrorsWithInfo(n,o)?AjaxHelper.AjaxWaitHide():(Support.stringIsEmpty(n.redirectUrl)||(window.location.href=n.redirectUrl),n.result!="OK"&&Support.stringIsEmpty(n.redirectUrl)?window.location.href=App.getUrlAction(n.result+"/"+o.model.transactionCode):(AjaxHelper.AjaxWaitHide(),o.confirmation(!0),$("#refundConfirmationBreadCrumb").css("display",""),$("#refundDetailBreadCrumb").css("display","none"),$("html,body").animate({scrollTop:0},0)))})}};this.checkSameName=function(n){return(n=n.trim(),!ValidationHelper.isCardName(n))?(o.sendEnabledChangeName(!1),!0):Support.stringIsEmpty(n)?(o.sendEnabledChangeName(!1),!0):n!=o.model.customerName?(o.sendEnabledChangeName(!0),!0):(o.sendEnabledChangeName(!1),!0)};this.countChange=function(){o.countChangeButton(0)};this.countChangeButton=function(n){o.clearError();var t=parseInt(o.count());isNaN(t)&&(t=o.countMin);t=Support.checkValueInInterval(t+n,o.countMin,o.countMax);o.count(t.toString())};this.setValidFrom=function(n){o.returnTicketDate().setValidFrom(n)};this.setIKCard=function(n){var i=n.getAttribute("data-is-pc-json"),t;i!=null&&i.length>0?(t=JSON.parse(i),t!=null&&(o.customerIKNumber.canValidate(!0),o.dayOfBirth.canValidate(!0),o.customerIKNumber(Support.formatIKNumber(t.id)),o.dob.setDOBFromDate(DateTimeHelper.parseDate(t.date)))):o.customerIKNumber(n.value);n.removeAttribute("data-is-pc-json")};this.openSchema=function(n){if(!Support.stringIsEmpty(n)){var t=700,i=960,r=(window.screen.width-(i+60))/2,u=(window.screen.height-(t+80))/2,f="/eshop/schema-vlaku/?sui="+n,e=window.open(f,"Schema","height="+t+", width="+i+", left="+r+", top="+u+", location=no, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes",!0);e.focus()}};this.model=r;this.reasonText=ko.observable(r.reasonText);this.refundPayment=ko.observable(r.refundPayment);this.customerIKNumber=ko.observable(r.customerIKNumber);this.customerEmail=ko.observable(r.customerEmail);this.customerName=ko.observable(r.customerName);this.validity=ko.observable(r.validity);this.irretrievable=ko.observable(r.irretrievable);this.confirmation=ko.observable(!1);this.dayOfBirth=ko.observable(this.model.dayOfBirth);this.reason("0");this.sendEnabledPartial=ko.observable(!0);this.maxFileSize=r.maxFileSize;this.dobIdSufix="1";this.dobErrTop=!0;this.dob=new DOBPicker(this);this.init=!1;this.isInvoice=ko.observable(this.model.isInvoice);this.isMOTO=ko.observable(this.model.isMOTO);this.isTravelPass=ko.observable(this.model.isTravelPass);r.refundSetupList&&(v=this.uniqueArray(r.refundSetupList),v.forEach(function(n){var t={name:n.refundType.name,value:n.refundType.value,shortName:n.refundType.shortName};o.refundTypeList.push(t)}));this.refundType.subscribe(function(){o.setRefundSetup()});this.refundType(r.refundType.toString());this.attachment.removeAll();r.attachment!=undefined&&r.attachment.forEach(function(n){o.attachment.push(new f(n.name(),o.maxFileSize))});this.attachment.length==0&&this.addItem();this.refundPayment.subscribe(function(n){o.clearError();n!=i.Loyaltypoints&&o.getMoneyBackInfo()});this.changeReservationDirectionSelected.subscribe(function(){if(o.clearError(),o.refundSetup()!=undefined&&o.refundSetup().changeReservationParams!=undefined){var n=o.refundSetup().changeReservationParams.filter(function(n){return n.reservationDirection.value.toString()==o.changeReservationDirectionSelected()});n!=undefined&&n.length>0&&(o.refundedAmount(n[0].price2Refund),o.refundedLoyaltyPoints(n[0].lP2Refund))}});this.customerName.subscribe(function(n){o.checkSameName(n)});this.reason.subscribe(function(n){if(o.refundType()!=t.Return_Railway_Ticket.toString()){if(o.clearError(),n!=undefined&&n!="-1"&&o.refundSetup()!=undefined&&o.refundSetup().reasonListExt!=undefined){var i=o.refundSetup().reasonListExt.filter(function(t){return t.value==Number(n)});if(i!=undefined&&i.length>0){o.showReasonText(i[0].showReasonText);o.showAttachments(i[0].showAttachments);o.showReturnTicketDate(i[0].showReturnTicketDate);o.reasonOfRefundNote(i[0].reasonOfRefundNote);return}}o.showReasonText(!1);o.showAttachments(!1);o.showReturnTicketDate(!1);o.reasonOfRefundNote("")}});y=this.model.refundSetupList.filter(function(n){return n.refundType.value==t.ChangePassengerName});y.length>0&&(Support.stringIsEmpty(this.customerIKNumber())||this.chngName(n.INCARDNAME),this.sendEnabledChangeName(!1));s=this.model.refundSetupList.filter(function(n){return n.refundType.value==t.ChangePassengersCount});s.length>0&&(this.count(s[0].personCount.toString()),this.countMax=s[0].personCount,this.countMin=s[0].personCountMin);l=this.model.refundSetupList.filter(function(n){return n.refundType.value==t.Return_Railway_Ticket});l.length>0&&(this.returnTicketDate(new FromToCalendar(this.setValidFrom)),p={from:DateTimeHelper.parseDate(l[0].ticketValidFrom),to:new Date},this.returnTicketDate().setEnabledDates([p]),this.setValidFrom(DateTimeHelper.today()),this.selectedTicketDate(DateTimeHelper.today()),this.returnTicketDate().validFrom.subscribe(function(n){n.getTime()!=o.selectedTicketDate().getTime()&&(o.selectedTicketDate(n),o.setRefundSetup())}));a=this.model.refundSetupList.filter(function(n){return n.refundType.value==t.ChangeReservation});a.length>0&&(h=a[0].changeReservationParams,h!=undefined&&h.length>0&&(h.forEach(function(n){var t={name:n.reservationDirection.name,value:n.reservationDirection.value,shortName:n.reservationDirection.shortName};o.changeReservationDirectionList.push(t)}),this.changeReservationDirectionSelected(this.changeReservationDirectionList()[0].value.toString())));w=this.model.refundSetupList.filter(function(n){return n.refundType.value==t.ReturnTicket});w.length>0;b=this.model.refundSetupList.filter(function(n){return n.refundType.value==t.ReturnTicketPartial});b.length>0&&(this.ticketItems.removeAll(),this.model.ticketItems&&this.model.ticketItems.length>0&&this.model.ticketItems.forEach(function(n){o.ticketItems.push(new e(o,n))}));this.error(new ErrorInfo("RefundError"));this.setValidation();this.errors=ko.validation.group(this);this.setCanValidate(!1);this.documentConditionsModal=new UserIdentity.DocumentConditionsModal;ko.applyBindings(this.documentConditionsModal,document.getElementById("documentConditionsModal"));ko.applyBindings(this,document.getElementById("main"));ko.applyBindings(this,document.getElementById("refundModal"));this.dayOfBirth(r.dayOfBirth);this.dob.initComponents();$("#passengersFavouriteModal .og-datepicker").ogDatePicker();this.dayOfBirth()==null&&Support.stringIsEmpty(this.dayOfBirth())||(c=this.dayOfBirth().split("."),this.dob.setInitialDOB(c[2],c[1],c[0]));this.dayOfBirth.subscribe(function(){o.customerIKNumber.valueHasMutated()});this.ikCardHolderValue.subscribe(function(){o.clearError()});$(".ispassenger-dd-ik").ISPassengerCardsDD({incardonly:!0});this.model.errorInfo!=undefined&&ErrorHandler.checkErrorsWithInfo(this.model.errorInfo,this)}return n.prototype.dobFirstValidDate=function(){return moment().add(-100,"year").toDate()},n.prototype.dobLastValidDate=function(){return new Date},n.prototype.setDOBDate=function(n){this.dayOfBirth(DateTimeHelper.formatDateBase(n))},n.prototype.setExtraValidation=function(){return this.NameInCard()},n.prototype.NameInCard=function(){return this.chngName()==n.INCARDNAME},n.prototype.RefundCredit=function(){return this.refundPayment()===i.Credit},n.prototype.RefundAccount=function(){return this.refundPayment()===i.Account},n.prototype.uniqueArray=function(n){for(var i=[],u,t=0,r=n.length;t<r;t++)u=i.filter(function(i){return i.refundType.value==n[t].refundType.value}),u.length==0&&i.push(n[t]);return i},n.prototype.setRefundSetup=function(n){var c=this,f,i,e,s,h,o,u;if(this.clearError(),f=this.model.refundSetupList.filter(function(n){return n.refundType.value.toString()==c.refundType()}),f.length!=0){if(i=f[0],e=!1,f.length>1?(n==undefined&&(n="-1"),i.refundType.value==t.Return_Railway_Ticket&&(this.returnTicketDate()==undefined||DateTimeHelper.isToday(this.returnTicketDate().validFrom())?n=="-1"?(e=!0,i=f.filter(function(n){return n.returnValidityType==r.ToToday})[0]):(s=f.filter(function(t){return t.returnValidityType==r.ToToday&&n==t.reason.toString()}),s.length>0&&(i=s[0])):(h=f.filter(function(n){return n.returnValidityType==r.ToYesterday}),h.length>0&&(i=h[0],n="0")),this.showReasonText(!1),this.showAttachments(!1),this.showReturnTicketDate(!0),this.reasonOfRefundNote(""),i==undefined||i.reasonListExt==undefined||e||(u=i.reasonListExt.filter(function(t){return t.value==Number(n)}),u!=undefined&&u.length>0&&(this.showReasonText(u[0].showReasonText),this.showAttachments(u[0].showAttachments),this.showReturnTicketDate(u[0].showReturnTicketDate),this.reasonOfRefundNote(u[0].reasonOfRefundNote))),this.model.ticketItems.filter(function(n){return n.ticketEshop.commuterType>0}).length>0&&this.showReturnTicketDate(!1)),i.refundType.value==t.ReturnTicket&&(n=="-1"?(e=!0,i=f[0]):(o=f.filter(function(t){return n==t.reason.toString()}),o.length>0?i=o[0]:Number(n)>100&&Number(n)<108&&(o=f.filter(function(n){return"-1"==n.reason.toString()}),o.length>0&&(i=o[0]))),this.showReasonText(!1),this.showAttachments(!1),this.showReturnTicketDate(!1),this.reasonOfRefundNote(""),i==undefined||i.reasonListExt==undefined||e||(u=this.refundSetup().reasonListExt.filter(function(t){return t.value==Number(n)}),u!=undefined&&u.length>0&&(this.showReasonText(u[0].showReasonText),this.showAttachments(u[0].showAttachments),this.showReturnTicketDate(u[0].showReturnTicketDate),this.reasonOfRefundNote(u[0].reasonOfRefundNote))))):n==undefined&&(n=i.reasonListExt.length>1?"-1":"0"),this.refundSetup(i),this.getReasonOptions(n),e){this.refundedAmount(-1);this.refundedLoyaltyPoints(-1);this.priceFee(-1);this.refundAmount(-1);this.loyaltyPointsFee(-1);this.moneyBackInfo(null);this.reason("-1");return}this.getRefundedAmount();this.getMoneyBackInfo();this.refundType()==t.ChangePassengersCount.toString()&&this.showAttachments(!0)}},n.prototype.getMoneyBackInfo=function(){var u=this,r,n;if(this.refundSetup()==undefined){this.moneyBackInfo(null);return}if(this.isInvoice()){this.moneyBackInfo(null);return}if(this.refundType()==t.ReturnTicketPartial.toString()&&this.refundedAmount()<100&&this.refundedLoyaltyPoints()<=0&&this.sendEnabledPartial()){this.setMoneyBackInfo();return}if(this.refundType()==t.ReturnTicketPartial.toString()&&this.refundedAmount()<100&&this.refundedLoyaltyPoints()>0&&this.sendEnabledPartial()){this.refundPayment(i.Loyaltypoints);this.setMoneyBackInfo(this.refundPayment());return}if(this.refundedAmount()<100&&this.refundedLoyaltyPoints()>0)this.refundPayment(i.Loyaltypoints),n=this.refundSetup().refundInfo.filter(function(n){return n.value==u.refundPayment()}),this.moneyBackInfo(n.length==0?null:n[0].shortName);else{if(this.refundPayment()==i.Loyaltypoints&&(r=this.refundSetup()==undefined?null:this.refundSetup().refundPaymentList,r!=undefined&&r.length>0)){this.refundPayment(r[0].value);return}n=this.refundSetup().refundInfo.filter(function(n){return n.value==u.refundPayment()});n.length==0&&(n=this.refundSetup().refundInfo.filter(function(n){return n.value==i.None}));this.moneyBackInfo(n.length==0?null:n[0].shortName)}if(Support.stringIsEmpty(this.refundedAmountFormatted())&&!this.paymentMethodsVisible()){this.moneyBackInfo(null);return}},n.prototype.setMoneyBackInfo=function(n){if(this.refundSetup()==undefined){this.moneyBackInfo(null);return}var t=this.refundSetup().refundInfo.filter(function(t){return t.value==n});this.moneyBackInfo(t.length==0?null:t[0].shortName)},n.prototype.getRefundType=function(n){return this.refundType()==n?!0:!1},n.prototype.getRefundedAmount=function(){var i=this,n;if(this.refundType()==t.ReturnTicketPartial.toString())this.selectedPriceSum();else if(this.refundType()==t.ChangeReservation.toString())this.refundSetup()!=undefined&&this.refundSetup().changeReservationParams!=undefined&&(n=this.refundSetup().changeReservationParams.filter(function(n){return n.reservationDirection.value.toString()==i.changeReservationDirectionSelected()}),n!=undefined&&n.length>0&&(this.refundedAmount(n[0].price2Refund),this.refundedLoyaltyPoints(n[0].lP2Refund)));else{if(this.refundSetup()==undefined){this.refundedAmount(-1);this.refundedLoyaltyPoints(-1);this.priceFee(-1);this.refundAmount(-1);this.loyaltyPointsFee(-1);return}this.refunds(this.refundSetup().refunds);this.refundedAmount(this.refundSetup().refunds.price2Refund);this.refundedLoyaltyPoints(this.refundSetup().refunds.lP2Refund);this.priceFee(this.refundSetup().refunds.deduction);this.refundAmount(this.refundSetup().refunds.refund);this.loyaltyPointsFee(this.refundSetup().refunds.deductionLP);this.sendEnabledPartial(!0)}},n.prototype.getModalInfo=function(){var i=this,n;if(this.refundSetup()!=undefined){if(this.refundType()==t.ReturnTicketPartial.toString()&&(this.refundedAmount()>=1||this.refundedAmount()<1&&this.refundedLoyaltyPoints()>0))return null;if(this.refundType()==t.ChangePassengersCount.toString()||this.refundType()==t.ChangePassengerName.toString())return this.refundSetup().modalInfo;if(this.refundSetup().reasonListExt!=undefined&&(n=this.refundSetup().reasonListExt.filter(function(n){return n.value==Number(i.reason())}),n!=undefined&&n.length>0))return n[0].modalInfo}return null},n.prototype.getSpecPlaceholder=function(){return this.refundSetup()==undefined?null:this.refundSetup().specificationPlaceholder},n.prototype.getReasonOptions=function(n){var t=this;this.refundSetup()!=undefined&&(this.reasonList.removeAll(),this.refundSetup().reasonListExt.length>1&&this.reasonList.push({name:App.messages.ticketRefund.selectReason,value:-1}),this.refundSetup().reasonListExt.forEach(function(n){t.reasonList.push({name:n.shortName,value:n.value})}),n!=undefined?this.reason(n):this.refundSetup().reasonListExt.length>1?this.reason("-1"):this.reason("0"),$("#refund .cd-select").refreshNiceSelect())},n.prototype.isPaymentVisible=function(n){var t=this.refundSetup()==undefined?null:this.refundSetup().refundPaymentList,i;return t==undefined||t.length==0?!1:(i=t.filter(function(t){return t.value.toString()==n}),i.length==0)?!1:!0},n.prototype.paymentName=function(n){var t=this.refundSetup()==undefined?null:this.refundSetup().refundPaymentList,i;return t==undefined||t.length==0?"":(i=t.filter(function(t){return t.value.toString()==n}),i.length==0)?"":i[0].shortName},n.prototype.clearError=function(){this.error()!=undefined&&(this.ticketItems().length>0&&this.refundType()==t.ReturnTicketPartial.toString()&&this.ticketItems().filter(function(n){return n.isVisible()}).every(function(n){return n.isSelected()==!0})||this.error().message(""))},n.prototype.backToEshopClick=function(){var n=this;$.post(App.getUrlAction("vraceni-a-vymena/BackToEshop"),{__RequestVerificationToken:App.GetAntiForgeryToken()},function(t){ErrorHandler.checkErrorsWithInfo(t,n)||(window.location.href=App.getUrlAction(""))})},n.prototype.showRefundModal=function(){if(this.reason()=="-1"&&(this.isError()?this.error().message(this.error().message()+"<br/>"+App.messages.ticketRefund.selectReasonError):this.error().message(App.messages.ticketRefund.selectReasonError)),this.showAttachments()&&!this.canRemoveItem()&&this.showReasonText()&&Support.stringIsEmpty(this.reasonText())&&(this.isError()?this.error().message(this.error().message()+"<br/>"+App.messages.ticketRefund.reasonTextAttachmentError):this.error().message(App.messages.ticketRefund.reasonTextAttachmentError)),this.canSubmit()&&this.checkErrors()&&!this.isError())if(Support.stringIsEmpty(this.getModalInfo()))this.sendSpecificationForm();else{var n=$("#refundModal");n.modal("show")}},n.prototype.setCanValidate=function(n){this.reasonText.canValidate(n);this.customerName.canValidate(!0);this.customerIKNumber.canValidate(!0);this.dayOfBirth.canValidate(!0)},n.prototype.reasonTextLength=function(){return 1200-this.reasonText().length},n.prototype.changeTab=function(){this.clearError();this.getMoneyBackInfo();$("#refund .cd-select").refreshNiceSelect()},n.prototype.changeTabRWT=function(){this.init||(this.init=!0,this.setRefundSetup(this.reason()),this.init=!1)},n.prototype.checkErrors=function(){if(this.setCanValidate(!0),this.errors().length>0)return this.errors.showAllMessages(),!1;var n=this.attachment().filter(function(n){return n.isError()});return n.length>0?!1:!0},n.prototype.getData=function(){var f=this,n={},r,i;return n.transactionCode=this.model.transactionCode,n.inkartaCode=this.model.inkartaCode,n.azakID=this.model.azakId,n.email=this.model.email,n.language=this.model.language,n.requestTime=this.model.requestTime,n.refundType=this.refundType(),n.reason=this.reason(),n.reasonText=encodeURIComponent(this.reasonText()),r=this.attachment().filter(function(n){return!Support.stringIsEmpty(n.name())}),n.attachment=r,n.refundPayment=this.refundPayment(),n.creditAccountNumber=this.model.creditAccountNumber,n.refunds=this.refunds(),n.customerName=this.model.customerName,n.customerIKNumber=this.model.customerIKNumber,this.refundType()==t.ReturnTicket.toString(),this.ticketItems&&this.ticketItems().length>0&&(this.refundType()==t.ReturnTicketPartial.toString()?this.ticketItems().forEach(function(n){n.model().isSelected=n.isSelected()?!0:!1}):this.ticketItems().forEach(function(n){n.model().isSelected=!0})),n.ticketItems=this.model.ticketItems,(this.refundType()==t.ReturnTicket.toString()&&this.reason()==u.TripCancel.toString()||this.refundType()==t.ReturnTicketPartial.toString()||this.refundType()==t.Return_Railway_Ticket.toString()&&this.reason()==u.TripCancel.toString())&&(n.reasonText="",n.attachment=undefined),this.refundType()==t.ChangeReservation.toString()&&(i=this.refundSetup().changeReservationParams.filter(function(n){return n.reservationDirection.value.toString()==f.changeReservationDirectionSelected()}),i!=undefined&&i.length>0&&(n.changeReservationParams=i[0])),this.refundType()==t.ChangePassengersCount.toString()&&(n.personCount=Number(this.count())),this.refundType()==t.ChangePassengerName.toString()&&(this.NameInCard()?(n.customerNameNew=this.ikCardHolderValue(),n.customerIKNumberNew=this.customerIKNumber()):(n.customerNameNew=this.customerName(),n.customerIKNumberNew="")),this.refundType()==t.Return_Railway_Ticket.toString()&&(n.returnValidityType=this.refundSetup().returnValidityType),n},n.prototype.canSubmit=function(){return(this.customerIKNumber.canValidate(!0),this.dayOfBirth.canValidate(!0),this.errors().length>0&&this.dob!==null&&this.dob.canSubmit())?(this.errors().length>0&&this.errors.showAllMessages(),!1):!0},n.prototype.setValidation=function(){var n=this;this.customerIKNumber.extend({canValidate:!1,required:{onlyIf:function(){return n.customerIKNumber.canValidate()&&n.NameInCard()&&n.refundType()==t.ChangePassengerName.toString()},message:App.messages.validation.requiredItem},validation:[{onlyIf:function(){return n.customerIKNumber.canValidate()&&n.NameInCard()&&n.refundType()==t.ChangePassengerName.toString()},validator:function(n){return ValidationHelper.isIKNumberDigits(n)},message:App.messages.validation.errorIKNumberDigits},{onlyIf:function(){return n.customerIKNumber.canValidate()&&n.NameInCard()&&n.refundType()==t.ChangePassengerName.toString()},validator:function(n){return ValidationHelper.isIKNumberLength(n)},message:App.messages.validation.errorIKNumber},{async:!0,onlyIf:function(){return n.customerIKNumber.canValidate()&&n.NameInCard()&&n.refundType()==t.ChangePassengerName.toString()},validator:function(t,i,r){if(!n.dayOfBirth.canValidate()||!n.dayOfBirth.isValid())return r(!0);$.ajax({url:App.getUrlAction("")+"CheckCardNumberIK?cardNumber="+n.customerIKNumber()+"&dob="+n.dayOfBirth(),type:"GET",success:function(t){n.ikCardHolderValue(t.info);n.checkSameName(n.ikCardHolderValue());r(t.result)}})},message:App.messages.connection.errorIKNumberBirthdate}]});this.dayOfBirth.extend({canValidate:!1,required:{onlyIf:function(){return n.dayOfBirth.canValidate()&&n.NameInCard()&&n.refundType()==t.ChangePassengerName.toString()},message:App.messages.validation.requiredItem},validation:{onlyIf:function(){return n.dayOfBirth.canValidate()&&n.NameInCard()&&n.refundType()==t.ChangePassengerName.toString()},validator:function(n){return ValidationHelper.checkDate(n)},message:App.messages.validation.errorBirthdate}});this.reasonText.extend({canValidate:!1,validation:[{onlyIf:function(){return n.reasonText.canValidate()&&n.showReasonText()},validator:function(t){return n.clearError(),t.length<1200},message:App.messages.validation.errorTooLargeText},{onlyIf:function(){return n.reasonText.canValidate()&&n.showReasonText()},validator:function(t){return n.clearError(),ValidationHelper.isValidInput(t,"!%()?")},message:App.messages.validation.errorInvalidChars}]});this.customerName.extend({canValidate:!1,required:{onlyIf:function(){return n.customerName.canValidate()&&!n.NameInCard()&&n.refundType()==t.ChangePassengerName.toString()},message:App.messages.validation.requiredItem},validation:[{onlyIf:function(){return n.customerName.canValidate()&&!n.NameInCard()&&n.refundType()==t.ChangePassengerName.toString()},validator:function(t){return n.checkSameName(t)&&ValidationHelper.isCardName(t)},message:function(){return App.messages.validation.errorCardName}},{onlyIf:function(){return n.customerName.canValidate()&&!n.NameInCard()&&n.refundType()==t.ChangePassengerName.toString()},validator:function(n){return ValidationHelper.checkMaxLength(n,50)},message:function(){return App.messages.validation.errorCardNameLength}}]})},n.prototype.incDecPsg=function(n,t){t.which===38?this.countChangeButton(1):t.which===40&&this.countChangeButton(-1)},n.STANDARDNAME="standardname",n.INCARDNAME="incardname",n}();n.TicketRefundDetail=o}(TicketRefund||(TicketRefund={}))