{"version":3,"sources":["webpack:///./resources/js/src/app/components/common/GoogleMaps.vue?0c7f","webpack:///./resources/js/src/app/components/common/GoogleMaps.vue?fc6f","webpack:///resources/js/src/app/components/common/GoogleMaps.vue","webpack:///./resources/js/src/app/components/common/GoogleMaps.vue"],"names":["render","_h","this","$createElement","_c","_self","ref","staticClass","class","aspectClass","scriptBlocked","_t","_e","_withStripped","component","options","__file"],"mappings":"kGAAA,IAAIA,EAAS,WACX,IACIC,EADMC,KACGC,eACTC,EAFMF,KAEGG,MAAMD,IAAMH,EACzB,OAAOG,EACL,MACA,CACEE,IAAK,sBACLC,YAAa,mCACbC,MARMN,KAQKO,aAEb,CAVQP,KAUHQ,cAAgBN,EAAG,MAAO,CAVvBF,KAU4BS,GAAG,YAAa,GAV5CT,KAUqDU,QAIjEZ,EAAOa,eAAgB,E,qCCf2L,ECYlN,CACE,MAAF,CACI,QACJ,CACM,KAAN,OACM,UAAN,GAEI,IACJ,CACM,KAAN,OACM,UAAN,GAEI,IACJ,CACM,KAAN,OACM,UAAN,GAEI,KACJ,CACM,KAAN,OACM,QAAN,IAEI,QACJ,CACM,KAAN,OACM,QAAN,WAEI,YACJ,CACM,KAAN,OACM,QAAN,QAIE,KAAF,WAEI,MAAJ,CACM,eAAN,IAIE,SACF,CACI,YADJ,WAGM,MAAN,2BAIE,QAjDF,WAkDI,IAAJ,OACI,KAAJ,sBAEM,EAAN,eACA,iBAEQ,EAAR,mBAEA,0BAOE,QACF,CACI,aADJ,WAEM,IAAN,OACM,OAAN,2BAEQ,IAAR,mDAEA,eAkBU,OAAV,IAAU,CACV,oBACA,WAEY,EAAZ,iBACY,IAAZ,mCAEY,EAAZ,uBACY,EAAZ,qBACY,EAAZ,8FAEY,EAAZ,oCAAc,OAAd,WACY,EAAZ,qCAAc,OAAd,WAEY,SAAZ,uBAEA,WAEY,EAAZ,qBAjCU,EAAV,iBACA,2BAGY,EAAZ,oCAAc,OAAd,WAKY,EAAZ,QA8BI,eAjDJ,WAkDM,IAAN,OACA,8CACA,gDAEM,OAAN,KAEA,iBACU,IAAV,SACU,IAAV,WAGA,4BAEA,4BAEA,0BACA,QACA,CACY,QAAZ,YAEA,cAEA,6BAEc,EAAd,wBAIc,UAOd,kBAGI,cAxFJ,WAyFM,IAAN,OACM,KAAN,iBACA,kBAEQ,IAAR,kDACA,CACU,OAAV,EACU,KAAV,OACU,UAAV,YAGQ,IAAR,mBACA,CACU,IAAV,EACU,SAAV,U,OC9KIC,EAAY,YACd,EACAd,EHKoB,IGHpB,EACA,KACA,KACA,MAuBFc,EAAUC,QAAQC,OAAS,wDACZ,UAAAF,E","file":"chunks/ceres-24.min.js","sourcesContent":["var render = function() {\n  var _vm = this\n  var _h = _vm.$createElement\n  var _c = _vm._self._c || _h\n  return _c(\n    \"div\",\n    {\n      ref: \"googleMapsContainer\",\n      staticClass: \"maps-component position-relative\",\n      class: _vm.aspectClass\n    },\n    [_vm.scriptBlocked ? _c(\"div\", [_vm._t(\"default\")], 2) : _vm._e()]\n  )\n}\nvar staticRenderFns = []\nrender._withStripped = true\n\nexport { render, staticRenderFns }","import mod from \"-!../../../../../../node_modules/babel-loader/lib/index.js!../../../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./GoogleMaps.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../../../node_modules/babel-loader/lib/index.js!../../../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./GoogleMaps.vue?vue&type=script&lang=js&\"","<template>\n    <div :class=\"aspectClass\" class=\"maps-component position-relative\" ref=\"googleMapsContainer\">\n        <div v-if=\"scriptBlocked\">\n            <slot></slot>\n        </div>\n    </div>\n</template>\n\n<script>\nimport { whenConsented } from \"../../helper/whenConsented\";\nimport { isNullOrUndefined } from \"../../helper/utils\";\n\nexport default {\n    props: {\n        address:\n        {\n            type: String,\n            required: false\n        },\n        lat:\n        {\n            type: Number,\n            required: false\n        },\n        lng:\n        {\n            type: Number,\n            required: false\n        },\n        zoom:\n        {\n            type: Number,\n            default: 16\n        },\n        maptype:\n        {\n            type: String,\n            default: \"roadmap\"\n        },\n        aspectRatio:\n        {\n            type: String,\n            default: \"3-1\"\n        }\n    },\n\n    data: function()\n    {\n        return {\n            scriptBlocked: true\n        };\n    },\n\n    computed:\n    {\n        aspectClass()\n        {\n            return \"prop-\" + this.aspectRatio;\n        }\n    },\n\n    mounted()\n    {\n        this.$nextTick(() =>\n        {\n            this.createScript()\n                .then(() =>\n                {\n                    this.initializeMap();\n                })\n                .catch(() =>\n                {\n                    // Do nothing\n                });\n        });\n    },\n\n    methods:\n    {\n        createScript()\n        {\n            return new Promise((resolve, reject) =>\n            {\n                const script = document.querySelector(\"script#google-maps-api\");\n\n                if (!isNullOrUndefined(script))\n                {\n                    // script already injected...\n                    this.scriptBlocked = false;\n                    if (isNullOrUndefined(window.google))\n                    {\n                        // ...but not loaded yet\n                        script.addEventListener(\"load\", () => resolve(script), false);\n                    }\n                    else\n                    {\n                        // ..and fully loaded\n                        resolve(script);\n                    }\n                }\n                else\n                {\n                    // script not loaded\n                    whenConsented(\n                        \"media.googleMaps\",\n                        () =>\n                        {\n                            this.scriptBlocked = false;\n                            const script = document.createElement(\"script\");\n\n                            script.type = \"text/javascript\";\n                            script.id = \"google-maps-api\";\n                            script.src = `https://maps.googleapis.com/maps/api/js?key=${App.config.global.googleMapsApiKey}`;\n\n                            script.addEventListener(\"load\", () => resolve(script), false);\n                            script.addEventListener(\"error\", () => reject(script), false);\n\n                            document.body.appendChild(script);\n                        },\n                        () =>\n                        {\n                            this.scriptBlocked = true;\n                        });\n                }\n            });\n        },\n\n        getCoordinates()\n        {\n            const isLatValid = !isNaN(this.lat) && this.lat > -90 && this.lat < 90;\n            const isLngValid = !isNaN(this.lng) && this.lng > -180 && this.lng < 180;\n\n            if (isLatValid && isLngValid)\n            {\n                return Promise.resolve({\n                    lat: this.lat,\n                    lng: this.lng\n                });\n            }\n            else if(!!this.address && !!window.google)\n            {\n                return new Promise((resolve, reject) =>\n                {\n                    const geocoder = new google.maps.Geocoder();\n                    geocoder.geocode(\n                        {\n                            address: this.address\n                        },\n                        (result, status) =>\n                        {\n                            if(!!result && result.length > 0 && !!result[0].geometry)\n                            {\n                                resolve(result[0].geometry.location);\n                            }\n                            else\n                            {\n                                reject();\n                            }\n                        }\n                    );\n                });\n            }\n\n            return Promise.reject();\n        },\n\n        initializeMap()\n        {\n            this.getCoordinates()\n                .then((coordinates) =>\n                {\n                    const map = new google.maps.Map(this.$refs.googleMapsContainer,\n                        {\n                            center: coordinates,\n                            zoom  : this.zoom,\n                            mapTypeId: this.maptype\n                        });\n\n                    new google.maps.Marker(\n                        {\n                            map: map,\n                            position: coordinates\n                        });\n\n                });\n        }\n    }\n}\n</script>\n","import { render, staticRenderFns } from \"./GoogleMaps.vue?vue&type=template&id=5bf88bf2&\"\nimport script from \"./GoogleMaps.vue?vue&type=script&lang=js&\"\nexport * from \"./GoogleMaps.vue?vue&type=script&lang=js&\"\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  null,\n  null\n  \n)\n\n/* hot reload */\nif (module.hot) {\n  var api = require(\"/home/runner/work/plugin-ceres/plugin-ceres/node_modules/vue-hot-reload-api/dist/index.js\")\n  api.install(require('vue'))\n  if (api.compatible) {\n    module.hot.accept()\n    if (!api.isRecorded('5bf88bf2')) {\n      api.createRecord('5bf88bf2', component.options)\n    } else {\n      api.reload('5bf88bf2', component.options)\n    }\n    module.hot.accept(\"./GoogleMaps.vue?vue&type=template&id=5bf88bf2&\", function () {\n      api.rerender('5bf88bf2', {\n        render: render,\n        staticRenderFns: staticRenderFns\n      })\n    })\n  }\n}\ncomponent.options.__file = \"resources/js/src/app/components/common/GoogleMaps.vue\"\nexport default component.exports"],"sourceRoot":""}