class ArcMask {
	constructor(element, startX = 50, startY = 0, radius = 50) {
		this._element = element;
		this._startX = startX;
		this._startY = startY;
		this._radius = radius;

		this._dl = `M${startX},${startY} a${radius},${radius} 0`;
	}

	_getNewCoord(percent) {
		let theta = 2 * Math.PI * percent / 100, r = this._radius;
		return {x: r * Math.sin(theta), y: r * (1 - Math.cos(theta))};
	}

	drawArc(percent) {
		percent = 100 - percent;
		let dm;
		let dr = (percent === 100 || percent === 0) ? '' : "L50,50 z";
		if(percent <= 50) {
			dm = '1,0';
			if(percent === 0) percent = .01;
		} else {
			dm = '0,0 ';
		}

		let coord = this._getNewCoord(percent);


		this._element.setAttribute('d', `${this._dl} ${dm} ${coord.x},${coord.y} ${dr}`);
	}

}

// .svgSpace mask > path#arcMask

const arcMask = new ArcMask(document.getElementById('arcMask'));

eventDispatcher.on('timer-display-percent-left', (percentLeft) => {
	console.log("percentleft", percentLeft);
	arcMask.drawArc(percentLeft);
});


// .progress > progress#totalProgressBar

const prgBar = document.getElementById('totalProgressBar');

eventDispatcher.on('timer-display-percent-left', (percentLeft) => {
	console.log("percentleft", percentLeft);
	prgBar.value = 100 - percentLeft;
});

eventDispatcher.on('check-progress:changed', (on) => {
	prgBar.classList.toggle('progress-off', !on);
});


// .svgSpace mask > path#arcMask, .progress > progress#totalProgressBar

eventDispatcher.on('timer:session-in-progress', ({session: {name, left: secondsLeft, len: secondsTotal}}) => {
	let percentLeft = Math.round(secondsLeft / secondsTotal * 100);
	console.log("percent left", percentLeft);
	arcMask.drawArc(percentLeft);
	prgBar.value = 100 - percentLeft;
});

@@ -1705,28 +1705,311 @@
 ue = 100 - percentLeft;%0A%7D);%0A
+%0AeventDispatcher.on('timer:session-modified', (%7Bmodification: %7BvalueName, newValue: seconds%7D, isCurrentSession%7D) =%3E %7B%0A%09// reset progress indicators when session is modified by the user%0A%09if(valueName === %22len%22 && isCurrentSession) %7B%0A%09%09arcMask.drawArc(100);%0A%09%09prgBar.value = 0;%0A%09%7D%0A%7D);%0A

Reset progress indicators on session modification by the user