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