{"version":3,"file":"utils.mjs","names":[],"sources":["../../../../src/LayoutManager/LayoutStrategies/utils.ts"],"sourcesContent":["import { Point, ZERO } from '../../Point';\nimport type { Group } from '../../shapes/Group';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { multiplyTransformMatrixArray } from '../../util/misc/matrix';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport {\n  calcPlaneChangeMatrix,\n  sendVectorToPlane,\n} from '../../util/misc/planeChange';\n\n/**\n * @returns 2 points, the tl and br corners of the non rotated bounding box of an object\n * in the {@link group} plane, taking into account objects that {@link group} is their parent\n * but also belong to the active selection.\n */\nexport const getObjectBounds = (\n  destinationGroup: Group,\n  object: FabricObject,\n): Point[] => {\n  const {\n    strokeUniform,\n    strokeWidth,\n    width,\n    height,\n    group: currentGroup,\n  } = object;\n  const t =\n    currentGroup && currentGroup !== destinationGroup\n      ? calcPlaneChangeMatrix(\n          currentGroup.calcTransformMatrix(),\n          destinationGroup.calcTransformMatrix(),\n        )\n      : null;\n  const objectCenter = t\n    ? object.getRelativeCenterPoint().transform(t)\n    : object.getRelativeCenterPoint();\n  const accountForStroke = !object['isStrokeAccountedForInDimensions']();\n  const strokeUniformVector =\n    strokeUniform && accountForStroke\n      ? sendVectorToPlane(\n          new Point(strokeWidth, strokeWidth),\n          undefined,\n          destinationGroup.calcTransformMatrix(),\n        )\n      : ZERO;\n  const scalingStrokeWidth =\n    !strokeUniform && accountForStroke ? strokeWidth : 0;\n  const sizeVector = sizeAfterTransform(\n    width + scalingStrokeWidth,\n    height + scalingStrokeWidth,\n    multiplyTransformMatrixArray([t, object.calcOwnMatrix()], true),\n  )\n    .add(strokeUniformVector)\n    .scalarDivide(2);\n  return [objectCenter.subtract(sizeVector), objectCenter.add(sizeVector)];\n};\n"],"mappings":";;;;;;;;;;AAeA,MAAa,mBACX,kBACA,WACY;CACZ,MAAM,EACJ,eACA,aACA,OACA,QACA,OAAO,iBACL;CACJ,MAAM,IACJ,gBAAgB,iBAAiB,mBAC7B,sBACE,aAAa,qBAAqB,EAClC,iBAAiB,qBAAqB,CACvC,GACD;CACN,MAAM,eAAe,IACjB,OAAO,wBAAwB,CAAC,UAAU,EAAE,GAC5C,OAAO,wBAAwB;CACnC,MAAM,mBAAmB,CAAC,OAAO,qCAAqC;CACtE,MAAM,sBACJ,iBAAiB,mBACb,kBACE,IAAI,MAAM,aAAa,YAAY,EACnC,KAAA,GACA,iBAAiB,qBAAqB,CACvC,GACD;CACN,MAAM,qBACJ,CAAC,iBAAiB,mBAAmB,cAAc;CACrD,MAAM,aAAa,mBACjB,QAAQ,oBACR,SAAS,oBACT,6BAA6B,CAAC,GAAG,OAAO,eAAe,CAAC,EAAE,KAAK,CAChE,CACE,IAAI,oBAAoB,CACxB,aAAa,EAAE;AAClB,QAAO,CAAC,aAAa,SAAS,WAAW,EAAE,aAAa,IAAI,WAAW,CAAC"}