"use strict";const WIDGET_GENERATOR_DEBUG=!1;let OCULAR_SESSION_CAMMER_NAME=null,OCULAR_WIDGET_READY=!1;class OcularWidget{constructor(){window.addEventListener("message",function(t){if("object"==typeof t?.data)return!1;this.receiver(t)}.bind(this),!1),this.STORAGE_NAME="ocular-solution-widget",this.siteBody=document.querySelector("body"),this.container,this.iFrame,this.toolbar,this.togglerButtonElement,this.popUp,this.setDefaultConfig(),this.getDevice()}stringEndsWith=(t,e)=>t.at(-1)===e;urlOrigin=()=>{let t=`${location.hostname.indexOf("www")?location.hostname:location.hostname.substring(4)}${location.pathname}`;return t=this.stringEndsWith(t,"/")?t:`${t}/`,t+=`${location.search}${location.hash}`,t};async ajaxRequest(t){return"object"==typeof t&&new Promise(((e,i)=>{try{const s=this.urlOrigin();t.params.url=s,"GET"===t.method&&(t.route+="?"+Object.keys(t.params).map((e=>`${e}=${encodeURIComponent(t.params[e])}`)).join("&"));const a=new XMLHttpRequest;a.open(t.method,`${OCULAR_API_URL}/${t.route}`,!0),a.setRequestHeader("X-Requested-With","XMLHttpRequest"),a.onload=()=>{if(200===a.status){const t=JSON.parse(a.responseText);e(t)}else{const t={status:a.status,statusText:a.statusText};i(t)}};const r=Object.keys(t.params),o=new FormData;r.map((e=>{o.append(e,t.params[e])})),a.send(o)}catch(t){this.handleError(t,"ajaxRequest")}}))}setDefaultConfig(t){this.widgetIcon=t&&t.toggler&&t.toggler.image&&t.toggler.image.src?t.toggler.image.src:scriptOcular.dataset.image?scriptOcular.dataset.image:`${OCULAR_BASE_URL}/service/ocular/images/widgeticon.svg`;const e=t&&t.primaryColor?t.primaryColor:"#204DEF";this.defaultAttrs={width:360,height:t&&t.height?t.height:630,"border-radius":t&&t.borderRadius?t.borderRadius:"8px",margin:20,"margin-x":t&&t.marginX?t.marginX:20,"margin-y":t&&t.marginY?t.marginY:20,"primary-color":e,"toolbar-height":0,align:"right","dark-mode":!0,border:"0px solid #E6E6E6","z-index":t&&t.zIndex?t.zIndex:"999999",toggler:{width:t&&t.toggler&&t.toggler.width?t.toggler.width:70,height:t&&t.toggler&&t.toggler.height?t.toggler.height:70,"border-radius":t&&t.toggler&&t.toggler.borderRadius?t.toggler.borderRadius:"50%",color:t&&t.toggler&&t.toggler.color?t.toggler.color:e,"box-shadow":!t||!t.toggler||void 0===t.toggler.boxShadow||t.toggler.boxShadow,image:{width:t&&t.toggler&&t.toggler.image&&t.toggler.image.width?t.toggler.image.width:45,height:t&&t.toggler&&t.toggler.image&&t.toggler.image.height?t.toggler.image.height:45}}},t&&this.updateStyles()}reTry(){location.reload(!0)}updateStyles(){this.setOcularTogglerStyle(),this.setContainerStyle(),this.setFrameStyle(),this.setPopUpStyle(),this.setPopUpProgressStyle(),this.checkSiteDimensions(),this.setTogglerConfig()}setTogglerConfig(){if(!this.buttonIconElement)return!1;this.buttonIconElement.width=this.defaultAttrs.toggler.image.width,this.buttonIconElement.height=this.defaultAttrs.toggler.image.height,this.buttonIconElement.src=this.widgetIcon}getClassList(t){return{ocGoogleAnalitycs:ocGoogleAnalitycs,analitycsStorage:analitycsStorage,ocularWidget:ocularWidget,mainService:mainService,organization:organization,questionnary:questionnary,ocularStorage:ocularStorage,widgetIndentificator:widgetIndentificator}[t]}messageFunction(t){if(!t||"string"!=typeof t||t.includes("webpack"))return!1;try{const e=t.split("(")[0],i=t.slice(`${e}(`.length,-1),s=this.getClassList(e.split(".")[0]),a=e.split(".")[1],r=JSON.parse(`[${i}]`);"function"==typeof s[a]&&s[a](...r)}catch(e){Function(t)()}}receiver(t){if(t.origin!==OCULAR_APP_URL)return!1;const e=t.data;this.messageFunction(e)}crossDomainMessage(t){try{const e=document.querySelector("iframe#ocular-widget-iframe");e.contentWindow&&e.contentWindow.postMessage(t,OCULAR_APP_URL)}catch(t){}}emitMessage(t,e=null){try{["is-ready","minimized","hidden","opened","button-displayed","closed","call-started","call-ended","scheduled-success"].includes(t)&&window.parent.postMessage({type:"ocular-widget-event",msg:t,data:e})}catch(t){}}cleanHistory(t){try{history.pushState({},null,t)}catch(t){}}setWidgetParams(){const t=new URLSearchParams(location.search);t.get("ocularSessionId")?this.params.set("ocularSessionId",t.get("ocularSessionId")):t.get("ocularLinkSessionId")?(this.params.set("ocularLinkSessionId",t.get("ocularLinkSessionId")),this.params.set("ocularCustomer",t.get("ocularCustomer")),this.params.set("ocularLinkStatus",t.get("ocularLinkStatus"))):t.get("ocularStreaming")&&(this.params.set("ocularStreaming",t.get("ocularStreaming")),this.cleanHistory(`${location.origin}${location.pathname}`)),t.get("ocularOriginalUrl")&&this.cleanHistory(t.get("ocularOriginalUrl")),t.has("ocularWidgetCode")&&this.params.set("ocularWidgetCode",t.get("ocularWidgetCode"))}urlSearchParams(){this.params=new URLSearchParams(""),this.params.set("title",document.querySelector("head title")?document.querySelector("head title").innerHTML:""),this.params.set("hostname",location.hostname),this.params.set("origin",location.origin),this.params.set("pathname",location.pathname),this.params.set("href",location.href),this.params.set("search",location.search),this.params.set("hash",location.hash);const t=mountOcular.widgetCode??null;return t&&this.params.set("organizationCode",t),this.setWidgetParams(),this.params.toString()}setStorage(){this.storageData=localStorage.getItem(this.STORAGE_NAME)?JSON.parse(localStorage.getItem(this.STORAGE_NAME)):null}updateStorageData(){navigator.cookieEnabled&&(localStorage.setItem(this.STORAGE_NAME,JSON.stringify(this.widgetData)),this.storageData=this.widgetData)}initializeStorageData(t){navigator.cookieEnabled&&this.setStorage(),this.widgetData={state:!t&&this.storageData&&this.storageData.state?this.storageData.state:"minimized"},this.updateStorageData()}handleError(t,e){t.name,t.message}init(){return new Promise(((t,e)=>{this.createOcularToggler(),this.createPopUp(),this.createOcularContainer(),this.setDarkMode(this.defaultAttrs["dark-mode"]),this.align(this.defaultAttrs.align),this.initializeStorageData(!1),t("success")}))}restore(){"open"===this.widgetData.state&&this.show(!0)}setCustomer(t){let e=localStorage.getItem(ocularStorage.STORAGE_NAME);e=e?JSON.parse(e):null,e.room.customer=t,ocularStorage.updateStorageData(e);try{this.crossDomainMessage(`ocularStorage.setCustomer(${JSON.stringify(t)})`)}catch(t){}}getCustomer(){let t=localStorage.getItem(ocularStorage.STORAGE_NAME);return t=t?JSON.parse(t):null,t?t.room.customer:null}setLocale(t){if(!["en","es","pt","tr"].find((e=>e===t)))return!1;let e=localStorage.getItem(ocularStorage.STORAGE_NAME);e=e?JSON.parse(e):null,e.widget.lang=t,ocularStorage.updateStorageData(e);try{this.crossDomainMessage(`ocularStorage.setLocale(${JSON.stringify(t)})`)}catch(t){}}ocularCallEnded(){try{ocularCallEnded()}catch(t){}}setBuyOrderSessionId(t){try{ocularOrderTrack.setSessionId(t)}catch(t){}}setSessionCammerVar(t){OCULAR_SESSION_CAMMER_NAME=t?t.name:null}toggle(t=null){if(!this.container)return!1;null===t?this.togglerButtonElement.classList.toggle("active"):t?this.togglerButtonElement.classList.add("active"):this.togglerButtonElement.classList.remove("active"),this.toggleContainer(),this.widgetData.state=this.container.dataset.state,this.updateStorageData(),"open"===this.widgetData.state&&(this.iFrame||this.createOcularFrame())}parentToggle(){"open"===this.container.dataset.state?this.hide():this.show(!0)}async show(t,e=!1,i=!1,s=!0){const a=organization.widgetBasic;if(!a)return!1;if(!this.container)return!1;e&&"open"===this.container.dataset.state&&(t=!0),this.showToggler(s),!t&&s&&this.emitMessage("button-displayed"),t&&(this.togglerButtonElement.classList.add("active"),this.toggleContainer()),this.container.dataset.state=t?"open":"minimized",this.widgetData.state=this.container.dataset.state,this.updateStorageData(),"open"!==this.widgetData.state&&!i||this.iFrame||this.createOcularFrame();const r=a.attributes;setTimeout((()=>{r.length&&!widget.popupDisplayed()&&widget.showPopUpMessage(r)}),6e3)}hide(){if(!this.container)return!1;this.showToggler(!1),this.togglerButtonElement.classList.remove("active"),this.toggleContainer(!0),this.container.dataset.state="hidden",this.showPopUp(!1),this.widgetData.state=this.container.dataset.state,this.updateStorageData()}closeEvent(){this.emitMessage("closed")}align(t){if(!this.container)return!1;switch(t){case"left":this.container.style.right="auto",this.container.style.left="0px",this.container.style["-webkit-transform"]="translateX(0%)",this.container.style.transform="translateX(0%)",this.popUp&&(this.popUp.style.right="auto",this.popUp.style.left="0px",this.popUp.style["-webkit-transform"]="translateX(0%)",this.popUp.style.transform="translateX(0%)"),this.togglerButtonElement.style.right="auto",this.togglerButtonElement.style.left="0px",this.togglerButtonElement.style["-webkit-transform"]="translateX(0%)",this.togglerButtonElement.style.transform="translateX(0%)";break;case"center":this.container.style.right="auto",this.container.style.left="50%",this.container.style["-webkit-transform"]="translateX(-50%)",this.container.style.transform="translateX(-50%)",this.popUp&&(this.popUp.style.right="auto",this.popUp.style.left="50%",this.popUp.style["-webkit-transform"]="translateX(-50%)",this.popUp.style.transform="translateX(-50%)"),this.togglerButtonElement.style.right="auto",this.togglerButtonElement.style.left="50%",this.togglerButtonElement.style["-webkit-transform"]="translateX(-50%)",this.togglerButtonElement.style.transform="translateX(-50%)";break;case"right":this.container.style.right="0px",this.container.style.left="auto",this.container.style["-webkit-transform"]="translateX(0%)",this.container.style.transform="translateX(0%)",this.popUp&&(this.popUp.style.right="0px",this.popUp.style.left="auto",this.popUp.style["-webkit-transform"]="translateX(0%)",this.popUp.style.transform="translateX(0%)"),this.togglerButtonElement.style.right="0px",this.togglerButtonElement.style.left="auto",this.togglerButtonElement.style["-webkit-transform"]="translateX(0%)",this.togglerButtonElement.style.transform="translateX(0%)";break}}minimize(){if(!this.container)return!1;this.iFrame.style["border-radius"]=`${this.defaultAttrs["border-radius"]}px`,this.containerStyle={width:"100%","max-width":`${this.defaultAttrs.width}px`,height:`calc(100% - ${2*this.defaultAttrs["margin-y"]}px)`,"max-height":`${this.defaultAttrs.height}px`,position:"fixed",transition:"all .2s",margin:`${this.defaultAttrs["margin-y"]}px ${this.defaultAttrs["margin-x"]}px`,bottom:"0px","border-radius":`${this.defaultAttrs["border-radius"]}px`,"z-index":this.defaultAttrs["z-index"],visibility:"visible",opacity:"1","-webkit-box-shadow":"0 3px 5px -1px rgba(0,0,0,.2), 0 5px 8px 0 rgba(0,0,0,.14), 0 1px 14px 0 rgba(0,0,0,.12)","box-shadow":"0 3px 5px -1px rgba(0,0,0,.2), 0 5px 8px 0 rgba(0,0,0,.14), 0 1px 14px 0 rgba(0,0,0,.12)",border:this.defaultAttrs.border,background:"white"};Object.keys(this.containerStyle).map((t=>{this.container.style[t]=this.containerStyle[t]})),this.checkSiteDimensions()}maximize(){if(!this.container)return!1;this.iFrame.style["border-radius"]="0px",this.containerStyle={width:"100%","max-width":"100%",height:"100%","max-height":"100%",position:"fixed",transition:"all .2s",margin:"0px",bottom:"0px","border-radius":"0px","z-index":this.defaultAttrs["z-index"],visibility:"visible",opacity:"1","-webkit-box-shadow":"0 3px 5px -1px rgba(0,0,0,.2), 0 5px 8px 0 rgba(0,0,0,.14), 0 1px 14px 0 rgba(0,0,0,.12)","box-shadow":"0 3px 5px -1px rgba(0,0,0,.2), 0 5px 8px 0 rgba(0,0,0,.14), 0 1px 14px 0 rgba(0,0,0,.12)",border:this.defaultAttrs.border,backgroud:"white"};Object.keys(this.containerStyle).map((t=>{this.container.style[t]=this.containerStyle[t]}))}getDevice(){const t=navigator.userAgent,e=t.toLowerCase(),i=e.indexOf("mobile")>-1;let s,a;return-1!=e.indexOf("edg/")?s="Microsoft Edge":-1!=e.indexOf("opr/")||-1!=e.indexOf("opera/")?s="Opera":-1!=e.indexOf("chrome/")||-1!=e.indexOf("crios/")?s="Google Chrome":-1!=e.indexOf("safari/")?s="Apple Safari":-1!=e.indexOf("firefox")&&(s="Mozilla Firefox"),-1!=e.indexOf("win")||-1!=e.indexOf("windows")?a="Windows":-1!=e.indexOf("android")?a="Android":-1!=e.indexOf("linux")?a="Linux":-1!=e.indexOf("iphone")?a="iPhone":-1==e.indexOf("mac os")&&-1==e.indexOf("macintosh")||(a="MacOS"),this.device={userAgent:t,mobile:i,browserName:s,so:a},this.device}setDarkMode(t){if(!this.togglerButtonElement)return!1;this.togglerButtonElement.querySelector("img").style.filter=t?"invert(0%)":"invert(100%)"}checkSiteDimensions(){this.defaultAttrs.width+2*this.defaultAttrs["margin-x"]>document.body.offsetWidth&&(this.container&&(this.container.style.margin="3%",this.container.style.width="94%"),this.popUp&&(this.popUp.style["margin-right"]="3%",this.popUp.style["margin-left"]="3%",this.popUp.style.width="94%"),this.iFrameLoader&&(this.iFrameLoader.style.margin="3%",this.iFrameLoader.style.width="94%"))}createOcularToggler(){if(this.embedContainer=document.getElementById("ocular-service-container"),this.embedContainer)return!1;this.togglerButtonElement=document.createElement("button"),this.setOcularTogglerAttributes(),this.setOcularTogglerStyle(),this.togglerButtonElement.addEventListener("click",this.toggle.bind(this)),this.buttonIconElement=document.createElement("img"),this.buttonIconElement.width=this.defaultAttrs.toggler["img-size"],this.buttonIconElement.height=this.defaultAttrs.toggler["img-size"],this.buttonIconElement.display="inline",this.buttonIconElement.src=this.widgetIcon,this.buttonIconElement.alt="Ocular widget toggler image",this.buttonIconElement.style.display="inline",this.togglerButtonElement.appendChild(this.buttonIconElement),this.siteBody.appendChild(this.togglerButtonElement)}setOcularTogglerAttributes(){this.togglerAttrs={id:"ocular-widget-toggler"};Object.keys(this.togglerAttrs).map((t=>{this.togglerButtonElement.setAttribute(t,this.togglerAttrs[t])}))}setOcularTogglerStyle(){if(!this.togglerButtonElement)return!1;this.togglerStyle={width:`${this.defaultAttrs.toggler.width}px`,height:`${this.defaultAttrs.toggler.height}px`,position:"fixed",transition:"all .2s",margin:`${this.defaultAttrs["margin-y"]}px ${this.defaultAttrs["margin-x"]}px`,bottom:"-10px","border-radius":this.defaultAttrs.toggler["border-radius"],"z-index":"-1",visibility:"hidden",opacity:"0",border:"none",outline:"none",cursor:"pointer","-webkit-box-shadow":this.defaultAttrs.toggler["box-shadow"]?"0px 0px 15px 6px #D3D3D3":"none","box-shadow":this.defaultAttrs.toggler["box-shadow"]?"0px 0px 15px 6px #D3D3D3":"none",background:this.defaultAttrs.toggler.color?this.defaultAttrs.toggler.color:this.defaultAttrs["primary-color"],padding:"0px","text-align":"center",display:"flex","align-items":"center","justify-content":"center"};Object.keys(this.togglerStyle).map((t=>{this.togglerButtonElement.style[t]=this.togglerStyle[t]}))}showToggler(t){this.togglerButtonElement.style["z-index"]=t?this.defaultAttrs["z-index"]:"-1",this.togglerButtonElement.style.visibility=t?"visible":"hidden",this.togglerButtonElement.style.opacity=t?"1":"0",this.togglerButtonElement.style.bottom=t?"0px":"-10px"}createOcularContainer(){if(this.embedContainer=document.getElementById("ocular-service-container"),this.embedContainer)return!1;this.container=document.createElement("div"),this.container.setAttribute("data-state","minimized"),this.setContainerAttributes(),this.setContainerStyle(),this.checkSiteDimensions(),this.siteBody.appendChild(this.container)}setContainerAttributes(){this.containerAttrs={id:"ocular-widget-container"};Object.keys(this.containerAttrs).map((t=>{this.container.setAttribute(t,this.containerAttrs[t])}))}setContainerStyle(){if(!this.container)return!1;this.containerStyle={width:"100%","max-width":`${this.defaultAttrs.width}px`,height:`calc(100% - ${2*this.defaultAttrs["margin-y"]}px)`,"max-height":`${this.defaultAttrs.height}px`,position:"fixed",transition:"all .2s",margin:`${this.defaultAttrs["margin-y"]}px ${this.defaultAttrs["margin-x"]}px`,bottom:"-10px","border-radius":`${this.defaultAttrs["border-radius"]}px`,"z-index":"-1",visibility:"hidden",opacity:"0","-webkit-box-shadow":"0 3px 5px -1px rgba(0,0,0,.2), 0 5px 8px 0 rgba(0,0,0,.14), 0 1px 14px 0 rgba(0,0,0,.12)","box-shadow":"0 3px 5px -1px rgba(0,0,0,.2), 0 5px 8px 0 rgba(0,0,0,.14), 0 1px 14px 0 rgba(0,0,0,.12)",border:this.defaultAttrs.border,backgroud:"white"};Object.keys(this.containerStyle).map((t=>{this.container.style[t]=this.containerStyle[t]}))}toggleContainer(t){if(!this.container)return!1;const e=this.togglerButtonElement.classList.contains("active");this.container.style["z-index"]=e?`${this.defaultAttrs["z-index"]}9`:"-1",this.container.style.visibility=e?"visible":"hidden",this.container.style.opacity=e?"1":"0",this.container.style.bottom=e?"0px":"-10px",this.container.dataset.state=e?"open":"minimized","50%"===this.container.style.left&&(this.container.style["-webkit-transform"]="translateX(-50%)",this.container.style.transform="translateX(-50%)"),t||this.showToggler(!e),e&&this.showPopUp(!1),t||this.emitMessage(e?"opened":"minimized")}setFrameLoaderAttributes(){this.iFrameLoaderAttrs={id:"ocular-widget-iframe-loader"};Object.keys(this.iFrameLoaderAttrs).map((t=>{this.iFrameLoader.setAttribute(t,this.iFrameLoaderAttrs[t])}))}setFrameLoaderStyle(){this.iFrameLoaderStyle={width:"100%","max-width":`${this.defaultAttrs.width}px`,height:"100%","max-height":`${this.defaultAttrs.height}px`,position:"fixed",transition:"all .2s","border-radius":"12px","z-index":"9",opacity:"1",border:this.defaultAttrs.border,background:"white",display:"flex","flex-wrap":"wrap","justify-content":"center","align-items":"center","align-content":"center"};Object.keys(this.iFrameLoaderStyle).map((t=>{this.iFrameLoader.style[t]=this.iFrameLoaderStyle[t]}))}createOcularFrameLoader(){if(!this.container)return!1;this.iFrameLoader=document.createElement("div"),this.setFrameLoaderAttributes(),this.setFrameLoaderStyle();const t=document.getElementsByTagName("head")[0],e=document.createElement("STYLE");e.innerHTML="\n @keyframes play {\n 0% {\n transform: scale(1);\n }\n\n 15% {\n box-shadow: 0 0 0 5px rgba(21, 105, 255, 0.4);\n transform: scale(1.1);\n }\n\n 25% {\n box-shadow: 0 0 0 10px rgba(21, 105, 255, 0.4), 0 0 0 20px rgba(21, 105, 255, 0.2);\n transform: scale(1.2);\n }\n\n 25% {\n box-shadow: 0 0 0 15px rgba(21, 105, 255, 0.4), 0 0 0 30px rgba(21, 105, 255, 0.2);\n transform: scale(1.3);\n }\n\n 35% {\n transform: scale(1.2);\n }\n }",t.appendChild(e);const i=document.createElement("div");i.style.background="#1569ff",i.style.width="100px",i.style.height="100px",i.style.position="relative",i.style["border-radius"]="100%",i.style.border="solid 0px #fff",i.style.animation="play 2s ease infinite",i.style["-webkit-backface-visibility"]="hidden",i.style["-moz-backface-visibility"]="hidden",i.style["-ms-backface-visibility"]="hidden",i.style["backface-visibility"]="hidden";const s=document.createElement("img");s.src=`${OCULAR_BASE_URL}/service/ocular/images/logoocular.jpg`,s.style.width="100px",s.style.height="100px",s.style["object-fit"]="cover",s.style["border-radius"]="50%",i.appendChild(s);const a=document.createElement("div");a.style["text-align"]="center",a.appendChild(i),this.iFrameLoader.appendChild(a),this.container.appendChild(this.iFrameLoader)}createOcularFrame(){this.createOcularFrameLoader(),this.iFrame=document.createElement("iframe"),this.setFrameAttributes(),this.setFrameStyle(),this.setFrameSrc();(this.embedContainer?this.embedContainer:this.container).appendChild(this.iFrame)}setFrameSrc(){if(this.iFrame.src=`${OCULAR_APP_URL}?v=${(new Date).getTime().toString()}&${this.urlSearchParams()}&embed=${!!ocularWidget.embedContainer}`,!this.container)return!1;this.iFrame.addEventListener("load",(()=>{this.iFrameLoader.style.visibility="hidden",this.iFrameLoader.style.opacity="0",this.iFrameLoader.style["z-index"]="-1"}),!1)}setFrameAttributes(){this.iFrameAttrs={id:"ocular-widget-iframe",allowtransparency:"true",allow:"camera;microphone;display-capture;clipboard-read;clipboard-write"};Object.keys(this.iFrameAttrs).map((t=>{this.iFrame.setAttribute(t,this.iFrameAttrs[t])}))}setFrameStyle(){if(!this.iFrame)return!1;this.frameStyle={background:"white",width:"100%",height:`calc(100% - ${this.defaultAttrs["toolbar-height"]+1}px)`,border:"0px","border-bottom-right-radius":`${this.defaultAttrs["border-radius"]}px`,"border-bottom-left-radius":`${this.defaultAttrs["border-radius"]}px`,"border-top-right-radius":`${this.defaultAttrs["border-radius"]}px`,"border-top-left-radius":`${this.defaultAttrs["border-radius"]}px`};Object.keys(this.frameStyle).map((t=>{this.iFrame.style[t]=this.frameStyle[t]}))}createPopUp(){if(scriptOcularModules&&scriptOcularModules.includes("custom")&&!scriptOcular.dataset.popupMessage)return!1;if(this.embedContainer=document.getElementById("ocular-service-container"),this.embedContainer)return!1;this.popUp=document.createElement("div"),this.popUp.setAttribute("data-state","hide"),this.setPopUpAttributes(),this.setPopUpStyle();const t=document.createElement("button"),e=document.createElement("img");e.width="15",e.height="15",e.src=`${OCULAR_BASE_URL}/service/ocular/images/close-x.svg`,e.alt="Ocular widget close x",t.appendChild(e),t.style.width="30px",t.style.height="30px",t.style.position="absolute",t.style.top="0px",t.style.right="0px",t.style.border="0px",t.style.outline="none",t.style["border-radius"]="50px",t.style.padding="0px",t.style.cursor="pointer",t.style.background="transparent",t.style.margin="10px",t.addEventListener("click",(()=>this.showPopUp(!1)));const i=document.createElement("div");i.classList.add("ocular-popup-container"),this.popUp.appendChild(t),this.popUp.appendChild(i),this.popUpProgress(),this.siteBody.appendChild(this.popUp)}setPopUpContent(t){if(!this.popUp)return!1;const e=document.createElement("div");e.style.padding="20px",e.style["max-height"]="200px",e.style.overflow="auto",e.style.cursor="pointer",e.innerHTML=t,e.addEventListener("click",(()=>this.show(!0))),this.popUp.querySelector("div.ocular-popup-container").innerHTML="",this.popUp.querySelector("div.ocular-popup-container").append(e)}setPopUpAttributes(){this.popUpAttrs={id:"ocular-widget-popup"};Object.keys(this.popUpAttrs).map((t=>{this.popUp.setAttribute(t,this.popUpAttrs[t])}))}setPopUpStyle(){if(!this.popUp)return!1;this.popUpStyle={width:"100%","max-width":`${this.defaultAttrs.width}px`,position:"fixed",transition:"all .2s",margin:`calc(${this.defaultAttrs["margin-y"]}px + 10px) ${this.defaultAttrs["margin-x"]}px`,bottom:"-10px","border-radius":`${this.defaultAttrs["border-radius"]}px`,"z-index":"-1",visibility:"hidden",opacity:"0","-webkit-box-shadow":"0px 0px 25px 6px #D3D3D3","box-shadow":"0px 0px 25px 6px #D3D3D3",border:"1px solid #E6E6E6",background:"white","font-size":"17px"};Object.keys(this.popUpStyle).map((t=>{this.popUp.style[t]=this.popUpStyle[t]})),this.popUp.addEventListener("mouseenter",(()=>{this.popUp.style.border="1px solid #888"})),this.popUp.addEventListener("mouseleave",(()=>{this.popUp.style.border="1px solid #E6E6E6"}))}showPopUp(t,e,{popUpHandler:i,duration:s}={duration:10}){if(!this.popUp)return!1;if(this.container&&!["open","hidden"].includes(this.container.dataset.state)||(t=!1),i){this.popUp.querySelector("div.ocular-popup-container > div")?.addEventListener("click",(()=>this.executeFunctionFromString({ocGoogleAnalitycs:ocGoogleAnalitycs,analitycsStorage:analitycsStorage,ocularWidget:ocularWidget,mainService:mainService,organization:organization,questionnary:questionnary,widgetIndentificator:widgetIndentificator},i)))}this.setPopUpStyles(t),this.interval&&clearInterval(this.interval),t&&(e&&this.playPopUpSound(),this.startProgressBar(s)),sessionStorage.setItem("ocular-popup-displayed","true")}setPopUpStyles(t){this.popUp.style.zIndex=t?`${this.defaultAttrs["z-index"]}99`:"-1",this.popUp.style.visibility=t?"visible":"hidden",this.popUp.style.opacity=t?"1":"0",this.popUp.style.bottom=t?"80px":"-10px",this.popUp.dataset.state=t?"show":"hide","50%"===this.popUp.style.left&&(this.popUp.style.transform="translateX(-50%)",this.popUp.style["-webkit-transform"]="translateX(-50%)")}startProgressBar(t){const e=performance.now(),i=s=>{const a=(s-e)/(1e3*t),r=Math.max(100*(1-a),0);this.progressBarElement.style.width=`${r}%`,r>0?this.interval=requestAnimationFrame(i):(cancelAnimationFrame(this.interval),this.showPopUp(!1))};this.interval=requestAnimationFrame(i)}popUpProgress(){this.progressBarElement=document.createElement("div"),this.setPopUpProgressStyle();const t=document.createElement("div");t.style.margin="0px 20px",t.appendChild(this.progressBarElement),this.popUp.appendChild(t)}setPopUpProgressStyle(){if(!this.progressBarElement)return!1;this.popUpProgressStyle={height:"3px",background:this.defaultAttrs["primary-color"],"border-radius":"20px",trasition:"width .2s"};Object.keys(this.popUpProgressStyle).map((t=>{this.progressBarElement.style[t]=this.popUpProgressStyle[t]}))}playPopUpSound(){const t=new Audio(`${OCULAR_BASE_URL}/service/ocular/sounds/App_Notification.mp3`);t.volume=.15,t.play()}onOcularWidgetReady(){ocularWidget.embedContainer&&(this.iFrame||this.createOcularFrame())}ready(){OCULAR_WIDGET_READY=!0,this.emitMessage("is-ready");try{this.onOcularWidgetReady(),onOcularWidgetReady()}catch(t){}}mountSessionLink(t,e){return!!e&&(this.crossDomainMessage(`widget.mountSessionLink(${JSON.stringify(t)}, ${JSON.stringify(e)})`),"Success")}mount(t){mountOcular.start(t)}}const ocularWidget=new OcularWidget;class VersionChecker{constructor(){this.VERSION_CHECKER_STORAGE_NAME="ocular-app-version-checker",this.MAINTENANCE_STORAGE_NAME="ocular-in-maintenance",this.versionChecker}getMainVersionCheckerStorage(){const t=localStorage.getItem(this.VERSION_CHECKER_STORAGE_NAME);return t?JSON.parse(t):null}setMainVersionCheckerStorage(){localStorage.setItem(this.VERSION_CHECKER_STORAGE_NAME,JSON.stringify(this.versionChecker))}setVersion(t){if(!t){t=`${(new Date).toISOString().split("T")[0]} 00:00:00`}this.versionChecker={changeDate:t,lastTime:(new Date).getTime()},this.setMainVersionCheckerStorage()}clearStorage(){localStorage.removeItem("ocular-app-basic"),localStorage.removeItem("ocular-app-widget"),localStorage.removeItem("ocular-app-questionnary"),localStorage.removeItem("ocular-app-widget-urls")}versionCompare(t=null){const e=JSON.parse(localStorage.getItem("ocular-app"));if(4===(e?e.state:0).id)return!1;this.versionChecker&&t&&new Date(t.change_date).getTime()===new Date(this.versionChecker.changeDate).getTime()||(this.setVersion(t?t.change_date:null),this.clearStorage())}getTimeInterval(){if(!this.versionChecker)return!0;const t=this.versionChecker.lastTime?this.versionChecker.lastTime:0,e=(new Date).getTime(),i=e-t>6e4;return i&&(this.versionChecker.lastTime=e,this.setMainVersionCheckerStorage()),i}setMaintenance(t){t?localStorage.setItem(this.MAINTENANCE_STORAGE_NAME,"maintenance"):localStorage.getItem(this.MAINTENANCE_STORAGE_NAME)&&localStorage.removeItem(this.MAINTENANCE_STORAGE_NAME)}inMaintenance(){return!!localStorage.getItem(this.MAINTENANCE_STORAGE_NAME)}async getMainVersionChecker(){const t={route:"ocular/widget/widget-version",method:"GET",params:{}};return this.versionChecker=this.getMainVersionCheckerStorage(),this.versionChecker?!!this.getTimeInterval()&&(mountOcular.widgetCode&&(t.params.code=mountOcular.widgetCode),ocularWidget.ajaxRequest(t).then((t=>{const e=t;if(e&&0===e.statusCode){const t=!!e.maintenance&&e.maintenance;this.setMaintenance(t),this.versionCompare(e.widgetVersion)}})).catch((t=>{}))):(this.versionCompare(),!1)}}const versionChecker=new VersionChecker;class WidgetIndentificator{constructor(){this.STORAGE_NAME="ocular-solution-widget-id",this.uuid=null}getStorage(){const t=localStorage.getItem(this.STORAGE_NAME),e=t||null;try{ocularWidget.crossDomainMessage(`uuidGenerator.setUuid(${JSON.stringify(e)})`)}catch(t){}}setStorage(t){localStorage.setItem(this.STORAGE_NAME,t)}}const widgetIndentificator=new WidgetIndentificator;class AnalitycsStorage{constructor(){this.OCULAR_DEVICE_ANALITYCS_STORAGE_NAME="ocular-device-analitycs",this.device=ocularWidget.getDevice(),this.storageData={analitycId:null,device:null,customer:null,country:null,sessionId:null,history:[]},this.widgetUuid=null}uuidGenerator(){let t=(new Date).getTime(),e="undefined"!=typeof performance&&performance.now&&1e3*performance.now()||0;return this.widgetUuid="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(i=>{let s=16*Math.random();return t>0?(s=(t+s)%16|0,t=Math.floor(t/16)):(s=(e+s)%16|0,e=Math.floor(e/16)),("x"===i?s:3&s|8).toString(16)})),this.widgetUuid}initializeDeviceData(){const t={widgetUuid:this.widgetUuid?this.widgetUuid:this.uuidGenerator(),browser:this.device.browserName,mobile:this.device.mobile,so:this.device.so,fromWeb:document.referrer,baseUrl:window.location.href,userAgent:this.device.userAgent,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone};this.storageData.device=t}saveStorageData(){sessionStorage.setItem(this.OCULAR_DEVICE_ANALITYCS_STORAGE_NAME,JSON.stringify(this.storageData))}updateStorageData(t){this.storageData=t,this.saveStorageData()}initializeStorageData(t=!1,e=null){let i=localStorage.getItem("ocular-app");i=i?JSON.parse(i):null,this.storageData={analitycId:!t&&this.storageData&&this.storageData.analitycId?this.storageData.analitycId:null,device:this.storageData&&this.storageData.device?this.storageData.device:null,customer:i&&i.room&&i.room.customer?i.room.customer:null,country:e,sessionId:i&&i.room&&i.room.session&&i.room.session.id?i.room.session.id:null,history:!t&&this.storageData&&this.storageData.history?this.storageData.history:[]},this.storageData.device||this.initializeDeviceData()}resetStorageData(){this.initializeStorageData(!0),this.saveStorageData()}removeStorageData(){sessionStorage.removeItem(this.OCULAR_DEVICE_ANALITYCS_STORAGE_NAME)}initializeStorage(t){const e=sessionStorage.getItem(this.OCULAR_DEVICE_ANALITYCS_STORAGE_NAME);this.storageData=e?JSON.parse(e):null,this.initializeStorageData(!1,t)}addHistoryItem(t,e){this.initializeStorage(e),this.storageData.history.unshift(t),this.saveStorageData(),ocularWidget.crossDomainMessage(`ocularAnalitycs.addHistoryItem(${JSON.stringify(t)}, ${JSON.stringify(this.storageData)})`)}}const analitycsStorage=new AnalitycsStorage;class GoogleAnalitycs{constructor(){window.dataLayer=window.dataLayer||[]}dataLayerPush(t){dataLayer.push(t)}}const ocGoogleAnalitycs=new GoogleAnalitycs;class OcularStorage{constructor(){this.STORAGE_NAME="ocular-app"}updateStorageData(t){localStorage.setItem(this.STORAGE_NAME,JSON.stringify(t))}}const ocularStorage=new OcularStorage;class OcularLocalStorage{constructor(){this.STORAGE_NAME="ocular-app",this.states=[{id:1,name:"progress",actionState:!1},{id:2,name:"calling",actionState:!0},{id:3,name:"queue",actionState:!0},{id:4,name:"call",actionState:!0},{id:5,name:"rating",actionState:!0},{id:6,name:"Finished",actionState:!1},{id:7,name:"Optimizando",actionState:!0},{id:8,name:"Streaming",actionState:!0}]}setStorage(){const t=localStorage.getItem(this.STORAGE_NAME);this.storage=t?JSON.parse(t):null}updateStorageData(){localStorage.setItem(this.STORAGE_NAME,JSON.stringify(this.storage))}setWidgetCode(t){this.storage.widget.code=t,this.updateStorageData()}initialize(t=!1){this.setStorage(),this.storage={activeRoute:!t&&this.storage&&this.storage.activeRoute?this.storage.activeRoute:"/",state:!t&&this.storage&&this.storage.state?this.storage.state:this.states[0],category:!t&&this.storage&&this.storage.category?this.storage.category:null,codec:!t&&this.storage&&this.storage.codec?this.storage.codec:"VP8",form:{code:!t&&this.storage&&this.storage.form&&this.storage.form.code?this.storage.form.code:null},widget:{code:!t&&this.storage&&this.storage.widget?this.storage.widget.code:null,lang:!t&&this.storage&&this.storage.widget?this.storage.widget.lang:null},device:{camera:!(!t&&this.storage&&this.storage.device)||this.storage.device.camera,microphone:!(!t&&this.storage&&this.storage.device)||this.storage.device.microphone,screen:!(t||!this.storage||!this.storage.device)&&this.storage.device.screen},room:{currentLocation:this.storage&&this.storage.room&&this.storage.room.currentLocation?this.storage.room.currentLocation:{url:null,title:null},connected:!!(this.storage&&this.storage.room&&this.storage.room&&void 0!==this.storage.room.connected)&&this.storage.room.connected,customer:this.storage&&this.storage.room&&this.storage.room.customer?this.storage.room.customer:null,cammer:!t&&this.storage&&this.storage.room&&this.storage.room.cammer?this.storage.room.cammer:{user:{}},publisher:!t&&this.storage&&this.storage.room&&this.storage.room.publisher?this.storage.room.publisher:null,publisherSettings:!t&&this.storage&&this.storage.room&&this.storage.room.publisherSettings?this.storage.room.publisherSettings:null,chat:!t&&this.storage&&this.storage.room&&this.storage.room.chat?this.storage.room.chat:[],recommendations:!t&&this.storage&&this.storage.room&&this.storage.room.recommendations?this.storage.room.recommendations:[],session:{id:!t&&this.storage&&this.storage.room&&this.storage.room.session.id?this.storage.room.session.id:null,tokboxId:!t&&this.storage&&this.storage.room&&this.storage.room.session.tokboxId?this.storage.room.session.tokboxId:null,token:!t&&this.storage&&this.storage.room&&this.storage.room.session.token?this.storage.room.session.token:null},streams:[]}},this.updateStorageData()}}const ocularLocalStorage=new OcularLocalStorage;class Organization{constructor(){this.widgetBasic,this.widget,this.WIDGET_BASIC_STORAGE_NAME="ocular-app-basic",this.WIDGET_STORAGE_NAME="ocular-app-widget"}getWidgetBasicStorage(){const t=localStorage.getItem(this.WIDGET_BASIC_STORAGE_NAME),e=t?JSON.parse(t):null;return this.widgetBasic=e,e}setWidgetBasicStorage(){localStorage.setItem(this.WIDGET_BASIC_STORAGE_NAME,JSON.stringify(this.widgetBasic))}getWidgetStorage(){const t=localStorage.getItem(this.WIDGET_STORAGE_NAME);return t?JSON.parse(t):null}setWidgetStorage(){localStorage.setItem(this.WIDGET_STORAGE_NAME,JSON.stringify(this.widget))}clearWidgetStorage(){localStorage.removeItem(this.WIDGET_STORAGE_NAME),this.widgetBasic=null}async mount(){if(this.widgetBasic=this.widgetBasic?this.widgetBasic:this.getWidgetBasicStorage(),this.widgetBasic)widget.mount(this.widgetBasic);else{const t={route:"ocular/widget/mount-ocular",method:"GET",params:{timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone},successHandler:"organization.mountOrganizationSuccess",errorHandler:"organization.mountOrganizationError"},e=new URLSearchParams(location.search),i=e.get("ocularSessionId")||e.get("ocularLinkSessionId")||e.get("ocularStreaming")?1:0;i&&(t.params.fromLink=i),mountOcular.widgetCode&&(t.params.code=mountOcular.widgetCode),await ocularWidget.ajaxRequest(t).then((t=>{const e=t;e&&0===e.statusCode&&e.widget&&(this.widgetBasic=e.widget,this.setWidgetBasicStorage(),versionChecker.setVersion(e.widget.version_date),widget.mount(this.widgetBasic))})).catch((t=>{}))}}async getWidget(t){this.widget=organization.getWidgetStorage(),this.widget?ocularWidget.crossDomainMessage(`${t.successHandler}(${JSON.stringify(this.widget)}, ${JSON.stringify(ocularLocalStorage.storage)})`):(mountOcular.widgetCode&&(t.params.code=mountOcular.widgetCode),await ocularWidget.ajaxRequest(t).then((e=>{const i=e;i&&0===i.statusCode&&i.widget&&i.widget.uuid?(this.widget=i.widget,this.setWidgetStorage(),ocularWidget.crossDomainMessage(`${t.successHandler}(${JSON.stringify(this.widget)}, ${JSON.stringify(ocularLocalStorage.storage)})`)):ocularWidget.crossDomainMessage(`${t.errorHandler}(${JSON.stringify(i)})`)})).catch((e=>{ocularWidget.crossDomainMessage(`${t.errorHandler}(${JSON.stringify(e)})`)})))}}const organization=new Organization;class OrganizationUrl{constructor(){this.widgetUrls,this.widget_URLS_STORAGE_NAME="ocular-app-widget-urls"}getOrganizationUrlsStorage(){const t=localStorage.getItem(this.widget_URLS_STORAGE_NAME);return t?JSON.parse(t):null}setOrganizationUrlsStorage(){localStorage.setItem(this.widget_URLS_STORAGE_NAME,JSON.stringify(this.widgetUrls))}async getOrganizationUrls(t){this.widgetUrls=this.getOrganizationUrlsStorage(),this.widgetUrls?ocularWidget.crossDomainMessage(`${t.successHandler}(${JSON.stringify(this.widgetUrls)})`):await ocularWidget.ajaxRequest(t).then((e=>{const i=e;i&&0===i.statusCode&&i.urls&&i.urls.length?(this.widgetUrls=i.urls,this.setOrganizationUrlsStorage(),ocularWidget.crossDomainMessage(`${t.successHandler}(${JSON.stringify(this.widgetUrls)})`)):ocularWidget.crossDomainMessage(`${t.errorHandler}(${JSON.stringify(i)})`)})).catch((e=>{ocularWidget.crossDomainMessage(`${t.errorHandler}(${JSON.stringify(e)})`)}))}}const organizationUrls=new OrganizationUrl;class Questionnary{constructor(){this.QUESTIONNARY_STORAGE_NAME="ocular-app-questionnary",this.questionnary}getMainQuestionnaryStorage(){const t=localStorage.getItem(this.QUESTIONNARY_STORAGE_NAME);return t?JSON.parse(t):null}setMainQuestionnaryStorage(){localStorage.setItem(this.QUESTIONNARY_STORAGE_NAME,JSON.stringify(this.questionnary))}async getMainQuestionnary(t){this.questionnary=this.getMainQuestionnaryStorage(),this.questionnary?ocularWidget.crossDomainMessage(`${t.successHandler}(${JSON.stringify(this.questionnary)})`):(mountOcular.widgetCode&&(t.params.code=mountOcular.widgetCode),await ocularWidget.ajaxRequest(t).then((e=>{const i=e;i&&0===i.statusCode&&i.questionnary?(this.questionnary={item:i.questionnary,geoip:i.geoip?i.geoip:store.state.questionnary.geoip},this.setMainQuestionnaryStorage(),ocularWidget.crossDomainMessage(`${t.successHandler}(${JSON.stringify(this.questionnary)})`)):ocularWidget.crossDomainMessage(`${t.errorHandler}(${JSON.stringify(i)})`)})).catch((e=>{ocularWidget.crossDomainMessage(`${t.errorHandler}(${JSON.stringify(e)})`)})))}}const questionnary=new Questionnary;class MainService{async apiRequest(t){mountOcular.widgetCode&&(t.params.code=mountOcular.widgetCode),await ocularWidget.ajaxRequest(t).then((e=>{const i=e;ocularWidget.crossDomainMessage(`${t.successHandler}(${JSON.stringify(i)})`)})).catch((e=>{ocularWidget.crossDomainMessage(`${t.catchHandler}(${JSON.stringify(e)})`)}))}}const mainService=new MainService,ocularElement={toggleButtons:[],parentToggleButtons:[],serviceContainer:null},setOcularElements=()=>{ocularElement.toggleButtons=document.querySelectorAll(".ocular-toggler"),ocularElement.parentToggleButtons=document.querySelectorAll(".ocular-parent-toggler"),ocularElement.serviceContainer=document.querySelector("#ocular-service-container")},widgetToggle=()=>{if(!ocularElement.toggleButtons)return!1;ocularElement.toggleButtons.forEach((t=>{t.onclick=()=>{ocularWidget.toggle()}}))},widgetParentToggle=()=>{if(!ocularElement.parentToggleButtons)return!1;ocularElement.parentToggleButtons.forEach((t=>{t.onclick=()=>{OCULAR_SESSION_ID?ocularWidget.toggle():ocularWidget.parentToggle()}}))},clearOcular=()=>{const t=document.querySelector("#ocular-widget-toggler"),e=document.querySelector("#ocular-widget-popup"),i=document.querySelector("#ocular-widget-container");t&&t.remove(),e&&e.remove(),i&&i.remove()},findServiceContainer=async()=>!!ocularElement.serviceContainer&&(!ocularElement.serviceContainer.querySelector("iframe#ocular-widget-iframe")&&(clearOcular(),void await ocularWidget.init()));class OcularWidgetConfig{togglerConfig(t){let e=t.find((t=>18===t.type));e=e?e.value:null;let i=t.find((t=>19===t.type));i=i?i.value:null;let s=t.find((t=>20===t.type));s=s?s.value:null;let a=t.find((t=>38===t.type));a=!a||"true"===a.value;let r=t.find((t=>39===t.type));r=r?r.value:null;const o=t.find((t=>21===t.type)),n=t.find((t=>37===t.type)),l=t.find((t=>22===t.type));return{color:r,width:e,height:i,borderRadius:s,image:{width:o?o.value:null,height:n?n.value:null,src:l?l.value:null},boxShadow:a}}createScripts(t){for(let e=0;e14===t.type)),i=t.find((t=>15===t.type)),s=t.find((t=>17===t.type));let a=t.find((t=>23===t.type));a=a?a.value:null;let r=t.find((t=>24===t.type));r=r?r.value:null;const o={marginX:a,marginY:r},n=this.togglerConfig(t),l={primaryColor:e?e.value:null,borderRadius:i?i.value:null,zIndex:s?s.value:null,height:630,marginX:o.marginX,marginY:o.marginY,toggler:n},c=t.find((t=>7===t.type)),g=c?c.value:"right";ocularWidget.align(g),ocularWidget.setDefaultConfig(l);const h=t.find((t=>55===t.type&&"true"===t.value));h&&JSON.parse(h.data).length>0&&this.createScripts(JSON.parse(h.data))}popupDisplayed(){return!!sessionStorage.getItem("ocular-popup-displayed")}showPopUpContent(t="",e=!0){return ocularWidget.setPopUpContent(t),ocularWidget.showPopUp(!0,e),"popup content set success"}showPopUpMessage(t){const e=t.find((t=>3===t.type)),i=!t.find((t=>12===t.type&&"false"===t.value));if(!t.find((t=>13===t.type&&"true"===t.value)))return!1;const s=e?e.value:'

😎
Tienes dudas? conversa con un agente en vivo.

';this.showPopUpContent(s,i)}initialVisibility(t){return!t.find((t=>10===t.type&&"false"===t.value))}urlVisivility(t,e){let i=!0;if(!e.actionState&&t.length){let e=`${location.hostname}${location.pathname}`;e=ocularWidget.stringEndsWith(e,"/")?e:`${e}/`,i=!!t.find((t=>e.indexOf(t)>-1))}return i}deviceVisibility(t){let e=!0;const i=!t.find((t=>8===t.type&&"false"===t.value)),s=!t.find((t=>9===t.type&&"false"===t.value));return i||ocularWidget.device.mobile?!s&&ocularWidget.device.mobile&&(e=!1):e=!1,e}mountCustom(){const t=scriptOcular.dataset;organization.widgetBasic={attributes:[{type:3,value:t.popupMessage?t.popupMessage:null},{type:9,value:"true"},{type:8,value:"true"},{type:10,value:t.show?t.show:"true"},{type:12,value:t.popupSound?t.popupSound:"true"},{type:13,value:"true"},{type:14,value:t.color},{type:15,value:"10"},{type:17,value:"999999999999999999"},{type:22,value:t.image},{type:38,value:"true"},{type:39,value:t.color}],show_service:!0,attending:!0}}mount(t){const e=t,i=e.attributes,s=e.urls?e.urls:[];if(!e||!e.show_service)return!1;i.length&&this.setMountConfig(i),ocularWidget.ready();const a=JSON.parse(localStorage.getItem("ocular-app")),r=a?a.state:null;let o=r.actionState,n=!0;const l=new URLSearchParams(location.search);if(l.get("ocularSessionId")||l.get("ocularLinkSessionId")||l.get("ocularStreaming"))o=!0;else{if(!this.urlVisivility(s,r)&&!r.actionState)return!1;if(!this.deviceVisibility(i)&&!r.actionState)return!1;this.initialVisibility(i)||(n=!1)}const c=i.find((t=>44===t.type&&"true"===t.value));setTimeout((()=>{ocularWidget.show(o,!0,c,n)}),100)}}const widget=new OcularWidgetConfig;class MountOcular{constructor(){this.widgetCode=scriptOcular?scriptOcular.getAttribute("code"):null}resetOcular(){document.querySelector("#ocular-widget-toggler")?.remove(),document.querySelector("#ocular-widget-popup")?.remove(),document.querySelector("#ocular-widget-iframe")?.remove()}async start(t=null){if(this.cookieEnabled=navigator.cookieEnabled,!this.cookieEnabled)return!1;t?(this.widgetCode=t,this.resetOcular(),ocularWidget.createOcularToggler(),ocularWidget.createPopUp(),ocularWidget.createOcularFrame(),organization.clearWidgetStorage()):await ocularWidget.init(),ocularLocalStorage.initialize();const e=ocularLocalStorage.storage.widget.code,i=ocularLocalStorage.storage.state;return this.widgetCode&&!e?(ocularLocalStorage.setWidgetCode(this.widgetCode),await versionChecker.getMainVersionChecker()):this.widgetCode&&e!==this.widgetCode&&!i.actionState?(ocularLocalStorage.setWidgetCode(this.widgetCode),versionChecker.clearStorage()):await versionChecker.getMainVersionChecker(),!versionChecker.inMaintenance()&&(scriptOcularModules&&scriptOcularModules.includes("custom")&&widget.mountCustom(),this.widgetCode=ocularLocalStorage.storage.widget.code,organization.mount(),"Success")}}const mountOcular=new MountOcular;mountOcular.start();const createObserver=()=>{if(!document)return!1;new MutationObserver((()=>{runFunctions()})).observe(document,{attributes:!0,childList:!0,subtree:!0})},runFunctions=async()=>{ocularElement.toggleButtons=document.querySelectorAll(".ocular-toggler"),ocularElement.parentToggleButtons=document.querySelectorAll(".ocular-parent-toggler"),ocularElement.serviceContainer=document.querySelector("#ocular-service-container"),await findServiceContainer(),widgetToggle(),widgetParentToggle()};createObserver();