function Argument.Transform(h)if#h.TransformedValues~=0 then return end local c=h.RawValue if c=="\046"and h.Type.Default then c=h.Type.Default(h.Executor)or""h.RawSegmentsAreAutocomplete=true end if c=="\063"and h.Type.Autocomplete then local j,f=h:GetDefaultAutocomplete()if not f.IsPartial and#j>0 then c=j[math.random(1,#j)]h.RawSegmentsAreAutocomplete=true end end if h.Type.Listable and#h.RawValue>0 then local j=c:match("\094\037\063\040\037\100\043\041\036")if j then local f=tonumber(j)if f and f>0 then local j={}local M,P=h:GetDefaultAutocomplete()if not P.IsPartial and#M>0 then for h=1,math.min(f,#M),1 do table.insert(j,table.remove(M,math.random(1,#M)))end c=table.concat(j,"\044")h.RawSegmentsAreAutocomplete=true end end elseif c=="\042"or c=="\042\042"then local j,f=h:GetDefaultAutocomplete()if not f.IsPartial and#j>0 then if c=="\042\042"and h.Type.Default then local c=h.Type.Default(h.Executor)or""for h,f in ipairs(j)do if f==c then table.remove(j,h)end end end c=table.concat(j,"\044")h.RawSegmentsAreAutocomplete=true end end c=unescapeOperators(c)local f=Util.SplitStringSimple(c,"\044")if#f==0 then f={""}end if c:sub(#c,#c)=="\044"then f[#f+1]=""end for c,j in ipairs(f)do h.RawSegments[c]=j h.TransformedValues[c]={h:TransformSegment(j)}end h.TextSegmentInProgress=f[#f]else c=unescapeOperators(c)h.RawSegments[1]=unescapeOperators(c)h.TransformedValues[1]={h:TransformSegment(c)}h.TextSegmentInProgress=h.RawValue end end function Argument.TransformSegment(c,h)if c.Type.Transform then return c.Type.Transform(h,c.Executor)else return h end end

function Argument:Transform()
	if #self.TransformedValues ~= 0 then
		return
	end

	local rawValue = self.RawValue

	if rawValue == "." and self.Type.Default then
		rawValue = self.Type.Default(self.Executor) or ""
		self.RawSegmentsAreAutocomplete = true
	end

	if rawValue == "?" and self.Type.Autocomplete then
		local strings, options = self:GetDefaultAutocomplete()

		if not options.IsPartial and #strings > 0 then
			rawValue = strings[math.random(1, #strings)]
			self.RawSegmentsAreAutocomplete = true
		end

	end

	if self.Type.Listable and #self.RawValue > 0 then
		local randomMatch = rawValue:match("^%?(%d+)$")
		if randomMatch then
			local maxSize = tonumber(randomMatch)

			if maxSize and maxSize > 0 then
				local items = {}
				local remainingItems, options = self:GetDefaultAutocomplete()

				if not options.IsPartial and #remainingItems > 0 then
					for _ = 1, math.min(maxSize, #remainingItems) do
						table.insert(items, table.remove(remainingItems, math.random(1, #remainingItems)))
					end

					rawValue = table.concat(items, ",")
					self.RawSegmentsAreAutocomplete = true
				end
			end
		elseif rawValue == "*" or rawValue == "**" then
			local strings, options = self:GetDefaultAutocomplete()

			if not options.IsPartial and #strings > 0 then
				if rawValue == "**" and self.Type.Default then
					local defaultString = self.Type.Default(self.Executor) or ""

					for i, string in ipairs(strings) do
						if string == defaultString then
							table.remove(strings, i)
						end
					end
				end

				rawValue = table.concat(
					strings,
					","
				)
				self.RawSegmentsAreAutocomplete = true
			end
		end

		rawValue = unescapeOperators(rawValue)

		local rawSegments = Util.SplitStringSimple(rawValue, ",")

		if #rawSegments == 0 then
			rawSegments = {""}
		end

		if rawValue:sub(#rawValue, #rawValue) == "," then
			rawSegments[#rawSegments + 1] = "" -- makes auto complete tick over right after pressing ,
		end

		for i, rawSegment in ipairs(rawSegments) do
			self.RawSegments[i] = rawSegment
			self.TransformedValues[i] = { self:TransformSegment(rawSegment) }
		end

		self.TextSegmentInProgress = rawSegments[#rawSegments]
	else
		rawValue = unescapeOperators(rawValue)

		self.RawSegments[1] = unescapeOperators(rawValue)
		self.TransformedValues[1] = { self:TransformSegment(rawValue) }
		self.TextSegmentInProgress = self.RawValue
	end
end

function Argument:TransformSegment(rawSegment)
	if self.Type.Transform then
		return self.Type.Transform(rawSegment, self.Executor)
	else
		return rawSegment
	end
end
