{"ast":null,"code":"import { flatten } from '../../utils/array.js';\nimport { factory } from '../../utils/factory.js';\nvar name = 'setUnion';\nvar dependencies = ['typed', 'size', 'concat', 'subset', 'setIntersect', 'setSymDifference', 'Index'];\nexport var createSetUnion = /* #__PURE__ */factory(name, dependencies, function (_ref) {\n  var typed = _ref.typed,\n      size = _ref.size,\n      concat = _ref.concat,\n      subset = _ref.subset,\n      setIntersect = _ref.setIntersect,\n      setSymDifference = _ref.setSymDifference,\n      Index = _ref.Index;\n  /**\n   * Create the union of two (multi)sets.\n   * Multi-dimension arrays will be converted to single-dimension arrays before the operation.\n   *\n   * Syntax:\n   *\n   *    math.setUnion(set1, set2)\n   *\n   * Examples:\n   *\n   *    math.setUnion([1, 2, 3, 4], [3, 4, 5, 6])            // returns [1, 2, 3, 4, 5, 6]\n   *    math.setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])    // returns [1, 2, 3, 4, 5, 6]\n   *\n   * See also:\n   *\n   *    setIntersect, setDifference\n   *\n   * @param {Array | Matrix}    a1  A (multi)set\n   * @param {Array | Matrix}    a2  A (multi)set\n   * @return {Array | Matrix}    The union of two (multi)sets\n   */\n\n  return typed(name, {\n    'Array | Matrix, Array | Matrix': function ArrayMatrixArrayMatrix(a1, a2) {\n      if (subset(size(a1), new Index(0)) === 0) {\n        // if any of them is empty, return the other one\n        return flatten(a2);\n      } else if (subset(size(a2), new Index(0)) === 0) {\n        return flatten(a1);\n      }\n\n      var b1 = flatten(a1);\n      var b2 = flatten(a2);\n      return concat(setSymDifference(b1, b2), setIntersect(b1, b2));\n    }\n  });\n});","map":{"version":3,"sources":["/Users/macpro/GITHUB/REPOS/Calculator/node_modules/mathjs/lib/esm/function/set/setUnion.js"],"names":["flatten","factory","name","dependencies","createSetUnion","_ref","typed","size","concat","subset","setIntersect","setSymDifference","Index","ArrayMatrixArrayMatrix","a1","a2","b1","b2"],"mappings":"AAAA,SAASA,OAAT,QAAwB,sBAAxB;AACA,SAASC,OAAT,QAAwB,wB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UAAIG,EAAE,GAAGjB,OAAO,CAACe,EAAD,CAAhB;AACA,aAAOP,MAAM,CAACG,gBAAgB,CAACK,EAAD,EAAKC,EAAL,CAAjB,EAA2BP,YAAY,CAACM,EAAD,EAAKC,EAAL,CAAvC,CAAb;AACD;AAZgB,GAAP,CAAZ;AAcD,CA9CiD,CAA3C","sourcesContent":["import { flatten } from '../../utils/array.js';\nimport { factory } from '../../utils/factory.js';\nvar name = 'setUnion';\nvar dependencies = ['typed', 'size', 'concat', 'subset', 'setIntersect', 'setSymDifference', 'Index'];\nexport var createSetUnion = /* #__PURE__ */factory(name, dependencies, (_ref) => {\n  var {\n    typed,\n    size,\n    concat,\n    subset,\n    setIntersect,\n    setSymDifference,\n    Index\n  } = _ref;\n\n  /**\n   * Create the union of two (multi)sets.\n   * Multi-dimension arrays will be converted to single-dimension arrays before the operation.\n   *\n   * Syntax:\n   *\n   *    math.setUnion(set1, set2)\n   *\n   * Examples:\n   *\n   *    math.setUnion([1, 2, 3, 4], [3, 4, 5, 6])            // returns [1, 2, 3, 4, 5, 6]\n   *    math.setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])    // returns [1, 2, 3, 4, 5, 6]\n   *\n   * See also:\n   *\n   *    setIntersect, setDifference\n   *\n   * @param {Array | Matrix}    a1  A (multi)set\n   * @param {Array | Matrix}    a2  A (multi)set\n   * @return {Array | Matrix}    The union of two (multi)sets\n   */\n  return typed(name, {\n    'Array | Matrix, Array | Matrix': function ArrayMatrixArrayMatrix(a1, a2) {\n      if (subset(size(a1), new Index(0)) === 0) {\n        // if any of them is empty, return the other one\n        return flatten(a2);\n      } else if (subset(size(a2), new Index(0)) === 0) {\n        return flatten(a1);\n      }\n\n      var b1 = flatten(a1);\n      var b2 = flatten(a2);\n      return concat(setSymDifference(b1, b2), setIntersect(b1, b2));\n    }\n  });\n});"]},"metadata":{},"sourceType":"module"}