{"version":3,"sources":["../../src/services/ClientFileService.ts"],"sourcesContent":["import { CoolhandClientFilePayload, CoolhandClientFileResponse } from '../types';\nimport { BaseService, BaseServiceConfig } from './BaseService.js';\n\nexport interface ClientFileServiceConfig extends BaseServiceConfig {}\n\nexport class ClientFileService extends BaseService {\n  constructor(config: ClientFileServiceConfig) {\n    super(config, '/api/v2/client_files');\n  }\n\n  public async createClientFile(payload: CoolhandClientFilePayload): Promise<CoolhandClientFileResponse | null> {\n    const formData = new FormData();\n    formData.append('client_file[name]', payload.name);\n    if (payload.file_type) {\n      formData.append('client_file[file_type]', payload.file_type);\n    }\n    if (payload.description) {\n      formData.append('client_file[description]', payload.description);\n    }\n    const filePart = payload.file instanceof Blob ? payload.file : new Blob([new Uint8Array(payload.file)]);\n    formData.append('client_file[file]', filePart, payload.filename);\n    if (payload.metadata) {\n      for (const [key, value] of Object.entries(payload.metadata)) {\n        // A bare String(value) mangles non-primitives (arrays comma-join, objects become\n        // \"[object Object]\") since multipart fields are always strings — JSON.stringify keeps\n        // them round-trippable instead of silently losing structure.\n        const stringValue = typeof value === 'string' ? value : JSON.stringify(value);\n        formData.append(`client_file[metadata][${key}]`, stringValue);\n      }\n    }\n\n    const result = await this.sendMultipart<CoolhandClientFileResponse>(\n      formData,\n      `✅ Successfully uploaded client file: ${payload.name}`\n    );\n\n    this.logSeparator();\n\n    return result;\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAA+C;AAIxC,MAAM,0BAA0B,+BAAY;AAAA,EACjD,YAAY,QAAiC;AAC3C,UAAM,QAAQ,sBAAsB;AAAA,EACtC;AAAA,EAEA,MAAa,iBAAiB,SAAgF;AAC5G,UAAM,WAAW,IAAI,SAAS;AAC9B,aAAS,OAAO,qBAAqB,QAAQ,IAAI;AACjD,QAAI,QAAQ,WAAW;AACrB,eAAS,OAAO,0BAA0B,QAAQ,SAAS;AAAA,IAC7D;AACA,QAAI,QAAQ,aAAa;AACvB,eAAS,OAAO,4BAA4B,QAAQ,WAAW;AAAA,IACjE;AACA,UAAM,WAAW,QAAQ,gBAAgB,OAAO,QAAQ,OAAO,IAAI,KAAK,CAAC,IAAI,WAAW,QAAQ,IAAI,CAAC,CAAC;AACtG,aAAS,OAAO,qBAAqB,UAAU,QAAQ,QAAQ;AAC/D,QAAI,QAAQ,UAAU;AACpB,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,QAAQ,QAAQ,GAAG;AAI3D,cAAM,cAAc,OAAO,UAAU,WAAW,QAAQ,KAAK,UAAU,KAAK;AAC5E,iBAAS,OAAO,yBAAyB,GAAG,KAAK,WAAW;AAAA,MAC9D;AAAA,IACF;AAEA,UAAM,SAAS,MAAM,KAAK;AAAA,MACxB;AAAA,MACA,6CAAwC,QAAQ,IAAI;AAAA,IACtD;AAEA,SAAK,aAAa;AAElB,WAAO;AAAA,EACT;AACF;","names":[]}