@carddb/browser 0.3.0 → 0.4.0

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.
@@ -1,4 +1,4 @@
1
- var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardDBError",this.response=r,Error.captureStackTrace&&Error.captureStackTrace(this,re);}},B=class extends y{constructor(e="Invalid or missing API key",t){super(e,t),this.name="AuthenticationError";}},q=class extends y{retryAfter;limit;remaining;resetAt;constructor(e="Rate limit exceeded",t={}){super(e,t.response),this.name="RateLimitError",this.retryAfter=t.retryAfter??null,this.limit=t.limit??null,this.remaining=t.remaining??null,this.resetAt=t.resetAt??null;}},mt=class extends y{constructor(e="Resource not found",t){super(e,t),this.name="NotFoundError";}},V=class extends y{errors;constructor(e="Validation error",t={}){super(e,t.response),this.name="ValidationError",this.errors=t.errors??[];}},b=class extends y{constructor(e,t){super(e,t),this.name="RestrictedError";}},se=class extends y{errors;constructor(e="GraphQL error",t={}){super(e,t.response),this.name="GraphQLError",this.errors=t.errors??[];}},E=class extends y{constructor(e="Connection error",t){super(e,t),this.name="ConnectionError";}},_=class extends E{constructor(e="Request timed out",t){super(e,t),this.name="TimeoutError";}},J=class extends y{status;constructor(e="Server error",t={}){super(e,t.response),this.name="ServerError",this.status=t.status??null;}},gt=class extends y{failures;partialResults;constructor(e="Some links could not be resolved",t={}){super(e,t.response),this.name="LinkResolutionError",this.failures=t.failures??[],this.partialResults=t.partialResults;}getFailuresForField(e){return this.failures.filter(t=>t.field===e)}hasFailuresForField(e){return this.failures.some(t=>t.field===e)}};function kt(e){return {eq:e}}function It(e){return {neq:e}}function $t(e){return {gt:e}}function bt(e){return {gte:e}}function Dt(e){return {lt:e}}function vt(e){return {lte:e}}function wt(e){return {in:e}}function At(e){return {nin:e}}function Et(e){return {contains:e}}function St(e){return {like:e}}function xt(e){return {ilike:e}}function Rt(){return {is_null:true}}function qt(){return {is_null:false}}var be=class ie{conditions=[];orGroups=[];where(t,r){if(typeof t=="string")this.conditions.push({[t]:r});else for(let[s,i]of Object.entries(t))this.conditions.push({[s]:i});return this}any(t){let r=new ie;t(r);let s=r.getConditions();return s.length>0&&this.orGroups.push({$or:s}),this}whereLink(t,r){let s={};for(let[i,n]of Object.entries(r))s[i]=n;return this.conditions.push({[`${t}._link`]:s}),this}whereAny(t,r){let s={};for(let[i,n]of Object.entries(r))s[i]=n;return this.conditions.push({[`${t}._any`]:s}),this}getConditions(){return this.conditions}build(){let t=[...this.conditions,...this.orGroups];return t.length===0?{}:t.length===1?t[0]:{$and:t}}};function C(e){if(e!==void 0){if(typeof e=="function"){let t=new be;e(t);let r=t.build();return Object.keys(r).length>0?r:void 0}return Object.keys(e).length>0?e:void 0}}var S=`
1
+ var y=class ae extends Error{response;constructor(t,r){super(t),this.name="CardDBError",this.response=r,Error.captureStackTrace&&Error.captureStackTrace(this,ae);}},M=class extends y{constructor(e="Invalid or missing API key",t){super(e,t),this.name="AuthenticationError";}},K=class extends y{retryAfter;limit;remaining;resetAt;constructor(e="Rate limit exceeded",t={}){super(e,t.response),this.name="RateLimitError",this.retryAfter=t.retryAfter??null,this.limit=t.limit??null,this.remaining=t.remaining??null,this.resetAt=t.resetAt??null;}},Bt=class extends y{constructor(e="Resource not found",t){super(e,t),this.name="NotFoundError";}},J=class extends y{errors;constructor(e="Validation error",t={}){super(e,t.response),this.name="ValidationError",this.errors=t.errors??[];}},$=class extends y{constructor(e,t){super(e,t),this.name="RestrictedError";}},ne=class extends y{errors;constructor(e="GraphQL error",t={}){super(e,t.response),this.name="GraphQLError",this.errors=t.errors??[];}},E=class extends y{constructor(e="Connection error",t){super(e,t),this.name="ConnectionError";}},G=class extends E{constructor(e="Request timed out",t){super(e,t),this.name="TimeoutError";}},O=class extends y{status;constructor(e="Server error",t={}){super(e,t.response),this.name="ServerError",this.status=t.status??null;}},Mt=class extends y{failures;partialResults;constructor(e="Some links could not be resolved",t={}){super(e,t.response),this.name="LinkResolutionError",this.failures=t.failures??[],this.partialResults=t.partialResults;}getFailuresForField(e){return this.failures.filter(t=>t.field===e)}hasFailuresForField(e){return this.failures.some(t=>t.field===e)}};function Jt(e){return {eq:e}}function Gt(e){return {neq:e}}function Ot(e){return {gt:e}}function Nt(e){return {gte:e}}function jt(e){return {lt:e}}function Ht(e){return {lte:e}}function Yt(e){return {in:e}}function zt(e){return {nin:e}}function Wt(e){return {contains:e}}function Xt(e){return {like:e}}function Qt(e){return {ilike:e}}function Zt(){return {is_null:true}}function er(){return {is_null:false}}var Se=class ce{conditions=[];orGroups=[];where(t,r){if(typeof t=="string")this.conditions.push({[t]:r});else for(let[s,i]of Object.entries(t))this.conditions.push({[s]:i});return this}any(t){let r=new ce;t(r);let s=r.getConditions();return s.length>0&&this.orGroups.push({$or:s}),this}whereLink(t,r){let s={};for(let[i,n]of Object.entries(r))s[i]=n;return this.conditions.push({[`${t}._link`]:s}),this}whereAny(t,r){let s={};for(let[i,n]of Object.entries(r))s[i]=n;return this.conditions.push({[`${t}._any`]:s}),this}getConditions(){return this.conditions}build(){let t=[...this.conditions,...this.orGroups];return t.length===0?{}:t.length===1?t[0]:{$and:t}}};function F(e){if(e!==void 0){if(typeof e=="function"){let t=new Se;e(t);let r=t.build();return Object.keys(r).length>0?r:void 0}return Object.keys(e).length>0?e:void 0}}var q=`
2
2
  id
3
3
  createdAt
4
4
  updatedAt
@@ -11,9 +11,9 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
11
11
  entityType
12
12
  entityId
13
13
  url
14
- `,De=`
14
+ `,Ae=`
15
15
  file {
16
- ${S}
16
+ ${q}
17
17
  }
18
18
  uploadUrl
19
19
  expiresAt
@@ -34,7 +34,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
34
34
  id
35
35
  url
36
36
  }
37
- `,f=`
37
+ `,p=`
38
38
  id
39
39
  publisherId
40
40
  key
@@ -60,7 +60,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
60
60
  id
61
61
  url
62
62
  }
63
- `,p=`
63
+ `,m=`
64
64
  id
65
65
  publisherId
66
66
  gameId
@@ -88,7 +88,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
88
88
  key
89
89
  name
90
90
  }
91
- `,ve=4;function ae(e){return `
91
+ `,Ee=4;function oe(e){return `
92
92
  key
93
93
  label
94
94
  description
@@ -121,12 +121,12 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
121
121
  isUnique
122
122
  ${e>0?`
123
123
  nestedFields {
124
- ${ae(e-1)}
124
+ ${oe(e-1)}
125
125
  }`:""}
126
- `}var v=`
126
+ `}var D=`
127
127
  schema {
128
128
  fields {
129
- ${ae(ve)}
129
+ ${oe(Ee)}
130
130
  }
131
131
  filterableFields
132
132
  searchableFields
@@ -142,7 +142,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
142
142
  isArray
143
143
  }
144
144
  }
145
- `,ne=`
145
+ `,ue=`
146
146
  id
147
147
  objectTypeId
148
148
  key
@@ -176,7 +176,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
176
176
  parentFieldId
177
177
  createdAt
178
178
  updatedAt
179
- `,we=`
179
+ `,xe=`
180
180
  pricing {
181
181
  productId
182
182
  prices {
@@ -192,7 +192,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
192
192
  id
193
193
  datasetId
194
194
  data
195
- ${e.includePricing?we:""}
195
+ ${e.includePricing?xe:""}
196
196
  createdAt
197
197
  updatedAt
198
198
  dataset {
@@ -202,7 +202,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
202
202
  gameId
203
203
  publisherId
204
204
  }
205
- `}var A=k(),O=`
205
+ `}var A=k(),N=`
206
206
  key
207
207
  label
208
208
  description
@@ -214,7 +214,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
214
214
  excludedFromDeckSize
215
215
  legalCardTypes
216
216
  metadata
217
- `,T=`
217
+ `,U=`
218
218
  id
219
219
  datasetId
220
220
  recordId
@@ -227,7 +227,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
227
227
  record {
228
228
  ${A}
229
229
  }
230
- `,ce=`
230
+ `,le=`
231
231
  rulesetId
232
232
  rulesetVersionId
233
233
  rulesetVersionLabel
@@ -235,7 +235,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
235
235
  cardDatasetVersionId
236
236
  validatedAt
237
237
  validationResultSummary
238
- `,x=`
238
+ `,R=`
239
239
  code
240
240
  severity
241
241
  message
@@ -244,14 +244,14 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
244
244
  datasetId
245
245
  identifier
246
246
  metadata
247
- `,G=`
247
+ `,j=`
248
248
  deckId
249
249
  valid
250
250
  blockers {
251
- ${x}
251
+ ${R}
252
252
  }
253
253
  warnings {
254
- ${x}
254
+ ${R}
255
255
  }
256
256
  affectedEntries {
257
257
  entryId
@@ -262,17 +262,17 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
262
262
  quantity
263
263
  }
264
264
  validatedAgainst {
265
- ${ce}
265
+ ${le}
266
266
  }
267
267
  checkedAt
268
- `,W=`
268
+ `,Q=`
269
269
  deckId
270
270
  fromVersionId
271
271
  toVersionId
272
272
  toDraftRevision
273
273
  hasChanges
274
274
  diff
275
- `,R=`
275
+ `,C=`
276
276
  id
277
277
  deckId
278
278
  versionNumber
@@ -294,18 +294,18 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
294
294
  validatedAt
295
295
  validationSummary
296
296
  validatedAgainst {
297
- ${ce}
297
+ ${le}
298
298
  }
299
299
  sectionDefinitions {
300
- ${O}
300
+ ${N}
301
301
  }
302
302
  publishedByAccountId
303
303
  publishedByApiApplicationId
304
304
  createdAt
305
305
  entries {
306
- ${T}
306
+ ${U}
307
307
  }
308
- `,Q=`
308
+ `,Z=`
309
309
  id
310
310
  deckId
311
311
  accountId
@@ -313,7 +313,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
313
313
  createdByAccountId
314
314
  createdAt
315
315
  updatedAt
316
- `,z=`
316
+ `,ee=`
317
317
  id
318
318
  deckId
319
319
  label
@@ -322,7 +322,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
322
322
  lastUsedAt
323
323
  createdAt
324
324
  updatedAt
325
- `,Z=`
325
+ `,te=`
326
326
  id
327
327
  deckId
328
328
  apiApplicationId
@@ -335,7 +335,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
335
335
  lastUsedAt
336
336
  createdAt
337
337
  updatedAt
338
- `,K=`
338
+ `,P=`
339
339
  id
340
340
  deckId
341
341
  apiApplicationId
@@ -349,7 +349,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
349
349
  revokedAt
350
350
  createdAt
351
351
  updatedAt
352
- `,Ae=`
352
+ `,Te=`
353
353
  id
354
354
  deckId
355
355
  apiApplicationId
@@ -361,7 +361,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
361
361
  lastUsedAt
362
362
  createdAt
363
363
  updatedAt
364
- `,M=`
364
+ `,H=`
365
365
  lineNumber
366
366
  raw
367
367
  datasetKey
@@ -375,12 +375,12 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
375
375
  record {
376
376
  ${A}
377
377
  }
378
- `,oe=`
378
+ `,de=`
379
379
  lineNumber
380
380
  raw
381
381
  code
382
382
  message
383
- `,N=`
383
+ `,Y=`
384
384
  lineNumber
385
385
  raw
386
386
  datasetKey
@@ -389,7 +389,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
389
389
  section
390
390
  code
391
391
  message
392
- `,j=`
392
+ `,z=`
393
393
  lineNumber
394
394
  raw
395
395
  datasetKey
@@ -415,39 +415,39 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
415
415
  isArchived
416
416
  createdAt
417
417
  updatedAt
418
- `,ue=`
418
+ `,he=`
419
419
  formatId
420
420
  key
421
421
  name
422
422
  confidence
423
423
  reason
424
- `,Ee=`
424
+ `,qe=`
425
425
  detection {
426
- ${ue}
426
+ ${he}
427
427
  }
428
428
  entries {
429
- ${M}
429
+ ${H}
430
430
  }
431
431
  parseErrors {
432
- ${oe}
432
+ ${de}
433
433
  }
434
434
  unmatched {
435
- ${N}
435
+ ${Y}
436
436
  }
437
437
  ambiguous {
438
- ${j}
438
+ ${z}
439
439
  }
440
- `,Se=`
440
+ `,Re=`
441
441
  entries {
442
- ${M}
442
+ ${H}
443
443
  }
444
444
  unmatched {
445
- ${N}
445
+ ${Y}
446
446
  }
447
447
  ambiguous {
448
- ${j}
448
+ ${z}
449
449
  }
450
- `,xe=`
450
+ `,Ce=`
451
451
  deckId
452
452
  format
453
453
  text
@@ -482,10 +482,10 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
482
482
  sourceUrl
483
483
  metadata
484
484
  sectionDefinitions {
485
- ${O}
485
+ ${N}
486
486
  }
487
487
  latestPublishedVersion {
488
- ${R}
488
+ ${C}
489
489
  }
490
490
  publishedAt
491
491
  draftRevision
@@ -496,28 +496,28 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
496
496
  createdAt
497
497
  updatedAt
498
498
  game {
499
- ${f}
499
+ ${p}
500
500
  }
501
501
  entries {
502
- ${T}
502
+ ${U}
503
503
  }
504
- `,ee=`
504
+ `,re=`
505
505
  deck {
506
506
  ${u}
507
507
  }
508
508
  retainedAppAccess
509
- `,Re=`
509
+ `,Ke=`
510
510
  deck {
511
511
  ${u}
512
512
  }
513
513
  copiedFromDeckId
514
514
  retainedAppAccess
515
- `,qe=`
515
+ `,Fe=`
516
516
  id
517
517
  name
518
518
  description
519
519
  revokedAt
520
- `,U=`
520
+ `,L=`
521
521
  id
522
522
  deckId
523
523
  deck {
@@ -525,7 +525,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
525
525
  }
526
526
  apiApplicationId
527
527
  apiApplication {
528
- ${qe}
528
+ ${Fe}
529
529
  }
530
530
  role
531
531
  grantSource
@@ -535,37 +535,37 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
535
535
  revokedAt
536
536
  createdAt
537
537
  updatedAt
538
- `,Ce=`
538
+ `,Ue=`
539
539
  deck {
540
540
  ${u}
541
541
  }
542
542
  version {
543
- ${R}
543
+ ${C}
544
544
  }
545
545
  validation {
546
- ${G}
546
+ ${j}
547
547
  }
548
548
  blockers {
549
- ${x}
549
+ ${R}
550
550
  }
551
551
  warnings {
552
- ${x}
552
+ ${R}
553
553
  }
554
- `,F=`
554
+ `,_=`
555
555
  deck {
556
556
  ${u}
557
557
  }
558
558
  entry {
559
- ${T}
559
+ ${U}
560
560
  }
561
- `,de=`
561
+ `,ye=`
562
562
  deck {
563
563
  ${u}
564
564
  }
565
565
  entries {
566
- ${T}
566
+ ${U}
567
567
  }
568
- `,Te=de,Ke=`
568
+ `,Pe=ye,Le=`
569
569
  deck {
570
570
  ${u}
571
571
  }
@@ -577,24 +577,24 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
577
577
  ${I}
578
578
  }
579
579
  detection {
580
- ${ue}
580
+ ${he}
581
581
  }
582
582
  entries {
583
- ${M}
583
+ ${H}
584
584
  }
585
585
  parseErrors {
586
- ${oe}
586
+ ${de}
587
587
  }
588
588
  unmatched {
589
- ${N}
589
+ ${Y}
590
590
  }
591
591
  ambiguous {
592
- ${j}
592
+ ${z}
593
593
  }
594
594
  validation {
595
- ${G}
595
+ ${j}
596
596
  }
597
- `,te=`
597
+ `,se=`
598
598
  resolvedLinks {
599
599
  field
600
600
  linkFieldKey
@@ -605,7 +605,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
605
605
  data
606
606
  }
607
607
  }
608
- `,le=`
608
+ `,fe=`
609
609
  datasetKey
610
610
  index
611
611
  errors {
@@ -613,13 +613,13 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
613
613
  message
614
614
  details
615
615
  }
616
- `,Ue=`
616
+ `,_e=`
617
617
  total
618
618
  inserted
619
619
  updated
620
620
  skipped
621
621
  failed
622
- `,he=`
622
+ `,pe=`
623
623
  inserted {
624
624
  ${A}
625
625
  }
@@ -628,21 +628,21 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
628
628
  }
629
629
  skipped
630
630
  errors {
631
- ${le}
631
+ ${fe}
632
632
  }
633
633
  createdFields {
634
- ${ne}
634
+ ${ue}
635
635
  }
636
636
  stats {
637
- ${Ue}
637
+ ${_e}
638
638
  }
639
- `,ye=`
639
+ `,me=`
640
640
  fileId
641
641
  filename
642
642
  file {
643
- ${S}
643
+ ${q}
644
644
  }
645
- `,$=`
645
+ `,b=`
646
646
  id
647
647
  publisherId
648
648
  publisher {
@@ -650,8 +650,8 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
650
650
  }
651
651
  datasetId
652
652
  dataset {
653
- ${p}
654
- ${v}
653
+ ${m}
654
+ ${D}
655
655
  }
656
656
  accountId
657
657
  status
@@ -667,14 +667,14 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
667
667
  skippedCount
668
668
  failedCount
669
669
  createdFields {
670
- ${ne}
670
+ ${ue}
671
671
  }
672
672
  errors {
673
- ${le}
673
+ ${fe}
674
674
  }
675
675
  errorMessage
676
676
  assets {
677
- ${ye}
677
+ ${me}
678
678
  }
679
679
  startedAt
680
680
  completedAt
@@ -685,7 +685,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
685
685
  imagesPending
686
686
  imagesCompleted
687
687
  imagesFailed
688
- `,Fe=`
688
+ `,Ve=`
689
689
  id
690
690
  importJobId
691
691
  level
@@ -695,20 +695,20 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
695
695
  fieldKey
696
696
  details
697
697
  createdAt
698
- `,Pe=`
698
+ `,Be=`
699
699
  job {
700
- ${$}
700
+ ${b}
701
701
  }
702
702
  dryRunResult {
703
- ${he}
703
+ ${pe}
704
704
  }
705
- `,Le=`
705
+ `,Me=`
706
706
  target
707
707
  recordId
708
708
  identifier
709
709
  status
710
710
  message
711
- `,P=`
711
+ `,V=`
712
712
  id
713
713
  publisherId
714
714
  publisher {
@@ -716,7 +716,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
716
716
  }
717
717
  datasetId
718
718
  dataset {
719
- ${p}
719
+ ${m}
720
720
  }
721
721
  accountId
722
722
  status
@@ -732,14 +732,14 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
732
732
  blockedCount
733
733
  failedCount
734
734
  results {
735
- ${Le}
735
+ ${Me}
736
736
  }
737
737
  errorMessage
738
738
  startedAt
739
739
  completedAt
740
740
  createdAt
741
741
  updatedAt
742
- `,fe=`
742
+ `,ge=`
743
743
  sourceField
744
744
  targetField
745
745
  targetFieldLabel
@@ -765,30 +765,30 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
765
765
  targetFieldType
766
766
  sampleValues
767
767
  status
768
- `,L=`
768
+ `,B=`
769
769
  datasetKey
770
770
  field
771
771
  message
772
772
  severity
773
- `,Be=`
773
+ `,Je=`
774
774
  datasetKey
775
775
  datasetName
776
776
  datasetId
777
777
  exists
778
778
  recordCount
779
779
  fieldMappings {
780
- ${fe}
780
+ ${ge}
781
781
  }
782
782
  warnings {
783
- ${L}
783
+ ${B}
784
784
  }
785
785
  canProceed
786
786
  sampleRecords
787
787
  availableDatasets {
788
- ${p}
789
- ${v}
788
+ ${m}
789
+ ${D}
790
790
  }
791
- `,Ve=`
791
+ `,Ge=`
792
792
  datasets {
793
793
  datasetKey
794
794
  datasetName
@@ -796,19 +796,19 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
796
796
  exists
797
797
  recordCount
798
798
  fieldMappings {
799
- ${fe}
799
+ ${ge}
800
800
  }
801
801
  warnings {
802
- ${L}
802
+ ${B}
803
803
  }
804
804
  sampleRecords
805
805
  }
806
806
  importOrder
807
807
  warnings {
808
- ${L}
808
+ ${B}
809
809
  }
810
810
  canProceed
811
- `,_e=`
811
+ `,Oe=`
812
812
  datasetKey
813
813
  datasetId
814
814
  datasetName
@@ -819,7 +819,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
819
819
  skippedCount
820
820
  failedCount
821
821
  errorMessage
822
- `,D=`
822
+ `,v=`
823
823
  id
824
824
  publisherId
825
825
  publisher {
@@ -827,7 +827,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
827
827
  }
828
828
  gameId
829
829
  game {
830
- ${f}
830
+ ${p}
831
831
  }
832
832
  accountId
833
833
  status
@@ -835,14 +835,14 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
835
835
  onConflict
836
836
  fileId
837
837
  assets {
838
- ${ye}
838
+ ${me}
839
839
  }
840
840
  totalDatasets
841
841
  completedDatasets
842
842
  progress
843
843
  importOrder
844
844
  datasetStatuses {
845
- ${_e}
845
+ ${Oe}
846
846
  }
847
847
  errorMessage
848
848
  startedAt
@@ -862,7 +862,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
862
862
  linkBuildingCompletedDatasets
863
863
  linkBuildingProcessedRecords
864
864
  linkBuildingTotalRecords
865
- `,w=`
865
+ `,S=`
866
866
  id
867
867
  publisherId
868
868
  publisher {
@@ -870,7 +870,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
870
870
  }
871
871
  datasetId
872
872
  dataset {
873
- ${p}
873
+ ${m}
874
874
  }
875
875
  accountId
876
876
  status
@@ -888,7 +888,160 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
888
888
  createdAt
889
889
  updatedAt
890
890
  lastCheckpointIndex
891
- `;function l(e){return `
891
+ `,Ne=`
892
+ recordId
893
+ rank
894
+ score
895
+ confidence
896
+ reasons
897
+ `,je=`
898
+ configured
899
+ url
900
+ latestDeliveryId
901
+ status
902
+ attemptCount
903
+ nextAttemptAt
904
+ lastAttemptAt
905
+ deliveredAt
906
+ lastStatusCode
907
+ lastError
908
+ `,He=`
909
+ featureVersion
910
+ candidateCount
911
+ confidenceScore
912
+ confidenceLabel
913
+ stages {
914
+ name
915
+ status
916
+ durationMs
917
+ completedAt
918
+ details
919
+ }
920
+ timings
921
+ `,ie=`
922
+ jobId
923
+ status
924
+ publisherSlug
925
+ gameKey
926
+ datasetKey
927
+ fileId
928
+ clientRequestId
929
+ templateId
930
+ templateVersionId
931
+ bestMatch {
932
+ recordId
933
+ score
934
+ confidence
935
+ }
936
+ candidates {
937
+ ${Ne}
938
+ }
939
+ extracted
940
+ metrics {
941
+ ${He}
942
+ }
943
+ webhook {
944
+ ${je}
945
+ }
946
+ error {
947
+ code
948
+ message
949
+ }
950
+ createdAt
951
+ updatedAt
952
+ startedAt
953
+ completedAt
954
+ `,Ye=`
955
+ publisherSlug
956
+ gameKey
957
+ datasetKey
958
+ since
959
+ until
960
+ generatedAt
961
+ totalJobs
962
+ completedJobs
963
+ failedJobs
964
+ failureRate
965
+ averageShortlistSize
966
+ confidenceDistribution
967
+ feedback {
968
+ total
969
+ correct
970
+ corrected
971
+ unknown
972
+ accuracy
973
+ }
974
+ featureVersions {
975
+ featureVersion
976
+ jobCount
977
+ completedJobs
978
+ failedJobs
979
+ averageConfidence
980
+ averageShortlistSize
981
+ feedbackCount
982
+ correctFeedback
983
+ correctedFeedback
984
+ feedbackAccuracy
985
+ }
986
+ `,x=`
987
+ code
988
+ region
989
+ message
990
+ `,ze=`
991
+ id
992
+ key
993
+ label
994
+ sortOrder
995
+ shapeType
996
+ geometry
997
+ semanticType
998
+ extractionMode
999
+ lookupMode
1000
+ isRequired
1001
+ weight
1002
+ config
1003
+ `,T=`
1004
+ id
1005
+ key
1006
+ name
1007
+ status
1008
+ version
1009
+ isDefault
1010
+ publisherSlug
1011
+ gameKey
1012
+ datasetKey
1013
+ exampleFileId
1014
+ coordinateSpace
1015
+ cardAspectRatio
1016
+ notes
1017
+ config
1018
+ regions {
1019
+ ${ze}
1020
+ }
1021
+ createdAt
1022
+ updatedAt
1023
+ `,We=`
1024
+ key
1025
+ label
1026
+ semanticType
1027
+ extractionMode
1028
+ lookupMode
1029
+ rawText
1030
+ normalizedValue
1031
+ source
1032
+ status
1033
+ confidence
1034
+ `,Xe=`
1035
+ id
1036
+ key
1037
+ name
1038
+ description
1039
+ sortOrder
1040
+ isActive
1041
+ metadata
1042
+ createdAt
1043
+ updatedAt
1044
+ `;function d(e){return `
892
1045
  totalCount
893
1046
  pageInfo {
894
1047
  hasNextPage
@@ -905,7 +1058,7 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
905
1058
  `}var a={searchPublishers(e={}){let t={},r=[],s=[];e.search!==void 0&&(s.push("$search: String"),r.push("search: $search"),t.search=e.search),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
906
1059
  query SearchPublishers${i} {
907
1060
  searchPublishers${n} {
908
- ${l(g)}
1061
+ ${d(g)}
909
1062
  }
910
1063
  }
911
1064
  `,variables:t}},fetchPublisherById(){return {query:`
@@ -929,96 +1082,96 @@ var y=class re extends Error{response;constructor(t,r){super(t),this.name="CardD
929
1082
  `}},searchGames(e={}){let t={},r=[],s=[];e.publisherSlug!==void 0&&(s.push("$publisherSlug: String"),r.push("publisherSlug: $publisherSlug"),t.publisherSlug=e.publisherSlug),e.search!==void 0&&(s.push("$search: String"),r.push("search: $search"),t.search=e.search),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
930
1083
  query SearchGames${i} {
931
1084
  searchGames${n} {
932
- ${l(f)}
1085
+ ${d(p)}
933
1086
  }
934
1087
  }
935
1088
  `,variables:t}},fetchGameById(){return {query:`
936
1089
  query FetchGame($id: UUID!) {
937
1090
  fetchGame(id: $id) {
938
- ${f}
1091
+ ${p}
939
1092
  }
940
1093
  }
941
1094
  `}},fetchGameByKeys(){return {query:`
942
1095
  query FetchGame($publisherSlug: String!, $gameKey: String!) {
943
1096
  fetchGame(publisherSlug: $publisherSlug, gameKey: $gameKey) {
944
- ${f}
1097
+ ${p}
945
1098
  }
946
1099
  }
947
1100
  `}},fetchGames(){return {query:`
948
1101
  query FetchGames($ids: [UUID!]!) {
949
1102
  fetchGames(ids: $ids) {
950
- ${f}
1103
+ ${p}
951
1104
  }
952
1105
  }
953
1106
  `}},listGames(e){let t={publisherId:e.publisherId},r=["publisherId: $publisherId"],s=["$publisherId: UUID!"];return e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),e.includeArchived!==void 0&&(s.push("$includeArchived: Boolean"),r.push("includeArchived: $includeArchived"),t.includeArchived=e.includeArchived),{query:`
954
1107
  query Games(${s.join(", ")}) {
955
1108
  games(${r.join(", ")}) {
956
- ${l(f)}
1109
+ ${d(p)}
957
1110
  }
958
1111
  }
959
1112
  `,variables:t}},game(e){let t={},r=[],s=[];return e.id!==void 0&&(s.push("$id: UUID"),r.push("id: $id"),t.id=e.id),e.publisherId!==void 0&&(s.push("$publisherId: UUID"),r.push("publisherId: $publisherId"),t.publisherId=e.publisherId),e.publisherSlug!==void 0&&(s.push("$publisherSlug: String"),r.push("publisherSlug: $publisherSlug"),t.publisherSlug=e.publisherSlug),e.gameKey!==void 0&&(s.push("$gameKey: String"),r.push("gameKey: $gameKey"),t.gameKey=e.gameKey),e.gameSlug!==void 0&&(s.push("$gameSlug: String"),r.push("gameSlug: $gameSlug"),t.gameSlug=e.gameSlug),{query:`
960
1113
  query Game(${s.join(", ")}) {
961
1114
  game(${r.join(", ")}) {
962
- ${f}
1115
+ ${p}
963
1116
  }
964
1117
  }
965
1118
  `,variables:t}},createGame(){return {query:`
966
1119
  mutation GameCreate($input: GameCreateInput!) {
967
1120
  gameCreate(input: $input) {
968
- ${f}
1121
+ ${p}
969
1122
  }
970
1123
  }
971
1124
  `}},updateGame(){return {query:`
972
1125
  mutation GameUpdate($id: UUID!, $input: GameUpdateInput!) {
973
1126
  gameUpdate(id: $id, input: $input) {
974
- ${f}
1127
+ ${p}
975
1128
  }
976
1129
  }
977
1130
  `}},searchDatasets(e={}){let t={},r=[],s=[];e.publisherSlug!==void 0&&(s.push("$publisherSlug: String"),r.push("publisherSlug: $publisherSlug"),t.publisherSlug=e.publisherSlug),e.gameKey!==void 0&&(s.push("$gameKey: String"),r.push("gameKey: $gameKey"),t.gameKey=e.gameKey),e.search!==void 0&&(s.push("$search: String"),r.push("search: $search"),t.search=e.search),e.purpose!==void 0&&(s.push("$purpose: DatasetPurpose"),r.push("purpose: $purpose"),t.purpose=e.purpose),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
978
1131
  query SearchDatasets${i} {
979
1132
  searchDatasets${n} {
980
- ${l(p)}
1133
+ ${d(m)}
981
1134
  }
982
1135
  }
983
1136
  `,variables:t}},fetchDatasetById(){return {query:`
984
1137
  query FetchDataset($id: UUID!) {
985
1138
  fetchDataset(id: $id) {
986
- ${p}
987
- ${v}
1139
+ ${m}
1140
+ ${D}
988
1141
  }
989
1142
  }
990
1143
  `}},fetchDatasetByKeys(){return {query:`
991
1144
  query FetchDataset($publisherSlug: String!, $gameKey: String!, $datasetKey: String!) {
992
1145
  fetchDataset(publisherSlug: $publisherSlug, gameKey: $gameKey, datasetKey: $datasetKey) {
993
- ${p}
994
- ${v}
1146
+ ${m}
1147
+ ${D}
995
1148
  }
996
1149
  }
997
1150
  `}},fetchDatasets(){return {query:`
998
1151
  query FetchDatasets($ids: [UUID!]!) {
999
1152
  fetchDatasets(ids: $ids) {
1000
- ${p}
1153
+ ${m}
1001
1154
  }
1002
1155
  }
1003
1156
  `}},listDatasets(e){let t={publisherId:e.publisherId},r=["publisherId: $publisherId"],s=["$publisherId: UUID!"];return e.gameId!==void 0&&(s.push("$gameId: UUID"),r.push("gameId: $gameId"),t.gameId=e.gameId),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),e.includeArchived!==void 0&&(s.push("$includeArchived: Boolean"),r.push("includeArchived: $includeArchived"),t.includeArchived=e.includeArchived),e.purpose!==void 0&&(s.push("$purpose: DatasetPurpose"),r.push("purpose: $purpose"),t.purpose=e.purpose),{query:`
1004
1157
  query Datasets(${s.join(", ")}) {
1005
1158
  datasets(${r.join(", ")}) {
1006
- ${l(`${p}
1007
- ${v}`)}
1159
+ ${d(`${m}
1160
+ ${D}`)}
1008
1161
  }
1009
1162
  }
1010
1163
  `,variables:t}},dataset(e){let t={},r=[],s=[];return e.id!==void 0&&(s.push("$id: UUID"),r.push("id: $id"),t.id=e.id),e.publisherId!==void 0&&(s.push("$publisherId: UUID"),r.push("publisherId: $publisherId"),t.publisherId=e.publisherId),e.gameId!==void 0&&(s.push("$gameId: UUID"),r.push("gameId: $gameId"),t.gameId=e.gameId),e.datasetKey!==void 0&&(s.push("$datasetKey: String"),r.push("datasetKey: $datasetKey"),t.datasetKey=e.datasetKey),{query:`
1011
1164
  query Dataset(${s.join(", ")}) {
1012
1165
  dataset(${r.join(", ")}) {
1013
- ${p}
1014
- ${v}
1166
+ ${m}
1167
+ ${D}
1015
1168
  }
1016
1169
  }
1017
1170
  `,variables:t}},searchRecords(e){let t={publisherSlug:e.publisherSlug,gameKey:e.gameKey,datasetKey:e.datasetKey},r=["publisherSlug: $publisherSlug","gameKey: $gameKey","datasetKey: $datasetKey"],s=["$publisherSlug: String!","$gameKey: String!","$datasetKey: String!"];e.filter!==void 0&&(s.push("$filter: JSON"),r.push("filter: $filter"),t.filter=e.filter),e.search!==void 0&&(s.push("$search: String"),r.push("search: $search"),t.search=e.search),e.orderBy!==void 0&&(s.push("$orderBy: String"),r.push("orderBy: $orderBy"),t.orderBy=e.orderBy),e.resolveLinks!==void 0&&(s.push("$resolveLinks: [String!]"),r.push("resolveLinks: $resolveLinks"),t.resolveLinks=e.resolveLinks),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),e.validateSchema!==void 0&&(s.push("$validateSchema: Boolean"),r.push("validateSchema: $validateSchema"),t.validateSchema=e.validateSchema);let i=e.resolveLinks&&e.resolveLinks.length>0,n=k({includePricing:e.includePricing}),c=i?`${n}
1018
- ${te}`:n;return {query:`
1171
+ ${se}`:n;return {query:`
1019
1172
  query SearchRecords(${s.join(", ")}) {
1020
1173
  searchRecords(${r.join(", ")}) {
1021
- ${l(c)}
1174
+ ${d(c)}
1022
1175
  }
1023
1176
  }
1024
1177
  `,variables:t}},fetchRecordById(e={}){return {query:`
@@ -1048,11 +1201,11 @@ ${te}`:n;return {query:`
1048
1201
  `}},listDatasetRecords(e){let t={datasetId:e.datasetId},r=["datasetId: $datasetId"],s=["$datasetId: UUID!"];return e.filter!==void 0&&(s.push("$filter: JSON"),r.push("filter: $filter"),t.filter=e.filter),e.orderBy!==void 0&&(s.push("$orderBy: DatasetRecordOrderByInput"),r.push("orderBy: $orderBy"),t.orderBy=e.orderBy),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),e.last!==void 0&&(s.push("$last: Int"),r.push("last: $last"),t.last=e.last),e.before!==void 0&&(s.push("$before: String"),r.push("before: $before"),t.before=e.before),e.validateSchema!==void 0&&(s.push("$validateSchema: Boolean"),r.push("validateSchema: $validateSchema"),t.validateSchema=e.validateSchema),{query:`
1049
1202
  query DatasetRecords(${s.join(", ")}) {
1050
1203
  datasetRecords(${r.join(", ")}) {
1051
- ${l(A)}
1204
+ ${d(A)}
1052
1205
  }
1053
1206
  }
1054
1207
  `,variables:t}},datasetRecord(e){let t={},r=[],s=[];e.id!==void 0&&(s.push("$id: UUID"),r.push("id: $id"),t.id=e.id),e.datasetId!==void 0&&(s.push("$datasetId: UUID"),r.push("datasetId: $datasetId"),t.datasetId=e.datasetId),e.identifier!==void 0&&(s.push("$identifier: String"),r.push("identifier: $identifier"),t.identifier=e.identifier),e.publisherSlug!==void 0&&(s.push("$publisherSlug: String"),r.push("publisherSlug: $publisherSlug"),t.publisherSlug=e.publisherSlug),e.gameKey!==void 0&&(s.push("$gameKey: String"),r.push("gameKey: $gameKey"),t.gameKey=e.gameKey),e.datasetKey!==void 0&&(s.push("$datasetKey: String"),r.push("datasetKey: $datasetKey"),t.datasetKey=e.datasetKey),e.recordId!==void 0&&(s.push("$recordId: UUID"),r.push("recordId: $recordId"),t.recordId=e.recordId),e.resolveLinks!==void 0&&(s.push("$resolveLinks: [String!]"),r.push("resolveLinks: $resolveLinks"),t.resolveLinks=e.resolveLinks),e.validateSchema!==void 0&&(s.push("$validateSchema: Boolean"),r.push("validateSchema: $validateSchema"),t.validateSchema=e.validateSchema);let i=e.resolveLinks&&e.resolveLinks.length>0,n=k({includePricing:e.includePricing}),c=i?`${n}
1055
- ${te}`:n;return {query:`
1208
+ ${se}`:n;return {query:`
1056
1209
  query DatasetRecord(${s.join(", ")}) {
1057
1210
  datasetRecord(${r.join(", ")}) {
1058
1211
  ${c}
@@ -1061,199 +1214,293 @@ ${te}`:n;return {query:`
1061
1214
  `,variables:t}},upsertDatasetRecords(){return {query:`
1062
1215
  mutation DatasetRecordsUpsert($input: DatasetRecordsUpsertInput!) {
1063
1216
  datasetRecordsUpsert(input: $input) {
1064
- ${Pe}
1217
+ ${Be}
1065
1218
  }
1066
1219
  }
1067
1220
  `}},deleteDatasetRecords(){return {query:`
1068
1221
  mutation DatasetRecordsDelete($input: DatasetRecordsDeleteInput!) {
1069
1222
  datasetRecordsDelete(input: $input) {
1070
- ${P}
1223
+ ${V}
1071
1224
  }
1072
1225
  }
1073
1226
  `}},datasetRecordDeleteJob(){return {query:`
1074
1227
  query DatasetRecordDeleteJob($id: UUID!) {
1075
1228
  datasetRecordDeleteJob(id: $id) {
1076
- ${P}
1229
+ ${V}
1077
1230
  }
1078
1231
  }
1079
1232
  `}},datasetRecordDeleteJobs(e){let t={publisherId:e.publisherId},r=["publisherId: $publisherId"],s=["$publisherId: UUID!"];return e.datasetId!==void 0&&(s.push("$datasetId: UUID"),r.push("datasetId: $datasetId"),t.datasetId=e.datasetId),e.status!==void 0&&(s.push("$status: DatasetRecordDeleteJobStatus"),r.push("status: $status"),t.status=e.status),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),{query:`
1080
1233
  query DatasetRecordDeleteJobs(${s.join(", ")}) {
1081
1234
  datasetRecordDeleteJobs(${r.join(", ")}) {
1082
- ${l(P)}
1235
+ ${d(V)}
1083
1236
  }
1084
1237
  }
1085
1238
  `,variables:t}},datasetImportPreview(){return {query:`
1086
1239
  query DatasetImportPreview($input: DatasetImportPreviewInput!) {
1087
1240
  datasetImportPreview(input: $input) {
1088
- ${Be}
1241
+ ${Je}
1089
1242
  }
1090
1243
  }
1091
1244
  `}},datasetImportValidate(){return {query:`
1092
1245
  query DatasetImportValidate($input: DatasetImportValidateInput!) {
1093
1246
  datasetImportValidate(input: $input) {
1094
- ${he}
1247
+ ${pe}
1095
1248
  }
1096
1249
  }
1097
1250
  `}},datasetImportFromFile(){return {query:`
1098
1251
  mutation DatasetImportFromFile($input: DatasetImportFromFileInput!) {
1099
1252
  datasetImportFromFile(input: $input) {
1100
- ${$}
1253
+ ${b}
1101
1254
  }
1102
1255
  }
1103
1256
  `}},datasetImportFromPayload(){return {query:`
1104
1257
  mutation DatasetImportFromPayload($input: DatasetImportFromPayloadInput!) {
1105
1258
  datasetImportFromPayload(input: $input) {
1106
- ${$}
1259
+ ${b}
1107
1260
  }
1108
1261
  }
1109
1262
  `}},datasetImportFromUrl(){return {query:`
1110
1263
  mutation DatasetImportFromUrl($input: DatasetImportFromUrlInput!) {
1111
1264
  datasetImportFromUrl(input: $input) {
1112
- ${$}
1265
+ ${b}
1113
1266
  }
1114
1267
  }
1115
1268
  `}},importJob(){return {query:`
1116
1269
  query ImportJob($id: UUID!) {
1117
1270
  importJob(id: $id) {
1118
- ${$}
1271
+ ${b}
1119
1272
  }
1120
1273
  }
1121
1274
  `}},importJobs(e){let t={publisherId:e.publisherId},r=["publisherId: $publisherId"],s=["$publisherId: UUID!"];return e.datasetId!==void 0&&(s.push("$datasetId: UUID"),r.push("datasetId: $datasetId"),t.datasetId=e.datasetId),e.status!==void 0&&(s.push("$status: ImportJobStatus"),r.push("status: $status"),t.status=e.status),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),{query:`
1122
1275
  query ImportJobs(${s.join(", ")}) {
1123
1276
  importJobs(${r.join(", ")}) {
1124
- ${l($)}
1277
+ ${d(b)}
1125
1278
  }
1126
1279
  }
1127
1280
  `,variables:t}},importJobCancel(){return {query:`
1128
1281
  mutation ImportJobCancel($id: UUID!) {
1129
1282
  importJobCancel(id: $id) {
1130
- ${$}
1283
+ ${b}
1131
1284
  }
1132
1285
  }
1133
1286
  `}},importJobLogs(e){let t={importJobId:e.importJobId},r=["id: $importJobId"],s=[],i=["$importJobId: UUID!"];e.level!==void 0&&(i.push("$level: ImportLogLevel"),s.push("level: $level"),t.level=e.level),e.datasetKey!==void 0&&(i.push("$datasetKey: String"),s.push("datasetKey: $datasetKey"),t.datasetKey=e.datasetKey),e.first!==void 0&&(i.push("$first: Int"),s.push("first: $first"),t.first=e.first),e.after!==void 0&&(i.push("$after: String"),s.push("after: $after"),t.after=e.after);let n=s.length>0?`(${s.join(", ")})`:"";return {query:`
1134
1287
  query ImportJobLogs(${i.join(", ")}) {
1135
1288
  importJob(${r.join(", ")}) {
1136
1289
  logs${n} {
1137
- ${l(Fe)}
1290
+ ${d(Ve)}
1138
1291
  }
1139
1292
  }
1140
1293
  }
1141
1294
  `,variables:t}},gameImportPreview(){return {query:`
1142
1295
  query GameImportPreview($input: GameImportPreviewInput!) {
1143
1296
  gameImportPreview(input: $input) {
1144
- ${Ve}
1297
+ ${Ge}
1145
1298
  }
1146
1299
  }
1147
1300
  `}},gameImportFromFile(){return {query:`
1148
1301
  mutation GameImportFromFile($input: GameImportFromFileInput!) {
1149
1302
  gameImportFromFile(input: $input) {
1150
- ${D}
1303
+ ${v}
1151
1304
  }
1152
1305
  }
1153
1306
  `}},gameImportFromPayload(){return {query:`
1154
1307
  mutation GameImportFromPayload($input: GameImportFromPayloadInput!) {
1155
1308
  gameImportFromPayload(input: $input) {
1156
- ${D}
1309
+ ${v}
1157
1310
  }
1158
1311
  }
1159
1312
  `}},gameImportFromUrl(){return {query:`
1160
1313
  mutation GameImportFromUrl($input: GameImportFromUrlInput!) {
1161
1314
  gameImportFromUrl(input: $input) {
1162
- ${D}
1315
+ ${v}
1163
1316
  }
1164
1317
  }
1165
1318
  `}},gameImportJob(){return {query:`
1166
1319
  query GameImportJob($id: UUID!) {
1167
1320
  gameImportJob(id: $id) {
1168
- ${D}
1321
+ ${v}
1169
1322
  }
1170
1323
  }
1171
1324
  `}},gameImportJobs(e){let t={gameId:e.gameId},r=["gameId: $gameId"],s=["$gameId: UUID!"];return e.status!==void 0&&(s.push("$status: ImportJobStatus"),r.push("status: $status"),t.status=e.status),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),{query:`
1172
1325
  query GameImportJobs(${s.join(", ")}) {
1173
1326
  gameImportJobs(${r.join(", ")}) {
1174
- ${l(D)}
1327
+ ${d(v)}
1175
1328
  }
1176
1329
  }
1177
1330
  `,variables:t}},gameImportJobCancel(){return {query:`
1178
1331
  mutation GameImportJobCancel($id: UUID!) {
1179
1332
  gameImportJobCancel(id: $id) {
1180
- ${D}
1333
+ ${v}
1181
1334
  }
1182
1335
  }
1183
1336
  `}},file(){return {query:`
1184
1337
  query File($id: UUID!) {
1185
1338
  file(id: $id) {
1186
- ${S}
1339
+ ${q}
1187
1340
  }
1188
1341
  }
1189
1342
  `}},fileUploadRequest(){return {query:`
1190
1343
  mutation FileUploadRequest($input: FileUploadInput!) {
1191
1344
  fileUploadRequest(input: $input) {
1192
- ${De}
1345
+ ${Ae}
1193
1346
  }
1194
1347
  }
1195
1348
  `}},fileUploadConfirm(){return {query:`
1196
1349
  mutation FileUploadConfirm($id: UUID!) {
1197
1350
  fileUploadConfirm(id: $id) {
1198
- ${S}
1351
+ ${q}
1199
1352
  }
1200
1353
  }
1201
1354
  `}},fileDelete(){return {query:`
1202
1355
  mutation FileDelete($id: UUID!) {
1203
1356
  fileDelete(id: $id)
1204
1357
  }
1358
+ `}},createScanJob(){return {query:`
1359
+ mutation CreateScanJob($input: CreateScanJobInput!) {
1360
+ createScanJob(input: $input) {
1361
+ job {
1362
+ ${ie}
1363
+ }
1364
+ created
1365
+ }
1366
+ }
1367
+ `}},scanJob(){return {query:`
1368
+ query ScanJob($id: UUID!) {
1369
+ scanJob(id: $id) {
1370
+ ${ie}
1371
+ }
1372
+ }
1373
+ `}},submitScanFeedback(){return {query:`
1374
+ mutation SubmitScanFeedback($input: SubmitScanFeedbackInput!) {
1375
+ submitScanFeedback(input: $input) {
1376
+ feedbackId
1377
+ jobId
1378
+ status
1379
+ persisted
1380
+ correct
1381
+ predictedRecordId
1382
+ selectedRecordId
1383
+ featureVersion
1384
+ message
1385
+ }
1386
+ }
1387
+ `}},scanMetrics(){return {query:`
1388
+ query ScanMetrics($input: ScanMetricsInput!) {
1389
+ scanMetrics(input: $input) {
1390
+ ${Ye}
1391
+ }
1392
+ }
1393
+ `}},resolveScanTemplate(){return {query:`
1394
+ query ResolveScanTemplate($input: ResolveScanTemplateInput!) {
1395
+ resolveScanTemplate(input: $input) {
1396
+ template {
1397
+ ${T}
1398
+ }
1399
+ warnings {
1400
+ ${x}
1401
+ }
1402
+ }
1403
+ }
1404
+ `}},scanTemplates(){return {query:`
1405
+ query ScanTemplates($input: ScanTemplatesInput!) {
1406
+ scanTemplates(input: $input) {
1407
+ templates {
1408
+ ${T}
1409
+ }
1410
+ }
1411
+ }
1412
+ `}},createScanTemplate(){return {query:`
1413
+ mutation CreateScanTemplate($input: SaveScanTemplateInput!) {
1414
+ createScanTemplate(input: $input) {
1415
+ template {
1416
+ ${T}
1417
+ }
1418
+ warnings {
1419
+ ${x}
1420
+ }
1421
+ }
1422
+ }
1423
+ `}},updateScanTemplate(){return {query:`
1424
+ mutation UpdateScanTemplate($id: UUID!, $input: SaveScanTemplateInput!) {
1425
+ updateScanTemplate(id: $id, input: $input) {
1426
+ template {
1427
+ ${T}
1428
+ }
1429
+ warnings {
1430
+ ${x}
1431
+ }
1432
+ }
1433
+ }
1434
+ `}},previewScanTemplate(){return {query:`
1435
+ mutation PreviewScanTemplate($input: PreviewScanTemplateInput!) {
1436
+ previewScanTemplate(input: $input) {
1437
+ warnings {
1438
+ ${x}
1439
+ }
1440
+ regions {
1441
+ ${We}
1442
+ }
1443
+ message
1444
+ }
1445
+ }
1446
+ `}},gameScanRegions(){return {query:`
1447
+ query GameScanRegions($publisherSlug: String!, $gameKey: String!, $includeInactive: Boolean) {
1448
+ gameScanRegions(publisherSlug: $publisherSlug, gameKey: $gameKey, includeInactive: $includeInactive) {
1449
+ ${Xe}
1450
+ }
1451
+ }
1205
1452
  `}},exportJob(){return {query:`
1206
1453
  query ExportJob($id: UUID!) {
1207
1454
  exportJob(id: $id) {
1208
- ${w}
1455
+ ${S}
1209
1456
  }
1210
1457
  }
1211
1458
  `}},exportJobs(e){let t={publisherId:e.publisherId},r=["publisherId: $publisherId"],s=["$publisherId: UUID!"];return e.gameId!==void 0&&(s.push("$gameId: UUID"),r.push("gameId: $gameId"),t.gameId=e.gameId),e.datasetId!==void 0&&(s.push("$datasetId: UUID"),r.push("datasetId: $datasetId"),t.datasetId=e.datasetId),e.status!==void 0&&(s.push("$status: ExportJobStatus"),r.push("status: $status"),t.status=e.status),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),{query:`
1212
1459
  query ExportJobs(${s.join(", ")}) {
1213
1460
  exportJobs(${r.join(", ")}) {
1214
- ${l(w)}
1461
+ ${d(S)}
1215
1462
  }
1216
1463
  }
1217
1464
  `,variables:t}},datasetExport(){return {query:`
1218
1465
  mutation DatasetExport($input: DatasetExportInput!) {
1219
1466
  datasetExport(input: $input) {
1220
- ${w}
1467
+ ${S}
1221
1468
  }
1222
1469
  }
1223
1470
  `}},exportJobCancel(){return {query:`
1224
1471
  mutation ExportJobCancel($id: UUID!) {
1225
1472
  exportJobCancel(id: $id) {
1226
- ${w}
1473
+ ${S}
1227
1474
  }
1228
1475
  }
1229
1476
  `}},exportJobRefreshUrl(){return {query:`
1230
1477
  mutation ExportJobRefreshUrl($id: UUID!) {
1231
1478
  exportJobRefreshUrl(id: $id) {
1232
- ${w}
1479
+ ${S}
1233
1480
  }
1234
1481
  }
1235
1482
  `}},listMyDecks(e={}){let t={},r=[],s=[];e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),e.includeArchived!==void 0&&(s.push("$includeArchived: Boolean"),r.push("includeArchived: $includeArchived"),t.includeArchived=e.includeArchived);let i=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1236
1483
  query MyDecks${i} {
1237
1484
  myDecks${n} {
1238
- ${l(u)}
1485
+ ${d(u)}
1239
1486
  }
1240
1487
  }
1241
1488
  `,variables:t}},viewerDecks(e={}){let t={},r=[],s=[];e.filter!==void 0&&(s.push("$filter: ViewerDecksFilterInput"),r.push("filter: $filter"),t.filter=e.filter),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1242
1489
  query ViewerDecks${i} {
1243
1490
  viewerDecks${n} {
1244
- ${l(u)}
1491
+ ${d(u)}
1245
1492
  }
1246
1493
  }
1247
1494
  `,variables:t}},appDecks(e={}){let t={},r=[],s=[];e.filter!==void 0&&(s.push("$filter: AppDecksFilterInput"),r.push("filter: $filter"),t.filter=e.filter),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1248
1495
  query AppDecks${i} {
1249
1496
  appDecks${n} {
1250
- ${l(u)}
1497
+ ${d(u)}
1251
1498
  }
1252
1499
  }
1253
1500
  `,variables:t}},publicDecks(e={}){let t={},r=[],s=[];e.filter!==void 0&&(s.push("$filter: PublicDecksFilterInput"),r.push("filter: $filter"),t.filter=e.filter),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1254
1501
  query PublicDecks${i} {
1255
1502
  publicDecks${n} {
1256
- ${l(u)}
1503
+ ${d(u)}
1257
1504
  }
1258
1505
  }
1259
1506
  `,variables:t}},fetchDeckById(){return {query:`
@@ -1301,13 +1548,13 @@ ${te}`:n;return {query:`
1301
1548
  `}},deckVersion(){return {query:`
1302
1549
  query DeckVersion($id: UUID!) {
1303
1550
  deckVersion(id: $id) {
1304
- ${R}
1551
+ ${C}
1305
1552
  }
1306
1553
  }
1307
1554
  `}},deckVersions(e={}){let t={},r=["deckId: $deckId"],s=["$deckId: UUID!"];return e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after),{query:`
1308
1555
  query DeckVersions(${s.join(", ")}) {
1309
1556
  deckVersions(${r.join(", ")}) {
1310
- ${l(R)}
1557
+ ${d(C)}
1311
1558
  }
1312
1559
  }
1313
1560
  `,variables:t}},deckPreview(){return {query:`
@@ -1331,73 +1578,73 @@ ${te}`:n;return {query:`
1331
1578
  `}},deckDraftDiff(){return {query:`
1332
1579
  query DeckDraftDiff($id: UUID!) {
1333
1580
  deckDraftDiff(id: $id) {
1334
- ${W}
1581
+ ${Q}
1335
1582
  }
1336
1583
  }
1337
1584
  `}},deckVersionDiff(){return {query:`
1338
1585
  query DeckVersionDiff($fromVersionId: UUID!, $toVersionId: UUID!) {
1339
1586
  deckVersionDiff(fromVersionId: $fromVersionId, toVersionId: $toVersionId) {
1340
- ${W}
1587
+ ${Q}
1341
1588
  }
1342
1589
  }
1343
1590
  `}},deckHydrateEntries(){return {query:`
1344
1591
  query DeckHydrateEntries($input: DeckHydrateEntriesInput!) {
1345
1592
  deckHydrateEntries(input: $input) {
1346
- ${Se}
1593
+ ${Re}
1347
1594
  }
1348
1595
  }
1349
1596
  `}},deckExport(){return {query:`
1350
1597
  query DeckExport($id: UUID!, $format: DeckExportFormat!) {
1351
1598
  deckExport(id: $id, format: $format) {
1352
- ${xe}
1599
+ ${Ce}
1353
1600
  }
1354
1601
  }
1355
1602
  `}},deckValidate(){return {query:`
1356
1603
  query DeckValidate($id: UUID!, $input: DeckValidateInput) {
1357
1604
  deckValidate(id: $id, input: $input) {
1358
- ${G}
1605
+ ${j}
1359
1606
  }
1360
1607
  }
1361
1608
  `}},deckSectionDefinitions(e={}){let t={},r=[],s=[];e.publisherSlug!==void 0&&(s.push("$publisherSlug: String"),r.push("publisherSlug: $publisherSlug"),t.publisherSlug=e.publisherSlug),e.gameKey!==void 0&&(s.push("$gameKey: String"),r.push("gameKey: $gameKey"),t.gameKey=e.gameKey),e.gameId!==void 0&&(s.push("$gameId: UUID"),r.push("gameId: $gameId"),t.gameId=e.gameId),e.rulesetKey!==void 0&&(s.push("$rulesetKey: String"),r.push("rulesetKey: $rulesetKey"),t.rulesetKey=e.rulesetKey),e.rulesetVersionId!==void 0&&(s.push("$rulesetVersionId: UUID"),r.push("rulesetVersionId: $rulesetVersionId"),t.rulesetVersionId=e.rulesetVersionId);let i=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1362
1609
  query DeckSectionDefinitions${i} {
1363
1610
  deckSectionDefinitions${n} {
1364
- ${O}
1611
+ ${N}
1365
1612
  }
1366
1613
  }
1367
1614
  `,variables:t}},deckCollaborators(){return {query:`
1368
1615
  query DeckCollaborators($deckId: UUID!) {
1369
1616
  deckCollaborators(deckId: $deckId) {
1370
- ${Q}
1617
+ ${Z}
1371
1618
  }
1372
1619
  }
1373
1620
  `}},deckEmbedTokens(){return {query:`
1374
1621
  query DeckEmbedTokens($deckId: UUID!) {
1375
1622
  deckEmbedTokens(deckId: $deckId) {
1376
- ${Z}
1623
+ ${te}
1377
1624
  }
1378
1625
  }
1379
1626
  `}},deckAccessTokenIssuers(){return {query:`
1380
1627
  query DeckAccessTokenIssuers($deckId: UUID!) {
1381
1628
  deckAccessTokenIssuers(deckId: $deckId) {
1382
- ${K}
1629
+ ${P}
1383
1630
  }
1384
1631
  }
1385
1632
  `}},deckApiApplicationAccesses(){return {query:`
1386
1633
  query DeckApiApplicationAccesses($deckId: UUID!, $includeRevoked: Boolean) {
1387
1634
  deckApiApplicationAccesses(deckId: $deckId, includeRevoked: $includeRevoked) {
1388
- ${U}
1635
+ ${L}
1389
1636
  }
1390
1637
  }
1391
1638
  `}},myDeckApiApplicationAccesses(){return {query:`
1392
1639
  query MyDeckApiApplicationAccesses($applicationId: UUID) {
1393
1640
  myDeckApiApplicationAccesses(applicationId: $applicationId) {
1394
- ${U}
1641
+ ${L}
1395
1642
  }
1396
1643
  }
1397
1644
  `}},deckImportFormats(e){let t={},r=[],s=[];e.publisherId!==void 0&&(s.push("$publisherId: UUID"),r.push("publisherId: $publisherId"),t.publisherId=e.publisherId),e.gameId!==void 0&&(s.push("$gameId: UUID"),r.push("gameId: $gameId"),t.gameId=e.gameId),e.includeArchived!==void 0&&(s.push("$includeArchived: Boolean"),r.push("includeArchived: $includeArchived"),t.includeArchived=e.includeArchived),e.first!==void 0&&(s.push("$first: Int"),r.push("first: $first"),t.first=e.first),e.after!==void 0&&(s.push("$after: String"),r.push("after: $after"),t.after=e.after);let i=s.length>0?`(${s.join(", ")})`:"",n=r.length>0?`(${r.join(", ")})`:"";return {query:`
1398
1645
  query DeckImportFormats${i} {
1399
1646
  deckImportFormats${n} {
1400
- ${l(I)}
1647
+ ${d(I)}
1401
1648
  }
1402
1649
  }
1403
1650
  `,variables:t}},deckImportFormat(){return {query:`
@@ -1409,13 +1656,13 @@ ${te}`:n;return {query:`
1409
1656
  `}},deckImportFormatTest(){return {query:`
1410
1657
  query DeckImportFormatTest($input: DeckImportFormatTestInput!) {
1411
1658
  deckImportFormatTest(input: $input) {
1412
- ${Ee}
1659
+ ${qe}
1413
1660
  }
1414
1661
  }
1415
1662
  `}},deckPreviewTokens(){return {query:`
1416
1663
  query DeckPreviewTokens($deckId: UUID!) {
1417
1664
  deckPreviewTokens(deckId: $deckId) {
1418
- ${z}
1665
+ ${ee}
1419
1666
  }
1420
1667
  }
1421
1668
  `}},createDeck(){return {query:`
@@ -1455,37 +1702,37 @@ ${te}`:n;return {query:`
1455
1702
  `}},addDeckEntry(){return {query:`
1456
1703
  mutation DeckEntryAdd($input: DeckEntryAddInput!) {
1457
1704
  deckEntryAdd(input: $input) {
1458
- ${F}
1705
+ ${_}
1459
1706
  }
1460
1707
  }
1461
1708
  `}},updateDeckEntry(){return {query:`
1462
1709
  mutation DeckEntryUpdate($id: UUID!, $input: DeckEntryUpdateInput!) {
1463
1710
  deckEntryUpdate(id: $id, input: $input) {
1464
- ${F}
1711
+ ${_}
1465
1712
  }
1466
1713
  }
1467
1714
  `}},removeDeckEntry(){return {query:`
1468
1715
  mutation DeckEntryRemove($id: UUID!, $expectedDraftRevision: Int!) {
1469
1716
  deckEntryRemove(id: $id, expectedDraftRevision: $expectedDraftRevision) {
1470
- ${F}
1717
+ ${_}
1471
1718
  }
1472
1719
  }
1473
1720
  `}},reorderDeckEntries(){return {query:`
1474
1721
  mutation DeckEntryReorder($deckId: UUID!, $input: DeckEntryReorderInput!) {
1475
1722
  deckEntryReorder(deckId: $deckId, input: $input) {
1476
- ${de}
1723
+ ${ye}
1477
1724
  }
1478
1725
  }
1479
1726
  `}},replaceDeckEntries(){return {query:`
1480
1727
  mutation DeckEntriesReplace($deckId: UUID!, $input: DeckEntriesReplaceInput!) {
1481
1728
  deckEntriesReplace(deckId: $deckId, input: $input) {
1482
- ${Te}
1729
+ ${Pe}
1483
1730
  }
1484
1731
  }
1485
1732
  `}},importDeck(){return {query:`
1486
1733
  mutation DeckImport($input: DeckImportInput!) {
1487
1734
  deckImport(input: $input) {
1488
- ${Ke}
1735
+ ${Le}
1489
1736
  }
1490
1737
  }
1491
1738
  `}},createDeckImportFormat(){return {query:`
@@ -1525,25 +1772,25 @@ ${te}`:n;return {query:`
1525
1772
  `}},claimDeck(){return {query:`
1526
1773
  mutation DeckClaim($id: UUID!, $input: DeckClaimInput!) {
1527
1774
  deckClaim(id: $id, input: $input) {
1528
- ${ee}
1775
+ ${re}
1529
1776
  }
1530
1777
  }
1531
1778
  `}},transferDeckOwnership(){return {query:`
1532
1779
  mutation DeckTransferOwnership($id: UUID!, $input: DeckTransferOwnershipInput!) {
1533
1780
  deckTransferOwnership(id: $id, input: $input) {
1534
- ${ee}
1781
+ ${re}
1535
1782
  }
1536
1783
  }
1537
1784
  `}},copyDeck(){return {query:`
1538
1785
  mutation DeckCopy($id: UUID!, $input: DeckCopyInput!) {
1539
1786
  deckCopy(id: $id, input: $input) {
1540
- ${Re}
1787
+ ${Ke}
1541
1788
  }
1542
1789
  }
1543
1790
  `}},publishDeck(){return {query:`
1544
1791
  mutation DeckPublish($id: UUID!, $input: DeckPublishInput!) {
1545
1792
  deckPublish(id: $id, input: $input) {
1546
- ${Ce}
1793
+ ${Ue}
1547
1794
  }
1548
1795
  }
1549
1796
  `}},removeInvalidDeckEntries(){return {query:`
@@ -1555,7 +1802,7 @@ ${te}`:n;return {query:`
1555
1802
  `}},upsertDeckCollaborator(){return {query:`
1556
1803
  mutation DeckCollaboratorUpsert($deckId: UUID!, $accountId: UUID!, $role: DeckCollaboratorRole!) {
1557
1804
  deckCollaboratorUpsert(deckId: $deckId, accountId: $accountId, role: $role) {
1558
- ${Q}
1805
+ ${Z}
1559
1806
  }
1560
1807
  }
1561
1808
  `}},removeDeckCollaborator(){return {query:`
@@ -1567,7 +1814,7 @@ ${te}`:n;return {query:`
1567
1814
  deckPreviewTokenCreate(input: $input) {
1568
1815
  token
1569
1816
  previewToken {
1570
- ${z}
1817
+ ${ee}
1571
1818
  }
1572
1819
  }
1573
1820
  }
@@ -1580,7 +1827,7 @@ ${te}`:n;return {query:`
1580
1827
  deckEmbedTokenCreate(input: $input) {
1581
1828
  token
1582
1829
  embedToken {
1583
- ${Z}
1830
+ ${te}
1584
1831
  }
1585
1832
  }
1586
1833
  }
@@ -1591,7 +1838,7 @@ ${te}`:n;return {query:`
1591
1838
  `}},createDeckAccessTokenIssuer(){return {query:`
1592
1839
  mutation DeckAccessTokenIssuerCreate($input: DeckAccessTokenIssuerCreateInput!) {
1593
1840
  deckAccessTokenIssuerCreate(input: $input) {
1594
- ${K}
1841
+ ${P}
1595
1842
  }
1596
1843
  }
1597
1844
  `}},revokeDeckAccessTokenIssuer(){return {query:`
@@ -1601,7 +1848,7 @@ ${te}`:n;return {query:`
1601
1848
  `}},revokeDeckAccessTokenIssuerSigningKey(){return {query:`
1602
1849
  mutation DeckAccessTokenIssuerSigningKeyRevoke($id: UUID!) {
1603
1850
  deckAccessTokenIssuerSigningKeyRevoke(id: $id) {
1604
- ${K}
1851
+ ${P}
1605
1852
  }
1606
1853
  }
1607
1854
  `}},exchangeDeckAccessToken(){return {query:`
@@ -1609,7 +1856,7 @@ ${te}`:n;return {query:`
1609
1856
  deckAccessTokenExchange(input: $input) {
1610
1857
  token
1611
1858
  accessToken {
1612
- ${Ae}
1859
+ ${Te}
1613
1860
  }
1614
1861
  }
1615
1862
  }
@@ -1636,7 +1883,7 @@ ${te}`:n;return {query:`
1636
1883
  `}},grantDeckApiApplicationAccess(){return {query:`
1637
1884
  mutation DeckApiApplicationAccessGrant($input: DeckAPIApplicationAccessGrantInput!) {
1638
1885
  deckApiApplicationAccessGrant(input: $input) {
1639
- ${U}
1886
+ ${L}
1640
1887
  }
1641
1888
  }
1642
1889
  `}},revokeDeckApiApplicationAccess(){return {query:`
@@ -1647,7 +1894,7 @@ ${te}`:n;return {query:`
1647
1894
  mutation DeckAccessTokenRevoke($id: UUID!) {
1648
1895
  deckAccessTokenRevoke(id: $id)
1649
1896
  }
1650
- `}},deckCreateVariables(e){return {input:e}},deckUpdateVariables(e,t){return {id:e,input:t}},deckEntryAddVariables(e){return {input:e}},deckEntryUpdateVariables(e,t){return {id:e,input:t}},deckEntryRemoveVariables(e,t){return {id:e,expectedDraftRevision:t}},deckEntryReorderVariables(e,t){return {deckId:e,input:t}},deckEntriesReplaceVariables(e,t){return {deckId:e,input:t}},deckImportVariables(e){return {input:e}},deckImportFormatCreateVariables(e){return {input:e}},deckImportFormatUpdateVariables(e,t){return {id:e,input:t}},deckImportFormatTestVariables(e){return {input:e}},deckUpsertByExternalRefVariables(e){return {input:e}},deckClaimVariables(e,t){return {id:e,input:t}},deckTransferOwnershipVariables(e,t){return {id:e,input:t}},deckCopyVariables(e,t){return {id:e,input:t}},deckPublishVariables(e,t){return {id:e,input:t}},deckValidateVariables(e,t){return t===void 0?{id:e}:{id:e,input:t}},deckRemoveInvalidEntriesVariables(e,t){return {id:e,input:t}},deckHydrateEntriesVariables(e){return {input:e}},deckExportVariables(e,t){return {id:e,format:t}},deckVersionDiffVariables(e,t){return {fromVersionId:e,toVersionId:t}},deckCollaboratorVariables(e,t,r){return r===void 0?{deckId:e,accountId:t}:{deckId:e,accountId:t,role:r}},deckPreviewTokenCreateVariables(e){return {input:e}},deckEmbedTokenCreateVariables(e){return {input:e}},deckAccessTokenIssuerCreateVariables(e){return {input:e}},deckAccessTokenExchangeVariables(e){return {input:e}},deckSessionTokenExchangeVariables(e){return {input:e}},deckApiApplicationAccessesVariables(e,t){return t===void 0?{deckId:e}:{deckId:e,includeRevoked:t}},myDeckApiApplicationAccessesVariables(e){return e===void 0?{}:{applicationId:e}},deckApiApplicationAccessGrantVariables(e){return {input:e}},deckApiApplicationAccessRevokeVariables(e,t){return {deckId:e,apiApplicationId:t}},gameCreateVariables(e){return {input:e}},gameUpdateVariables(e,t){return {id:e,input:t}},datasetImportPreviewVariables(e){return {input:e}},datasetImportValidateVariables(e){return {input:e}},datasetImportFromFileVariables(e){return {input:e}},datasetImportFromPayloadVariables(e){return {input:e}},datasetImportFromUrlVariables(e){return {input:e}},gameImportPreviewVariables(e){return {input:e}},gameImportFromFileVariables(e){return {input:e}},gameImportFromPayloadVariables(e){return {input:e}},gameImportFromUrlVariables(e){return {input:e}},datasetRecordsUpsertVariables(e){return {input:e}},datasetRecordsDeleteVariables(e){return {input:e}},fileUploadRequestVariables(e){return {input:e}},datasetExportVariables(e){return {input:e}},fetchMe(){return {query:`
1897
+ `}},deckCreateVariables(e){return {input:e}},deckUpdateVariables(e,t){return {id:e,input:t}},deckEntryAddVariables(e){return {input:e}},deckEntryUpdateVariables(e,t){return {id:e,input:t}},deckEntryRemoveVariables(e,t){return {id:e,expectedDraftRevision:t}},deckEntryReorderVariables(e,t){return {deckId:e,input:t}},deckEntriesReplaceVariables(e,t){return {deckId:e,input:t}},deckImportVariables(e){return {input:e}},deckImportFormatCreateVariables(e){return {input:e}},deckImportFormatUpdateVariables(e,t){return {id:e,input:t}},deckImportFormatTestVariables(e){return {input:e}},deckUpsertByExternalRefVariables(e){return {input:e}},deckClaimVariables(e,t){return {id:e,input:t}},deckTransferOwnershipVariables(e,t){return {id:e,input:t}},deckCopyVariables(e,t){return {id:e,input:t}},deckPublishVariables(e,t){return {id:e,input:t}},deckValidateVariables(e,t){return t===void 0?{id:e}:{id:e,input:t}},deckRemoveInvalidEntriesVariables(e,t){return {id:e,input:t}},deckHydrateEntriesVariables(e){return {input:e}},deckExportVariables(e,t){return {id:e,format:t}},deckVersionDiffVariables(e,t){return {fromVersionId:e,toVersionId:t}},deckCollaboratorVariables(e,t,r){return r===void 0?{deckId:e,accountId:t}:{deckId:e,accountId:t,role:r}},deckPreviewTokenCreateVariables(e){return {input:e}},deckEmbedTokenCreateVariables(e){return {input:e}},deckAccessTokenIssuerCreateVariables(e){return {input:e}},deckAccessTokenExchangeVariables(e){return {input:e}},deckSessionTokenExchangeVariables(e){return {input:e}},deckApiApplicationAccessesVariables(e,t){return t===void 0?{deckId:e}:{deckId:e,includeRevoked:t}},myDeckApiApplicationAccessesVariables(e){return e===void 0?{}:{applicationId:e}},deckApiApplicationAccessGrantVariables(e){return {input:e}},deckApiApplicationAccessRevokeVariables(e,t){return {deckId:e,apiApplicationId:t}},gameCreateVariables(e){return {input:e}},gameUpdateVariables(e,t){return {id:e,input:t}},datasetImportPreviewVariables(e){return {input:e}},datasetImportValidateVariables(e){return {input:e}},datasetImportFromFileVariables(e){return {input:e}},datasetImportFromPayloadVariables(e){return {input:e}},datasetImportFromUrlVariables(e){return {input:e}},gameImportPreviewVariables(e){return {input:e}},gameImportFromFileVariables(e){return {input:e}},gameImportFromPayloadVariables(e){return {input:e}},gameImportFromUrlVariables(e){return {input:e}},datasetRecordsUpsertVariables(e){return {input:e}},datasetRecordsDeleteVariables(e){return {input:e}},fileUploadRequestVariables(e){return {input:e}},createScanJobVariables(e){return {input:e}},submitScanFeedbackVariables(e){return {input:e}},scanMetricsVariables(e){return {input:e}},resolveScanTemplateVariables(e){return {input:e}},scanTemplatesVariables(e){return {input:e}},createScanTemplateVariables(e){return {input:e}},updateScanTemplateVariables(e,t){return {id:e,input:t}},previewScanTemplateVariables(e){return {input:e}},gameScanRegionsVariables(e,t,r){return r===void 0?{publisherSlug:e,gameKey:t}:{publisherSlug:e,gameKey:t,includeInactive:r}},datasetExportVariables(e){return {input:e}},fetchMe(){return {query:`
1651
1898
  query FetchMe {
1652
1899
  fetchMe {
1653
1900
  application {
@@ -1669,6 +1916,6 @@ ${te}`:n;return {query:`
1669
1916
  }
1670
1917
  }
1671
1918
  }
1672
- `}}},d=class{totalCount;pageInfo;items;nextPageLoader;constructor(e,t={}){this.totalCount=e.totalCount,this.pageInfo=e.pageInfo,this.items=e.edges.map(r=>t.itemTransformer?t.itemTransformer(r.node):r.node),this.nextPageLoader=t.nextPageLoader;}get hasNextPage(){return this.pageInfo.hasNextPage}get hasPreviousPage(){return this.pageInfo.hasPreviousPage}get endCursor(){return this.pageInfo.endCursor}get startCursor(){return this.pageInfo.startCursor}get length(){return this.items.length}get isEmpty(){return this.items.length===0}get first(){return this.items[0]}get last(){return this.items[this.items.length-1]}async nextPage(){if(!this.hasNextPage)return null;if(!this.nextPageLoader)throw new Error("No next page loader configured");return this.endCursor?this.nextPageLoader(this.endCursor):null}async*[Symbol.asyncIterator](){let e=this;for(;e;){for(let t of e.items)yield t;if(!e.hasNextPage)break;e=await e.nextPage();}}async forEach(e){let t=0;for await(let r of this)await e(r,t++);}async map(e){let t=[],r=0;for await(let s of this)t.push(await e(s,r++));return t}async filter(e){let t=[],r=0;for await(let s of this)await e(s,r++)&&t.push(s);return t}async find(e){let t=0;for await(let r of this)if(await e(r,t++))return r}async take(e){let t=[];for await(let r of this){if(t.length>=e)break;t.push(r);}return t}async toArray(){let e=[];for await(let t of this)e.push(t);return e}async*batches(){let e=this;for(;e&&(e.items.length>0&&(yield e.items),!!e.hasNextPage);)e=await e.nextPage();}each(){return this}};var Je="https://carddb.xtda.org/query",Oe=3e4,Ge=1e4,Me=300,Ne=3,je=2,Ye=1e3,He=3e4,Xe=class pe{apiKey;publishableKey;secretKey;accessToken;legacyApiKey;environment;endpoint;timeout;openTimeout;defaultPublisher;defaultGame;allowedPublishers;allowedGames;logger;logLevel;retryOnRateLimit;maxRetries;retryOnNetworkError;maxNetworkRetries;retryBaseDelay;retryMaxDelay;cache;cacheTtl;cacheTtls;constructor(t={}){this.legacyApiKey=t.apiKey,this.publishableKey=t.publishableKey,this.secretKey=t.secretKey,this.accessToken=t.accessToken,this.apiKey=t.apiKey??t.publishableKey??t.secretKey,this.environment=t.environment,this.endpoint=t.endpoint??Je,this.timeout=t.timeout??Oe,this.openTimeout=t.openTimeout??Ge,this.defaultPublisher=t.defaultPublisher,this.defaultGame=t.defaultGame,this.allowedPublishers=t.allowedPublishers,this.allowedGames=t.allowedGames,this.logger=t.logger,this.logLevel=t.logLevel??"info",this.retryOnRateLimit=t.retryOnRateLimit??false,this.maxRetries=t.maxRetries??Ne,this.retryOnNetworkError=t.retryOnNetworkError??true,this.maxNetworkRetries=t.maxNetworkRetries??je,this.retryBaseDelay=t.retryBaseDelay??Ye,this.retryMaxDelay=t.retryMaxDelay??He,this.cache=t.cache,this.cacheTtl=t.cacheTtl??Me,this.cacheTtls=t.cacheTtls??{};}calculateRetryDelay(t){let r=this.retryBaseDelay*Math.pow(2,t),s=Math.min(r,this.retryMaxDelay),i=s*.25*(Math.random()*2-1);return Math.round(s+i)}cacheTtlFor(t){return this.cacheTtls[t]??this.cacheTtl}resolvePublisher(t){return t??this.defaultPublisher}resolveGame(t){return t??this.defaultGame}validatePublisher(t){if(this.allowedPublishers&&!this.allowedPublishers.includes(t))throw new b(`Publisher '${t}' is not in the allowed publishers list`)}validateGame(t,r){if(!this.allowedGames)return;let s=this.allowedGames[t];if(s&&!s.includes(r))throw new b(`Game '${r}' is not allowed for publisher '${t}'`)}validateAccess(t,r){t&&(this.validatePublisher(t),r&&this.validateGame(t,r));}requireSecretCredential(t){if(!(!this.accessToken&&(this.legacyApiKey||this.secretKey&&!this.publishableKey)))throw new b(`${t} requires a server-side secretKey or legacy apiKey credential`)}requestApiKey(){return this.legacyApiKey??this.publishableKey??this.secretKey}configApiKey(){return this.legacyApiKey}shouldLog(t){let r={debug:0,info:1,warn:2,error:3};return r[t]>=r[this.logLevel]}merge(t){return new pe({apiKey:t.apiKey??this.legacyApiKey,publishableKey:t.publishableKey??this.publishableKey,secretKey:t.secretKey??this.secretKey,accessToken:t.accessToken??this.accessToken,environment:t.environment??this.environment,endpoint:t.endpoint??this.endpoint,timeout:t.timeout??this.timeout,openTimeout:t.openTimeout??this.openTimeout,defaultPublisher:t.defaultPublisher??this.defaultPublisher,defaultGame:t.defaultGame??this.defaultGame,allowedPublishers:t.allowedPublishers??this.allowedPublishers,allowedGames:t.allowedGames??this.allowedGames,logger:t.logger??this.logger,logLevel:t.logLevel??this.logLevel,retryOnRateLimit:t.retryOnRateLimit??this.retryOnRateLimit,maxRetries:t.maxRetries??this.maxRetries,retryOnNetworkError:t.retryOnNetworkError??this.retryOnNetworkError,maxNetworkRetries:t.maxNetworkRetries??this.maxNetworkRetries,retryBaseDelay:t.retryBaseDelay??this.retryBaseDelay,retryMaxDelay:t.retryMaxDelay??this.retryMaxDelay,cache:t.cache??this.cache,cacheTtl:t.cacheTtl??this.cacheTtl,cacheTtls:t.cacheTtls??this.cacheTtls})}},me="0.1.0";function We(){if(typeof globalThis<"u"&&"Bun"in globalThis){let e=globalThis.Bun&&typeof globalThis.Bun=="object"&&globalThis.Bun.version;return {name:"bun",version:typeof e=="string"?e:"unknown"}}if(typeof globalThis<"u"&&"Deno"in globalThis){let e=globalThis.Deno&&typeof globalThis.Deno=="object"&&globalThis.Deno.version&&typeof globalThis.Deno.version=="object"&&globalThis.Deno.version.deno;return {name:"deno",version:typeof e=="string"?e:"unknown"}}return typeof process<"u"&&process.versions&&process.versions.node?{name:"node",version:process.versions.node}:typeof navigator<"u"&&navigator.userAgent?Qe(navigator.userAgent):{name:"unknown",version:"unknown"}}function Qe(e){let t=e.match(/Edg\/(\d+(?:\.\d+)*)/);if(t)return {name:"edge",version:t[1]};let r=e.match(/Chrome\/(\d+(?:\.\d+)*)/);if(r&&!e.includes("Edg/"))return {name:"chrome",version:r[1]};let s=e.match(/Firefox\/(\d+(?:\.\d+)*)/);if(s)return {name:"firefox",version:s[1]};let i=e.match(/Version\/(\d+(?:\.\d+)*).*Safari/);return i?{name:"safari",version:i[1]}:{name:"browser",version:"unknown"}}function ze(){let e=We();return `CardDB-SDK/js/${me} (${e.name}/${e.version})`}function Mt(){return me}var ge=null;function Ze(){return ge}var et=class{config;constructor(e){this.config=e;}async execute(e,t={}){let r=this.extractOperationName(e),s=0,i=0;for(;;)try{let n=Date.now();this.logRequest(r,t);let c=await this.fetch(e,t),o=Date.now()-n,h=await this.handleResponse(c);return this.logResponse(r,o),h}catch(n){if(n instanceof q&&this.config.retryOnRateLimit&&s<this.config.maxRetries){s++;let c=n.retryAfter??60;this.logRateLimitRetry(r,s,c),await this.sleep(c*1e3);continue}if(this.isRetryableNetworkError(n)&&this.config.retryOnNetworkError&&i<this.config.maxNetworkRetries){let c=this.config.calculateRetryDelay(i);this.logNetworkRetry(r,i+1,c,n),i++,await this.sleep(c);continue}if(n instanceof J&&this.config.retryOnNetworkError&&i<this.config.maxNetworkRetries){let c=this.config.calculateRetryDelay(i);this.logNetworkRetry(r,i+1,c,n),i++,await this.sleep(c);continue}throw n}}isRetryableNetworkError(e){return e instanceof E||e instanceof _}async fetch(e,t){let r=new AbortController,s=setTimeout(()=>r.abort(),this.config.timeout),i=this.config.requestApiKey();try{return await fetch(this.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","User-Agent":ze(),...this.config.accessToken?{Authorization:`Bearer ${this.config.accessToken}`}:{},...!this.config.accessToken&&i?{"X-API-Key":i}:{}},body:JSON.stringify({query:e,variables:t}),signal:r.signal})}catch(n){throw n instanceof Error?n.name==="AbortError"?(this.logError("Request timed out"),new _("Request timed out")):(this.logError(`Connection failed: ${n.message}`),new E(`Connection failed: ${n.message}`)):new E("Connection failed")}finally{clearTimeout(s);}}async handleResponse(e){switch(this.extractRateLimitInfo(e),e.status){case 200:return this.handleSuccessResponse(e);case 401:throw new B("Invalid or missing API key");case 429:return this.handleRateLimitResponse(e);default:if(e.status>=400&&e.status<500)return this.handleClientError(e);if(e.status>=500){let t=await this.parseBody(e);throw new J(`Server error (${e.status})`,{status:e.status,response:t})}throw new y(`Unexpected response status: ${e.status}`)}}async handleSuccessResponse(e){let t=await this.parseBody(e);return t.errors&&t.errors.length>0&&this.handleGraphQLErrors(t.errors,t),t.data??{}}handleGraphQLErrors(e,t){let r=e[0],s=r.message||"GraphQL error";switch(r.extensions?.code){case "UNAUTHENTICATED":throw new B(s,t);case "RATE_LIMITED":throw new q(s,{response:t});case "NOT_FOUND":throw new y(s,t);case "VALIDATION_ERROR":case "BAD_USER_INPUT":throw new V(s,{errors:e,response:t});default:throw new se(s,{errors:e,response:t})}}async handleRateLimitResponse(e){let t=parseInt(e.headers.get("Retry-After")??"60",10),r=parseInt(e.headers.get("X-RateLimit-Limit")??"",10)||null,s=parseInt(e.headers.get("X-RateLimit-Remaining")??"",10)||null,i=parseInt(e.headers.get("X-RateLimit-Reset")??"",10)||null,n=i?new Date(i*1e3):null,c=await this.parseBody(e);throw new q("Rate limit exceeded",{retryAfter:t,limit:r,remaining:s,resetAt:n,response:c})}async handleClientError(e){let t=await this.parseBody(e),r=t.errors?.[0]?.message??`Client error (${e.status})`;throw new V(r,{response:t})}async parseBody(e){try{return await e.json()}catch{return {raw:await e.text()}}}extractRateLimitInfo(e){let t=parseInt(e.headers.get("X-RateLimit-Limit")??"",10)||null,r=parseInt(e.headers.get("X-RateLimit-Remaining")??"",10)||null,s=parseInt(e.headers.get("X-RateLimit-Reset")??"",10)||null;ge={limit:t,remaining:r,reset:s};}extractOperationName(e){let t=e.match(/(?:query|mutation)\s+(\w+)/);return t?t[1]:"Unknown"}sleep(e){return new Promise(t=>setTimeout(t,e))}logRequest(e,t){!this.config.logger||!this.config.shouldLog("debug")||this.config.logger.debug(`[CardDB] Executing ${e}`,{variables:t});}logResponse(e,t){!this.config.logger||!this.config.shouldLog("info")||this.config.logger.info(`[CardDB] ${e} completed in ${t}ms`);}logRateLimitRetry(e,t,r){!this.config.logger||!this.config.shouldLog("warn")||this.config.logger.warn(`[CardDB] Rate limited on ${e}, retry ${t}/${this.config.maxRetries} after ${r}s`);}logNetworkRetry(e,t,r,s){if(!this.config.logger||!this.config.shouldLog("warn"))return;let i=s instanceof Error?s.name:"Unknown";this.config.logger.warn(`[CardDB] ${i} on ${e}, retry ${t}/${this.config.maxNetworkRetries} after ${r}ms`);}logError(e){!this.config.logger||!this.config.shouldLog("error")||this.config.logger.error(`[CardDB] ${e}`);}};function tt(e,t,r){let s=Object.entries(r).filter(([,i])=>i!==void 0).sort(([i],[n])=>i.localeCompare(n)).map(([i,n])=>`${i}=${JSON.stringify(n)}`).join("&");return `carddb:${e}:${t}:${s}`}async function rt(e,t){let r=e.get(t);return r}async function st(e,t,r,s){let i=e.set(t,r,s);i instanceof Promise&&await i;}var m=class{connection;config;constructor(e,t){this.connection=e,this.config=t;}resolvePublisher(e){let t=this.config.resolvePublisher(e);if(!t)throw new Error("publisher_slug is required (no default configured)");return t}resolveGame(e){let t=this.config.resolveGame(e);if(!t)throw new Error("game_key is required (no default configured)");return t}validateAccess(e,t){this.config.validateAccess(e,t);}async withCache(e,t,r,s){let i=r.cache??!!this.config.cache,n=this.config.cache;if(!i||!n)return s();let c=await rt(n,e);if(c!==null)return c;let o=await s();if(o!=null){let h=this.config.cacheTtlFor(t);await st(n,e,o,h);}return o}cacheKey(e,t,r){return tt(e,t,r)}},it=class extends m{constructor(e,t){super(e,t);}async search(e={}){let{query:t,variables:r}=a.searchPublishers({search:e.search,first:e.first,after:e.after}),s=this.cacheKey("publishers","search",r),i=await this.withCache(s,"publishers",e,async()=>(await this.connection.execute(t,r)).searchPublishers);return new d(i,{nextPageLoader:async n=>this.search({...e,after:n})})}async get(e,t={}){let r=this.isUUID(e),s=this.cacheKey("publishers","get",{[r?"id":"slug"]:e});return this.withCache(s,"publishers",t,async()=>{if(r){let{query:i}=a.fetchPublisherById();return (await this.connection.execute(i,{id:e})).fetchPublisher??null}else {let{query:i}=a.fetchPublisherBySlug();return (await this.connection.execute(i,{slug:e})).fetchPublisher??null}})}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("publishers","getMany",{slugs:e});return this.withCache(r,"publishers",t,async()=>{let{query:s}=a.fetchPublishers();return (await this.connection.execute(s,{slugs:e})).fetchPublishers??[]})}isUUID(e){return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}},at=class extends m{constructor(e,t){super(e,t);}async list(e,t={}){let{query:r,variables:s}=a.listGames({publisherId:e,first:t.first,after:t.after,includeArchived:t.includeArchived}),i=this.cacheKey("games","list",s),n=await this.withCache(i,"games",t,async()=>(await this.connection.execute(r,s)).games);return new d(n,{nextPageLoader:async c=>this.list(e,{...t,after:c})})}async getByKey(e){let t=this.cacheKey("games","getByKey",{publisherId:e.publisherId,publisherSlug:e.publisherSlug,gameKey:e.gameKey});return this.withCache(t,"games",e,async()=>{let{query:r,variables:s}=a.game(e);return (await this.connection.execute(r,s)).game??null})}async getBySlug(e){let t=this.cacheKey("games","getBySlug",{publisherId:e.publisherId,publisherSlug:e.publisherSlug,gameSlug:e.gameSlug});return this.withCache(t,"games",e,async()=>{let{query:r,variables:s}=a.game(e);return (await this.connection.execute(r,s)).game??null})}async create(e){this.config.requireSecretCredential("games.create");let{query:t}=a.createGame();return (await this.connection.execute(t,a.gameCreateVariables(e))).gameCreate}async update(e,t){this.config.requireSecretCredential("games.update");let{query:r}=a.updateGame();return (await this.connection.execute(r,a.gameUpdateVariables(e,t))).gameUpdate}async search(e={}){let t=this.config.resolvePublisher(e.publisherSlug);t&&this.validateAccess(t);let{query:r,variables:s}=a.searchGames({publisherSlug:t,search:e.search,first:e.first,after:e.after}),i=this.cacheKey("games","search",s),n=await this.withCache(i,"games",e,async()=>(await this.connection.execute(r,s)).searchGames);return new d(n,{nextPageLoader:async c=>this.search({...e,after:c})})}async get(e,t,r){if(typeof t=="string"){let s=e,i=t,n=r??{};this.validateAccess(s,i);let c=this.cacheKey("games","getByKeys",{publisherSlug:s,gameKey:i});return this.withCache(c,"games",n,async()=>{let{query:o}=a.fetchGameByKeys();return (await this.connection.execute(o,{publisherSlug:s,gameKey:i})).fetchGame??null})}else {let s=e,i=t??{},n=this.cacheKey("games","get",{id:s});return this.withCache(n,"games",i,async()=>{let{query:c}=a.fetchGameById();return (await this.connection.execute(c,{id:s})).fetchGame??null})}}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("games","getMany",{ids:e});return this.withCache(r,"games",t,async()=>{let{query:s}=a.fetchGames();return (await this.connection.execute(s,{ids:e})).fetchGames??[]})}},nt=class extends m{constructor(e,t){super(e,t);}async list(e,t={}){let{query:r,variables:s}=a.listDatasets({publisherId:e,gameId:t.gameId,includeArchived:t.includeArchived,purpose:t.purpose,first:t.first,after:t.after}),i=this.cacheKey("datasets","list",s),n=await this.withCache(i,"datasets",t,async()=>(await this.connection.execute(r,s)).datasets);return new d(n,{nextPageLoader:async c=>this.list(e,{...t,after:c})})}async getByKey(e){let t=this.cacheKey("datasets","getByKey",{publisherId:e.publisherId,gameId:e.gameId,datasetKey:e.datasetKey});return this.withCache(t,"datasets",e,async()=>{let{query:r,variables:s}=a.dataset(e);return (await this.connection.execute(r,s)).dataset??null})}async getSchema(e){return (typeof e=="string"?await this.withCache(this.cacheKey("datasets","getSchema",{id:e}),"datasets",{},async()=>{let{query:r,variables:s}=a.dataset({id:e});return (await this.connection.execute(r,s)).dataset??null}):await this.getByKey(e))?.schema??null}async search(e={}){let t=this.config.resolvePublisher(e.publisherSlug),r=this.config.resolveGame(e.gameKey);t&&this.validateAccess(t,r);let{query:s,variables:i}=a.searchDatasets({publisherSlug:t,gameKey:r,search:e.search,purpose:e.purpose,first:e.first,after:e.after}),n=this.cacheKey("datasets","search",i),c=await this.withCache(n,"datasets",e,async()=>(await this.connection.execute(s,i)).searchDatasets);return new d(c,{nextPageLoader:async o=>this.search({...e,after:o})})}async get(e,t,r,s){if(typeof t=="string"&&typeof r=="string"){let i=e,n=t,c=s??{};this.validateAccess(i,n);let o=this.cacheKey("datasets","getByKeys",{publisherSlug:i,gameKey:n,datasetKey:r});return this.withCache(o,"datasets",c,async()=>{let{query:h}=a.fetchDatasetByKeys();return (await this.connection.execute(h,{publisherSlug:i,gameKey:n,datasetKey:r})).fetchDataset??null})}else {let i=e,n=t??{},c=this.cacheKey("datasets","get",{id:i});return this.withCache(c,"datasets",n,async()=>{let{query:o}=a.fetchDatasetById();return (await this.connection.execute(o,{id:i})).fetchDataset??null})}}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("datasets","getMany",{ids:e});return this.withCache(r,"datasets",t,async()=>{let{query:s}=a.fetchDatasets();return (await this.connection.execute(s,{ids:e})).fetchDatasets??[]})}},ct=class extends m{constructor(e,t){super(e,t);}async fetch(e,t={}){let r=this.cacheKey("decks","fetch",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.fetchDeckById();return (await this.connection.execute(s,{id:e})).fetchDeck??null})}async get(e,t={}){let r=this.cacheKey("decks","get",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckById();return (await this.connection.execute(s,{id:e})).deck??null})}async fetchMine(e,t={}){let r=this.cacheKey("decks","fetchMine",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.myDeck();return (await this.connection.execute(s,{id:e})).myDeck??null})}async fetchBySlug(e,t,r,s={}){let i=this.cacheKey("decks","fetchBySlug",{publisherSlug:e,gameKey:t,slug:r});return this.withCache(i,"decks",s,async()=>{let{query:n}=a.fetchDeckBySlug();return (await this.connection.execute(n,{publisherSlug:e,gameKey:t,slug:r})).fetchDeckBySlug??null})}async getBySlug(e,t,r,s={}){let i=this.cacheKey("decks","getBySlug",{publisherSlug:e,gameKey:t,slug:r});return this.withCache(i,"decks",s,async()=>{let{query:n}=a.deckBySlug();return (await this.connection.execute(n,{publisherSlug:e,gameKey:t,slug:r})).deckBySlug??null})}async fetchByExternalRef(e,t={}){let r=this.cacheKey("decks","fetchByExternalRef",{externalRef:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.fetchDeckByExternalRef();return (await this.connection.execute(s,{externalRef:e})).fetchDeckByExternalRef??null})}async getByExternalRef(e,t={}){let r=this.cacheKey("decks","getByExternalRef",{externalRef:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckByExternalRef();return (await this.connection.execute(s,{externalRef:e})).deckByExternalRef??null})}async listMine(e={}){let{query:t,variables:r}=a.listMyDecks({first:e.first,after:e.after,includeArchived:e.includeArchived}),s=this.cacheKey("decks","listMine",r),i=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).myDecks);return new d(i,{nextPageLoader:async n=>this.listMine({...e,after:n})})}async listViewer(e={}){let{query:t,variables:r}=a.viewerDecks({filter:e.filter,first:e.first,after:e.after}),s=this.cacheKey("decks","listViewer",r),i=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).viewerDecks);return new d(i,{nextPageLoader:async n=>this.listViewer({...e,after:n})})}async listApp(e={}){this.config.requireSecretCredential("decks.listApp");let{query:t,variables:r}=a.appDecks({filter:e.filter,first:e.first,after:e.after}),s=this.cacheKey("decks","listApp",r),i=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).appDecks);return new d(i,{nextPageLoader:async n=>this.listApp({...e,after:n})})}async listPublic(e={}){let{query:t,variables:r}=a.publicDecks({filter:e.filter,first:e.first,after:e.after}),s=this.cacheKey("decks","listPublic",r),i=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).publicDecks);return new d(i,{nextPageLoader:async n=>this.listPublic({...e,after:n})})}async fetchVersion(e,t={}){let r=this.cacheKey("decks","fetchVersion",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckVersion();return (await this.connection.execute(s,{id:e})).deckVersion??null})}async listVersions(e,t={}){let{query:r,variables:s}=a.deckVersions({first:t.first,after:t.after}),i={deckId:e,...s},n=this.cacheKey("decks","listVersions",i),c=await this.withCache(n,"decks",t,async()=>(await this.connection.execute(r,i)).deckVersions);return new d(c,{nextPageLoader:async o=>this.listVersions(e,{...t,after:o})})}async preview(e,t={}){let r=this.cacheKey("decks","preview",{token:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckPreview();return (await this.connection.execute(s,{token:e})).deckPreview??null})}async embed(e,t={}){let r=this.cacheKey("decks","embed",{token:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckEmbed();return (await this.connection.execute(s,{token:e})).deckEmbed??null})}async access(e,t={}){let r=this.cacheKey("decks","access",{token:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckAccess();return (await this.connection.execute(s,{token:e})).deckAccess??null})}async draftDiff(e,t={}){let r=this.cacheKey("decks","draftDiff",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckDraftDiff();return (await this.connection.execute(s,{id:e})).deckDraftDiff})}async versionDiff(e,t,r={}){let s=a.deckVersionDiffVariables(e,t),i=this.cacheKey("decks","versionDiff",s);return this.withCache(i,"decks",r,async()=>{let{query:n}=a.deckVersionDiff();return (await this.connection.execute(n,s)).deckVersionDiff})}async validate(e,t,r={}){let s=a.deckValidateVariables(e,t),i=this.cacheKey("decks","validate",s);return this.withCache(i,"decks",r,async()=>{let{query:n}=a.deckValidate();return (await this.connection.execute(n,s)).deckValidate})}async hydrateDeckEntries(e,t={}){let r=a.deckHydrateEntriesVariables(e),s=this.cacheKey("decks","hydrateDeckEntries",r);return this.withCache(s,"decks",t,async()=>{let{query:i}=a.deckHydrateEntries();return (await this.connection.execute(i,r)).deckHydrateEntries})}async exportDeck(e,t="SIMPLE_TEXT",r={}){let s=a.deckExportVariables(e,t),i=this.cacheKey("decks","exportDeck",s);return this.withCache(i,"decks",r,async()=>{let{query:n}=a.deckExport();return (await this.connection.execute(n,s)).deckExport})}async sectionDefinitions(e={}){let{query:t,variables:r}=a.deckSectionDefinitions({publisherSlug:e.publisherSlug,gameKey:e.gameKey,gameId:e.gameId,rulesetKey:e.rulesetKey,rulesetVersionId:e.rulesetVersionId}),s=this.cacheKey("decks","sectionDefinitions",r);return this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).deckSectionDefinitions)}async listCollaborators(e,t={}){let r=this.cacheKey("decks","listCollaborators",{deckId:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckCollaborators();return (await this.connection.execute(s,{deckId:e})).deckCollaborators})}async listPreviewTokens(e,t={}){let r=this.cacheKey("decks","listPreviewTokens",{deckId:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckPreviewTokens();return (await this.connection.execute(s,{deckId:e})).deckPreviewTokens})}async listEmbedTokens(e,t={}){let r=this.cacheKey("decks","listEmbedTokens",{deckId:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckEmbedTokens();return (await this.connection.execute(s,{deckId:e})).deckEmbedTokens})}async listAccessTokenIssuers(e,t={}){let r=this.cacheKey("decks","listAccessTokenIssuers",{deckId:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckAccessTokenIssuers();return (await this.connection.execute(s,{deckId:e})).deckAccessTokenIssuers})}async listApiApplicationAccesses(e,t={}){let r=a.deckApiApplicationAccessesVariables(e,t.includeRevoked),s=this.cacheKey("decks","listApiApplicationAccesses",r);return this.withCache(s,"decks",t,async()=>{let{query:i}=a.deckApiApplicationAccesses();return (await this.connection.execute(i,r)).deckApiApplicationAccesses})}async listMyApiApplicationAccesses(e={}){let t=a.myDeckApiApplicationAccessesVariables(e.applicationId),r=this.cacheKey("decks","listMyApiApplicationAccesses",t);return this.withCache(r,"decks",e,async()=>{let{query:s}=a.myDeckApiApplicationAccesses();return (await this.connection.execute(s,t)).myDeckApiApplicationAccesses})}async create(e){let{query:t}=a.createDeck(),r=a.deckCreateVariables(e);return (await this.connection.execute(t,r)).deckCreate}async update(e,t){let{query:r}=a.updateDeck(),s=a.deckUpdateVariables(e,t);return (await this.connection.execute(r,s)).deckUpdate}async updateMetadata(e,t){return this.update(e,t)}async upsertByExternalRef(e){this.config.requireSecretCredential("decks.upsertByExternalRef");let{query:t}=a.upsertDeckByExternalRef(),r=a.deckUpsertByExternalRefVariables(e);return (await this.connection.execute(t,r)).deckUpsertByExternalRef}async claim(e,t){let{query:r}=a.claimDeck(),s=a.deckClaimVariables(e,t);return (await this.connection.execute(r,s)).deckClaim}async transferOwnership(e,t){let{query:r}=a.transferDeckOwnership(),s=a.deckTransferOwnershipVariables(e,t);return (await this.connection.execute(r,s)).deckTransferOwnership}async copy(e,t){let{query:r}=a.copyDeck(),s=a.deckCopyVariables(e,t);return (await this.connection.execute(r,s)).deckCopy}async addEntry(e){let{query:t}=a.addDeckEntry(),r=a.deckEntryAddVariables(e);return (await this.connection.execute(t,r)).deckEntryAdd}async updateEntry(e,t){let{query:r}=a.updateDeckEntry(),s=a.deckEntryUpdateVariables(e,t);return (await this.connection.execute(r,s)).deckEntryUpdate}async removeEntry(e,t){let{query:r}=a.removeDeckEntry(),s=a.deckEntryRemoveVariables(e,t);return (await this.connection.execute(r,s)).deckEntryRemove}async reorderEntries(e,t){let{query:r}=a.reorderDeckEntries(),s=a.deckEntryReorderVariables(e,t);return (await this.connection.execute(r,s)).deckEntryReorder}async replaceEntries(e,t){let{query:r}=a.replaceDeckEntries(),s=a.deckEntriesReplaceVariables(e,t);return (await this.connection.execute(r,s)).deckEntriesReplace}async importDeck(e){let{query:t}=a.importDeck(),r=a.deckImportVariables(e);return (await this.connection.execute(t,r)).deckImport}async listImportFormats(e,t={}){let{query:r,variables:s}=a.deckImportFormats({gameId:e,includeArchived:t.includeArchived,first:t.first,after:t.after}),i=this.cacheKey("decks","listImportFormats",s),n=await this.withCache(i,"decks",t,async()=>(await this.connection.execute(r,s)).deckImportFormats);return new d(n,{nextPageLoader:async c=>this.listImportFormats(e,{...t,after:c})})}async fetchImportFormat(e,t={}){let r=this.cacheKey("decks","fetchImportFormat",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckImportFormat();return (await this.connection.execute(s,{id:e})).deckImportFormat??null})}async testImportFormat(e){let{query:t}=a.deckImportFormatTest(),r=a.deckImportFormatTestVariables(e);return (await this.connection.execute(t,r)).deckImportFormatTest}async createImportFormat(e){let{query:t}=a.createDeckImportFormat(),r=a.deckImportFormatCreateVariables(e);return (await this.connection.execute(t,r)).deckImportFormatCreate}async updateImportFormat(e,t){let{query:r}=a.updateDeckImportFormat(),s=a.deckImportFormatUpdateVariables(e,t);return (await this.connection.execute(r,s)).deckImportFormatUpdate}async archiveImportFormat(e){let{query:t}=a.archiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatArchive}async unarchiveImportFormat(e){let{query:t}=a.unarchiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatUnarchive}async delete(e){let{query:t}=a.deleteDeck();return !!(await this.connection.execute(t,{id:e})).deckDelete}async archive(e){let{query:t}=a.archiveDeck();return (await this.connection.execute(t,{id:e})).deckArchive}async restore(e){let{query:t}=a.restoreDeck();return (await this.connection.execute(t,{id:e})).deckRestore}async unpublish(e){let{query:t}=a.unpublishDeck();return (await this.connection.execute(t,{id:e})).deckUnpublish}async publish(e,t){let{query:r}=a.publishDeck(),s=a.deckPublishVariables(e,t);return (await this.connection.execute(r,s)).deckPublish}async removeInvalidEntries(e,t){let{query:r}=a.removeInvalidDeckEntries(),s=a.deckRemoveInvalidEntriesVariables(e,t);return (await this.connection.execute(r,s)).deckRemoveInvalidEntries}async upsertCollaborator(e,t,r){let{query:s}=a.upsertDeckCollaborator(),i=a.deckCollaboratorVariables(e,t,r);return (await this.connection.execute(s,i)).deckCollaboratorUpsert}async removeCollaborator(e,t){let{query:r}=a.removeDeckCollaborator(),s=a.deckCollaboratorVariables(e,t);return !!(await this.connection.execute(r,s)).deckCollaboratorRemove}async createPreviewToken(e){let{query:t}=a.createDeckPreviewToken(),r=a.deckPreviewTokenCreateVariables(e);return (await this.connection.execute(t,r)).deckPreviewTokenCreate}async revokePreviewToken(e){let{query:t}=a.revokeDeckPreviewToken();return !!(await this.connection.execute(t,{id:e})).deckPreviewTokenRevoke}async createEmbedToken(e){let{query:t}=a.createDeckEmbedToken(),r=a.deckEmbedTokenCreateVariables(e);return (await this.connection.execute(t,r)).deckEmbedTokenCreate}async revokeEmbedToken(e){let{query:t}=a.revokeDeckEmbedToken();return !!(await this.connection.execute(t,{id:e})).deckEmbedTokenRevoke}async createAccessTokenIssuer(e){let{query:t}=a.createDeckAccessTokenIssuer(),r=a.deckAccessTokenIssuerCreateVariables(e);return (await this.connection.execute(t,r)).deckAccessTokenIssuerCreate}async revokeAccessTokenIssuer(e){let{query:t}=a.revokeDeckAccessTokenIssuer();return !!(await this.connection.execute(t,{id:e})).deckAccessTokenIssuerRevoke}async revokeAccessTokenIssuerSigningKey(e){let{query:t}=a.revokeDeckAccessTokenIssuerSigningKey();return (await this.connection.execute(t,{id:e})).deckAccessTokenIssuerSigningKeyRevoke}async grantApiApplicationAccess(e){let{query:t}=a.grantDeckApiApplicationAccess(),r=a.deckApiApplicationAccessGrantVariables(e);return (await this.connection.execute(t,r)).deckApiApplicationAccessGrant}async revokeApiApplicationAccess(e,t){let{query:r}=a.revokeDeckApiApplicationAccess(),s=a.deckApiApplicationAccessRevokeVariables(e,t);return !!(await this.connection.execute(r,s)).deckApiApplicationAccessRevoke}async exchangeAccessToken(e){this.config.requireSecretCredential("decks.exchangeAccessToken");let{query:t}=a.exchangeDeckAccessToken(),r=a.deckAccessTokenExchangeVariables(e);return (await this.connection.execute(t,r)).deckAccessTokenExchange}async exchangeSessionToken(e){this.config.requireSecretCredential("decks.exchangeSessionToken");let{query:t}=a.exchangeDeckSessionToken(),r=a.deckSessionTokenExchangeVariables(e);return (await this.connection.execute(t,r)).deckSessionTokenExchange}async revokeAccessToken(e){this.config.requireSecretCredential("decks.revokeAccessToken");let{query:t}=a.revokeDeckAccessToken();return !!(await this.connection.execute(t,{id:e})).deckAccessTokenRevoke}async hydrateEntries(e){if(e.entries.length===0)return [];let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=e.entries.map(o=>o.identifier),i=this.cacheKey("decks","hydrateEntries",{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:s}),n=await this.withCache(i,"decks",e,async()=>{let{query:o}=a.fetchRecordsByIdentifier();return (await this.connection.execute(o,{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:s})).fetchRecordsByIdentifier}),c=ot(n,s,e.identifierField);return e.entries.map(o=>({...o,record:c.get(o.identifier)??null}))}};function ot(e,t,r){let s=new Set(t),i=new Map;for(let n of e){let c=r?n.data[r]:Object.values(n.data).find(h=>s.has(String(h)));if(c==null)continue;let o=String(c);s.has(o)&&(i.set(o,n),s.delete(o));}return i}var ut=class extends m{constructor(e,t){super(e,t);}async list(e){let t=C(e.filter),{query:r,variables:s}=a.listDatasetRecords({datasetId:e.datasetId,filter:t,orderBy:e.orderBy,first:e.first,after:e.after,last:e.last,before:e.before,validateSchema:e.validateSchema}),i=this.cacheKey("records","list",s),n=await this.withCache(i,"records",e,async()=>(await this.connection.execute(r,s)).datasetRecords);return new d(n,{nextPageLoader:async c=>this.list({...e,after:c})})}async getByDatasetIdentifier(e){let t=this.cacheKey("records","getByDatasetIdentifier",{datasetId:e.datasetId,identifier:e.identifier,includePricing:e.includePricing??false});return this.withCache(t,"records",e,async()=>{let{query:r,variables:s}=a.datasetRecord({datasetId:e.datasetId,identifier:e.identifier,includePricing:e.includePricing});return (await this.connection.execute(r,s)).datasetRecord??null})}async upsertBatch(e){this.config.requireSecretCredential("records.upsertBatch");let{query:t}=a.upsertDatasetRecords();return (await this.connection.execute(t,a.datasetRecordsUpsertVariables(e))).datasetRecordsUpsert}async deleteBatch(e){this.config.requireSecretCredential("records.deleteBatch");let{query:t}=a.deleteDatasetRecords();return (await this.connection.execute(t,a.datasetRecordsDeleteVariables(e))).datasetRecordsDelete}async getDeleteJob(e,t={}){let r=this.cacheKey("records","getDeleteJob",{id:e});return this.withCache(r,"records",t,async()=>{let{query:s}=a.datasetRecordDeleteJob();return (await this.connection.execute(s,{id:e})).datasetRecordDeleteJob??null})}async listDeleteJobs(e,t={}){let{query:r,variables:s}=a.datasetRecordDeleteJobs({publisherId:e,datasetId:t.datasetId,status:t.status,first:t.first,after:t.after}),i=this.cacheKey("records","listDeleteJobs",s),n=await this.withCache(i,"records",t,async()=>(await this.connection.execute(r,s)).datasetRecordDeleteJobs);return new d(n,{nextPageLoader:async c=>this.listDeleteJobs(e,{...t,after:c})})}async waitForDeleteJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,i=Date.now();for(;;){let n=await this.getDeleteJob(e,{cache:false});if(!n)throw new Error(`Delete job '${e}' was not found`);if(n.status==="COMPLETED"||n.status==="FAILED")return n;if(Date.now()-i>=s)throw new Error(`Timed out waiting for delete job '${e}'`);await new Promise(c=>setTimeout(c,r));}}async search(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=C(e.filter),{query:i,variables:n}=a.searchRecords({publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,filter:s,search:e.search,orderBy:e.orderBy,resolveLinks:e.resolveLinks,first:e.first,after:e.after,validateSchema:e.validateSchema,includePricing:e.includePricing}),c=this.cacheKey("records","search",{...n,includePricing:e.includePricing??false}),o=await this.withCache(c,"records",e,async()=>(await this.connection.execute(i,n)).searchRecords);return new d(o,{nextPageLoader:async h=>this.search({...e,after:h})})}async get(e,t={}){let r=this.cacheKey("records","get",{id:e,includePricing:t.includePricing??false});return this.withCache(r,"records",t,async()=>{let{query:s}=a.fetchRecordById({includePricing:t.includePricing});return (await this.connection.execute(s,{id:e})).fetchRecord??null})}async getByIdentifier(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=this.cacheKey("records","getByIdentifier",{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifier:e.identifier,includePricing:e.includePricing??false});return this.withCache(s,"records",e,async()=>{let{query:i}=a.fetchRecordByIdentifier({includePricing:e.includePricing});return (await this.connection.execute(i,{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifier:e.identifier})).fetchRecordByIdentifier??null})}async getManyByIdentifier(e){if(e.identifiers.length===0)return [];let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=this.cacheKey("records","getManyByIdentifier",{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:e.identifiers,includePricing:e.includePricing??false});return this.withCache(s,"records",e,async()=>{let{query:i}=a.fetchRecordsByIdentifier({includePricing:e.includePricing});return (await this.connection.execute(i,{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:e.identifiers})).fetchRecordsByIdentifier??[]})}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("records","getMany",{ids:e,includePricing:t.includePricing??false});return this.withCache(r,"records",t,async()=>{let{query:s}=a.fetchRecords({includePricing:t.includePricing});return (await this.connection.execute(s,{ids:e})).fetchRecords??[]})}},dt=class extends m{constructor(e,t){super(e,t);}async datasets(e={}){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let{query:s,variables:i}=a.searchDatasets({publisherSlug:t,gameKey:r,search:e.search,purpose:"RULES",first:e.first,after:e.after}),n=this.cacheKey("rules","datasets",i),c=await this.withCache(n,"datasets",e,async()=>(await this.connection.execute(s,i)).searchDatasets);return new d(c,{nextPageLoader:async o=>this.datasets({...e,after:o})})}async list(e={}){return this.searchRuleRecords("rules",e)}async formats(e={}){return this.searchRuleRecords(e.datasetKey??"formats",e)}async searchRuleRecords(e,t){let r=this.resolvePublisher(t.publisherSlug),s=this.resolveGame(t.gameKey),i=t.datasetKey??e;this.validateAccess(r,s);let n=C(t.filter),{query:c,variables:o}=a.searchRecords({publisherSlug:r,gameKey:s,datasetKey:i,filter:n,search:t.search,orderBy:t.orderBy,resolveLinks:t.resolveLinks,first:t.first,after:t.after,validateSchema:t.validateSchema}),h=this.cacheKey("rules","records",o),H=await this.withCache(h,"records",t,async()=>(await this.connection.execute(c,o)).searchRecords);return new d(H,{nextPageLoader:async X=>this.searchRuleRecords(e,{...t,after:X})})}},lt=class extends m{constructor(e,t){super(e,t);}async list(e){let{query:t,variables:r}=a.deckImportFormats({publisherId:e.publisherId,gameId:e.gameId,includeArchived:e.includeArchived,first:e.first,after:e.after}),s=this.cacheKey("importFormats","list",r),i=await this.withCache(s,"importFormats",e,async()=>(await this.connection.execute(t,r)).deckImportFormats);return new d(i,{nextPageLoader:async n=>this.list({...e,after:n})})}async get(e,t={}){let r=this.cacheKey("importFormats","get",{id:e});return this.withCache(r,"importFormats",t,async()=>{let{query:s}=a.deckImportFormat();return (await this.connection.execute(s,{id:e})).deckImportFormat??null})}async getByKey(e){let t=this.cacheKey("importFormats","getByKey",{gameId:e.gameId,formatKey:e.key});return this.withCache(t,"importFormats",e,async()=>{let{query:r}=a.deckImportFormat();return (await this.connection.execute(r,{gameId:e.gameId,key:e.key})).deckImportFormat??null})}async test(e){let{query:t}=a.deckImportFormatTest();return (await this.connection.execute(t,a.deckImportFormatTestVariables(e))).deckImportFormatTest}async create(e){this.config.requireSecretCredential("importFormats.create");let{query:t}=a.createDeckImportFormat();return (await this.connection.execute(t,a.deckImportFormatCreateVariables(e))).deckImportFormatCreate}async update(e,t){this.config.requireSecretCredential("importFormats.update");let{query:r}=a.updateDeckImportFormat();return (await this.connection.execute(r,a.deckImportFormatUpdateVariables(e,t))).deckImportFormatUpdate}async archive(e){this.config.requireSecretCredential("importFormats.archive");let{query:t}=a.archiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatArchive}async unarchive(e){this.config.requireSecretCredential("importFormats.unarchive");let{query:t}=a.unarchiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatUnarchive}},ht=class extends m{constructor(e,t){super(e,t);}async preview(e){let{query:t}=a.datasetImportPreview();return (await this.connection.execute(t,a.datasetImportPreviewVariables(e))).datasetImportPreview}async validate(e){let{query:t}=a.datasetImportValidate();return (await this.connection.execute(t,a.datasetImportValidateVariables(e))).datasetImportValidate}async run(e){if(this.config.requireSecretCredential("imports.run"),"fileId"in e&&e.fileId){let{query:s}=a.datasetImportFromFile();return (await this.connection.execute(s,a.datasetImportFromFileVariables(e))).datasetImportFromFile}if("sourceUrl"in e&&e.sourceUrl){let{query:s}=a.datasetImportFromUrl();return (await this.connection.execute(s,a.datasetImportFromUrlVariables(e))).datasetImportFromUrl}let{query:t}=a.datasetImportFromPayload();return (await this.connection.execute(t,a.datasetImportFromPayloadVariables(e))).datasetImportFromPayload}async getJob(e,t={}){let r=this.cacheKey("imports","getJob",{id:e});return this.withCache(r,"imports",t,async()=>{let{query:s}=a.importJob();return (await this.connection.execute(s,{id:e})).importJob??null})}async listJobs(e,t={}){let{query:r,variables:s}=a.importJobs({publisherId:e,datasetId:t.datasetId,status:t.status,first:t.first,after:t.after}),i=this.cacheKey("imports","listJobs",s),n=await this.withCache(i,"imports",t,async()=>(await this.connection.execute(r,s)).importJobs);return new d(n,{nextPageLoader:async c=>this.listJobs(e,{...t,after:c})})}async cancelJob(e){this.config.requireSecretCredential("imports.cancelJob");let{query:t}=a.importJobCancel();return (await this.connection.execute(t,{id:e})).importJobCancel}async listJobLogs(e,t={}){let{query:r,variables:s}=a.importJobLogs({importJobId:e,level:t.level,datasetKey:t.datasetKey,first:t.first,after:t.after}),i=this.cacheKey("imports","listJobLogs",s),n=await this.withCache(i,"imports",t,async()=>(await this.connection.execute(r,s)).importJob?.logs??yt());return new d(n,{nextPageLoader:async c=>this.listJobLogs(e,{...t,after:c})})}async waitForJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,i=Date.now();for(;;){let n=await this.getJob(e,{cache:false});if(!n)throw new Error(`Import job '${e}' was not found`);if(n.status==="COMPLETED"||n.status==="FAILED")return n;if(Date.now()-i>=s)throw new Error(`Timed out waiting for import job '${e}'`);await new Promise(c=>setTimeout(c,r));}}async previewGame(e){let{query:t}=a.gameImportPreview();return (await this.connection.execute(t,a.gameImportPreviewVariables(e))).gameImportPreview}async runGame(e){if(this.config.requireSecretCredential("imports.runGame"),"fileId"in e&&e.fileId){let{query:s}=a.gameImportFromFile();return (await this.connection.execute(s,a.gameImportFromFileVariables(e))).gameImportFromFile}if("sourceUrl"in e&&e.sourceUrl){let{query:s}=a.gameImportFromUrl();return (await this.connection.execute(s,a.gameImportFromUrlVariables(e))).gameImportFromUrl}let{query:t}=a.gameImportFromPayload();return (await this.connection.execute(t,a.gameImportFromPayloadVariables(e))).gameImportFromPayload}async getGameJob(e,t={}){let r=this.cacheKey("imports","getGameJob",{id:e});return this.withCache(r,"imports",t,async()=>{let{query:s}=a.gameImportJob();return (await this.connection.execute(s,{id:e})).gameImportJob??null})}async listGameJobs(e,t={}){let{query:r,variables:s}=a.gameImportJobs({gameId:e,status:t.status,first:t.first,after:t.after}),i=this.cacheKey("imports","listGameJobs",s),n=await this.withCache(i,"imports",t,async()=>(await this.connection.execute(r,s)).gameImportJobs);return new d(n,{nextPageLoader:async c=>this.listGameJobs(e,{...t,after:c})})}async cancelGameJob(e){this.config.requireSecretCredential("imports.cancelGameJob");let{query:t}=a.gameImportJobCancel();return (await this.connection.execute(t,{id:e})).gameImportJobCancel}async waitForGameJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,i=Date.now();for(;;){let n=await this.getGameJob(e,{cache:false});if(!n)throw new Error(`Game import job '${e}' was not found`);if(n.status==="COMPLETED"||n.status==="FAILED")return n;if(Date.now()-i>=s)throw new Error(`Timed out waiting for game import job '${e}'`);await new Promise(c=>setTimeout(c,r));}}};function yt(){return {totalCount:0,pageInfo:{hasNextPage:false,hasPreviousPage:false,startCursor:null,endCursor:null},edges:[]}}var ft=class extends m{constructor(e,t){super(e,t);}async run(e){this.config.requireSecretCredential("exports.run");let{query:t}=a.datasetExport();return (await this.connection.execute(t,a.datasetExportVariables(e))).datasetExport}async create(e){return this.run(e)}async getJob(e,t={}){let r=this.cacheKey("exports","getJob",{id:e});return this.withCache(r,"exports",t,async()=>{let{query:s}=a.exportJob();return (await this.connection.execute(s,{id:e})).exportJob??null})}async listJobs(e,t={}){let{query:r,variables:s}=a.exportJobs({publisherId:e,gameId:t.gameId,datasetId:t.datasetId,status:t.status,first:t.first,after:t.after}),i=this.cacheKey("exports","listJobs",s),n=await this.withCache(i,"exports",t,async()=>(await this.connection.execute(r,s)).exportJobs);return new d(n,{nextPageLoader:async c=>this.listJobs(e,{...t,after:c})})}async refreshUrl(e){let{query:t}=a.exportJobRefreshUrl();return (await this.connection.execute(t,{id:e})).exportJobRefreshUrl}async cancel(e){this.config.requireSecretCredential("exports.cancel");let{query:t}=a.exportJobCancel();return (await this.connection.execute(t,{id:e})).exportJobCancel}async waitForJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,i=Date.now();for(;;){let n=await this.getJob(e,{cache:false});if(!n)throw new Error(`Export job '${e}' was not found`);if(n.status==="COMPLETED"||n.status==="FAILED")return n;if(Date.now()-i>=s)throw new Error(`Timed out waiting for export job '${e}'`);await new Promise(c=>setTimeout(c,r));}}},pt=class extends m{constructor(e,t){super(e,t);}async get(e,t={}){let r=this.cacheKey("files","get",{id:e});return this.withCache(r,"files",t,async()=>{let{query:s}=a.file();return (await this.connection.execute(s,{id:e})).file??null})}async requestUpload(e){this.config.requireSecretCredential("files.requestUpload");let{query:t}=a.fileUploadRequest();return (await this.connection.execute(t,a.fileUploadRequestVariables(e))).fileUploadRequest}async confirmUpload(e){this.config.requireSecretCredential("files.confirmUpload");let{query:t}=a.fileUploadConfirm();return (await this.connection.execute(t,{id:e})).fileUploadConfirm}async delete(e){this.config.requireSecretCredential("files.delete");let{query:t}=a.fileDelete();return !!(await this.connection.execute(t,{id:e})).fileDelete}},ke=class Ie{config;connection;publishers;games;datasets;records;decks;rules;importFormats;imports;exports;files;constructor(t={}){this.config=new Xe(t),this.connection=new et(this.config),this.publishers=new it(this.connection,this.config),this.games=new at(this.connection,this.config),this.datasets=new nt(this.connection,this.config),this.records=new ut(this.connection,this.config),this.decks=new ct(this.connection,this.config),this.rules=new dt(this.connection,this.config),this.importFormats=new lt(this.connection,this.config),this.imports=new ht(this.connection,this.config),this.exports=new ft(this.connection,this.config),this.files=new pt(this.connection,this.config);}async me(){let{query:t}=a.fetchMe();return (await this.connection.execute(t)).fetchMe??null}getRateLimitInfo(){return Ze()}withConfig(t){let r=this.config.merge(t);return new Ie({apiKey:r.configApiKey(),publishableKey:r.publishableKey,secretKey:r.secretKey,accessToken:r.accessToken,environment:r.environment,endpoint:r.endpoint,timeout:r.timeout,openTimeout:r.openTimeout,defaultPublisher:r.defaultPublisher,defaultGame:r.defaultGame,allowedPublishers:r.allowedPublishers,allowedGames:r.allowedGames,logger:r.logger,logLevel:r.logLevel,retryOnRateLimit:r.retryOnRateLimit,maxRetries:r.maxRetries,retryOnNetworkError:r.retryOnNetworkError,maxNetworkRetries:r.maxNetworkRetries,retryBaseDelay:r.retryBaseDelay,retryMaxDelay:r.retryMaxDelay,cache:r.cache,cacheTtl:r.cacheTtl,cacheTtls:r.cacheTtls})}};var Y=class{storage;prefix;constructor(t={}){let r=t.storage??"localStorage";this.storage=r==="sessionStorage"?globalThis.sessionStorage:globalThis.localStorage,this.prefix=t.prefix??"carddb:";}get(t){try{let r=this.storage.getItem(this.prefix+t);if(!r)return null;let s=JSON.parse(r);return s.expiresAt!==null&&Date.now()>s.expiresAt?(this.storage.removeItem(this.prefix+t),null):s.value}catch{return this.storage.removeItem(this.prefix+t),null}}set(t,r,s){try{let i={value:r,expiresAt:s!==void 0?Date.now()+s*1e3:null};this.storage.setItem(this.prefix+t,JSON.stringify(i));}catch(i){console.warn("[CardDB] Failed to write to cache:",i);}}delete(t){this.storage.removeItem(this.prefix+t);}clear(){let t=[];for(let r=0;r<this.storage.length;r++){let s=this.storage.key(r);s&&s.startsWith(this.prefix)&&t.push(s);}for(let r of t)this.storage.removeItem(r);}has(t){return this.get(t)!==null}get size(){let t=0;for(let r=0;r<this.storage.length;r++){let s=this.storage.key(r);s&&s.startsWith(this.prefix)&&t++;}return t}cleanup(){let t=Date.now(),r=[];for(let s=0;s<this.storage.length;s++){let i=this.storage.key(s);if(i&&i.startsWith(this.prefix))try{let n=this.storage.getItem(i);if(n){let c=JSON.parse(n);c.expiresAt!==null&&t>c.expiresAt&&r.push(i);}}catch{r.push(i);}}for(let s of r)this.storage.removeItem(s);}};var $e=class extends ke{constructor(t={}){if("apiKey"in t&&t.apiKey!==void 0)throw new b("apiKey is not accepted in browsers; use publishableKey or accessToken");if("secretKey"in t&&t.secretKey!==void 0)throw new b("secretKey is server-only; use publishableKey or accessToken in browsers");super(t);}};
1673
- export{B as AuthenticationError,m as BaseResource,Y as BrowserCache,$e as CardDBClient,y as CardDBError,d as Collection,Xe as Configuration,et as Connection,E as ConnectionError,Me as DEFAULT_CACHE_TTL,Je as DEFAULT_ENDPOINT,je as DEFAULT_MAX_NETWORK_RETRIES,Ne as DEFAULT_MAX_RETRIES,Ge as DEFAULT_OPEN_TIMEOUT,Ye as DEFAULT_RETRY_BASE_DELAY,He as DEFAULT_RETRY_MAX_DELAY,Oe as DEFAULT_TIMEOUT,nt as DatasetsResource,ct as DecksResource,ft as ExportsResource,pt as FilesResource,be as FilterBuilder,at as GamesResource,se as GraphQLError,lt as ImportFormatsResource,ht as ImportsResource,gt as LinkResolutionError,mt as NotFoundError,it as PublishersResource,a as QueryBuilder,q as RateLimitError,ut as RecordsResource,b as RestrictedError,dt as RulesResource,J as ServerError,_ as TimeoutError,V as ValidationError,tt as cacheKey,Et as contains,kt as eq,Ze as getRateLimitInfo,Mt as getSDKVersion,ze as getUserAgent,$t as gt,bt as gte,xt as ilike,qt as isNotNull,Rt as isNull,St as like,Dt as lt,vt as lte,It as neq,At as notWithin,rt as readCache,C as resolveFilter,wt as within,st as writeCache};//# sourceMappingURL=index.js.map
1919
+ `}}},l=class{totalCount;pageInfo;items;nextPageLoader;constructor(e,t={}){this.totalCount=e.totalCount,this.pageInfo=e.pageInfo,this.items=e.edges.map(r=>t.itemTransformer?t.itemTransformer(r.node):r.node),this.nextPageLoader=t.nextPageLoader;}get hasNextPage(){return this.pageInfo.hasNextPage}get hasPreviousPage(){return this.pageInfo.hasPreviousPage}get endCursor(){return this.pageInfo.endCursor}get startCursor(){return this.pageInfo.startCursor}get length(){return this.items.length}get isEmpty(){return this.items.length===0}get first(){return this.items[0]}get last(){return this.items[this.items.length-1]}async nextPage(){if(!this.hasNextPage)return null;if(!this.nextPageLoader)throw new Error("No next page loader configured");return this.endCursor?this.nextPageLoader(this.endCursor):null}async*[Symbol.asyncIterator](){let e=this;for(;e;){for(let t of e.items)yield t;if(!e.hasNextPage)break;e=await e.nextPage();}}async forEach(e){let t=0;for await(let r of this)await e(r,t++);}async map(e){let t=[],r=0;for await(let s of this)t.push(await e(s,r++));return t}async filter(e){let t=[],r=0;for await(let s of this)await e(s,r++)&&t.push(s);return t}async find(e){let t=0;for await(let r of this)if(await e(r,t++))return r}async take(e){let t=[];for await(let r of this){if(t.length>=e)break;t.push(r);}return t}async toArray(){let e=[];for await(let t of this)e.push(t);return e}async*batches(){let e=this;for(;e&&(e.items.length>0&&(yield e.items),!!e.hasNextPage);)e=await e.nextPage();}each(){return this}};var Qe="https://carddb.dev/query",Ze=3e4,et=1e4,tt=300,rt=3,st=2,it=1e3,at=3e4,nt=class ke{apiKey;publishableKey;secretKey;accessToken;legacyApiKey;environment;endpoint;timeout;openTimeout;defaultPublisher;defaultGame;allowedPublishers;allowedGames;logger;logLevel;retryOnRateLimit;maxRetries;retryOnNetworkError;maxNetworkRetries;retryBaseDelay;retryMaxDelay;cache;cacheTtl;cacheTtls;constructor(t={}){this.legacyApiKey=t.apiKey,this.publishableKey=t.publishableKey,this.secretKey=t.secretKey,this.accessToken=t.accessToken,this.apiKey=t.apiKey??t.publishableKey??t.secretKey,this.environment=t.environment,this.endpoint=t.endpoint??Qe,this.timeout=t.timeout??Ze,this.openTimeout=t.openTimeout??et,this.defaultPublisher=t.defaultPublisher,this.defaultGame=t.defaultGame,this.allowedPublishers=t.allowedPublishers,this.allowedGames=t.allowedGames,this.logger=t.logger,this.logLevel=t.logLevel??"info",this.retryOnRateLimit=t.retryOnRateLimit??false,this.maxRetries=t.maxRetries??rt,this.retryOnNetworkError=t.retryOnNetworkError??true,this.maxNetworkRetries=t.maxNetworkRetries??st,this.retryBaseDelay=t.retryBaseDelay??it,this.retryMaxDelay=t.retryMaxDelay??at,this.cache=t.cache,this.cacheTtl=t.cacheTtl??tt,this.cacheTtls=t.cacheTtls??{};}calculateRetryDelay(t){let r=this.retryBaseDelay*Math.pow(2,t),s=Math.min(r,this.retryMaxDelay),i=s*.25*(Math.random()*2-1);return Math.round(s+i)}cacheTtlFor(t){return this.cacheTtls[t]??this.cacheTtl}resolvePublisher(t){return t??this.defaultPublisher}resolveGame(t){return t??this.defaultGame}validatePublisher(t){if(this.allowedPublishers&&!this.allowedPublishers.includes(t))throw new $(`Publisher '${t}' is not in the allowed publishers list`)}validateGame(t,r){if(!this.allowedGames)return;let s=this.allowedGames[t];if(s&&!s.includes(r))throw new $(`Game '${r}' is not allowed for publisher '${t}'`)}validateAccess(t,r){t&&(this.validatePublisher(t),r&&this.validateGame(t,r));}requireSecretCredential(t){if(!(!this.accessToken&&(this.legacyApiKey||this.secretKey&&!this.publishableKey)))throw new $(`${t} requires a server-side secretKey or legacy apiKey credential`)}requestApiKey(){return this.legacyApiKey??this.publishableKey??this.secretKey}configApiKey(){return this.legacyApiKey}shouldLog(t){let r={debug:0,info:1,warn:2,error:3};return r[t]>=r[this.logLevel]}merge(t){return new ke({apiKey:t.apiKey??this.legacyApiKey,publishableKey:t.publishableKey??this.publishableKey,secretKey:t.secretKey??this.secretKey,accessToken:t.accessToken??this.accessToken,environment:t.environment??this.environment,endpoint:t.endpoint??this.endpoint,timeout:t.timeout??this.timeout,openTimeout:t.openTimeout??this.openTimeout,defaultPublisher:t.defaultPublisher??this.defaultPublisher,defaultGame:t.defaultGame??this.defaultGame,allowedPublishers:t.allowedPublishers??this.allowedPublishers,allowedGames:t.allowedGames??this.allowedGames,logger:t.logger??this.logger,logLevel:t.logLevel??this.logLevel,retryOnRateLimit:t.retryOnRateLimit??this.retryOnRateLimit,maxRetries:t.maxRetries??this.maxRetries,retryOnNetworkError:t.retryOnNetworkError??this.retryOnNetworkError,maxNetworkRetries:t.maxNetworkRetries??this.maxNetworkRetries,retryBaseDelay:t.retryBaseDelay??this.retryBaseDelay,retryMaxDelay:t.retryMaxDelay??this.retryMaxDelay,cache:t.cache??this.cache,cacheTtl:t.cacheTtl??this.cacheTtl,cacheTtls:t.cacheTtls??this.cacheTtls})}},Ie="0.1.0";function ct(){if(typeof globalThis<"u"&&"Bun"in globalThis){let e=globalThis.Bun&&typeof globalThis.Bun=="object"&&globalThis.Bun.version;return {name:"bun",version:typeof e=="string"?e:"unknown"}}if(typeof globalThis<"u"&&"Deno"in globalThis){let e=globalThis.Deno&&typeof globalThis.Deno=="object"&&globalThis.Deno.version&&typeof globalThis.Deno.version=="object"&&globalThis.Deno.version.deno;return {name:"deno",version:typeof e=="string"?e:"unknown"}}return typeof process<"u"&&process.versions&&process.versions.node?{name:"node",version:process.versions.node}:typeof navigator<"u"&&navigator.userAgent?ot(navigator.userAgent):{name:"unknown",version:"unknown"}}function ot(e){let t=e.match(/Edg\/(\d+(?:\.\d+)*)/);if(t)return {name:"edge",version:t[1]};let r=e.match(/Chrome\/(\d+(?:\.\d+)*)/);if(r&&!e.includes("Edg/"))return {name:"chrome",version:r[1]};let s=e.match(/Firefox\/(\d+(?:\.\d+)*)/);if(s)return {name:"firefox",version:s[1]};let i=e.match(/Version\/(\d+(?:\.\d+)*).*Safari/);return i?{name:"safari",version:i[1]}:{name:"browser",version:"unknown"}}function ut(){let e=ct();return `CardDB-SDK/js/${Ie} (${e.name}/${e.version})`}function fr(){return Ie}var be=null;function lt(){return be}var dt=class{config;constructor(e){this.config=e;}async execute(e,t={}){let r=this.extractOperationName(e),s=0,i=0;for(;;)try{let n=Date.now();this.logRequest(r,t);let c=await this.fetch(e,t),o=Date.now()-n,h=await this.handleResponse(c);return this.logResponse(r,o),h}catch(n){if(n instanceof K&&this.config.retryOnRateLimit&&s<this.config.maxRetries){s++;let c=n.retryAfter??60;this.logRateLimitRetry(r,s,c),await this.sleep(c*1e3);continue}if(this.isRetryableNetworkError(n)&&this.config.retryOnNetworkError&&i<this.config.maxNetworkRetries){let c=this.config.calculateRetryDelay(i);this.logNetworkRetry(r,i+1,c,n),i++,await this.sleep(c);continue}if(n instanceof O&&this.config.retryOnNetworkError&&i<this.config.maxNetworkRetries){let c=this.config.calculateRetryDelay(i);this.logNetworkRetry(r,i+1,c,n),i++,await this.sleep(c);continue}throw n}}isRetryableNetworkError(e){return e instanceof E||e instanceof G}async fetch(e,t){let r=new AbortController,s=setTimeout(()=>r.abort(),this.config.timeout),i=this.config.requestApiKey();try{return await fetch(this.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","User-Agent":ut(),...this.config.accessToken?{Authorization:`Bearer ${this.config.accessToken}`}:{},...!this.config.accessToken&&i?{"X-API-Key":i}:{}},body:JSON.stringify({query:e,variables:t}),signal:r.signal})}catch(n){throw n instanceof Error?n.name==="AbortError"?(this.logError("Request timed out"),new G("Request timed out")):(this.logError(`Connection failed: ${n.message}`),new E(`Connection failed: ${n.message}`)):new E("Connection failed")}finally{clearTimeout(s);}}async handleResponse(e){switch(this.extractRateLimitInfo(e),e.status){case 200:return this.handleSuccessResponse(e);case 401:throw new M("Invalid or missing API key");case 429:return this.handleRateLimitResponse(e);default:if(e.status>=400&&e.status<500)return this.handleClientError(e);if(e.status>=500){let t=await this.parseBody(e);throw new O(`Server error (${e.status})`,{status:e.status,response:t})}throw new y(`Unexpected response status: ${e.status}`)}}async handleSuccessResponse(e){let t=await this.parseBody(e);return t.errors&&t.errors.length>0&&this.handleGraphQLErrors(t.errors,t),t.data??{}}handleGraphQLErrors(e,t){let r=e[0],s=r.message||"GraphQL error";switch(r.extensions?.code){case "UNAUTHENTICATED":throw new M(s,t);case "RATE_LIMITED":throw new K(s,{response:t});case "NOT_FOUND":throw new y(s,t);case "VALIDATION_ERROR":case "BAD_USER_INPUT":throw new J(s,{errors:e,response:t});default:throw new ne(s,{errors:e,response:t})}}async handleRateLimitResponse(e){let t=parseInt(e.headers.get("Retry-After")??"60",10),r=parseInt(e.headers.get("X-RateLimit-Limit")??"",10)||null,s=parseInt(e.headers.get("X-RateLimit-Remaining")??"",10)||null,i=parseInt(e.headers.get("X-RateLimit-Reset")??"",10)||null,n=i?new Date(i*1e3):null,c=await this.parseBody(e);throw new K("Rate limit exceeded",{retryAfter:t,limit:r,remaining:s,resetAt:n,response:c})}async handleClientError(e){let t=await this.parseBody(e),r=t.errors?.[0]?.message??`Client error (${e.status})`;throw new J(r,{response:t})}async parseBody(e){try{return await e.json()}catch{return {raw:await e.text()}}}extractRateLimitInfo(e){let t=parseInt(e.headers.get("X-RateLimit-Limit")??"",10)||null,r=parseInt(e.headers.get("X-RateLimit-Remaining")??"",10)||null,s=parseInt(e.headers.get("X-RateLimit-Reset")??"",10)||null;be={limit:t,remaining:r,reset:s};}extractOperationName(e){let t=e.match(/(?:query|mutation)\s+(\w+)/);return t?t[1]:"Unknown"}sleep(e){return new Promise(t=>setTimeout(t,e))}logRequest(e,t){!this.config.logger||!this.config.shouldLog("debug")||this.config.logger.debug(`[CardDB] Executing ${e}`,{variables:t});}logResponse(e,t){!this.config.logger||!this.config.shouldLog("info")||this.config.logger.info(`[CardDB] ${e} completed in ${t}ms`);}logRateLimitRetry(e,t,r){!this.config.logger||!this.config.shouldLog("warn")||this.config.logger.warn(`[CardDB] Rate limited on ${e}, retry ${t}/${this.config.maxRetries} after ${r}s`);}logNetworkRetry(e,t,r,s){if(!this.config.logger||!this.config.shouldLog("warn"))return;let i=s instanceof Error?s.name:"Unknown";this.config.logger.warn(`[CardDB] ${i} on ${e}, retry ${t}/${this.config.maxNetworkRetries} after ${r}ms`);}logError(e){!this.config.logger||!this.config.shouldLog("error")||this.config.logger.error(`[CardDB] ${e}`);}};function ht(e,t,r){let s=Object.entries(r).filter(([,i])=>i!==void 0).sort(([i],[n])=>i.localeCompare(n)).map(([i,n])=>`${i}=${JSON.stringify(n)}`).join("&");return `carddb:${e}:${t}:${s}`}async function yt(e,t){let r=e.get(t);return r}async function ft(e,t,r,s){let i=e.set(t,r,s);i instanceof Promise&&await i;}var f=class{connection;config;constructor(e,t){this.connection=e,this.config=t;}resolvePublisher(e){let t=this.config.resolvePublisher(e);if(!t)throw new Error("publisher_slug is required (no default configured)");return t}resolveGame(e){let t=this.config.resolveGame(e);if(!t)throw new Error("game_key is required (no default configured)");return t}validateAccess(e,t){this.config.validateAccess(e,t);}async withCache(e,t,r,s){let i=r.cache??!!this.config.cache,n=this.config.cache;if(!i||!n)return s();let c=await yt(n,e);if(c!==null)return c;let o=await s();if(o!=null){let h=this.config.cacheTtlFor(t);await ft(n,e,o,h);}return o}cacheKey(e,t,r){return ht(e,t,r)}},pt=class extends f{constructor(e,t){super(e,t);}async search(e={}){let{query:t,variables:r}=a.searchPublishers({search:e.search,first:e.first,after:e.after}),s=this.cacheKey("publishers","search",r),i=await this.withCache(s,"publishers",e,async()=>(await this.connection.execute(t,r)).searchPublishers);return new l(i,{nextPageLoader:async n=>this.search({...e,after:n})})}async get(e,t={}){let r=this.isUUID(e),s=this.cacheKey("publishers","get",{[r?"id":"slug"]:e});return this.withCache(s,"publishers",t,async()=>{if(r){let{query:i}=a.fetchPublisherById();return (await this.connection.execute(i,{id:e})).fetchPublisher??null}else {let{query:i}=a.fetchPublisherBySlug();return (await this.connection.execute(i,{slug:e})).fetchPublisher??null}})}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("publishers","getMany",{slugs:e});return this.withCache(r,"publishers",t,async()=>{let{query:s}=a.fetchPublishers();return (await this.connection.execute(s,{slugs:e})).fetchPublishers??[]})}isUUID(e){return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}},mt=class extends f{constructor(e,t){super(e,t);}async list(e,t={}){let{query:r,variables:s}=a.listGames({publisherId:e,first:t.first,after:t.after,includeArchived:t.includeArchived}),i=this.cacheKey("games","list",s),n=await this.withCache(i,"games",t,async()=>(await this.connection.execute(r,s)).games);return new l(n,{nextPageLoader:async c=>this.list(e,{...t,after:c})})}async getByKey(e){let t=this.cacheKey("games","getByKey",{publisherId:e.publisherId,publisherSlug:e.publisherSlug,gameKey:e.gameKey});return this.withCache(t,"games",e,async()=>{let{query:r,variables:s}=a.game(e);return (await this.connection.execute(r,s)).game??null})}async getBySlug(e){let t=this.cacheKey("games","getBySlug",{publisherId:e.publisherId,publisherSlug:e.publisherSlug,gameSlug:e.gameSlug});return this.withCache(t,"games",e,async()=>{let{query:r,variables:s}=a.game(e);return (await this.connection.execute(r,s)).game??null})}async create(e){this.config.requireSecretCredential("games.create");let{query:t}=a.createGame();return (await this.connection.execute(t,a.gameCreateVariables(e))).gameCreate}async update(e,t){this.config.requireSecretCredential("games.update");let{query:r}=a.updateGame();return (await this.connection.execute(r,a.gameUpdateVariables(e,t))).gameUpdate}async getRegions(e={}){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=a.gameScanRegionsVariables(t,r,e.includeInactive),i=this.cacheKey("games","getRegions",s);return this.withCache(i,"games",e,async()=>{let{query:n}=a.gameScanRegions();return (await this.connection.execute(n,s)).gameScanRegions??[]})}async search(e={}){let t=this.config.resolvePublisher(e.publisherSlug);t&&this.validateAccess(t);let{query:r,variables:s}=a.searchGames({publisherSlug:t,search:e.search,first:e.first,after:e.after}),i=this.cacheKey("games","search",s),n=await this.withCache(i,"games",e,async()=>(await this.connection.execute(r,s)).searchGames);return new l(n,{nextPageLoader:async c=>this.search({...e,after:c})})}async get(e,t,r){if(typeof t=="string"){let s=e,i=t,n=r??{};this.validateAccess(s,i);let c=this.cacheKey("games","getByKeys",{publisherSlug:s,gameKey:i});return this.withCache(c,"games",n,async()=>{let{query:o}=a.fetchGameByKeys();return (await this.connection.execute(o,{publisherSlug:s,gameKey:i})).fetchGame??null})}else {let s=e,i=t??{},n=this.cacheKey("games","get",{id:s});return this.withCache(n,"games",i,async()=>{let{query:c}=a.fetchGameById();return (await this.connection.execute(c,{id:s})).fetchGame??null})}}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("games","getMany",{ids:e});return this.withCache(r,"games",t,async()=>{let{query:s}=a.fetchGames();return (await this.connection.execute(s,{ids:e})).fetchGames??[]})}},gt=class extends f{constructor(e,t){super(e,t);}async list(e,t={}){let{query:r,variables:s}=a.listDatasets({publisherId:e,gameId:t.gameId,includeArchived:t.includeArchived,purpose:t.purpose,first:t.first,after:t.after}),i=this.cacheKey("datasets","list",s),n=await this.withCache(i,"datasets",t,async()=>(await this.connection.execute(r,s)).datasets);return new l(n,{nextPageLoader:async c=>this.list(e,{...t,after:c})})}async getByKey(e){let t=this.cacheKey("datasets","getByKey",{publisherId:e.publisherId,gameId:e.gameId,datasetKey:e.datasetKey});return this.withCache(t,"datasets",e,async()=>{let{query:r,variables:s}=a.dataset(e);return (await this.connection.execute(r,s)).dataset??null})}async getSchema(e){return (typeof e=="string"?await this.withCache(this.cacheKey("datasets","getSchema",{id:e}),"datasets",{},async()=>{let{query:r,variables:s}=a.dataset({id:e});return (await this.connection.execute(r,s)).dataset??null}):await this.getByKey(e))?.schema??null}async search(e={}){let t=this.config.resolvePublisher(e.publisherSlug),r=this.config.resolveGame(e.gameKey);t&&this.validateAccess(t,r);let{query:s,variables:i}=a.searchDatasets({publisherSlug:t,gameKey:r,search:e.search,purpose:e.purpose,first:e.first,after:e.after}),n=this.cacheKey("datasets","search",i),c=await this.withCache(n,"datasets",e,async()=>(await this.connection.execute(s,i)).searchDatasets);return new l(c,{nextPageLoader:async o=>this.search({...e,after:o})})}async get(e,t,r,s){if(typeof t=="string"&&typeof r=="string"){let i=e,n=t,c=s??{};this.validateAccess(i,n);let o=this.cacheKey("datasets","getByKeys",{publisherSlug:i,gameKey:n,datasetKey:r});return this.withCache(o,"datasets",c,async()=>{let{query:h}=a.fetchDatasetByKeys();return (await this.connection.execute(h,{publisherSlug:i,gameKey:n,datasetKey:r})).fetchDataset??null})}else {let i=e,n=t??{},c=this.cacheKey("datasets","get",{id:i});return this.withCache(c,"datasets",n,async()=>{let{query:o}=a.fetchDatasetById();return (await this.connection.execute(o,{id:i})).fetchDataset??null})}}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("datasets","getMany",{ids:e});return this.withCache(r,"datasets",t,async()=>{let{query:s}=a.fetchDatasets();return (await this.connection.execute(s,{ids:e})).fetchDatasets??[]})}},kt=class extends f{constructor(e,t){super(e,t);}async fetch(e,t={}){let r=this.cacheKey("decks","fetch",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.fetchDeckById();return (await this.connection.execute(s,{id:e})).fetchDeck??null})}async get(e,t={}){let r=this.cacheKey("decks","get",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckById();return (await this.connection.execute(s,{id:e})).deck??null})}async fetchMine(e,t={}){let r=this.cacheKey("decks","fetchMine",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.myDeck();return (await this.connection.execute(s,{id:e})).myDeck??null})}async fetchBySlug(e,t,r,s={}){let i=this.cacheKey("decks","fetchBySlug",{publisherSlug:e,gameKey:t,slug:r});return this.withCache(i,"decks",s,async()=>{let{query:n}=a.fetchDeckBySlug();return (await this.connection.execute(n,{publisherSlug:e,gameKey:t,slug:r})).fetchDeckBySlug??null})}async getBySlug(e,t,r,s={}){let i=this.cacheKey("decks","getBySlug",{publisherSlug:e,gameKey:t,slug:r});return this.withCache(i,"decks",s,async()=>{let{query:n}=a.deckBySlug();return (await this.connection.execute(n,{publisherSlug:e,gameKey:t,slug:r})).deckBySlug??null})}async fetchByExternalRef(e,t={}){let r=this.cacheKey("decks","fetchByExternalRef",{externalRef:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.fetchDeckByExternalRef();return (await this.connection.execute(s,{externalRef:e})).fetchDeckByExternalRef??null})}async getByExternalRef(e,t={}){let r=this.cacheKey("decks","getByExternalRef",{externalRef:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckByExternalRef();return (await this.connection.execute(s,{externalRef:e})).deckByExternalRef??null})}async listMine(e={}){let{query:t,variables:r}=a.listMyDecks({first:e.first,after:e.after,includeArchived:e.includeArchived}),s=this.cacheKey("decks","listMine",r),i=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).myDecks);return new l(i,{nextPageLoader:async n=>this.listMine({...e,after:n})})}async listViewer(e={}){let{query:t,variables:r}=a.viewerDecks({filter:e.filter,first:e.first,after:e.after}),s=this.cacheKey("decks","listViewer",r),i=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).viewerDecks);return new l(i,{nextPageLoader:async n=>this.listViewer({...e,after:n})})}async listApp(e={}){this.config.requireSecretCredential("decks.listApp");let{query:t,variables:r}=a.appDecks({filter:e.filter,first:e.first,after:e.after}),s=this.cacheKey("decks","listApp",r),i=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).appDecks);return new l(i,{nextPageLoader:async n=>this.listApp({...e,after:n})})}async listPublic(e={}){let{query:t,variables:r}=a.publicDecks({filter:e.filter,first:e.first,after:e.after}),s=this.cacheKey("decks","listPublic",r),i=await this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).publicDecks);return new l(i,{nextPageLoader:async n=>this.listPublic({...e,after:n})})}async fetchVersion(e,t={}){let r=this.cacheKey("decks","fetchVersion",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckVersion();return (await this.connection.execute(s,{id:e})).deckVersion??null})}async listVersions(e,t={}){let{query:r,variables:s}=a.deckVersions({first:t.first,after:t.after}),i={deckId:e,...s},n=this.cacheKey("decks","listVersions",i),c=await this.withCache(n,"decks",t,async()=>(await this.connection.execute(r,i)).deckVersions);return new l(c,{nextPageLoader:async o=>this.listVersions(e,{...t,after:o})})}async preview(e,t={}){let r=this.cacheKey("decks","preview",{token:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckPreview();return (await this.connection.execute(s,{token:e})).deckPreview??null})}async embed(e,t={}){let r=this.cacheKey("decks","embed",{token:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckEmbed();return (await this.connection.execute(s,{token:e})).deckEmbed??null})}async access(e,t={}){let r=this.cacheKey("decks","access",{token:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckAccess();return (await this.connection.execute(s,{token:e})).deckAccess??null})}async draftDiff(e,t={}){let r=this.cacheKey("decks","draftDiff",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckDraftDiff();return (await this.connection.execute(s,{id:e})).deckDraftDiff})}async versionDiff(e,t,r={}){let s=a.deckVersionDiffVariables(e,t),i=this.cacheKey("decks","versionDiff",s);return this.withCache(i,"decks",r,async()=>{let{query:n}=a.deckVersionDiff();return (await this.connection.execute(n,s)).deckVersionDiff})}async validate(e,t,r={}){let s=a.deckValidateVariables(e,t),i=this.cacheKey("decks","validate",s);return this.withCache(i,"decks",r,async()=>{let{query:n}=a.deckValidate();return (await this.connection.execute(n,s)).deckValidate})}async hydrateDeckEntries(e,t={}){let r=a.deckHydrateEntriesVariables(e),s=this.cacheKey("decks","hydrateDeckEntries",r);return this.withCache(s,"decks",t,async()=>{let{query:i}=a.deckHydrateEntries();return (await this.connection.execute(i,r)).deckHydrateEntries})}async exportDeck(e,t="SIMPLE_TEXT",r={}){let s=a.deckExportVariables(e,t),i=this.cacheKey("decks","exportDeck",s);return this.withCache(i,"decks",r,async()=>{let{query:n}=a.deckExport();return (await this.connection.execute(n,s)).deckExport})}async sectionDefinitions(e={}){let{query:t,variables:r}=a.deckSectionDefinitions({publisherSlug:e.publisherSlug,gameKey:e.gameKey,gameId:e.gameId,rulesetKey:e.rulesetKey,rulesetVersionId:e.rulesetVersionId}),s=this.cacheKey("decks","sectionDefinitions",r);return this.withCache(s,"decks",e,async()=>(await this.connection.execute(t,r)).deckSectionDefinitions)}async listCollaborators(e,t={}){let r=this.cacheKey("decks","listCollaborators",{deckId:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckCollaborators();return (await this.connection.execute(s,{deckId:e})).deckCollaborators})}async listPreviewTokens(e,t={}){let r=this.cacheKey("decks","listPreviewTokens",{deckId:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckPreviewTokens();return (await this.connection.execute(s,{deckId:e})).deckPreviewTokens})}async listEmbedTokens(e,t={}){let r=this.cacheKey("decks","listEmbedTokens",{deckId:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckEmbedTokens();return (await this.connection.execute(s,{deckId:e})).deckEmbedTokens})}async listAccessTokenIssuers(e,t={}){let r=this.cacheKey("decks","listAccessTokenIssuers",{deckId:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckAccessTokenIssuers();return (await this.connection.execute(s,{deckId:e})).deckAccessTokenIssuers})}async listApiApplicationAccesses(e,t={}){let r=a.deckApiApplicationAccessesVariables(e,t.includeRevoked),s=this.cacheKey("decks","listApiApplicationAccesses",r);return this.withCache(s,"decks",t,async()=>{let{query:i}=a.deckApiApplicationAccesses();return (await this.connection.execute(i,r)).deckApiApplicationAccesses})}async listMyApiApplicationAccesses(e={}){let t=a.myDeckApiApplicationAccessesVariables(e.applicationId),r=this.cacheKey("decks","listMyApiApplicationAccesses",t);return this.withCache(r,"decks",e,async()=>{let{query:s}=a.myDeckApiApplicationAccesses();return (await this.connection.execute(s,t)).myDeckApiApplicationAccesses})}async create(e){let{query:t}=a.createDeck(),r=a.deckCreateVariables(e);return (await this.connection.execute(t,r)).deckCreate}async update(e,t){let{query:r}=a.updateDeck(),s=a.deckUpdateVariables(e,t);return (await this.connection.execute(r,s)).deckUpdate}async updateMetadata(e,t){return this.update(e,t)}async upsertByExternalRef(e){this.config.requireSecretCredential("decks.upsertByExternalRef");let{query:t}=a.upsertDeckByExternalRef(),r=a.deckUpsertByExternalRefVariables(e);return (await this.connection.execute(t,r)).deckUpsertByExternalRef}async claim(e,t){let{query:r}=a.claimDeck(),s=a.deckClaimVariables(e,t);return (await this.connection.execute(r,s)).deckClaim}async transferOwnership(e,t){let{query:r}=a.transferDeckOwnership(),s=a.deckTransferOwnershipVariables(e,t);return (await this.connection.execute(r,s)).deckTransferOwnership}async copy(e,t){let{query:r}=a.copyDeck(),s=a.deckCopyVariables(e,t);return (await this.connection.execute(r,s)).deckCopy}async addEntry(e){let{query:t}=a.addDeckEntry(),r=a.deckEntryAddVariables(e);return (await this.connection.execute(t,r)).deckEntryAdd}async updateEntry(e,t){let{query:r}=a.updateDeckEntry(),s=a.deckEntryUpdateVariables(e,t);return (await this.connection.execute(r,s)).deckEntryUpdate}async removeEntry(e,t){let{query:r}=a.removeDeckEntry(),s=a.deckEntryRemoveVariables(e,t);return (await this.connection.execute(r,s)).deckEntryRemove}async reorderEntries(e,t){let{query:r}=a.reorderDeckEntries(),s=a.deckEntryReorderVariables(e,t);return (await this.connection.execute(r,s)).deckEntryReorder}async replaceEntries(e,t){let{query:r}=a.replaceDeckEntries(),s=a.deckEntriesReplaceVariables(e,t);return (await this.connection.execute(r,s)).deckEntriesReplace}async importDeck(e){let{query:t}=a.importDeck(),r=a.deckImportVariables(e);return (await this.connection.execute(t,r)).deckImport}async listImportFormats(e,t={}){let{query:r,variables:s}=a.deckImportFormats({gameId:e,includeArchived:t.includeArchived,first:t.first,after:t.after}),i=this.cacheKey("decks","listImportFormats",s),n=await this.withCache(i,"decks",t,async()=>(await this.connection.execute(r,s)).deckImportFormats);return new l(n,{nextPageLoader:async c=>this.listImportFormats(e,{...t,after:c})})}async fetchImportFormat(e,t={}){let r=this.cacheKey("decks","fetchImportFormat",{id:e});return this.withCache(r,"decks",t,async()=>{let{query:s}=a.deckImportFormat();return (await this.connection.execute(s,{id:e})).deckImportFormat??null})}async testImportFormat(e){let{query:t}=a.deckImportFormatTest(),r=a.deckImportFormatTestVariables(e);return (await this.connection.execute(t,r)).deckImportFormatTest}async createImportFormat(e){let{query:t}=a.createDeckImportFormat(),r=a.deckImportFormatCreateVariables(e);return (await this.connection.execute(t,r)).deckImportFormatCreate}async updateImportFormat(e,t){let{query:r}=a.updateDeckImportFormat(),s=a.deckImportFormatUpdateVariables(e,t);return (await this.connection.execute(r,s)).deckImportFormatUpdate}async archiveImportFormat(e){let{query:t}=a.archiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatArchive}async unarchiveImportFormat(e){let{query:t}=a.unarchiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatUnarchive}async delete(e){let{query:t}=a.deleteDeck();return !!(await this.connection.execute(t,{id:e})).deckDelete}async archive(e){let{query:t}=a.archiveDeck();return (await this.connection.execute(t,{id:e})).deckArchive}async restore(e){let{query:t}=a.restoreDeck();return (await this.connection.execute(t,{id:e})).deckRestore}async unpublish(e){let{query:t}=a.unpublishDeck();return (await this.connection.execute(t,{id:e})).deckUnpublish}async publish(e,t){let{query:r}=a.publishDeck(),s=a.deckPublishVariables(e,t);return (await this.connection.execute(r,s)).deckPublish}async removeInvalidEntries(e,t){let{query:r}=a.removeInvalidDeckEntries(),s=a.deckRemoveInvalidEntriesVariables(e,t);return (await this.connection.execute(r,s)).deckRemoveInvalidEntries}async upsertCollaborator(e,t,r){let{query:s}=a.upsertDeckCollaborator(),i=a.deckCollaboratorVariables(e,t,r);return (await this.connection.execute(s,i)).deckCollaboratorUpsert}async removeCollaborator(e,t){let{query:r}=a.removeDeckCollaborator(),s=a.deckCollaboratorVariables(e,t);return !!(await this.connection.execute(r,s)).deckCollaboratorRemove}async createPreviewToken(e){let{query:t}=a.createDeckPreviewToken(),r=a.deckPreviewTokenCreateVariables(e);return (await this.connection.execute(t,r)).deckPreviewTokenCreate}async revokePreviewToken(e){let{query:t}=a.revokeDeckPreviewToken();return !!(await this.connection.execute(t,{id:e})).deckPreviewTokenRevoke}async createEmbedToken(e){let{query:t}=a.createDeckEmbedToken(),r=a.deckEmbedTokenCreateVariables(e);return (await this.connection.execute(t,r)).deckEmbedTokenCreate}async revokeEmbedToken(e){let{query:t}=a.revokeDeckEmbedToken();return !!(await this.connection.execute(t,{id:e})).deckEmbedTokenRevoke}async createAccessTokenIssuer(e){let{query:t}=a.createDeckAccessTokenIssuer(),r=a.deckAccessTokenIssuerCreateVariables(e);return (await this.connection.execute(t,r)).deckAccessTokenIssuerCreate}async revokeAccessTokenIssuer(e){let{query:t}=a.revokeDeckAccessTokenIssuer();return !!(await this.connection.execute(t,{id:e})).deckAccessTokenIssuerRevoke}async revokeAccessTokenIssuerSigningKey(e){let{query:t}=a.revokeDeckAccessTokenIssuerSigningKey();return (await this.connection.execute(t,{id:e})).deckAccessTokenIssuerSigningKeyRevoke}async grantApiApplicationAccess(e){let{query:t}=a.grantDeckApiApplicationAccess(),r=a.deckApiApplicationAccessGrantVariables(e);return (await this.connection.execute(t,r)).deckApiApplicationAccessGrant}async revokeApiApplicationAccess(e,t){let{query:r}=a.revokeDeckApiApplicationAccess(),s=a.deckApiApplicationAccessRevokeVariables(e,t);return !!(await this.connection.execute(r,s)).deckApiApplicationAccessRevoke}async exchangeAccessToken(e){this.config.requireSecretCredential("decks.exchangeAccessToken");let{query:t}=a.exchangeDeckAccessToken(),r=a.deckAccessTokenExchangeVariables(e);return (await this.connection.execute(t,r)).deckAccessTokenExchange}async exchangeSessionToken(e){this.config.requireSecretCredential("decks.exchangeSessionToken");let{query:t}=a.exchangeDeckSessionToken(),r=a.deckSessionTokenExchangeVariables(e);return (await this.connection.execute(t,r)).deckSessionTokenExchange}async revokeAccessToken(e){this.config.requireSecretCredential("decks.revokeAccessToken");let{query:t}=a.revokeDeckAccessToken();return !!(await this.connection.execute(t,{id:e})).deckAccessTokenRevoke}async hydrateEntries(e){if(e.entries.length===0)return [];let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=e.entries.map(o=>o.identifier),i=this.cacheKey("decks","hydrateEntries",{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:s}),n=await this.withCache(i,"decks",e,async()=>{let{query:o}=a.fetchRecordsByIdentifier();return (await this.connection.execute(o,{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:s})).fetchRecordsByIdentifier}),c=It(n,s,e.identifierField);return e.entries.map(o=>({...o,record:c.get(o.identifier)??null}))}};function It(e,t,r){let s=new Set(t),i=new Map;for(let n of e){let c=r?n.data[r]:Object.values(n.data).find(h=>s.has(String(h)));if(c==null)continue;let o=String(c);s.has(o)&&(i.set(o,n),s.delete(o));}return i}var bt=class extends f{constructor(e,t){super(e,t);}async list(e){let t=F(e.filter),{query:r,variables:s}=a.listDatasetRecords({datasetId:e.datasetId,filter:t,orderBy:e.orderBy,first:e.first,after:e.after,last:e.last,before:e.before,validateSchema:e.validateSchema}),i=this.cacheKey("records","list",s),n=await this.withCache(i,"records",e,async()=>(await this.connection.execute(r,s)).datasetRecords);return new l(n,{nextPageLoader:async c=>this.list({...e,after:c})})}async getByDatasetIdentifier(e){let t=this.cacheKey("records","getByDatasetIdentifier",{datasetId:e.datasetId,identifier:e.identifier,includePricing:e.includePricing??false});return this.withCache(t,"records",e,async()=>{let{query:r,variables:s}=a.datasetRecord({datasetId:e.datasetId,identifier:e.identifier,includePricing:e.includePricing});return (await this.connection.execute(r,s)).datasetRecord??null})}async upsertBatch(e){this.config.requireSecretCredential("records.upsertBatch");let{query:t}=a.upsertDatasetRecords();return (await this.connection.execute(t,a.datasetRecordsUpsertVariables(e))).datasetRecordsUpsert}async deleteBatch(e){this.config.requireSecretCredential("records.deleteBatch");let{query:t}=a.deleteDatasetRecords();return (await this.connection.execute(t,a.datasetRecordsDeleteVariables(e))).datasetRecordsDelete}async getDeleteJob(e,t={}){let r=this.cacheKey("records","getDeleteJob",{id:e});return this.withCache(r,"records",t,async()=>{let{query:s}=a.datasetRecordDeleteJob();return (await this.connection.execute(s,{id:e})).datasetRecordDeleteJob??null})}async listDeleteJobs(e,t={}){let{query:r,variables:s}=a.datasetRecordDeleteJobs({publisherId:e,datasetId:t.datasetId,status:t.status,first:t.first,after:t.after}),i=this.cacheKey("records","listDeleteJobs",s),n=await this.withCache(i,"records",t,async()=>(await this.connection.execute(r,s)).datasetRecordDeleteJobs);return new l(n,{nextPageLoader:async c=>this.listDeleteJobs(e,{...t,after:c})})}async waitForDeleteJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,i=Date.now();for(;;){let n=await this.getDeleteJob(e,{cache:false});if(!n)throw new Error(`Delete job '${e}' was not found`);if(n.status==="COMPLETED"||n.status==="FAILED")return n;if(Date.now()-i>=s)throw new Error(`Timed out waiting for delete job '${e}'`);await new Promise(c=>setTimeout(c,r));}}async search(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=F(e.filter),{query:i,variables:n}=a.searchRecords({publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,filter:s,search:e.search,orderBy:e.orderBy,resolveLinks:e.resolveLinks,first:e.first,after:e.after,validateSchema:e.validateSchema,includePricing:e.includePricing}),c=this.cacheKey("records","search",{...n,includePricing:e.includePricing??false}),o=await this.withCache(c,"records",e,async()=>(await this.connection.execute(i,n)).searchRecords);return new l(o,{nextPageLoader:async h=>this.search({...e,after:h})})}async get(e,t={}){let r=this.cacheKey("records","get",{id:e,includePricing:t.includePricing??false});return this.withCache(r,"records",t,async()=>{let{query:s}=a.fetchRecordById({includePricing:t.includePricing});return (await this.connection.execute(s,{id:e})).fetchRecord??null})}async getByIdentifier(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=this.cacheKey("records","getByIdentifier",{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifier:e.identifier,includePricing:e.includePricing??false});return this.withCache(s,"records",e,async()=>{let{query:i}=a.fetchRecordByIdentifier({includePricing:e.includePricing});return (await this.connection.execute(i,{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifier:e.identifier})).fetchRecordByIdentifier??null})}async getManyByIdentifier(e){if(e.identifiers.length===0)return [];let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let s=this.cacheKey("records","getManyByIdentifier",{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:e.identifiers,includePricing:e.includePricing??false});return this.withCache(s,"records",e,async()=>{let{query:i}=a.fetchRecordsByIdentifier({includePricing:e.includePricing});return (await this.connection.execute(i,{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,identifiers:e.identifiers})).fetchRecordsByIdentifier??[]})}async getMany(e,t={}){if(e.length===0)return [];let r=this.cacheKey("records","getMany",{ids:e,includePricing:t.includePricing??false});return this.withCache(r,"records",t,async()=>{let{query:s}=a.fetchRecords({includePricing:t.includePricing});return (await this.connection.execute(s,{ids:e})).fetchRecords??[]})}},$t=class extends f{constructor(e,t){super(e,t);}async datasets(e={}){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);this.validateAccess(t,r);let{query:s,variables:i}=a.searchDatasets({publisherSlug:t,gameKey:r,search:e.search,purpose:"RULES",first:e.first,after:e.after}),n=this.cacheKey("rules","datasets",i),c=await this.withCache(n,"datasets",e,async()=>(await this.connection.execute(s,i)).searchDatasets);return new l(c,{nextPageLoader:async o=>this.datasets({...e,after:o})})}async list(e={}){return this.searchRuleRecords("rules",e)}async formats(e={}){return this.searchRuleRecords(e.datasetKey??"formats",e)}async searchRuleRecords(e,t){let r=this.resolvePublisher(t.publisherSlug),s=this.resolveGame(t.gameKey),i=t.datasetKey??e;this.validateAccess(r,s);let n=F(t.filter),{query:c,variables:o}=a.searchRecords({publisherSlug:r,gameKey:s,datasetKey:i,filter:n,search:t.search,orderBy:t.orderBy,resolveLinks:t.resolveLinks,first:t.first,after:t.after,validateSchema:t.validateSchema}),h=this.cacheKey("rules","records",o),w=await this.withCache(h,"records",t,async()=>(await this.connection.execute(c,o)).searchRecords);return new l(w,{nextPageLoader:async X=>this.searchRuleRecords(e,{...t,after:X})})}},vt=class extends f{constructor(e,t){super(e,t);}async list(e){let{query:t,variables:r}=a.deckImportFormats({publisherId:e.publisherId,gameId:e.gameId,includeArchived:e.includeArchived,first:e.first,after:e.after}),s=this.cacheKey("importFormats","list",r),i=await this.withCache(s,"importFormats",e,async()=>(await this.connection.execute(t,r)).deckImportFormats);return new l(i,{nextPageLoader:async n=>this.list({...e,after:n})})}async get(e,t={}){let r=this.cacheKey("importFormats","get",{id:e});return this.withCache(r,"importFormats",t,async()=>{let{query:s}=a.deckImportFormat();return (await this.connection.execute(s,{id:e})).deckImportFormat??null})}async getByKey(e){let t=this.cacheKey("importFormats","getByKey",{gameId:e.gameId,formatKey:e.key});return this.withCache(t,"importFormats",e,async()=>{let{query:r}=a.deckImportFormat();return (await this.connection.execute(r,{gameId:e.gameId,key:e.key})).deckImportFormat??null})}async test(e){let{query:t}=a.deckImportFormatTest();return (await this.connection.execute(t,a.deckImportFormatTestVariables(e))).deckImportFormatTest}async create(e){this.config.requireSecretCredential("importFormats.create");let{query:t}=a.createDeckImportFormat();return (await this.connection.execute(t,a.deckImportFormatCreateVariables(e))).deckImportFormatCreate}async update(e,t){this.config.requireSecretCredential("importFormats.update");let{query:r}=a.updateDeckImportFormat();return (await this.connection.execute(r,a.deckImportFormatUpdateVariables(e,t))).deckImportFormatUpdate}async archive(e){this.config.requireSecretCredential("importFormats.archive");let{query:t}=a.archiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatArchive}async unarchive(e){this.config.requireSecretCredential("importFormats.unarchive");let{query:t}=a.unarchiveDeckImportFormat();return (await this.connection.execute(t,{id:e})).deckImportFormatUnarchive}},Dt=class extends f{constructor(e,t){super(e,t);}async preview(e){let{query:t}=a.datasetImportPreview();return (await this.connection.execute(t,a.datasetImportPreviewVariables(e))).datasetImportPreview}async validate(e){let{query:t}=a.datasetImportValidate();return (await this.connection.execute(t,a.datasetImportValidateVariables(e))).datasetImportValidate}async run(e){if(this.config.requireSecretCredential("imports.run"),"fileId"in e&&e.fileId){let{query:s}=a.datasetImportFromFile();return (await this.connection.execute(s,a.datasetImportFromFileVariables(e))).datasetImportFromFile}if("sourceUrl"in e&&e.sourceUrl){let{query:s}=a.datasetImportFromUrl();return (await this.connection.execute(s,a.datasetImportFromUrlVariables(e))).datasetImportFromUrl}let{query:t}=a.datasetImportFromPayload();return (await this.connection.execute(t,a.datasetImportFromPayloadVariables(e))).datasetImportFromPayload}async getJob(e,t={}){let r=this.cacheKey("imports","getJob",{id:e});return this.withCache(r,"imports",t,async()=>{let{query:s}=a.importJob();return (await this.connection.execute(s,{id:e})).importJob??null})}async listJobs(e,t={}){let{query:r,variables:s}=a.importJobs({publisherId:e,datasetId:t.datasetId,status:t.status,first:t.first,after:t.after}),i=this.cacheKey("imports","listJobs",s),n=await this.withCache(i,"imports",t,async()=>(await this.connection.execute(r,s)).importJobs);return new l(n,{nextPageLoader:async c=>this.listJobs(e,{...t,after:c})})}async cancelJob(e){this.config.requireSecretCredential("imports.cancelJob");let{query:t}=a.importJobCancel();return (await this.connection.execute(t,{id:e})).importJobCancel}async listJobLogs(e,t={}){let{query:r,variables:s}=a.importJobLogs({importJobId:e,level:t.level,datasetKey:t.datasetKey,first:t.first,after:t.after}),i=this.cacheKey("imports","listJobLogs",s),n=await this.withCache(i,"imports",t,async()=>(await this.connection.execute(r,s)).importJob?.logs??wt());return new l(n,{nextPageLoader:async c=>this.listJobLogs(e,{...t,after:c})})}async waitForJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,i=Date.now();for(;;){let n=await this.getJob(e,{cache:false});if(!n)throw new Error(`Import job '${e}' was not found`);if(n.status==="COMPLETED"||n.status==="FAILED")return n;if(Date.now()-i>=s)throw new Error(`Timed out waiting for import job '${e}'`);await new Promise(c=>setTimeout(c,r));}}async previewGame(e){let{query:t}=a.gameImportPreview();return (await this.connection.execute(t,a.gameImportPreviewVariables(e))).gameImportPreview}async runGame(e){if(this.config.requireSecretCredential("imports.runGame"),"fileId"in e&&e.fileId){let{query:s}=a.gameImportFromFile();return (await this.connection.execute(s,a.gameImportFromFileVariables(e))).gameImportFromFile}if("sourceUrl"in e&&e.sourceUrl){let{query:s}=a.gameImportFromUrl();return (await this.connection.execute(s,a.gameImportFromUrlVariables(e))).gameImportFromUrl}let{query:t}=a.gameImportFromPayload();return (await this.connection.execute(t,a.gameImportFromPayloadVariables(e))).gameImportFromPayload}async getGameJob(e,t={}){let r=this.cacheKey("imports","getGameJob",{id:e});return this.withCache(r,"imports",t,async()=>{let{query:s}=a.gameImportJob();return (await this.connection.execute(s,{id:e})).gameImportJob??null})}async listGameJobs(e,t={}){let{query:r,variables:s}=a.gameImportJobs({gameId:e,status:t.status,first:t.first,after:t.after}),i=this.cacheKey("imports","listGameJobs",s),n=await this.withCache(i,"imports",t,async()=>(await this.connection.execute(r,s)).gameImportJobs);return new l(n,{nextPageLoader:async c=>this.listGameJobs(e,{...t,after:c})})}async cancelGameJob(e){this.config.requireSecretCredential("imports.cancelGameJob");let{query:t}=a.gameImportJobCancel();return (await this.connection.execute(t,{id:e})).gameImportJobCancel}async waitForGameJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,i=Date.now();for(;;){let n=await this.getGameJob(e,{cache:false});if(!n)throw new Error(`Game import job '${e}' was not found`);if(n.status==="COMPLETED"||n.status==="FAILED")return n;if(Date.now()-i>=s)throw new Error(`Timed out waiting for game import job '${e}'`);await new Promise(c=>setTimeout(c,r));}}};function wt(){return {totalCount:0,pageInfo:{hasNextPage:false,hasPreviousPage:false,startCursor:null,endCursor:null},edges:[]}}var St=class extends f{constructor(e,t){super(e,t);}async run(e){this.config.requireSecretCredential("exports.run");let{query:t}=a.datasetExport();return (await this.connection.execute(t,a.datasetExportVariables(e))).datasetExport}async create(e){return this.run(e)}async getJob(e,t={}){let r=this.cacheKey("exports","getJob",{id:e});return this.withCache(r,"exports",t,async()=>{let{query:s}=a.exportJob();return (await this.connection.execute(s,{id:e})).exportJob??null})}async listJobs(e,t={}){let{query:r,variables:s}=a.exportJobs({publisherId:e,gameId:t.gameId,datasetId:t.datasetId,status:t.status,first:t.first,after:t.after}),i=this.cacheKey("exports","listJobs",s),n=await this.withCache(i,"exports",t,async()=>(await this.connection.execute(r,s)).exportJobs);return new l(n,{nextPageLoader:async c=>this.listJobs(e,{...t,after:c})})}async refreshUrl(e){let{query:t}=a.exportJobRefreshUrl();return (await this.connection.execute(t,{id:e})).exportJobRefreshUrl}async cancel(e){this.config.requireSecretCredential("exports.cancel");let{query:t}=a.exportJobCancel();return (await this.connection.execute(t,{id:e})).exportJobCancel}async waitForJob(e,t={}){let r=t.intervalMs??1e3,s=t.timeoutMs??3e5,i=Date.now();for(;;){let n=await this.getJob(e,{cache:false});if(!n)throw new Error(`Export job '${e}' was not found`);if(n.status==="COMPLETED"||n.status==="FAILED")return n;if(Date.now()-i>=s)throw new Error(`Timed out waiting for export job '${e}'`);await new Promise(c=>setTimeout(c,r));}}},At=class extends f{constructor(e,t){super(e,t);}async get(e,t={}){let r=this.cacheKey("files","get",{id:e});return this.withCache(r,"files",t,async()=>{let{query:s}=a.file();return (await this.connection.execute(s,{id:e})).file??null})}async requestUpload(e){this.config.requireSecretCredential("files.requestUpload");let{query:t}=a.fileUploadRequest();return (await this.connection.execute(t,a.fileUploadRequestVariables(e))).fileUploadRequest}async confirmUpload(e){this.config.requireSecretCredential("files.confirmUpload");let{query:t}=a.fileUploadConfirm();return (await this.connection.execute(t,{id:e})).fileUploadConfirm}async upload(e){let t=e.size??xt(e.body);if(!t||t<=0)throw new Error("files.upload requires a positive size or a body with an inferable size");let r=await this.requestUpload({filename:e.filename,contentType:e.contentType,size:t,isPublic:e.isPublic??false,entityType:e.entityType??Tt(e.purpose),entityId:e.entityId,publisherId:e.publisherId,datasetId:e.datasetId});return await Et(r.uploadUrl,e.contentType,e.body),this.confirmUpload(r.file.id)}async delete(e){this.config.requireSecretCredential("files.delete");let{query:t}=a.fileDelete();return !!(await this.connection.execute(t,{id:e})).fileDelete}};async function Et(e,t,r){let s=globalThis.fetch;if(!s)throw new Error("files.upload requires a runtime with fetch support");let i=await s(e,{method:"PUT",headers:{"Content-Type":t},body:r});if(!i.ok){let n=await i.text().catch(()=>"");throw new Error(`File upload failed with ${i.status} ${i.statusText}${n?`: ${n}`:""}`)}}function xt(e){if(typeof e=="string")return new TextEncoder().encode(e).byteLength;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return e.byteLength;let t=e;if(typeof t?.size=="number")return t.size;if(typeof t?.byteLength=="number")return t.byteLength;if(typeof t?.length=="number")return t.length}function Tt(e){if(!(!e||e==="scan_image"))return e==="import"?"import":e==="scan_template_example"?"scan_template_example":e}var qt=class extends f{constructor(e,t){super(e,t);}async createJob(e){let t=this.resolveCreateJobInput(e),{query:r}=a.createScanJob();return (await this.connection.execute(r,a.createScanJobVariables(t))).createScanJob}async getJob(e,t={}){let r=this.cacheKey("scans","getJob",{id:e});return this.withCache(r,"scans",t,async()=>{let{query:s}=a.scanJob();return (await this.connection.execute(s,{id:e})).scanJob??null})}async pollJob(e,t={}){let r=t.timeoutMs??3e5,s=Math.max(t.backoffFactor??1.5,1),i=t.maxIntervalMs??1e4,n=Date.now(),c=Math.max(t.intervalMs??1e3,1);for(;;){Kt(t.signal);let o=await this.getJob(e,{cache:false});if(!o)throw new Error(`Scan job '${e}' was not found`);if(Rt(o.status))return o;let h=Date.now()-n,w=r-h;if(w<=0)throw new Error(`Timed out waiting for scan job '${e}'`);await Ct(Math.min(c,w)),c=Math.min(Math.ceil(c*s),i);}}async submitFeedback(e){let{query:t}=a.submitScanFeedback();return (await this.connection.execute(t,a.submitScanFeedbackVariables(e))).submitScanFeedback}async metrics(e){let t=this.resolveMetricsInput(e),{query:r}=a.scanMetrics();return (await this.connection.execute(r,a.scanMetricsVariables(t))).scanMetrics}async verifyWebhookSignature(e){let t=Ft(),r=await t.importKey("raw",$e(e.secret),{name:"HMAC",hash:"SHA-256"},false,["sign"]),s=await t.sign("HMAC",r,Ut(e.body)),i=`sha256=${Pt(new Uint8Array(s))}`;return Lt(e.signature.trim().toLowerCase(),i)}resolveCreateJobInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}resolveMetricsInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}};function Rt(e){let t=e.toLowerCase();return t==="completed"||t==="failed"||t==="cancelled"}async function Ct(e){return new Promise(t=>setTimeout(t,e))}function Kt(e){if(e&&(e.throwIfAborted&&e.throwIfAborted(),e.aborted))throw new Error("Scan job polling aborted")}function Ft(){let t=globalThis.crypto?.subtle;if(!t)throw new Error("Web Crypto HMAC support is not available in this runtime");return t}function Ut(e){return typeof e=="string"?$e(e):e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function $e(e){return new TextEncoder().encode(e)}function Pt(e){return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}function Lt(e,t){let r=Math.max(e.length,t.length),s=e.length^t.length;for(let i=0;i<r;i++)s|=(e.charCodeAt(i)||0)^(t.charCodeAt(i)||0);return s===0}var _t=class extends f{constructor(e,t){super(e,t);}async resolve(e){let t=this.resolveTemplateScope(e),r=this.cacheKey("scanTemplates","resolve",{...t});return this.withCache(r,"scanTemplates",e,async()=>{let{query:s}=a.resolveScanTemplate();return (await this.connection.execute(s,a.resolveScanTemplateVariables(t))).resolveScanTemplate})}async list(e){let t=this.resolveListScope(e),r=this.cacheKey("scanTemplates","list",{...t});return this.withCache(r,"scanTemplates",e,async()=>{let{query:s}=a.scanTemplates();return (await this.connection.execute(s,a.scanTemplatesVariables(t))).scanTemplates?.templates??[]})}async create(e){this.config.requireSecretCredential("scanTemplates.create");let t=this.resolveSaveInput(e),{query:r}=a.createScanTemplate();return (await this.connection.execute(r,a.createScanTemplateVariables(t))).createScanTemplate}async update(e,t){this.config.requireSecretCredential("scanTemplates.update");let r=typeof e=="string"?e:e.id,s=typeof e=="string"?t:Vt(e);if(!s)throw new Error("scan template input is required");let i=this.resolveSaveInput(s),{query:n}=a.updateScanTemplate();return (await this.connection.execute(n,a.updateScanTemplateVariables(r,i))).updateScanTemplate}async preview(e){let t=this.resolvePreviewInput(e),{query:r}=a.previewScanTemplate();return (await this.connection.execute(r,a.previewScanTemplateVariables(t))).previewScanTemplate}resolveTemplateScope(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,templateId:e.templateId}}resolveListScope(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{publisherSlug:t,gameKey:r,datasetKey:e.datasetKey,includeArchived:e.includeArchived}}resolveSaveInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}resolvePreviewInput(e){let t=this.resolvePublisher(e.publisherSlug),r=this.resolveGame(e.gameKey);return this.validateAccess(t,r),{...e,publisherSlug:t,gameKey:r}}};function Vt(e){let t={...e};return delete t.id,t}var ve=class De{config;connection;publishers;games;datasets;records;decks;rules;importFormats;imports;exports;files;scans;scanTemplates;constructor(t={}){this.config=new nt(t),this.connection=new dt(this.config),this.publishers=new pt(this.connection,this.config),this.games=new mt(this.connection,this.config),this.datasets=new gt(this.connection,this.config),this.records=new bt(this.connection,this.config),this.decks=new kt(this.connection,this.config),this.rules=new $t(this.connection,this.config),this.importFormats=new vt(this.connection,this.config),this.imports=new Dt(this.connection,this.config),this.exports=new St(this.connection,this.config),this.files=new At(this.connection,this.config),this.scans=new qt(this.connection,this.config),this.scanTemplates=new _t(this.connection,this.config);}async me(){let{query:t}=a.fetchMe();return (await this.connection.execute(t)).fetchMe??null}getRateLimitInfo(){return lt()}withConfig(t){let r=this.config.merge(t);return new De({apiKey:r.configApiKey(),publishableKey:r.publishableKey,secretKey:r.secretKey,accessToken:r.accessToken,environment:r.environment,endpoint:r.endpoint,timeout:r.timeout,openTimeout:r.openTimeout,defaultPublisher:r.defaultPublisher,defaultGame:r.defaultGame,allowedPublishers:r.allowedPublishers,allowedGames:r.allowedGames,logger:r.logger,logLevel:r.logLevel,retryOnRateLimit:r.retryOnRateLimit,maxRetries:r.maxRetries,retryOnNetworkError:r.retryOnNetworkError,maxNetworkRetries:r.maxNetworkRetries,retryBaseDelay:r.retryBaseDelay,retryMaxDelay:r.retryMaxDelay,cache:r.cache,cacheTtl:r.cacheTtl,cacheTtls:r.cacheTtls})}};var W=class{storage;prefix;constructor(t={}){let r=t.storage??"localStorage";this.storage=r==="sessionStorage"?globalThis.sessionStorage:globalThis.localStorage,this.prefix=t.prefix??"carddb:";}get(t){try{let r=this.storage.getItem(this.prefix+t);if(!r)return null;let s=JSON.parse(r);return s.expiresAt!==null&&Date.now()>s.expiresAt?(this.storage.removeItem(this.prefix+t),null):s.value}catch{return this.storage.removeItem(this.prefix+t),null}}set(t,r,s){try{let i={value:r,expiresAt:s!==void 0?Date.now()+s*1e3:null};this.storage.setItem(this.prefix+t,JSON.stringify(i));}catch(i){console.warn("[CardDB] Failed to write to cache:",i);}}delete(t){this.storage.removeItem(this.prefix+t);}clear(){let t=[];for(let r=0;r<this.storage.length;r++){let s=this.storage.key(r);s&&s.startsWith(this.prefix)&&t.push(s);}for(let r of t)this.storage.removeItem(r);}has(t){return this.get(t)!==null}get size(){let t=0;for(let r=0;r<this.storage.length;r++){let s=this.storage.key(r);s&&s.startsWith(this.prefix)&&t++;}return t}cleanup(){let t=Date.now(),r=[];for(let s=0;s<this.storage.length;s++){let i=this.storage.key(s);if(i&&i.startsWith(this.prefix))try{let n=this.storage.getItem(i);if(n){let c=JSON.parse(n);c.expiresAt!==null&&t>c.expiresAt&&r.push(i);}}catch{r.push(i);}}for(let s of r)this.storage.removeItem(s);}};var we=class extends ve{constructor(t={}){if("apiKey"in t&&t.apiKey!==void 0)throw new $("apiKey is not accepted in browsers; use publishableKey or accessToken");if("secretKey"in t&&t.secretKey!==void 0)throw new $("secretKey is server-only; use publishableKey or accessToken in browsers");super(t);}};
1920
+ export{M as AuthenticationError,f as BaseResource,W as BrowserCache,we as CardDBClient,y as CardDBError,l as Collection,nt as Configuration,dt as Connection,E as ConnectionError,tt as DEFAULT_CACHE_TTL,Qe as DEFAULT_ENDPOINT,st as DEFAULT_MAX_NETWORK_RETRIES,rt as DEFAULT_MAX_RETRIES,et as DEFAULT_OPEN_TIMEOUT,it as DEFAULT_RETRY_BASE_DELAY,at as DEFAULT_RETRY_MAX_DELAY,Ze as DEFAULT_TIMEOUT,gt as DatasetsResource,kt as DecksResource,St as ExportsResource,At as FilesResource,Se as FilterBuilder,mt as GamesResource,ne as GraphQLError,vt as ImportFormatsResource,Dt as ImportsResource,Mt as LinkResolutionError,Bt as NotFoundError,pt as PublishersResource,a as QueryBuilder,K as RateLimitError,bt as RecordsResource,$ as RestrictedError,$t as RulesResource,_t as ScanTemplatesResource,qt as ScansResource,O as ServerError,G as TimeoutError,J as ValidationError,ht as cacheKey,Wt as contains,Jt as eq,lt as getRateLimitInfo,fr as getSDKVersion,ut as getUserAgent,Ot as gt,Nt as gte,Qt as ilike,er as isNotNull,Zt as isNull,Xt as like,jt as lt,Ht as lte,Gt as neq,zt as notWithin,yt as readCache,F as resolveFilter,Yt as within,ft as writeCache};//# sourceMappingURL=index.js.map
1674
1921
  //# sourceMappingURL=index.js.map