define([],function(){"use strict";functionisHighSurrogate(codePoint){returncodePoint>=55296&&codePoint<=56319}functionisLowSurrogate(codePoint){returncodePoint>=56320&&codePoint<=57343}functiongetByteLength(string){if("string"!=typeofstring)thrownewError("Input must be string");for(varcharLength=string.length,byteLength=0,codePoint=null,prevCodePoint=null,i=0;i<charLength;i++)codePoint=string.charCodeAt(i),isLowSurrogate(codePoint)?byteLength+=null!=prevCodePoint&&isHighSurrogate(prevCodePoint)?1:3:codePoint<=127?byteLength+=1:codePoint>=128&&codePoint<=2047?byteLength+=2:codePoint>=2048&&codePoint<=65535&&(byteLength+=3),prevCodePoint=codePoint;returnbyteLength}functiontruncate(string,byteLength){if("string"!=typeofstring)thrownewError("Input must be string");for(varcodePoint,segment,charLength=string.length,curByteLength=0,i=0;i<charLength;i+=1){if(codePoint=string.charCodeAt(i),segment=string[i],isHighSurrogate(codePoint)&&isLowSurrogate(string.charCodeAt(i+1))&&(i+=1,segment+=string[i]),curByteLength+=getByteLength(segment),curByteLength===byteLength)returnstring.slice(0,i+1);if(curByteLength>byteLength)returnstring.slice(0,i-segment.length+1)}returnstring}varillegalRe=/[\/\?<>\\:\*\|":]/g,controlRe=/[\x00-\x1f\x80-\x9f]/g,reservedRe=/^\.+$/,windowsReservedRe=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,windowsTrailingRe=/[\. ]+$/;return{sanitize:function(input,replacement){varsanitized=input.replace(illegalRe,replacement).replace(controlRe,replacement).replace(reservedRe,replacement).replace(windowsReservedRe,replacement).replace(windowsTrailingRe,replacement);returntruncate(sanitized,255)}}});