(()=>{function e(a){var i=this,c="selected";function n(e,t){return _.get(i.reference,[e,t],"--")}function r(e,t){return _.get(i.context,[e,t],"--")}function o(e,t){return r(e,t)===n(e,t)}function t(e){var t=i.reference,c=e.key,n=_.get(e.schema,"c8y_JsonSchema"),r=_.reduce(n.properties,function(e,t,n){var r=!_.isUndefined(_.get(i.reference,[c,n]));return!(e=>{var t=!0;return"operations"!==e.type&&(t=(e=>_.keys(e).map(function(e){return e.toLowerCase()}).includes("readonly"))(e))&&(e=_.map(e.operations,"name").map(function(e){return e.toLowerCase()}),t=!_.includes(e,"write")),t})(t)&&r&&((r=_.clone(t)).key=n,r.schemaMatchKey=c,e[n]=r),e},{});return Object.keys(r).length?(t=n.titleDisplay?a.replaceObjectPlaceholders(n.titleDisplay,t,e.key):n.title,_.assign({title:t,properties:r,closed:!0},e)):null}function e(e){e=e.properties;return!i.hideSynced||_.some(e,s)}function s(e){var t=e.schemaMatchKey;return!i.hideSynced||!o(t,e.key)}function l(){var r=[],e=i.schemaMatches;return _.forEach(e,function(t){var n=!0;_.forEach(t.properties,function(e){o(t.key,e.key)||(n=n&&!1,r.push(e))}),n||r.push(t)}),r}function u(){var e,t,n=l(),r=!1;n.length?(e=_.every(n,c),t=_.filter(n,c),n=_.difference(n,t),i.onSelect({allSelected:e,selected:t,notSelected:n})):r=!0,i.disableSelectAll({disabled:r})}function h(e){return _.filter(e.properties,function(e){return o(e.schemaMatchKey,e.key)}).length}_.assign(i,{$onChanges:function(e){(e.reference||e.schemas)&&i.reference&&i.schemas&&(()=>{var e=a.matchObjectWithSchemas(i.reference,i.schemas),e=(i.schemaMatches=_.sortBy(_.filter(e.map(t)),"title"),i.schemaMatches);i.onSchemaMatch({matches:e}),u()})();e.selectAll&&(t=>{var e=l();!1===t&&_.some(e,function(e){return!e[c]})||(l().forEach(function(e){return _.set(e,c,t)}),u())})(i.selectAll)},getValueReference:n,getValueContext:r,valuesMatch:o,allValuesMatch:function(t){return _.every(t.properties,function(e){return o(t.key,e.key)})},fragmentExistsInContext:function(e){return!!_.get(i.context,e)},isPropertyVisible:s,isSchemaMatchVisible:e,countSyncedProperties:h,countUnsyncedProperties:function(e){var t=e.properties;return Object.keys(t).length-h(e)},updateSelectAll:u,onSelectChangeMatchSchema:function(e){var t=e[c],e=_.filter(e.properties,function(e){return!o(e.schemaMatchKey,e.key)});_.forEach(e,function(e){return _.set(e,c,t)}),u()},onSelectChangeProperty:function(e){var t=e.schemaMatchKey,e=_.find(i.schemaMatches,function(e){return e.key===t}),n=_.filter(e.properties,function(e){return!o(e.schemaMatchKey,e.key)});e[c]=_.every(n,c),u()},allSynced:function(){return i.matches&&_.every(i.matches,e)},SELECTED:c})}e.$inject=["c8yGenericUi"],angular.module("c8y.configAudit").component("c8yConfigAuditDiff",{templateUrl:":::PLUGIN_PATH:::/config-audit/config-audit-diff.html",controllerAs:"vm",controller:e,bindings:{context:"<",schemas:"<",reference:"<",onSchemaMatch:"&",hideSynced:"<",disableSelectAll:"&",selectAll:"<",onSelect:"&"}})})();