{
  "version": 3,
  "sources": ["../src/Area.ts", "../src/AtlasResource.ts", "../src/AtlasAllocator.ts", "../src/GuilloteneAllocator.ts", "../src/TextureAllocator.ts", "../src/CanvasTextureAllocator.ts", "../src/RenderTextureAllocator.ts"],
  "sourcesContent": ["/**\n * The orientation of an area indicates the axis along which it is split. This is a 1-bit field.\n *\n * @public\n */\nexport enum AreaOrientation {\n    HORIZONTAL = 0,\n    VERTICAL = 1\n};\n\n/**\n * Alias for the 31-bit field texture-area type.\n *\n * @public\n */\nexport type AreaField = number;\n\n/**\n * An area represents an oriented rectangular region. It is implemented as a 31-bit field. The open/close edges are\n * specified along its parent's orientation axis, i.e. if the parent is horizontal, the left and right edges are defined,\n * else if the parent is vertical, the top and bottom edges are defined. Similarly, the open/close edges of its\n * children will be along its own orientation axis.\n *\n * The orientation axes flip-flop along the hierarchy, i.e. an area's parent's orientation is always opposite to\n * the area's own orientation. This is because if the orientation were to be same, the area's children could be\n * \"pulled up\" to the parent making itself redundant.\n *\n * All four edges of an area can be retrieved from it and its parent.\n *\n * <table>\n *  <thead>\n *    <tr>\n *      <th>Field</th>\n *      <th>Bits</th>\n *      <th>Description</th>\n *    </tr>\n *  </thead>\n *  <tbody>\n *    <tr>\n *      <td>OPEN_OFFSET</td>\n *      <td>0-14</td>\n *      <td>\n *        The offset along the parent's axis at which the area begins. If orientation is horizontal,\n *        this is the left edge. If orientation is vertical, this is the top edge.\n *      </td>\n *    </tr>\n *    <tr>\n *      <td>CLOSE_OFFSET</td>\n *      <td>15-29</td>\n *      <td>\n *        The offset along the parent's axis at which the area ends. If orientation is horizontal,\n *        this is the right edge. If orientation is vertical, this is the bottom edge.\n *      </td>\n *    </tr>\n *    <tr>\n *      <td>ORIENTATION</td>\n *      <td>30</td>\n *      <td>\n *        The orientation of the area, which indicates the axis along it is split. The open and close\n *        offsets of its children are along this axis. See {@link AreaOrientation}.\n *      </td>\n *    </tr>\n *  </tbody>\n * </table>\n *\n * @public\n */\nexport class Area\n{\n    static makeArea(openOffset: number, closeOffset: number, orientation: number): number\n    {\n        return openOffset | (closeOffset << 15) | (orientation << 30);\n    }\n\n    static getOpenOffset(area: AreaField): number\n    {\n        return area & ((1 << 15) - 1);\n    }\n\n    static getCloseOffset(area: AreaField): number\n    {\n        return (area >> 15) & ((1 << 15) - 1);\n    }\n\n    static getOrientation(area: AreaField): AreaOrientation\n    {\n        return (area >> 30) & 1;\n    }\n\n    static setOpenOffset(area: AreaField, offset: number): number\n    {\n        return Area.makeArea(\n            offset,\n            Area.getCloseOffset(area),\n            Area.getOrientation(area)\n        );\n    }\n\n    static setCloseOffset(area: AreaField, offset: number): number\n    {\n        return Area.makeArea(\n            Area.getOpenOffset(offset),\n            offset,\n            Area.getOrientation(area)\n        );\n    }\n}", "import { ALPHA_MODES } from '@pixi/constants';\nimport { BaseTexture, GLTexture, Resource, Renderer } from '@pixi/core';\n\nimport type { Rectangle } from '@pixi/math';\nimport type { Texture } from '@pixi/core';\n\n/**\n * Types of image sources supported by {@link AtlasResource}.\n *\n * @public\n */\nexport type AtlasResourceSource =  HTMLImageElement | HTMLCanvasElement | ImageBitmap | ImageData | ArrayBufferView;\n\n/**\n * An item that is uploaded to the atlas texture.\n *\n * @public\n */\nexport type AtlasResourceItem =\n{\n    /**\n     * The location of the atlas item in the base-texture's space.\n     */\n    frame: Rectangle;\n\n    /**\n     * The source of the texture data.\n     */\n    source: AtlasResourceSource;\n\n    /**\n     * This flags when the resource is to be re-uploaded.\n     */\n    dirtyId: number;\n\n    /**\n     * This flags when the resource is uploaded and update-to-date with the dirty ID.\n     */\n    updateId: number;\n\n    /**\n     * The texture holding this item.\n     */\n    texture: Texture;\n};\n\n/**\n * An {@code AtlasResource} is used by {@link AtlasAllocator} to manage texture sources\n *\n * @public\n */\nexport class AtlasResource extends Resource\n{\n    /**\n     * The list of managed resources in the atlas.\n     */\n    public managedItems: AtlasResourceItem[];\n\n    /**\n     * Creates an atlas resource.\n     *\n     * @param width\n     * @param height\n     */\n    constructor(width: number, height: number)\n    {\n        super(width, height);\n\n        this.managedItems = [];\n    }\n\n    /**\n     * Uploads the atlas.\n     *\n     * @param renderer\n     * @param baseTexture\n     * @param glTexture\n     */\n    upload(renderer: Renderer, baseTexture: BaseTexture, glTexture: GLTexture): boolean\n    {\n        const gl: WebGLRenderingContext = renderer.gl;\n        const width = baseTexture.realWidth;\n        const height = baseTexture.realHeight;\n\n        gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, baseTexture.alphaMode === ALPHA_MODES.UNPACK)\n\n        // Allocate the texture on the GPU\n        if (glTexture.width !== width ||\n            glTexture.height !== height)\n        {\n            glTexture.width = width;\n            glTexture.height = height;\n\n            gl.texImage2D(\n                baseTexture.target,\n                0,\n                baseTexture.format,\n                width,\n                height,\n                0,\n                baseTexture.format,\n                baseTexture.type,\n                undefined\n            );\n        }\n\n        const items = this.managedItems;\n\n        // Upload all atlas items.\n        for (let i = 0, j = items.length; i < j; i++)\n        {\n            this.uploadItem(\n                renderer,\n                baseTexture.target,\n                baseTexture.format,\n                baseTexture.type,\n                items[i]\n            );\n        }\n\n        return true;\n    }\n\n    /**\n     * Uploads the atlas item to the GPU.\n     *\n     * @param renderer - The renderer holding the WebGL context.\n     * @param target - The binding point of the base-texture.\n     * @param format - The format of the base-texture.\n     * @param type - The type of the base-texture data.\n     * @param item - The item to upload.\n     */\n    protected uploadItem(\n        renderer: Renderer,\n        target: number,\n        format: number,\n        type: number,\n        item: AtlasResourceItem\n    ): void\n    {\n        // see https://github.com/rapideditor/pixi-texture-allocator/issues/2\n        // if (item.updateId === item.dirtyId)\n        // {\n        //     return;\n        // }\n\n        const gl: WebGLRenderingContext = renderer.gl;\n        const isWebGL2 = (gl instanceof WebGL2RenderingContext);\n        const frame = item.frame;\n        let source = item.source;\n\n        // if WebGL1, convert whatever we have into a typed array\n        if (!isWebGL2) {\n            if (source instanceof ImageData) {\n                source = source.data;  // pass the typed array directly\n\n            } else if (source instanceof HTMLCanvasElement) {\n                const ctx = source.getContext('2d');\n                const [w, h] = [source.width, source.height];\n                source = ctx.getImageData(0, 0, w, h).data;\n\n            } else if (source instanceof HTMLImageElement) {\n                const [w, h] = [source.naturalWidth, source.naturalHeight];\n                const canvas = document.createElement('canvas');\n                canvas.width = w;\n                canvas.height = h;\n\n                const ctx = canvas.getContext('2d');\n                ctx.drawImage(source, 0, 0);\n                source = ctx.getImageData(0, 0, w, h).data;\n            }\n        }\n\n        gl.texSubImage2D(\n            target,\n            0,\n            frame.x,\n            frame.y,\n            frame.width,\n            frame.height,\n            format,\n            type,\n            source as any,\n        );\n\n        item.updateId = item.dirtyId;\n    }\n}", "import { AtlasResource } from './AtlasResource';\nimport { BaseTexture, Texture } from '@pixi/core';\nimport { GuilloteneAllocator } from './GuilloteneAllocator';\nimport { TextureAllocator } from './TextureAllocator';\nimport { TextureSlab } from './TextureSlab';\n\nimport type { AtlasResourceSource } from './AtlasResource';\n\n/**\n * This texture allocator auto-manages the base-texture with an {@link AtlasResource}. You can also\n * pass a texture source to `allocate`, mimicing {@link Texture.from} functionality.\n *\n * @public\n */\nexport class AtlasAllocator extends TextureAllocator\n{\n    /**\n     * Creates a texture slab backed by an {@link AtlasResource}.\n     */\n    protected createSlab(): TextureSlab\n    {\n        return {\n            managedArea: new GuilloteneAllocator(this.slabWidth, this.slabHeight),\n            managedTextures: [],\n            slab: new BaseTexture(new AtlasResource(this.slabWidth, this.slabHeight),\n            {\n                width: this.slabWidth,\n                height: this.slabHeight,\n            }),\n        };\n    }\n\n    /**\n     * Allocates a texture backed by the given atlas source, with the given padding.\n     *\n     * @override\n     * @param width\n     * @param height\n     * @param padding\n     * @param source\n     */\n    allocate(width: number, height: number, padding?: number, source?: AtlasResourceSource): Texture;\n\n    /**\n     * Allocates a texture backed by the given source, with default padding.\n     *\n     * @param width\n     * @param height\n     * @param source\n     */\n    allocate(width: number, height: number, source?: AtlasResourceSource): Texture;\n\n    allocate(width: number, height: number, paddingOrSource?: number | AtlasResourceSource, source?: AtlasResourceSource): Texture\n    {\n        let padding: number;\n\n        if (typeof paddingOrSource === 'number')\n        {\n            padding = paddingOrSource;\n        }\n        else\n        {\n            padding = this.calculatePadding(width, height);\n            source = paddingOrSource;\n        }\n\n        const texture = super.allocate(width, height, padding);\n\n        if (source)\n        {\n            const atlas = texture.baseTexture.resource as AtlasResource;\n            const item = {\n                frame: texture.frame,\n                source,\n                // dirtyId !== updateId only if image loaded\n                dirtyId: source instanceof HTMLImageElement && !source.complete ? -1 : 0,\n                updateId: -1,\n                texture,\n            };\n\n            atlas.managedItems.push(item);\n\n            if (source instanceof HTMLImageElement && !source.complete) {\n                source.addEventListener('load', () => {\n                    if (texture.baseTexture.valid && !texture.baseTexture.destroyed && atlas.managedItems.indexOf(item) >= 0) {\n                        item.dirtyId++;\n                        texture.baseTexture.update();\n                    }\n                });\n            }\n\n            texture.baseTexture.update();\n        }\n\n        return texture;\n    }\n\n    free(texture: Texture): void\n    {\n        super.free(texture);\n\n        const atlas = texture.baseTexture.resource as AtlasResource;\n        const item = atlas.managedItems.find(item => item.texture === texture);\n\n        if (item)\n        {\n            atlas.managedItems.splice(atlas.managedItems.indexOf(item), 1);\n        }\n    }\n}", "import { Rectangle } from '@pixi/math';\nimport { Area, AreaOrientation } from './Area';\n\nimport type { AreaAllocator } from './AreaAllocator';\nimport type { AreaField } from './Area';\n\n/**\n * An allocator node is represented as a tuple. The zeroth element is the parent of the node. The first element\n * always exists and is the texture area it wholly represents. The second element is whether the rectangle\n * is allocated or free. The last element is optional and is the list\n * of its children.\n *\n * @public\n * @ignore\n */\nexport type AreaNode = [AreaNode, AreaField, boolean] | [AreaNode, AreaField, AreaNode[]];\n\n/**\n * Pointer to guillotene node.\n *\n * @public\n * @ignore\n */\nexport type AreaPtr = { __mem_area: AreaNode };\n\n/**\n * @public\n * @ignore\n */\nexport enum SPLIT_ORIENTATION {\n    HOR = 0,\n    VERT = 1,\n    NONE = 2\n}\n\nconst tempRect = new Rectangle();\n\n/** @public */\nexport class GuilloteneAllocator implements AreaAllocator<AreaPtr>\n{\n    protected _root: AreaNode;\n\n    private _width: number;\n    private _height: number;\n\n    constructor(width: number, height: number)\n    {\n        this._width = width;\n        this._height = height;\n\n        // NOTE: getFrame assumes root node is always horizontal!\n        this._root = [\n            null,\n            Area.makeArea(0, this._height, AreaOrientation.HORIZONTAL),\n            false\n        ];\n    }\n\n    /**\n     * Allocates an area of the given `width` and `height`.\n     *\n     * @param width - The width required for the allocated area.\n     * @param height - The height required for the allocated area.\n     * @param rect - An optional `Rectangle` instance to put the resulting area frame into.\n     * @return The rectangle frame of the area allocated.\n     */\n    allocate(width: number, height: number, rect?: Rectangle): Rectangle & AreaPtr\n    {\n        const area = this.findArea(width, height);\n\n        if (!area)\n        {\n            return null;\n        }\n\n        if (!rect)\n        {\n            rect = new Rectangle();\n        }\n\n        this.getFrame(area, rect);\n\n        const hole = new Rectangle(rect.x, rect.y, width, height);\n        const node = this.split(area, rect, hole);\n\n        rect.copyFrom(hole);\n        (rect as any).__mem_area = node;\n\n        return rect as (Rectangle & AreaPtr);\n    }\n\n    /**\n     * Frees the area represented by the given area pointer. The original rectangle returned by\n     * {@link GuilloteneAllocator#allocate} included this pointer (the `__mem_area` property).\n     *\n     * @param areaPtr\n     */\n    free(areaPtr: AreaPtr): void\n    {\n        const area = areaPtr.__mem_area;\n\n        area[2] = false;\n        this.merge(area);\n    }\n\n    get width(): number\n    {\n        return this._width;\n    }\n\n    get height(): number\n    {\n        return this._height;\n    }\n\n    /**\n     * Returns the [area]{@link Area} data for the node.\n     *\n     * @param node\n     * @returns The area data for the node.\n     */\n    protected getAreaField(node: AreaNode): AreaField\n    {\n        return node[1];\n    }\n\n    /**\n     * Returns the rectangle covered by the area node.\n     *\n     * @param node - The node whose covered rectangular area is needed.\n     * @param rect - An optional `Rectangle` instance to put the data in.\n     * @return The rectangle covered by `node`.\n     */\n    protected getFrame(node: AreaNode, rect?: Rectangle): Rectangle\n    {\n        if (!rect)\n        {\n            rect = new Rectangle();\n        }\n\n        const nodeArea = this.getAreaField(node);\n        const nodeParent = this.getParent(node);\n        const nodeOrientation = Area.getOrientation(nodeArea);\n        const nodeOpen = Area.getOpenOffset(nodeArea);\n        const nodeClose = Area.getCloseOffset(nodeArea);\n        const parentOpen = nodeParent ? Area.getOpenOffset(nodeParent[1]) : 0;\n        const parentClose = nodeParent ? Area.getCloseOffset(nodeParent[1]) : this._width;// (because root node is horizontal)\n\n        if (nodeOrientation) // VERTICAL\n        {\n            rect.x = nodeOpen;\n            rect.y = parentOpen;\n            rect.width = nodeClose - rect.x;\n            rect.height = parentClose - parentOpen;\n        }\n        else // HORIZONTAL\n        {\n            rect.x = parentOpen;\n            rect.y = nodeOpen;\n            rect.width = parentClose - rect.x;\n            rect.height = nodeClose - rect.y;\n        }\n\n        return rect;\n    }\n\n    /**\n     * Returns the parent of the area node.\n     *\n     * @param node\n     * @return The parent of `node`\n     */\n    protected getParent(node: AreaNode): AreaNode\n    {\n        return node[0];\n    }\n\n    /**\n     * Returns whether the given node has any children.\n     *\n     * @param node\n     * @return Whether the given node has any children.\n     */\n    protected hasChildren(node: AreaNode): boolean\n    {\n        return (Array.isArray(node[2]) && (node[2].length !== 0));\n    }\n\n    /**\n     * Returns the children of the passed node, if any.\n     *\n     * @param node\n     */\n    protected getChildren(node: AreaNode): AreaNode[]\n    {\n        if (!Array.isArray(node[2])) {\n            throw new Error(\"Children don't exist\")\n        }\n\n        return node[2];\n    }\n\n    protected addChild(parent: AreaNode, ...nodes: AreaNode[]): void\n    {\n        parent[2] = Array.isArray(parent[2]) ? parent[2] : []\n        parent[2].push(...nodes)\n    }\n\n    /**\n     * Finds an area node with minimum width `aw` and minimum height `ah`.\n     *\n     * @param aw\n     * @param ah\n     */\n    protected findArea(aw: number, ah: number): AreaNode\n    {\n        return this.findAreaRecursive(this._root, aw, ah);\n    }\n\n    /**\n     * The recursive implementation for {@link AreaAllocator#findArea}.\n     *\n     * @param rootArea\n     * @param aw\n     * @param ah\n     */\n    protected findAreaRecursive(rootArea: AreaNode, aw: number, ah: number): AreaNode\n    {\n        const frame = this.getFrame(rootArea, tempRect);\n\n        if (frame.width < aw || frame.height < ah)\n        {\n            return null;\n        }\n\n        if (!this.hasChildren(rootArea))\n        {\n            const dx = frame.width - aw;\n            const dy = frame.height - ah;\n\n            if (dx < 0 || dy < 0 || rootArea[2])\n            {\n                return null;\n            }\n\n            return rootArea;\n        }\n\n        const children = this.getChildren(rootArea);\n\n        let bestCandidate = null;\n        let bestCandidateScore = Infinity;\n\n        for (let i = 0, j = children.length; i < j; i++)\n        {\n            const candidate = this.findAreaRecursive(children[i], aw, ah);\n\n            if (!candidate)\n            {\n                continue;\n            }\n\n            const candidateFrame = this.getFrame(candidate, tempRect);\n\n            const dx = candidateFrame.width - aw;\n            const dy = candidateFrame.height - ah;\n\n            if (dx < 0 || dy < 0)\n            {\n                continue;\n            }\n            if (!dx && !dy)\n            {\n                // Perfect fit!\n                return candidate;\n            }\n\n            const score = Math.min(dx, dy);\n\n            if (bestCandidateScore > score)\n            {\n                bestCandidate = candidate;\n                bestCandidateScore = score;\n            }\n        }\n\n        return bestCandidate;\n    }\n\n    /**\n     * Returns the orientation of the primary split of host.\n     */\n    protected splitOrientation(host: Rectangle, hole: Rectangle): SPLIT_ORIENTATION\n    {\n        if (hole.width === host.width && hole.height === host.height) {\n            return SPLIT_ORIENTATION.NONE;\n        }\n        if (hole.width === host.width) {\n            return SPLIT_ORIENTATION.VERT;\n        }\n        if (hole.height === host.height) {\n            return SPLIT_ORIENTATION.HOR;\n        }\n\n        // ____________________\n        // |        |         |\n        // |        |         |\n        // |  hole  |         |\n        // |        |         |\n        // |________| Primary |\n        // |        |         |\n        // |        |         |\n        // |  Sec.  |         |\n        // |________|_________|\n        const horAreaDiff = Math.abs(\n            // (Primary) Right\n            (host.width - hole.width) * host.height -\n            // (Secondary) Bottom\n            hole.width * (host.height - hole.height)\n        )\n\n        // ____________________\n        // |        |         |\n        // |        |         |\n        // |  hole  | Sec.    |\n        // |        |         |\n        // |________|_________|\n        // |                  |\n        // |    Primary       |\n        // |__________________|\n        const verAreaDiff = Math.abs(\n            // (Primary) Bottom\n            host.width * (host.height - hole.height) -\n            (host.width - hole.width) * hole.height\n        )\n\n        if (horAreaDiff > verAreaDiff)\n        {\n            return SPLIT_ORIENTATION.HOR\n        }\n        else\n        {\n            return SPLIT_ORIENTATION.VERT\n        }\n    }\n\n    protected split(\n        area: AreaNode,\n        areaFrame: Rectangle,\n        holeFrame: Rectangle,\n        orientation: SPLIT_ORIENTATION = this.getParent(area) ? this.splitOrientation(areaFrame, holeFrame) : SPLIT_ORIENTATION.HOR\n    ): AreaNode\n    {\n        if (area[2] === true)\n        {\n            throw new Error('Cannot deallocate')\n        }\n        if (orientation === SPLIT_ORIENTATION.NONE)\n        {\n            area[2] = true;\n            return area;\n        }\n\n        return this[orientation === SPLIT_ORIENTATION.HOR\n            ? 'splitPrimaryHorizontal'\n            : 'splitPrimaryVertical'](area, areaFrame, holeFrame);\n    }\n\n    private splitPrimaryHorizontal(area: AreaNode, areaFrame: Rectangle, holeFrame: Rectangle): AreaNode\n    {\n        const field = this.getAreaField(area);\n        const axis = Area.getOrientation(field);\n        const parent = this.getParent(area);\n\n        if (this.hasChildren(area))\n        {\n            throw new Error(\"Can't split non-leaf node\")\n        }\n\n        const firstChild: AreaNode = [\n            area,\n            Area.makeArea(\n                areaFrame.left,\n                areaFrame.x + holeFrame.width,\n                AreaOrientation.VERTICAL\n            ),\n            []\n        ];\n        const secondChild: AreaNode = [\n            area,\n            Area.makeArea(\n                areaFrame.x + holeFrame.width,\n                areaFrame.right,\n                AreaOrientation.VERTICAL\n            ),\n            false\n        ];\n\n        if (axis === AreaOrientation.HORIZONTAL) {\n            this.addChild(area, firstChild, secondChild)\n        } else {\n            const i = this.getChildren(parent).indexOf(area);\n\n            firstChild[0] = parent;\n            secondChild[0] = parent;\n\n            this.getChildren(parent).splice(i, 1, firstChild, secondChild);\n        }\n\n        if (holeFrame.height !== areaFrame.height)\n        {\n            const secondaryFirstChild: AreaNode = [\n                firstChild,\n                Area.makeArea(\n                    areaFrame.top,\n                    areaFrame.y + holeFrame.height,\n                    AreaOrientation.HORIZONTAL\n                ),\n                true\n            ];\n            const secondarySecondChild: AreaNode = [\n                firstChild,\n                Area.makeArea(\n                    areaFrame.y + holeFrame.height,\n                    areaFrame.bottom,\n                    AreaOrientation.HORIZONTAL\n                ),\n                false\n            ];\n\n            this.addChild(firstChild, secondaryFirstChild, secondarySecondChild);\n\n            return secondaryFirstChild;\n        }\n        else\n        {\n            (firstChild as AreaNode)[2] = true;\n        }\n\n        return firstChild;\n    }\n\n    private splitPrimaryVertical(area: AreaNode, areaFrame: Rectangle, holeFrame: Rectangle): AreaNode\n    {\n        const field = this.getAreaField(area);\n        const axis = Area.getOrientation(field);\n        const parent = this.getParent(area);\n\n        if (this.hasChildren(area)) {\n            throw new Error(\"Can't split non-leaf node\")\n        }\n\n        const primaryFirstChild: AreaNode = [\n            area,\n            Area.makeArea(\n                areaFrame.top,\n                areaFrame.y + holeFrame.height,\n                AreaOrientation.HORIZONTAL\n            ),\n            []\n        ];\n        const primarySecondChild: AreaNode = [\n            area,\n            Area.makeArea(\n                areaFrame.y + holeFrame.height,\n                areaFrame.bottom,\n                AreaOrientation.HORIZONTAL\n            ),\n            false\n        ];\n\n        if (axis === AreaOrientation.VERTICAL)\n        {\n            this.addChild(area, primaryFirstChild, primarySecondChild);\n        }\n        else\n        {\n            const i = this.getChildren(parent).indexOf(area);\n            primaryFirstChild[0] = parent;\n            primarySecondChild[0] = parent;\n            this.getChildren(parent).splice(i, 1, primaryFirstChild, primarySecondChild);\n        }\n\n        if (holeFrame.width !== areaFrame.height)\n        {\n            const secondaryFirstChild: AreaNode = [\n                primaryFirstChild,\n                Area.makeArea(\n                    areaFrame.left,\n                    areaFrame.x + holeFrame.width,\n                    AreaOrientation.VERTICAL\n                ),\n                true\n            ];\n            const secondarySecondChild: AreaNode = [\n                primaryFirstChild,\n                Area.makeArea(\n                    areaFrame.x + holeFrame.width,\n                    areaFrame.right,\n                    AreaOrientation.VERTICAL\n                ),\n                false\n            ];\n\n            this.addChild(primaryFirstChild, secondaryFirstChild, secondarySecondChild);\n\n            return secondaryFirstChild;\n        }\n        else\n        {\n            (primaryFirstChild as AreaNode)[2] = true;\n        }\n\n        return primaryFirstChild;\n    }\n\n    protected merge(\n        area: AreaNode\n    ) {\n        if (this.hasChildren(area))\n        {\n            throw new Error(\"Cannot merge a non-leaf node\");\n        }\n\n        const parent = this.getParent(area);\n\n        if (!parent)\n        {\n            return;\n        }\n\n        const siblings = this.getChildren(parent);\n        const i = siblings.indexOf(area);\n\n        const leftSibling = siblings[i - 1];\n        const rightSibling = siblings[i + 1];\n\n        if (rightSibling && rightSibling[2] === false)\n        {\n            // Merge rightSibling into area\n            area[1] = Area.setCloseOffset(area[1], Area.getCloseOffset(rightSibling[1]));\n            siblings.splice(i + 1, 1);\n        }\n        if (leftSibling && leftSibling[2] === false)\n        {\n            // Merge leftSibling into area\n            area[1] = Area.setOpenOffset(area[1], Area.getOpenOffset(leftSibling[1]));\n            siblings.splice(i - 1, 1);\n        }\n\n        if (siblings.length === 1) {\n            parent[2] = false;\n            this.merge(parent);\n        }\n    }\n\n    private printState(area: AreaNode): void\n    {\n        if (!this.hasChildren(area)) {\n            console.log({ ...this.getFrame(area) }, area[2])\n        } else {\n            this.getChildren(area).forEach(n => this.printState(n))\n        }\n    }\n}", "import { BaseTexture, Texture } from '@pixi/core';\nimport { GuilloteneAllocator } from './GuilloteneAllocator';\nimport { Rectangle } from '@pixi/math';\n\nimport type { TextureSlab } from './TextureSlab';\n\nconst tempRect = new Rectangle();\n\n/**\n * The texture allocator dynamically manages space on base-texture slabs. It can be used to generate\n * atlases on demand, which improve batching efficiency.\n *\n * @public\n */\nexport class TextureAllocator<T extends Texture = Texture>\n{\n    /**\n     * The width of texture slabs.\n     */\n    public readonly slabWidth: number;\n\n    /**\n     * The height of texture slabs.\n     */\n    public readonly slabHeight: number;\n\n    /**\n     * The list of base-textures that are used to allocate texture space.\n     */\n    protected textureSlabs: TextureSlab[];\n\n    /**\n     * @param slabWidth - The width of base-texture slabs. This should be at most 2048.\n     * @param slabHeight - The height of base-texture slabs. This should be at most 2048.\n     */\n    constructor(slabWidth = 2048, slabHeight = 2048)\n    {\n        this.slabWidth = slabWidth;\n        this.slabHeight = slabHeight;\n\n        this.textureSlabs = [];\n    }\n\n    get maxWidth() {\n        return this.slabWidth - (2 * this.calculatePadding(this.slabWidth, this.slabHeight));\n    }\n\n    get maxHeight() {\n        return this.slabHeight - (2 * this.calculatePadding(this.slabWidth, this.slabHeight));\n    }\n\n    /**\n     * Allocates a texture from this allocator.\n     *\n     * If its existing slab pool has enough space, the texture is issued from one. Otherwise,\n     * a new slab is created and the texture is issued from it. However, if the requested\n     * dimensions are larger than slabs themselves, then `null` is always returned.\n     *\n     * To upload a texture source, you will have to create an atlas-managing {@link Resource}\n     * yourself on the base-texture. The {@link AtlasAllocator} does this for you, while the\n     * {@link CanvasTextureAllocator} can be used to draw on a canvas-based atlas.\n     *\n     * @param width - The width of the requested texture.\n     * @param height - The height of the requested texture.\n     * @param padding - The padding requested around the texture, to prevent bleeding.\n     * @return The allocated texture, if successful; otherwise, `null`.\n     */\n    allocate(width: number, height: number, padding = this.calculatePadding(width, height)): T\n    {\n        // Cannot allocate a texture larger than a texture-slab.\n        if (width + 2 * padding > this.slabWidth ||\n                height + 2 * padding > this.slabHeight)\n        {\n            return null;\n        }\n\n        const slabs = this.textureSlabs;\n\n        // Loop through the slabs and find one with enough space, if any.\n        for (let i = 0, j = slabs.length; i < j; i++)\n        {\n            const slab = slabs[i];\n            const texture = this.issueTexture(slab, width, height, padding);\n\n            if (texture)\n            {\n                return texture;\n            }\n        }\n\n        // Issue a new slab.\n        const slab = this.createSlab();\n\n        // Append this slab to the head of the list.\n        this.textureSlabs.unshift(slab);\n\n        // Issue the texture from this blank slab.\n        return this.issueTexture(slab, width, height, padding);\n    }\n\n    /**\n     * Frees the texture and reclaims its space. It is assumed you will not use it again, and have\n     * destroyed any resource uploading its data.\n     *\n     * @param texture\n     * @throws When the texture was not located in this allocator.\n     */\n    free(texture: T): void\n    {\n        const baseTexture = (texture as Texture).baseTexture;\n        const slab = this.textureSlabs.find(sl => sl.slab === baseTexture);\n\n        if (!slab)\n        {\n            throw new Error(\"The texture cannot be freed because \" +\n                \"its base-texture is not pooled by this allocator. \" +\n                \"This is either a bug in TextureAllocator or you tried to free a \" +\n                \"texture that was never allocated by one.\");\n        }\n\n        const textureEntry = slab.managedTextures.find(entry => entry.texture === texture);\n\n        if (!textureEntry)\n        {\n            throw new Error(\"The texture cannot be freed because it was not found \" +\n                \"in the managed list of issued textures on its slab. This may be because you \" +\n                \"duplicated this texture or a bug in TextureAllocator\");\n        }\n\n        slab.managedArea.free(textureEntry.area);\n        slab.managedTextures.splice(slab.managedTextures.indexOf(textureEntry), 1);\n    }\n\n    protected calculatePadding(width: number, height: number): number\n    {\n        const dimen = Math.max(width, height);\n\n        if (dimen < 64)\n        {\n            return 2;\n        }\n        else if (dimen < 128)\n        {\n            return 4;\n        }\n        else if (dimen < 1024)\n        {\n            return 8;\n        }\n        else\n        {\n            return 16;\n        }\n    }\n\n    /**\n     * Creates a texture slab. The slab's base-texture is not backed by any resource. You\n     * will have to manage that yourself. See {@link AtlasAllocator} or {@link CanvasTextureAllocator}\n     * for better resource semantics.\n     */\n    protected createSlab(): TextureSlab\n    {\n        return {\n            managedArea: new GuilloteneAllocator(this.slabWidth, this.slabHeight),\n            managedTextures: [],\n            slab: new BaseTexture(null,\n            {\n                width: this.slabWidth,\n                height: this.slabHeight,\n            }),\n        };\n    }\n\n    /**\n     * Creates a texture on the given base-texture at {@code frame}.\n     *\n     * @param baseTexture - The base texture that will hold the texture's space.\n     * @param frame - The frame in which the texture will be stored.\n     */\n    protected createTexture(baseTexture: BaseTexture, frame: Rectangle): T\n    {\n        // Override this method to return correct texture type T.\n        return new Texture(baseTexture, frame) as T;\n    }\n\n    /**\n     * Issues a texture from the given texture slab, if possible.\n     *\n     * @param slab - The texture slab to allocate frame.\n     * @param width - The width of the requested texture.\n     * @param height - The height of the requested texture.\n     * @param padding - Padding required around the texture.\n     * @return The issued texture, if successful; otherwise, `null`.\n     */\n    protected issueTexture(slab: TextureSlab, width: number, height: number, padding = 0): T\n    {\n        const area = slab.managedArea.allocate(width + 2 * padding, height + 2 * padding);\n\n        if (!area)\n        {\n            return null;\n        }\n\n        tempRect.copyFrom(area);\n        tempRect.pad(-padding);\n\n        const baseTexture = slab.slab;\n        const issuedTexture = this.createTexture(baseTexture, tempRect.clone());\n\n        slab.managedTextures.push({\n            area,\n            texture: issuedTexture,\n        });\n\n        return issuedTexture;\n    }\n}", "import { BaseTexture } from '@pixi/core';\n\nimport { GuilloteneAllocator } from './GuilloteneAllocator';\nimport { TextureAllocator } from './TextureAllocator';\nimport { TextureSlab } from './TextureSlab';\n\n/**\n * This allocator issues texture backed by a canvas. You can draw on to that canvas to soruce\n * each texture.\n *\n * @public\n */\nexport class CanvasTextureAllocator extends TextureAllocator\n{\n    /**\n     * Creates a texture slab backed by a canvas.\n     */\n    protected createSlab(): TextureSlab\n    {\n        const canvas = document.createElement('canvas');\n\n        canvas.width = this.slabWidth;\n        canvas.height = this.slabHeight;\n\n        return {\n            managedArea: new GuilloteneAllocator(this.slabWidth, this.slabHeight),\n            managedTextures: [],\n            slab: new BaseTexture(canvas, {\n                width: this.slabWidth,\n                height: this.slabHeight\n            })\n        };\n    }\n}", "import { BaseRenderTexture, RenderTexture } from '@pixi/core';\nimport { GuilloteneAllocator } from './GuilloteneAllocator';\nimport { TextureAllocator } from './TextureAllocator';\n\nimport type { BaseTexture } from '@pixi/core';\nimport type { Rectangle } from '@pixi/math';\nimport type { TextureSlab } from './TextureSlab';\n\n/**\n * This allocator issues render-textures, and is otherwise just like {@link TextureAllocator}.\n *\n * @public\n */\nexport class RenderTextureAllocator extends TextureAllocator<RenderTexture>\n{\n    /**\n     * Creates a texture slab backed by a base render-texture.\n     */\n    protected createSlab(): TextureSlab\n    {\n        return {\n            managedArea: new GuilloteneAllocator(this.slabWidth, this.slabHeight),\n            managedTextures: [],\n            slab: new BaseRenderTexture({\n                width: this.slabWidth,\n                height: this.slabHeight\n            })\n        };\n    }\n\n    /**\n     * Creates a render-texture from the given base render-texture.\n     *\n     * @param baseTexture\n     * @param frame\n     */\n    protected createTexture(baseTexture: BaseTexture, frame: Rectangle): RenderTexture\n    {\n        return new RenderTexture(baseTexture as BaseRenderTexture, frame);\n    }\n}"],
  "mappings": ";AAKO,IAAK,kBAAL,kBAAKA,qBAAL;AACH,EAAAA,kCAAA,gBAAa,KAAb;AACA,EAAAA,kCAAA,cAAW,KAAX;AAFQ,SAAAA;AAAA,GAAA;AA8DL,IAAM,OAAN,MAAM,MACb;AAAA,EACI,OAAO,SAAS,YAAoB,aAAqB,aACzD;AACI,WAAO,aAAc,eAAe,KAAO,eAAe;AAAA,EAC9D;AAAA,EAEA,OAAO,cAAc,MACrB;AACI,WAAO,QAAS,KAAK,MAAM;AAAA,EAC/B;AAAA,EAEA,OAAO,eAAe,MACtB;AACI,WAAQ,QAAQ,MAAQ,KAAK,MAAM;AAAA,EACvC;AAAA,EAEA,OAAO,eAAe,MACtB;AACI,WAAQ,QAAQ,KAAM;AAAA,EAC1B;AAAA,EAEA,OAAO,cAAc,MAAiB,QACtC;AACI,WAAO,MAAK;AAAA,MACR;AAAA,MACA,MAAK,eAAe,IAAI;AAAA,MACxB,MAAK,eAAe,IAAI;AAAA,IAC5B;AAAA,EACJ;AAAA,EAEA,OAAO,eAAe,MAAiB,QACvC;AACI,WAAO,MAAK;AAAA,MACR,MAAK,cAAc,MAAM;AAAA,MACzB;AAAA,MACA,MAAK,eAAe,IAAI;AAAA,IAC5B;AAAA,EACJ;AACJ;;;AC1GA,SAAS,mBAAmB;AAC5B,SAAiC,gBAA0B;AAkDpD,IAAM,gBAAN,cAA4B,SACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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Orientation", "BaseTexture", "SPLIT_ORIENTATION", "BaseTexture", "Rectangle", "tempRect", "slab", "BaseTexture", "BaseTexture", "item", "BaseTexture", "BaseTexture"]
}
