@flesh-and-blood/search 4.2.1 → 4.2.2

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 +1,8 @@
1
1
  export declare const PUNCTUATION: RegExp;
2
+ /**
3
+ * The markdown emphasis that wraps keywords in a card's functional text. Kept
4
+ * out of `PUNCTUATION` because an asterisk is also a printed card value:
5
+ * `specialPower`, `specialDefense` and `specialLife` store one for a variable
6
+ * stat, and `power:*` needs the character to survive normalization.
7
+ */
8
+ export declare const MARKUP: RegExp;
package/dist/constants.js CHANGED
@@ -1,4 +1,6 @@
1
1
  const PUNCTUATION = /[!"#$%&'’(),./:;<=>?@[\]^_`|~]/g;
2
+ const MARKUP = /\*/g;
2
3
  export {
4
+ MARKUP,
3
5
  PUNCTUATION
4
6
  };
package/dist/filters.d.ts CHANGED
@@ -31,6 +31,13 @@ export interface FilterToPropertyMapping {
31
31
  isString?: boolean;
32
32
  isBoolean?: boolean;
33
33
  isDate?: boolean;
34
+ /**
35
+ * The card stores this property with markdown emphasis around its keywords,
36
+ * so the matcher strips that from both sides. A searched phrase then reads
37
+ * the text the way the card renders it rather than the way it is stored,
38
+ * and a phrase spanning a keyword boundary still matches.
39
+ */
40
+ hasMarkup?: boolean;
34
41
  isMeta?: boolean;
35
42
  /**
36
43
  * The card stores this property the way a filter value is written, so the
package/dist/filters.js CHANGED
@@ -12,6 +12,7 @@ import { getAbbreviation } from "./abbreviations.js";
12
12
  import { getExcludedMetaFilters, getMetaFilters } from "./metaFilters.js";
13
13
  import { multiWordShorthands, singleWordShorthands } from "./shorthands.js";
14
14
  import { PUNCTUATION } from "./constants.js";
15
+ import { getTextWithoutMarkup } from "./helpers.js";
15
16
  import {
16
17
  getCardsByName,
17
18
  getCardsReferencedBy,
@@ -174,6 +175,7 @@ const talentFilter = {
174
175
  };
175
176
  const textFilter = {
176
177
  property: "functionalText",
178
+ hasMarkup: true,
177
179
  isString: true,
178
180
  partialMatch: true
179
181
  };
@@ -542,7 +544,7 @@ const getKeywordsAndAppliedFiltersFromText = (text, index, additionalHeroes = []
542
544
  if (filterToPropertyMapping && !areValuesAlreadyApplied) {
543
545
  appliedFilters.push({
544
546
  filterToPropertyMapping,
545
- values,
547
+ values: filterToPropertyMapping.hasMarkup ? values.map((value) => getTextWithoutMarkup(value)) : values,
546
548
  isAnd,
547
549
  isOr,
548
550
  modifier,
package/dist/helpers.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export declare const getCleanText: (text: string) => string;
2
2
  export declare const getNormalizedText: (text: string) => string;
3
+ export declare const getTextWithoutMarkup: (text: string) => string;
package/dist/helpers.js CHANGED
@@ -1,7 +1,9 @@
1
- import { PUNCTUATION } from "./constants.js";
1
+ import { MARKUP, PUNCTUATION } from "./constants.js";
2
2
  const getCleanText = (text) => getNormalizedText(text.toLowerCase().trim().replace(PUNCTUATION, ""));
3
3
  const getNormalizedText = (text) => text.normalize("NFD").replace(/\p{Diacritic}/gu, "");
4
+ const getTextWithoutMarkup = (text) => text.replace(MARKUP, "");
4
5
  export {
5
6
  getCleanText,
6
- getNormalizedText
7
+ getNormalizedText,
8
+ getTextWithoutMarkup
7
9
  };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- var dr=Object.create;var Y=Object.defineProperty;var ur=Object.getOwnPropertyDescriptor;var fr=Object.getOwnPropertyNames;var gr=Object.getPrototypeOf,hr=Object.prototype.hasOwnProperty;var br=(e,r)=>{for(var t in r)Y(e,t,{get:r[t],enumerable:!0})},Be=(e,r,t,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of fr(r))!hr.call(e,i)&&i!==t&&Y(e,i,{get:()=>r[i],enumerable:!(a=ur(r,i))||a.enumerable});return e};var yr=(e,r,t)=>(t=e!=null?dr(gr(e)):{},Be(r||!e||!e.__esModule?Y(t,"default",{value:e,enumerable:!0}):t,e)),mr=e=>Be(Y({},"__esModule",{value:!0}),e);var yt={};br(yt,{FilterProperty:()=>Ie,PUNCTUATION:()=>f,RARITY_VALUES_MAPPING:()=>Pe,abbreviations:()=>de,availableExclusions:()=>or,availableModifiers:()=>sr,buildSearchIndex:()=>me,default:()=>cr,filterCard:()=>pr,filtersToCardPropertyMappings:()=>xe,getAbbreviation:()=>J,getAbbreviationByCard:()=>Cr,getCardsByName:()=>re,getCardsByReferencedCardIdentifier:()=>ye,getCardsReferencedBy:()=>ie,getCardsReferencing:()=>te,getCleanText:()=>z,getExcludedMetaFilters:()=>fe,getKeywordsAndAppliedFiltersFromText:()=>we,getMetaFilters:()=>ue,getNormalizedText:()=>q,getOtherPitches:()=>Rr,getReferencedCards:()=>Er,getTokensReferencedByCards:()=>Nr,multiWordShorthands:()=>he,shorthands:()=>ge,singleWordShorthands:()=>be});module.exports=mr(yt);var ne=require("@flesh-and-blood/types"),ke=yr(require("fuse.js"),1);var f=/[!"#$%&'’(),./:;<=>?@[\]^_`|~]/g;var l=require("@flesh-and-blood/types");var J=e=>de.find(({abbreviations:r})=>r.find(t=>t.toLowerCase()===e)),Cr=e=>de.find(({card:r})=>r.toLowerCase()===e.name.toLowerCase()),de=[{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 T=require("@flesh-and-blood/types");var Ie=(a=>(a.BannedFormats="bannedFormats",a.LegalFormats="legalFormats",a.LegalHeroes="legalHeroes",a))(Ie||{}),ee=Array.from(Array(50).keys()).map(e=>`${e}`),Fr=[{format:T.Format.ClassicConstructed,nicknames:["cc","classic"]},{format:T.Format.LivingLegend,nicknames:["cc ll","classic constructed ll","ll cc","ll","living legend"]},{format:T.Format.SilverAge,nicknames:["sage"]},{format:T.Format.GoldenAge,nicknames:["gage"]},{format:T.Format.UltimatePitFight,nicknames:["upf"]}],Mr=Object.values(T.Format).map(e=>{let r=Fr.find(({format:a})=>a===e),t=e.toLowerCase().replaceAll(f,"");return r?{...r,format:t}:{format:t}}),vr=[{hero:T.Hero.DataDoll,nicknames:["data","datadoll"]},{hero:T.Hero.Dorinthea,nicknames:["dori"]},{hero:T.Hero.Genis,nicknames:["genis"]},{hero:T.Hero.GravyBones,nicknames:["gravy"]},{hero:T.Hero.Iyslander,nicknames:["islander"]}],Ar=Object.values(T.Hero).map(e=>{let r=vr.find(({hero:a})=>a===e),t=e.toLowerCase().replaceAll(f,"");return r?{...r,hero:t}:{hero:t}}),Q=["common","rare","super rare","majestic","legendary","fabled"],Tr=(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 Q)o?i.push(n):n===s&&(o=!0,i.push(n));break}case">":{let o=!1;for(let n of Q)o?i.push(n):n===s&&(o=!0);break}case"<=":{let o=!1;for(let n of Q.slice().reverse())o?i.push(n):n===s&&(o=!0,i.push(n));break}case"<":{let o=!1;for(let n of Q.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}},Re=(e,r,t,a,i)=>{let s=a.map(d=>({hero:d.toLowerCase().replaceAll(f,"")})),o=[],n=[],c=[];for(let d of e){let p=Mr.find(({format:m,nicknames:F})=>m===d||!!F&&F.includes(d));if(p)n.push(p.format);else{let m=Ar.find(({hero:F,nicknames:M})=>F===d||!!M&&M.includes(d))||s.find(({hero:F})=>F===d);m&&c.push(m.hero)}}let g=i||"legalFormats";return n.length>0&&o.push({filterToPropertyMapping:{property:g,isArray:!0},values:n,isOr:!0,isExcluded:r,isOptional:t}),c.length>0&&o.push({filterToPropertyMapping:{property:"legalHeroes",isArray:!0},values:c,isOr:!0,isExcluded:r,isOptional:t}),o},Sr=(e,r,t,a)=>Re(e,r,t,a,"bannedFormats"),ue=(e,r,t,a,i,s)=>{let o=[];return wr(t)?o.push(...Re(a,e,r,s)):Lr(t)?o.push(...Sr(a,e,r,s)):Ir(t)&&o.push(Tr(a,i,e,r)),o},j=[{filterToPropertyMapping:{property:"cost",isNumber:!0},isExcluded:!0,values:ee},{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"]}],O=[{filterToPropertyMapping:{property:"defense",isNumber:!0},isExcluded:!0,values:ee},{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"]}],X=[{filterToPropertyMapping:{property:"pitch",isNumber:!0},isExcluded:!0,values:ee},{filterToPropertyMapping:{property:"types",isArray:!0,partialMatch:!0},isExcluded:!0,values:["equipment","hero","placeholder","token","weapon"]},{filterToPropertyMapping:{property:"isCardBack",isBoolean:!0},isExcluded:!0,values:["true"]}],V=[{filterToPropertyMapping:{property:"power",isNumber:!0},isExcluded:!0,values:ee},{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"]}],Z=[{filterToPropertyMapping:{property:"talents",isArray:!0},isExcluded:!0,values:Object.values(T.Talent).map(e=>e.toLowerCase())}],Pr={"!co":j,"-co":j,"!cost":j,"-cost":j,"!color":j,"-color":j,"!b":O,"-b":O,"!block":O,"-block":O,"!d":O,"-d":O,"!def":O,"-def":O,"!defense":O,"-defense":O,"!pitch":X,"-pitch":X,"!p":X,"-p":X,"!attack":V,"-attack":V,"!power":V,"-power":V,"!pwr":V,"-pwr":V,"!pow":V,"-pow":V,"!talents":Z,"-talents":Z,"!tal":Z,"-tal":Z},fe=e=>{let r=[],t=Pr[e];return t&&r.push(...t),r},xr=["l","legal","hero"],wr=e=>xr.includes(e),kr=["banned"],Lr=e=>kr.includes(e),Br=["r","rarity"],Ir=e=>Br.includes(e);var R=require("@flesh-and-blood/types"),ge=[{description:"Attack actions",expanded:["st:attack"],filters:{subtypes:[R.Subtype.Attack]},isCardProperty:!1,shorthands:["AA"]},{description:"Arcane barrier",expanded:['k:"arcane barrier"'],filters:{keywords:[R.Keyword.ArcaneBarrier]},isCardProperty:!1,shorthands:["AB"]},{description:"Attack reactions",expanded:['t:"attack reaction"'],filters:{types:[R.Type.AttackReaction]},isCardProperty:!1,shorthands:["AR"]},{description:"Defense reactions",expanded:['t:"defense reaction"'],filters:{types:[R.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:[R.Keyword.GoAgain]},isCardProperty:!1,shorthands:["GA"]},{description:"Non-attack actions",expanded:["t:action","st:non-attack"],filters:{subtypes:[R.Subtype.NonAttack],types:[R.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:[R.Keyword.Spellvoid]},isCardProperty:!1,shorthands:["SV"]}],he=ge.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)})),be=ge.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 z=e=>q(e.toLowerCase().trim().replace(f,"")),q=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,"");var Rr=(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},Er=(e,r)=>{let t=new Set(e?.referencedCards),a=[];for(let i of r)t.has(i.cardIdentifier)&&a.push(i);return a},ye=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},Nr=(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};var me=e=>{let r=new Map,t=new Map,a=[],i=new Map,s=0;for(let o of e){r.set(o.cardIdentifier,o),t.set(o.cardIdentifier,s),s++;let n=z(o.name),c=i.get(n);c?c.push(o):(i.set(n,[o]),a.push(n))}return{cards:e,cardByCardIdentifier:r,corpusPositionByCardIdentifier:t,cleanedNames:a,pitchCycleByCleanedName:i,referencingCardsByCardIdentifier:ye(e)}},Ce=(e,r)=>e.pitchCycleByCleanedName.get(z(r.name))||[],re=(e,r)=>{let t=z(r),a=e.pitchCycleByCleanedName.get(t);if(!a){let i=e.cleanedNames.find(s=>s.includes(t));i&&(a=e.pitchCycleByCleanedName.get(i))}return a||[]},Ee=(e,r)=>{let t=new Map;for(let i of r)for(let s of Ce(e,i))t.set(s.cardIdentifier,s);let a=({cardIdentifier:i})=>e.corpusPositionByCardIdentifier.get(i)||0;return[...t.values()].sort((i,s)=>a(i)-a(s))},te=(e,r)=>{let t=[];for(let a of Ce(e,r))t.push(...e.referencingCardsByCardIdentifier.get(a.cardIdentifier)||[]);return Ee(e,t)},ie=(e,r)=>{let t=[];for(let a of Ce(e,r))for(let i of a.referencedCards||[]){let s=e.cardByCardIdentifier.get(i);s&&t.push(s)}return Ee(e,t)};var sr=[">=",">","<=","<"],or=["!","-"],Dr={property:"arcane",specialProperty:"specialArcane",isNumber:!0,partialMatch:!0},Fe={property:"artists",isArray:!0,partialMatch:!0},Ne={property:"n/a",isMeta:!0},De={property:"bonds",isArray:!0},Or={property:"cardIdentifier",isString:!0,isNormalized:!0},Oe=(e,{isAnd:r,isExcluded:t,isOptional:a,modifier:i})=>({filterToPropertyMapping:Or,values:[...e],valuesSet:e,isAnd:r,isOr:!0,modifier:i,isExcluded:t,isOptional:a}),Hr={property:"n/a"},He={property:"classes",isArray:!0,partialMatch:!0},Ve={property:"cost",specialProperty:"specialCost",isNumber:!0,partialMatch:!0},_={property:"defense",specialProperty:"specialDefense",isNumber:!0},Ge={property:"flows",isArray:!0},We={nestedProperty:"foiling",property:"printings",isArray:!0},Ue={property:"fusions",isArray:!0},Ke={property:"intellect",isNumber:!0},je={property:"keywords",isArray:!0},Me={property:"n/a",isMeta:!0},ze={property:"life",specialProperty:"specialLife",isNumber:!0},Se={property:"meta",isArray:!0},qe={property:"name",isString:!0,partialMatch:!0},ve={property:"pitch",isNumber:!0},_e={property:"firstReleaseDate",isDate:!0},ae={property:"power",specialProperty:"specialPower",isNumber:!0},Vr={property:"setIdentifiers",isArray:!0,partialMatch:!0},$e={property:"n/a",isMeta:!0},Gr={property:"n/a"},Wr={property:"n/a"},Ye={property:"sets",isArray:!0,partialMatch:!0},Ae={property:"shorthands",isArray:!0,partialMatch:!0},se={property:"specializations",isArray:!0,partialMatch:!0},Je={property:"subtypes",isArray:!0},Qe={property:"types",isArray:!0},Xe={property:"talents",isArray:!0},Ur={property:"functionalText",isString:!0,partialMatch:!0},Kr={property:"traits",isArray:!0,partialMatch:!0},jr={property:"typeText",isString:!0,partialMatch:!0},oe={nestedProperty:"treatments",property:"printings",isArray:!0,isNestedPropertyArray:!0},zr={property:"firstReleaseDate",isString:!0,partialMatch:!0},xe={arcane:Dr,a:Fe,artist:Fe,art:Fe,attack:ae,b:_,block:_,banned:Ne,bond:De,bonds:De,c:He,class:He,chain:Hr,co:Ve,cost:Ve,color:ve,d:_,def:_,defense:_,flow:Ge,flows:Ge,f:Ue,fusion:Ue,foil:We,foiling:We,i:Ke,intellect:Ke,is:Se,k:je,keyword:je,l:Me,legal:Me,hero:Me,li:ze,life:ze,meta:Se,n:qe,name:qe,p:ve,pitch:ve,pwr:ae,pow:ae,power:ae,print:Vr,r:$e,rarity:$e,referencedby:Gr,references:Wr,rf:Ne,s:Ye,set:Ye,short:Ae,shorthand:Ae,shorthands:Ae,sp:se,spec:se,specialization:se,specializations:se,st:Je,subtype:Je,t:Qe,type:Qe,tal:Xe,talent:Xe,text:Ur,trait:Kr,treat:oe,treatment:oe,var:oe,variation:oe,x:jr,year:zr},qr=[{text:l.Release.ClassicBattlesRhinarDorinthea.toLowerCase(),override:l.Release.ClassicBattlesRhinarDorinthea.toLowerCase().replaceAll(f,"")}],_r=e=>{let r=[],t=e.replaceAll("\u201D",'"');for(let{text:i,override:s}of qr)t.includes(i)&&(t=t.replace(i,s));if(J(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},$r=20,we=(e,r,t=[],a=[],i=rt())=>{let s=e.trim().toLowerCase();for(let{expanded:S,shorthands:P}of he)for(let u of P)if(s.includes(u)){s=s.replace(u,S.join(" "));break}for(let[S,P]of Object.entries(l.setToSetIdentifierMappings))s.includes(S.toLowerCase())&&(s=s.replace(S.toLowerCase(),P[0]));let o=_r(s),n=[];for(let S of o){let P=be.find(({shorthands:u})=>u.includes(S));P&&!P.isCardProperty?n.push(...P.expanded):n.push(S)}let c=[],g=[],d=[],p=[],m=!1,F=[],M=[],B=[],G=[];for(let S of n)if(lt(S)){let[P,u]=S.split(":"),{modifier:E,values:h,isAnd:b,isOr:x}=ot(u),{filterKey:C,isExcluded:w,isOptional:L,isMeta:ce}=nt(P),W=!1;if(ce){if(["rarity","r"].includes(C)){let U=st(h);w||(M=[...U]),h=U.map(v=>v.toLowerCase())}["legal","l","hero"].includes(C),c.push(...ue(w,L,C,h,E,t))}else{if(["chain"].includes(C)){let v=new Set,k=[],N=new Set,D=A=>{v.add(A.cardIdentifier),N.has(A.name)||(N.add(A.name),k.push(A))},K=A=>{A.types.includes(l.Type.Hero)||D(A)};for(let A of h)if(A)for(let I of re(r,A))D(I);let H=0;for(let A of k){if(H>$r)break;for(let pe of ie(r,A))K(pe);if(H===0)for(let pe of te(r,A))K(pe);H++}c.push(Oe(v,{isAnd:b,isExcluded:w,isOptional:L,modifier:E})),W=!0}else if(["referencedby","references"].includes(C)){let v=["referencedby"].includes(C),k=new Set;for(let N of h)if(N)for(let D of re(r,N)){let K=v?ie(r,D):te(r,D);for(let H of K)k.add(H.cardIdentifier)}c.push(Oe(k,{isAnd:b,isExcluded:w,isOptional:L,modifier:E})),W=!0}else if(["art","artist"].includes(C))g=h;else if(["print","prints","printing","printings"].includes(C))F=h;else if(["is","meta"].includes(C)){let v=[],k=[],N=[],D=[];for(let I of h)Xr.includes(I)?v.push(I):Zr.includes(I)?k.push(I):et.includes(I)?N.push(I):D.push(I);v.length>0&&(c.push({filterToPropertyMapping:Se,values:[l.Meta.Reprint.toLowerCase().replaceAll(f,"")],isAnd:b,isOr:x,isExcluded:!w,isOptional:L}),W=D.length===0);let K=k.length>0;K&&c.push({filterToPropertyMapping:_e,values:[i],isAnd:b,isOr:x,isExcluded:w,isOptional:L});let H=N.length>0;H&&c.push({filterToPropertyMapping:_e,values:[i],isAnd:b,isOr:x,isExcluded:!w,isOptional:L}),(K||H)&&(W=D.length===0);let A=tt(D);h=A.map(I=>I.toLowerCase().replaceAll(f,"")),A.includes(l.Meta.Expansion)&&!w&&(m=!0)}else["foiling","foil"].includes(C)?(p=it(h),h=p.map(v=>v.toLowerCase())):["treat","treatment","var","variation"].includes(C)?(G=at(h),h=G.map(v=>v.toLowerCase())):["set","s"].includes(C)?(B=Yr(h,a),h=B.map(v=>v.toLowerCase().replaceAll(f,""))):["pitch","p","color"].includes(C)&&(h=Qr(h));let U=xe[C];U&&!W&&c.push({filterToPropertyMapping:U,values:h,isAnd:b,isOr:x,modifier:E,isExcluded:w,isOptional:L})}}else if(S){let P=J(S)?.card,u=fe(S);P?d.push(`"${P.toLowerCase().replace(f,"")}"`):u&&u.length>0?c.push(...u):d.push(S.replace(f,""))}return{appliedFilters:c,attributes:{artists:g,foilings:p,isExpansionSlot:m,prints:F,rarities:M,releases:B,treatments:G},keywords:d}},Yr=(e,r=[])=>{let t=[];for(let a of e)t.push(...Jr(a,r));return t},Jr=(e,r=[])=>{let t=[],a=Object.values(l.Release).find(i=>i.toLowerCase().replaceAll(f,"")===e);if(a&&t.push(a),t.length===0){let i=l.setIdentifierToSetMappings[e];i&&t.push(i)}if(t.length===0){let i=Object.values(l.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(f,"")===e);i&&t.push(i)}return t},Te={purple:4,blue:3,yellow:2,red:1,white:0},Qr=e=>{let r=[];for(let t of e)Te[t]||Te[t]===0?r.push(Te[t].toString()):r.push(t);return r},Xr=["unique"],Zr=["preview","spoiler","unreleased"],et=["released"],rt=()=>{let e=new Date,r=`${e.getMonth()+1}`.padStart(2,"0"),t=`${e.getDate()}`.padStart(2,"0");return`${e.getFullYear()}-${r}-${t}`},Ze={dual:l.Meta.DualClass,exp:l.Meta.Expansion,expansion:l.Meta.Expansion,expansionSlot:l.Meta.Expansion,rainbow:l.Meta.Rainbow,reprint:l.Meta.Reprint,reprints:l.Meta.Reprint},tt=e=>{let r=[];for(let t of e)Ze[t]?r.push(Ze[t]):l.Meta[t]&&r.push(l.Meta[t]);if(e.length>0&&r.length===0){for(let t of Object.values(l.Meta))for(let a of e)if(t.toLowerCase().includes(a)){r.push(t);break}}return r},er={r:l.Foiling.Rainbow,rf:l.Foiling.Rainbow,rainbow:l.Foiling.Rainbow,c:l.Foiling.Cold,cf:l.Foiling.Cold,cold:l.Foiling.Cold,g:l.Foiling.Gold,gf:l.Foiling.Gold,gold:l.Foiling.Gold},it=e=>{let r=[];for(let t of e)er[t]&&r.push(er[t]);return r},rr={...Object.values(l.Treatment).reduce((e,r)=>(e[r.toLowerCase()]=r,e),{}),aa:l.Treatment.AA,alt:l.Treatment.AA,"alt art":l.Treatment.AA,ab:l.Treatment.AB,"alt border":l.Treatment.AB,at:l.Treatment.AT,"alt text":l.Treatment.AT,ea:l.Treatment.EA,extended:l.Treatment.EA,"extended art":l.Treatment.EA,fa:l.Treatment.FA,full:l.Treatment.FA,"full art":l.Treatment.FA},at=e=>{let r=[];for(let t of e)rr[t]?r.push(rr[t]):l.Treatment[t.toUpperCase()]&&r.push(l.Treatment[t.toUpperCase()]);return r},Pe={b:l.Rarity.Basic,c:l.Rarity.Common,f:l.Rarity.Fabled,l:l.Rarity.Legendary,m:l.Rarity.Majestic,p:l.Rarity.Promo,r:l.Rarity.Rare,s:l.Rarity.SuperRare,t:l.Rarity.Token,v:l.Rarity.Marvel},st=e=>{let r=[];for(let t of e)Pe[t]?r.push(Pe[t]):r.push(t);return r},ot=e=>{let r=[],t,a,i=sr.find(s=>e.includes(s));if(i){let[,s]=e.split(i);tr(s)?(t=!0,r.push(...s.trim().split("+").map(o=>o.replace(f,"")))):ir(s)?(a=!0,r.push(...s.trim().split(",").map(o=>o.replace(f,"")))):r.push(s.trim().replace(f,""))}else tr(e)?(t=!0,r.push(...e.trim().split("+").map(s=>s.replace(f,"")))):ir(e)?(a=!0,r.push(...e.trim().split(",").map(s=>s.replace(f,"")))):e.startsWith('"')&&e.endsWith('"')?r.push(e.trim().replaceAll('"',"").replace(f,"")):r.push(e.trim().replace(f,""));return{modifier:i,values:r,isAnd:t,isOr:a}},nt=e=>{let r=ct(e);if(r){let[,t]=e.split(r);return{filterKey:t,isExcluded:!0,isOptional:!1,isMeta:ar(t)}}else return{filterKey:e,isExcluded:!1,isOptional:!1,isMeta:ar(e)}},lt=e=>e.indexOf(":")>=0,tr=e=>e.indexOf("+")>=0,ir=e=>e.indexOf(",")>=0,ar=e=>!!xe[e]?.isMeta,ct=e=>or.find(r=>e.includes(r))?.slice(0,1);var y=require("@flesh-and-blood/types"),nr={artists:["Hoodwill"],cardIdentifier:"fangs-a-lot-blue",classes:[y.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:[y.Hero.Kayo,y.Hero.Levia,y.Hero.Rhinar],printings:[{artists:["Hoodwill"],identifier:"FNG000",image:"FNG000",print:"FNG000",rarity:y.Rarity.Rare,set:y.Release.Promos},{artists:["Hoodwill"],identifier:"FNG000",image:"FNG000_Marvel",print:`FNG000-${y.Treatment.FA}`,rarity:y.Rarity.Marvel,set:y.Release.Promos,treatment:y.Treatment.FA}],name:"Fangs A Lot",rarities:[y.Rarity.Rare,y.Rarity.Marvel],rarity:y.Rarity.Rare,sets:[y.Release.Promos],setIdentifiers:["FNG000"],specialImage:"FNG000_Marvel",subtypes:[y.Subtype.Attack],types:[y.Type.Action],typeText:"Generic Action - Attack"},lr=[{keyword:nr.name.toLowerCase(),card:nr}];var Le=class{constructor(r,t=[],a=[],i=!1){this.log=(r,...t)=>{this.debug&&console.log(r,...t)};this.search=(r,t)=>{let a,{appliedFilters:i,attributes:s,keywords:o}=we(r,this.index,this.additionalHeroes,this.additionalSets),n=o.join(" "),c=t?lr.filter(u=>u.keyword===n):[];if(c.length>0?a=c.map(({card:u})=>u):o.length?a=this.fuse.search(n).map(u=>u.item):a=[...this.cards],i.length&&(a=a.filter(u=>u&&pr(u,i))),o.length===0){let u="";if(s.releases.length===1)try{let b=s.releases[0];u=ne.setToSetIdentifierMappings[b][0].toUpperCase()}catch(b){console.error("Error getting set identifier from search",b)}if(!u&&s.prints.length===1)try{let b=s.prints[0];ne.setIdentifierToSetMappings[b]&&(u=b.toUpperCase())}catch(b){console.error("Error getting set identifier from search",b)}u?a.sort((b,x)=>{let C=b.setIdentifiers.find(L=>L.includes(u))?.replace(u,""),w=x.setIdentifiers.find(L=>L.includes(u))?.replace(u,"");return C&&w?C.localeCompare(w):-1}):a.sort((b,x)=>b.name===x.name?`${b.pitch}`.localeCompare(`${x.pitch}`):b.name.localeCompare(x.name))}else{let u=[],E=[],h=o.map(b=>b.toLowerCase().replace(f,"")).join(" ");for(let b of a)b.name.toLowerCase().replace(f,"")===h?u.push(b):E.push(b);a=[...u,...E]}let g,{artists:d,isExpansionSlot:p,foilings:m,prints:F,rarities:M,releases:B,treatments:G}=s;(d.length>0||p||m.length>0||F.length>0||M.length>0||B.length>0||G.length>0)&&(g=a.map(u=>{let E=u.printings.filter(h=>{let b=!!h.image,x=d.length===0||d.some(k=>h.artists.find(N=>N.replace(f,"").toLowerCase().includes(k))),C=!p||p===h.isExpansionSlot,w=m.length===0||m.includes(h.foiling),L=F.length===0||F.some(k=>h.identifier.includes(k.toUpperCase())),ce=M.length===0||M.includes(h.rarity),W=B.length===0||B.includes(h.set),U=G.length===0||h.treatments?.some(k=>G.includes(k));return b&&x&&C&&w&&L&&ce&&W&&U});return{...u,matchingPrintings:E}}));let P=g?.length>0?g:a;return{appliedFilters:i,attributes:s,keywords:o,searchResults:P}};let s={getFn:(o,n)=>{let c=ke.default.config.getFn(o,n);return c&&(Array.isArray(c)?c.map(g=>q(g.replace(f,""))):q(c).replace(f,""))},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};this.additionalHeroes=t,this.additionalSets=a,this.cards=[...r],this.debug=i,this.fuse=new ke.default([...r],s),this.index=me(this.cards)}},cr=Le,pr=(e,r)=>{let t=!0,a=!1;for(let i of r){let s=i.isOptional,{isNumber:o,isString:n,isArray:c,isBoolean:g,isDate:d}=i.filterToPropertyMapping;if(o){let p=pt(e,i);s?p&&(a=!0):t=t&&p}else if(n){let p=dt(e,i);s?p&&(a=!0):t=t&&p}else if(c){let p=ut(e,i,r);s?p&&(a=!0):t=t&&p}else if(g){let p=ft(e,i);s?p&&(a=!0):t=t&&p}else if(d){let p=gt(e,i);s?p&&(a=!0):t=t&&p}}return t},pt=(e,r)=>{if($(r,e)){let{values:t,modifier:a,isExcluded:i,filterToPropertyMapping:{partialMatch:s}}=r,o=le(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=bt(e,r)?.toLowerCase(),c=s?t?.some(g=>n?.includes(g)):t?.some(g=>n===g);return i?!c:c}}else return!0},dt=(e,r)=>{if($(r,e)){let{values:t,valuesSet:a,isAnd:i,isExcluded:s,filterToPropertyMapping:{isNormalized:o,partialMatch:n}}=r,c=le(e,r),g=o?c:c?.replaceAll(f,"").toLowerCase();if(n){let d=i?t?.every(p=>g?.includes(p)):t?.some(p=>g?.includes(p));return s?!d:d}else{let d;return i?d=t?.every(p=>g===p):a?d=a.has(g):d=t?.some(p=>g===p),s?!d:d}}else return!0},ut=(e,r,t)=>{if($(r,e)){let{values:a,isAnd:i,isExcluded:s,filterToPropertyMapping:{partialMatch:o}}=r,n=ht(e,r,t).map(c=>c?.replaceAll(f,""));if(o){let c=i?a.every(d=>n?.some(p=>p?.toLowerCase().includes(d))):a.some(d=>n?.some(p=>p?.toLowerCase().includes(d))),g=n.length===0;return s?!c||g:c}else{let c=i?a.every(g=>n?.some(d=>d?.toLowerCase()===g)):a.some(g=>n?.some(d=>d?.toLowerCase()===g));return s?!c:c}}else return!0},ft=(e,r)=>{if($(r,e)){let{isExcluded:t}=r,a=le(e,r);return t?!a:a}else return!0},gt=(e,r)=>{if($(r,e)){let{values:t,isExcluded:a}=r,i=le(e,r),s=t?.some(o=>i>o);return a?!s:s}else return!0},le=(e,r)=>{let{filterToPropertyMapping:t}=r;return e[t.property]},ht=(e,r,t)=>{let{filterToPropertyMapping:{isNestedPropertyArray:a,nestedProperty:i,property:s}}=r,o=e[s]||[],n=[],c=Object.keys(e.legalOverrides||{}).length>0,g=r.filterToPropertyMapping.property==="legalHeroes",d=t.find(({filterToPropertyMapping:m})=>m.property==="legalFormats");if(c&&g&&!!d){let m=new Set;for(let{format:F,heroes:M}of e.legalOverrides||[])if(d.values.includes(F.toLowerCase()))for(let B of M)m.add(B);n=Array.from(m)}if(n.length===0)if(i){let m=new Set;for(let F of o)if(a){let M=F[i]||[];for(let B of M)m.add(B)}else{let M=F[i];M&&m.add(M)}n=Array.from(m)}else n=o;return n},bt=(e,r)=>{let{filterToPropertyMapping:t}=r;return e[t.specialProperty]},$=({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()));0&&(module.exports={FilterProperty,PUNCTUATION,RARITY_VALUES_MAPPING,abbreviations,availableExclusions,availableModifiers,buildSearchIndex,filterCard,filtersToCardPropertyMappings,getAbbreviation,getAbbreviationByCard,getCardsByName,getCardsByReferencedCardIdentifier,getCardsReferencedBy,getCardsReferencing,getCleanText,getExcludedMetaFilters,getKeywordsAndAppliedFiltersFromText,getMetaFilters,getNormalizedText,getOtherPitches,getReferencedCards,getTokensReferencedByCards,multiWordShorthands,shorthands,singleWordShorthands});
1
+ var fr=Object.create;var J=Object.defineProperty;var gr=Object.getOwnPropertyDescriptor;var hr=Object.getOwnPropertyNames;var br=Object.getPrototypeOf,yr=Object.prototype.hasOwnProperty;var mr=(e,r)=>{for(var t in r)J(e,t,{get:r[t],enumerable:!0})},Ie=(e,r,t,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of hr(r))!yr.call(e,i)&&i!==t&&J(e,i,{get:()=>r[i],enumerable:!(a=gr(r,i))||a.enumerable});return e};var Cr=(e,r,t)=>(t=e!=null?fr(br(e)):{},Ie(r||!e||!e.__esModule?J(t,"default",{value:e,enumerable:!0}):t,e)),Mr=e=>Ie(J({},"__esModule",{value:!0}),e);var Ct={};mr(Ct,{FilterProperty:()=>Ee,MARKUP:()=>ue,PUNCTUATION:()=>g,RARITY_VALUES_MAPPING:()=>we,abbreviations:()=>fe,availableExclusions:()=>lr,availableModifiers:()=>nr,buildSearchIndex:()=>Me,default:()=>dr,filterCard:()=>ur,filtersToCardPropertyMappings:()=>ke,getAbbreviation:()=>Q,getAbbreviationByCard:()=>Fr,getCardsByName:()=>te,getCardsByReferencedCardIdentifier:()=>Ce,getCardsReferencedBy:()=>ae,getCardsReferencing:()=>ie,getCleanText:()=>q,getExcludedMetaFilters:()=>he,getKeywordsAndAppliedFiltersFromText:()=>Le,getMetaFilters:()=>ge,getNormalizedText:()=>_,getOtherPitches:()=>Nr,getReferencedCards:()=>Dr,getTextWithoutMarkup:()=>j,getTokensReferencedByCards:()=>Or,multiWordShorthands:()=>ye,shorthands:()=>be,singleWordShorthands:()=>me});module.exports=Mr(Ct);var le=require("@flesh-and-blood/types"),Be=Cr(require("fuse.js"),1);var g=/[!"#$%&'’(),./:;<=>?@[\]^_`|~]/g,ue=/\*/g;var l=require("@flesh-and-blood/types");var Q=e=>fe.find(({abbreviations:r})=>r.find(t=>t.toLowerCase()===e)),Fr=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 T=require("@flesh-and-blood/types");var Ee=(a=>(a.BannedFormats="bannedFormats",a.LegalFormats="legalFormats",a.LegalHeroes="legalHeroes",a))(Ee||{}),re=Array.from(Array(50).keys()).map(e=>`${e}`),vr=[{format:T.Format.ClassicConstructed,nicknames:["cc","classic"]},{format:T.Format.LivingLegend,nicknames:["cc ll","classic constructed ll","ll cc","ll","living legend"]},{format:T.Format.SilverAge,nicknames:["sage"]},{format:T.Format.GoldenAge,nicknames:["gage"]},{format:T.Format.UltimatePitFight,nicknames:["upf"]}],Ar=Object.values(T.Format).map(e=>{let r=vr.find(({format:a})=>a===e),t=e.toLowerCase().replaceAll(g,"");return r?{...r,format:t}:{format:t}}),Tr=[{hero:T.Hero.DataDoll,nicknames:["data","datadoll"]},{hero:T.Hero.Dorinthea,nicknames:["dori"]},{hero:T.Hero.Genis,nicknames:["genis"]},{hero:T.Hero.GravyBones,nicknames:["gravy"]},{hero:T.Hero.Iyslander,nicknames:["islander"]}],Sr=Object.values(T.Hero).map(e=>{let r=Tr.find(({hero:a})=>a===e),t=e.toLowerCase().replaceAll(g,"");return r?{...r,hero:t}:{hero:t}}),X=["common","rare","super rare","majestic","legendary","fabled"],xr=(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 X)o?i.push(n):n===s&&(o=!0,i.push(n));break}case">":{let o=!1;for(let n of X)o?i.push(n):n===s&&(o=!0);break}case"<=":{let o=!1;for(let n of X.slice().reverse())o?i.push(n):n===s&&(o=!0,i.push(n));break}case"<":{let o=!1;for(let n of X.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}},Ne=(e,r,t,a,i)=>{let s=a.map(u=>({hero:u.toLowerCase().replaceAll(g,"")})),o=[],n=[],c=[];for(let u of e){let p=Ar.find(({format:b,nicknames:m})=>b===u||!!m&&m.includes(u));if(p)n.push(p.format);else{let b=Sr.find(({hero:m,nicknames:v})=>m===u||!!v&&v.includes(u))||s.find(({hero:m})=>m===u);b&&c.push(b.hero)}}let h=i||"legalFormats";return n.length>0&&o.push({filterToPropertyMapping:{property:h,isArray:!0},values:n,isOr:!0,isExcluded:r,isOptional:t}),c.length>0&&o.push({filterToPropertyMapping:{property:"legalHeroes",isArray:!0},values:c,isOr:!0,isExcluded:r,isOptional:t}),o},Pr=(e,r,t,a)=>Ne(e,r,t,a,"bannedFormats"),ge=(e,r,t,a,i,s)=>{let o=[];return Lr(t)?o.push(...Ne(a,e,r,s)):Rr(t)?o.push(...Pr(a,e,r,s)):Er(t)&&o.push(xr(a,i,e,r)),o},z=[{filterToPropertyMapping:{property:"cost",isNumber:!0},isExcluded:!0,values:re},{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"]}],O=[{filterToPropertyMapping:{property:"defense",isNumber:!0},isExcluded:!0,values:re},{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"]}],Z=[{filterToPropertyMapping:{property:"pitch",isNumber:!0},isExcluded:!0,values:re},{filterToPropertyMapping:{property:"types",isArray:!0,partialMatch:!0},isExcluded:!0,values:["equipment","hero","placeholder","token","weapon"]},{filterToPropertyMapping:{property:"isCardBack",isBoolean:!0},isExcluded:!0,values:["true"]}],G=[{filterToPropertyMapping:{property:"power",isNumber:!0},isExcluded:!0,values:re},{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"]}],ee=[{filterToPropertyMapping:{property:"talents",isArray:!0},isExcluded:!0,values:Object.values(T.Talent).map(e=>e.toLowerCase())}],wr={"!co":z,"-co":z,"!cost":z,"-cost":z,"!color":z,"-color":z,"!b":O,"-b":O,"!block":O,"-block":O,"!d":O,"-d":O,"!def":O,"-def":O,"!defense":O,"-defense":O,"!pitch":Z,"-pitch":Z,"!p":Z,"-p":Z,"!attack":G,"-attack":G,"!power":G,"-power":G,"!pwr":G,"-pwr":G,"!pow":G,"-pow":G,"!talents":ee,"-talents":ee,"!tal":ee,"-tal":ee},he=e=>{let r=[],t=wr[e];return t&&r.push(...t),r},kr=["l","legal","hero"],Lr=e=>kr.includes(e),Br=["banned"],Rr=e=>Br.includes(e),Ir=["r","rarity"],Er=e=>Ir.includes(e);var I=require("@flesh-and-blood/types"),be=[{description:"Attack actions",expanded:["st:attack"],filters:{subtypes:[I.Subtype.Attack]},isCardProperty:!1,shorthands:["AA"]},{description:"Arcane barrier",expanded:['k:"arcane barrier"'],filters:{keywords:[I.Keyword.ArcaneBarrier]},isCardProperty:!1,shorthands:["AB"]},{description:"Attack reactions",expanded:['t:"attack reaction"'],filters:{types:[I.Type.AttackReaction]},isCardProperty:!1,shorthands:["AR"]},{description:"Defense reactions",expanded:['t:"defense reaction"'],filters:{types:[I.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:[I.Keyword.GoAgain]},isCardProperty:!1,shorthands:["GA"]},{description:"Non-attack actions",expanded:["t:action","st:non-attack"],filters:{subtypes:[I.Subtype.NonAttack],types:[I.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:[I.Keyword.Spellvoid]},isCardProperty:!1,shorthands:["SV"]}],ye=be.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)})),me=be.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 q=e=>_(e.toLowerCase().trim().replace(g,"")),_=e=>e.normalize("NFD").replace(/\p{Diacritic}/gu,""),j=e=>e.replace(ue,"");var Nr=(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},Dr=(e,r)=>{let t=new Set(e?.referencedCards),a=[];for(let i of r)t.has(i.cardIdentifier)&&a.push(i);return a},Ce=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},Or=(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};var Me=e=>{let r=new Map,t=new Map,a=[],i=new Map,s=0;for(let o of e){r.set(o.cardIdentifier,o),t.set(o.cardIdentifier,s),s++;let n=q(o.name),c=i.get(n);c?c.push(o):(i.set(n,[o]),a.push(n))}return{cards:e,cardByCardIdentifier:r,corpusPositionByCardIdentifier:t,cleanedNames:a,pitchCycleByCleanedName:i,referencingCardsByCardIdentifier:Ce(e)}},Fe=(e,r)=>e.pitchCycleByCleanedName.get(q(r.name))||[],te=(e,r)=>{let t=q(r),a=e.pitchCycleByCleanedName.get(t);if(!a){let i=e.cleanedNames.find(s=>s.includes(t));i&&(a=e.pitchCycleByCleanedName.get(i))}return a||[]},De=(e,r)=>{let t=new Map;for(let i of r)for(let s of Fe(e,i))t.set(s.cardIdentifier,s);let a=({cardIdentifier:i})=>e.corpusPositionByCardIdentifier.get(i)||0;return[...t.values()].sort((i,s)=>a(i)-a(s))},ie=(e,r)=>{let t=[];for(let a of Fe(e,r))t.push(...e.referencingCardsByCardIdentifier.get(a.cardIdentifier)||[]);return De(e,t)},ae=(e,r)=>{let t=[];for(let a of Fe(e,r))for(let i of a.referencedCards||[]){let s=e.cardByCardIdentifier.get(i);s&&t.push(s)}return De(e,t)};var nr=[">=",">","<=","<"],lr=["!","-"],Hr={property:"arcane",specialProperty:"specialArcane",isNumber:!0,partialMatch:!0},ve={property:"artists",isArray:!0,partialMatch:!0},Oe={property:"n/a",isMeta:!0},He={property:"bonds",isArray:!0},Vr={property:"cardIdentifier",isString:!0,isNormalized:!0},Ve=(e,{isAnd:r,isExcluded:t,isOptional:a,modifier:i})=>({filterToPropertyMapping:Vr,values:[...e],valuesSet:e,isAnd:r,isOr:!0,modifier:i,isExcluded:t,isOptional:a}),Gr={property:"n/a"},Ge={property:"classes",isArray:!0,partialMatch:!0},We={property:"cost",specialProperty:"specialCost",isNumber:!0,partialMatch:!0},$={property:"defense",specialProperty:"specialDefense",isNumber:!0},Ue={property:"flows",isArray:!0},Ke={nestedProperty:"foiling",property:"printings",isArray:!0},ze={property:"fusions",isArray:!0},je={property:"intellect",isNumber:!0},qe={property:"keywords",isArray:!0},Ae={property:"n/a",isMeta:!0},_e={property:"life",specialProperty:"specialLife",isNumber:!0},Pe={property:"meta",isArray:!0},$e={property:"name",isString:!0,partialMatch:!0},Te={property:"pitch",isNumber:!0},Ye={property:"firstReleaseDate",isDate:!0},se={property:"power",specialProperty:"specialPower",isNumber:!0},Wr={property:"setIdentifiers",isArray:!0,partialMatch:!0},Je={property:"n/a",isMeta:!0},Ur={property:"n/a"},Kr={property:"n/a"},Qe={property:"sets",isArray:!0,partialMatch:!0},Se={property:"shorthands",isArray:!0,partialMatch:!0},oe={property:"specializations",isArray:!0,partialMatch:!0},Xe={property:"subtypes",isArray:!0},Ze={property:"types",isArray:!0},er={property:"talents",isArray:!0},zr={property:"functionalText",hasMarkup:!0,isString:!0,partialMatch:!0},jr={property:"traits",isArray:!0,partialMatch:!0},qr={property:"typeText",isString:!0,partialMatch:!0},ne={nestedProperty:"treatments",property:"printings",isArray:!0,isNestedPropertyArray:!0},_r={property:"firstReleaseDate",isString:!0,partialMatch:!0},ke={arcane:Hr,a:ve,artist:ve,art:ve,attack:se,b:$,block:$,banned:Oe,bond:He,bonds:He,c:Ge,class:Ge,chain:Gr,co:We,cost:We,color:Te,d:$,def:$,defense:$,flow:Ue,flows:Ue,f:ze,fusion:ze,foil:Ke,foiling:Ke,i:je,intellect:je,is:Pe,k:qe,keyword:qe,l:Ae,legal:Ae,hero:Ae,li:_e,life:_e,meta:Pe,n:$e,name:$e,p:Te,pitch:Te,pwr:se,pow:se,power:se,print:Wr,r:Je,rarity:Je,referencedby:Ur,references:Kr,rf:Oe,s:Qe,set:Qe,short:Se,shorthand:Se,shorthands:Se,sp:oe,spec:oe,specialization:oe,specializations:oe,st:Xe,subtype:Xe,t:Ze,type:Ze,tal:er,talent:er,text:zr,trait:jr,treat:ne,treatment:ne,var:ne,variation:ne,x:qr,year:_r},$r=[{text:l.Release.ClassicBattlesRhinarDorinthea.toLowerCase(),override:l.Release.ClassicBattlesRhinarDorinthea.toLowerCase().replaceAll(g,"")}],Yr=e=>{let r=[],t=e.replaceAll("\u201D",'"');for(let{text:i,override:s}of $r)t.includes(i)&&(t=t.replace(i,s));if(Q(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},Jr=20,Le=(e,r,t=[],a=[],i=it())=>{let s=e.trim().toLowerCase();for(let{expanded:S,shorthands:x}of ye)for(let d of x)if(s.includes(d)){s=s.replace(d,S.join(" "));break}for(let[S,x]of Object.entries(l.setToSetIdentifierMappings))s.includes(S.toLowerCase())&&(s=s.replace(S.toLowerCase(),x[0]));let o=Yr(s),n=[];for(let S of o){let x=me.find(({shorthands:d})=>d.includes(S));x&&!x.isCardProperty?n.push(...x.expanded):n.push(S)}let c=[],h=[],u=[],p=[],b=!1,m=[],v=[],B=[],W=[];for(let S of n)if(pt(S)){let[x,d]=S.split(":"),{modifier:E,values:f,isAnd:y,isOr:P}=lt(d),{filterKey:M,isExcluded:w,isOptional:L,isMeta:pe}=ct(x),U=!1;if(pe){if(["rarity","r"].includes(M)){let H=nt(f);w||(v=[...H]),f=H.map(F=>F.toLowerCase())}["legal","l","hero"].includes(M),c.push(...ge(w,L,M,f,E,t))}else{if(["chain"].includes(M)){let F=new Set,k=[],N=new Set,D=A=>{F.add(A.cardIdentifier),N.has(A.name)||(N.add(A.name),k.push(A))},K=A=>{A.types.includes(l.Type.Hero)||D(A)};for(let A of f)if(A)for(let R of te(r,A))D(R);let V=0;for(let A of k){if(V>Jr)break;for(let de of ae(r,A))K(de);if(V===0)for(let de of ie(r,A))K(de);V++}c.push(Ve(F,{isAnd:y,isExcluded:w,isOptional:L,modifier:E})),U=!0}else if(["referencedby","references"].includes(M)){let F=["referencedby"].includes(M),k=new Set;for(let N of f)if(N)for(let D of te(r,N)){let K=F?ae(r,D):ie(r,D);for(let V of K)k.add(V.cardIdentifier)}c.push(Ve(k,{isAnd:y,isExcluded:w,isOptional:L,modifier:E})),U=!0}else if(["art","artist"].includes(M))h=f;else if(["print","prints","printing","printings"].includes(M))m=f;else if(["is","meta"].includes(M)){let F=[],k=[],N=[],D=[];for(let R of f)et.includes(R)?F.push(R):rt.includes(R)?k.push(R):tt.includes(R)?N.push(R):D.push(R);F.length>0&&(c.push({filterToPropertyMapping:Pe,values:[l.Meta.Reprint.toLowerCase().replaceAll(g,"")],isAnd:y,isOr:P,isExcluded:!w,isOptional:L}),U=D.length===0);let K=k.length>0;K&&c.push({filterToPropertyMapping:Ye,values:[i],isAnd:y,isOr:P,isExcluded:w,isOptional:L});let V=N.length>0;V&&c.push({filterToPropertyMapping:Ye,values:[i],isAnd:y,isOr:P,isExcluded:!w,isOptional:L}),(K||V)&&(U=D.length===0);let A=at(D);f=A.map(R=>R.toLowerCase().replaceAll(g,"")),A.includes(l.Meta.Expansion)&&!w&&(b=!0)}else["foiling","foil"].includes(M)?(p=st(f),f=p.map(F=>F.toLowerCase())):["treat","treatment","var","variation"].includes(M)?(W=ot(f),f=W.map(F=>F.toLowerCase())):["set","s"].includes(M)?(B=Qr(f,a),f=B.map(F=>F.toLowerCase().replaceAll(g,""))):["pitch","p","color"].includes(M)&&(f=Zr(f));let H=ke[M];H&&!U&&c.push({filterToPropertyMapping:H,values:H.hasMarkup?f.map(F=>j(F)):f,isAnd:y,isOr:P,modifier:E,isExcluded:w,isOptional:L})}}else if(S){let x=Q(S)?.card,d=he(S);x?u.push(`"${x.toLowerCase().replace(g,"")}"`):d&&d.length>0?c.push(...d):u.push(S.replace(g,""))}return{appliedFilters:c,attributes:{artists:h,foilings:p,isExpansionSlot:b,prints:m,rarities:v,releases:B,treatments:W},keywords:u}},Qr=(e,r=[])=>{let t=[];for(let a of e)t.push(...Xr(a,r));return t},Xr=(e,r=[])=>{let t=[],a=Object.values(l.Release).find(i=>i.toLowerCase().replaceAll(g,"")===e);if(a&&t.push(a),t.length===0){let i=l.setIdentifierToSetMappings[e];i&&t.push(i)}if(t.length===0){let i=Object.values(l.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(g,"")===e);i&&t.push(i)}return t},xe={purple:4,blue:3,yellow:2,red:1,white:0},Zr=e=>{let r=[];for(let t of e)xe[t]||xe[t]===0?r.push(xe[t].toString()):r.push(t);return r},et=["unique"],rt=["preview","spoiler","unreleased"],tt=["released"],it=()=>{let e=new Date,r=`${e.getMonth()+1}`.padStart(2,"0"),t=`${e.getDate()}`.padStart(2,"0");return`${e.getFullYear()}-${r}-${t}`},rr={dual:l.Meta.DualClass,exp:l.Meta.Expansion,expansion:l.Meta.Expansion,expansionSlot:l.Meta.Expansion,rainbow:l.Meta.Rainbow,reprint:l.Meta.Reprint,reprints:l.Meta.Reprint},at=e=>{let r=[];for(let t of e)rr[t]?r.push(rr[t]):l.Meta[t]&&r.push(l.Meta[t]);if(e.length>0&&r.length===0){for(let t of Object.values(l.Meta))for(let a of e)if(t.toLowerCase().includes(a)){r.push(t);break}}return r},tr={r:l.Foiling.Rainbow,rf:l.Foiling.Rainbow,rainbow:l.Foiling.Rainbow,c:l.Foiling.Cold,cf:l.Foiling.Cold,cold:l.Foiling.Cold,g:l.Foiling.Gold,gf:l.Foiling.Gold,gold:l.Foiling.Gold},st=e=>{let r=[];for(let t of e)tr[t]&&r.push(tr[t]);return r},ir={...Object.values(l.Treatment).reduce((e,r)=>(e[r.toLowerCase()]=r,e),{}),aa:l.Treatment.AA,alt:l.Treatment.AA,"alt art":l.Treatment.AA,ab:l.Treatment.AB,"alt border":l.Treatment.AB,at:l.Treatment.AT,"alt text":l.Treatment.AT,ea:l.Treatment.EA,extended:l.Treatment.EA,"extended art":l.Treatment.EA,fa:l.Treatment.FA,full:l.Treatment.FA,"full art":l.Treatment.FA},ot=e=>{let r=[];for(let t of e)ir[t]?r.push(ir[t]):l.Treatment[t.toUpperCase()]&&r.push(l.Treatment[t.toUpperCase()]);return r},we={b:l.Rarity.Basic,c:l.Rarity.Common,f:l.Rarity.Fabled,l:l.Rarity.Legendary,m:l.Rarity.Majestic,p:l.Rarity.Promo,r:l.Rarity.Rare,s:l.Rarity.SuperRare,t:l.Rarity.Token,v:l.Rarity.Marvel},nt=e=>{let r=[];for(let t of e)we[t]?r.push(we[t]):r.push(t);return r},lt=e=>{let r=[],t,a,i=nr.find(s=>e.includes(s));if(i){let[,s]=e.split(i);ar(s)?(t=!0,r.push(...s.trim().split("+").map(o=>o.replace(g,"")))):sr(s)?(a=!0,r.push(...s.trim().split(",").map(o=>o.replace(g,"")))):r.push(s.trim().replace(g,""))}else ar(e)?(t=!0,r.push(...e.trim().split("+").map(s=>s.replace(g,"")))):sr(e)?(a=!0,r.push(...e.trim().split(",").map(s=>s.replace(g,"")))):e.startsWith('"')&&e.endsWith('"')?r.push(e.trim().replaceAll('"',"").replace(g,"")):r.push(e.trim().replace(g,""));return{modifier:i,values:r,isAnd:t,isOr:a}},ct=e=>{let r=dt(e);if(r){let[,t]=e.split(r);return{filterKey:t,isExcluded:!0,isOptional:!1,isMeta:or(t)}}else return{filterKey:e,isExcluded:!1,isOptional:!1,isMeta:or(e)}},pt=e=>e.indexOf(":")>=0,ar=e=>e.indexOf("+")>=0,sr=e=>e.indexOf(",")>=0,or=e=>!!ke[e]?.isMeta,dt=e=>lr.find(r=>e.includes(r))?.slice(0,1);var C=require("@flesh-and-blood/types"),cr={artists:["Hoodwill"],cardIdentifier:"fangs-a-lot-blue",classes:[C.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:[C.Hero.Kayo,C.Hero.Levia,C.Hero.Rhinar],printings:[{artists:["Hoodwill"],identifier:"FNG000",image:"FNG000",print:"FNG000",rarity:C.Rarity.Rare,set:C.Release.Promos},{artists:["Hoodwill"],identifier:"FNG000",image:"FNG000_Marvel",print:`FNG000-${C.Treatment.FA}`,rarity:C.Rarity.Marvel,set:C.Release.Promos,treatment:C.Treatment.FA}],name:"Fangs A Lot",rarities:[C.Rarity.Rare,C.Rarity.Marvel],rarity:C.Rarity.Rare,sets:[C.Release.Promos],setIdentifiers:["FNG000"],specialImage:"FNG000_Marvel",subtypes:[C.Subtype.Attack],types:[C.Type.Action],typeText:"Generic Action - Attack"},pr=[{keyword:cr.name.toLowerCase(),card:cr}];var Re=class{constructor(r,t=[],a=[],i=!1){this.log=(r,...t)=>{this.debug&&console.log(r,...t)};this.search=(r,t)=>{let a,{appliedFilters:i,attributes:s,keywords:o}=Le(r,this.index,this.additionalHeroes,this.additionalSets),n=o.join(" "),c=t?pr.filter(d=>d.keyword===n):[];if(c.length>0?a=c.map(({card:d})=>d):o.length?a=this.fuse.search(n).map(d=>d.item):a=[...this.cards],i.length&&(a=a.filter(d=>d&&ur(d,i))),o.length===0){let d="";if(s.releases.length===1)try{let y=s.releases[0];d=le.setToSetIdentifierMappings[y][0].toUpperCase()}catch(y){console.error("Error getting set identifier from search",y)}if(!d&&s.prints.length===1)try{let y=s.prints[0];le.setIdentifierToSetMappings[y]&&(d=y.toUpperCase())}catch(y){console.error("Error getting set identifier from search",y)}d?a.sort((y,P)=>{let M=y.setIdentifiers.find(L=>L.includes(d))?.replace(d,""),w=P.setIdentifiers.find(L=>L.includes(d))?.replace(d,"");return M&&w?M.localeCompare(w):-1}):a.sort((y,P)=>y.name===P.name?`${y.pitch}`.localeCompare(`${P.pitch}`):y.name.localeCompare(P.name))}else{let d=[],E=[],f=o.map(y=>y.toLowerCase().replace(g,"")).join(" ");for(let y of a)y.name.toLowerCase().replace(g,"")===f?d.push(y):E.push(y);a=[...d,...E]}let h,{artists:u,isExpansionSlot:p,foilings:b,prints:m,rarities:v,releases:B,treatments:W}=s;(u.length>0||p||b.length>0||m.length>0||v.length>0||B.length>0||W.length>0)&&(h=a.map(d=>{let E=d.printings.filter(f=>{let y=!!f.image,P=u.length===0||u.some(k=>f.artists.find(N=>N.replace(g,"").toLowerCase().includes(k))),M=!p||p===f.isExpansionSlot,w=b.length===0||b.includes(f.foiling),L=m.length===0||m.some(k=>f.identifier.includes(k.toUpperCase())),pe=v.length===0||v.includes(f.rarity),U=B.length===0||B.includes(f.set),H=W.length===0||f.treatments?.some(k=>W.includes(k));return y&&P&&M&&w&&L&&pe&&U&&H});return{...d,matchingPrintings:E}}));let x=h?.length>0?h:a;return{appliedFilters:i,attributes:s,keywords:o,searchResults:x}};let s={getFn:(o,n)=>{let c=Be.default.config.getFn(o,n);if(c){if(Array.isArray(c))return c.map(h=>_(h.replace(g,"")));{let h=_(c).replace(g,"");return n.includes("functionalText")?j(h):h}}else return c},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};this.additionalHeroes=t,this.additionalSets=a,this.cards=[...r],this.debug=i,this.fuse=new Be.default([...r],s),this.index=Me(this.cards)}},dr=Re,ur=(e,r)=>{let t=!0,a=!1;for(let i of r){let s=i.isOptional,{isNumber:o,isString:n,isArray:c,isBoolean:h,isDate:u}=i.filterToPropertyMapping;if(o){let p=ut(e,i);s?p&&(a=!0):t=t&&p}else if(n){let p=ft(e,i);s?p&&(a=!0):t=t&&p}else if(c){let p=gt(e,i,r);s?p&&(a=!0):t=t&&p}else if(h){let p=ht(e,i);s?p&&(a=!0):t=t&&p}else if(u){let p=bt(e,i);s?p&&(a=!0):t=t&&p}}return t},ut=(e,r)=>{if(Y(r,e)){let{values:t,modifier:a,isExcluded:i,filterToPropertyMapping:{partialMatch:s}}=r,o=ce(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=mt(e,r)?.toLowerCase(),c=s?t?.some(h=>n?.includes(h)):t?.some(h=>n===h);return i?!c:c}}else return!0},ft=(e,r)=>{if(Y(r,e)){let{values:t,valuesSet:a,isAnd:i,isExcluded:s,filterToPropertyMapping:{hasMarkup:o,isNormalized:n,partialMatch:c}}=r,h=ce(e,r),u=n?h:h?.replaceAll(g,"").toLowerCase(),p=o&&u?j(u):u;if(c){let b=i?t?.every(m=>p?.includes(m)):t?.some(m=>p?.includes(m));return s?!b:b}else{let b;return i?b=t?.every(m=>p===m):a?b=a.has(p):b=t?.some(m=>p===m),s?!b:b}}else return!0},gt=(e,r,t)=>{if(Y(r,e)){let{values:a,isAnd:i,isExcluded:s,filterToPropertyMapping:{partialMatch:o}}=r,n=yt(e,r,t).map(c=>c?.replaceAll(g,""));if(o){let c=i?a.every(u=>n?.some(p=>p?.toLowerCase().includes(u))):a.some(u=>n?.some(p=>p?.toLowerCase().includes(u))),h=n.length===0;return s?!c||h:c}else{let c=i?a.every(h=>n?.some(u=>u?.toLowerCase()===h)):a.some(h=>n?.some(u=>u?.toLowerCase()===h));return s?!c:c}}else return!0},ht=(e,r)=>{if(Y(r,e)){let{isExcluded:t}=r,a=ce(e,r);return t?!a:a}else return!0},bt=(e,r)=>{if(Y(r,e)){let{values:t,isExcluded:a}=r,i=ce(e,r),s=t?.some(o=>i>o);return a?!s:s}else return!0},ce=(e,r)=>{let{filterToPropertyMapping:t}=r;return e[t.property]},yt=(e,r,t)=>{let{filterToPropertyMapping:{isNestedPropertyArray:a,nestedProperty:i,property:s}}=r,o=e[s]||[],n=[],c=Object.keys(e.legalOverrides||{}).length>0,h=r.filterToPropertyMapping.property==="legalHeroes",u=t.find(({filterToPropertyMapping:b})=>b.property==="legalFormats");if(c&&h&&!!u){let b=new Set;for(let{format:m,heroes:v}of e.legalOverrides||[])if(u.values.includes(m.toLowerCase()))for(let B of v)b.add(B);n=Array.from(b)}if(n.length===0)if(i){let b=new Set;for(let m of o)if(a){let v=m[i]||[];for(let B of v)b.add(B)}else{let v=m[i];v&&b.add(v)}n=Array.from(b)}else n=o;return n},mt=(e,r)=>{let{filterToPropertyMapping:t}=r;return e[t.specialProperty]},Y=({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()));0&&(module.exports={FilterProperty,MARKUP,PUNCTUATION,RARITY_VALUES_MAPPING,abbreviations,availableExclusions,availableModifiers,buildSearchIndex,filterCard,filtersToCardPropertyMappings,getAbbreviation,getAbbreviationByCard,getCardsByName,getCardsByReferencedCardIdentifier,getCardsReferencedBy,getCardsReferencing,getCleanText,getExcludedMetaFilters,getKeywordsAndAppliedFiltersFromText,getMetaFilters,getNormalizedText,getOtherPitches,getReferencedCards,getTextWithoutMarkup,getTokensReferencedByCards,multiWordShorthands,shorthands,singleWordShorthands});
package/dist/search.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  getKeywordsAndAppliedFiltersFromText
9
9
  } from "./filters.js";
10
10
  import { memes } from "./memes.js";
11
- import { getNormalizedText } from "./helpers.js";
11
+ import { getNormalizedText, getTextWithoutMarkup } from "./helpers.js";
12
12
  import { FilterProperty } from "./metaFilters.js";
13
13
  import { buildSearchIndex } from "./searchIndex.js";
14
14
  class Search {
@@ -145,7 +145,11 @@ class Search {
145
145
  (val) => getNormalizedText(val.replace(PUNCTUATION, ""))
146
146
  );
147
147
  } else {
148
- return getNormalizedText(value).replace(PUNCTUATION, "");
148
+ const text = getNormalizedText(value).replace(
149
+ PUNCTUATION,
150
+ ""
151
+ );
152
+ return path.includes("functionalText") ? getTextWithoutMarkup(text) : text;
149
153
  }
150
154
  },
151
155
  ignoreLocation: true,
@@ -305,10 +309,11 @@ const getDoesCardMatchStringFilter = (card, filter) => {
305
309
  valuesSet,
306
310
  isAnd,
307
311
  isExcluded: excluded,
308
- filterToPropertyMapping: { isNormalized, partialMatch }
312
+ filterToPropertyMapping: { hasMarkup, isNormalized, partialMatch }
309
313
  } = filter;
310
314
  const storedValue = getCardValue(card, filter);
311
- const cardValue = isNormalized ? storedValue : storedValue?.replaceAll(PUNCTUATION, "").toLowerCase();
315
+ const normalizedValue = isNormalized ? storedValue : storedValue?.replaceAll(PUNCTUATION, "").toLowerCase();
316
+ const cardValue = hasMarkup && normalizedValue ? getTextWithoutMarkup(normalizedValue) : normalizedValue;
312
317
  if (partialMatch) {
313
318
  const isPartialMatch = isAnd ? values?.every((filterValue) => cardValue?.includes(filterValue)) : values?.some((filterValue) => cardValue?.includes(filterValue));
314
319
  return excluded ? !isPartialMatch : isPartialMatch;
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": "4.2.1",
4
+ "version": "4.2.2",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "main": "dist/index.cjs",
@@ -46,7 +46,7 @@
46
46
  "@flesh-and-blood/types": "^4.0.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@flesh-and-blood/cards": "^4.2.1",
49
+ "@flesh-and-blood/cards": "^4.2.2",
50
50
  "@flesh-and-blood/types": "^4.1.1",
51
51
  "@types/jest": "^29.5.11",
52
52
  "@types/node": "^20.10.5",
@@ -77,5 +77,5 @@
77
77
  "FAB",
78
78
  "FABTCG"
79
79
  ],
80
- "gitHead": "fd0eb5e0a048b794a2e999ed563f15cbad5b80b2"
80
+ "gitHead": "0a0daec0b9384c6b78bb1cb35d04627ebf0243c3"
81
81
  }