UNPKG

215 kBJavaScriptView Raw
1var __extends=this&&this.__extends||function(e,t){function r(){this.constructor=e}for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)},powerbi;!function(e){var t;!function(e){var t=function(){function e(){}return e.prototype.visitEntity=function(e,t){return this.visitDefault(e,t)},e.prototype.visitColumnRef=function(e,t){return this.visitDefault(e,t)},e.prototype.visitMeasureRef=function(e,t){return this.visitDefault(e,t)},e.prototype.visitAggr=function(e,t){return this.visitDefault(e,t)},e.prototype.visitPercentile=function(e,t){return this.visitDefault(e,t)},e.prototype.visitHierarchy=function(e,t){return this.visitDefault(e,t)},e.prototype.visitHierarchyLevel=function(e,t){return this.visitDefault(e,t)},e.prototype.visitPropertyVariationSource=function(e,t){return this.visitDefault(e,t)},e.prototype.visitSelectRef=function(e,t){return this.visitDefault(e,t)},e.prototype.visitBetween=function(e,t){return this.visitDefault(e,t)},e.prototype.visitIn=function(e,t){return this.visitDefault(e,t)},e.prototype.visitAnd=function(e,t){return this.visitDefault(e,t)},e.prototype.visitOr=function(e,t){return this.visitDefault(e,t)},e.prototype.visitCompare=function(e,t){return this.visitDefault(e,t)},e.prototype.visitContains=function(e,t){return this.visitDefault(e,t)},e.prototype.visitExists=function(e,t){return this.visitDefault(e,t)},e.prototype.visitNot=function(e,t){return this.visitDefault(e,t)},e.prototype.visitStartsWith=function(e,t){return this.visitDefault(e,t)},e.prototype.visitConstant=function(e,t){return this.visitDefault(e,t)},e.prototype.visitDateSpan=function(e,t){return this.visitDefault(e,t)},e.prototype.visitDateAdd=function(e,t){return this.visitDefault(e,t)},e.prototype.visitNow=function(e,t){return this.visitDefault(e,t)},e.prototype.visitDefaultValue=function(e,t){return this.visitDefault(e,t)},e.prototype.visitAnyValue=function(e,t){return this.visitDefault(e,t)},e.prototype.visitArithmetic=function(e,t){return this.visitDefault(e,t)},e.prototype.visitFillRule=function(e,t){return this.visitDefault(e,t)},e.prototype.visitResourcePackageItem=function(e,t){return this.visitDefault(e,t)},e.prototype.visitScopedEval=function(e,t){return this.visitDefault(e,t)},e.prototype.visitDefault=function(e,t){},e}();e.DefaultSQExprVisitorWithArg=t;var r=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t}(t);e.DefaultSQExprVisitor=r;var i=function(){function e(){}return e.prototype.visitEntity=function(e){this.visitDefault(e)},e.prototype.visitColumnRef=function(e){e.source.accept(this)},e.prototype.visitMeasureRef=function(e){e.source.accept(this)},e.prototype.visitAggr=function(e){e.arg.accept(this)},e.prototype.visitPercentile=function(e){e.arg.accept(this)},e.prototype.visitHierarchy=function(e){e.arg.accept(this)},e.prototype.visitHierarchyLevel=function(e){e.arg.accept(this)},e.prototype.visitPropertyVariationSource=function(e){e.arg.accept(this)},e.prototype.visitSelectRef=function(e){this.visitDefault(e)},e.prototype.visitBetween=function(e){e.arg.accept(this),e.lower.accept(this),e.upper.accept(this)},e.prototype.visitIn=function(e){for(var t=e.args,r=0,i=t.length;i>r;r++)t[r].accept(this);for(var n=e.values,r=0,i=n.length;i>r;r++)for(var a=n[r],o=0,u=a.length;u>o;o++)a[o].accept(this)},e.prototype.visitAnd=function(e){e.left.accept(this),e.right.accept(this)},e.prototype.visitOr=function(e){e.left.accept(this),e.right.accept(this)},e.prototype.visitCompare=function(e){e.left.accept(this),e.right.accept(this)},e.prototype.visitContains=function(e){e.left.accept(this),e.right.accept(this)},e.prototype.visitExists=function(e){e.arg.accept(this)},e.prototype.visitNot=function(e){e.arg.accept(this)},e.prototype.visitStartsWith=function(e){e.left.accept(this),e.right.accept(this)},e.prototype.visitConstant=function(e){this.visitDefault(e)},e.prototype.visitDateSpan=function(e){e.arg.accept(this)},e.prototype.visitDateAdd=function(e){e.arg.accept(this)},e.prototype.visitNow=function(e){this.visitDefault(e)},e.prototype.visitDefaultValue=function(e){this.visitDefault(e)},e.prototype.visitAnyValue=function(e){this.visitDefault(e)},e.prototype.visitArithmetic=function(e){e.left.accept(this),e.right.accept(this)},e.prototype.visitFillRule=function(e){e.input.accept(this);var t=e.rule,r=t.linearGradient2,i=t.linearGradient3;r&&this.visitLinearGradient2(r),i&&this.visitLinearGradient3(i)},e.prototype.visitLinearGradient2=function(e){this.visitFillRuleStop(e.min),this.visitFillRuleStop(e.max)},e.prototype.visitLinearGradient3=function(e){this.visitFillRuleStop(e.min),this.visitFillRuleStop(e.mid),this.visitFillRuleStop(e.max)},e.prototype.visitResourcePackageItem=function(e){this.visitDefault(e)},e.prototype.visitScopedEval=function(e){e.expression.accept(this);for(var t=0,r=e.scope;t<r.length;t++){var i=r[t];i.accept(this)}},e.prototype.visitDefault=function(e){},e.prototype.visitFillRuleStop=function(e){e.color.accept(this);var t=e.value;t&&t.accept(this)},e}();e.DefaultSQExprVisitorWithTraversal=i}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){function t(e){return new r(e)}e.createEnumType=t;var r=function(){function e(e){this.allMembers=e}return e.prototype.members=function(e){var t=this.allMembers;if(!e)return t;for(var r=[],i=0,n=t;i<n.length;i++){var a=n[i];_.contains(e,a.value)&&r.push(a)}return r},e}()}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){function t(e){if(e===!0)return!1;var t=e;return!!t.nullable}e.nullable=t}(t=e.FillSolidColorTypeDescriptor||(e.FillSolidColorTypeDescriptor={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){e.urlType={misc:{imageUrl:!0}}}(t=e.ImageDefinition||(e.ImageDefinition={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){function t(e){return!!(e.fill||e.fillRule||e.filter||e.expression||e.image||e.paragraphs)}e.isValid=t}(t=e.StructuralTypeDescriptor||(e.StructuralTypeDescriptor={}))}(powerbi||(powerbi={}));var powerbi;!function(e){function t(e){return e&g}function r(e){return(e&d)===e}function i(e){if(r(e))return null;var t=h[e];if(t){var i=t.lastIndexOf("_");if(i>0){var n=t.slice(0,i);h[n]&&(t=n)}}return t||null}function n(e,r){var i=v[e],n=h[i];if(null==n&&(n=h.Null),e&&r){var a=h[r];if(a){var o=t(a);o===v.Null?(a=n|a,h[a]&&(n=a)):o===e&&(n=a)}}return n}function a(e,t){return(e&y)===(t&y)}var o=jsCommon.EnumExtensions,u=function(){function e(e,t,r){this.underlyingType=e,this.category=t,o.hasFlag(e,h.Temporal)&&(this.temporalType=new c(e)),o.hasFlag(e,h.Geography)&&(this.geographyType=new l(e)),o.hasFlag(e,h.Miscellaneous)&&(this.miscType=new p(e)),o.hasFlag(e,h.Formatting)&&(this.formattingType=new f(e)),o.hasFlag(e,h.Enumeration)&&(this.enumType=r),o.hasFlag(e,h.Scripting)&&(this.scriptingType=new s(e))}return e.fromDescriptor=function(t){if(t=t||{},t.text)return e.fromExtendedType(h.Text);if(t.integer)return e.fromExtendedType(h.Integer);if(t.numeric)return e.fromExtendedType(h.Double);if(t.bool)return e.fromExtendedType(h.Boolean);if(t.dateTime)return e.fromExtendedType(h.DateTime);if(t.duration)return e.fromExtendedType(h.Duration);if(t.binary)return e.fromExtendedType(h.Binary);if(t.none)return e.fromExtendedType(h.None);if(t.scripting&&t.scripting.source)return e.fromExtendedType(h.ScriptSource);if(t.enumeration)return e.fromEnum(t.enumeration);if(t.temporal){if(t.temporal.year)return e.fromExtendedType(h.Year_Integer);if(t.temporal.month)return e.fromExtendedType(h.Month_Integer)}if(t.geography){if(t.geography.address)return e.fromExtendedType(h.Address);if(t.geography.city)return e.fromExtendedType(h.City);if(t.geography.continent)return e.fromExtendedType(h.Continent);if(t.geography.country)return e.fromExtendedType(h.Country);if(t.geography.county)return e.fromExtendedType(h.County);if(t.geography.region)return e.fromExtendedType(h.Region);if(t.geography.postalCode)return e.fromExtendedType(h.PostalCode_Text);if(t.geography.stateOrProvince)return e.fromExtendedType(h.StateOrProvince);if(t.geography.place)return e.fromExtendedType(h.Place);if(t.geography.latitude)return e.fromExtendedType(h.Latitude_Double);if(t.geography.longitude)return e.fromExtendedType(h.Longitude_Double)}if(t.misc){if(t.misc.image)return e.fromExtendedType(h.Image);if(t.misc.imageUrl)return e.fromExtendedType(h.ImageUrl);if(t.misc.webUrl)return e.fromExtendedType(h.WebUrl);if(t.misc.barcode)return e.fromExtendedType(h.Barcode_Text)}if(t.formatting){if(t.formatting.color)return e.fromExtendedType(h.Color);if(t.formatting.formatString)return e.fromExtendedType(h.FormatString);if(t.formatting.alignment)return e.fromExtendedType(h.Alignment);if(t.formatting.labelDisplayUnits)return e.fromExtendedType(h.LabelDisplayUnits);if(t.formatting.fontSize)return e.fromExtendedType(h.FontSize);if(t.formatting.labelDensity)return e.fromExtendedType(h.LabelDensity)}return t.extendedType?e.fromExtendedType(t.extendedType):e.fromExtendedType(h.Null)},e.fromExtendedType=function(r){r=r||h.Null;var n=t(r),a=i(r);return e.fromPrimitiveTypeAndCategory(n,a)},e.fromPrimitiveTypeAndCategory=function(t,r){t=t||v.Null,r=r||null;var i=t.toString();return r&&(i+="|"+r),e.typeCache[i]||(e.typeCache[i]=new e(n(t,r),r))},e.fromEnum=function(t){return new e(h.Enumeration,null,t)},e.isCompatibleTo=function(t,r){for(var i=e.fromDescriptor(t),n=0,a=r;n<a.length;n++){var o=a[n],u=e.fromDescriptor(o);if(u.isCompatibleFrom(i))return!0}return!1},e.prototype.isCompatibleFrom=function(e){var t=e.primitiveType;return this===e||this.primitiveType===t||t===v.Null},e.prototype.equals=function(e){return _.isEqual(this,e)},Object.defineProperty(e.prototype,"primitiveType",{get:function(){return t(this.underlyingType)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"extendedType",{get:function(){return this.underlyingType},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"categoryString",{get:function(){return this.category},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"text",{get:function(){return this.primitiveType===v.Text},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"numeric",{get:function(){return o.hasFlag(this.underlyingType,h.Numeric)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"integer",{get:function(){return this.primitiveType===v.Integer},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bool",{get:function(){return this.primitiveType===v.Boolean},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dateTime",{get:function(){return this.primitiveType===v.DateTime||this.primitiveType===v.Date||this.primitiveType===v.Time},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){return this.primitiveType===v.Duration},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"binary",{get:function(){return this.primitiveType===v.Binary},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"none",{get:function(){return this.primitiveType===v.None},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"temporal",{get:function(){return this.temporalType},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"geography",{get:function(){return this.geographyType},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"misc",{get:function(){return this.miscType},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"formatting",{get:function(){return this.formattingType},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enum",{get:function(){return this.enumType},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scripting",{get:function(){return this.scriptingType},enumerable:!0,configurable:!0}),e.typeCache={},e}();e.ValueType=u;var s=function(){function e(e){this.underlyingType=e}return Object.defineProperty(e.prototype,"source",{get:function(){return a(this.underlyingType,h.ScriptSource)},enumerable:!0,configurable:!0}),e}();e.ScriptType=s;var c=function(){function e(e){this.underlyingType=e}return Object.defineProperty(e.prototype,"year",{get:function(){return a(this.underlyingType,h.Year)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"month",{get:function(){return a(this.underlyingType,h.Month)},enumerable:!0,configurable:!0}),e}();e.TemporalType=c;var l=function(){function e(e){this.underlyingType=e}return Object.defineProperty(e.prototype,"address",{get:function(){return a(this.underlyingType,h.Address)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"city",{get:function(){return a(this.underlyingType,h.City)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"continent",{get:function(){return a(this.underlyingType,h.Continent)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"country",{get:function(){return a(this.underlyingType,h.Country)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"county",{get:function(){return a(this.underlyingType,h.County)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"region",{get:function(){return a(this.underlyingType,h.Region)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"postalCode",{get:function(){return a(this.underlyingType,h.PostalCode)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"stateOrProvince",{get:function(){return a(this.underlyingType,h.StateOrProvince)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"place",{get:function(){return a(this.underlyingType,h.Place)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"latitude",{get:function(){return a(this.underlyingType,h.Latitude)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"longitude",{get:function(){return a(this.underlyingType,h.Longitude)},enumerable:!0,configurable:!0}),e}();e.GeographyType=l;var p=function(){function e(e){this.underlyingType=e}return Object.defineProperty(e.prototype,"image",{get:function(){return a(this.underlyingType,h.Image)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"imageUrl",{get:function(){return a(this.underlyingType,h.ImageUrl)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"webUrl",{get:function(){return a(this.underlyingType,h.WebUrl)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"barcode",{get:function(){return a(this.underlyingType,h.Barcode)},enumerable:!0,configurable:!0}),e}();e.MiscellaneousType=p;var f=function(){function e(e){this.underlyingType=e}return Object.defineProperty(e.prototype,"color",{get:function(){return a(this.underlyingType,h.Color)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"formatString",{get:function(){return a(this.underlyingType,h.FormatString)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alignment",{get:function(){return a(this.underlyingType,h.Alignment)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"labelDisplayUnits",{get:function(){return a(this.underlyingType,h.LabelDisplayUnits)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fontSize",{get:function(){return a(this.underlyingType,h.FontSize)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"labelDensity",{get:function(){return a(this.underlyingType,h.LabelDensity)},enumerable:!0,configurable:!0}),e}();e.FormattingType=f,function(e){e[e.Null=0]="Null",e[e.Text=1]="Text",e[e.Decimal=2]="Decimal",e[e.Double=3]="Double",e[e.Integer=4]="Integer",e[e.Boolean=5]="Boolean",e[e.Date=6]="Date",e[e.DateTime=7]="DateTime",e[e.DateTimeZone=8]="DateTimeZone",e[e.Time=9]="Time",e[e.Duration=10]="Duration",e[e.Binary=11]="Binary",e[e.None=12]="None"}(e.PrimitiveType||(e.PrimitiveType={}));var v=e.PrimitiveType;!function(e){e[e.Numeric=256]="Numeric",e[e.Temporal=512]="Temporal",e[e.Geography=1024]="Geography",e[e.Miscellaneous=2048]="Miscellaneous",e[e.Formatting=4096]="Formatting",e[e.Scripting=8192]="Scripting",e[e.Null=0]="Null",e[e.Text=1]="Text",e[e.Decimal=258]="Decimal",e[e.Double=259]="Double",e[e.Integer=260]="Integer",e[e.Boolean=5]="Boolean",e[e.Date=518]="Date",e[e.DateTime=519]="DateTime",e[e.DateTimeZone=520]="DateTimeZone",e[e.Time=521]="Time",e[e.Duration=10]="Duration",e[e.Binary=11]="Binary",e[e.None=12]="None",e[e.Year=66048]="Year",e[e.Year_Text=66049]="Year_Text",e[e.Year_Integer=66308]="Year_Integer",e[e.Year_Date=66054]="Year_Date",e[e.Year_DateTime=66055]="Year_DateTime",e[e.Month=131584]="Month",e[e.Month_Text=131585]="Month_Text",e[e.Month_Integer=131844]="Month_Integer",e[e.Month_Date=131590]="Month_Date",e[e.Month_DateTime=131591]="Month_DateTime",e[e.Address=6554625]="Address",e[e.City=6620161]="City",e[e.Continent=6685697]="Continent",e[e.Country=6751233]="Country",e[e.County=6816769]="County",e[e.Region=6882305]="Region",e[e.PostalCode=6947840]="PostalCode",e[e.PostalCode_Text=6947841]="PostalCode_Text",e[e.PostalCode_Integer=6948100]="PostalCode_Integer",e[e.StateOrProvince=7013377]="StateOrProvince",e[e.Place=7078913]="Place",e[e.Latitude=7144448]="Latitude",e[e.Latitude_Decimal=7144706]="Latitude_Decimal",e[e.Latitude_Double=7144707]="Latitude_Double",e[e.Longitude=7209984]="Longitude",e[e.Longitude_Decimal=7210242]="Longitude_Decimal",e[e.Longitude_Double=7210243]="Longitude_Double",e[e.Image=13109259]="Image",e[e.ImageUrl=13174785]="ImageUrl",e[e.WebUrl=13240321]="WebUrl",e[e.Barcode=13305856]="Barcode",e[e.Barcode_Text=13305857]="Barcode_Text",e[e.Barcode_Integer=13306116]="Barcode_Integer",e[e.Color=19664897]="Color",e[e.FormatString=19730433]="FormatString",e[e.Alignment=20058113]="Alignment",e[e.LabelDisplayUnits=20123649]="LabelDisplayUnits",e[e.FontSize=20189443]="FontSize",e[e.LabelDensity=20254979]="LabelDensity",e[e.Enumeration=26214401]="Enumeration",e[e.ScriptSource=32776193]="ScriptSource"}(e.ExtendedType||(e.ExtendedType={}));var h=e.ExtendedType,g=255,d=65535,y=4294901760}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){!function(e){e[e.Top=0]="Top",e[e.First=1]="First",e[e.Last=2]="Last",e[e.Sample=3]="Sample",e[e.Bottom=4]="Bottom"}(e.DataShapeBindingLimitType||(e.DataShapeBindingLimitType={}));e.DataShapeBindingLimitType;!function(e){e[e.None=0]="None",e[e.Before=1]="Before",e[e.After=2]="After"}(e.SubtotalType||(e.SubtotalType={}));e.SubtotalType}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){var t;!function(e){function t(e){if(e){var t;return e.top&&(t={Top:{}},e.top.count&&(t.Top.Count=e.top.count)),e.bottom&&(t={Bottom:{}},e.bottom.count&&(t.Bottom.Count=e.bottom.count)),e.sample&&(t={Sample:{}},e.sample.count&&(t.Sample.Count=e.sample.count)),e.window&&(t={Window:{}},e.window.count&&(t.Window.Count=e.window.count)),t}}e.createFrom=t}(t=e.DataShapeBindingDataReduction||(e.DataShapeBindingDataReduction={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){var t=function(){function e(e){this.schemas=e.schemas,e.links&&(this.links=e.links)}return e.prototype.schema=function(e){return this.schemas[e]},e}();e.FederatedConceptualSchema=t}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){var r;!function(r){function i(r,i){if(!_.isEmpty(r)){for(var n=[],a=0,o=r.length;o>a;a++){var u=r[a],s=u.data,c=void 0;if(s&&s.length)for(var l=0,p=s.length;p>l;l++)c=t.SQExprBuilder.and(c,u.data[l].expr);c&&n.push(c)}return _.isEmpty(n)?void 0:e.DataViewScopeIdentity.filterFromExprs(n,i)}}function n(r,i){var n=r.data;if(n.length!==i.length)return!1;for(var a=0,o=n.length;o>a;a++){var u=r.data[a],s=u;if(s.expr){if(!e.DataViewScopeIdentity.equals(s,i[a]))return!1}else if(!t.DataViewScopeWildcard.matches(u,i[a]))return!1}return!0}function a(e,r){var i=e.data,n=i.length;if(n!==r.length)return!1;for(var a=0;n>a;a++){var o=e.data[a],u=void 0;if(o.expr)u=t.ScopeIdentityExtractor.getKeys(o.expr);else{if(!o.exprs)return!1;u=o.exprs}if(u&&!t.SQExprUtils.sequenceEqual(r[a],u))return!1}return!0}function o(e,t){return e=e||null,t=t||null,e===t?!0:!e!=!t?!1:e.id!==t.id?!1:e.metadata!==t.metadata?!1:!!u(e.data,t.data)}function u(e,t){if(e=e||null,t=t||null,e===t)return!0;if(!e!=!t)return!1;if(e.length!==t.length)return!1;for(var r=0,i=e.length;i>r;r++)if(!s(e[r],t[r]))return!1;return!0}function s(r,i){var n=r,a=i;return n.expr&&a.expr?e.DataViewScopeIdentity.equals(n,a):n.exprs&&a.exprs?t.DataViewScopeWildcard.equals(n,a):n.roles&&a.roles?t.DataViewRoleWildcard.equals(n,a):!1}function c(e){var t={};if(e.data){for(var r=[],i=0,n=e.data.length;n>i;i++)r.push(e.data[i].key);t.data=r}return e.metadata&&(t.metadata=e.metadata),e.id&&(t.id=e.id),JSON.stringify(t)}function l(e){var t=e.data;if(!t)return!1;for(var r=0,i=t;r<i.length;r++){var n=i[r],a=n;if(a.exprs||a.roles)return!0}return!1}function p(e){var t=e.data;if(_.isEmpty(t))return!1;for(var r=0,i=t;r<i.length;r++){var n=i[r];if(f(n))return!0}return!1}function f(e){return!_.isEmpty(e.roles)}r.filterFromSelector=i,r.matchesData=n,r.matchesKeys=a,r.equals=o,r.getKey=c,r.containsWildcard=l,r.hasRoleWildcard=p,r.isRoleWildcard=f}(r=t.Selector||(t.Selector={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){function t(e){switch(e){case 0:return"Add";case 1:return"Subtract";case 2:return"Multiply";case 3:return"Divide"}throw new Error("Unexpected ArithmeticOperatorKind: "+e)}!function(e){e[e.Table=0]="Table",e[e.Pod=1]="Pod"}(e.EntitySourceType||(e.EntitySourceType={}));e.EntitySourceType;e.getArithmeticOperatorName=t,function(e){e[e.Day=0]="Day",e[e.Week=1]="Week",e[e.Month=2]="Month",e[e.Year=3]="Year",e[e.Decade=4]="Decade",e[e.Second=5]="Second",e[e.Minute=6]="Minute",e[e.Hour=7]="Hour"}(e.TimeUnit||(e.TimeUnit={}));e.TimeUnit;!function(e){e[e.Sum=0]="Sum",e[e.Avg=1]="Avg",e[e.Count=2]="Count",e[e.Min=3]="Min",e[e.Max=4]="Max",e[e.CountNonNull=5]="CountNonNull",e[e.Median=6]="Median",e[e.StandardDeviation=7]="StandardDeviation",e[e.Variance=8]="Variance"}(e.QueryAggregateFunction||(e.QueryAggregateFunction={}));e.QueryAggregateFunction;!function(e){e[e.Equal=0]="Equal",e[e.GreaterThan=1]="GreaterThan",e[e.GreaterThanOrEqual=2]="GreaterThanOrEqual",e[e.LessThan=3]="LessThan",e[e.LessThanOrEqual=4]="LessThanOrEqual"}(e.QueryComparisonKind||(e.QueryComparisonKind={}));e.QueryComparisonKind;!function(e){e[e.None=0]="None",e[e.Number=1]="Number",e[e.Integer=3]="Integer",e[e.DateTime=4]="DateTime",e[e.Time=8]="Time",e[e.Date=20]="Date",e[e.Month=35]="Month",e[e.Year=67]="Year",e[e.YearAndMonth=128]="YearAndMonth",e[e.MonthAndDay=256]="MonthAndDay",e[e.Decade=515]="Decade",e[e.YearAndWeek=1024]="YearAndWeek",e[e.String=2048]="String",e[e.Boolean=4096]="Boolean",e[e.Table=8192]="Table",e[e.Range=16384]="Range"}(e.SemanticType||(e.SemanticType={}));e.SemanticType;!function(e){e[e.Default=0]="Default",e[e.Period=1]="Period"}(e.FilterKind||(e.FilterKind={}));e.FilterKind}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){var t=function(){function e(e,t,r){this.items=e,this._activeProjectionRefs=t,this._showAll=r}return e.prototype.all=function(){return this.items},Object.defineProperty(e.prototype,"activeProjectionRefs",{get:function(){return this._activeProjectionRefs},set:function(e){if(!_.isEmpty(e)){for(var t=this.items.map(function(e){return e.queryRef}),r=0,i=e;r<i.length;r++){var n=i[r];if(!_.contains(t,n))return}this._activeProjectionRefs=e}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showAll",{get:function(){return this._showAll},set:function(e){this._showAll=e},enumerable:!0,configurable:!0}),e.prototype.addActiveQueryReference=function(e){this._activeProjectionRefs?this._activeProjectionRefs.push(e):this._activeProjectionRefs=[e]},e.prototype.getLastActiveQueryReference=function(){return _.isEmpty(this._activeProjectionRefs)?void 0:this._activeProjectionRefs[this._activeProjectionRefs.length-1]},e.prototype.replaceQueryRef=function(e,t){for(var r=0,i=this.items;r<i.length;r++){var n=i[r];n.queryRef===e&&(n.queryRef=t)}},e.prototype.clone=function(){return new e(_.cloneDeep(this.items),_.clone(this._activeProjectionRefs),this._showAll)},e}();e.QueryProjectionCollection=t;var r;!function(e){function t(e){if(!e)return e;var t={};for(var r in e)t[r]=e[r].clone();return t}function r(e,t){return e?e[t]:void 0}e.clone=t,e.getRole=r}(r=e.QueryProjectionsByRole||(e.QueryProjectionsByRole={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){!function(e){e[e.Default=0]="Default",e[e.Verbose=1]="Verbose",e[e.WholeUnits=2]="WholeUnits",e[e.DataLabels=3]="DataLabels"}(e.DisplayUnitSystemType||(e.DisplayUnitSystemType={}));e.DisplayUnitSystemType}(powerbi||(powerbi={}));var powerbi;!function(e){var t=function(){function t(e){this.unit=e,this.sequence=[],this.min=new Date("9999-12-31T23:59:59.999"),this.max=new Date("0001-01-01T00:00:00.000")}return t.prototype.add=function(e){e<this.min&&(this.min=e),e>this.max&&(this.max=e),this.sequence.push(e)},t.prototype.extendToCover=function(e,r){for(var i=this.min;i>e;)i=t.addInterval(i,-this.interval,this.unit),this.sequence.splice(0,0,i);for(this.min=i,i=this.max;r>i;)i=t.addInterval(i,this.interval,this.unit),this.sequence.push(i);this.max=i},t.prototype.moveToCover=function(e,r){var i=t.getDelta(e,r,this.unit),n=Math.floor(i/this.interval);for(this.min=t.addInterval(this.min,n*this.interval,this.unit),this.sequence=[],this.sequence.push(this.min),this.max=this.min;this.max<r;)this.max=t.addInterval(this.max,this.interval,this.unit),this.sequence.push(this.max)},t.calculate=function(r,i,n,a){switch(a||(a=t.getIntervalUnit(r,i,n)),a){case e.DateTimeUnit.Year:return t.calculateYears(r,i,n);case e.DateTimeUnit.Month:return t.calculateMonths(r,i,n);case e.DateTimeUnit.Week:return t.calculateWeeks(r,i,n);case e.DateTimeUnit.Day:return t.calculateDays(r,i,n);case e.DateTimeUnit.Hour:return t.calculateHours(r,i,n);case e.DateTimeUnit.Minute:return t.calculateMinutes(r,i,n);case e.DateTimeUnit.Second:return t.calculateSeconds(r,i,n);case e.DateTimeUnit.Millisecond:return t.calculateMilliseconds(r,i,n)}},t.calculateYears=function(r,i,n){var a=e.NumericSequenceRange.calculateDataRange(r.getFullYear(),i.getFullYear(),!1),o=e.NumericSequence.calculate(e.NumericSequenceRange.calculate(0,a.max-a.min),n,0,null,null,[1,2,5]),u=Math.floor(a.min/o.interval)*o.interval,s=new Date(u,0,1),c=t.fromNumericSequence(s,o,e.DateTimeUnit.Year);return c},t.calculateMonths=function(r,i,n){var a=r.getFullYear(),o=i.getFullYear(),u=r.getMonth(),s=12*(o-a)+i.getMonth(),c=new Date(a,0,1),l=e.NumericSequence.calculateUnits(u,s,n,[1,2,3,6,12]),p=t.fromNumericSequence(c,l,e.DateTimeUnit.Month);return p},t.calculateWeeks=function(r,i,n){var a=0,o=r.getDay(),u=(o-a+7)%7,s=r.getDate()-u,c=new Date(r.getFullYear(),r.getMonth(),s),l=0,p=e.Double.ceilWithPrecision(t.getDelta(c,i,e.DateTimeUnit.Week)),f=e.NumericSequence.calculateUnits(l,p,n,[1,2,4,8]),v=t.fromNumericSequence(c,f,e.DateTimeUnit.Week);return v},t.calculateDays=function(r,i,n){var a=new Date(r.getFullYear(),r.getMonth(),r.getDate()),o=0,u=e.Double.ceilWithPrecision(t.getDelta(r,i,e.DateTimeUnit.Day)),s=e.NumericSequence.calculateUnits(o,u,n,[1,2,7,14]),c=t.fromNumericSequence(a,s,e.DateTimeUnit.Day);return c},t.calculateHours=function(r,i,n){var a=new Date(r.getFullYear(),r.getMonth(),r.getDate()),o=e.Double.floorWithPrecision(t.getDelta(a,r,e.DateTimeUnit.Hour)),u=e.Double.ceilWithPrecision(t.getDelta(a,i,e.DateTimeUnit.Hour)),s=e.NumericSequence.calculateUnits(o,u,n,[1,2,3,6,12,24]),c=t.fromNumericSequence(a,s,e.DateTimeUnit.Hour);return c},t.calculateMinutes=function(r,i,n){var a=new Date(r.getFullYear(),r.getMonth(),r.getDate(),r.getHours()),o=e.Double.floorWithPrecision(t.getDelta(a,r,e.DateTimeUnit.Minute)),u=e.Double.ceilWithPrecision(t.getDelta(a,i,e.DateTimeUnit.Minute)),s=e.NumericSequence.calculateUnits(o,u,n,[1,2,5,10,15,30,60,120,180,360,720,1440]),c=t.fromNumericSequence(a,s,e.DateTimeUnit.Minute);return c},t.calculateSeconds=function(r,i,n){var a=new Date(r.getFullYear(),r.getMonth(),r.getDate(),r.getHours(),r.getMinutes()),o=e.Double.floorWithPrecision(t.getDelta(a,r,e.DateTimeUnit.Second)),u=e.Double.ceilWithPrecision(t.getDelta(a,i,e.DateTimeUnit.Second)),s=e.NumericSequence.calculateUnits(o,u,n,[1,2,5,10,15,30,60,120,300,600,900,1800,3600]),c=t.fromNumericSequence(a,s,e.DateTimeUnit.Second);return c},t.calculateMilliseconds=function(r,i,n){var a=new Date(r.getFullYear(),r.getMonth(),r.getDate(),r.getHours(),r.getMinutes(),r.getSeconds()),o=t.getDelta(a,r,e.DateTimeUnit.Millisecond),u=t.getDelta(a,i,e.DateTimeUnit.Millisecond),s=e.NumericSequence.calculate(e.NumericSequenceRange.calculate(o,u),n,0),c=t.fromNumericSequence(a,s,e.DateTimeUnit.Millisecond);return c},t.addInterval=function(t,i,n){switch(i=Math.round(i),n){case e.DateTimeUnit.Year:return r.addYears(t,i);case e.DateTimeUnit.Month:return r.addMonths(t,i);case e.DateTimeUnit.Week:return r.addWeeks(t,i);case e.DateTimeUnit.Day:return r.addDays(t,i);case e.DateTimeUnit.Hour:return r.addHours(t,i);case e.DateTimeUnit.Minute:return r.addMinutes(t,i);case e.DateTimeUnit.Second:return r.addSeconds(t,i);case e.DateTimeUnit.Millisecond:return r.addMilliseconds(t,i)}},t.fromNumericSequence=function(e,r,i){for(var n=new t(i),a=0;a<r.sequence.length;a++){var o=r.sequence[a],u=t.addInterval(e,o,i);n.add(u)}return n.interval=r.interval,n.intervalOffset=r.intervalOffset,n},t.getDelta=function(t,r,i){var n=0;switch(i){case e.DateTimeUnit.Year:n=r.getFullYear()-t.getFullYear();break;case e.DateTimeUnit.Month:n=12*(r.getFullYear()-t.getFullYear())+r.getMonth()-t.getMonth();break;case e.DateTimeUnit.Week:n=(r.getTime()-t.getTime())/6048e5;break;case e.DateTimeUnit.Day:n=(r.getTime()-t.getTime())/864e5;break;case e.DateTimeUnit.Hour:n=(r.getTime()-t.getTime())/36e5;break;case e.DateTimeUnit.Minute:n=(r.getTime()-t.getTime())/6e4;break;case e.DateTimeUnit.Second:n=(r.getTime()-t.getTime())/1e3;break;case e.DateTimeUnit.Millisecond:n=r.getTime()-t.getTime()}return n},t.getIntervalUnit=function(r,i,n){n=Math.max(n,2);var a=t.getDelta(r,i,e.DateTimeUnit.Day);if(a>356&&a>=180*n)return e.DateTimeUnit.Year;if(a>60&&a>7*n)return e.DateTimeUnit.Month;if(a>14&&a>2*n)return e.DateTimeUnit.Week;var o=t.getDelta(r,i,e.DateTimeUnit.Hour);if(a>2&&o>12*n)return e.DateTimeUnit.Day;if(o>=24&&o>=n)return e.DateTimeUnit.Hour;var u=t.getDelta(r,i,e.DateTimeUnit.Minute);if(u>2&&u>=n)return e.DateTimeUnit.Minute;var s=t.getDelta(r,i,e.DateTimeUnit.Second);if(s>2&&s>=.8*n)return e.DateTimeUnit.Second;var c=t.getDelta(r,i,e.DateTimeUnit.Millisecond);if(c>0)return e.DateTimeUnit.Millisecond;var l=r;return 0!==l.getMilliseconds()?e.DateTimeUnit.Millisecond:0!==l.getSeconds()?e.DateTimeUnit.Second:0!==l.getMinutes()?e.DateTimeUnit.Minute:0!==l.getHours()?e.DateTimeUnit.Hour:1!==l.getDate()?e.DateTimeUnit.Day:0!==l.getMonth()?e.DateTimeUnit.Month:e.DateTimeUnit.Year},t.MIN_COUNT=1,t.MAX_COUNT=1e3,t}();e.DateTimeSequence=t;var r;!function(e){function t(e){return e%4===0&&e%100!==0||e%400===0}function r(e,r){return t(e)?f[r]:p[r]}function i(e,r){var i=e.getFullYear(),n=e.getMonth(),a=e.getDate(),o=2===n&&29===a,u=new Date(e.getTime());return i+=r,o&&!t(i)&&(a=28),u.setFullYear(i,n,a),u}function n(e,t){var i=e.getFullYear(),n=e.getMonth(),a=e.getDate(),o=new Date(e.getTime());return i+=(t-t%12)/12,n+=t%12,n>11&&(n%=12,i++),a=Math.min(a,r(i,n)),o.setFullYear(i,n,a),o}function a(e,t){return o(e,7*t)}function o(e,t){var r=e.getFullYear(),i=e.getMonth(),n=e.getDate(),a=new Date(e.getTime());return a.setFullYear(r,i,n+t),a}function u(e,t){return new Date(e.getTime()+36e5*t)}function s(e,t){return new Date(e.getTime()+6e4*t)}function c(e,t){return new Date(e.getTime()+1e3*t)}function l(e,t){return new Date(e.getTime()+t)}var p=[31,28,31,30,31,30,31,31,30,31,30,31],f=[31,29,31,30,31,30,31,31,30,31,30,31];
2e.addYears=i,e.addMonths=n,e.addWeeks=a,e.addDays=o,e.addHours=u,e.addMinutes=s,e.addSeconds=c,e.addMilliseconds=l}(r=e.DateUtils||(e.DateUtils={}))}(powerbi||(powerbi={}));var powerbi;!function(e){function t(t,n){for(var a=[],o=3;i>o;o++){var u=t(o);u&&r(a,e.Double.pow10(o),u.title,u.format,n)}return a}function r(e,t,r,i,n){if(r||i){var a=t;if(e.length>0){var o=e[e.length-1];n&&(a=n(t,o.value,a)),o.applicableRangeMax=a}var u=new l;u.value=t,u.applicableRangeMin=a,u.applicableRangeMax=1e3*a,u.title=r,u.labelFormat=i,e.push(u)}}var i=24,n=1e15,a=1e-4,o="%",u="E+0",s="0.##"+u,c=/^([0\#,]*\.[0\#]+|[0\#,]+|g)$/i,l=function(){function t(){}return t.prototype.project=function(t){return this.value?e.Double.removeDecimalNoise(t/this.value):t},t.prototype.reverseProject=function(e){return this.value?e*this.value:e},t.prototype.isApplicableTo=function(t){t=Math.abs(t);var r=e.Double.getPrecision(t,3);return e.Double.greaterOrEqualWithPrecision(t,this.applicableRangeMin,r)&&e.Double.lessWithPrecision(t,this.applicableRangeMax,r)},t.prototype.isScaling=function(){return this.value>1},t}();e.DisplayUnit=l;var p=function(){function t(e){this.units=e?e:[]}return Object.defineProperty(t.prototype,"title",{get:function(){return this.displayUnit?this.displayUnit.title:void 0},enumerable:!0,configurable:!0}),t.prototype.update=function(e){void 0!==e&&(this.unitBaseValue=e,this.displayUnit=this.findApplicableDisplayUnit(e))},t.prototype.findApplicableDisplayUnit=function(e){for(var t=0,r=this.units;t<r.length;t++){var i=r[t];if(i.isApplicableTo(e))return i}},t.prototype.format=function(t,r,i,n){if(this.isFormatSupported(r)){if(i=this.getNumberOfDecimalsForFormatting(r,i),this.hasScientitifcFormat(r))return this.formatHelper(t,"",r,i,n);if(this.isScalingUnit()&&this.shouldRespectScalingUnit(r))return this.formatHelper(this.displayUnit.project(t),this.displayUnit.labelFormat,r,i,n);if(null!=i)return this.formatHelper(t,"",r,i,n)}return e.formattingService.formatValue(t,r)},t.prototype.isFormatSupported=function(e){return!t.UNSUPPORTED_FORMATS.test(e)},t.prototype.isPercentageFormat=function(e){return e&&e.indexOf(o)>=0},t.prototype.shouldRespectScalingUnit=function(e){return!this.isPercentageFormat(e)},t.prototype.getNumberOfDecimalsForFormatting=function(e,t){return t},t.prototype.isScalingUnit=function(){return this.displayUnit&&this.displayUnit.isScaling()},t.prototype.formatHelper=function(t,r,i,n,a){if("g"!==i&&"G"!==i||null==n||(i=e.visuals.valueFormatter.DefaultNumericFormat),i=e.NumberFormat.addDecimalsToFormat(i,n,a),i&&!e.formattingService.isStandardNumberFormat(i))return e.formattingService.formatNumberWithCustomOverride(t,i,r);i||(i="G"),r||(r="{0}");var o=e.formattingService.formatValue(t,i);return e.formattingService.format(r,[o])},t.prototype.formatSingleValue=function(t,r,i,n){return this.update(this.shouldUseValuePrecision(t)?e.Double.getPrecision(t,8):t),this.format(t,r,i,n)},t.prototype.shouldUseValuePrecision=function(e){if(0===this.units.length)return!0;for(var t=0,r=0;r<this.units.length;r++)if(this.units[r].isScaling()){t=this.units[r].applicableRangeMin;break}return Math.abs(e)<t},t.prototype.isScientific=function(e){return-n>e||e>n||e>-a&&a>e&&0!==e},t.prototype.hasScientitifcFormat=function(e){return e&&-1!==e.toUpperCase().indexOf("E")},t.prototype.supportsScientificFormat=function(e){return e?c.test(e):!0},t.prototype.shouldFallbackToScientific=function(e,t){return!this.hasScientitifcFormat(t)&&this.supportsScientificFormat(t)&&this.isScientific(e)},t.prototype.getScientificFormat=function(t,r,i,n){if(this.isFormatSupported(r)&&this.shouldFallbackToScientific(t,r)){var a=e.NumberFormat.getNumericFormat(t,r);return i&&(a=e.NumberFormat.addDecimalsToFormat(a?a:"0",Math.abs(i),n)),a?a+u:s}return r},t.UNSUPPORTED_FORMATS=/^(p\d*)|(.*\%)|(e\d*)$/i,t}();e.DisplayUnitSystem=p;var f=function(e){function t(){e.call(this,[])}return __extends(t,e),t}(p);e.NoDisplayUnitSystem=f;var v=function(e){function r(t){e.call(this,r.getUnits(t))}return __extends(r,e),r.prototype.format=function(t,r,i,n){return r=this.getScientificFormat(t,r,i,n),e.prototype.format.call(this,t,r,i,n)},r.reset=function(){r.units=null},r.getUnits=function(e){return r.units||(r.units=t(e,function(e,t,r){return e-t>=1e3?e/10:r}),r.units[r.units.length-1].applicableRangeMax=1/0),r.units},r}(p);e.DefaultDisplayUnitSystem=v;var h=function(e){function r(t){e.call(this,r.getUnits(t))}return __extends(r,e),r.reset=function(){r.units=null},r.getUnits=function(e){return r.units||(r.units=t(e),r.units[r.units.length-1].applicableRangeMax=1/0),r.units},r.prototype.format=function(t,r,i,n){return r=this.getScientificFormat(t,r,i,n),e.prototype.format.call(this,t,r,i,n)},r}(p);e.WholeUnitsDisplayUnitSystem=h;var g=function(e){function i(t){e.call(this,i.getUnits(t))}return __extends(i,e),i.prototype.isFormatSupported=function(e){return!i.UNSUPPORTED_FORMATS.test(e)},i.getUnits=function(e){if(!i.units){var n=[],a=function(e,t,r){return-1===e&&e-t>=1e3?e/10:r},o=e(-1);r(n,i.AUTO_DISPLAYUNIT_VALUE,o.title,o.format,a),o=e(0),r(n,i.NONE_DISPLAYUNIT_VALUE,o.title,o.format,a),i.units=n.concat(t(e,a)),i.units[i.units.length-1].applicableRangeMax=1/0}return i.units},i.prototype.format=function(t,r,i,n){return r=this.getScientificFormat(t,r,i,n),e.prototype.format.call(this,t,r,i,n)},i.AUTO_DISPLAYUNIT_VALUE=0,i.NONE_DISPLAYUNIT_VALUE=1,i.UNSUPPORTED_FORMATS=/^(e\d*)$/i,i}(p);e.DataLabelsDisplayUnitSystem=g}(powerbi||(powerbi={}));var powerbi;!function(e){var t=function(){function t(){}return t.calculate=function(r,i,n,a,o,u){var s=new t;if(i=void 0===i?10:e.Double.ensureInRange(i,t.MIN_COUNT,t.MAX_COUNT),void 0===a&&(a=e.Double.MIN_EXP),void 0===o&&(o=!1),void 0===n&&(n=1),void 0===u&&(u=[1,2,5]),r.forcedSingleStop)return s.interval=r.getSize(),s.intervalOffset=s.interval-(r.forcedSingleStop-r.min),s.min=r.min,s.max=r.max,s.sequence=[r.forcedSingleStop],s;var c=0,l=0,p=9,f=n>0&&!r.hasFixedMin,v=n>0&&!r.hasFixedMax,h=r.getSize(),g=e.Double.log10(h),d=e.Double.log10(u[0]);g-=d;var y=e.Double.log10(i);g-=y,g=Math.max(g,a-d+1);var m=void 0;if(0!==c){var x=e.Double.pow10(g),S=e.Double.floorToPrecision(r.min,x),E=e.Double.ceilToPrecision(r.max,x),w=e.NumericSequenceRange.calculateFixedRange(S,E);w.shrinkByStep(r,c),l=w.min,p=w.max,m=Math.floor(w.getSize()/c)}else{var b=void 0;for(b=0;3>b;b++){for(var D=g+b,x=e.Double.pow10(D),S=e.Double.floorToPrecision(r.min,x),E=e.Double.ceilToPrecision(r.max,x),C=u.length,T=e.Double.pow10(D-1),V=0;C>V;V++){var _=u[V]*T,w=e.NumericSequenceRange.calculateFixedRange(S,E,o);if(w.shrinkByStep(r,_),f&&r.min===w.min&&n>=1&&(w.min-=_),v&&r.max===w.max&&n>=1&&(w.max+=_),m=e.Double.ceilWithPrecision(w.getSize()/_),i>=m||2===b&&V===C-1||1===i&&2===m&&(_>r.getSize()||r.min<0&&r.max>0&&2*_>=r.getSize())){c=_,l=w.min,p=w.max;break}}if(0!==c)break}}(m>32*i||m>t.MAX_COUNT)&&(m=Math.min(32*i,t.MAX_COUNT),c=(p-l)/m),s.min=l,s.max=p,s.interval=c,s.intervalOffset=l-r.min,s.maxAllowedMargin=n,s.canExtendMin=f,s.canExtendMax=v;var F=e.Double.getPrecision(c,0);s.precision=F;var P=[],M=e.Double.roundToPrecision(l,F);P.push(M);for(var V=0;m>V;V++)M=e.Double.roundToPrecision(M+c,F),P.push(M);return s.sequence=P,s.trimMinMax(r.min,r.max),s},t.calculateUnits=function(r,i,n,a){n=e.Double.ensureInRange(n,t.MIN_COUNT,t.MAX_COUNT),r===i&&(i=r+1);for(var o=0,u=0,s=0;s<a.length;s++){u=a[s];var c=e.Double.ceilWithPrecision(i/u),l=e.Double.floorWithPrecision(r/u);if(o=c-l,n>=o)break}var p=-r;p%=u;var f=new t;f.sequence=[];for(var v=r+p;f.sequence.push(v),!(v>=i);v+=u);return f.interval=u,f.intervalOffset=p,f.min=f.sequence[0],f.max=f.sequence[f.sequence.length-1],f},t.prototype.trimMinMax=function(e,t){var r=(e-this.min)/this.interval,i=(this.max-t)/this.interval,n=.001;(!this.canExtendMin||r>this.maxAllowedMargin&&r>n)&&(this.min=e),(!this.canExtendMax||i>this.maxAllowedMargin&&i>n)&&(this.max=t)},t.MIN_COUNT=1,t.MAX_COUNT=1e3,t}();e.NumericSequence=t}(powerbi||(powerbi={}));var powerbi;!function(e){var t=function(){function t(){}return t.prototype._ensureIncludeZero=function(){this.includeZero&&(this.min>0&&!this.hasFixedMin&&(this.min=0),this.max<0&&!this.hasFixedMax&&(this.max=0))},t.prototype._ensureNotEmpty=function(){if(this.min===this.max)if(this.min){var r=this.min,i=e.Double.log10(Math.abs(r)),n=void 0;i>=0&&4>i?(n=.5,this.forcedSingleStop=r):(n=e.Double.pow10(i)/2,this.forcedSingleStop=null),this.min=r-n,this.max=r+n}else this.min=0,this.max=t.DEFAULT_MAX,this.hasFixedMin=!0,this.hasFixedMax=!0},t.prototype._ensureDirection=function(){if(this.min>this.max){var e=this.min;this.min=this.max,this.max=e}},t.prototype.getSize=function(){return this.max-this.min},t.prototype.shrinkByStep=function(e,t){var r=this.min/t,i=e.min/t,n=Math.floor(i-r);this.min+=n*t,r=this.max/t,i=e.max/t,n=Math.ceil(i-r),this.max+=n*t},t.calculate=function(i,n,a,o,u){var s=new t;return s.includeZero=!!u,s.hasDataRange=r.hasValue(i)&&r.hasValue(n),s.hasFixedMin=r.hasValue(a),s.hasFixedMax=r.hasValue(o),i=e.Double.ensureInRange(i,t.MIN_SUPPORTED_DOUBLE,t.MAX_SUPPORTED_DOUBLE),n=e.Double.ensureInRange(n,t.MIN_SUPPORTED_DOUBLE,t.MAX_SUPPORTED_DOUBLE),s.hasFixedMin&&s.hasFixedMax?(s.min=a,s.max=o):s.hasFixedMin?(s.min=a,s.max=n>a?n:a):s.hasFixedMax?(s.min=o>i?i:o,s.max=o):s.hasDataRange?(s.min=i,s.max=n):(s.min=0,s.max=0),s._ensureIncludeZero(),s._ensureNotEmpty(),s._ensureDirection(),0===s.min?s.hasFixedMin=!0:0===s.max&&(s.hasFixedMax=!0),s},t.calculateDataRange=function(e,i,n){return r.hasValue(e)&&r.hasValue(i)?t.calculate(e,i,null,null,n):t.calculateFixedRange(0,t.DEFAULT_MAX)},t.calculateFixedRange=function(e,r,i){var n=new t;return n.hasDataRange=!1,n.includeZero=i,n.min=e,n.max=r,n._ensureIncludeZero(),n._ensureNotEmpty(),n._ensureDirection(),n.hasFixedMin=!0,n.hasFixedMax=!0,n},t.DEFAULT_MAX=10,t.MIN_SUPPORTED_DOUBLE=-1e307,t.MAX_SUPPORTED_DOUBLE=1e307,t}();e.NumericSequenceRange=t;var r;!function(e){function t(e){return void 0!==e&&null!==e}e.hasValue=t}(r=e.ValueUtil||(e.ValueUtil={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){var r;!function(t){function r(e){var t=b[e];return t?D[t]||e:e}function i(e){var t=-1===e?"Auto":e.toString(),r=D["DisplayUnitSystem_E"+t+"_Title"],i=0>=e?"{0}":D["DisplayUnitSystem_E"+t+"_LabelFormat"];return r||i?{title:r,format:i}:void 0}function n(e){return D[e]}function a(t){return e.NumberFormat.getCustomFormatMetadata(t)}function o(t){C=t,e.DefaultDisplayUnitSystem.reset(),e.WholeUnitsDisplayUnitSystem.reset()}function u(e,t){void 0===t&&(t=!1);var r=t?C.beautify(e):e;return{format:function(e){return null==e?C["null"]:x(e,r)}}}function s(t){var r=t.allowFormatBeautification?C.beautify(t.format):t.format;if(v(t)){var i=f(t.displayUnitSystemType),n=!!t.formatSingleValues;i.update(Math.max(Math.abs(t.value||0),Math.abs(t.value2||0)));var a,o=null!=t.precision;if(o?a=-t.precision:i.displayUnit&&i.displayUnit.value>1&&(a=-T),t.detectAxisPrecision){o=!0;var s=t.value;i.displayUnit&&i.displayUnit.value>0&&(s/=i.displayUnit.value),a=e.Double.isInteger(s)?0:e.Double.log10(s)}return{format:function(t){var u=S(t,!0);return w.isNullOrUndefinedOrWhiteSpaceString(u)?(t&&!i.isScalingUnit()&&Math.abs(t)<V&&!o&&(t=e.Double.roundToPrecision(t)),n?i.formatSingleValue(t,r,a,o):i.format(t,r,a,o)):u},displayUnit:i.displayUnit,options:t}}if(h(t.value,t.value2,t.tickCount)){var c=e.DateTimeSequence.getIntervalUnit(t.value,t.value2,t.tickCount);return{format:function(t){if(null==t)return C["null"];var r=e.formattingService.dateFormatString(c);return x(t,r)},options:t}}return u(r)}function c(e,t,r){return null==e?C["null"]:x(e,r?C.beautify(t):t)}function l(e,t){return t&&t.dateTime||!(e instanceof Date)?void 0:g(P,null,!1)}function p(e,t,r){var i=l(e,t.type);return i?x(e,i):x(e,g(t,r))}function f(t){if(null==t)return new e.DefaultDisplayUnitSystem(C.describe);switch(t){case e.DisplayUnitSystemType.Default:return new e.DefaultDisplayUnitSystem(C.describe);case e.DisplayUnitSystemType.WholeUnits:return new e.WholeUnitsDisplayUnitSystem(C.describe);case e.DisplayUnitSystemType.Verbose:return new e.NoDisplayUnitSystem;case e.DisplayUnitSystemType.DataLabels:return new e.DataLabelsDisplayUnitSystem(C.describe);default:return new e.DefaultDisplayUnitSystem(C.describe)}}function v(t){var r=t.value,i=t.value2,n=t.format;if(t.formatSingleValues&&n&&Math.abs(r)<_){var a=!e.NumberFormat.isStandardFormat(n);if(a){var o=e.NumberFormat.getCustomFormatMetadata(n,!0).precision;if(F>o)return!1}else if(e.Double.isInteger(r))return!1}return"number"==typeof r||"number"==typeof i?!0:void 0}function h(e,t,r){return e instanceof Date&&t instanceof Date&&void 0!==r&&null!==r}function g(r,i,n){if(r){if(i){var a=e.DataViewObjects.getValue(r.objects,i);if(a)return a}if(!n){var o=r.type;if(o){if(o.dateTime)return t.DefaultDateFormat;if(o.integer)return t.DefaultIntegerFormat;if(o.numeric)return t.DefaultNumericFormat}}}}function d(e,t){var r;if(!e)return null;var i=e.length;if(i>0){r=e[0];for(var n=i-1,a=1,o=n;o>a;a++){var u=e[a];r=w.format(C.restatementComma,r,u)}if(i>1){var u=e[n];r=w.format(t,r,u)}}else r=null;return r}function y(e){return d(e,C.restatementCompoundAnd)}function m(e){return d(e,C.restatementCompoundOr)}function x(t,r){var i=S(t,!1);return w.isNullOrUndefinedOrWhiteSpaceString(i)?e.formattingService.formatValue(t,r):i}function S(e,t){return null==e&&t?C["null"]:e===!0?C["true"]:e===!1?C["false"]:"number"==typeof e&&isNaN(e)?C.NaN:e===Number.NEGATIVE_INFINITY?C.negativeInfinity:e===Number.POSITIVE_INFINITY?C.infinity:""}function E(e){var t=f(e);return t.units}var w=jsCommon.StringExtensions,b={"0.00 %;-0.00 %;0.00 %":"Percentage","0.0 %;-0.0 %;0.0 %":"Percentage1"};t.DefaultIntegerFormat="g",t.DefaultNumericFormat="#,0.00",t.DefaultDateFormat="d";var D={NullValue:"(Blank)",BooleanTrue:"True",BooleanFalse:"False",NaNValue:"NaN",InfinityValue:"+Infinity",NegativeInfinityValue:"-Infinity",RestatementComma:"{0}, {1}",RestatementCompoundAnd:"{0} and {1}",RestatementCompoundOr:"{0} or {1}",DisplayUnitSystem_EAuto_Title:"Auto",DisplayUnitSystem_E0_Title:"None",DisplayUnitSystem_E3_LabelFormat:"{0}K",DisplayUnitSystem_E3_Title:"Thousands",DisplayUnitSystem_E6_LabelFormat:"{0}M",DisplayUnitSystem_E6_Title:"Millions",DisplayUnitSystem_E9_LabelFormat:"{0}bn",DisplayUnitSystem_E9_Title:"Billions",DisplayUnitSystem_E12_LabelFormat:"{0}T",DisplayUnitSystem_E12_Title:"Trillions",Percentage:"#,0.##%",Percentage1:"#,0.#%",TableTotalLabel:"Total",Tooltip_HighlightedValueDisplayName:"Highlighted",Funnel_PercentOfFirst:"Percent of first",Funnel_PercentOfPrevious:"Percent of previous",Funnel_PercentOfFirst_Highlight:"Percent of first (highlighted)",Funnel_PercentOfPrevious_Highlight:"Percent of previous (highlighted)",GeotaggingString_Continent:"continent",GeotaggingString_Continents:"continents",GeotaggingString_Country:"country",GeotaggingString_Countries:"countries",GeotaggingString_State:"state",GeotaggingString_States:"states",GeotaggingString_City:"city",GeotaggingString_Cities:"cities",GeotaggingString_Town:"town",GeotaggingString_Towns:"towns",GeotaggingString_Province:"province",GeotaggingString_Provinces:"provinces",GeotaggingString_County:"county",GeotaggingString_Counties:"counties",GeotaggingString_Village:"village",GeotaggingString_Villages:"villages",GeotaggingString_Post:"post",GeotaggingString_Zip:"zip",GeotaggingString_Code:"code",GeotaggingString_Place:"place",GeotaggingString_Places:"places",GeotaggingString_Address:"address",GeotaggingString_Addresses:"addresses",GeotaggingString_Street:"street",GeotaggingString_Streets:"streets",GeotaggingString_Longitude:"longitude",GeotaggingString_Longitude_Short:"lon",GeotaggingString_Latitude:"latitude",GeotaggingString_Latitude_Short:"lat",GeotaggingString_PostalCode:"postal code",GeotaggingString_PostalCodes:"postal codes",GeotaggingString_ZipCode:"zip code",GeotaggingString_ZipCodes:"zip codes",GeotaggingString_Territory:"territory",GeotaggingString_Territories:"territories"};t.getLocalizedString=n;var C={"null":D.NullValue,"true":D.BooleanTrue,"false":D.BooleanFalse,NaN:D.NaNValue,infinity:D.InfinityValue,negativeInfinity:D.NegativeInfinityValue,beautify:function(e){return r(e)},describe:function(e){return i(e)},restatementComma:D.RestatementComma,restatementCompoundAnd:D.RestatementCompoundAnd,restatementCompoundOr:D.RestatementCompoundOr},T=2,V=1e3,_=1e4,F=2,P={displayName:"",type:e.ValueType.fromPrimitiveTypeAndCategory(e.PrimitiveType.DateTime)};t.getFormatMetadata=a,t.setLocaleOptions=o,t.createDefaultFormatter=u,t.create=s,t.format=c,t.formatValueColumn=p,t.getFormatString=g,t.formatListAnd=y,t.formatListOr=m,t.getDisplayUnits=E}(r=t.valueFormatter||(t.valueFormatter={}))}(t=e.visuals||(e.visuals={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){var t;!function(e){function t(e,t){if(!_.isEmpty(e)){var r=e[0];if(r.values&&r.values.length>0)for(var n=0,a=r.values.length;a>n;++n){var o=r.values[n];if(o&&o.source&&i(o.source,t))return n}}return-1}function r(e,t){if(!_.isEmpty(e))for(var r=0,n=e.length;n>r;r++)if(i(e[r].source,t))return r;return-1}function i(e,t){var r=e.roles;return r&&r[t]}function n(e,t){return null!=e&&null!=e.metadata&&e.metadata.columns&&_.any(e.metadata.columns,function(e){return e.roles&&void 0!==e.roles[t]})}function a(e,t){return e&&e.source&&e.source.roles&&e.source.roles[t]===!0}e.getMeasureIndexOfRole=t,e.getCategoryIndexOfRole=r,e.hasRole=i,e.hasRoleInDataView=n,e.hasRoleInValueColumn=a}(t=e.DataRoleHelper||(e.DataRoleHelper={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){function r(e){return new n(e)}var i=e.data.DataRoleHelper;t.createIDataViewCategoricalReader=r;var n=function(){function e(e){this.dataView=e;var t;e&&(t=e.categorical);var r;t&&(r=this.categories=t.categories),this.hasValidCategories=!_.isEmpty(r);var i;if(t&&(i=t.values),this.hasAnyValidValues=!1,null!=i){var n=e.categorical.values.grouped();if(n.length>0){this.hasAnyValidValues=!0,this.grouped=n;for(var a={},o=n[0].values,u=0,s=o.length;s>u;u++){var c=o[u].source.roles;for(var l in c)c[l]&&(a[l]||(a[l]=[]),a[l].push(u))}this.valueRoleIndexMapping=a}}this.hasAnyValidValues&&(this.dataHasDynamicSeries=!!this.dataView.categorical.values.source)}return e.prototype.hasCategories=function(){return this.hasValidCategories},e.prototype.getCategoryCount=function(){return this.hasValidCategories?this.categories[0].values.length:0},e.prototype.getCategoryValues=function(e){if(this.hasValidCategories){var t=this.getCategoryFromRole(e);return t?t.values:void 0}},e.prototype.getCategoryValue=function(e,t){if(this.hasValidCategories){var r=this.getCategoryFromRole(e);return r?r.values[t]:void 0}},e.prototype.getCategoryColumn=function(e){return this.hasValidCategories?this.getCategoryFromRole(e):void 0},e.prototype.getCategoryMetadataColumn=function(e){if(this.hasValidCategories){var t=this.getCategoryFromRole(e);return t?t.source:void 0}},e.prototype.getCategoryColumnIdentityFields=function(e){if(this.hasValidCategories){var t=this.getCategoryFromRole(e);return t?t.identityFields:void 0}},e.prototype.getCategoryDisplayName=function(e){if(this.hasValidCategories){var t=this.getCategoryColumn(e);if(t&&t.source)return t.source.displayName}},e.prototype.hasCompositeCategories=function(){return this.hasValidCategories?this.categories.length>1:void 0},e.prototype.hasCategoryWithRole=function(e){return-1!==i.getCategoryIndexOfRole(this.categories,e)},e.prototype.getCategoryObjects=function(e,t){if(this.hasValidCategories){var r=this.getCategoryFromRole(e);if(r&&r.objects)return r.objects[t]}},e.prototype.getCategoryFromRole=function(e){var t=this.categories;return t[i.getCategoryIndexOfRole(t,e)]},e.prototype.hasValues=function(e){return this.valueRoleIndexMapping&&!_.isEmpty(this.valueRoleIndexMapping[e])},e.prototype.getValue=function(e,t,r){return void 0===r&&(r=0),this.hasValues(e)?this.dataHasDynamicSeries?this.getValueInternal(e,t,r,0,!1):this.getValueInternal(e,t,0,r,!1):void 0},e.prototype.getHighlight=function(e,t,r){return void 0===r&&(r=0),this.hasValues(e)?this.dataHasDynamicSeries?this.getValueInternal(e,t,r,0,!0):this.getValueInternal(e,t,0,r,!0):void 0},e.prototype.getAllValuesForRole=function(e,t,r){if(void 0===r&&(r=0),this.hasValues(e)){for(var i=[],n=void 0,a=this.valueRoleIndexMapping[e].length;a>n;n++)i.push(this.getValueInternal(e,t,r,n,!1));return i}},e.prototype.getAllHighlightsForRole=function(e,t,r){if(void 0===r&&(r=0),this.hasValues(e)){for(var i=[],n=void 0,a=this.valueRoleIndexMapping[e].length;a>n;n++)i.push(this.getValueInternal(e,t,r,n,!0));return i}},e.prototype.getValueInternal=function(e,t,r,i,n){if(this.hasValues(e)){var a=this.valueRoleIndexMapping[e][i],o=this.grouped[r].values[a];return n?o.highlights[t]:o.values[t]}},e.prototype.getFirstNonNullValueForCategory=function(e,t){if(this.hasValues(e)){if(!this.dataHasDynamicSeries)return this.getValue(e,t);for(var r=0,i=this.grouped.length;i>r;r++){var n=this.getValue(e,t,r);if(null!=n)return n}}},e.prototype.getMeasureQueryName=function(e){return this.hasValues(e)?this.grouped[0].values[this.valueRoleIndexMapping[e][0]].source.queryName:void 0},e.prototype.getValueColumn=function(e,t){return void 0===t&&(t=0),this.hasValues(e)?this.dataHasDynamicSeries?this.grouped[t].values[this.valueRoleIndexMapping[e][0]]:this.grouped[0].values[this.valueRoleIndexMapping[e][t]]:void 0},e.prototype.getValueMetadataColumn=function(e,t){void 0===t&&(t=0);var r=this.getValueColumn(e,t);return r?r.source:void 0},e.prototype.getValueDisplayName=function(e,t){if(this.hasValues(e)){var r=this.getValueColumn(e,t);if(r&&r.source)return r.source.displayName}},e.prototype.hasDynamicSeries=function(){return this.dataHasDynamicSeries},e.prototype.getSeriesCount=function(e){return this.hasAnyValidValues?this.dataHasDynamicSeries?this.grouped.length:e?this.valueRoleIndexMapping[e].length:1:void 0},e.prototype.getSeriesObjects=function(e){return this.hasAnyValidValues?this.grouped[e].objects:void 0},e.prototype.getSeriesValueColumns=function(){return this.hasAnyValidValues?this.dataView.categorical.values:void 0},e.prototype.getSeriesValueColumnGroup=function(e){return this.hasAnyValidValues?this.grouped[e]:void 0},e.prototype.getSeriesMetadataColumn=function(){return this.hasAnyValidValues?this.dataView.categorical.values.source:void 0},e.prototype.getSeriesColumnIdentityFields=function(){return this.hasAnyValidValues?this.dataView.categorical.values.identityFields:void 0},e.prototype.getSeriesName=function(e){return this.hasAnyValidValues?this.grouped[e].name:void 0},e.prototype.getSeriesDisplayName=function(){return this.hasAnyValidValues&&this.dataHasDynamicSeries?this.dataView.categorical.values.source.displayName:void 0},e}()}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){var r,i=e.Prototype.inherit,n=e.Prototype.inheritSingle,a=e.visuals.valueFormatter;!function(r){function o(e,t,r,i,n,a){var o=e,u=e.categorical;if(u){var c=s(u,e.metadata,r,n,a);if(c){var l=h(i,c.roleName,c.categories);if(l.length>=2){var p=_.chain(a[c.roleName]).filter(function(e){return e.suppressConcat}).map(function(e){return e.queryRef}).value();o=f(e,t,c.roleName,l,p)}}}return o}function u(e,t,r,n){var a;if(!_.isEmpty(n.categories)&&n.categories.length>=2){var o=i(e.columns),u=i(e,function(e){e.columns=o}),s={metadata:u,categorical:n};a=f(s,t,r,n.categories,[])}else a={metadata:e,categorical:n};return a}function s(r,i,n,a,o){var u,s=t.DataViewSelectTransform.createRoleKindFromMetadata(a,i),p=t.DataViewSelectTransform.projectionsFromSelects(a,o),f=e.DataViewAnalysis.chooseDataViewMappings(p,n,s).supportedMappings,v=!_.isEmpty(f)&&_.every(f,function(e){return!!e.categorical});if(v){var h=c(f);if(h&&l(h,f)){var g=_.filter(r.categories,function(e){return e.source.roles&&!!e.source.roles[h]});if(g.length>=2){var d=_.every(g,function(e){return e.values.length===g[0].values.length});d&&(u={roleName:h,categories:g})}}}return u}function c(e){var t,r=_.chain(e).map(function(e){var t=p(e.categorical);return 1===t.length?t[0]:void 0}).uniq().value(),i=1===r.length&&!_.isUndefined(r[0]);return i&&(t=r[0]),t}function l(e,t){var r=_.every(t,function(t){return!_.isEmpty(t.conditions)&&_.every(t.conditions,function(t){return t[e]&&1===t[e].max})});return r}function p(t){var r=[];return e.DataViewMapping.visitCategoricalCategories(t.categories,{visitRole:function(e){r.push(e)}}),r}function f(e,r,i,a,o){var u=t.DataViewObjectDescriptors.findFormatString(r),s=v(a,o,u),c=_.map(a,function(e){return e.source}),l=g(i,c,o),p=n(e);d(p,l);var f=y(a,l,s),h=e.categorical,m=_.difference(h.categories,a);m.push(f);var x=n(h);return x.categories=m,p.categorical=x,p}function v(e,t,r){for(var i=[],n=0,o=e;n<o.length;n++)for(var u=o[n],s=a.getFormatString(u.source,r),c=0,l=u.values.length;l>c;c++)if(!_.contains(t,u.source.queryName)){var p=u.values&&u.values[c],f=a.format(p,s);i[c]=void 0===i[c]?f:f+" "+i[c]}return i}function h(e,t,r){var i;if(e){for(var n={},a=0,o=r;a<o.length;a++){var u=o[a];u.source.roles[t]&&(n[u.source.index]=u)}var s=e[t];i=_.chain(s).map(function(e){return n[e]}).filter(function(e){return!!e}).value()}else i=_.filter(r,function(e){return e.source.roles[t]});return i}function g(t,r,i){for(var n,a=0,o=r;a<o.length;a++){var u=o[a];_.contains(i,u.queryName)||(n=null==n?u.displayName:u.displayName+" "+n)}var s={};s[t]=!0;var c={displayName:n,roles:s,type:e.ValueType.fromPrimitiveTypeAndCategory(e.PrimitiveType.Text)},l=_.last(r);return void 0!==l.isMeasure&&(c.isMeasure=l.isMeasure),c.queryName=l.queryName,c}function d(e,t){var r=n(e.metadata.columns);r.push(t);var i=n(e.metadata);i.columns=r,e.metadata=i}function y(e,t,r){var i={source:t,values:r},n=e[0];return n.identity&&(i.identity=n.identity),n.identityFields&&(i.identityFields=n.identityFields),n.objects&&(i.objects=n.objects),i}r.detectAndApply=o,r.applyToPlayChartCategorical=u}(r=t.DataViewConcatenateCategoricalColumns||(t.DataViewConcatenateCategoricalColumns={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){function t(e,t){var i=e.categorical;i&&r(i,t);var n=e.table;n&&a(n,t);var u=e.matrix;u&&o(u,t);var c=e.tree;c&&s(c,t);var l=e.single;l&&d(l,t)}function r(e,t){i(e.categories,t),n(e.values,t)}function i(e,t){e&&(p(e,t),f(e,t),v(e,t),g(e,t))}function n(e,t){if(e){p(e,t,0),f(e,t,0),v(e,t,0);var r=e;h(r,t);var i=r.group;if(i)for(var n=0,a=i.select;n<a.length;n++){var o=a[n];p(o,t,1),f(o,t,1)}}}function a(e,t){var r=e.rows;p(r,t),f(r,t),v(r,t),g(r,t)}function o(e,t){u(e.rows,t),u(e.columns,t),u(e.values,t)}function u(e,t){e&&(f(e,t),v(e,t),g(e,t))}function s(e,t){c(e.nodes,t),l(e.values,t)}function c(e,t){e&&(f(e,t),g(e,t))}function l(e,t){e&&f(e,t)}function p(e,t,r){var i=e.bind;i&&(null!=r?t.visitRole(i.to,r):t.visitRole(i.to))}function f(e,t,r){var i=e["for"];i&&(null!=r?t.visitRole(i["in"],r):t.visitRole(i["in"]))}function v(e,t,r){var i=e.select;if(i)for(var n=0,a=i;n<a.length;n++){var o=a[n];p(o,t,r),f(o,t,r)}}function h(e,t){if(e){var r=e.group;r&&(t.visitRole(r.by),g(r,t))}}function g(e,t){if(t.visitReduction){var r=e.dataReductionAlgorithm;r&&t.visitReduction(r)}}function d(e,t){t.visitRole(e.role)}e.visitMapping=t,e.visitCategorical=r,e.visitCategoricalCategories=i,e.visitCategoricalValues=n,e.visitTable=a,e.visitMatrixItems=u,e.visitTreeNodes=c,e.visitTreeValues=l,e.visitGrouped=h}(t=e.DataViewMapping||(e.DataViewMapping={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){var r,i=e.Prototype.inheritSingle;!function(t){function r(e){var t=_.filter(e.dataRoles,function(e){return!_.isEmpty(e.requiredTypes)});n(e.dataview,e.dataViewMappings,t)}function n(e,t,r){if(!_.isEmpty(t)&&!_.isEmpty(r)){for(var i=a(e.metadata.columns,r),n=o(e.metadata.columns,r),u={},s=0,v=t;s<v.length;s++){var g=v[s];for(var d in g)null!=e[d]&&(u[d]=!0)}u.categorical&&c(e.categorical,i,n),u.table&&l(e.table,i,n),u.tree&&p(e.tree.root,i,n),u.matrix&&f(e.matrix,i,n),u.single&&h(e,t,r,n)}}function a(e,t){if(!e||!t)return function(){return!1};for(var r={},i=0,n=e;i<n.length;i++){var a=n[i],o=a.roles;if(o)for(var u=0,s=t;u<s.length;u++){var c=s[u];if(o[c.name]){r[a.index]=!0;break}}}return function(e){return isNaN(e)?!1:!!r[e]}}function o(e,t){if(!e||!t)return function(){return!0};for(var r=[],i=0,n=e;i<n.length;i++){var a=n[i],o=u(a,t);o&&(r[a.index]=o)}return function(e,t){return r[e]?r[e](t):!0}}function u(e,t){var r=s(e,t);if(!_.isEmpty(r))return function(e){return d(e,r)}}function s(t,r){var i=[],n=t&&t.roles;if(!n)return i;for(var a=0,o=r;a<o.length;a++){var u=o[a];if(n[u.name])for(var s=0,c=u.requiredTypes;s<c.length;s++){var l=c[s],p=e.ValueType.fromDescriptor(l);i.push(p)}}return i}function c(e,t,r){var i=e&&e.values;if(i){var n=i.grouped();if(n)for(var a=0,o=n;a<o.length;a++)for(var u=o[a],s=u.values,c=0,l=s;c<l.length;c++){var p=l[c],f=p.source.index;if(t(f))for(var v=0,h=p.values.length;h>v;v++)p.values=g(p.values,v,f,r)}}}function l(e,t,r){var i=e&&e.columns;if(i){for(var n=[],a=0,o=i;a<o.length;a++){var u=o[a];t(u.index)&&n.push(u.index)}for(var s=e.rows,c=0,l=s.length;l>c;c++)for(var p=0,f=n;p<f.length;p++){var v=f[p];s[c]=g(s[c],v,v,r)}}}function p(e,t,r){if(e.values)for(var i in e.values)t(i)&&("object"==typeof e.values[i]&&"value"in e.values[i]?e.values[i]=g(e.values[i],"value",i,r):e.values=g(e.values,i,i,r));else if(e.children)for(var n=0,a=e.children;n<a.length;n++){var o=a[n];p(o,t,r)}}function f(e,t,r){var i=e&&e.rows&&e.rows.root;i&&v(e,i,t,r)}function v(e,t,r,i){if(t.values)for(var n in t.values){var a=t.values[n],o=a.valueSourceIndex||0,u=e.valueSources[o].index;_.isNumber(u)&&r(u)&&(t.values[n]=g(a,"value",u,i))}else if(t.children)for(var s=0,c=t.children;s<c.length;s++){var l=c[s];v(e,l,r,i)}}function h(e,t,r,i){if(e.single){for(var n=[],a=0,o=r;a<o.length;a++){var u=o[a];u.name&&n.push(u.name)}for(var s=e.metadata.columns,c=0,l=t;c<l.length;c++){var p=l[c],f=p.single.role;if(-1!==n.indexOf(f)){var v=y(s,f);return void(v&&(e.single=g(e.single,"value",v.index,i)))}}}}function g(e,t,r,n){if(e){var a=e[t];return null===a||n(r,a)||(e=i(e),e[t]=null),e}}function d(e,t){for(var r=0,i=t;r<i.length;r++){var n=i[r];if(n.numeric||n.integer)return"number"==typeof e}return!1}function y(e,t){for(var r=0,i=e;r<i.length;r++){var n=i[r],a=n&&n.roles;if(a&&a[t])return n}}t.apply=r,t.filterVariantMeasures=n,t.generateMetadataColumnFilter=a,t.generateValueFilter=o,t.getColumnRequiredTypes=s,t.normalizeVariant=g}(r=t.DataViewNormalizeValues||(t.DataViewNormalizeValues={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){function t(e,t,i){if(!e)return i;var n=e[t.objectName],a=n;return r.getValue(a,t.propertyName,i)}function i(e,t,r){if(e&&e[t]){var i=e[t];return i}return r}function n(e,t){if(e&&e[t]){var r=e[t];return r}}function a(e,r,i){var n=t(e,r);return n&&n.solid?n.solid.color:i}function o(e){return _.isArray(e)}e.getValue=t,e.getObject=i,e.getUserDefinedObjects=n,e.getFillColor=a,e.isUserDefined=o}(t=e.DataViewObjects||(e.DataViewObjects={}));var r;!function(e){function t(e,t,r){if(!e)return r;var i=e[t];return void 0===i?r:i}function r(t,r,i){var n=e.getValue(t,r);return n&&n.solid?n.solid.color:i}e.getValue=t,e.getFillColorByPropertyName=r}(r=e.DataViewObject||(e.DataViewObject={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){var t,r=jsCommon.JsonComparer;!function(t){function n(t,r,i){var n=t[r];n||(t[r]=n=[]);for(var a=0,o=n.length;o>a;a++){var u=n[a];if(e.Selector.equals(u.selector,i))return u}var s={selector:i,properties:{}};return n.push(s),s}function a(e,t,r,n){var a=c(e,t,r);a&&i.deleteSingleProperty(a,n)}function o(e,t,r,i){n(e,t.objectName,r).properties[t.propertyName]=i}function u(e,t,r){var i=s(e,t,r);if(i)return i[t.propertyName]}function s(e,t,r){var i=c(e,t.objectName,r);if(i)return i.properties}function c(t,r,i){if(t){var n=t[r];if(n)for(var a=0,o=n.length;o>a;a++){var u=n[a];if(e.Selector.equals(u.selector,i))return u;
3}}}function l(t,i){return t instanceof e.SemanticFilter&&i instanceof e.SemanticFilter?e.SemanticFilter.isSameFilter(t,i):r.equals(t,i)}function p(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var r in e)if(!l(e[r],t[r]))return!1;return!0}function f(t,r){if(r.bool)return"boolean"!=typeof t&&(t=!1),e.SQExprBuilder["boolean"](t);if(r.text||r.scripting&&r.scripting.source)return e.SQExprBuilder.text(t);if(r.numeric){if($.isNumeric(t))return e.SQExprBuilder["double"](+t)}else if(r.fill){if(t)return{solid:{color:e.SQExprBuilder.text(t)}}}else{if(r.formatting)return r.formatting.labelDisplayUnits?e.SQExprBuilder["double"](+t):e.SQExprBuilder.text(t);if(r.enumeration)return $.isNumeric(t)?e.SQExprBuilder["double"](+t):e.SQExprBuilder.text(t);if(r.misc)t=t?e.SQExprBuilder.text(t):null;else if(r.image&&t){var i=t,n={name:e.SQExprBuilder.text(i.name),url:e.SQExprBuilder.text(i.url)};return i.scaling&&(n.scaling=e.SQExprBuilder.text(i.scaling)),n}}return t}function v(e){var t={};for(var r in e){var i=e[r];if(!_.isEmpty(i)){for(var n=[],a=0,o=i;a<o.length;a++){var u=o[a];n.push({properties:h(u.properties),selector:u.selector})}t[r]=n}}return t}function h(e){return _.clone(e)}t.ensure=n,t.deleteProperty=a,t.setValue=o,t.getValue=u,t.getPropertyContainer=s,t.getObjectDefinition=c,t.propertiesAreEqual=l,t.allPropertiesAreEqual=p,t.encodePropertyValue=f,t.clone=v}(t=e.DataViewObjectDefinitions||(e.DataViewObjectDefinitions={}));var i;!function(e){function t(e,t){delete e.properties[t]}e.deleteSingleProperty=t}(i=e.DataViewObjectDefinition||(e.DataViewObjectDefinition={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){var r;!function(t){function r(t){return a(t,function(t){var r=e.ValueType.fromDescriptor(t.type).formatting;return r&&r.formatString})}function i(e){return a(e,function(e){var t=e.type;return t&&!!t.filter})}function n(e){return a(e,function(e){var t=e.type;return t&&!!t.expression&&t.expression.defaultValue})}function a(e,t){if(e)for(var r in e){var i=e[r].properties;for(var n in i)if(t(i[n]))return{objectName:r,propertyName:n}}}t.findFormatString=r,t.findFilterOutput=i,t.findDefaultValue=n}(r=t.DataViewObjectDescriptors||(t.DataViewObjectDescriptors={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){var t;!function(t){function r(t,r,i){for(var n,a=0,o=i.length;o>a;a++){var u=i[a],s=u.name,c=e.DataViewObjectEvaluator.run(t,r[s],u.properties);c&&(n||(n={}),n[s]=c)}return n}function i(e){var t={data:[]};if(e)for(var r in e)for(var i=e[r],a=0,o=i.length;o>a;a++){var u=i[a];n(t,u.selector).objects.push({name:r,properties:u.properties})}return t}function n(t,r){if(!r)return t.metadataOnce||(t.metadataOnce={objects:[]}),t.metadataOnce;var i;r.data?i=t.data:r.metadata?(t.metadata||(t.metadata=[]),i=t.metadata):r.id&&(t.userDefined||(t.userDefined=[]),i=t.userDefined);for(var n=0,a=i;n<a.length;n++){var o=a[n];if(e.Selector.equals(r,o.selector))return o}var u={selector:r,objects:[]};return i.push(u),u}function a(e,t,r,i){i&&(o(e,t,r,i),u(e,t,r,i))}function o(t,r,i,n){var a=e.DataViewObjectDescriptors.findFormatString(r);if(a)for(var o=0,u=n.length;u>o;o++){var l=n[o];l&&c(t,a,l.queryName,l.format||s(i,o))}}function u(t,r,i,n){var a=e.DataViewObjectDescriptors.findDefaultValue(r);if(a)for(var o=0,u=n;o<u.length;o++){var s=u[o];s&&l(t,a,s.queryName,s.defaultValue)}}function s(e,t){for(var r=0,i=e.length;i>r;r++){var n=e[r];if(n&&n.index===t)return n.format}}function c(t,r,i,n){n&&p(t,r,{metadata:i},e.SQExprBuilder.text(n))}function l(e,t,r,i){i&&p(e,t,{metadata:r},i)}function p(e,t,r,i){var n;if(r){var a=e.metadata;a||(a=e.metadata=[]),n=a}else{var o=e.metadataOnce;o||(o=e.metadataOnce={selector:r,objects:[]}),n=[o]}var u,s=f(n,r);if(s){var c=s.objects;if(u=v(c,t.objectName)){if(u.properties[t.propertyName])return}else u={name:t.objectName,properties:{}},c.push(u)}else u={name:t.objectName,properties:{}},n.push({selector:r,objects:[u]});u.properties[t.propertyName]=i}function f(t,r){for(var i=0,n=t.length;n>i;i++){var a=t[i];if(e.Selector.equals(a.selector,r))return a}}function v(e,t){for(var r=0,i=e.length;i>r;r++){var n=e[r];if(n.name===t)return n}}t.evaluateDataViewObjects=r,t.groupObjectsBySelector=i,t.addImplicitObjects=a}(t=e.DataViewObjectEvaluationUtils||(e.DataViewObjectEvaluationUtils={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){var r;!function(r){function i(e,t,r){if(t){var i,a=t.properties;for(var o in r){var u=r[o],s=a[o];if(s){var c=n(e,s,u);void 0!==c&&(i||(i={}),i[o]=c)}}return i}}function n(r,i,n){var u=i.type;if(u&&u.expression)return n;var l=v(r,n,e.ValueType.fromDescriptor(i.type));return void 0!==l||n instanceof t.RuleEvaluation?l:a(r,n,u)||o(r,n,u)||s(r,n,u)||c(r,n,u)||n}function a(t,r,i){var n=i.fill;if(n)return n&&n.solid&&n.solid.color&&r.solid?{solid:{color:v(t,r.solid.color,e.ValueType.fromExtendedType(e.ExtendedType.Color))}}:void 0}function o(e,t,r){if(r.fillRule){if(t.linearGradient2){var i=t.linearGradient2;return{linearGradient2:{min:u(e,i.min),max:u(e,i.max)}}}if(t.linearGradient3){var n=t.linearGradient3;return{linearGradient3:{min:u(e,n.min),mid:u(e,n.mid),max:u(e,n.max)}}}}}function u(e,t){var r={color:v(e,t.color,h)},i=v(e,t.value,g);return null!=i&&(r.value=i),r}function s(t,r,i){if(i.image&&r){var n={name:v(t,r.name,d),url:v(t,r.url,e.ValueType.fromDescriptor(e.ImageDefinition.urlType))};return r.scaling&&(n.scaling=v(t,r.scaling,d)),n}}function c(e,t,r){return r.paragraphs&&t?f(e,t,l):void 0}function l(e,t){var r,i=t.textRuns,n=f(e,i,p);return i!==n&&(r=_.clone(t),r.textRuns=n),r||t}function p(e,t){var r,i=t.value,n=v(e,i,d);return void 0!==n&&(r=_.clone(t),r.value=n),r||t}function f(e,t,r){for(var i,n=0,a=t.length;a>n;n++){var o=t[n],u=r(e,o);i||o===u||(i=_.take(t,n)),i&&i.push(u)}return i||t}function v(e,r,i){return r instanceof t.SQExpr?y.evaluate(r,e):r instanceof t.RuleEvaluation?r.evaluate(e):void 0}var h=e.ValueType.fromDescriptor({formatting:{color:!0}}),g=e.ValueType.fromDescriptor({numeric:!0}),d=e.ValueType.fromDescriptor({text:!0});r.run=i,r.evaluateProperty=n;var y=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.evaluate=function(e,r){return null!=e?e.accept(t.instance,r):void 0},t.prototype.visitColumnRef=function(e,t){return t.getExprValue(e)},t.prototype.visitConstant=function(e,t){return e.value},t.prototype.visitMeasureRef=function(e,t){return t.getExprValue(e)},t.prototype.visitAggr=function(e,t){return t.getExprValue(e)},t.prototype.visitFillRule=function(e,t){var r=e.input.accept(this,t);if(void 0!==r){var i=t.getColorAllocator(e);if(i)return i.color(r)}},t.prototype.visitSelectRef=function(e,t){return t.getExprValue(e)},t.instance=new t,t}(t.DefaultSQExprVisitorWithArg)}(r=t.DataViewObjectEvaluator||(t.DataViewObjectEvaluator={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){var r,i=e.Prototype.inherit;!function(e){function r(e){var r=e.categorical;if(!r)return null;var n=r.categories;if(!n||1!==n.length)return null;var a=r.values;if(_.isEmpty(a)||a.source)return null;for(var o=n[0],u=o.identity,s=o.values,c=[],l=[],p=0,f=s.length;f>p;p++)for(var v=s[p],h=u[p],g=0,d=a.length;d>g;g++){var y=a[g],m=i(y.source);if(y.identity)return null;m.groupName=v;var x={source:m,values:[y.values[p]],identity:h,min:y.min,max:y.max,subtotal:y.subtotal},S=y.highlights;S&&(x.highlights=[S[p]]),c.push(m),l.push(x)}var E=i(e.metadata);return E.columns=c,a=t.DataViewTransform.createValueColumns(l,o.identityFields,o.source),{metadata:E,categorical:{values:a},matrix:e.matrix}}e.apply=r}(r=t.DataViewPivotCategorical||(t.DataViewPivotCategorical={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){var r;!function(t){function r(t,r){r.columnHierarchyRewritten||(t.columns=e.Prototype.inherit(t.columns));var o=t.columns;r.rowHierarchyRewritten||(t.rows=e.Prototype.inherit(t.rows));var u=t.rows;if(!(o.levels.length>1)){var s={level:0},c=o.root.children,l=c.length,p=u.levels.length;if(l>0){var f=0,v=function(e){if(e.values){s.values||(s.values={});for(var t=0;l>t;t++)s.values[f++]=e.values[t];delete e.values}if(l>1){e.children||(e.children=[]);for(var r=0;l>r;r++){var i={level:p},n=c[r];i.levelSourceIndex=n.levelSourceIndex,e.isSubtotal&&(i.isSubtotal=!0),e.children.push(i)}}};r.hierarchyTreesRewritten?i(u.root,v):t.columns.root=a(u.root,v)}else r.hierarchyTreesRewritten||(t.columns.root=n(u.root));if(l>1){var h={sources:o.levels[0].sources};u.levels.push(h),o.levels.length=0}if(r.hierarchyTreesRewritten)t.columns.root=u.root,t.rows.root={children:[s]};else{var g=e.Prototype.inherit(t.rows.root);g.children=[s],t.rows.root=g}t.columns.levels=u.levels,t.rows.levels=[]}}function i(e,t){var r=e.children;if(r&&r.length>0)for(var n=0,a=r.length;a>n;n++)i(r[n],t);else t(e)}function n(e){return a(e)}function a(t,r){var i=e.Prototype.inherit(t),n=t.children;if(n&&n.length>0){for(var o=[],u=0,s=n.length;s>u;u++){var c=a(n[u],r);o.push(c)}i.children=o}else r&&r(i);return i}t.apply=r,t.cloneTree=n,t.cloneTreeExecuteOnLeaf=a}(r=t.DataViewPivotMatrix||(t.DataViewPivotMatrix={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){function r(e){for(var t=new Array(e),r=0;e>r;r++)t[r]=null;return t}function i(t,r,i){var n=e.Prototype.inherit(t);return n[i]=r[i],n}var n;!function(n){function a(e){if(e.categorical){var t=e.categorical;if(t.categories&&1===t.categories.length&&(!t.values||!t.values.source))return o(e.metadata,t)}}function o(r,i){var n=i.categories[0],a=n.values,o=a.length;if(0!==o){var s=i.values?i.values.grouped()[0].values:[],c=t.createCategoricalDataViewBuilder().withCategories(i.categories).withGroupedValues(u(n,a,o,s)).build();return r=e.Prototype.inherit(r),r.columns=c.metadata.columns,{metadata:r,categorical:c.categorical}}}function u(e,t,n,a){for(var o=r(n),u=a.length,s=[],c=0;n>c;c++){for(var l=[],p=0;u>p;p++){var f=a[p],v=f.highlights,h={values:i(o,f.values,c)};v&&(h.highlights=i(o,v,c)),l.push(h)}s.push(l)}return{groupColumn:{source:e.source,identityFrom:{fields:e.identityFields,identities:e.identity},values:e.values},valueColumns:_.map(a,function(e){return{source:e.source}}),data:s}}n.apply=a}(n=t.DataViewSelfCrossJoin||(t.DataViewSelfCrossJoin={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){var r,i=jsCommon.ArrayExtensions,n=e.data.DataShapeBindingDataReduction,a=e.Prototype.inheritSingle;!function(r){function o(e,t,r,i){t&&1===t.length&&r.categorical&&r.categorical.dataReductionAlgorithm&&e&&s(e,r)&&(e.Primary.Groupings=[e.Secondary.Groupings[0],e.Primary.Groupings[0]],e.Secondary=void 0,e.DataReduction={Primary:n.createFrom(r.categorical.dataReductionAlgorithm),DataVolume:r.categorical.dataVolume||i})}function u(e){return e&&e.Groupings&&1===e.Groupings.length&&!_.isEmpty(e.Groupings[0].Projections)&&!e.Groupings[0].Subtotal&&_.isEmpty(e.Groupings[0].SuppressedProjections)}function s(e,t){return u(e.Primary)&&u(e.Secondary)&&1===e.Secondary.Groupings[0].Projections.length?!e.DataReduction||!e.DataReduction.Primary&&!e.DataReduction.Secondary:!1}function c(e,r,n,a){if(!l(r,n,e,a))return e;var o={metadata:{columns:i.copy(e.metadata.columns)}};if(e.single&&(o.single=e.single),e.table&&(o.table=e.table),e.matrix){var u=p(e.matrix);if(!_.isEmpty(u.valueSources)){var s=t.utils.DataViewMatrixUtils.containsCompositeGroup(u.columns);s||(o.categorical=f(u,o.metadata.columns))}}return o}function l(r,i,n,a){if(_.isEmpty(r)||_.isEmpty(i)||!n)return!1;var o=t.DataViewSelectTransform.createRoleKindFromMetadata(r,n.metadata),u=t.DataViewSelectTransform.projectionsFromSelects(r,a),s=e.DataViewAnalysis.chooseDataViewMappings(u,i,o).supportedMappings;if(!s||1!==s.length)return!1;var c=s[0].categorical;if(!c)return!1;var l=n.matrix;if(!l)return!1;if(!l.rows||!l.rows.levels||2!==l.rows.levels.length)return!1;var p=[],f=[],v=function(t,r){var i=u[t];if(i)for(var n=0,a=i.all();n<a.length;n++){var s=a[n];o[s.queryRef]===e.VisualDataRoleKind.Grouping&&r.push(s.queryRef)}};if(e.DataViewMapping.visitCategoricalCategories(c.categories,{visitRole:function(e){v(e,p)}}),e.DataViewMapping.visitCategoricalValues(c.values,{visitRole:function(e){v(e,f)}}),_.isEmpty(p)||_.isEmpty(f))return!1;for(var h=0,g=l.columns.levels;h<g.length;h++)for(var d=g[h],y=0,m=d.sources;y<m.length;y++){var x=m[y];if(!x.isMeasure)return!1}return!0}function p(e){var t=e.rows,r=t.root,i=r.children,n=[],o=t.levels[0],u=r.childIdentityFields,s={},c=[],l=t.levels[1],p=_.isEmpty(i)?void 0:i[0].childIdentityFields,f=e.valueSources.length,v=function(e){var t=s[e.key];return t};if(i)for(var h=function(e){var t=e.identity.key,r=s[t];void 0===r&&(r=c.length,s[t]=r,c.push(e))},g=0,d=i;g<d.length;g++){var y=d[g];n.push(y);for(var m=0,x=y.children;m<x.length;m++){var S=x[m];h(S)}}for(var E=new Array(c.length),w=0;w<n.length;++w)for(var y=i[w],b=0,D=y.children;b<D.length;b++){var S=D[b],C=v(S.identity);E[C]||(E[C]=new Array(n.length)),E[C][w]=S.values}var T={root:{children:_.map(n,function(e){var t=a(e);return t.level=0,t.children=void 0,t.childIdentityFields=void 0,t}),childIdentityFields:u},levels:[o]};if(f>0){for(var V=_.map(e.columns.root.children,function(e){var t={level:1};return e.levelSourceIndex&&(t.levelSourceIndex=e.levelSourceIndex),t}),C=0;C<T.root.children.length;++C)T.root.children[C].children=V;T.levels.push(e.columns.levels[0])}var F={root:{children:_.map(c,function(e){var t=a(e);return t.level=0,t.children=void 0,t.childIdentityFields=void 0,t}),childIdentityFields:p},levels:[l]};if(f>0)for(var C=0;C<c.length;++C){for(var P=F.root.children[C],M={},w=0;w<n.length;++w)for(var R=E[C]&&E[C][w],A=0;f>A;++A){var N=w*f+A;M[N]=R?R[A]:0===A?{value:null}:{value:null,valueSourceIndex:A}}P.values=M}var I={rows:F,columns:T,valueSources:e.valueSources};return I}function f(e,t){for(var r=e.columns.root.children.length,i=e.valueSources,n=i.length,a=v(e),o=[],u=0;r>u;++u){var s=e.columns.root.children[u],c={values:[],identity:s.identity,name:s.value||null};o.push(c);for(var l=0;n>l;++l){var p=i[l],f={};for(var h in p)f[h]=p[h];f.groupName=c.name,t.push(f);var g={source:f,values:[],identity:c.identity};c.values.push(g);for(var d=l+u*n,y=0,m=e.rows.root.children;y<m.length;y++){var x=m[y],S=x.values[d].value;g.values.push(S)}}}for(var E=[],w=0,b=o;w<b.length;w++)for(var c=b[w],l=0;n>l;++l)E.push(c.values[l]);E.grouped=function(){return o},E.identityFields=e.columns.root.childIdentityFields,E.source=e.columns.levels[0].sources[0];var D={categories:a,values:E};return D}function v(e){for(var t=_.map(e.rows.root.children,function(e){return e.identity}),r=e.rows.root.childIdentityFields,i=e.rows.levels[0].sources,n=[],a=0,o=i.length;o>a;a++){var u=_.map(e.rows.root.children,function(e){var t=e.levelValues;return void 0!==t?t[a].value:void 0});n.push({source:i[a],values:u,identity:t,identityFields:r})}return n}r.pivotBinding=o,r.unpivotResult=c}(r=t.DataViewPivotCategoricalToPrimaryGroups||(t.DataViewPivotCategoricalToPrimaryGroups={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){var r,i=e.Prototype.inherit,n=e.Prototype.inheritSingle,a=jsCommon.ArrayExtensions,o=jsCommon.EnumExtensions;!function(r){function u(e){var r=e.prototype,i=e.objectDescriptors,n=e.dataViewMappings,a=e.transforms,o=a&&a.roles&&a.roles.activeItems,u=e.colorAllocatorFactory,l=e.dataRoles;if(!r)return c(i,a,u);if(!a)return[r];r=t.DataViewPivotCategoricalToPrimaryGroups.unpivotResult(r,a.selects,n,o);var p=s(r,a,i,n,u,l);return p=t.DataViewRegression.run({dataViewMappings:n,visualDataViews:p,dataRoles:l,objectDescriptors:i,objectDefinitions:a.objects,colorAllocatorFactory:u,transformSelects:a.selects,metadata:r.metadata,projectionActiveItems:o})}function s(e,t,r,i,n,a){var o=[],u=t.splits;if(_.isEmpty(u))o.push(l(e,r,i,t,n,a));else for(var s=0,c=u;s<c.length;s++){var p=c[s],f=l(e,r,i,t,n,a,p.selects);o.push(f)}return o}function c(e,t,r){if(t&&t.objects){var i={metadata:{columns:[]}};return R(i,0,e,t.objects,t.selects,r),[i]}return[]}function l(e,r,n,a,o,u,s){var c=p(n),l=i(e);l.metadata=i(e.metadata);var v=a.roles&&a.roles.ordering,h=a.roles&&a.roles.activeItems;return l=f(l,c,n,a.selects,v,s),R(l,c,r,a.objects,a.selects,o),l=t.DataViewConcatenateCategoricalColumns.detectAndApply(l,r,n,v,a.selects,h),t.DataViewNormalizeValues.apply({dataview:l,dataViewMappings:n,dataRoles:u}),l}function p(e){if(!e)return 0;for(var t=0,r=0,i=e;r<i.length;r++){var n=i[r];n.categorical&&(t|=1),n.matrix&&(t|=2),n.single&&(t|=4),n.table&&(t|=8),n.tree&&(t|=16)}return t}function f(e,r,i,n,a,u){var s=[];if(n&&(e.metadata.columns=v(e.metadata.columns,n,s)),e.categorical&&o.hasFlag(r,1)&&(e.categorical=g(e.categorical,s,u),e=se(e,i)),e.matrix&&o.hasFlag(r,2)){var c={rowHierarchyRewritten:!1,columnHierarchyRewritten:!1,hierarchyTreesRewritten:!1};e.matrix=m(e.matrix,s,i,a,c),le(e.matrix,i)&&t.DataViewPivotMatrix.apply(e.matrix,c)}return e.table&&o.hasFlag(r,8)&&(e.table=d(e.table,s,a)),e}function v(e,t,r){if(!t)return e;for(var n=i(e),a=0,o=e.length;o>a;a++){var u=e[a],s=t[u.index];if(s){var c=n[a]=i(u);s.roles&&(c.roles=s.roles),s.type&&(c.type=s.type),c.format=h(s,c),s.displayName&&(c.displayName=s.displayName),s.queryName&&(c.queryName=s.queryName),s.kpi&&(c.kpi=s.kpi),s.sort&&(c.sort=s.sort),s.discourageAggregationAcrossGroups&&(c.discourageAggregationAcrossGroups=s.discourageAggregationAcrossGroups),r.push({from:u,to:c})}}return n}function h(e,t){return e.format||t.format}function g(t,r,n){function a(e){var t=P(e.source,r);if(t){var n=i(e);return n.source=t,n}}var o=i(t),u=e.Prototype.overrideArray(t.categories,a);u&&(o.categories=u);var s=e.Prototype.overrideArray(t.values,a),c=s||t.values;if(c){if(c.source)if(n&&!n[c.source.index])c.source=void 0;else{var l=P(c.source,r);l&&(c.source=l)}if(n)for(var p=c.length-1;p>=0;p--)n[c[p].source.index]||c.splice(p,1);var f,v=!!c.source;if(v){f=i(c.grouped());for(var h=0,g=void 0,p=0,d=c.length;d>p;p++){var y=c[p];g&&y.identity===g.identity||(g=i(f[h]),f[h]=g,g.values=[],h++),g.values.push(y)}}else f=[{values:c}];c.grouped=function(){return f},o.values=c}return o}function d(t,r,n){var a=i(t),o=function(e){return P(e,r)},u=e.Prototype.overrideArray(t.columns,o);if(u&&(a.columns=u),!n)return a;var s=y(n,r);if(!s)return a;for(var c=u.slice(0),l=Object.keys(s),p=0,f=l.length;f>p;p++){var v=c[s[l[p]]];p===u.length?u.push(v):u[p]=v}var h=e.Prototype.overrideArray(a.rows,function(e){for(var t=[],r=0,i=l.length;i>r;++r)t[r]=e[s[l[r]]];return t});return h&&(a.rows=h),a}function y(e,t){var r=Object.keys(e);if(1===r.length){var i=r[0],n=_.map(t,function(e){return e.from.index}),a=e[i];return T(n,a)}}function m(r,n,a,o,u){function s(e){return P(e,n)}function c(t){var r=null,i=e.Prototype.overrideArray(t.levels,function(t){var r=null,i=e.Prototype.overrideArray(t.sources,s);return i&&(r=M(r,t,function(e){return e.sources=i})),r});return i&&(r=M(r,t,function(e){return e.levels=i})),r}var l=_.find(a,function(e){return!!e.matrix}),p=l.matrix,f=i(r),v=c(f.rows);v&&(f.rows=v,u.rowHierarchyRewritten=!0);var h=c(f.columns);h&&(f.columns=h,u.columnHierarchyRewritten=!0);var g=e.Prototype.overrideArray(f.valueSources,s);if(g){f.valueSources=g;var d=p.values;if(o&&g.length>1&&d&&d["for"]){var y=h.levels.length;if(y>0){var m=C(d,o,g,n);if(m){var E=Object.keys(m),w=E.length;h.root=t.DataViewPivotMatrix.cloneTree(h.root),1===y?x(h.root,m):F(h.root,y-2,function(e){return x(e,m)}),f.rows.root=t.DataViewPivotMatrix.cloneTreeExecuteOnLeaf(f.rows.root,function(e){if(e.values){for(var t={},r=Object.keys(e.values).length/w,i=0,n=r;n>i;i++)for(var a=i*w,o=0;w>o;o++)t[a+o]=e.values[a+m[E[o]]];e.values=t}}),u.hierarchyTreesRewritten=!0}}}}return S(f,p,o),f}function x(e,t){for(var r=Object.keys(t),i=r.length,n=e.children,a=n.slice(0),o=0,u=i;u>o;o++){var s=a[t[r[o]]];o===n.length?n.push(s):n[o]=s}}function S(t,r,i){var a;if(t&&r&&i){var o;e.DataViewMapping.visitMatrixItems(r.rows,{visitRole:function(e,r){o=E(o||t.rows,e,i)}});var u;e.DataViewMapping.visitMatrixItems(r.columns,{visitRole:function(e,r){u=E(u||t.columns,e,i)}}),(o||u)&&(a=n(t),a.rows=o||a.rows,a.columns=u||a.columns)}return a}function E(e,r,i){var a,o=i[r],u=o&&o.length>=2;if(u&&!_.isEmpty(e.levels))for(var s=e.levels.length-1;s>=0;s--){var c=e.levels[s],l=w(c,r,i);if(l){_.isUndefined(a)&&(a=n(e),a.levels=n(e.levels),a.root=t.utils.DataViewMatrixUtils.inheritMatrixNodeHierarchy(e.root,s,!0));var p=n(e.levels[s]);a.levels[s]=b(p,l),D(a.root,s,l)}}return a}function w(e,r,i){var n,a=e.sources;if(a&&a.length>=2){var o=t.utils.DataViewMetadataColumnUtils.joinMetadataColumnsAndProjectionOrder(a,i,r);if(o&&o.length>=2){var u=_.sortBy(o,function(e){return e.projectionOrderIndex});n=T(_.map(o,function(e){return e.sourceIndex}),_.map(u,function(e){return e.sourceIndex}))}}return n}function b(e,t){var r=e.sources;e.sources=r.slice(0);for(var i=Object.keys(t),n=0,a=i.length;a>n;n++){var o=i[n],u=t[o];e.sources[o]=r[u]}return e}function D(e,t,r){var i=V(r);return F(e,t,function(e){var t=e.levelValues;if(!_.isEmpty(t)){for(var r=_.sortBy(t,function(e){return i[e.levelSourceIndex]}),a=0,o=r.length;o>a;a++){var u=n(r[a]);u.levelSourceIndex=i[u.levelSourceIndex],r[a]=u}e.levelValues=r;var s=_.last(r);e.value!==s.value&&(e.value=s.value),(e.levelSourceIndex||0)!==s.levelSourceIndex&&(e.levelSourceIndex=s.levelSourceIndex)}}),e}function C(e,t,r,i){var n=e["for"]["in"],a=t[n],o=_.chain(i).filter(function(e){return _.contains(r,e.to)}).map(function(e){return e.from.index}).value();return T(o,a)}function T(e,t){if(!a.sequenceEqual(e,t,function(e,t){return e===t})){for(var r={},i=0,n=t.length;n>i;++i){var o=t[i];r[i]=e.indexOf(o)}return r}}function V(e){var t={};for(var r in e){var i=e[r],n=parseInt(r,10);t[i]=n}return t}function F(e,t,r){if(e.level===t)return void r(e);var i=e.children;if(i&&i.length>0)for(var n=0,a=i.length;a>n;n++)F(i[n],t,r)}function P(e,t){for(var r=0,i=t.length;i>r;r++){var n=t[r];if(n.from===e)return n.to}}function M(e,t,r){return e||(e=i(t)),r&&r(e),e}function R(e,r,i,n,a,o){if(i){var u=t.DataViewObjectEvaluationUtils.groupObjectsBySelector(n);t.DataViewObjectEvaluationUtils.addImplicitObjects(u,i,e.metadata.columns,a);var s=u.metadataOnce,c=u.data;s&&N(e,a,i,s.objects,c,o);var l=u.metadata;if(l)for(var p=0,f=l.length;f>p;p++){var v=l[p],h=v.objects,g=L(e,a,h,o);ee(e,a,i,v.selector,h,g)}for(var p=0,f=c.length;f>p;p++){var d=c[p],h=d.objects,g=L(e,a,h,o);q(e,r,a,i,d.selector,d.rules,h,g)}var y=u.userDefined;y&&A(e,a,i,y,o)}}function A(e,r,i,n,a){var o=e.metadata.objects;o||(o=e.metadata.objects={});for(var u=0,s=n;u<s.length;u++){var c=s[u],l=c.selector.id,p=L(e,r,c.objects,a),f=t.createStaticEvalContext(p,e,r),v=t.DataViewObjectEvaluationUtils.evaluateDataViewObjects(f,i,c.objects);for(var h in v){var g=v[h],d=o[h];d||(d=o[h]=[]),d.push({id:l,object:g})}}}function N(e,r,i,n,a,o){var u=L(e,r,n,o),s=t.createStaticEvalContext(u,e,r),c=t.DataViewObjectEvaluationUtils.evaluateDataViewObjects(s,i,n);if(c){e.metadata.objects=c;for(var l in c){var p=c[l],f=i[l];for(var v in p){var h=f.properties[v],g=h.rule;if(g){var d=I(e,o,g,l,p[v],h.type);d&&a.push(d)}}}}}function I(e,t,r,i,n,a){var o=r.output;if(o){var u=re(e,o.selector);if(u)return a.fillRule?O(e,t,r,u,i,n):void 0}}function O(e,r,i,n,a,o){var u=Q(e,r,i.inputRole,1,o);if(u){var s=new t.ColorRuleEvaluation(i.inputRole,u),c={};return c[i.output.property]={solid:{color:s}},{selector:n,rules:[s],objects:[{name:a,properties:c}]}}}function Q(e,t,r,i,n){return n.linearGradient2?U(e,t,r,i,n,n.linearGradient2):n.linearGradient3?j(e,t,r,i,n,n.linearGradient3):void 0}function U(e,t,r,i,n,a){if(a=n.linearGradient2,void 0===a.min.value||void 0===a.max.value){var o=ne(e,r,i);if(!o)return;void 0===a.min.value&&(a.min.value=o.min),void 0===a.max.value&&(a.max.value=o.max)}return t.linearGradient2(n.linearGradient2)}function j(e,t,r,i,n,a){var o;if(a=n.linearGradient3,void 0===a.min.value||void 0===a.mid.value||void 0===a.max.value){var u=ne(e,r,i);if(!u)return;if(o=void 0===a.min.value&&void 0===a.max.value&&void 0!==a.mid.value,void 0===a.min.value&&(a.min.value=u.min),void 0===a.max.value&&(a.max.value=u.max),void 0===a.mid.value){var s=(a.max.value+a.min.value)/2;a.mid.value=s}}return t.linearGradient3(n.linearGradient3,o)}function L(e,r,i,n){for(var a=t.createColorAllocatorCache(),o=t.createStaticEvalContext(),u=0,s=i.length;s>u;u++){var c=i[u].properties;for(var l in c){var p=c[l];if(p&&p.solid&&p.solid.color&&23===p.solid.color.kind){var f=p.solid.color,v=ie(r,f.input);if(!v)continue;var h=t.DataViewObjectEvaluator.evaluateProperty(o,he,f.rule),g=Q(e,n,v,0,h);g&&a.register(f,g)}}}return a}function q(e,r,i,n,a,u,s,c){var l=t.Selector.containsWildcard(a),p=e.categorical;p&&o.hasFlag(r,1)&&(W(p,n,a,u,l,s,c),Y(p,n,a,u,l,s,c));var f=e.matrix;if(f&&o.hasFlag(r,2)){var v=K(f,n,a,u,l,s,c);v&&(e.matrix=v)}var h=e.table;if(h&&o.hasFlag(r,8)){var g=H(h,a),d=J(h,i,n,g,u,l,s,c);d&&(e.table=d)}}function H(e,r){return t.Selector.hasRoleWildcard(r)&&(r=k(e,r)),r}function k(e,r){for(var i={data:[],id:r.id,metadata:r.metadata},n=0,a=r.data;n<a.length;n++){var o=a[n];if(t.Selector.isRoleWildcard(o)){var u=o.roles,s=G(e.columns,u),c=e.identityFields;if(s&&c){i.data.push(t.DataViewScopeWildcard.fromExprs(c));continue}}B(i.data,o)&&i.data.push(o)}return i}function B(e,t){return _.isEmpty(e)?!0:!_.any(e,function(e){return e.key===t.key})}function G(e,t){for(var r=0,i=e;r<i.length;r++){var n=i[r],a=n.roles;if(!a||!_.any(t,function(e){return a[e]}))return!1}return!0}function W(e,r,i,n,a,o,u){if(e.categories&&0!==e.categories.length){var s=te(e,i);if(s){var c,l=s.identities,p=t.createCategoricalEvalContext(u,e);if(l){for(var f=0,v=l.length;v>f;f++){var h=l[f];if(a||t.Selector.matchesData(i,[h])){p.setCurrentRowIndex(f);var g=t.DataViewObjectEvaluationUtils.evaluateDataViewObjects(p,r,o);if(g&&(s.column.objects||(s.column.objects=[],s.column.objects.length=v),s.column.objects[f]=g),!a)return!0;c=!0}}return c}}}}function Y(r,i,n,a,o,u,s){var c=r.values;if(c&&c.identityFields&&t.Selector.matchesKeys(n,[c.identityFields])){var l=c.grouped();if(l){for(var p,f=t.createCategoricalEvalContext(s,r),v=0,h=l.length;h>v;v++){var g=l[v],d=n.metadata,y=g.values;if(o||t.Selector.matchesData(n,[g.identity])){var m=t.DataViewObjectEvaluationUtils.evaluateDataViewObjects(f,i,u);if(m)if(d)for(var x=0,S=y.length;S>x;x++){var E=y[x],w=E.source;if(w.queryName===d){var b=e.Prototype.inherit(w);b.objects=m,E.source=b,p=!0;break}}else g.objects=m,oe(c,l),p=!0;if(!o)return!0}}return p}}}function K(e,r,i,a,o,u,s){var c=t.createMatrixEvalContext(s,e),l=z(c,e.rows,r,i,a,o,u),p=z(c,e.columns,r,i,a,o,u);if(l||p){var f=n(e);return l&&(f.rows=l),p&&(f.columns=p),f}}function z(e,t,r,i,a,o,u){if(t){var s=t.root;if(s){var c=X(e,s,r,i,a,o,u);if(c){var l=n(t);return l.root=c,l}}}}function X(e,r,i,a,o,u,s){var c=r.children;if(c){var l,p,f=r.childIdentityFields;f&&(p=t.Selector.matchesKeys(a,[f]));for(var v=0,h=c.length;h>v;v++){var g=c[v],d=g.identity,y=null;if(p){if(u||t.Selector.matchesData(a,[d])){var m=t.DataViewObjectEvaluationUtils.evaluateDataViewObjects(e,i,s);m&&(y=n(g),y.objects=m)}}else y=X(e,g,i,a,o,u,s);if(y&&(l||(l=Z(r)),l.children[v]=y,!u))break}return l}}function Z(e){if(Object.getPrototypeOf(e)!==Object.prototype)return e;var t=n(e);return t.children=i(e.children),t}function J(e,r,i,a,o,u,s,c){var l=t.createTableEvalContext(c,e,r),p=$(l,e.columns,e.rows,e.identity,e.identityFields,i,a,o,u,s);if(p){var f=n(e);return f.rows=p,f}}function $(e,r,i,a,o,u,s,c,l,p){if(!_.isEmpty(a)&&!_.isEmpty(o)&&s.metadata&&t.Selector.matchesKeys(s,[o])){var f=_.findIndex(r,function(e){return e.queryName===s.metadata});if(!(0>f)){for(var v,h=r.length,g=0,d=a.length;d>g;g++){var y=a[g];if(l||t.Selector.matchesData(s,[y])){e.setCurrentRowIndex(g);var m=t.DataViewObjectEvaluationUtils.evaluateDataViewObjects(e,u,p);if(m){v||(v=n(i));var x=v[g]=n(v[g]),S=x.objects;S||(x.objects=S=new Array(h)),S[f]=m}if(!l)break}}return v}}}function ee(e,r,i,n,a,o){for(var u=e.metadata.columns,s=n.metadata,c=t.createStaticEvalContext(o,e,r),l=0,p=u.length;p>l;l++){var f=u[l];if(f.queryName===s){var v=t.DataViewObjectEvaluationUtils.evaluateDataViewObjects(c,i,a);v&&(f.objects=v)}}}function te(e,r){var i=e.categories[0];if(i.identityFields&&t.Selector.matchesKeys(r,[i.identityFields])){var n=i.identity,a=i,o=r.metadata;if(o){var u=e.values;if(u)for(var s=0,c=u.length;c>s;s++){var l=u[s];if(l.source.queryName===o){a=l;break}}}return{column:a,identities:n}}}function re(e,r){if(1===r.length){var i=e.categorical;if(i){var n=i.categories;if(n&&1===n.length){var a=n[0],o=a.source.roles,u=a.identityFields;if(o&&u&&o[r[0]])return{data:[t.DataViewScopeWildcard.fromExprs(u)]}}}}}function ie(e,r){if(t.SQExpr.isSelectRef(r))return r.expressionName;if(e)for(var i=0,n=e.length;n>i;i++){var a=e[i],o=a.expr;if(o&&t.SQExpr.equals(r,a.expr))return a.queryName}}function ne(e,t,r){for(var i=e.metadata.columns,n=0,a=i.length;a>n;n++){var o=i[n];if(1===r){var u=o.roles;if(!u||!u[t])continue}else if(o.queryName!==t)continue;var s=o.aggregates;if(s){var c=s.min;if(void 0===c&&(c=s.minLocal),void 0!==c){var l=s.max;if(void 0===l&&(l=s.maxLocal),void 0!==l)return{min:c,max:l}}}}}function ae(e,t,r){void 0===e&&(e=[]);var i=e;return oe(e),t&&(i.identityFields=t),r&&(i.source=r),i}function oe(e,t){e.grouped=t?function(){return t}:function(){return ue(e)}}function ue(e){for(var t,r=[],i=0,n=e.length;n>i;i++){var a=e[i];if(!t||t.identity!==a.identity){if(t={values:[]},a.identity){t.identity=a.identity;var o=a.source;void 0!==o.groupName?t.name=o.groupName:o.displayName&&(t.name=o.displayName)}r.push(t)}t.values.push(a)}return r}function se(e,r){var i;switch(ce(e.categorical,r)){case 1:i=t.DataViewPivotCategorical.apply(e);break;case 2:i=t.DataViewSelfCrossJoin.apply(e)}return i||e}function ce(e,t){if(e&&!_.isEmpty(t)){var r=e.categories;if(r&&1===r.length){var i=e.values;if(!_.isEmpty(i)&&!i.grouped().some(function(e){return!!e.identity}))for(var n=r[0].source.roles,a=0,o=t.length;o>a;a++){var u=t[a].categorical;if(u&&ve(n,u.values)){var s=u.categories,c=pe(n,s)||fe(n,s);return c?2:1}}}}}function le(e,t){if(e&&!_.isEmpty(t)){var r=e.rows.levels;if(!(r.length<1)){var i=e.rows.root.children;if(i&&0!==i.length)for(var n=r[0].sources[0].roles,a=0,o=t.length;o>a;a++){var u=t[a].matrix;if(u&&!fe(n,u.rows)&&fe(n,u.columns))return!0}}}}function pe(e,t){return e&&t&&t.bind?e[t.bind.to]:void 0}function fe(e,t){return e&&t&&t["for"]?e[t["for"]["in"]]:void 0}function ve(e,t){return e&&t&&t.group?e[t.group.by]:void 0}var he={type:{fillRule:{}}};r.apply=u,r.forEachNodeAtLevel=F,r.transformObjects=R,r.createValueColumns=ae,r.setGrouped=oe}(r=t.DataViewTransform||(t.DataViewTransform={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){function t(e){return function(t){return t.get(e)}}function r(e,t){return"function"==typeof e?e(t):"string"==typeof e?e:void 0}e.createDisplayNameGetter=t,e.getDisplayName=r}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){!function(e){e[e.Year=0]="Year",e[e.Month=1]="Month",e[e.Week=2]="Week",e[e.Day=3]="Day",e[e.Hour=4]="Hour",e[e.Minute=5]="Minute",e[e.Second=6]="Second",e[e.Millisecond=7]="Millisecond"}(e.DateTimeUnit||(e.DateTimeUnit={}));e.DateTimeUnit}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){var t;!function(e){function t(e){var t=i.visit(e,l.instance);return t}function r(t){return e.aggregate(n(t),t.aggregate)}function n(t){return e.columnRef(a(t),t.name)}function a(t){return e.entity(t.schema,t.entity,t.entityVar)}function o(t){return e.aggregate(a(t),t.aggregate)}function u(t){return e.aggregate(s(t),t.aggregate)}function s(t){return e.hierarchyLevel(c(t),t.level)}function c(t){return e.hierarchy(a(t),t.name)}e.fieldExpr=t,e.fromColumnAggr=r,e.fromColumn=n,e.fromEntity=a,
4e.fromEntityAggr=o,e.fromHierarchyLevelAggr=u,e.fromHierarchyLevel=s,e.fromHierarchy=c;var l=function(){function t(){}return t.prototype.visitColumn=function(e){return n(e)},t.prototype.visitColumnAggr=function(e){return r(e)},t.prototype.visitColumnHierarchyLevelVariation=function(t){return e.propertyVariationSource(this.visitEntity(t.source),t.source.name,t.level.name)},t.prototype.visitEntity=function(e){return a(e)},t.prototype.visitEntityAggr=function(e){return o(e)},t.prototype.visitHierarchy=function(e){return c(e)},t.prototype.visitHierarchyLevel=function(e){return s(e)},t.prototype.visitHierarchyLevelAggr=function(e){return u(e)},t.prototype.visitMeasure=function(t){return e.measureRef(this.visitEntity(t),t.name)},t.prototype.visitPercentile=function(t){var r=e.fieldExpr(t.arg);return e.percentile(r,t.k,t.exclusive)},t.prototype.visitPercentOfGrandTotal=function(t){var r=e.fieldExpr(t.baseExpr);return e.arithmetic(r,e.scopedEval(r,[]),3)},t.prototype.visitSelectRef=function(t){return e.selectRef(t.expressionName)},t.instance=new t,t}()}(t=e.SQExprBuilder||(e.SQExprBuilder={}));var r;!function(e){function t(e){return e.accept(n.instance)}e.asFieldPattern=t}(r=e.SQExprConverter||(e.SQExprConverter={}));var i,n=function(r){function i(){r.apply(this,arguments)}return __extends(i,r),i.prototype.visitColumnRef=function(e){var t=e.source.accept(a.instance);if(t&&t.entity){var r=t.entity;return r.name=e.ref,{column:r}}},i.prototype.visitMeasureRef=function(e){var t=e.source.accept(a.instance);if(t&&t.entity){var r=t.entity;return r.name=e.ref,{measure:r}}},i.prototype.visitEntity=function(e){var t={schema:e.schema,entity:e.entity};return e.variable&&(t.entityVar=e.variable),{entity:t}},i.prototype.visitAggr=function(e){var t=e.arg.accept(this);if(t&&t.column){var r=t.column;return r.aggregate=e.func,{columnAggr:r}}if(t&&t.columnAggr){var r=t.columnAggr;return r.aggregate=e.func,{columnAggr:r}}if(t&&t.hierarchyLevel){var r=t.hierarchyLevel;return r.aggregate=e.func,{hierarchyLevelAggr:r}}var i=e.arg.accept(a.instance);if(i&&i.entity){var r=i.entity;return r.aggregate=e.func,{entityAggr:r}}},i.prototype.visitPercentile=function(e){return{percentile:{arg:e.arg.accept(this),k:e.k,exclusive:e.exclusive}}},i.prototype.visitHierarchy=function(e){var t=e.arg.accept(a.instance);if(t&&t.entity){var r=t.entity;return r.name=e.hierarchy,{hierarchy:r}}},i.prototype.visitHierarchyLevel=function(e){var t=e.arg.accept(o.instance);if(t){var r;return t.hierarchy&&(r={entity:t.hierarchy.entity,schema:t.hierarchy.schema,name:t.hierarchy.name,level:e.level}),t.variation?{columnHierarchyLevelVariation:{source:{entity:t.variation.column.entity,schema:t.variation.column.schema,name:t.variation.column.name},level:r,variationName:t.variation.variationName}}:{hierarchyLevel:r}}},i.prototype.visitArithmetic=function(r){var i={percentOfGrandTotal:{baseExpr:r.left.accept(this)}};return e.SQExpr.equals(r,t.fieldExpr(i))?i:void 0},i.prototype.visitSelectRef=function(e){return{selectRef:{expressionName:e.expressionName}}},i.instance=new i,i}(e.DefaultSQExprVisitor),a=function(t){function r(){t.apply(this,arguments)}return __extends(r,t),r.prototype.visitEntity=function(e){var t={schema:e.schema,entity:e.entity};return e.variable&&(t.entityVar=e.variable),{entity:t}},r.prototype.visitPropertyVariationSource=function(t){var r=t.arg;if(r instanceof e.SQEntityExpr){var i={schema:r.schema,entity:r.entity,name:t.property};return r.variable&&(i.entityVar=r.variable),{variation:{column:i,variationName:t.name}}}},r.instance=new r,r}(e.DefaultSQExprVisitor),o=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.visitHierarchy=function(e){var t,r,i=e.arg.accept(a.instance);return i.variation?(t={name:e.hierarchy,schema:i.variation.column.schema,entity:i.variation.column.entity},r=i.variation):t={name:e.hierarchy,schema:i.entity.schema,entity:i.entity.entity},{hierarchy:t,variation:r}},t.instance=new t,t}(e.DefaultSQExprVisitor);!function(i){function n(t,i){var n=t instanceof e.SQExpr?r.asFieldPattern(t):t;return n.column?a(n.column,i):n.columnAggr?o(n.columnAggr,i):n.columnHierarchyLevelVariation?u(n.columnHierarchyLevelVariation,i):n.entity?s(n.entity,i):n.entityAggr?c(n.entityAggr,i):n.hierarchy?l(n.hierarchy,i):n.hierarchyLevel?p(n.hierarchyLevel,i):n.hierarchyLevelAggr?f(n.hierarchyLevelAggr,i):n.measure?v(n.measure,i):n.percentile?g(n.percentile,i):n.percentOfGrandTotal?d(n.percentOfGrandTotal,i):n.selectRef?h(n.selectRef,i):void 0}function a(e,t){return t.visitColumn(e)}function o(e,t){return t.visitColumnAggr(e)}function u(e,t){return t.visitColumnHierarchyLevelVariation(e)}function s(e,t){return t.visitEntity(e)}function c(e,t){return t.visitEntityAggr(e)}function l(e,t){return t.visitHierarchy(e)}function p(e,t){return t.visitHierarchyLevel(e)}function f(e,t){return t.visitHierarchyLevelAggr(e)}function v(e,t){return t.visitMeasure(e)}function h(e,t){return t.visitSelectRef(e)}function g(e,t){return t.visitPercentile(e)}function d(e,t){return t.visitPercentOfGrandTotal(e)}function y(e){return t.columnRef(t.entity(e.schema,e.entity,e.entityVar),e.name)}function m(e){return n(e,_.instance)}function x(e){return n(e,F.instance)}function S(e){return void 0!==(e.column||e.columnAggr||e.measure)}function E(e){return i.visit(e,M.instance)}function w(e){var t=e.hierarchy;return t?t.name:void 0}function b(e){return e.columnHierarchyLevelVariation?e.columnHierarchyLevelVariation.source:e.column||e.measure||e.columnAggr}function D(e){var t=E(e);return t?t:T(e).entity}function C(e){var t=i.toFieldExprEntityItemPattern(e);return t.schema}function T(e){return i.visit(e,P.instance)}function V(e){return i.visit(e,P.instance)}i.visit=n,i.toColumnRefSQExpr=y,i.getAggregate=m,i.isAggregation=x,i.hasFieldExprName=S,i.getPropertyName=E,i.getHierarchyName=w,i.getColumnRef=b,i.getFieldExprName=D,i.getSchema=C,i.toFieldExprEntityPattern=T,i.toFieldExprEntityItemPattern=V;var _=function(){function r(){}return r.prototype.visitColumn=function(e){},r.prototype.visitColumnAggr=function(e){return e.aggregate},r.prototype.visitColumnHierarchyLevelVariation=function(e){},r.prototype.visitEntity=function(e){},r.prototype.visitEntityAggr=function(e){return e.aggregate},r.prototype.visitHierarchy=function(e){},r.prototype.visitHierarchyLevel=function(e){},r.prototype.visitHierarchyLevelAggr=function(e){return e.aggregate},r.prototype.visitMeasure=function(e){},r.prototype.visitSelectRef=function(e){},r.prototype.visitPercentile=function(e){},r.prototype.visitPercentOfGrandTotal=function(r){return e.SQExprInfo.getAggregate(t.fieldExpr(r.baseExpr))},r.instance=new r,r}(),F=function(){function e(){}return e.prototype.visitColumn=function(e){return!1},e.prototype.visitColumnAggr=function(e){return!0},e.prototype.visitColumnHierarchyLevelVariation=function(e){return!1},e.prototype.visitEntity=function(e){return!1},e.prototype.visitEntityAggr=function(e){return!0},e.prototype.visitHierarchy=function(e){return!1},e.prototype.visitHierarchyLevel=function(e){return!1},e.prototype.visitHierarchyLevelAggr=function(e){return!0},e.prototype.visitMeasure=function(e){return!0},e.prototype.visitSelectRef=function(e){return!1},e.prototype.visitPercentile=function(e){return!0},e.prototype.visitPercentOfGrandTotal=function(e){return!0},e.instance=new e,e}(),P=function(){function e(){}return e.prototype.visitColumn=function(t){return e.toEntityItemExprPattern(t)},e.prototype.visitColumnAggr=function(t){return e.toEntityItemExprPattern(t)},e.prototype.visitColumnHierarchyLevelVariation=function(t){return e.toEntityItemExprPattern(t.source)},e.prototype.visitEntity=function(t){return e.toEntityItemExprPattern(t)},e.prototype.visitEntityAggr=function(t){return e.toEntityItemExprPattern(t)},e.prototype.visitHierarchy=function(t){return e.toEntityItemExprPattern(t)},e.prototype.visitHierarchyLevel=function(t){return e.toEntityItemExprPattern(t)},e.prototype.visitHierarchyLevelAggr=function(t){return e.toEntityItemExprPattern(t)},e.prototype.visitMeasure=function(t){return e.toEntityItemExprPattern(t)},e.prototype.visitSelectRef=function(e){},e.prototype.visitPercentile=function(e){return i.visit(e.arg,this)},e.prototype.visitPercentOfGrandTotal=function(e){return i.visit(e.baseExpr,this)},e.toEntityItemExprPattern=function(e){var t={schema:e.schema,entity:e.entity};return e.entityVar&&(t.entityVar=e.entityVar),t},e.instance=new e,e}(),M=function(){function e(){}return e.prototype.visitColumn=function(e){return e.name},e.prototype.visitColumnAggr=function(e){return e.name},e.prototype.visitColumnHierarchyLevelVariation=function(e){},e.prototype.visitEntity=function(e){},e.prototype.visitEntityAggr=function(e){},e.prototype.visitHierarchy=function(e){},e.prototype.visitHierarchyLevel=function(e){},e.prototype.visitHierarchyLevelAggr=function(e){},e.prototype.visitMeasure=function(e){return e.name},e.prototype.visitSelectRef=function(e){},e.prototype.visitPercentile=function(e){return i.visit(e.arg,this)},e.prototype.visitPercentOfGrandTotal=function(e){return i.visit(e.baseExpr,this)},e.instance=new e,e}()}(i=e.FieldExprPattern||(e.FieldExprPattern={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){function r(t,r){if(!r||0===r.length)return{dataView:t,isValid:!0};if(t)for(var u=0,s=r;u<s.length;u++){var l=s[u];if(c(t,l))return{dataView:t,isValid:!0};if(l.categorical&&t.categorical)return i(t,l);if(l.tree&&t.tree)return a(t,l.tree);if(l.single&&t.single)return n(t,l.single);if(l.table&&t.table)return o(t,l.table)}else if(e.ScriptResultUtil.findScriptResult(r))return{dataView:t,isValid:!0};return{isValid:!1}}function i(t,r){var i=r.categorical,n=t.categorical;if(!n)return{isValid:!1};var a;if(i.rowCount&&(a=i.rowCount.supported,a&&a.max)){var o=void 0,u=n.categories,s=a.max,c=void 0;if(u)for(var p=0,f=u.length;f>p;p++){var v=u[p];if(c=v.values.length,void 0!==s&&c>s){var h=C.range(v.values,0,s-1);o=o||{categories:[]},o.categories.push({source:v.source,values:h})}}if(n.values&&n.values.length>0&&s&&(c||(c=n.values[0].values.length),void 0!==s&&c>s)){o=o||{},o.values=e.data.DataViewTransform.createValueColumns();for(var p=0,f=n.values.length;f>p;p++){var g=n.values[p],d={source:g.source,values:C.range(g.values,0,s-1)};void 0!==g.min&&(d.min=g.min),void 0!==g.max&&(d.max=g.max),void 0!==g.subtotal&&(d.subtotal=g.subtotal),o.values.push(d)}}o&&(t={metadata:t.metadata,categorical:o})}return l(t,r)?{dataView:t,isValid:!0}:null}function n(e,t){return e.single?{dataView:e,isValid:!0}:{isValid:!1}}function a(e,t){var r=e.metadata;return null==g(u(r.columns),t.depth)?{dataView:e,isValid:!0}:{isValid:!1}}function o(e,t){return e.table?{dataView:e,isValid:!0}:{isValid:!1}}function u(e){for(var t=0,r=0,i=e.length;i>r;r++)e[r].isMeasure||++t;return t}function s(e){for(var t=0,r=0,i=e.length;i>r;r++)e[r].isMeasure&&++t;return t}function c(e,t,r){return t&&e?t.scriptResult&&!h(e.scriptResult,t.scriptResult)?!1:t.categorical&&!l(e,t.categorical,r)?!1:t.tree&&!f(e,t.tree)?!1:t.single&&!p(e.single,t.single)?!1:!t.table||v(e.table,t.table,r):!1}function l(e,t,r){var i=e.categorical;if(!i)return!1;if(t.rowCount){var n=t.rowCount.supported;if(r&&t.rowCount.preferred&&(n=t.rowCount.preferred),n){var a=0;if(i.values&&i.values.length?a=i.values[0].values.length:i.categories&&i.categories.length&&(a=i.categories[0].values.length),null!=g(a,n))return!1}}return!0}function p(e,t){return!!e}function f(e,t){var r=e.metadata;return null==g(u(r.columns),t.depth)}function v(e,t,r){if(!e)return!1;if(t.rowCount){var i=t.rowCount.supported;if(r&&t.rowCount.preferred&&(i=t.rowCount.preferred),i){var n=0;if(e.rows&&e.rows.length&&(n=e.rows.length),null!=g(n,i))return!1}}return!0}function h(e,t){return e?!!e.imageBase64:!1}function g(e,t,r){return t?!r&&void 0!==t.min&&t.min>e?V.conditionRangeTooSmall:void 0!==t.max&&t.max<e?V.conditionRangeTooLarge:void 0:void 0}function d(t,r,i,n){if(t&&void 0!==t.kind){var a=t.kind,o=i[r];if(o)for(var u=o.all(),s=0,c=u;s<c.length;s++){var l=c[s];if(n[l.queryRef]!==a)switch(a){case e.VisualDataRoleKind.Measure:return V.conditionKindExpectedMeasure;case e.VisualDataRoleKind.Grouping:return V.conditionKindExpectedGrouping;case e.VisualDataRoleKind.GroupingOrMeasure:return V.conditionKindExpectedGroupingOrMeasure}}}}function y(e,t,r,i,n){var a=[],o=[];if(!_.isEmpty(t))for(var u=0,s=t.length;s>u;u++){var c=t[u],l=c.conditions,p=c.requiredProperties,f=x(p,i,n),v=[];if(_.isEmpty(l))v.push({});else for(var h=0,g=l.length;g>h;h++){var d=l[h],y=m(e,d,r);if(_.isEmpty(y))v.push(d);else for(var S=0,E=y;S<E.length;S++){var w=E[S];w.mappingIndex=u,w.conditionIndex=h,o.push(w)}}if(!_.isEmpty(v)&&f){var b=_.cloneDeep(c),D=_.filter(v,function(e){return Object.keys(e).length>0});_.isEmpty(D)||(b.conditions=D),a.push(b)}}return{supportedMappings:C.emptyToNull(a),mappingErrors:C.emptyToNull(o)}}function m(e,t,r){for(var i=Object.keys(t),n=[],a=0,o=i.length;o>a;a++){var u=i[a],s=e[u]&&!_.isEmpty(e[u].activeProjectionRefs),c=t[u],l=S(u,e,s),p=g(l,c);null!=p&&n.push({code:p,roleName:u});var f=d(c,u,e,r);null!=f&&n.push({code:f,roleName:u})}return n}function x(t,r,i){if(_.isEmpty(t))return!0;if(!r||!i)return!1;var n=e.data.createStaticEvalContext();return _.every(t,function(t){var a=null,o=r[t.objectName];o&&(a=o.properties[t.propertyName]);var u=T.getValue(i,t,null);return a&&u?e.data.DataViewObjectEvaluator.evaluateProperty(n,a,u):!1})}function S(e,t,r){var i=t[e];return i?r?1:i.all().length:0}function E(t,r){if(t&&r&&t.categorical&&r.categorical){var i=t.categorical.categories,n=r.categorical.categories;if(i&&n&&i.length===n.length){for(var a=0,o=i.length;o>a;a++){var u=i[a].identity,s=n[a].identity,c=w(u);if(c!==w(s))return!1;for(var l=0;c>l;l++)if(!e.DataViewScopeIdentity.equals(u[l],s[l]))return!1}return!0}}return!1}function w(e){return e?e.length:0}function b(e,t){return e||t?e&&t?e.displayName!==t.displayName?!1:e.queryName!==t.queryName?!1:e.isMeasure!==t.isMeasure?!1:e.type!==t.type?!1:e.sort===t.sort:!1:!0}function D(e,r){if(!e&&!r)return!0;if(!e||!r)return!1;var i=e.columns.length,n=r.columns.length;if(i!==n)return!1;for(var a=0;n>a;a++)if(!t.areMetadataColumnsEquivalent(e.columns[a],r.columns[a]))return!1;return!0}var C=jsCommon.ArrayExtensions,T=e.data.DataViewObjectDefinitions;!function(e){e[e.conditionRangeTooLarge=0]="conditionRangeTooLarge",e[e.conditionRangeTooSmall=1]="conditionRangeTooSmall",e[e.conditionKindExpectedMeasure=2]="conditionKindExpectedMeasure",e[e.conditionKindExpectedGrouping=3]="conditionKindExpectedGrouping",e[e.conditionKindExpectedGroupingOrMeasure=4]="conditionKindExpectedGroupingOrMeasure"}(t.DataViewMappingMatchErrorCode||(t.DataViewMappingMatchErrorCode={}));var V=t.DataViewMappingMatchErrorCode;t.validateAndReshape=r,t.countGroups=u,t.countMeasures=s,t.supports=c,t.validateRange=g,t.chooseDataViewMappings=y,t.getPropertyCount=S,t.hasSameCategoryIdentity=E,t.areMetadataColumnsEquivalent=b,t.isMetadataEquivalent=D}(t=e.DataViewAnalysis||(e.DataViewAnalysis={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){var t,r=jsCommon.ArrayExtensions,i=jsCommon.Lazy;!function(e){function t(e){return new a(e)}function n(e,t){return e.key&&t.key&&e.key===t.key&&r.sequenceEqual(e.roles,t.roles,function(e,t){return e===t})}e.fromRoles=t,e.equals=n;var a=function(){function e(e){var t=this;this._roles=e,this._key=new i(function(){return JSON.stringify(t.roles)})}return Object.defineProperty(e.prototype,"roles",{get:function(){return this._roles},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"key",{get:function(){return this._key.getValue()},enumerable:!0,configurable:!0}),e}()}(t=e.DataViewRoleWildcard||(e.DataViewRoleWildcard={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){function i(e,t,i){return e=e||null,t=t||null,e===t?!0:!e!=!t?!1:r.SQExpr.equals(e.expr,t.expr,i)}function n(e,t){if(!_.isEmpty(e)){for(var r=[],i=0,n=e;i<n.length;i++){var o=n[i];r.push(o.expr)}return a(r,t)}}function a(t,i){if(!_.isEmpty(t)){for(var n,a=0,o=t;a<o.length;a++){var u=o[a],s=r.ScopeIdentityExtractor.getInExpr(u);n=n?r.SQExprBuilder.or(n,s):s||u}return n&&i&&(n=e.data.SQExprBuilder.not(n)),e.data.SemanticFilter.fromSQExpr(n)}}t.equals=i,t.filterFromIdentity=n,t.filterFromExprs=a}(t=e.DataViewScopeIdentity||(e.DataViewScopeIdentity={}));var r;!function(e){function t(e){return new i(e)}var r=jsCommon.Lazy;e.createDataViewScopeIdentity=t;var i=function(){function t(t){this._expr=t,this._key=new r(function(){return e.SQExprShortSerializer.serialize(t)})}return Object.defineProperty(t.prototype,"expr",{get:function(){return this._expr},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"key",{get:function(){return this._key.getValue()},enumerable:!0,configurable:!0}),t}()}(r=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){var t,r=jsCommon.Lazy;!function(t){function i(t,r){var i=e.ScopeIdentityExtractor.getKeys(r.expr);return i?e.SQExprUtils.sequenceEqual(t.exprs,i):!1}function n(t,r){return t.key===r.key&&e.SQExprUtils.sequenceEqual(t.exprs,r.exprs)}function a(e){return new o(e)}t.matches=i,t.equals=n,t.fromExprs=a;var o=function(){function t(t){this._exprs=t,this._key=new r(function(){return e.SQExprShortSerializer.serializeArray(t)})}return Object.defineProperty(t.prototype,"exprs",{get:function(){return this._exprs},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"key",{get:function(){return this._key.getValue()},enumerable:!0,configurable:!0}),t}()}(t=e.DataViewScopeWildcard||(e.DataViewScopeWildcard={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){function t(){return new r}e.createColorAllocatorCache=t;var r=function(){function e(){this.cache=[]}return e.prototype.get=function(e){for(var t=0,r=this.cache;t<r.length;t++){var i=r[t];if(i.key===e)return i.allocator}},e.prototype.register=function(e,t){return this.cache.push({key:e,allocator:t}),this},e}()}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){var r;!function(r){function i(r){var i=r.dataViewMappings,n=r.visualDataViews,a=r.dataRoles,o=r.objectDescriptors,u=r.objectDefinitions,s=r.colorAllocatorFactory,c=r.transformSelects,l=r.projectionActiveItems,p=r.metadata;if(!_.isEmpty(n)&&c&&p){var f=t.DataViewSelectTransform.createRoleKindFromMetadata(c,p),v=t.DataViewSelectTransform.projectionsFromSelects(c,l);if(!f||!v||_.isEmpty(i)||!o||!u)return n;var h=e.DataViewAnalysis.chooseDataViewMappings(v,i,f,o,u).supportedMappings;if(h){var g=_.find(h,function(e){return e.usage&&e.usage.regression});if(g){for(var d=[],y=0,m=n;y<m.length;y++){var x=m[y],S=this.linearRegressionTransform(x,a,g,o,u,s);S&&d.push(S)}_.isEmpty(d)||n.push.apply(n,d)}}}return n}function n(t,r,i,n,u,s){if(t.categorical){var c=o(0,t.categorical,r),l=o(1,t.categorical,r);if(!_.isEmpty(c)&&!_.isEmpty(l)){var f=c[0].source,d=l[0].source,y=!0;if(i.usage&&i.usage.regression&&t.metadata.objects){var m=i.usage.regression,x=m.combineSeries;x&&(y=e.DataViewObjects.getValue(t.metadata.objects,x,!0))}var S,E=v(c,l,y,!1),w=a(E),b=w.xMin,D=w.xMax,C=g(l)||g(c);if(C){var T=v(c,l,y,!0);S=a(T),S?(b=_.min([b,S.xMin]),D=_.max([D,S.xMax])):C=!1}for(var V=[],F=0,P=w.lineDefs;F<P.length;F++){var M=P[F];V.push(p(M,+b,+D))}var R;if(C){R=[];for(var A=0,N=S.lineDefs;A<N.length;A++){var M=N[A];R.push(p(M,+b,+D))}}var I;if(y)I=["combinedRegressionSeries"];else if(t.categorical.values.source){var O=t.categorical.values.grouped();I=_.map(O,function(e){return e.name})}else I=_.map(l,function(e){return e.source.queryName});var Q=h(f,d,I,[b,D],V,R,t,i,n,u,s);return Q}}}function a(e){for(var t,r,i=[],n=0,a=e;n<a.length;n++){var o=a[n],u=o.xValues,p=o.yValues;if(_.isEmpty(u)||_.isEmpty(p))return;var f=s(u);if(!f)return;var v=s(p);if(!v)return;var h=c(u,p),g=h.xValues[0],d=h.xValues[h.xValues.length-1],y=l(h.xValues,h.yValues);t=_.min([t,g]),r=_.max([r,d]),i.push(y)}return{lineDefs:i,xMin:t,xMax:r}}function o(e,t,r){var i=u(e,t.values,r);if(!_.isEmpty(i))return i;var n=t.categories;if(!_.isEmpty(n)){var a=n[0];return i=u(e,[a],r),_.isEmpty(i)?void 0:i}}function u(e,t,r){return _.isEmpty(t)?void 0:_.filter(t,function(t){var i=function(i){if(!t.source.roles[i])return"continue";var n=_.find(r,function(e){return e.name===i});return n&&n.cartesianKind===e?{value:!0}:void 0};for(var n in t.source.roles){var a=i(n);if("object"==typeof a)return a.value}return!1})}function s(e){var t=_.find(e,function(e){return null!=e});if(null!=t){var r=typeof t;if(!_.some(e,function(e){return null!=e&&typeof e!==r}))return r}}function c(e,t){var r=_.zip(e,t),i=_.chain(r).filter(function(e){return null!=e[0]&&null!=e[1]}).sortBy(function(e){return e[0]}).unzip().value(),n=i[0],a=i[1];return{xValues:n,yValues:a}}function l(e,t){var r=_.sum(e)/e.length,i=_.sum(t)/t.length,n=_.chain(e).map(function(e){return Math.pow(e-r,2)}).sum(),a=_.chain(e).map(function(e,n){return(e-r)*(t[n]-i)}).sum(),o=a/n,u=i-r*o;return{slope:o,intercept:u}}function p(e,t,r){return[t*e.slope+e.intercept,r*e.slope+e.intercept]}function f(e,t){if(t){var r=e;if(r.highlights)return r.highlights}return e.values}function v(e,t,r,i){for(var n=[],a=_.map(e,function(e){return f(e,i)}),o=_.map(t,function(e){return f(e,i)}),u=e.length>1,s=0;s<o.length;s++){var c=u?a[s]:a[0],l=o[s];r&&n.length>0?(n[0].xValues=n[0].xValues.concat(c),n[0].yValues=n[0].yValues.concat(l)):n.push({xValues:c,yValues:l})}return n}function h(e,i,n,a,o,u,s,c,l,p,f){var v,h,g=c.categorical.categories["for"]["in"],m=c.categorical.values.group;if(m&&!_.isEmpty(m.select)&&(v=m.select[0]["for"]?m.select[0]["for"]["in"]:m.select[0].bind.to,h=m.by),v&&h){var x=(T={},T[g]=!0,T),S=(V={},V[v]=!0,V),E=(F={},F[h]=!0,F),w=[];for(var b in o){var D={values:o[b]};u&&(D.highlights=u[b]),w.push([D])}var C=t.createCategoricalDataViewBuilder().withCategory({source:{displayName:e.displayName,queryName:d,type:e.type,isMeasure:!1,roles:x},values:a,identityFrom:{fields:[t.SQExprBuilder.columnRef(t.SQExprBuilder.entity("s","RegressionEntity"),"RegressionCategories")]}}).withGroupedValues({groupColumn:{source:{displayName:i.displayName+"Regression",queryName:y,type:i.type,isMeasure:i.isMeasure,roles:E},values:n,identityFrom:{fields:[t.SQExprBuilder.columnRef(t.SQExprBuilder.entity("s","RegressionEntity"),"RegressionSeries")]}},valueColumns:[{source:{displayName:i.displayName,queryName:r.regressionYQueryName,type:i.type,isMeasure:i.isMeasure,roles:S}}],data:w}).build();return t.DataViewTransform.transformObjects(C,1,l,p,[],f),C;var T,V,F}}function g(e){return _.any(e,function(e){var t=e;return null!=t.highlights})}var d="RegressionX",y="RegressionSeries";r.regressionYQueryName="RegressionY",r.run=i,r.linearRegressionTransform=n}(r=t.DataViewRegression||(t.DataViewRegression={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){var r;!function(r){function i(e,r){for(var i={},n=0,a=e;n<a.length;n++){var o=a[n],u=o.roles;if(u)for(var s in u)if(u[s]){var c=i[s];c||(c=i[s]=new t.QueryProjectionCollection([])),c.all().push({queryRef:o.queryName}),r&&r[s]&&(c.activeProjectionRefs=_.map(r[s],function(e){return e.queryRef}))}}return i}function n(t,r){for(var i={},n=0,a=r.columns;n<a.length;n++){var o=a[n];if(!(!o.index&&0!==o.index||o.index<0||o.index>=t.length)){var u=t[o.index];if(u){var s=u.queryName;s&&void 0===i[s]&&(i[s]=o.isMeasure?e.VisualDataRoleKind.Measure:e.VisualDataRoleKind.Grouping)}}}return i}r.projectionsFromSelects=i,r.createRoleKindFromMetadata=n}(r=t.DataViewSelectTransform||(t.DataViewSelectTransform={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){function t(e,t){return new n(e,t)}function r(e,t){return i(e.values,t)||i(e.categories,t)}function i(e,t){if(e)for(var r=0,i=e;r<i.length;r++){var n=i[r],a=n.source.roles;if(a&&a[t])return n}}e.createCategoricalEvalContext=t;var n=function(){function e(e,t){this.colorAllocatorProvider=e,this.dataView=t,this.columnsByRole={}}return e.prototype.getColorAllocator=function(e){return this.colorAllocatorProvider.get(e)},e.prototype.getExprValue=function(e){},e.prototype.getRoleValue=function(e){var t=this.columnsByRole,i=t[e];if(i||(i=t[e]=r(this.dataView,e)),i){var n=this.index;return null!=n?i.values[this.index]:void 0}},e.prototype.setCurrentRowIndex=function(e){this.index=e},e}()}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){function t(e,t,i){return new r(e,t,i)}e.createTableEvalContext=t;var r=function(){function t(e,t,r){this.colorAllocatorProvider=e,this.dataView=t,this.selectTransforms=r}return t.prototype.getColorAllocator=function(e){return this.colorAllocatorProvider.get(e)},t.prototype.getExprValue=function(t){var r=this.rowIdx;if(null!=r)return e.getExprValueFromTable(t,this.selectTransforms,this.dataView,r)},t.prototype.getRoleValue=function(e){},t.prototype.setCurrentRowIndex=function(e){this.rowIdx=e},t}()}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){var t=function(){function e(){}return e.prototype.evaluate=function(e){},e}();e.RuleEvaluation=t}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){var t=function(e){function t(t,r){e.call(this),this.inputRole=t,this.allocator=r}return __extends(t,e),t.prototype.evaluate=function(e){var t=e.getRoleValue(this.inputRole);return void 0!==t?this.allocator.color(t):void 0},t}(e.RuleEvaluation);e.ColorRuleEvaluation=t}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){var r;!function(t){var r,i=e.Prototype.inherit,n=e.Prototype.inheritSingle,a=jsCommon.ArrayExtensions;!function(e){function t(e,t){if(e)if(r(e))for(var i=0,n=0,a=e;n<a.length;n++){var u=a[n];u&&(i=o(u,i,[],t))}else o(e,0,[],t)}function r(e){return a.isArrayOrInheritedArray(e)}function o(e,t,r,i){if(r.push(e),_.isEmpty(e.children))i(e,t,r),t++;else for(var n=e.children,a=0,u=n;a<u.length;a++){var s=u[a];s&&(t=o(s,t,r,i))}return r.pop(),t}function u(e,t,r){var a=e,o=_.isUndefined(e.level),s=o||e.level<=t;if(s){var c=r?n:i,l=c(e),p=o||e.level<t;if(p&&!_.isEmpty(e.children)){l.children=c(e.children);for(var f=0,v=l.children.length;v>f;f++)l.children[f]=u(l.children[f],t,r)}a=l}return a}function s(e){var t=!1;if(e)if(c(e))t=s(e.rows)||s(e.columns);else{var r=e.levels;if(!_.isEmpty(r))for(var i=0,n=r;i<n.length;i++){var a=n[i];if(a.sources&&a.sources.length>=2){var o=a.sources[0].isMeasure;if(!o){t=!0;break}}}}return t}function c(e){return"rows"in e&&"columns"in e&&"valueSources"in e}e.forEachLeafNode=t,e.inheritMatrixNodeHierarchy=u,e.containsCompositeGroup=s}(r=t.DataViewMatrixUtils||(t.DataViewMatrixUtils={}))}(r=t.utils||(t.utils={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){var t;!function(e){var t;!function(e){function t(e,t){var r=e.roles;return r&&r[t]}function r(e,r,i){var n=[];if(!_.isEmpty(e)){for(var a=r[i],o={},u=0,s=a.length;s>u;u++){var c=a[u];o[c]=u}for(var l=0,p=e.length;p>l;l++){var f=e[l];if(t(f,i)){var v={metadataColumn:f,sourceIndex:l,projectionOrderIndex:o[f.index]};n.push(v)}}}return n}e.isForRole=t,e.joinMetadataColumnsAndProjectionOrder=r}(t=e.DataViewMetadataColumnUtils||(e.DataViewMetadataColumnUtils={}))}(t=e.utils||(e.utils={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){var t=function(){function e(){}return e.prototype.findProperty=function(e,t){var r=this.entities.withName(e);if(r&&!_.isEmpty(r.properties))return r.properties.withName(t)},e.prototype.findHierarchy=function(e,t){var r=this.entities.withName(e);if(r&&!_.isEmpty(r.hierarchies))return r.hierarchies.withName(t)},e.prototype.findHierarchyByVariation=function(e,t,r,i){var n=this.entities.withName(e);if(n&&!_.isEmpty(n.properties)){var a=n.properties.withName(t);if(a){var o=a.column;if(o&&!_.isEmpty(o.variations)){var u=o.variations.withName(r);if(u){var s=u.navigationProperty?u.navigationProperty.targetEntity:n;if(!s||_.isEmpty(s.hierarchies))return;return s.hierarchies.withName(i)}}}}},e.prototype.findPropertyWithKpi=function(e,t){var r=this.entities.withName(e);if(r&&!_.isEmpty(r.properties))for(var i=0,n=r.properties;i<n.length;i++){var a=n[i];if(a&&a.measure&&a.measure.kpi&&(a.measure.kpi.status===t||a.measure.kpi.goal===t))return a}},e}();e.ConceptualSchema=t,function(e){e[e.None=0]="None",e[e.Address=1]="Address",e[e.City=2]="City",e[e.Company=3]="Company",e[e.Continent=4]="Continent",e[e.Country=5]="Country",e[e.County=6]="County",e[e.Date=7]="Date",e[e.Image=8]="Image",e[e.ImageUrl=9]="ImageUrl",e[e.Latitude=10]="Latitude",e[e.Longitude=11]="Longitude",e[e.Organization=12]="Organization",e[e.Place=13]="Place",e[e.PostalCode=14]="PostalCode",e[e.Product=15]="Product",e[e.StateOrProvince=16]="StateOrProvince",e[e.WebUrl=17]="WebUrl"}(e.ConceptualDataCategory||(e.ConceptualDataCategory={}));e.ConceptualDataCategory}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t,r=jsCommon.StringExtensions,i=e.data.FieldExprPattern;!function(t){function n(e){return e&&1===e.length?e[0].scriptResult:void 0}function a(t){var r=n(t);if(r){var i=t[0].metadata.objects,a=e.DataViewObjects.getValue(i,r.script.source),o=e.DataViewObjects.getValue(i,r.script.provider);return{source:a,provider:o}}}function o(t,r){var i=n(t);if(i&&r){var a=e.data.DataViewObjectDefinitions.getValue(r,i.script.source,null),o=e.data.DataViewObjectDefinitions.getValue(r,i.script.provider,null);return{source:a?a.value:null,provider:o?o.value:null}}}function u(e,t,n){var a={VariableName:"dataset",Columns:[]};if(e&&t&&!_.isEmpty(t)){var o=[],u=[];for(var c in e)for(var l=0,p=e[c].all();l<p.length;l++){var f=p[l],v=t.withName(f.queryRef);if(v){var h={QueryName:v.name,Name:i.visit(v.expr,new s(n))};u.push(h),o.push(h.Name)}}o=r.ensureUniqueNames(o);for(var g=0;g<o.length;g++){var h=u[g];h.Name=o[g]}a.Columns=u}return a}t.findScriptResult=n,t.extractScriptResult=a,t.extractScriptResultFromVisualConfig=o,t.getScriptInput=u;var s=function(){function e(e){this.federatedSchema=e}return e.prototype.visitColumn=function(t){return e.getNameForProperty(t,this.federatedSchema)},e.prototype.visitColumnAggr=function(t){return e.getNameForProperty(t,this.federatedSchema)},e.prototype.visitColumnHierarchyLevelVariation=function(t){return e.getVariationLevelName(t,this.federatedSchema)},e.prototype.visitEntity=function(e){return e.entity},e.prototype.visitEntityAggr=function(e){return e.entity},e.prototype.visitHierarchy=function(t){return e.getNameForHierarchy(t,this.federatedSchema)},e.prototype.visitHierarchyLevel=function(e){},e.prototype.visitHierarchyLevelAggr=function(t){return e.getNameForProperty(t,this.federatedSchema)},e.prototype.visitMeasure=function(t){return e.getNameForProperty(t,this.federatedSchema)},e.prototype.visitSelectRef=function(e){return i.visit(e,this)},e.prototype.visitPercentile=function(e){return i.visit(e.arg,this)},e.prototype.visitPercentOfGrandTotal=function(e){return i.visit(e.baseExpr,this)},e.getNameForHierarchy=function(e,t){var r=t.schema(e.schema),i=r.findHierarchy(e.entity,e.name);return i?i.name:void 0},e.getNameForProperty=function(e,t){var r=t.schema(e.schema),i=r.findProperty(e.entity,e.name);return i?i.name:void 0},e.getVariationLevelName=function(e,t){var r=e.source,i=t.schema(r.schema).findProperty(r.entity,r.name);if(i)for(var n=i.column.variations,a=0,o=n;a<o.length;a++){var u=o[a];if(u.name===e.variationName)for(var s=0,c=u.defaultHierarchy.levels;s<c.length;s++){var l=c[s];if(l.name===e.level.level)return l.column.name}}},e}()}(t=e.ScriptResultUtil||(e.ScriptResultUtil={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){var r;!function(t){var r;!function(t){function r(t,r){!e.DataViewAnalysis.isMetadataEquivalent(t.metadata,r.metadata),r.metadata.segment||delete t.metadata.segment,
5t.table&&r.table&&i(t.table,r.table),t.categorical&&r.categorical&&n(t.categorical,r.categorical),t.tree&&r.tree&&o(t.tree.root,r.tree.root,!0),t.matrix&&r.matrix&&o(t.matrix.rows.root,r.matrix.rows.root,!1)}function i(e,t){if(!_.isEmpty(t.rows)){var r=t.lastMergeIndex+1;a(e.rows,t.rows,r),t.identity&&a(e.identity,t.identity,r)}}function n(e,t){if(e.categories&&t.categories)for(var r=t.categories.length,i=0;r>i;i++){var n=t.categories[i],o=e.categories[i],u=t.lastMergeIndex+1;n.values&&a(o.values,n.values,u),n.identity&&a(o.identity,n.identity,u)}if(e.values&&t.values)for(var s=t.values.length,c=0;s>c;c++){var l=t.values[c],p=e.values[c];!p.values&&l.values&&(p.values=[]);var u=t.lastMergeIndex+1;l.values&&a(p.values,l.values,u),l.highlights&&a(p.highlights,l.highlights,u)}}function a(e,t,r){if(r>=t.length)return t;var i=[];return void 0!==r&&(i=t.splice(0,r)),Array.prototype.push.apply(e,t),i}function o(e,t,r){if(t.children&&0!==t.children.length){if(r&&(!e.children||0===e.children.length))return void(e.children=t.children);var i=u(t.children),n=e.children[e.children.length-1],s=a(e.children,t.children,i);s.length>0&&o(n,s[s.length-1],r)}}function u(e){if(0===e.length)return 0;for(var t=0;t<e.length;t++){var r=e[t];if(!r.isMerge)break}return t}t.mergeDataViews=r,t.mergeTables=i,t.mergeCategorical=n,t.mergeTreeNodes=o}(r=t.DataViewMerger||(t.DataViewMerger={}))}(r=t.segmentation||(t.segmentation={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){var t=jsCommon.ArrayExtensions,r=function(){function r(){}return r.prototype.visitColumnRef=function(t){var r=t.source,i=r.accept(this);return r===i?t:new e.SQColumnRefExpr(i,t.ref)},r.prototype.visitMeasureRef=function(t){var r=t.source,i=r.accept(this);return r===i?t:new e.SQMeasureRefExpr(i,t.ref)},r.prototype.visitAggr=function(t){var r=t.arg,i=r.accept(this);return r===i?t:new e.SQAggregationExpr(i,t.func)},r.prototype.visitSelectRef=function(e){return e},r.prototype.visitPercentile=function(t){var r=t.arg,i=r.accept(this);return r===i?t:new e.SQPercentileExpr(i,t.k,t.exclusive)},r.prototype.visitHierarchy=function(t){var r=t.arg,i=r.accept(this);return r===i?t:new e.SQHierarchyExpr(i,t.hierarchy)},r.prototype.visitHierarchyLevel=function(t){var r=t.arg,i=r.accept(this);return r===i?t:new e.SQHierarchyLevelExpr(i,t.level)},r.prototype.visitPropertyVariationSource=function(t){var r=t.arg,i=r.accept(this);return r===i?t:new e.SQPropertyVariationSourceExpr(i,t.name,t.property)},r.prototype.visitEntity=function(e){return e},r.prototype.visitAnd=function(t){var r=t.left,i=r.accept(this),n=t.right,a=n.accept(this);return r===i&&n===a?t:new e.SQAndExpr(i,a)},r.prototype.visitBetween=function(t){var r=t.arg,i=r.accept(this),n=t.lower,a=n.accept(this),o=t.upper,u=o.accept(this);return r===i&&n===a&&o===u?t:new e.SQBetweenExpr(i,a,u)},r.prototype.visitIn=function(r){for(var i,n=r.args,a=this.rewriteAll(n),o=r.values,u=0,s=o.length;s>u;u++){var c=o[u],l=this.rewriteAll(c);c===l||i||(i=t.take(o,u)),i&&i.push(l)}return n!==a||i?new e.SQInExpr(a,i||o):r},r.prototype.rewriteAll=function(e){for(var r,i=0,n=e.length;n>i;i++){var a=e[i],o=a.accept(this);a===o||r||(r=t.take(e,i)),r&&r.push(o)}return r||e},r.prototype.visitOr=function(t){var r=t.left,i=r.accept(this),n=t.right,a=n.accept(this);return r===i&&n===a?t:new e.SQOrExpr(i,a)},r.prototype.visitCompare=function(t){var r=t.left,i=r.accept(this),n=t.right,a=n.accept(this);return r===i&&n===a?t:new e.SQCompareExpr(t.comparison,i,a)},r.prototype.visitContains=function(t){var r=t.left,i=r.accept(this),n=t.right,a=n.accept(this);return r===i&&n===a?t:new e.SQContainsExpr(i,a)},r.prototype.visitExists=function(t){var r=t.arg,i=r.accept(this);return r===i?t:new e.SQExistsExpr(i)},r.prototype.visitNot=function(t){var r=t.arg,i=r.accept(this);return r===i?t:new e.SQNotExpr(i)},r.prototype.visitStartsWith=function(t){var r=t.left,i=r.accept(this),n=t.right,a=n.accept(this);return r===i&&n===a?t:new e.SQStartsWithExpr(i,a)},r.prototype.visitConstant=function(e){return e},r.prototype.visitDateSpan=function(t){var r=t.arg,i=r.accept(this);return r===i?t:new e.SQDateSpanExpr(t.unit,i)},r.prototype.visitDateAdd=function(t){var r=t.arg,i=r.accept(this);return r===i?t:new e.SQDateAddExpr(t.unit,t.amount,i)},r.prototype.visitNow=function(e){return e},r.prototype.visitDefaultValue=function(e){return e},r.prototype.visitAnyValue=function(e){return e},r.prototype.visitArithmetic=function(t){var r=t.left,i=r.accept(this),n=t.right,a=n.accept(this);return r===i&&n===a?t:new e.SQArithmeticExpr(i,a,t.operator)},r.prototype.visitScopedEval=function(t){var r=t.expression,i=r.accept(this),n=t.scope,a=this.rewriteAll(n);return r===i&&n===a?t:new e.SQScopedEvalExpr(i,a)},r.prototype.visitFillRule=function(t){var r=t.input,i=r.accept(this),n=t.rule,a=n.linearGradient2,o=a;a&&(o=this.visitLinearGradient2(a));var u=n.linearGradient3,s=u;if(u&&(s=this.visitLinearGradient3(u)),r!==i||a!==o||u!==s){var c={};return o&&(c.linearGradient2=o),s&&(c.linearGradient3=s),new e.SQFillRuleExpr(i,c)}return t},r.prototype.visitLinearGradient2=function(e){var t=e.min,r=this.visitFillRuleStop(t),i=e.max,n=this.visitFillRuleStop(i);return t!==r||i!==n?{min:r,max:n}:e},r.prototype.visitLinearGradient3=function(e){var t=e.min,r=this.visitFillRuleStop(t),i=e.mid,n=this.visitFillRuleStop(i),a=e.max,o=this.visitFillRuleStop(a);return t!==r||i!==n||a!==o?{min:r,mid:n,max:o}:e},r.prototype.visitFillRuleStop=function(e){var t=e.color,r=e.color.accept(this),i=e.value,n=i;if(i&&(n=i.accept(this)),t!==r||i!==n){var a={color:r};return n&&(a.value=n),a}return e},r.prototype.visitResourcePackageItem=function(e){return e},r}();e.SQExprRewriter=r}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){var t;!function(t){function r(e){return e.accept(new i)}t.run=r;var i=function(t){function r(){t.call(this)}return __extends(r,t),r.prototype.visitCompare=function(t){if(t.comparison!==e.QueryComparisonKind.Equal)return this.visitUnsupported(t);if(!this.isSupported(t.left)||!this.isSupported(t.right))return this.visitUnsupported(t);var r=this.isComparand(t.left),i=this.isComparand(t.right);if(r===i)return this.visitUnsupported(t);var n=r?t.left:t.right,a=r?t.right:t.left,o=this.current;return o?(o.add(n,a),t):e.SQExprBuilder.inExpr([n],[[a]])},r.prototype.visitOr=function(e){if(!this.isSupported(e.left)||!this.isSupported(e.right))return this.visitUnsupported(e);var t;return this.current||(t=this.current=new n),e.left.accept(this),e.right.accept(this),t?(this.current=null,t.complete()||e):e},r.prototype.visitAnd=function(e){if(!this.isSupported(e.left)||!this.isSupported(e.right))return this.visitUnsupported(e);var r=this.current;return r?(r.cancel(),e):t.prototype.visitAnd.call(this,e)},r.prototype.visitUnsupported=function(e){var t=this.current;return t&&t.cancel(),e},r.prototype.isSupported=function(t){return t instanceof e.SQCompareExpr||t instanceof e.SQColumnRefExpr||t instanceof e.SQConstantExpr||t instanceof e.SQHierarchyLevelExpr||t instanceof e.SQOrExpr||t instanceof e.SQAndExpr},r.prototype.isComparand=function(t){return t instanceof e.SQColumnRefExpr||t instanceof e.SQHierarchyLevelExpr},r}(e.SQExprRewriter),n=function(){function t(){}return t.prototype.add=function(t,r){if(!this.cancelled){if(this.operand&&!e.SQExpr.equals(t,this.operand))return void this.cancel();this.operand=t;var i=this.values;i||(i=this.values=[]),i.push(r)}},t.prototype.cancel=function(){this.cancelled=!0},t.prototype.complete=function(){return!this.cancelled&&this.operand?e.SQExprBuilder.inExpr([this.operand],_.map(this.values,function(e){return[e]})):void 0},t}()}(t=e.EqualsToInRewriter||(e.EqualsToInRewriter={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){var r;!function(e){function t(e,t){var r=e.conditions(),n=r[0];if(n){var a=new i(t);if(n.accept(a))return a.getResult()}}function r(e){var t=e.expr.accept(new n);return t?t.value:void 0}e.asScopeIdsContainer=t,e.getFirstComparandValue=r}(r=t.SQExprConverter||(t.SQExprConverter={}));var i=function(r){function i(e){r.call(this),this.isRoot=!0,this.isNot=!1,this.keyExprsCount=null,this.valueExprs=[],this.fieldExprs=[];for(var i=0,n=e;i<n.length;i++){var a=n[i];this.fieldExprs.push(t.SQExprBuilder.removeEntityVariables(a))}}return __extends(i,r),i.prototype.getResult=function(){for(var t=this.valueExprs,r=[],n=this.keyExprsCount||1,a=0,o=n,u=t.length;u>a&&u>=o;){var s=t.slice(a,o),c=i.getScopeIdentity(this.fieldExprs,s);jsCommon.ArrayExtensions.isInArray(r,c,e.DataViewScopeIdentity.equals)||r.push(c),a+=n,o+=n}return{isNot:this.isNot,scopeIds:r}},i.getScopeIdentity=function(e,r){for(var i,n=0,a=e.length;a>n;n++){var o=t.SQExprBuilder.equal(e[n],r[n]);i=i?t.SQExprBuilder.and(i,o):o}return t.createDataViewScopeIdentity(i)},i.prototype.visitOr=function(e){return null!==this.keyExprsCount?this.unsupportedSQExpr():(this.isRoot=!1,e.left.accept(this)&&e.right.accept(this))},i.prototype.visitNot=function(e){return this.isRoot?(this.isNot=!0,e.arg.accept(this)):this.unsupportedSQExpr()},i.prototype.visitConstant=function(t){return this.isRoot&&t.type.primitiveType===e.PrimitiveType.Null?this.unsupportedSQExpr():(this.valueExprs.push(t),!0)},i.prototype.visitCompare=function(e){return null!==this.keyExprsCount?this.unsupportedSQExpr():(this.isRoot=!1,e.comparison!==t.QueryComparisonKind.Equal?this.unsupportedSQExpr():e.left.accept(this)&&e.right.accept(this))},i.prototype.visitIn=function(e){this.keyExprsCount=0;var t;this.isRoot=!1;for(var r=0,i=e.args;r<i.length;r++){var n=i[r];if(t=n.accept(this),!t)return this.unsupportedSQExpr();this.keyExprsCount++}if(this.keyExprsCount!==this.fieldExprs.length)return this.unsupportedSQExpr();for(var a=e.values,o=0,u=a;o<u.length;o++)for(var s=u[o],c=(s.length,0),l=s;c<l.length;c++){var p=l[c];if(t=p.accept(this),!t)return this.unsupportedSQExpr()}return t},i.prototype.visitColumnRef=function(e){if(this.isRoot)return this.unsupportedSQExpr();var r=t.SQExprBuilder.removeEntityVariables(e);return null!==this.keyExprsCount?t.SQExpr.equals(this.fieldExprs[this.keyExprsCount],r):t.SQExpr.equals(this.fieldExprs[0],r)},i.prototype.visitDefaultValue=function(e){return this.isRoot||null!==this.keyExprsCount?this.unsupportedSQExpr():(this.valueExprs.push(e),!0)},i.prototype.visitAnyValue=function(e){return this.isRoot||null!==this.keyExprsCount?this.unsupportedSQExpr():(this.valueExprs.push(e),!0)},i.prototype.visitDefault=function(e){return this.unsupportedSQExpr()},i.prototype.unsupportedSQExpr=function(){return!1},i}(t.DefaultSQExprVisitor),n=function(e){function r(){e.apply(this,arguments)}return __extends(r,e),r.prototype.visitAnd=function(e){return e.left.accept(this)||e.right.accept(this)},r.prototype.visitCompare=function(e){if(e.comparison===t.QueryComparisonKind.Equal){if(e.right instanceof t.SQConstantExpr)return e.right;if(e.left instanceof t.SQConstantExpr)return e.left}},r}(t.DefaultSQExprVisitor)}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){var t,r=jsCommon.ArrayExtensions;!function(t){function i(e){var t=new a;return e.accept(t),t.malformed?null:r.emptyToNull(t.keys)}function n(t){var i=new a;if(t.accept(i),!i.malformed){var n=r.emptyToNull(i.keys),o=r.emptyToNull(i.values);return n&&o?e.SQExprBuilder.inExpr(n,[o]):void 0}}t.getKeys=i,t.getInExpr=n;var a=function(t){function r(){t.apply(this,arguments),this.keys=[],this.values=[]}return __extends(r,t),r.prototype.visitAnd=function(e){e.left.accept(this),e.right.accept(this)},r.prototype.visitCompare=function(t){return t.comparison!==e.QueryComparisonKind.Equal?void this.visitDefault(t):(t.left.accept(this),void t.right.accept(this))},r.prototype.visitColumnRef=function(e){this.keys.push(e)},r.prototype.visitHierarchyLevel=function(e){this.keys.push(e)},r.prototype.visitConstant=function(e){this.values.push(e)},r.prototype.visitArithmetic=function(e){this.keys.push(e)},r.prototype.visitDefault=function(e){this.malformed=!0},r}(e.DefaultSQExprVisitor)}(t=e.ScopeIdentityExtractor||(e.ScopeIdentityExtractor={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){var t;!function(e){function t(e){return e+"M"}function r(e){return e+"D"}function i(e){return e+"L"}function n(e){var t=new Date(e.getTime()-6e4*e.getTimezoneOffset()),r=t.toISOString();return jsCommon.StringExtensions.endsWith(r,"Z")&&(r=r.substr(0,r.length-1)),"datetime'"+r+"'"}function a(e){return"'"+e.replace(s,"''")+"'"}function o(){return"null"}function u(e){return e?"true":"false"}var s=/'/g;e.decimal=t,e["double"]=r,e.integer=i,e.dateTime=n,e.text=a,e.nullEncoding=o,e["boolean"]=u}(t=e.PrimitiveValueEncoding||(e.PrimitiveValueEncoding={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){function r(e){return new a(e)}function i(e,r){var i=t.SQExprBuilder.removeAggregate(e).getMetadata(r);return i||(i=e.getMetadata(r)),i}var n=e.data.QueryAggregateFunction;t.createSQAggregationOperations=r;var a=function(){function r(e){this.datetimeMinMaxSupported=e}return r.prototype.getSupportedAggregates=function(r,a,o){var u=i(r,a);if(!u)return[];var s=u.type,c=u.kind,l=u.idOnEntityKey;if(!s)return[];if(1===c)return[];if(s.numeric||s.integer){var p=[n.Sum,n.Avg,n.Min,n.Max,n.Count,n.CountNonNull,n.StandardDeviation,n.Variance],f=t.SQExprConverter.asFieldPattern(r),v=t.FieldExprPattern.toFieldExprEntityItemPattern(f),h=a.schema(v.schema);return h.capabilities.supportsMedian&&p.push(n.Median),p}var g=[];this.datetimeMinMaxSupported&&s.dateTime&&(_.isEmpty(o)||e.ValueType.isCompatibleTo(s,o))&&(g.push(n.Min),g.push(n.Max));var d=t.SQExprInfo.getAggregate(r)===n.Count;return l&&!d||g.push(n.Count),g.push(n.CountNonNull),g},r.prototype.isSupportedAggregate=function(e,t,r,i){var n=this.getSupportedAggregates(e,t,i);return _.contains(n,r)},r.prototype.createExprWithAggregate=function(e,r,i,n,a){var o;return o=null!=a&&this.isSupportedAggregate(e,r,a,n)?a:e.getDefaultAggregate(r,i),void 0!==o&&(e=t.SQExprBuilder.aggregate(e,o)),e},r}()}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){var t;!function(t){function a(r,i){var n=e.FieldExprPattern.toFieldExprEntityItemPattern(i),a=i.hierarchyLevel||i.hierarchyLevelAggr;return a?t.getConceptualHierarchyLevel(r,n.schema,n.entity,a.name,a.level):void 0}function o(e,t,r,i,n){var a=e.schema(t),o=a.findHierarchy(r,i);return o?o.levels.withName(n):void 0}function u(t,r){if(t instanceof e.SQHierarchyExpr){var i=t;if(t.arg instanceof e.SQEntityExpr){var n=t.arg;return r.schema(n.schema).findHierarchy(n.entity,i.hierarchy)}if(t.arg instanceof e.SQPropertyVariationSourceExpr){var a=t.arg,o=a.arg;return r.schema(o.schema).findHierarchyByVariation(o.entity,a.property,a.name,i.hierarchy)}}}function s(e,t,a){return r.convert(t,e)||n.expand(t,e)||!a&&i.expand(t,e)||t}function c(t,r){if(r instanceof e.SQHierarchyExpr||r instanceof e.SQHierarchyLevelExpr)return!0;var i=r.getConceptualProperty(t);if(i){var n=i.column;if(n&&n.variations&&n.variations.length>0)return!0}return!1}function l(t){var r=e.SQExprConverter.asFieldPattern(t);if(r.columnHierarchyLevelVariation){var i=e.SQExprBuilder.entity(r.columnHierarchyLevelVariation.source.schema,r.columnHierarchyLevelVariation.source.entity);return e.SQExprBuilder.columnRef(i,r.columnHierarchyLevelVariation.source.name)}}function p(t){var r=e.SQExprConverter.asFieldPattern(t),i=r.hierarchyLevel;if(i){var n=e.SQExprBuilder.entity(i.schema,i.entity,i.entityVar);return e.SQExprBuilder.hierarchy(n,i.name)}}function f(t){if(t.arg instanceof e.SQHierarchyExpr){var r=t.arg;return r.arg instanceof e.SQPropertyVariationSourceExpr?r.arg:void 0}}function v(t,r,i){if(!(r instanceof e.SQHierarchyLevelExpr&&i instanceof e.SQHierarchyLevelExpr))return!1;var n=r,a=i;if(!e.SQExpr.equals(n.arg,a.arg))return!1;var o=e.SQExprUtils.indexOfExpr(t,n),u=e.SQExprUtils.indexOfExpr(t,a);return-1!==o&&-1!==u&&u>o}function h(e,t,r){for(var i=0;i<t.length&&v(e,t[i],r);)i++;return i}t.getConceptualHierarchyLevelFromExpr=a,t.getConceptualHierarchyLevel=o,t.getConceptualHierarchy=u,t.expandExpr=s,t.isHierarchyOrVariation=c,t.getSourceVariationExpr=l,t.getSourceHierarchy=p,t.getHierarchySourceAsVariationSource=f,t.areHierarchyLevelsOrdered=v,t.getInsertionIndex=h}(t=e.SQHierarchyExprUtils||(e.SQHierarchyExprUtils={}));var r;!function(r){function i(r,i){if(r instanceof e.SQHierarchyExpr){var n=r,a=t.getConceptualHierarchy(n,i);if(a)return _.map(a.levels,function(t){return e.SQExprBuilder.hierarchyLevel(r,t.name)})}}r.convert=i}(r=e.SQExprHierarchyToHierarchyLevelConverter||(e.SQExprHierarchyToHierarchyLevelConverter={}));var i;!function(t){function r(t,r){var i=[];if(t instanceof e.SQHierarchyLevelExpr){var n=e.SQExprConverter.asFieldPattern(t);if(n.hierarchyLevel){var a=e.FieldExprPattern.toFieldExprEntityItemPattern(n),o=r.schema(a.schema).findHierarchy(a.entity,n.hierarchyLevel.name);if(o)for(var u=o.levels,s=0,c=u;s<c.length;s++){var l=c[s];if(l.name===n.hierarchyLevel.level){i.push(t);break}i.push(e.SQExprBuilder.hierarchyLevel(e.SQExprBuilder.hierarchy(e.SQExprBuilder.entity(a.schema,a.entity,a.entityVar),o.name),l.name))}}}return _.isEmpty(i)?void 0:i}t.expand=r}(i||(i={}));var n;!function(t){function r(t,r){var i,n=t.getConceptualProperty(r);if(n){var a=n.column;if(a&&a.variations&&a.variations.length>0){var o=a.variations,u=o[0],s=e.SQExprConverter.asFieldPattern(t),c=e.FieldExprPattern.toFieldExprEntityItemPattern(s);if(i=[],u.defaultHierarchy)for(var l=e.SQExprBuilder.hierarchy(e.SQExprBuilder.propertyVariationSource(e.SQExprBuilder.entity(c.schema,c.entity,c.entityVar),u.name,n.name),u.defaultHierarchy.name),p=0,f=u.defaultHierarchy.levels;p<f.length;p++){var v=f[p];i.push(e.SQExprBuilder.hierarchyLevel(l,v.name))}}}return i}t.expand=r}(n||(n={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){var t;!function(t){function r(t,r){for(var n=[],a=0,o=r.length;o>a;a++){var u=r[a];u instanceof e.SQHierarchyLevelExpr?i(t,n,u,a):n.push({expr:u,children:null,selectQueryIndex:a})}return n}function i(t,r,i,n){var a=!0,o=e.SQHierarchyExprUtils.getSourceVariationExpr(i)||e.SQHierarchyExprUtils.getSourceHierarchy(i),u=_.last(r);if(u&&u.children&&e.SQExpr.equals(u.expr,o)){var s=e.SQHierarchyExprUtils.expandExpr(t,i.arg);if(s instanceof Array){var c=s;a=!e.SQHierarchyExprUtils.areHierarchyLevelsOrdered(c,_.last(u.children),i)}}a?r.push({expr:o,children:[i],selectQueryIndex:n}):u.children.push(i)}t.groupExprs=r}(t=e.SQExprGroupUtils||(e.SQExprGroupUtils={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){function r(e){return e.integer||e.numeric?t.QueryAggregateFunction.Sum:t.QueryAggregateFunction.Count}function i(e){switch(e){case 6:return t.QueryAggregateFunction.Avg;case 3:return t.QueryAggregateFunction.CountNonNull;case 7:return t.QueryAggregateFunction.Count;case 5:return t.QueryAggregateFunction.Max;case 4:return t.QueryAggregateFunction.Min;case 2:return t.QueryAggregateFunction.Sum;default:return}}var n=jsCommon.StringExtensions,a=function(){function n(e){this._kind=e}return n.equals=function(e,t,r){return U.run(e,t,r)},n.prototype.validate=function(e,t,r){var i=new L(e,t,r);return this.accept(i),i.errors},n.prototype.accept=function(e,t){},Object.defineProperty(n.prototype,"kind",{get:function(){return this._kind},enumerable:!0,configurable:!0}),n.isColumn=function(e){return 1===e.kind},n.isConstant=function(e){return 16===e.kind},n.isEntity=function(e){return 0===e.kind},n.isHierarchy=function(e){return 5===e.kind},n.isHierarchyLevel=function(e){return 6===e.kind},n.isAggregation=function(e){return 3===e.kind},n.isMeasure=function(e){return 2===e.kind},n.isSelectRef=function(e){return 28===e.kind},n.isResourcePackageItem=function(e){return 24===e.kind},n.prototype.getMetadata=function(e){var r=t.SQExprConverter.asFieldPattern(this);if(r)return r.column||r.columnAggr||r.measure?this.getMetadataForProperty(r,e):r.hierarchyLevel||r.hierarchyLevelAggr?this.getMetadataForHierarchyLevel(r,e):r.columnHierarchyLevelVariation?this.getMetadataForVariation(r,e):r.percentOfGrandTotal?this.getMetadataForPercentOfGrandTotal():n.getMetadataForEntity(r,e)},n.prototype.getDefaultAggregate=function(e,n){void 0===n&&(n=!1);var a=this.getConceptualProperty(e)||this.getHierarchyLevelConceptualProperty(e);if(a){var o;if(a&&0===a.kind){var u=a.column?a.column.defaultAggregate:null;(a.type.integer||a.type.numeric)&&1!==u&&(o=i(u),void 0===o&&(o=r(a.type))),void 0===o&&n&&(o=t.QueryAggregateFunction.CountNonNull)}return o}},n.prototype.getKeyColumns=function(e){var t=H.getColumnRefSQExpr(e,this);if(t){var r=[],i=this.getPropertyKeys(e);if(i&&i.length>0)for(var n=0,a=i.length;a>n;n++)r.push(O.columnRef(t.source,i[n].name));else r.push(t);return r}},n.prototype.hasGroupOnKeys=function(e){var t=H.getColumnRefSQExpr(e,this);if(t){var r=this.getPropertyKeys(e);if(!r||r.length<1)return!1;if(r.length>1)return!0;var i=O.columnRef(t.source,r[0].name);return!n.equals(i,this)}},n.prototype.getPropertyKeys=function(e){var t=this.getConceptualProperty(e)||this.getHierarchyLevelConceptualProperty(e);if(t)return t.column?t.column.keys:void 0},n.prototype.getConceptualProperty=function(e){var r=t.SQExprConverter.asFieldPattern(this);if(r){var i=t.FieldExprPattern.toFieldExprEntityItemPattern(r),n=t.FieldExprPattern.getPropertyName(r);return n?e.schema(i.schema).findProperty(i.entity,n):void 0}},n.prototype.getTargetEntityForVariation=function(e,t){var r=this.getConceptualProperty(e);if(r&&r.column&&!_.isEmpty(r.column.variations))for(var i=r.column.variations,n=0,a=i;n<a.length;n++){var o=a[n];if(o.name===t)return o.navigationProperty.targetEntity.name}},n.prototype.getTargetEntity=function(e){return k.getEntityExpr(e,this)},n.prototype.getHierarchyLevelConceptualProperty=function(e){var r=t.SQExprConverter.asFieldPattern(this);if(r){var i=r.hierarchyLevel||r.hierarchyLevelAggr;if(i){var n=t.FieldExprPattern.toFieldExprEntityItemPattern(r),a=e.schema(n.schema).findHierarchy(n.entity,i.name);if(a){var o=a.levels.withName(i.level);if(o)return o.column}}}},n.prototype.getMetadataForVariation=function(e,r){var i=e.columnHierarchyLevelVariation,n=t.FieldExprPattern.toFieldExprEntityItemPattern(e),a=r.schema(n.schema).findProperty(n.entity,i.source.name);if(a&&a.column&&a.column.variations)for(var o=0,u=a.column.variations;o<u.length;o++){var s=u[o];if(s.defaultHierarchy&&s.defaultHierarchy.levels)for(var c=0,l=s.defaultHierarchy.levels;c<l.length;c++){var p=l[c];if(p.name===i.level.level){var f=p.column;return{kind:1===f.kind?1:0,type:f.type,format:f.format,idOnEntityKey:f.column?f.column.idOnEntityKey:!1,defaultAggregate:f.column?f.column.defaultAggregate:null}}}}},n.prototype.getMetadataForHierarchyLevel=function(e,t){var r=this.getHierarchyLevelConceptualProperty(t);if(r)return this.getPropertyMetadata(e,r)},n.prototype.getMetadataForPercentOfGrandTotal=function(){return{kind:1,format:"#,##0.##%",type:e.ValueType.fromExtendedType(e.ExtendedType.Double)}},n.prototype.getPropertyMetadata=function(r,i){var n=i.format,a=i.type,o=r.columnAggr||r.hierarchyLevelAggr;if(o)switch(o.aggregate){case t.QueryAggregateFunction.Count:case t.QueryAggregateFunction.CountNonNull:a=e.ValueType.fromExtendedType(e.ExtendedType.Integer),n=void 0;break;case t.QueryAggregateFunction.Avg:a.integer&&(a=e.ValueType.fromExtendedType(e.ExtendedType.Double))}return{kind:1===i.kind||o&&void 0!==o.aggregate?1:0,type:a,format:n,idOnEntityKey:i.column?i.column.idOnEntityKey:!1,aggregate:o?o.aggregate:void 0,defaultAggregate:i.column?i.column.defaultAggregate:null}},n.prototype.getMetadataForProperty=function(e,t){var r=this.getConceptualProperty(t);if(r)return this.getPropertyMetadata(e,r)},n.getMetadataForEntity=function(r,i){var n=t.FieldExprPattern.toFieldExprEntityItemPattern(r),a=i.schema(n.schema).entities.withName(n.entity);if(a&&r.entityAggr)switch(r.entityAggr.aggregate){case t.QueryAggregateFunction.Count:case t.QueryAggregateFunction.CountNonNull:return{kind:1,type:e.ValueType.fromExtendedType(e.ExtendedType.Integer),format:void 0,idOnEntityKey:!1,aggregate:r.entityAggr.aggregate}}},n}();t.SQExpr=a,t.defaultAggregateForDataType=r,t.defaultAggregateToQueryAggregateFunction=i;var o=function(e){function t(t,r,i){e.call(this,0),this.schema=t,this.entity=r,i&&(this.variable=i)}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitEntity(this,t)},t}(a);t.SQEntityExpr=o;var u=function(e){function t(t,r,i){e.call(this,22),this.left=t,this.right=r,this.operator=i}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitArithmetic(this,t)},t}(a);t.SQArithmeticExpr=u;var s=function(e){function t(t,r){e.call(this,25),this.expression=t,this.scope=r}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitScopedEval(this,t)},t.prototype.getMetadata=function(e){return this.expression.getMetadata(e)},t}(a);t.SQScopedEvalExpr=s;var c=function(e){function t(t,r,i){e.call(this,t),this.source=r,this.ref=i}return __extends(t,e),t}(a);t.SQPropRefExpr=c;var l=function(e){function t(t,r){e.call(this,1,t,r)}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitColumnRef(this,t)},t}(c);t.SQColumnRefExpr=l;var p=function(e){function t(t,r){e.call(this,2,t,r)}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitMeasureRef(this,t)},t}(c);t.SQMeasureRefExpr=p;var f=function(e){function t(t,r){e.call(this,3),this.arg=t,this.func=r}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitAggr(this,t)},t}(a);t.SQAggregationExpr=f;var v=function(e){function t(t,r,i){e.call(this,27),this.arg=t,this.k=r,this.exclusive=i}return __extends(t,e),t.prototype.getMetadata=function(e){var t=this.arg.getMetadata(e);return t?{kind:1,type:t.type}:void 0},t.prototype.accept=function(e,t){return e.visitPercentile(this,t)},t}(a);t.SQPercentileExpr=v;var h=function(e){function t(t,r,i){e.call(this,4),this.arg=t,this.name=r,this.property=i}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitPropertyVariationSource(this,t)},t}(a);t.SQPropertyVariationSourceExpr=h;var g=function(e){function t(t,r){e.call(this,5),this.arg=t,this.hierarchy=r}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitHierarchy(this,t)},t}(a);t.SQHierarchyExpr=g;var d=function(e){function t(t,r){e.call(this,6),this.arg=t,this.level=r}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitHierarchyLevel(this,t)},t}(a);t.SQHierarchyLevelExpr=d;var y=function(e){function t(t){e.call(this,28),this.expressionName=t}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitSelectRef(this,t)},t}(a);t.SQSelectRefExpr=y;var m=function(e){function t(t,r){e.call(this,7),this.left=t,this.right=r}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitAnd(this,t)},t}(a);t.SQAndExpr=m;var x=function(e){function t(t,r,i){e.call(this,8),this.arg=t,this.lower=r,this.upper=i}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitBetween(this,t)},t}(a);t.SQBetweenExpr=x;var S=function(e){function t(t,r){e.call(this,9),this.args=t,this.values=r}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitIn(this,t)},t}(a);t.SQInExpr=S;var E=function(e){function t(t,r){e.call(this,10),this.left=t,this.right=r}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitOr(this,t)},t}(a);t.SQOrExpr=E;var w=function(e){function t(t,r,i){e.call(this,12),this.comparison=t,this.left=r,this.right=i}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitCompare(this,t)},t}(a);t.SQCompareExpr=w;var b=function(e){function t(t,r){e.call(this,11),this.left=t,this.right=r}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitContains(this,t)},t}(a);t.SQContainsExpr=b;var D=function(e){function t(t,r){e.call(this,13),this.left=t,this.right=r}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitStartsWith(this,t)},t}(a);t.SQStartsWithExpr=D;var C=function(e){function t(t){e.call(this,14),this.arg=t}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitExists(this,t)},t}(a);t.SQExistsExpr=C;var T=function(e){function t(t){e.call(this,15),this.arg=t}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitNot(this,t)},t}(a);t.SQNotExpr=T;var V=function(e){function t(t,r,i){e.call(this,16),this.type=t,this.value=r,this.valueEncoded=i}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitConstant(this,t)},t.prototype.getMetadata=function(e){return{kind:1,type:this.type}},t}(a);t.SQConstantExpr=V;var F=function(e){function t(t,r){e.call(this,17),this.unit=t,this.arg=r}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitDateSpan(this,t)},t}(a);t.SQDateSpanExpr=F;var P=function(e){function t(t,r,i){e.call(this,18),this.unit=t,this.arg=i,this.amount=r}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitDateAdd(this,t)},t}(a);t.SQDateAddExpr=P;var M=function(e){function t(){e.call(this,19)}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitNow(this,t)},t}(a);t.SQNowExpr=M;var R=function(e){function t(){e.call(this,21)}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitDefaultValue(this,t)},t}(a);t.SQDefaultValueExpr=R;var A=function(e){function t(){e.call(this,20)}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitAnyValue(this,t)},t}(a);t.SQAnyValueExpr=A;var N=function(e){function t(t,r){e.call(this,23),this.input=t,this.rule=r}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitFillRule(this,t)},t}(a);t.SQFillRuleExpr=N;var I=function(e){function t(t,r,i){e.call(this,24),this.packageName=t,this.packageType=r,this.itemName=i}return __extends(t,e),t.prototype.accept=function(e,t){return e.visitResourcePackageItem(this,t)},t}(a);t.SQResourcePackageItemExpr=I;var O;!function(r){function i(e,t,r){return new o(e,t,r)}function n(e,t){return new l(e,t)}function c(e,t){return new p(e,t)}function O(e,t){return new f(e,t)}function Q(e){return new y(e)}function U(e,t,r){return new v(e,t,r)}function j(e,t,r){return new u(e,t,r)}function L(e,t){return new s(e,t)}function q(e,t){return new g(e,t)}function H(e,t,r){return new h(e,t,r)}function k(e,t){return new d(e,t)}function B(e,t){return e?t?new m(e,t):e:t}function Y(e,t,r){return new x(e,t,r)}function Z(e,t){return new S(e,t)}function J(e,t){if(!e)return t;if(!t)return e;if(e instanceof S&&t instanceof S){var r=$(e,t);if(r)return r}return new E(e,t)}function $(e,t){if(e.args&&t.args){var i=e.args.length,n=t.args.length;if(i===n){for(var o=0;i>o;++o)if(!a.equals(e.args[o],t.args[o]))return;var u=e.values.concat(t.values);return r.inExpr(e.args,u)}}}function ee(e,t,r){return new w(e,t,r)}function te(e,t){return new b(e,t)}function re(e){return new C(e)}function ie(e,r){return ee(t.QueryComparisonKind.Equal,e,r)}function ne(e){return new T(e)}function ae(e,t){return new D(e,t)}function oe(){return new V(e.ValueType.fromExtendedType(e.ExtendedType.Null),null,t.PrimitiveValueEncoding.nullEncoding())}function ue(){return new M}function se(){return new R}function ce(){return new A}function le(r){return new V(e.ValueType.fromExtendedType(e.ExtendedType.Boolean),r,t.PrimitiveValueEncoding["boolean"](r))}function pe(e,t,r){return new P(e,t,r)}function fe(r,i){return void 0===i&&(i=t.PrimitiveValueEncoding.dateTime(r)),new V(e.ValueType.fromExtendedType(e.ExtendedType.DateTime),r,i)}function ve(e,t){return new F(e,t)}function he(r,i){return void 0===i&&(i=t.PrimitiveValueEncoding.decimal(r)),new V(e.ValueType.fromExtendedType(e.ExtendedType.Decimal),r,i)}function ge(r,i){return void 0===i&&(i=t.PrimitiveValueEncoding["double"](r)),new V(e.ValueType.fromExtendedType(e.ExtendedType.Double),r,i)}function de(r,i){return void 0===i&&(i=t.PrimitiveValueEncoding.integer(r)),
6new V(e.ValueType.fromExtendedType(e.ExtendedType.Integer),r,i)}function ye(r,i){return new V(e.ValueType.fromExtendedType(e.ExtendedType.Text),r,i||t.PrimitiveValueEncoding.text(r))}function me(t,r){return null==t?oe():_.isBoolean(t)?le(t):_.isString(t)?ye(t):_.isNumber(t)?r.integer&&e.Double.isInteger(t)?de(t):ge(t):t instanceof Date?fe(t):void 0}function xe(e,t){return G.rewrite(e,t)}function Se(e){return W.rewrite(e)}function Ee(e){return X.rewrite(e)}function we(e){return z.rewrite(e)}function be(e){return K.rewrite(e)}function De(e,t){return new N(e,t)}function Ce(e,t,r){return new I(e,t,r)}r.entity=i,r.columnRef=n,r.measureRef=c,r.aggregate=O,r.selectRef=Q,r.percentile=U,r.arithmetic=j,r.scopedEval=L,r.hierarchy=q,r.propertyVariationSource=H,r.hierarchyLevel=k,r.and=B,r.between=Y,r.inExpr=Z,r.or=J,r.compare=ee,r.contains=te,r.exists=re,r.equal=ie,r.not=ne,r.startsWith=ae,r.nullConstant=oe,r.now=ue,r.defaultValue=se,r.anyValue=ce,r["boolean"]=le,r.dateAdd=pe,r.dateTime=fe,r.dateSpan=ve,r.decimal=he,r["double"]=ge,r.integer=de,r.text=ye,r.typedConstant=me,r.setAggregate=xe,r.removeAggregate=Se,r.setPercentOfGrandTotal=Ee,r.removePercentOfGrandTotal=we,r.removeEntityVariables=be,r.fillRule=De,r.resourcePackageItem=Ce}(O=t.SQExprBuilder||(t.SQExprBuilder={}));var Q;!function(e){function t(e){return q.getAggregate(e)}e.getAggregate=t}(Q=t.SQExprInfo||(t.SQExprInfo={}));var U=function(){function e(e){this.ignoreCase=e}return e.run=function(t,r,i){return t=t||null,r=r||null,t===r?!0:!t!=!r?!1:i?t.accept(e.ignoreCaseInstance,r):t.accept(e.instance,r)},e.prototype.visitColumnRef=function(e,t){return t instanceof l&&e.ref===t.ref&&this.equals(e.source,t.source)},e.prototype.visitMeasureRef=function(e,t){return t instanceof p&&e.ref===t.ref&&this.equals(e.source,t.source)},e.prototype.visitAggr=function(e,t){return t instanceof f&&e.func===t.func&&this.equals(e.arg,t.arg)},e.prototype.visitPercentile=function(e,t){return t instanceof v&&e.exclusive===t.exclusive&&e.k===t.k&&this.equals(e.arg,t.arg)},e.prototype.visitHierarchy=function(e,t){return t instanceof g&&e.hierarchy===t.hierarchy&&this.equals(e.arg,t.arg)},e.prototype.visitHierarchyLevel=function(e,t){return t instanceof d&&e.level===t.level&&this.equals(e.arg,t.arg)},e.prototype.visitPropertyVariationSource=function(e,t){return t instanceof h&&e.name===t.name&&e.property===t.property&&this.equals(e.arg,t.arg)},e.prototype.visitSelectRef=function(e,t){return t instanceof y&&e.expressionName===t.expressionName},e.prototype.visitBetween=function(e,t){return t instanceof x&&this.equals(e.arg,t.arg)&&this.equals(e.lower,t.lower)&&this.equals(e.upper,t.upper)},e.prototype.visitIn=function(e,t){if(!(t instanceof S&&this.equalsAll(e.args,t.args)))return!1;var r=e.values,i=t.values;if(r.length!==i.length)return!1;for(var n=0,a=r.length;a>n;n++)if(!this.equalsAll(r[n],i[n]))return!1;return!0},e.prototype.visitEntity=function(e,t){return t instanceof o&&e.schema===t.schema&&e.entity===t.entity&&this.optionalEqual(e.variable,t.variable)},e.prototype.visitAnd=function(e,t){return t instanceof m&&this.equals(e.left,t.left)&&this.equals(e.right,t.right)},e.prototype.visitOr=function(e,t){return t instanceof E&&this.equals(e.left,t.left)&&this.equals(e.right,t.right)},e.prototype.visitCompare=function(e,t){return t instanceof w&&e.comparison===t.comparison&&this.equals(e.left,t.left)&&this.equals(e.right,t.right)},e.prototype.visitContains=function(e,t){return t instanceof b&&this.equals(e.left,t.left)&&this.equals(e.right,t.right)},e.prototype.visitDateSpan=function(e,t){return t instanceof F&&e.unit===t.unit&&this.equals(e.arg,t.arg)},e.prototype.visitDateAdd=function(e,t){return t instanceof P&&e.unit===t.unit&&e.amount===t.amount&&this.equals(e.arg,t.arg)},e.prototype.visitExists=function(e,t){return t instanceof C&&this.equals(e.arg,t.arg)},e.prototype.visitNot=function(e,t){return t instanceof T&&this.equals(e.arg,t.arg)},e.prototype.visitNow=function(e,t){return t instanceof M},e.prototype.visitDefaultValue=function(e,t){return t instanceof R},e.prototype.visitAnyValue=function(e,t){return t instanceof A},e.prototype.visitResourcePackageItem=function(e,t){return t instanceof I&&e.packageName===t.packageName&&e.packageType===t.packageType&&e.itemName===t.itemName},e.prototype.visitStartsWith=function(e,t){return t instanceof D&&this.equals(e.left,t.left)&&this.equals(e.right,t.right)},e.prototype.visitConstant=function(e,t){return t instanceof V&&e.type===t.type?e.type.text&&this.ignoreCase?n.equalIgnoreCase(e.valueEncoded,t.valueEncoded):e.valueEncoded===t.valueEncoded:!1},e.prototype.visitFillRule=function(e,t){if(t instanceof N&&this.equals(e.input,t.input)){var r=e.rule,i=t.rule;if(r===i)return!0;var n=r.linearGradient2,a=i.linearGradient2;if(n&&a)return this.visitLinearGradient2(n,a);var o=r.linearGradient3,u=i.linearGradient3;if(o&&u)return this.visitLinearGradient3(o,u)}return!1},e.prototype.visitLinearGradient2=function(e,t){return this.equalsFillRuleStop(e.min,t.min)&&this.equalsFillRuleStop(e.max,t.max)},e.prototype.visitLinearGradient3=function(e,t){return this.equalsFillRuleStop(e.min,t.min)&&this.equalsFillRuleStop(e.mid,t.mid)&&this.equalsFillRuleStop(e.max,t.max)},e.prototype.equalsFillRuleStop=function(e,t){return this.equals(e.color,t.color)?e.value?this.equals(e.value,t.value):e.value===t.value:!1},e.prototype.visitArithmetic=function(e,t){return t instanceof u&&e.operator===t.operator&&this.equals(e.left,t.left)&&this.equals(e.right,t.right)},e.prototype.visitScopedEval=function(e,t){return t instanceof s&&this.equals(e.expression,t.expression)&&this.equalsAll(e.scope,t.scope)},e.prototype.optionalEqual=function(e,t){return e&&t?e===t:!0},e.prototype.equals=function(e,t){return e.accept(this,t)},e.prototype.equalsAll=function(e,t){var r=e.length;if(r!==t.length)return!1;for(var i=0;r>i;i++)if(!this.equals(e[i],t[i]))return!1;return!0},e.instance=new e(!1),e.ignoreCaseInstance=new e(!0),e}(),j=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.visitDefault=function(e){return e},t}(t.DefaultSQExprVisitor),L=function(e){function r(t,r,i){e.call(this),this.schema=t,this.aggrUtils=r,i&&(this.errors=i)}return __extends(r,e),r.prototype.visitIn=function(t){for(var r=e.prototype.visitIn.call(this,t),i=r.args,n=r.values,a=0,o=n;a<o.length;a++)for(var u=o[a],s=0,c=u.length;c>s;++s)this.validateCompatibleType(i[s],u[s]);return r},r.prototype.visitCompare=function(t){var r=e.prototype.visitCompare.call(this,t);return this.validateCompatibleType(r.left,r.right),r},r.prototype.visitColumnRef=function(e){var r=t.SQExprConverter.asFieldPattern(e);if(r){var i=t.FieldExprPattern.toFieldExprEntityItemPattern(r),n=this.validateEntity(i.schema,i.entity);if(n){var a=n.properties.withName(r.column.name);a&&0===a.kind&&this.isQueryable(r)||this.register(3)}}return e},r.prototype.visitMeasureRef=function(e){var r=t.SQExprConverter.asFieldPattern(e);if(r){var i=t.FieldExprPattern.toFieldExprEntityItemPattern(r),n=this.validateEntity(i.schema,i.entity);if(n){var a=n.properties.withName(r.measure.name);a&&1===a.kind&&this.isQueryable(r)||this.register(4)}}return e},r.prototype.visitAggr=function(t){var r=e.prototype.visitAggr.call(this,t),i=H.getColumnRefSQExpr(this.schema,r.arg);return i&&(this.aggrUtils.isSupportedAggregate(t,this.schema,t.func,null)||this.register(0)),r},r.prototype.visitHierarchy=function(e){var r=t.SQExprConverter.asFieldPattern(e);if(r){var i=r.hierarchy;i?this.validateHierarchy(i.schema,i.entity,i.name):this.register(5)}return e},r.prototype.visitHierarchyLevel=function(e){var r=t.SQExprConverter.asFieldPattern(e);if(r){var i=r.hierarchyLevel;i?this.validateHierarchyLevel(i.schema,i.entity,i.name,i.level):r.columnHierarchyLevelVariation||this.register(6)}return e},r.prototype.visitPercentile=function(e){if(e.arg.accept(this),_.isEmpty(this.errors)){var t=e.arg.getMetadata(this.schema);t&&0===t.kind&&t.type&&(t.type.integer||t.type.numeric)||this.register(10)}return e},r.prototype.visitEntity=function(e){return this.validateEntity(e.schema,e.entity),e},r.prototype.visitContains=function(e){return this.validateOperandsAndTypeForStartOrContains(e.left,e.right),e},r.prototype.visitStartsWith=function(e){return this.validateOperandsAndTypeForStartOrContains(e.left,e.right),e},r.prototype.visitArithmetic=function(e){return this.validateArithmeticTypes(e.left,e.right),e},r.prototype.visitScopedEval=function(e){return e},r.prototype.validateOperandsAndTypeForStartOrContains=function(e,t){e instanceof l?this.visitColumnRef(e):e instanceof d?this.visitHierarchyLevel(e):this.register(7),t instanceof V&&t.type.text?this.validateCompatibleType(e,t):this.register(8)},r.prototype.validateArithmeticTypes=function(e,r){t.SQExprUtils.supportsArithmetic(e,this.schema)||this.register(7),t.SQExprUtils.supportsArithmetic(r,this.schema)||this.register(8)},r.prototype.validateCompatibleType=function(e,t){var r=e.getMetadata(this.schema),i=r&&r.type,n=t.getMetadata(this.schema),a=n&&n.type;i&&a&&!i.isCompatibleFrom(a)&&this.register(9)},r.prototype.validateEntity=function(e,t){var r=this.schema.schema(e);if(r){var i=r.entities.withName(t);if(i)return i;this.register(2)}else this.register(1)},r.prototype.validateHierarchy=function(e,t,r){var i=this.validateEntity(e,t);if(i){var n=i.hierarchies.withName(r);if(n)return n;this.register(5)}},r.prototype.validateHierarchyLevel=function(e,t,r,i){var n=this.validateHierarchy(e,t,r);if(n){var a=n.levels.withName(i);if(a)return a;this.register(6)}},r.prototype.register=function(e){this.errors||(this.errors=[]),this.errors.push(e)},r.prototype.isQueryable=function(e){var r=t.FieldExprPattern.toFieldExprEntityItemPattern(e);if(e.hierarchyLevel||e.hierarchyLevelAggr){var i=t.SQHierarchyExprUtils.getConceptualHierarchyLevelFromExpr(this.schema,e);return i&&1!==i.column.queryable}return 1!==this.schema.schema(r.schema).findProperty(r.entity,t.FieldExprPattern.getPropertyName(e)).queryable},r}(t.SQExprRewriter);t.SQExprValidationVisitor=L;var q=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.visitAggr=function(e){return e.func},t.prototype.visitDefault=function(e){},t.getAggregate=function(e){var r=new t;return e.accept(r)},t}(t.DefaultSQExprVisitor),H=function(e){function r(t){e.call(this),this.schema=t}return __extends(r,e),r.prototype.visitColumnRef=function(e){return e},r.prototype.visitHierarchyLevel=function(e){var r=e.level,i=e.arg,n=i.accept(this);if(i&&i.arg instanceof h){var a=i.arg,o=n.getTargetEntityForVariation(this.schema,a.name);if(n&&o){var u=n.source.schema,s=O.entity(u,o),c=this.schema.schema(u).findHierarchy(o,i.hierarchy);if(c)for(var p=0,f=c.levels;p<f.length;p++){var v=f[p];if(v.name===r)return new l(s,v.column.name)}}}else{var g=i.arg,d=t.SQHierarchyExprUtils.getConceptualHierarchyLevel(this.schema,g.schema,g.entity,i.hierarchy,e.level);if(d)return new l(i.arg,d.column.name)}},r.prototype.visitHierarchy=function(e){return e.arg.accept(this)},r.prototype.visitPropertyVariationSource=function(e){var t=e.property;return new l(e.arg,t)},r.prototype.visitAggr=function(e){return e.arg.accept(this)},r.prototype.visitDefault=function(e){},r.getColumnRefSQExpr=function(e,t){var i=new r(e);return t.accept(i)},r}(t.DefaultSQExprVisitor),k=function(e){function r(t){e.call(this),this.schema=t}return __extends(r,e),r.prototype.visitEntity=function(e){return e},r.prototype.visitColumnRef=function(e){return r.getEntity(e)},r.prototype.visitHierarchyLevel=function(e){var t=r.getColumnRefSQExpr(this.schema,e);return r.getEntity(t)},r.prototype.visitHierarchy=function(e){return e.arg.accept(this)},r.prototype.visitPropertyVariationSource=function(e){var t=r.getColumnRefSQExpr(this.schema,e);return r.getEntity(t)},r.prototype.visitAggr=function(e){var t=r.getColumnRefSQExpr(this.schema,e);return r.getEntity(t)},r.prototype.visitMeasureRef=function(e){return e.source.accept(this)},r.getColumnRefSQExpr=function(e,t){var r=new H(e);return t.accept(r)},r.getEntity=function(e){var r=t.SQExprConverter.asFieldPattern(e),i=r.column;return O.entity(i.schema,i.entity,i.entityVar)},r.getEntityExpr=function(e,t){var i=new r(e);return t.accept(i)},r}(t.DefaultSQExprVisitor),B=function(e){function t(t){e.call(this),this.func=t}return __extends(t,e),t.prototype.visitAggr=function(e){return e.func===this.func?e:new f(e.arg,this.func)},t.prototype.visitColumnRef=function(e){return new f(e,this.func)},t.rewrite=function(e,r){var i=new t(r);return e.accept(i)},t}(j),G=function(){function e(e,t){this.sqExpr=e,this.aggregate=t}return e.rewrite=function(r,i){return t.FieldExprPattern.visit(r,new e(r,i))},e.prototype.visitPercentOfGrandTotal=function(e){return e.baseExpr=t.SQExprConverter.asFieldPattern(B.rewrite(O.fieldExpr(e.baseExpr),this.aggregate)),O.fieldExpr({percentOfGrandTotal:e})},e.prototype.visitColumn=function(e){return this.defaultRewrite()},e.prototype.visitColumnAggr=function(e){return this.defaultRewrite()},e.prototype.visitColumnHierarchyLevelVariation=function(e){return this.defaultRewrite()},e.prototype.visitSelectRef=function(e){return this.defaultRewrite()},e.prototype.visitEntity=function(e){return this.defaultRewrite()},e.prototype.visitEntityAggr=function(e){return this.defaultRewrite()},e.prototype.visitHierarchy=function(e){return this.defaultRewrite()},e.prototype.visitHierarchyLevel=function(e){return this.defaultRewrite()},e.prototype.visitHierarchyLevelAggr=function(e){return this.defaultRewrite()},e.prototype.visitMeasure=function(e){return this.defaultRewrite()},e.prototype.visitPercentile=function(e){return this.defaultRewrite()},e.prototype.defaultRewrite=function(){return B.rewrite(this.sqExpr,this.aggregate)},e}(),W=function(){function e(e){this.sqExpr=e}return e.rewrite=function(r){return t.FieldExprPattern.visit(r,new e(r))},e.prototype.visitPercentOfGrandTotal=function(t){return e.rewrite(O.fieldExpr(t.baseExpr))},e.prototype.visitColumn=function(e){return this.defaultRewrite()},e.prototype.visitColumnAggr=function(e){return this.defaultRewrite()},e.prototype.visitColumnHierarchyLevelVariation=function(e){return this.defaultRewrite()},e.prototype.visitSelectRef=function(e){return this.defaultRewrite()},e.prototype.visitEntity=function(e){return this.defaultRewrite()},e.prototype.visitEntityAggr=function(e){return this.defaultRewrite()},e.prototype.visitHierarchy=function(e){return this.defaultRewrite()},e.prototype.visitHierarchyLevel=function(e){return this.defaultRewrite()},e.prototype.visitHierarchyLevelAggr=function(e){return this.defaultRewrite()},e.prototype.visitMeasure=function(e){return this.defaultRewrite()},e.prototype.visitPercentile=function(e){return this.defaultRewrite()},e.prototype.defaultRewrite=function(){return Y.rewrite(this.sqExpr)},e}(),Y=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.visitAggr=function(e){return e.arg},t.rewrite=function(e){return e.accept(t.instance)},t.instance=new t,t}(j),K=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.visitEntity=function(e){return e.variable?O.entity(e.schema,e.entity):e},t.rewrite=function(e){return e.accept(t.instance)},t.instance=new t,t}(t.SQExprRewriter),z=function(e){function r(){e.apply(this,arguments)}return __extends(r,e),r.rewrite=function(e){return e.accept(r.instance)},r.prototype.visitDefault=function(e){var r=t.SQExprConverter.asFieldPattern(e);return r&&r.percentOfGrandTotal&&(e=O.fieldExpr(r.percentOfGrandTotal.baseExpr)),e},r.instance=new r,r}(j),X=function(e){function r(){e.apply(this,arguments)}return __extends(r,e),r.rewrite=function(e){return e.accept(r.instance)},r.prototype.visitDefault=function(e){var r=t.SQExprConverter.asFieldPattern(e);return r&&!r.percentOfGrandTotal&&(e=O.fieldExpr({percentOfGrandTotal:{baseExpr:t.SQExprConverter.asFieldPattern(e)}})),e},r.instance=new r,r}(j)}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){var r,i=jsCommon.ArrayExtensions,n=jsCommon.StringExtensions;!function(r){function a(e,t){var r=e.getMetadata(t),i=r&&r.type;return r&&i?i.numeric||i.dateTime||i.duration:!1}function o(e,r){for(var i=0,n=e.length;n>i;i++)if(t.SQExpr.equals(e[i],r))return i;return-1}function u(e,r){var i=e.length;if(i!==r.length)return!1;for(var n=0;i>n;n++)if(!t.SQExpr.equals(e[n],r[n]))return!1;return!0}function s(e,t,r){for(var i={},a=0,o=e.length;o>a;a++)i[e[a].name]=!0;return n.findUniqueName(i,r||c(t))}function c(e,t){return void 0===t&&(t="select"),e?e.accept(R.instance,t):t}function l(e){return e.accept(A.instance)}function p(e){return e.accept(I.instance)}function f(e){return e.accept(N.instance)}function v(e,t){var r=g(e,t);return r&&r.discourageQueryAggregateUsage}function h(e,t){var r=E(e,t);return r?r.aggregateBehavior:void 0}function g(e,r){var i=t.SQExprConverter.asFieldPattern(e);if(i){var n=t.FieldExprPattern.toFieldExprEntityItemPattern(i),a=r.schema(n.schema);return a?a.capabilities:void 0}}function d(e,t){var r=m(e,t);if(r)return r.kpiValue.measure.kpi.statusMetadata;var i=x(e,t);return i?i.kpiValue.measure.kpi.trendMetadata:void 0}function y(e,t){var r=t.schema(e.schema).entities.withName(e.entity);return r}function m(e,t){var r=e.getConceptualProperty(t);if(r){var i=r.kpiValue;return i&&i.measure.kpi.status===r?r:void 0}}function x(e,t){var r=e.getConceptualProperty(t);if(r){var i=r.kpiValue;return i&&i.measure.kpi.trend===r?r:void 0}}function S(e,t){var r=E(e,t);return r?r.defaultValue:void 0}function E(e,r){if(e&&r){var i=t.SQExprConverter.asFieldPattern(e);if(i){var n=i.column;if(n){if(r.schema(n.schema)&&i.column.name){var a=r.schema(n.schema).findProperty(n.entity,i.column.name);if(a)return a.column}}else{var o=i.hierarchyLevel;if(o){var u=t.FieldExprPattern.toFieldExprEntityItemPattern(i),s=u.schema;if(r.schema(s)){var c=r.schema(s).findHierarchy(u.entity,o.name);if(c){var l=c.levels.withName(o.level);if(l&&l.column)return l.column.column}}}}}}}function w(e,t){if(!_.isEmpty(e)&&t){for(var r=[],i=0,n=e;i<n.length;i++){var a=n[i],o=S(a,t);o&&r.push(o)}return r}}function b(e,r){for(var i=[],n=0;n<e.length;n++)i.push(t.SQExprBuilder.compare(t.QueryComparisonKind.Equal,e[n],r[n]));if(!_.isEmpty(i)){for(var a,o=0,u=i;o<u.length;o++){var s=u[o];a=t.SQExprBuilder.and(a,s)}return a}}function D(e){var t=[];if(e){var r=e.from();if(void 0!==r)for(var i=0,n=r.keys();i<n.length;i++){var a=n[i],o=r.entity(a);t.indexOf(o.entity)<0&&t.push(o.entity)}}return t}function C(e,t,r){return V(e,t,r,0,2)||V(e,r,t,2,0)}function T(e,t,r){return V(e,t,r,2,0)||V(e,r,t,0,2)}function V(e,t,i,n,a){var o=r.getConceptualEntity(t,e);if(_.isEmpty(o.navigationProperties))return!1;var u=r.getConceptualEntity(i,e),s=[];for(s.push(o);!_.isEmpty(s);){var c=s.shift(),l=c.navigationProperties;if(!_.isEmpty(l))for(var p=0,f=l;p<f.length;p++){var v=f[p];if(v.isActive&&v.targetMultiplicity===a&&v.sourceMultiplicity===n){if(v.targetEntity===u)return!0;s.push(v.targetEntity)}}}return!1}function F(e,t,i){var n=r.getConceptualEntity(t,e),a=r.getConceptualEntity(i,e),o=n.navigationProperties,u=a.navigationProperties;return _.isEmpty(o)&&_.isEmpty(u)?!1:P(o,a)||P(u,n)}function P(e,t){if(_.isEmpty(e))return!1;for(var r=0,i=e;r<i.length;r++){var n=i[r];if(n.isActive&&n.targetEntity===t&&0===n.sourceMultiplicity&&0===n.targetMultiplicity)return!0}return!1}function M(e,t){for(var r=i.copy(e),n=0,a=t;n<a.length;n++){var u=a[n];-1===o(r,u)&&r.push(u)}return r}r.supportsArithmetic=a,r.indexOfExpr=o,r.sequenceEqual=u,r.uniqueName=s,r.defaultName=c,r.isMeasure=l,r.isAnyValue=p,r.isDefaultValue=f,r.discourageAggregation=v,r.getAggregateBehavior=h,r.getSchemaCapabilities=g,r.getKpiMetadata=d,r.getConceptualEntity=y,r.getDefaultValue=S,r.getDefaultValues=w,r.getDataViewScopeIdentityComparisonExpr=b,r.getActiveTablesNames=D,r.isRelatedToMany=C,r.isRelatedToOne=T,r.isRelatedOneToOne=F,r.concatUnique=M;var R=function(r){function i(){r.apply(this,arguments)}return __extends(i,r),i.prototype.visitEntity=function(e){return e.entity},i.prototype.visitColumnRef=function(e){return e.source.accept(this)+"."+e.ref},i.prototype.visitMeasureRef=function(e,t){return e.source.accept(this)+"."+e.ref},i.prototype.visitAggr=function(e,r){return t.QueryAggregateFunction[e.func]+"("+e.arg.accept(this)+")"},i.prototype.visitPercentile=function(e,t){var r=e.exclusive?"Percentile.Exc(":"Percentile.Inc(";return r+e.arg.accept(this)+", "+e.k+")"},i.prototype.visitArithmetic=function(t,r){return e.data.getArithmeticOperatorName(t.operator)+"("+t.left.accept(this)+", "+t.right.accept(this)+")"},i.prototype.visitConstant=function(e){return"const"},i.prototype.visitDefault=function(e,t){return t||"expr"},i.instance=new i,i}(t.DefaultSQExprVisitorWithArg),A=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.visitMeasureRef=function(e){return!0},t.prototype.visitAggr=function(e){return!0},t.prototype.visitArithmetic=function(e){return!0},t.prototype.visitDefault=function(e){return!1},t.instance=new t,t}(t.DefaultSQExprVisitor),N=function(e){function r(){e.apply(this,arguments)}return __extends(r,e),r.prototype.visitCompare=function(e){return e.comparison!==t.QueryComparisonKind.Equal?!1:e.right.accept(this)},r.prototype.visitAnd=function(e){return e.left.accept(this)&&e.right.accept(this)},r.prototype.visitDefaultValue=function(e){return!0},r.prototype.visitDefault=function(e){return!1},r.instance=new r,r}(t.DefaultSQExprVisitor),I=function(e){function r(){e.apply(this,arguments)}return __extends(r,e),r.prototype.visitCompare=function(e){return e.comparison!==t.QueryComparisonKind.Equal?!1:e.right.accept(this)},r.prototype.visitAnd=function(e){return e.left.accept(this)&&e.right.accept(this)},r.prototype.visitAnyValue=function(e){return!0},r.prototype.visitDefault=function(e){return!1},r.instance=new r,r}(t.DefaultSQExprVisitor)}(r=t.SQExprUtils||(t.SQExprUtils={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){var t=function(){function t(e){this.exprRewriter=e}return t.prototype.rewriteFrom=function(t){for(var r={},i=t,n=i.keys(),a=0,o=n.length;o>a;a++){var u=n[a],s=i.entity(u),c=e.SQExprBuilder.entity(s.schema,s.entity,u),l=c.accept(this.exprRewriter);r[u]={schema:l.schema,entity:l.entity}}return new e.SQFrom(r)},t.prototype.rewriteSelect=function(e,t){return this.rewriteNamedSQExpressions(e,t)},t.prototype.rewriteGroupBy=function(e,t){return _.isEmpty(e)?void 0:this.rewriteNamedSQExpressions(e,t)},t.prototype.rewriteNamedSQExpressions=function(t,r){var i=this;return _.map(t,function(t){return{name:t.name,expr:e.SQExprRewriterWithSourceRenames.rewrite(t.expr.accept(i.exprRewriter),r)}})},t.prototype.rewriteOrderBy=function(t,r){if(!_.isEmpty(t)){for(var i=[],n=0,a=t.length;a>n;n++){var o=t[n],u=e.SQExprRewriterWithSourceRenames.rewrite(o.expr.accept(this.exprRewriter),r);i.push({direction:o.direction,expr:u})}return i}},t.prototype.rewriteWhere=function(t,r){var i=this;if(!_.isEmpty(t)){for(var n=[],a=0,o=t.length;o>a;a++){var u=t[a],s={condition:e.SQExprRewriterWithSourceRenames.rewrite(u.condition.accept(this.exprRewriter),r)};u.target&&(s.target=_.map(u.target,function(t){return e.SQExprRewriterWithSourceRenames.rewrite(t.accept(i.exprRewriter),r)})),n.push(s)}return n}},t}();e.SemanticQueryRewriter=t}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){var t=jsCommon.ArrayExtensions,r=function(){function r(e,t,r,i,n){this.fromValue=e,this.whereItems=t,this.orderByItems=r,this.selectItems=i,this.groupByItems=n}return r.create=function(){return r.empty||(r.empty=new r(new n,null,null,[],null)),r.empty},r.createWithTrimmedFrom=function(e,t,i,n,a){var o=new u(e.keys());if(t)for(var s=0,c=t.length;c>s;s++){var l=t[s];l.condition.accept(o);var p=l.target;if(p)for(var f=0,v=p.length;v>f;f++)p[f]&&p[f].accept(o)}if(i)for(var s=0,c=i.length;c>s;s++)i[s].expr.accept(o);for(var s=0,c=n.length;c>s;s++)n[s].expr.accept(o);if(a)for(var s=0,c=a.length;c>s;s++)a[s].expr.accept(o);for(var h=o.result(),s=0,c=h.length;c>s;s++)e.remove(h[s]);return new r(e,t,i,n,a)},r.prototype.from=function(){return this.fromValue.clone()},r.prototype.select=function(e){return _.isEmpty(arguments)?this.getSelect():this.setSelect(e)},r.prototype.getSelect=function(){return r.createNamedExpressionArray(this.selectItems)},r.createNamedExpressionArray=function(e){return t.extendWithName(_.map(e,function(e){return{name:e.name,expr:e.expr}}))},r.prototype.setSelect=function(e){var t=this.fromValue.clone(),i=r.rewriteExpressionsWithSourceRenames(e,t);return r.createWithTrimmedFrom(t,this.whereItems,this.orderByItems,i,this.groupByItems)},r.rewriteExpressionsWithSourceRenames=function(e,t){for(var r=[],i=0,n=e.length;n>i;i++){var o=e[i];r.push({name:o.name,expr:a.rewrite(o.expr,t)})}return r},r.prototype.removeSelect=function(t){for(var i=this.selectItems,n=[],a=0,o=i.length;o>a;a++){var u=i[a];e.SQExpr.equals(u.expr,t)||n.push(u)}return r.createWithTrimmedFrom(this.fromValue.clone(),this.whereItems,this.orderByItems,n,this.groupByItems)},r.prototype.removeOrderBy=function(t){for(var i=this.orderBy(),n=i.length-1;n>=0;n--)e.SQExpr.equals(i[n].expr,t)&&i.splice(n,1);return r.createWithTrimmedFrom(this.fromValue.clone(),this.whereItems,i,this.selectItems,this.groupByItems)},r.prototype.selectNameOf=function(t){var r=e.SQExprUtils.indexOfExpr(_.map(this.selectItems,function(e){return e.expr}),t);return r>=0?this.selectItems[r].name:void 0},r.prototype.setSelectAt=function(e,t){if(!(e>=this.selectItems.length)){var i=this.select(),n=this.fromValue.clone(),o=i[e].name;return i[e]={name:o,expr:a.rewrite(t,n)},r.createWithTrimmedFrom(n,this.whereItems,this.orderByItems,i,this.groupByItems)}},r.prototype.addSelect=function(e,t){var i=this.select(),n=this.fromValue.clone();return i.push(this.createNamedExpr(i,n,e,t)),r.createWithTrimmedFrom(n,this.whereItems,this.orderByItems,i,this.groupByItems)},r.prototype.createNamedExpr=function(t,r,i,n){return{name:e.SQExprUtils.uniqueName(t,i,n),expr:a.rewrite(i,r)}},r.prototype.groupBy=function(e){return _.isEmpty(arguments)?this.getGroupBy():this.setGroupBy(e)},r.prototype.getGroupBy=function(){return r.createNamedExpressionArray(this.groupByItems)},r.prototype.setGroupBy=function(e){var t=this.fromValue.clone(),i=r.rewriteExpressionsWithSourceRenames(e,t);return r.createWithTrimmedFrom(t,this.whereItems,this.orderByItems,this.selectItems,i)},r.prototype.addGroupBy=function(e){var t=this.groupBy(),i=this.fromValue.clone();return t.push(this.createNamedExpr(t,i,e)),r.createWithTrimmedFrom(i,this.whereItems,this.orderByItems,this.selectItems,t)},r.prototype.orderBy=function(e){return _.isEmpty(arguments)?this.getOrderBy():this.setOrderBy(e)},r.prototype.getOrderBy=function(){var e=[],t=this.orderByItems;if(t)for(var r=0,i=t.length;i>r;r++){var n=t[r];e.push({expr:n.expr,direction:n.direction})}return e},r.prototype.setOrderBy=function(e){for(var t=[],i=this.fromValue.clone(),n=0,o=e.length;o>n;n++){var u=e[n];t.push({expr:a.rewrite(u.expr,i),direction:u.direction})}return r.createWithTrimmedFrom(i,this.whereItems,t,this.selectItems,this.groupByItems)},r.prototype.where=function(e){return _.isEmpty(arguments)?this.getWhere():this.setWhere(e)},r.prototype.getWhere=function(){var e=[],t=this.whereItems;if(t)for(var r=0,i=t.length;i>r;r++)e.push(t[r]);return e},r.prototype.setWhere=function(e){for(var t=[],i=this.fromValue.clone(),n=0,o=e.length;o>n;n++){var u=e[n],s={condition:a.rewrite(u.condition,i)},c=u.target;if(c){s.target=[];for(var l=0,p=c.length;p>l;l++)if(c[l]){var f=a.rewrite(c[l],i);s.target.push(f)}}t.push(s)}return r.createWithTrimmedFrom(i,t,this.orderByItems,this.selectItems,this.groupByItems)},r.prototype.addWhere=function(e){for(var t=this.where(),i=e.where(),n=this.fromValue.clone(),o=0,u=i.length;u>o;o++){var s=i[o],c={condition:a.rewrite(s.condition,n)};s.target&&(c.target=_.map(s.target,function(e){return a.rewrite(e,n)})),t.push(c)}return r.createWithTrimmedFrom(n,t,this.orderByItems,this.selectItems,this.groupByItems)},r.prototype.rewrite=function(t){var i=new e.SemanticQueryRewriter(t),n=i.rewriteFrom(this.fromValue),a=i.rewriteWhere(this.whereItems,n),o=i.rewriteOrderBy(this.orderByItems,n),u=i.rewriteSelect(this.selectItems,n),s=i.rewriteGroupBy(this.groupByItems,n);return r.createWithTrimmedFrom(n,a,o,u,s)},r}();e.SemanticQuery=r;var i=function(){function r(e,t){this.fromValue=e,this.whereItems=t}return r.fromSQExpr=function(e){var t=new n,i=a.rewrite(e,t),o=[{condition:i}];return new r(t,o)},r.getDefaultValueFilter=function(t){return r.getDataViewScopeIdentityComparisonFilters(t,e.SQExprBuilder.defaultValue())},r.getAnyValueFilter=function(t){return r.getDataViewScopeIdentityComparisonFilters(t,e.SQExprBuilder.anyValue())},r.getDataViewScopeIdentityComparisonFilters=function(t,i){if(t instanceof Array){var n=Array.apply(null,Array(t.length)).map(function(){return i});return r.fromSQExpr(e.SQExprUtils.getDataViewScopeIdentityComparisonExpr(t,n))}return r.fromSQExpr(e.SQExprBuilder.equal(t,i))},r.prototype.from=function(){return this.fromValue.clone()},r.prototype.conditions=function(){for(var e=[],t=this.whereItems,r=0,i=t.length;i>r;r++){var n=t[r];e.push(n.condition)}return e},r.prototype.where=function(){for(var e=[],t=this.whereItems,r=0,i=t.length;i>r;r++)e.push(t[r]);return e},r.prototype.rewrite=function(t){var i=new e.SemanticQueryRewriter(t),n=i.rewriteFrom(this.fromValue),a=i.rewriteWhere(this.whereItems,n);return new r(n,a)},r.prototype.validate=function(t,r,i){var n=new e.SQExprValidationVisitor(t,r,i);return this.rewrite(n),n.errors},r.merge=function(e){if(_.isEmpty(e))return null;if(1===e.length)return e[0];for(var i=e[0],n=i.from(),a=t.take(i.whereItems,i.whereItems.length),o=1,u=e.length;u>o;o++)r.applyFilter(e[o],n,a);return new r(n,a)},r.isDefaultFilter=function(t){return t&&1===t.where().length?e.SQExprUtils.isDefaultValue(t.where()[0].condition):!1},r.isAnyFilter=function(t){return t&&1===t.where().length?e.SQExprUtils.isAnyValue(t.where()[0].condition):!1},r.isSameFilter=function(e,t){return jsCommon.JsonComparer.equals(e,t)?!(r.isDefaultFilter(e)&&r.isAnyFilter(t)||r.isAnyFilter(e)&&r.isDefaultFilter(t)):!1},r.applyFilter=function(e,t,r){for(var i=e.whereItems,n=0;n<i.length;n++){var o=i[n],u={condition:a.rewrite(o.condition,t)};o.target&&(u.target=_.map(o.target,function(e){return a.rewrite(e,t)})),r.push(u)}},r}();e.SemanticFilter=i;var n=function(){function e(e){this.items=e||{}}return e.prototype.keys=function(){return Object.keys(this.items)},e.prototype.entity=function(e){return this.items[e]},e.prototype.ensureEntity=function(e,t){for(var r=this.keys(),i=0,n=r.length;n>i;i++){var a=r[i],o=this.items[a];if(o&&e.entity===o.entity&&e.schema===o.schema)return{name:a}}for(var u=t||this.candidateName(e.entity),s=u,c=2;this.items[s];)s=u+c++;return this.items[s]=e,{name:s,"new":!0}},e.prototype.remove=function(e){delete this.items[e]},e.prototype.candidateName=function(e){var t=e.lastIndexOf(".");return t>=0&&t!==e.length-1&&(e=e.substr(t+1)),e.substring(0,1).toLowerCase()},e.prototype.clone=function(){var t=new e;return $.extend(t.items,this.items),t},e}();e.SQFrom=n;var a=function(r){function i(e){r.call(this),this.renames=e}return __extends(i,r),i.prototype.visitEntity=function(t){var i=this.renames[t.entity];return i?new e.SQEntityExpr(t.schema,t.entity,i):r.prototype.visitEntity.call(this,t)},i.prototype.rewriteFilter=function(e){var t=void 0;e.target&&(t=this.rewriteArray(e.target));var r=e.condition.accept(this);if(e.condition===r&&e.target===t)return e;var i={condition:r};return t&&(i.target=t),i},i.prototype.rewriteArray=function(e){for(var r,i=0,n=e.length;n>i;i++){var a=e[i],o=a.accept(this);a===o||r||(r=t.take(e,i)),r&&r.push(o)}return r||e},i.rewrite=function(e,t){var r=o.run(e,t),n=new i(r);return e.accept(n)},i}(e.SQExprRewriter);e.SQExprRewriterWithSourceRenames=a;var o=function(e){function t(t){e.call(this),this.from=t,
7this.renames={}}return __extends(t,e),t.run=function(e,r){var i=new t(r);return e.accept(i),i.renames},t.prototype.visitEntity=function(e){var t=this.from.entity(e.variable);if(!t||t.schema!==e.schema||t.entity!==e.entity){var r=this.from.ensureEntity({schema:e.schema,entity:e.entity},e.variable);this.renames[e.entity]=r.name}},t}(e.DefaultSQExprVisitorWithTraversal),u=function(e){function t(t){e.call(this),this.keys=t}return __extends(t,e),t.prototype.visitEntity=function(e){var t=this.keys.indexOf(e.variable);t>=0&&this.keys.splice(t,1)},t.prototype.result=function(){return this.keys},t}(e.DefaultSQExprVisitorWithTraversal)}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){function r(){return new s}function i(e,r,i,n){var a=e.identities;return a?a[r]:t.createDataViewScopeIdentity(u.equal(e.fields[0],u.typedConstant(i,n)))}function n(e,t){_.contains(e,t)||e.push(t)}function a(e,t,r){var i=t.values;e.values=i;var n=t.highlights;n&&(e.highlights=n);var a;void 0!==t.minLocal&&(a||(a={}),a.minLocal=t.minLocal),void 0!==t.maxLocal&&(a||(a={}),a.maxLocal=t.maxLocal),a&&(e.source.aggregates=a,_.extend(e,a))}var o=e.data.DataViewTransform,u=e.data.SQExprBuilder;t.createCategoricalDataViewBuilder=r;var s=function(){function e(){this.categories=[],this.staticMeasureColumns=[],this.dynamicMeasureColumns=[],this.columnIndex=0}return e.prototype.withCategory=function(e){var t=e.values,r=e.identityFrom,n=e.source.type,a={source:e.source,identityFields:e.identityFrom.fields,identity:e.identityFrom.identities||[],values:t};if(!e.identityFrom.identities)for(var o=0,u=t.length;u>o;o++)a.identity.push(i(r,o,t[o],n));return this.categories||(this.categories=[]),this.categories.push(a),this},e.prototype.withCategories=function(e){return _.isEmpty(this.categories)?this.categories=e:Array.prototype.push.apply(this.categories,e),this},e.prototype.withValues=function(e){for(var t=e.columns,r=0,i=t;r<i.length;r++){var n=i[r];this.staticMeasureColumns.push(n.source)}return this.staticSeriesValues=t,this},e.prototype.withGroupedValues=function(e){var t=e.groupColumn;this.dynamicSeriesMetadata={column:t.source,identityFrom:t.identityFrom,values:t.values};for(var r=e.valueColumns,i=0,n=r;i<n.length;i++){var a=n[i];this.dynamicMeasureColumns.push(a.source)}return this.dynamicSeriesValues=e.data,this},e.prototype.fillData=function(e){var t=_.first(this.categories),r=t&&t.values?t.values.length:1;if(this.hasDynamicSeries)for(var i=0;i<this.dynamicSeriesMetadata.values.length;i++)for(var n=this.dynamicSeriesValues[i],o=0,u=this.dynamicMeasureColumns.length;u>o;o++){var s=i*u+o;a(e[s],n[o],r)}if(this.hasStaticSeries)for(var c=this.hasDynamicSeries?this.dynamicSeriesValues.length*this.dynamicMeasureColumns.length:0,o=0,u=this.staticMeasureColumns.length;u>o;o++)a(e[c+o],this.staticSeriesValues[o],r)},e.prototype.build=function(){for(var e=[],t={},r=this.categories,a=this.dynamicSeriesMetadata,u=0,s=r;u<s.length;u++){var c=s[u];n(e,c.source)}if(this.hasDynamicSeries){n(e,a.column),t.values=o.createValueColumns([],a.identityFrom.fields,a.column);for(var l=a.values,p=0;p<l.length;p++)for(var f=l[p],v=i(a.identityFrom,p,f,a.column.type),h=0,g=this.dynamicMeasureColumns;h<g.length;h++){var d=g[h],y=_.clone(d);y.groupName=f,n(e,y),t.values.push({source:y,values:[],identity:v})}if(this.hasStaticSeries){var m=t.values.grouped();t.values.grouped=function(){return m},this.appendStaticMeasureColumns(e,t.values)}}else t.values=o.createValueColumns(),this.appendStaticMeasureColumns(e,t.values);var x=this.categories;_.isEmpty(x)||(t.categories=x),this.fillData(t.values);var S={metadata:{columns:e},categorical:t};return this.isLegalDataView(S)?S:void 0},e.prototype.appendStaticMeasureColumns=function(e,t){if(!_.isEmpty(this.staticMeasureColumns))for(var r=0,i=this.staticMeasureColumns;r<i.length;r++){var a=i[r];n(e,a),t.push({source:a,values:[]})}},e.prototype.isLegalDataView=function(t){return!(this.hasDynamicSeries&&this.hasStaticSeries&&e.isVisualDataView(t.metadata.columns))},e.isVisualDataView=function(e){return!_.isEmpty(e)&&_.any(e,function(e){return!!e.queryName})},Object.defineProperty(e.prototype,"hasDynamicSeries",{get:function(){return!!this.dynamicSeriesMetadata},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasStaticSeries",{get:function(){return!!this.staticSeriesValues},enumerable:!0,configurable:!0}),e}()}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){function r(e,r,i){return new o(e||t.createColorAllocatorCache(),r||{metadata:{columns:[]}},i)}function i(e,t,r,i){var o=r.rows;if(!(_.isEmpty(o)||o.length<=i))for(var u=n(e,t),s=r.columns,c=0,l=t.length;l>c;c++){var p=t[c];if(a.equals(p.expr,u)&&p.queryName)for(var f=0,v=s.length;v>f;f++)if(c===s[f].index)return o[i][f]}}function n(e,t){if(a.isSelectRef(e))for(var r=0,i=t;r<i.length;r++){var n=i[r];if(n.queryName===e.expressionName)return n.expr}return e}var a=e.data.SQExpr;t.createStaticEvalContext=r;var o=function(){function e(e,t,r){this.colorAllocatorCache=e,this.dataView=t,this.selectTransforms=r}return e.prototype.getColorAllocator=function(e){return this.colorAllocatorCache.get(e)},e.prototype.getExprValue=function(e){var t=this.dataView,r=this.selectTransforms;return t&&t.table&&r?i(e,r,t.table,0):void 0},e.prototype.getRoleValue=function(e){},e}();t.getExprValueFromTable=i}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){function t(t,r){return e.createStaticEvalContext(t)}e.createMatrixEvalContext=t}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t,r=jsCommon.StringExtensions,i=jsCommon.Formatting,n=jsCommon.RegExpExtensions;!function(e){function t(e,t){for(var i=t.length,n=0;i>n;n++){var a="\\"+t[n],o=String.fromCharCode(57344+n);e=r.replaceAll(e,a,o)}return e}function i(e,t){for(var i=t.length,n=0;i>n;n++){var a=String.fromCharCode(57344+n),o=t[n];e=r.replaceAll(e,a,o)}return r.replaceAll(e,"\\","")}function n(e,t){e=r.replaceAll(e,'"',"'");for(var i=0;;i++){var n=e.indexOf("'");if(0>n)break;var a=e.indexOf("'",n+1);if(0>a)break;var o=e.substring(n,a+1);t.push(o.substring(1,a-n));var u=String.fromCharCode(57600+i);e=e.replace(o,u)}return e}function a(e,t){for(var r=t.length,i=0;r>i;i++){var n=String.fromCharCode(57600+i),a=t[i];e=e.replace(n,a)}return e}e.preserveEscaped=t,e.restoreEscaped=i,e.preserveLiterals=n,e.restoreLiterals=a}(t||(t={}));var a,o=/({{)|(}})|{(\d+[^}]*)}/g,u="0",s="#",c="E",l=[u,s],p=new RegExp(l.join("|"),"g"),f=function(){function e(){}return e.prototype.formatValue=function(e,t,r){if(void 0===e||null===e)return"";var i=this.getCulture(r);return a.canFormat(e)?a.format(e,t,i):v.canFormat(e)?v.format(e,t,i):e.toString()},e.prototype.format=function(e,t,r){var i=this;if(!e)return"";var n=e.replace(o,function(e,n,a,o){if(n)return"{";if(a)return"}";var u=o.split(":"),s=parseInt(u[0],10),c=u[1];return i.formatValue(t[s],c,r)});return n},e.prototype.isStandardNumberFormat=function(e){return v.isStandardFormat(e)},e.prototype.formatNumberWithCustomOverride=function(e,t,r,i){var n=this.getCulture(i);return v.formatWithCustomOverride(e,t,r,n)},e.prototype.dateFormatString=function(e){return this._dateTimeScaleFormatInfo||this.initialize(),this._dateTimeScaleFormatInfo.getFormatString(e)},e.prototype.setCurrentCulture=function(e){this._currentCultureSelector!==e&&(this._currentCulture=this.getCulture(e),this._currentCultureSelector=e,this._dateTimeScaleFormatInfo=new h(this._currentCulture))},e.prototype.getCulture=function(e){if(null==e)return null==this._currentCulture&&this.initialize(),this._currentCulture;var t=Globalize.findClosestCulture(e);return t||(t=Globalize.culture("en-US")),t},e.prototype.initialize=function(){var e=this.getCurrentCulture();this.setCurrentCulture(e);var t=this.getUrlParam("calendar");if(t){var r=this._currentCulture,i=r.calendars[t];i&&(r.calendar=i)}},e.prototype.getCurrentCulture=function(){var e=this.getUrlParam("language");return e?e:powerbi&&powerbi.common&&powerbi.common.cultureInfo?powerbi.common.cultureInfo:window.navigator.userLanguage||window.navigator.language||Globalize.culture().name},e.prototype.getUrlParam=function(e){var t=window.location.search.match(RegExp("[?&]"+e+"=([^&]*)"));return t?t[1]:void 0},e}();!function(e){function n(e){var t=e instanceof Date;return t}function a(e,t,r){t=t||"G";var i=1===t.length;try{return i?o(e,t,r):u(e,t,r)}catch(n){return o(e,"G",r)}}function o(e,t,r){var n=r.calendar.patterns;l(r.calendar);var a=i.findDateFormat(e,t,r.name);return t=1===a.format.length?n[a.format]:a.format,r=Globalize.culture("en-US"),Globalize.format(a.value,t,r)}function u(e,i,n){var a,o=[];if(i=t.preserveEscaped(i,"\\dfFghHKmstyz:/%'\""),i=t.preserveLiterals(i,o),i=r.replaceAll(i,'"',"'"),i.indexOf("F")>-1){i=r.replaceAll(i,"FFFF","FFF");var u=e.getMilliseconds();if(u%10>=1&&(i=r.replaceAll(i,"FFF","fff")),i=r.replaceAll(i,"FFF","FF"),u%100/10>=1&&(i=r.replaceAll(i,"FF","ff")),i=r.replaceAll(i,"FF","F"),u%1e3/100>=1&&(i=r.replaceAll(i,"F","f")),i=r.replaceAll(i,"F",""),""===i||"%"===i)return""}return i=s(i),a=Globalize.format(e,i,n),a=c(a,n.calendar),a=t.restoreLiterals(a,o),a=t.restoreEscaped(a,"\\dfFghHKmstyz:/%'\"")}function s(e){return e===p?f:(p=e,e=i.fixDateTimeFormat(e),f=e,e)}function c(e,t){var r=t[":"];if(":"===r)return e;for(var i="",n=e.length,a=0;n>a;a++){var o=e.charAt(a);switch(o){case":":i+=r;break;default:i+=o}}return i}function l(e){var t=e.patterns;void 0===t.g&&(t.g=t.f.replace(t.D,t.d),t.G=t.F.replace(t.D,t.d))}var p,f;e.canFormat=n,e.format=a}(a||(a={}));var v;!function(i){function a(e,t){if(!t||void 0===e)return e;var r="{0:"+t+"}";return e.replace("{0}",r)}function o(e,t){if(null==t)return t;if(h(t)){var r=i.getComponents(t),n=r.positive,a=r.negative,o=r.zero;return e>0?l(e,n):0===e?l(e,o):l(e,a)}return l(e,t)}function l(e,t){var r=n.run(I,t);return r?r[0]:t}function f(e,t,r){if(null==t)return e;if(null==e&&(e=u),h(e)){for(var n=i.getComponents(e),a=n.positive,o=n.negative,s=n.zero,c=[a,o,s],l=0;l<c.length;l++)c[l]=v(c[l],t,r);return c.join(i.NumberFormatComponentsDelimeter)}return v(e,t,r)}function v(e,t,i){if(t=Math.abs(t),t>=0){var a=i?u:s,o=r.repeat(a,Math.abs(t)),c=n.run(N,e);if(c){var l=e.substr(0,c.index),p=e.substr(c.index+1,c[1].length),f=e.substr(c.index+c[0].length);if(i)p=o;else{var v=o.length-p.length;v>0?p+=o.slice(-v):0>v&&(p=p.slice(0,v))}return p.length>0&&(p=Q+p),l+p+f}if(o.length>0)return e.replace(O,"$1"+Q+o)}return e}function h(e){return-1!==e.indexOf(i.NumberFormatComponentsDelimeter)}function g(e){var t={hasNegative:!1,positive:e,negative:e,zero:e},r=e.split(i.NumberFormatComponentsDelimeter),n=r.length;return n>1&&(t.hasNegative=!0,t.positive=t.zero=r[0],t.negative=r[1],n>2&&(t.zero=r[2])),t}function d(e){var t="number"==typeof e;return t}function y(e){return R.test(e)}function m(e,t,r){t=t||"G";try{return y(t)?S(e,t,r):E(e,t,r)}catch(i){return Globalize.format(e,void 0,r)}}function x(e,t,r,i){return E(e,t,i,r)}function S(e,t,i){var n,a=t.length>1?parseInt(t.substr(1,t.length-1),10):void 0,o=i.numberFormat,u=t.charAt(0);switch(u){case"e":case"E":void 0===a&&(a=6);var s=r.repeat("0",a);t="0."+s+u+"+000",n=E(e,t,i);break;case"f":case"F":n=void 0!==a?e.toFixed(a):e.toFixed(o.decimals),n=F(n,o);break;case"g":case"G":var c=Math.abs(e);if(0===c||c>=1e-4&&1e15>c)n=void 0!==a?e.toPrecision(a):e.toString();else{if("number"!=typeof e)return String(e);n=void 0!==a?e.toExponential(a):e.toExponential(),n=n.replace("e","E")}n=F(n,o);break;case"r":case"R":n=e.toString(),n=F(n,o);break;case"x":case"X":if(n=e.toString(16),"X"===u&&(n=n.toUpperCase()),void 0!==a){var l=n.length,p=0>e;p&&l--;var f=a-l,v=void 0;f>0&&(v=r.repeat("0",f)),n=p?"-"+v+n.substr(1):v+n}n=F(n,o);break;default:n=Globalize.format(e,t,i)}return n}function E(r,o,u,s){var c,l=u.numberFormat;if(!isFinite(r))return Globalize.format(r,void 0);var p=g(o);o=r>0?p.positive:0===r?p.zero:p.negative,p.hasNegative&&(r=Math.abs(r));var f=b(o,!0);f.hasEscapes&&(o=t.preserveEscaped(o,"\\0#.,%‰"));var v=[];if(f.hasQuotes&&(o=t.preserveLiterals(o,v)),f.hasE&&!s){var h=n.run(M,o);if(h){var d=o.substr(0,h.index),y=o.substr(h.index+2),m=D(d,f),x=C(d,f);if(1!==x&&(r*=x),"number"!=typeof r)return String(r);var S=r.toExponential(m),E=S.indexOf("e"),V=S.substr(0,E),_=S.substr(E+1),F=T(V,d,l),P=T(_,y,l);"+"===P.charAt(0)&&"+"!==h[0].charAt(1)&&(P=P.substr(1));var R=h[0].charAt(0);c=F+R+P}}if(void 0===c){var A=void 0,N=!1,m=D(o,f),x=C(o,f);if(1!==x&&(r*=x),r=parseFloat(w(r,m)),s){var I=i.getNumericFormat(r,o);s=a(s,I),A=e.formattingService.format(s,[r],u.name),N=!0}else A=w(r,m);c=T(A,o,l,s,N)}return f.hasQuotes&&(c=t.restoreLiterals(c,v)),f.hasEscapes&&(c=t.restoreEscaped(c,"\\0#.,%‰")),U=f,c}function w(t,i){var n="",a=0;i>16&&(a=i-16,i=16);var o=e.Double.log10(Math.abs(t));if(16>o){if(o>0){var u=16-o;i>u&&(a+=i-u,i=u)}n=t.toFixed(i)}else if(16===o)n=t.toFixed(0),a+=i,a>0&&(n+=".");else{if("number"!=typeof t)return String(t);n=t.toExponential(15);var s=n.indexOf("e");if(s>0){var c=n.indexOf("."),l=n.substr(0,s),p=n.substr(s+1),f=parseInt(p,10)-(l.length-c-1);n=l.replace(".","")+r.repeat("0",f),i>0&&(n=n+"."+r.repeat("0",i))}}return a>0&&(n+=r.repeat("0",a)),n}function b(e,t,r){if(void 0!==U&&e===U.format)return U;for(var i={format:e,hasEscapes:!1,hasQuotes:!1,hasE:!1,hasCommas:!1,hasDots:!1,hasPercent:!1,hasPermile:!1,precision:void 0,scale:void 0},n=0,a=e.length;a>n;n++){var o=e.charAt(n);switch(o){case"\\":i.hasEscapes=!0;break;case"'":case'"':i.hasQuotes=!0;break;case"e":case"E":i.hasE=!0;break;case",":i.hasCommas=!0;break;case".":i.hasDots=!0;break;case"%":i.hasPercent=!0;break;case"‰":i.hasPermile=!0}}var u=g(e);return t&&(i.precision=D(u.positive,i)),r&&(i.scale=C(u.positive,i)),i}function D(e,t){if(t.precision>-1)return t.precision;var r=0;if(t.hasDots){var i=e.indexOf(".");if(i>-1){for(var n=e.length,a=i;n>a;a++){var o=e.charAt(a);if(o.match(p)&&r++,o===c)break}r=Math.min(19,r)}}return t.precision=r,r}function C(e,t){if(t.scale>-1)return t.scale;var r=1;if(t.hasPercent&&e.indexOf("%")>-1&&(r=100*r),t.hasPermile&&e.indexOf("‰")>-1&&(r=1e3*r),t.hasCommas){var i=e.indexOf(".");-1===i&&(i=e.length);for(var n=i-1;n>-1;n--){var a=e.charAt(n);if(","!==a)break;r/=1e3}}return t.scale=r,r}function T(e,t,r,i,n){var a=!!i,o=t.split(".",2);if(2===o.length){var u=o[0],s=o[1],c="";i&&(c=i.replace(P,""),e=e.replace(c,""));var l=r["."],p=n?l:".",f=e.split(p,2),v=1===f.length?f[0]+c:f[0],h=2===f.length?f[1]+c:"";h=h.replace(A,"");var g=V(v,u,r,a),d=_(h,s,a);return d.fmtOnly||""===d.value?g+d.value:g+l+d.value}return V(e,t,r,a)}function V(e,t,r,i){var n=t.indexOf(","),a=n>-1&&n<Math.max(t.lastIndexOf("0"),t.lastIndexOf("#"))&&r[","],o=0,c=0,l=r.groupSizes||[3],p=l[0],f=r[","],v="",h=e.charAt(0);"+"!==h&&"-"!==h||(v=r[h],e=e.substr(1));for(var g="0"===e,d="",y="",m=e.length-1,x=!0,S=t.length-1;S>-1;S--){var E=t.charAt(S);switch(E){case u:case s:x=!1,""!==y&&(d=y+d,y=""),i||((m>-1||E===u)&&a&&(o===p?(d=f+d,c++,c<l.length&&(p=l[c]),o=1):o++),m>-1?(g&&E===s||(d=e.charAt(m)+d),m--):E!==s&&(d=E+d));break;case",":break;default:y=E+y}}if(!i){if(m>-1&&""!==d)if(a)for(;m>-1;)o===p?(d=f+d,c++,c<l.length&&(p=l[c]),o=1):o++,d=e.charAt(m)+d,m--;else d=e.substr(0,m+1)+d;return v+y+d}return x?v+y+d:v+y+e+d}function _(e,t,r){var i=0,n=t.length,a=e.length;if(r){var o=t.charAt(n-1);return o.match(p)?{value:e,fmtOnly:""===e}:{value:e+o,fmtOnly:""===e}}for(var c="",l=!0,f=0;n>f;f++){var v=t.charAt(f);if(a>i)switch(v){case u:case s:c+=e[i++],l=!1;break;default:c+=v}else v!==s&&(c+=v,l=l&&v!==u)}return{value:c,fmtOnly:l}}function F(e,t){var r=t["+"],i=t["-"],n=t["."],a=t[","];if("+"===r&&"-"===i&&"."===n&&","===a)return e;for(var o=e.length,u="",s=0;o>s;s++){var c=e.charAt(s);switch(c){case"+":u+=r;break;case"-":u+=i;break;case".":u+=n;break;case",":u+=a;break;default:u+=c}}return u}var P=/\{.+\}/,M=/e[+-]*[0#]+/i,R=/^[a-z]\d{0,2}$/i,A=/0+$/,N=/\.([0#]*)/g,I=/[0#,\.]+[0,#]*/g,O=/(0|#)([^(0|#)]*)$/,Q=".";i.NumberFormatComponentsDelimeter=";",i.getNumericFormat=o,i.addDecimalsToFormat=f,i.hasFormatComponents=h,i.getComponents=g;var U;i.canFormat=d,i.isStandardFormat=y,i.format=m,i.formatWithCustomOverride=x,i.getCustomFormatMetadata=b}(v=e.NumberFormat||(e.NumberFormat={}));var h=function(){function t(e){var t=e.calendar,r=t.patterns,i=t.months.namesAbbr,n=i&&i[0],a=r.Y,o=r.M,u=r.f,s=r.T,c=r.t,l=u.indexOf(",")>-1?", ":" ",p=0===a.indexOf("yyyy'")&&a.length>6&&"'"===a[6];this.YearPattern=p?a.substr(0,7):"yyyy";var f=u.indexOf("yy"),v=u.indexOf("MMMM");this.MonthPattern=n&&v>-1?f>v?"MMM yyyy":"yyyy MMM":a,this.DayPattern=n?o.replace("MMMM","MMM"):o;var h=u.indexOf("mm"),g=u.indexOf("tt"),d=g>-1?c.replace(":mm ",""):c;switch(this.HourPattern=h>f?this.DayPattern+l+d:d+l+this.DayPattern,this.MinutePattern=c,this.SecondPattern=s,this.MillisecondPattern=s.replace("ss","ss.fff"),e.name){case"fi-FI":this.DayPattern=this.DayPattern.replace("'ta'",""),this.HourPattern=this.HourPattern.replace("'ta'","")}}return t.prototype.getFormatString=function(t){switch(t){case e.DateTimeUnit.Year:return this.YearPattern;case e.DateTimeUnit.Month:return this.MonthPattern;case e.DateTimeUnit.Week:case e.DateTimeUnit.Day:return this.DayPattern;case e.DateTimeUnit.Hour:return this.HourPattern;case e.DateTimeUnit.Minute:return this.MinutePattern;case e.DateTimeUnit.Second:return this.SecondPattern;case e.DateTimeUnit.Millisecond:return this.MillisecondPattern}},t}();e.formattingService=new f}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(e){var t;!function(t){function r(e){return JSON.stringify(e.accept(n.instance))}function i(e){for(var r="[",i=0,n=e.length;n>i;i++)i>0&&(r+=","),r+=t.serialize(e[i]);return r+"]"}t.serialize=r,t.serializeArray=i;var n=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.visitColumnRef=function(e){return{col:{s:e.source.accept(this),r:e.ref}}},t.prototype.visitMeasureRef=function(e){return{measure:{s:e.source.accept(this),r:e.ref}}},t.prototype.visitAggr=function(e){return{agg:{a:e.arg.accept(this),f:e.func}}},t.prototype.visitEntity=function(e){return{e:e.entity}},t.prototype.visitHierarchyLevel=function(e){return{h:e.arg.accept(this),l:e.level}},t.prototype.visitHierarchy=function(e){return{e:e.arg.accept(this),h:e.hierarchy}},t.prototype.visitPropertyVariationSource=function(e){return{e:e.arg.accept(this),n:e.name,p:e.property}},t.prototype.visitAnd=function(e){return{and:{l:e.left.accept(this),r:e.right.accept(this)}}},t.prototype.visitCompare=function(e){return{comp:{k:e.comparison,l:e.left.accept(this),r:e.right.accept(this)}}},t.prototype.visitConstant=function(e){return{"const":{t:e.type.primitiveType,v:e.value}}},t.prototype.visitArithmetic=function(e){return{arithmetic:{o:e.operator,l:e.left.accept(this),r:e.right.accept(this)}}},t.prototype.visitScopedEval=function(e){return{scopedEval:{e:e.expression.accept(this),s:i(e.scope)}}},t.prototype.visitDefault=function(e){},t.instance=new t,t}(e.DefaultSQExprVisitor)}(t=e.SQExprShortSerializer||(e.SQExprShortSerializer={}))}(t=e.data||(e.data={}))}(powerbi||(powerbi={}));var powerbi;!function(e){var t;!function(t){var r=e.data.Selector,i=function(){function t(e,t){this.selector=e,this.highlight=t,this.key=JSON.stringify({selector:e?r.getKey(e):null,highlight:t}),this.keyWithoutHighlight=JSON.stringify({selector:e?r.getKey(e):null})}return t.prototype.equals=function(e){return this.selector&&e.selector?this.highlight===e.highlight&&r.equals(this.selector,e.selector):!this.selector==!e.selector&&this.highlight===e.highlight},t.prototype.includes=function(t,r){void 0===r&&(r=!1);var i=this.selector,n=t.selector;if(!i||!n)return!1;var a=i.data,o=n.data;if(!a&&i.metadata&&i.metadata!==n.metadata)return!1;if(!r&&this.highlight!==t.highlight)return!1;if(a){if(!o)return!1;if(a.length>0)for(var u=0,s=a.length;s>u;u++){var c=a[u];if(!o.some(function(t){return e.DataViewScopeIdentity.equals(c,t)}))return!1}}return!0},t.prototype.getKey=function(){return this.key},t.prototype.getKeyWithoutHighlight=function(){return this.keyWithoutHighlight},t.prototype.hasIdentity=function(){return this.selector&&!!this.selector.data},t.prototype.getSelector=function(){return this.selector},t.prototype.getSelectorsByColumn=function(){return this.selectorsByColumn},t.createNull=function(e){return void 0===e&&(e=!1),new t(null,e)},t.createWithId=function(e,r){void 0===r&&(r=!1);var i=null;return e&&(i={data:[e]}),new t(i,r)},t.createWithMeasure=function(e,r){void 0===r&&(r=!1);var i={metadata:e},n=new t(i,r);return n.selectorsByColumn={metadata:e},n},t.createWithIdAndMeasure=function(e,r,i){void 0===i&&(i=!1);var n={};e&&(n.data=[e]),r&&(n.metadata=r),e||r||(n=null);var a=new t(n,i);return a},t.createWithIdAndMeasureAndCategory=function(e,t,r,i){void 0===i&&(i=!1);var n=this.createWithIdAndMeasure(e,t,i);return n.selector&&(n.selectorsByColumn={},e&&r&&(n.selectorsByColumn.dataMap={},n.selectorsByColumn.dataMap[r]=e),t&&(n.selectorsByColumn.metadata=t)),n},t.createWithIds=function(e,r,i){void 0===i&&(i=!1);var n=null,a=t.idArray(e,r);return a&&(n={data:a}),new t(n,i)},t.createWithIdsAndMeasure=function(e,r,i,n){void 0===n&&(n=!1);var a={},o=t.idArray(e,r);return o&&(a.data=o),i&&(a.metadata=i),e||r||i||(a=null),new t(a,n)},t.createWithSelectorForColumnAndMeasure=function(e,t,r){void 0===r&&(r=!1);var i,n=Object.keys(e);i=2===n.length?this.createWithIdsAndMeasure(e[n[0]],e[n[1]],t,r):1===n.length?this.createWithIdsAndMeasure(e[n[0]],null,t,r):this.createWithIdsAndMeasure(null,null,t,r);var a={};return _.isEmpty(e)||(a.dataMap=e),t&&(a.metadata=t),e||t||(a=null),i.selectorsByColumn=a,i},t.createWithHighlight=function(e){var r=new t(e.getSelector(),!0);return r.selectorsByColumn=e.selectorsByColumn,r},t.idArray=function(e,t){if(e||t){var r=[];return e&&r.push(e),t&&t!==e&&r.push(t),r}},t}();t.SelectionId=i;var n=function(){function e(){}return e.builder=function(){return new e},e.prototype.withCategory=function(e,t){return e&&e.source&&e.source.queryName&&e.identity&&(this.ensureDataMap()[e.source.queryName]=e.identity[t]),this},e.prototype.withSeries=function(e,t){return e&&e.source&&e.source.queryName&&t&&(this.ensureDataMap()[e.source.queryName]=t.identity),this},e.prototype.withMeasure=function(e){return this.measure=e,this},e.prototype.createSelectionId=function(){return i.createWithSelectorForColumnAndMeasure(this.ensureDataMap(),this.measure)},e.prototype.ensureDataMap=function(){return this.dataMap||(this.dataMap={}),this.dataMap},e}();t.SelectionIdBuilder=n}(t=e.visuals||(e.visuals={}))}(powerbi||(powerbi={}));
8//# sourceMappingURL=VisualsData.min.js.map