{"version":3,"sources":["Translations.js","LoginButton.js","index.js"],"names":["Translations","language","_this","this","Object","classCallCheck","DICTIONARY","pt","login_button_content","login_switch_wordpress","en","es","it","DEFAULT_LANGUAGE","get_translation","key","content","dict","subLang","split","LoginButton","props","possibleConstructorReturn","getPrototypeOf","call","LOGIN_ADMIN_REDIRECT_URI","get_redirect_url","replace","document","location","host","login_redirect","window","href","restore_wordpress","getElementById","style","display","error_element","restore_ref","current","React","createRef","translations","locale","extraSpace","qs","parse","search","loggedout","loginform","react_default","a","createElement","className","concat","onClick","alt","src","pluginroot","ref","fallback","Component","console","log","login_element","dataset","ReactDOM","render","src_LoginButton_0","wordpressfallback"],"mappings":"yOA0CeA,EApBb,SAAAA,EAAYC,GAAS,IAAAC,EAAAC,KAAAC,OAAAC,EAAA,EAAAD,CAAAD,KAAAH,GAAAG,KArBrBG,WAAa,CACXC,GAAM,CACJC,qBAAwB,kCACxBC,uBAA0B,0BAE5BC,GAAM,CACJF,qBAAwB,kCACxBC,uBAA0B,0BAE5BE,GAAM,CACJH,qBAAwB,kCACxBC,uBAA0B,0BAE5BG,GAAM,CACJJ,qBAAwB,kCACxBC,uBAA0B,2BAMTN,KAFrBU,iBAAmB,KAEEV,KAIrBW,gBAAkB,SAACC,GACjB,IAAIC,EAAU,GACVC,EAAOf,EAAKI,WAAWJ,EAAKD,UAEhC,KADAe,EAAWC,EAAOA,EAAKF,GAAO,MAClB,CACV,IAAIG,EAAUhB,EAAKD,SAASkB,MAAM,MAElCH,GADAC,EAAOf,EAAKI,WAAWY,EAAQ,KACbD,EAAKF,GAAO,QAE5BC,EAAUd,EAAKI,WAAWJ,EAAKW,kBAAkBE,IAGrD,OAAOC,GAfPb,KAAKF,SAAWA,GC6BLmB,qBA3Cb,SAAAA,EAAYC,GAAO,IAAAnB,EAAA,OAAAE,OAAAC,EAAA,EAAAD,CAAAD,KAAAiB,IAClBlB,EAAAE,OAAAkB,EAAA,EAAAlB,CAAAD,KAAAC,OAAAmB,EAAA,EA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CAzCxP2B,IAAMqB,YCChCC,QAAQC,IAAI,uCAEZ,IAAIC,EAAgBrC,SAASO,eAAe,6BACzC8B,IACDF,QAAQC,IAAI,6BACZD,QAAQC,IAAIC,EAAcC,SAC1BC,IAASC,OAAOjB,EAAAC,EAAAC,cAACgB,EAAD,CAAazB,OAAQqB,EAAcC,QAAQtB,OAAQiB,SAAUI,EAAcC,QAAQI,kBAAmBX,WAAYM,EAAcC,QAAQP,aAAeM","file":"static/js/main.2a37d5db.chunk.js","sourcesContent":["class Translations {\r\n  DICTIONARY = {\r\n    \"pt\": {\r\n      \"login_button_content\": \"Acessar com a conta PRÓ-VIDA\",\r\n      \"login_switch_wordpress\": \"Mostra Login Wordpress\",\r\n    },\r\n    \"en\": {\r\n      \"login_button_content\": \"Login using PRÓ-VIDA account\",\r\n      \"login_switch_wordpress\": \"Mostra Login Wordpress\",\r\n    },\r\n    \"es\": {\r\n      \"login_button_content\": \"Login using PRÓ-VIDA account\",\r\n      \"login_switch_wordpress\": \"Mostra Login Wordpress\",\r\n    },\r\n    \"it\": {\r\n      \"login_button_content\": \"Login using PRÓ-VIDA account\",\r\n      \"login_switch_wordpress\": \"Mostra Login Wordpress\",\r\n    }\r\n  };\r\n\r\n  DEFAULT_LANGUAGE = \"en\";\r\n\r\n  constructor(language){\r\n    this.language = language;\r\n  }\r\n\r\n  get_translation = (key) => {\r\n    let content = \"\";\r\n    let dict = this.DICTIONARY[this.language];\r\n    content = (dict ? dict[key] : null);\r\n    if(!content){\r\n      let subLang = this.language.split(\"_\");\r\n      dict = this.DICTIONARY[subLang[0]];\r\n      content = (dict ? dict[key] : null);\r\n      if(!content){\r\n        content = this.DICTIONARY[this.DEFAULT_LANGUAGE][key];\r\n      }\r\n    }\r\n    return content;\r\n  }\r\n}\r\n\r\nexport default Translations;\r\n","import React from 'react';\r\nimport qs from 'query-string';\r\nimport Translations from './Translations.js';\r\nimport './LoginButton.css';\r\n\r\nclass LoginButton extends React.Component {\r\n\r\n  LOGIN_ADMIN_REDIRECT_URI = \"https://{{URI}}/wp-json/pv_login/v1/pv-login-admin-oauth\";\r\n\r\n  constructor(props) {\r\n   super(props);\r\n   this.restore_ref = React.createRef();\r\n   this.translations =  new Translations(props.locale);\r\n  }\r\n\r\n  get_redirect_url = () => {\r\n    return this.LOGIN_ADMIN_REDIRECT_URI.replace(\"{{URI}}\", document.location.host)\r\n  };\r\n\r\n  login_redirect = () => {\r\n    window.location.href = \"https://login.provida.digital/auth/realms/pro-vida/protocol/openid-connect/auth?client_id=sites-pantheon&redirect_uri=\"+this.get_redirect_url()+\"&response_type=code\";\r\n  };\r\n\r\n  restore_wordpress = () => {\r\n    document.getElementById(\"loginform\").style.display = \"block\";\r\n    let error_element = document.getElementById(\"login_error\");\r\n    if(error_element){\r\n      error_element.style.display = \"block\";\r\n    }\r\n    document.getElementById(\"nav\").style.display = \"block\";\r\n    this.restore_ref.current.style.display = \"none\";\r\n  }\r\n\r\n  render(){\r\n    let params = qs.parse(window.location.search)\r\n    let extraSpace = \"\";\r\n\r\n    if(params.loggedout === \"true\"){\r\n      extraSpace = \"pv-login-extra-space\";\r\n    }\r\n\r\n    let loginform = document.getElementById(\"loginform\");\r\n\r\n    return (\r\n      <div className={`pv-login-form ${extraSpace}`}>\r\n        <a className={`pv-login-button`} href=\"javascript: void(0);\" onClick={this.login_redirect}><span className=\"pv-login-button-content\"><img alt=\"PRÓ-VIDA Logo\" src={this.props.pluginroot + \"/ovo.png\"}/>{this.translations.get_translation(\"login_button_content\")}</span></a>\r\n        <div ref={this.restore_ref} style={(loginform && this.props.fallback === \"true\" ? {display: \"block\"} : {display: \"none\"})} className={`pv-login-button-show-wordpress`}><a href=\"javascript: void(0)\" onClick={this.restore_wordpress}>{this.translations.get_translation(\"login_switch_wordpress\")}</a></div>\r\n      </div>\r\n    );\r\n  }\r\n}\r\n\r\nexport default LoginButton;\r\n","import React from 'react';\r\nimport ReactDOM from 'react-dom';\r\nimport './index.css';\r\n\r\nimport LoginButton from './LoginButton.js';\r\n\r\nconsole.log(\"PVLogin React Component Initialized\");\r\n\r\nvar login_element = document.getElementById('pv_login_button_container');\r\nif(login_element){\r\n  console.log(\"Rendering PvLoginButton: \");\r\n  console.log(login_element.dataset);\r\n  ReactDOM.render(<LoginButton locale={login_element.dataset.locale} fallback={login_element.dataset.wordpressfallback} pluginroot={login_element.dataset.pluginroot}/>, login_element);\r\n}\r\n"],"sourceRoot":""}