{"version":3,"file":"conditional-fields.mjs","sources":["../../../src/services/utils/conditional-fields.ts"],"sourcesContent":["import { map, values, sumBy, pipe, flatMap } from 'lodash/fp';\nimport type { Schema, UID } from '@strapi/types';\n\nconst getNumberOfConditionalFields = () => {\n  const contentTypes: Record<UID.ContentType, Schema.ContentType> = strapi.contentTypes;\n  const components: Record<UID.Component, Schema.Component> = strapi.components;\n\n  const countConditionalFieldsInSchema = (\n    schema: Record<string, Schema.ContentType | Schema.Component>\n  ) => {\n    return pipe(\n      map('attributes'),\n      flatMap(values),\n      sumBy((attribute: Schema.Attribute.AnyAttribute) => {\n        if (attribute.conditions && typeof attribute.conditions === 'object') {\n          return 1;\n        }\n        return 0;\n      })\n    )(schema);\n  };\n\n  const contentTypeCount = countConditionalFieldsInSchema(contentTypes);\n  const componentCount = countConditionalFieldsInSchema(components);\n\n  return contentTypeCount + componentCount;\n};\n\nexport default getNumberOfConditionalFields;\n"],"names":["getNumberOfConditionalFields","contentTypes","strapi","components","countConditionalFieldsInSchema","schema","pipe","map","flatMap","values","sumBy","attribute","conditions","contentTypeCount","componentCount"],"mappings":";;AAGA,MAAMA,4BAAAA,GAA+B,IAAA;IACnC,MAAMC,YAAAA,GAA4DC,OAAOD,YAAY;IACrF,MAAME,UAAAA,GAAsDD,OAAOC,UAAU;AAE7E,IAAA,MAAMC,iCAAiC,CACrCC,MAAAA,GAAAA;AAEA,QAAA,OAAOC,KACLC,GAAAA,CAAI,YAAA,CAAA,EACJC,OAAAA,CAAQC,MAAAA,CAAAA,EACRC,MAAM,CAACC,SAAAA,GAAAA;AACL,YAAA,IAAIA,UAAUC,UAAU,IAAI,OAAOD,SAAAA,CAAUC,UAAU,KAAK,QAAA,EAAU;gBACpE,OAAO,CAAA;AACT,YAAA;YACA,OAAO,CAAA;QACT,CAAA,CAAA,CAAA,CACAP,MAAAA,CAAAA;AACJ,IAAA,CAAA;AAEA,IAAA,MAAMQ,mBAAmBT,8BAAAA,CAA+BH,YAAAA,CAAAA;AACxD,IAAA,MAAMa,iBAAiBV,8BAAAA,CAA+BD,UAAAA,CAAAA;AAEtD,IAAA,OAAOU,gBAAAA,GAAmBC,cAAAA;AAC5B;;;;"}