{"version":3,"file":"i18n.mjs","sources":["../../../../../../src/services/document-service/transform/relations/utils/i18n.ts"],"sourcesContent":["import type { UID } from '@strapi/types';\nimport { LongHandDocument } from './types';\n\nexport const isLocalizedContentType = (uid: UID.Schema) => {\n  const model = strapi.getModel(uid);\n  return strapi.plugin('i18n').service('content-types').isLocalizedContentType(model);\n};\n\nexport const getDefaultLocale = () => {\n  return strapi.plugin('i18n').service('locales').getDefaultLocale();\n};\n\nexport const getRelationTargetLocale = (\n  relation: LongHandDocument,\n  opts: {\n    targetUid: UID.Schema;\n    sourceUid: UID.Schema;\n    sourceLocale?: string | null;\n  }\n) => {\n  const targetLocale = relation.locale || opts.sourceLocale;\n\n  const isTargetLocalized = isLocalizedContentType(opts.targetUid);\n  const isSourceLocalized = isLocalizedContentType(opts.sourceUid);\n\n  // Both source and target locales should match\n  if (isSourceLocalized && isTargetLocalized) {\n    return opts.sourceLocale;\n  }\n\n  if (isTargetLocalized) {\n    return targetLocale;\n  }\n\n  return null;\n};\n"],"names":["isLocalizedContentType","uid","model","strapi","getModel","plugin","service","getDefaultLocale","getRelationTargetLocale","relation","opts","targetLocale","locale","sourceLocale","isTargetLocalized","targetUid","isSourceLocalized","sourceUid"],"mappings":"AAGO,MAAMA,yBAAyB,CAACC,GAAAA,GAAAA;IACrC,MAAMC,KAAAA,GAAQC,MAAAA,CAAOC,QAAQ,CAACH,GAAAA,CAAAA;IAC9B,OAAOE,MAAAA,CAAOE,MAAM,CAAC,MAAA,CAAA,CAAQC,OAAO,CAAC,eAAA,CAAA,CAAiBN,sBAAsB,CAACE,KAAAA,CAAAA;AAC/E;MAEaK,gBAAAA,GAAmB,IAAA;AAC9B,IAAA,OAAOJ,OAAOE,MAAM,CAAC,QAAQC,OAAO,CAAC,WAAWC,gBAAgB,EAAA;AAClE;AAEO,MAAMC,uBAAAA,GAA0B,CACrCC,QAAAA,EACAC,IAAAA,GAAAA;AAMA,IAAA,MAAMC,YAAAA,GAAeF,QAAAA,CAASG,MAAM,IAAIF,KAAKG,YAAY;IAEzD,MAAMC,iBAAAA,GAAoBd,sBAAAA,CAAuBU,IAAAA,CAAKK,SAAS,CAAA;IAC/D,MAAMC,iBAAAA,GAAoBhB,sBAAAA,CAAuBU,IAAAA,CAAKO,SAAS,CAAA;;AAG/D,IAAA,IAAID,qBAAqBF,iBAAAA,EAAmB;AAC1C,QAAA,OAAOJ,KAAKG,YAAY;AAC1B,IAAA;AAEA,IAAA,IAAIC,iBAAAA,EAAmB;QACrB,OAAOH,YAAAA;AACT,IAAA;IAEA,OAAO,IAAA;AACT;;;;"}