{"version":3,"file":"UdpAiAppSurface.mjs","names":["React","ReactNode","useMemo","ConfigService","isDevelopment","UdpAiProvider","UdpAiConfig","UdpAiAppSurface","t0","$","_c","children","baseUrl","config","UDP_AI_GATEWAY_BASE","productId","UNITY_PRODUCT_ID","t1","Symbol","for","gateway","headers","String","console","warn","t2"],"sources":["../../src/providers/UdpAiAppSurface.tsx"],"sourcesContent":["import React, { ReactNode, useMemo } from 'react';\nimport { ConfigService } from '../configService';\nimport { isDevelopment } from '../utilities/env';\nimport { UdpAiProvider, UdpAiConfig } from '../aiAssistant/provider/UdpAiProvider';\n\n/**\n * Mounts the app-level AI context for UdpAppProvider's `ai` opt-in: the gateway\n * connection from ConfigService (URL from UDP_AI_GATEWAY_BASE, product header\n * from UNITY_PRODUCT_ID — environment config stays in the app's runtime config).\n * Whether AI actually renders is then the gateway's call — UdpAiProvider asks it\n * once per tenant and every AI surface reads the answer through `useAiAccess()`.\n *\n * It renders no assistant of its own. A page builds an `AiCapability` and\n * mounts `UdpAiAssistant` for it wherever the chat belongs.\n *\n * With no gateway URL configured this renders children untouched, so an app\n * that opts in before its environment is ready degrades to no assistant rather\n * than a broken one.\n */\nexport const UdpAiAppSurface = ({ children }: { children?: ReactNode }) => {\n  const baseUrl = ConfigService.config?.UDP_AI_GATEWAY_BASE;\n  const productId = ConfigService.config?.UNITY_PRODUCT_ID;\n\n  const config = useMemo<UdpAiConfig | null>(\n    () =>\n      baseUrl\n        ? {\n            gateway: {\n              baseUrl,\n              headers: { 'udp-product-id': String(productId ?? '') }\n            }\n          }\n        : null,\n    [baseUrl, productId]\n  );\n\n  if (!config) {\n    if (isDevelopment()) {\n      console.warn(\n        '[udp] UdpAppProvider: `ai` is set but ConfigService.UDP_AI_GATEWAY_BASE is empty — AI surfaces will not render. Set it in the app runtime config.'\n      );\n    }\n    return <>{children}</>;\n  }\n\n  return <UdpAiProvider config={config}>{children}</UdpAiProvider>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,MAAaO,mBAAkBC,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAC,MAAA,EAAAC,aAAAH;CAC9B,MAAAI,UAAgBT,cAAaU,QAA4BC;CACzD,MAAAC,YAAkBZ,cAAaU,QAAyBG;CAAC,IAAAC;AAAA,KAAAR,EAAA,OAAAS,OAAAC,IAAA,4BAAA,EAAA;AAIrDF,OAAAL,UAAA,EAAAQ,SAEe;GAAAR;GAAAS,SAEE,EAAA,kBAAoBC,OAAOP,aAAA,GAAe,EAAE;GACvD,EAEE,GAPR;AAOQN,IAAA,KAAAQ;OAAAA,MAAAR,EAAA;CATZ,MAAAI,SAEII;AAWJ,KAAI,CAACJ,QAAM;AACT,MAAIT,eAAe,CACjBmB,SAAOC,KACL,oJACD;EACF,IAAAC;AAAA,MAAAhB,EAAA,OAAAE,UAAA;AACMc,QAAA,sBAAA,cAAA,MAAA,UAAA,MAAGd,SAAY;AAAAF,KAAA,KAAAE;AAAAF,KAAA,KAAAgB;QAAAA,MAAAhB,EAAA;AAAA,SAAfgB;;CACR,IAAAA;AAAA,KAAAhB,EAAA,OAAAE,UAAA;AAEMc,OAAA,sBAAA,cAAC,eAAD,EAAuBZ,QAAkC,EAAzBF,SAAyB;AAAAF,IAAA,KAAAE;AAAAF,IAAA,KAAAgB;OAAAA,MAAAhB,EAAA;AAAA,QAAzDgB"}