var CustomChannel=CustomChannel?(console.warn("Já existe uma outra instância do CustomChannel na página."),CustomChannel):function(){function scriptUrlParam(e,t){const n=new URL(document.currentScript.src).searchParams;return!!n&&(n.get(e)||t)}const t=window.top!==window.self,n=scriptUrlParam("ccid"),o=scriptUrlParam("urlPay",!1);var a=!1,i=scriptUrlParam("rbclicod"),s=[],r=0,c=[],d=[],l="",u=[],p=new URL(document.currentScript.src).origin+"/",f=0,m=0,h=!1,g=scriptUrlParam("localUrl",""),v=[],b=!1,y=document.URL;document.cookie="ckcookie=0",-1==document.cookie.indexOf("ckcookie")&&(b=!0);var C=[n,"page"],O=!0;if(!b)O=sessionStorage.hasOwnProperty("newVisitor");var w=[],P=[],E={},S=idGenerator(),T=!1;const I={intlTelInputCss:"",intlTelInput:"",materializeCss:"",materialIcons:"",actionsForm:"",materialize:""};fetchHandler(`${p}css/intlTelInput.min.css`,"GET",e=>{I.intlTelInputCss=e}),fetchHandler(`${p}js/intlTelInput.min.js`,"GET",e=>{I.intlTelInput=e}),fetchHandler("https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css","GET",e=>{I.materializeCss=e}),fetchHandler("https://fonts.googleapis.com/icon?family=Material+Icons","GET",e=>{I.materialIcons=e}),fetchHandler(`${p}js/ActionsForm.min.js`,"GET",e=>{I.actionsForm=e.replace("{{urlPay}}",o)}),fetchHandler(`${p}js/materialize.mod.min.js`,"GET",e=>{I.materialize=e}),""===i&&(i=RBTracking.getHostClient());const A="{%}",k="{#}",D="{?}";var j;function getCustomChannelsData(){if(!h){h=!0;var e={isPreview:f,currentUrl:document.URL,authKey:i};1==f&&(delete e.authKey,e.domain=g,e.CustomChannelId=m),requestHandler(p+"api/getCustomChannel",e,"POST",function(e){e=e.data,h=!1,Array.isArray(e)?(e.forEach(function(e){!function(e,t){t.etapas.sort(compare);var n={bodyData:e,settings:t};s.push(n)}(e.ChannelData,e.FormData)}),function(){const e=document.createElement("div");s.forEach(function(n,o){var i="",s="",r=n.bodyData,c=n.settings;if(c||1!=r.idTipoCanalPersonalizado){if(c.etapas.forEach(function(e){e.campos.forEach(function(e){var t=e.atributo,n=e.nome;"Estado"===n&&e.opcoes.forEach(function(e){P.push(e.titulo)}),t.indexOf("camposPersonalizados")>-1&&(t=(t=t.split("."))[0]+"."+t[2]+(e.regra.indexOf("logico")>-1?D+"bool":""));var o=c.idCanalPersonalizado+A+n+k+t;-1==w.indexOf(o)&&w.push(o),"evento.codOferta"===t&&e.camposVinculados.forEach(function(e){w.push(c.idCanalPersonalizado+A+e.nome+k+e.atributo)})})}),"string"!=typeof r.codigoHtml)return"html is necessary";switch(i+=setStyleOnBody(r.codigoCss),i+=setStyleOnBody(r.codigoAvancadoCss),i+=r.codigoHtml,r.idTipoCanalPersonalizado){case"1":if(a)break;void 0!==c.editorInformacaoPagina&&(b=c.editorInformacaoPagina[0].tituloPagina,(y=document.getElementsByTagName("title")).length>0?y[0].text=b:document.head.innerHTML+=""+b+"",setMetaOnHead("description",c.editorInformacaoPagina[0].descricao),setMetaOnHead("viewport","width=device-width, initial-scale=1.0"),document.head.innerHTML+=(u="icon",m="32x32",h="image/png",g=c.editorInformacaoPagina[0].favIcon,'')),injectLibrariesById(r.idCanalPersonalizado),document.head.innerHTML+=s;const n=document.createElement("div");n.innerHTML=i,document.body.appendChild(n),setAdvancedJsHead(r.codigoAvancadoJavascriptHead),setAdvancedJsBody(r.codigoAvancadoJavascriptBody),d=r.idCanalPersonalizado,l=setInterval(function(){("undefined"!=typeof RBTracking||t)&&(sendEventOnShowChannel(d,"page"),clearInterval(l))},500);break;case"2":t&&1!=f||(idChannel=r.idCanalPersonalizado,e.appendChild(function(e,t,n){const o=document.createElement("div");o.id="rubeusModalCustomChannel"+e,o.className="rubeus-modal",o.style.display="none";const a=document.createElement("div");a.className="rubeus-div-iframe";const i=document.createElement("span");i.id="rubeusModalClose"+e,i.className="rubeus-close";const s=document.createElement("img");s.src="https://docs.rubeus.com.br/assets/images/baseline_clear_white_48dp.png",s.style="width: 32px";const r=document.createElement("iframe");return r.id="#customChannel"+e,r.className="rubeus-custom-channel-iframe",r.style="max-width: "+n+"px; max-height: "+t+"px;",r.src=p+"page/customChannelFrame/"+e,i.appendChild(s),a.appendChild(i),a.appendChild(r),o.appendChild(a),o}(idChannel,c.editorPopup[0].alturaPopup,c.editorPopup[0].larguraPopup)),ed={body:i,jsBody:r.codigoAvancadoJavascriptBody,head:s,jsHead:r.codigoAvancadoJavascriptHead},v[idChannel]=ed)}var d,l,u,m,h,g,b,y;!function(e){e.etapas.forEach(function(e){e.campos.forEach(function(e){if("evento.codOferta"===e.atributo)e.camposVinculados.length>0&&e.camposVinculados.forEach(function(e){setFirstFieldToLoading(e.atributo)}),setFirstFieldToLoading(e.atributo)})})}(c),function(){var e=document.querySelectorAll('div[name="anchor"]');if(e.length>0)for(const t in e)if(e.hasOwnProperty(t)){e[t].addEventListener("click",function(){var e=this.getAttribute("anchorId"),t=this.getAttribute("behavior");if(e){var n=document.getElementById(e);n&&window.scrollTo({top:n.offsetTop,behavior:t})}})}}(),function(){var e=document.querySelectorAll('div[name="cta"]');if(e.length>0)for(const t in e)if(e.hasOwnProperty(t)){const n=e[t],o=n.getAttribute("cta-script");n.setAttribute("cta-script",""),scriptNode=createScriptNode(o),scriptNode&&n.appendChild(scriptNode)}}()}else document.body.innerHTML=r.codigoHtml}),document.body.insertAdjacentElement("beforeend",e),document.body.insertAdjacentElement("beforeend",function(e,t,n,o){const a=document.createElement("link");return a.rel=e,a.size=null,a.type=n,a.href=o||null,a}("stylesheet",0,"text/css",p+"css/PatternStyle.min.css"))}()):console.warn("Your form template has not been uploaded!",e)},erroRequestChannel),setInterval(function(){y!=document.URL&&y!=document.URL.split("#")[0]&&(y=document.URL,r=0,a=!0,s=[],function(){const e=document.querySelectorAll(".rubeus-modal")[0];e&&e.parentElement.remove()}(),getCustomChannelsData())},500)}}function compare(e,t){return parseInt(e.ordem)parseInt(t.ordem)?1:0}function getOffers(e,t){var n={isPreview:f,id:e};1==f?n.domain=g:n.authKey=i;const o=function(e){const t=window.location.search;return new URLSearchParams(t).get(e)||""}("idoferta");o&&(n.offers=o.split(",")),requestHandler(p+"api/getOffersAllowed",n,"POST",function(n){n.success&&(u[e]=n.dados,setSelects({attribute:"evento.codOferta",data:n.dados,id:e},t))},erroRequestOffers)}function returnChannelOffers(e){return u[e]?u[e]:[]}function setSelects(e,t){switch(t){case"1":ActionsForm.setSelectOptions(e.attribute,e.data);break;case"2":sendDown(e,"SD",e.id)}}function settingsCustomChannel(e,t){switch(e.isPreview=f,e.CustomChannelType=t,t){case"1":ActionsForm.setSettings(e);break;case"2":1==e.editorPopup[0].gatilhoRolagem&&(n=e.idCanalPersonalizado,(o=[])[n]=setInterval(function(){window.innerHeight/2+window.scrollY>=document.body.offsetHeight/2&&(showPopup(n,"center"),clearInterval(o[n]))},100)),1==e.editorPopup[0].gatilhoIntencaoSaida&&escapePopup(e.idCanalPersonalizado),1==e.editorPopup[0].gatilhoTempoDecorrido&&function(e,t){setTimeout(function(){showPopup(t,"timed")},1e3*e)}(e.editorPopup[0].tempoDecorrido,e.idCanalPersonalizado),sendDown(e,"StartActionsForm",e.idCanalPersonalizado)}var n,o;return e.etapas.forEach(function(n){n.campos.forEach(function(n){switch(n.atributo){case"pessoa.cidade":!function(e,t){if(""==l){var n={isPreview:f};1==f?n.domain=g:n.authKey=i,requestHandler(p+"api/getCities",n,"POST",function(n){n.success&&(l=n.dados,setSelects({attribute:"pessoa.cidade",data:n.dados,id:e},t))},erroRequestCities)}else setSelects({attribute:"pessoa.cidade",data:l,id:e},t)}(e.idCanalPersonalizado,t);break;case"evento.codOferta":getOffers(e.idCanalPersonalizado,t);break;default:n.temOpcoesPredefinidas&&setSelects({attribute:n.atributo,data:n.opcoes,id:e.idCanalPersonalizado},t)}})}),0}function erroRequestOffers(e){console.warn("Nenhuma oferta disponível para este canal",e)}function erroRequestCities(e){console.error("Nenhuma lista de cidades encontrada",e)}function erroRequestChannel(e){h=!1,console.warn("Nenhum popup disponível para esta página")}function getCustomChannel(e=customChannelId){return customChannel=[],s.forEach(function(t){t.bodyData.idCanalPersonalizado!=e||(customChannel=t)}),customChannel}function createScriptNode(e){var t=document.createElement("script"),n=function(e){var t=e.match(/(\S+)=(?:(['"])([\s\S]*?)\2|([^\s>]+))/gim),n=[];return!!(Array.isArray(t)&&t.length>0)&&(t.forEach(function(e){(e=e.split("='"))[1]=e[1].split("'")[0],n.push({key:e[0],value:e[1]})}),n)}(e);return!!n&&(n.forEach(function(e){t.setAttribute(e.key,e.value)}),t.setAttribute("defer",""),t)}function setFirstFieldToLoading(e){const t=document.getElementsByName(e);t.length>0&&(t.item(0).options[0].innerText="Carregando...")}function setMetaOnHead(e,t){document.head.innerHTML+=''}function setAdvancedJsBody(e){"string"==typeof e&&document.body.appendChild(createScriptToAppend(e))}function setAdvancedJsHead(e,t=!0){"string"==typeof e&&document.head.appendChild(createScriptToAppend(e,t))}function createScriptToAppend(t,n=!0){var o=document.createElement("script");return o.text=t,n&&(o.text=function(t){return`\n try {\n ${t}\n } catch (e) {\n console.warn('Script personalizado não foi executado, pois, contem os seguintes erros: ', e);\n ${"qEimxMvC8B46HPYsg2d2"==i&&8==m?enviaDebug(e):""}\n }`}(t)),o}function setStyleOnBody(e){return"string"==typeof e?"":""}function setStyleHead(e){const t=document.createElement("style");t.textContent=e,document.head.appendChild(t)}function escapePopup(e){"function"!=typeof document.body.onmouseleave?document.body.onmouseleave=function(){showPopup(e,"escape"),document.body.onmouseleave=null,d.length>0&&escapePopup(d.shift())}:-1==d.indexOf(e)&&d.push(e)}function showPopup(e,t,o){if(o||(o=""),0==r){C=[e,t],!b&&window.localStorage.getItem("popupShown"),sendEventOnShowChannel(e,t),r=e;var a=document.getElementById("rubeusModalCustomChannel"+e);if(null==a)return r=0,"not a popup";if(document.body.style.overflow="hidden",a.style.display="block",document.getElementById("rubeusModalClose"+e).onclick=function(){!function(e){var t=document.getElementById("rubeusModalCustomChannel"+e);getOffers(e,"evento.codOferta"),r=0,t.className="rubeus-modal rubeus-modal-off",document.body.style.overflow="auto",C=[n,"page"],sendDown(u[e],"CustomOffer",e),setTimeout(function(){t.style.display="none",t.className="rubeus-modal",c.length>0&&(showPopup(c[0][0],c[0][1],c[0][2]),c.shift())},580)}(e)},""!==o){for(index in filteredOffer=[],u[e])u[e][index].codOfertaCurso==o&&filteredOffer.push(u[e][index]);filteredOffer.length>0&&sendDown(filteredOffer,"CustomOffer",e)}}else c.push([e,t,o])}function sendEventOnShowChannel(e,t){var n=getCustomChannel(e);if(Array.isArray(n))return!1;var o=0;switch(t){case"center":o=n.settings.idTipoEventoRolagem;break;case"timed":o=n.settings.idTipoEventoTempo;break;case"escape":o=n.settings.idTipoEventoFuga;break;case"page":o=n.settings.idTipoVisualizouPagina}RBTracking.sendEvent({tipo:o,origem:n.settings.idOrigem})}function idGenerator(){var e=window.navigator,t=window.screen,n=e.mimeTypes.length;n+=e.userAgent.replace(/\D+/g,""),n+=e.plugins.length,n+=t.height+t.width+t.pixelDepth+t.colorDepth;for(var o="",a=0;a<32;a++)o+=n.charAt(Math.floor(Math.random()*n.length));return o+1*new Date}(j=document.URL.split("/")).indexOf("editar-modelo-de-formulario")>-1&&(f=1,m=j[j.length-1],C=[m,"page"],""===g&&(g=j[0]+"//"+j[2]+"/")),function(){if(document.body)getCustomChannelsData();else{var e=new MutationObserver(function(){document.body&&(getCustomChannelsData(),e.disconnect())});e.observe(document.documentElement,{childList:!0})}}();var z={eventData:{},currentStep:0,external_id:0,steps:0,PopupId:0};function setObjectToSubmit(e,t){t||(t=0),z.currentStep=e.currentStage;const n=getCustomChannel(e.channelId);let o=n.settings.etapas;if(z.steps=o.length-1,o=o[z.currentStep],z.PopupId=t,e.contato!={}){!function(e,t){let n=t.editorAcaoFormulario&&t.editorAcaoFormulario[0];if(!n)return;1===Number(n.tipoContato)?e.naturezaJuridica=1:2===Number(n.tipoContato)&&(e.naturezaJuridica=2)}(e.contato,n.settings),0==Object.keys(e.contato.camposPersonalizados).length&&delete e.contato.camposPersonalizados,0!=z.external_id&&(e.contato.id=z.external_id);RBTracking.sendData(e.contato,function(e){CustomChannel.callbackListener({type:"contact",data:{success:!0,id:e.data.id,objectResponse:e}})},function(e){CustomChannel.callbackListener({type:"contact",data:{success:!1,objectResponse:e}})})}if(e.processo!={}){var a=e.processo;for(var i in a)"null"!==a[i]&&null!==a[i]||delete a[i];if(e.processo.descricao=function(e){var t="

";s.forEach(function(t){if(t.settings.idOrigem==e.contato.origem)return customChannelId=t.settings.idCanalPersonalizado});var n=createObjectForDescription(e.processo),o=createObjectForDescription(e.contato),a=Object.assign(o,n);for(var i in a){var r=a[i];w.forEach(function(e){const n={key:"",label:"",channel:"",isBoolean:""};if(e.indexOf("estadoCidade.estado")>-1?(n.key=e.split(k)[1].split(".")[2].split(D)[0],n.label=e.split(k)[0].split(A)[1],n.channel=e.split(A)[0],n.isBoolean=!!e.split(k)[1].split(".")[1].split(D)[1]):(n.key=e.split(k)[1].split(".")[1].split(D)[0],n.label=e.split(k)[0].split(A)[1],n.channel=e.split(A)[0],n.isBoolean=!!e.split(k)[1].split(".")[1].split(D)[1]),n.key===i&&n.channel==customChannelId){if(-1==n.key.indexOf("campopersonalizado"))switch(n.label){case"Cidade/Estado":l.forEach(function(e){e.id!=r||(r=e.titulo)});break;case"Estado":r=P[a[i]-1];break;case"Sexo":r=2==r?"Feminino":"Masculino";break;case"Natureza jurídica":r=2==r?"Jurídica":"Física";break;default:description=searchDescription(n.key,r,u[customChannelId]),0!=description&&(r=description)}n.isBoolean&&(r="1"==r?"Verdadeiro":"Falso"),Array.isArray(r)&&(r=r[0]instanceof File?joinValuesFromArrayOfObjects(r,"name"):r.join(", ")),r instanceof File?r=r.name:"object"==typeof r&&(r=r[i]),r&&""!==r||(r="vazio"),t+=''+n.label+": "+r+"
"}})}return t+="

"}(e),e.processo.codOferta&&(e.processo.curso=e.processo.codOferta),e.processo.data){const t=n.settings.nomeCanal.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/([^\w]+|\s+)/g,"_").replace(/\-\-+/g,"_").replace(/(^-+|-+$)/,"")+"_data_atividade";e.processo.tipoData=t}if("1"===getCustomChannel().settings.utilizaCodRegistro&&(e.processo.codRegistro=S),e.processo!={}&&e.processo.codOferta)if(0!=t){sendDown(Object.assign({},e.processo),"Pay",t)}else ActionsForm.setProcessData(Object.assign({},e.processo));!function(e){E={unidade:e.unidade||E.unidade||null,nivelEnsino:e.nivelEnsino||E.nivelEnsino||null,modalidade:e.modalidade||E.modalidade||null,curso:e.curso||E.curso||null,processoSeletivo:e.processoSeletivo||E.processoSeletivo||null,localOferta:e.localOferta||E.localOferta||null}}(e.processo),function(e){e.unidade=e.unidade||E.unidade,e.nivelEnsino=e.nivelEnsino||E.nivelEnsino,e.modalidade=e.modalidade||E.modalidade,e.curso=e.curso||E.curso,e.processoSeletivo=e.processoSeletivo||E.processoSeletivo,e.localOferta=e.localOferta||E.localOferta}(e.processo),z.eventData={eventData:e.processo,eventType:o.tipoEvento}}}function createObjectForDescription(e){var t=Object.assign({},e);return"object"==typeof t.camposPersonalizados&&delete(t=Object.assign(t,t.camposPersonalizados)).camposPersonalizados,t}function joinValuesFromArrayOfObjects(e,t){return e.map(e=>e[t]).join(", ")}function searchDescription(e,t,n){const o={curso:{title:"tituloCurso",field:"idCurso"},codOferta:{title:"tituloOfertaCurso",field:"idOfertaCurso"},unidade:{title:"tituloUnidade",field:"idUnidade"},nivelEnsino:{title:"tituloNivelEnsino",field:"idNivelEnsino"},modalidade:{title:"tituloModalidade",field:"idModalidade"},processoSeletivo:{title:"tituloProcessoSeletivo",field:"idProcessoSeletivo"},localOferta:{title:"tituloLocalOferta",field:"idLocalOferta"}};if(-1==["curso","codOferta","unidade","nivelEnsino","modalidade","processoSeletivo","localOferta"].indexOf(e)||!Array.isArray(n))return!1;var a="";return n.forEach(function(n){const i=o[e];n[i.field]==t&&(a=n[i.title])}),a}function sendDown(e,t,n){var o={type:t,data:e},a=document.getElementById("#customChannel"+n);a&&a.contentWindow.postMessage(o,"*")}const H={};function injectLibrariesById(e){H[e]=setInterval(()=>{if(""!=I.intlTelInputCss&&""!=I.intlTelInput&&""!=I.materialIcons&&""!=I.materializeCss&&""!=I.actionsForm&&""!=I.materialize){const t=getCustomChannel(e);if(Array.isArray(t)||!t.bodyData)return void clearInterval(H[e]);"1"==t.bodyData.idTipoCanalPersonalizado?(setStyleHead(I.intlTelInputCss),setStyleHead(I.materialIcons),setAdvancedJsHead(I.intlTelInput,!1),setAdvancedJsHead(I.materialize,!1),setAdvancedJsHead(I.actionsForm,!1),ActionsForm.iniciaInputTel()):sendDown(I,"LibsInjection",e),settingsCustomChannel(t.settings,t.bodyData.idTipoCanalPersonalizado),clearInterval(H[e])}},500)}function requestHandler(e,t,n,o,a){"function"!=typeof o&&(o=function(e){return e}),"function"!=typeof a&&(a=function(e){return e});var i=new XMLHttpRequest;i.open(n,e,!0),i.setRequestHeader("Content-Type","application/json");i.onreadystatechange=function(){var e;4==i.readyState&&(200==i.status?""!=(e=i.responseText)&&("string"==typeof e&&(e=JSON.parse(e)),e.success?o(e):a(e)):a(i.responseText))},i.send(JSON.stringify(t))}async function fetchHandler(e,t,n){const o=await fetch(e,{method:t});o.headers.get("content-type")&&o.text().then(function(e){n(e)})}return window.addEventListener("message",function(e){var t=e.data;switch(t.type){case"CC":var n=t.data;v[n]&&(sendDown(v[n],"CC",n),v[n]=!0,injectLibrariesById(n)),T=!0;break;case"objectToSubmit":setObjectToSubmit(t.data,t.data.channelId);break;case"offers":sendDown(returnChannelOffers(t.data),"CustomOffer",t.data)}},!1),{callbackListener:function(e){switch(e.type){case"contact":if(e.data.success){O&&sendEventOnShowChannel(C[0],C[1]),0==z.external_id&&(z.external_id=e.data.id);var callback=function(e){CustomChannel.callbackListener({type:"event",data:{success:e.success,objectResponse:e}})};RBTracking.sendEvent(z.eventData,callback,callback),z.steps==z.currentStep&&(z.external_id=0,E={},S=idGenerator(),O=!0,b||sessionStorage.setItem("newVisitor",!0))}else 0!=r?sendDown(e.data.objectResponse,"contact",r):ActionsForm.callbackError(e.data.objectResponse);break;case"event":z.PopupId&&0!=z.PopupId?sendDown(e.data.success,"event",z.PopupId):e.data.success?ActionsForm.callbackNextStage():ActionsForm.callbackError(e.data.objectResponse)}},setObjectToSubmit,showPopup,loadCustomJs:function(){s.forEach(e=>{switch(e.bodyData.idTipoCanalPersonalizado){case"1":setAdvancedJsHead(e.bodyData.codigoCookieJavascriptHead),setAdvancedJsBody(e.bodyData.codigoCookieJavascriptBody);break;case"2":if(!t){sendDown({jsCookieHead:e.bodyData.codigoCookieJavascriptHead,jsCookieBody:e.bodyData.codigoCookieJavascriptBody},"LgpdStatus",e.bodyData.idCanalPersonalizado)}}})},returnChannelOffers,channelsLoaded:()=>T}}();