{"version":3,"file":"SkeletonData.mjs","sources":["../../src/core/SkeletonData.ts"],"sourcesContent":["import type { ISkeletonData } from '@pixi-spine/base';\nimport type { Animation } from './Animation';\nimport type { BoneData } from './BoneData';\nimport type { SlotData } from './SlotData';\nimport type { Skin } from './Skin';\nimport type { EventData } from './EventData';\nimport type { IkConstraintData } from './IkConstraintData';\nimport type { TransformConstraintData } from './TransformConstraintData';\nimport type { PathConstraintData } from './PathConstraintData';\n\n/** Stores the setup pose and all of the stateless data for a skeleton.\n *\n * See [Data objects](http://esotericsoftware.com/spine-runtime-architecture#Data-objects) in the Spine Runtimes\n * Guide.\n * @public\n * */\nexport class SkeletonData implements ISkeletonData<BoneData, SlotData, Skin, Animation, EventData, IkConstraintData, TransformConstraintData, PathConstraintData> {\n    /** The skeleton's name, which by default is the name of the skeleton data file, if possible. May be null. */\n    name: string | null = null;\n\n    /** The skeleton's bones, sorted parent first. The root bone is always the first bone. */\n    bones = new Array<BoneData>(); // Ordered parents first.\n\n    /** The skeleton's slots. */\n    slots = new Array<SlotData>(); // Setup pose draw order.\n    skins = new Array<Skin>();\n\n    /** The skeleton's default skin. By default this skin contains all attachments that were not in a skin in Spine.\n     *\n     * See {@link Skeleton#getAttachmentByName()}.\n     * May be null. */\n    defaultSkin: Skin | null = null;\n\n    /** The skeleton's events. */\n    events = new Array<EventData>();\n\n    /** The skeleton's animations. */\n    animations = new Array<Animation>();\n\n    /** The skeleton's IK constraints. */\n    ikConstraints = new Array<IkConstraintData>();\n\n    /** The skeleton's transform constraints. */\n    transformConstraints = new Array<TransformConstraintData>();\n\n    /** The skeleton's path constraints. */\n    pathConstraints = new Array<PathConstraintData>();\n\n    /** The X coordinate of the skeleton's axis aligned bounding box in the setup pose. */\n    x = 0;\n\n    /** The Y coordinate of the skeleton's axis aligned bounding box in the setup pose. */\n    y = 0;\n\n    /** The width of the skeleton's axis aligned bounding box in the setup pose. */\n    width = 0;\n\n    /** The height of the skeleton's axis aligned bounding box in the setup pose. */\n    height = 0;\n\n    /** The Spine version used to export the skeleton data, or null. */\n    version: string | null = null;\n\n    /** The skeleton data hash. This value will change if any of the skeleton data has changed. May be null. */\n    hash: string | null = null;\n\n    // Nonessential\n    /** The dopesheet FPS in Spine. Available only when nonessential data was exported. */\n    fps = 0;\n\n    /** The path to the images directory as defined in Spine. Available only when nonessential data was exported. May be null. */\n    imagesPath: string | null = null;\n\n    /** The path to the audio directory as defined in Spine. Available only when nonessential data was exported. May be null. */\n    audioPath: string | null = null;\n\n    /** Finds a bone by comparing each bone's name. It is more efficient to cache the results of this method than to call it\n     * multiple times.\n     * @returns May be null. */\n    findBone(boneName: string) {\n        if (!boneName) throw new Error('boneName cannot be null.');\n        const bones = this.bones;\n\n        for (let i = 0, n = bones.length; i < n; i++) {\n            const bone = bones[i];\n\n            if (bone.name == boneName) return bone;\n        }\n\n        return null;\n    }\n\n    /** removed from spine-ts runtime **/\n    findBoneIndex(boneName: string) {\n        if (!boneName) throw new Error('boneName cannot be null.');\n        const bones = this.bones;\n\n        for (let i = 0, n = bones.length; i < n; i++) if (bones[i].name == boneName) return i;\n\n        return -1;\n    }\n\n    /** Finds a slot by comparing each slot's name. It is more efficient to cache the results of this method than to call it\n     * multiple times.\n     * @returns May be null. */\n    findSlot(slotName: string) {\n        if (!slotName) throw new Error('slotName cannot be null.');\n        const slots = this.slots;\n\n        for (let i = 0, n = slots.length; i < n; i++) {\n            const slot = slots[i];\n\n            if (slot.name == slotName) return slot;\n        }\n\n        return null;\n    }\n\n    /** removed from spine-ts runtime **/\n    findSlotIndex(slotName: string) {\n        if (!slotName) throw new Error('slotName cannot be null.');\n        const slots = this.slots;\n\n        for (let i = 0, n = slots.length; i < n; i++) if (slots[i].name == slotName) return i;\n\n        return -1;\n    }\n\n    /** Finds a skin by comparing each skin's name. It is more efficient to cache the results of this method than to call it\n     * multiple times.\n     * @returns May be null. */\n    findSkin(skinName: string) {\n        if (!skinName) throw new Error('skinName cannot be null.');\n        const skins = this.skins;\n\n        for (let i = 0, n = skins.length; i < n; i++) {\n            const skin = skins[i];\n\n            if (skin.name == skinName) return skin;\n        }\n\n        return null;\n    }\n\n    /** Finds an event by comparing each events's name. It is more efficient to cache the results of this method than to call it\n     * multiple times.\n     * @returns May be null. */\n    findEvent(eventDataName: string) {\n        if (!eventDataName) throw new Error('eventDataName cannot be null.');\n        const events = this.events;\n\n        for (let i = 0, n = events.length; i < n; i++) {\n            const event = events[i];\n\n            if (event.name == eventDataName) return event;\n        }\n\n        return null;\n    }\n\n    /** Finds an animation by comparing each animation's name. It is more efficient to cache the results of this method than to\n     * call it multiple times.\n     * @returns May be null. */\n    findAnimation(animationName: string) {\n        if (!animationName) throw new Error('animationName cannot be null.');\n        const animations = this.animations;\n\n        for (let i = 0, n = animations.length; i < n; i++) {\n            const animation = animations[i];\n\n            if (animation.name == animationName) return animation;\n        }\n\n        return null;\n    }\n\n    /** Finds an IK constraint by comparing each IK constraint's name. It is more efficient to cache the results of this method\n     * than to call it multiple times.\n     * @return May be null. */\n    findIkConstraint(constraintName: string) {\n        if (!constraintName) throw new Error('constraintName cannot be null.');\n        const ikConstraints = this.ikConstraints;\n\n        for (let i = 0, n = ikConstraints.length; i < n; i++) {\n            const constraint = ikConstraints[i];\n\n            if (constraint.name == constraintName) return constraint;\n        }\n\n        return null;\n    }\n\n    /** Finds a transform constraint by comparing each transform constraint's name. It is more efficient to cache the results of\n     * this method than to call it multiple times.\n     * @return May be null. */\n    findTransformConstraint(constraintName: string) {\n        if (!constraintName) throw new Error('constraintName cannot be null.');\n        const transformConstraints = this.transformConstraints;\n\n        for (let i = 0, n = transformConstraints.length; i < n; i++) {\n            const constraint = transformConstraints[i];\n\n            if (constraint.name == constraintName) return constraint;\n        }\n\n        return null;\n    }\n\n    /** Finds a path constraint by comparing each path constraint's name. It is more efficient to cache the results of this method\n     * than to call it multiple times.\n     * @return May be null. */\n    findPathConstraint(constraintName: string) {\n        if (!constraintName) throw new Error('constraintName cannot be null.');\n        const pathConstraints = this.pathConstraints;\n\n        for (let i = 0, n = pathConstraints.length; i < n; i++) {\n            const constraint = pathConstraints[i];\n\n            if (constraint.name == constraintName) return constraint;\n        }\n\n        return null;\n    }\n\n    /** removed from spine-ts runtime **/ findPathConstraintIndex(pathConstraintName: string) {\n        if (pathConstraintName == null) throw new Error('pathConstraintName cannot be null.');\n        const pathConstraints = this.pathConstraints;\n\n        for (let i = 0, n = pathConstraints.length; i < n; i++) if (pathConstraints[i].name == pathConstraintName) return i;\n\n        return -1;\n    }\n}\n"],"names":[],"mappings":"AAgBO,MAAM,YAAqJ,CAAA;AAAA,EAA3J,WAAA,GAAA;AAEH;AAAA,IAAsB,IAAA,CAAA,IAAA,GAAA,IAAA,CAAA;AAGtB;AAAA,IAAA,IAAA,CAAA,KAAA,GAAQ,IAAI,KAAgB,EAAA,CAAA;AAG5B;AAAA;AAAA,IAAA,IAAA,CAAA,KAAA,GAAQ,IAAI,KAAgB,EAAA,CAAA;AAC5B;AAAA,IAAA,IAAA,CAAA,KAAA,GAAQ,IAAI,KAAY,EAAA,CAAA;AAMxB;AAAA;AAAA;AAAA;AAAA,IAA2B,IAAA,CAAA,WAAA,GAAA,IAAA,CAAA;AAG3B;AAAA,IAAA,IAAA,CAAA,MAAA,GAAS,IAAI,KAAiB,EAAA,CAAA;AAG9B;AAAA,IAAA,IAAA,CAAA,UAAA,GAAa,IAAI,KAAiB,EAAA,CAAA;AAGlC;AAAA,IAAA,IAAA,CAAA,aAAA,GAAgB,IAAI,KAAwB,EAAA,CAAA;AAG5C;AAAA,IAAA,IAAA,CAAA,oBAAA,GAAuB,IAAI,KAA+B,EAAA,CAAA;AAG1D;AAAA,IAAA,IAAA,CAAA,eAAA,GAAkB,IAAI,KAA0B,EAAA,CAAA;AAGhD;AAAA,IAAI,IAAA,CAAA,CAAA,GAAA,CAAA,CAAA;AAGJ;AAAA,IAAI,IAAA,CAAA,CAAA,GAAA,CAAA,CAAA;AAGJ;AAAA,IAAQ,IAAA,CAAA,KAAA,GAAA,CAAA,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