{"version":3,"sources":["webpack:///./src/views/ListingMakeAnOffer.vue?d0ae","webpack:///./src/views/ListingMakeAnOffer.vue","webpack:///./src/views/ListingMakeAnOffer.vue?b4d9","webpack:///./src/views/ListingMakeAnOffer.vue?ba71","webpack:///./src/components/Forms/Form.vue?f8f5","webpack:///./node_modules/client-website-ts-library/plugins/view/index.ts","webpack:///./src/components/Forms/Form.vue?4717","webpack:///./src/components/Forms/Form.vue","webpack:///./src/components/Forms/Form.vue?d965","webpack:///./src/components/Forms/Form.vue?4d45"],"names":["render","_vm","this","_h","$createElement","_c","_self","attrs","listing","Address","FullAddress","Images","Preview","Url","formData","_e","staticRenderFns","Listings","Get","$route","params","id","then","ClientWebsiteId","Website","Id","Items","Type","Context","Listing","components","Form","component","prolistAnalyticsService","ServiceManager","Analytics","headService","Require","Head","evt","obj","getAnalyticsEvent","call","getAnalyticsData","path","name","undefined","triggerAnalyticsEvent","event","GetAll","forEach","adapter","Record","result","head","bind","Promise","meta","Update","UpdateWithStatic","View","requestAnimationFrame","updateHead","updateAnalytics","AsyncView","$on","staticClass","style","fieldBg","loading","on","loadAutosave","_v","_s","autosaveDate","domProps","definition","Options","SubmittedText","_l","section","key","SectionId","ref","refInFor","errors","ctx","type","handleFieldInput","class","submitButtonClass","submitButtonColour","submitButtonBackgroundColour","submitForm","SubmitButtonText","context","errored","submitted","autosaveManager","FormAutosave","hasAutosave","submitPercent","recaptchaService","ReCaptcha","progress","total","Math","round","console","log","Forms","GetForm","def","enableAutosave","state","GetState","catch","Sections","sectionComponent","$refs","setData","fieldDef","filter","err","Key","collectData","data","normalisedData","normaliseData","SubmitForm","Valid","Submitted","$emit","resetRecaptcha","ValidationState","Errors","newValues","entry","Value","Array","length","push","i","includeRecaptcha","resolve","reject","getRecaptchaResponse","recaptchaResponse","Log","Debug","Reset","GetResponse","default","Section","Loader"],"mappings":"yHAAA,IAAIA,EAAS,WAAa,IAAIC,EAAIC,KAASC,EAAGF,EAAIG,eAAmBC,EAAGJ,EAA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AIjB,gBADC,eAAK,CAAEA,QAAS,qC,mCAIjB,gBADC,eAAK,CAAEA,QAAS,kC,qCAIjB,gBADC,eAAK,CAAEA,QAAS,sC,yCArCE,EAAI,kBANxB,eAAU,CACT1H,WAAY,CACV2H,UAAA,KACAC,SAAA,SAGiB,WCtE4X,I,wBCQ7Y1H,EAAY,eACd,EACAhC,EACAgB,GACA,EACA,KACA,WACA,MAIa,OAAAgB,E","file":"js/chunk-4a2c4b2d.652c3508.js","sourcesContent":["var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('Page',[(_vm.listing)?[_c('SiteMasthead',{attrs:{\"mini\":\"true\",\"title\":\"Make an Offer\",\"subtitle\":_vm.listing.Address.FullAddress,\"darken\":\"true\",\"image\":_vm.listing.Images[0].Preview.Url}}),_c('ContentRow',[_c('ContentContainer',[_c('Form',{attrs:{\"context\":_vm.formData,\"type\":\"Variations.TSPropertyGroup.MakeAnOfferForm\"}})],1)],1)]:_vm._e()],2)}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","\n\n\n\n\n\n\n\n\n\n\n\n\n\nimport { AsyncView } from 'client-website-ts-library/plugins';\nimport { API, Config } from 'client-website-ts-library/services';\nimport { Listing } from 'client-website-ts-library/types';\nimport { Component, Mixins } from 'vue-property-decorator';\n\nimport Form from '@/components/Forms/Form.vue';\nimport { FormConstructorData } from 'client-website-ts-library/types/Forms';\nimport { ContextItemType } from 'client-website-ts-library/types/Context';\n\n@Component({\n components: {\n Form,\n },\n})\nexport default class ListingMakeAnOffer extends Mixins(AsyncView) {\n private listing: Listing | null = null;\n\n private formData: FormConstructorData | null = null;\n\n mounted() {\n API.Listings.Get(this.$route.params.id).then((listing) => {\n this.listing = listing;\n\n this.formData = {\n ClientWebsiteId: Config.Website.Id,\n Items: [\n {\n Type: ContextItemType.Listing,\n Id: listing.Id,\n },\n ],\n };\n });\n }\n}\n","import mod from \"-!../../node_modules/cache-loader/dist/cjs.js??ref--14-0!../../node_modules/thread-loader/dist/cjs.js!../../node_modules/babel-loader/lib/index.js!../../node_modules/ts-loader/index.js??ref--14-3!../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../node_modules/vue-loader/lib/index.js??vue-loader-options!./ListingMakeAnOffer.vue?vue&type=script&lang=ts&\"; export default mod; export * from \"-!../../node_modules/cache-loader/dist/cjs.js??ref--14-0!../../node_modules/thread-loader/dist/cjs.js!../../node_modules/babel-loader/lib/index.js!../../node_modules/ts-loader/index.js??ref--14-3!../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../node_modules/vue-loader/lib/index.js??vue-loader-options!./ListingMakeAnOffer.vue?vue&type=script&lang=ts&\"","import { render, staticRenderFns } from \"./ListingMakeAnOffer.vue?vue&type=template&id=bcc40d8c&scoped=true&\"\nimport script from \"./ListingMakeAnOffer.vue?vue&type=script&lang=ts&\"\nexport * from \"./ListingMakeAnOffer.vue?vue&type=script&lang=ts&\"\n\n\n/* normalize component */\nimport normalizer from \"!../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n \"bcc40d8c\",\n null\n \n)\n\nexport default component.exports","export * from \"-!../../../node_modules/mini-css-extract-plugin/dist/loader.js??ref--6-oneOf-1-0!../../../node_modules/css-loader/dist/cjs.js??ref--6-oneOf-1-1!../../../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../../../node_modules/postcss-loader/src/index.js??ref--6-oneOf-1-2!../../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./Form.vue?vue&type=style&index=0&id=726d98f2&scoped=true&lang=css&\"","import Vue from \"vue\";\r\nimport { Component } from \"vue-property-decorator\";\r\nimport { AnalyticsEvent, AnalyticsEventObject, AnalyticsPageView, IAnalyticsAdapter, PROListAnalyticsAdapter } from \"../../services/Analytics\";\r\nimport { HeadService } from \"../../services/HeadService\";\r\nimport { ServiceManager, ServiceType } from \"../../services/ServiceManager\";\r\nimport { RouteMeta } from \"../meta\";\r\n\r\ninterface ViewBase {\r\n getAnalyticsEvent?(): AnalyticsEvent | null;\r\n getAnalyticsData?(): AnalyticsEventObject | null;\r\n head?(): RouteMeta | Promise | null;\r\n}\r\n\r\n@Component\r\nclass ViewBase extends Vue {\r\n protected prolistAnalyticsService = ServiceManager.Get(ServiceType.Analytics, 'PROListAnalyticsAdapter');\r\n protected headService = ServiceManager.Require(ServiceType.Head)!;\r\n\r\n public updateAnalytics() {\r\n let evt: AnalyticsEvent | null = null;\r\n let obj: AnalyticsEventObject | null = null;\r\n\r\n if (typeof this.getAnalyticsEvent !== 'undefined') {\r\n evt = this.getAnalyticsEvent.call(this);\r\n } else if(typeof this.getAnalyticsData !== 'undefined') {\r\n obj = this.getAnalyticsData.call(this);\r\n }\r\n\r\n if (evt === null) evt = new AnalyticsPageView(this.$route.path, this.$route.name || '', obj || undefined);\r\n\r\n this.triggerAnalyticsEvent(evt);\r\n }\r\n\r\n public triggerAnalyticsEvent(event: AnalyticsEvent) {\r\n ServiceManager.GetAll(ServiceType.Analytics).forEach((adapter) => {\r\n adapter.Record(event);\r\n });\r\n }\r\n\r\n public triggerCustomAnalyticsEvent(event: AnalyticsEvent) {\r\n if (this.prolistAnalyticsService !== null) this.prolistAnalyticsService.Record(event);\r\n }\r\n\r\n protected updateHead() {\r\n if ('head' in this) {\r\n const result = this.head!.bind(this)();\r\n\r\n if(result instanceof Promise) {\r\n result.then((meta: RouteMeta | null) => {\r\n this.headService.Update(meta);\r\n });\r\n } else {\r\n this.headService.Update(result as RouteMeta | null);\r\n }\r\n } else {\r\n this.headService.UpdateWithStatic(this.$route.path);\r\n }\r\n }\r\n}\r\n\r\n@Component\r\nclass View extends ViewBase {\r\n public mounted() {\r\n requestAnimationFrame(() => {\r\n this.updateHead();\r\n this.updateAnalytics();\r\n });\r\n }\r\n}\r\n\r\n@Component\r\nclass AsyncView extends ViewBase {\r\n public mounted() {\r\n this.$on('updateView', () => {\r\n requestAnimationFrame(() => {\r\n this.updateHead();\r\n this.updateAnalytics();\r\n });\r\n });\r\n }\r\n}\r\n\r\nexport {\r\n View,\r\n AsyncView\r\n}\r\n","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('form',{staticClass:\"form\",style:({'--field-bg': _vm.fieldBg})},[_c('Loader',{attrs:{\"loading\":_vm.loading}}),(_vm.hasAutosave)?_c('div',{staticClass:\"form__panel form__panel--autosaved\",on:{\"click\":_vm.loadAutosave}},[_c('p',[_vm._v(\" This form was autosaved at \"+_vm._s(_vm.autosaveDate)+\". Click here to load the autosave. \")])]):_vm._e(),(_vm.errored)?_c('div',{staticClass:\"form__panel form__panel--errored\"},[_c('p',[_vm._v(\" An error occurred. Please try again later. \")])]):_vm._e(),(_vm.definition)?[(_vm.submitted)?_c('div',{staticClass:\"form__panel form__panel--success\"},[_c('p',{domProps:{\"innerHTML\":_vm._s(_vm.definition.Options.SubmittedText)}})]):[_vm._l((_vm.definition.Sections),function(section){return _c('Section',{key:section.SectionId,ref:section.SectionId,refInFor:true,attrs:{\"def\":section,\"errors\":_vm.errors,\"form-context\":_vm.ctx,\"form-type\":_vm.type},on:{\"field_input\":_vm.handleFieldInput}})}),_c('div',{staticClass:\"center-text\"},[_c('Button',{staticClass:\"form__submit-btn\",class:_vm.submitButtonClass,attrs:{\"loading\":_vm.loading,\"colour\":_vm.submitButtonColour,\"background-colour\":_vm.submitButtonBackgroundColour},on:{\"click\":_vm.submitForm}},[_vm._v(_vm._s(_vm.definition.Options.SubmitButtonText))])],1)]]:_vm._e()],2)}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nimport { Component, Vue, Prop } from 'vue-property-decorator';\nimport { FormDefinition, FormSubmissionValidationError, FormField, FormValue } from 'client-website-ts-library/types/Forms';\nimport {\n AutosaveManager,\n ServiceManager,\n ServiceType,\n API,\n Config,\n Logger,\n LogLevel,\n ReCaptchaService,\n} from 'client-website-ts-library/services';\nimport { Context } from 'client-website-ts-library/types';\nimport { PDFFieldData } from 'client-website-ts-library/types/Forms/FieldTypes';\nimport { IRequestProgressDelegate } from 'client-website-ts-library/services/API/IRequestProgressDelegate';\n\nimport Section from './Section.vue';\nimport Loader from '../UI/Loader.vue';\n\n@Component({\n components: {\n Section,\n Loader,\n },\n})\nexport default class Form extends Vue implements IRequestProgressDelegate {\n @Prop({ default: () => ({ Items: [] }) })\n private readonly context!: Context;\n\n @Prop()\n private readonly type!: string;\n\n @Prop()\n private readonly submitButtonColour!: string;\n\n @Prop()\n private readonly submitButtonBackgroundColour!: string;\n\n @Prop()\n private readonly submitButtonClass!: string;\n\n @Prop()\n private readonly autosaveNamespace!: string;\n\n @Prop()\n private readonly enableAutosave!: boolean;\n\n @Prop({ default: 'var(--form-field-bg)' })\n private readonly fieldBg!: string;\n\n @Prop({ default: 'var(--form-field-colour)' })\n private readonly fieldColour!: string;\n\n @Prop({ default: 'var(--form-label-colour)' })\n private readonly labelColour!: string;\n\n @Prop({ default: 'var(--form-field-border-colour)' })\n private readonly borderColour!: string;\n\n @Prop({ default: 'var(--form-label-focused-bg)' })\n private readonly labelFocusedBg!: string;\n\n @Prop({ default: 'var(--form-label-focused-colour)' })\n private readonly labelFocusedColour!: string;\n\n private ctx: Context = this.context;\n\n private errored = false;\n\n private submitted = false;\n\n private errors: FormSubmissionValidationError[] = [];\n\n private loading = true;\n\n private definition: FormDefinition | null = null;\n\n private autosaveManager: AutosaveManager = ServiceManager.Require(ServiceType.FormAutosave);\n\n private hasAutosave = false;\n\n private autosaveDate: string | null = null;\n\n private submitPercent = 0;\n\n private recaptchaService = ServiceManager.Require(ServiceType.ReCaptcha) as ReCaptchaService;\n\n onProgress(progress: number, total: number) {\n this.submitPercent = Math.round((progress / total) * 100);\n\n console.log(this.submitPercent);\n }\n\n mounted() {\n if (this.ctx === null) {\n this.ctx = {\n Items: [],\n ClientWebsiteId: Config.Website.Id,\n };\n }\n\n if (this.ctx.ClientWebsiteId === undefined) {\n this.ctx.ClientWebsiteId = Config.Website.Id;\n }\n\n API.Forms.GetForm(this.type, this.context).then((def) => {\n this.loading = false;\n this.definition = def;\n\n if (this.enableAutosave) {\n const state = this.autosaveManager.GetState(this.type);\n\n if (state !== null) {\n this.hasAutosave = true;\n }\n }\n }).catch(() => {\n this.errored = true;\n });\n }\n\n loadAutosave(): void {\n if (!this.hasAutosave) return;\n\n const state = this.autosaveManager.GetState(this.type);\n\n if (state === null) return;\n\n this.definition!.Sections.forEach((section) => {\n const sectionComponent = (this.$refs[section.SectionId] as Vue[])[0] as Section;\n\n sectionComponent.setData(state);\n });\n }\n\n private handleFieldInput(fieldDef: FormField): void {\n this.errors = this.errors.filter((err) => err.Key !== fieldDef.Key);\n }\n\n submitForm(): void {\n if (this.loading) return;\n\n this.loading = true;\n\n this.errors = [];\n\n this.collectData(true).then((data) => {\n const normalisedData = Form.normaliseData(data);\n\n console.log(normalisedData);\n\n this.loading = false;\n\n // this.context.ClientWebsiteId = Config.Website.Id;\n\n // if (this.enableAutosave) this.autosaveManager.SetState(this.type, data);\n\n API.Forms.SubmitForm(this.type, this.context, normalisedData).then((result) => {\n this.loading = false;\n\n if (!result.Valid) {\n // Reset ReCaptcha\n this.resetRecaptcha();\n\n // Update errors\n this.errors = result.ValidationState.Errors;\n } else if (result.Submitted) {\n // Inform the user that the form was submitted\n this.submitted = true;\n\n this.$emit('submitted');\n }\n }).catch(() => {\n // Reset ReCaptcha\n this.resetRecaptcha();\n\n // Inform the user that there was an error\n this.errored = true;\n });\n });\n }\n\n private static normaliseData(data: FormValue[]): FormValue[] {\n const newValues: FormValue[] = [];\n\n data.forEach((entry) => {\n if (entry.Value instanceof Array) {\n if (entry.Value.length) {\n newValues.push({\n Key: `${entry.Key}_length`,\n Value: entry.Value.length,\n });\n\n for (let i = 0; i < entry.Value.length; i += 1) {\n newValues.push({\n Key: `${entry.Key}_${i}`,\n Value: entry.Value[i],\n });\n }\n }\n } else {\n newValues.push(entry);\n }\n });\n\n return newValues;\n }\n\n private collectData(includeRecaptcha: boolean): Promise {\n return new Promise((resolve, reject) => {\n const data: FormValue[] = [];\n\n // Loop through each form secction and collect the data from it\n this.definition!.Sections.forEach((section) => {\n const sectionComponent = (this.$refs[section.SectionId] as Vue[])[0] as Section;\n\n data.push(...sectionComponent.collectData());\n });\n\n // If we also need to submit the ReCaptcha response, make sure we call getResponse on the ReCaptcha component\n if (includeRecaptcha) {\n this.getRecaptchaResponse().then((recaptchaResponse: string) => {\n Logger.Log(LogLevel.Debug, '[Form]', 'Got ReCaptcha response');\n\n data.push({\n Key: '_recaptcha',\n Value: recaptchaResponse,\n });\n\n resolve(data);\n }).catch(reject);\n\n return;\n }\n\n // If we don't need ReCaptcha, resolve straight away\n resolve(data);\n });\n }\n\n private resetRecaptcha(): void {\n this.recaptchaService.Reset();\n }\n\n private getRecaptchaResponse(): Promise {\n return this.recaptchaService.GetResponse();\n }\n}\n","import mod from \"-!../../../node_modules/cache-loader/dist/cjs.js??ref--14-0!../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/babel-loader/lib/index.js!../../../node_modules/ts-loader/index.js??ref--14-3!../../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./Form.vue?vue&type=script&lang=ts&\"; export default mod; export * from \"-!../../../node_modules/cache-loader/dist/cjs.js??ref--14-0!../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/babel-loader/lib/index.js!../../../node_modules/ts-loader/index.js??ref--14-3!../../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./Form.vue?vue&type=script&lang=ts&\"","import { render, staticRenderFns } from \"./Form.vue?vue&type=template&id=726d98f2&scoped=true&\"\nimport script from \"./Form.vue?vue&type=script&lang=ts&\"\nexport * from \"./Form.vue?vue&type=script&lang=ts&\"\nimport style0 from \"./Form.vue?vue&type=style&index=0&id=726d98f2&scoped=true&lang=css&\"\n\n\n/* normalize component */\nimport normalizer from \"!../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n \"726d98f2\",\n null\n \n)\n\nexport default component.exports"],"sourceRoot":""}