import { CCBaseShapeUtil } from '../CCBaseShapeUtil'
import { CCBaseShape } from '../cc-types'
import { ccGraphShapeProps, getDefaultCCPlannerNodeProps } from './cc-graph-props'
import { getNodeStyles, NODE_THEMES, NODE_TYPE_THEMES } from './cc-graph-styles'
import { CCPlannerNodeProps } from './cc-graph-types'

export interface CCPlannerNodeShape extends CCBaseShape {
  type: 'cc-planner-node'
  props: CCPlannerNodeProps
}

export class CCPlannerNodeShapeUtil extends CCBaseShapeUtil<CCPlannerNodeShape> {
  static type = 'cc-planner-node' as const
  static props = ccGraphShapeProps['cc-planner-node']

  getDefaultProps(): CCPlannerNodeShape['props'] {
    const defaultProps = getDefaultCCPlannerNodeProps()
    const theme = NODE_THEMES[NODE_TYPE_THEMES[CCPlannerNodeShapeUtil.type]] ?? NODE_THEMES.resource
    return {
      ...defaultProps,
      headerColor: theme.headerColor,
    }
  }

  DefaultComponent = () => null

  renderContent = (shape: CCPlannerNodeShape) => {
    const styles = getNodeStyles(shape.type)
    return (
      <div style={styles.container}>
        <div style={{ ...styles.header, color: shape.props.headerColor }}>Planner</div>
        <div style={{ fontSize: 11, color: 'var(--color-text-2)' }}>Lesson and weekly planner</div>
      </div>
    )
  }
}
