{"version":3,"file":"calculateWithSingleValue.cjs","sources":["../../../../../src/core/mixins/utils/position/calculateWithSingleValue.ts"],"sourcesContent":["import { type PointData, type Size } from 'pixi.js';\nimport { type ComputedLayout, type NumberValue, type PositionKeyword, type PositionSpecifier } from '../../../types';\nimport { getNumberFromStyle, getTypeFromStyle } from '../../../utils/getNumberFromStyle';\n\n/**\n * Calculates position when a single value is provided (e.g., \"center\", \"top\", \"50%\")\n * This implements CSS object-position behavior with a single value\n *\n * @param tokens - Array containing a single position token\n * @param computedLayout - The computed layout from Yoga\n * @param visualBounds - The visual bounds of the element being positioned\n * @returns Object with x and y coordinates for positioning\n */\nexport function calculateWithSingleValue(\n    tokens: PositionSpecifier[],\n    computedLayout: ComputedLayout,\n    visualBounds: Size,\n): PointData {\n    const keyword = tokens[0]! as NumberValue | PositionKeyword;\n    const result = { x: undefined, y: undefined } as unknown as PointData;\n\n    switch (keyword) {\n        case 'top':\n            result.y = 0;\n            result.x = (computedLayout.width - visualBounds.width) / 2;\n            break;\n        case 'bottom':\n            result.y = computedLayout.height - visualBounds.height;\n            result.x = (computedLayout.width - visualBounds.width) / 2;\n            break;\n        case 'left':\n            result.x = 0;\n            result.y = (computedLayout.height - visualBounds.height) / 2;\n            break;\n        case 'right':\n            result.x = computedLayout.width - visualBounds.width;\n            result.y = (computedLayout.height - visualBounds.height) / 2;\n            break;\n        case 'center':\n            result.x = (computedLayout.width - visualBounds.width) / 2;\n            result.y = (computedLayout.height - visualBounds.height) / 2;\n            break;\n        default: {\n            const isPercentage = getTypeFromStyle(keyword) === 'percentage';\n            const multiple = isPercentage ? computedLayout.width - visualBounds.width : 1;\n\n            // Handle single number value as x coordinate\n            result.x = getNumberFromStyle(keyword) * multiple;\n            result.y = (computedLayout.height - visualBounds.height) / 2;\n        }\n    }\n\n    return result;\n}\n"],"names":["getTypeFromStyle","getNumberFromStyle"],"mappings":";;;AAagB,SAAA,yBACZ,QACA,gBACA,cACS;AACH,QAAA,UAAU,OAAO,CAAC;AACxB,QAAM,SAAS,EAAE,GAAG,QAAW,GAAG,OAAU;AAE5C,UAAQ,SAAS;AAAA,IACb,KAAK;AACD,aAAO,IAAI;AACX,aAAO,KAAK,eAAe,QAAQ,aAAa,SAAS;AACzD;AAAA,IACJ,KAAK;AACM,aAAA,IAAI,eAAe,SAAS,aAAa;AAChD,aAAO,KAAK,eAAe,QAAQ,aAAa,SAAS;AACzD;AAAA,IACJ,KAAK;AACD,aAAO,IAAI;AACX,aAAO,KAAK,eAAe,SAAS,aAAa,UAAU;AAC3D;AAAA,IACJ,KAAK;AACM,aAAA,IAAI,eAAe,QAAQ,aAAa;AAC/C,aAAO,KAAK,eAAe,SAAS,aAAa,UAAU;AAC3D;AAAA,IACJ,KAAK;AACD,aAAO,KAAK,eAAe,QAAQ,aAAa,SAAS;AACzD,aAAO,KAAK,eAAe,SAAS,aAAa,UAAU;AAC3D;AAAA,IACJ,SAAS;AACC,YAAA,eAAeA,mBAAAA,iBAAiB,OAAO,MAAM;AACnD,YAAM,WAAW,eAAe,eAAe,QAAQ,aAAa,QAAQ;AAGrE,aAAA,IAAIC,sCAAmB,OAAO,IAAI;AACzC,aAAO,KAAK,eAAe,SAAS,aAAa,UAAU;AAAA,IAAA;AAAA,EAC/D;AAGG,SAAA;AACX;;"}