import{__awaiter as e,__generator as r,__assign as t}from"./_virtual/_tslib.js";import n from"./load-plugins.js";import i from"vue";import s from"./mixins/mixins.js";import{defineProp as o,setPropValue as a}from"./mixins/props.js";import u from"./mixins/base.js";import c from"./marker.js";import l from"./utils/safe-get.js";import m from"./utils/debounce.js";import{start as d,stop as p}from"./utils/perf.js";var f=c.sealedOptions,h=i.extend({props:f.props}),k=void 0;function v(e,r,t){var n=e[r];Array.isArray(n)&&(e[r]=new t(n[0],n[1]))}function M(e){return e&&0!==e.length?e.map((function(e){var r=t({},e);return v(r,"size",AMap.Size),v(r,"offset",AMap.Pixel),v(r,"imageOffset",AMap.Pixel),r})):e}var y=s(u).extend({name:"AmapMarkerCluster",amapMeta:{prepare:function(){return n("AMap.MarkerCluster")},initComponent:function(t,n){return e(this,void 0,void 0,(function(){var e;return r(this,(function(r){return e=this,this.$scopedSlots.cluster&&(n.renderClusterMarker=e._renderCluster),this.$scopedSlots.marker&&(n.renderMarker=e._renderMarker),[2,new t.MarkerCluster(e.$map,e.data||[],n)]}))}))},events:["click"]},props:{data:o({type:Array,required:!0,initialize:!1}),gridSize:o("setGridSize",Number),maxZoom:o("setMaxZoom",Number),averageCenter:o({type:Boolean,default:void 0,setter:"setAverageCenter"}),clusterByZoomChange:{type:Boolean,default:void 0},styles:o({type:Array,setter:function(e,r){e.setStyles(M(r))},transform:M}),markerOptions:o({type:Function,initialize:!1}),clusterOptions:o({type:Function,initialize:!1})},data:function(){return{$mcc:null}},mounted:function(){var e=this,r=m(this._onDataChange,100),t=this.$scopedSlots.marker,n=this.$scopedSlots.cluster;this.$context.ready.then((function(){e._onDataChange()}));var s=i.extend({props:{point:{type:Object}},render:function(){if(!t)return null;var e=t(this.point);return l(e,"0",null)}}),o=i.extend({props:{context:{type:Object}},render:function(){if(!n)return null;var e=n(this.context);return l(e,"0",null)}});this.$mcc={marker:new s,cluster:new o,dummy:new h},this.$watch("data",{handler:r})},beforeDestroy:function(){this.$mcc.marker.$destroy(),this.$mcc.cluster.$destroy(),this.$mcc.dummy.$destroy()},methods:{_onDataChange:function(){return e(this,void 0,void 0,(function(){var e,t,n;return r(this,(function(r){switch(r.label){case 0:return t=(e=this).data,[4,(n=e.$context).ready];case 1:return r.sent(),n.destroyed?[2]:(this.$target.setData(t),[2])}}))}))},_renderMarkerContent:function(e,r,t){d("MarkerCluster#_renderMarkerContent");var n=function(e,r){k||(k=document.createElement("div"));var t=e;return t._props=r,t._vnode=null,t.$mount(k),t._vnode.elm}(r,t);e.marker.setContent(n),p("MarkerCluster#_renderMarkerContent")},_setMarkerOptions:function(e,r,t){var n={};"function"==typeof r&&Object.assign(n,r(t));for(var i=Object.keys(n),s=this.$mcc.dummy,o=0;o