{"version":3,"file":"media.cjs","names":["hostApiPath","sessionApiPath"],"sources":["../../src/types/media.ts"],"sourcesContent":["import { hostApiPath, sessionApiPath } from '@agimon-ai/po-core/web';\n/**\n * How the cockpit previews a file a message mentions: the hub serves it from\n * the session's working directory and the timeline picks the element by\n * kind. Anything not listed here is offered as a plain file link.\n */\nexport type MediaKind = 'image' | 'video' | 'pdf';\n\nexport interface MediaType {\n  kind: MediaKind;\n  contentType: string;\n}\n\n/** Keyed by lower-case extension without the dot. */\nexport const MEDIA_TYPES: Readonly<Record<string, MediaType>> = {\n  avif: { kind: 'image', contentType: 'image/avif' },\n  bmp: { kind: 'image', contentType: 'image/bmp' },\n  gif: { kind: 'image', contentType: 'image/gif' },\n  jpeg: { kind: 'image', contentType: 'image/jpeg' },\n  jpg: { kind: 'image', contentType: 'image/jpeg' },\n  png: { kind: 'image', contentType: 'image/png' },\n  svg: { kind: 'image', contentType: 'image/svg+xml' },\n  webp: { kind: 'image', contentType: 'image/webp' },\n  m4v: { kind: 'video', contentType: 'video/mp4' },\n  mov: { kind: 'video', contentType: 'video/quicktime' },\n  mp4: { kind: 'video', contentType: 'video/mp4' },\n  webm: { kind: 'video', contentType: 'video/webm' },\n  pdf: { kind: 'pdf', contentType: 'application/pdf' },\n};\n\n/** The hub refuses to serve a mentioned file past this size. */\nexport const MAX_SESSION_FILE_BYTES = 25 * 1024 * 1024;\n\n/** Session file bytes; paths may be cwd-relative or absolute inside the working directory. */\nexport const SESSION_FILE_ROUTE = '/api/workspaces/:workspaceId/sessions/:sessionId/file';\nexport const SESSION_FILE_SHA256_HEADER = 'X-File-SHA256';\nexport const SESSION_FILE_EXPECTED_SHA256_HEADER = 'X-Expected-SHA256';\n\n/**\n * Explicit artifact references stay on the artifact owner's guarded, session-scoped content route.\n * `space:<id>/<path>` is a po-space file, read from the host. The older `artifact:host/<path>`\n * named the host shelf, which is the Personal space now.\n */\nexport function sessionFileUrl(sessionId: string, relativePath: string): string {\n  const named = /^@?space:([a-z][a-z0-9-]{0,39})\\/(.+)$/su.exec(relativePath);\n  const shelf = /^@?artifact:host\\/(.+)$/su.exec(relativePath)?.[1];\n  if (named || shelf !== undefined) {\n    const query = `space=${named?.[1] ?? 'personal'}&path=${encodeURIComponent(named?.[2] ?? shelf ?? '')}`;\n    return `${hostApiPath()}/plugins/space/content?${query}`;\n  }\n  const artifact = /^@?artifact:(.*)$/su.exec(relativePath)?.[1];\n  const route = artifact === undefined ? 'file' : 'plugins/artifacts/content';\n  return `${sessionApiPath(sessionId)}/${route}?path=${encodeURIComponent(artifact ?? relativePath)}`;\n}\n"],"mappings":";;;AAcA,MAAa,cAAmD;CAC9D,MAAM;EAAE,MAAM;EAAS,aAAa;CAAa;CACjD,KAAK;EAAE,MAAM;EAAS,aAAa;CAAY;CAC/C,KAAK;EAAE,MAAM;EAAS,aAAa;CAAY;CAC/C,MAAM;EAAE,MAAM;EAAS,aAAa;CAAa;CACjD,KAAK;EAAE,MAAM;EAAS,aAAa;CAAa;CAChD,KAAK;EAAE,MAAM;EAAS,aAAa;CAAY;CAC/C,KAAK;EAAE,MAAM;EAAS,aAAa;CAAgB;CACnD,MAAM;EAAE,MAAM;EAAS,aAAa;CAAa;CACjD,KAAK;EAAE,MAAM;EAAS,aAAa;CAAY;CAC/C,KAAK;EAAE,MAAM;EAAS,aAAa;CAAkB;CACrD,KAAK;EAAE,MAAM;EAAS,aAAa;CAAY;CAC/C,MAAM;EAAE,MAAM;EAAS,aAAa;CAAa;CACjD,KAAK;EAAE,MAAM;EAAO,aAAa;CAAkB;AACrD;;AAGA,MAAa,yBAAyB;;AAGtC,MAAa,qBAAqB;AAClC,MAAa,6BAA6B;AAC1C,MAAa,sCAAsC;;;;;;AAOnD,SAAgB,eAAe,WAAmB,cAA8B;CAC9E,MAAM,QAAQ,2CAA2C,KAAK,YAAY;CAC1E,MAAM,QAAQ,4BAA4B,KAAK,YAAY,CAAC,GAAG;CAC/D,IAAI,SAAS,UAAU,KAAA,GAAW;EAChC,MAAM,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