@ianlucas/cs2-lib 7.28.0 → 7.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -66,6 +66,7 @@ interface CS2Item {
66
66
  statTrakless?: boolean | undefined;
67
67
  statTrakOnly?: boolean | undefined;
68
68
  stickerId?: number | undefined;
69
+ stickerIndex?: number | undefined;
69
70
  stickerSlots?: number | undefined;
70
71
  teams?: CS2ItemTeamValues | undefined;
71
72
  textureImage?: string | undefined;
@@ -78,6 +78,8 @@ declare class CS2EconomyItem implements Interface<Omit<CS2Item, "contents" | "sp
78
78
  specialsImage: string | undefined;
79
79
  statTrakless: boolean | undefined;
80
80
  statTrakOnly: boolean | undefined;
81
+ stickerId: number | undefined;
82
+ stickerIndex: number | undefined;
81
83
  stickerSlots: number | undefined;
82
84
  textureImage: string | undefined;
83
85
  tint: number | undefined;
@@ -101,6 +103,7 @@ declare class CS2EconomyItem implements Interface<Omit<CS2Item, "contents" | "sp
101
103
  get specials(): CS2EconomyItem[] | undefined;
102
104
  set teams(value: CS2ItemTeamValues);
103
105
  get teams(): CS2TeamValues[] | undefined;
106
+ get wrappedSticker(): CS2EconomyItem | undefined;
104
107
  isC4(): boolean;
105
108
  isPistol(): boolean;
106
109
  isSMG(): boolean;
package/dist/economy.mjs CHANGED
@@ -1 +1 @@
1
- import{CS2ContainerType as e,CS2ItemTeam as t,CS2ItemType as n,CS2ItemWear as r}from"./economy-types.mjs";import{assert as i,compare as a,ensure as o,safe as s}from"./utils.mjs";import{CS2_CONTAINER_ITEMS as c,CS2_DISPLAY_ITEMS as l,CS2_EQUIPMENT_ITEMS as u,CS2_GRAPHIC_ART_ITEMS as d,CS2_KEYCHAINABLE_ITEMS as f,CS2_MACHINEGUN_MODELS as p,CS2_MAX_FACTORY_NEW_WEAR as m,CS2_MAX_FIELD_TESTED_WEAR as h,CS2_MAX_KEYCHAIN_SEED as g,CS2_MAX_MINIMAL_WEAR_WEAR as _,CS2_MAX_SEED as v,CS2_MAX_WELL_WORN_WEAR as y,CS2_MIDTIER_CATEGORIES as b,CS2_MISC_CATEGORIES as x,CS2_NAMETAGGABLE_ITEMS as S,CS2_NAMETAG_RE as C,CS2_PAINTABLE_ITEMS as w,CS2_PATCHABLE_ITEMS as T,CS2_RIFLE_CATEGORIES as E,CS2_SEEDABLE_ITEMS as D,CS2_SNIPER_RIFLE_MODELS as O,CS2_STATTRAKABLE_ITEMS as k,CS2_STICKERABLE_ITEMS as A,CS2_TEAMS_BOTH as j,CS2_TEAMS_CT as M,CS2_TEAMS_T as N,CS2_WEAR_FACTOR as P}from"./economy-constants.mjs";import{CS2RarityColorName as F,CS2RarityColorOrder as I,CS2RaritySoundName as L,CS2_RARITY_ORDER as R,randomFloat as z,randomInt as B}from"./economy-container.mjs";function V(e){return function(t){return a(e.type,t.type)&&a(e.free,t.free)&&a(e.model,t.model)&&a(e.base,t.base)&&a(e.category,t.category)&&(e.team===void 0||t.teams===void 0||t.teams.includes(e.team))}}var H=class{baseUrl=`https://cdn.cstrike.app`;categories=new Set;items=new Map;itemsAsArray=[];stickers=new Set;use({assetsBaseUrl:e,items:t,language:n}){this.baseUrl=e??this.baseUrl,this.categories.clear(),this.items.clear(),this.stickers.clear(),this.itemsAsArray=[];for(let e of t){let t=new U(this,e,o(n[e.id]));this.items.set(e.id,t),t.isSticker()&&(this.stickers.add(t),this.categories.add(o(t.category))),this.itemsAsArray.push(t)}}getById(e){return o(this.items.get(e))}get(e){return typeof e==`number`?this.getById(e):e}findItem(e){return o(this.itemsAsArray.find(V(e)))}filterItems(e){let t=this.itemsAsArray.filter(V(e));return i(t.length>0),t}validateWear(e,t){return e===void 0?!0:(i(Number.isFinite(e)),i(String(e).length<=String(P).length),i(e>=0&&e<=1),t!==void 0&&(i(t.hasWear()),i(t.wearMin===void 0||e>=t.wearMin),i(t.wearMax===void 0||e<=t.wearMax)),!0)}safeValidateWear(e,t){return s(()=>this.validateWear(e,t))}validateSeed(e,t){return e===void 0?!0:(i(Number.isFinite(e)),i(Number.isInteger(e)),i(t===void 0||t.hasSeed()),i(e>=(t?.getMinimumSeed()??1)&&e<=(t?.getMaximumSeed()??1e3)),!0)}safeValidateSeed(e,t){return s(()=>this.validateSeed(e,t))}trimNametag(e){let t=e?.trim();return t===``?void 0:t}validateNametag(e,t){return e!==void 0&&(i(t===void 0||t.hasNametag()),i(e[0]!==` `&&C.test(e))),!0}safeValidateNametag(e,t){return s(()=>this.validateNametag(e,t))}requireNametag(e,t){return i(e===void 0||e.trim().length>0),this.validateNametag(e,t)}safeRequireNametag(e,t){return s(()=>this.requireNametag(e,t))}validateStatTrak(e,t){return e===void 0?!0:(i(t===void 0||t.hasStatTrak()),i(Number.isInteger(e)),i(e>=0&&e<=999999),!0)}safeValidateStatTrak(e,t){return s(()=>this.validateStatTrak(e,t))}getWearFromValue(e){switch(!0){case e<=m:return r.FactoryNew;case e<=_:return r.MinimalWear;case e<=h:return r.FieldTested;case e<=y:return r.WellWorn;default:return r.BattleScarred}}getStickerCategories(){return Array.from(this.categories).sort()}getStickers(){return Array.from(this.stickers)}validateContainerAndKey(e,t){return e=this.get(e),e.expectContainer(),t=t===void 0?void 0:this.get(t),t===void 0?i(e.keys===void 0):(t.expectKey(),i(e.keys!==void 0),i(e.keys.includes(t.id))),!0}safeValidateContainerAndKey(e,t){return s(()=>this.validateContainerAndKey(e,t))}validateUnlockedItem(e,{id:t}){e=this.get(e).expectContainer(),i(e.rawContents?.includes(t)||e.rawSpecials?.includes(t))}},U=class{altName;base;baseId;category;collection;collectionDesc;collectionImage;collectionName;containerType;def;desc;free;id=null;image;index;keys;legacy;legacyStickerSlots;model;modelBinary;name=null;rarity=null;specialsImage;statTrakless;statTrakOnly;stickerSlots;textureImage;tint;tournamentDesc;type=null;voFallback;voFemale;voPrefix;wearMax;wearMin;_contents;_specials;_teams;constructor(e,t,r){this.economy=e,this.item=t,this.language=r,Object.assign(this,t),Object.assign(this,r),i(typeof this.id==`number`),i(this.name),i(this.type),i(t.type===n.Stub||typeof this.rarity==`string`)}set contents(e){this._contents=e}get contents(){return this.expectContainer(),o(this._contents).map(e=>this.economy.get(e))}get parent(){return this.baseId===void 0?void 0:this.economy.items.has(this.baseId)?this.economy.get(this.baseId):void 0}get rawContents(){return this._contents}get rawSpecials(){return this._specials}set specials(e){this._specials=e}get specials(){return this.expectContainer(),this._specials?.map(e=>this.economy.get(e))}set teams(e){this._teams=e}get teams(){switch(this._teams){case t.Both:return j;case t.T:return N;case t.CT:return M;default:return}}isC4(){return this.category===`c4`}isPistol(){return this.category===`secondary`}isSMG(){return this.category===`smg`}isRifle(){return this.category===`rifle`}isSniperRifle(){return this.model!==void 0&&O.includes(this.model)}isMachinegun(){return this.model!==void 0&&p.includes(this.model)}isHeavy(){return this.category===`heavy`}isEquipment(){return this.category===`equipment`}isInMidTiers(){return this.category!==void 0&&b.includes(this.category)}isInRifles(){return this.category!==void 0&&E.includes(this.category)}isInMisc(){return this.category!==void 0&&x.includes(this.category)}isAgent(){return this.type===n.Agent}isCollectible(){return this.type===n.Collectible}isContainer(){return this.type===n.Container}isKey(){return this.type===n.Key}isGloves(){return this.type===n.Gloves}isGraffiti(){return this.type===n.Graffiti}isMelee(){return this.type===n.Melee}isMusicKit(){return this.type===n.MusicKit}isPatch(){return this.type===n.Patch}isSticker(){return this.type===n.Sticker}isKeychain(){return this.type===n.Keychain}isStub(){return this.type===n.Stub}isTool(){return this.type===n.Tool}isWeapon(){return this.type===n.Weapon}isStorageUnit(){return this.isTool()&&this.def===1201}isNameTag(){return this.isTool()&&this.def===1200}isStatTrakSwapTool(){return this.isTool()&&this.def===1324}isContract(){return this.isTool()&&this.def===62}expectAgent(){return i(this.isAgent()),this}expectPatch(){return i(this.isPatch()),this}expectSticker(){return i(this.isSticker()),this}expectKeychain(){return i(this.isKeychain()),this}expectStorageUnit(){return i(this.isStorageUnit()),this}expectNameTag(){return i(this.isNameTag()),this}expectStatTrakSwapTool(){return i(this.isStatTrakSwapTool()),this}expectContainer(){return i(this.isContainer()),this}expectKey(){return i(this.isKey()),this}hasWear(){return w.includes(this.type)&&!this.free&&this.index!==0}hasSeed(){return D.includes(this.type)&&!this.free&&this.index!==0}hasStickers(){return A.includes(this.type)&&!this.isC4()}hasKeychains(){return f.includes(this.type)&&!this.isC4()}hasPatches(){return T.includes(this.type)}hasNametag(){return S.includes(this.type)||this.isStorageUnit()}hasStatTrak(){return k.includes(this.type)&&!this.free}isWeaponCase(){return this.containerType===e.WeaponCase}isStickerCapsule(){return this.containerType===e.StickerCapsule}isGraffitiBox(){return this.containerType===e.GraffitiBox}isSouvenirCase(){return this.containerType===e.SouvenirCase}isInEquipments(){return u.includes(this.type)}isInGraphicArts(){return d.includes(this.type)}isInContainers(){return c.includes(this.type)}isInDisplay(){return l.includes(this.type)}isPaintable(){return w.includes(this.type)}getImage(e){if(i(this.image),this.hasWear()&&e!==void 0){let t=`${this.economy.baseUrl}${this.image}`;switch(!0){case e<1/3:return t.replace(`.webp`,`_light.webp`);case e<2/3:return t.replace(`.webp`,`_medium.webp`);default:return t.replace(`.webp`,`_heavy.webp`)}}return`${this.economy.baseUrl}${this.image}`}getCollectionImage(){return`${this.economy.baseUrl}${this.collectionImage}`}getSpecialsImage(){return this.expectContainer(),i(this.rawSpecials),i(this.specialsImage),`${this.economy.baseUrl}${this.specialsImage}`}getTextureImage(){return`${this.economy.baseUrl}${o(this.textureImage)}`}getModelBinary(){let{modelBinary:e}=this.parent??this;return`${this.economy.baseUrl}${o(e)}`}getMinimumWear(){return this.wearMin??0}getMaximumWear(){return this.wearMax??1}getMinimumSeed(){return this.isKeychain(),1}getMaximumSeed(){return this.isKeychain()?g:v}getStickerSlotCount(){return this.parent?.[this.legacy?`legacyStickerSlots`:`stickerSlots`]??5}groupContents(){let e={},t=this.specials;for(let t of this.contents){let n=F[t.rarity];e[n]||(e[n]=[]),e[n].push(t)}if(t!==void 0)for(let n of t){let t=`special`;e[t]||(e[t]=[]),e[t].push(n)}return e}listContents(e=!1){let t=this.specials;return[...this.contents,...!e&&t!==void 0?t:[]].sort((e,t)=>(I[e.rarity]??0)-(I[t.rarity]??0))}unlockContainer(e){let t=this.groupContents(),n=Object.keys(t),r=R.filter(e=>n.includes(e)),i=e?.computeOdds?.(r)??r.map((e,t)=>.8/5**t),a=i.reduce((e,t)=>e+t,0),s=r.map((e,t)=>[e,o(i[t])/a]),c=Math.random(),[l]=o(s[0]),u=0;for(let[e,t]of s)if(u+=t,c<=u){l=e;break}let d=o(t[l]),f=o(d[Math.floor(Math.random()*d.length)]),p=this.statTrakless!==!0,m=this.statTrakOnly===!0;return{attributes:{containerId:this.id,seed:f.hasSeed()?B(1,v):void 0,statTrak:p&&f.hasStatTrak()&&(m||Math.random()<=.1)?0:void 0,wear:f.hasWear()?Number(z(f.wearMin??0,f.wearMax??1).toString().substring(0,P.toString().length)):void 0},id:f.id,rarity:L[f.rarity],special:l===`special`}}};const W=new H;export{W as CS2Economy,H as CS2EconomyInstance,U as CS2EconomyItem};
1
+ import{CS2ContainerType as e,CS2ItemTeam as t,CS2ItemType as n,CS2ItemWear as r}from"./economy-types.mjs";import{assert as i,compare as a,ensure as o,safe as s}from"./utils.mjs";import{CS2_CONTAINER_ITEMS as c,CS2_DISPLAY_ITEMS as l,CS2_EQUIPMENT_ITEMS as u,CS2_GRAPHIC_ART_ITEMS as d,CS2_KEYCHAINABLE_ITEMS as f,CS2_MACHINEGUN_MODELS as p,CS2_MAX_FACTORY_NEW_WEAR as m,CS2_MAX_FIELD_TESTED_WEAR as h,CS2_MAX_KEYCHAIN_SEED as g,CS2_MAX_MINIMAL_WEAR_WEAR as _,CS2_MAX_SEED as v,CS2_MAX_WELL_WORN_WEAR as y,CS2_MIDTIER_CATEGORIES as b,CS2_MISC_CATEGORIES as x,CS2_NAMETAGGABLE_ITEMS as S,CS2_NAMETAG_RE as C,CS2_PAINTABLE_ITEMS as w,CS2_PATCHABLE_ITEMS as T,CS2_RIFLE_CATEGORIES as E,CS2_SEEDABLE_ITEMS as D,CS2_SNIPER_RIFLE_MODELS as O,CS2_STATTRAKABLE_ITEMS as k,CS2_STICKERABLE_ITEMS as A,CS2_TEAMS_BOTH as j,CS2_TEAMS_CT as M,CS2_TEAMS_T as N,CS2_WEAR_FACTOR as P}from"./economy-constants.mjs";import{CS2RarityColorName as F,CS2RarityColorOrder as I,CS2RaritySoundName as L,CS2_RARITY_ORDER as R,randomFloat as z,randomInt as B}from"./economy-container.mjs";function V(e){return function(t){return a(e.type,t.type)&&a(e.free,t.free)&&a(e.model,t.model)&&a(e.base,t.base)&&a(e.category,t.category)&&(e.team===void 0||t.teams===void 0||t.teams.includes(e.team))}}var H=class{baseUrl=`https://cdn.cstrike.app`;categories=new Set;items=new Map;itemsAsArray=[];stickers=new Set;use({assetsBaseUrl:e,items:t,language:n}){this.baseUrl=e??this.baseUrl,this.categories.clear(),this.items.clear(),this.stickers.clear(),this.itemsAsArray=[];for(let e of t){let t=new U(this,e,o(n[e.id]));this.items.set(e.id,t),t.isSticker()&&(this.stickers.add(t),this.categories.add(o(t.category))),this.itemsAsArray.push(t)}}getById(e){return o(this.items.get(e))}get(e){return typeof e==`number`?this.getById(e):e}findItem(e){return o(this.itemsAsArray.find(V(e)))}filterItems(e){let t=this.itemsAsArray.filter(V(e));return i(t.length>0),t}validateWear(e,t){return e===void 0?!0:(i(Number.isFinite(e)),i(String(e).length<=String(P).length),i(e>=0&&e<=1),t!==void 0&&(i(t.hasWear()),i(t.wearMin===void 0||e>=t.wearMin),i(t.wearMax===void 0||e<=t.wearMax)),!0)}safeValidateWear(e,t){return s(()=>this.validateWear(e,t))}validateSeed(e,t){return e===void 0?!0:(i(Number.isFinite(e)),i(Number.isInteger(e)),i(t===void 0||t.hasSeed()),i(e>=(t?.getMinimumSeed()??1)&&e<=(t?.getMaximumSeed()??1e3)),!0)}safeValidateSeed(e,t){return s(()=>this.validateSeed(e,t))}trimNametag(e){let t=e?.trim();return t===``?void 0:t}validateNametag(e,t){return e!==void 0&&(i(t===void 0||t.hasNametag()),i(e[0]!==` `&&C.test(e))),!0}safeValidateNametag(e,t){return s(()=>this.validateNametag(e,t))}requireNametag(e,t){return i(e===void 0||e.trim().length>0),this.validateNametag(e,t)}safeRequireNametag(e,t){return s(()=>this.requireNametag(e,t))}validateStatTrak(e,t){return e===void 0?!0:(i(t===void 0||t.hasStatTrak()),i(Number.isInteger(e)),i(e>=0&&e<=999999),!0)}safeValidateStatTrak(e,t){return s(()=>this.validateStatTrak(e,t))}getWearFromValue(e){switch(!0){case e<=m:return r.FactoryNew;case e<=_:return r.MinimalWear;case e<=h:return r.FieldTested;case e<=y:return r.WellWorn;default:return r.BattleScarred}}getStickerCategories(){return Array.from(this.categories).sort()}getStickers(){return Array.from(this.stickers)}validateContainerAndKey(e,t){return e=this.get(e),e.expectContainer(),t=t===void 0?void 0:this.get(t),t===void 0?i(e.keys===void 0):(t.expectKey(),i(e.keys!==void 0),i(e.keys.includes(t.id))),!0}safeValidateContainerAndKey(e,t){return s(()=>this.validateContainerAndKey(e,t))}validateUnlockedItem(e,{id:t}){e=this.get(e).expectContainer(),i(e.rawContents?.includes(t)||e.rawSpecials?.includes(t))}},U=class{altName;base;baseId;category;collection;collectionDesc;collectionImage;collectionName;containerType;def;desc;free;id=null;image;index;keys;legacy;legacyStickerSlots;model;modelBinary;name=null;rarity=null;specialsImage;statTrakless;statTrakOnly;stickerId;stickerIndex;stickerSlots;textureImage;tint;tournamentDesc;type=null;voFallback;voFemale;voPrefix;wearMax;wearMin;_contents;_specials;_teams;constructor(e,t,r){this.economy=e,this.item=t,this.language=r,Object.assign(this,t),Object.assign(this,r),i(typeof this.id==`number`),i(this.name),i(this.type),i(t.type===n.Stub||typeof this.rarity==`string`)}set contents(e){this._contents=e}get contents(){return this.expectContainer(),o(this._contents).map(e=>this.economy.get(e))}get parent(){return this.baseId===void 0?void 0:this.economy.items.has(this.baseId)?this.economy.get(this.baseId):void 0}get rawContents(){return this._contents}get rawSpecials(){return this._specials}set specials(e){this._specials=e}get specials(){return this.expectContainer(),this._specials?.map(e=>this.economy.get(e))}set teams(e){this._teams=e}get teams(){switch(this._teams){case t.Both:return j;case t.T:return N;case t.CT:return M;default:return}}get wrappedSticker(){return this.stickerId===void 0?void 0:this.economy.get(this.stickerId)}isC4(){return this.category===`c4`}isPistol(){return this.category===`secondary`}isSMG(){return this.category===`smg`}isRifle(){return this.category===`rifle`}isSniperRifle(){return this.model!==void 0&&O.includes(this.model)}isMachinegun(){return this.model!==void 0&&p.includes(this.model)}isHeavy(){return this.category===`heavy`}isEquipment(){return this.category===`equipment`}isInMidTiers(){return this.category!==void 0&&b.includes(this.category)}isInRifles(){return this.category!==void 0&&E.includes(this.category)}isInMisc(){return this.category!==void 0&&x.includes(this.category)}isAgent(){return this.type===n.Agent}isCollectible(){return this.type===n.Collectible}isContainer(){return this.type===n.Container}isKey(){return this.type===n.Key}isGloves(){return this.type===n.Gloves}isGraffiti(){return this.type===n.Graffiti}isMelee(){return this.type===n.Melee}isMusicKit(){return this.type===n.MusicKit}isPatch(){return this.type===n.Patch}isSticker(){return this.type===n.Sticker}isKeychain(){return this.type===n.Keychain}isStub(){return this.type===n.Stub}isTool(){return this.type===n.Tool}isWeapon(){return this.type===n.Weapon}isStorageUnit(){return this.isTool()&&this.def===1201}isNameTag(){return this.isTool()&&this.def===1200}isStatTrakSwapTool(){return this.isTool()&&this.def===1324}isContract(){return this.isTool()&&this.def===62}expectAgent(){return i(this.isAgent()),this}expectPatch(){return i(this.isPatch()),this}expectSticker(){return i(this.isSticker()),this}expectKeychain(){return i(this.isKeychain()),this}expectStorageUnit(){return i(this.isStorageUnit()),this}expectNameTag(){return i(this.isNameTag()),this}expectStatTrakSwapTool(){return i(this.isStatTrakSwapTool()),this}expectContainer(){return i(this.isContainer()),this}expectKey(){return i(this.isKey()),this}hasWear(){return w.includes(this.type)&&!this.free&&this.index!==0}hasSeed(){return D.includes(this.type)&&!this.free&&this.index!==0}hasStickers(){return A.includes(this.type)&&!this.isC4()}hasKeychains(){return f.includes(this.type)&&!this.isC4()}hasPatches(){return T.includes(this.type)}hasNametag(){return S.includes(this.type)||this.isStorageUnit()}hasStatTrak(){return k.includes(this.type)&&!this.free}isWeaponCase(){return this.containerType===e.WeaponCase}isStickerCapsule(){return this.containerType===e.StickerCapsule}isGraffitiBox(){return this.containerType===e.GraffitiBox}isSouvenirCase(){return this.containerType===e.SouvenirCase}isInEquipments(){return u.includes(this.type)}isInGraphicArts(){return d.includes(this.type)}isInContainers(){return c.includes(this.type)}isInDisplay(){return l.includes(this.type)}isPaintable(){return w.includes(this.type)}getImage(e){if(i(this.image),this.hasWear()&&e!==void 0){let t=`${this.economy.baseUrl}${this.image}`;switch(!0){case e<1/3:return t.replace(`.webp`,`_light.webp`);case e<2/3:return t.replace(`.webp`,`_medium.webp`);default:return t.replace(`.webp`,`_heavy.webp`)}}return`${this.economy.baseUrl}${this.image}`}getCollectionImage(){return`${this.economy.baseUrl}${this.collectionImage}`}getSpecialsImage(){return this.expectContainer(),i(this.rawSpecials),i(this.specialsImage),`${this.economy.baseUrl}${this.specialsImage}`}getTextureImage(){return`${this.economy.baseUrl}${o(this.textureImage)}`}getModelBinary(){let{modelBinary:e}=this.parent??this;return`${this.economy.baseUrl}${o(e)}`}getMinimumWear(){return this.wearMin??0}getMaximumWear(){return this.wearMax??1}getMinimumSeed(){return this.isKeychain(),1}getMaximumSeed(){return this.isKeychain()?g:v}getStickerSlotCount(){return this.parent?.[this.legacy?`legacyStickerSlots`:`stickerSlots`]??5}groupContents(){let e={},t=this.specials;for(let t of this.contents){let n=F[t.rarity];e[n]||(e[n]=[]),e[n].push(t)}if(t!==void 0)for(let n of t){let t=`special`;e[t]||(e[t]=[]),e[t].push(n)}return e}listContents(e=!1){let t=this.specials;return[...this.contents,...!e&&t!==void 0?t:[]].sort((e,t)=>(I[e.rarity]??0)-(I[t.rarity]??0))}unlockContainer(e){let t=this.groupContents(),n=Object.keys(t),r=R.filter(e=>n.includes(e)),i=e?.computeOdds?.(r)??r.map((e,t)=>.8/5**t),a=i.reduce((e,t)=>e+t,0),s=r.map((e,t)=>[e,o(i[t])/a]),c=Math.random(),[l]=o(s[0]),u=0;for(let[e,t]of s)if(u+=t,c<=u){l=e;break}let d=o(t[l]),f=o(d[Math.floor(Math.random()*d.length)]),p=this.statTrakless!==!0,m=this.statTrakOnly===!0;return{attributes:{containerId:this.id,seed:f.hasSeed()?B(1,v):void 0,statTrak:p&&f.hasStatTrak()&&(m||Math.random()<=.1)?0:void 0,wear:f.hasWear()?Number(z(f.wearMin??0,f.wearMax??1).toString().substring(0,P.toString().length)):void 0},id:f.id,rarity:L[f.rarity],special:l===`special`}}};const W=new H;export{W as CS2Economy,H as CS2EconomyInstance,U as CS2EconomyItem};