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AACzE;AACA,0CAAU,SAAS,CAAC,QAAQ,GAAG,SAAS,QAAQ,EAAC,IAAI,EAAE;IACtD,IAAI,KAAK,IAAI,EAAE,IAAI;IACnB,GAAG;QACF,IAAI,QAAQ,GAAG,GAAG,CAAC,GAAE;QACrB,IAAG,UAAQ,WACV,SAAS,OAAM,GAAE;QAElB;IACD,QAAQ,UAAQ,WAAW;AAC5B;AACA,0CAAU,SAAS,CAAC,OAAO,GAAG,0CAAU,SAAS,CAAC,QAAQ","sources":["src/index.js"],"sourcesContent":["/*\r\nMIT License\r\n\r\nCopyright (c) 2016-2023 Simon Y. Blackwell\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\n\tThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE.\r\n*/\r\n//\tportions from http://phrogz.net/lazy-cartesian-product\r\n\r\nimport {intersector} from \"intersector\";\r\nconst intersection = intersector(true);\r\n\r\n\r\n\tfunction CXProduct(collections,options={}){ // options = {cache:true||false}\r\n\t\tif(!this || typeof(this)!==\"object\" || !(this instanceof CXProduct)) {\r\n\t\t\treturn new CXProduct(collections,options);\r\n\t\t}\r\n\t\tthis.collections = (collections ? collections : []);\r\n\t\tObject.defineProperty(this,\"length\",{set:function() {},get:function() { let size = 1; this.collections.forEach(function(collection) { size *= collection.length; }); return size; }});\r\n\t\tObject.defineProperty(this,\"size\",{set:function() {},get:function() { return this.length; }});\r\n\t\tObject.defineProperty(this,\"_options\",{value:Object.assign({},options)});\r\n\t\tObject.defineProperty(this,\"_cache\",{configurable:true,value:{}});\r\n\t\t//createIterable(this);\r\n\t}\r\n\tCXProduct.prototype.asGenerator = function() {\r\n\t\tconst ctx = this,\r\n\t\t\tgenerator = (function* generator([head, ...tail]) {\r\n\t\t\t\tif(head===undefined) return;\r\n\t\t\t\tconst remainder = tail.length > 0 ? generator(tail) : [[]];\r\n\t\t\t\tfor (let r of remainder) for (let h of head) yield [h, ...r];\r\n\t\t\t})(this.collections);\r\n\t\tObject.defineProperty(generator,\"length\",{get() { return ctx.length; }});\r\n\t\treturn generator;\r\n\t}\r\n\tCXProduct.prototype.asArrayLike = function() {\r\n\t\tconst scope = this;\r\n\t\treturn new Proxy([],{\r\n\t\t\tget(target,key) {\r\n\t\t\t\tif(key===\"length\") {\r\n\t\t\t\t\treturn scope.length;\r\n\t\t\t\t}\r\n\t\t\t\tif(typeof(key)===\"number\") {\r\n\t\t\t\t\treturn scope.get(key)\r\n\t\t\t\t}\r\n\t\t\t\treturn target[key];\r\n\t\t\t}\r\n\t\t})\r\n\t}\r\n\tCXProduct.prototype.add = function(...collections) {\r\n\t\tvar me = this;\r\n\t\tcollections.forEach(function(collection) {\r\n\t\t\tme.collections.push(collection);\r\n\t\t});\r\n\t\tthis.flush();\r\n\t\treturn me;\r\n\t}\r\n\tCXProduct.prototype.push = function(collectionIndex,element) {\r\n\t\tthis.collections[collectionIndex].push(element);\r\n\t\tthis.flush();\r\n\t\treturn this;\r\n\t}\r\n\tfunction get(n,collections,dm,c) {\r\n\t\tfor (var i=collections.length;i--;)c[i]=collections[i][(n/dm[i][0]<<0)%dm[i][1]];\r\n\t}\r\n\tCXProduct.prototype.flush = function(index) {\r\n\t\tif(typeof(index)===\"number\") {\r\n\t\t\tdelete this._cache[index];\r\n\t\t} else {\r\n\t\t\tObject.defineProperty(this,\"_cache\",{configurable:true,value:{}});\r\n\t\t}\r\n\t}\r\n\tCXProduct.prototype.get = function(n,{test,cache}={}){\r\n\t\tvar me = this, c = [], size = 1, value = this._cache[n];\r\n\t\tif(value!==undefined) {\r\n\t\t\treturn value;\r\n\t\t}\r\n\t\tfor (var dm=[],f=1,l,i=me.collections.length;i--;f*=l){ dm[i]=[f,l=me.collections[i].length]; size*=me.collections[i].length; }\r\n\t\tif(n>=size) {\r\n\t\t\treturn undefined;\r\n\t\t}\r\n\t\tget(n,me.collections,dm,c);\r\n\t\tvalue = c.slice(0);\r\n\t\tif(test && !test(c)) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif(cache===true || this._options.cache) {\r\n\t\t\tthis._cache[n] = value;\r\n\t\t}\r\n\t\treturn value;\r\n\t}\r\n\tCXProduct.has = function(row,{cache}={}) {\r\n\t\treturn this.get(row,{cache})>=0\r\n\t}\r\n\tCXProduct.prototype.indexable = function() {\r\n\t\treturn new Proxy(this,{\r\n\t\t\tget(target,property) {\r\n\t\t\t\tvar num = parseInt(property);\r\n\t\t\t\tif(num>=0) {\r\n\t\t\t\t\treturn target.get(num);\r\n\t\t\t\t}\r\n\t\t\t\treturn target[property];\r\n\t\t\t}\r\n\t\t})\r\n\t}\r\n\tCXProduct.prototype.indexOf = function(row,{cache}={}) {\r\n\t\tvar me = this, index = 0;\r\n\t\tfor (var dm=[],f=1,l,i=me.collections.length;i--;f*=l){ dm[i]=f,l=me.collections[i].length; }\r\n\t\tif(me.collections.every(function(collection,i) {\r\n\t\t\tvar pos = collection.indexOf(row[i]);\r\n\t\t\tif(pos>=0) {\r\n\t\t\t\tindex += (pos * dm[i]);\r\n\t\t\t\treturn true;\r\n\t\t\t}\r\n\t\t\treturn false;\r\n\t\t})) {\r\n\t\t\tif(cache===true || this._options.cache) {\r\n\t\t\t\tthis._cache[index] = row.slice(0);\r\n\t\t\t}\r\n\t\t\treturn index;\r\n\t\t}\r\n\t\treturn -1;\r\n\t}\r\n\tCXProduct.prototype.intersection = function(cxproduct) {\r\n\t\tvar me = this, collections = [];\r\n\t\tif(me.collections.length!==cxproduct.collections.length) {\r\n\t\t\treturn new CXProduct([],this._options);\r\n\t\t}\r\n\t\tme.collections.forEach(function(collection,i) {\r\n\t\t\tcollections.push(intersection(collection,cxproduct.collections[i]));\r\n\t\t});\r\n\t\treturn new CXProduct(collections,this._options);\r\n\t}\r\n\tCXProduct.prototype.verify = function(i,row,{cache}={}) {\r\n\t\tvar me = this;\r\n\t\tvar match = me.get(i,{cache});\r\n\t\treturn match && match.every(function(element,i) { return element===row[i]; });\r\n\t}\r\n\tfunction dive(d,count,collections,lens,p,callback,test,cache,cxproduct){\r\n\t\tvar a=collections[d], max=collections.length-1,len=lens[d];\r\n\t\tif (d==max) {\r\n\t\t\tfor (var i=0;i<len;++i) { \r\n\t\t\t\tp[d]=a[i]; \r\n\t\t\t\tif(!test || test(p)) {\r\n\t\t\t\t\tvar value = p.slice(0);\r\n\t\t\t\t\t!cache || (cache[count] = value);\r\n\t\t\t\t\tcallback(value,count,cxproduct); \r\n\t\t\t\t}\r\n\t\t\t\tcount++;\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\tfor (var i=0;i<len;++i) {\r\n\t\t\t\tp[d]=a[i];\r\n\t\t\t\tdive(d+1,count,collections,lens,p,callback,test,cache,cxproduct);\r\n\t\t\t}\r\n\t\t}\r\n\t\tp.pop();\r\n\t}\r\n\tCXProduct.prototype.forEach1 = function(callback,{test,cache}={}) {\r\n\t\tvar me = this, p=[],lens=[];\r\n\t\tfor (var i=me.collections.length;i--;) lens[i]=me.collections[i].length;\r\n\t\tdive(0,0,me.collections,lens,p,callback,test,cache ? this._cache : null,me);\r\n\t}\r\n\tCXProduct.prototype.forEach2 = function(callback,test) {\r\n\t\tvar me = this, i = 0;\r\n\t\tdo {\r\n\t\t\tvar value = me.get(i,test);\r\n\t\t\tif(value!==undefined) {\r\n\t\t\t\tcallback(value,i,cxproduct);\r\n\t\t\t}\r\n\t\t\ti++;\r\n\t\t} while(value!==undefined);\r\n\t}\r\n\tCXProduct.prototype.forEach = CXProduct.prototype.forEach1;\r\n\r\n\r\nexport {CXProduct,CXProduct as default}"],"names":[],"version":3,"file":"index.js.map"}