@flesh-and-blood/search 5.0.4 → 5.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/filters.js +49 -27
- package/dist/index.cjs +1 -1
- package/dist/lookups.d.ts +21 -0
- package/dist/lookups.js +14 -0
- package/dist/metaFilters.js +3 -2
- package/dist/search.js +12 -23
- package/package.json +4 -4
package/dist/filters.js
CHANGED
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
Release,
|
|
6
6
|
Treatment,
|
|
7
7
|
Type,
|
|
8
|
-
setIdentifierToSetMappings,
|
|
9
8
|
setToSetIdentifierMappings
|
|
10
9
|
} from "@flesh-and-blood/types";
|
|
11
10
|
import { getAbbreviation } from "./abbreviations.js";
|
|
@@ -13,6 +12,10 @@ import { getExcludedMetaFilters, getMetaFilters } from "./metaFilters.js";
|
|
|
13
12
|
import { multiWordShorthands, singleWordShorthands } from "./shorthands.js";
|
|
14
13
|
import { PUNCTUATION } from "./constants.js";
|
|
15
14
|
import { getTextWithoutMarkup } from "./helpers.js";
|
|
15
|
+
import {
|
|
16
|
+
getLookupWithoutInheritedKeys,
|
|
17
|
+
releasesBySetIdentifier
|
|
18
|
+
} from "./lookups.js";
|
|
16
19
|
import {
|
|
17
20
|
getCardsByName,
|
|
18
21
|
getCardsReferencedBy,
|
|
@@ -275,7 +278,7 @@ const filtersToCardPropertyMappings = {
|
|
|
275
278
|
x: typeTextFilter,
|
|
276
279
|
year: yearFilter
|
|
277
280
|
};
|
|
278
|
-
const filtersToCardPropertyMappingsByKey = filtersToCardPropertyMappings;
|
|
281
|
+
const filtersToCardPropertyMappingsByKey = getLookupWithoutInheritedKeys(filtersToCardPropertyMappings);
|
|
279
282
|
const punctuationOverrides = [
|
|
280
283
|
{
|
|
281
284
|
text: Release.ClassicBattlesRhinarDorinthea.toLowerCase(),
|
|
@@ -285,6 +288,21 @@ const punctuationOverrides = [
|
|
|
285
288
|
)
|
|
286
289
|
}
|
|
287
290
|
];
|
|
291
|
+
const setIdentifiersBySetName = new Map(
|
|
292
|
+
Object.entries(setToSetIdentifierMappings).map(([set, setIdentifiers]) => [
|
|
293
|
+
set.toLowerCase(),
|
|
294
|
+
setIdentifiers
|
|
295
|
+
])
|
|
296
|
+
);
|
|
297
|
+
const SET_FILTER_KEYS = ["set", "s", "print"];
|
|
298
|
+
const getEscapedForRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
299
|
+
const setNamesLongestFirst = [...setIdentifiersBySetName.keys()].sort((first, second) => second.length - first.length).map(getEscapedForRegExp).join("|");
|
|
300
|
+
const setNameInSetFilterPattern = new RegExp(
|
|
301
|
+
`(?<=^|\\s)([${availableExclusions.join("")}]?(?:${SET_FILTER_KEYS.join(
|
|
302
|
+
"|"
|
|
303
|
+
)}):(?:[^\\s]*[,+])?"?)(${setNamesLongestFirst})(?="?(?:[,+]|\\s|$))`,
|
|
304
|
+
"g"
|
|
305
|
+
);
|
|
288
306
|
const getSearchCriteria = (text) => {
|
|
289
307
|
const searchCriteria = [];
|
|
290
308
|
let rawSearchCriteria = text.replaceAll("\u201D", '"');
|
|
@@ -334,12 +352,17 @@ const getKeywordsAndAppliedFiltersFromText = (text, index, additionalHeroes = []
|
|
|
334
352
|
}
|
|
335
353
|
}
|
|
336
354
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
355
|
+
expandedText = expandedText.replace(
|
|
356
|
+
setNameInSetFilterPattern,
|
|
357
|
+
(setNameInSetFilter, filterPrefix, setName) => {
|
|
358
|
+
const setIdentifiers = setIdentifiersBySetName.get(setName);
|
|
359
|
+
return setIdentifiers ? `${filterPrefix}${setIdentifiers[0]}` : setNameInSetFilter;
|
|
342
360
|
}
|
|
361
|
+
);
|
|
362
|
+
const wholeQuerySetIdentifiers = setIdentifiersBySetName.get(expandedText);
|
|
363
|
+
const namesACard = index.getCardsByExactName(expandedText).length > 0;
|
|
364
|
+
if (wholeQuerySetIdentifiers && !namesACard) {
|
|
365
|
+
expandedText = `set:${wholeQuerySetIdentifiers[0]}`;
|
|
343
366
|
}
|
|
344
367
|
const rawSearchCriteria = getSearchCriteria(expandedText);
|
|
345
368
|
const searchCriteria = [];
|
|
@@ -597,7 +620,7 @@ const getMatchingReleasesFromRawValue = (rawValue, additionalSets = []) => {
|
|
|
597
620
|
releases.push(setFromValue);
|
|
598
621
|
}
|
|
599
622
|
if (releases.length === 0) {
|
|
600
|
-
const setFromSetIdentifier =
|
|
623
|
+
const setFromSetIdentifier = releasesBySetIdentifier[rawValue];
|
|
601
624
|
if (setFromSetIdentifier) {
|
|
602
625
|
releases.push(setFromSetIdentifier);
|
|
603
626
|
}
|
|
@@ -620,20 +643,21 @@ const getMatchingReleasesFromRawValue = (rawValue, additionalSets = []) => {
|
|
|
620
643
|
}
|
|
621
644
|
return releases;
|
|
622
645
|
};
|
|
623
|
-
const pitchValuesMapping = {
|
|
646
|
+
const pitchValuesMapping = getLookupWithoutInheritedKeys({
|
|
624
647
|
purple: 4,
|
|
625
648
|
blue: 3,
|
|
626
649
|
yellow: 2,
|
|
627
650
|
red: 1,
|
|
628
651
|
white: 0
|
|
629
|
-
};
|
|
652
|
+
});
|
|
630
653
|
const getPitchValuesFromText = (rawValues) => {
|
|
631
654
|
const values = [];
|
|
632
655
|
for (const rawValue of rawValues) {
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
} else {
|
|
656
|
+
const pitchValue = pitchValuesMapping[rawValue];
|
|
657
|
+
if (pitchValue === void 0) {
|
|
636
658
|
values.push(rawValue);
|
|
659
|
+
} else {
|
|
660
|
+
values.push(pitchValue.toString());
|
|
637
661
|
}
|
|
638
662
|
}
|
|
639
663
|
return values;
|
|
@@ -647,22 +671,20 @@ const getTodayAsReleaseDate = () => {
|
|
|
647
671
|
const dayOfMonth = `${now.getDate()}`.padStart(2, "0");
|
|
648
672
|
return `${now.getFullYear()}-${month}-${dayOfMonth}`;
|
|
649
673
|
};
|
|
650
|
-
const metaValuesMapping = {
|
|
674
|
+
const metaValuesMapping = getLookupWithoutInheritedKeys({
|
|
651
675
|
dual: Meta.DualClass,
|
|
652
676
|
exp: Meta.Expansion,
|
|
653
677
|
expansion: Meta.Expansion,
|
|
654
|
-
expansionSlot: Meta.Expansion,
|
|
655
678
|
rainbow: Meta.Rainbow,
|
|
656
679
|
reprint: Meta.Reprint,
|
|
657
680
|
reprints: Meta.Reprint
|
|
658
|
-
};
|
|
681
|
+
});
|
|
659
682
|
const getMetaValuesFromText = (rawValues) => {
|
|
660
683
|
const values = [];
|
|
661
684
|
for (const rawValue of rawValues) {
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
values.push(Meta[rawValue]);
|
|
685
|
+
const meta = metaValuesMapping[rawValue];
|
|
686
|
+
if (meta) {
|
|
687
|
+
values.push(meta);
|
|
666
688
|
}
|
|
667
689
|
}
|
|
668
690
|
if (rawValues.length > 0 && values.length === 0) {
|
|
@@ -677,7 +699,7 @@ const getMetaValuesFromText = (rawValues) => {
|
|
|
677
699
|
}
|
|
678
700
|
return values;
|
|
679
701
|
};
|
|
680
|
-
const foilingValuesMapping = {
|
|
702
|
+
const foilingValuesMapping = getLookupWithoutInheritedKeys({
|
|
681
703
|
r: Foiling.Rainbow,
|
|
682
704
|
rf: Foiling.Rainbow,
|
|
683
705
|
rainbow: Foiling.Rainbow,
|
|
@@ -687,7 +709,7 @@ const foilingValuesMapping = {
|
|
|
687
709
|
g: Foiling.Gold,
|
|
688
710
|
gf: Foiling.Gold,
|
|
689
711
|
gold: Foiling.Gold
|
|
690
|
-
};
|
|
712
|
+
});
|
|
691
713
|
const getFoilingValuesFromText = (rawValues) => {
|
|
692
714
|
const values = [];
|
|
693
715
|
for (const rawValue of rawValues) {
|
|
@@ -697,7 +719,7 @@ const getFoilingValuesFromText = (rawValues) => {
|
|
|
697
719
|
}
|
|
698
720
|
return values;
|
|
699
721
|
};
|
|
700
|
-
const treatmentValuesMapping = {
|
|
722
|
+
const treatmentValuesMapping = getLookupWithoutInheritedKeys({
|
|
701
723
|
...Object.values(Treatment).reduce(
|
|
702
724
|
(treatmentsByLowercasedName, treatment) => {
|
|
703
725
|
treatmentsByLowercasedName[treatment.toLowerCase()] = treatment;
|
|
@@ -722,8 +744,8 @@ const treatmentValuesMapping = {
|
|
|
722
744
|
full: Treatment.FA,
|
|
723
745
|
"full art": Treatment.FA
|
|
724
746
|
}
|
|
725
|
-
};
|
|
726
|
-
const treatmentsByAbbreviation = Treatment;
|
|
747
|
+
});
|
|
748
|
+
const treatmentsByAbbreviation = getLookupWithoutInheritedKeys(Treatment);
|
|
727
749
|
const getTreatmentValuesFromText = (rawValues) => {
|
|
728
750
|
const values = [];
|
|
729
751
|
for (const rawValue of rawValues) {
|
|
@@ -737,7 +759,7 @@ const getTreatmentValuesFromText = (rawValues) => {
|
|
|
737
759
|
}
|
|
738
760
|
return values;
|
|
739
761
|
};
|
|
740
|
-
const RARITY_VALUES_MAPPING = {
|
|
762
|
+
const RARITY_VALUES_MAPPING = getLookupWithoutInheritedKeys({
|
|
741
763
|
b: Rarity.Basic,
|
|
742
764
|
c: Rarity.Common,
|
|
743
765
|
f: Rarity.Fabled,
|
|
@@ -748,7 +770,7 @@ const RARITY_VALUES_MAPPING = {
|
|
|
748
770
|
s: Rarity.SuperRare,
|
|
749
771
|
t: Rarity.Token,
|
|
750
772
|
v: Rarity.Marvel
|
|
751
|
-
};
|
|
773
|
+
});
|
|
752
774
|
const getRarityValuesFromText = (rawValues) => {
|
|
753
775
|
const values = [];
|
|
754
776
|
for (const rawValue of rawValues) {
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Cr=Object.create;var te=Object.defineProperty;var mr=Object.getOwnPropertyDescriptor;var br=Object.getOwnPropertyNames;var Tr=Object.getPrototypeOf,Mr=Object.prototype.hasOwnProperty;var Fr=(e,r)=>{for(var t in r)te(e,t,{get:r[t],enumerable:!0})},Ee=(e,r,t,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of br(r))!Mr.call(e,i)&&i!==t&&te(e,i,{get:()=>r[i],enumerable:!(a=mr(r,i))||a.enumerable});return e};var vr=(e,r,t)=>(t=e!=null?Cr(Tr(e)):{},Ee(r||!e||!e.__esModule?te(t,"default",{value:e,enumerable:!0}):t,e)),Ar=e=>Ee(te({},"__esModule",{value:!0}),e);var Rt={};Fr(Rt,{FilterProperty:()=>Q,MARKUP:()=>he,NO_CARD_PROPERTY:()=>U,PUNCTUATION:()=>b,RARITY_VALUES_MAPPING:()=>Ie,abbreviations:()=>Ce,availableExclusions:()=>cr,availableModifiers:()=>dr,default:()=>yr,filterCard:()=>hr,filtersToCardPropertyMappings:()=>pr,getAbbreviation:()=>ae,getAbbreviationByCard:()=>xr,getCardsByName:()=>le,getCardsByReferencedCardIdentifier:()=>wt,getCardsReferencedBy:()=>ce,getCardsReferencing:()=>de,getCatalogueIndex:()=>ve,getCleanText:()=>$,getExcludedMetaFilters:()=>be,getKeywordsAndAppliedFiltersFromText:()=>Be,getMetaFilters:()=>me,getNormalizedText:()=>X,getOtherPitches:()=>Pt,getReferencedCards:()=>St,getTextWithoutMarkup:()=>J,getTokensReferencedByCards:()=>kt,multiWordShorthands:()=>Me,shorthands:()=>Te,singleWordShorthands:()=>Fe});module.exports=Ar(Rt);var ge=require("@flesh-and-blood/types"),Ne=vr(require("fuse.js"),1);var b=/[!"#$%&'’(),./:;<=>?@[\]^_`|~]/g,he=/\*/g;var d=require("@flesh-and-blood/types");var ae=e=>Ce.find(({abbreviations:r})=>r.find(t=>t.toLowerCase()===e)),xr=e=>Ce.find(({card:r})=>r.toLowerCase()===e.name.toLowerCase()),Ce=[{abbreviations:["10k"],card:"10,000 Year Reunion"},{abbreviations:["Pajamas","PJs"],card:"Alluvion Constellas"},{abbreviations:["Slippy","Arakni Slipped Through the Cracks","Arakni, Slipped Through the Cracks"],card:"Arakni, 5L!p3d 7hRu 7h3 cR4X"},{abbreviations:["Dullcap"],card:"Arcanite Skullcap"},{abbreviations:["ALS"],card:"Arc Light Sentinel"},{abbreviations:["AoW"],card:"Art of War"},{abbreviations:["BBD"],card:"Barraging Beatdown"},{abbreviations:["BBS"],card:"Big Blue Sky"},{abbreviations:["Starvo"],card:"Bravo, Star of the Show"},{abbreviations:["BEB"],card:"Bull's Eye Bracers"},{abbreviations:["BLW"],card:"Be Like Water"},{abbreviations:["BoJ"],card:"Balance of Justice"},{abbreviations:["BOHH"],card:"Blood on Her Hands"},{abbreviations:["BRB"],card:"Bloodrush Bellow"},{abbreviations:["Breezies"],card:"Breeze Rider Boots"},{abbreviations:["BTA"],card:"Burn Them All"},{abbreviations:["CStrike","C-Strike","C Strike"],card:"Celestial Cataclysm"},{abbreviations:["CBelly"],card:"Cerebellum Processor"},{abbreviations:["CLF"],card:"Channel Lake Frigid"},{abbreviations:["CLV"],card:"Channel Lightning Valley"},{abbreviations:["CMH"],card:"Channel Mount Heroic"},{abbreviations:["CMI"],card:"Channel Mount Isen"},{abbreviations:["CMT"],card:"Channel the Millennium Tree"},{abbreviations:["CnC","C&C"],card:"Command and Conquer"},{abbreviations:["Sea and Sea"],card:"Conqueror of the High Seas"},{abbreviations:["CYB"],card:"Count Your Blessings"},{abbreviations:["Cat","Kitty"],card:"Crouching Tiger"},{abbreviations:["CoD"],card:"Crown of Dominion"},{abbreviations:["CoP"],card:"Crown of Providence"},{abbreviations:["CtW"],card:"Crush the Weak"},{abbreviations:["DD"],card:"Death Dealer"},{abbreviations:["DnD"],card:"Devotion Never Dies"},{abbreviations:["DIO"],card:"Dash I/O"},{abbreviations:["EBTT"],card:"Even Bigger Than That!"},{abbreviations:["NewNigma"],card:"Enigma, New Moon"},{abbreviations:["EPot","E Pot"],card:"Energy Potion"},{abbreviations:["EStrike","E-Strike","E Strike"],card:"Enlightened Strike"},{abbreviations:["FFS"],card:"Fyendal's Fighting Spirit"},{abbreviations:["FoN"],card:"Force of Nature"},{abbreviations:["Frosty","\u{1F976}","\u{1F9CA}","\u2744\uFE0F"],card:"Frostbite"},{abbreviations:["Yum yum"],card:"Fruits of the Forest"},{abbreviations:["GnT"],card:"Give and Take"},{abbreviations:["Habibi"],card:"Hanabi Blaster"},{abbreviations:["HMH"],card:"Hope Merchant's Hood"},{abbreviations:["HoI"],card:"Heart of Ice"},{abbreviations:["Pumpkin"],card:"Jack-o'-lantern"},{abbreviations:["RKO","Cheato"],card:"Kayo, Underhanded Cheat"},{abbreviations:["KKBB"],card:"Knick Knack Bric-a-brac"},{abbreviations:["BStrike"],card:"Levels of Enlightenment"},{abbreviations:["LAG","Twominaris"],card:"Luminaris, Angel's Glow"},{abbreviations:["LCF","Newminaris"],card:"Luminaris, Celestial Fury"},{abbreviations:["LDE"],card:"Last Ditch Effort"},{abbreviations:["LtC"],card:"Lead the Charge"},{abbreviations:["LNW"],card:"Leave No Witnesses"},{abbreviations:["LFaL","L4aL"],card:"Life for a Life"},{abbreviations:["LiT"],card:"Lost in Thought"},{abbreviations:["MMB"],card:"Mage Master Boots"},{abbreviations:["MaxV"],card:"Maximum Velocity"},{abbreviations:["MoM"],card:"Mask of Momentum"},{abbreviations:["MoPL"],card:"Mask of the Pouncing Lynx"},{abbreviations:["MnG"],card:"Meat and Greet"},{abbreviations:["Cake","\u{1F382}"],card:"Ninth Blade of the Blood Oath"},{abbreviations:["PoM"],card:"Peace of Mind"},{abbreviations:["P-Bone"],card:"Performance Bonus"},{abbreviations:["PF","\u{1F525}"],card:"Phoenix Flame"},{abbreviations:["PtW"],card:"Poison the Well"},{abbreviations:["Thanos","Infinity Gauntlet"],card:"Polarity Reversal Script"},{abbreviations:["DPot","D Pot"],card:"Potion of D\xE9j\xE0 Vu"},{abbreviations:["Ponder Run"],card:"Premeditate"},{abbreviations:["Qi Unbound"],card:"Qi Unleashed"},{abbreviations:["RitL"],card:"Red in the Ledger"},{abbreviations:["Cats","Ghost cat","Ghost cats"],card:"Restless Coalescence"},{abbreviations:["Eugene"],card:"Rhinar, Reckless Rampage",isHidden:!0},{abbreviations:["SSGB"],card:"Sandscour Greatbow"},{abbreviations:["SSP"],card:"Sand Sketched Plan"},{abbreviations:["SFaS","S4aS"],card:"Scar for a Scar"},{abbreviations:["Tyler"],card:"Scurv, Stowaway",isHidden:!0},{abbreviations:["SWOMB"],card:"Shifting Winds of the Mystic Beast"},{abbreviations:["Snaps"],card:"Snapdragon Scalers"},{abbreviations:["SWK"],card:"Spinning Wheel Kick"},{abbreviations:["SFTL"],card:"Swing Fist, Think Later"},{abbreviations:["TTT"],card:"Take the Tempo"},{abbreviations:["Ultron"],card:"Teklovossen, the Mechropotent"},{abbreviations:["ToS"],card:"Test of Strength"},{abbreviations:["TAYG"],card:"That All You Got?"},{abbreviations:["TROM"],card:"This Round's on Me"},{abbreviations:["3oak"],card:"Three of a Kind"},{abbreviations:["Pox Malone","Post Malone"],card:"Virulent Touch"},{abbreviations:["Cast Homes"],card:"Visit Goldmane Estate"},{abbreviations:["Frosty Hammer"],card:"Winter's Wail"},{abbreviations:["Wreckless Wing"],card:"War Cry of Bellona"},{abbreviations:["ZTS"],card:"Zero to Sixty"}];var k=require("@flesh-and-blood/types");var Q={BannedFormats:"bannedFormats",LegalFormats:"legalFormats",LegalHeroes:"legalHeroes"},ne=Array.from(Array(50).keys()).map(e=>`${e}`),Pr=[{format:k.Format.ClassicConstructed,nicknames:["cc","classic"]},{format:k.Format.LivingLegend,nicknames:["cc ll","classic constructed ll","ll cc","ll","living legend"]},{format:k.Format.SilverAge,nicknames:["sage"]},{format:k.Format.GoldenAge,nicknames:["gage"]},{format:k.Format.UltimatePitFight,nicknames:["upf"]}],Sr=Object.values(k.Format).map(e=>{let r=Pr.find(({format:a})=>a===e),t=e.toLowerCase().replaceAll(b,"");return r?{...r,format:t}:{format:t}}),wr=[{hero:k.Hero.DataDoll,nicknames:["data","datadoll"]},{hero:k.Hero.Dorinthea,nicknames:["dori"]},{hero:k.Hero.Genis,nicknames:["genis"]},{hero:k.Hero.GravyBones,nicknames:["gravy"]},{hero:k.Hero.Iyslander,nicknames:["islander"]}],kr=Object.values(k.Hero).map(e=>{let r=wr.find(({hero:a})=>a===e),t=e.toLowerCase().replaceAll(b,"");return r?{...r,hero:t}:{hero:t}}),ie=["common","rare","super rare","majestic","legendary","fabled"],Rr=(e,r,t,a)=>{let i=[];if(!r)i.push(...e);else for(let s of e)switch(r){case">=":{let o=!1;for(let n of ie)o?i.push(n):n===s&&(o=!0,i.push(n));break}case">":{let o=!1;for(let n of ie)o?i.push(n):n===s&&(o=!0);break}case"<=":{let o=!1;for(let n of ie.slice().reverse())o?i.push(n):n===s&&(o=!0,i.push(n));break}case"<":{let o=!1;for(let n of ie.slice().reverse())o?i.push(n):n===s&&(o=!0);break}default:break}return{filterToPropertyMapping:{nestedProperty:"rarity",property:"printings",isArray:!0},isExcluded:t,isOptional:a,isOr:!0,values:i}},De=(e,r,t,a,i)=>{let s=a.map(p=>({hero:p.toLowerCase().replaceAll(b,"")})),o=[],n=[],c=[];for(let p of e){let f=Sr.find(({format:T,nicknames:M})=>T===p||!!M&&M.includes(p));if(f)n.push(f.format);else{let T=kr.find(({hero:M,nicknames:L})=>M===p||!!L&&L.includes(p))||s.find(({hero:M})=>M===p);T&&c.push(T.hero)}}let F=i||"legalFormats";return n.length>0&&o.push({filterToPropertyMapping:{property:F,isArray:!0},values:n,isOr:!0,isExcluded:r,isOptional:t}),c.length>0&&o.push({filterToPropertyMapping:{property:Q.LegalHeroes,isArray:!0},values:c,isOr:!0,isExcluded:r,isOptional:t}),o},Ir=(e,r,t,a)=>De(e,r,t,a,"bannedFormats"),me=(e,r,t,a,i,s)=>{let o=[];return Nr(t)?o.push(...De(a,e,r,s)):Dr(t)?o.push(...Ir(a,e,r,s)):Hr(t)&&o.push(Rr(a,i,e,r)),o},Y=[{filterToPropertyMapping:{property:"cost",isNumber:!0},isExcluded:!0,values:ne},{filterToPropertyMapping:{property:"specialCost",isString:!0,partialMatch:!0},isExcluded:!0,values:["*","x"]},{filterToPropertyMapping:{property:"types",isArray:!0,partialMatch:!0},isExcluded:!0,values:["equipment","hero","placeholder","token","weapon"]}],G=[{filterToPropertyMapping:{property:"defense",isNumber:!0},isExcluded:!0,values:ne},{filterToPropertyMapping:{property:"specialDefense",isString:!0,partialMatch:!0},isExcluded:!0,values:["*","x"]},{filterToPropertyMapping:{property:"types",isArray:!0,partialMatch:!0},isExcluded:!0,values:["hero","placeholder","token","weapon"]}],se=[{filterToPropertyMapping:{property:"pitch",isNumber:!0},isExcluded:!0,values:ne},{filterToPropertyMapping:{property:"types",isArray:!0,partialMatch:!0},isExcluded:!0,values:["equipment","hero","placeholder","token","weapon"]},{filterToPropertyMapping:{property:"isCardBack",isBoolean:!0},isExcluded:!0,values:["true"]}],_=[{filterToPropertyMapping:{property:"power",isNumber:!0},isExcluded:!0,values:ne},{filterToPropertyMapping:{property:"specialPower",isString:!0,partialMatch:!0},isExcluded:!0,values:["*","x"]},{filterToPropertyMapping:{property:"types",isArray:!0,partialMatch:!0},isExcluded:!0,values:["equipment","hero","placeholder","token"]}],oe=[{filterToPropertyMapping:{property:"talents",isArray:!0},isExcluded:!0,values:Object.values(k.Talent).map(e=>e.toLowerCase())}],Br={"!co":Y,"-co":Y,"!cost":Y,"-cost":Y,"!color":Y,"-color":Y,"!b":G,"-b":G,"!block":G,"-block":G,"!d":G,"-d":G,"!def":G,"-def":G,"!defense":G,"-defense":G,"!pitch":se,"-pitch":se,"!p":se,"-p":se,"!attack":_,"-attack":_,"!power":_,"-power":_,"!pwr":_,"-pwr":_,"!pow":_,"-pow":_,"!talents":oe,"-talents":oe,"!tal":oe,"-tal":oe},be=e=>{let r=[],t=Br[e];return t&&r.push(...t),r},Lr=["l","legal","hero"],Nr=e=>Lr.includes(e),Er=["banned"],Dr=e=>Er.includes(e),Or=["r","rarity"],Hr=e=>Or.includes(e);var D=require("@flesh-and-blood/types"),Te=[{description:"Attack actions",expanded:["st:attack"],filters:{subtypes:[D.Subtype.Attack]},isCardProperty:!1,shorthands:["AA"]},{description:"Arcane barrier",expanded:['k:"arcane barrier"'],filters:{keywords:[D.Keyword.ArcaneBarrier]},isCardProperty:!1,shorthands:["AB"]},{description:"Attack reactions",expanded:['t:"attack reaction"'],filters:{types:[D.Type.AttackReaction]},isCardProperty:!1,shorthands:["AR"]},{description:"Defense reactions",expanded:['t:"defense reaction"'],filters:{types:[D.Type.DefenseReaction]},isCardProperty:!1,shorthands:["DR"]},{description:"Gain life",expanded:["gain {h}"],filters:{functionalText:"gain {h}"},isCardProperty:!1,shorthands:["Gain life","Gains life"]},{description:"Go again",expanded:['k:"go again"'],filters:{keywords:[D.Keyword.GoAgain]},isCardProperty:!1,shorthands:["GA"]},{description:"Non-attack actions",expanded:["t:action","st:non-attack"],filters:{subtypes:[D.Subtype.NonAttack],types:[D.Type.Action]},isCardProperty:!1,shorthands:["NAA"]},{description:"Plus defense",expanded:["+ {d}"],filters:{functionalText:"+ {d}"},isCardProperty:!1,shorthands:["Pump defense","Pumps defense","Buff defense","Buffs defense"]},{description:"Spellvoid",expanded:['k:"spellvoid"'],filters:{keywords:[D.Keyword.Spellvoid]},isCardProperty:!1,shorthands:["SV"]}],Me=Te.filter(({shorthands:e})=>e.some(r=>r.includes(" "))).map(e=>({...e,shorthands:e.shorthands.filter(r=>r.includes(" ")).map(r=>r.toLowerCase()).sort((r,t)=>t.length-r.length)})),Fe=Te.filter(({shorthands:e})=>e.some(r=>!r.includes(" "))).map(e=>({...e,shorthands:e.shorthands.filter(r=>!r.includes(" ")).map(r=>r.toLowerCase()).sort((r,t)=>t.length-r.length)}));var $=e=>X(e.toLowerCase().trim().replace(b,"")),X=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,""),J=e=>e.replace(he,"");var q=require("@flesh-and-blood/types");var Oe=new WeakMap,j=Object.freeze([]),Vr=Number.MAX_SAFE_INTEGER,He=(e,r)=>{let t=new Map;for(let a of e)for(let i of r(a)||[]){let s=t.get(i);s?s.push(a):t.set(i,[a])}return t},Gr=e=>{let r=new Map;for(let t of e){let a=t.types.includes(q.Type.Hero)&&!t.isCardBack,i=a?q.CardRole.Hero:(0,q.getCardRole)(t);if(a||i!==q.CardRole.Hero){let o=r.get(i);o?o.push(t):r.set(i,[t])}}return r},Wr=e=>{let r,t,a,i,s,o=()=>{if(!r){let l=new Map,g=new Map,u=[],y=new Map,m=0;for(let R of e){l.set(R.cardIdentifier,R),g.set(R.cardIdentifier,m),m++;let A=$(R.name),B=y.get(A);B?B.push(R):(y.set(A,[R]),u.push(A))}r={cardByCardIdentifier:l,corpusPositionByCardIdentifier:g,cleanedNames:u,pitchCycleByCleanedName:y}}return r},n=l=>{let{corpusPositionByCardIdentifier:g}=o(),u=({cardIdentifier:y})=>g.get(y)??Vr;return[...l].sort((y,m)=>u(y)-u(m))},c=l=>o().cardByCardIdentifier.get(l),F=l=>{let{cardByCardIdentifier:g}=o(),u=[];for(let y of l||[]){let m=g.get(y);m&&u.push(m)}return n(u)},p=l=>{let g=new Map;return u=>{let y=g.get(u);if(!y){let m=c(u),R=F(m&&l(m)),A=R.length>0;y=A?R:j,A&&g.set(u,y)}return y}},f=l=>{let{pitchCycleByCleanedName:g}=o(),u=c(l);return u?g.get($(u.name))??j:j},T=l=>{let{cleanedNames:g,pitchCycleByCleanedName:u}=o(),y=$(l),m=u.get(y);if(!m&&y.length>0){let A=g.find(B=>B.includes(y));A&&(m=u.get(A))}return m??j},M=l=>{let{pitchCycleByCleanedName:g}=o();return g.get($(l))??j},L=()=>{if(!s){let l=new Set;for(let g of e)for(let u of g.artists)l.add(u);s=[...l].sort((g,u)=>g.localeCompare(u,"en",{sensitivity:"base"}))}return s},O=p(({oppositeSideCardIdentifiers:l})=>l),W=p(({referencedCards:l})=>l),P=l=>(t||(t=He(e,({referencedCards:g})=>g)),t.get(l)??j),S=p(({createdExtras:l})=>l);return{cards:e,getCard:c,getPitchCycle:f,getCardsByName:T,getCardsByExactName:M,getArtists:L,getOppositeSide:O,getReferences:W,getReferencedBy:P,getCreates:S,getCreatedBy:l=>(a||(a=He(e,({createdExtras:g})=>g)),a.get(l)??j),getCreatedClosure:l=>{let g=new Map,u=new Set,y=[...l];for(let m of y)if(!u.has(m)){u.add(m);for(let A of S(m))g.set(A.cardIdentifier,A),y.push(A.cardIdentifier)}return n([...g.values()])},getByRole:l=>(i||(i=Gr(e)),i.get(l)??j),getCardsInCorpusOrder:n}},ve=e=>{let r=Oe.get(e);return r||(r=Wr(e),Oe.set(e,r)),r},Ae=(e,r)=>e.getPitchCycle(r.cardIdentifier),le=(e,r)=>e.getCardsByName(r),Ve=(e,r)=>{let t=new Map;for(let a of r)for(let i of Ae(e,a))t.set(i.cardIdentifier,i);return e.getCardsInCorpusOrder([...t.values()])},de=(e,r)=>{let t=[];for(let a of Ae(e,r))t.push(...e.getReferencedBy(a.cardIdentifier));return Ve(e,t)},ce=(e,r)=>{let t=[];for(let a of Ae(e,r))t.push(...e.getReferences(a.cardIdentifier));return Ve(e,t)};var dr=[">=",">","<=","<"],cr=["!","-"],U="n/a",Ur={property:"arcane",specialProperty:"specialArcane",isNumber:!0,partialMatch:!0},xe={property:"artists",isArray:!0,partialMatch:!0},Ge={property:U,isMeta:!0},We={property:"bonds",isArray:!0},Kr={property:"cardIdentifier",isString:!0,isNormalized:!0},Ue=(e,{isAnd:r,isExcluded:t,isOptional:a,modifier:i})=>({filterToPropertyMapping:Kr,values:[...e],valuesSet:e,isAnd:r,isOr:!0,modifier:i,isExcluded:t,isOptional:a}),_r={property:U},Ke={property:"classes",isArray:!0,partialMatch:!0},_e={property:"cost",specialProperty:"specialCost",isNumber:!0,partialMatch:!0},Z={property:"defense",specialProperty:"specialDefense",isNumber:!0},je={property:"flows",isArray:!0},ze={nestedProperty:"foiling",property:"printings",isArray:!0},qe={property:"fusions",isArray:!0},Ye={property:"intellect",isNumber:!0},$e={property:"keywords",isArray:!0},Pe={property:U,isMeta:!0},Je={property:"life",specialProperty:"specialLife",isNumber:!0},Re={property:"meta",isArray:!0},Qe={property:"name",isString:!0,partialMatch:!0},Se={property:"pitch",isNumber:!0},Xe={property:"firstReleaseDate",isDate:!0},pe={property:"power",specialProperty:"specialPower",isNumber:!0},jr={property:"setIdentifiers",isArray:!0,partialMatch:!0},Ze={property:U,isMeta:!0},zr={property:U},qr={property:U},er={property:"sets",isArray:!0,partialMatch:!0},we={property:"shorthands",isArray:!0,partialMatch:!0},ue={property:"specializations",isArray:!0,partialMatch:!0},rr={property:"subtypes",isArray:!0},tr={property:"types",isArray:!0},ar={property:"talents",isArray:!0},Yr={property:"functionalText",hasMarkup:!0,isString:!0,partialMatch:!0},$r={property:"traits",isArray:!0,partialMatch:!0},Jr={property:"typeText",isString:!0,partialMatch:!0},fe={nestedProperty:"treatments",property:"printings",isArray:!0,isNestedPropertyArray:!0},Qr={property:"firstReleaseDate",isString:!0,partialMatch:!0},pr={arcane:Ur,a:xe,artist:xe,art:xe,attack:pe,b:Z,block:Z,banned:Ge,bond:We,bonds:We,c:Ke,class:Ke,chain:_r,co:_e,cost:_e,color:Se,d:Z,def:Z,defense:Z,flow:je,flows:je,f:qe,fusion:qe,foil:ze,foiling:ze,i:Ye,intellect:Ye,is:Re,k:$e,keyword:$e,l:Pe,legal:Pe,hero:Pe,li:Je,life:Je,meta:Re,n:Qe,name:Qe,p:Se,pitch:Se,pwr:pe,pow:pe,power:pe,print:jr,r:Ze,rarity:Ze,referencedby:zr,references:qr,rf:Ge,s:er,set:er,short:we,shorthand:we,shorthands:we,sp:ue,spec:ue,specialization:ue,specializations:ue,st:rr,subtype:rr,t:tr,type:tr,tal:ar,talent:ar,text:Yr,trait:$r,treat:fe,treatment:fe,var:fe,variation:fe,x:Jr,year:Qr},ur=pr,Xr=[{text:d.Release.ClassicBattlesRhinarDorinthea.toLowerCase(),override:d.Release.ClassicBattlesRhinarDorinthea.toLowerCase().replaceAll(b,"")}],Zr=e=>{let r=[],t=e.replaceAll("\u201D",'"');for(let{text:i,override:s}of Xr)t.includes(i)&&(t=t.replace(i,s));if(ae(t)?.card)r.push(t);else{let i=t.split(/[ ]+/),s="",o=0;for(let n of i)o===2&&(r.push(s.trim().replaceAll('"',"")),s="",o=0),o<2&&n.split('"').length===2?(s+=" "+n,o++):o===0&&s===""?r.push(n):o===1&&(s+=" "+n);o===2&&(r.push(s.trim().replaceAll('"',"")),s="",o=0)}return r},et=20,Be=(e,r,t=[],a=[],i=nt())=>{let s=e.trim().toLowerCase();for(let{expanded:P,shorthands:S}of Me)for(let h of S)if(s.includes(h)){s=s.replace(h,P.join(" "));break}for(let[P,S]of Object.entries(d.setToSetIdentifierMappings))s.includes(P.toLowerCase())&&(s=s.replace(P.toLowerCase(),S[0]));let o=Zr(s),n=[];for(let P of o){let S=Fe.find(({shorthands:h})=>h.includes(P));S&&!S.isCardProperty?n.push(...S.expanded):n.push(P)}let c=[],F=[],p=[],f=[],T=!1,M=[],L=[],O=[],W=[];for(let P of n)if(ht(P)){let[S,h]=P.split(":"),{modifier:E,values:C,isAnd:l,isOr:g}=gt(h),{filterKey:u,isExcluded:y,isOptional:m,isMeta:R}=yt(S),A=!1;if(R){if(["rarity","r"].includes(u)){let B=ft(C);y||(L=[...B]),C=B.map(x=>x.toLowerCase())}["legal","l","hero"].includes(u),c.push(...me(y,m,u,C,E,t))}else{if(["chain"].includes(u)){let x=new Set,I=[],H=new Set,V=w=>{x.add(w.cardIdentifier),H.has(w.name)||(H.add(w.name),I.push(w))},z=w=>{w.types.includes(d.Type.Hero)||V(w)};for(let w of C)if(w)for(let N of le(r,w))V(N);let K=0;for(let w of I){if(K>et)break;for(let ye of ce(r,w))z(ye);if(K===0)for(let ye of de(r,w))z(ye);K++}c.push(Ue(x,{isAnd:l,isExcluded:y,isOptional:m,modifier:E})),A=!0}else if(["referencedby","references"].includes(u)){let x=["referencedby"].includes(u),I=new Set;for(let H of C)if(H)for(let V of le(r,H)){let z=x?ce(r,V):de(r,V);for(let K of z)I.add(K.cardIdentifier)}c.push(Ue(I,{isAnd:l,isExcluded:y,isOptional:m,modifier:E})),A=!0}else if(["art","artist"].includes(u))F=C;else if(["print","prints","printing","printings"].includes(u))M=C;else if(["is","meta"].includes(u)){let x=[],I=[],H=[],V=[];for(let N of C)it.includes(N)?x.push(N):st.includes(N)?I.push(N):ot.includes(N)?H.push(N):V.push(N);x.length>0&&(c.push({filterToPropertyMapping:Re,values:[d.Meta.Reprint.toLowerCase().replaceAll(b,"")],isAnd:l,isOr:g,isExcluded:!y,isOptional:m}),A=V.length===0);let z=I.length>0;z&&c.push({filterToPropertyMapping:Xe,values:[i],isAnd:l,isOr:g,isExcluded:y,isOptional:m});let K=H.length>0;K&&c.push({filterToPropertyMapping:Xe,values:[i],isAnd:l,isOr:g,isExcluded:!y,isOptional:m}),(z||K)&&(A=V.length===0);let w=lt(V);C=w.map(N=>N.toLowerCase().replaceAll(b,"")),w.includes(d.Meta.Expansion)&&!y&&(T=!0)}else["foiling","foil"].includes(u)?(f=dt(C),C=f.map(x=>x.toLowerCase())):["treat","treatment","var","variation"].includes(u)?(W=ut(C),C=W.map(x=>x.toLowerCase())):["set","s"].includes(u)?(O=rt(C,a),C=O.map(x=>x.toLowerCase().replaceAll(b,""))):["pitch","p","color"].includes(u)&&(C=at(C));let B=ur[u];B&&!A&&c.push({filterToPropertyMapping:B,values:B.hasMarkup?C.map(x=>J(x)):C,isAnd:l,isOr:g,modifier:E,isExcluded:y,isOptional:m})}}else if(P){let S=ae(P)?.card,h=be(P);S?p.push(`"${S.toLowerCase().replace(b,"")}"`):h&&h.length>0?c.push(...h):p.push(P.replace(b,""))}return{appliedFilters:c,attributes:{artists:F,foilings:f,isExpansionSlot:T,prints:M,rarities:L,releases:O,treatments:W},keywords:p}},rt=(e,r=[])=>{let t=[];for(let a of e)t.push(...tt(a,r));return t},tt=(e,r=[])=>{let t=[],a=Object.values(d.Release).find(i=>i.toLowerCase().replaceAll(b,"")===e);if(a&&t.push(a),t.length===0){let i=d.setIdentifierToSetMappings[e];i&&t.push(i)}if(t.length===0){let i=Object.values(d.Release).filter(s=>s.toLowerCase().includes(e));i.length>0&&t.push(...i)}if(t.length===0){let i=r.find(s=>s.toLowerCase().replaceAll(b,"")===e);i&&t.push(i)}return t},ke={purple:4,blue:3,yellow:2,red:1,white:0},at=e=>{let r=[];for(let t of e)ke[t]||ke[t]===0?r.push(ke[t].toString()):r.push(t);return r},it=["unique"],st=["preview","spoiler","unreleased"],ot=["released"],nt=()=>{let e=new Date,r=`${e.getMonth()+1}`.padStart(2,"0"),t=`${e.getDate()}`.padStart(2,"0");return`${e.getFullYear()}-${r}-${t}`},ir={dual:d.Meta.DualClass,exp:d.Meta.Expansion,expansion:d.Meta.Expansion,expansionSlot:d.Meta.Expansion,rainbow:d.Meta.Rainbow,reprint:d.Meta.Reprint,reprints:d.Meta.Reprint},lt=e=>{let r=[];for(let t of e)ir[t]?r.push(ir[t]):d.Meta[t]&&r.push(d.Meta[t]);if(e.length>0&&r.length===0){for(let t of Object.values(d.Meta))for(let a of e)if(t.toLowerCase().includes(a)){r.push(t);break}}return r},sr={r:d.Foiling.Rainbow,rf:d.Foiling.Rainbow,rainbow:d.Foiling.Rainbow,c:d.Foiling.Cold,cf:d.Foiling.Cold,cold:d.Foiling.Cold,g:d.Foiling.Gold,gf:d.Foiling.Gold,gold:d.Foiling.Gold},dt=e=>{let r=[];for(let t of e)sr[t]&&r.push(sr[t]);return r},ct={...Object.values(d.Treatment).reduce((e,r)=>(e[r.toLowerCase()]=r,e),{}),aa:d.Treatment.AA,alt:d.Treatment.AA,"alt art":d.Treatment.AA,ab:d.Treatment.AB,"alt border":d.Treatment.AB,at:d.Treatment.AT,"alt text":d.Treatment.AT,ea:d.Treatment.EA,extended:d.Treatment.EA,"extended art":d.Treatment.EA,fa:d.Treatment.FA,full:d.Treatment.FA,"full art":d.Treatment.FA},pt=d.Treatment,ut=e=>{let r=[];for(let t of e){let a=ct[t],i=pt[t.toUpperCase()];a?r.push(a):i&&r.push(i)}return r},Ie={b:d.Rarity.Basic,c:d.Rarity.Common,f:d.Rarity.Fabled,l:d.Rarity.Legendary,m:d.Rarity.Majestic,p:d.Rarity.Promo,r:d.Rarity.Rare,s:d.Rarity.SuperRare,t:d.Rarity.Token,v:d.Rarity.Marvel},ft=e=>{let r=[];for(let t of e)Ie[t]?r.push(Ie[t]):r.push(t);return r},gt=e=>{let r=[],t,a,i=dr.find(s=>e.includes(s));if(i){let[,s]=e.split(i);or(s)?(t=!0,r.push(...s.trim().split("+").map(o=>o.replace(b,"")))):nr(s)?(a=!0,r.push(...s.trim().split(",").map(o=>o.replace(b,"")))):r.push(s.trim().replace(b,""))}else or(e)?(t=!0,r.push(...e.trim().split("+").map(s=>s.replace(b,"")))):nr(e)?(a=!0,r.push(...e.trim().split(",").map(s=>s.replace(b,"")))):e.startsWith('"')&&e.endsWith('"')?r.push(e.trim().replaceAll('"',"").replace(b,"")):r.push(e.trim().replace(b,""));return{modifier:i,values:r,isAnd:t,isOr:a}},yt=e=>{let r=Ct(e);if(r){let[,t]=e.split(r);return{filterKey:t,isExcluded:!0,isOptional:!1,isMeta:lr(t)}}else return{filterKey:e,isExcluded:!1,isOptional:!1,isMeta:lr(e)}},ht=e=>e.indexOf(":")>=0,or=e=>e.indexOf("+")>=0,nr=e=>e.indexOf(",")>=0,lr=e=>!!ur[e]?.isMeta,Ct=e=>cr.find(r=>e.includes(r))?.slice(0,1);var v=require("@flesh-and-blood/types"),fr={artists:["Hoodwill"],cardIdentifier:"fangs-a-lot-blue",classes:[v.Class.Generic],defaultImage:"FNG000",firstReleaseDate:"2022-06-02",functionalText:"If Fangs A Lot is put into your banished zone from your graveyard, instead put it into your hand.",legalFormats:[],legalHeroes:[v.Hero.Kayo,v.Hero.Levia,v.Hero.Rhinar],printings:[{artists:["Hoodwill"],identifier:"FNG000",image:"FNG000",print:"FNG000",rarity:v.Rarity.Rare,set:v.Release.Promos},{artists:["Hoodwill"],identifier:"FNG000",image:"FNG000_Marvel",print:`FNG000-${v.Treatment.FA}`,rarity:v.Rarity.Marvel,set:v.Release.Promos,treatment:v.Treatment.FA}],name:"Fangs A Lot",rarities:[v.Rarity.Rare,v.Rarity.Marvel],rarity:v.Rarity.Rare,sets:[v.Release.Promos],setIdentifiers:["FNG000"],specialImage:"FNG000_Marvel",subtypes:[v.Subtype.Attack],types:[v.Type.Action],typeText:"Generic Action - Attack"},gr=[{keyword:fr.name.toLowerCase(),card:fr}];var mt={getFn:(e,r)=>{let t=Ne.default.config.getFn(e,r),a=t;if(Array.isArray(t))a=t.map(i=>X(i.replace(b,"")));else if(t){let i=X(t).replace(b,"");a=r.includes("functionalText")?J(i):i}return a},ignoreLocation:!0,includeScore:!0,keys:[{name:"name",weight:10},{name:"functionalText",weight:6},{name:"shorthands",weight:4},{name:"setIdentifiers",weight:2},{name:"traits",weight:4},{name:"typeText",weight:6}],threshold:.15,useExtendedSearch:!0},Le=class{constructor(r,t=[],a=[],i=!1){this.getFuse=()=>(this.fuse||(this.fuse=new Ne.default(this.cards,mt)),this.fuse);this.log=(r,...t)=>{this.debug&&console.log(r,...t)};this.search=(r,t)=>{let a,{appliedFilters:i,attributes:s,keywords:o}=Be(r,this.index,this.additionalHeroes,this.additionalSets),n=o.join(" "),c=t?gr.filter(h=>h.keyword===n):[];if(c.length>0?a=c.map(({card:h})=>h):o.length?a=this.getFuse().search(n).map(h=>h.item):a=[...this.cards],i.length&&(a=a.filter(h=>h&&hr(h,i))),o.length===0){let h="";if(s.releases.length===1)try{let l=s.releases[0];h=ge.setToSetIdentifierMappings[l][0].toUpperCase()}catch(l){console.error("Error getting set identifier from search",l)}if(!h&&s.prints.length===1)try{let l=s.prints[0];ge.setIdentifierToSetMappings[l]&&(h=l.toUpperCase())}catch(l){console.error("Error getting set identifier from search",l)}h?a.sort((l,g)=>{let u=l.setIdentifiers.find(m=>m.includes(h))?.replace(h,""),y=g.setIdentifiers.find(m=>m.includes(h))?.replace(h,"");return u&&y?u.localeCompare(y):-1}):a.sort((l,g)=>l.name===g.name?`${l.pitch}`.localeCompare(`${g.pitch}`):l.name.localeCompare(g.name))}else{let h=[],E=[],C=o.map(l=>l.toLowerCase().replace(b,"")).join(" ");for(let l of a)l.name.toLowerCase().replace(b,"")===C?h.push(l):E.push(l);a=[...h,...E]}let F=[],{artists:p,isExpansionSlot:f,foilings:T,prints:M,rarities:L,releases:O,treatments:W}=s;(p.length>0||f||T.length>0||M.length>0||L.length>0||O.length>0||W.length>0)&&(F=a.map(h=>{let E=h.printings.filter(C=>{let l=!!C.image,g=p.length===0||p.some(I=>C.artists.find(H=>H.replace(b,"").toLowerCase().includes(I))),u=!f||f===C.isExpansionSlot,y=T.length===0||!!C.foiling&&T.includes(C.foiling),m=M.length===0||M.some(I=>C.identifier.includes(I.toUpperCase())),R=L.length===0||L.includes(C.rarity),A=O.length===0||O.includes(C.set),B=W.length===0||C.treatments?.some(I=>W.includes(I));return l&&g&&u&&y&&m&&R&&A&&B});return{...h,matchingPrintings:E}}));let S=F.length>0?F:a;return{appliedFilters:i,attributes:s,keywords:o,searchResults:S}};let s=Array.isArray(t)?{additionalHeroes:t,additionalSets:a,debug:i}:t;this.additionalHeroes=s.additionalHeroes||[],this.additionalSets=s.additionalSets||[],this.cards=[...r],this.debug=s.debug||!1,this.index=s.index||ve(r)}},yr=Le,hr=(e,r)=>{let t=!0,a=!1;for(let i of r){let s=i.isOptional,{isNumber:o,isString:n,isArray:c,isBoolean:F,isDate:p}=i.filterToPropertyMapping;if(o){let f=bt(e,i);s?f&&(a=!0):t=t&&f}else if(n){let f=Tt(e,i);s?f&&(a=!0):t=t&&f}else if(c){let f=Mt(e,i,r);s?f&&(a=!0):t=t&&f}else if(F){let f=Ft(e,i);s?f&&(a=!0):t=t&&f}else if(p){let f=vt(e,i);s?f&&(a=!0):t=t&&f}}return t},bt=(e,r)=>{if(re(r,e)){let{values:t,modifier:a,isExcluded:i,filterToPropertyMapping:{partialMatch:s}}=r,o=ee(e,r);if(o!=null&&!isNaN(o))if(o=parseInt(o),a)switch(a){case">=":{let n=t?.some(c=>o>=parseInt(c));return i?!n:n}case">":{let n=t?.some(c=>o>parseInt(c));return i?!n:n}case"<=":{let n=t?.some(c=>o<=parseInt(c));return i?!n:n}case"<":{let n=t?.some(c=>o<parseInt(c));return i?!n:n}default:return!1}else{let n=t?.some(c=>o===parseInt(c));return i?!n:n}else{let n=xt(e,r)?.toLowerCase(),c=s?t?.some(F=>n?.includes(F)):t?.some(F=>n===F);return i?!c:c}}else return!0},Tt=(e,r)=>{if(re(r,e)){let{values:t,valuesSet:a,isAnd:i,isExcluded:s,filterToPropertyMapping:{hasMarkup:o,isNormalized:n,partialMatch:c}}=r,F=ee(e,r),p=n?F:F?.replaceAll(b,"").toLowerCase(),f=o&&p?J(p):p;if(c){let T=i?t?.every(M=>f?.includes(M)):t?.some(M=>f?.includes(M));return s?!T:T}else{let T;return i?T=t?.every(M=>f===M):a?T=a.has(f):T=t?.some(M=>f===M),s?!T:T}}else return!0},Mt=(e,r,t)=>{if(re(r,e)){let{values:a,isAnd:i,isExcluded:s,filterToPropertyMapping:{partialMatch:o}}=r,n=At(e,r,t).map(c=>c?.replaceAll(b,""));if(o){let c=i?a.every(p=>n?.some(f=>f?.toLowerCase().includes(p))):a.some(p=>n?.some(f=>f?.toLowerCase().includes(p))),F=n.length===0;return s?!c||F:c}else{let c=i?a.every(F=>n?.some(p=>p?.toLowerCase()===F)):a.some(F=>n?.some(p=>p?.toLowerCase()===F));return s?!c:c}}else return!0},Ft=(e,r)=>{if(re(r,e)){let{isExcluded:t}=r,a=ee(e,r);return t?!a:a}else return!0},vt=(e,r)=>{if(re(r,e)){let{values:t,isExcluded:a}=r,i=ee(e,r),s=t?.some(o=>i>o);return a?!s:s}else return!0},ee=(e,r)=>{let{filterToPropertyMapping:{property:t}}=r,a;return t!==U&&(a=e[t]),a},At=(e,r,t)=>{let{filterToPropertyMapping:{isNestedPropertyArray:a,nestedProperty:i}}=r,s=[],o=Object.keys(e.legalOverrides||{}).length>0,n=r.filterToPropertyMapping.property===Q.LegalHeroes,c=t.find(({filterToPropertyMapping:p})=>p.property===Q.LegalFormats);if(o&&n&&!!c){let p=new Set;for(let{format:f,heroes:T}of e.legalOverrides||[])if(c.values.includes(f.toLowerCase()))for(let M of T)p.add(M);s=Array.from(p)}if(s.length===0)if(i){let p=new Set;for(let f of e.printings){let T=f[i];if(a){if(Array.isArray(T))for(let M of T)p.add(M)}else T&&typeof T=="string"&&p.add(T)}s=Array.from(p)}else{let p=ee(e,r);if(Array.isArray(p))for(let f of p)typeof f=="string"&&s.push(f)}return s},xt=(e,r)=>{let{filterToPropertyMapping:{specialProperty:t}}=r,a;return t&&(a=e[t]),a},re=({cardTypes:e},{types:r,subtypes:t})=>!e||e?.some(a=>r.map(i=>i.toLowerCase()).includes(a.toLowerCase())||t.map(i=>i.toLowerCase()).includes(a.toLowerCase()));var Pt=(e,r)=>{let t=[];if(e)for(let a of r){let i=a.name===e.name,s=a.cardIdentifier!==e.cardIdentifier,o=a.pitch!==e.pitch;i&&s&&o&&t.push(a)}return t},St=(e,r)=>{let t=new Set(e?.referencedCards),a=[];for(let i of r)t.has(i.cardIdentifier)&&a.push(i);return a},wt=e=>{let r=new Map;for(let t of e)for(let a of t.referencedCards||[]){let i=r.get(a);i?i.push(t):r.set(a,[t])}return r},kt=(e,r)=>{let t=new Set;for(let i of e)for(let s of i.createdExtras||[])t.add(s);let a=[];for(let i of r)t.has(i.cardIdentifier)&&a.push(i);return a};0&&(module.exports={FilterProperty,MARKUP,NO_CARD_PROPERTY,PUNCTUATION,RARITY_VALUES_MAPPING,abbreviations,availableExclusions,availableModifiers,filterCard,filtersToCardPropertyMappings,getAbbreviation,getAbbreviationByCard,getCardsByName,getCardsByReferencedCardIdentifier,getCardsReferencedBy,getCardsReferencing,getCatalogueIndex,getCleanText,getExcludedMetaFilters,getKeywordsAndAppliedFiltersFromText,getMetaFilters,getNormalizedText,getOtherPitches,getReferencedCards,getTextWithoutMarkup,getTokensReferencedByCards,multiWordShorthands,shorthands,singleWordShorthands});
|
|
1
|
+
"use strict";var Fr=Object.create;var se=Object.defineProperty;var Mr=Object.getOwnPropertyDescriptor;var vr=Object.getOwnPropertyNames;var Ar=Object.getPrototypeOf,xr=Object.prototype.hasOwnProperty;var Pr=(e,r)=>{for(var t in r)se(e,t,{get:r[t],enumerable:!0})},Ge=(e,r,t,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of vr(r))!xr.call(e,i)&&i!==t&&se(e,i,{get:()=>r[i],enumerable:!(a=Mr(r,i))||a.enumerable});return e};var Sr=(e,r,t)=>(t=e!=null?Fr(Ar(e)):{},Ge(r||!e||!e.__esModule?se(t,"default",{value:e,enumerable:!0}):t,e)),wr=e=>Ge(se({},"__esModule",{value:!0}),e);var Gt={};Pr(Gt,{FilterProperty:()=>ee,MARKUP:()=>Te,NO_CARD_PROPERTY:()=>H,PUNCTUATION:()=>b,RARITY_VALUES_MAPPING:()=>Ee,abbreviations:()=>Fe,availableExclusions:()=>De,availableModifiers:()=>gr,default:()=>br,filterCard:()=>Tr,filtersToCardPropertyMappings:()=>yr,getAbbreviation:()=>oe,getAbbreviationByCard:()=>kr,getCardsByName:()=>fe,getCardsByReferencedCardIdentifier:()=>Ht,getCardsReferencedBy:()=>ye,getCardsReferencing:()=>ge,getCatalogueIndex:()=>Se,getCleanText:()=>X,getExcludedMetaFilters:()=>ve,getKeywordsAndAppliedFiltersFromText:()=>Oe,getMetaFilters:()=>Me,getNormalizedText:()=>re,getOtherPitches:()=>Dt,getReferencedCards:()=>Ot,getTextWithoutMarkup:()=>Z,getTokensReferencedByCards:()=>Vt,multiWordShorthands:()=>xe,shorthands:()=>Ae,singleWordShorthands:()=>Pe});module.exports=wr(Gt);var Ve=Sr(require("fuse.js"),1);var b=/[!"#$%&'’(),./:;<=>?@[\]^_`|~]/g,Te=/\*/g;var d=require("@flesh-and-blood/types");var oe=e=>Fe.find(({abbreviations:r})=>r.find(t=>t.toLowerCase()===e)),kr=e=>Fe.find(({card:r})=>r.toLowerCase()===e.name.toLowerCase()),Fe=[{abbreviations:["10k"],card:"10,000 Year Reunion"},{abbreviations:["Pajamas","PJs"],card:"Alluvion Constellas"},{abbreviations:["Slippy","Arakni Slipped Through the Cracks","Arakni, Slipped Through the Cracks"],card:"Arakni, 5L!p3d 7hRu 7h3 cR4X"},{abbreviations:["Dullcap"],card:"Arcanite Skullcap"},{abbreviations:["ALS"],card:"Arc Light Sentinel"},{abbreviations:["AoW"],card:"Art of War"},{abbreviations:["BBD"],card:"Barraging Beatdown"},{abbreviations:["BBS"],card:"Big Blue Sky"},{abbreviations:["Starvo"],card:"Bravo, Star of the Show"},{abbreviations:["BEB"],card:"Bull's Eye Bracers"},{abbreviations:["BLW"],card:"Be Like Water"},{abbreviations:["BoJ"],card:"Balance of Justice"},{abbreviations:["BOHH"],card:"Blood on Her Hands"},{abbreviations:["BRB"],card:"Bloodrush Bellow"},{abbreviations:["Breezies"],card:"Breeze Rider Boots"},{abbreviations:["BTA"],card:"Burn Them All"},{abbreviations:["CStrike","C-Strike","C Strike"],card:"Celestial Cataclysm"},{abbreviations:["CBelly"],card:"Cerebellum Processor"},{abbreviations:["CLF"],card:"Channel Lake Frigid"},{abbreviations:["CLV"],card:"Channel Lightning Valley"},{abbreviations:["CMH"],card:"Channel Mount Heroic"},{abbreviations:["CMI"],card:"Channel Mount Isen"},{abbreviations:["CMT"],card:"Channel the Millennium Tree"},{abbreviations:["CnC","C&C"],card:"Command and Conquer"},{abbreviations:["Sea and Sea"],card:"Conqueror of the High Seas"},{abbreviations:["CYB"],card:"Count Your Blessings"},{abbreviations:["Cat","Kitty"],card:"Crouching Tiger"},{abbreviations:["CoD"],card:"Crown of Dominion"},{abbreviations:["CoP"],card:"Crown of Providence"},{abbreviations:["CtW"],card:"Crush the Weak"},{abbreviations:["DD"],card:"Death Dealer"},{abbreviations:["DnD"],card:"Devotion Never Dies"},{abbreviations:["DIO"],card:"Dash I/O"},{abbreviations:["EBTT"],card:"Even Bigger Than That!"},{abbreviations:["NewNigma"],card:"Enigma, New Moon"},{abbreviations:["EPot","E Pot"],card:"Energy Potion"},{abbreviations:["EStrike","E-Strike","E Strike"],card:"Enlightened Strike"},{abbreviations:["FFS"],card:"Fyendal's Fighting Spirit"},{abbreviations:["FoN"],card:"Force of Nature"},{abbreviations:["Frosty","\u{1F976}","\u{1F9CA}","\u2744\uFE0F"],card:"Frostbite"},{abbreviations:["Yum yum"],card:"Fruits of the Forest"},{abbreviations:["GnT"],card:"Give and Take"},{abbreviations:["Habibi"],card:"Hanabi Blaster"},{abbreviations:["HMH"],card:"Hope Merchant's Hood"},{abbreviations:["HoI"],card:"Heart of Ice"},{abbreviations:["Pumpkin"],card:"Jack-o'-lantern"},{abbreviations:["RKO","Cheato"],card:"Kayo, Underhanded Cheat"},{abbreviations:["KKBB"],card:"Knick Knack Bric-a-brac"},{abbreviations:["BStrike"],card:"Levels of Enlightenment"},{abbreviations:["LAG","Twominaris"],card:"Luminaris, Angel's Glow"},{abbreviations:["LCF","Newminaris"],card:"Luminaris, Celestial Fury"},{abbreviations:["LDE"],card:"Last Ditch Effort"},{abbreviations:["LtC"],card:"Lead the Charge"},{abbreviations:["LNW"],card:"Leave No Witnesses"},{abbreviations:["LFaL","L4aL"],card:"Life for a Life"},{abbreviations:["LiT"],card:"Lost in Thought"},{abbreviations:["MMB"],card:"Mage Master Boots"},{abbreviations:["MaxV"],card:"Maximum Velocity"},{abbreviations:["MoM"],card:"Mask of Momentum"},{abbreviations:["MoPL"],card:"Mask of the Pouncing Lynx"},{abbreviations:["MnG"],card:"Meat and Greet"},{abbreviations:["Cake","\u{1F382}"],card:"Ninth Blade of the Blood Oath"},{abbreviations:["PoM"],card:"Peace of Mind"},{abbreviations:["P-Bone"],card:"Performance Bonus"},{abbreviations:["PF","\u{1F525}"],card:"Phoenix Flame"},{abbreviations:["PtW"],card:"Poison the Well"},{abbreviations:["Thanos","Infinity Gauntlet"],card:"Polarity Reversal Script"},{abbreviations:["DPot","D Pot"],card:"Potion of D\xE9j\xE0 Vu"},{abbreviations:["Ponder Run"],card:"Premeditate"},{abbreviations:["Qi Unbound"],card:"Qi Unleashed"},{abbreviations:["RitL"],card:"Red in the Ledger"},{abbreviations:["Cats","Ghost cat","Ghost cats"],card:"Restless Coalescence"},{abbreviations:["Eugene"],card:"Rhinar, Reckless Rampage",isHidden:!0},{abbreviations:["SSGB"],card:"Sandscour Greatbow"},{abbreviations:["SSP"],card:"Sand Sketched Plan"},{abbreviations:["SFaS","S4aS"],card:"Scar for a Scar"},{abbreviations:["Tyler"],card:"Scurv, Stowaway",isHidden:!0},{abbreviations:["SWOMB"],card:"Shifting Winds of the Mystic Beast"},{abbreviations:["Snaps"],card:"Snapdragon Scalers"},{abbreviations:["SWK"],card:"Spinning Wheel Kick"},{abbreviations:["SFTL"],card:"Swing Fist, Think Later"},{abbreviations:["TTT"],card:"Take the Tempo"},{abbreviations:["Ultron"],card:"Teklovossen, the Mechropotent"},{abbreviations:["ToS"],card:"Test of Strength"},{abbreviations:["TAYG"],card:"That All You Got?"},{abbreviations:["TROM"],card:"This Round's on Me"},{abbreviations:["3oak"],card:"Three of a Kind"},{abbreviations:["Pox Malone","Post Malone"],card:"Virulent Touch"},{abbreviations:["Cast Homes"],card:"Visit Goldmane Estate"},{abbreviations:["Frosty Hammer"],card:"Winter's Wail"},{abbreviations:["Wreckless Wing"],card:"War Cry of Bellona"},{abbreviations:["ZTS"],card:"Zero to Sixty"}];var k=require("@flesh-and-blood/types");var ne=require("@flesh-and-blood/types"),L=e=>Object.assign(Object.create(null),e),le=L(ne.setIdentifierToSetMappings),We=L(ne.setToSetIdentifierMappings);var ee={BannedFormats:"bannedFormats",LegalFormats:"legalFormats",LegalHeroes:"legalHeroes"},ue=Array.from(Array(50).keys()).map(e=>`${e}`),Rr=[{format:k.Format.ClassicConstructed,nicknames:["cc","classic"]},{format:k.Format.LivingLegend,nicknames:["cc ll","classic constructed ll","ll cc","ll","living legend"]},{format:k.Format.SilverAge,nicknames:["sage"]},{format:k.Format.GoldenAge,nicknames:["gage"]},{format:k.Format.UltimatePitFight,nicknames:["upf"]}],Ir=Object.values(k.Format).map(e=>{let r=Rr.find(({format:a})=>a===e),t=e.toLowerCase().replaceAll(b,"");return r?{...r,format:t}:{format:t}}),Br=[{hero:k.Hero.DataDoll,nicknames:["data","datadoll"]},{hero:k.Hero.Dorinthea,nicknames:["dori"]},{hero:k.Hero.Genis,nicknames:["genis"]},{hero:k.Hero.GravyBones,nicknames:["gravy"]},{hero:k.Hero.Iyslander,nicknames:["islander"]}],Lr=Object.values(k.Hero).map(e=>{let r=Br.find(({hero:a})=>a===e),t=e.toLowerCase().replaceAll(b,"");return r?{...r,hero:t}:{hero:t}}),de=["common","rare","super rare","majestic","legendary","fabled"],Nr=(e,r,t,a)=>{let i=[];if(!r)i.push(...e);else for(let s of e)switch(r){case">=":{let o=!1;for(let n of de)o?i.push(n):n===s&&(o=!0,i.push(n));break}case">":{let o=!1;for(let n of de)o?i.push(n):n===s&&(o=!0);break}case"<=":{let o=!1;for(let n of de.slice().reverse())o?i.push(n):n===s&&(o=!0,i.push(n));break}case"<":{let o=!1;for(let n of de.slice().reverse())o?i.push(n):n===s&&(o=!0);break}default:break}return{filterToPropertyMapping:{nestedProperty:"rarity",property:"printings",isArray:!0},isExcluded:t,isOptional:a,isOr:!0,values:i}},Ue=(e,r,t,a,i)=>{let s=a.map(p=>({hero:p.toLowerCase().replaceAll(b,"")})),o=[],n=[],f=[];for(let p of e){let u=Ir.find(({format:C,nicknames:T})=>C===p||!!T&&T.includes(p));if(u)n.push(u.format);else{let C=Lr.find(({hero:T,nicknames:R})=>T===p||!!R&&R.includes(p))||s.find(({hero:T})=>T===p);C&&f.push(C.hero)}}let F=i||"legalFormats";return n.length>0&&o.push({filterToPropertyMapping:{property:F,isArray:!0},values:n,isOr:!0,isExcluded:r,isOptional:t}),f.length>0&&o.push({filterToPropertyMapping:{property:ee.LegalHeroes,isArray:!0},values:f,isOr:!0,isExcluded:r,isOptional:t}),o},Er=(e,r,t,a)=>Ue(e,r,t,a,"bannedFormats"),Me=(e,r,t,a,i,s)=>{let o=[];return Hr(t)?o.push(...Ue(a,e,r,s)):Gr(t)?o.push(...Er(a,e,r,s)):Ur(t)&&o.push(Nr(a,i,e,r)),o},J=[{filterToPropertyMapping:{property:"cost",isNumber:!0},isExcluded:!0,values:ue},{filterToPropertyMapping:{property:"specialCost",isString:!0,partialMatch:!0},isExcluded:!0,values:["*","x"]},{filterToPropertyMapping:{property:"types",isArray:!0,partialMatch:!0},isExcluded:!0,values:["equipment","hero","placeholder","token","weapon"]}],D=[{filterToPropertyMapping:{property:"defense",isNumber:!0},isExcluded:!0,values:ue},{filterToPropertyMapping:{property:"specialDefense",isString:!0,partialMatch:!0},isExcluded:!0,values:["*","x"]},{filterToPropertyMapping:{property:"types",isArray:!0,partialMatch:!0},isExcluded:!0,values:["hero","placeholder","token","weapon"]}],ce=[{filterToPropertyMapping:{property:"pitch",isNumber:!0},isExcluded:!0,values:ue},{filterToPropertyMapping:{property:"types",isArray:!0,partialMatch:!0},isExcluded:!0,values:["equipment","hero","placeholder","token","weapon"]},{filterToPropertyMapping:{property:"isCardBack",isBoolean:!0},isExcluded:!0,values:["true"]}],_=[{filterToPropertyMapping:{property:"power",isNumber:!0},isExcluded:!0,values:ue},{filterToPropertyMapping:{property:"specialPower",isString:!0,partialMatch:!0},isExcluded:!0,values:["*","x"]},{filterToPropertyMapping:{property:"types",isArray:!0,partialMatch:!0},isExcluded:!0,values:["equipment","hero","placeholder","token"]}],pe=[{filterToPropertyMapping:{property:"talents",isArray:!0},isExcluded:!0,values:Object.values(k.Talent).map(e=>e.toLowerCase())}],Dr=L({"!co":J,"-co":J,"!cost":J,"-cost":J,"!color":J,"-color":J,"!b":D,"-b":D,"!block":D,"-block":D,"!d":D,"-d":D,"!def":D,"-def":D,"!defense":D,"-defense":D,"!pitch":ce,"-pitch":ce,"!p":ce,"-p":ce,"!attack":_,"-attack":_,"!power":_,"-power":_,"!pwr":_,"-pwr":_,"!pow":_,"-pow":_,"!talents":pe,"-talents":pe,"!tal":pe,"-tal":pe}),ve=e=>{let r=[],t=Dr[e];return t&&r.push(...t),r},Or=["l","legal","hero"],Hr=e=>Or.includes(e),Vr=["banned"],Gr=e=>Vr.includes(e),Wr=["r","rarity"],Ur=e=>Wr.includes(e);var N=require("@flesh-and-blood/types"),Ae=[{description:"Attack actions",expanded:["st:attack"],filters:{subtypes:[N.Subtype.Attack]},isCardProperty:!1,shorthands:["AA"]},{description:"Arcane barrier",expanded:['k:"arcane barrier"'],filters:{keywords:[N.Keyword.ArcaneBarrier]},isCardProperty:!1,shorthands:["AB"]},{description:"Attack reactions",expanded:['t:"attack reaction"'],filters:{types:[N.Type.AttackReaction]},isCardProperty:!1,shorthands:["AR"]},{description:"Defense reactions",expanded:['t:"defense reaction"'],filters:{types:[N.Type.DefenseReaction]},isCardProperty:!1,shorthands:["DR"]},{description:"Gain life",expanded:["gain {h}"],filters:{functionalText:"gain {h}"},isCardProperty:!1,shorthands:["Gain life","Gains life"]},{description:"Go again",expanded:['k:"go again"'],filters:{keywords:[N.Keyword.GoAgain]},isCardProperty:!1,shorthands:["GA"]},{description:"Non-attack actions",expanded:["t:action","st:non-attack"],filters:{subtypes:[N.Subtype.NonAttack],types:[N.Type.Action]},isCardProperty:!1,shorthands:["NAA"]},{description:"Plus defense",expanded:["+ {d}"],filters:{functionalText:"+ {d}"},isCardProperty:!1,shorthands:["Pump defense","Pumps defense","Buff defense","Buffs defense"]},{description:"Spellvoid",expanded:['k:"spellvoid"'],filters:{keywords:[N.Keyword.Spellvoid]},isCardProperty:!1,shorthands:["SV"]}],xe=Ae.filter(({shorthands:e})=>e.some(r=>r.includes(" "))).map(e=>({...e,shorthands:e.shorthands.filter(r=>r.includes(" ")).map(r=>r.toLowerCase()).sort((r,t)=>t.length-r.length)})),Pe=Ae.filter(({shorthands:e})=>e.some(r=>!r.includes(" "))).map(e=>({...e,shorthands:e.shorthands.filter(r=>!r.includes(" ")).map(r=>r.toLowerCase()).sort((r,t)=>t.length-r.length)}));var X=e=>re(e.toLowerCase().trim().replace(b,"")),re=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,""),Z=e=>e.replace(Te,"");var q=require("@flesh-and-blood/types");var je=new WeakMap,$=Object.freeze([]),jr=Number.MAX_SAFE_INTEGER,Ke=(e,r)=>{let t=new Map;for(let a of e)for(let i of r(a)||[]){let s=t.get(i);s?s.push(a):t.set(i,[a])}return t},Kr=e=>{let r=new Map;for(let t of e){let a=t.types.includes(q.Type.Hero)&&!t.isCardBack,i=a?q.CardRole.Hero:(0,q.getCardRole)(t);if(a||i!==q.CardRole.Hero){let o=r.get(i);o?o.push(t):r.set(i,[t])}}return r},_r=e=>{let r,t,a,i,s,o=()=>{if(!r){let l=new Map,c=new Map,h=[],m=new Map,g=0;for(let v of e){l.set(v.cardIdentifier,v),c.set(v.cardIdentifier,g),g++;let A=X(v.name),W=m.get(A);W?W.push(v):(m.set(A,[v]),h.push(A))}r={cardByCardIdentifier:l,corpusPositionByCardIdentifier:c,cleanedNames:h,pitchCycleByCleanedName:m}}return r},n=l=>{let{corpusPositionByCardIdentifier:c}=o(),h=({cardIdentifier:m})=>c.get(m)??jr;return[...l].sort((m,g)=>h(m)-h(g))},f=l=>o().cardByCardIdentifier.get(l),F=l=>{let{cardByCardIdentifier:c}=o(),h=[];for(let m of l||[]){let g=c.get(m);g&&h.push(g)}return n(h)},p=l=>{let c=new Map;return h=>{let m=c.get(h);if(!m){let g=f(h),v=F(g&&l(g)),A=v.length>0;m=A?v:$,A&&c.set(h,m)}return m}},u=l=>{let{pitchCycleByCleanedName:c}=o(),h=f(l);return h?c.get(X(h.name))??$:$},C=l=>{let{cleanedNames:c,pitchCycleByCleanedName:h}=o(),m=X(l),g=h.get(m);if(!g&&m.length>0){let A=c.find(W=>W.includes(m));A&&(g=h.get(A))}return g??$},T=l=>{let{pitchCycleByCleanedName:c}=o();return c.get(X(l))??$},R=()=>{if(!s){let l=new Set;for(let c of e)for(let h of c.artists)l.add(h);s=[...l].sort((c,h)=>c.localeCompare(h,"en",{sensitivity:"base"}))}return s},O=p(({oppositeSideCardIdentifiers:l})=>l),V=p(({referencedCards:l})=>l),Y=l=>(t||(t=Ke(e,({referencedCards:c})=>c)),t.get(l)??$),G=p(({createdExtras:l})=>l);return{cards:e,getCard:f,getPitchCycle:u,getCardsByName:C,getCardsByExactName:T,getArtists:R,getOppositeSide:O,getReferences:V,getReferencedBy:Y,getCreates:G,getCreatedBy:l=>(a||(a=Ke(e,({createdExtras:c})=>c)),a.get(l)??$),getCreatedClosure:l=>{let c=new Map,h=new Set,m=[...l];for(let g of m)if(!h.has(g)){h.add(g);for(let A of G(g))c.set(A.cardIdentifier,A),m.push(A.cardIdentifier)}return n([...c.values()])},getByRole:l=>(i||(i=Kr(e)),i.get(l)??$),getCardsInCorpusOrder:n}},Se=e=>{let r=je.get(e);return r||(r=_r(e),je.set(e,r)),r},we=(e,r)=>e.getPitchCycle(r.cardIdentifier),fe=(e,r)=>e.getCardsByName(r),_e=(e,r)=>{let t=new Map;for(let a of r)for(let i of we(e,a))t.set(i.cardIdentifier,i);return e.getCardsInCorpusOrder([...t.values()])},ge=(e,r)=>{let t=[];for(let a of we(e,r))t.push(...e.getReferencedBy(a.cardIdentifier));return _e(e,t)},ye=(e,r)=>{let t=[];for(let a of we(e,r))t.push(...e.getReferences(a.cardIdentifier));return _e(e,t)};var gr=[">=",">","<=","<"],De=["!","-"],H="n/a",$r={property:"arcane",specialProperty:"specialArcane",isNumber:!0,partialMatch:!0},ke={property:"artists",isArray:!0,partialMatch:!0},$e={property:H,isMeta:!0},ze={property:"bonds",isArray:!0},zr={property:"cardIdentifier",isString:!0,isNormalized:!0},qe=(e,{isAnd:r,isExcluded:t,isOptional:a,modifier:i})=>({filterToPropertyMapping:zr,values:[...e],valuesSet:e,isAnd:r,isOr:!0,modifier:i,isExcluded:t,isOptional:a}),qr={property:H},Ye={property:"classes",isArray:!0,partialMatch:!0},Qe={property:"cost",specialProperty:"specialCost",isNumber:!0,partialMatch:!0},te={property:"defense",specialProperty:"specialDefense",isNumber:!0},Je={property:"flows",isArray:!0},Xe={nestedProperty:"foiling",property:"printings",isArray:!0},Ze={property:"fusions",isArray:!0},er={property:"intellect",isNumber:!0},rr={property:"keywords",isArray:!0},Re={property:H,isMeta:!0},tr={property:"life",specialProperty:"specialLife",isNumber:!0},Le={property:"meta",isArray:!0},ar={property:"name",isString:!0,partialMatch:!0},Ie={property:"pitch",isNumber:!0},ir={property:"firstReleaseDate",isDate:!0},he={property:"power",specialProperty:"specialPower",isNumber:!0},Yr={property:"setIdentifiers",isArray:!0,partialMatch:!0},sr={property:H,isMeta:!0},Qr={property:H},Jr={property:H},or={property:"sets",isArray:!0,partialMatch:!0},Be={property:"shorthands",isArray:!0,partialMatch:!0},Ce={property:"specializations",isArray:!0,partialMatch:!0},nr={property:"subtypes",isArray:!0},lr={property:"types",isArray:!0},dr={property:"talents",isArray:!0},Xr={property:"functionalText",hasMarkup:!0,isString:!0,partialMatch:!0},Zr={property:"traits",isArray:!0,partialMatch:!0},et={property:"typeText",isString:!0,partialMatch:!0},me={nestedProperty:"treatments",property:"printings",isArray:!0,isNestedPropertyArray:!0},rt={property:"firstReleaseDate",isString:!0,partialMatch:!0},yr={arcane:$r,a:ke,artist:ke,art:ke,attack:he,b:te,block:te,banned:$e,bond:ze,bonds:ze,c:Ye,class:Ye,chain:qr,co:Qe,cost:Qe,color:Ie,d:te,def:te,defense:te,flow:Je,flows:Je,f:Ze,fusion:Ze,foil:Xe,foiling:Xe,i:er,intellect:er,is:Le,k:rr,keyword:rr,l:Re,legal:Re,hero:Re,li:tr,life:tr,meta:Le,n:ar,name:ar,p:Ie,pitch:Ie,pwr:he,pow:he,power:he,print:Yr,r:sr,rarity:sr,referencedby:Qr,references:Jr,rf:$e,s:or,set:or,short:Be,shorthand:Be,shorthands:Be,sp:Ce,spec:Ce,specialization:Ce,specializations:Ce,st:nr,subtype:nr,t:lr,type:lr,tal:dr,talent:dr,text:Xr,trait:Zr,treat:me,treatment:me,var:me,variation:me,x:et,year:rt},hr=L(yr),tt=[{text:d.Release.ClassicBattlesRhinarDorinthea.toLowerCase(),override:d.Release.ClassicBattlesRhinarDorinthea.toLowerCase().replaceAll(b,"")}],Ne=new Map(Object.entries(d.setToSetIdentifierMappings).map(([e,r])=>[e.toLowerCase(),r])),at=["set","s","print"],it=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),st=[...Ne.keys()].sort((e,r)=>r.length-e.length).map(it).join("|"),ot=new RegExp(`(?<=^|\\s)([${De.join("")}]?(?:${at.join("|")}):(?:[^\\s]*[,+])?"?)(${st})(?="?(?:[,+]|\\s|$))`,"g"),nt=e=>{let r=[],t=e.replaceAll("\u201D",'"');for(let{text:i,override:s}of tt)t.includes(i)&&(t=t.replace(i,s));if(oe(t)?.card)r.push(t);else{let i=t.split(/[ ]+/),s="",o=0;for(let n of i)o===2&&(r.push(s.trim().replaceAll('"',"")),s="",o=0),o<2&&n.split('"').length===2?(s+=" "+n,o++):o===0&&s===""?r.push(n):o===1&&(s+=" "+n);o===2&&(r.push(s.trim().replaceAll('"',"")),s="",o=0)}return r},lt=20,Oe=(e,r,t=[],a=[],i=ht())=>{let s=e.trim().toLowerCase();for(let{expanded:y,shorthands:P}of xe)for(let M of P)if(s.includes(M)){s=s.replace(M,y.join(" "));break}s=s.replace(ot,(y,P,M)=>{let l=Ne.get(M);return l?`${P}${l[0]}`:y});let o=Ne.get(s),n=r.getCardsByExactName(s).length>0;o&&!n&&(s=`set:${o[0]}`);let f=nt(s),F=[];for(let y of f){let P=Pe.find(({shorthands:M})=>M.includes(y));P&&!P.isCardProperty?F.push(...P.expanded):F.push(y)}let p=[],u=[],C=[],T=[],R=!1,O=[],V=[],Y=[],G=[];for(let y of F)if(Pt(y)){let[P,M]=y.split(":"),{modifier:l,values:c,isAnd:h,isOr:m}=At(M),{filterKey:g,isExcluded:v,isOptional:A,isMeta:W}=xt(P),Q=!1;if(W){if(["rarity","r"].includes(g)){let I=vt(c);v||(V=[...I]),c=I.map(S=>S.toLowerCase())}["legal","l","hero"].includes(g),p.push(...Me(v,A,g,c,l,t))}else{if(["chain"].includes(g)){let S=new Set,U=[],j=new Set,E=w=>{S.add(w.cardIdentifier),j.has(w.name)||(j.add(w.name),U.push(w))},z=w=>{w.types.includes(d.Type.Hero)||E(w)};for(let w of c)if(w)for(let B of fe(r,w))E(B);let K=0;for(let w of U){if(K>lt)break;for(let be of ye(r,w))z(be);if(K===0)for(let be of ge(r,w))z(be);K++}p.push(qe(S,{isAnd:h,isExcluded:v,isOptional:A,modifier:l})),Q=!0}else if(["referencedby","references"].includes(g)){let S=["referencedby"].includes(g),U=new Set;for(let j of c)if(j)for(let E of fe(r,j)){let z=S?ye(r,E):ge(r,E);for(let K of z)U.add(K.cardIdentifier)}p.push(qe(U,{isAnd:h,isExcluded:v,isOptional:A,modifier:l})),Q=!0}else if(["art","artist"].includes(g))u=c;else if(["print","prints","printing","printings"].includes(g))O=c;else if(["is","meta"].includes(g)){let S=[],U=[],j=[],E=[];for(let B of c)ft.includes(B)?S.push(B):gt.includes(B)?U.push(B):yt.includes(B)?j.push(B):E.push(B);S.length>0&&(p.push({filterToPropertyMapping:Le,values:[d.Meta.Reprint.toLowerCase().replaceAll(b,"")],isAnd:h,isOr:m,isExcluded:!v,isOptional:A}),Q=E.length===0);let z=U.length>0;z&&p.push({filterToPropertyMapping:ir,values:[i],isAnd:h,isOr:m,isExcluded:v,isOptional:A});let K=j.length>0;K&&p.push({filterToPropertyMapping:ir,values:[i],isAnd:h,isOr:m,isExcluded:!v,isOptional:A}),(z||K)&&(Q=E.length===0);let w=mt(E);c=w.map(B=>B.toLowerCase().replaceAll(b,"")),w.includes(d.Meta.Expansion)&&!v&&(R=!0)}else["foiling","foil"].includes(g)?(T=bt(c),c=T.map(S=>S.toLowerCase())):["treat","treatment","var","variation"].includes(g)?(G=Mt(c),c=G.map(S=>S.toLowerCase())):["set","s"].includes(g)?(Y=dt(c,a),c=Y.map(S=>S.toLowerCase().replaceAll(b,""))):["pitch","p","color"].includes(g)&&(c=ut(c));let I=hr[g];I&&!Q&&p.push({filterToPropertyMapping:I,values:I.hasMarkup?c.map(S=>Z(S)):c,isAnd:h,isOr:m,modifier:l,isExcluded:v,isOptional:A})}}else if(y){let P=oe(y)?.card,M=ve(y);P?C.push(`"${P.toLowerCase().replace(b,"")}"`):M&&M.length>0?p.push(...M):C.push(y.replace(b,""))}return{appliedFilters:p,attributes:{artists:u,foilings:T,isExpansionSlot:R,prints:O,rarities:V,releases:Y,treatments:G},keywords:C}},dt=(e,r=[])=>{let t=[];for(let a of e)t.push(...ct(a,r));return t},ct=(e,r=[])=>{let t=[],a=Object.values(d.Release).find(i=>i.toLowerCase().replaceAll(b,"")===e);if(a&&t.push(a),t.length===0){let i=le[e];i&&t.push(i)}if(t.length===0){let i=Object.values(d.Release).filter(s=>s.toLowerCase().includes(e));i.length>0&&t.push(...i)}if(t.length===0){let i=r.find(s=>s.toLowerCase().replaceAll(b,"")===e);i&&t.push(i)}return t},pt=L({purple:4,blue:3,yellow:2,red:1,white:0}),ut=e=>{let r=[];for(let t of e){let a=pt[t];a===void 0?r.push(t):r.push(a.toString())}return r},ft=["unique"],gt=["preview","spoiler","unreleased"],yt=["released"],ht=()=>{let e=new Date,r=`${e.getMonth()+1}`.padStart(2,"0"),t=`${e.getDate()}`.padStart(2,"0");return`${e.getFullYear()}-${r}-${t}`},Ct=L({dual:d.Meta.DualClass,exp:d.Meta.Expansion,expansion:d.Meta.Expansion,rainbow:d.Meta.Rainbow,reprint:d.Meta.Reprint,reprints:d.Meta.Reprint}),mt=e=>{let r=[];for(let t of e){let a=Ct[t];a&&r.push(a)}if(e.length>0&&r.length===0){for(let t of Object.values(d.Meta))for(let a of e)if(t.toLowerCase().includes(a)){r.push(t);break}}return r},cr=L({r:d.Foiling.Rainbow,rf:d.Foiling.Rainbow,rainbow:d.Foiling.Rainbow,c:d.Foiling.Cold,cf:d.Foiling.Cold,cold:d.Foiling.Cold,g:d.Foiling.Gold,gf:d.Foiling.Gold,gold:d.Foiling.Gold}),bt=e=>{let r=[];for(let t of e)cr[t]&&r.push(cr[t]);return r},Tt=L({...Object.values(d.Treatment).reduce((e,r)=>(e[r.toLowerCase()]=r,e),{}),aa:d.Treatment.AA,alt:d.Treatment.AA,"alt art":d.Treatment.AA,ab:d.Treatment.AB,"alt border":d.Treatment.AB,at:d.Treatment.AT,"alt text":d.Treatment.AT,ea:d.Treatment.EA,extended:d.Treatment.EA,"extended art":d.Treatment.EA,fa:d.Treatment.FA,full:d.Treatment.FA,"full art":d.Treatment.FA}),Ft=L(d.Treatment),Mt=e=>{let r=[];for(let t of e){let a=Tt[t],i=Ft[t.toUpperCase()];a?r.push(a):i&&r.push(i)}return r},Ee=L({b:d.Rarity.Basic,c:d.Rarity.Common,f:d.Rarity.Fabled,l:d.Rarity.Legendary,m:d.Rarity.Majestic,p:d.Rarity.Promo,r:d.Rarity.Rare,s:d.Rarity.SuperRare,t:d.Rarity.Token,v:d.Rarity.Marvel}),vt=e=>{let r=[];for(let t of e)Ee[t]?r.push(Ee[t]):r.push(t);return r},At=e=>{let r=[],t,a,i=gr.find(s=>e.includes(s));if(i){let[,s]=e.split(i);pr(s)?(t=!0,r.push(...s.trim().split("+").map(o=>o.replace(b,"")))):ur(s)?(a=!0,r.push(...s.trim().split(",").map(o=>o.replace(b,"")))):r.push(s.trim().replace(b,""))}else pr(e)?(t=!0,r.push(...e.trim().split("+").map(s=>s.replace(b,"")))):ur(e)?(a=!0,r.push(...e.trim().split(",").map(s=>s.replace(b,"")))):e.startsWith('"')&&e.endsWith('"')?r.push(e.trim().replaceAll('"',"").replace(b,"")):r.push(e.trim().replace(b,""));return{modifier:i,values:r,isAnd:t,isOr:a}},xt=e=>{let r=St(e);if(r){let[,t]=e.split(r);return{filterKey:t,isExcluded:!0,isOptional:!1,isMeta:fr(t)}}else return{filterKey:e,isExcluded:!1,isOptional:!1,isMeta:fr(e)}},Pt=e=>e.indexOf(":")>=0,pr=e=>e.indexOf("+")>=0,ur=e=>e.indexOf(",")>=0,fr=e=>!!hr[e]?.isMeta,St=e=>De.find(r=>e.includes(r))?.slice(0,1);var x=require("@flesh-and-blood/types"),Cr={artists:["Hoodwill"],cardIdentifier:"fangs-a-lot-blue",classes:[x.Class.Generic],defaultImage:"FNG000",firstReleaseDate:"2022-06-02",functionalText:"If Fangs A Lot is put into your banished zone from your graveyard, instead put it into your hand.",legalFormats:[],legalHeroes:[x.Hero.Kayo,x.Hero.Levia,x.Hero.Rhinar],printings:[{artists:["Hoodwill"],identifier:"FNG000",image:"FNG000",print:"FNG000",rarity:x.Rarity.Rare,set:x.Release.Promos},{artists:["Hoodwill"],identifier:"FNG000",image:"FNG000_Marvel",print:`FNG000-${x.Treatment.FA}`,rarity:x.Rarity.Marvel,set:x.Release.Promos,treatment:x.Treatment.FA}],name:"Fangs A Lot",rarities:[x.Rarity.Rare,x.Rarity.Marvel],rarity:x.Rarity.Rare,sets:[x.Release.Promos],setIdentifiers:["FNG000"],specialImage:"FNG000_Marvel",subtypes:[x.Subtype.Attack],types:[x.Type.Action],typeText:"Generic Action - Attack"},mr=[{keyword:Cr.name.toLowerCase(),card:Cr}];var wt={getFn:(e,r)=>{let t=Ve.default.config.getFn(e,r),a=t;if(Array.isArray(t))a=t.map(i=>re(i.replace(b,"")));else if(t){let i=re(t).replace(b,"");a=r.includes("functionalText")?Z(i):i}return a},ignoreLocation:!0,includeScore:!0,keys:[{name:"name",weight:10},{name:"functionalText",weight:6},{name:"shorthands",weight:4},{name:"setIdentifiers",weight:2},{name:"traits",weight:4},{name:"typeText",weight:6}],threshold:.15,useExtendedSearch:!0},He=class{constructor(r,t=[],a=[],i=!1){this.getFuse=()=>(this.fuse||(this.fuse=new Ve.default(this.cards,wt)),this.fuse);this.log=(r,...t)=>{this.debug&&console.log(r,...t)};this.search=(r,t)=>{let a,{appliedFilters:i,attributes:s,keywords:o}=Oe(r,this.index,this.additionalHeroes,this.additionalSets),n=o.join(" "),f=t?mr.filter(y=>y.keyword===n):[];if(f.length>0?a=f.map(({card:y})=>y):o.length?a=this.getFuse().search(n).map(y=>y.item):a=[...this.cards],i.length&&(a=a.filter(y=>y&&Tr(y,i))),o.length===0){let y="";if(s.releases.length===1){let l=We[s.releases[0]];l?.length&&(y=l[0].toUpperCase())}if(!y&&s.prints.length===1){let l=s.prints[0];le[l]&&(y=l.toUpperCase())}y?a.sort((l,c)=>{let h=l.setIdentifiers.find(g=>g.includes(y))?.replace(y,""),m=c.setIdentifiers.find(g=>g.includes(y))?.replace(y,"");return h&&m?h.localeCompare(m):-1}):a.sort((l,c)=>l.name===c.name?`${l.pitch}`.localeCompare(`${c.pitch}`):l.name.localeCompare(c.name))}else{let y=[],P=[],M=o.map(l=>l.toLowerCase().replace(b,"")).join(" ");for(let l of a)l.name.toLowerCase().replace(b,"")===M?y.push(l):P.push(l);a=[...y,...P]}let F=[],{artists:p,isExpansionSlot:u,foilings:C,prints:T,rarities:R,releases:O,treatments:V}=s;(p.length>0||u||C.length>0||T.length>0||R.length>0||O.length>0||V.length>0)&&(F=a.map(y=>{let P=y.printings.filter(M=>{let l=!!M.image,c=p.length===0||p.some(I=>M.artists.find(S=>S.replace(b,"").toLowerCase().includes(I))),h=!u||u===M.isExpansionSlot,m=C.length===0||!!M.foiling&&C.includes(M.foiling),g=T.length===0||T.some(I=>M.identifier.includes(I.toUpperCase())),v=R.length===0||R.includes(M.rarity),A=O.length===0||O.includes(M.set),W=V.length===0||M.treatments?.some(I=>V.includes(I));return l&&c&&h&&m&&g&&v&&A&&W});return{...y,matchingPrintings:P}}));let G=F.length>0?F:a;return{appliedFilters:i,attributes:s,keywords:o,searchResults:G}};let s=Array.isArray(t)?{additionalHeroes:t,additionalSets:a,debug:i}:t;this.additionalHeroes=s.additionalHeroes||[],this.additionalSets=s.additionalSets||[],this.cards=[...r],this.debug=s.debug||!1,this.index=s.index||Se(r)}},br=He,Tr=(e,r)=>{let t=!0,a=!1;for(let i of r){let s=i.isOptional,{isNumber:o,isString:n,isArray:f,isBoolean:F,isDate:p}=i.filterToPropertyMapping;if(o){let u=kt(e,i);s?u&&(a=!0):t=t&&u}else if(n){let u=Rt(e,i);s?u&&(a=!0):t=t&&u}else if(f){let u=It(e,i,r);s?u&&(a=!0):t=t&&u}else if(F){let u=Bt(e,i);s?u&&(a=!0):t=t&&u}else if(p){let u=Lt(e,i);s?u&&(a=!0):t=t&&u}}return t},kt=(e,r)=>{if(ie(r,e)){let{values:t,modifier:a,isExcluded:i,filterToPropertyMapping:{partialMatch:s}}=r,o=ae(e,r);if(o!=null&&!isNaN(o))if(o=parseInt(o),a)switch(a){case">=":{let n=t?.some(f=>o>=parseInt(f));return i?!n:n}case">":{let n=t?.some(f=>o>parseInt(f));return i?!n:n}case"<=":{let n=t?.some(f=>o<=parseInt(f));return i?!n:n}case"<":{let n=t?.some(f=>o<parseInt(f));return i?!n:n}default:return!1}else{let n=t?.some(f=>o===parseInt(f));return i?!n:n}else{let n=Et(e,r)?.toLowerCase(),f=s?t?.some(F=>n?.includes(F)):t?.some(F=>n===F);return i?!f:f}}else return!0},Rt=(e,r)=>{if(ie(r,e)){let{values:t,valuesSet:a,isAnd:i,isExcluded:s,filterToPropertyMapping:{hasMarkup:o,isNormalized:n,partialMatch:f}}=r,F=ae(e,r),p=n?F:F?.replaceAll(b,"").toLowerCase(),u=o&&p?Z(p):p;if(f){let C=i?t?.every(T=>u?.includes(T)):t?.some(T=>u?.includes(T));return s?!C:C}else{let C;return i?C=t?.every(T=>u===T):a?C=a.has(u):C=t?.some(T=>u===T),s?!C:C}}else return!0},It=(e,r,t)=>{if(ie(r,e)){let{values:a,isAnd:i,isExcluded:s,filterToPropertyMapping:{partialMatch:o}}=r,n=Nt(e,r,t).map(f=>f?.replaceAll(b,""));if(o){let f=i?a.every(p=>n?.some(u=>u?.toLowerCase().includes(p))):a.some(p=>n?.some(u=>u?.toLowerCase().includes(p))),F=n.length===0;return s?!f||F:f}else{let f=i?a.every(F=>n?.some(p=>p?.toLowerCase()===F)):a.some(F=>n?.some(p=>p?.toLowerCase()===F));return s?!f:f}}else return!0},Bt=(e,r)=>{if(ie(r,e)){let{isExcluded:t}=r,a=ae(e,r);return t?!a:a}else return!0},Lt=(e,r)=>{if(ie(r,e)){let{values:t,isExcluded:a}=r,i=ae(e,r),s=t?.some(o=>i>o);return a?!s:s}else return!0},ae=(e,r)=>{let{filterToPropertyMapping:{property:t}}=r,a;return t!==H&&(a=e[t]),a},Nt=(e,r,t)=>{let{filterToPropertyMapping:{isNestedPropertyArray:a,nestedProperty:i}}=r,s=[],o=Object.keys(e.legalOverrides||{}).length>0,n=r.filterToPropertyMapping.property===ee.LegalHeroes,f=t.find(({filterToPropertyMapping:p})=>p.property===ee.LegalFormats);if(o&&n&&!!f){let p=new Set;for(let{format:u,heroes:C}of e.legalOverrides||[])if(f.values.includes(u.toLowerCase()))for(let T of C)p.add(T);s=Array.from(p)}if(s.length===0)if(i){let p=new Set;for(let u of e.printings){let C=u[i];if(a){if(Array.isArray(C))for(let T of C)p.add(T)}else C&&typeof C=="string"&&p.add(C)}s=Array.from(p)}else{let p=ae(e,r);if(Array.isArray(p))for(let u of p)typeof u=="string"&&s.push(u)}return s},Et=(e,r)=>{let{filterToPropertyMapping:{specialProperty:t}}=r,a;return t&&(a=e[t]),a},ie=({cardTypes:e},{types:r,subtypes:t})=>!e||e?.some(a=>r.map(i=>i.toLowerCase()).includes(a.toLowerCase())||t.map(i=>i.toLowerCase()).includes(a.toLowerCase()));var Dt=(e,r)=>{let t=[];if(e)for(let a of r){let i=a.name===e.name,s=a.cardIdentifier!==e.cardIdentifier,o=a.pitch!==e.pitch;i&&s&&o&&t.push(a)}return t},Ot=(e,r)=>{let t=new Set(e?.referencedCards),a=[];for(let i of r)t.has(i.cardIdentifier)&&a.push(i);return a},Ht=e=>{let r=new Map;for(let t of e)for(let a of t.referencedCards||[]){let i=r.get(a);i?i.push(t):r.set(a,[t])}return r},Vt=(e,r)=>{let t=new Set;for(let i of e)for(let s of i.createdExtras||[])t.add(s);let a=[];for(let i of r)t.has(i.cardIdentifier)&&a.push(i);return a};0&&(module.exports={FilterProperty,MARKUP,NO_CARD_PROPERTY,PUNCTUATION,RARITY_VALUES_MAPPING,abbreviations,availableExclusions,availableModifiers,filterCard,filtersToCardPropertyMappings,getAbbreviation,getAbbreviationByCard,getCardsByName,getCardsByReferencedCardIdentifier,getCardsReferencedBy,getCardsReferencing,getCatalogueIndex,getCleanText,getExcludedMetaFilters,getKeywordsAndAppliedFiltersFromText,getMetaFilters,getNormalizedText,getOtherPitches,getReferencedCards,getTextWithoutMarkup,getTokensReferencedByCards,multiWordShorthands,shorthands,singleWordShorthands});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Release } from "@flesh-and-blood/types";
|
|
2
|
+
/**
|
|
3
|
+
* Copies a lookup table onto a null prototype so that a key can only ever match
|
|
4
|
+
* a real entry. Keys here come from raw search text, and a plain object literal
|
|
5
|
+
* answers `constructor`, `__proto__` and the rest of `Object.prototype` with an
|
|
6
|
+
* inherited member, handing the caller a function where it expects a value.
|
|
7
|
+
*
|
|
8
|
+
* Deliberately not re-exported from the package barrel: it guards an internal
|
|
9
|
+
* invariant rather than serving consumers.
|
|
10
|
+
*/
|
|
11
|
+
export declare const getLookupWithoutInheritedKeys: <T>(entries: {
|
|
12
|
+
[key: string]: T;
|
|
13
|
+
}) => {
|
|
14
|
+
[key: string]: T;
|
|
15
|
+
};
|
|
16
|
+
export declare const releasesBySetIdentifier: {
|
|
17
|
+
[key: string]: Release;
|
|
18
|
+
};
|
|
19
|
+
export declare const setIdentifiersByRelease: {
|
|
20
|
+
[key: string]: string[] | undefined;
|
|
21
|
+
};
|
package/dist/lookups.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setIdentifierToSetMappings,
|
|
3
|
+
setToSetIdentifierMappings
|
|
4
|
+
} from "@flesh-and-blood/types";
|
|
5
|
+
const getLookupWithoutInheritedKeys = (entries) => Object.assign(/* @__PURE__ */ Object.create(null), entries);
|
|
6
|
+
const releasesBySetIdentifier = getLookupWithoutInheritedKeys(
|
|
7
|
+
setIdentifierToSetMappings
|
|
8
|
+
);
|
|
9
|
+
const setIdentifiersByRelease = getLookupWithoutInheritedKeys(setToSetIdentifierMappings);
|
|
10
|
+
export {
|
|
11
|
+
getLookupWithoutInheritedKeys,
|
|
12
|
+
releasesBySetIdentifier,
|
|
13
|
+
setIdentifiersByRelease
|
|
14
|
+
};
|
package/dist/metaFilters.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Format, Hero, Talent } from "@flesh-and-blood/types";
|
|
2
2
|
import { PUNCTUATION } from "./constants.js";
|
|
3
|
+
import { getLookupWithoutInheritedKeys } from "./lookups.js";
|
|
3
4
|
const FilterProperty = {
|
|
4
5
|
BannedFormats: "bannedFormats",
|
|
5
6
|
LegalFormats: "legalFormats",
|
|
@@ -343,7 +344,7 @@ const noTalents = [
|
|
|
343
344
|
values: Object.values(Talent).map((talent) => talent.toLowerCase())
|
|
344
345
|
}
|
|
345
346
|
];
|
|
346
|
-
const excludedFilters = {
|
|
347
|
+
const excludedFilters = getLookupWithoutInheritedKeys({
|
|
347
348
|
"!co": noCost,
|
|
348
349
|
"-co": noCost,
|
|
349
350
|
"!cost": noCost,
|
|
@@ -376,7 +377,7 @@ const excludedFilters = {
|
|
|
376
377
|
"-talents": noTalents,
|
|
377
378
|
"!tal": noTalents,
|
|
378
379
|
"-tal": noTalents
|
|
379
|
-
};
|
|
380
|
+
});
|
|
380
381
|
const getExcludedMetaFilters = (filterKey) => {
|
|
381
382
|
const filters = [];
|
|
382
383
|
const matchingFilters = excludedFilters[filterKey];
|
package/dist/search.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
setIdentifierToSetMappings,
|
|
3
|
-
setToSetIdentifierMappings
|
|
4
|
-
} from "@flesh-and-blood/types";
|
|
5
1
|
import Fuse from "fuse.js";
|
|
6
2
|
import { PUNCTUATION } from "./constants.js";
|
|
7
3
|
import {
|
|
@@ -10,6 +6,7 @@ import {
|
|
|
10
6
|
} from "./filters.js";
|
|
11
7
|
import { memes } from "./memes.js";
|
|
12
8
|
import { getNormalizedText, getTextWithoutMarkup } from "./helpers.js";
|
|
9
|
+
import { releasesBySetIdentifier, setIdentifiersByRelease } from "./lookups.js";
|
|
13
10
|
import { FilterProperty } from "./metaFilters.js";
|
|
14
11
|
import { getCatalogueIndex } from "./searchIndex.js";
|
|
15
12
|
const searchOptions = {
|
|
@@ -77,33 +74,25 @@ class Search {
|
|
|
77
74
|
);
|
|
78
75
|
}
|
|
79
76
|
if (keywords.length === 0) {
|
|
80
|
-
let
|
|
77
|
+
let setIdentifierToSortBy = "";
|
|
81
78
|
const shouldSortByRelease = attributes.releases.length === 1;
|
|
82
79
|
if (shouldSortByRelease) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
setIdentifieToSortBy = matchingSetIdentifiers[0].toUpperCase();
|
|
87
|
-
} catch (e) {
|
|
88
|
-
console.error(`Error getting set identifier from search`, e);
|
|
80
|
+
const matchingSetIdentifiers = setIdentifiersByRelease[attributes.releases[0]];
|
|
81
|
+
if (matchingSetIdentifiers?.length) {
|
|
82
|
+
setIdentifierToSortBy = matchingSetIdentifiers[0].toUpperCase();
|
|
89
83
|
}
|
|
90
84
|
}
|
|
91
|
-
const shouldSortByPrint = !
|
|
85
|
+
const shouldSortByPrint = !setIdentifierToSortBy && attributes.prints.length === 1;
|
|
92
86
|
if (shouldSortByPrint) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (matchingSetIdentifiers) {
|
|
97
|
-
setIdentifieToSortBy = setToSort.toUpperCase();
|
|
98
|
-
}
|
|
99
|
-
} catch (e) {
|
|
100
|
-
console.error(`Error getting set identifier from search`, e);
|
|
87
|
+
const setToSort = attributes.prints[0];
|
|
88
|
+
if (releasesBySetIdentifier[setToSort]) {
|
|
89
|
+
setIdentifierToSortBy = setToSort.toUpperCase();
|
|
101
90
|
}
|
|
102
91
|
}
|
|
103
|
-
if (
|
|
92
|
+
if (setIdentifierToSortBy) {
|
|
104
93
|
results.sort((c1, c2) => {
|
|
105
|
-
const c1SetNumber = c1.setIdentifiers.find((identifier) => identifier.includes(
|
|
106
|
-
const c2SetNumber = c2.setIdentifiers.find((identifier) => identifier.includes(
|
|
94
|
+
const c1SetNumber = c1.setIdentifiers.find((identifier) => identifier.includes(setIdentifierToSortBy))?.replace(setIdentifierToSortBy, "");
|
|
95
|
+
const c2SetNumber = c2.setIdentifiers.find((identifier) => identifier.includes(setIdentifierToSortBy))?.replace(setIdentifierToSortBy, "");
|
|
107
96
|
return c1SetNumber && c2SetNumber ? c1SetNumber.localeCompare(c2SetNumber) : -1;
|
|
108
97
|
});
|
|
109
98
|
} else {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flesh-and-blood/search",
|
|
3
3
|
"description": "TypeScript search engine for Flesh and Blood cards",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.6",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "dist/index.cjs",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"@flesh-and-blood/types": "^5.0.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@flesh-and-blood/cards": "^5.0.
|
|
50
|
-
"@flesh-and-blood/types": "^5.0.
|
|
49
|
+
"@flesh-and-blood/cards": "^5.0.6",
|
|
50
|
+
"@flesh-and-blood/types": "^5.0.5",
|
|
51
51
|
"@types/jest": "^29.5.11",
|
|
52
52
|
"@types/node": "^20.10.5",
|
|
53
53
|
"esbuild": "^0.19.10",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"FAB",
|
|
78
78
|
"FABTCG"
|
|
79
79
|
],
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "d712ef4c8db033385665619c25ef464d66d0ada0"
|
|
81
81
|
}
|