text: /*!
   * OpenUI5
   * (c) Copyright 2009-2022 SAP SE or an SAP affiliate company.
   * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
   */
  sap.ui.define(["./lib/_Helper","sap/ui/base/SyncPromise","sap/ui/model/ChangeReason","sap/ui/model/odata/OperationMode","sap/ui/model/odata/v4/Context"],function(e,t,n,i,r){"use strict";var o=[n.Context,n.Change,n.Refresh,n.Sort,n.Filter],s="sap.ui.model.odata.v4.ODataBinding",a=/\/\d|\(\$uid=/;function h(e,t){return o.indexOf(e)>o.indexOf(t)}function u(){this.mCacheByResourcePath=undefined;this.oCache=null;this.oCachePromise=t.resolve(null);this.mCacheQueryOptions=undefined;this.oFetchCacheCallToken=undefined;this.mLateQueryOptions=undefined;this.sReducedPath=undefined;this.sResumeChangeReason=undefined}u.prototype.adjustPredicate=function(e,t){this.sReducedPath=this.sReducedPath.replace(e,t)};u.prototype.assertSameCache=function(e){var t;if(this.oCache!==e){t=new Error(this+" is ignoring response from inactive cache: "+e);t.canceled=true;throw t}};u.prototype.checkBindingParameters=function(e,t){var n=this;Object.keys(e).forEach(function(r){var o=e[r];if(!r.startsWith("$$")){return}if(t.indexOf(r)<0){throw new Error("Unsupported binding parameter: "+r)}switch(r){case"$$aggregation":break;case"$$groupId":case"$$updateGroupId":n.oModel.checkGroupId(o,false,"Unsupported value for binding parameter '"+r+"': ");break;case"$$ignoreMessages":if(o!==true&&o!==false){throw new Error("Unsupported value for binding parameter "+"'$$ignoreMessages': "+o)}break;case"$$inheritExpandSelect":if(o!==true&&o!==false){throw new Error("Unsupported value for binding parameter "+"'$$inheritExpandSelect': "+o)}if(!n.oOperation){throw new Error("Unsupported binding parameter $$inheritExpandSelect: "+"binding is not an operation binding")}if(e.$expand){throw new Error("Must not set parameter $$inheritExpandSelect on a binding "+"which has a $expand binding parameter")}break;case"$$operationMode":if(o!==i.Server){throw new Error("Unsupported operation mode: "+o)}break;case"$$canonicalPath":case"$$noPatch":case"$$ownRequest":case"$$patchWithoutSideEffects":case"$$sharedRequest":if(o!==true){throw new Error("Unsupported value for binding parameter '"+r+"': "+o)}break;default:throw new Error("Unknown binding-specific parameter: "+r)}})};u.prototype.checkSuspended=function(e){var t=this.getRootBinding();if(t&&t.isSuspended()&&(!e||this.isRoot()||this.getResumeChangeReason())){throw new Error("Must not call method when the binding's root binding is suspended: "+this)}};u.prototype.checkUpdate=function(e){var t=this;if(arguments.length>1){throw new Error("Only the parameter bForceUpdate is supported")}this.checkUpdateInternal(e).catch(function(e){t.oModel.reportError("Failed to update "+t,s,e)})};u.prototype.createAndSetCache=function(t,n,i,r,o){var s,a,h;this.mCacheQueryOptions=Object.assign({},this.oModel.mUriParameters,t);if(this.bRelative){if(i.isTransient&&i.isTransient()&&i.getProperty("@$ui5.context.isTransient")){this.oCache=null;return null}s=this.mCacheByResourcePath&&this.mCacheByResourcePath[n];h=i.getGeneration&&i.getGeneration()||0;if(s&&s.$generation>=h){s.setActive(true)}else{a=e.buildPath(i.getPath(),this.sPath).slice(1);s=this.doCreateCache(n,this.mCacheQueryOptions,i,a,r,o);if(!(this.mParameters&&this.mParameters.$$sharedRequest)){this.mCacheByResourcePath=this.mCacheByResourcePath||{};this.mCacheByResourcePath[n]=s}s.$deepResourcePath=a;s.$generation=h}}else{s=this.doCreateCache(n,this.mCacheQueryOptions,undefined,undefined,r,o)}if(o!==s){if(o){o.setActive(false)}if(this.mLateQueryOptions){s.setLateQueryOptions(this.mLateQueryOptions)}}this.oCache=s;return s};u.prototype.destroy=function(){this.mCacheByResourcePath=undefined;this.oCachePromise.then(function(e){if(e){e.setActive(false)}},function(){});this.oCache=null;this.oCachePromise=t.resolve(null);this.mCacheQueryOptions=undefined;this.oContext=undefined;this.oFetchCacheCallToken=undefined};u.prototype.doDeregisterChangeListener=function(e,t){this.oCache.deregisterChange(e,t)};u.prototype.fetchCache=function(e,n,i,o){var a=this.oCache,h={oOldCache:a===undefined?this.oFetchCacheCallToken.oOldCache:a},u,c=this;if(!this.bRelative){e=undefined}if(!a&&i){if(a===undefined){throw new Error("Unsupported bKeepQueryOptions while oCachePromise is pending")}return}this.oCache=undefined;this.oFetchCacheCallToken=h;if(i){this.oCachePromise=t.resolve(Promise.resolve()).then(function(){return c.createAndSetCache(c.mCacheQueryOptions,a.getResourcePath(),e,o,a)});return}u=[this.fetchQueryOptionsForOwnCache(e,n),this.oModel.oRequestor.ready()];this.mCacheQueryOptions=undefined;this.oCachePromise=t.all(u).then(function(t){var n=t[0].mQueryOptions;c.sReducedPath=t[0].sReducedPath;if(n&&!(e&&e.iIndex===r.VIRTUAL)){return c.fetchResourcePath(e).then(function(t){var i;if(c.oFetchCacheCallToken!==h){i=new Error("Cache discarded as a new cache has been created");i.canceled=true;throw i}return c.createAndSetCache(n,t,e,o,h.oOldCache)})}c.oCache=null;return null});this.oCachePromise.catch(function(e){c.oModel.reportError("Failed to create cache for binding "+c,s,e)})};u.prototype.fetchQueryOptionsForOwnCache=function(e,n){var i,r,o=this.oModel.resolve(this.sPath,e),s=this;function a(e,n){return t.resolve(e).then(function(e){return{mQueryOptions:e,sReducedPath:n||o}})}if(this.oOperation||this.bRelative&&!e||this.isMeta()){return a(undefined)}r=this.doFetchQueryOptions(e);if(this.oModel.bAutoExpandSelect&&this.aChildCanUseCachePromises&&!(this.mParameters&&this.mParameters.$$aggregation)){r=t.all([r,Promise.resolve().then(function(){return t.all(s.aChildCanUseCachePromises)})]).then(function(e){s.aChildCanUseCachePromises=[];s.updateAggregatedQueryOptions(e[0]);return s.mAggregatedQueryOptions})}if(n||!this.bRelative||!e.fetchValue){return a(r)}if(this.oModel.bAutoExpandSelect){i=this.mParameters&&Object.keys(s.mParameters).some(function(e){return e[0]!=="$"||e[1]==="$"});if(i){return a(r)}return e.getBinding().fetchIfChildCanUseCache(e,s.sPath,r).then(function(e){return a(e?undefined:r,e)})}if(this.mParameters&&Object.keys(this.mParameters).length){return a(r)}return r.then(function(e){return a(Object.keys(e).length?e:undefined)})};u.prototype.fetchResourcePath=function(n){var i,r,o,s=this;if(!this.bRelative){return t.resolve(this.sPath.slice(1))}n=n||this.oContext;if(!n){return t.resolve()}r=n.getPath();i=n.fetchCanonicalPath&&(this.mParameters&&this.mParameters.$$canonicalPath||a.test(r));o=i?n.fetchCanonicalPath():t.resolve(r);return o.then(function(t){return e.buildPath(t,s.sPath).slice(1)})};u.prototype.getGroupId=function(){return this.sGroupId||this.bRelative&&this.oContext&&this.oContext.getGroupId&&this.oContext.getGroupId()||this.oModel.getGroupId()};u.prototype.getRelativePath=function(t){var n;if(t[0]==="/"){n=e.getRelativePath(t,this.getResolvedPath());if(n===undefined&&this.oReturnValueContext){n=e.getRelativePath(t,this.oReturnValueContext.getPath())}return n}return t};u.prototype.getResumeChangeReason=function(){var e=this.sResumeChangeReason;this.getDependentBindings().forEach(function(t){var n=t.getResumeChangeReason();if(n&&h(n,e)){e=n}});return e};u.prototype.getRootBinding=function(){if(this.bRelative){if(!this.oContext){return undefined}if(this.oContext.getBinding){return this.oContext.getBinding().getRootBinding()}}return this};u.prototype.getRootBindingResumePromise=function(){var e=this.getRootBinding();return e&&e.getResumePromise()||t.resolve()};u.prototype.getUpdateGroupId=function(){return this.sUpdateGroupId||this.bRelative&&this.oContext&&this.oContext.getUpdateGroupId&&this.oContext.getUpdateGroupId()||this.oModel.getUpdateGroupId()};u.prototype.hasPendingChanges=function(e){return this.isResolved()&&(this.hasPendingChangesForPath("",e)||this.hasPendingChangesInDependents(e))};u.prototype.hasPendingChangesForPath=function(e,t){return this.withCache(function(e,n){return e.hasPendingChangesForPath(n,t)},e,true).unwrap()};u.prototype.hasPendingChangesInCaches=function(e){var t=this;if(!this.mCacheByResourcePath){return false}return Object.keys(this.mCacheByResourcePath).some(function(n){var i=t.mCacheByResourcePath[n];return i.$deepResourcePath.startsWith(e)&&i.hasPendingChangesForPath("")})};u.prototype.isInitial=function(){throw new Error("Unsupported operation: isInitial")};u.prototype.isRoot=function(){return!this.bRelative||this.oContext&&!this.oContext.getBinding};u.prototype.isRootBindingSuspended=function(){var e=this.getRootBinding();return e&&e.isSuspended()};u.prototype.lockGroup=function(e,t,n,i){e=e||(n?this.getUpdateGroupId():this.getGroupId());return this.oModel.lockGroup(e,this,t,n,i)};u.prototype.refresh=function(e){if(typeof e==="boolean"){throw new Error("Unsupported parameter bForceUpdate")}this.requestRefresh(e).catch(this.oModel.getReporter())};u.prototype.removeCachesAndMessages=function(t,n){var i=this;if(!n&&this.oCache){this.oCache.removeMessages()}if(this.mCacheByResourcePath){Object.keys(this.mCacheByResourcePath).forEach(function(r){var o=i.mCacheByResourcePath[r],s=o.$deepResourcePath;if(e.hasPathPrefix(s,t)){if(!n){o.removeMessages()}delete i.mCacheByResourcePath[r]}})}};u.prototype.requestAbsoluteSideEffects=function(t,n){var i=[],r=e.getMetaPath(this.getResolvedPath());n.some(function(t){var n=e.getRelativePath(t,r);if(n!==undefined){i.push(n)}else if(e.hasPathPrefix(r,t)){i=[""];return true}});if(i.length){if(this.requestSideEffects){return this.requestSideEffects(t,i)}return this.refreshInternal("",t,true,true)}};u.prototype.requestRefresh=function(e){if(!this.isRoot()){throw new Error("Refresh on this binding is not supported")}if(this.hasPendingChanges()){throw new Error("Cannot refresh due to pending changes")}this.oModel.checkGroupId(e);return Promise.resolve(this.refreshInternal("",e,true)).then(function(){})};u.prototype.resetChanges=function(){var e=[];this.checkSuspended();this.resetChangesForPath("",e);this.resetChangesInDependents(e);this.resetInvalidDataState();return Promise.all(e).then(function(){})};u.prototype.resetChangesForPath=function(e,t){t.push(this.withCache(function(e,t){e.resetChangesForPath(t)},e).unwrap())};u.prototype.resetInvalidDataState=function(){};u.prototype.setResumeChangeReason=function(e){if(h(e,this.sResumeChangeReason)){this.sResumeChangeReason=e}};u.prototype.toString=function(){return this.getMetadata().getName()+": "+(this.bRelative?this.oContext+"|":"")+this.sPath};u.prototype.withCache=function(n,i,r,o){var s=r?t.resolve(this.oCache):this.oCachePromise,a,h=this;i=i||"";return s.then(function(t){if(t){a=h.getRelativePath(i);if(a!==undefined){return n(t,a,h)}}else if(t===undefined){return undefined}else if(h.oOperation){return o?n(null,h.getRelativePath(i),h):undefined}if(h.bRelative&&h.oContext&&h.oContext.withCache){return h.oContext.withCache(n,i[0]==="/"?i:e.buildPath(h.sPath,i),r,o)}return undefined})};function c(e){if(this){u.apply(this,arguments)}else{Object.assign(e,u.prototype)}}["adjustPredicate","destroy","doDeregisterChangeListener","hasPendingChangesForPath"].forEach(function(e){c.prototype[e]=u.prototype[e]});return c},false);