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,EAAQ0D,eAAeO,OAC9C,GAGDjE,EAAQyD,gBAAkB,IAAMzD,EAAQ0D,eAAeO,OAAS,GAAK,IAG/ElC,iCAAkCA,CAAChH,EAAOiF,KACjC,CACLa,OAAQ,GAAGb,EAAQuE,6BACnBzD,SAAU,wBAIdgB,iCAAkCA,CAAC+B,EAAQ7D,IAClC,GAAGA,EAAQuE,8BClFtB,M,SACKQ,EAGH3D,UAAW,KAGXf,UAAW,KAGXwC,kBAAkB,EAIlBlB,iBAAkB,KAGlB7E,UAAW,GACXsF,aAAc,KAGdlC,sBAAsB,EAGtBsC,mBAAoB,KAGpB7F,OAAQ,CACNC,iBAAkB,KAClBI,cAAe,KACfgI,mCAAmC,EACnCC,eAAgB,KAChBC,MAAO,GACPC,IAAK,GACLC,KAAM,GACNC,IAAK,GACLT,aAAc,KACd/E,SAAU,KACVyF,UAAW,CAAC,GAGdlK,iBAAkB,CAAC,EAGnBsG,eAAgB,KAChBQ,6BAA8B,KAC9BjB,eAAe,EACfsE,cAAc,GC1CD,SAASC,IACtB,MAAMC,EAAKC,SAASC,cAAc,iEAC5B,YAAE5E,KAAgB6E,GAAiBvB,KAAKwB,MAAMJ,EAAGK,QAAQC,WAEzDhL,EAAQ,IAAIiL,KAAiBJ,GAE7BK,GAAQC,EAAAA,EAAAA,IAAY,CACxBnL,QACAiF,QAAO,EACPmG,UAAS,EACTC,QACF,IAIA,OAFAH,EAAMzG,OAAO,kBAAmBuB,GAEzBkF,CACT,C","sources":["webpack://agra/./app/javascript/campaign-form-shared/store/mutations.js","webpack://agra/./app/javascript/campaign-form-shared/store/state.js","webpack://agra/./app/javascript/campaign-form-shared/store/actions.js","webpack://agra/./app/javascript/campaign-form-shared/store/getters.js","webpack://agra/./app/javascript/petition/start/store/actions.js","webpack://agra/./app/javascript/petition/start/store/mutations.js","webpack://agra/./app/javascript/petition/start/store/getters.js","webpack://agra/./app/javascript/petition/start/store/state.js","webpack://agra/./app/javascript/petition/start/store/index.js"],"sourcesContent":["export default {\n setPublishUrl(state, publishUrl) {\n state.publishUrl = publishUrl\n },\n\n setLinkUserUrl(state, linkUserUrl) {\n state.linkUserUrl = linkUserUrl\n },\n\n setValidationErrors(state, validationErrors) {\n state.validationErrors = validationErrors\n },\n\n setAuthenticationModalData(state, authenticationModalData) {\n state.authenticationModalData = Object.assign(state.authenticationModalData, authenticationModalData)\n },\n\n setDisplayMissingInfoModal(state, { value, requiredFields }) {\n state.displayMissingInfoModal = value\n state.missingInfoRequiredFields = requiredFields\n },\n\n setDisplayUserAccountCreationAwaitingEmailConfirmation(state, { value, userEmail }) {\n state.displayUserAccountCreationAwaitingEmailConfirmation = value\n state.userEmailAddressAwaitingConfirmation = userEmail\n },\n\n setDisplayVerifyMfaTokenModal(state, { value, mfaParameters }) {\n state.displayVerifyMfaTokenModal = value\n state.mfaParameters = mfaParameters\n },\n\n setDisplayAuthenticationModal(state, displayAuthenticationModal) {\n state.displayAuthenticationModal = displayAuthenticationModal\n },\n\n setDisplayAwaitingApprovalModal(state, displayAwaitingApprovalModal) {\n state.displayAwaitingApprovalModal = displayAwaitingApprovalModal\n },\n\n setStaffLedCampaign: (state, newStaffLedCampaign) => {\n state.values.staffLedCampaign = newStaffLedCampaign\n\n // If the partnership selection field is present, clear its value since a staff-led\n // campaign can't belong to a partnership.\n // We use different property names for the petition and event stores\n if ((state.fields || state.allFields || []).includes('partnershipId')) {\n state.values.partnershipId = null\n }\n }\n}\n","export default {\n // Where to submit to publish after user authenticates\n publishUrl: null,\n\n // Where to submit to link user to new campaign\n linkUserUrl: null,\n\n // Text to display on the form, organised by field\n content: {},\n\n // Extra parameters we should submit with the form\n extraParameters: {},\n\n // If the user can choose to associate the event with a partnership, the list of options\n partnershipOptions: [],\n\n // Flag indicating if the \"campaign awaiting approval\" modal should be displayed\n displayAwaitingApprovalModal: false,\n\n //// Sign in / sign up properties\n authenticationModalData: {\n // SSO options\n enableFacebookLogin: false,\n facebookLoginUrl: null,\n enableGoogleLogin: false,\n googleLoginUrl: null,\n\n askForCountry: null,\n countryData: null,\n askForPostcode: null,\n phoneNumberMandatory: null,\n\n emailOptInTypeData: null,\n\n newAccountDisclaimer: null,\n\n // EU Data processing consent\n showEuDataProcessingConsent: false,\n euDataProcessingConsentData: null,\n\n termsOfServiceData: null,\n\n organisationId: null,\n additionalFieldConfigs: []\n },\n\n // Flag indicating if the user authentication modal should be displayed\n displayAuthenticationModal: false,\n\n // Flag indicating if the modal notifying user that account creation is pending\n // email confirmation should be displayed\n displayUserAccountCreationAwaitingEmailConfirmation: false,\n\n // Flag indicating if the MFA token verification modal should be displayed\n displayVerifyMfaTokenModal: false,\n\n // Flag indicating if the modal to collect missing user account info should be displayed\n displayMissingInfoModal: false,\n\n // Error message for non recoverable error during sign up (e.g.: member is banned)\n nonRecoverableErrorOnSignup: null,\n\n // Email address of the user that's awaiting to be confirmed\n userEmailAddressAwaitingConfirmation: null,\n\n // Setup information for the MFA token verification modal\n mfaParameters: {\n userId: null,\n statusCheckPath: null,\n supportsSms: false,\n tokenHelpText: null,\n verifyTokenPath: null\n },\n\n // Setup information for the Missing Info modal\n missingInfoRequiredFields: []\n}\n","import ajax from '../../helpers/ajax'\n\nexport default {\n linkCampaignWithUnconfirmedUser({ state }, userToken) {\n ajax.put({\n url: state.linkUserUrl,\n data: {\n user_token: userToken\n },\n errorHandler: (response) => {\n window.errorLogger.error(`Error linking campaign with user: ${response}`)\n }\n })\n }\n}\n","export default {\n isStaffLedCampaign(state) {\n return state.values.staffLedCampaign === true\n }\n}\n","import sharedActions from '@/campaign-form-shared/store/actions'\nimport ajax from '@/helpers/ajax'\nimport { objectKeysToSnakeCase } from '@/helpers/transform-object-keys'\nimport { trackEvent } from '@/analytics/track'\n\nfunction createPetitionStart({ state, commit, dispatch }) {\n commit('setSubmitInProgress', true)\n\n return new Promise((resolve) => {\n ajax.post({\n url: state.createUrl,\n data: {\n petition: objectKeysToSnakeCase({\n ...state.values,\n locale: state.extraParameters.locale,\n source: state.extraParameters.source,\n source_partnership: state.extraParameters.source_partnership,\n external_action_id: state.extraParameters.external_action_id\n })\n },\n successHandler: (response) => {\n if (response.success) {\n commit('setPetitionStartToken', response.petition.token)\n commit('setUpdateUrl', response.updateUrl)\n commit('setPublishUrl', response.publishUrl)\n commit('setRequestHelpUrl', response.requestHelpUrl)\n commit('setPetitionStartCreated', true)\n commit('setCurrentField', response.petition.currentStep)\n commit('setPetitionStartUrl', response.petitionStartUrl)\n\n dispatch('trackFieldShown')\n\n // Clear validation errors\n commit('setValidationErrors', {})\n } else {\n commit('setValidationErrors', response.validationErrors)\n }\n\n commit('setSubmitInProgress', false)\n resolve(response.success)\n }\n })\n })\n}\n\nfunction updatePetitionStart({ state, commit, getters, dispatch }) {\n commit('setSubmitInProgress', true)\n\n return new Promise((resolve) => {\n ajax.put({\n url: state.updateUrl,\n data: {\n petition: objectKeysToSnakeCase(state.values)\n },\n successHandler: (response) => {\n if (response.success) {\n if (response.finished) {\n // Last step is either authenticating the user to associate with the new petition\n // or redirecting to the petition page (if the user was already signed in)\n if (response.requiresAuthentication) {\n if (response.forceSingleSignOn) {\n window.location = response.singleSignOnRedirect.url\n } else {\n commit('setAuthenticationModalData', response.authenticationModalData)\n commit('setDisplayAuthenticationModal', true)\n commit('setLinkUserUrl', response.linkUserUrl)\n\n trackEvent(\n 'Login/Signup Modal Shown',\n {\n action: 'auth-modal-shown',\n category: 'petition-start-form'\n }\n )\n }\n } else if (response.requiresApproval) {\n commit('setDisplayAwaitingApprovalModal', true)\n } else if (response.redirectUrl) {\n window.location = response.redirectUrl\n }\n } else {\n commit('setCurrentField', response.petition.currentStep)\n dispatch('trackFieldShown')\n }\n\n // Clear validation errors\n commit('setValidationErrors', {})\n commit('clearRequestHelpPrompt')\n } else {\n commit('setValidationErrors', response.validationErrors)\n\n if (response.helpPromptEnabled && !state.helpRequested) {\n commit('setRequestHelpPromptOnField', getters.firstFieldWithError)\n } else {\n commit('clearRequestHelpPrompt')\n }\n }\n\n commit('setSubmitInProgress', false)\n resolve(response.success)\n }\n })\n })\n}\n\nexport default {\n ...sharedActions,\n\n publish({ state, commit }) {\n commit('setSubmitInProgress', true)\n\n ajax.post({\n url: state.publishUrl,\n successHandler: (response) => {\n commit('setSubmitInProgress', false)\n if (response.success) {\n if (response.requiresApproval) {\n commit('setDisplayAwaitingApprovalModal', true)\n } else {\n window.location = response.redirectUrl\n }\n }\n }\n })\n },\n\n submitField({ state, commit, getters, dispatch }) {\n if (!state.petitionStartCreated) {\n return createPetitionStart({ state, commit, dispatch })\n } else {\n return updatePetitionStart({ state, commit, getters, dispatch })\n }\n },\n\n trackFieldShown({ getters }) {\n trackEvent(\n getters.trackingEventNameForCurrentField,\n getters.trackingEventDataForCurrentField\n )\n }\n}\n","import sharedMutations from '@/campaign-form-shared/store/mutations'\n\nexport default {\n ...sharedMutations,\n clearRequestHelpPrompt(state) {\n state.fieldToShowRequestHelpPrompt = null\n },\n\n setCurrentField(state, currentField) {\n state.currentField = currentField\n },\n\n setHelpRequested(state) {\n state.helpRequested = true\n },\n\n setPetitionStartCreated(state, value) {\n state.petitionStartCreated = value\n },\n\n setPetitionStartToken(state, token) {\n state.petitionStartToken = token\n },\n\n setPetitionStartUrl(state, petitionStartUrl) {\n state.petitionStartUrl = petitionStartUrl\n history.pushState({ token: state.petitionStartToken }, '', state.petitionStartUrl)\n },\n\n setSubmitInProgress(state, value) {\n state.submitInProgress = value\n },\n\n setNonRecoverableErrorOnSignup(state, errorMessage) {\n state.nonRecoverableErrorOnSignup = errorMessage\n },\n\n setUpdateUrl(state, updateUrl) {\n state.updateUrl = updateUrl\n },\n\n setRequestHelpUrl(state, requestHelpUrl) {\n state.requestHelpUrl = requestHelpUrl\n },\n\n setRequestHelpPromptOnField(state, field) {\n state.fieldToShowRequestHelpPrompt = field\n },\n\n setValue(state, {field, value}) {\n state.values[field] = value\n\n // Clear error on field if there was one\n if (state.validationErrors[field]) {\n let clonedValidationErrors = Object.assign({}, state.validationErrors)\n delete clonedValidationErrors[field]\n\n state.validationErrors = clonedValidationErrors\n }\n }\n}\n","import camelCase from 'lodash/camelCase'\nimport memberFacingCampaignFormGetters from '@/campaign-form-shared/store/getters'\n\nexport default {\n ...memberFacingCampaignFormGetters,\n\n contentForNextField: (state, getters) => {\n return state.content[getters.nextField]\n },\n\n currentFieldIdx: (state, getters) => {\n return getters.filteredFields.indexOf(state.currentField)\n },\n\n currentlyShownFields: (_state, getters) => {\n return getters.filteredFields.slice(0, getters.currentFieldIdx + 1)\n },\n\n filteredFields: (state) => {\n // We don't display the partnership field if the petition is staff-led\n if (state.values.staffLedCampaign) {\n return state.allFields.filter((field) => field !== 'partnershipId')\n } else {\n return state.allFields\n }\n },\n\n firstFieldWithError: (state, getters) => {\n if (Object.keys(state.validationErrors).length === 0) {\n return null\n }\n\n for (let fieldIndex in getters.filteredFields) {\n const fieldName = getters.filteredFields[fieldIndex]\n if (state.validationErrors[camelCase(fieldName)]) {\n return fieldName\n }\n }\n\n throw `Could not find field for validation error. Validation errors: ${JSON.stringify(state.validationErrors)}`\n },\n\n lastShownField: (_state, getters) => {\n const shownFields = getters.currentlyShownFields\n return shownFields[shownFields.length - 1]\n },\n\n nextField: (_state, getters) => {\n return getters.filteredFields[getters.currentFieldIdx + 1]\n },\n\n onFirstField: (_state, getters) => {\n return getters.currentFieldIdx === 0\n },\n\n onLastField: (state, getters) => {\n return getters.currentFieldIdx + 1 === getters.filteredFields.length\n },\n\n pendingGeocodingOnNextSubmit: (state) => {\n // Location field is visible, user chose 'local' option but geocoded location is missing\n return state.values.locationKind === 'local' &&\n (!state.values.location || !state.values.location.latitude)\n },\n\n progressPercentage: (state, getters) => {\n // This is the case before the index, fields are initialized and\n // returning 0 before initialization is necessary to make the\n // progress bar animate from 0 to the actual value (instead of from 100%).\n if (getters.currentFieldIdx === getters.filteredFields.length) {\n return 0\n }\n // Starts with it partially filled in (1 / (#fields + 1))\n return (getters.currentFieldIdx + 1) / (getters.filteredFields.length + 1) * 100\n },\n\n trackingEventDataForCurrentField: (state, getters) => {\n return {\n action: `${getters.lastShownField}-field-shown`,\n category: 'petition-start-form'\n }\n },\n\n trackingEventNameForCurrentField: (_state, getters) => {\n return `${getters.lastShownField} Field Shown`\n }\n}\n","import sharedState from '@/campaign-form-shared/store/state'\n\nexport default {\n ...sharedState,\n\n // Where to submit to create the petition start\n createUrl: null,\n\n // Where to submit to update the petition start\n updateUrl: null,\n\n //\n submitInProgress: false,\n\n // The petition start's URL once it has been created. This allows users to browse back and continue\n // with the petititon start process if they leave the page\n petitionStartUrl: null,\n\n // The list of all fields on the form, and which one we're currently on\n allFields: [],\n currentField: null,\n\n // Flag indicating if the petition start has been already created or not\n petitionStartCreated: false,\n\n // Petition start's token, should only have a value if it has been already created\n petitionStartToken: null,\n\n // When the form has been submitted, submitted values and validation errors by field\n values: {\n staffLedCampaign: null,\n partnershipId: null,\n cannotChangeAssociatedPartnership: false,\n localChapterId: null,\n title: '',\n who: '',\n what: '',\n why: '',\n locationKind: null,\n location: null,\n utmParams: {}\n },\n\n validationErrors: {},\n\n // State for the Get Help form\n requestHelpUrl: null,\n fieldToShowRequestHelpPrompt: null,\n helpRequested: false,\n userLoggedIn: false\n}\n","import { createStore } from 'vuex'\n\nimport actions from './actions'\nimport mutations from './mutations'\nimport getters from './getters'\nimport defaultState from './state'\n\nexport default function buildStore() {\n const el = document.querySelector('.vue-component-loader[data-component-name=petitionStartForm]')\n const { currentStep, ...initialState } = JSON.parse(el.dataset.storeData)\n\n const state = {...defaultState, ...initialState}\n\n const store = createStore({\n state,\n getters,\n mutations,\n actions\n })\n\n store.commit('setCurrentField', currentStep)\n\n return store\n}\n"],"names":["setPublishUrl","state","publishUrl","setLinkUserUrl","linkUserUrl","setValidationErrors","validationErrors","setAuthenticationModalData","authenticationModalData","Object","assign","setDisplayMissingInfoModal","value","requiredFields","displayMissingInfoModal","missingInfoRequiredFields","setDisplayUserAccountCreationAwaitingEmailConfirmation","userEmail","displayUserAccountCreationAwaitingEmailConfirmation","userEmailAddressAwaitingConfirmation","setDisplayVerifyMfaTokenModal","mfaParameters","displayVerifyMfaTokenModal","setDisplayAuthenticationModal","displayAuthenticationModal","setDisplayAwaitingApprovalModal","displayAwaitingApprovalModal","setStaffLedCampaign","newStaffLedCampaign","values","staffLedCampaign","fields","allFields","includes","partnershipId","content","extraParameters","partnershipOptions","enableFacebookLogin","facebookLoginUrl","enableGoogleLogin","googleLoginUrl","askForCountry","countryData","askForPostcode","phoneNumberMandatory","emailOptInTypeData","newAccountDisclaimer","showEuDataProcessingConsent","euDataProcessingConsentData","termsOfServiceData","organisationId","additionalFieldConfigs","nonRecoverableErrorOnSignup","userId","statusCheckPath","supportsSms","tokenHelpText","verifyTokenPath","linkCampaignWithUnconfirmedUser","userToken","ajax","put","url","data","user_token","errorHandler","response","window","errorLogger","error","isStaffLedCampaign","sharedActions","publish","commit","post","successHandler","success","requiresApproval","location","redirectUrl","submitField","getters","dispatch","petitionStartCreated","Promise","resolve","updateUrl","petition","objectKeysToSnakeCase","finished","requiresAuthentication","forceSingleSignOn","singleSignOnRedirect","trackEvent","action","category","currentStep","helpPromptEnabled","helpRequested","firstFieldWithError","updatePetitionStart","createUrl","locale","source","source_partnership","external_action_id","token","requestHelpUrl","petitionStartUrl","createPetitionStart","trackFieldShown","trackingEventNameForCurrentField","trackingEventDataForCurrentField","sharedMutations","clearRequestHelpPrompt","fieldToShowRequestHelpPrompt","setCurrentField","currentField","setHelpRequested","setPetitionStartCreated","setPetitionStartToken","petitionStartToken","setPetitionStartUrl","history","pushState","setSubmitInProgress","submitInProgress","setNonRecoverableErrorOnSignup","errorMessage","setUpdateUrl","setRequestHelpUrl","setRequestHelpPromptOnField","field","setValue","clonedValidationErrors","memberFacingCampaignFormGetters","contentForNextField","nextField","currentFieldIdx","filteredFields","indexOf","currentlyShownFields","_state","slice","filter","keys","length","fieldIndex","fieldName","camelCase","JSON","stringify","lastShownField","shownFields","onFirstField","onLastField","pendingGeocodingOnNextSubmit","locationKind","latitude","progressPercentage","sharedState","cannotChangeAssociatedPartnership","localChapterId","title","who","what","why","utmParams","userLoggedIn","buildStore","el","document","querySelector","initialState","parse","dataset","storeData","defaultState","store","createStore","mutations","actions"],"sourceRoot":""}