"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ANDROID_ELEMENT_RESPONSE_ATTRIBUTES = void 0;
exports.isAndroidElementReference = isAndroidElementReference;
const Candidate_1 = __importStar(require("../Candidate"));
class AndroidReferenceElementClass {
    enabled = undefined;
    selected = undefined;
    text = undefined;
    rect = undefined;
    displayed = undefined;
    'attribute/checkable' = undefined;
    'attribute/checked' = undefined;
    'attribute/class' = undefined;
    'attribute/clickable' = undefined;
    'attribute/content-desc' = undefined;
    'attribute/focusable' = undefined;
    'attribute/focused' = undefined;
    'attribute/long-clickable' = undefined;
    'attribute/package' = undefined;
    'attribute/password' = undefined;
    'attribute/resource-id' = undefined;
    'attribute/scrollable' = undefined;
    'attribute/hint' = undefined;
    'attribute/bounds' = undefined;
}
exports.ANDROID_ELEMENT_RESPONSE_ATTRIBUTES = Object.keys(new AndroidReferenceElementClass());
class AndroidCandidate extends Candidate_1.default {
    static fromElementReference(elementReference) {
        const selector = elementReferenceToSelector(elementReference);
        return new AndroidCandidate(elementReference, selector);
    }
}
exports.default = AndroidCandidate;
function isAndroidElementReference(element) {
    return element['attribute/class'] !== undefined;
}
function elementReferenceToSelector(elementReference) {
    const androidElementReference = elementReference;
    return {
        checkable: (0, Candidate_1.parseBoolean)(androidElementReference['attribute/checkable']),
        checked: (0, Candidate_1.parseBoolean)(androidElementReference['attribute/checked']),
        class: androidElementReference['attribute/class'],
        clickable: (0, Candidate_1.parseBoolean)(androidElementReference['attribute/clickable']),
        contentDesc: androidElementReference['attribute/content-desc'],
        enabled: (0, Candidate_1.parseBoolean)(androidElementReference.enabled),
        focusable: (0, Candidate_1.parseBoolean)(androidElementReference['attribute/focusable']),
        focused: (0, Candidate_1.parseBoolean)(androidElementReference['attribute/focused']),
        longClickable: (0, Candidate_1.parseBoolean)(androidElementReference['attribute/long-clickable']),
        package: androidElementReference['attribute/package'],
        password: (0, Candidate_1.parseBoolean)(androidElementReference['attribute/password']),
        resourceId: androidElementReference['attribute/resource-id'] ?? undefined,
        scrollable: (0, Candidate_1.parseBoolean)(androidElementReference['attribute/scrollable']),
        selected: (0, Candidate_1.parseBoolean)(androidElementReference.selected),
        text: androidElementReference.text,
        hint: androidElementReference['attribute/hint'] ?? undefined,
        bounds: androidElementReference['attribute/bounds'],
        displayed: (0, Candidate_1.parseBoolean)(androidElementReference.displayed),
        rect: androidElementReference.rect,
    };
}
