import{a as t}from"./p-bdf078de.js";import{H as e}from"./p-c5a0d075.js";import{F as s}from"./p-70700d3b.js";import{g as n}from"./p-754b7832.js";const a="query GetPagesContent {\n getPagesContent {\n id\n site_group_id\n site_id\n path\n title\n name\n html\n created_at\n created_by_user_id\n publish_at\n unpublish_at\n is_head_revision\n revision_status\n page_type_id\n layout\n description\n robots\n image\n video\n audio\n into_head\n before_body\n path_aliases\n redirect_to\n keywords\n language_id\n allowed_role\n preview_key\n instance_id\n replacing_instance_id\n use_cache\n publish_timezone\n seo_title\n details\n }\n}\n";class i extends class{constructor(){this.amplify=null,this.currentUser=null}async initAmplify(){this.amplify=window.Amplify,this.amplify.configure(t)}async initGuestUser(){this.currentUser=await this.amplify.Auth.currentCredentials(),t.Auth={credentials:this.currentUser,region:t.aws_project_region,userPoolId:t.aws_user_pools_id,userPoolWebClientId:t.aws_user_pools_web_client_id},t.aws_appsync_authenticationType="AWS_IAM",this.amplify.configure(t)}async requireInitAll(){null===this.amplify&&await this.initAmplify(),null===this.currentUser&&await this.initGuestUser()}}{async runQuery(t,e){return await this.requireInitAll(),Amplify.configure({API:{graphql_headers:async()=>({"My-Custom-Header":"my value"})}}),await this.amplify.API.graphql(this.amplify.graphqlOperation(t,e))}}class o extends i{constructor(){super(...arguments),this.siteContents=null}async getPage(t){return await this.runQuery("query GetPage($path: String!) {\n getPage(path: $path) {\n id\n site_group_id\n site_id\n path\n title\n name\n html\n created_at\n created_by_user_id\n publish_at\n unpublish_at\n is_head_revision\n revision_status\n page_type_id\n layout\n description\n robots\n image\n video\n audio\n into_head\n before_body\n path_aliases\n redirect_to\n keywords\n language_id\n allowed_role\n preview_key\n instance_id\n replacing_instance_id\n use_cache\n publish_timezone\n seo_title\n details\n }\n}\n",{path:t})}async requestSiteContents(){return await this.runQuery(a,{})}async getSiteContents(t=!0){t&&e.scrollToTop();let s=!1;return null===this.siteContents&&(this.siteContents=localStorage.getItem("siteData"),null===this.siteContents?(await this.updateSiteContents(),s=!0):this.siteContents=JSON.parse(this.siteContents)),s||this.updateSiteContents(),this.siteContents}async updateSiteContents(){const t=await this.requestSiteContents();this.siteContents=JSON.parse(t.data.getPagesContent.details),localStorage.setItem("siteData",JSON.stringify(this.siteContents))}async getPagesContent(){return await this.runQuery(a,{})}}class r extends i{async submitForm(t,e){return(await this.runQuery("mutation SubmitForm($data: FormSubmission) {\n submitForm(data: $data) {\n formPath\n result\n formData\n errors {\n inputName\n errors\n }\n }\n}\n",{data:{formData:JSON.stringify(e),formPath:t}})).data.submitForm}setGraphqlFormErrors(t,e){const n=e.errors;let a=!1,i=[],o=!1;for(let _ in t)if(t[_]instanceof s){let e=!1;n&&n.length>0&&n.forEach(n=>{if(t[_].name===n.inputName){if(t[_]=new s(Object.assign(Object.assign({},t[_]),{errorText:n.errors.join("\n")})),!o&&t[_].id){var r=document.getElementById(t[_].id);r&&(r.scrollIntoView(),o=!0)}i.push(n.inputName),e=!0,a=!0}}),e||(t[_]=new s(Object.assign(Object.assign({},t[_]),{errorText:null}))),t[_].refreshAfterSubmit&&(t[_]=new s(Object.assign(Object.assign({},t[_]),{value:null})))}if(!n||!n.length||!a){if(n&&n.length){let e=[];n.forEach(t=>{i.includes(t.inputName)||e.push({message:t.errors.join("\n")})}),e.length>0&&(t.formErrors=e)}else t.formErrors=[{message:"Internal server error, please contact administrator"}];if(!o){var r=document.getElementById("common-form-errors");r&&(r.scrollIntoView(),o=!0)}}}setAwsError(t,e){var s;t.formErrors=[{code:e.code,message:(s=e.message,s.includes("UserMigration failed with error ")?s.substr("UserMigration failed with error ".length):s)}]}setFormErrors(t,e){this.isAwsError(e)?this.setAwsError(t,e):this.isGraphqlErrorResponse(e)?this.setGraphqlFormErrors(t,e):t.formErrors=[{message:"Internal server error, please contact administrator"}]}isAwsError(t){return t&&t.code&&t.name&&t.message}isGraphqlErrorResponse(t){return t&&t.errors}}let _;_={apiKey:"AIzaSyAEfWLUiJQxspkSK1j_XvM01pJzH_ADiDI",authDomain:"resourceville-com.firebaseapp.com",databaseURL:"https://resourceville-com.firebaseio.com",projectId:"resourceville-com",storageBucket:"resourceville-com.appspot.com",messagingSenderId:"482640812130",appId:"1:482640812130:web:9e9181c6e9b34b3e22993b",measurementId:"G-97M9J5V38K"};const c=_;class l extends i{async saveFcmToken(t){return await this.runQuery("mutation SubmitFirebaseDeviceToken($token: String) {\n submitFirebaseDeviceToken(token: $token)\n}\n",{token:t})}initSubscription(){const t=window.firebase&&!window.firebase.apps.length?window.firebase.initializeApp(c):window.firebase;navigator.serviceWorker.ready.then(e=>{t&&(t.messaging().useServiceWorker(e),t.messaging().requestPermission().then(async()=>{const e=await t.messaging().getToken();this.saveFcmToken(e).then(()=>{})}).catch(t=>{console.log("push notifications is blocked",t)}),t.messaging().onTokenRefresh(()=>{t.messaging().getToken().then(t=>{this.saveFcmToken(t)}).catch((function(t){console.log("push notifications is blocked",t)}))}),t.messaging().onMessage(t=>{e.showNotification(t.data["pinpoint.notification.title"],{body:t.data["pinpoint.notification.body"],icon:t.data["pinpoint.notification.icon"]?t.data["pinpoint.notification.icon"]:"assets/img/mville/logo.png",data:{url:t.data["pinpoint.url"]}})}))})}}const d=t=>((t,e="s")=>t.replace(new RegExp("^["+e+"]+"),""))(t,"/"),h=t=>((t,e="s")=>t.replace(new RegExp("["+e+"]+$"),""))(t,"/"),u="consent_data.consent_steps.how_to_share.title",p="consent_data.consent_steps.how_to_share.list.inputs.{index}",g="consent_data.consent_steps.how_to_contact.title",m="consent_data.consent_steps.how_to_contact.list.inputs.{index}",b="consent_data.consent_steps.signed_by.title",A="consent_data.consent_steps.signed_by.list.links.{index}",T="consent_data.consent_steps.how_to_use",w="consent_data.consent_steps.how_to_use.input_label",y="consent_data.consent_steps.how_to_use.title",E="consent_data.consent_steps.how_to_use.label",f="consent_data.consent_steps.is_legal_age.message",S="consent_data.consent_steps.is_legal_age",I="consent_data.consent_steps.is_legal_age.input_label",D="signed_by",M="consent_data.consent_steps.signed_by",O="consent_data.consent_provided",v="consent_data.consent_provided.link_href",N="consent_data.consent_provided.link_label",C="form_type",k="default",j=Object.freeze({__proto__:null,MYDATA_VENDORS_TITLE:"consent_data.consent_steps.how_to_share.title",MYDATA_VENDOR_INPUT:p,MYDATA_VENDOR_INPUT_LABEL:"consent_data.consent_steps.how_to_share.list.inputs.{index}.input_label",MYDATA_CONTACT_METHODS_TITLE:"consent_data.consent_steps.how_to_contact.title",MYDATA_CONTACT_METHOD_INPUT:"consent_data.consent_steps.how_to_contact.list.inputs.{index}",MYDATA_CONTACT_METHOD_INPUT_LABEL:"consent_data.consent_steps.how_to_contact.list.inputs.{index}.input_label",MYDATA_TERMS_PRIVACY_TITLE:"consent_data.consent_steps.signed_by.title",MYDATA_TERMS_PRIVACY_LINK:"consent_data.consent_steps.signed_by.list.links.{index}",MYDATA_TERMS_PRIVACY_INPUT:"consent_data.consent_steps.how_to_use",MYDATA_TERMS_PRIVACY_INPUT_LABEL:"consent_data.consent_steps.how_to_use.input_label",MYDATA_HOW_TO_USE_TITLE:"consent_data.consent_steps.how_to_use.title",MYDATA_HOW_TO_USE_CONTENT:"consent_data.consent_steps.how_to_use.label",MYDATA_AGE_VERIFICATION_TITLE:"consent_data.consent_steps.is_legal_age.message",MYDATA_AGE_VERIFICATION_INPUT:"consent_data.consent_steps.is_legal_age",MYDATA_AGE_VERIFICATION_INPUT_LABEL:"consent_data.consent_steps.is_legal_age.input_label",MYDATA_SIGNED_BY_EMAIL:"signed_by",MYDATA_SIGNED_BY_INPUT:"consent_data.consent_steps.signed_by",MYDATA_SIGNED_BY_MESSAGE:"consent_data.consent_steps.signed_by.message",MYDATA_REVOKE_CONSENT_LINK:"consent_data.consent_provided",MYDATA_REVOKE_CONSENT_LINK_HREF:"consent_data.consent_provided.link_href",MYDATA_REVOKE_CONSENT_LINK_LABEL:"consent_data.consent_provided.link_label",MYDATA_FORM_TYPE:"form_type",MYDATA_DEFAULT_FORM_ID:"default"});class x{constructor(){this.consentObjs={},this.getConsentFormRequest=this.getConsentFormRequest.bind(this),this.getSubmitFormRequest=this.getSubmitFormRequest.bind(this)}get baseUrl(){return h(n.myDataBaseUrl)}get appUrl(){return h(n.siteBaseUrl)}initConfig(){window.mydataConfig&&(window.mydataConfig.currentUrl=this.appUrl)}get currentUrl(){return`${this.appUrl}/${d(window.location.pathname)}`}getMyDataUrl(){return`${this.baseUrl}/form-consent?url=${encodeURIComponent(this.appUrl)}`}getSubmitUrl(){return this.baseUrl+"/save-consent"}async getConsentFormRequest(){const t=await fetch(this.getMyDataUrl());return await t.json()}getConsentFormJson(){return this.consentForm?rxjs.of(this.consentForm):(this.consentObservable||(this.consentObservable=rxjs.defer(this.getConsentFormRequest).pipe(rxjs.operators.retry(3),rxjs.operators.map(t=>(this.consentObservable=null,this.consentForm=t,this.consentForm)),rxjs.operators.share())),this.consentObservable)}getSubmitFormRequest(t){return fetch(this.getSubmitUrl(),{method:"POST",body:JSON.stringify(this.getConsentObj(t)),headers:{Accept:"application/json","Content-Type":"application/json"}})}submitConsent(t="default"){this.addRequiredVendors(t),this.addRequiredContactMethods(t),rxjs.of(this.getSubmitFormRequest(t)).pipe(rxjs.operators.retry(3)).subscribe()}setConsentData(t,e,s="default"){const n=this.getConsentObj(s),a=t.split(".");a.reduce((t,s,n)=>(t[s]||(t[s]={}),n===a.length-1&&(t[s]="object"==typeof e?Object.assign(t[s],e):e),t[s]),n)}addRequiredVendors(t="default"){this.getConsentFormJson().subscribe(e=>{const s=this.getConsentObj(t),n=s.consent_data.consent_steps.how_to_share.list.inputs.map(t=>t.vendor_key),a=e.consent_steps.how_to_share.list.inputs.filter(t=>t.required&&!n.includes(t.vendor_key));s.consent_data.consent_steps.how_to_share.list.inputs.push(...a.map(t=>Object.assign(Object.assign({},t),{checked:!0})))})}addRequiredContactMethods(t="default"){this.getConsentFormJson().subscribe(e=>{const s=this.getConsentObj(t),n=s.consent_data.consent_steps.how_to_contact.list.inputs.map(t=>t.input_label),a=e.consent_steps.how_to_contact.list.inputs.filter(t=>t.required&&!n.includes(t.input_label));s.consent_data.consent_steps.how_to_contact.list.inputs.push(...a.map(t=>Object.assign(Object.assign({},t),{checked:!0})))})}getConsentObj(t="default"){return this.consentObjs[t]||(this.consentObjs[t]=this.getNewConsentObj()),this.consentObjs[t]}getMyDataLinkUrl(t,e){return`${0===t.indexOf("http")||0===t.indexOf("//")?t:`${this.baseUrl}/${d(t)}`}?url=${encodeURIComponent(e)}`}getMyDataPath(t,e){return j[t]?j[t].replace("{index}",String(e||"0")):t.replace("{index}",String(e||"0"))}getNewConsentObj(){return{url:this.currentUrl,signed_by:"",consent_data:{head_checkbox_label:"",eu_resident_label:"",not_eu_resident_label:"",index:"",selected_radio:"",consent_provided:{title:"",title_on_refresh:"",link_href:"",link_label:""},consent_steps:{is_legal_age:{message:"",input_type:"",input_label:"",already_used_label:"",already_used_link:""},how_to_use:{title:"",label:"",input_type:"",input_label:""},how_to_contact:{title:"",list:{inputs:[]}},how_to_share:{title:"",list:{inputs:[]}},signed_by:{message:"",title:"",input_type:"",input_placeholder:"",list:{links:[]}}}}}}checkTermsAgreed(t){let e=t.querySelector("my-data-terms-agreement #my-data-terms-agree-checkbox-default");return null!=e&&(e.checked?(this.unsetTermsAgreeHighlighted(t),!0):(this.setTermsAgreeHighlighted(t),!1))}setTermsAgreeHighlighted(t){let e=t.querySelector("my-data-terms-agreement #my-data-terms-agree-text-container-default");null!=e&&(e.classList.contains("agreement-required")||e.classList.add("agreement-required"))}unsetTermsAgreeHighlighted(t){let e=t.querySelector("my-data-terms-agreement #my-data-terms-agree-text-container-default");null!=e&&e.classList.contains("agreement-required")&&e.classList.remove("agreement-required")}}class Y{constructor(){this.userAuthToken=null,this.userAuthTokenExpirationDate=null,this.userRefreshToken=null,this.currentRoute=null}testMethod(){console.log("Test method!")}}class R{constructor(){this._serviceInstances={}}static injector(){return this._mainInjectorInstance||(this._mainInjectorInstance=new R),this._mainInjectorInstance}get pageService(){return this._getOrCreateService("pageService",()=>new o)}get formSubmitService(){return this._getOrCreateService("formSubmitService",()=>new r)}get myDataService(){return this._getOrCreateService("myDataService",()=>new x)}get tokenService(){return this._getOrCreateService("tokenService",()=>new Y)}_getOrCreateService(t,e){return this._serviceInstances[t]||(this._serviceInstances[t]=e()),this._serviceInstances[t]}get pushMessagesService(){return this._getOrCreateService("pushMessages",()=>new l)}}export{R as A,k as M,f as a,I as b,C as c,u as d,g as e,E as f,y as g,D as h,M as i,T as j,S as k,m as l,p as m,O as n,v as o,N as p,A as q,b as r,w as s}