"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),s=require("./index-C4TeRZvT.cjs"),F=require("./useNestedProp-BS-4R8zR.cjs"),J=require("./Title-Iy2d-Bd1.cjs"),K=require("./Legend-KLm00z8t.cjs"),I=require("./usePrinter-bFMowLOh.cjs"),Q=require("./PackageVersion-DwKk69DU.cjs"),Z=require("./PenAndPaper-hlX2Djxv.cjs"),ee=require("./vue-ui-skeleton-D7ijXB6x.cjs"),te=require("./useUserOptionState-BgepsfED.cjs"),ae=require("./useChartAccessibility-Cm7nkzTG.cjs"),le=require("./_plugin-vue_export-helper-BHFhmbuH.cjs"),re=["id"],oe={key:1,ref:"noTitle",class:"vue-data-ui-no-title-space",style:"height:36px; width: 100%;background:transparent"},se=["xmlns","viewBox"],ne=["width","height"],ue={key:1},ie=["x","y","height","width","fill","stroke"],ce=["x","y","height","width","rx","fill","stroke","stroke-width"],de=["x","y","height","width","fill","stroke","stroke-width"],he=["x","y","font-size","font-weight","fill"],ve=["x","y","height","width","rx","fill","stroke","stroke-width"],me={key:3},ge=["x","y","fill","font-size","font-weight"],fe={key:4},ye=["x1","x2","y1","y2","stroke"],pe={key:5,class:"vue-data-ui-watermark"},ke={class:"vue-ui-bullet-legend-item",dir:"auto"},be={style:{"margin-right":"2px"}},we={key:7,ref:"source",dir:"auto"},Be={__name:"vue-ui-bullet",props:{config:{type:Object,default(){return{}}},dataset:{type:Object,default(){return{}}}},setup(z,{expose:H}){const{vue_ui_bullet:T}=s.useConfig(),n=z,w=e.ref(null),q=e.ref(null),B=e.ref(0),M=e.ref(null),U=e.ref(0),h=e.computed({get:()=>n.dataset.hasOwnProperty("value"),set:a=>a}),v=e.computed(()=>n.dataset.segments?Array.isArray(n.dataset.segments)?n.dataset.segments.length?!0:(console.warn(`VueUiBullet: dataset segments is empty. Provide segments with this datastructure:

segments: [
    {
        name: string;
        from: number;
        to: number;
        color?: string;
    },
    {...}
]
        `),h.value=!1,!1):(console.warn(`VueUiBullet: dataset segments must be an array of objects with this datastructure:

segments: [
    {
        name: string;
        from: number;
        to: number;
        color?: string;
    },
    {...}
] 
        `),h.value=!1,!1):(console.warn(`VueUiBullet: dataset segments is empty. Provide segments with this datastructure:

segments: [
    {
        name: string;
        from: number;
        to: number;
        color?: string;
    },
    {...}
]
        `),h.value=!1,!1));e.onMounted(C);function C(){s.objectIsEmpty(n.dataset)?s.error({componentName:"VueUiBullet",type:"dataset"}):v.value?n.dataset.segments.forEach((a,o)=>{s.getMissingDatasetAttributes({datasetObject:a,requiredAttributes:["name","from","to"]}).forEach(l=>{h.value=!1,s.error({componentName:"VueUiBullet segment",type:"datasetSerieAttribute",property:l,index:o})})}):h.value=!1,t.value.style.chart.animation.show&&P(n.dataset.value||0)}const y=e.ref(s.createUid());function x(){const a=F.useNestedProp({userConfig:n.config,defaultConfig:T});return a.theme?{...F.useNestedProp({userConfig:s.themes.vue_ui_bullet[a.theme]||n.config,defaultConfig:a})}:a}const t=e.computed({get:()=>x(),set:a=>a}),{userOptionsVisible:p,setUserOptionsVisibility:_,keepUserOptionState:L}=te.useUserOptionState({config:t.value}),{svgRef:S}=ae.useChartAccessibility({config:t.value.style.chart.title});e.watch(()=>n.config,a=>{t.value=x(),p.value=!t.value.userOptions.showOnChartHover,C(),B.value+=1},{deep:!0});const r=e.computed(()=>{const a=t.value.style.chart.height,o=t.value.style.chart.width,l=t.value.style.chart.padding.left,d=o-t.value.style.chart.padding.right,f=t.value.style.chart.padding.top,c=a-t.value.style.chart.padding.bottom;return{height:a,width:o,left:l,right:d,top:f,bottom:c,chartWidth:d-l,chartHeight:c-f}}),R=e.computed(()=>{if(!v.value)return[];const a=[];for(let o=0;o<n.dataset.segments.length;o+=1)a.push(s.lightenHexColor(t.value.style.chart.segments.baseColor,o/n.dataset.segments.length));return a}),k=e.computed(()=>v.value?{min:Math.min(...n.dataset.segments.map(a=>a.from)),max:Math.max(...n.dataset.segments.map(a=>a.to))}:{min:0,max:1}),u=e.ref(D());e.watch(()=>n.dataset,a=>{t.value.style.chart.animation.show?P(a.value||0):u.value=a.value||0},{deep:!0});function D(){return t.value.style.chart.animation.show?k.value.min:n.dataset.value||0}const N=e.ref(null);function P(a){const o=Math.abs(a-u.value)/t.value.style.chart.animation.animationFrames;function l(){u.value<a?u.value=Math.min(u.value+o,a):u.value>a&&(u.value=Math.max(u.value-o,a)),u.value!==a&&(N.value=requestAnimationFrame(l))}l()}e.onBeforeUnmount(()=>{cancelAnimationFrame(N.value)});const i=e.computed(()=>{if(!v.value)return[];const a=s.calculateNiceScale(k.value.min,k.value.max,t.value.style.chart.segments.ticks.divisions),o=a.min>=0?0:Math.abs(a.min),l={x:r.value.left+(n.dataset.target+o)/(a.max+o)*r.value.chartWidth-t.value.style.chart.target.width/2},d={width:(u.value+o)/(a.max+o)*r.value.chartWidth},f=a.ticks.map(c=>({value:c,y:r.value.bottom+t.value.style.chart.segments.dataLabels.fontSize+3+t.value.style.chart.segments.dataLabels.offsetY,x:r.value.left+(c+o)/(a.max+o)*r.value.chartWidth}));return{scale:a,target:l,value:d,ticks:f,chunks:n.dataset.segments.map((c,Y)=>({...c,color:c.color?s.convertColorToHex(c.color):R.value[Y],x:r.value.left+r.value.chartWidth*((c.from+o)/(a.max+o)),y:r.value.top,height:r.value.chartHeight,width:r.value.chartWidth*(Math.abs(c.to-c.from)/(a.max+o))}))}}),E=e.computed(()=>!i.value||!i.value.chunks||!i.value.chunks.length?[]:i.value.chunks.map(a=>{const o=s.applyDataLabel(t.value.style.chart.segments.dataLabels.formatter,a.from,s.dataLabel({p:t.value.style.chart.segments.dataLabels.prefix,v:a.from,s:t.value.style.chart.segments.dataLabels.suffix,r:t.value.style.chart.segments.dataLabels.rounding})),l=s.applyDataLabel(t.value.style.chart.segments.dataLabels.formatter,a.to,s.dataLabel({p:t.value.style.chart.segments.dataLabels.prefix,v:a.to,s:t.value.style.chart.segments.dataLabels.suffix,r:t.value.style.chart.segments.dataLabels.rounding}));return{...a,shape:"square",value:`${o} - ${l}`}})),W=e.computed(()=>({cy:"bullet-div-legend",backgroundColor:"transparent",color:t.value.style.chart.legend.color,fontSize:t.value.style.chart.legend.fontSize,paddingBottom:6,fontWeight:t.value.style.chart.legend.bold?"bold":""})),{isPrinting:$,isImaging:V,generatePdf:O,generateImage:A}=I.usePrinter({elementId:`bullet_${y.value}`,fileName:t.value.style.chart.title.text||"vue-ui-bullet",options:t.value.userOptions.print}),j=e.computed(()=>t.value.userOptions.show&&!t.value.style.chart.title.text),m=e.ref(!1);function G(a){m.value=a,U.value+=1}function X(){return i.value}const g=e.ref(!1);function b(){g.value=!g.value}return H({getData:X,generatePdf:O,generateImage:A,toggleAnnotator:b}),(a,o)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"bulletChart",ref:w,class:e.normalizeClass(`vue-ui-bullet ${m.value?"vue-data-ui-wrapper-fullscreen":""}`),style:e.normalizeStyle(`font-family:${t.value.style.fontFamily};width:100%;background:${t.value.style.chart.backgroundColor}`),id:`bullet_${y.value}`,onMouseenter:o[0]||(o[0]=()=>e.unref(_)(!0)),onMouseleave:o[1]||(o[1]=()=>e.unref(_)(!1))},[t.value.userOptions.buttons.annotator?(e.openBlock(),e.createBlock(Z.PenAndPaper,{key:0,svgRef:e.unref(S),backgroundColor:t.value.style.chart.backgroundColor,color:t.value.style.chart.color,active:g.value,onClose:b},null,8,["svgRef","backgroundColor","color","active"])):e.createCommentVNode("",!0),j.value?(e.openBlock(),e.createElementBlock("div",oe,null,512)):e.createCommentVNode("",!0),t.value.style.chart.title.text?(e.openBlock(),e.createElementBlock("div",{key:2,ref_key:"chartTitle",ref:q,style:"width:100%;background:transparent;"},[(e.openBlock(),e.createBlock(J._sfc_main,{lineHeight:"1.3rem",key:`title_${B.value}`,config:{title:{cy:"bullet-div-title",...t.value.style.chart.title},subtitle:{cy:"bullet-div-subtitle",...t.value.style.chart.title.subtitle}}},null,8,["config"]))],512)):e.createCommentVNode("",!0),t.value.userOptions.show&&h.value&&(e.unref(L)||e.unref(p))?(e.openBlock(),e.createBlock(I.UserOptions,{key:3,ref:"details",backgroundColor:t.value.style.chart.backgroundColor,color:t.value.style.chart.color,isPrinting:e.unref($),isImaging:e.unref(V),uid:y.value,hasTooltip:!1,hasPdf:t.value.userOptions.buttons.pdf,hasImg:t.value.userOptions.buttons.img,hasXls:!1,hasTable:!1,hasLabel:!1,hasFullscreen:t.value.userOptions.buttons.fullscreen,isFullscreen:m.value,chartElement:w.value,position:t.value.userOptions.position,titles:{...t.value.userOptions.buttonTitles},hasAnnotator:t.value.userOptions.buttons.annotator,isAnnotation:g.value,onToggleFullscreen:G,onGeneratePdf:e.unref(O),onGenerateImage:e.unref(A),onToggleAnnotator:b,style:e.normalizeStyle({visibility:e.unref(L)?e.unref(p)?"visible":"hidden":"visible"})},e.createSlots({_:2},[a.$slots.menuIcon?{name:"menuIcon",fn:e.withCtx(({isOpen:l,color:d})=>[e.renderSlot(a.$slots,"menuIcon",e.normalizeProps(e.guardReactiveProps({isOpen:l,color:d})),void 0,!0)]),key:"0"}:void 0,a.$slots.optionPdf?{name:"optionPdf",fn:e.withCtx(()=>[e.renderSlot(a.$slots,"optionPdf",{},void 0,!0)]),key:"1"}:void 0,a.$slots.optionImg?{name:"optionImg",fn:e.withCtx(()=>[e.renderSlot(a.$slots,"optionImg",{},void 0,!0)]),key:"2"}:void 0,a.$slots.optionFullscreen?{name:"optionFullscreen",fn:e.withCtx(({toggleFullscreen:l,isFullscreen:d})=>[e.renderSlot(a.$slots,"optionFullscreen",e.normalizeProps(e.guardReactiveProps({toggleFullscreen:l,isFullscreen:d})),void 0,!0)]),key:"3"}:void 0,a.$slots.optionAnnotator?{name:"optionAnnotator",fn:e.withCtx(({toggleAnnotator:l,isAnnotator:d})=>[e.renderSlot(a.$slots,"optionAnnotator",e.normalizeProps(e.guardReactiveProps({toggleAnnotator:l,isAnnotator:d})),void 0,!0)]),key:"4"}:void 0]),1032,["backgroundColor","color","isPrinting","isImaging","uid","hasPdf","hasImg","hasFullscreen","isFullscreen","chartElement","position","titles","hasAnnotator","isAnnotation","onGeneratePdf","onGenerateImage","style"])):e.createCommentVNode("",!0),h.value?(e.openBlock(),e.createElementBlock("svg",{key:4,ref_key:"svgRef",ref:S,xmlns:e.unref(s.XMLNS),class:e.normalizeClass({"vue-data-ui-fullscreen--on":m.value,"vue-data-ui-fulscreen--off":!m.value,"vue-ui-bullet-svg":!0}),viewBox:`0 0 ${r.value.width} ${r.value.height}`,style:e.normalizeStyle(`width: 100%; overflow: visible; background:transparent;color:${t.value.style.chart.color}`)},[e.createVNode(Q._sfc_main),a.$slots["chart-background"]?(e.openBlock(),e.createElementBlock("foreignObject",{key:0,x:0,y:0,width:r.value.width,height:r.value.height,style:{pointerEvents:"none"}},[e.renderSlot(a.$slots,"chart-background",{},void 0,!0)],8,ne)):e.createCommentVNode("",!0),v.value?(e.openBlock(),e.createElementBlock("g",ue,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value.chunks,l=>(e.openBlock(),e.createElementBlock("rect",{x:l.x,y:l.y,height:l.height,width:l.width,fill:l.color,"stroke-width":1,stroke:t.value.style.chart.backgroundColor},null,8,ie))),256)),t.value.style.chart.target.onTop?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("rect",{key:0,x:i.value.target.x,y:r.value.top+(r.value.chartHeight-r.value.chartHeight*t.value.style.chart.target.heightRatio)/2,height:r.value.chartHeight*t.value.style.chart.target.heightRatio,width:t.value.style.chart.target.width,rx:t.value.style.chart.target.rounded?t.value.style.chart.target.width/2:0,fill:t.value.style.chart.target.color,stroke:t.value.style.chart.target.stroke,"stroke-width":t.value.style.chart.target.strokeWidth},null,8,ce)),e.createElementVNode("rect",{x:r.value.left,y:r.value.top+(r.value.chartHeight-r.value.chartHeight*t.value.style.chart.valueBar.heightRatio)/2,height:r.value.chartHeight*t.value.style.chart.valueBar.heightRatio,width:i.value.value.width,fill:t.value.style.chart.valueBar.color,stroke:t.value.style.chart.valueBar.stroke,"stroke-width":t.value.style.chart.valueBar.strokeWidth},null,8,de),t.value.style.chart.valueBar.label.show?(e.openBlock(),e.createElementBlock("text",{key:1,x:r.value.left+i.value.value.width,y:r.value.top-6+t.value.style.chart.valueBar.label.offsetY,"font-size":t.value.style.chart.valueBar.label.fontSize,"font-weight":t.value.style.chart.valueBar.label.bold?"bold":"normal",fill:t.value.style.chart.valueBar.label.color,"text-anchor":"middle"},e.toDisplayString(e.unref(s.applyDataLabel)(t.value.style.chart.segments.dataLabels.formatter,u.value,e.unref(s.dataLabel)({p:t.value.style.chart.segments.dataLabels.prefix,v:u.value,s:t.value.style.chart.segments.dataLabels.suffix,r:t.value.style.chart.segments.dataLabels.rounding}))),9,he)):e.createCommentVNode("",!0),t.value.style.chart.target.onTop?(e.openBlock(),e.createElementBlock("rect",{key:2,x:i.value.target.x,y:r.value.top+(r.value.chartHeight-r.value.chartHeight*t.value.style.chart.target.heightRatio)/2,height:r.value.chartHeight*t.value.style.chart.target.heightRatio,width:t.value.style.chart.target.width,rx:t.value.style.chart.target.rounded?t.value.style.chart.target.width/2:0,fill:t.value.style.chart.target.color,stroke:t.value.style.chart.target.stroke,"stroke-width":t.value.style.chart.target.strokeWidth},null,8,ve)):e.createCommentVNode("",!0),t.value.style.chart.segments.dataLabels.show?(e.openBlock(),e.createElementBlock("g",me,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value.ticks,l=>(e.openBlock(),e.createElementBlock("text",{x:l.x,y:l.y,"text-anchor":"middle",fill:t.value.style.chart.segments.dataLabels.color,"font-size":t.value.style.chart.segments.dataLabels.fontSize+"px","font-weight":t.value.style.chart.segments.dataLabels.bold?"bold":"normal"},e.toDisplayString(e.unref(s.applyDataLabel)(t.value.style.chart.segments.dataLabels.formatter,l.value,e.unref(s.dataLabel)({p:t.value.style.chart.segments.dataLabels.prefix,v:l.value,s:t.value.style.chart.segments.dataLabels.suffix,r:t.value.style.chart.segments.dataLabels.rounding}))),9,ge))),256))])):e.createCommentVNode("",!0),t.value.style.chart.segments.dataLabels.show&&t.value.style.chart.segments.ticks.show?(e.openBlock(),e.createElementBlock("g",fe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value.ticks,l=>(e.openBlock(),e.createElementBlock("line",{x1:l.x,x2:l.x,y1:r.value.bottom,y2:r.value.bottom+3,stroke:t.value.style.chart.segments.ticks.stroke,"stroke-width":1,"stroke-linecap":"round"},null,8,ye))),256))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.renderSlot(a.$slots,"svg",{svg:r.value},void 0,!0)],14,se)):e.createCommentVNode("",!0),a.$slots.watermark?(e.openBlock(),e.createElementBlock("div",pe,[e.renderSlot(a.$slots,"watermark",e.normalizeProps(e.guardReactiveProps({isPrinting:e.unref($)||e.unref(V)})),void 0,!0)])):e.createCommentVNode("",!0),h.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(ee.default,{key:6,config:{type:"bullet",style:{backgroundColor:t.value.style.chart.backgroundColor,bullet:{color:"#CCCCCC"}}}},null,8,["config"])),e.createElementVNode("div",{ref_key:"chartLegend",ref:M},[t.value.style.chart.legend.show?(e.openBlock(),e.createBlock(K.Legend,{key:0,clickable:!1,legendSet:E.value,config:W.value},{item:e.withCtx(({legend:l})=>[e.createElementVNode("div",ke,[e.createElementVNode("span",be,e.toDisplayString(l.name)+":",1),e.createElementVNode("span",null,e.toDisplayString(l.value),1)])]),_:1},8,["legendSet","config"])):e.createCommentVNode("",!0),e.renderSlot(a.$slots,"legend",{legend:E.value},void 0,!0)],512),a.$slots.source?(e.openBlock(),e.createElementBlock("div",we,[e.renderSlot(a.$slots,"source",{},void 0,!0)],512)):e.createCommentVNode("",!0)],46,re))}},Ce=le._export_sfc(Be,[["__scopeId","data-v-e444b500"]]);exports.default=Ce;
