import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
function findByUid(schema, uid) {
    if (!__WEBPACK_EXTERNAL_MODULE__tachybase_schema__.Schema.isSchemaInstance(schema)) schema = new __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.Schema(schema);
    return schema.reduceProperties((buffter, s)=>{
        if (s['x-uid'] === uid) return s;
        const ss = findByUid(s, uid);
        if (ss) return ss;
        return buffter;
    }, null);
}
function findMenuItem(schema) {
    if (!__WEBPACK_EXTERNAL_MODULE__tachybase_schema__.Schema.isSchemaInstance(schema)) schema = new __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.Schema(schema);
    for (const { schema: s } of __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.Schema.getOrderProperties(schema)){
        if ('Menu.Item' === s['x-component']) return s;
        const ss = findMenuItem(s);
        if (ss) return ss;
    }
    return null;
}
function findKeys(schema) {
    if (!schema) return;
    const keys = [];
    keys.push(schema.name);
    while(schema.parent){
        if ('Menu' === schema.parent['x-component']) break;
        keys.push(schema.parent.name);
        schema = schema.parent;
    }
    return keys.reverse();
}
function findKeysByUid(schema, uid) {
    return findKeys(findByUid(schema, uid));
}
export { findByUid, findKeysByUid, findMenuItem };
