//>>built
define("mill/jssupport/form/_FormContentUtils","dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/_base/Deferred dojo/date dojo/when dojo/DeferredList dojo/query dojo/dom-style dijit/registry mill/jssupport/form/SelectListField mill/jssupport/base".split(" "),function(q,f,n,l,r,t,p,u,x,v,y,k){return mill.registerAlias("office.form._FormContentUtils",q("mill.jssupport.form._FormContentUtils",null,{getCarouselViewSlide:function(){for(var a=this;!a.isInstanceOf(office.layout._CarouselViewSlide)&&
a.getParent();)a=a.getParent();return a.isInstanceOf(office.layout._CarouselViewSlide)?a:null},getMenuItemTitle:function(){var a=this.getCarouselViewSlide();return a?a._layoutMenuItemWidget?a._layoutMenuItemWidget.get("text"):"":""},setWidgetHasDataValue:function(a,c){var b=new l,d=this.getFormWidget(a);if(d)return c||d.isInstanceOf(office.form.SelectListWidget)?(d.isInstanceOf(dijit.form.CheckBox)&&(c="1"===c),f.isObject(c)?(d.set("_savedValue",c)&&d.translate(),b.resolve()):d.isInstanceOf(office.form.FilteringSelectWidget)?
d.updateItem(c).then(b.resolve):(d.set("value",c),b.resolve())):b.resolve(),b.promise;b.resolve()},_setWidgetChainHasDataValueHandler:null,setWidgetChainHasDataValue:function(a){this._preventClearWidgetChildren=!0;var c=new l;this._setWidgetChainHasDataValueHandler||(this._setWidgetChainHasDataValueHandler=[]);var b=f.hitch(this,function(e){var g=this._setWidgetChainHasDataValueHandler.slice(),h=new l;this._setWidgetChainHasDataValueHandler.push(h);(new p(g)).then(f.hitch(this,function(){t(this.setWidgetHasDataValue(e,
a[e]),h.resolve)}))}),d;for(d in a)b(d);(new p(this._setWidgetChainHasDataValueHandler)).then(f.hitch(this,function(){this._preventClearWidgetChildren=!1;c.resolve()}));return c.promise},setAttachmentWidgetHasDataValue:function(a,c,b){if(b){var d=[b.className,b.propName,b.ID];b.fileName&&b.extension&&d.push(b.fileName,b.extension);d=d.join("','");c="\x3ca href\x3d\"javascript:base.downloadBlob('"+d+"')\""+(c?"":"style\x3d'text-decoration:none'")+"\x3e"+(c||"\x3cspan class\x3d'icon-set-attachment'\x3e\x3c/span\x3e")+
"\x3c/a\x3e"}c&&this.formWidgets[a]&&this.formWidgets[a].widget&&f.isFunction(this.formWidgets[a].widget._onComplete)&&this.formWidgets[a].widget._onComplete({name:c},!0)},setDependentWidgetsChainHasDataValue:function(a,c,b){var d=new l;require(["mill/mill"],f.hitch(this,function(e){var g=f.hitch(this,function(h){var m=e.fieldValue(c,a[h]);(m=m||(b&&f.isArray(b)?e.fieldValue(c,b[h]):""))&&l.when(this.formWidgets[a[h]].widget.updateItem(m),f.hitch(this,function(){h<a.length-1?g(h+1):d.resolve()}))});
g(0)}));return d.promise},_setCountry:function(a,c,b){var d=new l;"\u0420\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u0430\u044f \u0424\u0435\u0434\u0435\u0440\u0430\u0446\u0438\u044f"===a||"1"===a?this.formWidgets[b].widget.store.query({Description:"\u0420\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u0430\u044f \u0424\u0435\u0434\u0435\u0440\u0430\u0446\u0438\u044f"}).then(f.hitch(this,function(e){this.formWidgets[b].widget.set("item",e[0]);d.resolve()}),d.reject):this.formWidgets[b].widget.updateItem(c).then(d.resolve,
d.reject);return d.promise},_setRegion:function(a,c){var b=new l;this.formWidgets[a].widget.updateItem(c).then(b.resolve,b.reject);return b.promise},setCountryAndRegion:function(a,c,b,d){var e=new l;this.getFormWidget(b)&&this.getFormWidget(d)?this._setCountry(a,c,b,d).then(f.hitch(this,function(){this._setRegion(d,c).then(e.resolve,e.reject)}),e.reject):e.resolve();return e.promise},setMultipleAttachmentWidgetHasDataValue:function(a,c){var b=this[a];b&&b.setHasDataValue(c)},hideMultipleAttachmentWidgetHasDataValue:function(a,
c,b,d,e){(a=this[a])&&a.setHasDataValue(c,b,d,e);a.hideForValue()},getUploadedAttachmentFileName:function(a){return this.formWidgets[a].widget._uploadedFile?this.formWidgets[a].widget._uploadedFile.name:""},getField:function(a,c){var b=this.getFormWidget(a);if(b){for(;!b.isInstanceOf(office.form._FieldMixin)&&b.getParent();)b=b.getParent();b.isInstanceOf(office.form._FieldMixin)||(b=null);b&&f.isFunction(c)&&c.call(this,b);return b}return null},getMultipleAttachments:function(){return n.map(u(".officeMultipleAttachmentField",
this.containerNode),function(a){return v.byNode(a)})},hideDependentWidgetsChainHasDataValue:function(a,c,b){var d=new l;this.setDependentWidgetsChainHasDataValue(a,c,b).then(f.hitch(this,function(){for(var e={},g=0;g<a.length;g++)e[a[g]]=this.formWidgets[a[g]].widget.value;this.hideForValue(e,{hideMultiples:!1});d.resolve()}));return d.promise},hideCountryAndRegion:function(a,c,b,d){var e=new l;this.getFormWidget(b)&&this.getFormWidget(d)?this._setCountry(a,c,b).then(f.hitch(this,function(){this.formWidgets[b].widget.hideForValue(this.formWidgets[b].widget.value);
this._setRegion(d,c).then(f.hitch(this,function(){l.when(this.updateDependentWidget(d),f.hitch(this,function(){this.formWidgets[d].widget.hideForValue(this.formWidgets[d].widget.value).then(e.resolve)}))}))})):e.resolve();return e.promise},hideMultipleAttachments:function(){n.forEach(this.getMultipleAttachments(),function(a){a.hideForValue()})},unhideMultipleAttachments:function(){n.forEach(this.getMultipleAttachments(),function(a){a.unhideForValue()})},updateDependentWidget:function(a,c){var b=new l,
d=this.formWidgets[a].widget.get("item");if(d){var e=f.isFunction(this.formWidgets[a].widget.store.getValue)?this.formWidgets[a].widget.store.getValue(d,"ID"):d.ID;this.formWidgets[a].widget.set("item",null)}var g=f.hitch(this,function(m){1===m.length?(this.formWidgets[a].widget.set("item",m[0]),b.resolve()):e?f.isFunction(this.formWidgets[a].widget.store.fetchItemByIdentity)?this.formWidgets[a].widget.store.fetchItemByIdentity({identity:e,onItem:f.hitch(this,function(w){this.formWidgets[a].widget.set("item",
w)})}).then(b.resolve):(this.formWidgets[a].widget.store.query({ID:e})[0]&&this.formWidgets[a].widget.set("item",d),b.resolve()):b.resolve();this.formWidgets[a].widget.set("disabled","boolean"===typeof c?c:1===m.length)}),h=this.formWidgets[a].widget.store.query({ID:"*"});f.isArray(h)?g(h):h.then(g);return b.promise},setCharactersRemaining:function(a,c,b){(c=b.getFieldWidget())&&c.charactersRemainingWidget&&c.charactersRemainingWidget.set("text","Office.CharactersRemaining;: ;"+(b.maxLength-mill.normalizeLineBreaks(a).length))},
dateFormat:/^(((0[1-9]|[12]\d|3[01])\.(0[13578]|1[02])\.((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\.(0[13456789]|1[012])\.((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\.02\.((19|[2-9]\d)\d{2}))|(29\.02\.((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$/,dateInFuture:function(a){return 0<r.compare(mill.parseDate(a),mill.serverDate(k.mainHandler))},dateValidator:function(){var a=this.dateFormat;return function(c){return!this.required&&!c||a.test(c)}},timeFormat:/^\d\d:\d\d$/,
timeValidator:function(){var a=this.timeFormat;return function(c){return!this.required&&!c||a.test(c)}},emailValidator:function(a,c,b){var d=c=null,e="";"acSchoolOlymp"===k.accessCategory||"acStudOlymp"===k.accessCategory?(c=a.match(eval(k.getLocalization("Office.OlympMailRegExp","RU"))),d=!n.filter(k.getLocalization("Office.OlympInvalidMailDomains","RU").split(";"),function(g){var h=!a.match(new RegExp(g,"ig"));h||(e=k.getLocalization("Office.OlympInvalidMailDomainMessage").replace(/%domainName%/,
g));return!h}).length):(c=a.match(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,1000}))$/),d=!a.match(RegExp("\\@yahoo\\.","ig")));if(b||this.emailField)b?b.set("invalidMessageIdentifier",c&&!d?e||"Office.YahooConflict":"Office.DefaultInvalidMessage"):this.emailField&&this.emailField.set("invalidMessage",c&&!d?e||"Office.YahooConflict":"Office.DefaultInvalidMessage");return c&&d},emailConfirmValidator:function(a){return!!a&&
a===this.emailField.controlNode.get("value")},countryStore:function(){return k.domainStore("TCountry","TCountry (Descr) non required (no sections)",null,["Name","Description","EngDescription"])},regionStore:function(a){return k.domainStore("TCountry","TRFRegion of Country domain",[{domain:"TObject domain",name:"Country",value:f.hitch(this,function(){return this.formWidgets[a].widget.value||"1"})}])},notAnnulledCountryStore:function(){return k.domainStore("TCountry","TCountry (Descr) non required (no sections) (not annulled)",
null,["Name","Description","EngDescription"])},notAnnulledRegionStore:function(a){return k.domainStore("TCountry","TRFRegion of Country domain (not annulled)",[{domain:"TObject domain",name:"Country",value:f.hitch(this,function(){return this.formWidgets[a].widget.value||"1"})}])},cityTypeStore:function(){return k.enumerationStore("TCityType",!0)},campusStore:function(){return k.domainStore("TRegDepartment","TRegDepartment for postgraduate abit",[{domain:"TObject domain",name:"AdmYear",value:k.admissionYear}])}}))});