"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TrailMaker = void 0; const tsparticles_engine_1 = require("tsparticles-engine"); const Trail_1 = require("./Options/Classes/Trail"); class TrailMaker extends tsparticles_engine_1.ExternalInteractorBase { constructor(container) { super(container); this._delay = 0; } clear() { } init() { } interact(delta) { var _a, _b, _c, _d; return __awaiter(this, void 0, void 0, function* () { if (!this.container.retina.reduceFactor) { return; } const container = this.container, options = container.actualOptions, trailOptions = options.interactivity.modes.trail; if (!trailOptions) { return; } const optDelay = (trailOptions.delay * 1000) / this.container.retina.reduceFactor; if (this._delay < optDelay) { this._delay += delta.value; } if (this._delay < optDelay) { return; } let canEmit = true; if (trailOptions.pauseOnStop) { if (container.interactivity.mouse.position === this._lastPosition || (((_a = container.interactivity.mouse.position) === null || _a === void 0 ? void 0 : _a.x) === ((_b = this._lastPosition) === null || _b === void 0 ? void 0 : _b.x) && ((_c = container.interactivity.mouse.position) === null || _c === void 0 ? void 0 : _c.y) === ((_d = this._lastPosition) === null || _d === void 0 ? void 0 : _d.y))) { canEmit = false; } } if (container.interactivity.mouse.position) { this._lastPosition = { x: container.interactivity.mouse.position.x, y: container.interactivity.mouse.position.y, }; } else { delete this._lastPosition; } if (canEmit) { container.particles.push(trailOptions.quantity, container.interactivity.mouse, trailOptions.particles); } this._delay -= optDelay; }); } isEnabled(particle) { var _a; const container = this.container, options = container.actualOptions, mouse = container.interactivity.mouse, events = ((_a = particle === null || particle === void 0 ? void 0 : particle.interactivity) !== null && _a !== void 0 ? _a : options.interactivity).events; return ((mouse.clicking && mouse.inside && !!mouse.position && (0, tsparticles_engine_1.isInArray)("trail", events.onClick.mode)) || (mouse.inside && !!mouse.position && (0, tsparticles_engine_1.isInArray)("trail", events.onHover.mode))); } loadModeOptions(options, ...sources) { if (!options.trail) { options.trail = new Trail_1.Trail(); } for (const source of sources) { options.trail.load(source === null || source === void 0 ? void 0 : source.trail); } } reset() { } } exports.TrailMaker = TrailMaker;