apexcharts
Version:
A JavaScript Chart Library
6 lines (5 loc) • 20.3 kB
JavaScript
/*!
* ApexCharts v7.0.0
* (c) 2018-2026 ApexCharts
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ApexInk={})}(this,function(t){"use strict";const e=globalThis.ApexCharts,n=globalThis.ApexCharts.__internals.__apex_Utils,i=globalThis.ApexCharts.__internals.__apex_Options,s=["point","xaxis","yaxis"],a=[10,11,12,14,17,20],o=["circle","square","diamond","triangle"],r={circle:"\u25cf",square:"\u25a0",diamond:"\u25c6",triangle:"\u25b2"},l=["#ffffff","#334155","#2563eb","#16a34a","#d97706","#dc2626"];class c{constructor(t,e){this.w=t,this.ctx=e,this._wired=!1,this._drag=null,this._editor=null,this._creating=!1,this._createSeq=0,this._attach=this._attach.bind(this),this._onRerender=this._onRerender.bind(this),this._onMove=this._onMove.bind(this),this._onUp=this._onUp.bind(this),this._onCreateClick=this._onCreateClick.bind(this),this._onDocDownEditor=this._onDocDownEditor.bind(this),(this._enabledGlobally()||this._hasDraggable()||this._paletteEnabled())&&this._wire()}_enabledGlobally(){const t=this.w.config.chart.ink;return!(!t||!t.enabled)}_paletteEnabled(){const t=this.w.config.chart.ink;return!(!t||!t.palette)}_snapEnabled(){const t=this.w.config.chart.ink;return!(!t||!t.snap)}_nearest(t,e){let n=t,i=1/0;for(let s=0;s<e.length;s++){const a=Math.abs(e[s]-t);a<i&&(i=a,n=e[s])}return n}_snapX(t){if(!this._snapEnabled()||"number"!=typeof t)return t;const e=this.w.globals.xAxisScale;return e&&Array.isArray(e.result)&&e.result.length?this._nearest(t,e.result):t}_snapY(t,e){if(!this._snapEnabled()||"number"!=typeof t)return t;const n=this.w.globals.yAxisScale,i=n&&n[e];return i&&Array.isArray(i.result)&&i.result.length?this._nearest(t,i.result):t}_annoList(t){const e=this.w.config.annotations;if(!e)return[];const n="point"===t?"points":t;return Array.isArray(e[n])?e[n]:[]}_isDraggable(t){return!!t&&(!0===t.draggable||!1!==t.draggable&&this._enabledGlobally())}_hasDraggable(){return s.some(t=>this._annoList(t).some(t=>this._isDraggable(t)))}_wire(){this._wired||(this._wired=!0,this.ctx.addEventListener("mounted",this._onRerender),this.ctx.addEventListener("updated",this._onRerender))}_onRerender(){if(this._closeEditor(!1),this._attach(),this._creating){const t=this.w.dom.Paper&&this.w.dom.Paper.node;t&&(t.style.cursor="crosshair",t.addEventListener("click",this._onCreateClick,!0))}}_attach(){const t=this.w,e=t.dom.baseEl;e&&(s.forEach(n=>{this._annoList(n).forEach((i,s)=>{this._isDraggable(i)&&(i.id||(i.id="apexcharts-ink-"+n+"-"+s+"-"+t.globals.chartID),e.querySelectorAll("."+i.id).forEach(t=>{t.__inkBound||(t.__inkBound=!0,t.style.cursor="move",t.classList.add("apexcharts-ink-draggable"),t.addEventListener("mousedown",t=>this._onDown(t,n,s)),t.addEventListener("touchstart",t=>this._onDown(t,n,s)),t.addEventListener("dblclick",t=>{t.preventDefault(),t.stopPropagation(),this._startEdit(n,s,{select:!0})}))}))})}),this._paletteEnabled()&&this._renderPalette())}_onDown(t,e,n){if(t.button&&0!==t.button)return;const i=this.w,s=i.dom.baseEl&&i.dom.baseEl.ownerDocument;if(!s)return;t.stopPropagation(),t.cancelable&&t.preventDefault();const a="touchstart"===t.type?t.touches[0]:t,o=i.dom.Paper&&i.dom.Paper.node,r=o&&o.getScreenCTM?o.getScreenCTM():null,l=this._annoList(e)[n];let c="move",d=null,h=0,p=0;if("xaxis"===e&&null!=l.x2&&(d=i.dom.baseEl.querySelector(".apexcharts-annotation-rect."+l.id),d)){const t=d.getBoundingClientRect();Math.abs(a.clientX-t.left)<=8?c="resize-x1":Math.abs(a.clientX-t.right)<=8&&(c="resize-x2"),h=parseFloat(d.getAttribute("x"))||0,p=parseFloat(d.getAttribute("width"))||0}this._drag={type:e,index:n,anno:l,els:Array.from(i.dom.baseEl.querySelectorAll("."+l.id)),mode:c,rect:d,origX:h,origW:p,startX:a.clientX,startY:a.clientY,scaleX:r&&r.a?r.a:1,scaleY:r&&r.d?r.d:1,dxPixel:0,dyPixel:0,moved:!1},s.addEventListener("mousemove",this._onMove),s.addEventListener("touchmove",this._onMove,{passive:!1}),s.addEventListener("mouseup",this._onUp),s.addEventListener("touchend",this._onUp)}_onMove(t){const e=this._drag;if(!e)return;t.cancelable&&t.preventDefault();const n="touchmove"===t.type?t.touches[0]:t;if(e.dxPixel=(n.clientX-e.startX)/e.scaleX,e.dyPixel=(n.clientY-e.startY)/e.scaleY,(Math.abs(e.dxPixel)>2||Math.abs(e.dyPixel)>2)&&(e.moved=!0),"move"===e.mode){const t=`translate(${e.dxPixel} ${e.dyPixel})`;e.els.forEach(e=>e.setAttribute("transform",t))}else e.rect&&("resize-x1"===e.mode?(e.rect.setAttribute("x",e.origX+e.dxPixel),e.rect.setAttribute("width",Math.max(1,e.origW-e.dxPixel))):"resize-x2"===e.mode&&e.rect.setAttribute("width",Math.max(1,e.origW+e.dxPixel)))}_onUp(){const t=this._drag;if(this._drag=null,this._teardownDocListeners(),!t||!t.moved)return void(t&&(t.els.forEach(t=>t.removeAttribute("transform")),this._startEdit(t.type,t.index)));const e=this._annoList(t.type)[t.index];e&&(this._applyDelta(t,e),t.els.forEach(t=>t.removeAttribute("transform")),this._redrawAnno(t.type,e,t.index),this._checkpoint("ink:drag"),this._fireDragged(t.type,e,t.index))}_checkpoint(t){var e,n;null==(n=null==(e=this.ctx.history)?void 0:e.snapshot)||n.call(e,t)}_applyDelta(t,e){const n=this.w,i=n.layout.gridWidth?t.dxPixel*(n.globals.xRange/n.layout.gridWidth):0;if("point"===t.type){const{newX:i,newY:s}=this._invertPoint(e,t.dxPixel,t.dyPixel);if(e.x=this._snapX(i),null!=s){const t=e.yAxisIndex||0,i=n.globals.seriesYAxisMap;e.y=this._snapY(s,i&&i[t]?i[t][0]:0)}return}if("xaxis"!==t.type){if("yaxis"===t.type){const i=e.yAxisIndex||0,s=n.globals.seriesYAxisMap,a=s&&s[i]?s[i][0]:0,o=n.globals.yRange?n.globals.yRange[a]:null;if(null==o||!n.layout.gridHeight)return;const r=-t.dyPixel*(o/n.layout.gridHeight);"number"==typeof e.y2?("number"==typeof e.y&&(e.y+=r),e.y2+=r):"number"==typeof e.y&&(e.y=this._snapY(e.y+r,a))}}else{if("number"!=typeof e.x)return;if("move"===t.mode)"number"==typeof e.x2?(e.x+=i,e.x2+=i):e.x=this._snapX(e.x+i);else if("resize-x1"===t.mode||"resize-x2"===t.mode){const n=null==e.x2||e.x<=e.x2;("resize-x2"===t.mode?!n:n)?e.x=this._snapX(e.x+i):"number"==typeof e.x2&&(e.x2=this._snapX(e.x2+i))}}}_invertPoint(t,e,n){const i=this.w,s=("category"===i.config.xaxis.type||i.config.xaxis.convertedCatToNumeric)&&!i.axisFlags.dataFormatXNumeric;let a=t.x;!s&&"number"==typeof t.x&&i.layout.gridWidth&&(a=t.x+e*(i.globals.xRange/i.layout.gridWidth));let o=t.y;const r=t.yAxisIndex||0,l=i.globals.seriesYAxisMap,c=l&&l[r]?l[r][0]:0,d=i.globals.yRange?i.globals.yRange[c]:null,h=i.config.yaxis[r]&&i.config.yaxis[r].logarithmic;return"number"==typeof t.y&&null!=d&&!h&&i.layout.gridHeight&&(o=t.y-n*(d/i.layout.gridHeight)),{newX:a,newY:o}}_redrawAnno(t,e,n){const i=this.w.dom.baseEl,s=this.ctx.annotations;if(!i||!s)return;i.querySelectorAll("."+e.id).forEach(t=>t.remove());const a=i.querySelector(".apexcharts-"+t+"-annotations");if(!a)return;"point"===t&&s.pointsAnnotations?s.pointsAnnotations.addPointAnnotation(e,a,n):"xaxis"===t&&s.xAxisAnnotations?s.xAxisAnnotations.addXaxisAnnotation(e,a,n):"yaxis"===t&&s.yAxisAnnotations&&s.yAxisAnnotations.addYaxisAnnotation(e,a,n);const o=i.querySelector(".apexcharts-"+t+"-annotation-label."+e.id);if(o&&s.helpers&&e.label&&e.label.text){const t=s.helpers.addBackgroundToAnno(o,e);t&&o.parentNode&&o.parentNode.insertBefore(t.node,o)}this._attach()}_fireAnnotationEvent(t,e){var n;const i=this.w.config.chart.events;"function"==typeof i[t]&&i[t](this.ctx,e),null==(n=this.ctx.events)||n.fireEvent(t,[this.ctx,e])}_fireDragged(t,e,n){const i={type:t,id:e.id,index:n,x:e.x,y:e.y};null!=e.x2&&(i.x2=e.x2),null!=e.y2&&(i.y2=e.y2),this._fireAnnotationEvent("annotationDragged",i)}startCreate(){if(this._creating)return;const t=this.w.dom.Paper&&this.w.dom.Paper.node;t&&(this._creating=!0,t.style.cursor="crosshair",t.addEventListener("click",this._onCreateClick,!0),this._syncPalette())}stopCreate(){if(!this._creating)return;this._creating=!1;const t=this.w.dom.Paper&&this.w.dom.Paper.node;t&&(t.style.cursor="",t.removeEventListener("click",this._onCreateClick,!0)),this._syncPalette()}_onCreateClick(t){if(!this._creating)return;t.preventDefault(),t.stopPropagation();const e=this._pixelToData(t.clientX,t.clientY);this.stopCreate(),e&&this.createAt(e.x,e.y)}createAt(t,e,s={}){const a=this.w;this._wire(),this._createSeq+=1;const o="apexcharts-ink-new-"+this._createSeq+"-"+a.globals.chartID,r=n.extend((new i).pointAnnotation,{x:t,y:e,id:o,draggable:!0,label:{text:s.text||"Note"}});a.config.annotations||(a.config.annotations={}),Array.isArray(a.config.annotations.points)||(a.config.annotations.points=[]),a.config.annotations.points.push(r);const l=a.config.annotations.points.length-1;return this._redrawAnno("point",r,l),this._checkpoint("ink:create"),this._fireCreated("point",r,l),this._startEdit("point",l,{select:!0}),r}createLineAt(t,e,s={}){const a=this.w;this._wire(),this._createSeq+=1;const o="apexcharts-ink-new-"+this._createSeq+"-"+a.globals.chartID,r="y"===t?"yaxis":"xaxis",l="yaxis"===r?(new i).yAxisAnnotation:(new i).xAxisAnnotation,c={id:o,draggable:!0,strokeDashArray:null!=s.strokeDashArray?s.strokeDashArray:4,label:{text:s.text||""}};s.color&&(c.borderColor=s.color,c.label.borderColor=s.color),"yaxis"===r?c.y=e:c.x=e;const d=n.extend(l,c);a.config.annotations||(a.config.annotations={}),Array.isArray(a.config.annotations[r])||(a.config.annotations[r]=[]),a.config.annotations[r].push(d);const h=a.config.annotations[r].length-1;return this._redrawAnno(r,d,h),this._checkpoint("ink:create"),this._fireCreated(r,d,h),!1!==s.select&&this._startEdit(r,h,{select:!0}),d}_pixelToData(t,e){const n=this.w,i=n.dom.baseEl&&n.dom.baseEl.querySelector(".apexcharts-grid");if(!i)return null;const s=i.getBoundingClientRect();if(!s.width||!s.height)return null;const a=(t-s.left)/s.width,o=(e-s.top)/s.height;let r=n.globals.minX+a*n.globals.xRange;const l=(n.globals.minYArr&&null!=n.globals.minYArr[0]?n.globals.minYArr[0]:n.globals.minY)+(1-o)*(n.globals.yRange&&null!=n.globals.yRange[0]?n.globals.yRange[0]:n.globals.maxY-n.globals.minY);return("category"===n.config.xaxis.type||n.config.xaxis.convertedCatToNumeric)&&!n.axisFlags.dataFormatXNumeric&&(r=Math.round(r)),{x:r,y:l}}_fireCreated(t,e,n){const i={type:t,id:e.id,index:n};void 0!==e.x&&(i.x=e.x),void 0!==e.y&&(i.y=e.y),this._fireAnnotationEvent("annotationCreated",i)}_renderPalette(){const t=this.w.dom.elWrap;if(!t||t.querySelector(".apexcharts-ink-palette"))return;const e=t.ownerDocument,n=e.createElement("div");n.className="apexcharts-ink-palette";const i=n.style;i.position="absolute",i.top="6px",i.left="6px",i.zIndex="15";const s=e.createElement("button");s.type="button",s.className="apexcharts-ink-add",s.textContent="+ Note";const a=s.style;a.cursor="pointer",a.font="12px sans-serif",a.padding="4px 9px",a.borderRadius="5px",a.border="1px solid #6366f1",a.color="#4338ca",a.background="#fff",s.addEventListener("click",t=>{t.stopPropagation(),this._creating?this.stopCreate():this.startCreate()}),n.appendChild(s),t.appendChild(n),this._syncPalette()}_syncPalette(){const t=this.w.dom.elWrap,e=t&&t.querySelector(".apexcharts-ink-add");e&&(this._creating?(e.style.background="#6366f1",e.style.color="#fff",e.textContent="Click chart..."):(e.style.background="#fff",e.style.color="#4338ca",e.textContent="+ Note"))}_noteColors(){const t=this.w.config.chart.ink;return t&&Array.isArray(t.noteColors)&&t.noteColors.length?t.noteColors:l}static _isLight(t){const e=String(t||"").replace("#",""),n=3===e.length?e.split("").map(t=>t+t).join(""):e,i=parseInt(n,16);if(isNaN(i)||6!==n.length)return!1;return(.299*(i>>16&255)+.587*(i>>8&255)+.114*(255&i))/255>.72}static _isBold(t){const e=t&&t.fontWeight;return"bold"===e||parseInt(String(e),10)>=600}_cardBtn(t,e,n,i,s,a){const o=t.createElement("button");return o.type="button",o.className="apexcharts-ink-btn"+(s?" "+s:""),o.title=n,o.setAttribute("aria-label",n),a?o.innerHTML=e:o.textContent=e,o.addEventListener("mousedown",t=>t.preventDefault()),o.addEventListener("click",t=>{t.stopPropagation(),i()}),o}_cardLabel(t,e){const n=t.createElement("span");return n.className="apexcharts-ink-cardlabel",n.textContent=e,n}_mkSwatch(t,e,n,i){const s=t.createElement("button");return s.type="button",s.className="apexcharts-ink-swatch"+(i?" "+i:""),s.title=e,s.setAttribute("aria-label","Color "+e),s.dataset.color=e,s.style.background=e,s.addEventListener("mousedown",t=>t.preventDefault()),s.addEventListener("click",t=>{t.stopPropagation(),n(e)}),s}_startEdit(t,e,n={}){const i=this.w,s=this._annoList(t)[e],a=i.dom.baseEl,o=i.dom.elWrap;if(!(s&&s.id&&a&&o))return;this._closeEditor(!1);const l=a.ownerDocument,c=l.createElement("div");c.className="apexcharts-ink-card",c.setAttribute("role","dialog"),c.setAttribute("aria-label","Edit note"),c.style.visibility="hidden";const d=l.createElement("div");d.className="apexcharts-ink-card-row";const h=l.createElement("input");h.type="text",h.className="apexcharts-ink-editor",h.placeholder="Note text",h.value=s.label&&s.label.text||"",d.appendChild(h),d.appendChild(this._cardBtn(l,'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 6h18M8 6V4a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v2m3 0v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/></svg>',"Delete note",()=>this._deleteAnno(),"apexcharts-ink-btn--delete",!0)),c.appendChild(d);const p=l.createElement("div");p.className="apexcharts-ink-card-row","point"!==t&&p.appendChild(this._cardLabel(l,"Label")),this._noteColors().forEach(t=>{p.appendChild(this._mkSwatch(l,t,t=>this._applyColor(t)))});const _=l.createElement("span");if(_.className="apexcharts-ink-sep",p.appendChild(_),p.appendChild(this._cardBtn(l,"B","Bold",()=>this._toggleBold(),"apexcharts-ink-btn--bold")),p.appendChild(this._cardBtn(l,"A-","Smaller text",()=>this._stepFont(-1))),p.appendChild(this._cardBtn(l,"A+","Larger text",()=>this._stepFont(1))),c.appendChild(p),"point"!==t){const t=l.createElement("div");t.className="apexcharts-ink-card-row",t.appendChild(this._cardLabel(l,"Line")),this._noteColors().forEach(e=>{t.appendChild(this._mkSwatch(l,e,t=>this._applyLineColor(t),"apexcharts-ink-swatch--line"))}),c.appendChild(t)}if("point"===t){const t=l.createElement("div");t.className="apexcharts-ink-card-row",t.appendChild(this._cardLabel(l,"Marker")),t.appendChild(this._cardBtn(l,"-","Smaller marker",()=>this._stepMarker(-1)));const e=l.createElement("span");e.className="apexcharts-ink-marker-size",t.appendChild(e),t.appendChild(this._cardBtn(l,"+","Larger marker",()=>this._stepMarker(1))),t.appendChild(this._cardBtn(l,r.circle,"Marker shape",()=>this._cycleShape(),"apexcharts-ink-btn--shape")),c.appendChild(t)}o.appendChild(c),this._editor={card:c,input:h,type:t,index:e},this._positionCard(),this._syncCard(),c.style.visibility="",h.focus(),n.select&&h.select(),c.addEventListener("keydown",t=>{"Escape"===t.key?(t.preventDefault(),t.stopPropagation(),this._closeEditor(!1)):"Enter"===t.key&&t.target===h&&(t.preventDefault(),this._closeEditor(!0))}),l.addEventListener("mousedown",this._onDocDownEditor,!0),l.addEventListener("touchstart",this._onDocDownEditor,!0)}_onDocDownEditor(t){const e=this._editor;e&&!e.card.contains(t.target)&&this._closeEditor(!0)}_positionCard(){const t=this._editor;if(!t)return;const e=this.w,n=e.dom.baseEl,i=e.dom.elWrap,s=this._annoList(t.type)[t.index];if(!n||!i||!s)return;const a=n.querySelector(".apexcharts-"+t.type+"-annotation-label."+s.id)||n.querySelector("."+s.id);if(!a)return;const o=i.getBoundingClientRect(),r=a.getBoundingClientRect(),l=t.card.offsetWidth,c=t.card.offsetHeight;let d=Math.round(r.left-o.left),h=Math.round(r.bottom-o.top)+8;h+c>i.clientHeight-4&&(h=Math.round(r.top-o.top)-c-8),d+l>i.clientWidth-4&&(d=i.clientWidth-l-4),t.card.style.left=Math.max(4,d)+"px",t.card.style.top=Math.max(4,h)+"px"}_syncCard(){const t=this._editor;if(!t)return;const e=this._annoList(t.type)[t.index];if(!e)return;const n=e.label&&e.label.style||{},i=String(n.background||"").toLowerCase();t.card.querySelectorAll(".apexcharts-ink-swatch:not(.apexcharts-ink-swatch--line)").forEach(t=>{t.classList.toggle("apexcharts-ink-swatch--active",(t.dataset.color||"").toLowerCase()===i)});const s=String(e.borderColor||"").toLowerCase();t.card.querySelectorAll(".apexcharts-ink-swatch--line").forEach(t=>{t.classList.toggle("apexcharts-ink-swatch--active",(t.dataset.color||"").toLowerCase()===s)});const a=t.card.querySelector(".apexcharts-ink-btn--bold");a&&a.classList.toggle("apexcharts-ink-btn--active",c._isBold(n));const o=e.marker||{},l=t.card.querySelector(".apexcharts-ink-marker-size");l&&(l.textContent=String("number"==typeof o.size?o.size:4));const d=t.card.querySelector(".apexcharts-ink-btn--shape");d&&(d.textContent=r[o.shape]||r.circle)}_commitTextOf(t){const e=this._annoList(t.type)[t.index];if(!e)return;const n=t.input.value;e.label||(e.label={}),e.label.text!==n&&(e.label.text=n,this._redrawAnno(t.type,e,t.index),this._checkpoint("ink:edit"),this._fireEdited(t.type,e,t.index))}_closeEditor(t){const e=this._editor;if(!e)return;this._editor=null;const n=this.w.dom.baseEl&&this.w.dom.baseEl.ownerDocument;n&&(n.removeEventListener("mousedown",this._onDocDownEditor,!0),n.removeEventListener("touchstart",this._onDocDownEditor,!0)),e.card.parentNode&&e.card.parentNode.removeChild(e.card),t&&this._commitTextOf(e)}_applyStyle(t,e){const n=this._editor;if(!n)return;const i=this._annoList(n.type)[n.index];i&&(this._commitTextOf(n),i.label||(i.label={}),i.label.style||(i.label.style={}),e(i),this._redrawAnno(n.type,i,n.index),this._checkpoint(t),this._fireStyled(n.type,i,n.index),this._syncCard(),this._positionCard())}_applyColor(t){const e=this._editor;if(!e)return;const n=c._isLight(t);this._applyStyle("ink:style",i=>{i.label.style.background=t,i.label.style.color=n?"#334155":"#ffffff",i.label.borderColor=n?"#cbd5e1":t,"point"===e.type&&(i.marker||(i.marker={}),i.marker.strokeColor=n?"#334155":t,i.marker.fillColor=n?"#ffffff":t)})}_applyLineColor(t){const e=this._editor;e&&"point"!==e.type&&this._applyStyle("ink:style",e=>{e.borderColor=t,null==e.x2&&null==e.y2||(e.fillColor=t)})}_stepFont(t){this._applyStyle("ink:style",e=>{const n=parseFloat(e.label.style.fontSize)||11;let i=0;for(let t=1;t<a.length;t++)Math.abs(a[t]-n)<Math.abs(a[i]-n)&&(i=t);i=Math.min(a.length-1,Math.max(0,i+t)),e.label.style.fontSize=a[i]+"px"})}_toggleBold(){this._applyStyle("ink:style",t=>{t.label.style.fontWeight=c._isBold(t.label.style)?400:700})}_stepMarker(t){this._applyStyle("ink:style",e=>{e.marker||(e.marker={});const n="number"==typeof e.marker.size?e.marker.size:4;e.marker.size=Math.min(14,Math.max(2,n+t))})}_cycleShape(){this._applyStyle("ink:style",t=>{t.marker||(t.marker={});const e=o.indexOf(t.marker.shape);t.marker.shape=o[(e+1)%o.length]})}_deleteAnno(){const t=this._editor;if(!t)return;const e=this._annoList(t.type),n=e[t.index];if(this._closeEditor(!1),!n)return;const i=this.w.dom.baseEl;i&&n.id&&i.querySelectorAll("."+n.id).forEach(t=>t.remove()),e.splice(t.index,1);for(let n=t.index;n<e.length;n++)this._redrawAnno(t.type,e[n],n);this._checkpoint("ink:delete"),this._fireDeleted(t.type,n,t.index)}_fireEdited(t,e,n){const i={type:t,id:e.id,index:n,text:e.label?e.label.text:""};this._fireAnnotationEvent("annotationEdited",i)}_fireStyled(t,e,n){const i={type:t,id:e.id,index:n,label:e.label,marker:e.marker};this._fireAnnotationEvent("annotationStyled",i)}_fireDeleted(t,e,n){const i={type:t,id:e.id,index:n};this._fireAnnotationEvent("annotationDeleted",i)}_teardownDocListeners(){const t=this.w.dom.baseEl&&this.w.dom.baseEl.ownerDocument;t&&(t.removeEventListener("mousemove",this._onMove),t.removeEventListener("touchmove",this._onMove),t.removeEventListener("mouseup",this._onUp),t.removeEventListener("touchend",this._onUp))}teardown(){var t,e,n,i;this._teardownDocListeners(),this._closeEditor(!1),this.stopCreate(),this._drag=null,this._wired&&(null==(e=(t=this.ctx).removeEventListener)||e.call(t,"mounted",this._onRerender),null==(i=(n=this.ctx).removeEventListener)||i.call(n,"updated",this._onRerender),this._wired=!1)}}e.registerFeatures({ink:c}),t.default=e,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});