{"version":3,"file":"index.cjs","sources":["../../src/util/index.ts"],"sourcesContent":["import h from \"@macrostrat/hyper\";\nimport {\n  createElement,\n  forwardRef,\n  ForwardedRef,\n  SVGAttributes,\n  RefObject,\n} from \"react\";\nimport {\n  expandInnerSize,\n  extractPadding,\n  removePadding,\n  extractMargin,\n  removeMargin,\n  Padding,\n  Margin,\n} from \"@macrostrat/ui-components\";\nimport { useColumn } from \"../context\";\nimport classNames from \"classnames\";\n\nconst SVGNamespaces = {\n  xmlns: \"http://www.w3.org/2000/svg\",\n  xmlnsXlink: \"http://www.w3.org/1999/xlink\",\n};\n\ninterface SVGProps extends SVGAttributes<any>, Padding, Margin {\n  innerHeight?: number;\n  innerWidth?: number;\n  innerRef?: RefObject<SVGElement>;\n}\n\ninterface SVGPropsWithNumericSize extends Omit<SVGProps, \"width\" | \"height\"> {\n  width?: number;\n  height?: number;\n}\n\nconst SVG = forwardRef(\n  (props: SVGPropsWithNumericSize, ref: ForwardedRef<SVGElement>) => {\n    const { children, innerRef, ...props1 } = props;\n    const { style, ...rest } = expandInnerSize(props1);\n\n    // Sizing\n    const { paddingLeft, paddingTop } = extractPadding(props);\n    const margin = extractMargin(props);\n    const realRest = removeMargin(removePadding(rest));\n\n    return h(\n      \"svg\",\n      {\n        ref,\n        style: { ...margin, ...style },\n        ...realRest,\n        ...SVGNamespaces,\n      },\n      h(\n        \"g\",\n        {\n          transform: `translate(${paddingLeft},${paddingTop})`,\n        },\n        children,\n      ),\n    );\n  },\n);\n\nconst ForeignObject = (props) => createElement(\"foreignObject\", props);\n\nconst ColumnSVG = function (props: SVGPropsWithNumericSize) {\n  //# Need to rework to use UI Box code\n  const { children, className, innerRef, style, ...rest } = props;\n  const { pixelHeight } = useColumn();\n  const nextProps = expandInnerSize({ innerHeight: pixelHeight, ...rest });\n  const {\n    paddingLeft,\n    paddingTop,\n    innerHeight,\n    innerWidth,\n    height,\n    width,\n    ...remainingProps\n  } = nextProps;\n  return h(\n    SVG,\n    {\n      className: classNames(className, \"section\"),\n      height,\n      width,\n      innerRef,\n      ...remainingProps,\n      style,\n    },\n    h(\n      \"g.backdrop\",\n      {\n        transform: `translate(${paddingLeft},${paddingTop})`,\n      },\n      children,\n    ),\n  );\n};\n\nexport { SVGNamespaces, SVG, ColumnSVG, ForeignObject };\n\nexport * from \"./storage\";\nexport * from \"./column-box\";\nexport * from \"./scroll-box\";\n"],"names":["forwardRef","expandInnerSize","extractPadding","extractMargin","removeMargin","removePadding","h","createElement","useColumn","classNames"],"mappings":";;;;;;;;;;AAoBA,MAAM,gBAAgB;AAAA,EACpB,OAAO;AAAA,EACP,YAAY;AACd;AAaA,MAAM,MAAMA,MAAAA;AAAAA,EACV,CAAC,OAAgC,QAAkC;AACjE,UAAM,EAAE,UAAU,UAAU,GAAG,WAAW;AAC1C,UAAM,EAAE,OAAO,GAAG,KAAA,IAASC,aAAAA,gBAAgB,MAAM;AAGjD,UAAM,EAAE,aAAa,eAAeC,aAAAA,eAAe,KAAK;AACxD,UAAM,SAASC,aAAAA,cAAc,KAAK;AAClC,UAAM,WAAWC,aAAAA,aAAaC,aAAAA,cAAc,IAAI,CAAC;AAEjD,WAAOC,WAAAA;AAAAA,MACL;AAAA,MACA;AAAA,QACE;AAAA,QACA,OAAO,EAAE,GAAG,QAAQ,GAAG,MAAA;AAAA,QACvB,GAAG;AAAA,QACH,GAAG;AAAA,MAAA;AAAA,MAELA,WAAAA;AAAAA,QACE;AAAA,QACA;AAAA,UACE,WAAW,aAAa,WAAW,IAAI,UAAU;AAAA,QAAA;AAAA,QAEnD;AAAA,MAAA;AAAA,IACF;AAAA,EAEJ;AACF;AAEA,MAAM,gBAAgB,CAAC,UAAUC,MAAAA,cAAc,iBAAiB,KAAK;AAErE,MAAM,YAAY,SAAU,OAAgC;AAE1D,QAAM,EAAE,UAAU,WAAW,UAAU,OAAO,GAAG,SAAS;AAC1D,QAAM,EAAE,YAAA,IAAgBC,iBAAA;AACxB,QAAM,YAAYP,aAAAA,gBAAgB,EAA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