define("form/services/Rules",["app"],function(t){t.ng.service("Rules",["$rootScope","$q","$timeout","Form","Calc","Resource","Util","DynamicData","Scroll","Insights","Translation","Validation","Transact",function(t,e,a,r,n,i,c,s,o,l,u,d,h){function f(t){var e=t&&t.message+"\n"+t.fileName+":"+t.lineNumber;if(!(g.indexOf(e)>=0))throw g.push(e),r.view.transact.newFormApi&&e&&_&&parseInt(_.split(".")[0])>=18&&h.formError(e),t}var m,p,_,k=this,g=(u.T,[]);r.Rules=k,i.generated&&r.load().then(function(){p=r.getSystemData(),_=r.getSystemData("ServerBuildNumber"),m=p&&p.Job}),this.postsubmit_AvokaSmartForm=function(t,e,a){try{if(!t)return;t.AvokaSmartForm;"undefined"!=typeof GTM&&GTM.init()}catch(t){f(t)}},this.presubmit_AvokaSmartForm=function(t,e,a){try{if(!t)return;t.AvokaSmartForm;t.configurationClientID=window.gaClientId}catch(t){f(t)}},this.load_AvokaSmartForm=function(t,e,a){try{if(!t)return;t.AvokaSmartForm;if(maestro.Resource.preview)switch(t.configurationTemplateBrand){case"JDX":r.updateBranding({css:{id:"runtimeCssResource",cssUrl:"./css/jaguar.css"}});break;case"LRDX":r.updateBranding({css:{id:"runtimeCssResource",cssUrl:"./css/landrover.css"}});break;default:r.updateBranding({css:{id:"runtimeCssResource",cssUrl:"./css/default.css"}})}"undefined"==typeof RuntimeBranding||c.isBlank(t.configurationTargetCSSURL)||(maestro.Resource.preview=!1,RuntimeBranding.init()),getFormConfig(),"undefined"!=typeof FormScroller&&FormScroller.init(),"undefined"!=typeof MOI&&MOI.init(),"undefined"!=typeof CurrentVehicle&&CurrentVehicle.init(),c.isBlank(r.prefill.titles)||(t.$titles=JSON.parse(r.prefill.titles)),c.isBlank(r.prefill.academicTitles)||(t.$academicTitles=JSON.parse(r.prefill.academicTitles)),c.isBlank(r.prefill.regionStates)||(t.$regionStates=JSON.parse(r.prefill.regionStates)),"undefined"!=typeof COOKIEInit&&COOKIEInit(),u.fetch("fr")}catch(t){f(t)}},this.eq_configurationTemplateName=function(t,e,a){try{if(!t)return;t.configurationTemplateName;return"FP"}catch(t){f(t)}},this.eq_configurationTemplateBrand=function(t,e,a){try{if(!t)return;t.configurationTemplateBrand;return"JDX"}catch(t){f(t)}},this.eq_pageNames=function(t,e,a){try{if(!t)return;var r=(t.pageNames,t.configurationPages);return c.isBlank(t.convertTestDriveDate)||(r.page1.value=t.convertTestDriveDate),c.isBlank(t.selectedRetailerTrading)||(r.page2.value=t.selectedRetailerTrading),c.isBlank(t.personalDetailsFirstName)||(r.page3.value=t.personalDetailsFirstName),r.page1.html='<span class="number">'+r.page1.number+'</span><span class="name">'+r.page1.name+'</span><span class="value">'+r.page1.value+"</span>",r.page2.html='<span class="number">'+r.page2.number+'</span><span class="name">'+r.page2.name+'</span><span class="value">'+r.page2.value+"</span>",r.page3.html='<span class="number">'+r.page3.number+'</span><span class="name">'+r.page3.name+'</span><span class="value">'+r.page3.value+"</span>",r}catch(t){f(t)}},this.eq_configurationHeaderImageVisible=function(t,e,a){try{if(!t)return;t.configurationHeaderImageVisible;return!1!==t.configurationHeaderImageVisible}catch(t){f(t)}},this.sh_jlrFormHeader=function(t,e,a){try{if(!t)return;t.jlrFormHeader;return"FP"===t.configurationTemplateName}catch(t){f(t)}},this.sh_headerImageBlockNew=function(t,e,a){try{if(!t)return;t.headerImageBlockNew;return!1!==t.configurationHeaderImageVisible}catch(t){f(t)}},this.sh_headerImageTitle=function(t,e,a){try{if(!t)return;t.headerImageTitle;return c.isBlank(r.prefill.nameplateInstructions)}catch(t){f(t)}},this.sh_nameplateHeaderImageTitle=function(t,e,a){try{if(!t)return;t.nameplateHeaderImageTitle;return!c.isBlank(r.prefill.nameplateInstructions)}catch(t){f(t)}},this.sh_headerTitle=function(t,e,a){try{if(!t)return;t.headerTitle;return!1}catch(t){f(t)}},this.sh_headerIntro=function(t,e,a){try{if(!t)return;t.headerIntro;return c.isBlank(r.prefill.nameplateInstructions)}catch(t){f(t)}},this.sh_nameplateHeaderTitle=function(t,e,a){try{if(!t)return;t.nameplateHeaderTitle;return!1}catch(t){f(t)}},this.sh_nameplateHeaderIntro=function(t,e,a){try{if(!t)return;t.nameplateHeaderIntro;return!c.isBlank(r.prefill.nameplateInstructions)}catch(t){f(t)}},this.sh_brochureLinks=function(t,e,a){try{if(!t)return;t.brochureLinks;return!c.isBlank(t.$nameplateInstructions)&&!c.isBlank(t.$nameplateInstructions.brochureLinks)}catch(t){f(t)}},this.sh_mandatoryFieldNotice=function(t,e,a){try{if(!t)return;t.mandatoryFieldNotice;return!!t.configurationMandatoryMarkerText}catch(t){f(t)}},this.dc_form2=function(t,e,a){try{if(!t)return;t.form2;if(c.isBlank(t.configurationTemplateName))return"no-width";switch(t.configurationTemplateName){case"FP":return"full-page-width";case"CP":case"CP-US":return"compact-page-width";default:return"full-page-width"}}catch(t){f(t)}},this.ok_personalDetailsEmailAddress=function(t,e,a){try{if(!t)return;return/^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+(com|edu|info|gov|int|mil|net|org|biz|name|museum|coop|aero|pro|tv|[a-zA-Z]{2,3}))$/.test(t.personalDetailsEmailAddress)||"Entrez une adresse courriel valide. (ex. : nom@exemple.com)"}catch(t){f(t)}},this.sh_personalDetailsEmailAddress=function(t,e,a){try{if(!t)return;t.personalDetailsEmailAddress;return!!c.isBlank(t.$nameplateInstructions)||!(!c.isBlank(t.$nameplateInstructions.hiddenFields)&&-1!==t.$nameplateInstructions.hiddenFields.indexOf("emailAddress"))&&(c.isBlank(t.$nameplateInstructions.visibleFields)||t.$nameplateInstructions.visibleFields.indexOf("emailAddress"),!0)}catch(t){f(t)}},this.sh_personalDetailsVehicleUse=function(t,e,a){try{if(!t)return;t.personalDetailsVehicleUse;return!c.isBlank(t.$nameplateInstructions)&&(!(!c.isBlank(t.$nameplateInstructions.hiddenFields)&&-1!==t.$nameplateInstructions.hiddenFields.indexOf("vehicleUse"))&&(!c.isBlank(t.$nameplateInstructions.visibleFields)&&-1!==t.$nameplateInstructions.visibleFields.indexOf("vehicleUse")))}catch(t){f(t)}},this.sh_personalDetailsBusinessUser=function(t,e,a){try{if(!t)return;t.personalDetailsBusinessUser;return c.isBlank(t.$nameplateInstructions)?"Business"===t.personalDetailsVehicleUseType:!(!c.isBlank(t.$nameplateInstructions.hiddenFields)&&-1!==t.$nameplateInstructions.hiddenFields.indexOf("businessUser"))&&(!c.isBlank(t.$nameplateInstructions.visibleFields)&&-1!==t.$nameplateInstructions.visibleFields.indexOf("businessUser")||"Business"===t.personalDetailsVehicleUseType)}catch(t){f(t)}},this.ok_personalDetailsFirstName=function(t,e,a){try{if(!t)return;var r=t.personalDetailsFirstName;return!new RegExp(/^[.-]+$/).test(r)||"Entrez un prenom valide"}catch(t){f(t)}},this.sh_personalDetailsFirstName=function(t,e,a){try{if(!t)return;t.personalDetailsFirstName;return!!c.isBlank(t.$nameplateInstructions)||!(!c.isBlank(t.$nameplateInstructions.hiddenFields)&&-1!==t.$nameplateInstructions.hiddenFields.indexOf("firstName"))&&(c.isBlank(t.$nameplateInstructions.visibleFields)||t.$nameplateInstructions.visibleFields.indexOf("firstName"),!0)}catch(t){f(t)}},this.ok_personalDetailsLastName=function(t,e,a){try{if(!t)return;var r=t.personalDetailsLastName;return!new RegExp(/^[.-]+$/).test(r)||"Entrez un nom valide"}catch(t){f(t)}},this.sh_personalDetailsLastName=function(t,e,a){try{if(!t)return;t.personalDetailsLastName;return!!c.isBlank(t.$nameplateInstructions)||!(!c.isBlank(t.$nameplateInstructions.hiddenFields)&&-1!==t.$nameplateInstructions.hiddenFields.indexOf("lastName"))&&(c.isBlank(t.$nameplateInstructions.visibleFields)||t.$nameplateInstructions.visibleFields.indexOf("lastName"),!0)}catch(t){f(t)}},this.ok_personalDetailsMobileNumber=function(t,e,a){try{if(!t)return;var r=t.personalDetailsMobileNumber;r=r.replace(/[\s-]/g,"");var n=/^\d{10}/;return 10==r.length&&n.test(r)?(t[e.id]=r,!0):"Veuillez entrer un numéro de téléphone valide"}catch(t){f(t)}},this.sh_personalDetailsMobileNumber=function(t,e,a){try{if(!t)return;t.personalDetailsMobileNumber;return!!c.isBlank(t.$nameplateInstructions)||!(!c.isBlank(t.$nameplateInstructions.hiddenFields)&&-1!==t.$nameplateInstructions.hiddenFields.indexOf("mobileNumber"))&&(c.isBlank(t.$nameplateInstructions.visibleFields)||t.$nameplateInstructions.visibleFields.indexOf("mobileNumber"),!0)}catch(t){f(t)}},this.onComplete_pcaAddressLookupSearch=function(t,e,a){try{if(!t)return;var n=t.pcaAddressLookupSearch,i=t.$pcaSearchResult;if(Array.isArray(i)&&i.length>0){t.$pcaPredictAddressNext="";for(var c=0;c<i.length;c++){var s=i[c];if(s.next&&s.fullAddress===n){var o=angular.element("#"+r.getUniqueId(e.id,t)).scope();setTimeout(function(){o.onChangeSelection(s.next)},100),t.$pcaPredictAddressNext=s.next;break}}}var l="";switch(t.addressState){case"AB":l="Alberta";break;case"BC":l="British Columbia";break;case"MB":l="Manitoba";break;case"NB":l="New Brunswick";break;case"NL":l="Newfoundland & Labrador";break;case"NS":l="Nova Scotia";break;case"NT":l="Northwest Territories";break;case"NU":l="Nunavut";break;case"ON":l="Ontario";break;case"PE":l="Prince Edward Island";break;case"QC":l="Quebec";break;case"SK":l="Saskatchewan";break;case"YT":l="Yukon Territory";break;default:return""}t.pcaAddressLookupRegState=l,maestro.Form.getItemFromPath("maestro.Form.data.data.addressState").properties.defaultValueField=maestro.Form.data.addressState,maestro.Form.prefill.JLRData.AddressState=maestro.Form.data.addressState}catch(t){f(t)}},this.onExtraItemSelect_pcaAddressLookupSearch=function(t,e,a){try{if(!t)return;t.pcaAddressLookupSearch;t.pcaAddressLookupBuildingName="",t.pcaAddressLookupBuildingNumber="",t.pcaAddressLookupAddressLine1="",t.pcaAddressLookupAddressLine2="",t.pcaAddressLookupAddressLine3="",t.pcaAddressLookupDistrict="",t.pcaAddressLookupCity="",t.addressState="",t.pcaAddressLookupPostalCode="",t.pcaAddressLookupCountry="",t.pcaAddressLookupIsManualInput=!0}catch(t){f(t)}},this.onSuccess_pcaAddressLookupSearch=function(t,e,a){try{if(!t)return;var r=t.pcaAddressLookupSearch;if(t.$pcaSearchResult=a,Array.isArray(a)&&a.length>0){t.$pcaPredictAddressNext="";for(var n=0;n<a.length;n++){var e=a[n];if(e.next&&e.fullAddress===r){t.$pcaPredictAddressNext=e.next;break}}}var i=$("Form").scope().Form.items.pcaAddressLookupSearch;0==$(".id-"+i.id+" .continue-message").hasClass("ng-hide")?$(".id-"+i.id+" .wdg-input").addClass("av-dropdown-expanded"):$(".id-"+i.id+" .wdg-input").removeClass("av-dropdown-expanded")}catch(t){f(t)}},this.dc_pcaAddressLookupSearch=function(t,e,a){try{if(!t)return;t.pcaAddressLookupSearch;return $(".suggestion-items").is(":visible")?$(".suggestion-items").closest(".av-type-ahead").find(".input-container").addClass("av-dropdown-expanded"):$(".input-container").removeClass("av-dropdown-expanded")}catch(t){f(t)}},this.onListSelect_pcaAddressLookupSearch=function(t,e,a){try{if(!t)return;t.pcaAddressLookupSearch;t.pcaAddressLookupIsManualInput=!1}catch(t){f(t)}},this.click_pcaAddressLookupSearch=function(t,e,a){try{if(!t)return;t.pcaAddressLookupSearch;t.$pcaPredictAddressNext=""}catch(t){f(t)}},this.eq_pcaAddressLookupCountryCode=function(t,e,a){try{if(!t)return;t.pcaAddressLookupCountryCode;return t.configurationCountryCode}catch(t){f(t)}},this.eq_pcaAddressLookupAllCaps=function(t,e,a){try{if(!t)return;t.pcaAddressLookupAllCaps;return"false"}catch(t){f(t)}},this.eq_languageCode=function(t,e,a){try{if(!t)return;t.languageCode;return t.configurationLanguageCode}catch(t){f(t)}},this.sh_addressState=function(t,e,a){try{if(!t)return;t.addressState;return!0}catch(t){f(t)}},this.ok_pcaAddressLookupPostalCode=function(t,e,a){try{if(!t)return;var r=t.pcaAddressLookupPostalCode;return!!new RegExp("^(?!.*[DFIOQUdfioqu])[A-VXYa-vxy][0-9][A-Za-z] ?[0-9][A-Za-z][0-9]$").test(r)||t.configurationPostCodeNotValidMessage}catch(t){f(t)}},this.eq_pcaAddressLookupRegState=function(t,e,a){try{if(!t)return;var r=(t.pcaAddressLookupRegState,"");switch(t.addressState){case"AB":r="Alberta";break;case"BC":r="British Columbia";break;case"MB":r="Manitoba";break;case"NB":r="New Brunswick";break;case"NL":r="Newfoundland & Labrador";break;case"NS":r="Nova Scotia";break;case"NT":r="Northwest Territories";break;case"NU":r="Nunavut";break;case"ON":r="Ontario";break;case"PE":r="Prince Edward Island";break;case"QC":r="Quebec";break;case"SK":r="Saskatchewan";break;case"YT":r="Yukon Territory";break;default:return""}t.pcaAddressLookupRegState=r}catch(t){f(t)}},this.eq_pcaAddressLookupCountry=function(t,e,a){try{if(!t)return;t.pcaAddressLookupCountry;return c.isBlank(t.pcaAddressLookupBuildingName)&&c.isBlank(t.pcaAddressLookupBuildingNumber)&&c.isBlank(t.pcaAddressLookupAddressLine1)&&c.isBlank(t.pcaAddressLookupAddressLine2)&&c.isBlank(t.pcaAddressLookupAddressLine3)&&c.isBlank(t.pcaAddressLookupCity)&&c.isBlank(t.addressState)&&c.isBlank(t.pcaAddressLookupPostalCode)?"":t.configurationMarket}catch(t){f(t)}},this.eq_provinceList=function(t,e,a){try{if(!t)return;t.provinceList;return[{label:"AB",value:"AB"},{label:"BC",value:"BC"},{label:"MB",value:"MB"},{label:"NB",value:"NB"},{label:"NL",value:"NL"},{label:"NS",value:"NS"},{label:"NT",value:"NT"},{label:"NU",value:"NU"},{label:"ON",value:"ON"},{label:"PE",value:"PE"},{label:"QC",value:"QC"},{label:"SK",value:"SK"},{label:"YT",value:"YT"}]}catch(t){f(t)}},this.click_moiSelectionDropdown=function(t,e,a){try{if(!t)return;var r=t.moiSelectionDropdown;void 0!=r&&MOI.processSingleSelection(t.moiAvailableModels,r)}catch(t){f(t)}},this.change_moiSelectionDropdown=function(t,e,a){try{if(!t)return;var r=t.moiSelectionDropdown;MOI.processSingleSelection(t.moiAvailableModels,r)}catch(t){f(t)}},this.sh_moiSelectionDropdown=function(t,e,a){try{if(!t)return;t.moiSelectionDropdown;return c.isBlank(t.$nameplateInstructions)?"dropdown"===t.moiSelectionType:!(!c.isBlank(t.$nameplateInstructions.hiddenFields)&&-1!==t.$nameplateInstructions.hiddenFields.indexOf("modelOfInterest"))&&(!c.isBlank(t.$nameplateInstructions.visibleFields)&&-1!==t.$nameplateInstructions.visibleFields.indexOf("modelOfInterest")||"dropdown"===t.moiSelectionType)}catch(t){f(t)}},this.ok_moiSelectionCheckboxGroup=function(t,e,a){try{if(!t)return;for(var n=(t.moiSelectionCheckboxGroup,Object.keys(r.data.moiSelectionCheckboxGroup)),i=0,c=0;c<n.length;c++)!0===r.data.moiSelectionCheckboxGroup[n[c]]&&(i+=1);if(i>t.moiMaxSelection)return r.term("moiSelectionCheckboxGroup.moiMaxValidation")+" "+t.moiMaxSelection+" "+r.term("moiSelectionCheckboxGroup.moiMaxValidation2")}catch(t){f(t)}},this.hasValue_moiSelectionCheckboxGroup=function(t,e,a){try{if(!t)return;var r=t.moiSelectionCheckboxGroup;return function(t,e){return!(!e||""==e)&&Object.keys(e).some(function(t){return e[t]})}(0,r)}catch(t){f(t)}},this.change_moiSelectionCheckboxGroup=function(t,e,a){try{if(!t)return;var n=t.moiSelectionCheckboxGroup,i=$(a.target).closest(".id-"+$("Form").scope().Form.items.moiSelectionCheckboxGroup.id),c=r.term("moiSelectionCheckboxGroup.moiMaxValidation")+" "+t.moiMaxSelection+" "+r.term("moiSelectionCheckboxGroup.moiMaxValidation2"),s='<div class="err-msg list-group"><p class="list-group-item list-group-item-danger moiSelectionCheckboxGroup_error"><span class="fa fa-exclamation-triangle" aria-hidden="true">&nbsp;</span><span id="moiSelectionCheckboxGroup_error" class="message"><span class="av-hidden">Error. </span>'+c+"</span></p></div>",o=Object.keys(r.data.moiSelectionCheckboxGroup),l=0;MOI.processMultipleSelections(t.moiAvailableModels,n,r.data.moiVehicle);for(var u=0;u<o.length;u++)!0===r.data.moiSelectionCheckboxGroup[o[u]]&&(l+=1);if(l>t.moiMaxSelection){if($(i).hasClass("has-error"))return;!function(){$(i).addClass("has-error"),$(i).after(s)}()}else!function(){$(i).removeClass("has-error"),$(i).next(".err-msg").remove()}()}catch(t){f(t)}},this.sh_moiSelectionCheckboxGroup=function(t,e,a){try{if(!t)return;t.moiSelectionCheckboxGroup;return c.isBlank(t.$nameplateInstructions)?"checkbox"===t.moiSelectionType:!(!c.isBlank(t.$nameplateInstructions.hiddenFields)&&-1!==t.$nameplateInstructions.hiddenFields.indexOf("modelOfInterest"))&&(!c.isBlank(t.$nameplateInstructions.visibleFields)&&-1!==t.$nameplateInstructions.visibleFields.indexOf("modelOfInterest")||"checkbox"===t.moiSelectionType)}catch(t){f(t)}},this.change_moiSelectionRadioGroup=function(t,e,a){try{if(!t)return;var r=t.moiSelectionRadioGroup;MOI.processSingleSelection(t.moiAvailableModels,r)}catch(t){f(t)}},this.sh_moiSelectionRadioGroup=function(t,e,a){try{if(!t)return;t.moiSelectionRadioGroup;return c.isBlank(t.$nameplateInstructions)?"radio"===t.moiSelectionType:!(!c.isBlank(t.$nameplateInstructions.hiddenFields)&&-1!==t.$nameplateInstructions.hiddenFields.indexOf("modelOfInterest"))&&(!c.isBlank(t.$nameplateInstructions.visibleFields)&&-1!==t.$nameplateInstructions.visibleFields.indexOf("modelOfInterest")||"radio"===t.moiSelectionType)}catch(t){f(t)}},this.sh_moiVehiclesInterestedIn=function(t,e,a){try{if(!t)return;t.moiVehiclesInterestedIn;return!1}catch(t){f(t)}},this.sh_productsList=function(t,e,a){try{if(!t)return;t.productsList;return"Yes"==t.protectionOption}catch(t){f(t)}},this.sh_insuranceQuote=function(t,e,a){try{if(!t)return;t.insuranceQuote;return"Yes"==t.insuranceOption}catch(t){f(t)}},this.sh_currentVehicle_1=function(t,e,a){try{if(!t)return;t.currentVehicle_1;return!!c.isBlank(t.$nameplateInstructions)||!(!c.isBlank(t.$nameplateInstructions.hiddenFields)&&-1!==t.$nameplateInstructions.hiddenFields.indexOf("currentVehicle"))&&(c.isBlank(t.$nameplateInstructions.visibleFields)||t.$nameplateInstructions.visibleFields.indexOf("currentVehicle"),!0)}catch(t){f(t)}},this.change_currentVehicleMake=function(t,e,a){try{if(!t)return;var r=t.currentVehicleMake,n=r,i=!1;c.isBlank(t.currentVehicleMakesAndModels)||t.currentVehicleMakesAndModels.some(function(e){if(e.value.toString().trim()===n.toString().trim())return t.currentVehicleModelsByMake=e.models,i=!0,!0}),i||(t.currentVehicleModelsByMake="[]")}catch(t){f(t)}},this.click_currentVehicleMake=function(t,e,a){try{if(!t)return;var r=t.currentVehicleMake;if(!$(event.target).hasClass("jlr-dropdown__option"))return;var n=r,i=!1,s=$(event.target).closest(".jlr-dropdown").find(".jlr-dropdown__option");return t.currentVehicleModelsByMake="",c.isBlank(t.currentVehicleMakesAndModels)||t.currentVehicleMakesAndModels.some(function(e){if(e.value===n){if(t.currentVehicleModelsByMake=e.models,i=!0,0==$(event.target).hasClass("currentSelection")){$(s).each(function(t){$(event.target).is($(s[t]))?$($(s[t])).addClass("currentSelection"):$($(s[t])).removeClass("currentSelection")});var a=$("Form").scope().Form.items.currentVehicleModel;$(".id-"+a.id+" .jlr-dropdown__value").text(""),$(".id-"+a.id+" .jlr-dropdown__placeholder").removeClass("ng-hide")}return!0}}),void(i||(t.currentVehicleModelsByMake="[]"))}catch(t){f(t)}},this.click_currentVehicleModel=function(t,e,a){try{if(!t)return;var r=(t.currentVehicleModel,$("Form").scope().Form.items.currentVehicleModel);$(event.target).hasClass("jlr-dropdown__option")&&($(".id-"+r.id+" .jlr-dropdown__value").removeClass("ng-hide"),$(".id-"+r.id+" .jlr-dropdown__placeholder").addClass("ng-hide"))}catch(t){f(t)}},this.sh_retailerLookupAutocomplete=function(t,e,a){try{if(!t)return;t.retailerLookupAutocomplete;return c.isBlank(t.$nameplateInstructions)?!0!==t.preloadeddealer:!(!c.isBlank(t.$nameplateInstructions.hiddenFields)&&-1!==t.$nameplateInstructions.hiddenFields.indexOf("retailerLookup"))&&(!c.isBlank(t.$nameplateInstructions.visibleFields)&&-1!==t.$nameplateInstructions.visibleFields.indexOf("retailerLookup")||!0!==t.preloadeddealer)}catch(t){f(t)}},this.change_consentBlockAEmailSMS=function(t,e,a){try{if(!t)return;t.consentBlockAEmailSMS;"Yes"===t.consentBlockAEmailSMS?(t.consentBlockAEmail="Yes",t.consentBlockASMS="Yes"):(t.consentBlockAEmail="No",t.consentBlockASMS="No")}catch(t){f(t)}},this.sh_consentBlockAEmail=function(t,e,a){try{if(!t)return;t.consentBlockAEmail;return!1}catch(t){f(t)}},this.sh_consentBlockAPost=function(t,e,a){try{if(!t)return;t.consentBlockAPost;return!1}catch(t){f(t)}},this.sh_consentBlockAPhone=function(t,e,a){try{if(!t)return;t.consentBlockAPhone;return!1}catch(t){f(t)}},this.sh_consentBlockASMS=function(t,e,a){try{if(!t)return;t.consentBlockASMS;return!1}catch(t){f(t)}},this.eq_submissionKey=function(t,e,a){try{if(!t)return;t.submissionKey;return r.getSystemData("OfflineSubmissionId")}catch(t){f(t)}},this.dc_navigatorWizardBarNew=function(t,e,a){try{if(!t)return;t.navigatorWizardBarNew;if(c.isBlank(t.configurationTemplateName))return"no-width";switch(t.configurationTemplateName){case"FP":return"full-nav-width";case"CP":case"CP-US":return"compact-nav-width";default:return"full-nav-width"}}catch(t){f(t)}},this.sh_navigatorWizardBarNew=function(t,e,a){try{if(!t)return;t.navigatorWizardBarNew;return r.$Pages}catch(t){f(t)}},this.sh_submit2=function(t,e,a){try{if(!t)return;t.submit2;return r.$Pages.currentPage&&r.$Pages.currentPage.$isLast&&"FP"===t.configurationTemplateName}catch(t){f(t)}},this.click_submit2=function(t,e,a){try{if(!t)return;t.submit2;maestro.Form.data.hasOwnProperty("accountPreferredRetailerCode")&&c.isBlank(maestro.Form.data.accountPreferredRetailerCode)?(maestro.Form.data.retailerLookupSearch="",r.validate("form2",t,!1).then(function(t){r.gotoError(t.errors[0])})):r.validate("form2",t,!1).then(function(a){!0===a.valid?r.submit(e.properties.submissionMethod,e.properties.legacyMethod).then(function(a){r.fireRule("onSuccess",e,t,a)},function(a){r.fireRule("onFailure",e,t,a)}):r.gotoError(a.errors[0])})}catch(t){f(t)}},this.click_submitCP=function(t,e,a){try{if(!t)return;t.submitCP;maestro.Form.data.hasOwnProperty("accountPreferredRetailerCode")&&c.isBlank(maestro.Form.data.accountPreferredRetailerCode)?(maestro.Form.data.retailerLookupSearch="",r.validate("form2",t,!1).then(function(t){r.gotoError(t.errors[0])})):r.validate("form2",t,!1).then(function(a){!0===a.valid?r.submit(e.properties.submissionMethod,e.properties.legacyMethod).then(function(a){r.fireRule("onSuccess",e,t,a)},function(a){r.fireRule("onFailure",e,t,a)}):r.gotoError(a.errors[0])})}catch(t){f(t)}},this.sh_submitCP=function(t,e,a){try{if(!t)return;t.submitCP;return r.$Pages.currentPage&&r.$Pages.currentPage.$isLast&&"CP"===t.configurationTemplateName}catch(t){f(t)}},this.dc_jlrFormFooter=function(t,e,a){try{if(!t)return;t.jlrFormFooter;if(c.isBlank(t.configurationTemplateName))return"no-width";switch(t.configurationTemplateName){case"FP":return"full-footer-width";case"CP":case"CP-US":return"compact-footer-width";default:return"full-footer-width"}}catch(t){f(t)}},this.sh_copyrightJaguarLandRover=function(t,e,a){try{if(!t)return;t.copyrightJaguarLandRover;return"FP"===t.configurationTemplateName}catch(t){f(t)}},this.sh_copyrightJaguarLandRoverCP=function(t,e,a){try{if(!t)return;t.copyrightJaguarLandRoverCP;return"CP"===t.configurationTemplateName}catch(t){f(t)}},this.sh_copyrightJaguarLandRoverMP=function(t,e,a){try{if(!t)return;t.copyrightJaguarLandRoverMP;return"MP"===t.configurationTemplateName}catch(t){f(t)}},this.sh_cookieBanner=function(t,e,a){try{if(!t)return;var r=(t.cookieBanner,!0);return maestro.Form.prefill.hasOwnProperty("ConstCookieBnr")&&"1"===maestro.Form.prefill.ConstCookieBnr&&(r=!1),r}catch(t){f(t)}},this.click_cancel_10=function(t,e,a){try{if(!t)return;t.cancel_10;r.showDialog("")}catch(t){f(t)}},this.sh_cancel_10=function(t,e,a){try{if(!t)return;t.cancel_10;return"okay"!=e.$$parent.properties.dialogNavButtons&&!r.saveChallengeOnInit}catch(t){f(t)}},this.sh_confirm_10=function(t,e,a){try{if(!t)return;t.confirm_10;return"open"==e.$$parent.properties.dialogNavButtons}catch(t){f(t)}},this.click_confirm_10=function(t,e,a){try{if(!t)return;t.confirm_10;r.resumeForm(e.$$parent.properties.validationRef,e.properties.trackingCodeField,e.properties.challengeAnswerField).catch(function(t){"Session not available"==t.message?window.confirm("Session has expired, do you want to reload the page to renew the session?")&&(window.onbeforeunload&&(window.onbeforeunload=null),window.location.reload()):alert("Could not open saved form with the details provided")})}catch(t){f(t)}},this.click_confirm_11=function(t,e,a){try{if(!t)return;t.confirm_11;r.submit({save:"Saved",abandon:"Abandoned"}[e.$$parent.properties.dialogNavButtons],e.properties.legacyMethod,!1,e.$$parent.properties.validationRef)}catch(t){f(t)}},this.sh_confirm_11=function(t,e,a){try{if(!t)return;t.confirm_11;return"save"==e.$$parent.properties.dialogNavButtons||"abandon"==e.$$parent.properties.dialogNavButtons}catch(t){f(t)}},this.click_okay_5=function(t,e,a){try{if(!t)return;t.okay_5;r.showDialog("")}catch(t){f(t)}},this.sh_okay_5=function(t,e,a){try{if(!t)return;t.okay_5;return"okay"==e.$$parent.properties.dialogNavButtons||"okay-cancel"==e.$$parent.properties.dialogNavButtons}catch(t){f(t)}},this.click_cancel_11=function(t,e,a){try{if(!t)return;t.cancel_11;r.showDialog("")}catch(t){f(t)}},this.sh_cancel_11=function(t,e,a){try{if(!t)return;t.cancel_11;return"okay"!=e.$$parent.properties.dialogNavButtons&&!r.saveChallengeOnInit}catch(t){f(t)}},this.load_submitsuccess=function(t,e,a){try{if(!t)return;t.submitsuccess;!0===t.headerImageVisible&&""!==t.headerImageUrl&&$(".jlr-image-banner-08226 img").attr("src",t.headerImageUrl)}catch(t){f(t)}},this.eq_successPageImage=function(t,e,a){try{if(!t)return;t.successPageImage;if(!1!==t.configurationHeaderImageVisible)return $(".id-successPageImage img").attr("src",t.configurationHeaderImageUrl),!0}catch(t){f(t)}},this.dc_submitSuccessContentNew=function(t,e,a){try{if(!t)return;t.submitSuccessContentNew;if(c.isBlank(t.configurationTemplateName))return"no-width";switch(t.configurationTemplateName){case"FP":return"fp-submitSuccessPage-width";case"CP":return"cp-submitSuccessPage-width";case"MP":return"mp-submitSuccessPage-width";case"CP-US":return"cp-submitSuccessPage-width";default:return"fp-submitSuccessPage-width"}}catch(t){f(t)}},this.sh_submitSuccessHeadingFP=function(t,e,a){try{if(!t)return;t.submitSuccessHeadingFP;return"FP"===t.configurationTemplateName}catch(t){f(t)}},this.sh_submitSuccessHeadingCP=function(t,e,a){try{if(!t)return;t.submitSuccessHeadingCP;return"CP"===t.configurationTemplateName||"CP-US"===t.configurationTemplateName}catch(t){f(t)}},this.sh_submitSuccessHeadingMP=function(t,e,a){try{if(!t)return;t.submitSuccessHeadingMP;return"MP"===t.configurationTemplateName}catch(t){f(t)}},this.dc_subtitle=function(t,e,a){try{if(!t)return;t.subtitle;if("MP"===t.configurationTemplateName)return"mp-submitSuccessSubtitle-width"}catch(t){f(t)}},this.sh_submitSuccessSubtitleFP=function(t,e,a){try{if(!t)return;t.submitSuccessSubtitleFP;return"FP"===t.configurationTemplateName}catch(t){f(t)}},this.sh_submitSuccessSubtitleCP=function(t,e,a){try{if(!t)return;t.submitSuccessSubtitleCP;return"CP"===t.configurationTemplateName||"CP-US"===t.configurationTemplateName}catch(t){f(t)}},this.sh_submitSuccessSubtitleMP=function(t,e,a){try{if(!t)return;t.submitSuccessSubtitleMP;return"MP"===t.configurationTemplateName}catch(t){f(t)}},this.sh_jlrCtaComponentBlock=function(t,e,a){try{if(!t)return;t.jlrCtaComponentBlock;return!c.isBlank(t.ctaData_1)&&t.ctaData_1.length>0}catch(t){f(t)}},this.dc_jlrCtaTableBlock_1=function(t,e,a){try{if(!t)return;t.jlrCtaTableBlock_1;if(!Array.isArray(t.ctaData_1))return"no-data";switch(t.ctaData_1.length){case 1:return"width-100";case 2:return"width-50";case 3:case 5:case 6:return"width-34";case 4:case 7:case 8:return"width-25";default:return"width-100"}}catch(t){f(t)}},this.click_ctaBlock_8=function(t,e,a){try{if(!t)return;t.ctaBlock_8;window.location.href=t.ctaLinkUrl_8}catch(t){f(t)}},this.sh_ctaBlock_8=function(t,e,a){try{if(!t)return;t.ctaBlock_8;return!!Array.isArray(t.ctaData_1)&&0<t.ctaData_1.length}catch(t){f(t)}},this.eq_ctaBlockData_8=function(t,e,a){try{if(!t)return;t.ctaBlockData_8;return!c.isBlank(t.ctaData_1[0])&&t.ctaData_1[0]}catch(t){f(t)}},this.eq_ctaImageUrl_8=function(t,e,a){try{if(!t)return;t.ctaImageUrl_8;return t.ctaBlockData_8?t.ctaBlockData_8.imageUrl:""}catch(t){f(t)}},this.eq_ctaLinkText_8=function(t,e,a){try{if(!t)return;t.ctaLinkText_8;return t.ctaBlockData_8?t.ctaBlockData_8.linkText:""}catch(t){f(t)}},this.eq_ctaLinkUrl_8=function(t,e,a){try{if(!t)return;t.ctaLinkUrl_8;return t.ctaBlockData_8?t.ctaBlockData_8.linkUrl:""}catch(t){f(t)}},this.eq_ctaText_8=function(t,e,a){try{if(!t)return;t.ctaText_8;return t.ctaBlockData_8?t.ctaBlockData_8.ctaText_8:""}catch(t){f(t)}},this.eq_ctaImage_8=function(t,e,a){try{if(!t)return;t.ctaImage_8;return $(".id-"+e.id+" img").attr("src",t.ctaImageUrl_8),""}catch(t){f(t)}},this.click_ctaBlock_9=function(t,e,a){try{if(!t)return;t.ctaBlock_9;window.location.href=t.ctaLinkUrl_9}catch(t){f(t)}},this.sh_ctaBlock_9=function(t,e,a){try{if(!t)return;t.ctaBlock_9;return!!Array.isArray(t.ctaData_1)&&0<t.ctaData_1.length}catch(t){f(t)}},this.eq_ctaBlockData_9=function(t,e,a){try{if(!t)return;t.ctaBlockData_9;return!c.isBlank(t.ctaData_1[0])&&t.ctaData_1[0]}catch(t){f(t)}},this.eq_ctaImageUrl_9=function(t,e,a){try{if(!t)return;t.ctaImageUrl_9;return t.ctaBlockData_9?t.ctaBlockData_9.imageUrl:""}catch(t){f(t)}},this.eq_ctaLinkText_9=function(t,e,a){try{if(!t)return;t.ctaLinkText_9;return t.ctaBlockData_9?t.ctaBlockData_9.linkText:""}catch(t){f(t)}},this.eq_ctaLinkUrl_9=function(t,e,a){try{if(!t)return;t.ctaLinkUrl_9;return t.ctaBlockData_9?t.ctaBlockData_9.linkUrl:""}catch(t){f(t)}},this.eq_ctaText_9=function(t,e,a){try{if(!t)return;t.ctaText_9;return t.ctaBlockData_9?t.ctaBlockData_9.ctaText_9:""}catch(t){f(t)}},this.eq_ctaImage_9=function(t,e,a){try{if(!t)return;t.ctaImage_9;return $(".id-"+e.id+" img").attr("src",t.ctaImageUrl_9),""}catch(t){f(t)}},this.click_ctaBlock_10=function(t,e,a){try{if(!t)return;t.ctaBlock_10;window.location.href=t.ctaLinkUrl_10}catch(t){f(t)}},this.sh_ctaBlock_10=function(t,e,a){try{if(!t)return;t.ctaBlock_10;return!!Array.isArray(t.ctaData_1)&&0<t.ctaData_1.length}catch(t){f(t)}},this.eq_ctaBlockData_10=function(t,e,a){try{if(!t)return;t.ctaBlockData_10;return!c.isBlank(t.ctaData_1[0])&&t.ctaData_1[0]}catch(t){f(t)}},this.eq_ctaImageUrl_10=function(t,e,a){try{if(!t)return;t.ctaImageUrl_10;return t.ctaBlockData_10?t.ctaBlockData_10.imageUrl:""}catch(t){f(t)}},this.eq_ctaLinkText_10=function(t,e,a){try{if(!t)return;t.ctaLinkText_10;return t.ctaBlockData_10?t.ctaBlockData_10.linkText:""}catch(t){f(t)}},this.eq_ctaLinkUrl_10=function(t,e,a){try{if(!t)return;t.ctaLinkUrl_10;return t.ctaBlockData_10?t.ctaBlockData_10.linkUrl:""}catch(t){f(t)}},this.eq_ctaText_10=function(t,e,a){try{if(!t)return;t.ctaText_10;return t.ctaBlockData_10?t.ctaBlockData_10.ctaText_10:""}catch(t){f(t)}},this.eq_ctaImage_10=function(t,e,a){try{if(!t)return;t.ctaImage_10;return $(".id-"+e.id+" img").attr("src",t.ctaImageUrl_10),""}catch(t){f(t)}},this.click_ctaBlock_11=function(t,e,a){try{if(!t)return;t.ctaBlock_11;window.location.href=t.ctaLinkUrl_11}catch(t){f(t)}},this.sh_ctaBlock_11=function(t,e,a){try{if(!t)return;t.ctaBlock_11;return!!Array.isArray(t.ctaData_1)&&0<t.ctaData_1.length}catch(t){f(t)}},this.eq_ctaBlockData_11=function(t,e,a){try{if(!t)return;t.ctaBlockData_11;return!c.isBlank(t.ctaData_1[0])&&t.ctaData_1[0]}catch(t){f(t)}},this.eq_ctaImageUrl_11=function(t,e,a){try{if(!t)return;t.ctaImageUrl_11;return t.ctaBlockData_11?t.ctaBlockData_11.imageUrl:""}catch(t){f(t)}},this.eq_ctaLinkText_11=function(t,e,a){try{if(!t)return;t.ctaLinkText_11;return t.ctaBlockData_11?t.ctaBlockData_11.linkText:""}catch(t){f(t)}},this.eq_ctaLinkUrl_11=function(t,e,a){try{if(!t)return;t.ctaLinkUrl_11;return t.ctaBlockData_11?t.ctaBlockData_11.linkUrl:""}catch(t){f(t)}},this.eq_ctaText_11=function(t,e,a){try{if(!t)return;t.ctaText_11;return t.ctaBlockData_11?t.ctaBlockData_11.ctaText_11:""}catch(t){f(t)}},this.eq_ctaImage_11=function(t,e,a){try{if(!t)return;t.ctaImage_11;return $(".id-"+e.id+" img").attr("src",t.ctaImageUrl_11),""}catch(t){f(t)}},this.click_ctaBlock_12=function(t,e,a){try{if(!t)return;t.ctaBlock_12;window.location.href=t.ctaLinkUrl_12}catch(t){f(t)}},this.sh_ctaBlock_12=function(t,e,a){try{if(!t)return;t.ctaBlock_12;return!!Array.isArray(t.ctaData_1)&&0<t.ctaData_1.length}catch(t){
f(t)}},this.eq_ctaBlockData_12=function(t,e,a){try{if(!t)return;t.ctaBlockData_12;return!c.isBlank(t.ctaData_1[0])&&t.ctaData_1[0]}catch(t){f(t)}},this.eq_ctaImageUrl_12=function(t,e,a){try{if(!t)return;t.ctaImageUrl_12;return t.ctaBlockData_12?t.ctaBlockData_12.imageUrl:""}catch(t){f(t)}},this.eq_ctaLinkText_12=function(t,e,a){try{if(!t)return;t.ctaLinkText_12;return t.ctaBlockData_12?t.ctaBlockData_12.linkText:""}catch(t){f(t)}},this.eq_ctaLinkUrl_12=function(t,e,a){try{if(!t)return;t.ctaLinkUrl_12;return t.ctaBlockData_12?t.ctaBlockData_12.linkUrl:""}catch(t){f(t)}},this.eq_ctaText_12=function(t,e,a){try{if(!t)return;t.ctaText_12;return t.ctaBlockData_12?t.ctaBlockData_12.ctaText_12:""}catch(t){f(t)}},this.eq_ctaImage_12=function(t,e,a){try{if(!t)return;t.ctaImage_12;return $(".id-"+e.id+" img").attr("src",t.ctaImageUrl_12),""}catch(t){f(t)}},this.click_ctaBlock_13=function(t,e,a){try{if(!t)return;t.ctaBlock_13;window.location.href=t.ctaLinkUrl_13}catch(t){f(t)}},this.sh_ctaBlock_13=function(t,e,a){try{if(!t)return;t.ctaBlock_13;return!!Array.isArray(t.ctaData_1)&&0<t.ctaData_1.length}catch(t){f(t)}},this.eq_ctaBlockData_13=function(t,e,a){try{if(!t)return;t.ctaBlockData_13;return!c.isBlank(t.ctaData_1[0])&&t.ctaData_1[0]}catch(t){f(t)}},this.eq_ctaImageUrl_13=function(t,e,a){try{if(!t)return;t.ctaImageUrl_13;return t.ctaBlockData_13?t.ctaBlockData_13.imageUrl:""}catch(t){f(t)}},this.eq_ctaLinkText_13=function(t,e,a){try{if(!t)return;t.ctaLinkText_13;return t.ctaBlockData_13?t.ctaBlockData_13.linkText:""}catch(t){f(t)}},this.eq_ctaLinkUrl_13=function(t,e,a){try{if(!t)return;t.ctaLinkUrl_13;return t.ctaBlockData_13?t.ctaBlockData_13.linkUrl:""}catch(t){f(t)}},this.eq_ctaText_13=function(t,e,a){try{if(!t)return;t.ctaText_13;return t.ctaBlockData_13?t.ctaBlockData_13.ctaText_13:""}catch(t){f(t)}},this.eq_ctaImage_13=function(t,e,a){try{if(!t)return;t.ctaImage_13;return $(".id-"+e.id+" img").attr("src",t.ctaImageUrl_13),""}catch(t){f(t)}},this.click_ctaBlock_14=function(t,e,a){try{if(!t)return;t.ctaBlock_14;window.location.href=t.ctaLinkUrl_14}catch(t){f(t)}},this.sh_ctaBlock_14=function(t,e,a){try{if(!t)return;t.ctaBlock_14;return!!Array.isArray(t.ctaData_1)&&0<t.ctaData_1.length}catch(t){f(t)}},this.eq_ctaBlockData_14=function(t,e,a){try{if(!t)return;t.ctaBlockData_14;return!c.isBlank(t.ctaData_1[0])&&t.ctaData_1[0]}catch(t){f(t)}},this.eq_ctaImageUrl_14=function(t,e,a){try{if(!t)return;t.ctaImageUrl_14;return t.ctaBlockData_14?t.ctaBlockData_14.imageUrl:""}catch(t){f(t)}},this.eq_ctaLinkText_14=function(t,e,a){try{if(!t)return;t.ctaLinkText_14;return t.ctaBlockData_14?t.ctaBlockData_14.linkText:""}catch(t){f(t)}},this.eq_ctaLinkUrl_14=function(t,e,a){try{if(!t)return;t.ctaLinkUrl_14;return t.ctaBlockData_14?t.ctaBlockData_14.linkUrl:""}catch(t){f(t)}},this.eq_ctaText_14=function(t,e,a){try{if(!t)return;t.ctaText_14;return t.ctaBlockData_14?t.ctaBlockData_14.ctaText_14:""}catch(t){f(t)}},this.eq_ctaImage_14=function(t,e,a){try{if(!t)return;t.ctaImage_14;return $(".id-"+e.id+" img").attr("src",t.ctaImageUrl_14),""}catch(t){f(t)}},this.click_ctaBlock_15=function(t,e,a){try{if(!t)return;t.ctaBlock_15;window.location.href=t.ctaLinkUrl_15}catch(t){f(t)}},this.sh_ctaBlock_15=function(t,e,a){try{if(!t)return;t.ctaBlock_15;return!!Array.isArray(t.ctaData_1)&&0<t.ctaData_1.length}catch(t){f(t)}},this.eq_ctaBlockData_15=function(t,e,a){try{if(!t)return;t.ctaBlockData_15;return!c.isBlank(t.ctaData_1[0])&&t.ctaData_1[0]}catch(t){f(t)}},this.eq_ctaImageUrl_15=function(t,e,a){try{if(!t)return;t.ctaImageUrl_15;return t.ctaBlockData_15?t.ctaBlockData_15.imageUrl:""}catch(t){f(t)}},this.eq_ctaLinkText_15=function(t,e,a){try{if(!t)return;t.ctaLinkText_15;return t.ctaBlockData_15?t.ctaBlockData_15.linkText:""}catch(t){f(t)}},this.eq_ctaLinkUrl_15=function(t,e,a){try{if(!t)return;t.ctaLinkUrl_15;return t.ctaBlockData_15?t.ctaBlockData_15.linkUrl:""}catch(t){f(t)}},this.eq_ctaText_15=function(t,e,a){try{if(!t)return;t.ctaText_15;return t.ctaBlockData_15?t.ctaBlockData_15.ctaText_15:""}catch(t){f(t)}},this.eq_ctaImage_15=function(t,e,a){try{if(!t)return;t.ctaImage_15;return $(".id-"+e.id+" img").attr("src",t.ctaImageUrl_15),""}catch(t){f(t)}},this.sh_jlrSocialMediaBlock=function(t,e,a){try{if(!t)return;t.jlrSocialMediaBlock;return"CP-US"===t.configurationTemplateName}catch(t){f(t)}},this.sh_jlrSocialLinksJaguar=function(t,e,a){try{if(!t)return;t.jlrSocialLinksJaguar;return!c.isBlank(t.configurationBrand)&&"Jaguar"==t.configurationBrand}catch(t){f(t)}},this.sh_jlrSocialLinksLandRover=function(t,e,a){try{if(!t)return;t.jlrSocialLinksLandRover;return!c.isBlank(t.configurationBrand)&&"Jaguar"!=t.configurationBrand}catch(t){f(t)}},this.dc_submitSuccessPageFooterNew=function(t,e,a){try{if(!t)return;t.submitSuccessPageFooterNew;if(c.isBlank(t.configurationTemplateName))return"no-width";switch(t.configurationTemplateName){case"FP":return"fp-submitSuccessFooter-width";case"CP":return"cp-submitSuccessFooter-width";case"MP":return"mp-submitSuccessFooter-width";case"CP-US":return"cp-submitSuccessFooter-width";default:return"fp-submitSuccessFooter-width"}}catch(t){f(t)}}}])});
(function () {
      window.maestro = window.maestro || {};
  })();
function _asyncToGenerator(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){function r(i,a){try{var o=t[i](a),s=o.value}catch(e){return void n(e)}if(!o.done)return Promise.resolve(s).then(function(e){r("next",e)},function(e){r("throw",e)});e(s)}return r("next")})}}define("app",[],function(){var e=angular.module("app",["ngSanitize","ngAnimate","angularFileUpload","angularLoad"]),t=function(){return function(){}};return e.factory("requiredDirective",t).factory("ngRequiredDirective",t),{ng:e.config(["$sceProvider","$compileProvider",function(t,n){t.enabled=!1,e.directive=n.directive}]),init:function(){require(["form/form"],function(t){var n=(new Date).getTime();console.log("Bootstrapping"),e.injector=angular.bootstrap(document,["app"]),window._perf_bootstrap=(new Date).getTime()-n,console.log("Bootstrapped in "+window._perf_bootstrap+" ms")})},addStylesheet:function(e){},addModuleStylesheet:function(e){},modulePath:function(e){return e.uri.split("/").slice(0,-1).join("/")+"/"},moduleTemplateUrl:function(e){return"app/"+e.id+".html"}}}),define("form/filters",["app"],function(e){e.ng.filter("prettyPrint",function(){return function(e){return JSON.stringify(e,function(e,t){return"$$hashKey"===e?void 0:t||""},"    ")}}),e.ng.filter("prettyPrintHtml",function(){return function(e){return JSON.stringify(e,function(e,t){return"$$hashKey"===e||"data"===e?void 0:t||""},"    ").replace(/ /g,"&nbsp;").replace(/\n/g,"<br>")}}),e.ng.filter("safeLabel",function(){return function(e){return e.replace(/<\/?script\/?>/g,"").replace(/<\/?html\/?>/g,"").replace(/</g,"&lt;")}}),e.ng.filter("isIn",function(){return function(e,t){return t.indexOf(e)>-1}}),e.ng.filter("notIn",function(){return function(e,t){return-1===t.indexOf(e)}}),e.ng.filter("keyCount",function(){return function(e){return e?Object.keys(e).length:0}}),e.ng.filter("keyCountZero",function(){return function(e){return e&&0===Object.keys(e).length}}),e.ng.filter("flatten",function(){return function e(t){if(console.log("filters.flatten"),angular.isArray(t)){for(var n=0,r=t.length,i=[];n<r;++n)i=i.concat(e(t[n]));return i}return[t]}}),e.ng.filter("wrap",function(){return function(e){return e?[e]:[]}}),e.ng.filter("except",function(){return function(e,t){return e&&t?e.filter(function(e){return-1===t.indexOf(e)}):[]}}),e.ng.filter("commaList",function(){return function(e){return angular.isArray(e)?e:e.split(",").map(function(e){return $.trim(e)})}}),e.ng.filter("allResults",function(){return function(e){return function(t){e.apply(this,t)}}}),e.ng.filter("trustHtml",["$sce","Util",function(e,t){return function(n){return e.trustAsHtml(t.sanitizer()(n))}}]),e.ng.filter("rulesFilter",["Util",function(e){return function(t,n){return t.filter(function(t){return Array.isArray(n)?e.contains(n,t.type):t.type===n})}}]),e.ng.filter("rowFilter",[function(){return function(e){return e.filter(function(e){return!e.exLayout})}}])}),define("form/services/Resource",["app"],function(e){e.ng.service("Resource",["$window","$q","Http","EncUtil",function(e,t,n,r){var i=this,a=e.location.toString();this.maestroVersion="21.11.2",this.formDesignVersionId=$("#av-fdv").text()||a.split("?")[0].split("/").pop(),this.generated=!!$("#av-fdv").length,this.design=!i.generated,this.preview=!1,this.baseName=a.match(/SmartForm\.html/)?"form":"receipt",this.deviceType=function(){var e=navigator.userAgent,t=!!e.match(/(iPod|iPhone|iPad)/i),n=!!e.match(/Android/i),r=!!e.match(/BlackBerry/i),i=!!e.match(/IEMobile/i),a=!!e.match(/Opera Mini/i);return t?"iOS":n?"Android":r?"BlackBerry":i?"IEMobile":a?"Opera":"Unknown"}(),this.browserType=function(){var e=navigator.userAgent,t=!!window.opr&&!!opr.addons||!!window.opera||e.indexOf(" OPR/")>=0,n="undefined"!=typeof InstallTrigger,r=!!document.documentMode,a=!r&&!!window.StyleMedia,o=!!window.chrome&&(!!window.chrome.webstore||!!window.chrome.csi||"Android"===i.deviceType&&e.includes("Chrome")),s=(o||t)&&!!window.CSS,u=Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")>0||!o&&!t&&void 0!==window.webkitAudioContext,c=o&&e.indexOf("Edg")>=0;return t?"Opera":n?"Firefox":u?"Safari":r?"IE":a?"Edge":c?"Edge-Chromium":o?"Chrome":s?"Blink":"Unknown"}(),this.isMobile="Unknown"!=i.deviceType,this.get=function(r){var i=t.defer(),a=this.pathId(r),o=a?e.document.getElementById(a):null;return null!=o?(o=o.textContent.trim(),r.match(/json$/)&&(o=JSON.parse(o)),i.resolve(o)):r?n.get(r).then(i.resolve).catch(i.reject):i.reject(),i.promise},this.path=function(e,t){if(t=t||i.formDesignVersionId,e){var n=$("#"+i.pathId(e));if(n.length)return n.text()}return["services/formresources",t,e].filter(Boolean).join("/")},this.imagePath=function(e){return e?i.design||i.preview?i.path("images/"+e):"./images/"+e:""},this.fontPath=function(e){return i.design||i.preview?i.path("fonts/"+e):"./fonts/"+e},this.widgetPath=function(e,t){if(void 0!==t)return t.search("/")>1?t:"services/formresources/"+i.formDesignVersionId+"/widgets/"+e+"/"+t},this.getWidgetManifest=function(e){function n(e,t){for(var n=!1;e&&!n;){var r=i.Libraries.allLibsInfo.widgets[e].manifest;r.propDefs&&r.propDefs[t]?n=!0:e=r.type}return n}var r,a;if(i.Libraries){if(!i.Libraries.allLibsInfo.widgets[e])throw new Error("Missing widget definition: "+e);return a=i.Libraries.allLibsInfo.widgets[e].manifest,r=(i.widgetOverrides||{})[e],r&&(Object.keys(r.properties||{}).forEach(function(t){a.propDefs&&a.propDefs[t]?a.propDefs[t].value=r.properties[t]:e!==a.type&&n(a.type,t)&&(a.properties||(a.properties={}),a.properties[t]=r.properties[t])}),a.styles=r.styles||a.styles),t.when(a)}return $("script#widget_"+e+"_widget_json").length?i.get("script#widget_"+e+"_widget_json"):i.get("widgets/"+e+"/widget.json")},this.getWidgetTemplate=function(e,t){if(i.Libraries){var n="widgets/"+e+"/"+t,r=i.Libraries.resources[n]&&i.Libraries.resources[n].libraryResourceData.textData&&i.Libraries.resources[n].libraryResourceData.textData.replace(/\>[\s]+\</gm,"><");if(!r&&""!==r)throw new Error("The component widgets/"+e+" is missing resource "+t);return r}return $("#widget_"+e+"_html").text()},this.addWidgetStylesheet=function(e,t){var n;if(i.Libraries){var r="widgets/"+e+"/"+t;if(!(n=i.Libraries.resources[r]&&i.Libraries.resources[r].libraryResourceData.textData)&&""!==n)throw new Error("The component widgets/"+e+" is missing resource "+t);$("link").last().after("<style id='widget_"+e+"_css'>"+n+"</style>")}},this.getFormView=function(){return i.Libraries?t.when(JSON.parse(i.Libraries.resources["form.json"].libraryResourceData.textData)):$("script#form-view").length?i.get("form-view"):i.get(this.baseName+"/form-view.json")},this.systemPath=function(){return i.manager?"services/formresources/"+i.formDesignVersionId+"/system/":"system/"},this.pathId=function(e){return e.replace(/[ \/.()\\]/g,"_").replace(/[!"#$%&'*+,:;<=>]+/g,"\\$&")},this.webSubmit=function(e){var t="<form id='submitForm' action='"+$("#sfc-prepop").attr("data-sfc-submission")+"' method='POST' accept-charset='utf-8' style='display: none;'><textarea name='xml_data'>"+e+"</textarea></form>";$("body").append(t),$("#submitForm")[0].submit()},this.inlineSubmit=function(e,r,a,o,s,u,c,l){var f;if(i.design||i.preview)return t.when(!0);if(s){if("Submitted"===c)return i.Transact.userSubmit(!(!a||!l),l);if("Saved"===c)return o?i.Transact.formUpdate(null,!(!a||!l),l,null,null,null,null,null):i.Transact.userSave(!(!a||!l),null,l);if("Abandoned"===c)return i.Transact.userCancel();throw new Error("Unexpected transaction state type: "+c)}return f={sfmOperationName:"backgroundSave",xml_data:r},a&&(f.sendEmail=!0),o&&(f.backgroundSave=!0),n.post(e,f)}}])});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};define("form/services/Widget",["app"],function(e){e.ng.service("Widget",["$q","Resource","Util",function(e,t,n){function r(e){var t={};return n.sendAll(e,function(e){e.type&&(t[e.type]=!0)}),Object.keys(t)}function i(r){var i,s=function(){var n=e.defer();if(i.js&&t.design){var a=i.js;i.js=t.widgetPath(r,i.js),require([i.js],n.resolve,function(){n.reject("The component widgets/"+r+" is missing resource "+a)})}else n.resolve(!0);return n.promise};if(!o[r]){if(t.design&&!t.Libraries.allLibsInfo.widgets[r])return console.log("Missing widget definition: "+r);o[r]=t.getWidgetManifest(r).then(function(e){if(i="string"==typeof e?JSON.parse(e):e,i.type===r)throw new Error("Invalid Widget Manifest: type "+r+" declares itself as its own base type");return i.rows&&i.rows.length&&i.rows[0].length&&(i.$$isComponent=!0,n.sendAll(i,function(e){e.$$component=i},!0)),t.design&&(i.icon&&(i.icon=t.widgetPath(r,i.icon)),i.css&&t.addWidgetStylesheet(r,i.css),i.html&&(i.html=t.getWidgetTemplate(r,i.html))),s()}).then(function(){return a.initModel(i,!0)}).then(function(e){return a.types[r]=e})}return o[r]}var a=this,o={};this.doComponentUpdate=!1,this.types={"~deferred~":{type:"block",label:"Deferred item",rows:[[]],category:"hidden"}},this.librariesInfo={},this.initTypes=function(t){return e.all(t.map(i))},this.addType=function(e){return i(e)},this.initModel=function(t,i,o,s){var u,c=r(t);return a.initTypes(c).then(function(){return a.create(t,o,null,i)}).then(function(r){return u=r,!s||e.all(n.values(t.dialogs).map(function(e){return a.create(e)}))}).then(function(r){return!s||(Object.keys(t.dialogs||[]).forEach(function(e,t){u.dialogs[e]=r[t]}),e.all(n.values(t.modals).map(function(e){return a.create(e)})))}).then(function(e){return s?(Object.keys(t.modals||[]).forEach(function(t,n){u.modals[t]=e[n]}),u):u})},this.create=function(e,t,r,i){var o,s,u=r?r.type:"",c=i||a.blockEditId&&a.blockEditId===e.id;return r=r||a.types[e.type]||{span:{xs:12,sm:12,md:12,lg:12},offset:{xs:0,sm:0,md:0,lg:0}},a.doComponentUpdate&&(e.$$isComponent||r.$$isComponent)&&!r.$$component&&(o=a.updateComponentDef(e,r,c)),s=n.hyperExtend(r,e),u&&(s.type=u),s.properties=s.properties||{},Object.keys(s.propDefs||{}).forEach(function(e){e in s.properties||(s.properties[e]=s.propDefs[e].value),s.propDefs[e].key||(s.propDefs[e].key=e)}),t&&"object"===(void 0===t?"undefined":_typeof(t))&&(s.$$parent=t,s.$$component&&(s.$$component=t.$$isComponent?t:t.$$component)),(s.rows||[]).forEach(function(e){e.forEach(function(t){var n=Object.getPrototypeOf(t),r=n.$$component?n:null,o=a.create(t,s,r,i);e.splice(e.indexOf(t),1,o)})}),o&&a.refactorIds(s,o,!0),s},this.makeKey=function(e){if(!e||"string"!=typeof e)throw new Error("Cannot make key for item missing label");return e.replace(/(^\d)/,"_$1").replace(/ +/g,"_").replace(/\W/g,"")},this.label=function(e){return a.types[e.type||e].label},this.isa=function(e,t){for("string"==typeof e&&(e=[e]);t;){if(e.indexOf(t.type)>=0)return!0;t=Object.getPrototypeOf(t)}return!1},this.typeInfo=function(e){for(var t=[],n=e.type||e;n;)t.push(n),n=a.types[n]&&a.types[n].type;return t},this.removeTypePromise=function(e){delete o[e]}}])}),function(){function e(){var e=this;this.commaList=function(e){return angular.isArray(e)?e:e.split(",").map(function(e){return $.trim(e)})},this.total=function(e,t,n){return e.reduce(function(e,r){return e+(!n||n(r)?+r[t]:0)},0)},this.num=function(e){return 1*e},this.daysBetween=function(e,t){return Math.floor((+new Date(t).getTime()-+new Date(e).getTime())/864e5)},this.rangeSelection=function(e,t){for(var n=[],r=+e;r<=+t;r++)n.push({label:r,value:r});return n},this.delimitedSelection=function(e){if(!e)return[];var t=/(\"[^\"]+\")|[^,]+/g;return e.match(t).map(function(e){var t=e.split("|");return{value:t[0].trim(),label:(t[1]||t[0]).trim()}})},this.pipedSelection=function(e){return e?e.split("|").map(function(e){return{label:e,value:e}}):[]},this.date=function(t,n){if(t){"string"==typeof t&&(t=t.replace(/\//g,"-"));var r=moment(t,e.getValidDateFormats(n),!0);return r.isValid()&&r.toDate()||""}return new Date},this.getValidDateFormats=function(e){var t=function(e){return e.reduce(function(e,t){e.push(t);var n=t.replace(/\-/g,"/"),r=t.replace(/\-/g," ");return n!==t&&e.push(n),r!==t&&e.push(r),e},[])},n=["MM-DD-YYYY","M-D-YYYY","MM-YYYY","MMM-DD-YYYY","MM-DD-YYYY h:mm","MM-DD-YYYY h:mm a","MM-DD-YYYY HH:mm","MM-YYYY h:mm a","MM-YYYY HH:mm","MMM-DD-YYYY h:mm a","MMM-DD-YYYY HH:mm"],r=["YYYY-MM-DD","YYYY-M-D","DD-MM-YYYY","D-M-YYYY","DD-MMM-YYYY","YYYY-MM","YYYY-MMM-DD","YYYY-MM-DD h:mm","YYYY-MM-DD h:mm a","YYYY-MMM-DD h:mm","YYYY-MMM-DD h:mm a","YYYY-MMM-DD HH:mm","DD-MM-YYYY h:mm","DD-MM-YYYY h:mm a","D-M-YYYY h:mm","D-M-YYYY h:mm a","DD-MM-YYYY HH:mm","D-M-YYYY HH:mm","DD-MMM-YYYY h:mm","DD-MMM-YYYY h:mm a","DD-MMM-YYYY HH:mm"];return t(e?r.concat(n):n.concat(r))}}"undefined"==typeof window?module.exports=new e:define("form/services/Calc",["app"],function(t){t.ng.service("Calc",e)})}();var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(){function e(e,t,n,r,i){function a(n,r){function i(n,r){return e.all(t.children(n).map(function(e){return a(e,r)})).then(function(e){return t.flatten(e)})}function s(e){return void 0!==e.rows&&t.children(e).length>0}function u(e){return!1===e&&(e="Not valid"),"string"==typeof e&&e.length?{id:n.id,type:"V",data:r,msg:e}:"object"!==(void 0===e?"undefined":_typeof(e))||Array.isArray(e)?null:e}function l(e,t){for(var n,i=e.$$parent,a=i&&!!i.repeatingData,o=!a&&r||r.$p;i;){if((n=c.Rules[t+"_"+i.id])&&!n(o,i))return!0;i=i.$$parent,i&&i.repeatingData&&(a=i,o=o.$p)}return!1}var f,d=c.Rules["ok_"+n.id],p=c.Rules["chok_"+n.id];return r?l(n,"sh")||l(n,"us")?e.when([]):["sh","us"].every(function(e){var t=c.Rules[e+"_"+n.id];return!t||t(r,n)})?(f=c.Rules["md_"+n.id],f&&(n.mandatory=f(r,n)),n.mandatory&&!c.hasValue(n,r)?e.when([{id:n.id,type:"M",msg:c.Form.mandatoryMsg(n),data:r}]):e.when("function"!=typeof n.$validation||!c.hasValue(n,r)||o(n.$validation,n,r)).then(function(t){var i=u(t);return i||e.when(!d||!c.hasValue(n,r)&&!s(n)||d(r,n))}).then(function(t){var i=u(t);return i||(p?c.hasValue(n,r)?r.$chok&&r.$chok[n.id]&&angular.equals(r.$chok[n.id].value,r[n.id])?e.when(r.$chok[n.id].result):e.when(p(r,n)).then(function(e){return r.$chok=r.$chok||{},r.$chok[n.id]={value:r[n.id],result:e},e}):(r.$chok&&delete r.$chok[n.id],e.when(!0)):e.when(!0))}).then(function(a){var o=u(a);return n.repeatingData&&Array.isArray(r[n.id])?e.all(r[n.id].map(function(e){return i(n,e)})).then(function(e){return(o?[o]:[]).concat(t.flatten(e))}):i(n,r).then(function(e){return(o?[o]:[]).concat(e)})})):e.when([]):e.when([])}function o(e,i,a){return e(a,a[i.id],i,t,n,r,c.Form,c)}function s(e){var t=e,n=e&&e.path||null;if(!n)return null;if("abs"===e.pathContext||"sys"===e.pathContext)return n;if("not"===e.pathContext)return null;if(!e.pathContext)for(;(t=t.$$parent)&&t.$$parent&&!t.repeatingData;){if("not"===t.pathContext)return null;if(t.path&&!t.noData&&(n=t.path+"."+n),"abs"===t.pathContext&&!t.noData)break}return n}function u(e){(e.rows||[]).forEach(function(t){t.forEach(function(t){t.$$parent=e,t._component&&(t.$$component=c.Form.items[t._component]),u(t)})})}var c=this;c.Form={},c.initData=function(e,n,r){var i;return r=r||{},i=c.defaultData(e),t.sendAll(e,function(e){r[e.id]=e},!1,!0),u(e),Object.keys(e.dialogs||{}).forEach(function(t){var n=e.dialogs[t];u(n),angular.extend(i,c.defaultData(n))}),Object.keys(e.modals||{}).forEach(function(t){var n=e.modals[t];u(n),angular.extend(i,c.defaultData(n))}),n&&(c.importData(n,i,r),i.SFMData=n.SFMData),i},this.defaultData=function(e){var n={};return e.rows.forEach(function(e){e.forEach(function(e){if(e.repeatingData)n[e.id]=i.design||0!==e.properties.initialItems?[c.defaultData(e)]:[];else if(e.rows&&!e.excludeRowData)e.hasOwnProperty("rows")?t.extend(n,c.defaultData(e)):n[e.id]=c.defaultData(e);else if(!e.noData){var r=!1===e.initialData||0===e.initialData?e.initialData:e.initialData||"";"array"!==e.dataType||Array.isArray(e.initialData)||(r=[r]),n[e.id]=r}})}),n},this.importData=function(e,n,r,i){Object.keys(n).forEach(function(a){var o,u,l,f,d,p,m=r[a],h=s(m),v=!1;if(h){for(i=i||e,o="abs"===m.pathContext?i:"sys"===m.pathContext?i.SFMData.SystemProfile:e,d=h.split(/[\.\/]/);d.length>1&&!v;)p=d.shift(),o[p]?o=o[p]:v=!0;if(u=v?"":o[d[0]],m.properties&&"number"===m.properties.inputType&&isFinite(u)&&(u=parseFloat(u)),"array"!==m.dataType||Array.isArray(u)||void 0===u||(u=[u]),m.repeatingData){if(Array.isArray(n[a])?n[a].length=0:n[a]=[],!u)return;l=c.defaultData(m,!0),Array.isArray(u)||(u=[u]),u.forEach(function(e){f=JSON.parse(t.jsonify(l,[])),c.importData(e,f,r,i),f.$$prefill=e,n[a].push(f)})}else n[a]=void 0===u?"":u}})},this.validate=function(t,n){return i.design?e.when({valid:!0,errors:[]}):a(t,n).then(function(e){return{valid:!e.length,errors:e}})},this.hasValue=function(e,t){return"function"==typeof e.$hasValue?o(e.$hasValue,e,t):"function"==typeof c.Rules["hasValue_"+e.id]?c.Rules["hasValue_"+e.id](t,e):!!("number"==typeof t[e.id]&&!isNaN(t[e.id])||t[e.id]||"checkbox"!==e.type&&!1===t[e.id])}}if("undefined"==typeof window){var t=require("./Util.js"),n=require("./Calc"),r=require("q");module.exports=new e(r,t,n)}else define("form/services/Validation",["app"],function(t){t.ng.service("Validation",["$q","Util","Calc","DynamicData","Resource",e])})}();var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};define("form/services/Form",["app"],function(e){e.ng.service("Form",["$q","$rootScope","$timeout","Http","Resource","JXON","Util","EncUtil","Widget","Validation","DynamicData","Calc","Scroll","Insights",function(e,t,n,r,i,a,o,s,u,c,l,f,d,p){function m(e){var t=i.pathId(e);return $("#"+t).length?t:e}function h(){var e=1;o.sendAll(C.view,function(t){t.$fieldSequence=e++},!1,!0)}function v(){C.validation.errors.length&&e.all(C.validation.errors.map(function(e){return c.validate(C.items[e.id],C.data)})).then(function(e){C.validation.errors=o.flatten(e.map(o.getVal("errors")))})}function m(e){var t=i.pathId(e);return $("#"+t).length?t:e}function g(e,t){var n={};return t=t||n,"object"!==(void 0===e?"undefined":_typeof(e))?e:(Object.keys(e).forEach(function(r){var a,s,u=C.items[r],c=u,l=C.getXmlPath(u),f=e[r];if(u){if(i.generated){for(;!a&&c&&"no"!==c.clearHidden;)a=a||"submit"===c.clearHidden,c=c.$$parent;a&&!C.isVisible(u,e)&&(f=u.repeatingData?[]:"")}else u.repeatingData&&Array.isArray(f)&&0===f.length&&(f="");l&&(u.repeatingData&&angular.isArray(f)&&(f=f.map(function(n){n.$p=e;var r=g(n,t);return i.generated&&n.$$prefill&&(r=o.merge(n.$$prefill,r)),r})),(s="abs"===u.pathContext?t:"sys"===u.pathContext?C.data.SFMData&&C.data.SFMData.SystemProfile:n)&&C.setValue(s,l,f,!0))}}),n)}function y(e){var t=[];e.forEach(function(e){t.push({TaskSubject:e.taskSubject,TaskMessage:e.taskMessage,ScheduledTime:e.scheduledTime,ExpiryTime:e.expiryTime,FormCompleted:e.formCompleted,FormEditable:e.formEditable,FormName:e.formName,FormURL:e.formURL,ReceiptURL:e.receiptURL})}),C.setSystemData("Job.StepTasks.Task",t)}var w,b,S,D,k=this,C=this,x=e.defer(),A=!1,P=[],E=$(".av-a11y-alert"),I=null;this.maestroVersion=i.maestroVersion,this.view={},this.data={},this.items={},this.pageName="",this.disableSave=!1,this.userInteraction=!1,this.saveChallengeRequired=!1,this.saveChallengeOnInit="true"==o.getUrlQueryParam("saveChallenge"),this.Rules={},this.validation={valid:!0,errors:[]},this.Translation=null,this.showMobileErrors=!1,c.Form=d.Form=C,this.load=function(n,r,a){if(n){var s;console.log("Form loading");var c=(new Date).getTime();return n="string"==typeof n?JSON.parse(n):n,n.path=n.path||"AvokaSmartForm",C.maestroReleaseVersion=n.maestroReleaseVersion,s=i.design?u.initModel(n):e.when(n),s.then(function(n){function a(){if(C.initDDS(),"Receipt"===C.getSystemData("DisplayMode")&&(o.isReceipt=!0),t.avReceipt=o.isReceipt,t.avDebugPageBreaks=C.view.properties.addPageBreakDebugCss,o.isReceipt&&C.fixReceiptLayout($("body")),window._perf_initformmodel=(new Date).getTime()-c,!C.getSystemData("Insights.Enabled")||i.preview||C.isFieldWorker()||p.init(C.view),o.isReceipt){return C.loadAllPages()}}return t.Form=C,t.item=C.view=n,t.Util=o,t.$on("translate",v),(i.design?C.loadAllModalsDialogs():e.when(!0)).then(function(){return C.initData(r)}).then(a)}).then(function(){var e=o.getUrlQueryParams();return h(),window._perf_initmodalsdialogs=(new Date).getTime()-c,a&&P.forEach(function(e){e(C.view)}),x.resolve(C.view),A=!0,"saveChallenge"in e&&(C.view.modals&&"savechallenge"in C.view.modals?C.showModal("savechallenge"):C.view.dialogs&&"savechallenge"in C.view.dialogs&&C.showDialog("savechallenge")),window._perf_formload=(new Date).getTime()-c,console.log("Form loaded in "+window._perf_formload+"ms"),l.isFieldWorker=C.isFieldWorker(),C.view}).catch(function(e){return x.reject(e),e})}return x.promise},this.watchFormDataChange=function(){if(!I&&!C.userInteraction){var e=[],n={};o.sendAll(C.view,function(t){"data-field"!=t.type&&(e.push("data."+t.id),n[t.id]=C.data[t.id])},!0,!0,!0),I=t.$watchGroup(e,function(e,t){function n(e){if(angular.isObject(e))for(var t=Object.keys(e),r=0;r<t.length;r++)if(!n(e[t[r]]))return!0;return null==e}function r(e,t){for(var i=Object.keys(e).filter(function(e){return!e.match(/^\$/)}),a=Object.keys(t).filter(function(e){return!e.match(/^\$/)&&i.indexOf(e)<0}),o=0;o<a.length;o++)if(!n(t[a[o]]))return!0;for(var o=0;o<i.length;o++){var s=i[o];if(angular.isObject(e[s])&&angular.isObject(t[s]))return r(e[s],t[s]);if(e[s]!==t[s]&&!!e[s]!==t[s]&&e[s]!==!!t[s])return!0}return!1}r(e,t)&&(I(),C.registerFormInteraction())})}},this.showHidePages=function(e){var t=[];o.sendAll(C.view,function(e){if(u.isa("nav-page",e))return t.push(e),!1});var n=!0,r=!1,i=void 0;try{for(var a,s=t[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var c=a.value,l=e||c.$navSelected;e&&c.$navGroup&&C.Rules["sh_"+c.$navGroup.id]&&(l=C.Rules["sh_"+c.$navGroup.id](C.data,c.$navGroup)),c.$viewTemplate=m(l?"pages/"+c.id+"/page.html":"pages/page-spinner/page.html")}}catch(e){r=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(r)throw i}}},this.loadAllPages=_asyncToGenerator(regeneratorRuntime.mark(function e(){var t,n,r,i,a,o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",!0);case 8:if(t=(a=i.next()).done){e.next=15;break}return o=a.value,e.next=12,k.loadPage(o.id);case 12:t=!0,e.next=8;break;case 15:e.next=21;break;case 17:e.prev=17,e.t0=e.catch(6),n=!0,r=e.t0;case 21:e.prev=21,e.prev=22,!t&&i.return&&i.return();case 24:if(e.prev=24,!n){e.next=27;break}throw r;case 27:return e.finish(24);case 28:return e.finish(21);case 29:case"end":return e.stop()}},e,k,[[6,17,21,29],[22,,24,28]])})),this.loadPage=function(){var e=_asyncToGenerator(regeneratorRuntime.mark(function e(t){var n,r,a,o,s,u,l,f,d,p,v;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=C.items[t],!n.$$pageLoaded){e.next=3;break}return e.abrupt("return");case 3:if(n.$viewTemplate=m(i.baseName+"/pages/"+t+"/page.html"),C.view.publishOptions&&C.view.publishOptions.useDpl){e.next=6;break}return e.abrupt("return");case 6:return r=function(e){return new Promise(function(t,n){if(document.querySelector('script[src="'+e+'"]'))return t();var r=document.createElement("script");r.src=e,r.onload=t,r.onerror=n,document.head.appendChild(r)})},a="pages/"+t+"/page.json",e.next=10,i.get(a);case 10:o=e.sent,Object.assign(n,o),s=!0,u=!1,l=void 0,e.prev=15,f=(n.jsFiles||[])[Symbol.iterator]();case 17:if(s=(d=f.next()).done){e.next=24;break}return p=d.value,e.next=21,r(p);case 21:s=!0,e.next=17;break;case 24:e.next=30;break;case 26:e.prev=26,e.t0=e.catch(15),u=!0,l=e.t0;case 30:e.prev=30,e.prev=31,!s&&f.return&&f.return();case 33:if(e.prev=33,!u){e.next=36;break}throw l;case 36:return e.finish(33);case 37:return e.finish(30);case 38:v=c.initData(n,C.prefill,C.items),Object.assign(C.data,v),h(),n.$$pageLoaded=!0,console.log("Loaded page "+t);case 43:case"end":return e.stop()}},e,this,[[15,26,30,38],[31,,33,37]])}));return function(t){return e.apply(this,arguments)}}(),this.loadAllModalsDialogs=function(){var t=o.values(C.view.dialogs).concat(o.values(C.view.modals));return e.all(t.map(C.loadModalDialog))},this.loadModalDialog=function(e){return i.design?u.initModel(e).then(function(e){var t=e.isDialog?C.view.dialogs:C.view.modals,n=e.id;if(!t.hasOwnProperty(n))throw new Error("Unexpected Page Item: "+n);return t[n]=e,i.design&&angular.extend(C.data,c.initData(e,C.prefill,C.items)),h(),e.$$pageLoaded=!0}):C.loadPage(e.id)},this.initData=function(n,r,u){function l(e){var l;v&&(s.encryptSubmitData=!0),C.prefill=a.parse(e.trim()),m&&C.prefill&&!C.prefill.SFMData&&(C.prefill.SFMData=n),l=c.initData(C.view,C.prefill,C.items),!m&&n&&(l.SFMData=n),r||(t.data=C.data=l),i.design&&r&&!m&&o.sendAll(C.view,function(e){if(e.repeatingData&&""!==e.properties.initialItems){var t=o.findParentRepeat(e),n=t?l[t.id]:l[e.id];if(!n)return;t?Object.keys(n).forEach(function(t){d(n[t][e.id],e,u)}):d(n,e,u)}}),p.resolve(l)}function f(e){C.showProgress("Processing form data failed!"+(e?"\n"+e:"")),p.reject(e)}function d(e,t,n){var r=e.length,i=t.properties.initialItems>=t.properties.minItems?t.properties.initialItems:t.properties.minItems;n&&0===parseInt(i)&&e.splice(0,e.length);for(var a=e[0]||c.defaultData(t);r<i;)e.push(a),r++;for(;t.properties.maxItems&&r>t.properties.maxItems;)e.pop(),r--}var p=e.defer(),m=!!C.view.previewData&&(i.design||i.preview)&&!u&&!(!C.view.previewData.applyToWireframe&&!r),h=$("#sfc-prepop").text()||m&&C.view.previewData.xmlData||"",v=i.generated&&s.isDataEncrypted(h);return n=n||C.data.SFMData,v?s.isEncryptionSupported()?s.tmDecryptData(h).then(l).catch(f):f(s.failMsg):l(h),p.promise},this.updateData=function(t){return(s.isSubmitDataEncryptionNeeded()?s.tmDecryptData(t):e.when(t)).then(function(e){C.prefill=a.parse(e.trim()),c.importData(C.prefill,C.data,C.items),C.data.SFMData=C.prefill.SFMData})},this.initDDS=function(){l.init(C.getSystemData("FormDataServiceURL"),C.getSystemData("FormCode"),C.getSystemData("RequestLogKey"))},this.onReload=function(e){P.push(e),A&&e(C.view)},this.completeSectionsOnSubmit=[],this.submit=function(r,a,u,c,l,f,d){if(C.saveChallengeOnInit)return e.reject("Cannot submit/save on Save Challenge resume");var m,h,v=e.defer();return S?e.reject({errorMessage:"Submit call already in progress"}):(S=!0,void 0===l&&(l=C.view.properties.autoSendEmails),r=r||"Submitted",C.loadAllPages().then(function(){return"Submitted"===r||c?C.validate(c||C.view,null,"S"):e.when(!0)}).then(function(c){function g(){C.setSystemData("SubmissionType",r),"Saved"===r&&C.$Pages&&"number"==typeof C.$Pages.index&&C.setSystemData("LastSavedPageIndex",C.$Pages.index),m=C.getDataXml(),s.isSubmitDataEncryptionNeeded()&&!i.preview?s.tmEncryptData(m).then(w).catch(function(){S=!1}):w(m)}function w(s){var c,d={Submitted:"submit",Abandoned:"cancel",Saved:"save"},m=C.view.systemValues.email,h=m&&C.data[m];if("Submitted"===r)o.unique(C.completeSectionsOnSubmit,"id").forEach(function(e){p.sectionExit(e)});else if(C.dialogName){var g=C.view.dialogs[C.dialogName];p.sectionExit(g)}if(f||C.registerFormInteraction(),C.isFieldWorker()){var w=window.getFieldWorkerComposerAPI&&window.getFieldWorkerComposerAPI(),b={submissionType:r,xml:s};"Abandoned"==r&&(b.showSaveDiscard=!0),w&&w.notifySubmit(b),S=!1}else a?(f||p.terminate(d[r]),i.webSubmit(s),S=!1):(u||C.showProgress(C.term(C.view.id+".properties.progressMsg","Please wait...")),i.inlineSubmit(C.getSystemData("FormDataServiceURL"),s,l,f,!(!C.view.transact||!C.view.transact.newFormApi),C.getSystemData("RequestLogKey"),r,h).then(function(t){return c=t,c&&c.errorMessage?e.reject(c):c&&c.formData?C.updateData(c.formData):e.when(!0)}).then(function(){var e;if(f||p.terminate(d[r]),"Abandoned"!=r&&"Submitted"!=r||(C.disableSave=!0,clearInterval(D)),!u&&c){if(c.hasOwnProperty("redirectUrl")||c.hasOwnProperty("performRedirect")&&"true"===c.performRedirect)return void C.redirect(c.redirectUrl||c.redirectTarget,c.redirectParent);if(e={Saved:"savesuccess",Abandoned:"cancelsuccess",Submitted:"submitsuccess"}[r],t.$broadcast("postSubmit",c),c.hasOwnProperty("job")&&c.job.hasOwnProperty("allTasks")&&y(c.job.allTasks),C.data.$submitResponse=c,C.showProgress(""),C.showModal(e),c.sessionExpiredTarget){var i=C.view.properties.sessionExpiryRedirectTimeout,a=1e3*+(o.isBlank(i)?300:i);n(a).then(function(){C.redirect(c.sessionExpiredTarget,c.redirectParent)})}}if(c&&void 0!==c.revisionNumber){var s=+C.getSystemData("RevisionNumber"),l=+c.revisionNumber;l>s&&C.setSystemData("RevisionNumber",l)}v.resolve(c)}).catch(function(e){return C.handleUnauthorizedResponse(e),e&&e.errorMessage&&!e.redirectTarget&&!e.errorWasDisplayed&&alert(e.errorMessage),v.reject(e),C.showProgress(""),e}).finally(function(){S=!1}))}if("object"===(void 0===c?"undefined":_typeof(c))&&c.valid&&(c.errors=C.validation.errors.concat(c.errors)),C.showMobileErrors=!c.valid&&!0!==c,!c.valid&&"object"===(void 0===c?"undefined":_typeof(c)))return C.validation=c,d||C.gotoError(0),S=!1,v.reject(c),void(C.submitFailedValidation=!0);delete C.submitFailedValidation,h=C.fireRule("presubmit",C.view,C.data),"object"===(void 0===h?"undefined":_typeof(h))?h.then(g).catch(function(){S=!1}):!1!==h&&g()}).catch(function(){S=!1}),v.promise)},this.backgroundSave=function(){return C.disableSave?e.reject("Save is disabled"):C.submit("Saved",!1,!0,null,null,!0)},this.handleUnauthorizedResponse=function(e){if(e.errorMessage){var t=!1;if(e.errorMessage&&-1!=e.errorMessage.indexOf("Save Challenge Required")&&(C.showDialog("savechallenge"),C.saveChallengeRequired=!0,t=!0),!t){var n=e.redirectTarget;n&&o.openURL(n)}}},this.taskUrlNavigate=function(e,t){function n(){C.backgroundSave().then(function(t){C.redirect(e)},function(e){C.showProgress(""),console.log("There was an error saving and redirecting the form, please try again.")})}if(e){if(t)var r=C.getSystemData("Job.StepTasks.Task"),i=r.filter(function(e){return e.FormCompleted}).length;C.showProgress(C.term(C.view.id+".properties.progressMsg","Please wait...")),t&&i+1===r.length?C.validate().then(function(t){t.valid?C.submit("Submitted",!1,!0).then(function(){C.redirect(e)}):n()}):n()}},this.getDataXml=function(e,t,n){var r,s=angular.copy(n||C.data),u=i.generated?o.merge(C.prefill,g(s)):g(s),c=o.jsonify(s.SFMData,[]),l=JSON.parse(c),f={};return l=o.merge(l,u.SFMData||{}),t||angular.extend(u,{SFMData:l}),u=JSON.parse(o.jsonify(u),[]),f[C.view.path]=u,r=a.serialize(f,e),r=r.replace("<Referer>","<Referer><![CDATA["),r=r.replace("</Referer>","]]></Referer>")},this.availableRoutes=function(){var e=C.getSystemData("Job"),t=e&&e.AvailableRoutes;return t?t.split("|"):[]},this.isStep=function(e){var t=C.getSystemData("Job.StepName")||"";return angular.isArray(e)||(e=e.split("|")),o.contains(e,t)},this.getXmlPath=function(e,t){var n=e,r=e&&!e.noData&&e.path||null;if(!r)return null;if("abs"===e.pathContext||"sys"===e.pathContext)return r;if("not"===e.pathContext)return null;if(!e.pathContext)for(;(n=n.$$parent)&&n!==C.view&&(t||!n.repeatingData);){if("not"===n.pathContext)return null;if(n.path&&!n.noData&&(r=n.path+"/"+r),"abs"===n.pathContext&&!n.noData)return r}return r},this.showModal=function(t,r){var a,o=C.view.modals[t];if(t&&void 0===o)throw new Error("Modal with id:"+t+" does not exist");C.showDialog(""),C.pageName=t,t?i.generated&&(a=o.$$pageLoaded?e.when(!0):C.loadModalDialog(o),a.then(function(){var e=C.view.properties.gaBaseUrl||"/";/^\//.test(e)||(e="/"+e),/\/$/.test(e)||(e+="/"),C.modalTemplate=m("pages/"+t+"/page.html"),d.scrollTo(0),window.gtag?gtag("event","page_view",{page_title:t,page_path:e+u.makeKey(t)}):window.ga&&(ga("set",{page:e+u.makeKey(t),title:t}),ga("send","pageview")),n(function(){
C.hasRule("load",o)&&C.fireRule("load",o,C.data),C.showAccessibleAlert(o.properties.alertMsg||C.term(o.id+".label")+" has loaded"),n(350,!1).then(C.focusOnFirstHeading)},100),p.navigation(o)})):(C.modalTemplate="",r&&C.$Pages&&C.$Pages.currentPage&&C.showAccessibleAlert(C.$Pages.currentPage.label+" page has loaded"))},this.showDialog=function(r){function a(e){if(o.contains(["iOS","Android"],i.deviceType))if(e){var t=$("body > form:not('.av-modal-page')");b=$(window).scrollTop(),$(document.body).on("touchmove.dialog",function(e){s[0].contains(e.target)||e.preventDefault()}),n(50).then(function(){t.scrollTop(b)},!1)}else $(document.body).off("touchmove.dialog"),$(window).scrollTop(b)}var s,u,c,l=$("html"),f=C.view.dialogs[r];if(r&&void 0===f)throw new Error("Dialog with id:"+r+" does not exist");C.dialogName||C.dialogName===r||(w=document.activeElement),r?(u=e.when(!!f.$$pageLoaded||C.loadModalDialog(C.view.dialogs[r])),u.then(function(){function e(){i("av-popover-btn",!0),C.hasRule("load",f)&&C.fireRule("load",f,C.data),"function"==typeof c&&c()}function i(e,t){var r=s.find(d).filter(function(){return this.tabIndex>=0&&!(e&&$(this).hasClass(e))});return r.length&&(o=r[0],u=r.last(),t&&o&&n(350,!1).then(function(){C.focusOnFirstHeading(s,function(){o.focus()})})),r}var o,u,d=["input:visible, input[type='checkbox'], a:visible","input[type='radio'], button:visible, textarea, select"].join(", ");c=t.$on("$includeContentLoaded",function(t,r){n(function(){s=$(".av-dialog"),s.length?e():console.error("Cannot load dialog")},100)}),C.dialogName=r,C.dialogTemplate=m("pages/"+r+"/page.html"),l.find("form[name=form]").attr("aria-hidden","true"),C.showAccessibleAlert((f.properties.ariaLabel||C.term(f.id+".label"))+" dialog window has opened"),a(!0),l.addClass("av-show-dialog"),$(l).on("keydown.dialog",function(e){if(C.saveChallengeOnInit||27!==e.keyCode){if(9===e.keyCode){e.preventDefault(),e.stopPropagation();var n=i();if(!n.length)return;var r=n.index(document.activeElement),a=e.shiftKey?r-1:r+1;n[a]?n[a].focus():a>0?o.focus():u.focus()}}else C.showDialog(""),t.$digest()}),p.navigation(f)})):(f=C.view.dialogs[C.dialogName],f&&p.sectionExit(f),C.clearValidationErrors(f),l.find("form[name=form]").attr("aria-hidden",null),l.removeClass("av-show-dialog"),a(!1),$(l).off("keydown.dialog"),w&&w.focus(),n(5).then(function(){C.dialogName="",C.dialogTemplate=""}))},this.postData=function(e,t,n){var i=C.getSystemData("FormDataServiceURL"),a=t||!1;return e.sfmRequestKey=C.getSystemData("RequestLogKey"),a||C.showProgress(C.term(C.view.id+".properties.progressMsg","Please wait...")),r.sendMultipart("POST",i,e,n).then(function(e){return a||C.showProgress(""),e}).catch(function(e){throw a||C.showProgress(""),e})},this.emailOperation=function(e,t,n,r,a){if(!i.preview&&!i.design)return C.validate(n).then(function(i){if(i.valid){var o={sfmOperationName:e,emailAddress:C.data[n]};return r&&(o.senderName=C.data[r]),a&&(o.emailBody=C.data[a]),C.postData(o).then(function(){if(t){var e=C.items[t].properties.backgroundSuccessMessage;C.data[t]={$responseStatus:"success",$responseMessage:e}}}).catch(function(e){t&&(C.data[t]={$responseStatus:"error",$responseMessage:e||"There was an error, please try again."})})}})},this.resumeForm=function(t,n,r){if(i.preview||i.design)return e.when(!1);var a=C.getItemFromPath(t),o=C.getItemFromPath(n),s=C.getItemFromPath(r);return C.validate(a).then(function(e){if(e.valid){var t={sfmOperationName:"saveChallenge",referenceNumber:o&&C.data[o.id]||"",saveChallengeAnswer:s&&C.data[s.id]||""};return C.postData(t,!1,!0).then(function(e){if(!0===C.saveChallengeRequired)C.showDialog(""),C.saveChallengeRequired=!1;else{if(!e)return;C.redirect(e.redirectTarget,e.redirectParent)}})}})},this.redirect=function(e,t){o.isBlank(e)||(window.onbeforeunload=null,1!=t&&"true"!=t||!window.parent?window.location.replace(e):window.parent.location.replace(e))},this.getRevisionNumber=function(){var e=0,t=C.getSystemData("RevisionNumber");return t&&"string"==typeof t&&t.length>0&&(e=parseInt(t,10)),e},this.registerFormInteraction=function(){if(!C.userInteraction&&!i.preview){if(this.getRevisionNumber()>0)return void(C.userInteraction=!0);C.userInteraction=!0,C.view.transact&&C.view.transact.newFormApi?function(){C.Transact.formStart()}():C.postData({sfmOperationName:"formStart"},!0,!0)}},this.getItem=function(e,t){return C.load().then(function(){var n,r=C.getElementItemId(t);if(!(n=C.items[r]))throw new Error("Item lookup failed for ID "+r);return n.setData=function(t){e.data[r]=t},n.getData=function(){return e.data[r]},n.isDisabled=function(){return t.hasClass("av-disabled")},n})},this.getBlockData=function(e,t){var n={};if("string"==typeof e&&(e=C.items[e]),t=t||C.data,!e||!e.rows)throw new Error("Form.getBlockData called without valid container item");return o.children(e).forEach(function(e){o.contains(["string","number","boolean"]),_typeof(t[e.id])&&(n[e.id]=t[e.id])}),n},this.getItemsOfType=function(e){var t=[];return o.sendAll(C.view,function(n){n.type===e&&t.push(n)}),t},this.getElementItemId=function(e){var t,n;if(e&&0!==e.length){for(;e&&!(t=e.attr("class")&&e.attr("class").match(/(^| )id-([^ ]*)/))&&!n;)e=e.parent(),n=e.is("body");if(!(n||t&&(t=t[2])))throw new Error("Item lookup failed for element "+e);return t}},this.getUniqueId=function(e,t){for(var n=t&&t.$p||null,r=e.replace(/\s/g,"_");n;)void 0!==n.$i&&(r+="-p"+n.$i),n=n.$p||null;return t&&void 0!==t.$i&&(r+="-i"+t.$i),r},this.getDisplayValue=function(e,t){var n,r,i;if("string"==typeof e&&t?(r=C.items[e],n=o.findElementFromItem(r,t)):"object"===(void 0===e?"undefined":_typeof(e))&&(r=e.scope().item,n=e),n&&n.length&&(i=n.find("[data-ng-model='data."+r.id+"']"),i.length||(i=n.find("input, select, textarea")),i&&i.length)){if(i.is("select")){var a=i[0];return a.options&&0!=a.options.length?$(a.options[a.selectedIndex]).text():i.scope().data[r.id]}if(i.is("[type='radio']")){return C.getSelectionLabel(r.id)||i.filter("input:checked").val()}return i.is("[type='checkbox']")?i[0].checked:i.val()}},this.copyData=function(e,t,n,r){if("string"==typeof e&&(e=C.items[e.split(".").pop()]),"string"==typeof n&&(n=C.items[n.split(".").pop()]),!e||!n)return void console.log("Attempt to copy data between invalid items");e.rows.forEach(function(i,a){i.forEach(function(i,o){var s=e.rows[a][o].id,u=n.rows[a][o].id;t[s]||""===t[s]?r[u]=t[s]:delete r[u],C.items[s].rows&&C.copyData(C.items[s],t,C.items[u],r)})})},this.cacheData=function(e,t){var n={},r="string"==typeof e?C.items[e]:e;return t=t||C.data,o.descendants(r,function(e){return!e.$$parent.repeatingData}).forEach(function(e){n[e.id]=t[e.id]}),JSON.stringify(n)},this.loadCachedData=function(e,t){t=t||C.data,$.extend(t,JSON.parse(e))},this.setSystemData=function(e,t){for(var n,r=("data.SFMData.SystemProfile."+e).split("."),i=C;n=r.shift();)0===r.length?i[n]=t:(void 0===i[n]&&(i[n]={}),i=i[n])},this.getSystemData=function(e){return e?C.getPathData("data.SFMData.SystemProfile."+e):C.data.SFMData.SystemProfile},this.isAuthenticatedUser=function(){return!o.isBlank(C.getSystemData("UserName"))},this.getPathData=function(e,t){var n,r=e.split("."),i=t||C.data;if(""===e)return"";for(e.match(/^Form\.data\./)?(i=C.data,r.splice(0,2)):e.match(/^data\./)&&r.shift();n=r.shift();)if(void 0===(i=i[n]))return null;return void 0!==i?i:""},this.setPathData=function(e,t,n){var r=e.split("."),i=n||C.data;if(e.match(/^Form\.data\./)?(i=C.data,r.splice(0,2)):e.match(/^data\./)&&r.shift(),""!==e)for(;part=r.shift();){if(void 0===(void 0===i?"undefined":_typeof(i)))return;0===r.length?i[part]=t:i=i[part]}},this.getFieldRefPropValue=function(e,t){var n=C.getItemProperty(e,t);return n?C.getPathData(n):""},this.isFieldWorker=function(){var e;try{e=C.data.SFMData.SystemProfile.HostContext}catch(e){return console.log("Couldn't find Transact System Profile Host Context in prefill data"),!1}return"FieldWorker"===e},this.validate=function(e,t,n){var r="string"==typeof e?C.items[e]:e;return n||(n="PR"),r||(r=C.view),t||(t=C.data),C.resetRepeatRefs(C.data),c.validate(r,t,n).then(function(e){var i=o.findElementFromItem(r,t),a=i.scope();return a&&a.$broadcast("validate",e,i),e.valid?p.validation([{error:null,item:r,data:a?a.data:t}],n):p.validation(e.errors.map(function(e){return{error:e,item:C.items[e.id],data:e.data}}),n),e})},this.resetRepeatRefs=function(e){function t(e){if(e&&"object"===(void 0===e?"undefined":_typeof(e)))return Object.keys(e).filter(function(t){var n=C.items[t];return n&&n.repeatingData&&!t.match(/^\$/)&&Array.isArray(e[t])})}(function(e){return t(e).map(function(t){return e[t]})})(e).forEach(function(t){t.forEach(function(n,r){n.$p=e,n.$r=t,n.$i=r,C.resetRepeatRefs(n)})})},this.clearValidationErrors=function(e,t){var n,r="string"==typeof e?C.items[e]:e,i=C.validation.errors;r||(r=C.view),t||(t=C.data),0!==i.length&&(o.sendAll(r,function(e){(n=o.find(i,"id",e.id))&&o.removeItem(i,n)}),0===i.length&&(C.validation.valid=!0))},this.validateFieldRefMap=function(t,n,r){function i(e){e.valid?a[s+1]?(s++,C.validate(a[s],n).then(i)):o.resolve():r&&alert(r)}var a=t.map(function(e){return e.ref.replace(/(data\.|\$p\.|\$r\.)/,"")}).filter(function(e){return $(".id-"+e).length}),o=e.defer(),s=0;return a.length?C.validate(a[s],n).then(i):o.resolve(),o.promise},this.showProgress=function(e){C.notificationProgressing=!!e,n(25).then(function(){C.notificationMessage=e})},this.setTitle=function(e){$("title").text(e)},this.setValue=function(e,t,n,r){var i,a=o.startsWith(t,"data."),s=t.replace(/^data\./,"").split(/[\.\/]/);for(void 0===n&&(n=""),e||(e=C),a&&"object"===_typeof(e.data)&&(e=e.data);s.length>1;)i=s.shift(),"object"!==_typeof(e[i])&&(e[i]={}),e=e[i];i=s[0],r&&Array.isArray(e[i])&&Array.isArray(n)?e[i]=o.merge(n,e[i],!1,function(e,t,n){""===t[n]&&(t[n]=e[n]||"")}):e[i]=n},this.gotoError=function(e){function t(){var t=!1;n(function(){if(e&&void 0!==e.data.$i&&(r=o.findElementFromItem(C.items[e.id],e.data),t=!0),0===e){if($("form")[0].offsetWidth<+C.view.breakpoints[1])return void((r=$(".av-menu-errors-small")[0])&&r.focus());r=$(".av-menu-errors")[0]}else t||(r=$(".id-"+e.id)[0]);C.dialogName?$(r).find("input, textarea, select")[0].focus():d.scrollTo(r,!0,!0)},300)}var r,i,a,s=C.items[e.id];if(e&&s&&C.$Pages&&C.$Pages.flatPages){var u=null;i=C.$Pages.flatPages;do{u=o.find(i,"id",s.id),u&&(a=u),s=s.$$parent}while(s&&!a);if(a&&a!==C.$Pages.currentPage)return C.$Pages.choose(a.$navGroup||a,a,!0,!1,!0,!0).then(function(){t()})}t()},this.goToNextError=function(){var e,t=C.validation.errors,n=t.length,r=0,i=0;if(t.length>0){if(C.lastFocusedItem)for(e=C.lastFocusedItem.id;i<n;i++)if(t[i].id===e&&i+1<n){r=i+1;break}C.gotoError(t[r])}},this.getRepeatedLayout=function(e,t){var n=[],r=!1,i="vertical"===e,a=0,o=["lg","md","sm","xs"];if("horizontal"==e)return"";for(;a<o.length;a++)i||o[a]!==t||(r=!0),n.push("col-"+o[a]+"-"+(r?"12":function(e){return i?"12":e}(e)));return n.join(" ")},this.convertToFieldDataMap=function(e,t){if(!Array.isArray(e))throw new Error("Invalid parameter for Form.convertToDataParams, must be an array");var n={};return e.forEach(function(e){n[e.key]=C.getPathData(e.ref.split(".").splice(-1)[0],t)}),n},this.setFieldDataFromResponse=function(e,t,n){function r(e,t){return t&&"string"==typeof e&&t.properties&&t.properties.maxLength&&(e=e.substring(0,t.properties.maxLength)),e}if(!Array.isArray(e))throw new Error("Invalid parameter for Form.setFieldDataFromResponse, must be an array");if(0!=e.length){var i=Array.isArray(t),a=[];"object"!==(void 0===t?"undefined":_typeof(t))&&(t={value:t}),e.forEach(function(s){var u=s.ref,c=u.split(".").pop(),l=C.items[c];if(i){var f,d;d=o.findParentRepeat(l),d?(l=d,a.some(function(e){return e==l.id})||(a.push(l.id),f=t.map(function(t){var n={};return e.forEach(function(e){void 0!==t[e.key]&&(t[e.key]=r(t[e.key],l),n[e.ref.split(".").splice(-1)[0]]=t[e.key])}),n}),o.addRepeatContent(l,f))):t.forEach(function(e){e[s.key]=r(e[s.key],l),C.setValue(n,u,e[s.key]||"")})}else{t[s.key]=r(t[s.key],l);var p=t[s.key];t.hasOwnProperty(s.key)&&void 0!==p&&null!==p||(p=""),C.setValue(n,u,p)}})}},this.getSelectionLabel=function(e,t){var n,r,i=C.items[e.split(".").splice(-1)],a="";if(!i)throw new Error("Unable to find item: getSelectionLabel method.");return Object.keys(i.properties||{}).forEach(function(s){Array.isArray(i.properties[s])&&i.properties[s].length&&(r=C.term(i.id+".properties."+s),(n=o.find(r,"value",C.getPathData(e.replace("data.",""),t)))&&(a=n.label))}),!a&&i.properties.dataPath&&i.properties.labelField&&(n=o.find(C.getPathData(i.properties.dataPath,t),"value",C.getPathData(e.replace("data.",""),t)))&&(a=n.label),a},this.getItemFromPath=function(e){if(!e)return!1;var t=e.split(".").pop();return C.items[t]||!1},this.getItemProperty=function(e,t){var n="string"==typeof e?C.getItemFromPath(e):e;return n||console.log("Unable to find item "+e+" : getItemProperty method."),C.term(n.id+".properties."+t)||""},this.term=function(e,n){function r(e,t){for(var n=t.split(".");e&&n.length;)e=e[n.shift()];return e}var i=r(t.T,e)||r(C.items,e);return void 0===i&&(i=n||"MISSING TERM: "+e),i},C.mandatoryMsg=function(e){var t=C.term(C.view.id+".properties.mandatoryMsgSuffix","is required"),n=C.term(e.id+".label",e.label)+" "+t;return C.term(e.id+".mandatoryMsg",n)},this.fireRule=function(e,t,n,r){var i="string"==typeof t?C.items[t]:t,a=e+"_"+i.id;if("function"==typeof C.Rules[a])return C.Rules[a](n,i,r||null)},this.hasRule=function(e,t){var n="string"==typeof t?C.items[t]:t,r=e+"_"+n.id;return"function"==typeof C.Rules[r]},this.hasRuleInAncestry=function(e,t){var n="string"==typeof t?C.items[t]:t;return!!(C.hasRule(e,n)||n.$$parent&&C.hasRuleInAncestry(e,n.$$parent))},this.getCurrentPageNumber=function(){return C.$Pages&&C.getNavPages().indexOf(C.$Pages.currentPage)+1||null},this.getNavPages=function(){return C.$Pages&&Array.isArray(C.$Pages.flatPages)&&C.$Pages.flatPages.filter(function(e){return e.$navVisible&&!e.properties.offMenu})||[]},this.getNavPageCount=function(){return C.getNavPages().length},this.getDynamicPageTitle=function(){var e=t.T&&C.term(C.view.id+".label")||C.view.label;if(C.$Pages&&C.$Pages.currentPage){var n=C.$Pages.currentPage.$navGroup||C.$Pages.currentPage;e+=" - "+C.$Pages.pageLabel(n)}return e},this.goToPage=function(e,t,n){var r=!isNaN(e)&&e-1,i=!1===r?C.items[e]:C.$Pages.flatPages[r];if(i){if(i.$navVisible)return C.$Pages.chooseFlat(i,t,n);console.log("Page with id: "+i.id+" not visible.")}else console.log("Page "+e+" not found.")},this.getCurrentPageId=function(){return C.$Pages&&C.$Pages.currentPage&&C.$Pages.currentPage.id||""},this.addRepeatInstance=function(e,t,r){if("string"==typeof e&&(e=C.items[e.split(".").pop()]),!e.properties.maxItems||t.length<e.properties.maxItems){var i=t.push(c.defaultData(e)),a=C.Rules["add_"+e.id];return i--,a&&a(t,e),(e.properties.transferFocus||r)&&n(function(){o.findElementFromItem(e,t[i]).find("input, select, textarea, button").first().focus()},300),n(400).then(function(){var t=e.properties.itemLabel.toLowerCase()||"item";C.showAccessibleAlert(["Repeat",t,i+1,"added"].join(" "))}),t[i]}},this.removeRepeatInstance=function(e,t,r,i){"string"==typeof e&&(e=C.items[e.split(".").pop()]);var a,s=!o.isBlank(t.$i),u=C.Rules["delete_"+e.id],c=s?t.$r:t;c.length>e.properties.minItems&&(o.isBlank(r)&&(r=s?t.$i:c.length-1),a=c.splice(r,1)[0],u&&u(t,e),n(400).then(function(){var t=e.properties.itemLabel.toLowerCase()||"item";C.showAccessibleAlert(["Repeat",t,r+1,"deleted"].join(" "))}),(e.properties.transferFocusAfterDelete||i)&&function(){var i=r-1,a=e.properties.linkedDeleteButton.split(".").pop(),s=e.properties.linkedAddButton.split(".").pop();n(function(){if(i<0)C.items[s]?o.findElementFromItem(C.items[s],t.$p).find("button").first().focus():o.findElementFromItem(e,t).parent().find(".wdg-add-item-button").first().focus();else{var n=o.findElementFromItem(e,c[r-1]),u=n.find(".id-"+a+" button").first();u.length?u.focus():n.find("input, select, textarea, button").first().focus()}},300)}()),C.validation.errors=C.validation.errors.filter(function(e){return e.data!==a})},this.setInstanceCount=function(e,t,n){"string"==typeof e&&(e=C.items[e.split(".").pop()]);var r=t.length||0,i=0;if((n=+n)>=e.properties.minItems&&n<r)t.splice(n,r-n);else if(n>r)for(i=r;i<n;i++)C.addRepeatInstance(e,t)},this.getRepeatData=function(e,t,n){function r(e){return!!e.repeatingData}for(var i="string"==typeof e?C.items[e.split(".").pop()]:e,a=t,s=o.parents(i,r,!0);s.length;){var u=s.shift().id;Array.isArray(a)?a=o.flatten(a.map(function(e){return e[u]})):a[u]&&(a=a[u])}return Array.isArray(a)&&a.length?(a=a.map(function(e){return e[i.id]}),"function"==typeof n&&(a=a.filter(n)),a):[]},this.isVisible=function(e,n){if(!i.generated)return!0;var r="string"==typeof e?C.items[e]:e,a=r&&t.Rules["sh_"+r.id],o=a?a(n,r):!!r,s=r.$$parent,u=s&&n&&(s.repeatingData?n.$p:n);return!!(o&&s?C.isVisible(s,u):o)},this.showAccessibleAlert=function(e,t,r){var i=$("<div role='alert'><span class='av-a11y-msg'></span></div>"),a=i.find(".av-a11y-msg");i.attr("aria-expanded",t||null),n("number"==typeof r?r:300,!1).then(function(){E.html(i),a.text(e),n(1e3,!1).then(function(){i.attr("aria-hidden",!0)})})},this.focusOnFirstHeading=function(e,t){var r="h1, h2, h3, h4, h5, h6".split(",").join("[tabindex='-1'],")+"[tabindex='-1']",i=$(e||document).find(r);n(50,!1).then(function(){i.length?i[0].focus():"function"==typeof t&&t()})},this.fixReceiptLayout=function(e){n(200,!1).then(function(){e.find(".avoid-page-break").each(function(){$(this).closest(".row").addClass("pagebreak-avoid pagebreak-avoid-user")}),e.find("[data-widget-children] > .row").each(function(e,t){var n,r=$(t),i=r.children(),a=0,o=0;C.view.properties.enableImprovedPageBreaks&&(i.length<2&&r.addClass("pagebreak-block"),0==r.find(".row").length?r.addClass("pagebreak-avoid pagebreak-avoid-auto"):i.length>=2&&r.addClass("pagebreak-sbs")),i.length>1&&i.each(function(e,t){var i=$(t),s=C.getElementItemId(i),u=C.items[s],c=+u.span.lg,l=+u.offset.lg;if(n&&(n>l&&i.addClass("col-lg-offset-"+n),n=!1),(c||l)&&(l&&(n=l),(a+=c+l)>12||12==a&&o>=12)){i.wrap("<div class='row'></div>").parent().insertAfter(r),o=a,a=0}})})})},this.getEntityData=function(e,t){var n,r,i={};return e=e.split(/[\/\_\.]/).join("_"),r=new RegExp(e+"(?![a-zA-Z0-9])"),n=Object.keys(C.items).filter(function(e){var t=C.items[e].entityPath;return t&&t.match(r)}).sort(function(e,t){return e<t?-1:1}),t&&(n=n.filter(function(e){return!C.items[e].noData})),n.forEach(function(t){for(var n,r=t.substr(e.length+1).split("_"),a=i;r.length>1;)n=r.shift(),a=a[n]=a[n]||{};a[r[0]]=C.data[t]}),i},this.handleAutoSaveInterval=function(){var e=1e3*C.view.properties.autoSaveInterval,t=JSON.parse(o.jsonify(C.data,["SFMData"]));this.saveChallengeOnInit||(D=setInterval(function(){var e=JSON.parse(o.jsonify(C.data,["SFMData"]));angular.equals(t,e)||(C.backgroundSave(),t=e)},e))},this.addPreviewDDSData=function(e,t){l.previewData=l.previewData||{},l.previewData[e]={response:"object"===(void 0===t?"undefined":_typeof(t))?t:null,handler:"function"==typeof t?t:null}},this.getImagesByName=function(e){var t=[];return o.sendAll(C.view,function(n){n.properties&&n.properties.imageName==e&&t.push(n)},!1,!0,!1),t},this.updateImageByName=function(e,t){if(!e)throw new Error("imageName must be present");var n=C.getImagesByName(e);if(!n.length)return console.warn("Cannot find any images with name '"+e+"'"),!1;if(!t||0==Object.keys(t).length)throw new Error("newValues must be present and cannot be a blank object");var r=!1;return n.forEach(function(n){n.properties&&n.properties.imageName==e&&(r=!0,(t.imgUrl||""===t.imgUrl)&&(n.properties.imgUrl=t.imgUrl),(t.imgHeight||""===t.imgHeight)&&(n.properties.imgUrlHeight=t.imgHeight),(t.imgWidth||""===t.imgWidth)&&(n.properties.imgUrlWidth=t.imgWidth),(t.alternativeText||""===t.alternativeText)&&(n.properties.alternativeText=t.alternativeText),(t.toolTip||""===t.toolTip)&&(n.properties.toolTip=t.toolTip),(t.imageLink||""===t.imageLink)&&(n.properties.imageLink=t.imageLink))}),r},this.updateCssByName=function(e,t,n){i.preview&&t&&(t.startsWith("./css/")||t.startsWith("css/"))&&(t=i.path(t.replace(/^(\.\/)?css\//,"runtime-styles/")));var r=$("#"+e),a=$("head");if(0==r.length)console.warn("Cannot find named CSS with name: "+e);else if(r.length>1)console.warn("Multiple CSS resources with name: "+e);else if("LINK"==r[0].tagName&&t)r[0].href=t;else if("LINK"==r[0].tagName&&n){var o=document.createElement("style");o.id=e,o.innerHTML=n,a.append(o),r.remove()}else if("STYLE"==r[0].tagName&&t){var s=document.createElement("link");s.id=e,s.type="text/css",s.href=t,s.rel="stylesheet",a.append(s),r.remove()}else"STYLE"==r[0].tagName&&n&&(r[0].innerHTML=n)},this.updateBranding=function(e){var n=[];if("string"==typeof e&&(e=JSON.parse(e)),e&&"object"===(void 0===e?"undefined":_typeof(e))){if(e.css){var r=e.css;Array.isArray(r)||(r=[r]),r.forEach(function(e){e.id?C.updateCssByName(e.id,e.cssUrl,e.cssContent):n.push("updateBranding(): CSS Entry missing CSS resource Name:\n"+o.jsonify(e))})}if(e.images){var a=e.images;Array.isArray(a)||(a=[a]),a.forEach(function(e){e.imageName?C.updateImageByName(e.imageName,e):n.push("updateBranding(): Provided images is missing the imageName:\n"+o.jsonify(e))})}if(e.translation&&C.Translation)if("string"==typeof e.translation)C.Translation.fetch(e.translation,!0);else if(e.translation.code){var s=e.translation.url;i.preview&&s&&(s=s.replace(/^\.\/locales\//,"locales/")),C.Translation.fetch(e.translation.code,!0,s)}e.dataValues&&"object"===_typeof(e.dataValues)&&Object.keys(e.dataValues).forEach(function(t){C.data[t]=e.dataValues[t]})}else n.push("Cannot update branding, parameter is not a JSON object");n.length>0?console.error("Errors with brand options in Form.updateBranding():\n"+n.join("\n")):t.$broadcast("brandUpdate",e)}}])}),function(){function e(){function e(e){return/^\s*$/.test(e)?null:/^(?:true|false)$/i.test(e)?"true"===e.toLowerCase():e}function r(t){var n="",i=0,a="";if(t.hasChildNodes())for(var o,s,u,c=0;c<t.childNodes.length;c++)o=t.childNodes.item(c),4===o.nodeType?a+=o.nodeValue:3===o.nodeType?a+=o.nodeValue.trim():1!==o.nodeType||o.prefix||(0===i&&(n={}),s=o.nodeName,u=r(o),n.hasOwnProperty(s)?(n[s].constructor!==Array&&(n[s]=[n[s]]),n[s].push(u)):(n[s]=u,i++));return a&&(i>0?n.keyValue=e(a):n=e(a)),n}function i(e){function t(e,r){var i,a;if(r.constructor===String||r.constructor===Number||r.constructor===Boolean){if(e.appendChild(n.createTextNode(r.toString())),r===r.valueOf())return}else r.constructor===Date&&e.appendChild(n.createTextNode(r.toGMTString()));for(var o in r)if(!isFinite(o))if(i=r[o],null===i&&(i=""),"keyValue"===o)null!==i&&!0!==i&&e.appendChild(n.createTextNode(i.constructor===Date?i.toGMTString():String(i)));else if("keyAttributes"===o)for(var s in i)e.setAttribute(s,i[s]);else if("@"===o.charAt(0))e.setAttribute(o.slice(1),i);else if(i.constructor===Array)for(var u=0;u<i.length;u++)a=n.createElement(o),t(a,i[u]),e.appendChild(a);else a=n.createElement(o),i instanceof Object?t(a,i):null!==i&&a.appendChild(n.createTextNode(i.toString())),e.appendChild(a)}var n=document.implementation.createDocument("","",null);return t(n,e),n}this.serialize=function(e,t){var r,a=i(e),o=(new n).serializeToString(a),s=0;if(t){o=o.replace(/></g,">~|~<"),o=o.split("~|~"),r=o.map(function(e){return e.match(/^<\//)?-1:e.match(/\/>$/)||e.match(/<\//)?0:1});for(var u=0;u<o.length;u++)1===r[u]&&s++,o[u]=Array(s).join("\t")+o[u],-1===r[u]&&s--;o=o.join("\n")}return o},this.parse=function(e){return"string"==typeof e?(e=e.trim().replace(/(<!--[\s\S]*?-->)/g,"").replace(/<\?xml[\s\S]+\?>/g,"").trim(),e.match(/^</)?(e=(new t).parseFromString(e,"text/xml"),e=e.firstChild,r(e)):null):null}}var t,n;if("undefined"==typeof window){var r=require("xmldom");t=r.DOMParser,n=r.XMLSerializer,module.exports=new e}else define("form/services/JXON",["app"],function(r){t=window.DOMParser,n=window.XMLSerializer,r.ng.service("JXON",e)})}();var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};define("form/services/Transact",["app"],function(e){window.sfc$=window.$,e.ng.service("Transact",["$q","Form","Resource","EncUtil","Http",function(e,t,n,r,i){function a(n,a,u,c,l){var f,d=t.getDataXml();return(o?r.tmEncryptData(d,s):e.when(d)).then(function(t){u&&Object.keys(u).forEach(function(e){null!==u[e]&&void 0!==u[e]||delete u[e]}),a&&Object.keys(a).forEach(function(e){null!==a[e]&&void 0!==a[e]||delete a[e]});var i={type:n,requestKey:s,options:a||{},parameters:u||{}},l=JSON.stringify(i);return f={formData:t},c&&(f.fileAttachment=c),o?r.tmEncryptData(l):e.when(l)}).then(function(e){return f.command=e,i.sendMultipart("POST",t.getSystemData("FormDataServiceURL"),f,l)}).then(function(n){return n&&n.formData?t.updateData(n.formData).then(function(){return e.when(n)}):e.when(n)}).then(function(e){if(e.validationErrors&&e.validationErrors.length){if("function"!=typeof t.serverValidationErrorHandler)throw console.warn("Transact Validation Error(s):"),console.log(e.validationErrors),console.warn("These errors can be handled and suppressed by assigning Form.serverValidationErrorHandler"),alert("Transact function returned validation error(s), see console for details"),new Error("Transact function returned validation error(s), see console for details");t.serverValidationErrorHandler(e.validationErrors)}return e&&void 0!==e.revisionNumber&&t.setSystemData("RevisionNumber",e.revisionNumber),e&&e.redirectUrl?void t.redirect(e.redirectUrl):e})}var o,s,u=this;t.Transact=n.Transact=u,n.generated&&t.load().then(function(){s=t.getSystemData("RequestLogKey"),o=r.isSubmitDataEncryptionNeeded(),t.isFieldWorker()&&($("body").addClass("av-t-field"),window.av_bridge_getFormData=function(e){return e||$(":focus").blur(),t.getDataXml()},window.av_bridge_validateForm=function(){return"0,0"},u.tFieldApi=window.getFieldWorkerComposerAPI())}),this.userSave=function(e,t,n,r){return a("userSave",{sendEmailSavedForm:e,sendEmailShareForm:t,emailAddress:n,milestone:r})},this.userSubmit=function(e,t,n){return a("userSubmit",{sendEmailFormReceipt:e,emailAddress:t,milestone:n})},this.userCancel=function(e){return a("userCancel",{milestone:e})},this.formLoad=function(){return a("formLoad")},this.formStart=function(e){return a("formStart",{milestone:e})},this.formUpdate=function(e,t,n,r,i,o,s,u){return a("formUpdate",{userSaved:e,sendEmailSavedForm:t,emailAdress:n,milestone:r,addAttachmentFile:s,addAttachmentManually:i,removeAttachment:o},null,u)},this.makeAddAttachmentManually=function(e,t,n){return{path:"object"===(void 0===e?"undefined":_typeof(e))&&"path"in e?e.path:e,attachmentKey:t,attachmentName:n}},this.makeAddAttachmentFile=function(e,t,n,r,i,a){return{path:"object"===(void 0===e?"undefined":_typeof(e))&&"path"in e?e.path:path,attachmentKey:t,attachmentName:n,description:r,maxSize:i,fileTypes:a}},this.makeRemoveAttachment=function(e){return{attachmentKey:e}},this.formIneligible=function(e){return a("formIneligible",{milestone:e})},this.formFunction=function(e,t,n,r){return a("formFunction",{serviceName:e,serviceVersion:t,milestone:n},r)},this.formInit=function(){return a("formInit",{},{},null,!0)},this.formError=function(e,t){return a("formError",{stacktrace:e,context:t},{},null,!0)},this.referenceData=function(e,n,r,i,a){var o=n?JSON.stringify(n):null,s={sfmOperationName:"referenceData",name:e,query:o,locale:r||t.view.translation.currentLanguageCode||t.view.translation.defaultLanguageCode};return t.postData(s,i,a)}}])}),define("form/services/DynamicData",["app"],function(e){e.ng.service("DynamicData",["$rootScope","$q","$timeout","Http","Util","Resource",function(e,t,n,r,i,a){var o=this;o.isFieldWorker=!1,o.previewData=null,this.init=function(e,t,n){o.config={url:e,formCode:t,requestKey:n}},this.call=function(s,u,c,l,f,d){var p,m;if(a.preview){if(o.previewData&&o.previewData[s]){var h=o.previewData[s],v=h.handler?h.handler(u):h.response;return t.when(v)}return console.error("Cannot invoke DynamicData.call('"+s+"') in preview without adding preview data, see Form.addPreviewDDSData()"),t.reject("Cannot invoke DynamicData.call('"+s+"') in preview without adding preview data.")}if(u.sfmServiceName=s,u.sfmFormCode=o.config.formCode,u.sfmOperationName="dynamicData",f&&(u.sfmServiceVersion=f),o.config.requestKey&&(u.sfmRequestKey=o.config.requestKey),!i.isReceipt){if(o.config.url){var g=function(){n(100).then(function(){l||e.$broadcast("revalidate")})};return o.isFieldWorker?(m=t.defer(),p=window.getFieldWorkerComposerAPI&&window.getFieldWorkerComposerAPI(),p.ajax(o.config.url,{type:"POST",data:u,success:function(e){if(g(),"string"==typeof e)try{e=JSON.parse(e)}catch(e){}m.resolve(e)},error:function(e){m.reject(e)},timeout:6e4}),m.promise):r.post(o.config.url,u,null,c,d).then(function(e){return g(),e})}throw new Error("Dynamic Data Service Error: No SFM Data Service URL")}console.log("Dynamic Data Service Cannot Be Called On A Receipt")}}])});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};define("form/services/Scroll",["app"],function(e){e.ng.service("Scroll",["$q",function(e){function t(e,t,n,r,i){var a=e.height(),o=r?i.first().height():$(window).height(),s=100/(n<=100?n:100);return a<o?t-(o/s-a/s):t}function n(e,t){return e.offset().top-t.offset().top+t.scrollTop()}function r(e){var t=e.split(".").pop();if(!i.Form.items[t])throw Error("Unable to find item with id: "+t);return t}var i=this;i.Form={},this.scrollTo=function(a,o,s){if(void 0!==a&&("object"!==(void 0===a?"undefined":_typeof(a))||0!==a.length)){var u="number"!=typeof a&&$("string"==typeof a?".id-"+r(a):a),c=!!i.Form.dialogName,l=c?$(".av-dialog > .row"):$("html, body"),f="number"==typeof a?a:c?n(u,l):u.offset().top,d=!0===o&&u,p=e.defer();return!0===s&&(s=50),s&&!isNaN(s)&&(f=t(u,f,+s,c,l)),l.animate({scrollTop:f},500,function(){if(d){var e=u.find("input, textarea, select");e.length?e[0].focus():u[0].focus()}p.resolve()}),p.promise}}}])});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(){function e(e){var t=this;t.isReceipt=!!("undefined"!=typeof navigator&&navigator&&navigator.userAgent&&navigator.userAgent.match(/phantom/i)),this.VIEW_JSON_EXCLUSIONS=["data","propDefs","ruleTemplates","ruleHelpers","validChildren","validParents","html"],this.logError=function(e){console.error(e)},this.setVal=function(e,t,n){return void 0!==t&&t!==e?("function"==typeof n&&n(),t):e},this.range=function(e,t){var n,r=[];for(n=e;n<=t;n++)r.push(n);return r},this.getDataUrl=function(n,r,i,a,o){function s(e,n,r,i,a){var o=new Image;o.onload=function(){var e=n||this.width/this.height*r,o=r||this.height/this.width*n;t.resizeImage(this,e,o,i,null,a).then(function(e){u.resolve(e.src)})},o.src=e}var u=e.defer();return"object"===(void 0===n?"undefined":_typeof(n))&&n instanceof File?function(e){var t=new FileReader;t.onload=function(t){var n=t.target.result;r||i||a?s(n,parseInt(r),parseInt(i),a,e.type):u.resolve(n)},t.readAsDataURL(e)}(n):function(e,n){var o,c=new XMLHttpRequest;n=n||e.match(/\.([^.]*)$/)[1],o=t.getMimeType(n)||"image/"+n,c.overrideMimeType("text/plain; charset=x-user-defined"),c.open("GET",e,!0),c.send(null),c.onload=function(e){var t,l=c.responseText,f=l.length,d="";for(t=0;t<f;t+=1)d+=String.fromCharCode(255&l.charCodeAt(t));var p="data:"+o+";base64,"+window.btoa(d);(r||i||a)&&"svg"!==n&&"gif"!==n?s(p,parseInt(r),parseInt(i),a,o):u.resolve(p)},c.onerror=function(){u.reject("Cannot read data from URL: "+e)}}(n,o),u.promise},this.base64ToFile=function(e,t,n){n=n||""
;for(var r=atob(e),i=r.length,a=Math.ceil(i/1024),o=new Array(a),s=0;s<a;++s){for(var u=1024*s,c=Math.min(u+1024,i),l=new Array(c-u),f=u,d=0;f<c;++d,++f)l[d]=r[f].charCodeAt(0);o[s]=new Uint8Array(l)}return new File(o,t,{type:n})},this.binPathToFile=function(e,n){return t.getDataUrl(e,null,null,null,n).then(function(n){var r=n.slice(n.search(",")+1),i=e.split("/").pop();return t.base64ToFile(r,i,t.getMimeType(i))})},this.resizeImage=function(t,n,r,i,a,o){function s(){if(d=0|Math.max(d/2,n),p=0|Math.max(p/2,r),c.width=d,c.height=p,l.drawImage(h||t,0,0,d,p),m.src=c.toDataURL(f,a),d<=n||p<=r)return u.resolve(m);h||(h=new Image,h.onload=s),h.src=m.src}a=a||1;var u=e.defer(),c=document.createElement("canvas"),l=c.getContext("2d");l.imageSmoothingEnabled=!0,l.mozImageSmoothingEnabled=!0,l.oImageSmoothingEnabled=!0;var f=o||"image/png",d=t.naturalWidth,p=t.naturalHeight;i&&(p<d&&p>i?(n=Math.round(d/p*i),r=i):p>=d&&d>i?(r=Math.round(p/d*i),n=i):n||r||u.resolve(t));var m=new Image,h=null;return d<=n||p<=r||d/2<n||p/2<r?(c.width=n,c.height=r,l.drawImage(t,0,0,n,r),m.src=c.toDataURL(f,a),u.resolve(m)):s(),u.promise},this.logout=function(){console.error("Util.logout() is deprecated and no longer functions as intended"),window.open("../logout","_self")},this.selectFile=function(t){var n=t||"",r=e.defer();return fileInput=$("<input/>").appendTo("body").attr({type:"file",accept:n}).css({display:"none"}),fileInput.click(),fileInput.on("change",function(e){fileInput.remove();var t=e.target.files[0];r.resolve(t)}),r.promise},this.slot=function(e,t,n,r){var i;if(r)for(i=e.length;e[i]&&new String(e[i][n]).localeCompare(new String(t[n]))>=0;)i--;else for(i=0;e[i]&&new String(e[i][n]).localeCompare(new String(t[n]))<=0;)i++;e.splice(i,0,t)},this.removeItem=function(e,n){var r;for(t.assert(Array.isArray,"Array missing from call to removeItem");(r=e.indexOf(n))>=0;)e.splice(r,1);return e},this.sortBy=function(e,t){return function(n,r){return null!==n[e]&&void 0!==n[e]||!r[e]?null!==r[e]&&void 0!==r[e]||!n[e]?t?n[e].toLowerCase()<r[e].toLowerCase()?-1:n[e].toLowerCase()>r[e].toLowerCase()?1:0:n[e]<r[e]?-1:n[e]>r[e]?1:0:1:-1}},this.unique=function(e,t){var n={},r=[];for(var i in e)t&&void 0===n[e[i][t]]?r.push(e[i]):t||void 0!==n[e[i]]||r.push(e[i]),t?n[e[i][t]]=0:n[e[i]]=0;return r},this.lastItem=function(e){return t.assert(Array.isArray(e),"Array missing from call to lastItem"),0===e.length?null:e.slice(-1)[0]},this.getVal=function(e){return function(t){return t[e]}},this.contains=function(e,t){return(e||[]).indexOf(t)>=0},this.find=function(e,t,n,r){if(!e)return null;var i=e.filter(function(e){return e[t]===n});return r?i:i.length?i[0]:null},this.replace=function(e,t,n){e.splice(e.indexOf(t),1,n)},this.flatten=function(e){return e.reduce(function(e,n){return e.concat(Array.isArray(n)?t.flatten(n):n)},[])},this.append=function(e,t){if(!Array.isArray(e)||!Array.isArray(t))return e;t.forEach(function(t){e.push(t)})},this.values=function(e,t){return Object.keys(e||{}).map(function(n){return"function"==typeof t?t(n,e[n]):e[n]})},this.objectsToMap=function(e,t,n){var r={};return e.forEach(function(e){var i="function"==typeof t?t(e):e[t];value="function"==typeof n?n(e):"string"==typeof n?e[n]:e,r[i]=value}),r},this.objectPaths=function(e,n,r){return Object.keys(e||{}).reduce(function(i,a){var o=e[a],s=(r||"")+a,u=Array.isArray(o)||"object"!==(void 0===o?"undefined":_typeof(o))?n?[n(s,o)]:[s]:t.objectPaths(o,n,s+".");return i.concat(u)},[])},this.keys=function(e){var t,n=[];for(t in e)n.push(t);return n},this.getMimeType=function(e){return e=e.split(".").pop(),{png:"image/png",jpg:"image/jpeg",svg:"image/svg+xml",json:"application/json",less:"text/css",js:"application/javascript",csv:"text/csv",css:"text/css"}[e]},this.assert=function(e,t){e||this.logError("Assertion error: "+t+"\n"+(new Error).stack)},this.requireThen=function(t){var n=e.defer();return require(t,function(){n.resolve(arguments)}),n.promise},this.jsonify=function(e,n,r,i,a){function o(e,t,n){return n.every(function(n){return e[n]&&e[n]===t[n]})}function s(e){if("object"===(void 0===e?"undefined":_typeof(e))){var t={};return Object.keys(e).sort().forEach(function(n){t[n]=e[n]}),t}return e}return n=n||t.VIEW_JSON_EXCLUSIONS,"string"==typeof n&&(n=n.split(" ")),JSON.stringify(e,function(e,t){if("function"==typeof i&&(t=i(e,t)),null===t&&(t=void 0),e=""+e,!e.match(/^\$/)){if(!(n.indexOf(e)>=0)){if(Array.isArray(t)){if(+e!=e&&"rows"!==e&&t.$arrayProto&&t.length===t.$arrayProto.length&&t.every(function(e,n){var r=t.$arrayProto[n];return"object"!==(void 0===e?"undefined":_typeof(e))&&e===r||o(e,r,["label","value"])||o(e,r,["key","ref"])}))return;return t}return"object"===(void 0===t?"undefined":_typeof(t))&&0===Object.keys(t).length&&Object.getPrototypeOf(Object.getPrototypeOf(t))?void 0:a?s(t):t}if("string"!=typeof n[e])return"function"==typeof n[e]?n[e](t):void 0}},!r&&"\t")},this.equals=function(e,n){return t.jsonify(e,[])===t.jsonify(n,[])},this.copy=function(e){return JSON.parse(t.jsonify(e,[])||"{}")},this.sendAll=function(e,n,r,i,a){if(e&&(!a||!e.exclude)&&(r||!1!==n(e))){if(e&&e.rows)for(var o=0;o<e.rows.length;o++)for(var s=e.rows[o],u=0;u<s.length;u++)t.sendAll(e.rows[o][u],n,!1,!1,a);i&&t.values(t.extend({},e.dialogs,e.modals)).forEach(function(e){t.sendAll(e,n,!1,!1,a)})}},this.children=function(e){return Array.isArray(e)||(e=[e]),e.reduce(function(e,n){return e.concat(t.flatten(n.rows||[]))},[])},this.hasDescendants=function(e){return!!(Array.isArray(e.rows)&&e.rows.length&&e.rows[0].length)},this.descendants=function(e,n){var r,i=[];if(e&&e.rows)for(var a=0;a<e.rows.length;a++)for(var o=e.rows[a],s=0;s<o.length;s++)r=e.rows[a][s],n&&!n(r)||(i.push(r),i=i.concat(t.descendants(r,n,!0)));return i},this.getItemMap=function(e){var n={};return t.sendAll(e,function(e){n[e.id]=e},!1,!0),n},this.xray=function(e,n,r){var i,a,o={};for(var s in e)i=e[s],"function"==typeof n&&(a=n(s,i),"object"===(void 0===a?"undefined":_typeof(a))&&"string"==typeof a.key&&a.hasOwnProperty("value")?(s=a.key,i=a.value):i=a),("function"!=typeof r||r(s,i))&&(i&&"object"===(void 0===i?"undefined":_typeof(i))?o[s]=t.xray(i,n,r):o[s]=i);return Array.isArray(e)&&(o=t.values(o)),o},this.parents=function(e,t,n){for(var r=[],i=e.$$parent;i;)t&&!t(i)||(n?r.unshift(i):r.push(i)),i=i.$$parent;return r},this.locate=function(e){if(!e)return null;var t=0,n=null;return e.$$parent&&e.$$parent.rows.some(function(r){var i=r.indexOf(e);if(i>-1)return n={row:t,col:i},!0;t++}),n},this.nextItem=function(e){function n(e){for(;e.rows&&e.rows[0]&&e.rows[0][0];)e=e.rows[0][0];return e}var r,i;if(!e)return null;if(r=t.locate(e),(i=n(e))!==e)return i;for(;e&&e.$$parent&&"nav-content"!==e.$$parent.type&&!(i=e.$$parent.rows[r.row][r.col+1]||e.$$parent.rows[r.row+1]&&e.$$parent.rows[r.row+1][0]);)e=e.$$parent,r=t.locate(e);return i?n(i):null},this.sortItems=function(e,n){var r=[];return t.sendAll(n,function(n){t.contains(e,n)&&(t.removeItem(e,n),r.push(n))},!1,!0),r},this.populate=function(e,n){var r;n&&(r=n[0])&&("string"==typeof r&&(r=JSON.parse(r)),t.assert("object"===(void 0===r?"undefined":_typeof(r)),"Invalid data"),t.assert("object"===(void 0===e?"undefined":_typeof(e)),"Invalid object"),t.extend(e,r))},this.castArray=function(e,t){return e.map(function(e){return new t(e)})},this.testKeys=function(e){return Object.keys(e).filter(function(t){return e[t]})},this.extend=function(){var e=Array.prototype.slice.call(arguments),t=e.shift();return e.forEach(function(e){e&&Object.keys(e).forEach(function(n){t[n]=e[n]})}),t},this.merge=function(e,n,r,i){return r&&Object.keys(n).forEach(function(t){e.hasOwnProperty(t)||delete n[t]}),null===n||void 0===n?null:(Object.keys(e).forEach(function(a){var o=Array.isArray(e[a]);n.hasOwnProperty(a)||(!e[a]||"object"!==_typeof(e[a])||o?n[a]=e[a]:n[a]={}),"function"==typeof i&&i(e,n,a),e[a]&&"object"===_typeof(e[a])&&!o&&n[a]&&"object"===_typeof(n[a])&&t.merge(e[a],n[a],r,i)}),n)},this.hyperExtend=function(e,n){var r,i,a={},o=/^(\$|id$)/,s=o.test.bind(o);return t.assert(e&&"object"===(void 0===e?"undefined":_typeof(e)),"Base for hyper-extension must be a defined object or array"),t.assert(!n||(void 0===n?"undefined":_typeof(n))===(void 0===e?"undefined":_typeof(e)),"Values provided for hyper-extension must match base type"),Array.isArray(e)?(r=e.concat(),r.$arrayProto=e,i=t.range(0,e.length-1),n&&n.length>e.length&&(i=t.range(0,n.length-1))):(r=Object.create(e),i=t.keys(e).filter(function(e){return!s(e)}),n&&t.keys(n).forEach(function(e){-1===i.indexOf(e)&&(s(e)?a[e]=n[e]:i.push(e))})),i.forEach(function(i){"object"===_typeof(e[i])?Array.isArray(e[i])&&"rows"!==i&&!Array.isArray(e)?(r[i]=t.copy(n&&n[i]||e[i]),r[i].$arrayProto=e[i]):r[i]=t.hyperExtend(e[i],n&&n[i]):n&&null!=n[i]&&n[i]!==e[i]&&(r[i]=n[i])}),t.extend(r,a)},this.logItem=function(e,n,r){function i(e){return Array(e).join(" ")}function a(e){return e.id}var o;return n=n||a,o=n(e)+"\n",r=r||0,e.rows&&e.rows.forEach(function(e){0===e.length&&(o+=i(r)+"-\n"),e.forEach(function(a,s){o+=i(r+1),1===e.length?o+="─":0===s?o+="┌":s===e.length-1?o+="└":o+="│",o+=" "+t.logItem(a,n,r+1)})}),o},this.getUrlQueryParams=function(){var e={};return window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(t,n,r){e[n]=r}),e},this.getGeoLocation=function(){var t=e.defer();return navigator&&"geolocation"in navigator?navigator.geolocation.getCurrentPosition(function(e){t.resolve(e.coords)}):t.reject("GeoLocation is not available"),t.promise},this.getUrlQueryParam=function(e){return t.getUrlQueryParams()[e]||null},this.throttle=function(e,t,n){var r,i,a,o,s=0;n||(n={});var u=function(){s=!1===n.leading?0:+new Date,r=null,o=e.apply(i,a),r||(i=a=null)},c=function(){var c=+new Date;s||!1!==n.leading||(s=c);var l=t-(c-s);return i=this,a=arguments,l<=0||l>t?(r&&(clearTimeout(r),r=null),s=c,o=e.apply(i,a),r||(i=a=null)):r||!1===n.trailing||(r=setTimeout(u,l)),o};return c.cancel=function(){clearTimeout(r),s=0,r=i=a=null},c},this.isBlank=function(e){return null==e||""===e},this.openURL=function(e){(e=window.open(e,"_blank"))?e.focus():alert("Unable to open new window")},this.startsWith=function(e,t,n){return!!e&&(n=n||0,e.substr(n,t.length)===t)},this.endsWith=function(e,t,n){if(!e)return!1;var r=e.toString();("number"!=typeof n||!isFinite(n)||Math.floor(n)!==n||n>r.length)&&(n=r.length),n-=t.length;var i=r.indexOf(t,n);return-1!==i&&i===n},this.toCamelCase=function(e){return e.trim().replace(/ +/g," ").replace(/[^\w ]/g,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,function(e,t){return t.toUpperCase()})},this.addRepeatContent=function(e,t){if(Array.isArray(t)||(t=[t]),!e.repeatingData)throw new Error("Parameter repeatItem must be a repeat");var n,r=e.getData();t.forEach(function(t,i){n=r[i]||e.$addItem(),Object.keys(t).forEach(function(e){n.hasOwnProperty(e)&&(n[e]=t[e])})})},this.getRepeatDataArray=function(e,n){var r=t.findParentRepeat(e),i=[];return r&&"function"==typeof r.$getRepeatData&&(i=r.$getRepeatData().map(function(t){return t[e.id]}),"function"==typeof n&&(i=i.filter(n))),i},this.findParentRepeat=function(e){for(var t=e.$$parent,n=!0===e.isRepeatingContent;!n&&t;)t.repeatingData?(n=!0,e=t):t=t.$$parent;return!!n&&e},this.findFirstParent=function(e){for(;e.$$parent;)e.$$parent&&(e=e.$$parent);return e||!1},this.findElementFromItem=function(e,n){var r,i="repeat"===e.type;if(n&&!t.isBlank(n.$i)){var a=function(e,t){var n=e,r=t,a=[];for(i&&(a.push({id:e.id,data:t}),r=t.$p);n=n.$$parent;)"repeat"===n.type&&(a.unshift({id:n.id,data:r}),r=r.$p);return a}(e,n);if(!(0===a.length)){for(var o=a.shift(),s=t.isBlank(o.data.$i)?n.$i:o.data.$i,u=$(".id-"+o.id).find(" > .av-repeat > .wdg-repeated-item")[s];a.length;){var c,l=a.shift(),f=l.id,d=l.data;u=$(u).find(".id-"+f)[0],c=$(u).find(" > .av-repeat > .wdg-repeated-item")[d.$i],c&&(u=c)}r=i?$(u):$(u).find(".id-"+e.id)}}return r||(r=$(".id-"+e.id)),r||null},this.findFirstVisibleField=function(e,n){var r=t.findElementFromItem(e,n);return $(r).find("div[class*=id-]:visible").first().find("input, select, button, textarea, div[tabindex=0]").get(0)},this.escapeXml=function(e){return e.replace(/[<>&'"]/g,function(e){switch(e){case"<":return"&lt;";case">":return"&gt;";case"&":return"&amp;";case"'":return"&apos;";case'"':return"&quot;"}})},this.sanitizer=function(e){if(!(e=e||$))throw new Error("Attempt to use Util.sanitizer without a jQuery context");return function(t){var n=function(e){return e.attributes||Object.keys(e.attribs).map(function(t){return{name:t,value:e.attribs[t],specified:!0}})},r=e("<div/>").html(t);return r.find("script").remove(),r.children().each(function(){var t=e(this),r=!0,i=!1,a=void 0;try{for(var o,s=n(this)[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var u=o.value;u.specified&&0===u.name.indexOf("on")&&t.removeAttr(u.name)}}catch(e){i=!0,a=e}finally{try{!r&&s.return&&s.return()}finally{if(i)throw a}}}),r.html()}},this.decodeHtmlEntities=function(e){var t,n=document.createElement("textarea");return n.innerHTML=e,t=n.value,$(n).remove(),t},this.isLeapYear=function(e){return"number"!=typeof e&&(e=parseInt(e)),!(3&e||!(e%25)&&15&e)},this.sum=function(e){return angular.isArray(e)||(e=[e]),e.length&&e.reduce(function(e,t){return+e+ +t},0)},this.capitalizeFirstLetter=function(e){return e?(e=""+e,e.charAt(0).toUpperCase()+e.slice(1)):""},this.uuid=function(e,t){for(t=e="";e++<36;t+=51*e&52?(15^e?8^Math.random()*(20^e?16:4):4).toString(16):"");return t},this.openWithPopupBlockerCheck=function(e,t){var n;window.navigator.standalone?window.open(e,"_self"):(n=window.open(e,t),setTimeout(function(){n&&0!==n.outerHeight||Prompt.alert("WARNING: You might have popups blocked for this domain.")},2e3))},this.replaceIfNotPrecededBy=function(e,t){return function(n){return n.slice(0,e.length)===e?n:t}},this.utf8ToBinaryString=function(e){return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode(parseInt(t,16))})},this.utf8ToBuffer=function(e){var n=t.utf8ToBinaryString(e);return t.binaryStringToBuffer(n)},this.utf8ToBase64=function(e){var n=t.utf8ToBinaryString(e);return btoa(n)},this.binaryStringToUtf8=function(e){var t=e.replace(/(.)/g,function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n});return decodeURIComponent(t)},this.bufferToUtf8=function(e){var n=t.bufferToBinaryString(e);return t.binaryStringToUtf8(n)},this.base64ToUtf8=function(e){var n=atob(e);return t.binaryStringToUtf8(n)},this.bufferToBinaryString=function(e){return Array.prototype.map.call(e,function(e){return String.fromCharCode(e)}).join("")},this.bufferToBase64=function(e){var n=t.bufferToBinaryString(e);return btoa(n)},this.binaryStringToBuffer=function(e){var t;return t="undefined"!=typeof Uint8Array?new Uint8Array(e.length):[],Array.prototype.forEach.call(e,function(e,n){t[n]=e.charCodeAt(0)}),t},this.base64ToBuffer=function(e){var n=atob(e);return t.binaryStringToBuffer(n)},this.versionSort=function(e,t){function n(e){var t=e.releaseVersion||e.versionNumber||e;return"string"!=typeof t?null:t.split(".").map(function(e){var t=parseInt(e);return isNaN(t)?0:t})}var r=n(e),i=n(t);if(r&&i){if(1===r.length&&i[0]>=r[0])return-1;for(var a=0;a<=2;a++)if(r.length===a&&r.push(0),i.length===a&&i.push(0),r[a]!==i[a])return r[a]<i[a]?-1:1;return e.name?e.name<t.name?-1:1:e.createdAt?e.createdAt<t.createdAt?-1:1:0}},this.generateNewVersionNumber=function(e,t){var n=t.split(".");n[0]=n[0].split("-")[0],n[1]=n[1]?n[1].split("-")[0]:"0",n[2]=n[2]?n[2].split("-")[0]:"0";var r=e.filter(function(e){if(n[2]&&e.versionNumber.split(".")[2])return n[0]===e.versionNumber.split(".")[0]&&n[1]===e.versionNumber.split(".")[1]});if(r.length>=1)return n=r[0].versionNumber.split("."),n[2]=parseInt(n[2])+1,n.join(".");var i=e.filter(function(e){if(n[1]&&e.versionNumber.split(".")[1])return n[0]===e.versionNumber.split(".")[0]});if(i.length>=1)return n=i[0].versionNumber.split("."),n[1]=n[1].split("-")[0],n[2]="1",n.join(".");var a=e.filter(function(e){return n[0]===e.versionNumber.split(".")[0]});return a.length>=1?(n=a[0].versionNumber.split("."),n[1]="0",n[2]="1",n.join(".")):parseInt(n[0]).toString()+".0.1"},this.truncateVersionNumber=function(e){return e&&e.length>20?e.substring(0,20):e},this.validateVersionNumber=function(e,t){return this.isValidateSemanticVersion(e)?null:t?"Please enter a valid version number, e.g. 1.0.0 or 1.0.0-release":"Please enter a valid version number, e.g. 1.0-develop or 1.0.0"},this.validateLibraryVersionNumber=function(e){return this.isValidateSemanticVersion(e)?null:"Please enter a valid Library version number, e.g. 1.0.0"},this.isValidateSemanticVersion=function(e){return/^(\d{1,3}$)|^(\d{1,3}\-{1}[A-Za-z0-9-_#]{1,}$)|^(\d{1,3}(\.\d{1,2}){1,2}$)|^(\d{1,3}(\.\d{1,2}){1,2}\-{1}[A-Za-z0-9-_#]{1,}$)/.test(e)},this.majorMinor=function(e,t){return void 0===t&&(t="."),e.split(".").slice(0,2).join(t)},this.autoFillVersionNumber=function(e){return e&&e.length<3&&Number.isInteger(parseInt(e))?parseInt(e)+".0.0":e},this.getBlockCode=function(e){return e.toLowerCase().replace(/ /g,"-").replace(/[^\w-]/g,"")},this.getFileName=function(e){var n=e.match(/(.*)\.(\w*)$/);return e=n?t.getBlockCode(n[1])+"."+n[2]:t.getBlockCode(e)},this.semanticVersionSort=function(e){function t(e){e.sort(function(e,t){return r(e,t,1)});var t=n(e,1),i=[];return t.forEach(function(e){e.sort(function(e,t){return r(e,t,2)}),i.push(e)}),i=[].concat.apply([],i.reverse())}function n(e,t){var n={};e.forEach(function(e){var r=parseInt(e.versionNumber.split(".")[t]);n.hasOwnProperty(r)?n[r].push(e):n[r]=[e]});var r=[];for(key in n)r.push(n[key]);return r}function r(e,t,n){var r=function(e){return e.replace(/^0*([0-9]+)/,"$1")},i=e.versionNumber.split(".").map(r),a=t.versionNumber.split(".").map(r),o=i[n]?"1"+i[n]:"0",s=a[n]?"1"+a[n]:"0";if(o&&s){var u=o.split("-").length>1,c=s.split("-").length>1;if(u&&c){if(o.split("-")[0]!==s.split("-")[0])return parseInt(s)-parseInt(o);var l=o.split("-")[1],f=s.split("-")[1];return l.localeCompare(f)}if(parseInt(o)===parseInt(s)){if(u)return-1;if(c)return 1}return parseInt(s)-parseInt(o)}return o?1:-1}e.sort(function(e,t){e.versionNumber,t.versionNumber});var i=n(e,0),a=[];i.forEach(function(e){var n=t(e);a.push(n)});var a=[].concat.apply([],a.reverse());return a},this.downloadFile=function(e,t){if(window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(e,t);else{var n=URL.createObjectURL(e),r=$("<a class='av-hidden'/>").attr({href:n,download:t}).appendTo("body");r[0].click(),r.remove(),setTimeout(function(){URL.revokeObjectURL(n)},2e3)}},this.generateNormalizedString=function(e){return e&&e.toLowerCase().replace(/(\s|_)/g,"-").replace(/&/g,"and").replace(/[^-0-9a-zA-Z]/g,"").replace(/[-]+/g,"-")},this.isValidName=function(e){return!/^[\/\\.]|[<>]|\.\./g.test(e)},this.localeSensitiveComparator=function(e,t){if("string"!==e.type||"string"!==t.type)return e.index<t.index?-1:1;var n=parseFloat(e.value),r=parseFloat(t.value);return isNaN(n)||isNaN(r)?e.value.localeCompare(t.value):n<r?-1:1}}"undefined"==typeof window?module.exports=new e:define("form/services/Util",["app"],function(t){t.ng.service("Util",["$q",e]),window.$find=function(e,t){return angular.element(e[0].querySelector(t))}})}(),function(){function e(e,t){function n(e,t,n){r.isMsCrypto?(e.onerror=n,e.oncomplete=function(e){var n=e.target.result;t(n)}):r.isWebCrypto&&e.then(function(e){t(e)}).catch(n)}var r=this;r.isWebCrypto=window.crypto&&(window.crypto.subtle||window.crypto.webkitSubtle),r.isMsCrypto=window.msCrypto&&window.msCrypto.subtle,r.cryptoSubtle=r.isWebCrypto||r.isMsCrypto,r.encryptSubmitData=!1,r.encryptRequestKey="",r.failMsg="Browser does not support data encryption"+(window.top!=window.self?" or is contained in an insecure context":"")+"!",this.isEncryptionSupported=function(){return!!r.cryptoSubtle},this.isDataEncrypted=function(e){return null!=e&&""!=e&&-1==e.indexOf("<")&&-1==e.indexOf("%")},this.isSubmitDataEncryptionNeeded=function(){return r.encryptSubmitData},this.tmEncryptData=function(i,a){var o=(window.crypto||window.msCrypto,e.defer());a||(a=r.encryptRequestKey);try{if(!r.cryptoSubtle)throw new Error(r.failMsg);n(r.cryptoSubtle.generateKey({name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),function(e){n(r.cryptoSubtle.exportKey("raw",e),function(s){var u=t.utf8ToBuffer(i),c=pako.deflate(u),l=t.utf8ToBuffer(a.substring(16));n(r.cryptoSubtle.encrypt({name:"AES-CBC",iv:l},e,c),function(e){var n=t.utf8ToBuffer(a),r=new Uint8Array(n.byteLength+s.byteLength+e.byteLength);r.set(new Uint8Array(n),0),r.set(new Uint8Array(s),n.byteLength),r.set(new Uint8Array(e),n.byteLength+s.byteLength);var i=t.bufferToBase64(r);o.resolve(i)},o.reject)},o.reject)},o.reject)}catch(e){o.reject(e)}return o.promise},this.tmDecryptData=function(i){var a=(window.crypto||window.msCrypto,e.defer());try{if(!r.cryptoSubtle)throw new Error(r.failMsg);var o=t.base64ToBuffer(i),s=o.subarray(0,32),u=o.subarray(16,32),c=o.subarray(32,48),l=o.subarray(48);n(r.cryptoSubtle.importKey("raw",c,{name:"AES-CBC"},!1,["decrypt"]),function(e){n(r.cryptoSubtle.decrypt({name:"AES-CBC",iv:u},e,l),function(e){var n=new Uint8Array(e),i=pako.inflate(n),o=t.bufferToUtf8(i);r.encryptRequestKey=t.bufferToUtf8(s),a.resolve(o)},a.reject)},a.reject)}catch(e){a.reject(e)}return a.promise},this.getRequestKeyFromEncryptedData=function(e){try{if(e){var n=t.base64ToBuffer(e),r=n.subarray(0,32);return t.bufferToUtf8(r)}}catch(e){return null}return null}}"undefined"==typeof window?module.exports=new e:define("form/services/EncUtil",["app"],function(t){t.ng.service("EncUtil",["$q","Util",e])})}();var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};define("form/services/Http",["app"],function(e){e.ng.service("Http",["$q","$http",function(e,t){function n(e,n,r,i,a){return t[e.toLowerCase()](n,r,i).then(function(e){return e.data}).catch(o(e,n,a))}function r(e,n,r,i,s){return t[e.toLowerCase()](n,($.param||a)(r),i).then(function(e){return e.data}).catch(function(t){return o(e,n,s)(t),t&&t.data})}function i(e,t,i,a,o,s){e=e.toUpperCase(),a=a||"form";var u={};return o&&(u.timeout=o),"form"==a?(u.headers={"Content-Type":"application/x-www-form-urlencoded"},r(e,t,i,u,s)):"query"==a?(u.params=i,n(e,t,null,u,s)):"body"==a?n(e,t,i,u,s):void 0}function a(e){var t=[];for(var n in e)t.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t.join("&")}function o(e,t,n){return function(r){var i,a=r.data,o=r.status,s="HTTP "+e.toUpperCase()+" "+t,u=["services/formversions/\\d*$"],c=a&&(a.error||a.message||a.errorMessage||a.instructions||a);if("Form Revision Number Error"===c&&(c="A form with this reference code has been updated from another browser.\nPlease reload the form to continue"),!t.match(new RegExp(u.join("|")))||!e.match(/^get$/i))if(r.config&&"object"===_typeof(r.config.timeout));else if(401===o);else{if(9999===o)throw new Error("Authentication error. Please log in again using the new tab, then retry");if("string"!=typeof c||!c.match(/^<html>/))throw n?new Error("string"==typeof c&&c||r.statusText||r):(alert(s+"\n"+(c||"HTTP error: No error information provided")),a&&(a.errorWasDisplayed=!0),new Error(c));confirm(s+"\nTransact Manager has delivered a HTML-formatted error.\nClick OK to view content in a new tab, or Cancel to ignore.")&&(i=window.open("","_blank","menubar=0,toolbar=0,status=0,scrollbars=0,resizable=1"),i.document.writeln(c),i.document.close())}}}this.get=function(e,t){return n("GET",e,null,null,t)},this.delete=function(e,t){return n("DELETE",e,null,null,t)},this.post=function(e,t,n,r,a){return i("POST",e,t,n,r,a)},this.put=function(e,t,n){return i("PUT",e,t,n)},this.sendMultipart=function(e,n,r,i){var a,s=new FormData;return Object.keys(r).forEach(function(e){s.append(e,r[e])}),a=t({method:e.toUpperCase(),headers:{"Content-Type":void 0},data:s,transformRequest:function(e){return e},url:n}),a.then(function(e){return e.data}).catch(o(e,n,i))}}])});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};define("form/services/Automation",["app"],function(e){e.ng.service("Automation",["$rootScope","$timeout","Form","Calc","Resource","Util","DynamicData","Scroll","Insights","Translation","Validation","Rules","Transact",function(e,t,n,r,i,a,o,s,u,c,l,f,d){window.maestro=a.extend(window.maestro||{},{$rootScope:e,$timeout:t,Form:n,Calc:r,Resource:i,Util:a,DynamicData:o,Scroll:s,Insights:u,Translation:c,Validation:l,Rules:f,Transact:d,T:c.T,mountApiToWindow:function(){Object.keys(window.maestro).forEach(function(e){var t=window.maestro[e];void 0===window[e]&&(e.match(/^\$/)||"object"===(void 0===t?"undefined":_typeof(t))&&!Array.isArray(t))&&(window[e]=t)})}}),window.maestro.shouldMountApiToWindow&&window.maestro.mountApiToWindow(),i.generated&&n.load().then(function(){var e=n.getSystemData();window.maestro.SystemProfile=e,window.maestro.Job=e&&e.Job})}])}),function(){function e(e,t,n,r,i,a){function o(e){window&&window.localStorage&&window.localStorage.setItem("selectedLanguage",e)}function s(){return window&&window.localStorage?window.localStorage.getItem("selectedLanguage"):""}function u(){f&&a.cancel(f),f=null,t.showProgress("")}var c=this,l=0,f=null;c.T={},t.Translation=this,t&&t.load().then(function(){var e=t.view.translation&&t.view.translation.defaultLanguageCode||"en";if(c.rtl=!1,!n.design)if(t.view.translation.languages.length<2)c.set(t.view.translation.languages[0].dict),c.rtl=t.view.translation.languages[0].rtl;else{var r=t.getSystemData("SelectedLanguage"),i=!!r&&t.view.translation.languages.some(function(e){return e.code==r}),a=s(),o=!!a&&t.view.translation.languages.some(function(e){return e.code==a}),u=t.getSystemData("SelectedLanguageUrl"),l=i?r:o?a:e;c.fetch(l,!0,u)}}),this.fetch=function(e,r,s){var d;if(t.view.translation.languages.forEach(function(t){t.code==e&&(d=t)}),!d)return i.reject("Cannot find language code '"+e+"' in form");!f&&l>0&&(f=a(function(){t.showProgress("Please wait")},500));var p="locales/locale-"+e+".csv",m=s&&"string"==typeof s&&""!==s?s:p;return thisFetchTime=l=(new Date).getTime(),n.get(m).then(function(i){var a=Papa.parse(i);if(a.errors.length>0){console.error("Could not parse translation data from "+m);var s=a.errors.reduce(function(e,t){return e+=t.message+"\n"},"");throw new Error(s)}var u=c.csvToDict(a.data,1);l===thisFetchTime&&(t.view.translation.currentLanguageCode=e,c.setLayoutDir(d.rtl),c.set(u)),t.setSystemData("SelectedLanguage",e),t.setSystemData("SelectedLanguageUrl",m!=p?m:null),r||n.preview||o(e)}).catch(function(t){console.error("Could not fetch dictionary resource for language: "+e+"\n"+t),u()})},this.set=function(r){e.T=function(e,t){return Object.keys(e).forEach(function(t){delete e[t]}),$.extend(e,t),e}(c.T,r),n.design||(document.title=c.T[t.view.id].label),e.$broadcast("translate")},this.setLayoutDir=function(t){var n=!t||"string"==typeof t&&"ltr"===t.toLowerCase(),r=$("html"),i=r.css("direction"),a=n?"ltr":"rtl";if(c.rtl=!n,a!==i){var o=n?"app-styles":"rtl-app-styles",s=n?"rtl-app-styles":"app-styles",l=$("#"+o),f=$("#"+s);if("LINK"!==f.prop("tagName"))r.css("direction",a),l.attr("type",null),f.attr("type","text"),e.$broadcast("layoutDirChange",a),u();else{var d=n?"css/form-app-styles.css":"css/form-app-styles-rtl.css",p=document.createElement("link");p.id=o,p.type="text/css",p.rel="stylesheet",p.href=d,p.onload=function(){r.css("direction",a),f.remove(),e.$broadcast("layoutDirChange",a),u()},$(p).insertBefore(f)}}else u()},this.dictToCsv=function(e,t,n){function r(e,t,i){return Object.keys(e).reduce(function(a,o){var s=i?Array.isArray(e)?i+"["+o+"]":i+"."+o:o;if("string"==typeof e[o]){var u=t?t[o]||"":"",c=[s,e[o],u];return n&&!n(s,e[o],u)||a.push(c),a}var l=r(e[o],t&&t[o],s);return a.concat(l)},[])}return r(e,t)},this.csvToDict=function(e,t,n){var r=this,i={};return t=t||2,e.filter(function(e){return""===r.validateRowFormat(e,t,n)}).forEach(function(e){function n(e,t,r){var i,a,o=t.replace(/[\[\]]/g,".").replace(/\.+/g,".").split(".");1===o.length?e[t]=r:(i=o.shift(),a=o[0].match(/^\d*$/)?[]:{},a=e[i]=e[i]||a,n(a,o.join("."),r))}n(i,e[0],e[t])}),i},this.validateRowFormat=function(e,t,n){if(t=t||2,e.length<t+1)return"Too few columns";if(e.some(function(e){return"string"!=typeof e}))return"Invalid content in one or more columns";if(""===e[0])return"Missing Property Path";if(void 0!==n){for(var r=e[0].split("."),i=n;i&&r.length;){var a=r.shift();if(a.indexOf("[")>-1){var o=a.split(/[\[\]]/);i=i[o[0]][o[1]]}else i=i[a]}if(void 0===i)return"Invalid Property Path"}return""}}"undefined"==typeof window?module.exports=new e(null,null,null,require("../../form/services/Util"),Promise,null):define("form/services/Translation",["app"],function(t){t.ng.service("Translation",["$rootScope","Form","Resource","Util","$q","$timeout",e])})}(),define("form/directives/animateHeight",["app","module"],function(e,t){e.ng.animation(".animate-height-if",["$timeout",function(e){return{enter:function(t,n){var r=t[0].offsetHeight;t.css({"max-height":"0px","padding-top":"0px","padding-bottom":"0px",opacity:0}),e(function(){t.addClass("animate-height-transition"),t.css({"max-height":r,"padding-top":"","padding-bottom":"",opacity:1}),e(function(){n(),t.removeClass("animate-height-transition"),t.css({"max-height":"",opacity:""})},300,!1)},25,!1)},leave:function(t,n){var r=t[0].offsetHeight;t.css({"max-height":r,opacity:1}),e(function(){t.addClass("animate-height-transition"),t.css({"max-height":"0px","padding-top":"0px","padding-bottom":"0px",opacity:0}),e(function(){n(),t.removeClass("animate-height-transition"),t.css({"max-height":"","padding-top":"","padding-bottom":"",opacity:""})},300,!1)},25,!1)}}}])}),define("form/services/Insights",["app","require"],function(e,t){e.ng.service("Insights",["$rootScope","$q","$timeout",function(e,n,r){function i(e,t,n){u.then(function(r){(a.isNavPage(e)||e.isDialog||e.isModal||e===a.viewModelRoot?r.createSectionEmitter(e):r.createFieldEmitter(e,t)).then(function(e){n(e)})})}var a=this,o=0,s=5,u=n(function(e,n){function i(){t(["InsightsClientLoader"],function(t){t&&t.getEventConsumerClient("Maestro").then(function(t){a.enabled=!0,e(t)})},function(e){if(++o<s)r(i,100*o);else{var t=new Error("Insights client library failed to load or is not available");console.error(t),n(t)}})}a.init=function(e){a.viewModelRoot=e,i()}});this.emitterForField=function(e,t,n){i(e,t,n)},this.emitterForSection=function(e,t){i(e,null,t)},this.emit=function(){var e=Array.prototype.slice.call(arguments,0);u.then(function(t){t.emit.apply(t,e)})},this.getFormInfo=function(e,t,n,r){var i=r.save_option&&!r.save_option.properties.exclude,a=r.open_saved_form&&!r.open_saved_form.properties.exclude;return{name:n.label,formType:"Maestro",dataVersion:e,serverUrl:document.location.protocol+"//"+document.location.host,createdBy:t.formDesignVersion.createdBy,createdAt:new Date(parseInt(t.formDesignVersion.createdAt,10)),lastModifiedBy:t.formDesignVersion.lastModifiedBy,lastModifiedAt:new Date(parseInt(t.formDesignVersion.lastModifiedAt,10)),navigationMode:null,saveResume:i&&a||null,txnEffortScore:{totalScore:null,version:null},locales:n.translation.languages.map(function(e){return e.code}),classification:{industry:null,class:null,txnType:null}}},this.isNavPage=function(e){return e.hasOwnProperty("$viewTemplate")},this.getItemSectionParent=function(e){var t=e.$$parent;return t?this.isNavPage(t)||t.isDialog||t.isModal?t:this.getItemSectionParent(t):null},this.getComponentPaths=function(e){var t=[];if(e){var n=e.$$component;n&&(t.concat(this.getComponentPaths(n)),t.push(n.id))}return t},this.executePostDigest=function(e){return r(e,0,!1)},this.milestone=function(e){u.then(function(t){t.milestone(e)})},this.fieldNavigation=function(e,t){
this.emitterForField(e,t,function(e){e.enter()})},this.fieldHelp=function(e,t){this.emitterForField(e,t,function(e){e.help()})},this.fieldCompletion=function(e,t){this.emitterForField(e,t,function(n){n.exit(t[e.id])})},this.navigation=function(e){this.emitterForSection(e,function(e){e.enter()})},this.sectionExit=function(e){this.emitterForSection(e,function(e){e.exit()})},this.sectionCompletion=function(e){this.emitterForSection(e,function(e){e.exit()})},this.validation=function(e,t){u.then(function(n){n.getForm().then(function(n){var r=e.reduce(function(e,n){e[n.item.id]||(e[n.item.id]=[]);var r=n.data||n.error&&n.error.data;return r&&e[n.item.id].push({item:n.item,data:r,error:n.error,trigger:t}),e},{});Object.keys(r).forEach(function(e){var t=r[e][0].item,a=r[e][0].data,o=n.normaliseValidationResults(r[e]);i(t,a,function(e){e.validate(o)})})})})},this.segment=function(e,t){u.then(function(n){n.segment(e,t)})},this.click=function(e,t){this.emitterForField(e,t,function(e){e.click()})};var c=["submit","cancel","save"];this.terminate=function(e){c.indexOf(e)>-1&&this.emit(e)}}])}),define("form/services/EcclApi",["app"],function(e){e.ng.service("EcclApi",["$rootScope","$q","Form","Util","Rules","$timeout",function(e,t,n,r,i,a){this.getItemForEventTarget=function(e){var t=angular.element(e),r=n.getElementItemId(t);return n.items[r]},this.getDataForEventTarget=function(e){return angular.element(e).scope().data},this.getSystemDataForKey=function(e){return n.getSystemData(e)},this.itemRequiresValidation=function(e){return!!(i["ok_"+e.id]||i["chok_"+e.id]||e.mandatory)},this.elementForItem=function(e,t){return r.findElementFromItem(e,t)[0]},this.getItemForId=function(e){return n.items[id]},this.executePostDigest=function(e){return a(e,0,!1)},this.getParentRepeatInfo=function(e,t){for(var n=[],i=r.findParentRepeat(e),a=t;i;)n.unshift({item:i,index:a.$i}),i=r.findParentRepeat(i),a=a.$p;return n},this.getCurrentPage=function(){return n.$Pages.currentPage},this.getSections=function(){return{root:n.view,pages:n.$Pages.flatPages,dialogs:n.view.dialogs,modals:n.view.modals}}}])}),define("form/directives/eq",["app"],function(e){e.ng.directive("avEq",["Form",function(e){return function(t,n,r){e.getItem(t,n).then(function(e){t.$watch(function(){var n;try{n=t.$eval(r.avEq)}catch(t){console.log(e.id+" calc rule error: "+t)}return n},function(n){void 0!==n&&(t.data[e.id]=n)},!0)})}}])}),define("form/directives/change",["app"],function(e){e.ng.directive("avChange",["$timeout","Form","Rules",function(e,t,n){return function(r,i,a){t.getItem(r,i).then(function(t){i.on("change.changeRule","input[data-ng-model], select[data-ng-model], textarea[data-ng-model]",function(i){e(5).then(function(){n["change_"+t.id](r.data,t,i)})})})}}])}),define("form/directives/ok",["app"],function(e){e.ng.directive("avOk",["$timeout","$rootScope","Form","Rules","Validation","Util","Insights","Resource",function(e,t,n,r,i,a,o,s){var u={};return function(c,l){s.design||n.getItem(c,l).then(function(f){function d(){var e=n.getUniqueId(f.id,c.data);"function"==typeof u[e]&&u[e]()}function p(t){function n(){if(y||i.hasValue(f,c.data))return v||(v=$("<div class='av-input-spinner spin fa fa-spinner'></div>").insertAfter(l.find("input").first())),i.validate(f,c.data).then(function(e){h(e,l.has(t.target)||l.is(t.target)?"CH":"CA")})}"change"===t.type?e(5).then(n):e(function(){l[0].contains(document.activeElement)||n()},5)}function m(){p({type:"change"})}function h(e,t){function r(e){if(void 0===f.htmlLabel)return e;var t=f.htmlLabel.match(/(\{\{data[.][\w]+\}\})/g),n="";return t&&t.forEach(function(t){n=t.replace(/(\{\{|\}\})/g,""),e=e.replace(n,c.$eval(n))}),e}var i,s=e.errors.filter(function(e){return e.id===f.id&&e.data===c.data})[0],u=b.find(" > .err-msg"),d=[];if(v&&(v.remove(),v=null),t&&s&&!angular.equals(s,g)){var p=l.scope();o.validation([{error:s,item:f,data:p?p.data:null}],t),g=s}if(i=s?s.id+"_error":n.getElementItemId(l)+"_error",u.length&&(d=u.find("."+i)),s)if(l.addClass("has-error"),w.attr("aria-invalid","true"),u.length||(b.append('<div class="err-msg list-group"/>'),u=b.find(" > .err-msg")),w.attr("aria-describedby",i),d&&d.length)d.find(".message").html(["<span class='av-hidden'>Error. </span>",a.decodeHtmlEntities(s.msg)].join(""));else{u.append(function(){return['<p class="list-group-item list-group-item-danger '+i+'">','<span class="fa fa-exclamation-triangle" aria-hidden="true">&nbsp;</span>','<span id="'+i+'" class="message"><span class="av-hidden">Error. </span>',r(s.msg),"</span></p>"].join("")}()),u.on("click","."+i,function(){n.gotoError(s)});var h=l[0].contains(document.activeElement),$=[h?"Error - ":"Error on previously visited field - ",a.decodeHtmlEntities(s.msg)].join("");n.showAccessibleAlert($)}else{var S=n.validation.errors,D=S.length&&S.filter(function(e){return e.id===f.id&&e.data===c.data})[0];D&&a.removeItem(n.validation.errors,D),l.removeClass("has-error"),w.removeAttr("aria-invalid").removeAttr("aria-describedby"),d&&d.length&&d.remove(),u.children().length||u.remove(),e.valid&&0==S.length&&(n.validation.valid=!0,n.showMobileErrors=!1)}y||(l.off("blur.validation","input, textarea, select"),l.off("change.validation","select, input[type='radio'], input[type='checkbox']"),c.$on("revalidate",m),c.$on("translate",m),y=!0)}var v,g,y,w=l.find("input, textarea, select"),b=l.closest(".row");f.id,f.id;if(l.on("blur.validation","input, textarea, select",p),(1===w.length||w.is("[type=radio], [type=checkbox]"))&&l.on("change.validation","select, input[type='radio'], input[type='checkbox']",p),c.$on("validate",function(e,t,n){n[0].contains(l[0])&&h(t)}),s.generated&&n.hasRuleInAncestry("sh",f)){d();var S=n.getUniqueId(f.id,c.data);u[S]=t.$watch(function(){return n.isVisible(f,c.data)},function(e){e||m()})}if(c.$on("$destroy",d),n.hasRule("md",f)){var D=r["md_"+f.id],k=l.find("select, input:not(:checkbox):not(:radio), textarea, fieldset[role=radiogroup]"),C=l.find("select, input:not(:radio), textarea");c.$watch(function(){return D(c.data,f,c.data[f.id])},function(e){f.mandatory=e,l.toggleClass("av-mandatory",!!e),l.toggleClass("av-optional",!e),k.attr("aria-required",e),C.prop("required",e)})}})}}])}),define("form/directives/us",["app"],function(e){e.ng.directive("avUs",["Form","Util","$timeout",function(e,t,n){return function(r,i,a){var o,s,u=/^(input|select|textarea|button)$/i,c=["av-prevent-disabled"];e.getItem(r,i).then(function(e){function l(){function t(e,n){[].slice.call(e.children).forEach(function(e){c.some(function(t){return e.classList.contains(t)})||(u.test(e.tagName)&&(e.disabled=n,$(e).attr({readonly:n||null,"aria-disabled":n||null}),$(e).closest(".av-item-container").toggleClass("av-disabled",n)),t(e,n))})}o!==s&&(s=o,(e.overrideParentUsRule||!e.overrideParentUsRule&&!f(e))&&(t(i[0],o),e.itemIsDisabled=o))}function f(e){for(var t=e.$$parent,n=!!t.itemIsDisabled;t&&!n;)t.itemIsDisabled&&(n=!0),t=t.$$parent;return n}n(100,!1).then(function(){r.$watch(function(){try{o=!r.$eval(a.avUs)}catch(t){console.log(e.id+" editability rule error: "+t)}return o},l),Array.isArray(e.rows)&&r.$watch(function(){return i.find("input, button, select, textarea").length},l),o=!r.$eval(a.avUs),l()}),e.overrideParentUsRule||function(e){t.sendAll(e,function(e){e.overrideParentUsRule&&c.push("id-"+e.id)},!0)}(e)})}}])}),define("form/directives/blur",["app","module"],function(e){e.ng.directive("avBlur",[function(){return{link:function(e,t,n){$find(t,"input, button:not(.av-popover-btn), textarea, select").on("blur",function(r){var i=angular.element(r.relatedTarget);do{if(i[0]===t[0])return}while((i=i.parent())&&i.length);e.$apply(n.avBlur)})}}}])}),define("form/directives/focus",["app","module"],function(e){e.ng.directive("avFocus",[function(){return{link:function(e,t,n){$find(t,"input, button:not(.av-popover-btn), textarea, select").on("focus",function(r){var i=angular.element(r.relatedTarget);do{if(i[0]===t[0])return}while((i=i.parent())&&i.length);e.$apply(n.avFocus)})}}}])}),define("form/directives/img",["app"],function(e){e.ng.directive("avImg",["Form",function(e){return{scope:!0,link:{pre:function(t,n){e.getItem(t,n).then(function(e){t.imageSrc=function(){return e.properties.imgUrl?(t.source="url",e.properties.imgUrl):(t.source="far","./images/"+e.properties.src.fileName)},t.altText=function(){return e.properties.alternativeText},t.toolTip=function(){return e.properties.toolTip},t.imageLink=function(){return e.properties.imageLink},t.getHeight=function(){return"far"===t.source?e.properties.src.height:e.properties.imgUrlHeight},t.getWidth=function(){return"far"===t.source?e.properties.src.width:e.properties.imgUrlWidth}})}}}}])}),define("form/directives/comp",["app"],function(e){e.ng.directive("avComp",["Form",function(e){return{scope:!0,link:function(t,n){e.getItem(t,n).then(function(e){t.data=t.data[e.id]})}}}])}),define("form/directives/compile",["app"],function(e){e.ng.directive("avCompile",["$compile","$sanitize","Resource","Form","$timeout",function(e,t,n,r,i){return{link:function(t,a,o){r.getItem(t,a).then(function(r){if(angular.isDefined(o.ngBindHtml)){var s=function(r,o){function s(){e(a.contents())(t)}n.generated?i().then(s):s()};n.design?t.$watch(o.ngBindHtml,s):(t.$on("translate",s),s())}})}}}])}),define("form/directives/ngValid",["app"],function(e){e.ng.directive("avNgValid",function(){return{require:"ngModel",link:function(e,t,n,r){var i=function(e){return!0};r.$validators={email:i,number:i}}}})}),define("form/directives/bindKey",["app"],function(e){e.ng.directive("avBindKey",["$rootScope",function(e){return{require:"ngModel",link:function(t,n,r,i){n.bind("keyup",function(n){13===n.keyCode?(i.$commitViewValue(),r.avBindKey&&(t.$eval(r.avBindKey),e.$$phase||e.$digest())):27===n.keyCode&&i.$rollbackViewValue()})}}}])}),define("form/directives/decimal",["app","module"],function(e,t){e.ng.directive("avDecimal",["$filter","Resource",function(e,t){return{require:"?ngModel",link:function(n,r,i,a){function o(e){""!==e&&(g&&(e=e.split(g).join("")),""!==y&&"."!==y&&g!==y&&(e=e.split(y).join(".")),e=parseFloat(e,10).toString());var t=s(e);return a.$setViewValue(t),a.$render(),e}function s(t){if(t)if((t=e("number")(t,h))&&!g)t=t.split(",").join("");else if(g&&","!==g){var n,r=t.split(/[,\\.]/);h&&(n=r.pop()),t=r.join(g),n&&(t+=y+n)}return t}function u(e){return"number"==typeof e&&(e=e.toString()),g&&(e=e.split(g).join("")),""!==y&&"."!==y&&g!==y&&(e=e.split(".").join(y)),new RegExp("^[-+]?\\d+("+l(y)+"\\d+)?$").test(e)||(e=""),v&&(e=e.toString().replace(/-/g,"")),e||""}function c(){var e=r[0].selectionStart,n=r[0].selectionEnd,i=u(a.$viewValue);a.$setViewValue(i),a.$render(),"IE"!=t.browserType&&"Firefox"!=t.browserType||(r[0].selectionStart=e,r[0].selectionEnd=n)}function l(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")}function f(e){var n=function(e){if("IE"==t.browserType&&e.key.length>0){var n={Subtract:"-",Decimal:"."}[e.key];if(n)return n}return e.key}(e);return function(e){return-1!==["1","2","3","4","5","6","7","8","9","0",g,y].indexOf(e)||!v&&"-"==e}(n)&&function(t){var n=e.target.value,r=""===y?-1:n.indexOf(y),i=-1!==n.indexOf("-");if("number"==e.target.type)return"-"===t?!i:""===y||t!==y||-1==r&&0!==h;var a=e.target.selectionStart,o=e.target.selectionEnd;if(a!=o){var s=0==a?"":n.substring(0,a)+t+n.substring(o);return S.test(s)}if("-"==t)return 0==a;if(""!==y&&t==y&&(-1!=r||0==h))return!1;var u=n.replace(new RegExp(l(g),"g"),"").match(S);if(!u||!u[0])return!0;if(r>=0){if(a>r){if(t==g)return!1;if(u[2].length>=h)return!1}else if(t!==g&&w>0&&u[1].length>=w)return!1}else{if(""!==y&&t==y&&(a>=1||0==n.indexOf("-")&&a>=2))return!0;if(w>0&&u[1].length>=w)return!1}return!0}(n)||function(e){return 35<=e.which&&e.which<=40||-1!==[8,9,13,27,46].indexOf(e.which)||(e.ctrlKey||e.metaKey)&&-1!=["a","c","v","x","z"].indexOf(e.key.toLowerCase())||0===e.which}(e)}function d(e){var t=e.originalEvent.clipboardData||window.clipboardData,n=t.getData("text");S.test(n)||e.preventDefault()}function p(e){D.value=e.target.value,"number"!==e.target.type&&(D.startSelection=e.target.selectionStart,D.endSelection=e.target.selectionEnd)}function m(e){S.test(e.target.value)||(e.target.value=D.value,"number"!==e.target.type&&(e.target.selectionStart=D.startSelection,e.target.selectionEnd=D.endSelection))}var h=parseInt(i.avDecimal||2,10)||0,v="true"===i.preventNegative||!0===i.preventNegative,g=i.thousandsSeparator||"",y=i.decimalPoint||(0===h?"":"."),w=parseInt(i.maxLeadingDigits||"0",10),b=w<=0||isNaN(w)?-1:w+(v?0:1)+1+h,$="^["+(v?"":"-")+"+]?(\\d"+(w?"{0,"+w+"}":"*")+")"+(h?"(?:"+l(y)+"(\\d{0,"+h+"}))":"")+"?$",S=new RegExp($);r.on("focus",c),r.on("blur",function(e){o(e.target.value)}),r.on("paste",d),t.design?(r.on("keydown",f),n.$watch("item.properties.places",function(e){h=e,r.val(s(a.$viewValue))})):(g.length>1&&(console.warn("Thousands Separator must be a single character"),g=g.substr(0,1)),y.length>1&&(console.warn("Decimal Point must be a single character"),y=y.substr(0,1)),b>0&&(r[0].maxLength=b),"Android"==t.deviceType?(r.on("input",m),r.on("keydown",p)):r.on("keydown",f),a.$parsers.unshift(o),a.$formatters.push(function(e){return"number"==typeof e||e?s(e):""}));var D={value:"",startSelection:0,endSelection:0}}}}])}),define("form/directives/clear",["app"],function(e){e.ng.directive("avClear",["Form","Util",function(e,t){return{priority:700,compile:function(n,r){var i=e.getElementItemId(n),a=r.ngIf;return function(n,r,o){e.load().then(function(){var r=e.items[i],o="uNiNiTiAlIsEd";n.$watch(a,function(e){e===o||e||t.sendAll(r,function(e){n.data.hasOwnProperty(e.id)&&"no"!==e.clearHidden&&"submit"!==e.clearHidden&&(n.data[e.id]=e.repeatingData?[]:"")}),o=e})})}}}}])}),define("form/directives/preventCopyPaste",["app"],function(e){e.ng.directive("avPreventCopyPaste",function(){return function(e,t,n){t.on("copy paste","input, textarea",function(e){e.preventDefault()})}})}),define("form/directives/popoverHelp",["app"],function(e){e.ng.directive("avPopoverHelp",["Form","Insights","Resource",function(e,t,n){return{link:function(r,i){e.getItem(r,i).then(function(a){var o,s,u=i.find("button.av-popover-btn"),c="input, button, select, textarea, [tabindex=0]",l=function(e){var t=$(e),n=t.find(".popover-tooltip"),r=n.find(".content");t.addClass("ready");var i=t.width(),a=t.height(),o=n.height(),s=n.width(),u=-s/2+0+i/2,c=-o-9,l=$(window).scrollTop()+56,f=$(window).scrollTop()+$(window).height(),d=$(window).scrollLeft(),p=d+$(window).width();n.css({top:""});var m=n.offset().top,h=parseInt(c,10),v=a+9+3,g=v+o,y=m+h-l,w=f-(m+g);y>=0?(n.removeClass("is-below"),n.css({top:h,left:parseInt(u,10)})):w>=0?(n.addClass("is-below"),n.css({top:v,left:parseInt(u,10)-4})):w<y?(n.removeClass("is-below"),n.css({top:h,left:parseInt(u,10)})):(n.addClass("is-below"),n.css({top:v,left:parseInt(u,10)-4}));var b=n.offset().left,S=b+n.width(),D=s/2-20;if(b<=d){var k=-1*(b+d)+10;k=k>D?D:k,r.css("left",k)}else if(S>=p){var C=S-p+10;C=C>D?D:C,r.css("right",C)}else r.css("right","");t.removeClass("ready")},f=function(i){if(r.currentPopOverHelp){if(i.is(r.currentPopOverHelp))return;r.$emit("closeTooltip",r.currentPopOverHelp)}if(r.currentPopOverHelp=i,!$(i).hasClass("ready"))var u=setTimeout(function(){$(i).hasClass("active")&&(t.fieldHelp(a,i.scope().data),clearTimeout(u))},500);l(i),clearTimeout(o);var c=$(i).find(".content");"iOS"===n.deviceType&&c.on("click.helpText",function(e){e.stopPropagation()}),e.showAccessibleAlert(c.text(),!0),$(i).addClass("ready"),s=setTimeout(function(){$(i).addClass("active")},1)},d=function(e){clearTimeout(s),"iOS"===n.deviceType&&$(e).find(".content").off("click.helpText"),$(e).removeClass("active"),r.currentPopOverHelp=null,o=setTimeout(function(){$(e).removeClass("ready"),$(e).closest("[data-av-popover-help]").data("IsClicked",!1)},250)};r.$on("closeTooltip",function(e,t){u.parent().is(t)&&d(u.parent())}),i.data("IsClicked",!1);var p=$(document);!0!==p.data("popoverBlurListener")&&(p.on("focusin.globaltooltip",function(e){!$(e.target).closest(".av-item-container").children().filter(function(e,t){return""===t.getAttribute("data-av-popover-help")}).length&&r.currentPopOverHelp&&r.$emit("closeTooltip",r.currentPopOverHelp)}),p.data("popoverBlurListener",!0)),u.on("mouseover",function(){!1===i.data("IsClicked")&&(f($(this).parent()),"iOS"===n.deviceType&&$(this).parent().find("a").length&&(u.click(),i.data("IsClicked",!0)))}),u.on("mouseout",function(){!1===i.data("IsClicked")&&d($(this).parent())}),i.closest(".av-item-container").on("focus.tooltip",c,function(){if(r.currentPopOverHelp){$(this).closest(".av-item-container").find("div.av-popover-help").is(r.currentPopOverHelp)||r.$emit("closeTooltip",r.currentPopOverHelp)}}).on("blur.tooltip",c,function(){if(r.currentPopOverHelp)if(!1===i.data("IsClicked"))d($(this).parent());else{var e=$(this).closest(".av-item-container"),t=e.find("div.av-popover-help");setTimeout(function(){document.activeElement&&!e[0].contains(document.activeElement)&&d(t)},50)}}),u.on("click",function(e){e.preventDefault(),e.stopPropagation();var t=this;!1===i.data("IsClicked")?(f($(t).parent()),i.data("IsClicked",!0)):d($(t).parent())})})}}}])}),define("form/directives/select",["app","module"],function(e,t){e.ng.directive("avSelect",["Form","Resource","$timeout","$compile","Util",function(e,t,n,r,i){return{scope:!0,link:function(n,a,o){e.getItem(n,a).then(function(s){function u(){a.after(r("<div class='av-select-value av-select-placeholder' data-ng-show='getPlaceHolder() && !selectHasValue()' data-ng-bind='getPlaceHolder()'></div>")(n))}function c(e){e!==h.path&&(h.path=e),l(h.path)}function l(e){if(e||(e=[]),p)f(e),d();else{var t=n.data[s.id]||"",r=i.find(e,g,t);n.data[s.id]=r?r[g]||"":e.length>0?e[0][g]||"":""}}function f(e){if(Array.isArray(e)&&e.length){var t={};t[v]="",t[g]="",e[0]?""!==e[0][g]&&e.unshift(t):e[0]=t}}function d(){null!==n.data[s.id]&&void 0!==n.data[s.id]||(n.data[s.id]="")}var p=s.properties.addBlankValue||!1,m=s.properties.placeholder||!1,h=n.$eval(o.avSelectOptions)||!1,v=s.properties.labelField||"label",g=s.properties.valueField||"value";if(t.design||n.$on("translate",function(){h=n.$eval(o.avSelectOptions)||!1,p&&f(h.path)}),"IE"!=t.browserType&&"Edge"!=t.browserType||a.on("mousewheel",function(){return!1}),!h)return new Error("Dropdown "+s.label+" must have a data source set in the avSelectOptions attribute.");if(a.wrap("<div class='av-select-overlay form-control wdg-input'></div>"),a.after(r("<div class='av-select-value' data-ng-show='selectHasValue()' data-ng-bind='getSelectText()'></div><i class='av-select-icon wdg-select-icon' data-ng-class='getIcon()'></i>")(n)),t.design)u();else{if("data"===h.type&&(i.isBlank(n.data[s.id])||p))var y=n.$watch(function(){return h.path},function(e){var t=angular.isArray(e)?e:n.$eval(e);void 0!==t&&(l(t),y())});"data-dropdown"===s.type&&n.$watch(function(){return e.getPathData(h.path,n.data)},l),m&&u()}n.getPlaceHolder=function(){return e.term(s.id+".properties.placeholder")||!1},n.getIcon=function(){return s.properties.icon||"fa fa-caret-down"},n.selectHasValue=function(){return!i.isBlank(n.data[s.id])||h.noFormData&&-1==["?",""].indexOf(a.val())},n.getSelectText=function(){var t=i.isBlank(n.data[s.id]);if(t||!h.path)return"";if("string"==typeof n.data[s.id]&&(0===n.data[s.id].indexOf("string:")||0===n.data[s.id].indexOf("number:")||0===n.data[s.id].indexOf("boolean:"))){var r=n.data[s.id].substr(n.data[s.id].indexOf(":")+1),a=n.data[s.id].substr(0,n.data[s.id].indexOf(":"));"number"===a?r=parseInt(r):"boolean"===a&&(r="true"===r),n.data[s.id]=r}var o=Array.isArray(h.path)?h.path:e.getPathData(h.path,n.data),u=i.find(o,g,t?"":n.data[s.id]);return u&&(u[v]||u[g])||""},n.$on("updateSelectSource",function(e,t){c(t)})})}}}])}),define("form/directives/view-stack/view-stack",["app","module"],function(e,t){e.ng.directive("viewStack",["Util","$timeout",function(e,t){return function(e,n,r){function i(){f=e.$eval(r.index),d&&(o=n.find(" > .vstk-in > div"),o.hasClass("av-page-spinner")||(s=o.height())&&(n.height(s),n.addClass("stack-active"))),d&&u?(c&&t.cancel(c),c=t(p),c.then(function(){a()}).catch(function(){})):t(10).then(a)}function a(){var r=0;n.children().each(function(t,n){var i=$(n),a=i.attr("data-ng-if"),o=!a||e.$eval(a);i.hasClass("ng-leave")||(r<f||!o?(i.addClass("vstk-out vstk-down"),i.removeClass("vstk-up vstk-in")):r>f?(i.addClass("vstk-out vstk-up"),i.removeClass("vstk-down vstk-in")):(i.addClass("vstk-in"),i.removeClass("vstk-out vstk-up vstk-down")),o&&r++)}),d&&(u=!0,l&&t.cancel(l),l=t(p),l.then(function(){o.hasClass("av-page-spinner")||(n.removeClass("stack-active"),n.height(""),u=!1)}).catch(function(){}))}var o,s,u,c,l,f=0,d=!!e.$eval(r.viewStackHeight),p=e.$eval(r.viewStackDelay)||0;d||n.addClass("stack-active"),e.$watch(r.index,function(e,t){e!==t&&(u=!1,i())}),e.$watchCollection(function(){return n.children()},function(e,t){e&&e.length&&i()})}}])}),define("form/form",["app","module","./filters","./services/Resource","./services/Widget","./services/Rules","./services/Calc","./services/Validation","./services/Form","./services/JXON","./services/Transact","./services/DynamicData","./services/Scroll","./services/Util","./services/EncUtil","./services/Http","./services/Automation","./services/Translation","./directives/animateHeight","./services/Insights","./services/EcclApi","./directives/eq","./directives/change","./directives/ok","./directives/us","./directives/blur","./directives/focus","./directives/img","./directives/comp","./directives/compile","./directives/ngValid","./directives/bindKey","./directives/decimal","./directives/clear","./directives/preventCopyPaste","./directives/popoverHelp","./directives/select","./directives/view-stack/view-stack"],function(e,t){e.addModuleStylesheet(t),e.ng.directive("avForm",["$q","$parse","$sanitize","$sce","$timeout","Util","Resource","Form","Calc","Transact","Rules","Scroll","Validation","Automation","EcclApi",function(e,t,n,r,i,a,o,s,u,c,l,f,d,p,m){return{controller:["$scope",function(e){e.$parse=t,e.Resource=o,e.Calc=u,e.sanitize=n,e.Rules=l,e.Transact=c,e.Automation=p,e.EcclApi=m,d.Rules=l,e.trustUrl=function(e){return r.trustAsResourceUrl(e)},o.generated&&o.getFormView().then(function(e){return s.load(e)}).then(function(t){function n(t){return function(){t(e.data,e.item)}}if(!t||"string"==typeof t)return $("body.av-form").addClass("form-loaded"),void console.error(t);var r=l["load_"+t.id],u=l["postsubmit_"+t.id];if(t.publishOptions&&t.publishOptions.preview&&(o.preview=!0),r&&i(n(r),150,!1),u&&e.$on("postSubmit",n(u)),i(s.watchFormDataChange(),200,!1),$("body.av-form").addClass("form-loaded"),"function"==typeof window.callPhantom&&i(function(){if(t.properties.prePhantomCallbackTimeout){var e=parseInt(t.properties.prePhantomCallbackTimeout,10);i(function(){window.callPhantom({completed:!0})},e)}else window.callPhantom({completed:!0})},2e3,!1),!o.preview){var f=s.getSystemData("ServerBuildNumber");if(t.transact.newFormApi&&!a.isReceipt&&!o.preview&&f&&parseInt(f.split(".")[0])>=18&&(c.formInit(),window.onerror=function(e,t,n,r,i){var a=e+"\n"+t+":"+n+":"+r;c.formError(a)}),s.view.properties.enableLeavePageWarning){var d="WebkitAppearance"in document.documentElement.style,p=(d?"":"Are you sure you want to leave this page? ")+"Data you have entered may not be saved.",m=s.view.properties.leavePageWarningMessage||p;window.onbeforeunload=function(){if(!s.pageName)return m}}s.view.properties.autoSaveInterval&&!s.isFieldWorker()&&!0!==s.getSystemData("AutoSaveDisabled")&&"true"!==s.getSystemData("AutoSaveDisabled")&&s.handleAutoSaveInterval()}setTimeout(function(){e.$apply()},200)})}],link:function(e,t){if(!o.design){var n=function(){e.$broadcast("revalidate")},r=function(e){var t=window.getFieldWorkerComposerAPI&&window.getFieldWorkerComposerAPI(),n=e.target.getAttribute("href");t&&n&&(e.preventDefault(),t.openExternalLink(n))};"Unknown"!==o.deviceType&&t.addClass(o.deviceType),"Unknown"!==o.browserType&&t.addClass(o.browserType),t.on("change","input:checkbox, input:radio",function(e){var t=e.target;do{t=t.parentElement}while("div"!==t.tagName.toLowerCase());s.view.properties.checkboxRadioAutoScroll&&f.scrollTo(t,!1,25)}).on("focus","input, select, textarea",function(e){var t=angular.element(e.target),n=s.getElementItemId(t),r=s.items[n];t.closest(".id-"+n).addClass("av-focus"),r&&(s.lastFocusedItem=r)}).on("blur","input, select, textarea",function(e){var t=angular.element(e.target),n=s.getElementItemId(t);t.closest(".id-"+n).removeClass("av-focus")}).on("blur","input:not(:checkbox):not(:radio), textarea",n).on("change","select, input[type='radio'], input[type='checkbox']",n).on("click","button",n).on("focus.ascLink","a[target='_blank']",function(e){var t=["main landmark",$(e.target).text(),s.term(s.view.id+".properties.linkWarningMsg"),"clickable link"].join(" ");i(50).then(function(){s.showAccessibleAlert(t)})}),window.getFieldWorkerComposerAPI&&t.on("click","a",r)}}}}])}),requirejs.config({paths:{lib:"../lib"},shim:{"lib/jquery.layout/jquery.layout-latest":{deps:["lib/jquery-ui/jquery-ui"]}},waitSeconds:0}),"function"==typeof jQuery&&define("jquery",[],function(){return jQuery}),define("main",["app","form/form"],function(e){$(function(){e.init()})}),require(["main","form/form"]);
function _asyncToGenerator(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,n){function a(i,r){try{var o=t[i](r),s=o.value}catch(e){return void n(e)}if(!o.done)return Promise.resolve(s).then(function(e){a("next",e)},function(e){a("throw",e)});e(s)}return a("next")})}}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};define("services/formresources/6306/widgets/jlrDropdown/jlrDropdown.js",["app"],function(e){e.ng.directive("jlrDropdown",["Form","DynamicData","Resource","Validation","Util","$timeout","Translation","$document","$compile",function(e,t,n,a,i,r,o,s,l){return{scope:!0,restrict:"A",link:function(e,t,a){e.dropdownToggle=!1,e.toggleDataDropdown=function(){n.design||(e.dropdownToggle=!e.dropdownToggle)},s.bind("click",function(n){t[0].contains(n.target)||maestro.Resource.preview||(e.dropdownToggle=!1,e.$apply())})},controller:["$scope","Form","$element",function(e,t,n){t.getItem(e,n).then(function(a){function i(){if(Array.isArray(e.options)&&e.addBlankOption&&e.options.length&&""!==e.options[0][e.valueKey]){var t={};t[e.labelKey]="",t[e.valueKey]="",e.options.unshift(t)}}e.labelKey=a.properties.labelField||"label",e.valueKey=a.properties.valueField||"value",e.placeholder=a.properties.placeholder||!1,e.addBlankOption=a.properties.addBlankValue||!1,e.defaultValue=a.properties.defaultValueField||!1,e.prefilledDataKey="Form.prefill.JLRData."+[a.id.charAt(0).toUpperCase()+a.id.slice(1)],e.$watch(function(){return t.getPathData(a.properties.dataPath,e.data)},function(n){e.options=n||[];var r=t.prefill.JLRData[a.id.charAt(0).toUpperCase()+a.id.slice(1)];r&&(e.defaultValue=r),i(),e.optionSelect(n[n.findIndex(function(t){return t[e.valueKey]==e.defaultValue})])}),e.$watch("Form.prefill.JLRData."+[a.id.charAt(0).toUpperCase()+a.id.slice(1)],function(n,i){if(n!==i){var r=t.prefill.JLRData[a.id.charAt(0).toUpperCase()+a.id.slice(1)];e.defaultValue=r;var o=e.options;e.optionSelect(o[o.findIndex(function(t){return t[e.valueKey]==e.defaultValue})])}}),e.optionSelect=function(n){n&&(e.selectedOption=n,e.data[a.id]=n[e.valueKey],e.optionSelected=null,t.validate(a.id))},e.isSelectedOption=function(t){return t===e.optionSelected},e.optionIndex=-1,e.optionSelected=null,e.dropdownA11y=function(t){e.dropdownToggle&&(t.preventDefault(),"ArrowUp"===t.code?(e.optionIndex<0?e.optionIndex=0:e.optionIndex>0&&e.optionIndex--,e.optionSelected=e.options[e.optionIndex],n[0].querySelectorAll("li").item(e.optionIndex).focus()):"ArrowDown"===t.code?(e.optionIndex<0?e.optionIndex=0:e.optionIndex<e.options.length-1&&e.optionIndex++,n[0].querySelectorAll("li").item(e.optionIndex).focus(),e.optionSelected=e.options[e.optionIndex]):("Enter"===t.code||"NumpadEnter"===t.code)&&e.optionIndex>=0?(e.optionSelect(e.options[e.optionIndex]),e.optionSelected=e.options[e.optionIndex],e.dropdownToggle=!1):"Escape"===t.code&&(e.dropdownToggle=!1))}})}]}}])}),define("services/formresources/6306/widgets/page-controller/page-controller.js",["app"],function(e){e.ng.directive("avNavigator",["$rootScope","$timeout","$q","Form","Scroll","Util","Rules","Resource","Insights","Widget","Translation",function(e,t,n,a,i,r,o,s,l,c,u){function d(c,d){function p(){F.isLeft=d.properties.leftMenu}function f(){if(F.tree=[],F.groups=[],F.flatPages=[],d.rows.forEach(function(e){e.forEach(function(e){var t=F.tree.push(e);if(e.$navVisible=!0,F.policy.restrict&&t>2&&(e.$navDisabled=!0),e.isNavGroup){e.$navPages=[];var n=F.groups.push(e);e.rows.forEach(function(t){t.forEach(function(t){t.$navGroup=e,t.$navVisible=!0,F.policy.restrict&&n>2&&(t.$navDisabled=!0),e.$navPages.push(t),F.flatPages.push(t)})})}else F.flatPages.push(e)})}),F.flatPages[0].$notEditable||(F.flatPages[0].$navDisabled=!1),F.visiblePageCount=F.flatPages.length,x(),v(F.flatPages.filter(w)),F.flatPages.forEach(function(t){var n=e.avReceipt||t.$navSelected;e.avReceipt&&t.$navGroup&&o["sh_"+t.$navGroup.id]&&(n=o["sh_"+t.$navGroup.id](c.data,t.$navGroup)),t.$viewTemplate=t.$viewTemplate||I(n?"pages/"+t.id+"/page.html":"pages/page-spinner/page.html")}),F.flatPages.indexOf(F.currentPage)<0&&(F.pageTemplate=F.currentPage=null),!F.currentPage){var t=0;s.generated&&a.getRevisionNumber()>0&&T&&(t=+(a.getSystemData("LastSavedPageIndex")||0));var n=F.flatPages[t],i=n.$navGroup||n;F.choose(i,n,!0,!0,!0).then(function(){F.policy.restrict&&T&&t>0&&m()})}}function g(){F.tree.filter(function(e){return e.isNavGroup}).forEach(function(e){e.$navSelected=!1})}function v(e){F.flatPages.forEach(function(e){e.$isFirst=e.$isLast=!1}),e[0].$isFirst=!0,e[e.length-1].$isLast=!0,F.visiblePageCount=e.length}function h(e){r.sendAll(e,function(e){c.data.hasOwnProperty(e.id)&&"no"!==e.clearHidden&&"submit"!==e.clearHidden&&(c.data[e.id]=e.repeatingData?[]:"")})}function m(e){function t(e){var t=e.$navGroup.$navPages.filter(w),n=t.indexOf(F.currentPage);return-1!==n&&t.indexOf(e)>n+1}if(F.currentPage){e||(e=F.flatPages.filter(w));var n=e.indexOf(F.currentPage);-1!==n&&e.forEach(function(a){e.indexOf(a)>n+1||a.$navGroup&&t(a)?(a.$navGroup&&e[n+1].$navGroup!==a.$navGroup&&(a.$navGroup.$navDisabled=!0),a.$navDisabled=!0):a.$navDisabled=!1})}}function w(e){return e.$navVisible&&(!e.$navGroup||e.$navGroup.$navVisible)}function b(e){return!!F.policy.restrict||!e.$navDisabled}function P(e,t){for(var n=F.flatPages.indexOf(e),a={};a&&(!w(a)||!b(a));)n+=t?1:-1,a=F.flatPages[n];return a}function y(e){return e.filter(function(e){return e.$navVisible&&!e.properties.offMenu})}function x(){var e=F.tree.filter(function(e){return e.$navVisible&&!e.properties.offMenu}).length;F.topStyle=F.isLeft?{}:{width:100/e+"%"},F.tramlineTopStyle={width:100/(e-1)+"%"}}function S(e){F.subStyle=F.isLeft?{}:{width:(e.$navPages?100/y(e.$navPages).length:0)+"%"}}function D(){function e(){if("none"!==d.properties.focusMode){var e,t,n,i=window.matchMedia("(max-width: "+a.view.breakpoints[1]+"px)").matches;if(i||F.currentPage.properties.offMenu&&!F.uncollapsed){if(!e||!e.length){var r=["h1","h2","h3","h4","h5","h6[tabindex]:visible"].join("[tabindex]:visible, "),o=$(".id-"+F.currentPage.id);n=o.find(r),n.length&&(t=n[0])}}else e=$("nav[tabindex]"),e.length&&(t=e[0]);t&&t.focus()}}$(window).scrollTop()>0?i.scrollTo(0).then(e):e()}function I(e){var t=s.pathId(e);return $("#"+t).length?t:s.baseName+"/"+e}var R,F=this,E=a.getItemsOfType("nav-functions"),T=d.properties.restartAtLastSavedPage;if(this.viewIndex=0,this.isPageDisplayed=!1,this.policy={validate:"sequential"===d.properties.validationMode,restrict:"sequential"===d.properties.validationMode&&s.generated,saveOnPageChange:d.properties.saveOnPageChange},this.index=0,s.design?c.$watch("item.properties.leftMenu",function(){p(),F.isLeft&&(F.topStyle={})}):(p(),F.policy.saveOnPageChange&&(R=JSON.parse(r.jsonify(a.data,["SFMData"])))),this.toggleMenu=function(){var e=angular.element(document.getElementsByTagName("body"));F.uncollapsed=!F.uncollapsed,e.toggleClass("av-menu-uncollapsed",F.uncollapsed),F.collapsing=!0,e.addClass("av-menu-collapsing"),t(function(){F.collapsing=!1,e.removeClass("av-menu-collapsing")},500),F.uncollapsed?$(window).on("resize.menu",r.throttle(function(e){$(this).width()>+a.view.breakpoints[1]&&F.toggleMenu()},50)):$(window).off("resize.menu")},this.choose=function(e,i,u,p,f,v){function h(){var n,f=o["pagechange_"+d.id],h=o["pageload_"+y.id],b=o["pagescroll_"+y.id],T=d.properties.transitionDelay+100||0,C=a.view.properties.gaBaseUrl||"/",L=F.currentPage;if(g(),F.flatPages.forEach(function(e){e.$navSelected=!1}),e.$navSelected=!0,i?i.$navSelected=!0:e.$navPages&&(y.$navSelected=!0),e.$navPages&&S(e),F.index=E,F.currentPage){if(F.policy.saveOnPageChange&&c.Resource.generated&&!a.saveChallengeOnInit){var j=JSON.parse(r.jsonify(a.data,["SFMData"]));(!angular.equals(R,j)||a.view.transact&&a.view.transact.newFormApi)&&(a.backgroundSave(),R=j)}l.sectionExit(F.currentPage)}if(F.currentPage=y,F.currentPage.$navVisited=!0,F.groups.forEach(function(e){var t=e.$navPages.filter(function(e){return F.getVisiblePages().indexOf(e)>-1});e.$navVisited=t.length>0&&t.every(function(e){return e.$navVisited})}),a.completeSectionsOnSubmit.push(y),F.currentPage.$isLast||($=P(F.currentPage,!0),$.$notEditable||($.$navDisabled=!1),$.$navGroup&&$.$navGroup!==F.currentPage.$navGroup&&($.$notEditable||($.$navGroup.$navDisabled=!1)),F.policy.restrict&&m()),c.Editor&&!u&&t(function(){c.Editor.selectItem(F.currentPage,!0),c.Panels.showProperties()}),F.viewIndex=F.index,c.showSpinner(!1),F.currentPage.$viewTemplate=I("pages/"+F.currentPage.id+"/page.html"),F.isPageDisplayed=!0,r.isReceipt||setTimeout(function(){F.flatPages.forEach(function(e){e!==F.currentPage&&(e.$viewTemplate=I("pages/page-spinner/page.html"))}),a.submitFailedValidation&&F.validate()},d.properties.transitionDelay+100),s.design)localStorage.setItem("design-page-id-"+c.Resource.formDesignVersionId,y.id);else{if(/^\//.test(C)||(C="/"+C),/\/$/.test(C)||(C+="/"),n={from:L&&L.id,to:F.currentPage.id},!p&&f&&!1===f(c.data,d,n))return;t(T).then(function(){t(100,!1).then(function(){a.dialogName||a.showAccessibleAlert(a.term(F.currentPage.id+".label")+" page has loaded")}),t(500,!1).then(function(){a.dialogName||v||(b?b(c.data,F.currentPage,n):D())}),r.isReceipt?F.flatPages.forEach(function(e){var t=o["sh_"+e.id],n=o["pageload_"+e.id];(t&&t(c.data,e)||!t)&&n&&n(c.data,e)}):h&&h(c.data,F.currentPage,n)}),a.submitFailedValidation&&F.validate(),window.gtag?gtag("event","page_view",{page_title:y.label,page_path:C+y.id}):window.ga&&(ga("set",{page:C+y.id,title:y.label}),ga("send","pageview")),w(y)&&l.navigation(y)}x.resolve()}var $,b=function(){var e=_asyncToGenerator(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(s.generated&&a.view.publishOptions&&a.view.publishOptions.useDpl)||y.$$pageLoaded){e.next=3;break}return e.next=3,a.loadPage(y.id);case 3:h();case 4:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}(),y=i||(e.$navPages?e.$navPages.filter(w)[0]:e),x=n.defer(),E=F.flatPages.indexOf(y),T=!F.policy.validate||E<F.index||!F.currentPage||s.design;if(!y.$navDisabled||f||c.Editor){if(F.uncollapsed){if(!i&&e.$navPages)return g(),void(e.$navSelected=!0);F.toggleMenu()}return f?t(10).then(b):t(function(){F.validate(T).then(function(e){a.validation.valid?b():a.gotoError(0)})},10),x.promise}},F.validate=function(e){var t;return t=e?n.when({valid:!0,errors:[]}):a.validate(F.policy.validate?F.currentPage:a.view,null,"P"),t.then(function(t){return a.validation=t,a.showMobileErrors=!a.validation.valid,!e&&t.valid&&w(F.currentPage)&&(a.completeSectionsOnSubmit=a.completeSectionsOnSubmit.filter(function(e){return e.id!==F.currentPage.id})),t})},F.chooseFlat=function(e,t,n){if(e)return e.$navGroup?F.choose(e.$navGroup,e,null,null,t,n):F.choose(e,null,null,null,t,n)},F.move=function(e){return F.chooseFlat(P(F.currentPage,e))},F.getVisiblePages=function(){return(F.flatPages||[]).filter(w)},F.pageLabel=function(e){var t=u.T[e.id]||a.items[e.id];return t?t.properties&&t.properties.menuText||t.htmlLabel||t.label:""},F.pageDescription=function(e){var t=y(F.tree),n=t.indexOf(e)+1;return["Step",n,"of",t.length,function(){return e.$navSelected?"current":n>F.index+1?"upcoming":e.$navVisited?"visited":"not visited"}()+" "+(!e.$navPages&&"page"||"page group")].join(" ")+","},s.design){var C,L=[],j=d.validChildren.filter(function(e){return/page/.test(e)})[0]||new Error("No page in nav-content valid children");0===d.rows[0].length&&c.Editor.createItem({type:j,label:"Page X",rows:[[]]},d,0,0),c.$watchCollection(function(){return C=r.children(d),C.concat(r.children(C).filter(function(e){return e.type===j}))},function(e){var t,n=localStorage.getItem("design-page-id-"+c.Resource.formDesignVersionId);f(),L&&(L.forEach(function(e){e()}),L=[]),F.flatPages.forEach(function(e,t){void 0!==e.properties.offMenu&&L.push(c.$watch(function(){return c.Pages.flatPages[t].properties.offMenu},function(){var e=F.flatPages[t];e.$navGroup?F.subStyle=F.isLeft?{}:{width:(e.$navPages?100/y(e.$navGroup.$navPages).length:0)+"%"}:x()}))}),(t=F.flatPages.filter(function(e){return e.id===n})[0])&&F.chooseFlat(t)}),c.$watch("Editor.selectedItem",function(e){var t;if(e&&F.flatPages&&F.currentPage!==e){do{F.flatPages.indexOf(e)>=0&&(t=e),e=e.$$parent}while(e&&!t);t&&t!==F.currentPage&&(t.$navGroup?F.choose(t.$navGroup,t,!0):F.choose(t,null,!0))}})}else f(),E.length&&function(){var t=r.children(E);F.fnList=t.map(function(t){var n={icon:t.properties.icon,label:t.label,click:function(){if(!this.disabled){var e=o["click_"+t.id];e&&e(c.data,t),F.isLeft||F.toggleMenu()}},disabled:!1,visible:!0},a=o["sh_"+t.id],i=o["us_"+t.id];return i&&e.$watch(function(){return i(c.data,t)},function(e){n.disabled=!e}),a&&e.$watch(function(){return a(c.data,t)},function(e){n.visible=e}),n})}(),function(){F.flatPages.concat(F.groups).forEach(function(n){var a=o["sh_"+n.id],i=o["us_"+n.id];a&&e.$watch(function(){return a(c.data,n)},function(e){n.$navVisible=e;var a=F.flatPages.filter(w);t(15).then(function(){e||F.flatPages.indexOf(n)!==F.index||F.move(!0)}),F.policy.restrict&&m(a),x(),n.$navGroup&&S(n.$navGroup),v(a),e||"immediate"!==n.clearHidden||h(n)}),i&&e.$watch(function(){return i(c.data,n)},function(e){n.$notEditable=n.$navDisabled=!e})})}()}return function(e,t){function n(){a.getItem(e,t).then(function(n){e.item=n,s.design&&a.dialog||(!s.design&&a.$Pages?e.Pages=a.$Pages:a.$Pages=n.$Pages=e.Pages=new d(e,n),e.blurAll=function(){t.find("input, select, textarea").blur()},e.showSpinner=function(e){t[e?"removeClass":"addClass"]("av-page-loaded")})})}s.design?a.onReload(n):n()}}])}),define("services/formresources/6306/widgets/jlr-checkbox/jlr-checkbox.js",["app"],function(e){e.ng.controller("CbxGroupController",["$scope","Form","$element",function(e,t,n){t.getItem(e,n).then(function(n){function a(e){var t=e.trim().replace(/[^A-Za-z0-9_\-]+/g,"_");return(isNaN(parseInt(t.charAt(0)))?"":"_")+t}n.$hasValue=function(e,t){return!(!t||""==t)&&Object.keys(t).some(function(e){return t[e]})},e.$watch(function(){return t.getPathData(n.properties.dataPath,e.data)},function(t){e.checkboxItems=[],""===e.data[n.id]&&(e.data[n.id]={}),angular.isArray(t)&&t.length>0&&t.forEach(function(t){(t[n.properties.labelField]||t[n.properties.labelField])&&e.checkboxItems.push({label:t[n.properties.labelField],xmlPath:a(t[n.properties.labelField])})})},!0)})}])}),define("services/formresources/6306/widgets/data-radio-group/data-radio-group.js",["app"],function(e){e.ng.directive("ddRadioGroup",["Form",function(e){return{scope:!0,link:function(t,n){e.getItem(t,n).then(function(n){t.$watch(function(){return e.getPathData(n.properties.dataPath,t.data)},function(e){t.groupItems=[],angular.isArray(e)&&e.length>0&&e.forEach(function(e){var a=e[n.properties.valueField];"boolean"==typeof a||a||(a=e[n.properties.labelField]),e[n.properties.labelField]&&t.groupItems.push({label:e[n.properties.labelField],value:a})})},!0)})}}}])}),define("services/formresources/6306/widgets/section-2/section-2.js",["app"],function(e){e.ng.directive("avSection2",["Form","Util","Resource",function(e,t,n){return{scope:!0,link:function(a,i){e.getItem(a,i).then(function(i){function r(){var r=n.design?e.items:a.T||e.items,o=r[i.id],s=i.properties.headinglevel,l=["h1","h2","h3","h4"].includes(s)?s:"h3",c=i.properties.hideTitle?" av-hidden":"",u="<"+l+' class="wdg-section-2-title'+c+'">'+t.sanitizer()(o.htmlLabel?o.htmlLabel:o.label)+"</"+l+">",d='<div class="wdg-section-2-info-text">'+t.sanitizer()(o.properties.infoText)+"</div>";a.headerHtml=u+d}r(),a.collapseButtonText=function(){var t=a.T||e.items;return a.isCollapsed[i.id]?t[i.id].properties.expandText:t[i.id].properties.collapseText},a.$on("translate",r),n.design&&(a.$watchGroup(["item.label","item.htmlLabel"],r),a.$watchCollection("item.properties",r))})}}}])}),define("services/formresources/6306/widgets/data-typeahead/data-typeahead.js",["app"],function(e){e.ng.directive("avTypeahead",["$q","Resource","Form","DynamicData","Calc","Transact","Util","$timeout",function(e,t,n,a,i,r,o,s){return{restrict:"A",scope:!0,link:function(l,c){n.getItem(l,c).then(function(u){if(!t.design){var d=function(){l.current=0,l.selected=!0,l.showList=!1,l.data[u.id]=""},p=function(){"service"==S&&(l.items=[])},f=function(){if(l.results.length)return l.results[l.current]},g=function(e){function t(e){return(angular.isArray(e)?e:i.delimitedSelection(e)).map(function(e){var t={};if(t[D]=e.label||e,t[R]=e.value||e,angular.isDefined(t))return t})}if(e){angular.isString(e)?0==e.indexOf("[{")?l.items=function(e){var t="";try{t=JSON.parse(e)}catch(e){return!1}return t}(e):l.items=t(e):angular.isArray(e)?l.items=e:l.items=t(e[Object.keys(e)[0]]);var a,r=l.items.filter(l.filterBy).length;0===r?(a=[n.term(u.id+".properties.noResultsFoundMsg")],u.properties.extraItemMessage&&a.push(n.term(u.id+".properties.noResultsFoundMsgIfExtra")),a=a.join(" ")):a=1===r?"1 "+n.term(u.id+".properties.oneResultFoundMsg"):r+" "+n.term(u.id+".properties.resultsFoundMsg"),m(a)}},v=function(t,i,o,s,c){P&&P.resolve(),P=e.defer(),l.showSpinner=!0,(u.properties.useTransactFunctions?r.formFunction(t,i,null,o):a.call(t,o,P.promise)).then(function(e){u.properties.useTransactFunctions&&(e=e.data[c]),s||n.fireRule("onSuccess",u,l.data,e),s?(n.setFieldDataFromResponse(u.properties.secondDataResultMappings,e,l.data),u.properties.enableProgressMsg&&n.showProgress(""),n.fireRule("onComplete",u,l.data)):g(e),l.showSpinner=!1},function(){throw s&&u.properties.enableProgressMsg&&n.showProgress(""),l.showSpinner=!1,new Error("Error calling data service.")})},h=function(e){var t=u.properties.extraItemMessage===e;"object"===(void 0===e?"undefined":_typeof(e))&&(e=e[D]);var n=t?e:["Result",l.current+1,"of",l.results.length,e].join(" ");m(n)},m=function(e){C.hide(),C.text(""),s(300,!1).then(function(){C.show(),C.text(e)})};l.filterBy=function(e){return"refData"!=S||"string"!=typeof l.data[u.id]||(angular.isString(e)||(e=e[D]),-1!=e.toLowerCase().indexOf(l.data[u.id].toLowerCase()))},l.handleSelection=function(e,t){if(t){if(0!==t.button)return;t.preventDefault(),t.stopPropagation()}if(e){if(l.data[u.id]=e[D]||e,pathResultLength>0&&n.setFieldDataFromResponse(F,e,l.data),n.fireRule("onListSelect",u,l.data),u.properties.secondDynamicDataServiceName){var a=n.convertToFieldDataMap(u.properties.secondInputFieldRefs,l.data);u.properties.enableProgressMsg&&n.showProgress(u.properties.progressMsg||"Please wait..."),v(u.properties.secondDynamicDataServiceName,u.properties.secondServiceVersion,a,!0,u.properties.secondResponseKey)}else n.fireRule("onComplete",u,l.data);m(l.data[u.id]+" selected"),l.selected=!0,l.showList=!1,l.setCurrent(null),p()}},l.isCurrent=function(e){return l.current==e},l.setCurrent=function(e){E&&"boolean"==typeof e&&!l.extraSelected?(l.extraSelected=e,l.current=null,l.listHovered=e):(l.current=e,l.listHovered="number"==typeof e,l.extraSelected=!1)},l.extraItemSelect=function(e){if(e){if(0!==e.button)return;e.preventDefault(),e.stopPropagation()}n.fireRule("onExtraItemSelect",u,l.data),l.data[u.id]="",l.selected=!0,l.setCurrent(null),p()},l.getItemName=function(e){var t=l.data[u.id].replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");if(-1!=I.indexOf("|")){var n=I.replace(/ /g,"").split("|");n=n.map(function(t){if(void 0!==e[t])return e[t]}),e=n.join(" | ")}return angular.isString(e)||(e=e[D]),e?e.replace(new RegExp("("+t+")","gi"),"<b>$1</b>"):""},l.onChangeSelection=function(e){if(l.showList=!0,"service"==S){if(!u.properties.DynamicDataServiceName)return console.log("Data Service Name is Blank");var t=u.properties.delayDDSCall||200,a=n.convertToFieldDataMap(u.properties.inputFieldRefs,l.data);e=l.data[u.id],e.length>=u.properties.minCharTrigger&&(clearTimeout(b),b=setTimeout(function(){v(u.properties.DynamicDataServiceName,u.properties.serviceVersion,o.extend({},{search:e},a),null,u.properties.responseKey)},t))}},l.onLabelButtonClick=function(){n.fireRule("onLabelButtonClick",u,l.data)};var w,b,P,y,x=u.properties.dataPath,S=u.properties.dataSource,D=u.properties.triggerName||"label",I=u.properties.suggestionListNames||D,R=u.properties.dataName||"value",F=u.properties.dataResultMappings,E=u.properties.extraItemMessage||!1,T=c.find("input"),C=c.find(".typeahead-alert");pathResultLength=F.length,l.items=[],l.current=null,l.listHovered=!1,l.showSpinner=!1,l.selected=!0,l.limit=function(){return parseInt(u.properties.itemLimit)>0?parseInt(u.properties.itemLimit):""}(),l.showList=!1,"refData"==S&&setTimeout(function(){w=n.prefill[x]||n.getPathData(x.replace("data.",""),l.data),g(w)},150),$(T).bind("keyup",function(e){if(void 0!=l.items&&(E||0!=l.items.length))switch(l.results=l.items.filter(l.filterBy),y=l.results.length,e.which){case 40:E&&0==y?l.extraSelected=!0:null===l.current?l.current=0:l.current===y-1&&E&&!l.extraSelected?(l.extraSelected=!0,l.current++):(l.extraSelected=!1,l.current=(l.current+1)%y),h(l.extraSelected?u.properties.extraItemMessage:l.results[l.current]),l.$digest();break;case 38:null===l.current?l.current=y-1:0===l.current&&E&&!l.extraSelected?l.extraSelected=!0:(l.extraSelected=!1,l.current=(l.current?l.current:y)-1),h(l.extraSelected?u.properties.extraItemMessage:l.results[l.current]),l.$digest();break;case 13:case 9:l.$apply(function(){l.extraSelected?l.extraItemSelect():y>0&&l.handleSelection(f())});break;case 27:e.stopPropagation(),l.$apply(function(){d()})}}),$(T).bind("blur",function(e){if(l.showList){l.showList=!1;var t=l.items.length&&o.find(l.items,D,e.target.value);t?l.handleSelection(t):u.properties.clearWhenNotMatched&&(l.data[u.id]="",e.target.value=""),p()}})}})}}}])}),define("services/formresources/6306/widgets/section/section.js",["app"],function(e){e.ng.directive("avSection",["Form",function(e){return{scope:!0,link:{pre:function(t,n){e.getItem(t,n).then(function(e){t.item=e,t.$watchCollection("Pages.flatPages",function(n){n&&n.forEach(function(n){n.id===e.id&&(t.page=n)})})})}}}}])}),define("services/formresources/6306/widgets/repeat/repeat.js",["app"],function(e){e.ng.directive("avRepeat",["Form","Resource","Validation",function(e,t,n){return{scope:!0,link:{pre:function(a,i){e.getItem(a,i).then(function(i){function r(e){var t=0;void 0!==e&&e.forEach(function(n){n.$p=a.data,n.$r=e,n.$i=t++})}var o=a.data[i.id];if(Array.isArray(o)||(o=a.data[i.id]=t.generated&&0===i.properties.initialItems?[]:[n.defaultData(i)]),!t.design){for(;o.length<i.properties.minItems;)o.push(n.defaultData(i));for(;i.properties.maxItems&&o.length>i.properties.maxItems;)o.pop()}t.design&&a.$watch("item.id",function(e,t){e!==t&&(a.data[e]=a.data[t],delete a.data[t])}),a.$watchCollection("data."+i.id,r),a.item=i,i.$getRepeatData=a.getRepeatData=function(){return a.data[i.id]},i.$addItem=a.addItem=function(t){return e.addRepeatInstance(i,a.data[i.id],t)},i.$deleteItem=a.deleteItem=function(t){e.removeRepeatInstance(i,a.data[i.id],t)},i.setInstanceCount=function(t){e.setInstanceCount(i,a.data[i.id],t)},i.defaultData=n.defaultData(i),Object.keys(a.data).forEach(function(t){var n=e.items[t],i=n&&n.repeatingData,o=a.data[t];i&&Array.isArray(o)&&o.length>0&&!o[0].$r&&r(a.data[t])})})}}}}])}),require(["services/formresources/6306/widgets/page-controller/page-controller.js","services/formresources/6306/widgets/section/section.js","services/formresources/6306/widgets/section-2/section-2.js","services/formresources/6306/widgets/jlrDropdown/jlrDropdown.js","services/formresources/6306/widgets/data-typeahead/data-typeahead.js","services/formresources/6306/widgets/jlr-checkbox/jlr-checkbox.js","services/formresources/6306/widgets/data-radio-group/data-radio-group.js","services/formresources/6306/widgets/repeat/repeat.js"]);