function Argument.Transform(K)if#K.TransformedValues~=0 then return end local r=K.RawValue if r=="\046"and K.Type.Default then r=K.Type.Default(K.Executor)or""K.RawSegmentsAreAutocomplete=true end if r=="\063"and K.Type.Autocomplete then local N,m=K:GetDefaultAutocomplete()if not m.IsPartial and#N>0 then r=N[math.random(1,#N)]K.RawSegmentsAreAutocomplete=true end end if K.Type.Listable and#K.RawValue>0 then local N=r:match("\094\037\063\040\037\100\043\041\036")if N then local m=tonumber(N)if m and m>0 then local N={}local F,R=K:GetDefaultAutocomplete()if not R.IsPartial and#F>0 then for K=1,math.min(m,#F),1 do table.insert(N,table.remove(F,math.random(1,#F)))end r=table.concat(N,"\044")K.RawSegmentsAreAutocomplete=true end end elseif r=="\042"or r=="\042\042"then local N,m=K:GetDefaultAutocomplete()if not m.IsPartial and#N>0 then if r=="\042\042"and K.Type.Default then local r=K.Type.Default(K.Executor)or""for K,m in ipairs(N)do if m==r then table.remove(N,K)end end end r=table.concat(N,"\044")K.RawSegmentsAreAutocomplete=true end end r=unescapeOperators(r)local m=Util.SplitStringSimple(r,"\044")if#m==0 then m={""}end if r:sub(#r,#r)=="\044"then m[#m+1]=""end for r,N in ipairs(m)do K.RawSegments[r]=N K.TransformedValues[r]={K:TransformSegment(N)}end K.TextSegmentInProgress=m[#m]else r=unescapeOperators(r)K.RawSegments[1]=unescapeOperators(r)K.TransformedValues[1]={K:TransformSegment(r)}K.TextSegmentInProgress=K.RawValue end end function Argument.TransformSegment(r,K)if r.Type.Transform then return r.Type.Transform(K,r.Executor)else return K end end
--- Calls the transform function on this argument.
-- The return value(s) from this function are passed to all of the other argument methods.
-- Called automatically at instantiation
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
