export default async (templates) => {
  var _a, _b, _c, _d, _e, _f, _g, _h;
  for (const template of templates) {
    if ((_a = template === null || template === void 0 ? void 0 : template.frame) === null || _a === void 0 ? void 0 : _a.id) {
      template.frame = templates.find((tmp) => { var _a; return (tmp === null || tmp === void 0 ? void 0 : tmp.id) === ((_a = template === null || template === void 0 ? void 0 : template.frame) === null || _a === void 0 ? void 0 : _a.id); });
      if ((_c = (_b = template === null || template === void 0 ? void 0 : template.frame) === null || _b === void 0 ? void 0 : _b.header) === null || _c === void 0 ? void 0 : _c.id) {
        template.frame.header = templates.find((tmp) => { var _a, _b; return (tmp === null || tmp === void 0 ? void 0 : tmp.id) === ((_b = (_a = template === null || template === void 0 ? void 0 : template.frame) === null || _a === void 0 ? void 0 : _a.header) === null || _b === void 0 ? void 0 : _b.id); });
      }
      if ((_e = (_d = template === null || template === void 0 ? void 0 : template.frame) === null || _d === void 0 ? void 0 : _d.footer) === null || _e === void 0 ? void 0 : _e.id) {
        template.frame.footer = templates.find((tmp) => { var _a, _b; return (tmp === null || tmp === void 0 ? void 0 : tmp.id) === ((_b = (_a = template === null || template === void 0 ? void 0 : template.frame) === null || _a === void 0 ? void 0 : _a.footer) === null || _b === void 0 ? void 0 : _b.id); });
      }
      if ((_f = template === null || template === void 0 ? void 0 : template.footer) === null || _f === void 0 ? void 0 : _f.id) {
        template.footer = templates.find((tmp) => { var _a; return (tmp === null || tmp === void 0 ? void 0 : tmp.id) === ((_a = template === null || template === void 0 ? void 0 : template.footer) === null || _a === void 0 ? void 0 : _a.id); });
      }
    }
    if ((_g = template === null || template === void 0 ? void 0 : template.header) === null || _g === void 0 ? void 0 : _g.id) {
      template.header = templates.find((tmp) => { var _a; return (tmp === null || tmp === void 0 ? void 0 : tmp.id) === ((_a = template === null || template === void 0 ? void 0 : template.header) === null || _a === void 0 ? void 0 : _a.id); });
    }
    if ((_h = template === null || template === void 0 ? void 0 : template.footer) === null || _h === void 0 ? void 0 : _h.id) {
      template.footer = templates.find((tmp) => { var _a; return (tmp === null || tmp === void 0 ? void 0 : tmp.id) === ((_a = template === null || template === void 0 ? void 0 : template.footer) === null || _a === void 0 ? void 0 : _a.id); });
    }
  }
  return templates;
};
//# sourceMappingURL=linkTemplatesToPartials.js.map