@translated/lara 1.11.1 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,6 +14,7 @@ All major translation features are accessible, making it easy to integrate and c
14
14
  - **Audio Translation**: Translate audio files with status monitoring
15
15
  - **Translation Memory**: Store and reuse translations for consistency
16
16
  - **Glossaries**: Enforce terminology standards across translations
17
+ - **Styleguides**: Define tone, voice, and writing style rules for translations
17
18
  - **Language Detection**: Automatic source language identification
18
19
  - **Advanced Options**: Translation instructions and more
19
20
 
@@ -133,7 +134,7 @@ node memories_management.js
133
134
  - **[glossaries_management.js](examples/glossaries_management.js)** - Glossary management examples
134
135
  - Create, list, update, delete glossaries
135
136
  - CSV import with status monitoring
136
- - Glossary export
137
+ - Glossary export (sync and async)
137
138
  - Glossary terms count
138
139
  - Import status checking
139
140
 
@@ -142,6 +143,17 @@ cd examples
142
143
  node glossaries_management.js
143
144
  ```
144
145
 
146
+ ### Styleguide Management
147
+ - **[styleguide_management.js](examples/styleguide_management.js)** - Styleguide management examples
148
+ - Create, list, get, update, delete styleguides
149
+ - Update name, content, or both at once
150
+ - Handling of non-existent styleguides
151
+
152
+ ```bash
153
+ cd examples
154
+ node styleguide_management.js
155
+ ```
156
+
145
157
  ## 🔧 API Reference
146
158
 
147
159
  ### Core Components
@@ -302,7 +314,7 @@ const imageStream = fs.createReadStream("/path/to/your/image.png"); // Replace w
302
314
 
303
315
  // Translate image and receive a translated image stream
304
316
  const translatedImageStream = await lara.images.translate(imageStream, "en", "fr", {
305
- textRemoval: "inpainting",
317
+ model: "inpainting",
306
318
  style: "faithful"
307
319
  });
308
320
 
@@ -430,10 +442,55 @@ const completedImport = await lara.glossaries.waitForImport(glossaryImport, unde
430
442
  // Export glossary
431
443
  const csvData = await lara.glossaries.export("gls_1A2b3C4d5E6f7G8h9I0jKl", "csv/table-uni", "en-US");
432
444
 
445
+ // Async glossary export — returns a jobId; the result is delivered to your callback URL when ready
446
+ const { jobId } = await lara.glossaries.exportAsync(
447
+ "gls_1A2b3C4d5E6f7G8h9I0jKl",
448
+ "https://your-server.example.com/lara/export-callback",
449
+ "csv/table-uni",
450
+ "en-US"
451
+ );
452
+
433
453
  // Get glossary terms count
434
454
  const counts = await lara.glossaries.counts("gls_1A2b3C4d5E6f7G8h9I0jKl");
435
455
  ```
436
456
 
457
+ ### 📘 Styleguide Management
458
+
459
+ ```javascript
460
+ // Create styleguide
461
+ const styleguide = await lara.styleguides.create(
462
+ "MyStyleguide",
463
+ "Use a formal tone. Prefer British English spelling. Avoid contractions."
464
+ );
465
+
466
+ // List all styleguides
467
+ const styleguides = await lara.styleguides.list();
468
+
469
+ // Get a styleguide by ID (returns null if not found)
470
+ const retrieved = await lara.styleguides.get("stg_1A2b3C4d5E6f7G8h9I0jKl");
471
+
472
+ // Update a styleguide — pass undefined for fields you don't want to change
473
+ // Update only the name
474
+ const renamed = await lara.styleguides.update("stg_1A2b3C4d5E6f7G8h9I0jKl", "UpdatedName", undefined);
475
+
476
+ // Update only the content
477
+ const updatedContent = await lara.styleguides.update(
478
+ "stg_1A2b3C4d5E6f7G8h9I0jKl",
479
+ undefined,
480
+ "Use a casual tone. Prefer American English spelling."
481
+ );
482
+
483
+ // Update both name and content
484
+ const updated = await lara.styleguides.update(
485
+ "stg_1A2b3C4d5E6f7G8h9I0jKl",
486
+ "FinalName",
487
+ "Use clear and concise language. Avoid jargon."
488
+ );
489
+
490
+ // Delete a styleguide
491
+ await lara.styleguides.delete("stg_1A2b3C4d5E6f7G8h9I0jKl");
492
+ ```
493
+
437
494
  ### Translation Options
438
495
 
439
496
  ```javascript
@@ -31,12 +31,15 @@ export declare class Glossaries {
31
31
  get(id: string): Promise<Glossary | null>;
32
32
  delete(id: string): Promise<Glossary>;
33
33
  update(id: string, name: string): Promise<Glossary>;
34
- importCsv(id: string, csv: MultiPartFile, gzip?: boolean): Promise<GlossaryImport>;
35
- importCsv(id: string, csv: MultiPartFile, contentType: GlossaryFileFormat, gzip?: boolean): Promise<GlossaryImport>;
34
+ importCsv(id: string, csv: MultiPartFile, gzip?: boolean, callbackUrl?: string): Promise<GlossaryImport>;
35
+ importCsv(id: string, csv: MultiPartFile, contentType: GlossaryFileFormat, gzip?: boolean, callbackUrl?: string): Promise<GlossaryImport>;
36
36
  getImportStatus(id: string): Promise<GlossaryImport>;
37
37
  waitForImport(gImport: GlossaryImport, updateCallback?: GlossaryImportCallback, maxWaitTime?: number): Promise<GlossaryImport>;
38
38
  counts(id: string): Promise<GlossaryCounts>;
39
39
  export(id: string, contentType: GlossaryFileFormat, source?: string): Promise<string>;
40
+ exportAsync(id: string, callbackUrl: string, contentType: GlossaryFileFormat, source?: string): Promise<{
41
+ jobId: string;
42
+ }>;
40
43
  addOrReplaceEntry(id: string, terms: {
41
44
  language: string;
42
45
  value: string;
package/lib/glossaries.js CHANGED
@@ -30,22 +30,26 @@ class Glossaries {
30
30
  async update(id, name) {
31
31
  return await this.client.put(`/v2/glossaries/${id}`, { name });
32
32
  }
33
- async importCsv(id, csv, gzipOrContentType, maybeGzip) {
33
+ async importCsv(id, csv, gzipOrContentType, maybeGzipOrCallbackUrl, maybeCallbackUrl) {
34
34
  // Default values when no content type or gzip flag is provided
35
35
  let gzip = false;
36
36
  let contentType = "csv/table-uni";
37
+ let callbackUrl;
37
38
  if (typeof gzipOrContentType === "boolean") {
38
- // First overload: (id, csv, gzip)
39
+ // First overload: (id, csv, gzip, callbackUrl)
39
40
  gzip = gzipOrContentType;
41
+ callbackUrl = typeof maybeGzipOrCallbackUrl === "string" ? maybeGzipOrCallbackUrl : undefined;
40
42
  }
41
43
  else if (typeof gzipOrContentType === "string") {
42
- // Second overload: (id, csv, contentType, gzip)
44
+ // Second overload: (id, csv, contentType, gzip, callbackUrl)
43
45
  contentType = gzipOrContentType;
44
- gzip = maybeGzip !== null && maybeGzip !== void 0 ? maybeGzip : false;
46
+ gzip = typeof maybeGzipOrCallbackUrl === "boolean" ? maybeGzipOrCallbackUrl : false;
47
+ callbackUrl = maybeCallbackUrl;
45
48
  }
46
49
  return await this.client.post(`/v2/glossaries/${id}/import`, {
47
50
  compression: gzip ? "gzip" : undefined,
48
- content_type: contentType
51
+ content_type: contentType,
52
+ callback_url: callbackUrl
49
53
  }, {
50
54
  csv
51
55
  });
@@ -74,6 +78,13 @@ class Glossaries {
74
78
  source
75
79
  });
76
80
  }
81
+ async exportAsync(id, callbackUrl, contentType, source) {
82
+ return await this.client.get(`/v2/glossaries/${id}/export/async`, {
83
+ callback_url: callbackUrl,
84
+ content_type: contentType,
85
+ source
86
+ });
87
+ }
77
88
  async addOrReplaceEntry(id, terms, guid) {
78
89
  return await this.client.put(`/v2/glossaries/${id}/content`, { terms, guid });
79
90
  }
@@ -22,7 +22,9 @@ export type ImageTextTranslationOptions = {
22
22
  verbose?: boolean;
23
23
  };
24
24
  export type ImageTranslationOptions = Omit<ImageTextTranslationOptions & {
25
+ /** @deprecated Use `model` instead. */
25
26
  textRemoval?: "overlay" | "inpainting";
27
+ model?: "overlay" | "inpainting" | "generative" | "generative_fast";
26
28
  }, "verbose">;
27
29
  export declare class ImageTranslator {
28
30
  private readonly client;
@@ -6,6 +6,7 @@ class ImageTranslator {
6
6
  this.client = client;
7
7
  }
8
8
  async translate(file, source, target, options) {
9
+ var _a;
9
10
  const headers = (options === null || options === void 0 ? void 0 : options.noTrace) ? { "X-No-Trace": "true" } : {};
10
11
  headers["Content-Type"] = "multipart/form-data";
11
12
  return this.client.post(`/v2/images/translate`, {
@@ -14,7 +15,7 @@ class ImageTranslator {
14
15
  adapt_to: JSON.stringify(options === null || options === void 0 ? void 0 : options.adaptTo),
15
16
  glossaries: JSON.stringify(options === null || options === void 0 ? void 0 : options.glossaries),
16
17
  style: options === null || options === void 0 ? void 0 : options.style,
17
- text_removal: options === null || options === void 0 ? void 0 : options.textRemoval
18
+ model: (_a = options === null || options === void 0 ? void 0 : options.model) !== null && _a !== void 0 ? _a : options === null || options === void 0 ? void 0 : options.textRemoval
18
19
  }, {
19
20
  image: file
20
21
  }, headers, true);
@@ -13,4 +13,7 @@ export declare class Styleguides {
13
13
  constructor(client: LaraClient);
14
14
  list(): Promise<Styleguide[]>;
15
15
  get(id: string): Promise<Styleguide | null>;
16
+ create(name: string, content: string): Promise<Styleguide>;
17
+ update(id: string, name: string | undefined, content?: string): Promise<Styleguide>;
18
+ delete(id: string): Promise<Styleguide>;
16
19
  }
@@ -20,5 +20,14 @@ class Styleguides {
20
20
  throw e;
21
21
  }
22
22
  }
23
+ async create(name, content) {
24
+ return await this.client.post("/v2/styleguides", { name, content });
25
+ }
26
+ async update(id, name, content) {
27
+ return await this.client.put(`/v2/styleguides/${id}`, { name, content });
28
+ }
29
+ async delete(id) {
30
+ return await this.client.delete(`/v2/styleguides/${id}`);
31
+ }
23
32
  }
24
33
  exports.Styleguides = Styleguides;
@@ -1 +1 @@
1
- export declare const version = "1.11.1";
1
+ export declare const version = "1.12.1";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
- exports.version = "1.11.1";
4
+ exports.version = "1.12.1";
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Lara=e():t.Lara=e()}(this,()=>(()=>{"use strict";var t={328(t,e,r){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.AudioTranslator=e.VoiceGender=e.AudioStatus=void 0;const o=r(725),i=n(r(821));var s,a;!function(t){t.INITIALIZED="initialized",t.ANALYZING="analyzing",t.PAUSED="paused",t.READY="ready",t.TRANSLATING="translating",t.TRANSLATED="translated",t.ERROR="error"}(s||(e.AudioStatus=s={})),function(t){t.MALE="male",t.FEMALE="female"}(a||(e.VoiceGender=a={})),e.AudioTranslator=class{constructor(t){this.client=t,this.s3Client=(0,i.default)()}async upload(t,e,r,n,o){const{url:i,fields:s}=await this.client.get("/v2/audio/upload-url",{filename:e});await this.s3Client.upload(i,s,t,null==o?void 0:o.contentLength);const a=(null==o?void 0:o.noTrace)?{"X-No-Trace":"true"}:{};return this.client.post("/v2/audio/translate",{source:r,target:n,s3key:s.key,adapt_to:null==o?void 0:o.adaptTo,glossaries:null==o?void 0:o.glossaries,style:null==o?void 0:o.style,voice_gender:null==o?void 0:o.voiceGender},void 0,a)}async status(t){return await this.client.get(`/v2/audio/${t}`)}async download(t){const{url:e}=await this.client.get(`/v2/audio/${t}/download-url`);return await this.s3Client.downloadStream(e)}async translate(t,e,r,n,i){const{id:a}=await this.upload(t,e,r,n,i),u=Date.now();for(;Date.now()-u<9e5;){await new Promise(t=>setTimeout(t,2e3));const{status:t,errorReason:e}=await this.status(a);if(t===s.TRANSLATED)return await this.download(a);if(t===s.ERROR)throw new o.LaraApiError(500,"AudioError",e)}throw new o.TimeoutError}}},414(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.AuthToken=e.Credentials=e.AccessKey=void 0;class r{constructor(t,e){this.id=t,this.secret=e}}e.AccessKey=r,e.Credentials=class extends r{get accessKeyId(){return this.id}get accessKeySecret(){return this.secret}},e.AuthToken=class{constructor(t,e){this.token=t,this.refreshToken=e}}},780(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.BrowserCrypto=void 0,e.BrowserCrypto=class{constructor(){this.subtle=window.crypto.subtle}async digestBase64(t){const e=new TextEncoder,r=(await this.subtle.digest("sha-256",e.encode(t))).slice(0,16);return btoa(String.fromCharCode(...new Uint8Array(r)))}async hmac(t,e){const r=new TextEncoder;r.encode(e);const n=await this.subtle.importKey("raw",r.encode(t),{name:"hmac",hash:{name:"sha-256"}},!1,["sign"]),o=await this.subtle.sign("hmac",n,r.encode(e));return btoa(String.fromCharCode(...new Uint8Array(o)))}}},326(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(){return void 0===o&&(o=new n.BrowserCrypto),o};const n=r(780);let o},50(t,e,r){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Documents=e.DocumentStatus=void 0;const o=r(725),i=n(r(821)),s=n(r(841));var a;!function(t){t.INITIALIZED="initialized",t.ANALYZING="analyzing",t.PAUSED="paused",t.READY="ready",t.TRANSLATING="translating",t.TRANSLATED="translated",t.ERROR="error"}(a||(e.DocumentStatus=a={})),e.Documents=class{constructor(t){this.client=t,this.s3Client=(0,i.default)()}async upload(t,e,r,n,o){const{url:i,fields:a}=await this.client.get("/v2/documents/upload-url",{filename:e});await this.s3Client.upload(i,a,t,null==o?void 0:o.contentLength);const u=(null==o?void 0:o.noTrace)?{"X-No-Trace":"true"}:{};return this.client.post("/v2/documents",{source:r,target:n,s3key:a.key,adapt_to:null==o?void 0:o.adaptTo,glossaries:null==o?void 0:o.glossaries,style:null==o?void 0:o.style,password:null==o?void 0:o.password,extraction_params:(null==o?void 0:o.extractionParams)?(0,s.default)(o.extractionParams):void 0},void 0,u)}async status(t){return await this.client.get(`/v2/documents/${t}`)}async download(t,e){const{url:r}=await this.client.get(`/v2/documents/${t}/download-url`,{output_format:null==e?void 0:e.outputFormat});return await this.s3Client.download(r)}async downloadStream(t,e){const{url:r}=await this.client.get(`/v2/documents/${t}/download-url`,{output_format:null==e?void 0:e.outputFormat});return await this.s3Client.downloadStream(r)}async translate(t,e,r,n,i){const s={adaptTo:null==i?void 0:i.adaptTo,glossaries:null==i?void 0:i.glossaries,noTrace:null==i?void 0:i.noTrace,style:null==i?void 0:i.style,password:null==i?void 0:i.password,extractionParams:null==i?void 0:i.extractionParams,contentLength:null==i?void 0:i.contentLength},{id:u}=await this.upload(t,e,r,n,s),l=(null==i?void 0:i.outputFormat)?{outputFormat:i.outputFormat}:void 0,c=Date.now();for(;Date.now()-c<9e5;){await new Promise(t=>setTimeout(t,2e3));const{status:t,errorReason:e}=await this.status(u);if(t===a.TRANSLATED)return await this.download(u,l);if(t===a.ERROR)throw new o.LaraApiError(500,"DocumentError",e)}throw new o.TimeoutError}async translateStream(t,e,r,n,i){const s={adaptTo:null==i?void 0:i.adaptTo,glossaries:null==i?void 0:i.glossaries,noTrace:null==i?void 0:i.noTrace,style:null==i?void 0:i.style,password:null==i?void 0:i.password,extractionParams:null==i?void 0:i.extractionParams,contentLength:null==i?void 0:i.contentLength},{id:u}=await this.upload(t,e,r,n,s),l=(null==i?void 0:i.outputFormat)?{outputFormat:i.outputFormat}:void 0,c=Date.now();for(;Date.now()-c<9e5;){await new Promise(t=>setTimeout(t,2e3));const{status:t,errorReason:e}=await this.status(u);if(t===a.TRANSLATED)return await this.downloadStream(u,l);if(t===a.ERROR)throw new o.LaraApiError(500,"DocumentError",e)}throw new o.TimeoutError}}},725(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.LaraApiError=e.TimeoutError=e.LaraError=void 0;class r extends Error{}e.LaraError=r,e.TimeoutError=class extends r{},e.LaraApiError=class extends r{constructor(t,e,r,n){super(r),this.statusCode=t,this.type=e,this.message=r,this.idTransaction=n}}},514(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.Glossaries=void 0;const n=r(725);e.Glossaries=class{constructor(t){this.client=t,this.pollingInterval=2e3}async list(){return await this.client.get("/v2/glossaries")}async create(t){return await this.client.post("/v2/glossaries",{name:t})}async get(t){try{return await this.client.get(`/v2/glossaries/${t}`)}catch(t){if(t instanceof n.LaraApiError&&404===t.statusCode)return null;throw t}}async delete(t){return await this.client.delete(`/v2/glossaries/${t}`)}async update(t,e){return await this.client.put(`/v2/glossaries/${t}`,{name:e})}async importCsv(t,e,r,n){let o=!1,i="csv/table-uni";return"boolean"==typeof r?o=r:"string"==typeof r&&(i=r,o=null!=n&&n),await this.client.post(`/v2/glossaries/${t}/import`,{compression:o?"gzip":void 0,content_type:i},{csv:e})}async getImportStatus(t){return await this.client.get(`/v2/glossaries/imports/${t}`)}async waitForImport(t,e,r){const o=Date.now();for(;t.progress<1;){if(r&&Date.now()-o>r)throw new n.TimeoutError;await new Promise(t=>setTimeout(t,this.pollingInterval)),t=await this.getImportStatus(t.id),e&&e(t)}return t}async counts(t){return await this.client.get(`/v2/glossaries/${t}/counts`)}async export(t,e,r){return await this.client.get(`/v2/glossaries/${t}/export`,{content_type:e,source:r})}async addOrReplaceEntry(t,e,r){return await this.client.put(`/v2/glossaries/${t}/content`,{terms:e,guid:r})}async deleteEntry(t,e,r){return await this.client.delete(`/v2/glossaries/${t}/content`,void 0,{term:e,guid:r})}}},731(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.ImageTranslator=void 0,e.ImageTranslator=class{constructor(t){this.client=t}async translate(t,e,r,n){const o=(null==n?void 0:n.noTrace)?{"X-No-Trace":"true"}:{};return o["Content-Type"]="multipart/form-data",this.client.post("/v2/images/translate",{source:e,target:r,adapt_to:JSON.stringify(null==n?void 0:n.adaptTo),glossaries:JSON.stringify(null==n?void 0:n.glossaries),style:null==n?void 0:n.style,text_removal:null==n?void 0:n.textRemoval},{image:t},o,!0)}async translateText(t,e,r,n){const o=(null==n?void 0:n.noTrace)?{"X-No-Trace":"true"}:{};return o["Content-Type"]="multipart/form-data",this.client.post("/v2/images/translate-text",{source:e,target:r,adapt_to:JSON.stringify(null==n?void 0:n.adaptTo),glossaries:JSON.stringify(null==n?void 0:n.glossaries),style:null==n?void 0:n.style,verbose:JSON.stringify(null==n?void 0:n.verbose)},{image:t},o)}}},629(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.Memories=void 0;const n=r(725);e.Memories=class{constructor(t){this.client=t,this.pollingInterval=2e3}async list(){return await this.client.get("/v2/memories")}async create(t,e){return await this.client.post("/v2/memories",{name:t,external_id:e})}async get(t){try{return await this.client.get(`/v2/memories/${t}`)}catch(t){if(t instanceof n.LaraApiError&&404===t.statusCode)return null;throw t}}async delete(t){return await this.client.delete(`/v2/memories/${t}`)}async update(t,e){return await this.client.put(`/v2/memories/${t}`,{name:e})}async connect(t){const e=await this.client.post("/v2/memories/connect",{ids:Array.isArray(t)?t:[t]});return Array.isArray(t)?e:e[0]}async importTmx(t,e,r,n){let o,i=!1;return"boolean"==typeof r?(i=r,o=n):"string"==typeof r&&(o=r),await this.client.post(`/v2/memories/${t}/import`,{compression:i?"gzip":void 0,callback_url:o},{tmx:e})}async exportAsync(t,e,r){return await this.client.get(`/v2/memories/${t}/export/async`,{callback_url:e,format:r})}async addTranslation(t,e,r,n,o,i,s,a,u){const l={source:e,target:r,sentence:n,translation:o,tuid:i,sentence_before:s,sentence_after:a};return Array.isArray(t)?(l.ids=t,await this.client.put("/v2/memories/content",l,void 0,u)):await this.client.put(`/v2/memories/${t}/content`,l,void 0,u)}async deleteTranslation(t,e,r,n,o,i,s,a){const u={source:e,target:r,sentence:n,translation:o,tuid:i,sentence_before:s,sentence_after:a};return Array.isArray(t)?(u.ids=t,await this.client.delete("/v2/memories/content",void 0,u)):await this.client.delete(`/v2/memories/${t}/content`,void 0,u)}async getImportStatus(t){return await this.client.get(`/v2/memories/imports/${t}`)}async waitForImport(t,e,r){const o=Date.now();for(;t.progress<1;){if(r&&Date.now()-o>r)throw new n.TimeoutError;await new Promise(t=>setTimeout(t,this.pollingInterval)),t=await this.getImportStatus(t.id),e&&e(t)}return t}}},631(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.BrowserClient=e.BrowserLaraClient=void 0;const n=r(725),o=r(412);class i extends o.LaraClient{constructor(t,e,r,n){super(e);let o=`${t.secure?"https":"http"}://${t.hostname}`;var i,s;i=t.port,s=t.secure,80===i&&!s||443===i&&s||(o+=`:${t.port}`),this.baseUrl=o,this.timeout=n}async send(t,e,r,o,i){var s;let a;if(o)if("multipart/form-data"===r["Content-Type"]){delete r["Content-Type"];const t=new FormData;for(const[e,r]of Object.entries(o))if(r)if(Array.isArray(r))for(const n of r)t.append(e,n);else t.append(e,r);a=t}else a=JSON.stringify(o,void 0,0);const u=this.timeout&&this.timeout>0?AbortSignal.timeout(this.timeout):void 0;try{const n=await fetch(this.baseUrl+e,{headers:r,method:t,body:a,signal:u});return i&&n.status>=200&&n.status<300?{statusCode:n.status,body:n.body,headers:Object.fromEntries(n.headers)}:(null===(s=n.headers.get("Content-Type"))||void 0===s?void 0:s.includes("text/csv"))?{statusCode:n.status,body:{content:await n.text()},headers:Object.fromEntries(n.headers)}:{statusCode:n.status,body:await n.json(),headers:Object.fromEntries(n.headers)}}catch(t){if(t instanceof Error&&("AbortError"===t.name||"TimeoutError"===t.name))throw new n.TimeoutError(`Request timed out after ${this.timeout}ms`);throw t}}async*sendAndGetStream(t,e,r,o){let i;if(o)if("multipart/form-data"===r["Content-Type"]){delete r["Content-Type"];const t=new FormData;for(const[e,r]of Object.entries(o))if(r)if(Array.isArray(r))for(const n of r)t.append(e,n);else t.append(e,r);i=t}else i=JSON.stringify(o,void 0,0);const s=this.timeout&&this.timeout>0?AbortSignal.timeout(this.timeout):void 0;let a;try{a=await fetch(this.baseUrl+e,{headers:r,method:t,body:i,signal:s})}catch(t){if(t instanceof Error&&("AbortError"===t.name||"TimeoutError"===t.name))throw new n.TimeoutError(`Request timed out after ${this.timeout}ms`);throw t}if(!a.body)throw new Error("Response body is not available for streaming");const u=a.body.getReader(),l=new TextDecoder;let c="";try{for(;;){let t;try{t=await u.read()}catch(t){if(t instanceof Error&&("AbortError"===t.name||"TimeoutError"===t.name))throw new n.TimeoutError(`Request timed out after ${this.timeout}ms`);throw t}const{done:e,value:r}=t;if(e){if(c.trim())try{const t=JSON.parse(c);yield{statusCode:t.status||a.status,body:t.data||t,headers:Object.fromEntries(a.headers)}}catch(t){}break}c+=l.decode(r,{stream:!0});const o=c.split("\n");c=o.pop()||"";for(const t of o)if(t.trim())try{const e=JSON.parse(t);yield{statusCode:e.status||a.status,body:e.data||e,headers:Object.fromEntries(a.headers)}}catch(t){}}}finally{u.releaseLock()}}wrapMultiPartFile(t){if(t instanceof File)return t;throw new TypeError(`Invalid file input in the browser. Expected an instance of File but received ${typeof t}.`)}}e.BrowserLaraClient=i;class s{static async get(t,e){return s.send("GET",t,e)}static async send(t,e,r,n){var o;let i;if(n)if(r&&"multipart/form-data"===r["Content-Type"]){delete r["Content-Type"];const t=new FormData;for(const[e,r]of Object.entries(n))if(r)if(Array.isArray(r))for(const n of r)t.append(e,n);else t.append(e,r);i=t}else i=JSON.stringify(n,void 0,0);const s=await fetch(e,{headers:r,method:t,body:i});return{statusCode:s.status,headers:Object.fromEntries(s.headers),body:(null===(o=s.headers.get("Content-Type"))||void 0===o?void 0:o.includes("application/json"))?await s.json():await s.text()}}}e.BrowserClient=s},412(t,e,r){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.LaraClient=void 0;const o=r(414),i=n(r(326)),s=r(725),a=r(741),u=r(311);e.LaraClient=class{constructor(t){if(this.crypto=(0,i.default)(),this.extraHeaders={},t instanceof o.AccessKey)this.accessKey=t;else{if(!(t instanceof o.AuthToken))throw new Error("Invalid authentication method provided");this.authToken=t}}setExtraHeader(t,e){this.extraHeaders[t]=e}get(t,e,r){return this.request("GET",this.buildPathWithQuery(t,e),void 0,void 0,r)}delete(t,e,r,n){return this.request("DELETE",this.buildPathWithQuery(t,e),r,void 0,n)}post(t,e,r,n,o){return this.request("POST",t,e,r,n,void 0,o)}async*postAndGetStream(t,e,r,n){for await(const o of this.requestStream("POST",t,e,r,n))yield o}put(t,e,r,n){return this.request("PUT",t,e,r,n)}async request(t,e,r,n,o,i=0,s){await this.ensureAuthenticated();const u=e.startsWith("/")?e:`/${e}`,l=await this.buildRequestHeaders(r,n,o),c=this.buildRequestBody(r,n);l.Authorization=`Bearer ${this.token}`;const d=await this.send(t,u,l,c,s);if(this.isSuccessResponse(d))return s?d.body:(0,a.parseContent)(d.body);if(401===d.statusCode&&i<1)return this.token=void 0,await this.refreshOrReauthenticate(),this.request(t,e,r,n,o,i+1,s);throw this.createApiError(d)}async*requestStream(t,e,r,n,o,i=0){await this.ensureAuthenticated();const s=e.startsWith("/")?e:`/${e}`,u=await this.buildRequestHeaders(r,n,o),l=this.buildRequestBody(r,n);u.Authorization=`Bearer ${this.token}`;for await(const c of this.sendAndGetStream(t,s,u,l)){if(401===c.statusCode&&i<1)return this.token=void 0,await this.refreshOrReauthenticate(),void(yield*this.requestStream(t,e,r,n,o,i+1));if(!this.isSuccessResponse(c))throw this.createApiError(c);yield(0,a.parseContent)(c.body)}}isTokenExpired(t=5e3){if(!this.token)return!0;try{const e=this.token.split(".");if(3!==e.length)return!0;let r=e[1].replace(/-/g,"+").replace(/_/g,"/");for(;r.length%4;)r+="=";const n="undefined"!=typeof Buffer?Buffer.from(r,"base64").toString("utf-8"):atob(r),{exp:o}=JSON.parse(n);return"number"==typeof o&&1e3*o<=Date.now()+t}catch{return!0}}async ensureAuthenticated(){if(!this.token||this.isTokenExpired()){if(this.token=void 0,this.authenticationPromise)return this.authenticationPromise;this.authenticationPromise=this.performAuthentication();try{await this.authenticationPromise,this.authenticationPromise=void 0}catch(t){if(this.authenticationPromise=void 0,t instanceof s.LaraApiError&&(401===t.statusCode||403===t.statusCode))throw t;try{this.authenticationPromise=this.performAuthentication(),await this.authenticationPromise,this.authenticationPromise=void 0}catch(t){throw this.authenticationPromise=void 0,t instanceof s.LaraApiError?t:new s.LaraApiError(500,"AuthenticationError",t.message)}}}}async performAuthentication(){return this.authToken?(this.token=this.authToken.token,this.refreshToken=this.authToken.refreshToken,void(this.authToken=void 0)):this.doRefreshOrReauthenticate()}refreshOrReauthenticate(){return this.refreshPromise||(this.refreshPromise=this.doRefreshOrReauthenticate().finally(()=>{this.refreshPromise=void 0})),this.refreshPromise}async doRefreshOrReauthenticate(){if(this.refreshToken)try{return void await this.refreshTokens()}catch(t){if(this.refreshToken=void 0,!this.accessKey)throw t}if(!this.accessKey)throw new Error("No authentication method available for token renewal");await this.authenticateWithAccessKey()}async refreshTokens(){const t={Authorization:`Bearer ${this.refreshToken}`,"X-Lara-Date":(new Date).toUTCString(),...this.extraHeaders},e=await this.send("POST","/v2/auth/refresh",t);this.handleAuthResponse(e)}async authenticateWithAccessKey(){if(!this.accessKey)throw new Error("No access key provided");const t={id:this.accessKey.id},e=await this.crypto.digestBase64(JSON.stringify(t)),r={"Content-Type":"application/json","X-Lara-Date":(new Date).toUTCString(),"Content-MD5":e,...this.extraHeaders};r.Authorization=`Lara:${await this.sign("POST","/v2/auth",r)}`;const n=await this.send("POST","/v2/auth",r,t);this.handleAuthResponse(n)}buildPathWithQuery(t,e){const r=this.filterNullish(e);return r?`${t}?${new URLSearchParams(r).toString()}`:t}async buildRequestHeaders(t,e,r){const n={"X-Lara-Date":(new Date).toUTCString(),"X-Lara-SDK-Name":"lara-node","X-Lara-SDK-Version":u.version,...this.filterNullish(this.extraHeaders),...this.filterNullish(r)},o=this.filterNullish(t);if(e)n["Content-Type"]="multipart/form-data";else if(o){n["Content-Type"]="application/json";const t=JSON.stringify(o,void 0,0);n["Content-Length"]=(new TextEncoder).encode(t).length.toString()}return n}buildRequestBody(t,e){const r=this.filterNullish(t);if(e){const t={};for(const[r,n]of Object.entries(e))t[r]=this.wrapMultiPartFile(n);return{...t,...r}}return r}filterNullish(t){if(!t)return;const e=Object.fromEntries(Object.entries(t).filter(([t,e])=>null!=e));return Object.keys(e).length>0?e:void 0}isSuccessResponse(t){return t.statusCode>=200&&t.statusCode<300}handleAuthResponse(t){if(this.isSuccessResponse(t)){this.token=t.body.token;const e=t.headers["x-lara-refresh-token"];return void(e&&(this.refreshToken=e))}throw this.createApiError(t)}createApiError(t){const e=t.body||{};return new s.LaraApiError(t.statusCode,e.type||"UnknownError",e.message||"An unknown error occurred")}async sign(t,e,r){if(!this.accessKey)throw new Error("Access key not provided for signing");const n=r["X-Lara-Date"].trim(),o=(r["Content-MD5"]||"").trim(),i=(r["Content-Type"]||"").trim(),s=`${(r["X-HTTP-Method-Override"]||t).trim().toUpperCase()}\n${e}\n${o}\n${i}\n${n}`;return this.crypto.hmac(this.accessKey.secret,s)}}},837(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.HttpClient=e.LaraClient=void 0,e.default=function(t,e,r,i){const s=new URL(e||n.DEFAULT_BASE_URL);if("https:"!==s.protocol&&"http:"!==s.protocol)throw new TypeError(`Invalid URL (protocol): ${s.protocol}`);const a={secure:"https:"===s.protocol,hostname:s.hostname,port:s.port?parseInt(s.port,10):"https:"===s.protocol?443:80};return new o.BrowserLaraClient(a,t,null==r||r,i)};const n=r(221),o=r(631);var i=r(412);Object.defineProperty(e,"LaraClient",{enumerable:!0,get:function(){return i.LaraClient}});var s=r(631);Object.defineProperty(e,"HttpClient",{enumerable:!0,get:function(){return s.BrowserClient}})},343(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.BrowserS3Client=void 0;const n=r(364);class o extends n.S3Client{async _upload(t,e,r){const n=new FormData;for(const[t,r]of Object.entries(e))n.append(t,r);n.append("file",r),await fetch(t,{method:"POST",body:n})}async download(t){return(await fetch(t)).blob()}async downloadStream(t){const e=await fetch(t);if(!e.body)throw new Error("Response body is null");return e.body}wrapMultiPartFile(t){if(t instanceof File)return t;throw new TypeError(`Invalid file input in the browser. Expected an instance of File but received ${typeof t}.`)}}e.BrowserS3Client=o},364(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.S3Client=void 0,e.S3Client=class{async upload(t,e,r,n){return this._upload(t,e,this.wrapMultiPartFile(r),n)}}},821(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(){return new n.BrowserS3Client};const n=r(343)},816(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.Styleguides=void 0;const n=r(725);e.Styleguides=class{constructor(t){this.client=t}async list(){return await this.client.get("/v2/styleguides")}async get(t){try{return await this.client.get(`/v2/styleguides/${t}`)}catch(t){if(t instanceof n.LaraApiError&&404===t.statusCode)return null;throw t}}}},660(t,e,r){var n,o=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||(n=function(t){return n=Object.getOwnPropertyNames||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[e.length]=r);return e},n(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r=n(t),s=0;s<r.length;s++)"default"!==r[s]&&o(e,t,r[s]);return i(e,t),e});Object.defineProperty(e,"__esModule",{value:!0}),e.Translator=void 0;const a=r(328),u=r(50),l=r(514),c=r(731),d=r(629),h=s(r(837)),f=r(816),p=r(221),y=r(311);e.Translator=class{constructor(t,e){this.client=(0,h.default)(t,null==e?void 0:e.serverUrl,null==e?void 0:e.keepAlive,null==e?void 0:e.connectionTimeoutMs),this.memories=new d.Memories(this.client),this.documents=new u.Documents(this.client),this.glossaries=new l.Glossaries(this.client),this.styleguides=new f.Styleguides(this.client),this.audio=new a.AudioTranslator(this.client),this.images=new c.ImageTranslator(this.client)}get version(){return y.version}async getLanguages(){return await this.client.get("/v2/languages")}async translate(t,e,r,n,o){const i={};if(null==n?void 0:n.headers)for(const[t,e]of Object.entries(n.headers))i[t]=e;(null==n?void 0:n.noTrace)&&(i["X-No-Trace"]="true");const s=this.client.postAndGetStream("/v2/translate",{q:t,source:e,target:r,source_hint:null==n?void 0:n.sourceHint,content_type:null==n?void 0:n.contentType,multiline:!1!==(null==n?void 0:n.multiline),adapt_to:null==n?void 0:n.adaptTo,glossaries:null==n?void 0:n.glossaries,instructions:null==n?void 0:n.instructions,timeout:null==n?void 0:n.timeoutInMillis,priority:null==n?void 0:n.priority,use_cache:null==n?void 0:n.useCache,cache_ttl:null==n?void 0:n.cacheTTLSeconds,verbose:null==n?void 0:n.verbose,style:null==n?void 0:n.style,reasoning:null==n?void 0:n.reasoning,metadata:null==n?void 0:n.metadata,profanities_detect:null==n?void 0:n.profanitiesDetect,profanities_handling:null==n?void 0:n.profanitiesHandling,styleguide_id:null==n?void 0:n.styleguideId,styleguide_reasoning:null==n?void 0:n.styleguideReasoning,styleguide_explanation_language:null==n?void 0:n.styleguideExplanationLanguage},void 0,i);let a;for await(const t of s)(null==n?void 0:n.reasoning)&&o&&o(t),a=t;if(!a)throw new Error("No translation result received.");return a}async detect(t,e,r){return await this.client.post("/v2/detect/language",{q:t,hint:e,passlist:r})}async detectProfanities(t,e,r){return await this.client.post("/v2/detect/profanities",{text:t,language:e,content_type:r})}async qualityEstimation(t,e,r,n){return await this.client.post("/v2/detect/quality-estimation",{source:t,target:e,sentence:r,translation:n})}static async getLoginUrl(t){t||(t=p.DEFAULT_BASE_URL);const{body:e}=await h.HttpClient.get(`${t.replace(/\/+$/,"")}/v2/auth/login-page`);return e}}},221(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_BASE_URL=void 0,e.DEFAULT_BASE_URL="https://api.laratranslate.com"},741(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.parseContent=function t(e){if(null==e)return e;if(Array.isArray(e))return e.map(t);if("string"==typeof e)return e.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.[0-9]{3}Z$/)?new Date(e):e;if("object"==typeof e){const r={};for(const[n,o]of Object.entries(e))r[n.replace(/_([a-z])/g,(t,e)=>e.toUpperCase())]=t(o);return r}return e}},311(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.version=void 0,e.version="1.11.1"},841(t,e){Object.defineProperty(e,"__esModule",{value:!0});const r=t=>{if("string"==typeof t)return t;if(Array.isArray(t))return t.map(r);if("object"==typeof t&&null!==t){const e={};for(const[n,o]of Object.entries(t))e[n.replace(/([A-Z])/g,"_$1").toLowerCase()]=r(o);return e}return t};e.default=r}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}var n={};return(()=>{var t=n;Object.defineProperty(t,"__esModule",{value:!0}),t.version=t.Translator=t.Styleguides=t.Memories=t.ImageTranslator=t.Glossaries=t.TimeoutError=t.LaraError=t.LaraApiError=t.Documents=t.DocumentStatus=t.Credentials=t.AuthToken=t.AccessKey=t.VoiceGender=t.AudioTranslator=t.AudioStatus=void 0;var e=r(328);Object.defineProperty(t,"AudioStatus",{enumerable:!0,get:function(){return e.AudioStatus}}),Object.defineProperty(t,"AudioTranslator",{enumerable:!0,get:function(){return e.AudioTranslator}}),Object.defineProperty(t,"VoiceGender",{enumerable:!0,get:function(){return e.VoiceGender}});var o=r(414);Object.defineProperty(t,"AccessKey",{enumerable:!0,get:function(){return o.AccessKey}}),Object.defineProperty(t,"AuthToken",{enumerable:!0,get:function(){return o.AuthToken}}),Object.defineProperty(t,"Credentials",{enumerable:!0,get:function(){return o.Credentials}});var i=r(50);Object.defineProperty(t,"DocumentStatus",{enumerable:!0,get:function(){return i.DocumentStatus}}),Object.defineProperty(t,"Documents",{enumerable:!0,get:function(){return i.Documents}});var s=r(725);Object.defineProperty(t,"LaraApiError",{enumerable:!0,get:function(){return s.LaraApiError}}),Object.defineProperty(t,"LaraError",{enumerable:!0,get:function(){return s.LaraError}}),Object.defineProperty(t,"TimeoutError",{enumerable:!0,get:function(){return s.TimeoutError}});var a=r(514);Object.defineProperty(t,"Glossaries",{enumerable:!0,get:function(){return a.Glossaries}});var u=r(731);Object.defineProperty(t,"ImageTranslator",{enumerable:!0,get:function(){return u.ImageTranslator}});var l=r(629);Object.defineProperty(t,"Memories",{enumerable:!0,get:function(){return l.Memories}});var c=r(816);Object.defineProperty(t,"Styleguides",{enumerable:!0,get:function(){return c.Styleguides}});var d=r(660);Object.defineProperty(t,"Translator",{enumerable:!0,get:function(){return d.Translator}});var h=r(311);Object.defineProperty(t,"version",{enumerable:!0,get:function(){return h.version}})})(),n})());
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Lara=e():t.Lara=e()}(this,()=>(()=>{"use strict";var t={328(t,e,r){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.AudioTranslator=e.VoiceGender=e.AudioStatus=void 0;const i=r(725),o=n(r(821));var s,a;!function(t){t.INITIALIZED="initialized",t.ANALYZING="analyzing",t.PAUSED="paused",t.READY="ready",t.TRANSLATING="translating",t.TRANSLATED="translated",t.ERROR="error"}(s||(e.AudioStatus=s={})),function(t){t.MALE="male",t.FEMALE="female"}(a||(e.VoiceGender=a={})),e.AudioTranslator=class{constructor(t){this.client=t,this.s3Client=(0,o.default)()}async upload(t,e,r,n,i){const{url:o,fields:s}=await this.client.get("/v2/audio/upload-url",{filename:e});await this.s3Client.upload(o,s,t,null==i?void 0:i.contentLength);const a=(null==i?void 0:i.noTrace)?{"X-No-Trace":"true"}:{};return this.client.post("/v2/audio/translate",{source:r,target:n,s3key:s.key,adapt_to:null==i?void 0:i.adaptTo,glossaries:null==i?void 0:i.glossaries,style:null==i?void 0:i.style,voice_gender:null==i?void 0:i.voiceGender},void 0,a)}async status(t){return await this.client.get(`/v2/audio/${t}`)}async download(t){const{url:e}=await this.client.get(`/v2/audio/${t}/download-url`);return await this.s3Client.downloadStream(e)}async translate(t,e,r,n,o){const{id:a}=await this.upload(t,e,r,n,o),l=Date.now();for(;Date.now()-l<9e5;){await new Promise(t=>setTimeout(t,2e3));const{status:t,errorReason:e}=await this.status(a);if(t===s.TRANSLATED)return await this.download(a);if(t===s.ERROR)throw new i.LaraApiError(500,"AudioError",e)}throw new i.TimeoutError}}},414(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.AuthToken=e.Credentials=e.AccessKey=void 0;class r{constructor(t,e){this.id=t,this.secret=e}}e.AccessKey=r,e.Credentials=class extends r{get accessKeyId(){return this.id}get accessKeySecret(){return this.secret}},e.AuthToken=class{constructor(t,e){this.token=t,this.refreshToken=e}}},780(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.BrowserCrypto=void 0,e.BrowserCrypto=class{constructor(){this.subtle=window.crypto.subtle}async digestBase64(t){const e=new TextEncoder,r=(await this.subtle.digest("sha-256",e.encode(t))).slice(0,16);return btoa(String.fromCharCode(...new Uint8Array(r)))}async hmac(t,e){const r=new TextEncoder;r.encode(e);const n=await this.subtle.importKey("raw",r.encode(t),{name:"hmac",hash:{name:"sha-256"}},!1,["sign"]),i=await this.subtle.sign("hmac",n,r.encode(e));return btoa(String.fromCharCode(...new Uint8Array(i)))}}},326(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(){return void 0===i&&(i=new n.BrowserCrypto),i};const n=r(780);let i},50(t,e,r){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Documents=e.DocumentStatus=void 0;const i=r(725),o=n(r(821)),s=n(r(841));var a;!function(t){t.INITIALIZED="initialized",t.ANALYZING="analyzing",t.PAUSED="paused",t.READY="ready",t.TRANSLATING="translating",t.TRANSLATED="translated",t.ERROR="error"}(a||(e.DocumentStatus=a={})),e.Documents=class{constructor(t){this.client=t,this.s3Client=(0,o.default)()}async upload(t,e,r,n,i){const{url:o,fields:a}=await this.client.get("/v2/documents/upload-url",{filename:e});await this.s3Client.upload(o,a,t,null==i?void 0:i.contentLength);const l=(null==i?void 0:i.noTrace)?{"X-No-Trace":"true"}:{};return this.client.post("/v2/documents",{source:r,target:n,s3key:a.key,adapt_to:null==i?void 0:i.adaptTo,glossaries:null==i?void 0:i.glossaries,style:null==i?void 0:i.style,password:null==i?void 0:i.password,extraction_params:(null==i?void 0:i.extractionParams)?(0,s.default)(i.extractionParams):void 0},void 0,l)}async status(t){return await this.client.get(`/v2/documents/${t}`)}async download(t,e){const{url:r}=await this.client.get(`/v2/documents/${t}/download-url`,{output_format:null==e?void 0:e.outputFormat});return await this.s3Client.download(r)}async downloadStream(t,e){const{url:r}=await this.client.get(`/v2/documents/${t}/download-url`,{output_format:null==e?void 0:e.outputFormat});return await this.s3Client.downloadStream(r)}async translate(t,e,r,n,o){const s={adaptTo:null==o?void 0:o.adaptTo,glossaries:null==o?void 0:o.glossaries,noTrace:null==o?void 0:o.noTrace,style:null==o?void 0:o.style,password:null==o?void 0:o.password,extractionParams:null==o?void 0:o.extractionParams,contentLength:null==o?void 0:o.contentLength},{id:l}=await this.upload(t,e,r,n,s),u=(null==o?void 0:o.outputFormat)?{outputFormat:o.outputFormat}:void 0,c=Date.now();for(;Date.now()-c<9e5;){await new Promise(t=>setTimeout(t,2e3));const{status:t,errorReason:e}=await this.status(l);if(t===a.TRANSLATED)return await this.download(l,u);if(t===a.ERROR)throw new i.LaraApiError(500,"DocumentError",e)}throw new i.TimeoutError}async translateStream(t,e,r,n,o){const s={adaptTo:null==o?void 0:o.adaptTo,glossaries:null==o?void 0:o.glossaries,noTrace:null==o?void 0:o.noTrace,style:null==o?void 0:o.style,password:null==o?void 0:o.password,extractionParams:null==o?void 0:o.extractionParams,contentLength:null==o?void 0:o.contentLength},{id:l}=await this.upload(t,e,r,n,s),u=(null==o?void 0:o.outputFormat)?{outputFormat:o.outputFormat}:void 0,c=Date.now();for(;Date.now()-c<9e5;){await new Promise(t=>setTimeout(t,2e3));const{status:t,errorReason:e}=await this.status(l);if(t===a.TRANSLATED)return await this.downloadStream(l,u);if(t===a.ERROR)throw new i.LaraApiError(500,"DocumentError",e)}throw new i.TimeoutError}}},725(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.LaraApiError=e.TimeoutError=e.LaraError=void 0;class r extends Error{}e.LaraError=r,e.TimeoutError=class extends r{},e.LaraApiError=class extends r{constructor(t,e,r,n){super(r),this.statusCode=t,this.type=e,this.message=r,this.idTransaction=n}}},514(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.Glossaries=void 0;const n=r(725);e.Glossaries=class{constructor(t){this.client=t,this.pollingInterval=2e3}async list(){return await this.client.get("/v2/glossaries")}async create(t){return await this.client.post("/v2/glossaries",{name:t})}async get(t){try{return await this.client.get(`/v2/glossaries/${t}`)}catch(t){if(t instanceof n.LaraApiError&&404===t.statusCode)return null;throw t}}async delete(t){return await this.client.delete(`/v2/glossaries/${t}`)}async update(t,e){return await this.client.put(`/v2/glossaries/${t}`,{name:e})}async importCsv(t,e,r,n,i){let o,s=!1,a="csv/table-uni";return"boolean"==typeof r?(s=r,o="string"==typeof n?n:void 0):"string"==typeof r&&(a=r,s="boolean"==typeof n&&n,o=i),await this.client.post(`/v2/glossaries/${t}/import`,{compression:s?"gzip":void 0,content_type:a,callback_url:o},{csv:e})}async getImportStatus(t){return await this.client.get(`/v2/glossaries/imports/${t}`)}async waitForImport(t,e,r){const i=Date.now();for(;t.progress<1;){if(r&&Date.now()-i>r)throw new n.TimeoutError;await new Promise(t=>setTimeout(t,this.pollingInterval)),t=await this.getImportStatus(t.id),e&&e(t)}return t}async counts(t){return await this.client.get(`/v2/glossaries/${t}/counts`)}async export(t,e,r){return await this.client.get(`/v2/glossaries/${t}/export`,{content_type:e,source:r})}async exportAsync(t,e,r,n){return await this.client.get(`/v2/glossaries/${t}/export/async`,{callback_url:e,content_type:r,source:n})}async addOrReplaceEntry(t,e,r){return await this.client.put(`/v2/glossaries/${t}/content`,{terms:e,guid:r})}async deleteEntry(t,e,r){return await this.client.delete(`/v2/glossaries/${t}/content`,void 0,{term:e,guid:r})}}},731(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.ImageTranslator=void 0,e.ImageTranslator=class{constructor(t){this.client=t}async translate(t,e,r,n){var i;const o=(null==n?void 0:n.noTrace)?{"X-No-Trace":"true"}:{};return o["Content-Type"]="multipart/form-data",this.client.post("/v2/images/translate",{source:e,target:r,adapt_to:JSON.stringify(null==n?void 0:n.adaptTo),glossaries:JSON.stringify(null==n?void 0:n.glossaries),style:null==n?void 0:n.style,model:null!==(i=null==n?void 0:n.model)&&void 0!==i?i:null==n?void 0:n.textRemoval},{image:t},o,!0)}async translateText(t,e,r,n){const i=(null==n?void 0:n.noTrace)?{"X-No-Trace":"true"}:{};return i["Content-Type"]="multipart/form-data",this.client.post("/v2/images/translate-text",{source:e,target:r,adapt_to:JSON.stringify(null==n?void 0:n.adaptTo),glossaries:JSON.stringify(null==n?void 0:n.glossaries),style:null==n?void 0:n.style,verbose:JSON.stringify(null==n?void 0:n.verbose)},{image:t},i)}}},629(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.Memories=void 0;const n=r(725);e.Memories=class{constructor(t){this.client=t,this.pollingInterval=2e3}async list(){return await this.client.get("/v2/memories")}async create(t,e){return await this.client.post("/v2/memories",{name:t,external_id:e})}async get(t){try{return await this.client.get(`/v2/memories/${t}`)}catch(t){if(t instanceof n.LaraApiError&&404===t.statusCode)return null;throw t}}async delete(t){return await this.client.delete(`/v2/memories/${t}`)}async update(t,e){return await this.client.put(`/v2/memories/${t}`,{name:e})}async connect(t){const e=await this.client.post("/v2/memories/connect",{ids:Array.isArray(t)?t:[t]});return Array.isArray(t)?e:e[0]}async importTmx(t,e,r,n){let i,o=!1;return"boolean"==typeof r?(o=r,i=n):"string"==typeof r&&(i=r),await this.client.post(`/v2/memories/${t}/import`,{compression:o?"gzip":void 0,callback_url:i},{tmx:e})}async exportAsync(t,e,r){return await this.client.get(`/v2/memories/${t}/export/async`,{callback_url:e,format:r})}async addTranslation(t,e,r,n,i,o,s,a,l){const u={source:e,target:r,sentence:n,translation:i,tuid:o,sentence_before:s,sentence_after:a};return Array.isArray(t)?(u.ids=t,await this.client.put("/v2/memories/content",u,void 0,l)):await this.client.put(`/v2/memories/${t}/content`,u,void 0,l)}async deleteTranslation(t,e,r,n,i,o,s,a){const l={source:e,target:r,sentence:n,translation:i,tuid:o,sentence_before:s,sentence_after:a};return Array.isArray(t)?(l.ids=t,await this.client.delete("/v2/memories/content",void 0,l)):await this.client.delete(`/v2/memories/${t}/content`,void 0,l)}async getImportStatus(t){return await this.client.get(`/v2/memories/imports/${t}`)}async waitForImport(t,e,r){const i=Date.now();for(;t.progress<1;){if(r&&Date.now()-i>r)throw new n.TimeoutError;await new Promise(t=>setTimeout(t,this.pollingInterval)),t=await this.getImportStatus(t.id),e&&e(t)}return t}}},631(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.BrowserClient=e.BrowserLaraClient=void 0;const n=r(725),i=r(412);class o extends i.LaraClient{constructor(t,e,r,n){super(e);let i=`${t.secure?"https":"http"}://${t.hostname}`;var o,s;o=t.port,s=t.secure,80===o&&!s||443===o&&s||(i+=`:${t.port}`),this.baseUrl=i,this.timeout=n}async send(t,e,r,i,o){var s;let a;if(i)if("multipart/form-data"===r["Content-Type"]){delete r["Content-Type"];const t=new FormData;for(const[e,r]of Object.entries(i))if(r)if(Array.isArray(r))for(const n of r)t.append(e,n);else t.append(e,r);a=t}else a=JSON.stringify(i,void 0,0);const l=this.timeout&&this.timeout>0?AbortSignal.timeout(this.timeout):void 0;try{const n=await fetch(this.baseUrl+e,{headers:r,method:t,body:a,signal:l});return o&&n.status>=200&&n.status<300?{statusCode:n.status,body:n.body,headers:Object.fromEntries(n.headers)}:(null===(s=n.headers.get("Content-Type"))||void 0===s?void 0:s.includes("text/csv"))?{statusCode:n.status,body:{content:await n.text()},headers:Object.fromEntries(n.headers)}:{statusCode:n.status,body:await n.json(),headers:Object.fromEntries(n.headers)}}catch(t){if(t instanceof Error&&("AbortError"===t.name||"TimeoutError"===t.name))throw new n.TimeoutError(`Request timed out after ${this.timeout}ms`);throw t}}async*sendAndGetStream(t,e,r,i){let o;if(i)if("multipart/form-data"===r["Content-Type"]){delete r["Content-Type"];const t=new FormData;for(const[e,r]of Object.entries(i))if(r)if(Array.isArray(r))for(const n of r)t.append(e,n);else t.append(e,r);o=t}else o=JSON.stringify(i,void 0,0);const s=this.timeout&&this.timeout>0?AbortSignal.timeout(this.timeout):void 0;let a;try{a=await fetch(this.baseUrl+e,{headers:r,method:t,body:o,signal:s})}catch(t){if(t instanceof Error&&("AbortError"===t.name||"TimeoutError"===t.name))throw new n.TimeoutError(`Request timed out after ${this.timeout}ms`);throw t}if(!a.body)throw new Error("Response body is not available for streaming");const l=a.body.getReader(),u=new TextDecoder;let c="";try{for(;;){let t;try{t=await l.read()}catch(t){if(t instanceof Error&&("AbortError"===t.name||"TimeoutError"===t.name))throw new n.TimeoutError(`Request timed out after ${this.timeout}ms`);throw t}const{done:e,value:r}=t;if(e){if(c.trim())try{const t=JSON.parse(c);yield{statusCode:t.status||a.status,body:t.data||t,headers:Object.fromEntries(a.headers)}}catch(t){}break}c+=u.decode(r,{stream:!0});const i=c.split("\n");c=i.pop()||"";for(const t of i)if(t.trim())try{const e=JSON.parse(t);yield{statusCode:e.status||a.status,body:e.data||e,headers:Object.fromEntries(a.headers)}}catch(t){}}}finally{l.releaseLock()}}wrapMultiPartFile(t){if(t instanceof File)return t;throw new TypeError(`Invalid file input in the browser. Expected an instance of File but received ${typeof t}.`)}}e.BrowserLaraClient=o;class s{static async get(t,e){return s.send("GET",t,e)}static async send(t,e,r,n){var i;let o;if(n)if(r&&"multipart/form-data"===r["Content-Type"]){delete r["Content-Type"];const t=new FormData;for(const[e,r]of Object.entries(n))if(r)if(Array.isArray(r))for(const n of r)t.append(e,n);else t.append(e,r);o=t}else o=JSON.stringify(n,void 0,0);const s=await fetch(e,{headers:r,method:t,body:o});return{statusCode:s.status,headers:Object.fromEntries(s.headers),body:(null===(i=s.headers.get("Content-Type"))||void 0===i?void 0:i.includes("application/json"))?await s.json():await s.text()}}}e.BrowserClient=s},412(t,e,r){var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.LaraClient=void 0;const i=r(414),o=n(r(326)),s=r(725),a=r(741),l=r(311);e.LaraClient=class{constructor(t){if(this.crypto=(0,o.default)(),this.extraHeaders={},t instanceof i.AccessKey)this.accessKey=t;else{if(!(t instanceof i.AuthToken))throw new Error("Invalid authentication method provided");this.authToken=t}}setExtraHeader(t,e){this.extraHeaders[t]=e}get(t,e,r){return this.request("GET",this.buildPathWithQuery(t,e),void 0,void 0,r)}delete(t,e,r,n){return this.request("DELETE",this.buildPathWithQuery(t,e),r,void 0,n)}post(t,e,r,n,i){return this.request("POST",t,e,r,n,void 0,i)}async*postAndGetStream(t,e,r,n){for await(const i of this.requestStream("POST",t,e,r,n))yield i}put(t,e,r,n){return this.request("PUT",t,e,r,n)}async request(t,e,r,n,i,o=0,s){await this.ensureAuthenticated();const l=e.startsWith("/")?e:`/${e}`,u=await this.buildRequestHeaders(r,n,i),c=this.buildRequestBody(r,n);u.Authorization=`Bearer ${this.token}`;const d=await this.send(t,l,u,c,s);if(this.isSuccessResponse(d))return s?d.body:(0,a.parseContent)(d.body);if(401===d.statusCode&&o<1)return this.token=void 0,await this.refreshOrReauthenticate(),this.request(t,e,r,n,i,o+1,s);throw this.createApiError(d)}async*requestStream(t,e,r,n,i,o=0){await this.ensureAuthenticated();const s=e.startsWith("/")?e:`/${e}`,l=await this.buildRequestHeaders(r,n,i),u=this.buildRequestBody(r,n);l.Authorization=`Bearer ${this.token}`;for await(const c of this.sendAndGetStream(t,s,l,u)){if(401===c.statusCode&&o<1)return this.token=void 0,await this.refreshOrReauthenticate(),void(yield*this.requestStream(t,e,r,n,i,o+1));if(!this.isSuccessResponse(c))throw this.createApiError(c);yield(0,a.parseContent)(c.body)}}isTokenExpired(t=5e3){if(!this.token)return!0;try{const e=this.token.split(".");if(3!==e.length)return!0;let r=e[1].replace(/-/g,"+").replace(/_/g,"/");for(;r.length%4;)r+="=";const n="undefined"!=typeof Buffer?Buffer.from(r,"base64").toString("utf-8"):atob(r),{exp:i}=JSON.parse(n);return"number"==typeof i&&1e3*i<=Date.now()+t}catch{return!0}}async ensureAuthenticated(){if(!this.token||this.isTokenExpired()){if(this.token=void 0,this.authenticationPromise)return this.authenticationPromise;this.authenticationPromise=this.performAuthentication();try{await this.authenticationPromise,this.authenticationPromise=void 0}catch(t){if(this.authenticationPromise=void 0,t instanceof s.LaraApiError&&(401===t.statusCode||403===t.statusCode))throw t;try{this.authenticationPromise=this.performAuthentication(),await this.authenticationPromise,this.authenticationPromise=void 0}catch(t){throw this.authenticationPromise=void 0,t instanceof s.LaraApiError?t:new s.LaraApiError(500,"AuthenticationError",t.message)}}}}async performAuthentication(){return this.authToken?(this.token=this.authToken.token,this.refreshToken=this.authToken.refreshToken,void(this.authToken=void 0)):this.doRefreshOrReauthenticate()}refreshOrReauthenticate(){return this.refreshPromise||(this.refreshPromise=this.doRefreshOrReauthenticate().finally(()=>{this.refreshPromise=void 0})),this.refreshPromise}async doRefreshOrReauthenticate(){if(this.refreshToken)try{return void await this.refreshTokens()}catch(t){if(this.refreshToken=void 0,!this.accessKey)throw t}if(!this.accessKey)throw new Error("No authentication method available for token renewal");await this.authenticateWithAccessKey()}async refreshTokens(){const t={Authorization:`Bearer ${this.refreshToken}`,"X-Lara-Date":(new Date).toUTCString(),...this.extraHeaders},e=await this.send("POST","/v2/auth/refresh",t);this.handleAuthResponse(e)}async authenticateWithAccessKey(){if(!this.accessKey)throw new Error("No access key provided");const t={id:this.accessKey.id},e=await this.crypto.digestBase64(JSON.stringify(t)),r={"Content-Type":"application/json","X-Lara-Date":(new Date).toUTCString(),"Content-MD5":e,...this.extraHeaders};r.Authorization=`Lara:${await this.sign("POST","/v2/auth",r)}`;const n=await this.send("POST","/v2/auth",r,t);this.handleAuthResponse(n)}buildPathWithQuery(t,e){const r=this.filterNullish(e);return r?`${t}?${new URLSearchParams(r).toString()}`:t}async buildRequestHeaders(t,e,r){const n={"X-Lara-Date":(new Date).toUTCString(),"X-Lara-SDK-Name":"lara-node","X-Lara-SDK-Version":l.version,...this.filterNullish(this.extraHeaders),...this.filterNullish(r)},i=this.filterNullish(t);if(e)n["Content-Type"]="multipart/form-data";else if(i){n["Content-Type"]="application/json";const t=JSON.stringify(i,void 0,0);n["Content-Length"]=(new TextEncoder).encode(t).length.toString()}return n}buildRequestBody(t,e){const r=this.filterNullish(t);if(e){const t={};for(const[r,n]of Object.entries(e))t[r]=this.wrapMultiPartFile(n);return{...t,...r}}return r}filterNullish(t){if(!t)return;const e=Object.fromEntries(Object.entries(t).filter(([t,e])=>null!=e));return Object.keys(e).length>0?e:void 0}isSuccessResponse(t){return t.statusCode>=200&&t.statusCode<300}handleAuthResponse(t){if(this.isSuccessResponse(t)){this.token=t.body.token;const e=t.headers["x-lara-refresh-token"];return void(e&&(this.refreshToken=e))}throw this.createApiError(t)}createApiError(t){const e=t.body||{};return new s.LaraApiError(t.statusCode,e.type||"UnknownError",e.message||"An unknown error occurred")}async sign(t,e,r){if(!this.accessKey)throw new Error("Access key not provided for signing");const n=r["X-Lara-Date"].trim(),i=(r["Content-MD5"]||"").trim(),o=(r["Content-Type"]||"").trim(),s=`${(r["X-HTTP-Method-Override"]||t).trim().toUpperCase()}\n${e}\n${i}\n${o}\n${n}`;return this.crypto.hmac(this.accessKey.secret,s)}}},837(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.HttpClient=e.LaraClient=void 0,e.default=function(t,e,r,o){const s=new URL(e||n.DEFAULT_BASE_URL);if("https:"!==s.protocol&&"http:"!==s.protocol)throw new TypeError(`Invalid URL (protocol): ${s.protocol}`);const a={secure:"https:"===s.protocol,hostname:s.hostname,port:s.port?parseInt(s.port,10):"https:"===s.protocol?443:80};return new i.BrowserLaraClient(a,t,null==r||r,o)};const n=r(221),i=r(631);var o=r(412);Object.defineProperty(e,"LaraClient",{enumerable:!0,get:function(){return o.LaraClient}});var s=r(631);Object.defineProperty(e,"HttpClient",{enumerable:!0,get:function(){return s.BrowserClient}})},343(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.BrowserS3Client=void 0;const n=r(364);class i extends n.S3Client{async _upload(t,e,r){const n=new FormData;for(const[t,r]of Object.entries(e))n.append(t,r);n.append("file",r),await fetch(t,{method:"POST",body:n})}async download(t){return(await fetch(t)).blob()}async downloadStream(t){const e=await fetch(t);if(!e.body)throw new Error("Response body is null");return e.body}wrapMultiPartFile(t){if(t instanceof File)return t;throw new TypeError(`Invalid file input in the browser. Expected an instance of File but received ${typeof t}.`)}}e.BrowserS3Client=i},364(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.S3Client=void 0,e.S3Client=class{async upload(t,e,r,n){return this._upload(t,e,this.wrapMultiPartFile(r),n)}}},821(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(){return new n.BrowserS3Client};const n=r(343)},816(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.Styleguides=void 0;const n=r(725);e.Styleguides=class{constructor(t){this.client=t}async list(){return await this.client.get("/v2/styleguides")}async get(t){try{return await this.client.get(`/v2/styleguides/${t}`)}catch(t){if(t instanceof n.LaraApiError&&404===t.statusCode)return null;throw t}}async create(t,e){return await this.client.post("/v2/styleguides",{name:t,content:e})}async update(t,e,r){return await this.client.put(`/v2/styleguides/${t}`,{name:e,content:r})}async delete(t){return await this.client.delete(`/v2/styleguides/${t}`)}}},660(t,e,r){var n,i=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||(n=function(t){return n=Object.getOwnPropertyNames||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[e.length]=r);return e},n(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r=n(t),s=0;s<r.length;s++)"default"!==r[s]&&i(e,t,r[s]);return o(e,t),e});Object.defineProperty(e,"__esModule",{value:!0}),e.Translator=void 0;const a=r(328),l=r(50),u=r(514),c=r(731),d=r(629),h=s(r(837)),p=r(816),f=r(221),y=r(311);e.Translator=class{constructor(t,e){this.client=(0,h.default)(t,null==e?void 0:e.serverUrl,null==e?void 0:e.keepAlive,null==e?void 0:e.connectionTimeoutMs),this.memories=new d.Memories(this.client),this.documents=new l.Documents(this.client),this.glossaries=new u.Glossaries(this.client),this.styleguides=new p.Styleguides(this.client),this.audio=new a.AudioTranslator(this.client),this.images=new c.ImageTranslator(this.client)}get version(){return y.version}async getLanguages(){return await this.client.get("/v2/languages")}async translate(t,e,r,n,i){const o={};if(null==n?void 0:n.headers)for(const[t,e]of Object.entries(n.headers))o[t]=e;(null==n?void 0:n.noTrace)&&(o["X-No-Trace"]="true");const s=this.client.postAndGetStream("/v2/translate",{q:t,source:e,target:r,source_hint:null==n?void 0:n.sourceHint,content_type:null==n?void 0:n.contentType,multiline:!1!==(null==n?void 0:n.multiline),adapt_to:null==n?void 0:n.adaptTo,glossaries:null==n?void 0:n.glossaries,instructions:null==n?void 0:n.instructions,timeout:null==n?void 0:n.timeoutInMillis,priority:null==n?void 0:n.priority,use_cache:null==n?void 0:n.useCache,cache_ttl:null==n?void 0:n.cacheTTLSeconds,verbose:null==n?void 0:n.verbose,style:null==n?void 0:n.style,reasoning:null==n?void 0:n.reasoning,metadata:null==n?void 0:n.metadata,profanities_detect:null==n?void 0:n.profanitiesDetect,profanities_handling:null==n?void 0:n.profanitiesHandling,styleguide_id:null==n?void 0:n.styleguideId,styleguide_reasoning:null==n?void 0:n.styleguideReasoning,styleguide_explanation_language:null==n?void 0:n.styleguideExplanationLanguage},void 0,o);let a;for await(const t of s)(null==n?void 0:n.reasoning)&&i&&i(t),a=t;if(!a)throw new Error("No translation result received.");return a}async detect(t,e,r){return await this.client.post("/v2/detect/language",{q:t,hint:e,passlist:r})}async detectProfanities(t,e,r){return await this.client.post("/v2/detect/profanities",{text:t,language:e,content_type:r})}async qualityEstimation(t,e,r,n){return await this.client.post("/v2/detect/quality-estimation",{source:t,target:e,sentence:r,translation:n})}static async getLoginUrl(t){t||(t=f.DEFAULT_BASE_URL);const{body:e}=await h.HttpClient.get(`${t.replace(/\/+$/,"")}/v2/auth/login-page`);return e}}},221(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_BASE_URL=void 0,e.DEFAULT_BASE_URL="https://api.laratranslate.com"},741(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.parseContent=function t(e){if(null==e)return e;if(Array.isArray(e))return e.map(t);if("string"==typeof e)return e.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.[0-9]{3}Z$/)?new Date(e):e;if("object"==typeof e){const r={};for(const[n,i]of Object.entries(e))r[n.replace(/_([a-z])/g,(t,e)=>e.toUpperCase())]=t(i);return r}return e}},311(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.version=void 0,e.version="1.12.1"},841(t,e){Object.defineProperty(e,"__esModule",{value:!0});const r=t=>{if("string"==typeof t)return t;if(Array.isArray(t))return t.map(r);if("object"==typeof t&&null!==t){const e={};for(const[n,i]of Object.entries(t))e[n.replace(/([A-Z])/g,"_$1").toLowerCase()]=r(i);return e}return t};e.default=r}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,r),o.exports}var n={};return(()=>{var t=n;Object.defineProperty(t,"__esModule",{value:!0}),t.version=t.Translator=t.Styleguides=t.Memories=t.ImageTranslator=t.Glossaries=t.TimeoutError=t.LaraError=t.LaraApiError=t.Documents=t.DocumentStatus=t.Credentials=t.AuthToken=t.AccessKey=t.VoiceGender=t.AudioTranslator=t.AudioStatus=void 0;var e=r(328);Object.defineProperty(t,"AudioStatus",{enumerable:!0,get:function(){return e.AudioStatus}}),Object.defineProperty(t,"AudioTranslator",{enumerable:!0,get:function(){return e.AudioTranslator}}),Object.defineProperty(t,"VoiceGender",{enumerable:!0,get:function(){return e.VoiceGender}});var i=r(414);Object.defineProperty(t,"AccessKey",{enumerable:!0,get:function(){return i.AccessKey}}),Object.defineProperty(t,"AuthToken",{enumerable:!0,get:function(){return i.AuthToken}}),Object.defineProperty(t,"Credentials",{enumerable:!0,get:function(){return i.Credentials}});var o=r(50);Object.defineProperty(t,"DocumentStatus",{enumerable:!0,get:function(){return o.DocumentStatus}}),Object.defineProperty(t,"Documents",{enumerable:!0,get:function(){return o.Documents}});var s=r(725);Object.defineProperty(t,"LaraApiError",{enumerable:!0,get:function(){return s.LaraApiError}}),Object.defineProperty(t,"LaraError",{enumerable:!0,get:function(){return s.LaraError}}),Object.defineProperty(t,"TimeoutError",{enumerable:!0,get:function(){return s.TimeoutError}});var a=r(514);Object.defineProperty(t,"Glossaries",{enumerable:!0,get:function(){return a.Glossaries}});var l=r(731);Object.defineProperty(t,"ImageTranslator",{enumerable:!0,get:function(){return l.ImageTranslator}});var u=r(629);Object.defineProperty(t,"Memories",{enumerable:!0,get:function(){return u.Memories}});var c=r(816);Object.defineProperty(t,"Styleguides",{enumerable:!0,get:function(){return c.Styleguides}});var d=r(660);Object.defineProperty(t,"Translator",{enumerable:!0,get:function(){return d.Translator}});var h=r(311);Object.defineProperty(t,"version",{enumerable:!0,get:function(){return h.version}})})(),n})());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@translated/lara",
3
- "version": "1.11.1",
3
+ "version": "1.12.1",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "browser": "lib_browser/lara.min.js",