//>>built
define("dojox/encoding/compression/lzw",["dojo/_base/lang","../bits"],function(d){var c=d.getObject("dojox.encoding.compression.lzw",!0),f=function(a){for(var b=1,e=2;a>=e;e<<=1,++b);return b};c.Encoder=function(a){this.size=a;this.init()};d.extend(c.Encoder,{init:function(){this.dict={};for(var a=0;a<this.size;++a)this.dict[String.fromCharCode(a)]=a;this.width=f(this.code=this.size);this.p=""},encode:function(a,b){var e=String.fromCharCode(a),c=this.p+e,d=0;if(c in this.dict)return this.p=c,d;b.putBits(this.dict[this.p],
this.width);0==(this.code&this.code+1)&&b.putBits(this.code++,d=this.width++);this.dict[c]=this.code++;this.p=e;return d+this.width},flush:function(a){if(0==this.p.length)return 0;a.putBits(this.dict[this.p],this.width);this.p="";return this.width}});c.Decoder=function(a){this.size=a;this.init()};d.extend(c.Decoder,{init:function(){this.codes=Array(this.size);for(var a=0;a<this.size;++a)this.codes[a]=String.fromCharCode(a);this.width=f(this.size);this.p=-1},decode:function(a){var a=a.getBits(this.width),
b;if(a<this.codes.length)b=this.codes[a],0<=this.p&&this.codes.push(this.codes[this.p]+b.substr(0,1));else{if(0==(a&a+1))return this.codes.push(""),++this.width,"";b=this.codes[this.p];b+=b.substr(0,1);this.codes.push(b)}this.p=a;return b}});return c});