@shotstack/shotstack-canvas 2.0.13 → 2.0.14

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/dist/entry.web.js CHANGED
@@ -32091,7 +32091,10 @@ var _FontRegistry = class _FontRegistry {
32091
32091
  return;
32092
32092
  }
32093
32093
  try {
32094
- const canvasMod = { GlobalFonts: void 0 };
32094
+ const canvasMod = await import(
32095
+ /* @vite-ignore */
32096
+ "canvas"
32097
+ );
32095
32098
  const GlobalFonts = canvasMod.GlobalFonts;
32096
32099
  if (GlobalFonts && typeof GlobalFonts.register === "function") {
32097
32100
  const buffer = Buffer.from(bytes);
@@ -32153,6 +32156,862 @@ __publicField(_FontRegistry, "sharedInitPromise", null);
32153
32156
  __publicField(_FontRegistry, "fallbackLoader");
32154
32157
  var FontRegistry = _FontRegistry;
32155
32158
 
32159
+ // node_modules/.pnpm/bidi-js@1.0.3/node_modules/bidi-js/dist/bidi.mjs
32160
+ function bidiFactory() {
32161
+ var bidi = (function(exports) {
32162
+ var DATA = {
32163
+ "R": "13k,1a,2,3,3,2+1j,ch+16,a+1,5+2,2+n,5,a,4,6+16,4+3,h+1b,4mo,179q,2+9,2+11,2i9+7y,2+68,4,3+4,5+13,4+3,2+4k,3+29,8+cf,1t+7z,w+17,3+3m,1t+3z,16o1+5r,8+30,8+mc,29+1r,29+4v,75+73",
32164
+ "EN": "1c+9,3d+1,6,187+9,513,4+5,7+9,sf+j,175h+9,qw+q,161f+1d,4xt+a,25i+9",
32165
+ "ES": "17,2,6dp+1,f+1,av,16vr,mx+1,4o,2",
32166
+ "ET": "z+2,3h+3,b+1,ym,3e+1,2o,p4+1,8,6u,7c,g6,1wc,1n9+4,30+1b,2n,6d,qhx+1,h0m,a+1,49+2,63+1,4+1,6bb+3,12jj",
32167
+ "AN": "16o+5,2j+9,2+1,35,ed,1ff2+9,87+u",
32168
+ "CS": "18,2+1,b,2u,12k,55v,l,17v0,2,3,53,2+1,b",
32169
+ "B": "a,3,f+2,2v,690",
32170
+ "S": "9,2,k",
32171
+ "WS": "c,k,4f4,1vk+a,u,1j,335",
32172
+ "ON": "x+1,4+4,h+5,r+5,r+3,z,5+3,2+1,2+1,5,2+2,3+4,o,w,ci+1,8+d,3+d,6+8,2+g,39+1,9,6+1,2,33,b8,3+1,3c+1,7+1,5r,b,7h+3,sa+5,2,3i+6,jg+3,ur+9,2v,ij+1,9g+9,7+a,8m,4+1,49+x,14u,2+2,c+2,e+2,e+2,e+1,i+n,e+e,2+p,u+2,e+2,36+1,2+3,2+1,b,2+2,6+5,2,2,2,h+1,5+4,6+3,3+f,16+2,5+3l,3+81,1y+p,2+40,q+a,m+13,2r+ch,2+9e,75+hf,3+v,2+2w,6e+5,f+6,75+2a,1a+p,2+2g,d+5x,r+b,6+3,4+o,g,6+1,6+2,2k+1,4,2j,5h+z,1m+1,1e+f,t+2,1f+e,d+3,4o+3,2s+1,w,535+1r,h3l+1i,93+2,2s,b+1,3l+x,2v,4g+3,21+3,kz+1,g5v+1,5a,j+9,n+v,2,3,2+8,2+1,3+2,2,3,46+1,4+4,h+5,r+5,r+a,3h+2,4+6,b+4,78,1r+24,4+c,4,1hb,ey+6,103+j,16j+c,1ux+7,5+g,fsh,jdq+1t,4,57+2e,p1,1m,1m,1m,1m,4kt+1,7j+17,5+2r,d+e,3+e,2+e,2+10,m+4,w,1n+5,1q,4z+5,4b+rb,9+c,4+c,4+37,d+2g,8+b,l+b,5+1j,9+9,7+13,9+t,3+1,27+3c,2+29,2+3q,d+d,3+4,4+2,6+6,a+o,8+6,a+2,e+6,16+42,2+1i",
32173
+ "BN": "0+8,6+d,2s+5,2+p,e,4m9,1kt+2,2b+5,5+5,17q9+v,7k,6p+8,6+1,119d+3,440+7,96s+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+75,6p+2rz,1ben+1,1ekf+1,1ekf+1",
32174
+ "NSM": "lc+33,7o+6,7c+18,2,2+1,2+1,2,21+a,1d+k,h,2u+6,3+5,3+1,2+3,10,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,g+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+g,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c,2+6,5,7,4+1,5j+1l,2+4,k1+w,2db+2,3y,2p+v,ff+3,30+1,n9x+3,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,r2,6b,46+4,1af+2,2+1,6+3,15+2,5,4m+1,fy+3,as+1,4a+a,4x,1j+e,1l+2,1e+3,3+1,1y+2,11+4,2+7,1r,d+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+5,3+1,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2d+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,f0c+4,1o+6,t5,1s+3,2a,f5l+1,43t+2,i+7,3+6,v+3,45+2,1j0+1i,5+1d,9,f,n+4,2+e,11t+6,2+g,3+6,2+1,2+4,7a+6,c6+3,15t+6,32+6,gzhy+6n",
32175
+ "AL": "16w,3,2,e+1b,z+2,2+2s,g+1,8+1,b+m,2+t,s+2i,c+e,4h+f,1d+1e,1bwe+dp,3+3z,x+c,2+1,35+3y,2rm+z,5+7,b+5,dt+l,c+u,17nl+27,1t+27,4x+6n,3+d",
32176
+ "LRO": "6ct",
32177
+ "RLO": "6cu",
32178
+ "LRE": "6cq",
32179
+ "RLE": "6cr",
32180
+ "PDF": "6cs",
32181
+ "LRI": "6ee",
32182
+ "RLI": "6ef",
32183
+ "FSI": "6eg",
32184
+ "PDI": "6eh"
32185
+ };
32186
+ var TYPES = {};
32187
+ var TYPES_TO_NAMES = {};
32188
+ TYPES.L = 1;
32189
+ TYPES_TO_NAMES[1] = "L";
32190
+ Object.keys(DATA).forEach(function(type, i) {
32191
+ TYPES[type] = 1 << i + 1;
32192
+ TYPES_TO_NAMES[TYPES[type]] = type;
32193
+ });
32194
+ Object.freeze(TYPES);
32195
+ var ISOLATE_INIT_TYPES = TYPES.LRI | TYPES.RLI | TYPES.FSI;
32196
+ var STRONG_TYPES = TYPES.L | TYPES.R | TYPES.AL;
32197
+ var NEUTRAL_ISOLATE_TYPES = TYPES.B | TYPES.S | TYPES.WS | TYPES.ON | TYPES.FSI | TYPES.LRI | TYPES.RLI | TYPES.PDI;
32198
+ var BN_LIKE_TYPES = TYPES.BN | TYPES.RLE | TYPES.LRE | TYPES.RLO | TYPES.LRO | TYPES.PDF;
32199
+ var TRAILING_TYPES = TYPES.S | TYPES.WS | TYPES.B | ISOLATE_INIT_TYPES | TYPES.PDI | BN_LIKE_TYPES;
32200
+ var map2 = null;
32201
+ function parseData() {
32202
+ if (!map2) {
32203
+ map2 = /* @__PURE__ */ new Map();
32204
+ var loop = function(type2) {
32205
+ if (DATA.hasOwnProperty(type2)) {
32206
+ var lastCode = 0;
32207
+ DATA[type2].split(",").forEach(function(range) {
32208
+ var ref = range.split("+");
32209
+ var skip = ref[0];
32210
+ var step = ref[1];
32211
+ skip = parseInt(skip, 36);
32212
+ step = step ? parseInt(step, 36) : 0;
32213
+ map2.set(lastCode += skip, TYPES[type2]);
32214
+ for (var i = 0; i < step; i++) {
32215
+ map2.set(++lastCode, TYPES[type2]);
32216
+ }
32217
+ });
32218
+ }
32219
+ };
32220
+ for (var type in DATA) loop(type);
32221
+ }
32222
+ }
32223
+ function getBidiCharType(char) {
32224
+ parseData();
32225
+ return map2.get(char.codePointAt(0)) || TYPES.L;
32226
+ }
32227
+ function getBidiCharTypeName(char) {
32228
+ return TYPES_TO_NAMES[getBidiCharType(char)];
32229
+ }
32230
+ var data$1 = {
32231
+ "pairs": "14>1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,+2,1s>1,1>1,x>1,th>1,1>1,+2,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,4q>1,1e>2,u>2,2>1,+1",
32232
+ "canonical": "6f1>-6dx,6dy>-6dx,6ec>-6ed,6ee>-6ed,6ww>2jj,-2ji>2jj,14r4>-1e7l,1e7m>-1e7l,1e7m>-1e5c,1e5d>-1e5b,1e5c>-14qx,14qy>-14qx,14vn>-1ecg,1ech>-1ecg,1edu>-1ecg,1eci>-1ecg,1eda>-1ecg,1eci>-1ecg,1eci>-168q,168r>-168q,168s>-14ye,14yf>-14ye"
32233
+ };
32234
+ function parseCharacterMap(encodedString, includeReverse) {
32235
+ var radix = 36;
32236
+ var lastCode = 0;
32237
+ var map3 = /* @__PURE__ */ new Map();
32238
+ var reverseMap = includeReverse && /* @__PURE__ */ new Map();
32239
+ var prevPair;
32240
+ encodedString.split(",").forEach(function visit(entry) {
32241
+ if (entry.indexOf("+") !== -1) {
32242
+ for (var i = +entry; i--; ) {
32243
+ visit(prevPair);
32244
+ }
32245
+ } else {
32246
+ prevPair = entry;
32247
+ var ref = entry.split(">");
32248
+ var a = ref[0];
32249
+ var b = ref[1];
32250
+ a = String.fromCodePoint(lastCode += parseInt(a, radix));
32251
+ b = String.fromCodePoint(lastCode += parseInt(b, radix));
32252
+ map3.set(a, b);
32253
+ includeReverse && reverseMap.set(b, a);
32254
+ }
32255
+ });
32256
+ return { map: map3, reverseMap };
32257
+ }
32258
+ var openToClose, closeToOpen, canonical;
32259
+ function parse$1() {
32260
+ if (!openToClose) {
32261
+ var ref = parseCharacterMap(data$1.pairs, true);
32262
+ var map3 = ref.map;
32263
+ var reverseMap = ref.reverseMap;
32264
+ openToClose = map3;
32265
+ closeToOpen = reverseMap;
32266
+ canonical = parseCharacterMap(data$1.canonical, false).map;
32267
+ }
32268
+ }
32269
+ function openingToClosingBracket(char) {
32270
+ parse$1();
32271
+ return openToClose.get(char) || null;
32272
+ }
32273
+ function closingToOpeningBracket(char) {
32274
+ parse$1();
32275
+ return closeToOpen.get(char) || null;
32276
+ }
32277
+ function getCanonicalBracket(char) {
32278
+ parse$1();
32279
+ return canonical.get(char) || null;
32280
+ }
32281
+ var TYPE_L = TYPES.L;
32282
+ var TYPE_R = TYPES.R;
32283
+ var TYPE_EN = TYPES.EN;
32284
+ var TYPE_ES = TYPES.ES;
32285
+ var TYPE_ET = TYPES.ET;
32286
+ var TYPE_AN = TYPES.AN;
32287
+ var TYPE_CS = TYPES.CS;
32288
+ var TYPE_B = TYPES.B;
32289
+ var TYPE_S = TYPES.S;
32290
+ var TYPE_ON = TYPES.ON;
32291
+ var TYPE_BN = TYPES.BN;
32292
+ var TYPE_NSM = TYPES.NSM;
32293
+ var TYPE_AL = TYPES.AL;
32294
+ var TYPE_LRO = TYPES.LRO;
32295
+ var TYPE_RLO = TYPES.RLO;
32296
+ var TYPE_LRE = TYPES.LRE;
32297
+ var TYPE_RLE = TYPES.RLE;
32298
+ var TYPE_PDF = TYPES.PDF;
32299
+ var TYPE_LRI = TYPES.LRI;
32300
+ var TYPE_RLI = TYPES.RLI;
32301
+ var TYPE_FSI = TYPES.FSI;
32302
+ var TYPE_PDI = TYPES.PDI;
32303
+ function getEmbeddingLevels(string4, baseDirection) {
32304
+ var MAX_DEPTH = 125;
32305
+ var charTypes = new Uint32Array(string4.length);
32306
+ for (var i = 0; i < string4.length; i++) {
32307
+ charTypes[i] = getBidiCharType(string4[i]);
32308
+ }
32309
+ var charTypeCounts = /* @__PURE__ */ new Map();
32310
+ function changeCharType(i2, type2) {
32311
+ var oldType = charTypes[i2];
32312
+ charTypes[i2] = type2;
32313
+ charTypeCounts.set(oldType, charTypeCounts.get(oldType) - 1);
32314
+ if (oldType & NEUTRAL_ISOLATE_TYPES) {
32315
+ charTypeCounts.set(NEUTRAL_ISOLATE_TYPES, charTypeCounts.get(NEUTRAL_ISOLATE_TYPES) - 1);
32316
+ }
32317
+ charTypeCounts.set(type2, (charTypeCounts.get(type2) || 0) + 1);
32318
+ if (type2 & NEUTRAL_ISOLATE_TYPES) {
32319
+ charTypeCounts.set(NEUTRAL_ISOLATE_TYPES, (charTypeCounts.get(NEUTRAL_ISOLATE_TYPES) || 0) + 1);
32320
+ }
32321
+ }
32322
+ var embedLevels = new Uint8Array(string4.length);
32323
+ var isolationPairs = /* @__PURE__ */ new Map();
32324
+ var paragraphs = [];
32325
+ var paragraph = null;
32326
+ for (var i$1 = 0; i$1 < string4.length; i$1++) {
32327
+ if (!paragraph) {
32328
+ paragraphs.push(paragraph = {
32329
+ start: i$1,
32330
+ end: string4.length - 1,
32331
+ // 3.3.1 P2-P3: Determine the paragraph level
32332
+ level: baseDirection === "rtl" ? 1 : baseDirection === "ltr" ? 0 : determineAutoEmbedLevel(i$1, false)
32333
+ });
32334
+ }
32335
+ if (charTypes[i$1] & TYPE_B) {
32336
+ paragraph.end = i$1;
32337
+ paragraph = null;
32338
+ }
32339
+ }
32340
+ var FORMATTING_TYPES = TYPE_RLE | TYPE_LRE | TYPE_RLO | TYPE_LRO | ISOLATE_INIT_TYPES | TYPE_PDI | TYPE_PDF | TYPE_B;
32341
+ var nextEven = function(n) {
32342
+ return n + (n & 1 ? 1 : 2);
32343
+ };
32344
+ var nextOdd = function(n) {
32345
+ return n + (n & 1 ? 2 : 1);
32346
+ };
32347
+ for (var paraIdx = 0; paraIdx < paragraphs.length; paraIdx++) {
32348
+ paragraph = paragraphs[paraIdx];
32349
+ var statusStack = [{
32350
+ _level: paragraph.level,
32351
+ _override: 0,
32352
+ //0=neutral, 1=L, 2=R
32353
+ _isolate: 0
32354
+ //bool
32355
+ }];
32356
+ var stackTop = void 0;
32357
+ var overflowIsolateCount = 0;
32358
+ var overflowEmbeddingCount = 0;
32359
+ var validIsolateCount = 0;
32360
+ charTypeCounts.clear();
32361
+ for (var i$2 = paragraph.start; i$2 <= paragraph.end; i$2++) {
32362
+ var charType = charTypes[i$2];
32363
+ stackTop = statusStack[statusStack.length - 1];
32364
+ charTypeCounts.set(charType, (charTypeCounts.get(charType) || 0) + 1);
32365
+ if (charType & NEUTRAL_ISOLATE_TYPES) {
32366
+ charTypeCounts.set(NEUTRAL_ISOLATE_TYPES, (charTypeCounts.get(NEUTRAL_ISOLATE_TYPES) || 0) + 1);
32367
+ }
32368
+ if (charType & FORMATTING_TYPES) {
32369
+ if (charType & (TYPE_RLE | TYPE_LRE)) {
32370
+ embedLevels[i$2] = stackTop._level;
32371
+ var level = (charType === TYPE_RLE ? nextOdd : nextEven)(stackTop._level);
32372
+ if (level <= MAX_DEPTH && !overflowIsolateCount && !overflowEmbeddingCount) {
32373
+ statusStack.push({
32374
+ _level: level,
32375
+ _override: 0,
32376
+ _isolate: 0
32377
+ });
32378
+ } else if (!overflowIsolateCount) {
32379
+ overflowEmbeddingCount++;
32380
+ }
32381
+ } else if (charType & (TYPE_RLO | TYPE_LRO)) {
32382
+ embedLevels[i$2] = stackTop._level;
32383
+ var level$1 = (charType === TYPE_RLO ? nextOdd : nextEven)(stackTop._level);
32384
+ if (level$1 <= MAX_DEPTH && !overflowIsolateCount && !overflowEmbeddingCount) {
32385
+ statusStack.push({
32386
+ _level: level$1,
32387
+ _override: charType & TYPE_RLO ? TYPE_R : TYPE_L,
32388
+ _isolate: 0
32389
+ });
32390
+ } else if (!overflowIsolateCount) {
32391
+ overflowEmbeddingCount++;
32392
+ }
32393
+ } else if (charType & ISOLATE_INIT_TYPES) {
32394
+ if (charType & TYPE_FSI) {
32395
+ charType = determineAutoEmbedLevel(i$2 + 1, true) === 1 ? TYPE_RLI : TYPE_LRI;
32396
+ }
32397
+ embedLevels[i$2] = stackTop._level;
32398
+ if (stackTop._override) {
32399
+ changeCharType(i$2, stackTop._override);
32400
+ }
32401
+ var level$2 = (charType === TYPE_RLI ? nextOdd : nextEven)(stackTop._level);
32402
+ if (level$2 <= MAX_DEPTH && overflowIsolateCount === 0 && overflowEmbeddingCount === 0) {
32403
+ validIsolateCount++;
32404
+ statusStack.push({
32405
+ _level: level$2,
32406
+ _override: 0,
32407
+ _isolate: 1,
32408
+ _isolInitIndex: i$2
32409
+ });
32410
+ } else {
32411
+ overflowIsolateCount++;
32412
+ }
32413
+ } else if (charType & TYPE_PDI) {
32414
+ if (overflowIsolateCount > 0) {
32415
+ overflowIsolateCount--;
32416
+ } else if (validIsolateCount > 0) {
32417
+ overflowEmbeddingCount = 0;
32418
+ while (!statusStack[statusStack.length - 1]._isolate) {
32419
+ statusStack.pop();
32420
+ }
32421
+ var isolInitIndex = statusStack[statusStack.length - 1]._isolInitIndex;
32422
+ if (isolInitIndex != null) {
32423
+ isolationPairs.set(isolInitIndex, i$2);
32424
+ isolationPairs.set(i$2, isolInitIndex);
32425
+ }
32426
+ statusStack.pop();
32427
+ validIsolateCount--;
32428
+ }
32429
+ stackTop = statusStack[statusStack.length - 1];
32430
+ embedLevels[i$2] = stackTop._level;
32431
+ if (stackTop._override) {
32432
+ changeCharType(i$2, stackTop._override);
32433
+ }
32434
+ } else if (charType & TYPE_PDF) {
32435
+ if (overflowIsolateCount === 0) {
32436
+ if (overflowEmbeddingCount > 0) {
32437
+ overflowEmbeddingCount--;
32438
+ } else if (!stackTop._isolate && statusStack.length > 1) {
32439
+ statusStack.pop();
32440
+ stackTop = statusStack[statusStack.length - 1];
32441
+ }
32442
+ }
32443
+ embedLevels[i$2] = stackTop._level;
32444
+ } else if (charType & TYPE_B) {
32445
+ embedLevels[i$2] = paragraph.level;
32446
+ }
32447
+ } else {
32448
+ embedLevels[i$2] = stackTop._level;
32449
+ if (stackTop._override && charType !== TYPE_BN) {
32450
+ changeCharType(i$2, stackTop._override);
32451
+ }
32452
+ }
32453
+ }
32454
+ var levelRuns = [];
32455
+ var currentRun = null;
32456
+ for (var i$3 = paragraph.start; i$3 <= paragraph.end; i$3++) {
32457
+ var charType$1 = charTypes[i$3];
32458
+ if (!(charType$1 & BN_LIKE_TYPES)) {
32459
+ var lvl = embedLevels[i$3];
32460
+ var isIsolInit = charType$1 & ISOLATE_INIT_TYPES;
32461
+ var isPDI = charType$1 === TYPE_PDI;
32462
+ if (currentRun && lvl === currentRun._level) {
32463
+ currentRun._end = i$3;
32464
+ currentRun._endsWithIsolInit = isIsolInit;
32465
+ } else {
32466
+ levelRuns.push(currentRun = {
32467
+ _start: i$3,
32468
+ _end: i$3,
32469
+ _level: lvl,
32470
+ _startsWithPDI: isPDI,
32471
+ _endsWithIsolInit: isIsolInit
32472
+ });
32473
+ }
32474
+ }
32475
+ }
32476
+ var isolatingRunSeqs = [];
32477
+ for (var runIdx = 0; runIdx < levelRuns.length; runIdx++) {
32478
+ var run = levelRuns[runIdx];
32479
+ if (!run._startsWithPDI || run._startsWithPDI && !isolationPairs.has(run._start)) {
32480
+ var seqRuns = [currentRun = run];
32481
+ for (var pdiIndex = void 0; currentRun && currentRun._endsWithIsolInit && (pdiIndex = isolationPairs.get(currentRun._end)) != null; ) {
32482
+ for (var i$4 = runIdx + 1; i$4 < levelRuns.length; i$4++) {
32483
+ if (levelRuns[i$4]._start === pdiIndex) {
32484
+ seqRuns.push(currentRun = levelRuns[i$4]);
32485
+ break;
32486
+ }
32487
+ }
32488
+ }
32489
+ var seqIndices = [];
32490
+ for (var i$5 = 0; i$5 < seqRuns.length; i$5++) {
32491
+ var run$1 = seqRuns[i$5];
32492
+ for (var j = run$1._start; j <= run$1._end; j++) {
32493
+ seqIndices.push(j);
32494
+ }
32495
+ }
32496
+ var firstLevel = embedLevels[seqIndices[0]];
32497
+ var prevLevel = paragraph.level;
32498
+ for (var i$6 = seqIndices[0] - 1; i$6 >= 0; i$6--) {
32499
+ if (!(charTypes[i$6] & BN_LIKE_TYPES)) {
32500
+ prevLevel = embedLevels[i$6];
32501
+ break;
32502
+ }
32503
+ }
32504
+ var lastIndex = seqIndices[seqIndices.length - 1];
32505
+ var lastLevel = embedLevels[lastIndex];
32506
+ var nextLevel = paragraph.level;
32507
+ if (!(charTypes[lastIndex] & ISOLATE_INIT_TYPES)) {
32508
+ for (var i$7 = lastIndex + 1; i$7 <= paragraph.end; i$7++) {
32509
+ if (!(charTypes[i$7] & BN_LIKE_TYPES)) {
32510
+ nextLevel = embedLevels[i$7];
32511
+ break;
32512
+ }
32513
+ }
32514
+ }
32515
+ isolatingRunSeqs.push({
32516
+ _seqIndices: seqIndices,
32517
+ _sosType: Math.max(prevLevel, firstLevel) % 2 ? TYPE_R : TYPE_L,
32518
+ _eosType: Math.max(nextLevel, lastLevel) % 2 ? TYPE_R : TYPE_L
32519
+ });
32520
+ }
32521
+ }
32522
+ for (var seqIdx = 0; seqIdx < isolatingRunSeqs.length; seqIdx++) {
32523
+ var ref = isolatingRunSeqs[seqIdx];
32524
+ var seqIndices$1 = ref._seqIndices;
32525
+ var sosType = ref._sosType;
32526
+ var eosType = ref._eosType;
32527
+ var embedDirection = embedLevels[seqIndices$1[0]] & 1 ? TYPE_R : TYPE_L;
32528
+ if (charTypeCounts.get(TYPE_NSM)) {
32529
+ for (var si = 0; si < seqIndices$1.length; si++) {
32530
+ var i$8 = seqIndices$1[si];
32531
+ if (charTypes[i$8] & TYPE_NSM) {
32532
+ var prevType = sosType;
32533
+ for (var sj = si - 1; sj >= 0; sj--) {
32534
+ if (!(charTypes[seqIndices$1[sj]] & BN_LIKE_TYPES)) {
32535
+ prevType = charTypes[seqIndices$1[sj]];
32536
+ break;
32537
+ }
32538
+ }
32539
+ changeCharType(i$8, prevType & (ISOLATE_INIT_TYPES | TYPE_PDI) ? TYPE_ON : prevType);
32540
+ }
32541
+ }
32542
+ }
32543
+ if (charTypeCounts.get(TYPE_EN)) {
32544
+ for (var si$1 = 0; si$1 < seqIndices$1.length; si$1++) {
32545
+ var i$9 = seqIndices$1[si$1];
32546
+ if (charTypes[i$9] & TYPE_EN) {
32547
+ for (var sj$1 = si$1 - 1; sj$1 >= -1; sj$1--) {
32548
+ var prevCharType = sj$1 === -1 ? sosType : charTypes[seqIndices$1[sj$1]];
32549
+ if (prevCharType & STRONG_TYPES) {
32550
+ if (prevCharType === TYPE_AL) {
32551
+ changeCharType(i$9, TYPE_AN);
32552
+ }
32553
+ break;
32554
+ }
32555
+ }
32556
+ }
32557
+ }
32558
+ }
32559
+ if (charTypeCounts.get(TYPE_AL)) {
32560
+ for (var si$2 = 0; si$2 < seqIndices$1.length; si$2++) {
32561
+ var i$10 = seqIndices$1[si$2];
32562
+ if (charTypes[i$10] & TYPE_AL) {
32563
+ changeCharType(i$10, TYPE_R);
32564
+ }
32565
+ }
32566
+ }
32567
+ if (charTypeCounts.get(TYPE_ES) || charTypeCounts.get(TYPE_CS)) {
32568
+ for (var si$3 = 1; si$3 < seqIndices$1.length - 1; si$3++) {
32569
+ var i$11 = seqIndices$1[si$3];
32570
+ if (charTypes[i$11] & (TYPE_ES | TYPE_CS)) {
32571
+ var prevType$1 = 0, nextType = 0;
32572
+ for (var sj$2 = si$3 - 1; sj$2 >= 0; sj$2--) {
32573
+ prevType$1 = charTypes[seqIndices$1[sj$2]];
32574
+ if (!(prevType$1 & BN_LIKE_TYPES)) {
32575
+ break;
32576
+ }
32577
+ }
32578
+ for (var sj$3 = si$3 + 1; sj$3 < seqIndices$1.length; sj$3++) {
32579
+ nextType = charTypes[seqIndices$1[sj$3]];
32580
+ if (!(nextType & BN_LIKE_TYPES)) {
32581
+ break;
32582
+ }
32583
+ }
32584
+ if (prevType$1 === nextType && (charTypes[i$11] === TYPE_ES ? prevType$1 === TYPE_EN : prevType$1 & (TYPE_EN | TYPE_AN))) {
32585
+ changeCharType(i$11, prevType$1);
32586
+ }
32587
+ }
32588
+ }
32589
+ }
32590
+ if (charTypeCounts.get(TYPE_EN)) {
32591
+ for (var si$4 = 0; si$4 < seqIndices$1.length; si$4++) {
32592
+ var i$12 = seqIndices$1[si$4];
32593
+ if (charTypes[i$12] & TYPE_EN) {
32594
+ for (var sj$4 = si$4 - 1; sj$4 >= 0 && charTypes[seqIndices$1[sj$4]] & (TYPE_ET | BN_LIKE_TYPES); sj$4--) {
32595
+ changeCharType(seqIndices$1[sj$4], TYPE_EN);
32596
+ }
32597
+ for (si$4++; si$4 < seqIndices$1.length && charTypes[seqIndices$1[si$4]] & (TYPE_ET | BN_LIKE_TYPES | TYPE_EN); si$4++) {
32598
+ if (charTypes[seqIndices$1[si$4]] !== TYPE_EN) {
32599
+ changeCharType(seqIndices$1[si$4], TYPE_EN);
32600
+ }
32601
+ }
32602
+ }
32603
+ }
32604
+ }
32605
+ if (charTypeCounts.get(TYPE_ET) || charTypeCounts.get(TYPE_ES) || charTypeCounts.get(TYPE_CS)) {
32606
+ for (var si$5 = 0; si$5 < seqIndices$1.length; si$5++) {
32607
+ var i$13 = seqIndices$1[si$5];
32608
+ if (charTypes[i$13] & (TYPE_ET | TYPE_ES | TYPE_CS)) {
32609
+ changeCharType(i$13, TYPE_ON);
32610
+ for (var sj$5 = si$5 - 1; sj$5 >= 0 && charTypes[seqIndices$1[sj$5]] & BN_LIKE_TYPES; sj$5--) {
32611
+ changeCharType(seqIndices$1[sj$5], TYPE_ON);
32612
+ }
32613
+ for (var sj$6 = si$5 + 1; sj$6 < seqIndices$1.length && charTypes[seqIndices$1[sj$6]] & BN_LIKE_TYPES; sj$6++) {
32614
+ changeCharType(seqIndices$1[sj$6], TYPE_ON);
32615
+ }
32616
+ }
32617
+ }
32618
+ }
32619
+ if (charTypeCounts.get(TYPE_EN)) {
32620
+ for (var si$6 = 0, prevStrongType = sosType; si$6 < seqIndices$1.length; si$6++) {
32621
+ var i$14 = seqIndices$1[si$6];
32622
+ var type = charTypes[i$14];
32623
+ if (type & TYPE_EN) {
32624
+ if (prevStrongType === TYPE_L) {
32625
+ changeCharType(i$14, TYPE_L);
32626
+ }
32627
+ } else if (type & STRONG_TYPES) {
32628
+ prevStrongType = type;
32629
+ }
32630
+ }
32631
+ }
32632
+ if (charTypeCounts.get(NEUTRAL_ISOLATE_TYPES)) {
32633
+ var R_TYPES_FOR_N_STEPS = TYPE_R | TYPE_EN | TYPE_AN;
32634
+ var STRONG_TYPES_FOR_N_STEPS = R_TYPES_FOR_N_STEPS | TYPE_L;
32635
+ var bracketPairs = [];
32636
+ {
32637
+ var openerStack = [];
32638
+ for (var si$7 = 0; si$7 < seqIndices$1.length; si$7++) {
32639
+ if (charTypes[seqIndices$1[si$7]] & NEUTRAL_ISOLATE_TYPES) {
32640
+ var char = string4[seqIndices$1[si$7]];
32641
+ var oppositeBracket = void 0;
32642
+ if (openingToClosingBracket(char) !== null) {
32643
+ if (openerStack.length < 63) {
32644
+ openerStack.push({ char, seqIndex: si$7 });
32645
+ } else {
32646
+ break;
32647
+ }
32648
+ } else if ((oppositeBracket = closingToOpeningBracket(char)) !== null) {
32649
+ for (var stackIdx = openerStack.length - 1; stackIdx >= 0; stackIdx--) {
32650
+ var stackChar = openerStack[stackIdx].char;
32651
+ if (stackChar === oppositeBracket || stackChar === closingToOpeningBracket(getCanonicalBracket(char)) || openingToClosingBracket(getCanonicalBracket(stackChar)) === char) {
32652
+ bracketPairs.push([openerStack[stackIdx].seqIndex, si$7]);
32653
+ openerStack.length = stackIdx;
32654
+ break;
32655
+ }
32656
+ }
32657
+ }
32658
+ }
32659
+ }
32660
+ bracketPairs.sort(function(a, b) {
32661
+ return a[0] - b[0];
32662
+ });
32663
+ }
32664
+ for (var pairIdx = 0; pairIdx < bracketPairs.length; pairIdx++) {
32665
+ var ref$1 = bracketPairs[pairIdx];
32666
+ var openSeqIdx = ref$1[0];
32667
+ var closeSeqIdx = ref$1[1];
32668
+ var foundStrongType = false;
32669
+ var useStrongType = 0;
32670
+ for (var si$8 = openSeqIdx + 1; si$8 < closeSeqIdx; si$8++) {
32671
+ var i$15 = seqIndices$1[si$8];
32672
+ if (charTypes[i$15] & STRONG_TYPES_FOR_N_STEPS) {
32673
+ foundStrongType = true;
32674
+ var lr = charTypes[i$15] & R_TYPES_FOR_N_STEPS ? TYPE_R : TYPE_L;
32675
+ if (lr === embedDirection) {
32676
+ useStrongType = lr;
32677
+ break;
32678
+ }
32679
+ }
32680
+ }
32681
+ if (foundStrongType && !useStrongType) {
32682
+ useStrongType = sosType;
32683
+ for (var si$9 = openSeqIdx - 1; si$9 >= 0; si$9--) {
32684
+ var i$16 = seqIndices$1[si$9];
32685
+ if (charTypes[i$16] & STRONG_TYPES_FOR_N_STEPS) {
32686
+ var lr$1 = charTypes[i$16] & R_TYPES_FOR_N_STEPS ? TYPE_R : TYPE_L;
32687
+ if (lr$1 !== embedDirection) {
32688
+ useStrongType = lr$1;
32689
+ } else {
32690
+ useStrongType = embedDirection;
32691
+ }
32692
+ break;
32693
+ }
32694
+ }
32695
+ }
32696
+ if (useStrongType) {
32697
+ charTypes[seqIndices$1[openSeqIdx]] = charTypes[seqIndices$1[closeSeqIdx]] = useStrongType;
32698
+ if (useStrongType !== embedDirection) {
32699
+ for (var si$10 = openSeqIdx + 1; si$10 < seqIndices$1.length; si$10++) {
32700
+ if (!(charTypes[seqIndices$1[si$10]] & BN_LIKE_TYPES)) {
32701
+ if (getBidiCharType(string4[seqIndices$1[si$10]]) & TYPE_NSM) {
32702
+ charTypes[seqIndices$1[si$10]] = useStrongType;
32703
+ }
32704
+ break;
32705
+ }
32706
+ }
32707
+ }
32708
+ if (useStrongType !== embedDirection) {
32709
+ for (var si$11 = closeSeqIdx + 1; si$11 < seqIndices$1.length; si$11++) {
32710
+ if (!(charTypes[seqIndices$1[si$11]] & BN_LIKE_TYPES)) {
32711
+ if (getBidiCharType(string4[seqIndices$1[si$11]]) & TYPE_NSM) {
32712
+ charTypes[seqIndices$1[si$11]] = useStrongType;
32713
+ }
32714
+ break;
32715
+ }
32716
+ }
32717
+ }
32718
+ }
32719
+ }
32720
+ for (var si$12 = 0; si$12 < seqIndices$1.length; si$12++) {
32721
+ if (charTypes[seqIndices$1[si$12]] & NEUTRAL_ISOLATE_TYPES) {
32722
+ var niRunStart = si$12, niRunEnd = si$12;
32723
+ var prevType$2 = sosType;
32724
+ for (var si2 = si$12 - 1; si2 >= 0; si2--) {
32725
+ if (charTypes[seqIndices$1[si2]] & BN_LIKE_TYPES) {
32726
+ niRunStart = si2;
32727
+ } else {
32728
+ prevType$2 = charTypes[seqIndices$1[si2]] & R_TYPES_FOR_N_STEPS ? TYPE_R : TYPE_L;
32729
+ break;
32730
+ }
32731
+ }
32732
+ var nextType$1 = eosType;
32733
+ for (var si2$1 = si$12 + 1; si2$1 < seqIndices$1.length; si2$1++) {
32734
+ if (charTypes[seqIndices$1[si2$1]] & (NEUTRAL_ISOLATE_TYPES | BN_LIKE_TYPES)) {
32735
+ niRunEnd = si2$1;
32736
+ } else {
32737
+ nextType$1 = charTypes[seqIndices$1[si2$1]] & R_TYPES_FOR_N_STEPS ? TYPE_R : TYPE_L;
32738
+ break;
32739
+ }
32740
+ }
32741
+ for (var sj$7 = niRunStart; sj$7 <= niRunEnd; sj$7++) {
32742
+ charTypes[seqIndices$1[sj$7]] = prevType$2 === nextType$1 ? prevType$2 : embedDirection;
32743
+ }
32744
+ si$12 = niRunEnd;
32745
+ }
32746
+ }
32747
+ }
32748
+ }
32749
+ for (var i$17 = paragraph.start; i$17 <= paragraph.end; i$17++) {
32750
+ var level$3 = embedLevels[i$17];
32751
+ var type$1 = charTypes[i$17];
32752
+ if (level$3 & 1) {
32753
+ if (type$1 & (TYPE_L | TYPE_EN | TYPE_AN)) {
32754
+ embedLevels[i$17]++;
32755
+ }
32756
+ } else {
32757
+ if (type$1 & TYPE_R) {
32758
+ embedLevels[i$17]++;
32759
+ } else if (type$1 & (TYPE_AN | TYPE_EN)) {
32760
+ embedLevels[i$17] += 2;
32761
+ }
32762
+ }
32763
+ if (type$1 & BN_LIKE_TYPES) {
32764
+ embedLevels[i$17] = i$17 === 0 ? paragraph.level : embedLevels[i$17 - 1];
32765
+ }
32766
+ if (i$17 === paragraph.end || getBidiCharType(string4[i$17]) & (TYPE_S | TYPE_B)) {
32767
+ for (var j$1 = i$17; j$1 >= 0 && getBidiCharType(string4[j$1]) & TRAILING_TYPES; j$1--) {
32768
+ embedLevels[j$1] = paragraph.level;
32769
+ }
32770
+ }
32771
+ }
32772
+ }
32773
+ return {
32774
+ levels: embedLevels,
32775
+ paragraphs
32776
+ };
32777
+ function determineAutoEmbedLevel(start, isFSI) {
32778
+ for (var i2 = start; i2 < string4.length; i2++) {
32779
+ var charType2 = charTypes[i2];
32780
+ if (charType2 & (TYPE_R | TYPE_AL)) {
32781
+ return 1;
32782
+ }
32783
+ if (charType2 & (TYPE_B | TYPE_L) || isFSI && charType2 === TYPE_PDI) {
32784
+ return 0;
32785
+ }
32786
+ if (charType2 & ISOLATE_INIT_TYPES) {
32787
+ var pdi = indexOfMatchingPDI(i2);
32788
+ i2 = pdi === -1 ? string4.length : pdi;
32789
+ }
32790
+ }
32791
+ return 0;
32792
+ }
32793
+ function indexOfMatchingPDI(isolateStart) {
32794
+ var isolationLevel = 1;
32795
+ for (var i2 = isolateStart + 1; i2 < string4.length; i2++) {
32796
+ var charType2 = charTypes[i2];
32797
+ if (charType2 & TYPE_B) {
32798
+ break;
32799
+ }
32800
+ if (charType2 & TYPE_PDI) {
32801
+ if (--isolationLevel === 0) {
32802
+ return i2;
32803
+ }
32804
+ } else if (charType2 & ISOLATE_INIT_TYPES) {
32805
+ isolationLevel++;
32806
+ }
32807
+ }
32808
+ return -1;
32809
+ }
32810
+ }
32811
+ var data = "14>1,j>2,t>2,u>2,1a>g,2v3>1,1>1,1ge>1,1wd>1,b>1,1j>1,f>1,ai>3,-2>3,+1,8>1k0,-1jq>1y7,-1y6>1hf,-1he>1h6,-1h5>1ha,-1h8>1qi,-1pu>1,6>3u,-3s>7,6>1,1>1,f>1,1>1,+2,3>1,1>1,+13,4>1,1>1,6>1eo,-1ee>1,3>1mg,-1me>1mk,-1mj>1mi,-1mg>1mi,-1md>1,1>1,+2,1>10k,-103>1,1>1,4>1,5>1,1>1,+10,3>1,1>8,-7>8,+1,-6>7,+1,a>1,1>1,u>1,u6>1,1>1,+5,26>1,1>1,2>1,2>2,8>1,7>1,4>1,1>1,+5,b8>1,1>1,+3,1>3,-2>1,2>1,1>1,+2,c>1,3>1,1>1,+2,h>1,3>1,a>1,1>1,2>1,3>1,1>1,d>1,f>1,3>1,1a>1,1>1,6>1,7>1,13>1,k>1,1>1,+19,4>1,1>1,+2,2>1,1>1,+18,m>1,a>1,1>1,lk>1,1>1,4>1,2>1,f>1,3>1,1>1,+3,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,6>1,4j>1,j>2,t>2,u>2,2>1,+1";
32812
+ var mirrorMap;
32813
+ function parse3() {
32814
+ if (!mirrorMap) {
32815
+ var ref = parseCharacterMap(data, true);
32816
+ var map3 = ref.map;
32817
+ var reverseMap = ref.reverseMap;
32818
+ reverseMap.forEach(function(value, key) {
32819
+ map3.set(key, value);
32820
+ });
32821
+ mirrorMap = map3;
32822
+ }
32823
+ }
32824
+ function getMirroredCharacter(char) {
32825
+ parse3();
32826
+ return mirrorMap.get(char) || null;
32827
+ }
32828
+ function getMirroredCharactersMap(string4, embeddingLevels, start, end) {
32829
+ var strLen = string4.length;
32830
+ start = Math.max(0, start == null ? 0 : +start);
32831
+ end = Math.min(strLen - 1, end == null ? strLen - 1 : +end);
32832
+ var map3 = /* @__PURE__ */ new Map();
32833
+ for (var i = start; i <= end; i++) {
32834
+ if (embeddingLevels[i] & 1) {
32835
+ var mirror = getMirroredCharacter(string4[i]);
32836
+ if (mirror !== null) {
32837
+ map3.set(i, mirror);
32838
+ }
32839
+ }
32840
+ }
32841
+ return map3;
32842
+ }
32843
+ function getReorderSegments(string4, embeddingLevelsResult, start, end) {
32844
+ var strLen = string4.length;
32845
+ start = Math.max(0, start == null ? 0 : +start);
32846
+ end = Math.min(strLen - 1, end == null ? strLen - 1 : +end);
32847
+ var segments = [];
32848
+ embeddingLevelsResult.paragraphs.forEach(function(paragraph) {
32849
+ var lineStart = Math.max(start, paragraph.start);
32850
+ var lineEnd = Math.min(end, paragraph.end);
32851
+ if (lineStart < lineEnd) {
32852
+ var lineLevels = embeddingLevelsResult.levels.slice(lineStart, lineEnd + 1);
32853
+ for (var i = lineEnd; i >= lineStart && getBidiCharType(string4[i]) & TRAILING_TYPES; i--) {
32854
+ lineLevels[i] = paragraph.level;
32855
+ }
32856
+ var maxLevel = paragraph.level;
32857
+ var minOddLevel = Infinity;
32858
+ for (var i$1 = 0; i$1 < lineLevels.length; i$1++) {
32859
+ var level = lineLevels[i$1];
32860
+ if (level > maxLevel) {
32861
+ maxLevel = level;
32862
+ }
32863
+ if (level < minOddLevel) {
32864
+ minOddLevel = level | 1;
32865
+ }
32866
+ }
32867
+ for (var lvl = maxLevel; lvl >= minOddLevel; lvl--) {
32868
+ for (var i$2 = 0; i$2 < lineLevels.length; i$2++) {
32869
+ if (lineLevels[i$2] >= lvl) {
32870
+ var segStart = i$2;
32871
+ while (i$2 + 1 < lineLevels.length && lineLevels[i$2 + 1] >= lvl) {
32872
+ i$2++;
32873
+ }
32874
+ if (i$2 > segStart) {
32875
+ segments.push([segStart + lineStart, i$2 + lineStart]);
32876
+ }
32877
+ }
32878
+ }
32879
+ }
32880
+ }
32881
+ });
32882
+ return segments;
32883
+ }
32884
+ function getReorderedString(string4, embedLevelsResult, start, end) {
32885
+ var indices = getReorderedIndices(string4, embedLevelsResult, start, end);
32886
+ var chars = [].concat(string4);
32887
+ indices.forEach(function(charIndex, i) {
32888
+ chars[i] = (embedLevelsResult.levels[charIndex] & 1 ? getMirroredCharacter(string4[charIndex]) : null) || string4[charIndex];
32889
+ });
32890
+ return chars.join("");
32891
+ }
32892
+ function getReorderedIndices(string4, embedLevelsResult, start, end) {
32893
+ var segments = getReorderSegments(string4, embedLevelsResult, start, end);
32894
+ var indices = [];
32895
+ for (var i = 0; i < string4.length; i++) {
32896
+ indices[i] = i;
32897
+ }
32898
+ segments.forEach(function(ref) {
32899
+ var start2 = ref[0];
32900
+ var end2 = ref[1];
32901
+ var slice = indices.slice(start2, end2 + 1);
32902
+ for (var i2 = slice.length; i2--; ) {
32903
+ indices[end2 - i2] = slice[i2];
32904
+ }
32905
+ });
32906
+ return indices;
32907
+ }
32908
+ exports.closingToOpeningBracket = closingToOpeningBracket;
32909
+ exports.getBidiCharType = getBidiCharType;
32910
+ exports.getBidiCharTypeName = getBidiCharTypeName;
32911
+ exports.getCanonicalBracket = getCanonicalBracket;
32912
+ exports.getEmbeddingLevels = getEmbeddingLevels;
32913
+ exports.getMirroredCharacter = getMirroredCharacter;
32914
+ exports.getMirroredCharactersMap = getMirroredCharactersMap;
32915
+ exports.getReorderSegments = getReorderSegments;
32916
+ exports.getReorderedIndices = getReorderedIndices;
32917
+ exports.getReorderedString = getReorderedString;
32918
+ exports.openingToClosingBracket = openingToClosingBracket;
32919
+ Object.defineProperty(exports, "__esModule", { value: true });
32920
+ return exports;
32921
+ })({});
32922
+ return bidi;
32923
+ }
32924
+ var bidi_default = bidiFactory;
32925
+
32926
+ // src/core/bidi.ts
32927
+ var bidiInstance = null;
32928
+ function getBidi() {
32929
+ if (!bidiInstance) {
32930
+ bidiInstance = bidi_default();
32931
+ }
32932
+ return bidiInstance;
32933
+ }
32934
+ var RTL_SCRIPT_REGEX = /[֐-׿؀-ۿ܀-ݏݐ-ݿހ-޿߀-߿ࠀ-࠿ࡀ-࡟ࡠ-࡯ࢠ-ࣿיִ-ﭏﭐ-﷿ﹰ-𐴀-𐴿𐹠-𐹿𞠀-𞣟𞤀-𞥟𞱰-𞲿𞴀-𞵏𞸀-𞻿]/u;
32935
+ function containsRTLCharacters(text) {
32936
+ return RTL_SCRIPT_REGEX.test(text);
32937
+ }
32938
+ function detectParagraphDirection(text) {
32939
+ const bidi = getBidi();
32940
+ const { paragraphs } = bidi.getEmbeddingLevels(text);
32941
+ if (paragraphs.length === 0) {
32942
+ return "ltr";
32943
+ }
32944
+ return paragraphs[0].level % 2 === 1 ? "rtl" : "ltr";
32945
+ }
32946
+ function detectParagraphDirectionFromWords(words) {
32947
+ const combined = words.join(" ");
32948
+ return detectParagraphDirection(combined);
32949
+ }
32950
+ function reorderWordsForLine(wordTexts, paragraphDirection) {
32951
+ if (wordTexts.length <= 1) {
32952
+ return wordTexts.map((_, i) => i);
32953
+ }
32954
+ const lineText = wordTexts.join(" ");
32955
+ const bidi = getBidi();
32956
+ const { levels } = bidi.getEmbeddingLevels(lineText, paragraphDirection);
32957
+ const wordLevels = [];
32958
+ let charIndex = 0;
32959
+ for (let i = 0; i < wordTexts.length; i++) {
32960
+ const wordLevel = levels[charIndex];
32961
+ wordLevels.push(wordLevel);
32962
+ charIndex += wordTexts[i].length;
32963
+ if (i < wordTexts.length - 1) {
32964
+ charIndex += 1;
32965
+ }
32966
+ }
32967
+ const indices = wordTexts.map((_, i) => i);
32968
+ const maxLevel = Math.max(...wordLevels);
32969
+ const minOddLevel = paragraphDirection === "rtl" ? 1 : Math.min(...wordLevels.filter((l) => l % 2 === 1), maxLevel + 1);
32970
+ for (let level = maxLevel; level >= minOddLevel; level--) {
32971
+ let start = 0;
32972
+ while (start < indices.length) {
32973
+ if (wordLevels[indices[start]] >= level) {
32974
+ let end = start;
32975
+ while (end + 1 < indices.length && wordLevels[indices[end + 1]] >= level) {
32976
+ end++;
32977
+ }
32978
+ if (start < end) {
32979
+ let left = start;
32980
+ let right = end;
32981
+ while (left < right) {
32982
+ const tmp = indices[left];
32983
+ indices[left] = indices[right];
32984
+ indices[right] = tmp;
32985
+ left++;
32986
+ right--;
32987
+ }
32988
+ }
32989
+ start = end + 1;
32990
+ } else {
32991
+ start++;
32992
+ }
32993
+ }
32994
+ }
32995
+ return indices;
32996
+ }
32997
+ function getVisibleText(text, visibleCharacters, isRTL) {
32998
+ if (visibleCharacters < 0 || visibleCharacters >= text.length) {
32999
+ return text;
33000
+ }
33001
+ if (visibleCharacters === 0) {
33002
+ return "";
33003
+ }
33004
+ return text.slice(0, visibleCharacters);
33005
+ }
33006
+ function mirrorAnimationDirection(direction, isRTL) {
33007
+ if (!isRTL) {
33008
+ return direction;
33009
+ }
33010
+ if (direction === "left") return "right";
33011
+ if (direction === "right") return "left";
33012
+ return direction;
33013
+ }
33014
+
32156
33015
  // src/core/layout.ts
32157
33016
  function isEmoji(char) {
32158
33017
  const code = char.codePointAt(0);
@@ -32182,7 +33041,7 @@ var LayoutEngine = class {
32182
33041
  return t;
32183
33042
  }
32184
33043
  }
32185
- async shapeFull(text, desc) {
33044
+ async shapeFull(text, desc, direction) {
32186
33045
  try {
32187
33046
  const hb = await this.fonts.getHB();
32188
33047
  const buffer = hb.createBuffer();
@@ -32221,7 +33080,8 @@ var LayoutEngine = class {
32221
33080
  let shaped;
32222
33081
  try {
32223
33082
  if (!emojiFallback) {
32224
- shaped = await this.shapeFull(input, desc);
33083
+ const textDirection = containsRTLCharacters(input) ? "rtl" : void 0;
33084
+ shaped = await this.shapeFull(input, desc, textDirection);
32225
33085
  } else {
32226
33086
  const chars = Array.from(input);
32227
33087
  const runs = [];
@@ -32242,7 +33102,8 @@ var LayoutEngine = class {
32242
33102
  shaped = [];
32243
33103
  for (const run of runs) {
32244
33104
  const runFont = run.isEmoji ? emojiFallback : desc;
32245
- const runShaped = await this.shapeFull(run.text, runFont);
33105
+ const runDirection = containsRTLCharacters(run.text) ? "rtl" : void 0;
33106
+ const runShaped = await this.shapeFull(run.text, runFont, runDirection);
32246
33107
  for (const glyph of runShaped) {
32247
33108
  glyph.cl += run.startIndex;
32248
33109
  glyph.fontDesc = runFont;
@@ -32343,9 +33204,11 @@ var LayoutEngine = class {
32343
33204
  y: 0
32344
33205
  });
32345
33206
  }
33207
+ const textIsRTL = containsRTLCharacters(input);
32346
33208
  const lineHeight = params.lineHeight * fontSize;
32347
33209
  for (let i = 0; i < lines.length; i++) {
32348
33210
  lines[i].y = (i + 1) * lineHeight;
33211
+ lines[i].isRTL = textIsRTL;
32349
33212
  }
32350
33213
  return lines;
32351
33214
  } catch (err) {
@@ -32384,6 +33247,14 @@ function normalizePadding(padding) {
32384
33247
  }
32385
33248
  return padding;
32386
33249
  }
33250
+ function resolveHorizontalAlign(align, isRTL) {
33251
+ if (!isRTL || align === "center") {
33252
+ return align;
33253
+ }
33254
+ if (align === "left") return "right";
33255
+ if (align === "right") return "left";
33256
+ return align;
33257
+ }
32387
33258
  async function buildDrawOps(p) {
32388
33259
  const ops = [];
32389
33260
  const padding = normalizePadding(p.padding);
@@ -32424,7 +33295,8 @@ async function buildDrawOps(p) {
32424
33295
  let gMinX = Infinity, gMinY = Infinity, gMaxX = -Infinity, gMaxY = -Infinity;
32425
33296
  for (const line of p.lines) {
32426
33297
  let lineX;
32427
- switch (p.align.horizontal) {
33298
+ const effectiveAlign = resolveHorizontalAlign(p.align.horizontal, line.isRTL);
33299
+ switch (effectiveAlign) {
32428
33300
  case "left":
32429
33301
  lineX = 0;
32430
33302
  break;
@@ -32552,7 +33424,7 @@ async function buildDrawOps(p) {
32552
33424
  const contentWidth = p.contentRect?.width ?? p.canvas.width;
32553
33425
  const contentHeight = p.contentRect?.height ?? p.canvas.height;
32554
33426
  const borderWidth2 = p.border?.width ?? 0;
32555
- const borderRadius = p.border?.radius ?? 0;
33427
+ const borderRadius = p.border?.radius ?? p.background?.borderRadius ?? 0;
32556
33428
  const halfBorder = borderWidth2 / 2;
32557
33429
  const canvasCenterX = p.canvas.width / 2;
32558
33430
  const canvasCenterY = p.canvas.height / 2;
@@ -32670,7 +33542,15 @@ function applyAnimation(ops, lines, p) {
32670
33542
  case "fadeIn":
32671
33543
  return applyFadeInAnimation(ops, lines, progress, p.anim.style, p.fontSize, duration3);
32672
33544
  case "slideIn":
32673
- return applySlideInAnimation(ops, lines, progress, p.anim.direction ?? "left", p.fontSize, p.anim.style, duration3);
33545
+ return applySlideInAnimation(
33546
+ ops,
33547
+ lines,
33548
+ progress,
33549
+ p.anim.direction ?? "left",
33550
+ p.fontSize,
33551
+ p.anim.style,
33552
+ duration3
33553
+ );
32674
33554
  case "shift":
32675
33555
  return applyShiftAnimation(
32676
33556
  ops,
@@ -32698,6 +33578,9 @@ function applyAnimation(ops, lines, p) {
32698
33578
  }
32699
33579
  var isShadowFill = (op) => op.op === "FillPath" && op.isShadow === true;
32700
33580
  var isGlyphFill = (op) => op.op === "FillPath" && !op.isShadow === true;
33581
+ function isRTLLines(lines) {
33582
+ return lines.length > 0 && lines[0].isRTL === true;
33583
+ }
32701
33584
  function getTextColorFromOps(ops) {
32702
33585
  for (const op of ops) {
32703
33586
  if (op.op === "FillPath") {
@@ -32717,28 +33600,32 @@ function applyTypewriterAnimation(ops, lines, progress, style, fontSize, time3,
32717
33600
  const totalWords = wordSegments.length;
32718
33601
  const visibleWords = Math.floor(progress * totalWords);
32719
33602
  if (visibleWords === 0) {
32720
- return ops.filter((x2) => x2.op === "BeginFrame" || x2.op === "Rectangle" || x2.op === "RectangleStroke");
33603
+ return ops.filter(
33604
+ (x2) => x2.op === "BeginFrame" || x2.op === "Rectangle" || x2.op === "RectangleStroke"
33605
+ );
32721
33606
  }
32722
33607
  let totalVisibleGlyphs = 0;
32723
33608
  for (let i = 0; i < Math.min(visibleWords, wordSegments.length); i++) {
32724
33609
  totalVisibleGlyphs += wordSegments[i].glyphCount;
32725
33610
  }
32726
- const visibleOpsRaw = sliceGlyphOps(ops, totalVisibleGlyphs);
33611
+ const visibleOpsRaw = isRTLLines(lines) ? sliceGlyphOpsFromEnd(ops, totalVisibleGlyphs) : sliceGlyphOps(ops, totalVisibleGlyphs);
32727
33612
  const visibleOps = progress >= DECORATION_DONE_THRESHOLD ? visibleOpsRaw : visibleOpsRaw.filter((o) => o.op !== "DecorationLine");
32728
33613
  if (progress < 1 && totalVisibleGlyphs > 0) {
32729
- return addTypewriterCursor(visibleOps, totalVisibleGlyphs, fontSize, time3);
33614
+ return addTypewriterCursor(visibleOps, totalVisibleGlyphs, fontSize, time3, isRTLLines(lines));
32730
33615
  }
32731
33616
  return visibleOps;
32732
33617
  } else {
32733
33618
  const totalGlyphs = lines.reduce((s, l) => s + l.glyphs.length, 0);
32734
33619
  const visibleGlyphs = Math.floor(progress * totalGlyphs);
32735
33620
  if (visibleGlyphs === 0) {
32736
- return ops.filter((x2) => x2.op === "BeginFrame" || x2.op === "Rectangle" || x2.op === "RectangleStroke");
33621
+ return ops.filter(
33622
+ (x2) => x2.op === "BeginFrame" || x2.op === "Rectangle" || x2.op === "RectangleStroke"
33623
+ );
32737
33624
  }
32738
- const visibleOpsRaw = sliceGlyphOps(ops, visibleGlyphs);
33625
+ const visibleOpsRaw = isRTLLines(lines) ? sliceGlyphOpsFromEnd(ops, visibleGlyphs) : sliceGlyphOps(ops, visibleGlyphs);
32739
33626
  const visibleOps = progress >= DECORATION_DONE_THRESHOLD ? visibleOpsRaw : visibleOpsRaw.filter((o) => o.op !== "DecorationLine");
32740
33627
  if (progress < 1 && visibleGlyphs > 0) {
32741
- return addTypewriterCursor(visibleOps, visibleGlyphs, fontSize, time3);
33628
+ return addTypewriterCursor(visibleOps, visibleGlyphs, fontSize, time3, isRTLLines(lines));
32742
33629
  }
32743
33630
  return visibleOps;
32744
33631
  }
@@ -32769,7 +33656,8 @@ function applyAscendAnimation(ops, lines, progress, direction, fontSize, duratio
32769
33656
  acc += gcount;
32770
33657
  }
32771
33658
  if (wordIndex >= 0) {
32772
- const startF = wordIndex / Math.max(1, totalWords) * (duration3 / duration3);
33659
+ const effectiveWordIndex = isRTLLines(lines) ? Math.max(0, totalWords - 1 - wordIndex) : wordIndex;
33660
+ const startF = effectiveWordIndex / Math.max(1, totalWords) * (duration3 / duration3);
32773
33661
  const endF = Math.min(1, startF + 0.3);
32774
33662
  if (progress >= endF) {
32775
33663
  result.push(op);
@@ -32849,7 +33737,8 @@ function applyShiftAnimation(ops, lines, progress, direction, fontSize, style, d
32849
33737
  }
32850
33738
  unitIndex = Math.max(0, wordIndex);
32851
33739
  }
32852
- const { startF, endF } = windowFor(unitIndex);
33740
+ const effectiveUnit = isRTLLines(lines) ? Math.max(0, totalUnits - 1 - unitIndex) : unitIndex;
33741
+ const { startF, endF } = windowFor(effectiveUnit);
32853
33742
  if (progress <= startF) {
32854
33743
  const animated = { ...op, x: op.x + offset.x, y: op.y + offset.y };
32855
33744
  if (op.op === "FillPath") {
@@ -32930,7 +33819,8 @@ function applyFadeInAnimation(ops, lines, progress, style, fontSize, duration3)
32930
33819
  }
32931
33820
  unitIndex = Math.max(0, wordIndex);
32932
33821
  }
32933
- const { startF, endF } = windowFor(unitIndex);
33822
+ const effectiveUnit = isRTLLines(lines) ? Math.max(0, totalUnits - 1 - unitIndex) : unitIndex;
33823
+ const { startF, endF } = windowFor(effectiveUnit);
32934
33824
  if (progress <= startF) {
32935
33825
  const animated = { ...op };
32936
33826
  if (op.op === "FillPath") {
@@ -33017,7 +33907,8 @@ function applySlideInAnimation(ops, lines, progress, direction, fontSize, style,
33017
33907
  }
33018
33908
  unitIndex = Math.max(0, wordIndex);
33019
33909
  }
33020
- const { startF, endF } = windowFor(unitIndex);
33910
+ const effectiveUnit = isRTLLines(lines) ? Math.max(0, totalUnits - 1 - unitIndex) : unitIndex;
33911
+ const { startF, endF } = windowFor(effectiveUnit);
33021
33912
  if (progress <= startF) {
33022
33913
  const animated = { ...op, x: op.x + offset.x, y: op.y + offset.y };
33023
33914
  if (op.op === "FillPath") {
@@ -33084,6 +33975,43 @@ function segmentLineBySpaces(line) {
33084
33975
  if (current.length) words.push(current);
33085
33976
  return words;
33086
33977
  }
33978
+ function sliceGlyphOpsFromEnd(ops, maxGlyphs) {
33979
+ let totalGlyphs = 0;
33980
+ for (const op of ops) {
33981
+ if (op.op === "FillPath" && !isShadowFill(op)) totalGlyphs++;
33982
+ }
33983
+ const skipCount = Math.max(0, totalGlyphs - maxGlyphs);
33984
+ const result = [];
33985
+ let glyphCount = 0;
33986
+ let foundGlyphs = false;
33987
+ for (const op of ops) {
33988
+ if (op.op === "BeginFrame" || op.op === "Rectangle" || op.op === "RectangleStroke") {
33989
+ result.push(op);
33990
+ continue;
33991
+ }
33992
+ if (op.op === "FillPath" && !isShadowFill(op)) {
33993
+ if (glyphCount >= skipCount) {
33994
+ result.push(op);
33995
+ foundGlyphs = true;
33996
+ }
33997
+ glyphCount++;
33998
+ continue;
33999
+ }
34000
+ if (op.op === "StrokePath") {
34001
+ if (glyphCount >= skipCount) result.push(op);
34002
+ continue;
34003
+ }
34004
+ if (op.op === "FillPath" && isShadowFill(op)) {
34005
+ if (glyphCount >= skipCount) result.push(op);
34006
+ continue;
34007
+ }
34008
+ if (op.op === "DecorationLine" && foundGlyphs) {
34009
+ result.push(op);
34010
+ continue;
34011
+ }
34012
+ }
34013
+ return result;
34014
+ }
33087
34015
  function sliceGlyphOps(ops, maxGlyphs) {
33088
34016
  const result = [];
33089
34017
  let glyphCount = 0;
@@ -33116,27 +34044,30 @@ function sliceGlyphOps(ops, maxGlyphs) {
33116
34044
  }
33117
34045
  return result;
33118
34046
  }
33119
- function addTypewriterCursor(ops, glyphCount, fontSize, time3) {
34047
+ function addTypewriterCursor(ops, glyphCount, fontSize, time3, isRTL = false) {
33120
34048
  if (glyphCount === 0) return ops;
33121
34049
  const blinkRate = 1;
33122
34050
  const cursorVisible = Math.floor(time3 * blinkRate * 2) % 2 === 0;
33123
34051
  const alwaysShowCursor = true;
33124
34052
  if (!alwaysShowCursor && !cursorVisible) return ops;
33125
34053
  let last = null;
34054
+ let first = null;
33126
34055
  let count = 0;
33127
34056
  for (const op of ops) {
33128
34057
  if (op.op === "FillPath" && !isShadowFill(op)) {
33129
34058
  count++;
34059
+ if (count === 1) first = op;
33130
34060
  if (count === glyphCount) {
33131
34061
  last = op;
33132
34062
  break;
33133
34063
  }
33134
34064
  }
33135
34065
  }
33136
- if (last && last.op === "FillPath") {
34066
+ const cursorAnchor = isRTL && first ? first : last;
34067
+ if (cursorAnchor && cursorAnchor.op === "FillPath") {
33137
34068
  const color = getTextColorFromOps(ops);
33138
- const cursorX = last.x + fontSize * 0.5;
33139
- const cursorY = last.y;
34069
+ const cursorX = isRTL && first ? first.x - fontSize * 0.15 : cursorAnchor.x + fontSize * 0.5;
34070
+ const cursorY = cursorAnchor.y;
33140
34071
  const cursorWidth = Math.max(3, fontSize / 15);
33141
34072
  const cursorOp = {
33142
34073
  op: "DecorationLine",
@@ -33496,7 +34427,7 @@ function calculateNoneState(ctx) {
33496
34427
  isActive: isWordActive(ctx)
33497
34428
  };
33498
34429
  }
33499
- function calculateWordAnimationState(wordStart, wordEnd, currentTime, config2, activeScale = 1, charCount = 0, fontSize = 48) {
34430
+ function calculateWordAnimationState(wordStart, wordEnd, currentTime, config2, activeScale = 1, charCount = 0, fontSize = 48, isRTL = false) {
33500
34431
  const safeSpeed = config2.speed > 0 ? config2.speed : 1;
33501
34432
  const ctx = {
33502
34433
  wordStart,
@@ -33519,9 +34450,11 @@ function calculateWordAnimationState(wordStart, wordEnd, currentTime, config2, a
33519
34450
  case "fade":
33520
34451
  partialState = calculateFadeState(ctx, safeSpeed);
33521
34452
  break;
33522
- case "slide":
33523
- partialState = calculateSlideState(ctx, config2.direction, safeSpeed, fontSize);
34453
+ case "slide": {
34454
+ const slideDir = mirrorAnimationDirection(config2.direction, isRTL);
34455
+ partialState = calculateSlideState(ctx, slideDir, config2.speed, fontSize);
33524
34456
  break;
34457
+ }
33525
34458
  case "bounce":
33526
34459
  partialState = calculateBounceState(ctx, safeSpeed, fontSize);
33527
34460
  break;
@@ -33549,7 +34482,8 @@ function calculateAnimationStatesForGroup(words, currentTime, config2, activeSca
33549
34482
  config2,
33550
34483
  activeScale,
33551
34484
  word.text.length,
33552
- fontSize
34485
+ fontSize,
34486
+ word.isRTL
33553
34487
  );
33554
34488
  states.set(word.wordIndex, state);
33555
34489
  }
@@ -33693,7 +34627,7 @@ function extractActiveScale(asset) {
33693
34627
  }
33694
34628
  function createDrawCaptionWordOp(word, animState, asset, fontConfig) {
33695
34629
  const isActive = animState.isActive;
33696
- const displayText = animState.visibleCharacters >= 0 && animState.visibleCharacters < word.text.length ? word.text.slice(0, animState.visibleCharacters) : word.text;
34630
+ const displayText = getVisibleText(word.text, animState.visibleCharacters, word.isRTL);
33697
34631
  return {
33698
34632
  op: "DrawCaptionWord",
33699
34633
  text: displayText,
@@ -34081,7 +35015,7 @@ function createWebPainter(canvas) {
34081
35015
  }
34082
35016
  for (const wordOp of captionWordOps) {
34083
35017
  if (!wordOp.background) continue;
34084
- const wordDisplayText = wordOp.visibleCharacters >= 0 && wordOp.visibleCharacters < wordOp.text.length ? wordOp.text.slice(0, wordOp.visibleCharacters) : wordOp.text;
35018
+ const wordDisplayText = getVisibleText(wordOp.text, wordOp.visibleCharacters, wordOp.isRTL);
34085
35019
  if (wordDisplayText.length === 0) continue;
34086
35020
  ctx.save();
34087
35021
  const bgTx = Math.round(wordOp.x + wordOp.transform.translateX);
@@ -34113,7 +35047,7 @@ function createWebPainter(canvas) {
34113
35047
  ctx.restore();
34114
35048
  }
34115
35049
  for (const wordOp of captionWordOps) {
34116
- const displayText = wordOp.visibleCharacters >= 0 && wordOp.visibleCharacters < wordOp.text.length ? wordOp.text.slice(0, wordOp.visibleCharacters) : wordOp.text;
35050
+ const displayText = getVisibleText(wordOp.text, wordOp.visibleCharacters, wordOp.isRTL);
34117
35051
  if (displayText.length === 0) continue;
34118
35052
  ctx.save();
34119
35053
  const tx = Math.round(wordOp.x + wordOp.transform.translateX);
@@ -35985,9 +36919,8 @@ var L = (_c = class {
35985
36919
  }, _c);
35986
36920
 
35987
36921
  // src/core/rich-caption-layout.ts
35988
- var RTL_RANGES = /[\u0590-\u05FF\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/;
35989
36922
  function isRTLText(text) {
35990
- return RTL_RANGES.test(text);
36923
+ return containsRTLCharacters(text);
35991
36924
  }
35992
36925
  var WordTimingStore = class {
35993
36926
  constructor(words) {
@@ -36246,6 +37179,8 @@ var CaptionLayoutEngine = class {
36246
37179
  return (config2.frameHeight - totalHeight) / 2 + config2.fontSize;
36247
37180
  }
36248
37181
  };
37182
+ const allWordTexts = store.words.slice(0, store.length);
37183
+ const paragraphDirection = detectParagraphDirectionFromWords(allWordTexts);
36249
37184
  const calculateLineX = (lineWidth) => {
36250
37185
  switch (config2.horizontalAlign) {
36251
37186
  case "left":
@@ -36263,8 +37198,11 @@ var CaptionLayoutEngine = class {
36263
37198
  const line = group.lines[lineIdx];
36264
37199
  line.x = calculateLineX(line.width);
36265
37200
  line.y = baseY + lineIdx * config2.fontSize * config2.lineHeight;
37201
+ const lineWordTexts = line.wordIndices.map((idx) => store.words[idx]);
37202
+ const visualOrder = reorderWordsForLine(lineWordTexts, paragraphDirection);
36266
37203
  let xCursor = line.x;
36267
- for (const wordIdx of line.wordIndices) {
37204
+ for (const visualIdx of visualOrder) {
37205
+ const wordIdx = line.wordIndices[visualIdx];
36268
37206
  store.xPositions[wordIdx] = xCursor;
36269
37207
  store.yPositions[wordIdx] = line.y;
36270
37208
  xCursor += store.widths[wordIdx] + spaceWidth;
@@ -36274,7 +37212,8 @@ var CaptionLayoutEngine = class {
36274
37212
  return {
36275
37213
  store,
36276
37214
  groups,
36277
- shapedWords
37215
+ shapedWords,
37216
+ paragraphDirection
36278
37217
  };
36279
37218
  }
36280
37219
  getVisibleWordsAtTime(layout, timeMs) {
@@ -37106,7 +38045,7 @@ async function createTextEngine(opts = {}) {
37106
38045
  horizontal: asset.align?.horizontal ?? "center",
37107
38046
  vertical: asset.align?.vertical ?? "middle"
37108
38047
  },
37109
- background: asset.background,
38048
+ background: asset.background ? { color: asset.background.color, opacity: asset.background.opacity, borderRadius: typeof asset.background.borderRadius === "number" ? asset.background.borderRadius : Number(asset.background.borderRadius) || 0 } : void 0,
37110
38049
  border: asset.border,
37111
38050
  padding: asset.padding,
37112
38051
  glyphPathProvider: (gid, fontDesc) => fonts.glyphPath(fontDesc || desc, gid),
@@ -37181,6 +38120,7 @@ export {
37181
38120
  calculateAnimationStatesForGroup,
37182
38121
  commandsToPathString,
37183
38122
  computeSimplePathBounds,
38123
+ containsRTLCharacters,
37184
38124
  createDefaultGeneratorConfig,
37185
38125
  createFrameSchedule,
37186
38126
  createMediaRecorderFallback,
@@ -37188,6 +38128,8 @@ export {
37188
38128
  createVideoEncoder,
37189
38129
  createWebCodecsEncoder,
37190
38130
  createWebPainter,
38131
+ detectParagraphDirection,
38132
+ detectParagraphDirectionFromWords,
37191
38133
  detectPlatform,
37192
38134
  detectSubtitleFormat,
37193
38135
  extractCaptionPadding,
@@ -37199,12 +38141,14 @@ export {
37199
38141
  getDrawCaptionWordOps,
37200
38142
  getEncoderCapabilities,
37201
38143
  getEncoderWarning,
38144
+ getVisibleText,
37202
38145
  groupWordsByPause,
37203
38146
  initResvg,
37204
38147
  isDrawCaptionWordOp,
37205
38148
  isMediaRecorderSupported,
37206
38149
  isRTLText,
37207
38150
  isWebCodecsH264Supported,
38151
+ mirrorAnimationDirection,
37208
38152
  normalizePath,
37209
38153
  normalizePathString,
37210
38154
  parseSubtitleToWords,
@@ -37212,6 +38156,7 @@ export {
37212
38156
  quadraticToCubic,
37213
38157
  renderSvgAssetToPng,
37214
38158
  renderSvgToPng,
38159
+ reorderWordsForLine,
37215
38160
  richCaptionAssetSchema,
37216
38161
  shapeToSvgString,
37217
38162
  svgAssetSchema,