{"version":3,"file":"index.cjs","names":["n"],"sources":["../../../twenty-shared/dist/application-runtime.mjs","../../src/sdk/utils/get-application-access-token.ts","../../src/sdk/utils/get-public-asset-url.ts","../../../twenty-shared/dist/isDefined-Dtu5EYqP.mjs"],"sourcesContent":["//#region src/application-runtime/constants/ConnectionScopeByLegacyVisibility.ts\nvar e = {\n\tuser: \"USER\",\n\tworkspace: \"WORKSPACE\"\n}, t = \"TWENTY_API_KEY\", n = \"TWENTY_API_URL\", r = \"TWENTY_APP_ACCESS_TOKEN\", i = \"TWENTY_APP_APPLICATION_ACCESS_TOKEN\", a = \"TWENTY_FUNCTIONS_URL\", o = {\n\tUSER: \"user\",\n\tWORKSPACE: \"workspace\"\n}, s = [\n\t\"workspace-suspended\",\n\t\"no-subscription\",\n\t\"no-credits\"\n];\n//#endregion\nexport { e as CONNECTION_SCOPE_BY_LEGACY_VISIBILITY, s as CREDIT_UNAVAILABLE_REASONS, t as DEFAULT_API_KEY_NAME, n as DEFAULT_API_URL_NAME, r as DEFAULT_APP_ACCESS_TOKEN_NAME, i as DEFAULT_APP_APPLICATION_ACCESS_TOKEN_NAME, a as DEFAULT_FUNCTIONS_URL_NAME, o as LEGACY_CONNECTION_VISIBILITY_BY_SCOPE };\n","import {\n  DEFAULT_APP_ACCESS_TOKEN_NAME,\n  DEFAULT_APP_APPLICATION_ACCESS_TOKEN_NAME,\n} from 'twenty-shared/application-runtime';\n\n// These reach the application's own resources, so prefer the application token when the runtime injects one\nexport const getApplicationAccessToken = (): string | undefined =>\n  process.env[DEFAULT_APP_APPLICATION_ACCESS_TOKEN_NAME] ??\n  process.env[DEFAULT_APP_ACCESS_TOKEN_NAME];\n","import { DEFAULT_API_URL_NAME } from 'twenty-shared/application-runtime';\n\nimport { getApplicationAccessToken } from '@/sdk/utils/get-application-access-token';\n\nconst decodeTokenPayload = (\n  token: string,\n): { workspaceId: string; applicationId: string } => {\n  const payload = JSON.parse(atob(token.split('.')[1]));\n\n  return {\n    workspaceId: payload.workspaceId,\n    applicationId: payload.applicationId,\n  };\n};\n\n// Path is relative to the app's public/ folder (e.g. \"images/logo.png\")\nexport const getPublicAssetUrl = (path: string): string => {\n  const apiUrl = process.env[DEFAULT_API_URL_NAME];\n  const token = getApplicationAccessToken();\n\n  if (!apiUrl || !token) {\n    throw new Error(\n      'getPublicAssetUrl can only be called from within a logic function or front component',\n    );\n  }\n\n  const { workspaceId, applicationId } = decodeTokenPayload(token);\n  const withoutLeadingSlash = path.startsWith('/') ? path.slice(1) : path;\n  const withPublicPrefix = withoutLeadingSlash.startsWith('public/')\n    ? withoutLeadingSlash\n    : `public/${withoutLeadingSlash}`;\n\n  const encodedPath = withPublicPrefix\n    .split('/')\n    .map(encodeURIComponent)\n    .join('/');\n\n  return `${apiUrl}/public-assets/${workspaceId}/${applicationId}/${encodedPath}`;\n};\n","import { isNull as e, isUndefined as t } from \"@sniptt/guards\";\n//#region src/utils/validation/isDefined.ts\nvar n = (n) => !t(n) && !e(n);\n//#endregion\nexport { n as t };\n"],"mappings":"uGAIyBA,EAAI,iBCEhB,MACX,QAAQ,IAAA,qCACR,QAAQ,IAAA,wBCJJ,EACJ,GACmD,CACnD,IAAM,EAAU,KAAK,MAAM,KAAK,EAAM,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,EAEpD,MAAO,CACL,YAAa,EAAQ,YACrB,cAAe,EAAQ,aACzB,CACF,EAGa,EAAqB,GAAyB,CACzD,IAAM,EAAS,QAAQ,IAAI,GACrB,EAAQ,EAA0B,EAExC,GAAI,CAAC,GAAU,CAAC,EACd,MAAU,MACR,sFACF,EAGF,GAAM,CAAE,cAAa,iBAAkB,EAAmB,CAAK,EACzD,EAAsB,EAAK,WAAW,GAAG,EAAI,EAAK,MAAM,CAAC,EAAI,EAUnE,MAAO,GAAG,EAAO,iBAAiB,EAAY,GAAG,EAAc,IATtC,EAAoB,WAAW,SAAS,EAC7D,EACA,UAAU,IAAA,CAGX,MAAM,GAAG,CAAC,CACV,IAAI,kBAAkB,CAAC,CACvB,KAAK,GAE0D,GACpE,ECpCI,EAAK,GAAM,EAAA,EAAA,EAAA,YAAA,CAAG,CAAC,GAAK,EAAA,EAAA,EAAA,OAAA,CAAG,CAAC"}