// Normalize args convert multiple resources to resource tuples, a,b,c d
// as a transform to a/d b/d c/d
323592
func normalizeMultipleResourcesArgs(args []string) []string {
	if len(args) >= 2 {
		resources := []string{}
		resources = append(resources, SplitResourceArgument(args[0])...)
		if len(resources) > 1 {
			names := []string{}
			names = append(names, args[1:]...)
			newArgs := []string{}
			for _, resource := range resources {
				for _, name := range names {
					newArgs = append(newArgs, strings.Join([]string{resource, name}, "/"))
				}
			}
			return newArgs
		}
	}
	return args
}
1164205
func (v *Value_Object) Normalize() error {
	newObj, err := NormalizeJSON(v.Object, true)
	if err != nil {
		return err
	}
	v.Object = newObj
	return nil
}
965641
func (j *JsonResult) Normalize() error {
	if j == nil {
		return nil
	}
	if j.Object == "" {
		j.Size = 0
		return nil
	}
	if len(j.Object) > jsonNonNormalizedSize {
		return fmt.Errorf(
			"JSONObject.Object length exceeds max non-normalized length: %d > %d (max)",
			len(j.Object), jsonNonNormalizedSize)
	}
	normed, err := template.NormalizeJSON(j.Object, true)
	if err != nil {
		return err
	}
	if len(normed) > JSONObjectMaxLength {
		return fmt.Errorf(
			"JSONObject.Object length exceeds max: %d > %d (max)",
			len(normed), JSONObjectMaxLength)
	}
	j.Object = normed
	j.Size = uint32(len(j.Object))
	return nil
}
271842
func convertArgs(args ...interface{}) []interface{} {
	newArgs := []interface{}{}
	for _, arg := range args {
		v := ValueOf(arg)
		newArgs = append(newArgs, v.internal())
	}
	return newArgs
}
2456
func (g *GraphQuery) Normalize() error {
	if err := g.AttemptList.Normalize(); err != nil {
		return err
	}
	if len(g.AttemptRange) > 0 {
		lme := errors.NewLazyMultiError(len(g.AttemptRange))
		for i, rng := range g.AttemptRange {
			lme.Assign(i, rng.Normalize())
		}
		if err := lme.Get(); err != nil {
			return err
		}
	}
	if len(g.Search) > 0 {
		lme := errors.NewLazyMultiError(len(g.Search))
		for i, s := range g.Search {
			lme.Assign(i, s.Normalize())
		}
		if err := lme.Get(); err != nil {
			return err
		}
	}
	return nil
}
93927
func normalize(c context.Context, cfg *Config) error {
	for _, p := range cfg.Projects.GetProject() {
		p.Revision = cfg.revision
	}
	for _, v := range cfg.VMs.GetVms() {
		for _, ch := range v.Amount.GetChange() {
			if err := ch.Length.Normalize(); err != nil {
				return errors.Annotate(err, "failed to normalize %q", v.Prefix).Err()
			}
		}
		if err := v.Lifetime.Normalize(); err != nil {
			return errors.Annotate(err, "failed to normalize %q", v.Prefix).Err()
		}
		v.Revision = cfg.revision
		if err := v.Timeout.Normalize(); err != nil {
			return errors.Annotate(err, "failed to normalize %q", v.Prefix).Err()
		}
	}
	return nil
}
941634
func (al *GraphQuery_AttemptRange) Normalize() error {
	if al.Quest == "" {
		return fmt.Errorf("must specify quest")
	}
	if al.Low == 0 {
		return fmt.Errorf("must specify low")
	}
	if al.High <= al.Low {
		return fmt.Errorf("high must be > low")
	}
	return nil
}
306007
func (d *DepsStage) Normalize() error {
	for _, d := range d.Deps {
		if err := d.Normalize(); err != nil {
			return err
		}
	}
	return nil
}
288377
func Normalize(name string) string {
	fargs := func(c rune) bool {
		return !unicode.IsLetter(c) && !unicode.IsNumber(c)
	}
	// get function
	return strings.Join(strings.FieldsFunc(name, fargs), "-")
}
315877
func (h *FriendlyHost) Normalized() string {
	host, err := svchost.ForComparison(h.Raw)
	if err != nil {
		return InvalidHostString
	}
	return string(host)
}
986986
func (vn *VecN) Normalize(dst *VecN) *VecN {
	if vn == nil {
		return nil
	}

	return vn.Mul(dst, 1/vn.Len())
}
608333
func (a Dimensions) Normalize() (time.Duration, []string) {
	var dur time.Duration
	var tags []string

	for _, dim := range a {
		switch expr := dim.Expr.(type) {
		case *Call:
			lit, _ := expr.Args[0].(*DurationLiteral)
			dur = lit.Val
		case *VarRef:
			tags = append(tags, expr.Val)
		}
	}

	return dur, tags
}
801791
func (arc *AddressResourceConfig) Normalize() {
	testProto := strings.Trim(strings.ToLower(arc.Protocol), " ")
	arc.Protocol = testProto
}
1115788
func (i *Config_Isolate) Normalize() (err error) {
	if err = schemaHostURLValidate(i.Url); err != nil {
		return fmt.Errorf("config.isolate.host: %s", err)
	}
	return
}
740296
func (s *SparseRange) Normalize() error {
	if len(s.Items) == 0 {
		s.Items = []*RangeItem{{RangeItem: &RangeItem_Single{1}}}
		return nil
	}
	current := uint32(0)
	for _, itm := range s.Items {
		switch i := itm.RangeItem.(type) {
		case *RangeItem_Single:
			if i.Single <= current {
				return fmt.Errorf("malformed SparseRange")
			}
			current = i.Single
		case *RangeItem_Range:
			if err := i.Range.Normalize(); err != nil {
				return err
			}
			if i.Range.Low <= current {
				return fmt.Errorf("malformed SparseRange")
			}
			current = i.Range.High
		default:
			return fmt.Errorf("unknown SparseRange entry")
		}
	}
	return nil
}
1093702
func (v Vector) Normalize() Vector {
	n2 := v.Norm2()
	if n2 == 0 {
		return Vector{0, 0, 0}
	}
	return v.Mul(1 / math.Sqrt(n2))
}
1088722
func (h Host) Normalize() string {
	s := string(h)
	_, s = parse.Transport(s)

	// The error can be ignore here, because this function is called after the corefile has already been vetted.
	host, _, _, _ := SplitHostPort(s)
	return Name(host).Normalize()
}