"use strict";var L=Object.create;var y=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var H=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var q=(a,e,u,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of A(e))!J.call(a,c)&&c!==u&&y(a,c,{get:()=>e[c],enumerable:!(t=V(e,c))||t.enumerable});return a};var D=(a,e,u)=>(u=a!=null?L(H(a)):{},q(e||!a||!a.__esModule?y(u,"default",{value:a,enumerable:!0}):u,a));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("vue"),Z=require("@vueuse/core"),i=require("lodash"),I=require("is-electron"),M=require("echarts"),j=require("nanoid"),S=require("../utils/hoverLoop.js");require("echarts-wordcloud");require("echarts-liquidfill");function k(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const u in a)if(u!=="default"){const t=Object.getOwnPropertyDescriptor(a,u);Object.defineProperty(e,u,t.get?t:{enumerable:!0,get:()=>a[u]})}}return e.default=a,Object.freeze(e)}const v=k(M),T=a=>{const e=[];a.geo&&(i.isArray(a.geo)?e.push(...a.geo.map(t=>t.map)):e.push(a.geo.map)),a.series&&i.isArray(a.series)&&a.series.forEach(t=>{t.map&&e.push(t.map)});const u=e.map(t=>{if(t==="customize")if(i.isArray(a.geo)){const c=JSON.parse(a.geo.find(h=>h.map==="customize").geoData);return v.registerMap(t,c)}else{const c=JSON.parse(a.geo.geoData);return v.registerMap(t,c)}else return fetch((I()?"gismap/":"/gismap/")+t+".json").then(c=>c.json()).then(c=>{v.registerMap(t,c)}).catch(c=>{})});return Promise.all(u)},z=async a=>{a.bmap&&await import("echarts/extension/bmap/bmap")},B=({basicOption:a,useEvents:e,customRenderData:u,emit:t})=>{const c=j.nanoid(),h=f.ref(!0),l=f.shallowRef(null),m=u,n=f.ref(null),s=f.ref(null),b=(d,g)=>{try{l.value||(l.value=v.init(document.getElementById(c),null,{renderer:g||"svg"}));const o=i.cloneDeep(d);if(o){if(l.value.setOption(o,!0),o.hoverLoop)if(s.value&&clearInterval(s.value),n.value&&n.value.closeSwitchTooltip(),o.hoverLoop.type==="方式二"){let r=0;o.dataset&&o.dataset.source&&(r=o.dataset.source.length),o.series[0]&&o.series[0].data&&(r=o.series[0].data.length);const O=o.dataZoom[0].endValue,P=o.dataZoom[0].startValue,w=()=>{s.value=setInterval(()=>{o.dataZoom[0].endValue>r-2?(o.dataZoom[0].endValue=O,o.dataZoom[0].startValue=P):(o.dataZoom[0].endValue=o.dataZoom[0].endValue+1,o.dataZoom[0].startValue=o.dataZoom[0].startValue+1),l.value.setOption(o)},o.hoverLoop.delay2)};l.value.on("mousemove",function(){s.value&&clearInterval(s.value)}),l.value.on("mouseout",function(){s.value&&clearInterval(s.value),w()}),w()}else o.hoverLoop.type==="方式一"&&(l.value.on("mousemove",function(){n.value&&n.value.closeSwitchTooltip()}),l.value.on("mouseout",function(){n.value&&n.value.closeSwitchTooltip(),n.value=new S.HoverLoop(l.value,o)}),n.value=new S.HoverLoop(l.value,o));else s.value&&clearInterval(s.value),n.value&&n.value.closeSwitchTooltip();l.value.on("click",r=>{e&&i.isArray(e)&&e.length>0&&(t("chart-click",r),window.SHJParseEvent(e,"chart-click",r))}),l.value.on("dblclick",r=>{e&&i.isArray(e)&&e.length>0&&(t("chart-dblclick",r),window.SHJParseEvent(e,"chart-dblclick",r))}),l.value.on("mousedown",r=>{e&&i.isArray(e)&&e.length>0&&(t("chart-mousedown",r),window.SHJParseEvent(e,"chart-mousedown",r))}),l.value.on("mouseup",r=>{e&&i.isArray(e)&&e.length>0&&(t("chart-mouseup",r),window.SHJParseEvent(e,"chart-mouseup",r))}),l.value.on("mouseover",r=>{e&&i.isArray(e)&&e.length>0&&(t("chart-mouseover",r),window.SHJParseEvent(e,"chart-mouseover",r))}),l.value.on("mouseout",r=>{e&&i.isArray(e)&&e.length>0&&(t("chart-mouseout",r),window.SHJParseEvent(e,"chart-mouseout",r))}),l.value.on("contextmenu",r=>{e&&i.isArray(e)&&e.length>0&&(t("chart-contextmenu",r),window.SHJParseEvent(e,"chart-contextmenu",r))}),h.value=!1}}catch{try{l.value.dispose()}catch{}l.value=null}},p=i.debounce(d=>{h.value=!0,d=i.cloneDeep(d),T(d).then(()=>{z(d).then(()=>{m(d)})}).catch(g=>{})},100);return f.onMounted(()=>{p(a),Z.useResizeObserver(document.getElementById(c),d=>{l.value&&l.value.resize()})}),f.onBeforeUnmount(()=>{n.value&&n.value.closeSwitchTooltip(),s.value&&clearInterval(s.value);try{l.value&&l.value.dispose()}catch{}}),{id:c,status:h,chart:l,setOption:b,renderChart:p,renderData:m}};exports.useChart=B;
