{"version":3,"file":"content_objid-8ebeead4.mjs","sources":["../src/content_objid.ts"],"sourcesContent":["import { SystemDialogError, type LocalFile, type ZoneContent } from './content'\nimport { ensureUploaded, importFiles, releaseImportSession, type StartUploadOptions } from './ndm_client'\n\nexport interface EnsureObjIdOptions extends Pick<StartUploadOptions, 'endpoint' | 'sessionToken' | 'fetcher' | 'headers' | 'signal'> {}\n\n/**\n * The object ID of an item the system file picker returned: the one it already carries, or one computed and\n * registered in the Zone. A file from this device goes through `ndm.importFiles` + `ndm.ensureUploaded`; call\n * `release()` once your own data references the object. A Zone item without an ID needs the server-side `snapshot`\n * of nfs_server, which this Zone does not offer yet: that case rejects with `SystemDialogError('unsupported')`.\n */\nexport async function ensureObjId(item: ZoneContent | LocalFile, options: EnsureObjIdOptions = {}): Promise<{ objId: string; release(): void }> {\n  if (item.origin === 'zone') {\n    if (item.objId) return { objId: item.objId, release() {} }\n    throw new SystemDialogError('unsupported', 'This Zone cannot compute the object ID of a Zone file yet')\n  }\n  const snapshot = await importFiles([item.file], { mode: 'single_file', ...options })\n  let released = false\n  const release = () => { if (!released) { released = true; releaseImportSession(snapshot.sessionId) } }\n  try { await ensureUploaded(snapshot.sessionId, options) }\n  catch (error) { release(); throw error }\n  return { objId: snapshot.selection.objectId, release }\n}\n"],"names":[],"mappings":";;AAWA,eAAsB,YAAY,MAA+B,UAA8B,IAAiD;AAC1I,MAAA,KAAK,WAAW,QAAQ;AAC1B,QAAI,KAAK;AAAO,aAAO,EAAE,OAAO,KAAK,OAAO,UAAU;AAAA,MAAA;AAChD,UAAA,IAAI,kBAAkB,eAAe,2DAA2D;AAAA,EACxG;AACA,QAAM,WAAW,MAAM,YAAY,CAAC,KAAK,IAAI,GAAG,EAAE,MAAM,eAAe,GAAG,QAAS,CAAA;AACnF,MAAI,WAAW;AACf,QAAM,UAAU,MAAM;AAAE,QAAI,CAAC,UAAU;AAAa,iBAAA;AAAM,2BAAqB,SAAS,SAAS;AAAA,IAAE;AAAA,EAAA;AAC/F,MAAA;AAAQ,UAAA,eAAe,SAAS,WAAW,OAAO;AAAA,WAC/C,OAAO;AAAU;AAAS,UAAA;AAAA,EAAM;AACvC,SAAO,EAAE,OAAO,SAAS,UAAU,UAAU,QAAQ;AACvD;"}