{"version":3,"file":"comp-builder-BQCDZdOO.mjs","names":[],"sources":["../src/module/models/bits/action.ts","../src/module/models/bits/bonus.ts","../src/module/models/bits/synergy.ts","../src/module/models/bits/counter.ts","../src/module/models/actors/shared.ts","../src/module/models/actors/deployable.ts","../src/module/models/items/shared.ts","../src/module/models/items/pilot_armor.ts","../src/module/models/items/pilot_weapon.ts","../src/module/models/items/pilot_gear.ts","../src/module/models/items/core_bonus.ts","../src/module/models/items/skill.ts","../src/module/models/items/talent.ts","../src/module/models/bits/question.ts","../src/module/models/items/bond.ts","../src/module/models/items/license.ts","../src/module/models/bits/ammo.ts","../src/module/models/items/mech_system.ts","../src/module/models/items/mech_weapon.ts","../src/module/models/items/weapon_mod.ts","../src/module/models/items/reserve.ts","../src/module/models/items/frame.ts","../src/module/models/items/npc_class.ts","../src/module/models/items/npc_template.ts","../src/module/models/items/npc_feature.ts","../src/module/models/items/status.ts","../src/module/models/actors/npc.ts","../src/module/comp-builder.ts"],"sourcesContent":["import { ActivationType, ActivePeriod } from \"../../enums\";\nimport type { PackedActionData } from \"../../util/unpacking/packed-types\";\nimport { LIDField } from \"../shared\";\nimport { DamageField, unpackDamage } from \"./damage\";\nimport { RangeField, unpackRange } from \"./range\";\nimport type { SimpleMerge } from \"fvtt-types/utils\";\n\nimport fields = foundry.data.fields;\n\nconst frequencyFieldDefaults = {\n  required: true,\n  blank: false,\n  nullable: true,\n  initial: null,\n  readonly: true,\n  validationError: \"is not a properly formatted frequency\",\n};\n\ntype FrequencyFieldDefaults = SimpleMerge<fields.StringField.DefaultOptions, typeof frequencyFieldDefaults>;\ntype ApplyFrequencyDefaults<T extends fields.StringField.Options> = SimpleMerge<FrequencyFieldDefaults, T>;\n\n/**\n * A subclass of StringField which deals with frequency data.\n */\nclass FrequencyField<Options extends fields.StringField.Options = FrequencyFieldDefaults> extends fields.StringField<\n  ApplyFrequencyDefaults<Options>\n> {\n  /** @inheritdoc */\n  static get _defaults() {\n    return foundry.utils.mergeObject(super._defaults, frequencyFieldDefaults);\n  }\n\n  /** @override */\n  _validateType(value: unknown) {\n    if (typeof value == \"string\") {\n      FrequencyField.ParseField(value);\n    } else if (value != null) {\n      throw new Error();\n    }\n  }\n\n  static ParseField(freq: string): { uses: number; interval: ActivePeriod } | { interval: \"Unlimited\" } {\n    freq = freq.trim();\n    if (freq == \"Unlimited\") {\n      return { interval: \"Unlimited\" };\n    }\n\n    let match = freq.match(/(\\d)+\\s*\\/\\s*(.*)/);\n    if (!match) {\n      throw new Error(\n        `Frequency must be of a format alike \"X / [${Object.values(ActivePeriod).join(\n          \" | \"\n        )}]. Illegal option: \"${freq}\"`\n      );\n    }\n    let uses = Number.parseInt(match[1]);\n    let interval = match[2] as ActivePeriod;\n    // Force capitalize interval first char\n    interval = (interval[0].toUpperCase() + interval.substring(1)) as ActivePeriod;\n    if (!Object.keys(ActivePeriod).includes(interval)) {\n      throw new Error(\n        `Frequency interval must one of [${Object.values(ActivePeriod).join(\" | \")}]. Illegal option: \"${interval}\"`\n      );\n    } else if (uses < 1) {\n      throw new Error(`Frequency use count must be a positive integer. Illegal option: ${uses}`);\n    } else {\n      return { uses, interval };\n    }\n  }\n}\n\nconst getActionFieldSchema = () => {\n  return {\n    lid: new LIDField(),\n    name: new fields.StringField(),\n    activation: new fields.StringField({ choices: Object.values(ActivationType), initial: ActivationType.Quick }),\n    cost: new fields.NumberField({ min: 0, integer: true, nullable: false }),\n    frequency: new FrequencyField(),\n    init: new fields.HTMLField(),\n    trigger: new fields.HTMLField(),\n    terse: new fields.HTMLField(),\n    detail: new fields.HTMLField(),\n    pilot: new fields.BooleanField(),\n    mech: new fields.BooleanField(),\n    tech_attack: new fields.BooleanField(),\n    // confirm: new fields.StringField(),\n    // available_mounted: new fields.BooleanField(),\n    heat_cost: new fields.NumberField({ min: 0, integer: true, nullable: false }),\n    // TODO: synergy_locations: make em more fancy or somethin\n    synergy_locations: new fields.ArrayField(new fields.StringField({ required: true })),\n    damage: new fields.ArrayField(new DamageField()),\n    range: new fields.ArrayField(new RangeField()),\n    // ignore_used?\n    // log: new fields.StringField(),\n  };\n};\n\ntype ActionFieldSchema = ReturnType<typeof getActionFieldSchema>;\n\nexport type ActionData = fields.SchemaField.InitializedData<ActionFieldSchema>;\n\n// Action field is frequent, but not exactly deserving of a custom class like damage or range. It still needs a custom field (frequency)\nexport class ActionField<Options extends fields.SchemaField.Options<ActionFieldSchema>> extends fields.SchemaField<\n  ActionFieldSchema,\n  Options\n> {\n  constructor(options?: Options) {\n    super(getActionFieldSchema(), options);\n  }\n}\n\n// Converts an lcp action into our expected format\nexport function unpackAction(data: PackedActionData): ActionData {\n  let activation = repairActivationType(data.activation ?? ActivationType.Quick);\n  return {\n    activation,\n    cost: data.cost ?? 0,\n    damage: data.damage?.map(unpackDamage) ?? [],\n    detail: data.detail ?? \"\",\n    frequency: data.frequency ?? \"\",\n    heat_cost: data.heat_cost ?? 0,\n    init: data.init ?? \"\",\n    lid: data.id ?? \"\",\n    mech: data.mech ?? true,\n    name: data.name ?? \"Action\",\n    pilot: data.pilot ?? false,\n    range: data.range?.map(unpackRange) ?? [],\n    synergy_locations: data.synergy_locations ?? [],\n    terse: data.terse ?? \"\",\n    trigger: data.trigger ?? \"\",\n    tech_attack: data.tech_attack ?? false,\n  };\n}\n\nexport function repairActivationType(activation: string): ActivationType {\n  for (const value of Object.values(ActivationType)) {\n    if (value === activation) {\n      return value;\n    }\n  }\n  // It didn't match a standard action type string, so try some common alternates\n  if (activation.toLowerCase() === \"full action\") {\n    return ActivationType.Full;\n  } else if (activation.toLowerCase() === \"quick action\") {\n    return ActivationType.Quick;\n  } else if (activation.toLowerCase() === \"free action\") {\n    return ActivationType.Free;\n  }\n  // Still couldn't match an action type, so default to quick.\n  return ActivationType.Quick;\n}\n","import {\n  type DamageTypeChecklist,\n  makeWeaponSizeChecklist,\n  makeWeaponTypeChecklist,\n  type RangeTypeChecklist,\n  type WeaponSizeChecklist,\n  type WeaponTypeChecklist,\n} from \"../../enums\";\nimport { BONUS } from \"../../util/unpacking/defaults\";\nimport type { PackedBonusData } from \"../../util/unpacking/packed-types\";\nimport {\n  DamageTypeChecklistField,\n  RangeTypeChecklistField,\n  WeaponSizeChecklistField,\n  WeaponTypeChecklistField,\n} from \"../shared\";\nimport { Damage } from \"./damage\";\nimport { Range } from \"./range\";\n\nimport fields = foundry.data.fields;\n\nconst defineBonusFieldSchema = () => {\n  return {\n    lid: new fields.StringField({ nullable: false }), // Don't really want an LID field here\n    val: new fields.StringField({ nullable: false }),\n    overwrite: new fields.BooleanField(),\n    replace: new fields.BooleanField(),\n    damage_types: new DamageTypeChecklistField(),\n    range_types: new RangeTypeChecklistField(),\n    weapon_types: new WeaponTypeChecklistField(),\n    weapon_sizes: new WeaponSizeChecklistField(),\n  };\n};\n\ntype BonusFieldSchema = ReturnType<typeof defineBonusFieldSchema>;\n\nexport type BonusData = fields.SchemaField.InitializedData<BonusFieldSchema>;\n\nexport class BonusField<Options extends fields.SchemaField.Options<BonusFieldSchema>> extends fields.SchemaField<\n  BonusFieldSchema,\n  Options\n> {\n  constructor(options?: Options) {\n    super(defineBonusFieldSchema(), options);\n  }\n}\n\n// Just a more convenient constructor\nexport function generateBonus(\n  lid: string,\n  val: string | number,\n  replace: boolean = false,\n  overwrite: boolean = false\n): BonusData {\n  return {\n    ...BONUS(),\n    lid,\n    val: \"\" + val,\n    replace,\n    overwrite,\n  };\n}\n\n// Converts an lcp bonus into our expected format\nexport function unpackBonus(data: PackedBonusData): BonusData {\n  return {\n    lid: data.id,\n    val: data.val?.toString() ?? \"\",\n    damage_types: data.damage_types ? Damage.MakeChecklist(data.damage_types) : null,\n    range_types: data.range_types ? Range.MakeChecklist(data.range_types) : null,\n    weapon_sizes: data.weapon_sizes ? makeWeaponSizeChecklist(data.weapon_sizes) : null,\n    weapon_types: data.weapon_types ? makeWeaponTypeChecklist(data.weapon_types) : null,\n    overwrite: data.overwrite ?? false,\n    replace: data.replace ?? false,\n  };\n}\n","import {\n  AllSynergyLocations,\n  makeSystemTypeChecklist,\n  makeWeaponSizeChecklist,\n  makeWeaponTypeChecklist,\n  type SynergyLocation,\n  SystemType,\n  type SystemTypeChecklist,\n  WeaponSize,\n  type WeaponSizeChecklist,\n  WeaponType,\n  type WeaponTypeChecklist,\n} from \"../../enums\";\nimport type { PackedSynergyData } from \"../../util/unpacking/packed-types\";\nimport {\n  DamageTypeChecklistField,\n  RangeTypeChecklistField,\n  SystemTypeChecklistField,\n  WeaponSizeChecklistField,\n  WeaponTypeChecklistField,\n} from \"../shared\";\n\nimport fields = foundry.data.fields;\n\nconst defineSynergyFieldSchema = () => {\n  return {\n    locations: new fields.ArrayField(new fields.StringField({ choices: AllSynergyLocations, initial: \"any\" })),\n    detail: new fields.StringField({ nullable: false }),\n    damage_types: new DamageTypeChecklistField(),\n    range_types: new RangeTypeChecklistField(),\n    weapon_types: new WeaponTypeChecklistField(),\n    weapon_sizes: new WeaponSizeChecklistField(),\n    system_types: new SystemTypeChecklistField(),\n  };\n};\n\ntype SynergyFieldSchema = ReturnType<typeof defineSynergyFieldSchema>;\n\nexport type SynergyData = fields.SchemaField.InitializedData<SynergyFieldSchema>;\n\nexport class SynergyField<Options extends fields.SchemaField.Options<SynergyFieldSchema>> extends fields.SchemaField<\n  SynergyFieldSchema,\n  Options\n> {\n  constructor(options?: Options) {\n    super(defineSynergyFieldSchema(), options);\n  }\n\n  migrateSource(sourceData: any, fieldData: any) {\n    // In some old imports we never properly separated synergy locations\n    if (fieldData.locations?.some((s: string) => s.includes(\",\"))) {\n      fieldData.locations = fieldData.locations.flatMap((s: string) => s.split(\",\").map(s2 => s2.trim()));\n    }\n    // Ensure all lowercase\n    if (fieldData.locations) {\n      fieldData.locations = fieldData.locations.map((l: string) => l.toLowerCase());\n    }\n\n    return super.migrateSource(sourceData, fieldData);\n  }\n}\n\nexport function unpackSynergy(data: PackedSynergyData) {\n  // Have to do a lot of annoying fixup\n  let raw_locations = data.locations ?? [];\n  if (!Array.isArray(raw_locations)) raw_locations = [raw_locations];\n  let locations = raw_locations.flatMap(base => {\n    let l = base.toLowerCase().trim();\n    if (l.includes(\",\")) return l.split(\",\").map(sub_l => sub_l.trim());\n    return l;\n  }) as SynergyLocation[];\n\n  let sizes: WeaponSizeChecklist | null = null;\n  if (data.weapon_sizes) {\n    let x = data.weapon_sizes;\n    if (!Array.isArray(x)) {\n      x = [x];\n    }\n    if (x.includes(\"any\")) {\n      x = [WeaponSize.Aux, WeaponSize.Heavy, WeaponSize.Main, WeaponSize.Superheavy];\n    }\n    sizes = makeWeaponSizeChecklist(x as WeaponSize[]);\n  }\n\n  let types: WeaponTypeChecklist | null = null;\n  if (data.weapon_types) {\n    let x = data.weapon_types;\n    if (!Array.isArray(x)) {\n      x = [x];\n    }\n    if (x.includes(\"any\")) {\n      x = [\n        WeaponType.CQB,\n        WeaponType.Cannon,\n        WeaponType.Launcher,\n        WeaponType.Melee,\n        WeaponType.Nexus,\n        WeaponType.Rifle,\n      ];\n    }\n    types = makeWeaponTypeChecklist(x as WeaponType[]);\n  }\n\n  let systems: SystemTypeChecklist | null = null;\n  if (data.system_types) {\n    let x = data.system_types;\n    if (!Array.isArray(x)) {\n      x = [x];\n    }\n    if (x.includes(\"any\")) {\n      x = [\n        SystemType.AI,\n        SystemType.Armor,\n        SystemType.Deployable,\n        SystemType.Drone,\n        SystemType.FlightSystem,\n        SystemType.Integrated,\n        SystemType.Mod,\n        SystemType.Shield,\n        SystemType.System,\n        SystemType.Tech,\n      ];\n    }\n    systems = makeSystemTypeChecklist(x as SystemType[]);\n  }\n\n  return {\n    detail: data.detail,\n    locations,\n    damage_types: null,\n    range_types: null,\n    weapon_sizes: sizes,\n    weapon_types: types,\n    system_types: systems,\n  };\n}\n","import type { PackedCounterData } from \"../../util/unpacking/packed-types\";\nimport { LIDField } from \"../shared\";\n\nimport fields = foundry.data.fields;\n\nexport type CounterData = fields.SchemaField.InitializedData<CounterFieldSchema>;\n\nconst defineCounterFieldSchema = () => {\n  return {\n    lid: new LIDField(),\n    name: new fields.StringField(),\n    min: new fields.NumberField({ integer: true, nullable: false, initial: 0 }),\n    max: new fields.NumberField({ integer: true, nullable: true, initial: 6 }),\n    default_value: new fields.NumberField({ integer: true, nullable: false, initial: 0 }),\n    value: new fields.NumberField({ integer: true, nullable: false, initial: 0 }),\n  };\n};\n\ntype CounterFieldSchema = ReturnType<typeof defineCounterFieldSchema>;\n\n// A single <type, value> pairing for damage. mimics RegCounterData\nexport class CounterField<Options extends fields.SchemaField.Options<CounterFieldSchema>> extends fields.SchemaField<\n  CounterFieldSchema,\n  Options\n> {\n  constructor(options?: Options) {\n    super(defineCounterFieldSchema(), options);\n  }\n\n  static migrateData(value: any) {\n    value.value = value.value ?? value.val;\n    super.migrateData(value);\n  }\n\n  static bound_val(value: CounterData, sub_val: number) {\n    sub_val = Math.round(sub_val);\n    sub_val = Math.max(sub_val, value.min);\n    if (value.max !== null) sub_val = Math.min(sub_val, value.max);\n    return sub_val;\n  }\n\n  /** @inheritdoc */\n  clean(value: fields.SchemaField.AssignmentData<CounterFieldSchema>, options: any) {\n    // Attempt to move our .val back in bounds\n    const cleaned = super.clean(value, options);\n    if (cleaned == null) {\n      return cleaned;\n    }\n\n    cleaned.initialized = CounterField.bound_val(cleaned, cleaned.initialized || 0);\n    cleaned.default_value = CounterField.bound_val(cleaned, cleaned.default_value || 0);\n    return cleaned;\n  }\n\n  /** @override */\n  _validateType(value: CounterData) {\n    if (value.max != null && value.min != null && value.max < value.min) throw new Error(\"max must be > min\");\n  }\n}\n\n// Converts an lcp counter entry into our expected format\nexport function unpackCounter(data: PackedCounterData): CounterData {\n  let default_value = data.default_value ?? data.min ?? 0;\n  return {\n    default_value,\n    value: default_value,\n    lid: data.id,\n    max: data.max ?? 6,\n    min: data.min ?? 0,\n    name: data.name,\n  };\n}\n","import { CounterField } from \"../bits/counter\";\nimport { FullBoundedNumberField, LIDField } from \"../shared\";\nconst fields: any = foundry.data.fields;\n\n// We implement our templates here\nexport function template_universal_actor() {\n  return {\n    lid: new LIDField(),\n    burn: new fields.NumberField({ min: 0, integer: true, nullable: false, initial: 0 }),\n    activations: new fields.NumberField({ min: 0, integer: true, nullable: false, initial: 1 }),\n    custom_counters: new fields.ArrayField(new CounterField()),\n\n    hp: new FullBoundedNumberField({ initialValue: 10, max: 10 }),\n    overshield: new FullBoundedNumberField({ initialValue: 0, max: 14 }),\n    inherited_effects: new fields.SchemaField(\n      {\n        from_uuid: new fields.StringField(),\n        data: new fields.ArrayField(new fields.ObjectField()),\n        visible: new fields.BooleanField(),\n      },\n      { nullable: true, initial: null }\n    ),\n\n    // Our derived property melange - not actually here! We generate those in prepareData\n  };\n}\n\nexport function template_action_tracking() {\n  return {\n    action_tracker: new fields.SchemaField({\n      protocol: new fields.BooleanField(),\n      move: new fields.NumberField({ min: 0, integer: true, nullable: false, initial: 0 }),\n      full: new fields.BooleanField(),\n      quick: new fields.BooleanField(),\n      reaction: new fields.BooleanField(),\n      free: new fields.BooleanField(),\n      used_reactions: new fields.ArrayField(new fields.StringField({ nullable: false })), // lids\n    }),\n  };\n}\n\nexport function template_heat() {\n  return {\n    heat: new FullBoundedNumberField({ initialValue: 0, max: 6 }),\n  };\n}\n\nexport function template_struss() {\n  return {\n    stress: new FullBoundedNumberField({ initialValue: 0, max: 1 }),\n    structure: new FullBoundedNumberField({ initialValue: 0, max: 1 }),\n  };\n}\n\nexport function template_statuses() {\n  // Empty by design - these are all derived, so we don't want to track them\n  return {};\n}\n","import { template_heat, template_statuses, template_universal_actor } from \"./shared\";\n\nimport type { DeepPartial } from \"fvtt-types/utils\";\nimport { ActivationType, DeployableType, EntryType } from \"../../enums\";\nimport { restrict_enum } from \"../../helpers/commons\";\nimport type { SourceData } from \"../../source-template\";\nimport type { BaseData } from \"../../base-data\";\nimport { slugify } from \"../../util/lid\";\nimport { fixCCFormula } from \"../../util/misc\";\nimport type { PackedDeployableData } from \"../../util/unpacking/packed-types\";\nimport { ActionField, unpackAction } from \"../bits/action\";\nimport { unpackBonus } from \"../bits/bonus\";\nimport { CounterField, unpackCounter } from \"../bits/counter\";\nimport { SynergyField, unpackSynergy } from \"../bits/synergy\";\nimport { TagField, unpackTag } from \"../bits/tag\";\nimport { LancerDataModel, SyncUUIDRefField, type UnpackContext } from \"../shared\";\n\nimport fields = foundry.data.fields;\n\nconst defineDeployableSchema = () => ({\n  actions: new fields.ArrayField(new ActionField()),\n  // bonuses: new fields.ArrayField(new BonusField()),\n  counters: new fields.ArrayField(new CounterField()),\n  synergies: new fields.ArrayField(new SynergyField()),\n  tags: new fields.ArrayField(new TagField()),\n  activation: new fields.StringField({ choices: Object.values(ActivationType), initial: ActivationType.Quick }),\n  stats: new fields.SchemaField({\n    armor: new fields.NumberField({ min: 0, integer: true, nullable: false, initial: 0 }),\n    edef: new fields.NumberField({ min: 0, integer: true, nullable: false, initial: 10 }),\n    evasion: new fields.NumberField({ min: 0, integer: true, nullable: false, initial: 10 }),\n    heatcap: new fields.NumberField({ min: 0, integer: true, nullable: false, initial: 0 }),\n    hp: new fields.StringField({ initial: \"5\" }),\n    save: new fields.NumberField({ min: 0, integer: true, nullable: false, initial: 10 }),\n    size: new fields.NumberField({ min: 0.5, integer: false, nullable: false, initial: 0.5 }),\n    speed: new fields.NumberField({ min: 0, integer: true, nullable: false, initial: 0 }),\n  }),\n  cost: new fields.NumberField({ min: 0, integer: true, nullable: false, initial: 1 }),\n  instances: new fields.NumberField({ min: 1, integer: true, nullable: false, initial: 1 }),\n  deactivation: new fields.StringField({ choices: Object.values(ActivationType), initial: null, nullable: true }),\n  detail: new fields.HTMLField(),\n  recall: new fields.StringField({ choices: Object.values(ActivationType), initial: null, nullable: true }),\n  redeploy: new fields.StringField({ choices: Object.values(ActivationType), initial: null, nullable: true }),\n\n  type: new fields.StringField({ choices: Object.values(DeployableType), initial: DeployableType.Deployable }),\n  avail_mounted: new fields.BooleanField({ initial: true }),\n  avail_unmounted: new fields.BooleanField({ initial: false }),\n  deployer: new SyncUUIDRefField(\"Actor\", { allowed_types: [EntryType.MECH, EntryType.PILOT, EntryType.NPC] }),\n  owner: new SyncUUIDRefField(\"Actor\", { allowed_types: [EntryType.MECH, EntryType.PILOT, EntryType.NPC] }),\n  // destroyed: new fields.BooleanField({ initial: false }),\n  // notes: new fields.HTMLField(),\n\n  // destroyed: new fields.BooleanField({ initial: false }),\n  ...template_universal_actor(),\n  ...template_heat(),\n  ...template_statuses(),\n});\n\ntype DeployableSchema = ReturnType<typeof defineDeployableSchema>;\nexport class DeployableModel extends LancerDataModel<DeployableSchema, Actor.Implementation, BaseData.Deployable> {\n  static DEFAULT_ICON = \"systems/lancer/assets/icons/deployable.svg\";\n  static defineSchema(): DeployableSchema {\n    return defineDeployableSchema();\n  }\n\n  static migrateData(data: any) {\n    if (data.type && data.type[0] == data.type[0].toLowerCase()) {\n      data.type = restrict_enum(DeployableType, DeployableType.Deployable, data.type);\n    }\n    if (!data.stats) {\n      // v1.X had the config values in the base level of the system data object. 2.0 keeps them in\n      // a `stats` object.\n      data.stats = {\n        armor: data.armor || 0,\n        edef: data.edef || 8,\n        evasion: data.evasion || 5,\n        heatcap: data.heatcap || 0,\n        hp: fixCCFormula(data.max_hp?.toString() || \"5\"),\n        save: data.save || 10,\n        size: data.size || 0.5,\n        speed: data.speed || 0,\n      };\n    }\n    if (data.hp && typeof data.hp == \"string\") {\n      data.stats.hp = fixCCFormula(data.hp);\n      // Having a string data.hp instead of object will cause an error later in\n      // data preparation, so we need to delete it. It will get populated\n      // correctly later.\n      delete data.hp;\n    }\n    if (data.stats?.size !== undefined) {\n      // Sizes of 1 and up must be integer values\n      if (data.stats?.size >= 1.0) {\n        data.stats.size = Math.floor(data.stats.size);\n      } else {\n        // If size is less than 1, it must be 1/2.\n        data.stats.size = 0.5;\n      }\n    }\n\n    return super.migrateData(data);\n  }\n}\n\nexport function unpackDeployableData(data: PackedDeployableData): DeepPartial<SourceData.Deployable> {\n  let max_hp = Number.parseInt(data.hp?.toString() || \"5\") || 5;\n  let rv = {\n    actions: data.actions?.map(unpackAction),\n    bonuses: data.bonuses?.map(unpackBonus),\n    counters: data.counters?.map(unpackCounter),\n    synergies: data.synergies?.map(unpackSynergy),\n    tags: data.tags?.map(unpackTag),\n    activation: data.activation,\n    stats: {\n      armor: data.armor,\n      edef: data.edef,\n      evasion: data.evasion,\n      heatcap: data.heatcap,\n      hp: fixCCFormula(data.hp?.toString() || \"5\"),\n      save: data.save,\n      size: data.size,\n      speed: data.speed,\n    },\n    activations: 0,\n    avail_mounted: undefined,\n    avail_unmounted: undefined,\n    hp: { min: 0, max: max_hp, value: max_hp },\n    burn: undefined,\n    cost: data.cost,\n    custom_counters: undefined,\n    deactivation: data.deactivation,\n    deployer: undefined,\n    detail: data.detail,\n    instances: data.instances,\n    lid: undefined,\n    overshield: undefined,\n    recall: data.recall,\n    redeploy: data.redeploy,\n    type: restrict_enum(DeployableType, DeployableType.Deployable, data.type),\n  };\n\n  return rv;\n}\n\n// When we unpack a deployable, we generate for it a slugified name\nexport function unpackDeployable(data: PackedDeployableData, context: UnpackContext): string {\n  let lid = \"dep_\" + slugify(data.name);\n  let unpacked = unpackDeployableData(data);\n  unpacked.lid = lid;\n  context.createdDeployables.push({\n    name: data.name,\n    system: unpacked,\n    type: EntryType.DEPLOYABLE,\n  });\n  return lid;\n}\n","import { CounterField } from \"../bits/counter\";\nimport { ActionField } from \"../bits/action\";\nimport { SynergyField } from \"../bits/synergy\";\nimport { FakeBoundedNumberField, LIDField, type UnpackContext } from \"../shared\";\nimport { type TagData, TagField, unpackTag } from \"../bits/tag\";\nimport { BonusField } from \"../bits/bonus\";\nimport type { PackedDeployableData, PackedTagData } from \"../../util/unpacking/packed-types\";\nimport { unpackDeployable } from \"../actors/deployable\";\nimport { DeployableType } from \"../../enums\";\n\nimport fields = foundry.data.fields;\n\nexport function template_universal_item() {\n  return {\n    lid: new LIDField(),\n  };\n}\n\nexport function template_destructible() {\n  return {\n    cascading: new fields.BooleanField(),\n    destroyed: new fields.BooleanField(),\n  };\n}\n\nexport function template_uses() {\n  return {\n    uses: new FakeBoundedNumberField({ integer: true, nullable: false, initial: 0 }),\n  };\n}\n\nexport function template_bascdt() {\n  return {\n    bonuses: new fields.ArrayField(new BonusField()),\n    actions: new fields.ArrayField(new ActionField()),\n    synergies: new fields.ArrayField(new SynergyField()),\n    counters: new fields.ArrayField(new CounterField()),\n    deployables: new fields.ArrayField(new LIDField()),\n    integrated: new fields.ArrayField(new LIDField()),\n    tags: new fields.ArrayField(new TagField()),\n  };\n}\n\nexport function template_licensed() {\n  return {\n    manufacturer: new fields.StringField({ required: true, nullable: false, blank: false, initial: \"GMS\" }),\n    license_level: new fields.NumberField({ integer: true, minimum: 0, maximum: 3 }),\n    license: new fields.StringField({ required: true, nullable: false, blank: false, initial: \"mf_unknown\" }),\n  };\n}\n\nexport function migrateManufacturer(source: {\n  id?: string;\n  fallback_lid?: string;\n  type?: string;\n  reg_name?: string;\n}): string {\n  return source?.fallback_lid || \"GMS\";\n}\n\nexport function addDeployableTags(\n  packedDeployables: PackedDeployableData[] | undefined,\n  packedTags: PackedTagData[] | undefined,\n  context: UnpackContext\n): { deployables?: string[]; tags?: TagData[] } {\n  const deployableIds = packedDeployables?.map(d => unpackDeployable(d, context));\n  const deployables = context.createdDeployables.filter(d => d.system.lid && deployableIds?.includes(d.system.lid));\n  const tags = packedTags?.map(unpackTag);\n  if (deployables?.length) {\n    const depTypes = new Set(deployables.map(d => d.system.type));\n    if (depTypes.has(DeployableType.Deployable)) tags?.push({ lid: \"tg_deployable\", val: \"0\" });\n    if (depTypes.has(DeployableType.Drone)) tags?.push({ lid: \"tg_drone\", val: \"0\" });\n    if (depTypes.has(DeployableType.Mine)) tags?.push({ lid: \"tg_mine\", val: \"0\" });\n  }\n  return { deployables: deployableIds, tags };\n}\n","import type { DeepPartial } from \"fvtt-types/utils\";\nimport { EntryType } from \"../../enums\";\nimport type { SourceData } from \"../../source-template\";\nimport type { BaseData } from \"../../base-data\";\nimport type { PackedPilotArmorData } from \"../../util/unpacking/packed-types\";\nimport { unpackAction } from \"../bits/action\";\nimport { unpackBonus } from \"../bits/bonus\";\nimport { unpackSynergy } from \"../bits/synergy\";\nimport { LancerDataModel, type UnpackContext } from \"../shared\";\nimport { template_universal_item, template_bascdt, template_uses, addDeployableTags } from \"./shared\";\n\nimport fields = foundry.data.fields;\n\nconst definePilotArmorModelSchema = () => {\n  return {\n    description: new fields.StringField({ nullable: true }),\n    effect: new fields.StringField(),\n    ...template_universal_item(),\n    ...template_uses(),\n    ...template_bascdt(),\n  };\n};\n\ntype PilotArmorModelSchema = ReturnType<typeof definePilotArmorModelSchema>;\n\nexport class PilotArmorModel extends LancerDataModel<PilotArmorModelSchema, Item.Implementation, BaseData.PilotArmor> {\n  static DEFAULT_ICON = \"systems/lancer/assets/icons/role_tank.svg\";\n  static defineSchema() {\n    return definePilotArmorModelSchema();\n  }\n}\n\nexport function unpackPilotArmor(\n  data: PackedPilotArmorData,\n  context: UnpackContext\n): {\n  name: string;\n  type: EntryType.PILOT_ARMOR;\n  system: DeepPartial<SourceData.PilotArmor>;\n} {\n  const { deployables, tags } = addDeployableTags(data.deployables, data.tags, context);\n  return {\n    name: data.name,\n    type: EntryType.PILOT_ARMOR,\n    system: {\n      actions: data.actions?.map(unpackAction) ?? [],\n      bonuses: data.bonuses?.map(unpackBonus) ?? [],\n      synergies: data.synergies?.map(unpackSynergy),\n      counters: undefined,\n      deployables: deployables ?? [],\n      description: data.description ?? \"\",\n      effect: data.effect,\n      lid: data.id,\n      tags: tags ?? [],\n    },\n  };\n}\n","import type { DeepPartial } from \"fvtt-types/utils\";\nimport { EntryType } from \"../../enums\";\nimport type { SourceData } from \"../../source-template\";\nimport type { BaseData } from \"../../base-data\";\nimport type { PackedPilotWeaponData } from \"../../util/unpacking/packed-types\";\nimport { unpackAction } from \"../bits/action\";\nimport { unpackBonus } from \"../bits/bonus\";\nimport { DamageField, unpackDamage } from \"../bits/damage\";\nimport { RangeField, unpackRange } from \"../bits/range\";\nimport { unpackSynergy } from \"../bits/synergy\";\nimport { LancerDataModel, type UnpackContext } from \"../shared\";\nimport { addDeployableTags, template_bascdt, template_universal_item, template_uses } from \"./shared\";\n\nimport fields = foundry.data.fields;\n\nconst definePilotWeaponModelSchema = () => {\n  return {\n    description: new fields.StringField({ nullable: true }),\n    range: new fields.ArrayField(new RangeField()),\n    damage: new fields.ArrayField(new DamageField()),\n    effect: new fields.StringField(),\n    loaded: new fields.BooleanField(),\n\n    ...template_universal_item(),\n    ...template_uses(),\n    ...template_bascdt(),\n  };\n};\n\ntype PilotWeaponModelSchema = ReturnType<typeof definePilotWeaponModelSchema>;\n\nexport class PilotWeaponModel extends LancerDataModel<\n  PilotWeaponModelSchema,\n  Item.Implementation,\n  BaseData.PilotWeapon\n> {\n  static DEFAULT_ICON = \"systems/lancer/assets/icons/role_artillery.svg\";\n  static defineSchema() {\n    return definePilotWeaponModelSchema();\n  }\n}\n\nexport function unpackPilotWeapon(\n  data: PackedPilotWeaponData,\n  context: UnpackContext\n): {\n  name: string;\n  type: EntryType.PILOT_WEAPON;\n  system: DeepPartial<SourceData.PilotWeapon>;\n} {\n  const { deployables, tags } = addDeployableTags(data.deployables, data.tags, context);\n  return {\n    name: data.name,\n    type: EntryType.PILOT_WEAPON,\n    system: {\n      actions: data.actions?.map(unpackAction) ?? [],\n      bonuses: data.bonuses?.map(unpackBonus) ?? [],\n      synergies: data.synergies?.map(unpackSynergy),\n      counters: undefined,\n      deployables: deployables ?? [],\n\n      description: data.description ?? \"\",\n      range: data.range?.map(unpackRange) ?? [],\n      damage: data.damage?.map(unpackDamage) ?? [],\n      effect: data.effect,\n      loaded: undefined,\n\n      lid: data.id,\n      tags: tags ?? [],\n    },\n  };\n}\n","import type { DeepPartial } from \"fvtt-types/utils\";\nimport { EntryType } from \"../../enums\";\nimport type { SourceData } from \"../../source-template\";\nimport type { BaseData } from \"../../base-data\";\nimport type { PackedPilotGearData } from \"../../util/unpacking/packed-types\";\nimport { unpackAction } from \"../bits/action\";\nimport { unpackBonus } from \"../bits/bonus\";\nimport { unpackSynergy } from \"../bits/synergy\";\nimport { LancerDataModel, type UnpackContext } from \"../shared\";\nimport { template_universal_item, template_bascdt, template_uses, addDeployableTags } from \"./shared\";\n\nimport fields = foundry.data.fields;\n\nconst definePilotGearModelSchema = () => {\n  return {\n    description: new fields.StringField({ nullable: true }),\n    effect: new fields.StringField(),\n    ...template_universal_item(),\n    ...template_uses(),\n    ...template_bascdt(),\n  };\n};\n\ntype PilotGearModelSchema = ReturnType<typeof definePilotGearModelSchema>;\n\nexport class PilotGearModel extends LancerDataModel<PilotGearModelSchema, Item.Implementation, BaseData.PilotGear> {\n  static DEFAULT_ICON = \"systems/lancer/assets/icons/generic_item.svg\";\n  static defineSchema() {\n    return definePilotGearModelSchema();\n  }\n}\n\nexport function unpackPilotGear(\n  data: PackedPilotGearData,\n  context: UnpackContext\n): {\n  name: string;\n  type: EntryType.PILOT_GEAR;\n  system: DeepPartial<SourceData.PilotGear>;\n} {\n  const { deployables, tags } = addDeployableTags(data.deployables, data.tags, context);\n  return {\n    name: data.name,\n    type: EntryType.PILOT_GEAR,\n    system: {\n      actions: data.actions?.map(unpackAction) ?? [],\n      bonuses: data.bonuses?.map(unpackBonus) ?? [],\n      synergies: data.synergies?.map(unpackSynergy),\n      counters: undefined,\n      deployables: deployables ?? [],\n      description: data.description ?? \"\",\n      effect: data.effect,\n      lid: data.id,\n      tags: tags ?? [],\n    },\n  };\n}\n","import type { DeepPartial } from \"fvtt-types/utils\";\nimport { EntryType } from \"../../enums\";\nimport type { SourceData } from \"../../source-template\";\nimport type { PackedCoreBonusData } from \"../../util/unpacking/packed-types\";\nimport { unpackDeployable } from \"../actors/deployable\";\nimport { unpackAction } from \"../bits/action\";\nimport { unpackBonus } from \"../bits/bonus\";\nimport { unpackCounter } from \"../bits/counter\";\nimport { unpackSynergy } from \"../bits/synergy\";\nimport { LancerDataModel, type UnpackContext } from \"../shared\";\nimport { migrateManufacturer, template_bascdt, template_universal_item } from \"./shared\";\nimport type { BaseData } from \"../../base-data\";\n\nimport fields = foundry.data.fields;\n\nconst defineCoreBonusModelSchema = () => {\n  return {\n    description: new fields.StringField({ nullable: true }),\n    effect: new fields.StringField(),\n    mounted_effect: new fields.StringField(),\n    manufacturer: new fields.StringField(),\n    ...template_universal_item(),\n    ...template_bascdt(),\n  };\n};\n\ntype CoreBonusModelSchema = ReturnType<typeof defineCoreBonusModelSchema>;\n\nexport class CoreBonusModel extends LancerDataModel<CoreBonusModelSchema, Item.Implementation, BaseData.CoreBonus> {\n  static DEFAULT_ICON = \"systems/lancer/assets/icons/core_bonus.svg\";\n  static defineSchema() {\n    return defineCoreBonusModelSchema();\n  }\n\n  static migrateData(data: any) {\n    if (data.source) {\n      data.manufacturer = migrateManufacturer(data.source);\n    }\n\n    return super.migrateData(data);\n  }\n}\n\nexport function unpackCoreBonus(\n  data: PackedCoreBonusData,\n  context: UnpackContext\n): {\n  name: string;\n  type: EntryType.CORE_BONUS;\n  system: DeepPartial<SourceData.CoreBonus>;\n} {\n  return {\n    name: data.name,\n    type: EntryType.CORE_BONUS,\n    system: {\n      actions: data.actions?.map(unpackAction) ?? [],\n      bonuses: data.bonuses?.map(unpackBonus) ?? [],\n      counters: data.counters?.map(unpackCounter) ?? [],\n      deployables: data.deployables?.map(d => unpackDeployable(d, context)) ?? [],\n      description: data.description,\n      effect: data.effect,\n      integrated: data.integrated,\n      lid: data.id,\n      manufacturer: data.source,\n      mounted_effect: data.mounted_effect,\n      synergies: data.synergies?.map(unpackSynergy),\n      tags: [],\n    },\n  };\n}\n","import type { DeepPartial } from \"fvtt-types/utils\";\nimport { EntryType } from \"../../enums\";\nimport type { SourceData } from \"../../source-template\";\nimport type { BaseData } from \"../../base-data\";\nimport type { PackedSkillData } from \"../../util/unpacking/packed-types\";\nimport { LancerDataModel, type UnpackContext } from \"../shared\";\nimport { template_universal_item } from \"./shared\";\n\nimport fields = foundry.data.fields;\n\nconst defineSkillModelSchema = () => {\n  return {\n    description: new fields.HTMLField(),\n    detail: new fields.StringField(),\n    curr_rank: new fields.NumberField({ nullable: false, initial: 1, min: 1, max: 3 }),\n    ...template_universal_item(),\n  };\n};\n\ntype SkillModelSchema = ReturnType<typeof defineSkillModelSchema>;\n\nexport class SkillModel extends LancerDataModel<SkillModelSchema, Item.Implementation, BaseData.Skill> {\n  static DEFAULT_ICON = \"systems/lancer/assets/icons/skill.svg\";\n  static defineSchema() {\n    return defineSkillModelSchema();\n  }\n\n  static migrateData(data: any) {\n    if (data.rank) {\n      data.curr_rank = data.rank;\n    }\n\n    return super.migrateData(data);\n  }\n}\n\n// Converts an lcp bonus into our expected format\nexport function unpackSkill(\n  data: PackedSkillData,\n  context: UnpackContext\n): {\n  name: string;\n  type: EntryType.SKILL;\n  system: DeepPartial<SourceData.Skill>;\n} {\n  return {\n    name: data.name,\n    type: EntryType.SKILL,\n    system: {\n      lid: data.id,\n      curr_rank: 1,\n      description: data.description,\n      detail: data.detail,\n    },\n  };\n}\n","import type { DeepPartial } from \"fvtt-types/utils\";\nimport { EntryType } from \"../../enums\";\nimport type { SourceData } from \"../../source-template\";\nimport type { BaseData } from \"../../base-data\";\nimport type { PackedTalentData } from \"../../util/unpacking/packed-types\";\nimport { unpackDeployable } from \"../actors/deployable\";\nimport { ActionField, unpackAction } from \"../bits/action\";\nimport { BonusField, unpackBonus } from \"../bits/bonus\";\nimport { CounterField, unpackCounter } from \"../bits/counter\";\nimport { SynergyField, unpackSynergy } from \"../bits/synergy\";\nimport { LIDField, LancerDataModel, type UnpackContext } from \"../shared\";\nimport { template_universal_item } from \"./shared\";\n\nimport fields = foundry.data.fields;\n\nconst defineTalentModelSchema = () => {\n  return {\n    curr_rank: new fields.NumberField({ nullable: false, initial: 1, min: 1, max: 3 }),\n    description: new fields.HTMLField(),\n    terse: new fields.StringField(),\n\n    ranks: new fields.ArrayField(\n      new fields.SchemaField({\n        name: new fields.StringField(),\n        description: new fields.HTMLField(),\n        exclusive: new fields.BooleanField({ initial: false }),\n        actions: new fields.ArrayField(new ActionField()),\n        bonuses: new fields.ArrayField(new BonusField()),\n        synergies: new fields.ArrayField(new SynergyField()),\n        deployables: new fields.ArrayField(new LIDField()),\n        counters: new fields.ArrayField(new CounterField()),\n        integrated: new fields.ArrayField(new LIDField()),\n      })\n    ),\n\n    ...template_universal_item(),\n  };\n};\n\ntype TalentModelSchema = ReturnType<typeof defineTalentModelSchema>;\n\nexport class TalentModel extends LancerDataModel<TalentModelSchema, Item.Implementation, BaseData.Talent> {\n  static DEFAULT_ICON = \"systems/lancer/assets/icons/talent.svg\";\n  static defineSchema() {\n    return defineTalentModelSchema();\n  }\n}\n\n// Converts an lcp bonus into our expected format\nexport function unpackTalent(\n  data: PackedTalentData,\n  context: UnpackContext\n): {\n  name: string;\n  type: EntryType.TALENT;\n  system: DeepPartial<SourceData.Talent>;\n} {\n  return {\n    name: data.name,\n    type: EntryType.TALENT,\n    system: {\n      lid: data.id,\n      curr_rank: undefined,\n      description: data.description,\n      ranks: data.ranks.map(r => ({\n        actions: r.actions?.map(unpackAction) ?? [],\n        bonuses: r.bonuses?.map(unpackBonus) ?? [],\n        counters: r.counters?.map(unpackCounter) ?? [],\n        deployables: r.deployables?.map(d => unpackDeployable(d, context)) ?? [],\n        description: r.description,\n        exclusive: r.exclusive,\n        integrated: r.integrated!,\n        name: r.name,\n        synergies: r.synergies?.map(unpackSynergy) ?? [],\n      })),\n      terse: data.terse,\n    },\n  };\n}\n","import fields = foundry.data.fields;\n\nexport interface BondQuestionData {\n  question: string;\n  options: Array<string>;\n}\n\nconst defineBondQuestionFieldSchema = () => {\n  return {\n    question: new fields.StringField({ nullable: false }),\n    options: new fields.ArrayField(new fields.StringField({ nullable: false })),\n  };\n};\n\ntype BondQuestionFieldSchema = ReturnType<typeof defineBondQuestionFieldSchema>;\n\nexport class BondQuestionField<Options extends fields.SchemaField<BondQuestionFieldSchema>> extends fields.SchemaField<\n  BondQuestionFieldSchema,\n  Options\n> {\n  constructor(options?: Options) {\n    super(defineBondQuestionFieldSchema(), options);\n  }\n}\n\nexport function unpackQuestion(data: any): BondQuestionData {\n  return {\n    question: data.question,\n    options: data.options,\n  };\n}\n","import type { DeepPartial } from \"fvtt-types/utils\";\nimport { EntryType } from \"../../enums\";\nimport type { SourceData } from \"../../source-template\";\nimport type { PackedBondData } from \"../../util/unpacking/packed-types\";\nimport { PowerField, unpackPower } from \"../bits/power\";\nimport { BondQuestionField } from \"../bits/question\";\nimport { LancerDataModel } from \"../shared\";\nimport { template_universal_item } from \"./shared\";\nimport type { BaseData } from \"../../base-data\";\n\nimport fields = foundry.data.fields;\n\nconst defineBondModelSchema = () => {\n  return {\n    major_ideals: new fields.ArrayField(new fields.StringField()),\n    minor_ideals: new fields.ArrayField(new fields.StringField()),\n    questions: new fields.ArrayField(new BondQuestionField()),\n    powers: new fields.ArrayField(new PowerField()),\n    ...template_universal_item(),\n  };\n};\n\ntype BondModelSchema = ReturnType<typeof defineBondModelSchema>;\n\nexport class BondModel extends LancerDataModel<BondModelSchema, Item.Implementation, BaseData.Bond> {\n  static DEFAULT_ICON = \"systems/lancer/assets/icons/bond.svg\";\n  static defineSchema() {\n    return defineBondModelSchema();\n  }\n}\n\nexport function unpackBond(data: PackedBondData): {\n  name: string;\n  type: EntryType.BOND;\n  system: DeepPartial<SourceData.Bond>;\n} {\n  const powers = data.powers.map(p => unpackPower(p));\n  return {\n    name: data.name,\n    type: EntryType.BOND,\n    system: {\n      lid: data.id,\n      major_ideals: data.major_ideals,\n      minor_ideals: data.minor_ideals,\n      questions: data.questions,\n      powers,\n    },\n  };\n}\n","import type { DeepPartial } from \"fvtt-types/utils\";\nimport { EntryType } from \"../../enums\";\nimport type { SourceData } from \"../../source-template\";\nimport type { BaseData } from \"../../base-data\";\nimport { LancerDataModel, type UnpackContext } from \"../shared\";\nimport { template_universal_item } from \"./shared\";\n\nimport fields = foundry.data.fields;\n\nconst defineLicenseModelSchema = () => {\n  return {\n    key: new fields.StringField(),\n    manufacturer: new fields.StringField(),\n    curr_rank: new fields.NumberField({ nullable: false, initial: 1, min: 1, max: 3 }),\n    ...template_universal_item(),\n  };\n};\n\ntype LicenseModelSchema = ReturnType<typeof defineLicenseModelSchema>;\n\nexport class LicenseModel extends LancerDataModel<LicenseModelSchema, Item.Implementation, BaseData.License> {\n  static DEFAULT_ICON = \"systems/lancer/assets/icons/license.svg\";\n  static defineSchema() {\n    return defineLicenseModelSchema();\n  }\n\n  static migrateData(data: any) {\n    if (typeof data.manufacturer == \"object\") {\n      data.manufacturer = data.manufacturer.fallback_lid;\n    }\n    if (data.rank) data.curr_rank = data.rank;\n\n    return super.migrateData(data);\n  }\n}\n\n// Converts an lcp bonus into our expected format\nexport function unpackLicense(\n  name: string,\n  key: string,\n  manufacturer: string,\n  _context: UnpackContext\n): {\n  name: string;\n  type: EntryType.LICENSE;\n  system: DeepPartial<SourceData.License>;\n} {\n  return {\n    name,\n    type: EntryType.LICENSE,\n    system: {\n      lid: `lic_${key}`,\n      key,\n      manufacturer,\n    },\n  };\n}\n","import {\n  type WeaponSizeChecklist,\n  type WeaponTypeChecklist,\n  makeWeaponSizeChecklist,\n  makeWeaponTypeChecklist,\n} from \"../../enums\";\nimport type { PackedAmmoData } from \"../../util/unpacking/packed-types\";\nimport { WeaponSizeChecklistField, WeaponTypeChecklistField } from \"../shared\";\n\nimport fields = foundry.data.fields;\n\nconst defineAmmoFieldSchema = () => {\n  return {\n    name: new fields.StringField({ nullable: false }),\n    description: new fields.StringField({ nullable: false }),\n    cost: new fields.NumberField({ nullable: true }),\n    allowed_types: new WeaponTypeChecklistField(),\n    allowed_sizes: new WeaponSizeChecklistField(),\n    restricted_types: new WeaponTypeChecklistField(),\n    restricted_sizes: new WeaponSizeChecklistField(),\n  };\n};\n\ntype AmmoFieldSchema = ReturnType<typeof defineAmmoFieldSchema>;\n\nexport type AmmoData = fields.SchemaField.InitializedData<AmmoFieldSchema>;\n\nexport class AmmoField<Options extends fields.SchemaField.Options<AmmoFieldSchema>> extends fields.SchemaField<\n  AmmoFieldSchema,\n  Options\n> {\n  constructor(options?: Options) {\n    super(defineAmmoFieldSchema(), options);\n  }\n}\n\nexport function unpackAmmo(data: PackedAmmoData): AmmoData {\n  return {\n    name: data.name,\n    description: data.description,\n    cost: data.cost ?? null,\n    allowed_types: data.allowed_types ? makeWeaponTypeChecklist(data.allowed_types) : null,\n    allowed_sizes: data.allowed_sizes ? makeWeaponSizeChecklist(data.allowed_sizes) : null,\n    restricted_types: data.restricted_types ? makeWeaponTypeChecklist(data.restricted_types) : null,\n    restricted_sizes: data.restricted_sizes ? makeWeaponSizeChecklist(data.restricted_sizes) : null,\n  };\n}\n","import type { DeepPartial } from \"fvtt-types/utils\";\nimport { EntryType } from \"../../enums\";\nimport type { SourceData } from \"../../source-template\";\nimport type { BaseData } from \"../../base-data\";\nimport type { PackedMechSystemData } from \"../../util/unpacking/packed-types\";\nimport { unpackAction } from \"../bits/action\";\nimport { AmmoField, unpackAmmo } from \"../bits/ammo\";\nimport { unpackBonus } from \"../bits/bonus\";\nimport { unpackCounter } from \"../bits/counter\";\nimport { unpackSynergy } from \"../bits/synergy\";\nimport { LancerDataModel, type UnpackContext } from \"../shared\";\nimport {\n  addDeployableTags,\n  migrateManufacturer,\n  template_bascdt,\n  template_destructible,\n  template_licensed,\n  template_universal_item,\n  template_uses,\n} from \"./shared\";\n\nimport fields = foundry.data.fields;\n\nconst defineMechSystemModelSchema = () => {\n  return {\n    effect: new fields.HTMLField(),\n    sp: new fields.NumberField({ nullable: false, initial: 0 }),\n    description: new fields.HTMLField(),\n    type: new fields.StringField(),\n    ammo: new fields.ArrayField(new AmmoField()),\n    ...template_universal_item(),\n    ...template_bascdt(),\n    ...template_destructible(),\n    ...template_licensed(),\n    ...template_uses(),\n  };\n};\n\ntype MechSystemModelSchema = ReturnType<typeof defineMechSystemModelSchema>;\n\nexport class MechSystemModel extends LancerDataModel<MechSystemModelSchema, Item.Implementation, BaseData.MechSystem> {\n  static DEFAULT_ICON = \"systems/lancer/assets/icons/mech_system.svg\";\n  static defineSchema() {\n    return defineMechSystemModelSchema();\n  }\n\n  static migrateData(data: any) {\n    if (data.source) {\n      data.manufacturer = migrateManufacturer(data.source);\n    }\n\n    return super.migrateData(data);\n  }\n}\n\n// Converts an lcp bonus into our expected format\nexport function unpackMechSystem(\n  data: PackedMechSystemData,\n  context: UnpackContext\n): {\n  name: string;\n  type: EntryType.MECH_SYSTEM;\n  system: DeepPartial<SourceData.MechSystem>;\n} {\n  const { deployables, tags } = addDeployableTags(data.deployables, data.tags, context);\n  return {\n    name: data.name,\n    type: EntryType.MECH_SYSTEM,\n    system: {\n      lid: data.id,\n      actions: data.actions?.map(unpackAction),\n      bonuses: data.bonuses?.map(unpackBonus),\n      cascading: undefined,\n      counters: data.counters?.map(unpackCounter),\n      deployables,\n      description: data.description,\n      destroyed: undefined,\n      effect: data.effect,\n      integrated: data.integrated,\n      license: data.license_id || data.license,\n      license_level: data.license_level,\n      manufacturer: data.source,\n      sp: data.sp,\n      synergies: data.synergies?.map(unpackSynergy),\n      tags,\n      type: data.type,\n      ammo: data.ammo?.map(unpackAmmo),\n      uses: { value: 0, max: 0 },\n    },\n  };\n}\n","import type { DeepPartial } from \"fvtt-types/utils\";\nimport { EntryType, WeaponSize, WeaponType } from \"../../enums\";\nimport { restrict_enum } from \"../../helpers/commons\";\nimport type { SourceData } from \"../../source-template\";\nimport type { PackedMechWeaponData } from \"../../util/unpacking/packed-types\";\nimport { ActionField, unpackAction } from \"../bits/action\";\nimport { BonusField, unpackBonus } from \"../bits/bonus\";\nimport { CounterField, unpackCounter } from \"../bits/counter\";\nimport { DamageField, unpackDamage } from \"../bits/damage\";\nimport { RangeField, unpackRange } from \"../bits/range\";\nimport { SynergyField, unpackSynergy } from \"../bits/synergy\";\nimport { type TagData, TagField } from \"../bits/tag\";\nimport { LIDField, LancerDataModel, type UnpackContext } from \"../shared\";\nimport {\n  addDeployableTags,\n  migrateManufacturer,\n  template_destructible,\n  template_licensed,\n  template_universal_item,\n  template_uses,\n} from \"./shared\";\nimport type { BaseData } from \"../../base-data\";\n\nimport fields = foundry.data.fields;\n\nconst defineProfileSchema = () => ({\n  name: new fields.StringField({ initial: \"Base Profile\" }),\n  type: new fields.StringField({ choices: Object.values(WeaponType), initial: WeaponType.Rifle }),\n  damage: new fields.ArrayField(new DamageField()),\n  range: new fields.ArrayField(new RangeField()),\n  tags: new fields.ArrayField(new TagField()),\n  description: new fields.StringField(),\n  effect: new fields.StringField(),\n  on_attack: new fields.StringField(),\n  on_hit: new fields.StringField(),\n  on_crit: new fields.StringField(),\n  cost: new fields.NumberField({ nullable: false, initial: 0 }),\n  skirmishable: new fields.BooleanField(),\n  barrageable: new fields.BooleanField(),\n  actions: new fields.ArrayField(new ActionField()),\n  bonuses: new fields.ArrayField(new BonusField()),\n  synergies: new fields.ArrayField(new SynergyField()),\n  counters: new fields.ArrayField(new CounterField()),\n});\n\nconst defineMechWeaponModelSchema = () => {\n  return {\n    deployables: new fields.ArrayField(new LIDField()),\n    integrated: new fields.ArrayField(new LIDField()),\n    sp: new fields.NumberField({ nullable: false, initial: 0 }),\n    actions: new fields.ArrayField(new ActionField()),\n    profiles: new fields.ArrayField(\n      // TODO: Convert to EmbeddedDataField\n      new fields.SchemaField(defineProfileSchema()),\n      {\n        min: 1,\n        initial: [\n          {\n            damage: [{ val: \"1d6\", type: \"Kinetic\" }],\n            range: [{ type: \"Range\", val: 5 }],\n            tags: [],\n            skirmishable: true,\n            barrageable: true,\n            actions: [],\n            bonuses: [],\n            synergies: [],\n            counters: [],\n          },\n        ],\n      }\n    ),\n    loaded: new fields.BooleanField(),\n    selected_profile_index: new fields.NumberField({ nullable: false, initial: 0 }),\n    size: new fields.StringField({\n      choices: Object.values(WeaponSize).concat(\"Ship-class\" as unknown as WeaponSize),\n      initial: WeaponSize.Main,\n    }),\n    no_core_bonuses: new fields.BooleanField(),\n    no_mods: new fields.BooleanField(),\n    no_bonuses: new fields.BooleanField(),\n    no_synergies: new fields.BooleanField(),\n    no_attack: new fields.BooleanField(),\n    ...template_universal_item(),\n    ...template_destructible(),\n    ...template_licensed(),\n    ...template_uses(),\n  };\n};\n\ntype MechWeaponModelSchema = ReturnType<typeof defineMechWeaponModelSchema>;\n\ntype ProfileSchema = ReturnType<typeof defineProfileSchema>;\n\nexport type InitializedProfile = fields.SchemaField.InitializedData<ProfileSchema>;\n\nexport class MechWeaponModel extends LancerDataModel<MechWeaponModelSchema, Item.Implementation, BaseData.MechWeapon> {\n  static DEFAULT_ICON = \"systems/lancer/assets/icons/mech_weapon.svg\";\n  static defineSchema() {\n    return defineMechWeaponModelSchema();\n  }\n\n  static migrateData(data: any) {\n    if (data.source) {\n      data.manufacturer = migrateManufacturer(data.source);\n    }\n    return super.migrateData(data);\n  }\n}\n\nexport function unpackMechWeapon(\n  data: PackedMechWeaponData,\n  context: UnpackContext\n): {\n  name: string;\n  type: EntryType.MECH_WEAPON;\n  // TODO(LukeAbby): Should specifically be mech weapon's `CreateData`.\n  system: Item.CreateData;\n} {\n  let profiles: Array<Partial<SourceData.MechWeapon[\"profiles\"][0]>> = [];\n\n  let { deployables: parentDeployables, tags: parentTags } = addDeployableTags(data.deployables, data.tags, context);\n  // These can live at parent or profile level - extract them first\n  parentDeployables = parentDeployables ?? [];\n  parentTags = parentTags ?? [];\n  let parentIntegrated = data.integrated ?? [];\n\n  // Then unpack profiles, using the entire structure as a pseudo-profile if no specific profiles are given\n  let hasProfiles = (data.profiles?.length ?? 0) > 0;\n  for (let prof of hasProfiles ? data.profiles : [data]) {\n    // Unpack sub components iff not substituted in from parent\n    let profileDeployables: string[] = [];\n    let profileTags: TagData[] = [];\n    if (hasProfiles) {\n      const { deployables: newDeployables, tags: newTags } = addDeployableTags(prof.deployables, prof.tags, context);\n\n      profileDeployables = newDeployables ?? [];\n      profileTags = newTags ?? [];\n    }\n\n    // Then just store them at parent level\n    parentDeployables.push(...profileDeployables);\n    parentIntegrated.push(...(prof.integrated ?? []));\n\n    // Barrageable have a weird interaction.\n    let barrageable: boolean;\n    let skirmishable: boolean;\n    if (prof.barrage == undefined && prof.skirmish == undefined) {\n      // Neither set. Go with defaults\n      barrageable = true;\n      skirmishable = data.mount != WeaponSize.Superheavy;\n    } else if (prof.barrage == undefined) {\n      // Only skirmish set. We assume barrage to be false, in this case. (should we? the data spec is unclear)\n      skirmishable = prof.skirmish!;\n      barrageable = false;\n    } else if (prof.skirmish == undefined) {\n      // Only barrage set. We assume skirmish to be false, in this case.\n      skirmishable = false;\n      barrageable = prof.barrage!;\n    } else {\n      skirmishable = prof.skirmish!;\n      barrageable = prof.barrage!;\n    }\n\n    // The rest is left to the profile\n    let tags = hasProfiles ? [...parentTags, ...profileTags] : parentTags;\n    profiles.push({\n      damage: prof.damage?.filter(d => d.val != \"N/A\").map(unpackDamage),\n      range: prof.range?.filter(d => d.val != \"N/A\").map(unpackRange),\n      tags,\n      effect: prof.effect,\n      on_attack: prof.on_attack,\n      on_crit: prof.on_crit,\n      on_hit: prof.on_hit,\n      cost: prof.cost ?? 1,\n      barrageable,\n      skirmishable,\n      actions: prof.actions?.map(unpackAction),\n      bonuses: prof.bonuses?.map(unpackBonus),\n      counters: prof.counters?.map(unpackCounter),\n      description: prof.description ?? data.description,\n      name: prof.name ?? `${data.name} :: ${data.profiles?.length ?? 0 + 1}`,\n      synergies: prof.synergies?.map(unpackSynergy),\n      type: restrict_enum(WeaponType, WeaponType.Rifle, prof.type ?? data.type),\n    });\n  }\n\n  return {\n    name: data.name,\n    type: EntryType.MECH_WEAPON,\n    system: {\n      cascading: undefined,\n      deployables: parentDeployables,\n      destroyed: undefined,\n      integrated: data.integrated,\n      license: data.license_id || data.license,\n      license_level: data.license_level,\n      lid: data.id,\n      loaded: undefined,\n      manufacturer: data.source,\n      no_attack: data.no_attack,\n      no_bonuses: data.no_bonus,\n      no_core_bonuses: data.no_core_bonus,\n      no_mods: data.no_mods,\n      no_synergies: data.no_synergy,\n      actions: data.actions?.map(unpackAction) || [],\n      profiles: profiles as any,\n      selected_profile_index: 0,\n      size: data.mount,\n      sp: data.sp,\n      uses: { value: 0, max: 0 },\n    },\n  };\n}\n","import type { DeepPartial } from \"fvtt-types/utils\";\nimport { EntryType, makeWeaponSizeChecklist, makeWeaponTypeChecklist } from \"../../enums\";\nimport type { SourceData } from \"../../source-template\";\nimport type { BaseData } from \"../../base-data\";\nimport type { PackedWeaponModData } from \"../../util/unpacking/packed-types\";\nimport { unpackAction } from \"../bits/action\";\nimport { unpackBonus } from \"../bits/bonus\";\nimport { unpackCounter } from \"../bits/counter\";\nimport { DamageField, unpackDamage } from \"../bits/damage\";\nimport { RangeField, unpackRange } from \"../bits/range\";\nimport { unpackSynergy } from \"../bits/synergy\";\nimport { TagField, unpackTag } from \"../bits/tag\";\nimport { LancerDataModel, type UnpackContext, WeaponSizeChecklistField, WeaponTypeChecklistField } from \"../shared\";\nimport {\n  addDeployableTags,\n  migrateManufacturer,\n  template_bascdt,\n  template_destructible,\n  template_licensed,\n  template_universal_item,\n  template_uses,\n} from \"./shared\";\n\nimport fields = foundry.data.fields;\n\nconst defineWeaponModModel = () => {\n  return {\n    added_tags: new fields.ArrayField(new TagField()),\n    added_damage: new fields.ArrayField(new DamageField()),\n    added_range: new fields.ArrayField(new RangeField()),\n    effect: new fields.HTMLField(),\n    description: new fields.HTMLField(),\n    sp: new fields.NumberField({ nullable: false, initial: 0 }),\n    allowed_types: new WeaponTypeChecklistField(),\n    allowed_sizes: new WeaponSizeChecklistField(),\n    ...template_universal_item(),\n    ...template_bascdt(),\n    ...template_destructible(),\n    ...template_licensed(),\n    ...template_uses(),\n  };\n};\n\ntype WeaponModModelSchema = ReturnType<typeof defineWeaponModModel>;\n\nexport class WeaponModModel extends LancerDataModel<WeaponModModelSchema, Item.Implementation, BaseData.WeaponMod> {\n  static DEFAULT_ICON = \"systems/lancer/assets/icons/weapon_mod.svg\";\n  static defineSchema() {\n    return defineWeaponModModel();\n  }\n\n  static migrateData(data: any) {\n    if (data.source) {\n      data.manufacturer = migrateManufacturer(data.source);\n    }\n    return super.migrateData(data);\n  }\n}\n\n// Converts an lcp bonus into our expected format\nexport function unpackWeaponMod(\n  data: PackedWeaponModData,\n  context: UnpackContext\n): {\n  name: string;\n  type: EntryType.WEAPON_MOD;\n  // TODO(LukeAbby): Should specifically be weapon mod's `CreateData`.\n  system: Item.CreateData;\n} {\n  const { deployables, tags } = addDeployableTags(data.deployables, data.tags, context);\n  return {\n    name: data.name,\n    type: EntryType.WEAPON_MOD,\n    system: {\n      lid: data.id,\n      actions: data.actions?.map(unpackAction),\n      bonuses: data.bonuses?.map(unpackBonus),\n      cascading: undefined,\n      counters: data.counters?.map(unpackCounter),\n      deployables,\n      description: data.description,\n      destroyed: undefined,\n      effect: data.effect,\n      integrated: data.integrated,\n      license: data.license_id || data.license,\n      license_level: data.license_level,\n      manufacturer: data.source,\n      sp: data.sp,\n      synergies: data.synergies?.map(unpackSynergy),\n      tags,\n      uses: { value: 0, max: 0 },\n      added_damage: data.added_damage?.map(unpackDamage),\n      added_range: data.added_range?.map(unpackRange),\n      added_tags: data.added_tags?.map(unpackTag),\n      allowed_sizes: makeWeaponSizeChecklist(data.allowed_sizes ?? []),\n      allowed_types: makeWeaponTypeChecklist(data.allowed_types ?? []),\n    },\n  };\n}\n","import { EntryType, ReserveType } from \"../../enums\";\nimport { restrict_enum } from \"../../helpers/commons\";\nimport type { BaseData } from \"../../base-data\";\nimport type { PackedReserveData } from \"../../util/unpacking/packed-types\";\nimport { unpackDeployable } from \"../actors/deployable\";\nimport { unpackAction } from \"../bits/action\";\nimport { unpackBonus } from \"../bits/bonus\";\nimport { unpackCounter } from \"../bits/counter\";\nimport { unpackSynergy } from \"../bits/synergy\";\nimport { LancerDataModel, type UnpackContext } from \"../shared\";\nimport { template_bascdt, template_universal_item } from \"./shared\";\n\nimport fields = foundry.data.fields;\n\nconst defineReserveModelSchema = () => {\n  return {\n    consumable: new fields.BooleanField(),\n    label: new fields.StringField(),\n    // resource_name, resource_note, and resource_cost are in the lancer-data spec but not used currently\n    // resource_name: new fields.StringField(),\n    // resource_note: new fields.StringField(),\n    // resource_cost: new fields.StringField(),\n    // type: new fields.StringField({ choices: Object.values(ReserveType), initial: ReserveType.Tactical }),\n    type: new fields.StringField({ initial: ReserveType.Tactical }), // ^ Strictness here isn't really super useful\n    used: new fields.BooleanField(),\n    description: new fields.HTMLField(),\n    ...template_universal_item(),\n    ...template_bascdt(),\n  };\n};\n\ntype ReserveModelSchema = ReturnType<typeof defineReserveModelSchema>;\n\nexport class ReserveModel extends LancerDataModel<ReserveModelSchema, Item.Implementation, BaseData.Reserve> {\n  static DEFAULT_ICON = \"systems/lancer/assets/icons/reserve_tac.svg\";\n  static defineSchema() {\n    return defineReserveModelSchema();\n  }\n}\n\n// Converts an lcp bonus into our expected format\nexport function unpackReserve(\n  data: PackedReserveData,\n  context: UnpackContext\n): {\n  name: string;\n  type: EntryType.RESERVE;\n  // TODO(LukeAbby): Should specifically be reserve's `CreateData`.\n  system: Item.CreateData;\n} {\n  return {\n    name: data.name ?? data.label ?? \"Unnamed Reserve\",\n    type: EntryType.RESERVE,\n    system: {\n      lid: data.id,\n      description: data.description,\n      actions: data.actions?.map(unpackAction),\n      bonuses: data.bonuses?.map(unpackBonus),\n      consumable: data.consumable,\n      counters: data.counters?.map(unpackCounter),\n      deployables: data.deployables?.map(d => unpackDeployable(d, context)),\n      integrated: data.integrated,\n      label: data.label,\n      // These three attributes are in the lancer-data spec, but seem to be unused.\n      // resource_cost: data.resource_cost,\n      // resource_name: data.resource_name,\n      // resource_note: data.resource_note,\n      synergies: data.synergies?.map(unpackSynergy),\n      tags: undefined,\n      type: restrict_enum(ReserveType, ReserveType.Tactical, data.type),\n      used: data.used,\n    },\n  };\n}\n","import type { DeepPartial } from \"fvtt-types/utils\";\nimport { frameToPath } from \"../../actor/retrograde-map\";\nimport { ActivationType, EntryType, FrameEffectUse, MechType, MountType } from \"../../enums\";\nimport { restrict_enum } from \"../../helpers/commons\";\nimport type { SourceData } from \"../../source-template\";\nimport type { BaseData } from \"../../base-data\";\nimport type { PackedFrameData } from \"../../util/unpacking/packed-types\";\nimport { unpackDeployable } from \"../actors/deployable\";\nimport { ActionField, repairActivationType, unpackAction } from \"../bits/action\";\nimport { BonusField, unpackBonus } from \"../bits/bonus\";\nimport { CounterField, unpackCounter } from \"../bits/counter\";\nimport { SynergyField, unpackSynergy } from \"../bits/synergy\";\nimport { TagField } from \"../bits/tag\";\nimport { LIDField, LancerDataModel, type UnpackContext } from \"../shared\";\nimport { addDeployableTags, migrateManufacturer, template_licensed, template_universal_item } from \"./shared\";\n\nimport fields = foundry.data.fields;\n\nconst defineFrameSchema = () => {\n  return {\n    description: new fields.HTMLField(),\n    mechtype: new fields.ArrayField(new fields.StringField({ nullable: false, choices: Object.values(MechType) })),\n    mounts: new fields.ArrayField(new fields.StringField({ nullable: false, choices: Object.values(MountType) })),\n    stats: new fields.SchemaField({\n      armor: new fields.NumberField({ integer: true, minimum: 0, initial: 0 }),\n      edef: new fields.NumberField({ integer: true, minimum: 0, initial: 8 }),\n      evasion: new fields.NumberField({ integer: true, minimum: 0, initial: 8 }),\n      heatcap: new fields.NumberField({ integer: true, minimum: 0, initial: 5 }),\n      hp: new fields.NumberField({ integer: true, minimum: 0, initial: 10 }),\n      repcap: new fields.NumberField({ integer: true, minimum: 0, initial: 0 }),\n      save: new fields.NumberField({ integer: true, minimum: 0, initial: 10 }),\n      sensor_range: new fields.NumberField({ integer: true, minimum: 0, initial: 10 }),\n      size: new fields.NumberField({ integer: false, minimum: 0.5, initial: 1 }),\n      sp: new fields.NumberField({ integer: true, minimum: 0, initial: 0 }),\n      speed: new fields.NumberField({ integer: true, minimum: 0, initial: 4 }),\n      stress: new fields.NumberField({ integer: true, minimum: 0, initial: 4 }),\n      structure: new fields.NumberField({ integer: true, minimum: 0, initial: 4 }),\n      tech_attack: new fields.NumberField({ integer: true, initial: 0 }),\n    }),\n    traits: new fields.ArrayField(\n      new fields.SchemaField({\n        name: new fields.StringField(),\n        description: new fields.HTMLField(),\n        bonuses: new fields.ArrayField(new BonusField()),\n        counters: new fields.ArrayField(new CounterField()),\n        integrated: new fields.ArrayField(new LIDField()),\n        deployables: new fields.ArrayField(new LIDField()),\n        actions: new fields.ArrayField(new ActionField()),\n        synergies: new fields.ArrayField(new SynergyField()),\n        // use: new fields.StringField({ nullable: false, choices: Object.values(FrameEffectUse), initial: FrameEffectUse.Unknown, }),\n        use: new fields.StringField({ nullable: true, initial: null }), // ^ Core data does not adhere to this schema\n      })\n    ),\n    core_system: new fields.SchemaField({\n      name: new fields.StringField(),\n      description: new fields.HTMLField(),\n      activation: new fields.StringField({ nullable: false, choices: Object.values(ActivationType) }),\n      deactivation: new fields.StringField({ nullable: true, choices: Object.values(ActivationType), initial: null }),\n      // use: new fields.StringField({ nullable: true, choices: Object.values(FrameEffectUse), initial: null }),\n      use: new fields.StringField({ nullable: true, initial: null }), // ^ Core data does not adhere to this schema\n\n      active_name: new fields.StringField(),\n      active_effect: new fields.HTMLField(),\n      active_synergies: new fields.ArrayField(new SynergyField()),\n      active_bonuses: new fields.ArrayField(new BonusField()),\n      active_actions: new fields.ArrayField(new ActionField()),\n\n      passive_name: new fields.StringField(),\n      passive_effect: new fields.HTMLField(),\n      passive_synergies: new fields.ArrayField(new SynergyField()),\n      passive_bonuses: new fields.ArrayField(new BonusField()),\n      passive_actions: new fields.ArrayField(new ActionField()),\n\n      deployables: new fields.ArrayField(new LIDField()),\n      counters: new fields.ArrayField(new CounterField({ required: true })),\n      integrated: new fields.ArrayField(new LIDField()),\n      tags: new fields.ArrayField(new TagField()),\n    }),\n    ...template_universal_item(),\n    ...template_licensed(),\n  };\n};\n\ntype FrameModelSchema = ReturnType<typeof defineFrameSchema>;\n\nexport class FrameModel extends LancerDataModel<FrameModelSchema, Item.Implementation, BaseData.Frame> {\n  static DEFAULT_ICON = \"systems/lancer/assets/icons/mech.svg\";\n  static defineSchema() {\n    return defineFrameSchema();\n  }\n\n  static migrateData(data: any) {\n    if (data.source) {\n      data.manufacturer = migrateManufacturer(data.source);\n    }\n    if (data.stats?.size !== undefined) {\n      // Size of 1 and higher must be integer values\n      if (data.stats.size >= 1.0) {\n        data.stats.size = Math.floor(data.stats.size);\n      } else {\n        // Sizes below 1 must be 1/2\n        data.stats.size = 0.5;\n      }\n    }\n\n    return super.migrateData(data);\n  }\n}\n\nexport function unpackFrame(\n  data: PackedFrameData,\n  context: UnpackContext\n): {\n  name: string;\n  type: EntryType.FRAME;\n  img: string | undefined;\n  system: DeepPartial<SourceData.Frame>;\n} {\n  let cs = data.core_system;\n  const frameImg = frameToPath(data.name);\n  let csActivation = repairActivationType(cs.activation ?? ActivationType.Quick);\n  const { deployables, tags } = addDeployableTags(cs.deployables, cs.tags, context);\n  return {\n    name: data.name,\n    type: EntryType.FRAME,\n    img: frameImg ?? undefined,\n    system: {\n      core_system: {\n        activation: csActivation,\n        active_actions: cs.active_actions?.map(unpackAction),\n        active_bonuses: cs.active_bonuses?.map(unpackBonus),\n        active_effect: cs.active_effect,\n        active_name: cs.active_name,\n        active_synergies: cs.active_synergies?.map(unpackSynergy),\n        counters: cs.counters?.map(unpackCounter),\n        deactivation: cs.deactivation,\n        deployables,\n        description: cs.description,\n        integrated: cs.integrated,\n        name: cs.name,\n        passive_actions: cs.passive_actions?.map(unpackAction),\n        passive_bonuses: cs.passive_bonuses?.map(unpackBonus),\n        passive_effect: cs.passive_effect,\n        passive_name: cs.passive_name,\n        passive_synergies: cs.passive_synergies?.map(unpackSynergy),\n        tags,\n        use: restrict_enum(FrameEffectUse, FrameEffectUse.Unknown, cs.use),\n      },\n      description: data.description,\n      license: data.license_id || data.id,\n      license_level: data.license_level ?? 2,\n      lid: data.id,\n      manufacturer: data.source,\n      mechtype: data.mechtype?.map(mt => restrict_enum(MechType, MechType.Striker, mt)),\n      mounts: data.mounts,\n      stats: data.stats,\n      traits: data.traits?.map(t => ({\n        actions: t.actions?.map(unpackAction) ?? [],\n        bonuses: t.bonuses?.map(unpackBonus) ?? [],\n        counters: t.counters?.map(unpackCounter) ?? [],\n        deployables: t.deployables?.map(d => unpackDeployable(d, context)) ?? [],\n        description: t.description,\n        integrated: t.integrated ?? [],\n        name: t.name,\n        synergies: t.synergies?.map(unpackSynergy) ?? [],\n        use: restrict_enum(FrameEffectUse, FrameEffectUse.Unknown, t.use),\n      })),\n    },\n  };\n}\n","import type { DeepPartial } from \"fvtt-types/utils\";\nimport { frameToPath } from \"../../actor/retrograde-map\";\nimport { EntryType } from \"../../enums\";\nimport type { SourceData } from \"../../source-template\";\nimport type { BaseData } from \"../../base-data\";\nimport { convertNpcStats, regRefToLid } from \"../../util/migrations\";\nimport type { PackedNpcClassData } from \"../../util/unpacking/packed-types\";\nimport { LIDField, LancerDataModel, NpcStatBlockField, type UnpackContext } from \"../shared\";\nimport { template_universal_item } from \"./shared\";\n\nimport fields = foundry.data.fields;\n\nconst defineNpcClassModelSchema = () => {\n  return {\n    role: new fields.StringField(),\n    flavor: new fields.HTMLField(),\n    tactics: new fields.HTMLField(),\n    base_features: new fields.SetField(new LIDField()),\n    optional_features: new fields.SetField(new LIDField()),\n    base_stats: new fields.ArrayField(new NpcStatBlockField({ nullable: false }), {\n      min: 3,\n      max: 3,\n      initial: [{}, {}, {}],\n    }),\n    ...template_universal_item(),\n  };\n};\n\ntype NpcClassModelSchema = ReturnType<typeof defineNpcClassModelSchema>;\n\nexport class NpcClassModel extends LancerDataModel<NpcClassModelSchema, Item.Implementation, BaseData.NpcClass> {\n  static DEFAULT_ICON = \"systems/lancer/assets/icons/npc_class.svg\";\n  static defineSchema() {\n    return defineNpcClassModelSchema();\n  }\n\n  static migrateData(data: any) {\n    data.flavor ??= data.info?.flavor;\n    data.tactics ??= data.info?.tactics;\n\n    // Convert old regrefs\n    data.base_features = data.base_features?.map((bf: string | object) => regRefToLid(bf)).filter((x: any) => x);\n    data.optional_features = data.optional_features\n      ?.map((of: string | object) => regRefToLid(of))\n      .filter((x: any) => x);\n\n    // Invert stats\n    if (typeof data.base_stats == \"object\" && !Array.isArray(data.base_stats)) {\n      data.base_stats = convertNpcStats(data.base_stats);\n    }\n    if (data.base_stats) {\n      // Ensure sizes are reasonable values\n      for (let i = 0; i < data.base_stats.length; i++) {\n        if (data.base_stats[i].size !== undefined) {\n          // Size of 1 and higher must be integer values\n          if (data.base_stats[i].size >= 1.0) {\n            data.base_stats[i].size = Math.floor(data.base_stats[i].size);\n          } else {\n            // Sizes below 1 must be 1/2\n            data.base_stats[i].size = 0.5;\n          }\n        }\n      }\n    }\n\n    return super.migrateData(data);\n  }\n}\n\n// Converts an lcp bonus into our expected format\nexport function unpackNpcClass(\n  data: PackedNpcClassData,\n  context: UnpackContext\n): {\n  name: string;\n  type: EntryType.NPC_CLASS;\n  img: string | undefined;\n  system: DeepPartial<SourceData.NpcClass>;\n} {\n  // Rebake support - remove trailing \" [K]\"\n  const frameImg = frameToPath(data.name.replace(/ \\[K\\]$/, \"\"));\n  return {\n    name: data.name,\n    type: EntryType.NPC_CLASS,\n    img: frameImg ?? undefined,\n    system: {\n      lid: data.id,\n      role: data.role,\n      flavor: data.info.flavor,\n      tactics: data.info.tactics,\n      base_features: data.base_features as any,\n      optional_features: data.optional_features as any,\n      base_stats: convertNpcStats(data.stats),\n    },\n  };\n}\n","import type { DeepPartial } from \"fvtt-types/utils\";\nimport { EntryType } from \"../../enums\";\nimport type { SourceData } from \"../../source-template\";\nimport type { BaseData } from \"../../base-data\";\nimport { regRefToLid } from \"../../util/migrations\";\nimport type { PackedNpcTemplateData } from \"../../util/unpacking/packed-types\";\nimport { LancerDataModel, LIDField, type UnpackContext } from \"../shared\";\nimport { template_universal_item } from \"./shared\";\n\nimport fields = foundry.data.fields;\n\nconst defineNpcTemplateModelSchema = () => {\n  return {\n    description: new fields.HTMLField(),\n    base_features: new fields.SetField(new LIDField()),\n    optional_features: new fields.SetField(new LIDField()),\n    ...template_universal_item(),\n  };\n};\n\ntype NpcTemplateModelSchema = ReturnType<typeof defineNpcTemplateModelSchema>;\n\nexport class NpcTemplateModel extends LancerDataModel<\n  NpcTemplateModelSchema,\n  Item.Implementation,\n  BaseData.NpcTemplate\n> {\n  static DEFAULT_ICON = \"systems/lancer/assets/icons/npc_template.svg\";\n  static defineSchema() {\n    return defineNpcTemplateModelSchema();\n  }\n\n  static migrateData(data: any) {\n    // Convert old regrefs\n    data.base_features = data.base_features?.map((bf: string | object) => regRefToLid(bf)).filter((x: any) => x);\n    data.optional_features = data.optional_features\n      ?.map((of: string | object) => regRefToLid(of))\n      .filter((x: any) => x);\n\n    return super.migrateData(data);\n  }\n}\n\n// Converts an lcp bonus into our expected format\nexport function unpackNpcTemplate(\n  data: PackedNpcTemplateData,\n  context: UnpackContext\n): {\n  name: string;\n  type: EntryType.NPC_TEMPLATE;\n  system: DeepPartial<SourceData.NpcTemplate>;\n} {\n  return {\n    name: data.name,\n    type: EntryType.NPC_TEMPLATE,\n    system: {\n      lid: data.id,\n      description: data.description,\n      base_features: data.base_features as any,\n      optional_features: data.optional_features as any,\n    },\n  };\n}\n","import type { DeepPartial } from \"fvtt-types/utils\";\nimport { EntryType, NpcFeatureType, NpcTechType } from \"../../enums\";\nimport { restrict_enum } from \"../../helpers/commons\";\nimport type { SourceData, SourceTemplates } from \"../../source-template\";\nimport type { BaseData } from \"../../base-data\";\nimport { convertNpcStats } from \"../../util/migrations\";\nimport type {\n  PackedNpcReactionData,\n  PackedNpcSystemData,\n  PackedNpcTechData,\n  PackedNpcTraitData,\n  PackedNpcWeaponData,\n} from \"../../util/unpacking/packed-types\";\nimport { type DamageData, DamageField, unpackDamage } from \"../bits/damage\";\nimport { RangeField, unpackRange } from \"../bits/range\";\nimport { TagField, unpackTag } from \"../bits/tag\";\nimport { LancerDataModel, NpcStatBlockField, type UnpackContext } from \"../shared\";\nimport { template_destructible, template_universal_item, template_uses } from \"./shared\";\n\nimport fields = foundry.data.fields;\n\nconst defineNpcFeatureModelSchema = () => {\n  return {\n    effect: new fields.HTMLField(),\n    bonus: new NpcStatBlockField({ nullable: true }),\n    override: new NpcStatBlockField({ nullable: true }),\n    tags: new fields.ArrayField(new TagField()),\n    type: new fields.StringField({ choices: Object.values(NpcFeatureType), initial: NpcFeatureType.Trait }),\n\n    charged: new fields.BooleanField(),\n    loaded: new fields.BooleanField(),\n\n    tier_override: new fields.NumberField({ integer: true, min: 0, max: 3 }),\n\n    // Weapon\n    weapon_type: new fields.StringField(),\n    damage: new fields.ArrayField(new fields.ArrayField(new DamageField())),\n    range: new fields.ArrayField(new RangeField()),\n    on_hit: new fields.HTMLField(),\n    accuracy: new fields.ArrayField(new fields.NumberField({ integer: true, initial: 0 }), {\n      min: 3,\n      max: 3,\n      initial: [0, 0, 0],\n    }),\n    attack_bonus: new fields.ArrayField(new fields.NumberField({ integer: true, initial: 0 }), {\n      min: 3,\n      max: 3,\n      initial: [0, 0, 0],\n    }),\n\n    // Trait - N/A\n\n    // Reaction\n    trigger: new fields.StringField(),\n\n    // System - N/A\n\n    // Tech - mostly covered by weapon\n    tech_type: new fields.StringField({ choices: Object.values(NpcTechType), initial: NpcTechType.Quick }),\n    tech_attack: new fields.BooleanField({ nullable: true, initial: null }),\n\n    // Origin data - track where it came from\n    origin: new fields.SchemaField({\n      type: new fields.StringField(),\n      name: new fields.StringField(),\n      base: new fields.BooleanField(),\n    }),\n\n    // Templates\n    ...template_destructible(),\n    ...template_uses(),\n    ...template_universal_item(),\n  };\n};\n\ntype NpcFeatureModelSchema = ReturnType<typeof defineNpcFeatureModelSchema>;\n\nexport class NpcFeatureModel extends LancerDataModel<NpcFeatureModelSchema, Item.Implementation, BaseData.NpcFeature> {\n  static DEFAULT_ICON = \"systems/lancer/assets/icons/npc_feature.svg\";\n  static getDefaultArtwork(itemData?: Item.CreateData): Item.GetDefaultArtworkReturn {\n    let img = this.DEFAULT_ICON;\n    switch (itemData?.system?.type) {\n      case NpcFeatureType.Reaction:\n        img = \"systems/lancer/assets/icons/reaction.svg\";\n        break;\n      case NpcFeatureType.System:\n        img = \"systems/lancer/assets/icons/system.svg\";\n        break;\n      case NpcFeatureType.Tech:\n        img = \"systems/lancer/assets/icons/tech_full.svg\";\n        break;\n      case NpcFeatureType.Trait:\n        img = \"systems/lancer/assets/icons/trait.svg\";\n        break;\n      case NpcFeatureType.Weapon:\n        img = \"systems/lancer/assets/icons/weapon.svg\";\n        break;\n    }\n    return { img };\n  }\n\n  static defineSchema() {\n    return defineNpcFeatureModelSchema();\n  }\n\n  static migrateData(data: any) {\n    // Fix stats\n    if (data.bonus && typeof data.bonus == \"object\" && !Array.isArray(data.bonus)) {\n      data.bonus = convertNpcStats(data.bonus)[0];\n    }\n    if (data.override && typeof data.override == \"object\" && !Array.isArray(data.override)) {\n      data.override = convertNpcStats(data.override)[0];\n    }\n    // Non-tech features should not have tech_attack\n    if (data.type && data.type !== NpcFeatureType.Tech) {\n      data.tech_attack = false;\n    } else if (data.tech_attack === null) {\n      // Populate tech_attack if missing\n      data.tech_attack = !!data.attack_bonus || !!data.accuracy;\n    }\n\n    return super.migrateData(data);\n  }\n}\n\n// Converts an lcp bonus into our expected format\nexport function unpackNpcFeature(\n  data: PackedNpcReactionData | PackedNpcSystemData | PackedNpcTechData | PackedNpcTraitData | PackedNpcWeaponData,\n  context: UnpackContext\n): {\n  name: string;\n  type: EntryType.NPC_FEATURE;\n  system: DeepPartial<SourceData.NpcFeature>;\n} {\n  let base = {\n    name: data.name,\n    type: EntryType.NPC_FEATURE as const,\n    system: {\n      lid: data.id,\n      effect: data.effect,\n      bonus: data.bonus,\n      override: data.override,\n      tags: (data.tags || []).map(unpackTag),\n      type: data.type,\n\n      origin: data.origin,\n\n      charged: undefined,\n      uses: undefined,\n      loaded: undefined,\n      destroyed: undefined,\n\n      tier_override: 0,\n    },\n  };\n\n  // Then do our specific features - if they aren't needed they won't be used!\n  if (data.type == NpcFeatureType.Reaction) {\n    let bs = base.system as Partial<SourceTemplates.NPC.ReactionData>;\n    bs.trigger = data.trigger;\n  } else if (data.type == NpcFeatureType.System) {\n  } else if (data.type == NpcFeatureType.Trait) {\n  } else if (data.type == NpcFeatureType.Tech) {\n    let bs = base.system as Partial<SourceTemplates.NPC.TechData>;\n    bs.tech_type = restrict_enum(NpcTechType, NpcTechType.Quick, data.tech_type);\n    bs.accuracy = data.accuracy ?? [0, 0, 0];\n    bs.attack_bonus = data.attack_bonus ?? [0, 0, 0];\n    bs.tech_attack = !!data.attack_bonus || !!data.accuracy;\n  } else if (data.type == NpcFeatureType.Weapon) {\n    let bs = base.system as Partial<SourceTemplates.NPC.WeaponData>;\n    bs.accuracy = data.accuracy ?? [0, 0, 0];\n    bs.attack_bonus = data.attack_bonus ?? [0, 0, 0];\n    bs.weapon_type = data.weapon_type;\n    bs.on_hit = data.on_hit;\n\n    // Build out damage\n    bs.damage = [];\n    let i = 0;\n    let done = false;\n    while (!done) {\n      done = true;\n      let sub_damage: DamageData[] = [];\n      for (let d of data.damage) {\n        if (d.damage.length > i) {\n          sub_damage.push(\n            unpackDamage({\n              type: d.type as any,\n              val: d.damage[i],\n            })\n          );\n          done = false;\n        }\n      }\n      if (!done) bs.damage.push(sub_damage);\n      i += 1;\n    }\n\n    // Build out range\n    bs.range = data.range.map(unpackRange);\n  }\n\n  return base;\n}\n","import type { DeepPartial } from \"fvtt-types/utils\";\nimport { EntryType } from \"../../enums\";\nimport { restrict_choices } from \"../../helpers/commons\";\nimport type { SourceData } from \"../../source-template\";\nimport type { BaseData } from \"../../base-data\";\nimport type { PackedStatusData } from \"../../util/unpacking/packed-types\";\nimport { LancerDataModel, type UnpackContext } from \"../shared\";\nimport { template_universal_item } from \"./shared\";\n\nimport fields = foundry.data.fields;\n\ntype ActiveEffectData = ActiveEffect.InitializedData;\n\nconst defineStatusModelSchema = () => {\n  return {\n    effects: new fields.HTMLField(),\n    type: new fields.StringField({ choices: [\"status\", \"condition\", \"effect\"], initial: \"effect\" }),\n    ...template_universal_item(),\n  };\n};\n\ntype StatusModelSchema = ReturnType<typeof defineStatusModelSchema>;\n\nexport class StatusModel extends LancerDataModel<StatusModelSchema, Item.Implementation, BaseData.Status> {\n  static DEFAULT_ICON = \"systems/lancer/assets/icons/reticule.svg\";\n  static defineSchema() {\n    return defineStatusModelSchema();\n  }\n\n  static migrateData(data: any) {\n    if (data.type) data.type = data.type.toLowerCase(); // Fix \"Condition\" / \"Status\"\n    return super.migrateData(data);\n  }\n\n  async _preCreate(\n    ...[data, options, user]: Parameters<\n      LancerDataModel<foundry.data.fields.DataSchema, Item.Implementation>[\"_preCreate\"]\n    >\n  ) {\n    const allowed = await super._preCreate(data as any, options, user);\n    if (allowed === false) return false;\n    // Apply the corresponding status instead of creating the item if it's being created as embedded\n    if (this.parent.parent) {\n      this.parent.parent.toggleStatusEffect(this.lid, { active: true });\n      return false;\n    }\n  }\n}\n\nexport function generateStunnedEffect({ name = \"Stunned\", description = \"\" }): Partial<ActiveEffectData> {\n  return {\n    name,\n    description,\n    changes: [\n      {\n        key: \"system.evasion\",\n        mode: CONST.ACTIVE_EFFECT_MODES.OVERRIDE,\n        priority: null,\n        value: \"5\",\n      },\n    ],\n  };\n}\n\n// Converts an lcp bonus into our expected format\nexport function unpackStatus(\n  data: PackedStatusData,\n  _context: UnpackContext\n): {\n  name: string;\n  type: EntryType.STATUS;\n  img: string;\n  effects: Partial<ActiveEffectData>[];\n  system: DeepPartial<SourceData.Status>;\n} {\n  const lid = data.id || data.icon.replace(\"-\", \"\") || data.name.toLowerCase();\n  const img = `systems/lancer/assets/icons/white/${data.type.toLowerCase()}_${lid}.svg`;\n  const effects = Array.isArray(data.effects) ? data.effects.join(\"<br>\") : data.effects;\n  let effect: Partial<ActiveEffectData> | undefined = undefined;\n  // Special case for the one status/condition that actually modifies a stat\n  if (lid === \"stunned\") {\n    effect = generateStunnedEffect({ name: data.name, description: effects });\n  }\n  return {\n    name: data.name,\n    type: EntryType.STATUS,\n    img,\n    effects: effect ? [effect] : [],\n    system: {\n      lid,\n      effects,\n      terse: data.terse,\n      type: restrict_choices([\"status\", \"condition\", \"effect\"], \"effect\", data.type) as\n        | \"status\"\n        | \"condition\"\n        | \"effect\",\n    },\n  };\n}\n","import { EntryType } from \"../../enums\";\nimport {\n  template_action_tracking,\n  template_heat,\n  template_statuses,\n  template_struss,\n  template_universal_actor,\n} from \"./shared\";\n\nimport type { DeepPartial } from \"fvtt-types/utils\";\nimport type { SourceData } from \"../../source-template\";\nimport type { BaseData } from \"../../base-data\";\nimport { LancerDataModel } from \"../shared\";\n\nimport fields = foundry.data.fields;\n\nconst npc_schema = {\n  destroyed: new fields.BooleanField({ initial: false }),\n  meltdown_timer: new fields.NumberField({ required: false, nullable: true, integer: true, min: 0 }),\n  notes: new fields.HTMLField(),\n  tier: new fields.NumberField({ min: 1, max: 3, initial: 1, integer: true }),\n\n  ...template_universal_actor(),\n  ...template_action_tracking(),\n  ...template_heat(),\n  ...template_statuses(),\n  ...template_struss(),\n};\n\ntype NpcSchema = typeof npc_schema;\nexport class NpcModel extends LancerDataModel<NpcSchema, Actor.Implementation, BaseData.Npc> {\n  static DEFAULT_ICON = \"systems/lancer/assets/icons/npc_class.svg\";\n  static defineSchema(): NpcSchema {\n    return npc_schema;\n  }\n}\n\nexport function generateNpcDataFromClass(npc_class: {\n  name: string;\n  type: EntryType.NPC_CLASS;\n  img: string | undefined;\n  system: DeepPartial<SourceData.NpcClass>;\n}): {\n  name: string;\n  type: EntryType.NPC;\n  img: string | undefined;\n  system: DeepPartial<SourceData.Npc>;\n} {\n  return {\n    name: npc_class.name,\n    type: EntryType.NPC,\n    img: npc_class.img ?? undefined,\n    system: {\n      notes: `Updated via LCP import at ${new Date().toISOString()}`,\n    },\n  };\n}\n","import { LANCER } from \"./config\";\nconst lp = LANCER.log_prefix;\nimport { LCPIndex } from \"./apps/lcp-manager/lcp-manager\";\nimport { get_pack, get_pack_id } from \"./util/doc\";\nimport type { LancerActor, LancerNPC } from \"./actor/lancer-actor\";\nimport { LancerItem } from \"./item/lancer-item\";\nimport { EntryType } from \"./enums\";\nimport type {\n  IContentPack,\n  PackedPilotArmorData,\n  PackedPilotGearData,\n  PackedPilotWeaponData,\n} from \"./util/unpacking/packed-types\";\nimport type { UnpackContext } from \"./models/shared\";\nimport { unpackMechWeapon } from \"./models/items/mech_weapon\";\nimport { unpackFrame } from \"./models/items/frame\";\nimport { unpackMechSystem } from \"./models/items/mech_system\";\nimport { unpackCoreBonus } from \"./models/items/core_bonus\";\nimport { type TagTemplateData, unpackTagTemplate } from \"./models/bits/tag\";\nimport { unpackTalent } from \"./models/items/talent\";\nimport { unpackBond } from \"./models/items/bond\";\nimport { unpackPilotArmor } from \"./models/items/pilot_armor\";\nimport { unpackPilotGear } from \"./models/items/pilot_gear\";\nimport { unpackPilotWeapon } from \"./models/items/pilot_weapon\";\nimport { unpackSkill } from \"./models/items/skill\";\nimport { unpackLicense } from \"./models/items/license\";\nimport { unpackNpcClass } from \"./models/items/npc_class\";\nimport { unpackNpcTemplate } from \"./models/items/npc_template\";\nimport { unpackNpcFeature } from \"./models/items/npc_feature\";\nimport { unpackWeaponMod } from \"./models/items/weapon_mod\";\nimport { unpackReserve } from \"./models/items/reserve\";\nimport { unpackStatus } from \"./models/items/status\";\nimport { generateNpcDataFromClass } from \"./models/actors/npc\";\nimport { fromLid } from \"./helpers/from-lid\";\n\nexport const PACK_SCOPE = \"world\";\nconst packTypes = Object.values(EntryType).filter(et => ![EntryType.MECH, EntryType.PILOT].includes(et));\n\n// Clear all packs\nexport async function clearAll(v1 = false): Promise<void> {\n  await setAllLock(false, v1);\n  const pack_ids = v1\n    ? new Set(Object.values(EntryType).map(et => `world.${et}`))\n    : new Set(Object.values(EntryType).map(get_pack_id));\n  for (let p of pack_ids) {\n    let pack = game.packs.get(p);\n    if (!pack) continue;\n\n    const keys = Array.from(pack.index.keys());\n    await pack.documentClass.deleteDocuments(keys, { pack: pack.collection });\n    await Folder.deleteDocuments(Array.from(pack.folders.keys()), { pack: pack.collection });\n  }\n  await setAllLock(true, v1);\n}\n\nexport async function importCP(\n  cp: IContentPack,\n  progress_callback?: (done: number, out_of: number) => void\n): Promise<void> {\n  await setAllLock(false);\n\n  try {\n    // Stub in a progress callback so we don't have to null check it all the time\n    if (!progress_callback) {\n      progress_callback = (_a, _b) => {};\n    }\n\n    // Count the total items in the reg. We only do this for progress bar accurace\n    let totalItems = 0;\n    totalItems += cp.data.coreBonuses?.length ?? 0;\n    totalItems += cp.data.frames?.length ?? 0;\n    totalItems += cp.data.mods?.length ?? 0;\n    totalItems += cp.data.npcClasses?.length ?? 0;\n    totalItems += cp.data.npcFeatures?.length ?? 0;\n    totalItems += cp.data.npcTemplates?.length ?? 0;\n    totalItems += cp.data.pilotGear?.length ?? 0;\n    totalItems += cp.data.reserves?.length ?? 0;\n    totalItems += cp.data.skills?.length ?? 0;\n    totalItems += cp.data.statuses?.length ?? 0;\n    totalItems += cp.data.systems?.length ?? 0;\n    totalItems += cp.data.tags?.length ?? 0;\n    totalItems += cp.data.talents?.length ?? 0;\n    totalItems += cp.data.bonds?.length ?? 0;\n    totalItems += cp.data.weapons?.length ?? 0;\n    // We need to double count NPC classes since we'll also be creating actors for them,\n    // And then add again all the base features.\n    totalItems += cp.data.npcClasses?.length ?? 0;\n    totalItems += cp.data.npcClasses?.reduce((acc, nc) => acc + (nc.base_features?.length ?? 0), 0) ?? 0;\n\n    // Iterate over everything in core, collecting all lids into a map of LID -> document\n    let existingLids: Map<string, LancerItem | LancerActor> = new Map();\n    for (let et of packTypes) {\n      let pack = await get_pack(et);\n      // Get them all\n      // TODO: Use the index to improve performance\n      let docs = await pack.getDocuments();\n      // Get their ids\n      docs.forEach(d => {\n        existingLids.set((d as LancerActor | LancerItem).system.lid || d.name, d as LancerActor | LancerItem);\n      });\n    }\n\n    // Import data to the actual foundry reg\n    let transmitCount = 0;\n    let progress_hook = (doc: any) => {\n      if (doc.pack && !doc.parent) {\n        // Presumably part of this import\n        transmitCount++;\n        progress_callback!(transmitCount, totalItems);\n      }\n    };\n    Hooks.on(\"createItem\", progress_hook);\n    Hooks.on(\"createActor\", progress_hook);\n\n    let context: UnpackContext = {\n      createdDeployables: [],\n    };\n\n    let allCoreBonuses = cp.data.coreBonuses?.map(cb => unpackCoreBonus(cb, context)) ?? [];\n    let allFrames = cp.data.frames?.map(d => unpackFrame(d, context)) ?? [];\n    let allMods = cp.data.mods?.map(d => unpackWeaponMod(d, context)) ?? [];\n    let allNpcClasses = cp.data.npcClasses?.map(d => unpackNpcClass(d, context)) ?? [];\n    let allNpcs = allNpcClasses.map(d => generateNpcDataFromClass(d)) ?? [];\n    let allNpcFeatures = cp.data.npcFeatures?.map(d => unpackNpcFeature(d, context)) ?? [];\n    let allNpcTemplates = cp.data.npcTemplates?.map(d => unpackNpcTemplate(d, context)) ?? [];\n    let allPilotArmor =\n      cp.data.pilotGear\n        ?.filter(g => g.type == \"Armor\")\n        .map(pa => unpackPilotArmor(pa as PackedPilotArmorData, context)) ?? [];\n    let allPilotGear =\n      cp.data.pilotGear?.filter(g => g.type == \"Gear\").map(pa => unpackPilotGear(pa as PackedPilotGearData, context)) ??\n      [];\n    let allPilotWeapons =\n      cp.data.pilotGear\n        ?.filter(g => g.type == \"Weapon\")\n        .map(pa => unpackPilotWeapon(pa as PackedPilotWeaponData, context)) ?? [];\n    let allReserves = cp.data.reserves?.map(s => unpackReserve(s, context)) ?? [];\n    let allSkills = cp.data.skills?.map(s => unpackSkill(s, context)) ?? [];\n    let allStatuses = cp.data.statuses?.map(s => unpackStatus(s, context)) ?? [];\n    let allSystems = cp.data.systems?.map(s => unpackMechSystem(s, context)) ?? [];\n    let allTags = cp.data.tags?.map(t => unpackTagTemplate(t)) ?? [];\n    let allTalents = cp.data.talents?.map(t => unpackTalent(t, context)) ?? [];\n    let allBonds = cp.data.bonds?.map(b => unpackBond(b)) ?? [];\n    let allWeapons = cp.data.weapons?.map(d => unpackMechWeapon(d, context)) ?? [];\n    let allLicenses = [];\n    let existingLicenses =\n      (await game.packs.get(get_pack_id(EntryType.LICENSE))?.getDocuments({ type: EntryType.LICENSE }))?.map(\n        l => (l as any).system.key\n      ) ?? [];\n    for (let frame of cp.data.frames ?? []) {\n      let lid = frame.license_id ?? frame.id;\n      // Check existing\n      if (existingLicenses.includes(lid)) continue;\n      allLicenses.push(unpackLicense(frame.name, lid, frame.source, context));\n    }\n\n    // Get creating, or updating if the lid is already created. Typing is extremely fuzzy here, sorry, I just didn't really want to fight it\n    const createOrUpdateDocs = async (doc_class: any, item_data: Array<any>, et: EntryType) => {\n      let existingUpdates = [];\n      let newCreates = [];\n      let pack = await get_pack(et);\n      let folder: Folder | undefined = [EntryType.NPC, EntryType.STATUS].includes(et)\n        ? undefined\n        : pack.folders.find(f => f.getFlag(game.system.id, \"entrytype\") === et) ??\n          (await Folder.create(\n            {\n              name: game.i18n.localize(`TYPES.${pack.metadata.type}.${et}`),\n              type: pack.metadata.type,\n              [`flags.${game.system.id}.entrytype`]: et,\n            },\n            { pack: get_pack_id(et) }\n          ));\n      let results = [];\n      for (let d of item_data) {\n        let key = d.system.lid || d.name;\n        let existing = existingLids.get(key);\n        if (existing) {\n          // Formulate as an update\n          existingUpdates.push({\n            ...d,\n            _id: existing.id,\n            folder: folder?.id,\n          });\n        } else {\n          d.folder = folder?.id;\n          // Formulate as a doc\n          newCreates.push(d);\n        }\n      }\n      results.push(...(await doc_class.createDocuments(newCreates, { pack: get_pack_id(et) })));\n      results.push(...(await doc_class.updateDocuments(existingUpdates, { pack: get_pack_id(et) })));\n      return results;\n    };\n\n    await createOrUpdateDocs(CONFIG.Item.documentClass, allCoreBonuses, EntryType.CORE_BONUS);\n    await createOrUpdateDocs(CONFIG.Item.documentClass, allFrames, EntryType.FRAME);\n    await createOrUpdateDocs(CONFIG.Item.documentClass, allMods, EntryType.WEAPON_MOD);\n    await createOrUpdateDocs(CONFIG.Item.documentClass, allLicenses, EntryType.LICENSE);\n    await createOrUpdateDocs(CONFIG.Item.documentClass, allNpcClasses, EntryType.NPC_CLASS);\n    await createOrUpdateDocs(CONFIG.Item.documentClass, allNpcTemplates, EntryType.NPC_TEMPLATE);\n    await createOrUpdateDocs(CONFIG.Item.documentClass, allNpcFeatures, EntryType.NPC_FEATURE);\n    await createOrUpdateDocs(CONFIG.Item.documentClass, allPilotArmor, EntryType.PILOT_ARMOR);\n    await createOrUpdateDocs(CONFIG.Item.documentClass, allPilotGear, EntryType.PILOT_GEAR);\n    await createOrUpdateDocs(CONFIG.Item.documentClass, allPilotWeapons, EntryType.PILOT_WEAPON);\n    await createOrUpdateDocs(CONFIG.Item.documentClass, allReserves, EntryType.RESERVE);\n    await createOrUpdateDocs(CONFIG.Item.documentClass, allSkills, EntryType.SKILL);\n    await createOrUpdateDocs(CONFIG.Item.documentClass, allStatuses, EntryType.STATUS);\n    await createOrUpdateDocs(CONFIG.Item.documentClass, allSystems, EntryType.MECH_SYSTEM);\n    await createOrUpdateDocs(CONFIG.Item.documentClass, allTalents, EntryType.TALENT);\n    await createOrUpdateDocs(CONFIG.Item.documentClass, allBonds, EntryType.BOND);\n    await createOrUpdateDocs(CONFIG.Item.documentClass, allWeapons, EntryType.MECH_WEAPON);\n    await createOrUpdateDocs(CONFIG.Actor.documentClass, context.createdDeployables, EntryType.DEPLOYABLE);\n\n    // NPC actor generation needs to wait until here so that the features are properly populated in the compendium\n    const npcActors: LancerNPC[] = await createOrUpdateDocs(CONFIG.Actor.documentClass, allNpcs, EntryType.NPC);\n    const npcPromises = [];\n    // Create each NPC and add its class item\n    for (let npc of npcActors) {\n      // Remove existing class\n      const existingClass = npc.items.find(i => i.type === EntryType.NPC_CLASS);\n      if (existingClass) {\n        await npc.removeClassFeatures(existingClass);\n        await npc.deleteEmbeddedDocuments(\"Item\", [existingClass.id!]);\n      }\n      // Find the class and add it to the NPC\n      let classLid = allNpcClasses.find(n => n.name === npc.name)?.system.lid;\n      if (!classLid) continue;\n      let thisClass = (await fromLid(classLid, { source: \"compendium\" })) as LancerItem;\n      if (thisClass) {\n        await npc.quickOwn(thisClass);\n        npcPromises.push(...npc.npcClassSwapPromises);\n      }\n    }\n    await Promise.all(npcPromises);\n\n    // Tags are stored in config\n    let newTagConfig = foundry.utils.duplicate(game.settings.get(game.system.id, LANCER.setting_tag_config)) as Record<\n      string,\n      TagTemplateData\n    >;\n    for (let t of allTags) {\n      transmitCount++;\n      newTagConfig[t.lid] = t;\n      progress_callback(transmitCount, totalItems);\n    }\n    game.settings.set(game.system.id, LANCER.setting_tag_config, newTagConfig);\n\n    Hooks.off(\"createItem\", progress_hook);\n    Hooks.off(\"createActor\", progress_hook);\n\n    // Finish by forcing all packs to re-prepare\n    for (let p of packTypes) {\n      (await get_pack(p)).clear();\n    }\n    progress_callback(transmitCount, totalItems);\n  } catch (err) {\n    console.error(err);\n  }\n  await setAllLock(true);\n}\n\n// Lock/Unlock all packs\nexport let IS_IMPORTING = false;\nexport async function setAllLock(lock = false, v1 = false) {\n  IS_IMPORTING = !lock;\n  const pack_ids = v1\n    ? new Set(Object.values(EntryType).map(et => `world.${et}`))\n    : new Set(Object.values(EntryType).map(get_pack_id));\n  for (let p of pack_ids) {\n    let pack = game.packs.get(p);\n    await pack?.configure({ locked: lock });\n  }\n}\n\n/**\n * Wipe data from all compendiums generated by the system\n * @param options Options to configure behaviour\n * @param options.v1 Whether to clear v1 data\n */\nexport async function clearCompendiumData(options = { v1: false }) {\n  ui.notifications!.info(`Clearing all LANCER Compendium data. Please wait.`);\n  console.log(`${lp} Clearing all LANCER Compendium data.`);\n  await game.settings.set(game.system.id, LANCER.setting_core_data, \"\");\n  await game.settings.set(game.system.id, LANCER.setting_lcps, new LCPIndex(null));\n  await clearAll(options.v1);\n  ui.notifications!.info(`LANCER Compendiums cleared.`);\n}\n\ndeclare module \"fvtt-types/configuration\" {\n  interface FlagConfig {\n    Folder: {\n      lancer: {\n        entrytype: EntryType;\n      };\n    };\n  }\n}\n"],"mappings":";;;IAOO,IAAS,QAAQ,KAAK,QAEvB,KAAyB;CAC7B,UAAU;CACV,OAAO;CACP,UAAU;CACV,SAAS;CACT,UAAU;CACV,iBAAiB;AACnB,GAQM,KAAN,MAAM,uBAA4F,EAAO,YAEvG;CAEA,WAAW,YAAY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