text: /*!
   * UI development toolkit for HTML5 (OpenUI5)
   * (c) Copyright 2009-2017 SAP SE or an SAP affiliate company.
   * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
   */
  sap.ui.define(["jquery.sap.global","sap/ui/model/ChangeReason","sap/ui/model/PropertyBinding","./lib/_Cache","./lib/_SyncPromise","./ODataBinding"],function(q,C,P,_,a,b){"use strict";var c="sap.ui.model.odata.v4.ODataPropertyBinding",d=a.resolve({}),s={AggregatedDataStateChange:true,change:true,dataReceived:true,dataRequested:true,DataStateChange:true};var O=P.extend("sap.ui.model.odata.v4.ODataPropertyBinding",{constructor:function(m,p,o,e){var B;P.call(this,m,p);if(p.slice(-1)==="/"){throw new Error("Invalid path: "+p);}B=this.oModel.buildBindingParameters(e,["$$groupId"]);this.oCheckUpdateCallToken=undefined;this.sGroupId=B.$$groupId;this.mQueryOptions=this.oModel.buildQueryOptions(e,false);this.oCachePromise=a.resolve();this.fetchCache(o);this.oContext=o;this.bInitial=true;this.sPathWithFetchTypeError=undefined;this.vValue=undefined;m.bindingCreated(this);},metadata:{publicMethods:[]}});b(O.prototype);O.prototype.attachEvent=function(e){if(!(e in s)){throw new Error("Unsupported event '"+e+"': v4.ODataPropertyBinding#attachEvent");}return P.prototype.attachEvent.apply(this,arguments);};O.prototype.checkUpdate=function(f,e,g){var o={},h={reason:e||C.Change},D=false,F=false,m=this.oModel.getMetaModel(),p,i,j=[],r,R,k=this.oModel.resolve(this.sPath,this.oContext),t=this;this.oCheckUpdateCallToken=o;if(!k){i=Promise.resolve();if(t.vValue!==undefined){i=i.then(function(){t._fireChange(h);});}t.vValue=undefined;return i;}R=m.getMetaPath(k);if(R!==this.sPathWithFetchTypeError&&!this.oType&&this.sInternalType!=="any"){j.push(m.fetchUI5Type(k).then(function(T){t.setType(T,t.sInternalType);})["catch"](function(E){t.sPathWithFetchTypeError=R;q.sap.log.warning(E.message,k,c);}));}r=this.oCachePromise.then(function(l){if(l){g=g||t.getGroupId();return l.fetchValue(g,undefined,function(){D=true;t.fireDataRequested();},t);}if(!t.oContext){return undefined;}if(t.oContext.getIndex()===-2){f=false;}return t.oContext.fetchValue(t.sPath,t);});j.push(r.then(function(v){if(v&&typeof v==="object"){q.sap.log.error("Accessed value is not primitive",k,c);v=undefined;}F=t.vValue!==v;t.vValue=v;})["catch"](function(E){t.oModel.reportError("Failed to read path "+k,c,E);if(!E.canceled){p={error:E};if(t.oCheckUpdateCallToken===o){F=t.vValue!==undefined;t.vValue=undefined;}}return E.canceled;}));return Promise.all(j).then(function(l){var n=l[j.length-1];if(!n){t.bInitial=false;if(f||F){t._fireChange(h);}}if(D){t.fireDataReceived(p);}});};O.prototype.destroy=function(){var o=this.oContext,t=this;this.oCachePromise.then(function(e){if(e){e.deregisterChange(undefined,t);}else if(o){o.deregisterChange(t.sPath,t);}});this.oModel.bindingDestroyed(this);this.oCachePromise=undefined;this.oContext=undefined;P.prototype.destroy.apply(this,arguments);};O.prototype.doCreateCache=function(r,Q){return _.createProperty(this.oModel.oRequestor,r,Q);};O.prototype.doFetchQueryOptions=function(){return d;};O.prototype.getUnitOrCurrencyPath=function(p){var m=this.oModel.getMetaModel(),r=this.oModel.resolve(this.sPath,this.oContext),A=m.getObject("@",m.getMetaContext(r)),M=A["@Org.OData.Measures.V1.Unit"]||A["@Org.OData.Measures.V1.ISOCurrency"];return M&&M.$Path;};O.prototype.getValue=function(){return this.vValue;};O.prototype.getValueListType=function(){var r=this.getModel().resolve(this.sPath,this.oContext);if(!r){throw new Error(this+" is not resolved yet");}return this.getModel().getMetaModel().getValueListType(r);};O.prototype.onChange=function(v){this.vValue=v;this._fireChange({reason:C.Change});};O.prototype.refreshInternal=function(g,e){this.fetchCache(this.oContext);if(e){this.checkUpdate(true,C.Refresh,g);}};O.prototype.requestValueListInfo=function(){var r=this.getModel().resolve(this.sPath,this.oContext);if(!r){throw new Error(this+" is not resolved yet");}return this.getModel().getMetaModel().requestValueListInfo(r);};O.prototype.requestValueListType=function(){var r=this.getModel().resolve(this.sPath,this.oContext);if(!r){throw new Error(this+" is not resolved yet");}return this.getModel().getMetaModel().requestValueListType(r);};O.prototype.resetInvalidDataState=function(){if(this.getDataState().isControlDirty()){this._fireChange({reason:C.Change});}};O.prototype.setContext=function(o){if(this.oContext!==o){if(this.bRelative&&this.oContext&&this.oContext.deregisterChange){this.oContext.deregisterChange(this.sPath,this);}this.oContext=o;if(this.bRelative){this.fetchCache(this.oContext);this.checkUpdate(false,C.Context);}}};O.prototype.setType=function(t){var o=this.oType;if(t&&t.getName()==="sap.ui.model.odata.type.DateTimeOffset"){t.setV4();}P.prototype.setType.apply(this,arguments);if(!this.bInitial&&o!==t){this._fireChange({reason:C.Change});}};O.prototype.setValue=function(v,g){var t=this;function r(e){t.oModel.reportError("Failed to update path "+t.oModel.resolve(t.sPath,t.oContext),c,e);}if(typeof v==="function"||(v&&typeof v==="object")){throw new Error("Not a primitive value");}this.oModel.checkGroupId(g);if(this.vValue!==v){this.oCachePromise.then(function(o){if(o){q.sap.log.error("Cannot set value on this binding",t.oModel.resolve(t.sPath,t.oContext),c);}else if(t.oContext){t.oModel.getMetaModel().fetchUpdateData(t.sPath,t.oContext).then(function(R){return t.oContext.getBinding().updateValue(g,R.propertyPath,v,r,R.editUrl,R.entityPath,t.getUnitOrCurrencyPath(R.propertyPath));})["catch"](function(e){if(!e.canceled){r(e);}});}else{q.sap.log.warning("Cannot set value on relative binding without context",t.sPath,c);}});}};O.prototype.toString=function(){return c+": "+(this.bRelative?this.oContext+"|":"")+this.sPath;};return O;});
  