{"version":3,"sources":["../../../src/modelgarden/v2/utils.ts"],"sourcesContent":["/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { GenkitError } from 'genkit';\n\n/**\n * Gets the model name without certain prefixes..\n * e.g. for \"models/googleai/gemini-2.5-pro\" it returns just 'gemini-2.5-pro'\n * @param name A string containing the model string with possible prefixes\n * @returns the model string stripped of certain prefixes\n */\nexport function modelName(name?: string): string | undefined {\n  if (!name) return name;\n\n  // Remove any of these prefixes:\n  const prefixesToRemove =\n    /background-model\\/|model\\/|models\\/|embedders\\/|vertex-model-garden\\/|vertexai\\//g;\n  return name.replace(prefixesToRemove, '');\n}\n\n/**\n * Gets the suffix of a model string.\n * Throws if the string is empty.\n * @param name A string containing the model string\n * @returns the model string stripped of prefixes and guaranteed not empty.\n */\nexport function checkModelName(name?: string): string {\n  const version = modelName(name);\n  if (!version) {\n    throw new GenkitError({\n      status: 'INVALID_ARGUMENT',\n      message: 'Model name is required.',\n    });\n  }\n  return version;\n}\n"],"mappings":"AAgBA,SAAS,mBAAmB;AAQrB,SAAS,UAAU,MAAmC;AAC3D,MAAI,CAAC,KAAM,QAAO;AAGlB,QAAM,mBACJ;AACF,SAAO,KAAK,QAAQ,kBAAkB,EAAE;AAC1C;AAQO,SAAS,eAAe,MAAuB;AACpD,QAAM,UAAU,UAAU,IAAI;AAC9B,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,YAAY;AAAA,MACpB,QAAQ;AAAA,MACR,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACA,SAAO;AACT;","names":[]}