package shape

import (
	

	
	
	
)

type shapePage struct {
	*baseShape
}

const (
	// TODO: cleanup
	pageCornerWidth  = 20.8164
	pageCornerHeight = 20.348
)

func ( *geo.Box) Shape {
	 := shapePage{
		baseShape: &baseShape{
			Type: PAGE_TYPE,
			Box:  ,
		},
	}
	.FullShape = go2.Pointer(Shape())
	return 
}

func ( shapePage) () *geo.Box {
	// Note: for simplicity this assumes shape padding is greater than pageCornerSize
	 := .Box.Width
	// consider right hand side occupied by corner for short pages
	if .Box.Height < 3*pageCornerHeight {
		 -= pageCornerWidth
	}
	return geo.NewBox(.Box.TopLeft.Copy(), , .Box.Height)
}

func pageOuterPath( *geo.Box) *svg.SvgPathContext {
	// TODO: cleanup
	 := svg.NewSVGPathContext(.TopLeft, 1., 1.)
	.StartAt(.Absolute(0.5, 0))
	.H(false, .Width-20.8164)
	.C(false, .Width-19.6456, 0.0, .Width-18.521, 0.456297, .Width-17.6811, 1.27202)
	.L(false, .Width-1.3647, 17.12)
	.C(false, .Width-0.4923, 17.9674, .Width, 19.1318, .Width, 20.348)
	.V(false, .Height-0.5)
	.C(false, .Width, .Height-0.2239, .Width-0.2239, .Height, .Width-0.5, .Height)

	.H(false, 0.499999)
	.C(false, 0.223857, .Height, 0, .Height-0.2239, 0, .Height-0.5)
	.V(false, 0.499999)
	.C(false, 0, 0.223857, 0.223857, 0, 0.5, 0)
	.Z()
	return 
}

func pageInnerPath( *geo.Box) *svg.SvgPathContext {
	 := svg.NewSVGPathContext(.TopLeft, 1., 1.)
	.StartAt(.Absolute(.Width-1.08197, .Height))
	.H(false, 1.08196)
	.C(true, -0.64918, 0, -1.08196, -0.43287, -1.08196, -1.08219)
	.V(false, 1.08219)
	.C(true, 0, -0.64931, 0.43278, -1.08219, 1.08196, -1.08219)

	.H(true, .Width-22.72132)
	.C(true, 0.64918, 0, 1.08196, 0.43287, 1.08196, 1.08219)
	.V(true, 17.09863)
	.C(true, 0, 1.29863, 0.86557, 2.38082, 2.38032, 2.38082)
	.H(false, .Width-1.08197)
	.C(true, .64918, 0, 1.08196, 0.43287, 1.08196, 1.08196)
	.V(false, .Height-1.0822)
	.C(false, .Width-1.0, .Height-0.43288, .Width-0.43279, .Height, .Width-1.08197, .Height)
	.Z()
	return 
}

func ( shapePage) () []geo.Intersectable {
	return pageOuterPath(.Box).Path
}

func ( shapePage) () []string {
	return []string{
		pageOuterPath(.Box).PathData(),
		pageInnerPath(.Box).PathData(),
	}
}

func ( shapePage) (, , ,  float64) (float64, float64) {
	 :=  + 
	 :=  + 
	// add space for corner with short pages
	if  < 3*pageCornerHeight {
		 += pageCornerWidth
	}
	 = math.Max(, 2*pageCornerWidth)
	 = math.Max(, pageCornerHeight)
	return math.Ceil(), math.Ceil()
}

func ( shapePage) () (,  float64) {
	return defaultPadding, pageCornerHeight + defaultPadding
}