var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var _StringMatchController_instances, _StringMatchController_compareKeywordToTargets; import SyncedBooleanAttributesController from '../synced_boolean_attributes_controller/synced_boolean_attributes_controller'; class StringMatchController extends SyncedBooleanAttributesController { constructor() { super(...arguments); _StringMatchController_instances.add(this); this.outletUpdate = this.change; } change(event, updateTo = {}) { var _a; const value = (_a = updateTo.data) !== null && _a !== void 0 ? _a : event.currentTarget.value; this.keywordValue = value; __classPrivateFieldGet(this, _StringMatchController_instances, "m", _StringMatchController_compareKeywordToTargets).call(this); this.sendToOutlets(event, Object.assign(Object.assign({}, updateTo), { data: this.keywordValue })); } getElementsToSync() { return this.matchTargets; } getValueForElement(element) { var _a, _b; return (_b = (_a = element.innerText) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(this.keywordValue.toLowerCase())) !== null && _b !== void 0 ? _b : false; } getState() { return this.keywordValue; } } _StringMatchController_instances = new WeakSet(), _StringMatchController_compareKeywordToTargets = function _StringMatchController_compareKeywordToTargets() { if (this.hasMatchTarget) { let foundMatch = false; for (let index in this.matchTargets) { const target = this.matchTargets[index]; const value = this.getValueForElement(target); this.updateAttributesForElement(target, value); if (value) { foundMatch = true; } } if (this.hasEmptyTarget) { this.emptyTarget.setAttribute('aria-hidden', String(foundMatch)); } } }; StringMatchController.outlets = SyncedBooleanAttributesController.outlets; StringMatchController.targets = ['match', 'empty']; StringMatchController.values = Object.assign(Object.assign({}, SyncedBooleanAttributesController.values), { keyword: String }); export default StringMatchController;