{"version":3,"file":"sprite.cjs","sources":["../../../src/components/pixi/sprite.ts"],"sourcesContent":["import {\n    AnimatedSprite as PixiAnimatedSprite,\n    NineSliceSprite as PixiNineSliceSprite,\n    Sprite as PixiSprite,\n    Texture,\n    TilingSprite as PixiTilingSprite,\n    type TilingSpriteOptions,\n} from 'pixi.js';\nimport { BaseView, type ViewOptions } from './base';\n\n/**\n * A specialized wrapper around the PixiJS Sprite class that implements leaf node behavior similar to HTML elements\n * that supports additional layout properties.\n * e.g objectFit, objectPosition, backgroundColor, borderColor, and overflow properties.\n */\nexport class LayoutSprite extends BaseView<PixiSprite> {\n    constructor(opts: ConstructorParameters<typeof PixiSprite>[0] & ViewOptions) {\n        if (opts instanceof Texture) {\n            opts = { texture: opts };\n        }\n        super({\n            ...opts,\n            ClassType: PixiSprite,\n        });\n    }\n}\n\n/**\n * A re-export of the PixiJS Sprite class that ensures the layout is set after construction.\n *\n * The Sprite object is one of the most important objects in PixiJS. It is a\n * drawing item that can be added to a scene and rendered to the screen.\n */\nexport class Sprite extends PixiSprite {\n    constructor(opts: ConstructorParameters<typeof PixiSprite>[0]) {\n        if (opts instanceof Texture) {\n            opts = { texture: opts };\n        }\n        const { layout, ...options } = opts ?? {};\n\n        super(options);\n        this.layout = layout!;\n    }\n}\n\n/**\n * A specialized wrapper around the PixiJS NineSliceSprite class that implements leaf node behavior similar to HTML elements\n * that supports additional layout properties.\n * e.g objectFit, objectPosition, backgroundColor, borderColor, and overflow properties.\n */\nexport class LayoutNineSliceSprite extends BaseView<PixiNineSliceSprite> {\n    constructor(opts: ConstructorParameters<typeof PixiNineSliceSprite>[0] & ViewOptions) {\n        if (opts instanceof Texture) {\n            opts = { texture: opts };\n        }\n        super({\n            ...opts,\n            ClassType: PixiNineSliceSprite,\n        });\n    }\n}\n\n/**\n * A re-export of the PixiJS NineSliceSprite class that ensures the layout is set after construction.\n *\n * The NineSliceSprite object is a special type of sprite that allows you to\n * stretch and scale a texture while preserving its corners and edges.\n */\nexport class NineSliceSprite extends PixiNineSliceSprite {\n    constructor(opts: ConstructorParameters<typeof PixiNineSliceSprite>[0]) {\n        if (opts instanceof Texture) {\n            opts = { texture: opts };\n        }\n        const { layout, ...options } = opts;\n\n        super(options);\n        this.layout = layout!;\n    }\n}\n\n/**\n * A specialized wrapper around the PixiJS TilingSprite class that implements leaf node behavior similar to HTML elements\n * that supports additional layout properties.\n * e.g objectFit, objectPosition, backgroundColor, borderColor, and overflow properties.\n */\nexport class LayoutTilingSprite extends BaseView<PixiTilingSprite> {\n    constructor(opts: (Texture | TilingSpriteOptions) & ViewOptions) {\n        if (opts instanceof Texture) {\n            opts = { texture: opts };\n        }\n        super({\n            ...opts,\n            ClassType: PixiTilingSprite,\n        });\n    }\n}\n\n/**\n * A re-export of the PixiJS TilingSprite class that ensures the layout is set after construction.\n *\n * The TilingSprite object is a special type of sprite that allows you to\n * repeat a texture across a defined area.\n */\nexport class TilingSprite extends PixiTilingSprite {\n    constructor(opts: Texture | TilingSpriteOptions) {\n        if (opts instanceof Texture) {\n            opts = { texture: opts };\n        }\n        const { layout, ...options } = opts;\n\n        super(options);\n        this.layout = layout!;\n    }\n}\n\n/**\n * A specialized wrapper around the PixiJS AnimatedSprite class that implements leaf node behavior similar to HTML elements\n * that supports additional layout properties.\n * e.g objectFit, objectPosition, backgroundColor, borderColor, and overflow properties.\n */\nexport class LayoutAnimatedSprite extends BaseView<PixiAnimatedSprite> {\n    constructor(opts: ConstructorParameters<typeof PixiAnimatedSprite>[0] & ViewOptions) {\n        super({\n            ...opts,\n            ClassType: PixiAnimatedSprite,\n        });\n    }\n}\n\n/**\n * A re-export of the PixiJS AnimatedSprite class that ensures the layout is set after construction.\n *\n * The AnimatedSprite object is a special type of sprite that allows you to\n * animate a sequence of textures.\n */\nexport class AnimatedSprite extends PixiAnimatedSprite {\n    constructor(opts: ConstructorParameters<typeof PixiAnimatedSprite>[0]) {\n        const { layout, ...options } = opts;\n\n        super(options);\n        this.layout = layout!;\n    }\n}\n"],"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