This commit is contained in:
counterweight 2026-05-14 10:56:04 +02:00
parent bc92231240
commit b8225c639e
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
11904 changed files with 1472749 additions and 133 deletions

View file

@ -0,0 +1,37 @@
import { A11yDocument, Region } from './Region.js';
import Sre from '../sre.js';
export interface Explorer {
active: boolean;
stoppable: boolean;
Attach(): void;
Detach(): void;
Start(): void;
Stop(): void;
AddEvents(): void;
RemoveEvents(): void;
Update(force?: boolean): void;
}
export declare class AbstractExplorer<T> implements Explorer {
document: A11yDocument;
protected region: Region<T>;
protected node: HTMLElement;
stoppable: boolean;
protected events: [string, (x: Event) => void][];
protected highlighter: Sre.highlighter;
private _active;
protected static stopEvent(event: Event): void;
static create<T>(document: A11yDocument, region: Region<T>, node: HTMLElement, ...rest: any[]): Explorer;
protected constructor(document: A11yDocument, region: Region<T>, node: HTMLElement, ..._rest: any[]);
protected Events(): [string, (x: Event) => void][];
get active(): boolean;
set active(flag: boolean);
Attach(): void;
Detach(): void;
Start(): void;
Stop(): void;
AddEvents(): void;
RemoveEvents(): void;
Update(force?: boolean): void;
protected getHighlighter(): Sre.highlighter;
protected stopEvent(event: Event): void;
}

162
node_modules/mathjax-full/js/a11y/explorer/Explorer.js generated vendored Normal file
View file

@ -0,0 +1,162 @@
"use strict";
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractExplorer = void 0;
var sre_js_1 = __importDefault(require("../sre.js"));
var AbstractExplorer = (function () {
function AbstractExplorer(document, region, node) {
var _rest = [];
for (var _i = 3; _i < arguments.length; _i++) {
_rest[_i - 3] = arguments[_i];
}
this.document = document;
this.region = region;
this.node = node;
this.stoppable = true;
this.events = [];
this.highlighter = this.getHighlighter();
this._active = false;
}
AbstractExplorer.stopEvent = function (event) {
if (event.preventDefault) {
event.preventDefault();
}
else {
event.returnValue = false;
}
if (event.stopImmediatePropagation) {
event.stopImmediatePropagation();
}
else if (event.stopPropagation) {
event.stopPropagation();
}
event.cancelBubble = true;
};
AbstractExplorer.create = function (document, region, node) {
var rest = [];
for (var _i = 3; _i < arguments.length; _i++) {
rest[_i - 3] = arguments[_i];
}
var explorer = new (this.bind.apply(this, __spreadArray([void 0, document, region, node], __read(rest), false)))();
return explorer;
};
AbstractExplorer.prototype.Events = function () {
return this.events;
};
Object.defineProperty(AbstractExplorer.prototype, "active", {
get: function () {
return this._active;
},
set: function (flag) {
this._active = flag;
},
enumerable: false,
configurable: true
});
AbstractExplorer.prototype.Attach = function () {
this.AddEvents();
};
AbstractExplorer.prototype.Detach = function () {
this.RemoveEvents();
};
AbstractExplorer.prototype.Start = function () {
this.highlighter = this.getHighlighter();
this.active = true;
};
AbstractExplorer.prototype.Stop = function () {
if (this.active) {
this.region.Clear();
this.region.Hide();
this.active = false;
}
};
AbstractExplorer.prototype.AddEvents = function () {
var e_1, _a;
try {
for (var _b = __values(this.events), _c = _b.next(); !_c.done; _c = _b.next()) {
var _d = __read(_c.value, 2), eventkind = _d[0], eventfunc = _d[1];
this.node.addEventListener(eventkind, eventfunc);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
};
AbstractExplorer.prototype.RemoveEvents = function () {
var e_2, _a;
try {
for (var _b = __values(this.events), _c = _b.next(); !_c.done; _c = _b.next()) {
var _d = __read(_c.value, 2), eventkind = _d[0], eventfunc = _d[1];
this.node.removeEventListener(eventkind, eventfunc);
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_2) throw e_2.error; }
}
};
AbstractExplorer.prototype.Update = function (force) {
if (force === void 0) { force = false; }
};
AbstractExplorer.prototype.getHighlighter = function () {
var opts = this.document.options.a11y;
var foreground = { color: opts.foregroundColor.toLowerCase(),
alpha: opts.foregroundOpacity / 100 };
var background = { color: opts.backgroundColor.toLowerCase(),
alpha: opts.backgroundOpacity / 100 };
return sre_js_1.default.getHighlighter(background, foreground, { renderer: this.document.outputJax.name, browser: 'v3' });
};
AbstractExplorer.prototype.stopEvent = function (event) {
if (this.stoppable) {
AbstractExplorer.stopEvent(event);
}
};
return AbstractExplorer;
}());
exports.AbstractExplorer = AbstractExplorer;
//# sourceMappingURL=Explorer.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"Explorer.js","sourceRoot":"","sources":["../../../ts/a11y/explorer/Explorer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,qDAA4B;AAyE5B;IAqEE,0BACS,QAAsB,EACnB,MAAiB,EACjB,IAAiB;QAAE,eAAe;aAAf,UAAe,EAAf,qBAAe,EAAf,IAAe;YAAf,8BAAe;;QAFrC,aAAQ,GAAR,QAAQ,CAAc;QACnB,WAAM,GAAN,MAAM,CAAW;QACjB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AI,CAAC,iBAAiB,GAAG,GAAG,EAAC,CAAC;QACvD,OAAO,gBAAG,CAAC,cAAc,CACvB,UAAU,EAAE,UAAU,EACtB,EAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC,CAAC;IAC7D,CAAC;IAMS,oCAAS,GAAnB,UAAoB,KAAY;QAC9B,IAAI,IAAI,CAAC,SAAS,EAAE;YAClB,gBAAgB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;SACnC;IACH,CAAC;IAEH,uBAAC;AAAD,CAAC,AAtLD,IAsLC;AAtLY,4CAAgB"}

View file

@ -0,0 +1,55 @@
import { A11yDocument, Region } from './Region.js';
import { Explorer, AbstractExplorer } from './Explorer.js';
import Sre from '../sre.js';
export interface KeyExplorer extends Explorer {
KeyDown(event: KeyboardEvent): void;
FocusIn(event: FocusEvent): void;
FocusOut(event: FocusEvent): void;
}
export declare abstract class AbstractKeyExplorer<T> extends AbstractExplorer<T> implements KeyExplorer {
attached: boolean;
protected walker: Sre.walker;
private eventsAttached;
protected events: [string, (x: Event) => void][];
private oldIndex;
abstract KeyDown(event: KeyboardEvent): void;
FocusIn(_event: FocusEvent): void;
FocusOut(_event: FocusEvent): void;
Update(force?: boolean): void;
Attach(): void;
AddEvents(): void;
Detach(): void;
Stop(): void;
}
export declare class SpeechExplorer extends AbstractKeyExplorer<string> {
document: A11yDocument;
protected region: Region<string>;
protected node: HTMLElement;
private mml;
private static updatePromise;
speechGenerator: Sre.speechGenerator;
showRegion: string;
private init;
private restarted;
constructor(document: A11yDocument, region: Region<string>, node: HTMLElement, mml: string);
Start(): void;
Update(force?: boolean): void;
Speech(walker: Sre.walker): void;
KeyDown(event: KeyboardEvent): void;
protected triggerLink(code: number): boolean;
Move(key: number): void;
private initWalker;
private getOptions;
}
export declare class Magnifier extends AbstractKeyExplorer<HTMLElement> {
document: A11yDocument;
protected region: Region<HTMLElement>;
protected node: HTMLElement;
private mml;
constructor(document: A11yDocument, region: Region<HTMLElement>, node: HTMLElement, mml: string);
Update(force?: boolean): void;
Start(): void;
private showFocus;
Move(key: number): void;
KeyDown(event: KeyboardEvent): void;
}

View file

@ -0,0 +1,313 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
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());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Magnifier = exports.SpeechExplorer = exports.AbstractKeyExplorer = void 0;
var Explorer_js_1 = require("./Explorer.js");
var sre_js_1 = __importDefault(require("../sre.js"));
var AbstractKeyExplorer = (function (_super) {
__extends(AbstractKeyExplorer, _super);
function AbstractKeyExplorer() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.attached = false;
_this.eventsAttached = false;
_this.events = _super.prototype.Events.call(_this).concat([['keydown', _this.KeyDown.bind(_this)],
['focusin', _this.FocusIn.bind(_this)],
['focusout', _this.FocusOut.bind(_this)]]);
_this.oldIndex = null;
return _this;
}
AbstractKeyExplorer.prototype.FocusIn = function (_event) {
};
AbstractKeyExplorer.prototype.FocusOut = function (_event) {
this.Stop();
};
AbstractKeyExplorer.prototype.Update = function (force) {
if (force === void 0) { force = false; }
if (!this.active && !force)
return;
this.highlighter.unhighlight();
var nodes = this.walker.getFocus(true).getNodes();
if (!nodes.length) {
this.walker.refocus();
nodes = this.walker.getFocus().getNodes();
}
this.highlighter.highlight(nodes);
};
AbstractKeyExplorer.prototype.Attach = function () {
_super.prototype.Attach.call(this);
this.attached = true;
this.oldIndex = this.node.tabIndex;
this.node.tabIndex = 1;
this.node.setAttribute('role', 'application');
};
AbstractKeyExplorer.prototype.AddEvents = function () {
if (!this.eventsAttached) {
_super.prototype.AddEvents.call(this);
this.eventsAttached = true;
}
};
AbstractKeyExplorer.prototype.Detach = function () {
if (this.active) {
this.node.tabIndex = this.oldIndex;
this.oldIndex = null;
this.node.removeAttribute('role');
}
this.attached = false;
};
AbstractKeyExplorer.prototype.Stop = function () {
if (this.active) {
this.highlighter.unhighlight();
this.walker.deactivate();
}
_super.prototype.Stop.call(this);
};
return AbstractKeyExplorer;
}(Explorer_js_1.AbstractExplorer));
exports.AbstractKeyExplorer = AbstractKeyExplorer;
var SpeechExplorer = (function (_super) {
__extends(SpeechExplorer, _super);
function SpeechExplorer(document, region, node, mml) {
var _this = _super.call(this, document, region, node) || this;
_this.document = document;
_this.region = region;
_this.node = node;
_this.mml = mml;
_this.showRegion = 'subtitles';
_this.init = false;
_this.restarted = false;
_this.initWalker();
return _this;
}
SpeechExplorer.prototype.Start = function () {
var _this = this;
if (!this.attached)
return;
var options = this.getOptions();
if (!this.init) {
this.init = true;
SpeechExplorer.updatePromise = SpeechExplorer.updatePromise.then(function () { return __awaiter(_this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
return [2, sre_js_1.default.sreReady()
.then(function () { return sre_js_1.default.setupEngine({ locale: options.locale }); })
.then(function () {
_this.Speech(_this.walker);
_this.Start();
})];
});
}); })
.catch(function (error) { return console.log(error.message); });
return;
}
_super.prototype.Start.call(this);
this.speechGenerator = sre_js_1.default.getSpeechGenerator('Direct');
this.speechGenerator.setOptions(options);
this.walker = sre_js_1.default.getWalker('table', this.node, this.speechGenerator, this.highlighter, this.mml);
this.walker.activate();
this.Update();
if (this.document.options.a11y[this.showRegion]) {
SpeechExplorer.updatePromise.then(function () { return _this.region.Show(_this.node, _this.highlighter); });
}
this.restarted = true;
};
SpeechExplorer.prototype.Update = function (force) {
var _this = this;
if (force === void 0) { force = false; }
_super.prototype.Update.call(this, force);
var options = this.speechGenerator.getOptions();
if (options.modality === 'speech') {
this.document.options.sre.domain = options.domain;
this.document.options.sre.style = options.style;
this.document.options.a11y.speechRules =
options.domain + '-' + options.style;
}
SpeechExplorer.updatePromise = SpeechExplorer.updatePromise.then(function () { return __awaiter(_this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
return [2, sre_js_1.default.sreReady()
.then(function () { return sre_js_1.default.setupEngine({ modality: options.modality,
locale: options.locale }); })
.then(function () { return _this.region.Update(_this.walker.speech()); })];
});
}); });
};
SpeechExplorer.prototype.Speech = function (walker) {
var _this = this;
SpeechExplorer.updatePromise.then(function () {
walker.speech();
_this.node.setAttribute('hasspeech', 'true');
_this.Update();
if (_this.restarted && _this.document.options.a11y[_this.showRegion]) {
_this.region.Show(_this.node, _this.highlighter);
}
});
};
SpeechExplorer.prototype.KeyDown = function (event) {
var code = event.keyCode;
this.walker.modifier = event.shiftKey;
if (code === 27) {
this.Stop();
this.stopEvent(event);
return;
}
if (this.active) {
this.Move(code);
if (this.triggerLink(code))
return;
this.stopEvent(event);
return;
}
if (code === 32 && event.shiftKey || code === 13) {
this.Start();
this.stopEvent(event);
}
};
SpeechExplorer.prototype.triggerLink = function (code) {
var _a, _b;
if (code !== 13) {
return false;
}
var node = (_a = this.walker.getFocus().getNodes()) === null || _a === void 0 ? void 0 : _a[0];
var focus = (_b = node === null || node === void 0 ? void 0 : node.getAttribute('data-semantic-postfix')) === null || _b === void 0 ? void 0 : _b.match(/(^| )link($| )/);
if (focus) {
node.parentNode.dispatchEvent(new MouseEvent('click'));
return true;
}
return false;
};
SpeechExplorer.prototype.Move = function (key) {
this.walker.move(key);
this.Update();
};
SpeechExplorer.prototype.initWalker = function () {
this.speechGenerator = sre_js_1.default.getSpeechGenerator('Tree');
var dummy = sre_js_1.default.getWalker('dummy', this.node, this.speechGenerator, this.highlighter, this.mml);
this.walker = dummy;
};
SpeechExplorer.prototype.getOptions = function () {
var options = this.speechGenerator.getOptions();
var sreOptions = this.document.options.sre;
if (options.modality === 'speech' &&
(options.locale !== sreOptions.locale ||
options.domain !== sreOptions.domain ||
options.style !== sreOptions.style)) {
options.domain = sreOptions.domain;
options.style = sreOptions.style;
options.locale = sreOptions.locale;
this.walker.update(options);
}
return options;
};
SpeechExplorer.updatePromise = Promise.resolve();
return SpeechExplorer;
}(AbstractKeyExplorer));
exports.SpeechExplorer = SpeechExplorer;
var Magnifier = (function (_super) {
__extends(Magnifier, _super);
function Magnifier(document, region, node, mml) {
var _this = _super.call(this, document, region, node) || this;
_this.document = document;
_this.region = region;
_this.node = node;
_this.mml = mml;
_this.walker = sre_js_1.default.getWalker('table', _this.node, sre_js_1.default.getSpeechGenerator('Dummy'), _this.highlighter, _this.mml);
return _this;
}
Magnifier.prototype.Update = function (force) {
if (force === void 0) { force = false; }
_super.prototype.Update.call(this, force);
this.showFocus();
};
Magnifier.prototype.Start = function () {
_super.prototype.Start.call(this);
if (!this.attached)
return;
this.region.Show(this.node, this.highlighter);
this.walker.activate();
this.Update();
};
Magnifier.prototype.showFocus = function () {
var node = this.walker.getFocus().getNodes()[0];
this.region.Show(node, this.highlighter);
};
Magnifier.prototype.Move = function (key) {
var result = this.walker.move(key);
if (result) {
this.Update();
}
};
Magnifier.prototype.KeyDown = function (event) {
var code = event.keyCode;
this.walker.modifier = event.shiftKey;
if (code === 27) {
this.Stop();
this.stopEvent(event);
return;
}
if (this.active && code !== 13) {
this.Move(code);
this.stopEvent(event);
return;
}
if (code === 32 && event.shiftKey || code === 13) {
this.Start();
this.stopEvent(event);
}
};
return Magnifier;
}(AbstractKeyExplorer));
exports.Magnifier = Magnifier;
//# sourceMappingURL=KeyExplorer.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,33 @@
import { A11yDocument, Region } from './Region.js';
import { Explorer, AbstractExplorer } from './Explorer.js';
import '../sre.js';
export interface MouseExplorer extends Explorer {
MouseOver(event: MouseEvent): void;
MouseOut(event: MouseEvent): void;
}
export declare abstract class AbstractMouseExplorer<T> extends AbstractExplorer<T> implements MouseExplorer {
protected events: [string, (x: Event) => void][];
MouseOver(_event: MouseEvent): void;
MouseOut(_event: MouseEvent): void;
}
export declare abstract class Hoverer<T> extends AbstractMouseExplorer<T> {
document: A11yDocument;
protected region: Region<T>;
protected node: HTMLElement;
protected nodeQuery: (node: HTMLElement) => boolean;
protected nodeAccess: (node: HTMLElement) => T;
protected coord: [number, number];
protected constructor(document: A11yDocument, region: Region<T>, node: HTMLElement, nodeQuery: (node: HTMLElement) => boolean, nodeAccess: (node: HTMLElement) => T);
MouseOut(event: MouseEvent): void;
MouseOver(event: MouseEvent): void;
getNode(node: HTMLElement): [HTMLElement, T];
}
export declare class ValueHoverer extends Hoverer<string> {
}
export declare class ContentHoverer extends Hoverer<HTMLElement> {
}
export declare class FlameHoverer extends Hoverer<void> {
document: A11yDocument;
protected node: HTMLElement;
protected constructor(document: A11yDocument, _ignore: any, node: HTMLElement);
}

View file

@ -0,0 +1,139 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FlameHoverer = exports.ContentHoverer = exports.ValueHoverer = exports.Hoverer = exports.AbstractMouseExplorer = void 0;
var Region_js_1 = require("./Region.js");
var Explorer_js_1 = require("./Explorer.js");
require("../sre.js");
var AbstractMouseExplorer = (function (_super) {
__extends(AbstractMouseExplorer, _super);
function AbstractMouseExplorer() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.events = _super.prototype.Events.call(_this).concat([
['mouseover', _this.MouseOver.bind(_this)],
['mouseout', _this.MouseOut.bind(_this)]
]);
return _this;
}
AbstractMouseExplorer.prototype.MouseOver = function (_event) {
this.Start();
};
AbstractMouseExplorer.prototype.MouseOut = function (_event) {
this.Stop();
};
return AbstractMouseExplorer;
}(Explorer_js_1.AbstractExplorer));
exports.AbstractMouseExplorer = AbstractMouseExplorer;
var Hoverer = (function (_super) {
__extends(Hoverer, _super);
function Hoverer(document, region, node, nodeQuery, nodeAccess) {
var _this = _super.call(this, document, region, node) || this;
_this.document = document;
_this.region = region;
_this.node = node;
_this.nodeQuery = nodeQuery;
_this.nodeAccess = nodeAccess;
return _this;
}
Hoverer.prototype.MouseOut = function (event) {
if (event.clientX === this.coord[0] &&
event.clientY === this.coord[1]) {
return;
}
this.highlighter.unhighlight();
this.region.Hide();
_super.prototype.MouseOut.call(this, event);
};
Hoverer.prototype.MouseOver = function (event) {
_super.prototype.MouseOver.call(this, event);
var target = event.target;
this.coord = [event.clientX, event.clientY];
var _a = __read(this.getNode(target), 2), node = _a[0], kind = _a[1];
if (!node) {
return;
}
this.highlighter.unhighlight();
this.highlighter.highlight([node]);
this.region.Update(kind);
this.region.Show(node, this.highlighter);
};
Hoverer.prototype.getNode = function (node) {
var original = node;
while (node && node !== this.node) {
if (this.nodeQuery(node)) {
return [node, this.nodeAccess(node)];
}
node = node.parentNode;
}
node = original;
while (node) {
if (this.nodeQuery(node)) {
return [node, this.nodeAccess(node)];
}
var child = node.childNodes[0];
node = (child && child.tagName === 'defs') ?
node.childNodes[1] : child;
}
return [null, null];
};
return Hoverer;
}(AbstractMouseExplorer));
exports.Hoverer = Hoverer;
var ValueHoverer = (function (_super) {
__extends(ValueHoverer, _super);
function ValueHoverer() {
return _super !== null && _super.apply(this, arguments) || this;
}
return ValueHoverer;
}(Hoverer));
exports.ValueHoverer = ValueHoverer;
var ContentHoverer = (function (_super) {
__extends(ContentHoverer, _super);
function ContentHoverer() {
return _super !== null && _super.apply(this, arguments) || this;
}
return ContentHoverer;
}(Hoverer));
exports.ContentHoverer = ContentHoverer;
var FlameHoverer = (function (_super) {
__extends(FlameHoverer, _super);
function FlameHoverer(document, _ignore, node) {
var _this = _super.call(this, document, new Region_js_1.DummyRegion(document), node, function (x) { return _this.highlighter.isMactionNode(x); }, function () { }) || this;
_this.document = document;
_this.node = node;
return _this;
}
return FlameHoverer;
}(Hoverer));
exports.FlameHoverer = FlameHoverer;
//# sourceMappingURL=MouseExplorer.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"MouseExplorer.js","sourceRoot":"","sources":["../../../ts/a11y/explorer/MouseExplorer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,yCAA8D;AAC9D,6CAAyD;AACzD,qBAAmB;AA+BnB;IAAuD,yCAAmB;IAA1E;QAAA,qEA0BC;QArBW,YAAM,GACd,iBAAM,MAAM,YAAE,CAAC,MAAM,CAAC;YACpB,CAAC,WAAW,EAAE,KAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAI,CAAC,CAAC;YACxC,CAAC,UAAU,EAAE,KAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAI,CAAC,CAAC;SACvC,CAAC,CAAC;;IAiBP,CAAC;IAZQ,yCAAS,GAAhB,UAAiB,MAAkB;QACjC,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAMM,wCAAQ,GAAf,UAAgB,MAAkB;QAChC,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;IAEH,4BAAC;AAAD,CAAC,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O,GAAiB;AAA/C,wCAAc;AAQ3B;IAAkC,gCAAa;IAK7C,sBACS,QAAsB,EAC7B,OAAY,EACF,IAAiB;QAH7B,YAIE,kBAAM,QAAQ,EAAE,IAAI,uBAAW,CAAC,QAAQ,CAAC,EAAE,IAAI,EACzC,UAAA,CAAC,IAAI,OAAA,KAAI,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,EAAjC,CAAiC,EACtC,cAAO,CAAC,CAAC,SAChB;QANQ,cAAQ,GAAR,QAAQ,CAAc;QAEnB,UAAI,GAAJ,IAAI,CAAa;;IAI7B,CAAC;IAEH,mBAAC;AAAD,CAAC,AAdD,CAAkC,OAAO,GAcxC;AAdY,oCAAY"}

69
node_modules/mathjax-full/js/a11y/explorer/Region.d.ts generated vendored Normal file
View file

@ -0,0 +1,69 @@
import { MathDocument } from '../../core/MathDocument.js';
import { CssStyles } from '../../util/StyleList.js';
import Sre from '../sre.js';
export declare type A11yDocument = MathDocument<HTMLElement, Text, Document>;
export interface Region<T> {
AddStyles(): void;
AddElement(): void;
Show(node: HTMLElement, highlighter: Sre.highlighter): void;
Hide(): void;
Clear(): void;
Update(content: T): void;
}
export declare abstract class AbstractRegion<T> implements Region<T> {
document: A11yDocument;
protected static className: string;
protected static styleAdded: boolean;
protected static style: CssStyles;
protected div: HTMLElement;
protected inner: HTMLElement;
protected CLASS: typeof AbstractRegion;
constructor(document: A11yDocument);
AddStyles(): void;
AddElement(): void;
Show(node: HTMLElement, highlighter: Sre.highlighter): void;
protected abstract position(node: HTMLElement): void;
protected abstract highlight(highlighter: Sre.highlighter): void;
Hide(): void;
abstract Clear(): void;
abstract Update(content: T): void;
protected stackRegions(node: HTMLElement): void;
}
export declare class DummyRegion extends AbstractRegion<void> {
Clear(): void;
Update(): void;
Hide(): void;
Show(): void;
AddElement(): void;
AddStyles(): void;
position(): void;
highlight(_highlighter: Sre.highlighter): void;
}
export declare class StringRegion extends AbstractRegion<string> {
Clear(): void;
Update(speech: string): void;
protected position(node: HTMLElement): void;
protected highlight(highlighter: Sre.highlighter): void;
}
export declare class ToolTip extends StringRegion {
protected static className: string;
protected static style: CssStyles;
}
export declare class LiveRegion extends StringRegion {
document: A11yDocument;
protected static className: string;
protected static style: CssStyles;
constructor(document: A11yDocument);
}
export declare class HoverRegion extends AbstractRegion<HTMLElement> {
document: A11yDocument;
protected static className: string;
protected static style: CssStyles;
constructor(document: A11yDocument);
protected position(node: HTMLElement): void;
protected highlight(highlighter: Sre.highlighter): void;
Show(node: HTMLElement, highlighter: Sre.highlighter): void;
Clear(): void;
Update(node: HTMLElement): void;
private cloneNode;
}

267
node_modules/mathjax-full/js/a11y/explorer/Region.js generated vendored Normal file
View file

@ -0,0 +1,267 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var _a, _b, _c;
Object.defineProperty(exports, "__esModule", { value: true });
exports.HoverRegion = exports.LiveRegion = exports.ToolTip = exports.StringRegion = exports.DummyRegion = exports.AbstractRegion = void 0;
var StyleList_js_1 = require("../../util/StyleList.js");
var AbstractRegion = (function () {
function AbstractRegion(document) {
this.document = document;
this.CLASS = this.constructor;
this.AddStyles();
this.AddElement();
}
AbstractRegion.prototype.AddStyles = function () {
if (this.CLASS.styleAdded) {
return;
}
var node = this.document.adaptor.node('style');
node.innerHTML = this.CLASS.style.cssText;
this.document.adaptor.head(this.document.adaptor.document).
appendChild(node);
this.CLASS.styleAdded = true;
};
AbstractRegion.prototype.AddElement = function () {
var element = this.document.adaptor.node('div');
element.classList.add(this.CLASS.className);
element.style.backgroundColor = 'white';
this.div = element;
this.inner = this.document.adaptor.node('div');
this.div.appendChild(this.inner);
this.document.adaptor.
body(this.document.adaptor.document).
appendChild(this.div);
};
AbstractRegion.prototype.Show = function (node, highlighter) {
this.position(node);
this.highlight(highlighter);
this.div.classList.add(this.CLASS.className + '_Show');
};
AbstractRegion.prototype.Hide = function () {
this.div.classList.remove(this.CLASS.className + '_Show');
};
AbstractRegion.prototype.stackRegions = function (node) {
var rect = node.getBoundingClientRect();
var baseBottom = 0;
var baseLeft = Number.POSITIVE_INFINITY;
var regions = this.document.adaptor.document.getElementsByClassName(this.CLASS.className + '_Show');
for (var i = 0, region = void 0; region = regions[i]; i++) {
if (region !== this.div) {
baseBottom = Math.max(region.getBoundingClientRect().bottom, baseBottom);
baseLeft = Math.min(region.getBoundingClientRect().left, baseLeft);
}
}
var bot = (baseBottom ? baseBottom : rect.bottom + 10) + window.pageYOffset;
var left = (baseLeft < Number.POSITIVE_INFINITY ? baseLeft : rect.left) + window.pageXOffset;
this.div.style.top = bot + 'px';
this.div.style.left = left + 'px';
};
AbstractRegion.styleAdded = false;
return AbstractRegion;
}());
exports.AbstractRegion = AbstractRegion;
var DummyRegion = (function (_super) {
__extends(DummyRegion, _super);
function DummyRegion() {
return _super !== null && _super.apply(this, arguments) || this;
}
DummyRegion.prototype.Clear = function () { };
DummyRegion.prototype.Update = function () { };
DummyRegion.prototype.Hide = function () { };
DummyRegion.prototype.Show = function () { };
DummyRegion.prototype.AddElement = function () { };
DummyRegion.prototype.AddStyles = function () { };
DummyRegion.prototype.position = function () { };
DummyRegion.prototype.highlight = function (_highlighter) { };
return DummyRegion;
}(AbstractRegion));
exports.DummyRegion = DummyRegion;
var StringRegion = (function (_super) {
__extends(StringRegion, _super);
function StringRegion() {
return _super !== null && _super.apply(this, arguments) || this;
}
StringRegion.prototype.Clear = function () {
this.Update('');
this.inner.style.top = '';
this.inner.style.backgroundColor = '';
};
StringRegion.prototype.Update = function (speech) {
this.inner.textContent = '';
this.inner.textContent = speech;
};
StringRegion.prototype.position = function (node) {
this.stackRegions(node);
};
StringRegion.prototype.highlight = function (highlighter) {
var color = highlighter.colorString();
this.inner.style.backgroundColor = color.background;
this.inner.style.color = color.foreground;
};
return StringRegion;
}(AbstractRegion));
exports.StringRegion = StringRegion;
var ToolTip = (function (_super) {
__extends(ToolTip, _super);
function ToolTip() {
return _super !== null && _super.apply(this, arguments) || this;
}
ToolTip.className = 'MJX_ToolTip';
ToolTip.style = new StyleList_js_1.CssStyles((_a = {},
_a['.' + ToolTip.className] = {
position: 'absolute', display: 'inline-block',
height: '1px', width: '1px'
},
_a['.' + ToolTip.className + '_Show'] = {
width: 'auto', height: 'auto', opacity: 1, 'text-align': 'center',
'border-radius': '6px', padding: '0px 0px',
'border-bottom': '1px dotted black', position: 'absolute',
'z-index': 202
},
_a));
return ToolTip;
}(StringRegion));
exports.ToolTip = ToolTip;
var LiveRegion = (function (_super) {
__extends(LiveRegion, _super);
function LiveRegion(document) {
var _this = _super.call(this, document) || this;
_this.document = document;
_this.div.setAttribute('aria-live', 'assertive');
return _this;
}
LiveRegion.className = 'MJX_LiveRegion';
LiveRegion.style = new StyleList_js_1.CssStyles((_b = {},
_b['.' + LiveRegion.className] = {
position: 'absolute', top: '0', height: '1px', width: '1px',
padding: '1px', overflow: 'hidden'
},
_b['.' + LiveRegion.className + '_Show'] = {
top: '0', position: 'absolute', width: 'auto', height: 'auto',
padding: '0px 0px', opacity: 1, 'z-index': '202',
left: 0, right: 0, 'margin': '0 auto',
'background-color': 'rgba(0, 0, 255, 0.2)', 'box-shadow': '0px 10px 20px #888',
border: '2px solid #CCCCCC'
},
_b));
return LiveRegion;
}(StringRegion));
exports.LiveRegion = LiveRegion;
var HoverRegion = (function (_super) {
__extends(HoverRegion, _super);
function HoverRegion(document) {
var _this = _super.call(this, document) || this;
_this.document = document;
_this.inner.style.lineHeight = '0';
return _this;
}
HoverRegion.prototype.position = function (node) {
var nodeRect = node.getBoundingClientRect();
var divRect = this.div.getBoundingClientRect();
var xCenter = nodeRect.left + (nodeRect.width / 2);
var left = xCenter - (divRect.width / 2);
left = (left < 0) ? 0 : left;
left = left + window.pageXOffset;
var top;
switch (this.document.options.a11y.align) {
case 'top':
top = nodeRect.top - divRect.height - 10;
break;
case 'bottom':
top = nodeRect.bottom + 10;
break;
case 'center':
default:
var yCenter = nodeRect.top + (nodeRect.height / 2);
top = yCenter - (divRect.height / 2);
}
top = top + window.pageYOffset;
top = (top < 0) ? 0 : top;
this.div.style.top = top + 'px';
this.div.style.left = left + 'px';
};
HoverRegion.prototype.highlight = function (highlighter) {
if (this.inner.firstChild &&
!this.inner.firstChild.hasAttribute('sre-highlight')) {
return;
}
var color = highlighter.colorString();
this.inner.style.backgroundColor = color.background;
this.inner.style.color = color.foreground;
};
HoverRegion.prototype.Show = function (node, highlighter) {
this.div.style.fontSize = this.document.options.a11y.magnify;
this.Update(node);
_super.prototype.Show.call(this, node, highlighter);
};
HoverRegion.prototype.Clear = function () {
this.inner.textContent = '';
this.inner.style.top = '';
this.inner.style.backgroundColor = '';
};
HoverRegion.prototype.Update = function (node) {
this.Clear();
var mjx = this.cloneNode(node);
this.inner.appendChild(mjx);
};
HoverRegion.prototype.cloneNode = function (node) {
var mjx = node.cloneNode(true);
if (mjx.nodeName !== 'MJX-CONTAINER') {
if (mjx.nodeName !== 'g') {
mjx.style.marginLeft = mjx.style.marginRight = '0';
}
var container = node;
while (container && container.nodeName !== 'MJX-CONTAINER') {
container = container.parentNode;
}
if (mjx.nodeName !== 'MJX-MATH' && mjx.nodeName !== 'svg') {
var child = container.firstChild;
mjx = child.cloneNode(false).appendChild(mjx).parentNode;
if (mjx.nodeName === 'svg') {
mjx.firstChild.setAttribute('transform', 'matrix(1 0 0 -1 0 0)');
var W = parseFloat(mjx.getAttribute('viewBox').split(/ /)[2]);
var w = parseFloat(mjx.getAttribute('width'));
var _a = node.getBBox(), x = _a.x, y = _a.y, width = _a.width, height = _a.height;
mjx.setAttribute('viewBox', [x, -(y + height), width, height].join(' '));
mjx.removeAttribute('style');
mjx.setAttribute('width', (w / W * width) + 'ex');
mjx.setAttribute('height', (w / W * height) + 'ex');
container.setAttribute('sre-highlight', 'false');
}
}
mjx = container.cloneNode(false).appendChild(mjx).parentNode;
mjx.style.margin = '0';
}
return mjx;
};
HoverRegion.className = 'MJX_HoverRegion';
HoverRegion.style = new StyleList_js_1.CssStyles((_c = {},
_c['.' + HoverRegion.className] = {
position: 'absolute', height: '1px', width: '1px',
padding: '1px', overflow: 'hidden'
},
_c['.' + HoverRegion.className + '_Show'] = {
position: 'absolute', width: 'max-content', height: 'auto',
padding: '0px 0px', opacity: 1, 'z-index': '202', 'margin': '0 auto',
'background-color': 'rgba(0, 0, 255, 0.2)',
'box-shadow': '0px 10px 20px #888', border: '2px solid #CCCCCC'
},
_c));
return HoverRegion;
}(AbstractRegion));
exports.HoverRegion = HoverRegion;
//# sourceMappingURL=Region.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,22 @@
import { A11yDocument, Region } from './Region.js';
import { Explorer, AbstractExplorer } from './Explorer.js';
export interface TreeExplorer extends Explorer {
}
export declare class AbstractTreeExplorer extends AbstractExplorer<void> {
document: A11yDocument;
protected region: Region<void>;
protected node: HTMLElement;
protected mml: HTMLElement;
protected constructor(document: A11yDocument, region: Region<void>, node: HTMLElement, mml: HTMLElement);
readonly stoppable = false;
Attach(): void;
Detach(): void;
}
export declare class FlameColorer extends AbstractTreeExplorer {
Start(): void;
Stop(): void;
}
export declare class TreeColorer extends AbstractTreeExplorer {
Start(): void;
Stop(): void;
}

View file

@ -0,0 +1,91 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TreeColorer = exports.FlameColorer = exports.AbstractTreeExplorer = void 0;
var Explorer_js_1 = require("./Explorer.js");
var sre_js_1 = __importDefault(require("../sre.js"));
var AbstractTreeExplorer = (function (_super) {
__extends(AbstractTreeExplorer, _super);
function AbstractTreeExplorer(document, region, node, mml) {
var _this = _super.call(this, document, null, node) || this;
_this.document = document;
_this.region = region;
_this.node = node;
_this.mml = mml;
_this.stoppable = false;
return _this;
}
AbstractTreeExplorer.prototype.Attach = function () {
_super.prototype.Attach.call(this);
this.Start();
};
AbstractTreeExplorer.prototype.Detach = function () {
this.Stop();
_super.prototype.Detach.call(this);
};
return AbstractTreeExplorer;
}(Explorer_js_1.AbstractExplorer));
exports.AbstractTreeExplorer = AbstractTreeExplorer;
var FlameColorer = (function (_super) {
__extends(FlameColorer, _super);
function FlameColorer() {
return _super !== null && _super.apply(this, arguments) || this;
}
FlameColorer.prototype.Start = function () {
if (this.active)
return;
this.active = true;
this.highlighter.highlightAll(this.node);
};
FlameColorer.prototype.Stop = function () {
if (this.active) {
this.highlighter.unhighlightAll();
}
this.active = false;
};
return FlameColorer;
}(AbstractTreeExplorer));
exports.FlameColorer = FlameColorer;
var TreeColorer = (function (_super) {
__extends(TreeColorer, _super);
function TreeColorer() {
return _super !== null && _super.apply(this, arguments) || this;
}
TreeColorer.prototype.Start = function () {
if (this.active)
return;
this.active = true;
var generator = sre_js_1.default.getSpeechGenerator('Color');
if (!this.node.hasAttribute('hasforegroundcolor')) {
generator.generateSpeech(this.node, this.mml);
this.node.setAttribute('hasforegroundcolor', 'true');
}
this.highlighter.colorizeAll(this.node);
};
TreeColorer.prototype.Stop = function () {
if (this.active) {
this.highlighter.uncolorizeAll(this.node);
}
this.active = false;
};
return TreeColorer;
}(AbstractTreeExplorer));
exports.TreeColorer = TreeColorer;
//# sourceMappingURL=TreeExplorer.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"TreeExplorer.js","sourceRoot":"","sources":["../../../ts/a11y/explorer/TreeExplorer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AA2BA,6CAAyD;AACzD,qDAA4B;AAO5B;IAA0C,wCAAsB;IAK9D,8BAA6B,QAAsB,EACnB,MAAoB,EACpB,IAAiB,EACjB,GAAgB;QAHhD,YAIE,kBAAM,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,SAC5B;QAL4B,cAAQ,GAAR,QAAQ,CAAc;QACnB,YAAM,GAAN,MAAM,CAAc;QACpB,UAAI,GAAJ,IAAI,CAAa;QACjB,SAAG,GAAH,GAAG,CAAa;QAOhC,eAAS,GAAG,KAAK,CAAC;;IALlC,CAAC;IAWM,qCAAM,GAAb;QACE,iBAAM,MAAM,WAAE,CAAC;QACf,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAKM,qCAAM,GAAb;QACE,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,iBAAM,MAAM,WAAE,CAAC;IACjB,CAAC;IAEH,2BAAC;AAAD,CAAC,AAlCD,CAA0C,8BAAgB,GAkCzD;AAlCY,oDAAoB;AAqCjC;IAAkC,gCAAoB;IAAtD;;IAqBA,CAAC;IAhBQ,4BAAK,GAAZ;QACE,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAKM,2BAAI,GAAX;QACE,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC;SACnC;QACD,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