"),i.on("blur.tt",(function(t){var n,a,o;n=document.activeElement,a=r.is(n),o=r.has(n).length>0,e.isMsie()&&(a||o)&&(t.preventDefault(),t.stopImmediatePropagation(),e.defer((function(){i.focus()})))})),r.on("mousedown.tt",(function(t){t.preventDefault()}))},_onSelectableClicked:function t(e,n){this.select(n)},_onDatasetCleared:function t(){this._updateHint()},_onDatasetRendered:function t(e,n,i,r){this._updateHint(),this.eventBus.trigger("render",i,r,n)},_onAsyncRequested:function t(e,n,i){this.eventBus.trigger("asyncrequest",i,n)},_onAsyncCanceled:function t(e,n,i){this.eventBus.trigger("asynccancel",i,n)},_onAsyncReceived:function t(e,n,i){this.eventBus.trigger("asyncreceive",i,n)},_onFocused:function t(){this._minLengthMet()&&this.menu.update(this.input.getQuery())},_onBlurred:function t(){this.input.hasQueryChangedSinceLastFocus()&&this.eventBus.trigger("change",this.input.getQuery())},_onEnterKeyed:function t(e,n){var i;(i=this.menu.getActiveSelectable())&&this.select(i)&&n.preventDefault()},_onTabKeyed:function t(e,n){var i;(i=this.menu.getActiveSelectable())?this.select(i)&&n.preventDefault():(i=this.menu.getTopSelectable())&&this.autocomplete(i)&&n.preventDefault()},_onEscKeyed:function t(){this.close()},_onUpKeyed:function t(){this.moveCursor(-1)},_onDownKeyed:function t(){this.moveCursor(1)},_onLeftKeyed:function t(){"rtl"===this.dir&&this.input.isCursorAtEnd()&&this.autocomplete(this.menu.getTopSelectable())},_onRightKeyed:function t(){"ltr"===this.dir&&this.input.isCursorAtEnd()&&this.autocomplete(this.menu.getTopSelectable())},_onQueryChanged:function t(e,n){this._minLengthMet(n)?this.menu.update(n):this.menu.empty()},_onWhitespaceChanged:function t(){this._updateHint()},_onLangDirChanged:function t(e,n){this.dir!==n&&(this.dir=n,this.menu.setLanguageDirection(n))},_openIfActive:function t(){this.isActive()&&this.open()},_minLengthMet:function t(n){return(n=e.isString(n)?n:this.input.getQuery()||"").length>=this.minLength},_updateHint:function t(){var n,i,r,a,s,u,l;n=this.menu.getTopSelectable(),i=this.menu.getSelectableData(n),r=this.input.getInputValue(),!i||e.isBlankString(r)||this.input.hasOverflow()?this.input.clearHint():(a=o.normalizeQuery(r),s=e.escapeRegExChars(a),(l=(u=new RegExp("^(?:"+s+")(.+$)","i")).exec(i.val))&&this.input.setHint(r+l[1]))},isEnabled:function t(){return this.enabled},enable:function t(){this.enabled=!0},disable:function t(){this.enabled=!1},isActive:function t(){return this.active},activate:function t(){return!!this.isActive()||!(!this.isEnabled()||this.eventBus.before("active"))&&(this.active=!0,this.eventBus.trigger("active"),!0)},deactivate:function t(){return!this.isActive()||!this.eventBus.before("idle")&&(this.active=!1,this.close(),this.eventBus.trigger("idle"),!0)},isOpen:function t(){return this.menu.isOpen()},open:function t(){return this.isOpen()||this.eventBus.before("open")||(this.menu.open(),this._updateHint(),this.eventBus.trigger("open")),this.isOpen()},close:function t(){return this.isOpen()&&!this.eventBus.before("close")&&(this.menu.close(),this.input.clearHint(),this.input.resetInputValue(),this.eventBus.trigger("close")),!this.isOpen()},setVal:function t(n){this.input.setQuery(e.toStr(n))},getVal:function t(){return this.input.getQuery()},select:function t(e){var n=this.menu.getSelectableData(e);return!(!n||this.eventBus.before("select",n.obj)||(this.input.setQuery(n.val,!0),this.eventBus.trigger("select",n.obj),this.close(),0))},autocomplete:function t(e){var n,i,r;return n=this.input.getQuery(),!(!(r=(i=this.menu.getSelectableData(e))&&n!==i.val)||this.eventBus.before("autocomplete",i.obj)||(this.input.setQuery(i.val),this.eventBus.trigger("autocomplete",i.obj),0))},moveCursor:function t(e){var n,i,r,a,o;return n=this.input.getQuery(),i=this.menu.selectableRelativeToCursor(e),a=(r=this.menu.getSelectableData(i))?r.obj:null,!(o=this._minLengthMet()&&this.menu.update(n))&&!this.eventBus.before("cursorchange",a)&&(this.menu.setCursor(i),r?this.input.setInputValue(r.val):(this.input.resetInputValue(),this._updateHint()),this.eventBus.trigger("cursorchange",a),!0)},destroy:function t(){this.input.destroy(),this.menu.destroy()}}),n;function i(t){var n=[].slice.call(arguments,1);return function(){var i=[].slice.call(arguments);e.each(n,(function(e){return t[e].apply(t,i)}))}}}();!function(){"use strict";var r,a,s;function d(e,n){e.each((function(){var e=t(this),i;(i=e.data(a.typeahead))&&n(i,e)}))}function f(t,e){return t.clone().addClass(e.classes.hint).removeData().css(e.css.hint).css(p(t)).prop("readonly",!0).removeAttr("id name placeholder required").attr({autocomplete:"off",spellcheck:"false",tabindex:-1})}function h(t,e){t.data(a.attrs,{dir:t.attr("dir"),autocomplete:t.attr("autocomplete"),spellcheck:t.attr("spellcheck"),style:t.attr("style")}),t.addClass(e.classes.input).attr({autocomplete:"off",spellcheck:!1});try{!t.attr("dir")&&t.attr("dir","auto")}catch(n){}return t}function p(t){return{backgroundAttachment:t.css("background-attachment"),backgroundClip:t.css("background-clip"),backgroundColor:t.css("background-color"),backgroundImage:t.css("background-image"),backgroundOrigin:t.css("background-origin"),backgroundPosition:t.css("background-position"),backgroundRepeat:t.css("background-repeat"),backgroundSize:t.css("background-size")}}function m(t){var n,i;n=t.data(a.www),i=t.parent().filter(n.selectors.wrapper),e.each(t.data(a.attrs),(function(n,i){e.isUndefined(n)?t.removeAttr(i):t.attr(i,n)})),t.removeData(a.typeahead).removeData(a.www).removeData(a.attr).removeClass(n.classes.input),i.length&&(t.detach().insertAfter(i),i.remove())}function g(n){var i,r;return(r=(i=e.isJQuery(n)||e.isElement(n))?t(n).first():[]).length?r:null}r=t.fn.typeahead,a={www:"tt-www",attrs:"tt-attrs",typeahead:"tt-typeahead"},s={initialize:function r(s,d){var p;return d=e.isArray(d)?d:[].slice.call(arguments,1),p=n((s=s||{}).classNames),this.each(m);function m(){var n,r,m,v,_,y,b,k,w,x,T;e.each(d,(function(t){t.highlight=!!s.highlight})),n=t(this),r=t(p.html.wrapper),m=g(s.hint),v=g(s.menu),_=!1!==s.hint&&!m,y=!1!==s.menu&&!v,_&&(m=f(n,p)),y&&(v=t(p.html.menu).css(p.css.menu)),m&&m.val(""),n=h(n,p),(_||y)&&(r.css(p.css.wrapper),n.css(_?p.css.input:p.css.inputWithNoHint),n.wrap(r).parent().prepend(_?m:null).append(y?v:null)),T=y?l:u,b=new i({el:n}),k=new o({hint:m,input:n},p),w=new T({node:v,datasets:d},p),x=new c({input:k,menu:w,eventBus:b,minLength:s.minLength},p),n.data(a.www,p),n.data(a.typeahead,x)}},isEnabled:function t(){var e;return d(this.first(),(function(t){e=t.isEnabled()})),e},enable:function t(){return d(this,(function(t){t.enable()})),this},disable:function t(){return d(this,(function(t){t.disable()})),this},isActive:function t(){var e;return d(this.first(),(function(t){e=t.isActive()})),e},activate:function t(){return d(this,(function(t){t.activate()})),this},deactivate:function t(){return d(this,(function(t){t.deactivate()})),this},isOpen:function t(){var e;return d(this.first(),(function(t){e=t.isOpen()})),e},open:function t(){return d(this,(function(t){t.open()})),this},close:function t(){return d(this,(function(t){t.close()})),this},select:function e(n){var i=!1,r=t(n);return d(this.first(),(function(t){i=t.select(r)})),i},autocomplete:function e(n){var i=!1,r=t(n);return d(this.first(),(function(t){i=t.autocomplete(r)})),i},moveCursor:function t(e){var n=!1;return d(this.first(),(function(t){n=t.moveCursor(e)})),n},val:function t(e){var n;return arguments.length?(d(this,(function(t){t.setVal(e)})),this):(d(this.first(),(function(t){n=t.getVal()})),n)},destroy:function t(){return d(this,(function(t,e){m(e),t.destroy()})),this}},t.fn.typeahead=function(t){return s[t]?s[t].apply(this,[].slice.call(arguments,1)):s.initialize.apply(this,arguments)},t.fn.typeahead.noConflict=function e(){return t.fn.typeahead=r,this}}()},"function"==typeof define&&define.amd?define("typeahead.js",["jquery"],(function(t){return a(t)})):"object"==typeof n?t.exports=a(e("jquery")):a(jQuery)}).call(this,t)}},"template.af-typeahead.js":function t(){N.__checkName("afTypeAhead"),N.afTypeAhead=new N("Template.afTypeAhead",(function(){var t=this;return R.DIV({class:"typeahead-basics"},"\n ",R.INPUT(R.Attrs({type:"text",value:function(){return M.mustache(M.dot(t.lookup("."),"value"))},placeholder:""},(function(){return M.attrMustache(M.dot(t.lookup("."),"atts"))}))),"\n ")}))},"af-typeahead.coffee":function t(){var e=P="object"==typeof P?P:{};b.addInputType("typeahead",{template:"afTypeAhead",valueIn:function(t,e){return t},valueOut:function(){return this.val()},valueConverters:{stringArray:b.valueConverters.stringToStringArray,number:b.valueConverters.stringToNumber,numerArray:b.valueConverters.stringToNumberArray,boolean:b.valueConverters.stringToBoolean,booleanArray:b.valueConverters.stringToBooleanArray,date:b.valueConverters.stringToDate,dateArray:b.valueConverters.stringToDateArray},contextAdjust:function(t){return void 0===t.atts.maxlength&&"number"==typeof t.max&&(t.atts.maxlength=t.max),t.atts.class="typeahead form-control",t}}),N.afTypeAhead.helpers,N.afTypeAhead.events,N.afTypeAhead.onRendered((function(){var t,e,n,i;return n=this.data.selectOptions,t=this.data.atts.id,e=this.data.name,i=function(t){return function(e,n){var i,r;return i=[],e?(r=new RegExp(e,"i"),$.each(t,(function(t,e){r.test(e)&&i.push(e)})),n(i)):n(t)}},$("#"+t).typeahead({hint:!1,highlight:!0,minLength:0},{name:e,limit:10,source:i(n.getProperty("label"))})}))}},"coreform-number":{"template.steedos-number.js":function t(){N.__checkName("afSteedosNumber"),N.afSteedosNumber=new N("Template.afSteedosNumber",(function(){var t=this;return R.INPUT(R.Attrs({type:"number",value:function(){return M.mustache(M.dot(t.lookup("."),"value"))}},(function(){return M.attrMustache(M.dot(t.lookup("."),"atts"))})))}))},"steedos-number.coffee":function t(){var e=P="object"==typeof P?P:{},n;b.addInputType("steedosNumber",{template:"afSteedosNumber",valueIn:function(t,e){return t?Number(t).toFixed(e.scale):(0).toFixed(e.scale)},valueOut:function(){return b.valueConverters.stringToNumber(this.val())},valueConverters:{string:b.valueConverters.numberToString,stringArray:b.valueConverters.numberToStringArray,numberArray:b.valueConverters.numberToNumberArray,boolean:b.valueConverters.numberToBoolean,booleanArray:b.valueConverters.numberToBooleanArray},contextAdjust:function(t){var e,n;return e=t.atts.scale||0,void 0===t.atts.max&&"number"==typeof t.max&&(t.atts.max=t.max),void 0===t.atts.min&&"number"==typeof t.min&&(t.atts.min=t.min),void 0===t.atts.step&&a.isNumber(e)&&e>0&&(n="0.",a.range(e).forEach((function(t,n){var i;return n===e-1?i+"1":i+"0"})),t.atts.step="0."),t.atts.class="form-control",t.precision=t.atts.precision,t.scale=t.atts.scale,t}}),n=function(t,e,n,i){var r,a;return a=b.getFormId(),r=new Number(t),t.indexOf(".")>-1?t.length-1>n?Number(t.substring(0,n-i-1)).toFixed(i):r.toFixed(i):t.length>n?Number(t.substring(0,n-i)).toFixed(i):r.toFixed(i)},N.afSteedosNumber.events({"blur input[type=number]":function(t,e){return t.currentTarget.value=n(t.currentTarget.value,this.atts.name,this.atts.precision,this.atts.scale)}})}},"coreform-date-mobile":{"template.date.js":function t(){N.__checkName("steedosInputDateMobile"),N.steedosInputDateMobile=new N("Template.steedosInputDateMobile",(function(){var t=this;return R.INPUT(R.Attrs({type:function(){return M.mustache(t.lookup("inputtype"))},value:function(){return M.mustache(M.dot(t.lookup("."),"value"))}},(function(){return M.attrMustache(t.lookup("atts"))})))}))},"date.js":function t(){b.addInputType("steedos-date-mobile",{template:"steedosInputDateMobile",valueIn:function(t,e){let n="datetime";return e.dateMobileOptions&&(n=e.dateMobileOptions.type),"string"==typeof t&&(t=new Date(t)),t="date"===n?k.utc(t).format("YYYY-MM-DD"):k(t).format("YYYY-MM-DDTHH:mm:ss")},valueOut:function(){let t=this.val(),e=this.attr("type");if(!t)return t;if("date"===e)return t;{let e;return(t=k.tz(b.Utility.dateToNormalizedLocalDateAndTimeString(t),"utc").toDate()).setHours(t.getHours()+t.getTimezoneOffset()/60),t}}}),N.steedosInputDateMobile.helpers({atts:function(){var t=a.clone(this.atts);return delete(t=b.Utility.addClass(t,"form-control")).dateMobileOptions,t},inputtype:function(){let t="datetime";switch(this.atts.dateMobileOptions&&(t=this.atts.dateMobileOptions.type),t){case"datetime":return"datetime-local";case"date":return"date";default:return"datetime-local"}}})}},"coreform-html":{"template.html.js":function t(){N.__checkName("steedosInputHtml"),N.steedosInputHtml=new N("Template.steedosInputHtml",(function(){var t=this;return j.If((function(){return M.call(t.lookup("isReadOnly"))}),(function(){return["\n ",R.DIV(R.Attrs((function(){return M.attrMustache(t.lookup("attsPlusFormControlClass"))})),"\n ",j.View("lookup:..value",(function(){return M.makeRaw(M.mustache(M.dot(t.lookup("."),"value")))})),"\n "),"\n ",R.INPUT(R.Attrs({type:"text",value:function(){return M.mustache(M.dot(t.lookup("."),"value"))},style:"display: none"},(function(){return M.attrMustache(M.dot(t.lookup("."),"atts"))}),(function(){return M.attrMustache(t.lookup("attsPlusFormControlClass"))}))),"\n "]}),(function(){return["\n ",R.INPUT(R.Attrs({type:"text",value:function(){return M.mustache(M.dot(t.lookup("."),"value"))}},(function(){return M.attrMustache(M.dot(t.lookup("."),"atts"))}),(function(){return M.attrMustache(t.lookup("attsPlusFormControlClass"))}))),"\n "]}))}))},"html.js":function t(){b.addInputType("steedosHtml",{template:"steedosInputHtml",valueConverters:{stringArray:b.valueConverters.stringToStringArray},contextAdjust:function(t){return void 0===t.atts.maxlength&&"number"==typeof t.max&&(t.atts.maxlength=t.max),t}}),N.steedosInputHtml.helpers({isReadOnly:function(){var t=this.atts;return!(!t.hasOwnProperty("disabled")&&!t.hasOwnProperty("readonly"))}})}}},components:{"slds-quickForm":{"template.slds-quickForm.js":function t(){N.__checkName("quickForm_slds"),N.quickForm_slds=new N("Template.quickForm_slds",(function(){var t=this;return R.DIV({class:function(){return["quickForm_slds ",j.If((function(){return M.call(t.lookup("horizontal"))}),(function(){return"horizontal"}))]}},"\n\t",j._TemplateWith((function(){return M.call(t.lookup("qfAutoFormContext"))}),(function(){return M.include(t.lookupTemplate("autoForm"),(function(){return["\n\t\t",j.If((function(){return M.call(M.dot(t.lookup("schemaFields"),"grouplessFields"))}),(function(){return["\n\t\t\t",j.Each((function(){return M.call(M.dot(t.lookup("schemaFields"),"grouplessFields"))}),(function(){return["\n\t\t\t\t",R.DIV({class:function(){return["slds-grid view-page-section-row ",j.If((function(){return M.dataMustache(t.lookup("has_wide_field"),t.lookup("."))}),(function(){return"wide-fields"}))]}},"\n\t\t\t\t\t",j.Each((function(){return M.call(t.lookup("."))}),(function(){return["\n\t\t\t\t\t\t",R.DIV({class:"slds-has-flexi-truncate slds-p-horizontal_x-small full view-page-block-item"},"\n\t\t\t\t\t\t\t",R.DIV({class:function(){return["slds-form-element slds-form-element_edit slds-grow slds-hint-parent slds-p-vertical_xx-small override--slds-form-element uiInput ",j.If((function(){return M.dataMustache(t.lookup("hasInlineHelpText"),t.lookup("."))}),(function(){return"has-inline-text"}))]}},"\n\t\t\t\t\t\t\t\t",j.If((function(){return M.dataMustache(t.lookup("is_range"),t.lookup("."))}),(function(){return["\n\t\t\t\t\t\t\t\t\t",M.include(t.lookupTemplate("range_field")),"\n\t\t\t\t\t\t\t\t"]}),(function(){return["\n\t\t\t\t\t\t\t\t\t",j.Unless((function(){return M.dataMustache(t.lookup("is_renge_end"),t.lookup("."))}),(function(){return["\n\t\t\t\t\t\t\t\t\t\t",j.If((function(){return M.call(t.lookup("."))}),(function(){return["\n\t\t\t\t\t\t\t\t\t\t\t",j.If((function(){return M.dataMustache(t.lookup("hasInlineHelpText"),t.lookup("."))}),(function(){return["\n\t\t\t\t\t\t\t\t\t\t\t\t",R.DIV({class:"info-popover",id:function(){return["info_popover_",M.mustache(t.lookup("."))]},style:"display: none"},j.View("lookup:hasInlineHelpText",(function(){return M.mustache(t.lookup("hasInlineHelpText"),t.lookup("."))}))),"\n\t\t\t\t\t\t\t\t\t\t\t"]})),"\n\t\t\t\t\t\t\t\t\t\t\t",j.If((function(){return M.call(t.lookup("horizontal"))}),(function(){return["\n\t\t\t\t\t\t\t\t\t\t\t\t",j._TemplateWith((function(){return{name:M.call(t.lookup(".")),class:M.call(M.dataMustache(t.lookup("getClass"),t.lookup("."))),template:M.call("bootstrap3-horizontal"),"label-class":M.call("col-sm-3 col-xs-12"),"input-col-class":M.call("col-sm-9 col-xs-12")}}),(function(){return M.include(t.lookupTemplate("afQuickField"))})),"\n\t\t\t\t\t\t\t\t\t\t\t"]}),(function(){return["\n\t\t\t\t\t\t\t\t\t\t\t\t",j._TemplateWith((function(){return{name:M.call(t.lookup(".")),class:M.call(M.dataMustache(t.lookup("getClass"),t.lookup(".")))}}),(function(){return M.include(t.lookupTemplate("afQuickField"))})),"\n\t\t\t\t\t\t\t\t\t\t\t"]})),"\n\t\t\t\t\t\t\t\t\t\t"]})),"\n\t\t\t\t\t\t\t\t\t"]})),"\n\t\t\t\t\t\t\t\t"]})),"\n\t\t\t\t\t\t\t"),"\n\t\t\t\t\t\t"),"\n\t\t\t\t\t"]})),"\n\t\t\t\t"),"\n\t\t\t"]})),"\n\t\t"]})),"\n\n\t\t",j.If((function(){return M.call(M.dot(t.lookup("schemaFields"),"groupFields"))}),(function(){return["\n\t\t\t",j.Each((function(){return M.call(M.dot(t.lookup("schemaFields"),"groupFields"))}),(function(){return["\n\t\t\t\t",j.If((function(){return M.call(M.dot(t.lookup("."),"fields"))}),(function(){return["\n\t\t\t\t\t",R.DIV({class:function(){return["slds-section group-section ",j.If((function(){return M.call(t.lookup("autoExpandGroup"))}),(function(){return"slds-is-open"}))]}},"\n\t\t\t\t\t\t",R.H3({class:"slds-section__title group-section-control"},"\n\t\t\t\t\t\t\t",j._TemplateWith((function(){return{className:M.call("slds-section__title-action"),iconClassName:M.call("slds-section__title-action-icon slds-button__icon_left"),iconCategory:M.call("utility"),iconName:M.call("switch"),variant:M.call("icon"),label:M.call(M.dot(t.lookup("."),"name"))}}),(function(){return M.include(t.lookupTemplate("steedos_button"))})),"\n\t\t\t\t\t\t"),"\n\t\t\t\t\t\t",R.DIV({"aria-hidden":"false",class:"slds-section__content",id:"expando-unique-id"},"\n\t\t\t\t\t\t\t",j.Each((function(){return M.call(M.dot(t.lookup("."),"fields"))}),(function(){return["\n\t\t\t\t\t\t\t\t",R.DIV({class:function(){return["slds-grid view-page-section-row ",j.If((function(){return M.dataMustache(t.lookup("has_wide_field"),t.lookup("."))}),(function(){return"wide-fields"}))]}},"\n\t\t\t\t\t\t\t\t\t",j.Each((function(){return M.call(t.lookup("."))}),(function(){return["\n\t\t\t\t\t\t\t\t\t",R.DIV({class:"slds-has-flexi-truncate slds-p-horizontal_x-small full view-page-block-item"},"\n\t\t\t\t\t\t\t\t\t\t",R.DIV({class:function(){return["slds-form-element slds-form-element_edit slds-grow slds-hint-parent slds-p-vertical_xx-small override--slds-form-element uiInput ",j.If((function(){return M.dataMustache(t.lookup("hasInlineHelpText"),t.lookup("."))}),(function(){return"has-inline-text"}))]}},"\n\t\t\t\t\t\t\t\t\t\t",j.If((function(){return M.dataMustache(t.lookup("is_range"),t.lookup("."))}),(function(){return["\n\t\t\t\t\t\t\t\t\t\t\t",M.include(t.lookupTemplate("range_field")),"\n\t\t\t\t\t\t\t\t\t\t"]}),(function(){return["\n\t\t\t\t\t\t\t\t\t\t\t",j.Unless((function(){return M.dataMustache(t.lookup("is_renge_end"),t.lookup("."))}),(function(){return["\n\t\t\t\t\t\t\t\t\t\t\t\t",j.If((function(){return M.call(t.lookup("."))}),(function(){return["\n\t\t\t\t\t\t\t\t\t\t\t\t\t",j.If((function(){return M.dataMustache(t.lookup("hasInlineHelpText"),t.lookup("."))}),(function(){return["\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t",R.DIV({class:"info-popover",id:function(){return["info_popover_",M.mustache(t.lookup("."))]},style:"display: none"},j.View("lookup:hasInlineHelpText",(function(){return M.mustache(t.lookup("hasInlineHelpText"),t.lookup("."))}))),"\n\t\t\t\t\t\t\t\t\t\t\t\t\t"]})),"\n\t\t\t\t\t\t\t\t\t\t\t\t\t",j.If((function(){return M.call(t.lookup("horizontal"))}),(function(){return["\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t",j._TemplateWith((function(){return{name:M.call(t.lookup(".")),class:M.call(M.dataMustache(t.lookup("getClass"),t.lookup("."))),template:M.call("bootstrap3-horizontal"),"label-class":M.call("col-sm-3 col-xs-12"),"input-col-class":M.call("col-sm-9 col-xs-12")}}),(function(){return M.include(t.lookupTemplate("afQuickField"))})),"\n\t\t\t\t\t\t\t\t\t\t\t\t\t"]}),(function(){return["\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t",j._TemplateWith((function(){return{name:M.call(t.lookup(".")),class:M.call(M.dataMustache(t.lookup("getClass"),t.lookup(".")))}}),(function(){return M.include(t.lookupTemplate("afQuickField"))})),"\n\t\t\t\t\t\t\t\t\t\t\t\t\t"]})),"\n\t\t\t\t\t\t\t\t\t\t\t\t"]})),"\n\t\t\t\t\t\t\t\t\t\t\t"]})),"\n\t\t\t\t\t\t\t\t\t\t"]})),"\n\t\t\t\t\t\t\t\t\t\t"),"\n\t\t\t\t\t\t\t\t\t"),"\n\t\t\t\t\t\t\t\t\t"]})),"\n\t\t\t\t\t\t\t\t"),"\n\t\t\t\t\t\t\t"]})),"\n\t\t\t\t\t\t"),"\n\t\t\t\t\t"),"\n\t\t\t\t"]})),"\n\t\t\t"]})),"\n\t\t"]})),"\n\n\t\t",j.If((function(){return M.call(M.dot(t.lookup("schemaFields"),"hiddenFields"))}),(function(){return["\n\t\t\t",R.DIV({class:"slds-grid view-page-section-row hidden-fields"},"\n\t\t\t\t",R.DIV({class:"slds-has-flexi-truncate slds-p-horizontal_x-small full view-page-block-item"},"\n\t\t\t\t\t",j.Each((function(){return M.call(M.dot(t.lookup("schemaFields"),"hiddenFields"))}),(function(){return["\n\t\t\t\t\t\t",R.DIV({class:"slds-form-element slds-form-element_edit slds-grow slds-hint-parent slds-p-vertical_xx-small override--slds-form-element uiInput"},"\n\t\t\t\t\t\t\t",j.If((function(){return M.call(t.lookup("."))}),(function(){return["\n\t\t\t\t\t\t\t\t",j.If((function(){return M.call(t.lookup("horizontal"))}),(function(){return["\n\t\t\t\t\t\t\t\t\t",j._TemplateWith((function(){return{name:M.call(t.lookup(".")),class:M.call(M.dataMustache(t.lookup("getClass"),t.lookup("."))),template:M.call("bootstrap3-horizontal"),"label-class":M.call("col-sm-3 col-xs-12"),"input-col-class":M.call("col-sm-9 col-xs-12")}}),(function(){return M.include(t.lookupTemplate("afQuickField"))})),"\n\t\t\t\t\t\t\t\t"]}),(function(){return["\n\t\t\t\t\t\t\t\t\t",j._TemplateWith((function(){return{name:M.call(t.lookup(".")),class:M.call(M.dataMustache(t.lookup("getClass"),t.lookup(".")))}}),(function(){return M.include(t.lookupTemplate("afQuickField"))})),"\n\t\t\t\t\t\t\t\t"]})),"\n\t\t\t\t\t\t\t"]})),"\n\t\t\t\t\t\t"),"\n\t\t\t\t\t"]})),"\n\t\t\t\t"),"\n\t\t\t"),"\n\t\t"]})),"\n\n\t\t",j.If((function(){return M.call(M.dot(t.lookup("schemaFields"),"disabledFields"))}),(function(){return["\n\t\t\t",R.DIV({class:"slds-grid view-page-section-row disabled-fields"},"\n\t\t\t\t",R.DIV({class:"slds-has-flexi-truncate slds-p-horizontal_x-small full view-page-block-item"},"\n\t\t\t\t\t",j.Each((function(){return M.call(M.dot(t.lookup("schemaFields"),"disabledFields"))}),(function(){return["\n\t\t\t\t\t\t",R.DIV({class:"slds-form-element slds-form-element_edit slds-grow slds-hint-parent slds-p-vertical_xx-small override--slds-form-element uiInput"},"\n\t\t\t\t\t\t\t",j.If((function(){return M.call(t.lookup("."))}),(function(){return["\n\t\t\t\t\t\t\t\t",j.If((function(){return M.call(t.lookup("horizontal"))}),(function(){return["\n\t\t\t\t\t\t\t\t\t",j._TemplateWith((function(){return{name:M.call(t.lookup(".")),disabled:M.call(!1),readonly:M.call(!0),class:M.call(M.dataMustache(t.lookup("getClass"),t.lookup("."))),template:M.call("bootstrap3-horizontal"),"label-class":M.call("col-sm-3 col-xs-12"),"input-col-class":M.call("col-sm-9 col-xs-12")}}),(function(){return M.include(t.lookupTemplate("afQuickField"))})),"\n\t\t\t\t\t\t\t\t"]}),(function(){return["\n\t\t\t\t\t\t\t\t\t",j._TemplateWith((function(){return{name:M.call(t.lookup(".")),disabled:M.call(!1),readonly:M.call(!0),class:M.call(M.dataMustache(t.lookup("getClass"),t.lookup(".")))}}),(function(){return M.include(t.lookupTemplate("afQuickField"))})),"\n\t\t\t\t\t\t\t\t"]})),"\n\t\t\t\t\t\t\t"]})),"\n\t\t\t\t\t\t"),"\n\t\t\t\t\t"]})),"\n\t\t\t\t"),"\n\t\t\t"),"\n\t\t"]})),"\n\t"]}))})),"\n\t")})),N.__checkName("range_field"),N.range_field=new N("Template.range_field",(function(){var t=this;return R.DIV({class:function(){return["range-field field-code-",M.mustache(t.lookup("startName"))]}},"\n\t\t",R.DIV({class:"form-group"},"\n\t\t\t",R.LABEL({class:"col-sm-3 control-label",for:"dao2yaGvD4SFjifBi"},"\n\t\t\t\t",j.View("lookup:afFieldLabelText",(function(){return M.mustache(t.lookup("afFieldLabelText"),M.kw({name:t.lookup("startName"),class:"col-sm-3 col-xs-12"}))})),"\n\t\t\t"),"\n\t\t\t",R.DIV({class:"col-sm-9 col-xs-12"},"\n\t\t\t\t",R.DIV({class:"row show-grid"},"\n\t\t\t\t\t",R.DIV({class:"col-sm-6 col-xs-6 start"},j._TemplateWith((function(){return{name:M.call(t.lookup("startName")),class:M.call(M.dataMustache(t.lookup("getClass"),t.lookup("."))),label:M.call(!1)}}),(function(){return M.include(t.lookupTemplate("afQuickField"))}))),"\n\t\t\t\t\t",R.DIV({class:"col-sm-6 col-xs-6 end"},j._TemplateWith((function(){return{name:M.call(t.lookup("endName")),class:M.call(M.dataMustache(t.lookup("getClass"),t.lookup("."))),label:M.call(!1)}}),(function(){return M.include(t.lookupTemplate("afQuickField"))}))),"\n\t\t\t\t"),"\n\t\t\t"),"\n\t\t"),"\n\t")}))},"slds-quickForm.coffee":function t(){var e=P="object"==typeof P?P:{};N.quickForm_slds.helpers({isDisabled:function(t){var e,n,i,r;return null!=(e=N.instance())&&null!=(n=e.data)&&null!=(i=n.qfAutoFormContext.schema._schema[t])&&null!=(r=i.autoform)?r.disabled:void 0},hasInlineHelpText:function(t){var e,n,i,r;return null!=(e=N.instance())&&null!=(n=e.data)&&null!=(i=n.qfAutoFormContext.schema._schema[t])&&null!=(r=i.autoform)?r.inlineHelpText:void 0},is_range:function(t){var e,n,i,r;return null!=(e=N.instance())&&null!=(n=e.data)&&null!=(i=n.qfAutoFormContext.schema._schema[t])&&null!=(r=i.autoform)?r.is_range:void 0},is_renge_end:function(t){return null!=t?t.endsWith("_endLine"):void 0},getClass:function(t){var e,n,i,r;if("steedosGrid"!==(null!=(e=N.instance())&&null!=(n=e.data)&&null!=(i=n.qfAutoFormContext.schema._schema[t])&&null!=(r=i.autoform)?r.type:void 0))return"form-control"},schemaFields:function(){var t,e,n,i,o,s,u,l,c,d,f,h,p;return d=[],p=this.qfAutoFormContext.schema,h=p._schema,s=p._firstLevelSchemaKeys,(f=this.qfAutoFormContext.fields||s)||(f=[]),a.each(h,(function(t,e){var n;if(a.indexOf(s,e)>-1&&!(null!=(n=t.autoform)?n.omit:void 0))return d.push(e)})),1===d.length?o={grouplessFields:[d]}:(l=Creator.getHiddenFields(h),t=Creator.getDisabledFields(h),n=[],i=[],c=r.get("cmEditSingleField"),u=[],u=Creator.getFieldsWithNoGroup(h),u=Creator.getFieldsInFirstLevel(s,u),f&&(u=a.intersection(f,u)),u=Creator.getFieldsWithoutOmit(h,u),u=Creator.getFieldsForReorder(h,u,c),e=Creator.getSortedFieldGroupNames(h),a.each(e,(function(t){return i=Creator.getFieldsForGroup(h,t),i=Creator.getFieldsInFirstLevel(s,i),f&&(i=a.intersection(f,i)),i=Creator.getFieldsWithoutOmit(h,i),i=Creator.getFieldsForReorder(h,i,c),n.push({name:t,fields:i})})),o={grouplessFields:u,groupFields:n,hiddenFields:l,disabledFields:t})},horizontal:function(){return N.instance().data.atts.horizontal},is_range_fields:function(t){var e,n,i,r;if((null!=t?t.length:void 0)>0&&t[0])return null!=(e=N.instance())&&null!=(n=e.data)&&null!=(i=n.qfAutoFormContext.schema._schema[t[0]])&&null!=(r=i.autoform)?r.is_range:void 0},has_wide_field:function(t){var e,n,i,r;if((null!=t?t.length:void 0)>0&&t[0])return null!=(e=N.instance())&&null!=(n=e.data)&&null!=(i=n.qfAutoFormContext.schema._schema[t[0]])&&null!=(r=i.autoform)?r.is_wide:void 0},autoExpandGroup:function(){return N.instance().data.atts.autoExpandGroup||!1}}),N.quickForm_slds.events({"click .group-section-control":function(t,e){return t.preventDefault(),t.stopPropagation(),$(t.currentTarget).closest(".group-section").toggleClass("slds-is-open")}}),N.quickForm_slds.onRendered((function(){var t;return t=this,this.$(".has-inline-text").each((function(){var t,e;return t='
\n\t\n',$(".control-label",$(this)).append(t)})),this.$(".info-popover").each((function(){var t;return t=$("~ .form-group .help-info",$(this)).attr("id"),$(this).dxPopover({target:"#"+t,showEvent:"mouseenter",hideEvent:"mouseleave",position:"top",width:300,animation:{show:{type:"pop",from:{scale:0},to:{scale:1}},hide:{type:"fade",from:1,to:0}}})}))})),N.range_field.helpers({startName:function(){return this.toString()},endName:function(){return this.toString()+"_endLine"},getClass:function(t){return"form-control"}})}}}}}}}}},{extensions:[".js",".json",".coffee",".html",".less"]});W("/node_modules/meteor/steedos:autoform/client/core.coffee"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/boolean-checkbox/template.boolean-checkbox.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/boolean-checkbox/boolean-checkbox.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/boolean-toggle/template.boolean-toggle.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/boolean-toggle/boolean-toggle.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-org-localdata/template.select-orgs.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-org-localdata/select-orgs.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-org/lib/template.cf_organization.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-org/lib/cf_organization.coffee"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-org/lib/template.cf_organization_modal.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-org/lib/cf_organization_modal.coffee"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-org/template.select-orgs.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-org/select-orgs.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-user-localdata/template.select-users.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-user-localdata/select-users.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-user/lib/cf_data_manager.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-user/lib/cf_tabular_space_user.coffee"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-user/lib/template.cf_contact_modal.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-user/lib/cf_contact_modal.coffee"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-user/lib/template.cf_organization_list.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-user/lib/cf_organization_list.coffee"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-user/lib/template.cf_space_user_list.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-user/lib/cf_space_user_list.coffee"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-user/lib/template.cf_organization_modal.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-user/lib/cf_organization_modal.coffee"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-user/template.select-users.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-user/select-users.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-tree/template.select-tree.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-tree/select-tree.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-email/template.email.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-email/email.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-url/template.url.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-url/url.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-widearea/template.widearea.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-widearea/widearea.coffee"),W("/node_modules/meteor/steedos:autoform/client/coreform/components/slds-quickForm/template.slds-quickForm.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/components/slds-quickForm/slds-quickForm.coffee"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-typeahead/typeahead.js/bloodhound.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-typeahead/typeahead.js/typeahead.bundle.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-typeahead/typeahead.js/typeahead.jquery.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-typeahead/template.af-typeahead.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-typeahead/af-typeahead.coffee"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-number/template.steedos-number.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-number/steedos-number.coffee"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-date-mobile/template.date.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-date-mobile/date.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-html/template.html.js"),W("/node_modules/meteor/steedos:autoform/client/coreform/inputTypes/coreform-html/html.js"),Package._define("steedos:autoform",{CFDataManager:L})}();
-!function(){var Meteor=Package.meteor.Meteor,global=Package.meteor.global,meteorEnv=Package.meteor.meteorEnv,ReactiveVar=Package["reactive-var"].ReactiveVar,ReactiveDict=Package["reactive-dict"].ReactiveDict,Random=Package.random.Random,DDP=Package["ddp-client"].DDP,check=Package.check.check,Match=Package.check.Match,_=Package.underscore._,Tracker=Package.tracker.Tracker,Deps=Package.tracker.Deps,Session=Package.session.Session,Blaze=Package.ui.Blaze,UI=Package.ui.UI,Handlebars=Package.ui.Handlebars,Template=Package["templating-runtime"].Template,SimpleSchema=Package["aldeed:simple-schema"].SimpleSchema,MongoObject=Package["aldeed:simple-schema"].MongoObject,Tabular=Package["aldeed:tabular"].Tabular,AutoForm=Package["aldeed:autoform"].AutoForm,CollectionHooks=Package["matb33:collection-hooks"].CollectionHooks,BlazeLayout=Package["kadira:blaze-layout"].BlazeLayout,FlowRouter=Package["kadira:flow-router"].FlowRouter,SubsManager=Package["meteorhacks:subs-manager"].SubsManager,moment=Package["momentjs:moment"].moment,UniSelectize=Package["steedos:autoform-lookup"].UniSelectize,Accounts=Package["accounts-base"].Accounts,Selector=Package["steedos:base"].Selector,Steedos=Package["steedos:base"].Steedos,AjaxCollection=Package["steedos:base"].AjaxCollection,SteedosDataManager=Package["steedos:base"].SteedosDataManager,SteedosOffice=Package["steedos:base"].SteedosOffice,Modal=Package["steedos:base"].Modal,CFDataManager=Package["steedos:autoform"].CFDataManager,Push=Package["raix:push"].Push,Logger=Package["steedos:logger"].Logger,_i18n=Package["universe:i18n"]._i18n,i18n=Package["universe:i18n"].i18n,Promise=Package.promise.Promise,meteorInstall=Package.modules.meteorInstall,HTML=Package.htmljs.HTML,Collection2=Package["aldeed:collection2-core"].Collection2,FS=Package["steedos:cfs-base-package"].FS,Spacebars=Package.spacebars.Spacebars,Mongo=Package.mongo.Mongo,__coffeescriptShare,regions,require=meteorInstall({node_modules:{meteor:{"steedos:creator":{"core.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};Creator.getSchema=function(e){var t;return null!=(t=Creator.getObject(e))?t.schema:void 0},Creator.getObjectHomeComponent=function(e){return!1},Creator.getObjectUrl=function(e,t,r){var o,a;return r||(r=Session.get("app_id")),e||(e=Session.get("object_name")),a=null!=(o=Creator.getListView(e,null))?o._id:void 0,t?Creator.getRelativeUrl("/app/"+r+"/"+e+"/view/"+t):Creator.getObjectHomeComponent(e)?Creator.getRelativeUrl("/app/"+r+"/"+e):a?Creator.getRelativeUrl("/app/"+r+"/"+e+"/grid/"+a):Creator.getRelativeUrl("/app/"+r+"/"+e)},Creator.getObjectAbsoluteUrl=function(e,t,r){var o,a;return r||(r=Session.get("app_id")),e||(e=Session.get("object_name")),a=null!=(o=Creator.getListView(e,null))?o._id:void 0,t?Steedos.absoluteUrl("/app/"+r+"/"+e+"/view/"+t,!0):Steedos.absoluteUrl("/app/"+r+"/"+e+"/grid/"+a,!0)},Creator.getObjectRouterUrl=function(e,t,r){var o,a;return r||(r=Session.get("app_id")),e||(e=Session.get("object_name")),a=null!=(o=Creator.getListView(e,null))?o._id:void 0,t?"/app/"+r+"/"+e+"/view/"+t:"/app/"+r+"/"+e+"/grid/"+a},Creator.getListViewUrl=function(e,t,r){var o;return o=Creator.getListViewRelativeUrl(e,t,r),Creator.getRelativeUrl(o)},Creator.getListViewRelativeUrl=function(e,t,r){return"/app/"+t+"/"+e+"/grid/"+r},Creator.getSwitchListUrl=function(e,t,r){return r?Creator.getRelativeUrl("/app/"+t+"/"+e+"/"+r+"/list"):Creator.getRelativeUrl("/app/"+t+"/"+e+"/list/switch")},Creator.getRelatedObjectUrl=function(e,t,r,o,a){return a?Creator.getRelativeUrl("/app/"+t+"/"+e+"/"+r+"/"+o+"/grid?related_field_name="+a):Creator.getRelativeUrl("/app/"+t+"/"+e+"/"+r+"/"+o+"/grid")},Creator.getObjectLookupFieldOptions=function(e,t,r,o){var a,n,i,s,c,l;return n=[],e?(i=null!=(a=Creator.getObject(e))?a.fields:void 0,s=null!=a?a.icon:void 0,_.forEach(i,(function(e,t){if(!r||!e.hidden)return"select"===e.type?n.push({label:""+(e.label||t),value:""+t,icon:s}):n.push({label:e.label||t,value:t,icon:s})})),t&&_.forEach(i,(function(e,t){var o;if(!r||!e.hidden)return("lookup"===e.type||"master_detail"===e.type)&&e.reference_to&&_.isString(e.reference_to)&&(o=Creator.getObject(e.reference_to))?_.forEach(o.fields,(function(r,a){return n.push({label:(e.label||t)+"=>"+(r.label||a),value:t+"."+a,icon:null!=o?o.icon:void 0})})):void 0})),o&&(c=Creator.getRelatedObjects(e),_.each(c,(l=this,function(e){var t,r;return r=Creator.getObjectLookupFieldOptions(e.object_name,!1,!1,!1),t=Creator.getObject(e.object_name),_.each(r,(function(r){if(e.foreign_key!==r.value)return n.push({label:(t.label||t.name)+"=>"+r.label,value:t.name+"."+r.value,icon:null!=t?t.icon:void 0})}))}))),n):n},Creator.getObjectFilterFieldOptions=function(e){var t,r,o,a,n;return r=[],e?(o=null!=(t=Creator.getObject(e))?t.fields:void 0,n=Creator.getFields(e),a=null!=t?t.icon:void 0,_.forEach(o,(function(e,t){if(!_.include(["grid","object","[Object]","[object]","Object","avatar","image","markdown","html"],e.type)&&!e.hidden&&!/\w+\./.test(t)&&_.indexOf(n,t)>-1)return r.push({label:e.label||t,value:t,icon:a})})),r):r},Creator.getObjectFieldOptions=function(e){var t,r,o,a,n;return r=[],e?(o=null!=(t=Creator.getObject(e))?t.fields:void 0,n=Creator.getFields(e),a=null!=t?t.icon:void 0,_.forEach(o,(function(e,t){if(!_.include(["grid","object","[Object]","[object]","Object","markdown","html"],e.type)&&!/\w+\./.test(t)&&_.indexOf(n,t)>-1)return r.push({label:e.label||t,value:t,icon:a})})),r):r},Creator.getFiltersWithFilterFields=function(e,t,r){return e||(e=[]),r||(r=[]),(null!=r?r.length:void 0)&&r.forEach((function(r){if(_.isString(r)&&(r={field:r,required:!1}),t[r.field]&&!_.findWhere(e,{field:r.field}))return e.push({field:r.field,is_default:!0,is_required:r.required})})),e.forEach((function(e){var t;return t=r.find((function(t){return t===e.field||t.field===e.field})),_.isString(t)&&(t={field:t,required:!1}),t?(e.is_default=!0,e.is_required=t.required):(delete e.is_default,delete e.is_required)})),e},Creator.getObjectRecord=function(e,t,r,o){var a,n,i,s,c,l;if(e||(e=Session.get("object_name")),t||(t=Session.get("record_id")),Meteor.isClient){if(e!==Session.get("object_name")||t!==Session.get("record_id"))return Creator.odata.get(e,t,r,o);if(null!=(s=Template.instance())?s.record:void 0)return null!=(c=Template.instance())&&null!=(l=c.record)?l.get():void 0}if("meteor"!==(n=Creator.getObject(e)).database_name&&n.database_name){if(e&&t)return Creator.odata.get(e,t,r,o)}else if(a=Creator.getCollection(e))return i=a.findOne(t)},Creator.getObjectRecordName=function(e,t){var r,o;if(e||(e=Creator.getObjectRecord()),e&&(r="organizations"===t?"name":null!=(o=Creator.getObject(t))?o.NAME_FIELD_KEY:void 0,e&&r))return e.label||e[r]},Creator.getApp=function(e){var t,r;return(t=Session.get("_app_menus")||Session.get("app_menus"))?r=t.find((function(t){return t.id===e})):{}},Creator.getAppDashboard=function(e){var t,r;if(t=Creator.getApp(e))return r=null,_.each(Creator.Dashboards,(function(e,o){var a;if((null!=(a=e.apps)?a.indexOf(t._id):void 0)>-1)return r=e})),r},Creator.getAppDashboardComponent=function(e){var t;t=Creator.getApp(e)},Creator.getAppObjectNames=function(e){var t,r,o,a;if(t=Creator.getApp(e))return r=(o=Steedos.isMobile())?t.mobile_objects:t.objects,a=[],t&&_.each(r,(function(e){var t;if(null!=(t=Creator.getObject(e))?t.permissions.get().allowRead:void 0)return a.push(e)})),a},Creator.getUrlWithToken=function(e,t){var r,o,a;return(a={})["X-Space-Id"]=Steedos.spaceId(),a["X-User-Id"]=Steedos.userId(),a["X-Company-Ids"]=Steedos.getUserCompanyIds(),a["X-Auth-Token"]=Accounts._storedLoginToken(),Steedos.isExpression(e)&&(e=Steedos.parseSingleExpression(e,t,"#",Creator.USER_CONTEXT)),""+e+(o=(r=/(\#.+\?)|(\?[^#]*$)/g.test(e))?"&":"?")+$.param(a)},Creator.getAppMenu=function(e,t){var r;return(r=Creator.getAppMenus(e))&&r.find((function(e){return e.id===t}))},Creator.getAppMenuUrlForInternet=function(e){return Creator.getUrlWithToken(e.path,e)},Creator.getAppMenuUrl=function(e){var t;return t=e.path,"url"===e.type?e.target?Creator.getAppMenuUrlForInternet(e):"/app/-/tab_iframe/"+e.id:e.path},Creator.getAppMenus=function(e){var t,r;return(t=Session.get("_app_menus")||Session.get("app_menus"))?(r=t.find((function(t){return t.id===e})))?r.children:void 0:[]},Creator.loadAppsMenus=function(){var e,t,r;return e={},(t=Steedos.isMobile())&&(e.mobile=t),r={type:"get",data:e,success:function(e){return Session.set("app_menus",e)}},null!=Steedos?Steedos.authRequest("/service/api/apps/menus",r):void 0},Creator.creatorAppsSelector=function(e,t){var r,o,a;return r=void 0,a=void 0,_.each(e,(function(e,t){e._id||(e._id=t),e.is_creator||(e.visible=!1)})),a=_.sortBy(_.values(e),"sort"),o={},r={},_.each(a,(function(e){return"admin"===e._id?r=e:o[e._id]=e})),o.admin=r,t.length&&_.each(o,(function(e,r){t.indexOf(r)>-1?e.visible=e.is_creator:e.visible=!1})),o},Creator.visibleAppsSelector=function(e,t){var r;return null==t&&(t=!0),r=[],_.each(e,(function(e,o){(!1!==e.visible&&"admin"!==e._id||t&&"admin"===e._id)&&r.push(e)})),r},Creator.getVisibleApps=function(e){var t,r;return t=Creator._subApp.get(),r=Object.assign({},Creator.Apps,{apps:t}),Creator.visibleAppsSelector(r,e)},Creator.getVisibleAppsObjects=function(){var e,t,r;return e=Creator.getVisibleApps(),r=_.flatten(_.pluck(e,"objects")),t=(t=_.filter(Creator.Objects,(function(e){return!(r.indexOf(e.name)<0)}))).sort(Creator.sortingMethod.bind({key:"label"})),t=_.pluck(t,"name"),_.uniq(t)},Creator.getAppsObjects=function(){var e,t;return e=[],t=[],_.forEach(Creator.Apps,(function(r){return t=_.filter(r.objects,(function(e){return!e.hidden})),e=e.concat(t)})),_.uniq(e)},Creator.validateFilters=function(e,t){var r,o,a,n,i,s,c;if(a=_.map(e,(function(e){return!_.isEmpty(e)&&e})),a=_.compact(a),o="",n=a.length,t){if(t=t.replace(/\n/g,"").replace(/\s+/g," "),/[._\-!+]+/gi.test(t)&&(o="含有特殊字符。"),!o)if(s=t.match(/\d+/gi))for(s.forEach((function(e){if(e<1||e>n)return o="您的筛选条件引用了未定义的筛选器:"+e+"。"})),i=1;i<=n;)s.includes(""+i)||(o="有些筛选条件进行了定义,但未在高级筛选条件中被引用。"),i++;else o="有些筛选条件进行了定义,但未在高级筛选条件中被引用。";if(o||(c=t.match(/[a-zA-Z]+/gi))&&c.forEach((function(e){if(!/^(and|or)$/gi.test(e))return o="检查您的高级筛选条件中的拼写。"})),!o){try{Creator.eval(t.replace(/and/gi,"&&").replace(/or/gi,"||"))}catch(l){r=l,o="您的筛选器中含有特殊字符"}(/(AND)[^()]+(OR)/gi.test(t)||/(OR)[^()]+(AND)/gi.test(t))&&(o="您的筛选器必须在连续性的 AND 和 OR 表达式前后使用括号。")}}return!o||(console.log("error",o),Meteor.isClient&&toastr.error(o),!1)},Creator.formatFiltersToMongo=function(e,t){var r;if(null!=e?e.length:void 0)return e[0]instanceof Array||(e=_.map(e,(function(e){return[e.field,e.operation,e.value]}))),r=[],_.each(e,(function(e){var o,a,n,i,s;return o=e[0],a=e[1],s=Meteor.isClient?Creator.evaluateFormula(e[2]):Creator.evaluateFormula(e[2],null,t),(i={})[o]={},"="===a?i[o].$eq=s:"<>"===a?i[o].$ne=s:">"===a?i[o].$gt=s:">="===a?i[o].$gte=s:"<"===a?i[o].$lt=s:"<="===a?i[o].$lte=s:"startswith"===a?(n=new RegExp("^"+s,"i"),i[o].$regex=n):"contains"===a?(n=new RegExp(s,"i"),i[o].$regex=n):"notcontains"===a&&(n=new RegExp("^((?!"+s+").)*$","i"),i[o].$regex=n),r.push(i)})),r},Creator.isBetweenFilterOperation=function(e){var t;return"between"===e||!!(null!=(t=Creator.getBetweenTimeBuiltinValues(!0))?t[e]:void 0)},Creator.formatFiltersToDev=function(e,t,r){var o,a;if(e.length)return(null!=r?r.is_logic_or:void 0)&&(o=[],e.forEach((function(e){return o.push(e),o.push("or")})),o.pop(),e=o),a=SteedosFilters.formatFiltersToDev(e,Creator.USER_CONTEXT)},Creator.formatLogicFiltersToDev=function(e,t,r){var o;return o="["+(o=(o=t.replace(/\(\s+/gi,"(").replace(/\s+\)/gi,")").replace(/\(/g,"[").replace(/\)/g,"]").replace(/\s+/g,",").replace(/(and|or)/gi,"'$1'")).replace(/(\d)+/gi,(function(t){var o,a,n,i,s;return o=e[t-1],a=o.field,n=o.operation,s=Meteor.isClient?Creator.evaluateFormula(o.value):Creator.evaluateFormula(o.value,null,r),i=[],!0===_.isArray(s)?("="===n?_.each(s,(function(e){return i.push([a,n,e],"or")})):"<>"===n?_.each(s,(function(e){return i.push([a,n,e],"and")})):_.each(s,(function(e){return i.push([a,n,e],"or")})),"and"!==i[i.length-1]&&"or"!==i[i.length-1]||i.pop()):i=[a,n,s],JSON.stringify(i)})))+"]",Creator.eval(o)},Creator.getRelatedObjects=function(e,t,r){var o,a,n,i,s;return Meteor.isClient&&(e||(e=Session.get("object_name")),t||(t=Session.get("spaceId")),r||(r=Meteor.userId())),n=[],(o=Creator.getObject(e))?(i=Creator.getObjectRelateds(o._collection_name),0===(null!=(n=_.pluck(i,"object_name"))?n.length:void 0)?n:(s=(a=Creator.getPermissions(e,t,r)).unrelated_objects,n=_.difference(n,s),_.filter(i,(function(e){var o,i,s,c;return c=e.object_name,i=n.indexOf(c)>-1,o=null!=(s=Creator.getPermissions(c,t,r))?s.allowRead:void 0,"cms_files"===c&&(o=o&&a.allowReadFiles),i&&o})))):n},Creator.getRelatedObjectNames=function(e,t,r){var o;return o=Creator.getRelatedObjects(e,t,r),_.pluck(o,"object_name")},Creator.getRelatedObjectListActions=function(e,t,r){var o;return o=Creator.getActions(e,t,r),o=_.filter(o,(function(e){return"standard_follow"!==e.name&&("standard_query"!==e.name&&("list"===e.on&&("function"==typeof e.visible?e.visible():e.visible)))}))},Creator.getActions=function(e,t,r){var o,a,n,i,s,c;if(Meteor.isClient&&(e||(e=Session.get("object_name")),t||(t=Session.get("spaceId")),r||(r=Meteor.userId())),n=Creator.getObject(e))return i=Creator.getPermissions(e,t,r),a=i.disabled_actions,o=_.sortBy(_.values(n.actions),"sort"),_.has(n,"allow_customActions")&&(o=_.filter(o,(function(e){return _.include(n.allow_customActions,e.name)||_.include(_.keys(Creator.getObject("base").actions)||{},e.name)}))),_.has(n,"exclude_actions")&&(o=_.filter(o,(function(e){return!_.include(n.exclude_actions,e.name)}))),_.each(o,(function(e){if(Steedos.isMobile()&&["record","record_only"].indexOf(e.on)>-1&&"standard_edit"!==e.name)return"record_only"===e.on?e.on="record_only_more":e.on="record_more"})),Steedos.isMobile()&&["cms_files","cfs.files.filerecord"].indexOf(e)>-1&&(null!=(s=o.find((function(e){return"standard_edit"===e.name})))&&(s.on="record_more"),null!=(c=o.find((function(e){return"download"===e.name})))&&(c.on="record")),o=_.filter(o,(function(e){return _.indexOf(a,e.name)<0}))},Creator.getListViews=function(e,t,r){var o,a,n,i,s,c;if(Meteor.isClient&&(e||(e=Session.get("object_name")),t||(t=Session.get("spaceId")),r||(r=Meteor.userId())),e&&(s=Creator.getObject(e)))return o=(null!=(c=Creator.getPermissions(e,t,r))?c.disabled_list_views:void 0)||[],i=[],a=Steedos.isMobile(),_.each(s.list_views,(function(e,t){return e.name=t})),n=_.sortBy(_.values(s.list_views),"sort_no"),_.each(n,(function(e){var t;if(!a||"calendar"!==e.type)return"default"===e.name||(t=_.indexOf(o,e.name)>-1||e._id&&_.indexOf(o,e._id)>-1)&&e.owner!==r?void 0:i.push(e)})),i},Creator.getFields=function(e,t,r){var o,a,n;return Meteor.isClient&&(e||(e=Session.get("object_name")),t||(t=Session.get("spaceId")),r||(r=Meteor.userId())),o=Creator.getObjectFieldsName(e),n=null!=(a=Creator.getPermissions(e,t,r))?a.unreadable_fields:void 0,_.difference(o,n)},Creator.isloading=function(){return!Creator.bootstrapLoaded.get()},Creator.convertSpecialCharacter=function(e){return e.replace(/([\^\$\(\)\*\+\?\.\\\|\[\]\{\}])/g,"\\$1")},Creator.getDisabledFields=function(e){var t;return t=_.map(e,(function(e,t){return e.autoform&&e.autoform.disabled&&!e.autoform.omit&&t})),t=_.compact(t)},Creator.getHiddenFields=function(e){var t;return t=_.map(e,(function(e,t){return e.autoform&&"hidden"===e.autoform.type&&!e.autoform.omit&&t})),t=_.compact(t)},Creator.getFieldsWithNoGroup=function(e){var t;return t=_.map(e,(function(e,t){return(!e.autoform||!e.autoform.group||"-"===e.autoform.group)&&(!e.autoform||"hidden"!==e.autoform.type)&&t})),t=_.compact(t)},Creator.getSortedFieldGroupNames=function(e){var t;return t=_.map(e,(function(e){return e.autoform&&"-"!==e.autoform.group&&e.autoform.group})),t=_.compact(t),t=_.unique(t)},Creator.getFieldsForGroup=function(e,t){var r;return r=_.map(e,(function(e,r){return e.autoform&&e.autoform.group===t&&"hidden"!==e.autoform.type&&r})),r=_.compact(r)},Creator.getSystemBaseFields=function(){return["created","created_by","modified","modified_by"]},Creator.getFieldsWithoutSystemBase=function(e){return _.difference(e,Creator.getSystemBaseFields())},Creator.getFieldsWithoutOmit=function(e,t){return t=_.map(t,(function(t){var r,o;return(null==(o=(r=_.pick(e,t))[t].autoform)||!o.omit)&&t})),t=_.compact(t)},Creator.getFieldsInFirstLevel=function(e,t){return t=_.map(t,(function(t){return _.indexOf(e,t)>-1&&t})),t=_.compact(t)},Creator.getFieldsForReorder=function(e,t,r){var o,a,n,i,s,c,l,u;for(n=[],i=0,o=_.filter(t,(function(e){return!e.endsWith("_endLine")}));i
-1&&(o=e[t].data_type),o):"text"},Meteor.isServer&&(Creator.getAllRelatedObjects=function(e){var t;return t=[],_.each(Creator.Objects,(function(r,o){return _.each(r.fields,(function(r,a){if("master_detail"===r.type&&r.reference_to&&r.reference_to===e)return t.push(o)}))})),Creator.getObject(e).enable_files&&t.push("cms_files"),t}),Meteor.isServer&&(Steedos.formatIndex=function(e){var t,r,o,a,n,i;return o={background:!0},(r=(null!=(a=Meteor.settings)&&null!=(n=a.datasources)&&null!=(i=n.default)?i.documentDB:void 0)||!1)&&e.length>0&&(t=e.join("."),o.name=t,t.length>52&&(o.name=t.substring(0,52))),o})},lib:{"apps.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};Creator.appsByName={}},"object_recent.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};this.ObjectRecent={},ObjectRecent.insert=function(e,t,r){return Meteor.call("object_recent_viewed",e,t,Session.get("spaceId"),(function(){if(r&&_.isFunction(r))return r()}))}},"filters_transform.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{},r;this.FiltersTransform={},r=function(e){return["date","datetime","time","currency","number"].includes(e)?"between":["text","textarea","html"].includes(e)?"contains":"="},FiltersTransform.queryToFilters=function(e){var t,o,a,n;if(e)return n=e.query,a=e.object_name,o=Creator.getObject(a).fields,t=[],_.each(n,(function(e,a){var n,i;if(o[a]){if(i=Creator.getFieldDataType(o,a),["date","datetime","time","currency","number"].includes(i))return t.push({field:a,operation:r(i),start_value:e,value:[e,null]});if(!["text","textarea","html"].includes(i))return["boolean"].includes(i)?t.push({field:a,operation:"=",value:e}):t.push({field:a,operation:r(i),value:e});if(_.isString(e))return t.push({field:a,operation:r(i),value:e});if(_.isArray(e))return t.push({field:a,operation:"=",value:e})}else if(a=a.replace(/(_endLine)$/,""),i=Creator.getFieldDataType(o,a),o[a]&&["date","datetime","time","currency","number"].includes(i))return(n=_.find(t,(function(e){return e.field===a})))?(n.end_value=e,n.value[1]=e):t.push({field:a,operation:r(i),end_value:e,value:[null,e]})})),t}},"form_manager.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{},r,o;this.FormManager={},SimpleSchema.messages({formValidate:"[value]"}),FormManager.getRelatedInitialValues=(o=this,function(e,t,r){var o,a,n,i,s;if(!_.isString(t))throw new Meteor.Error("main_record_id must be String");return o={},i="",Creator.getRelatedList(e,t).forEach((function(e){if(r===e.object_name)return i=e.related_field_name})),a="company_id",(s=Creator.getObject(r))&&i&&s.fields[i]&&s.fields[i].reference_to_field&&(a=a+","+s.fields[i].reference_to_field),(n=Creator.odata.get(e,t,a))&&i&&n[s.fields[i].reference_to_field]&&(t=n[s.fields[i].reference_to_field]),o={},i&&("objects"===e?o[i]=Creator.getObjectRecord().name:(s=Creator.getObject(r),_.isString(s.fields[i].reference_to)?s.fields[i].multiple?o[i]=[t]:o[i]=t:o[i]={o:e,ids:[t]})),!_.has(o,"company_id")&&(null!=n?n.company_id:void 0)&&(o.company_id=n.company_id),o=Object.assign({},o,FormManager.getInitialValues(r,o))}),FormManager.getInitialValues=function(e,t){var r,o,a;return o=null!=(r=Creator.getObject(e))&&null!=(a=r.form)?a.initialValues:void 0,_.isFunction(o)?o.apply({doc:t||{}}):{}},FormManager.validate=function(e,t){var r,o,a,n,i,s;if(a=null!=(o=Creator.getObject(e))&&null!=(n=o.form)?n.validate:void 0,_.isFunction(a))try{if(s=a.apply({},[null!=(i=AutoForm.getFormValues(t))?i.insertDoc:void 0]),_.isBoolean(s)&&!1===s)return!1;if(!_.isEmpty(s)&&_.isObject(s))return _.each(s,(function(e,r){return AutoForm.addStickyValidationError(t,r,"formValidate",e),toastr.error(e)})),!1}catch(c){return r=c,console.error(r),toastr.error(r.message),!1}return!0},FormManager.onSubmit=function(e,t){var r,o,a,n,i;return o=null!=(r=Creator.getObject(e))&&null!=(n=r.form)?n.onSubmit:void 0,!(_.isFunction(o)&&(a=o.apply({},[null!=(i=AutoForm.getFormValues(t))?i.insertDoc:void 0]),!_.isEmpty(a)&&_.isObject(a)))||(_.each(a,(function(e,r){return AutoForm.addStickyValidationError(t,r,"formValidate",e),toastr.error(e)})),!1)},r=function(e,t,r){var o,a,n;return o={userId:Meteor.userId(),spaceId:Session.get("spaceId"),object_name:e},_.has(r,"previousDoc")&&(o.previousDoc=r.previousDoc),t.endsWith("Delete")?(o.id=r._id,o.doc=Creator.odata.get(e,r._id),t.startsWith("error")&&(o.error=r.error)):t.startsWith("after")?(o.id=null!=(a=r.dbDoc)?a._id:void 0,o.doc=r.dbDoc):t.startsWith("before")?(t.endsWith("Insert")||(o.id=r._id),t.endsWith("Update")?o.doc=null!=(n=r.doc)?n.$set:void 0:o.doc=r.doc):t.startsWith("error")&&(o.id=r._id,o.doc=r.doc,o.error=r.error),o},FormManager.getPreviousDoc=function(e,t,r){var o,a,n,i,s;if(("update"===r||"delete"===r)&&(o="after",a="after"+r.charAt(0).toLocaleUpperCase()+_.rest(r.split("")).join(""),i=null!=(n=Creator.getObject(e))&&null!=(s=n.form)?s[a]:void 0,_.isFunction(i)))return Creator.odata.get(e,t)},FormManager.runHook=function(e,t,o,a){var n,i,s,c,l,u,d,p;if(l=""+o+t.charAt(0).toLocaleUpperCase()+_.rest(t.split("")).join(""),"view"===t||"edit"===t)return FormManager.runViewEditHook(e,l,a.schema,a.record,a.doc);if(s=a.formId,d=null!=(u=Creator.getObject(e))&&null!=(p=u.form)?p[l]:void 0,_.isFunction(d))try{if(n=r(e,l,a),c=d.apply(n),_.isBoolean(c)&&!1===c)return!1;if(s&&"before"===o&&!_.isEmpty(c)&&_.isObject(c))return _.each(c,(function(e,t){return AutoForm.addStickyValidationError(s,t,"formValidate",e),toastr.error(e)})),!1}catch(f){return i=f,console.error(i),toastr.error(i.message),!1}return!0},FormManager.runViewEditHook=function(e,t,r,o,a){var n,i,s,c,l,u,d;if(l=null!=(u=Creator.getObject(e))&&null!=(d=u.form)?d[t]:void 0,_.isFunction(l)&&(s=r.get(),c={id:(i=a||o.get())._id,userId:Meteor.userId(),spaceId:Session.get("spaceId"),object_name:e,doc:i,schema:s},!1!==(n=l.apply(c))))return r.set(s),o.set(i)}},"grid_export.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{},r,o;this.ObjectGrid={},this.GridExport={},r={equals:"=",notEqual:"!=",contains:"contains",notContains:"notcontains",startsWith:"startswith",endsWith:"=",lessThan:"<",lessThanOrEqual:"<=",greaterThan:">",greaterThanOrEqual:">=",empty:"empty"},o=function(e){var t;return t=[],_.forEach(e,(function(e,o){var a;return"between"===e.type?"number"===e.filterType?t.push([o,"between",[e.numberFrom,e.numberTo]]):e.filter?t.push([o,e.type,e.filter]):t.push([o,"between",[e.dateFrom,e.dateTo]]):_.isEmpty(e.filter)?e.operator?(a=[],e.condition1&&a.push([o,r[e.condition1.type],e.condition1.filter]),a.push(e.operator.toLocaleLowerCase()),e.condition2&&a.push([o,r[e.condition2.type],e.condition2.filter]),t.push(a)):void 0:(a=[o,r[e.type],e.filter],t.push(a))})),t},ObjectGrid.getFilters=function(e,t,r,a,n){var i,s,c,l,u,d;return s=Steedos.Page.Listview.getDefaultName(e,t),l=window.gridRefs&&window.gridRefs[s]&&window.gridRefs[s].current?window.gridRefs[s].current:window.gridRef.current,u=[],i=Creator.getListViewFilters(e,t,r,a,n),d=o(l.api.getFilterModel()),c=_.compact([].concat(i).concat(d))},GridExport.excel=function(e,t,r,a,n,i,s){var c,l,u,d,p,f,m,g,h,v,b,w,S;return u=Steedos.Page.Listview.getDefaultName(e,t),f=window.gridRefs&&window.gridRefs[u]&&window.gridRefs[u].current?window.gridRefs[u].current:window.gridRef.current,v=[],_.each(f.props.columnDefs,(function(e){if(e&&e.field)return v.push(e.field)})),b=[],_.forEach(f.api.getSortModel(),(function(e){return b.push([e.colId,e.sort])})),l=Creator.getListViewFilters(e,t,r,a,n,s),S=o(f.api.getFilterModel()),p=_.compact([].concat(l).concat(S)),c=SteedosFilters.formatFiltersToODataQuery(p),d=r?i+"-"+Creator.getObject(a).label:Creator.getObject(e).label+"-"+(null!=(h=Creator.getListView(e,t))?h.label:void 0),g=[],_.map(b,(function(e){var t;return t="desc"===e[1]?e[0]+" desc":e[0],g.push(t)})),m=g.join(","),d=encodeURIComponent(d),w=r?"/api/record/export/"+a+"?$select="+v.toString()+"&filename="+d:"/api/record/export/"+e+"?$select="+v.toString()+"&filename="+d,b.length>0&&(w=w+"&$orderby="+m),c&&(w=w+"&$filter="+c),Meteor.isCordova?Steedos.cordovaDownload(encodeURI(Steedos.absoluteUrl(w)),d+".xlsx"):window.open(w)}}},client:{"listview.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{},r,o,a,n,i;n=function(e,t,r){var o,a,n;return o=null!=t?t.columns:void 0,r&&((null!=t?t.mobile_columns:void 0)?o=t.mobile_columns:(null!=(n=Creator.getObjectFirstListView(e))?n.mobile_columns:void 0)?o=n.mobile_columns:o&&(o=Creator.pickObjectMobileColumns(e,o))),o||(a=Creator.getObjectFirstListViewColumns(e,r))&&(o=a),o},o=function(e,t,r){var o,a,i,s,c,l;return s=(c=Creator.getObject(e)).NAME_FIELD_KEY,"organizations"===c.name&&(s="name"),o=[s],(i=Creator.getCollection("object_listviews").findOne(t))?o=n(e,i,r):c.list_views&&(l=c.list_views[t],o=n(e,l,r)),o=o.map((function(e){var t,r;return t=_.isObject(e)?e.field:e,(null!=(r=c.fields[t])?r.type:void 0)?t:void 0})),Creator.isCommonSpace(Session.get("spaceId"))&&o.indexOf("space")<0&&o.push("space"),"cms_files"===e&&o.push("parent"),o=_.compact(o),a=Creator.getObjectFieldsName(e),_.intersection(o,a)},i=function(e,t,r,o){var a;return r?(a=Creator.getObject(e).fields,o&&(t=t.filter((function(e){var t,o;return"master_detail"!==(null!=(o=a[e])?o.type:void 0)||(!!a[e].multiple||(a[e].reference_to?(t=a[e].reference_to,_.isFunction(t)&&(t=t())):t=a[e].optionsFunction({}).getProperty("value"),!!_.isArray(t)||t!==r))}))),t):t},r=function(e,t){var r,o;return o=Creator.getObject(e).fields,r=[],_.each(t,(function(e){var t;if(null!=(t=o[e])?t.depend_on:void 0)return r=_.union(o[e].depend_on)})),r},a=function(e,t,r){var o,a;return a=_.intersection(["owner","company_id","company_ids","locked"],_.keys(e.fields)),!r&&e.enable_tree&&(a.push("parent"),a.push("children")),(o=Creator.getObjectDefaultExtraColumns(e.name))&&(a=_.union(a,o)),a},Creator.unionSelectColumnsWithExtraAndDepandOn=function(e,t,o,n){var i,s;return i=t.name,s=a(t,o,n),e=_.union(e,s),e=_.union(e,r(i,e))},Creator.getListViewFilters=function(e,t,r,o,a,n){var i,s,c,l,u,d,p,f,m,g;if(!e)return null;if(c=Creator.getObject(e),r)l=Creator.getODataRelatedFilter(e,o,a,t,n);else{if(d=Session.get("filter_logic"),p=Session.get("filter_scope"),u=Session.get("filter_items"),s=c.fields,u&&u.length>0&&window.lodash.isArray(u[0]))return l=u,(g=Creator.getStandardQuery(e,Session.get("standard_query")))&&g.length&&(l=l?[l,"and",g]:g),(m=Session.get("grid_sidebar_filters"))&&m.length&&(l=l?[l,"and",m]:m),l||(l=null),l;i=[],_.forEach(u,(function(t){var r,o,a,n,c,l,u,d,p,f,m;if(void 0!==t.value)if(r=s[null!=t?t.field:void 0],o=Creator.getFieldDataType(s,null!=t?t.field:void 0),["text","textarea","html","code"].includes(o)){if(_.isString(t.value)&&(m=t.value.trim().split(" "),l=[],m.forEach((function(e){return e=encodeURIComponent(Creator.convertSpecialCharacter(e)),l.push([t.field,t.operation,e])})),l.length>0))return c=!1,["<>","notcontains"].includes(t.operation)&&(c=!1),i.push(Creator.formatFiltersToDev(l,e,{is_logic_or:c}))}else{if(!["lookup","master_detail"].includes(o))return i.push(t);if(a=null!=r?r.reference_to:void 0,_.isFunction(a)&&(a=a()),!_.isArray(a))return i.push(t);if((null!=(u=t.value)?u.ids:void 0)&&i.push({field:t.field+".ids",operation:t.operation,value:null!=(d=t.value)?d.ids:void 0}),null!=(p=t.value)?p.o:void 0)return n=Creator.getObject(null!=(f=t.value)?f.o:void 0),i.push({field:t.field+".o",operation:t.operation,value:n._collection_name})}})),i.length>0&&(f={filter_logic:d,filter_scope:p,filters:i}),l=Creator.getODataFilter(t,e,f),(g=Creator.getStandardQuery(e,Session.get("standard_query")))&&g.length&&(l=l?[l,"and",g]:g),r||(m=Session.get("grid_sidebar_filters"))&&m.length&&(l=l?[l,"and",m]:m)}return l||(l=null),l},Creator.getODataEndpointUrl=function(e,t,r,o){var a,n;return r?(a=Creator.formatObjectName(o),n=Creator.getListViewIsRecent(e,t)?"/api/v4/"+a+"/recent":"/api/v4/"+a):(a=Creator.formatObjectName(e),n=Creator.getListViewIsRecent(e,t)?"/api/v4/"+a+"/recent":"/api/v4/"+a),Steedos.absoluteUrl(n)},Creator.getListviewColumns=function(e,t,r,a,n,s){var c,l;return c=e.name,l=Tracker.nonreactive((function(){return o(c,a,s)})),n&&n.customRelatedListObject&&(n.columns&&(l=n.columns),s&&n.mobile_columns&&(l=n.mobile_columns),l&&(l=l.map((function(e){return _.isObject(e)?e.field:_.isString(e)?e:void 0})),l=_.uniq(_.compact(l)))),l=i(c,l,t,r)}},views:{"_helpers.coffee":function e(){var r=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};Creator.helpers={object_name:function(){return Session.get("object_name")},object:function(){return Creator.getObject(Session.get("object_name"))},object_listviews:function(){return Creator.getObject("object_listviews")},objectLabel:function(e){return Creator.getObject(e).label},getOperationLabel:function(e){switch(e){case"=":return t("creator_filter_operation_equal");case"<>":return t("creator_filter_operation_unequal");case"<":return t("creator_filter_operation_less_than");case">":return t("creator_filter_operation_greater_than");case"<=":return t("creator_filter_operation_less_or_equal");case">=":return t("creator_filter_operation_greater_or_equal");case"contains":return t("creator_filter_operation_contains");case"notcontains":return t("creator_filter_operation_does_not_contain");case"startswith":return t("creator_filter_operation_starts_with");case"between":return t("creator_filter_operation_between")}},isMobile:function(){return Steedos.isMobile()}}},"template.page_template.js":function e(){Template.__checkName("page_template"),Template.page_template=new Template("Template.page_template",(function(){var e=this;return HTML.Raw('')}))},"page_template.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};Template.page_template.onRendered((function(){var e,t;return t=this,e=Session.get("app_id"),this.containerList=[],this.autorun((function(){var r;if(r=Steedos.Page.App.render(t,Session.get("pageApiName"),e))return t.containerList.push(r)}))})),Template.page_template.onDestroyed((function(){return _.each(this.containerList,(function(e){if(e)return ReactDOM.unmountComponentAtNode(e)}))}))},"template.page_object.js":function e(){Template.__checkName("page_object"),Template.page_object=new Template("Template.page_object",(function(){var e=this;return HTML.Raw('')}))},"page_object.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};Template.page_object.onRendered((function(){var e;return e=this,Steedos.Page.Object.Template.onRendered.apply(this)})),Template.page_object.onDestroyed((function(){var e;return e=this,Steedos.Page.Object.Template.onDestroyed.apply(this)}))},"template.page_record_view.js":function e(){Template.__checkName("page_record_view"),Template.page_record_view=new Template("Template.page_record_view",(function(){var e=this;return HTML.Raw('')}))},"page_record_view.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};Template.page_record_view.onRendered((function(){var e,t,r;return r=this,e=Session.get("object_name"),t=Session.get("record_id"),this.containerList=[],this.pageName=null,this.autorun((function(){var o,a,n,i,s,c,l,u,d,p;if(d=!0,(l=r.data.regions()).objectName!==(null!=(i=this.lastRegions)?i.objectName:void 0)&&(d=!1),this.lastRegions=l,d&&r.pageName)try{if(SteedosUI.refs[r.pageName])return(p={objectName:e}).recordId=Tracker.nonreactive((function(){return Session.get("record_id")})),n=(null!=(s=SteedosUI.refs[r.pageName])&&null!=(c=s.__$schema)?c.data:void 0)||{},SteedosUI.refs[r.pageName].updateProps({data:window._.defaultsDeep(p,n)})}catch(f){a=f,console.error(r.pageName+": "+a)}if(!d&&r.pageName&&SteedosUI.refs[r.pageName])try{SteedosUI.refs[r.pageName].unmount()}catch(f){a=f,console.error(r.pageName+": "+a)}if(r.data.regions&&(l=Tracker.nonreactive(r.data.regions),this.lastRegions=l,l&&l.page&&l.page.schema&&(u=l.page.schema,_.isString(u)&&(u=JSON.parse(u)),r.pageName=u.name)),e=Tracker.nonreactive((function(){return Session.get("object_name")})),t=Tracker.nonreactive((function(){return Session.get("record_id")})),o=Steedos.Page.Record.render(r,e,t))return r.containerList.push(o)}))})),Template.page_record_view.onDestroyed((function(){var e;try{SteedosUI.refs[this.pageName].unmount()}catch(t){e=t,console.error(this.pageName+": "+e)}return _.each(this.containerList,(function(e){if(e)return ReactDOM.unmountComponentAtNode(e)}))}))},"template.page_list_view.js":function e(){Template.__checkName("page_list_view"),Template.page_list_view=new Template("Template.page_list_view",(function(){var e=this;return HTML.Raw('')}))},"page_list_view.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};Template.page_list_view.onRendered((function(){var e,t;return t=this,e=Session.get("object_name"),this.containerList=[],this.pageName=null,this.autorun((function(){var r,o,a,n;if(t.pageName)try{SteedosUI.refs[t.pageName].unmount()}catch(i){o=i,console.error(t.pageName+": "+o)}if(t.data.regions&&(a=t.data.regions())&&a.page&&a.page.schema&&(n=a.page.schema,_.isString(n)&&(n=JSON.parse(n)),t.pageName=n.name),r=Steedos.Page.Listview.render(t,e))return t.containerList.push(r)}))})),Template.page_list_view.onDestroyed((function(){var e;try{SteedosUI.refs[this.pageName].unmount()}catch(t){e=t,console.error(this.pageName+": "+e)}return _.each(this.containerList,(function(e){if(e)return ReactDOM.unmountComponentAtNode(e)}))}))},"template.page_related_list_view.js":function e(){Template.__checkName("page_related_list_view"),Template.page_related_list_view=new Template("Template.page_related_list_view",(function(){var e=this;return HTML.Raw('')}))},"page_related_list_view.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};Template.page_related_list_view.onRendered((function(){var e,t,r;return r=this,e=Session.get("object_name"),t=Session.get("record_id"),this.containerList=[],this.pageName=null,this.autorun((function(){var o,a,n,i;if(r.pageName)try{SteedosUI.refs[r.pageName].unmount()}catch(s){a=s,console.error(r.pageName+": "+a)}if(r.data.regions&&(n=r.data.regions())&&n.page&&n.page.schema&&(i=n.page.schema,_.isString(i)&&(i=JSON.parse(i)),r.pageName=i.name),o=Steedos.Page.RelatedListview.render(r,e,t))return r.containerList.push(o)}))})),Template.page_related_list_view.onDestroyed((function(){var e;try{SteedosUI.refs[this.pageName].unmount()}catch(t){e=t,console.error(this.pageName+": "+e)}return _.each(this.containerList,(function(e){if(e)return ReactDOM.unmountComponentAtNode(e)}))}))},"template.app_home.js":function e(){Template.__checkName("creator_app_home"),Template.creator_app_home=new Template("Template.creator_app_home",(function(){var e=this;return""}))},"app_home.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{},r;r=function(e){var t,r,o,a,n;return(null!=(t=Creator.getApp(e))?t.isExternalUrl:void 0)?/^http(s?):\/\//.test(t.path)?t.blank?window.open(t.path):window.location.href=t.path:FlowRouter.go(t.path):(a=Creator.getAppMenus(e),(r=_.first(a))?"url"===(o=Object.assign({},r,{target:!1})).type&&o.is_use_iframe?FlowRouter.go(o.path):(n=Creator.getAppMenuUrl(o),FlowRouter.go(n)):FlowRouter.go("/app/"+e))},Template.creator_app_home.onRendered((function(){return this.autorun((function(){var e,t,o;if(o=Creator.bootstrapLoaded.get(),_.has(FlowRouter.current().params,"app_id")){if(e=Session.get("app_id"),o&&e)return r(e)}else if(t=Steedos.getFirstApp(),o&&t)return r(t.code||t.id)}))}))},"template.app_iframe.js":function e(){Template.__checkName("creator_app_iframe"),Template.creator_app_iframe=new Template("Template.creator_app_iframe",(function(){var e=this;return Blaze.If((function(){return Spacebars.call(e.lookup("subsReady"))}),(function(){return["\n\t\t",HTML.IFRAME({id:"app_iframe",src:function(){return Spacebars.mustache(e.lookup("url"))},style:"width: 100%; height: 100%;"}),"\n\t"]}))}))},"app_iframe.coffee":function module(){__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};var share=__coffeescriptShare;Template.creator_app_iframe.helpers({subsReady:function(){return Steedos.subsBootstrap.ready()},url:function(){var e,t;return t=Session.get("app_id"),(e=Creator.getApp(t))&&!e.on_click&&e.url?Creator.getUrlWithToken(e.url,e):""}}),Template.creator_app_iframe.events,Template.creator_app_iframe.onCreated((function(){})),Template.creator_app_iframe.onRendered((function(){var app,app_id,e,evalFunString,iframe;if(Steedos.forbidNodeContextmenu(window,"#app_iframe"),app_id=Session.get("app_id"),app=Creator.getApp(app_id),iframe=$("#app_iframe"),app&&app.on_click){evalFunString="(function(){"+app.on_click+"})()";try{return eval(evalFunString)}catch(error){return e=error,console.error("catch some error when eval the on_click script for app link:"),console.error(e.message+"\r\n"+e.stack)}}})),Template.creator_app_iframe.onDestroyed((function(){}))},"template.page_iframe.js":function e(){Template.__checkName("page_iframe"),Template.page_iframe=new Template("Template.page_iframe",(function(){var e=this;return HTML.IFRAME({name:"pageIframe",src:function(){return Spacebars.mustache(e.lookup("url"))},style:function(){return Spacebars.mustache(e.lookup("style"))},class:function(){return Spacebars.mustache(e.lookup("className"))}})}))},"page_iframe.js":function e(){var t=function(e){const{data:t}=e;"nav.click"===t.type&&FlowRouter.current().params.tab_id==t.data.id&&$("[name='pageIframe']").attr("src",$("[name='pageIframe']").attr("src"))};Template.page_iframe.helpers({url:()=>{if(Template.instance().data.regions){var e,t=Template.instance().data.regions().queryParams.url;return t.startsWith("https:/")&&!t.startsWith("https://")&&(t=t.replace("https:/","https://")),t.startsWith("http:/")&&!t.startsWith("http://")&&(t=t.replace("http:/","http://")),!Meteor.isCordova||t.startsWith("http:")||t.startsWith("!https:")||(t=Meteor.absoluteUrl(t)),t}},className:()=>{if(Template.instance().data.regions)return(regions=Template.instance().data.regions()).queryParams.className||""},style:()=>Template.instance().data.regions&&(regions=Template.instance().data.regions()).queryParams.style||"width: 100%; height: 100%;"}),Template.page_iframe.onCreated((function(){window.addEventListener("message",t)})),Template.page_iframe.onDestroyed((function(){window.removeEventListener("message",t)})),Template.page_iframe.onRendered((function(){window.Steedos.setDocumentTitle({pageName:null,tabName:null})}))},"template.initiate_approval.js":function e(){Template.__checkName("initiate_approval"),Template.initiate_approval=new Template("Template.initiate_approval",(function(){var e=this;return HTML.DIV({class:"modal fade creator-modal",id:"initiate_approval"},"\n\t\t",HTML.DIV({class:"modal-dialog slds-modal slds-fade-in-open"},"\n\t\t\t",HTML.DIV({class:"slds-modal__container"},"\n\t\t\t\t",HTML.HEADER({class:"slds-modal__header"},"\n\t\t\t\t\t",HTML.DIV({"data-dismiss":"modal"},"\n\t\t\t\t\t\t",Blaze._TemplateWith((function(){return{className:Spacebars.call("slds-modal__close slds-button__icon"),iconSize:Spacebars.call("large"),inverse:Spacebars.call(!0),iconCategory:Spacebars.call("utility"),iconName:Spacebars.call("close"),title:Spacebars.call(Spacebars.dataMustache(e.lookup("_"),"close")),variant:Spacebars.call("icon")}}),(function(){return Spacebars.include(e.lookupTemplate("steedos_button"))})),"\n\t\t\t\t\t"),"\n\t\t\t\t\t",HTML.Raw('\n\t\t\t\t\t\t选择流程发起审批\n\t\t\t\t\t
'),"\n\t\t\t\t"),"\n\n\t\t\t\t",HTML.DIV({class:"slds-modal__content slds-p-around_medium",style:"font-size: 17px;"},"\n\t\t\t\t\t",Blaze.Each((function(){return Spacebars.call(e.lookup("flows"))}),(function(){return["\n\t\t\t\t\t",HTML.DIV({class:"weui_cells_weui_cells_access"},"\n\t\t\t\t\t\t",HTML.A({class:"weui_cell","data-flow":function(){return Spacebars.mustache(e.lookup("flow_id"))}},"\n\t\t\t\t\t\t\t",HTML.I({class:"ion ion-ios-compose-outline"}),HTML.CharRef({html:" ",str:" "}),HTML.CharRef({html:" ",str:" "}),Blaze.View("lookup:flow_name",(function(){return Spacebars.mustache(e.lookup("flow_name"))})),"\n\t\t\t\t\t\t"),"\n\t\t\t\t\t"),"\n\t\t\t\t\t"]})),"\n\n\t\t\t\t"),"\n\n\t\t\t"),"\n\t\t"),"\n\t")}))},"initiate_approval.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};Template.initiate_approval.helpers({flows:function(){return _.where(Creator.object_workflows,{object_name:this.object_name,can_add:!0})}}),Template.initiate_approval.events({"click .weui_cell":function(e,t){var r,o,a,n,i,s,c;o=e.currentTarget.dataset.flow,a=t.data.object_name,n=t.data.record_id,i=[{o:a,ids:[n]}],(s={}).methodOverride="POST",s["X-User-Id"]=Meteor.userId(),s["X-Auth-Token"]=Accounts._storedLoginToken(),c=Steedos.absoluteUrl()+"api/object/workflow/drafts?"+$.param(s),r={Instances:[{flow:o,applicant:Meteor.userId(),space:Session.get("spaceId"),record_ids:i}]},r=JSON.stringify(r),$(document.body).addClass("loading"),$.ajax({url:c,type:"POST",async:!0,data:r,dataType:"json",processData:!1,contentType:"application/json",success:function(e,r){var o;$(document.body).removeClass("loading"),e.errors?e.errors.forEach((function(e){toastr.error(e.errorMessage)})):(o=e.inserts[0],Steedos.openWindow(Steedos.absoluteUrl("/app/"+FlowRouter.current().params.app_id+"/instances/view/"+o._id+"?display="+FlowRouter.current().queryParams.display+"&side_object=instances&side_listview_id=draft")),Modal.hide(t),SteedosUI.reloadRecord(a,n),FlowRouter.reload())},error:function(e,t,r){$(document.body).removeClass("loading"),toastr.error(t)}})}})},"template.amis_action.js":function e(){Template.__checkName("amis_action"),Template.amis_action=new Template("Template.amis_action",(function(){var e=this;return HTML.LI({class:function(){return["steedos-amis-button steedos-button-",Spacebars.mustache(e.lookup("objectName")),"-",Spacebars.mustache(e.lookup("name"))," ",Spacebars.mustache(e.lookup("buttonClassName"))]}})}))},"amis_action.js":function e(){const t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window.location;(e=e||"")&&"#"===e[0]?e=t.pathname+t.search+e:e&&"?"===e[0]&&(e=t.pathname+e);const r=e.indexOf("?"),o=e.indexOf("#");let a=~r?e.substring(0,r):~o?e.substring(0,o):e,n=~r?e.substring(r,~o?o:void 0):"",i=~o?e.substring(o):t.hash;if(a){if("/"!=a[0]&&!/^https?\:\/\//.test(a)){let e;const r=t.pathname.split("/");let o;for(r.pop();o=/^\.\.?\//.exec(a);)"../"===o[0]&&r.pop(),a=a.substring(o[0].length);a=r.concat(a).join("/")}}else a=t.pathname;return a+n+i},r=()=>({theme:"antd",getModalContainer:e=>{let t=document.querySelector("#amisModalContainer");return t||((t=document.createElement("div")).className="amis-scope",t.style.height="0px",t.id="amisModalContainer",document.body.appendChild(t)),t},notify:(e,t)=>{var r,o;(null===(r=t.props)||void 0===r?void 0:r.schema.tpl)?SteedosUI.message[e](null===(o=t.props)||void 0===o?void 0:o.schema.tpl):"string"==typeof t?SteedosUI.message[e](t):console.warn("notify",e,t)},confirm:e=>new Promise((t,r)=>SteedosUI.Modal.confirm({title:e,onOk:()=>{t(!0)},okText:"确认",cancelText:"取消"})),jumpTo:(e,r)=>{if("goBack"===e)return window.history.back();e=t(e),r&&"url"===r.actionType?!1===r.blank?FlowRouter.go(e):window.open(e):r&&e&&r.target?window.open(e,r.target):/^https?:\/\//.test(e)?window.location.replace(e):FlowRouter.go(e)},requestAdaptor:e=>(e.url&&!/^http[s]?:\/\//i.test(e.url)?(Meteor.isCordova&&(e.url=Meteor.absoluteUrl(e.url)),e.headers||(e.headers={}),!e.headers.Authorization&&Builder.settings.context&&Builder.settings.context.tenantId&&Builder.settings.context.authToken&&(e.headers.Authorization="Bearer ".concat(Builder.settings.context.tenantId,",").concat(Builder.settings.context.authToken))):e.url&&Meteor.isCordova&&Builder.settings.context&&Builder.settings.context.rootUrl&&e.url.startsWith(Builder.settings.context.rootUrl)&&Meteor.isCordova&&(e.headers||(e.headers={}),!e.headers.Authorization&&Builder.settings.context&&Builder.settings.context.tenantId&&Builder.settings.context.authToken&&(e.headers.Authorization="Bearer ".concat(Builder.settings.context.tenantId,",").concat(Builder.settings.context.authToken))),console.log("env.requestAdaptor=action==",e),e)});Template.amis_action.helpers({objectName:()=>{var e=Template.instance().data;return e.button.object||e.button.object_name},name:()=>{var e;return Template.instance().data.button.name},buttonClassName:()=>{var e;return Template.instance().data.buttonClassName}}),Template.amis_action.onRendered(()=>{var e=Template.instance().data,t=e.button,o=e.buttonClassName,a=e.inMore,n=e.data,i=e.env,s=".steedos-button-"+(t.object||e.button.object_name)+"-"+t.name;const c=()=>{var e=Creator.USER_CONTEXT?Creator.USER_CONTEXT.user.language:null;return e?e="cn"===(e="zh"===(e="en"===(e=e.replace("_","-"))?"en-US":e)?"zh-CN":e)?"zh-CN":e:"zh-CN"};Promise.all([waitForThing(window,"amis")]).then(()=>{var e=amisRequire("amis/embed"),o=t.amis_schema?_.isString(t.amis_schema)?JSON.parse(t.amis_schema):t.amis_schema:{type:"service",bodyClassName:"p-0",body:[{type:"button",label:t.label}],regions:["body"]};const a=__meteor_runtime_config__.ROOT_URL,l=lodash.defaultsDeep({},{data:n},{data:{app_id:n.appId,object_name:n.objectName,record_id:n.recordId,formFactor:Steedos.isMobile()?"SMALL":"LARGE",context:{rootUrl:Meteor.isCordova?a.endsWith("/")?a.substr(0,a.length-1):a:"",tenantId:Creator.USER_CONTEXT.spaceId,userId:Creator.USER_CONTEXT.userId,authToken:Creator.USER_CONTEXT.user.authToken,user:Creator.USER_CONTEXT.user},global:{userId:Creator.USER_CONTEXT.userId,spaceId:Creator.USER_CONTEXT.spaceId,user:Creator.USER_CONTEXT.user,now:new Date},scopeId:o.name||o.id,$scopeId:o.name||o.id}});return o=lodash.defaultsDeep(l,o),e.embed(s,o,{locale:c()},Object.assign(r(),i))})})}},layout:{"template.layout.js":function e(){Template.__checkName("creatorLayout"),Template.creatorLayout=new Template("Template.creatorLayout",(function(){var e=this;return Blaze.If((function(){return Spacebars.call(e.lookup("isloading"))}),(function(){return"\n\t"}),(function(){return["\n\t\t",HTML.DIV({class:"steedos skin-blue-light creator h-full flex flex-col relative overflow-hidden"},"\n\t\t\t\n\n\t\t\t",HTML.HEADER({id:"header",class:"steedos-global-header-root flex-none"}),"\n\n\t\t\t\t\n\t\t\t",HTML.DIV({id:"main",class:function(){return["creator-content-wrapper ",Blaze.If((function(){return Spacebars.call(e.lookup("split"))}),(function(){return"split"}))]}},"\n\n\n\n\t\t\t\t",HTML.Comment(' {{#if split}}\n\t\t\t\t\t\n\t\t\t\t\t\t{{> Template.dynamic template="creatorSidebar"}}\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t{{> Template.dynamic template=main}}\n\t\t\t\t\t
\n\t\t\t\t{{else}} '),"\n\t\t\t\t\t",Blaze._TemplateWith((function(){return{template:Spacebars.call(e.lookup("main"))}}),(function(){return Spacebars.include((function(){return Spacebars.call(Template.__dynamic)}))})),"\n\t\t\t\t",HTML.Comment(" {{/if}} "),"\n\t\t\t"),"\n\t\t\t",HTML.FOOTER({id:"footer",class:"steedos-global-footer-root flex-none"}),"\n\t\t"),"\n",HTML.Comment(' \n\t\t\n\t\t\t{{> status}}\n\t\t
'),"\n\t\t"]}))}))},"layout.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{},r,o;Template.creatorLayout.helpers(Creator.helpers),Template.creatorLayout.helpers({isloading:function(){return Creator.isloading()},collection:function(){return Session.get("action_collection")},fields:function(){return Session.get("action_fields")},collectionName:function(){return Session.get("action_collection_name")},doc:function(){return Session.get("action_record_id")},saveAndInsert:function(){var e,t,r,o;return!!(e=Session.get("action_save_and_insert"))&&(r=(t=Session.get("action_collection")).replace(/Creator.Collections./,""),null!=(o=Creator.getPermissions(r))?o.allowCreate:void 0)},split:function(){var e,t,r;return!(!(e=Creator.getApp())||"admin"!==e._id)&&(r=/\/app\/\w+\/search\//,t=Session.get("router-path"),!r.test(t))},object_name:function(){return Session.get("object_name")},recordId:function(){return Session.get("recordId")},title:function(){return"编辑"},triggerLabel:function(){return"编辑"},onAddFinish:function(){return function(e){var t,r,o,a,n;return a=e[0],n="/app/"+(t=Session.get("app_id"))+"/"+(r=Session.get("object_name"))+"/view/"+(o=a._id),FlowRouter.go(n),!0}},onEditFinish:function(){return function(){return setTimeout((function(){return FlowRouter.reload()}),1),!0}}}),Template.creatorLayout.onRendered((function(){var e;return e=Session.get("pageApiName")||Session.get("object_name")||Session.get("tab_name"),this.autorun((function(){return Steedos.Page.Header.render(Session.get("app_id"),e)})),this.autorun((function(){return Steedos.Page.Footer.render(Session.get("app_id"),e)})),this.autorun((function(){var e,t;if(t=Session.get("pageApiName")||Session.get("object_name")||Session.get("tab_name"),window.SteedosUI&&(e=SteedosUI.refs.globalHeader))return Meteor.setTimeout((function(){var t;try{return e.updateProps({location:FlowRouter.current()},(function(){return console.log("amisScope.updateProps callback.......")}))}catch(r){t=r}}),100)})),this.autorun((function(){var e,t;if(t=Session.get("pageApiName")||Session.get("object_name")||Session.get("tab_name"),window.SteedosUI&&(e=SteedosUI.refs.globalFooter))return Meteor.setTimeout((function(){var t;try{return e.updateProps({location:FlowRouter.current()},(function(){return console.log("amisScope.updateProps callback.......")}))}catch(r){t=r}}),100)}))})),r=function(){var e;return"calendar"===(null!=(e=Creator.getListView(Session.get("object_name",Session.get("list_view_id"))))?e.type:void 0)},AutoForm.hooks({creatorAddForm:{onSuccess:function(e,t){var o,a,n,i;if($("#afModal").modal("hide"),"/app/:app_id/:object_name/calendar/"!==FlowRouter._current.route.path&&!r())return"post"===t.type?(i="/app/"+(o=Session.get("app_id"))+"/"+(a=t.object_name)+"/view/"+(n=t._id),FlowRouter.go(i)):void 0}}},!1),AutoForm.hooks({creatorEditForm:{onSuccess:function(e,t){var o,a,n,i,s,c;if($("#afModal").modal("hide"),!r())return"post"===t.type&&(c="/app/"+(o=Session.get("app_id"))+"/"+(a=t.object_name)+"/view/"+(s=t._id),FlowRouter.go(c)),this.docId&&t.object_name?(i=Creator.getObjectUrl(t.object_name,this.docId),n=Creator.getObjectRecordName(this.updateDoc.$set,t.object_name),Creator.updateTempNavLabel(t.object_name,i,n)):void 0}}},!1),AutoForm.hooks({creatorCellEditForm:{onSuccess:function(e,t){var r,o;if($("#afModal").modal("hide"),this.docId&&t.object_name)return o=Creator.getObjectUrl(t.object_name,this.docId),r=Creator.getObjectRecordName(this.updateDoc.$set,t.object_name),Creator.updateTempNavLabel(t.object_name,o,r)}}},!1),o=function(e,t){return FlowRouter.current().route.path.endsWith("/:record_id")?FlowRouter.reload():window.refreshGrid()},AutoForm.hooks({creatorAddRelatedForm:{onSuccess:o}},!1)},"template.loading.js":function e(){Template.__checkName("creatorLoading"),Template.creatorLoading=new Template("Template.creatorLoading",(function(){var e=this;return HTML.Raw('')}))},"template.empty_layout.js":function e(){Template.__checkName("empty_layout"),Template.empty_layout=new Template("Template.empty_layout",(function(){var e=this;return Blaze._TemplateWith((function(){return{template:Spacebars.call(e.lookup("main"))}}),(function(){return Spacebars.include((function(){return Spacebars.call(Template.__dynamic)}))}))}))}},mobile:{"template.admin.js":function e(){Template.__checkName("adminMenu"),Template.adminMenu=new Template("Template.adminMenu",(function(){var e=this;return HTML.DIV({class:"admin-menu mobile-template-container",id:"admin_menu"},"\n\n ",HTML.DIV({class:"admin-menu-content mobile-template-content"},"\n\t\t\t",HTML.DIV({class:"weui-panel weui-panel_access user-info"},"\n\t\t\t\t",HTML.A({class:"weui-media-box weui-media-box_appmsg"},"\n\t\t\t\t\t",HTML.DIV({class:"weui-media-box__hd",style:function(){return["background: url(",Spacebars.mustache(e.lookup("avatarURL")),")"]}},"\n\t\t\t\t\t\t",HTML.Raw('\x3c!-- --\x3e'),"\n\t\t\t\t\t"),"\n\t\t\t\t\t",HTML.DIV({class:"weui-media-box__bd"},"\n\t\t\t\t\t\t",HTML.H4({class:"weui-media-box__title"},Blaze.View("lookup:name",(function(){return Spacebars.mustache(e.lookup("name"))}))),"\n\t\t\t\t\t\t",HTML.P({class:"weui-media-box__desc"},"\n\t\t\t\t\t\t\t",Blaze.View("lookup:_",(function(){return Spacebars.mustache(e.lookup("_"),"Company")})),":",Blaze.View("lookup:spaceName",(function(){return Spacebars.mustache(e.lookup("spaceName"))})),"\n\t\t\t\t\t\t"),"\n\t\t\t\t\t"),"\n\t\t\t\t"),"\n\t\t\t"),"\n\n\t\t\t",HTML.DIV({class:"weui-panel"},"\n\t\t\t\t",HTML.DIV({class:"weui-panel__bd"},"\n\t\t\t\t\t",HTML.DIV({class:"weui-media-box weui-media-box_small-appmsg"},"\n\t\t\t\t\t\t",HTML.DIV({class:"weui-cells"},"\n\t\t\t\t\t\t\t",HTML.A({class:"weui-cell weui-cell_access btn-switch-space"},"\n\t\t\t\t\t\t\t\t",HTML.DIV({class:"weui-cell__bd weui-cell_primary"},"\n\t\t\t\t\t\t\t\t\t",HTML.P(Blaze.View("lookup:_",(function(){return Spacebars.mustache(e.lookup("_"),"Switch Company")}))),"\n\t\t\t\t\t\t\t\t"),"\n\t\t\t\t\t\t\t\t",HTML.SPAN({class:"space-name"},Blaze.View("lookup:spaceName",(function(){return Spacebars.mustache(e.lookup("spaceName"))}))),"\n\t\t\t\t\t\t\t\t",HTML.Raw(''),"\n\t\t\t\t\t\t\t"),"\n\t\t\t\t\t\t"),"\n\t\t\t\t\t"),"\n\n\n\n\t\t\t\t\t",HTML.DIV({class:"weui-media-box weui-media-box_small-appmsg"},"\n\t\t\t\t\t\t",HTML.DIV({class:"weui-cells"},"\n\t\t\t\t\t\t\t",HTML.A({class:"weui-cell weui-cell_access btn-change-password"},"\n\t\t\t\t\t\t\t\t",HTML.DIV({class:"weui-cell__bd weui-cell_primary"},"\n\t\t\t\t\t\t\t\t\t",HTML.P(Blaze.View("lookup:_",(function(){return Spacebars.mustache(e.lookup("_"),"Change Password")}))),"\n\t\t\t\t\t\t\t\t"),"\n\t\t\t\t\t\t\t\t",HTML.Raw(''),"\n\t\t\t\t\t\t\t"),"\n\t\t\t\t\t\t"),"\n\t\t\t\t\t"),"\n\t\t\t"),"\n\t\t\t"),"\n\n ",HTML.DIV({class:"weui-panel"},"\n\t\t\t\t",HTML.DIV({class:"weui-panel__bd"},"\n\t\t\t\t\t",HTML.DIV({class:"weui-media-box weui-media-box_small-appmsg"},"\n\t\t\t\t\t\t",HTML.DIV({class:"weui-cells"},"\n\t\t\t\t\t\t\t",HTML.A({class:"weui-cell weui-cell_access log-out steedos-logout"},"\n\t\t\t\t\t\t\t\t",HTML.DIV({class:"weui-cell__bd weui-cell_primary"},"\n\t\t\t\t\t\t\t\t\t",HTML.P(Blaze.View("lookup:_",(function(){return Spacebars.mustache(e.lookup("_"),"Logout")}))),"\n\t\t\t\t\t\t\t\t"),"\n\t\t\t\t\t\t\t"),"\n\t\t\t\t\t\t"),"\n\t\t\t\t\t"),"\n\t\t\t\t"),"\n\t\t\t"),"\n "),"\n ")}))},"admin.coffee":function e(){var r=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};Template.adminMenu.helpers({avatarURL:function(e,t,r,o){var a,n;return n=Meteor.userId(),(e=null!=(a=Creator.getCollection("users").findOne({_id:n}))?a.avatar:void 0)?Steedos.absoluteUrl("avatar/"+Meteor.userId()+"?avatar="+e):Creator.getRelativeUrl("/images/default-avatar.png")},name:function(){var e;return null!=(e=Creator.getCollection("users").findOne())?e.name:void 0},logoutUrL:function(){return Creator.getRelativeUrl("/accounts/a/#/logout")},spaceName:function(){var e;return Session.get("spaceId")&&(e=db.spaces.findOne(Session.get("spaceId")))?e.name:t("none_space_selected_title")}}),Template.adminMenu.events({"click .steedos-logout":function(){return Steedos.logout()},"click .admin-menu-back":function(e,t){var r;return r=urlQuery[urlQuery.length-2],urlQuery.pop(),t.$("#admin_menu").animateCss("fadeOutRight",(function(){return Blaze.remove(t.view),r?FlowRouter.go(r):FlowRouter.go("/app")}))},"click .btn-switch-space":function(e,t){return FlowRouter.go("/user_settings/switchspace")},"click .btn-change-password":function(e,t){return Modal.show("reset_password_modal")},"click .btn-change-avatar":function(e,t){return t.$("#mobile-avator-upload").click()},"change #mobile-avator-upload":function(e,r){var o;if(o=e.target.files[0])return $("body").addClass("loading"),db.avatars.insert(o,(function(e,r){return e?(console.error(e),toastr.error(t(e.reason)),$(document.body).removeClass("loading")):setTimeout((function(){return Meteor.call("updateUserAvatar",r._id,(function(e,r){return(null!=r?r.error:void 0)?($(document.body).removeClass("loading"),toastr.error(t(r.message))):$(document.body).removeClass("loading")}))}),3e3)}))}})},"template.switch_space.js":function e(){Template.__checkName("switchSpace"),Template.switchSpace=new Template("Template.switchSpace",(function(){var e=this;return HTML.DIV({class:"switch-space mobile-template-container",id:"switch_space"},"\n\t\t\n\t\t",HTML.DIV({class:"switch-space-content mobile-template-content"},"\n\t\t\t",HTML.DIV({class:"weui-panel"},"\n\t\t\t\t",HTML.DIV({class:"weui-panel__bd"},"\n\t\t\t\t\t",HTML.DIV({class:"weui-media-box weui-media-box_small-appmsg"},"\n\t\t\t\t\t\t",HTML.DIV({class:"weui-cells"},"\n\t\t\t\t\t\t\t",Blaze.Each((function(){return Spacebars.call(e.lookup("spaces"))}),(function(){return["\n\t\t\t\t\t\t\t",HTML.A({class:"weui-cell weui-cell_access switchSpace"},"\n\t\t\t\t\t\t\t\t",HTML.DIV({class:"weui-cell__bd weui-cell_primary"},"\n\t\t\t\t\t\t\t\t\t",HTML.P(Blaze.View("lookup:name",(function(){return Spacebars.mustache(e.lookup("name"))}))),"\n\t\t\t\t\t\t\t\t"),"\n\t\t\t\t\t\t\t\t",Blaze.If((function(){return Spacebars.dataMustache(e.lookup("current_space"),e.lookup("_id"))}),(function(){return["\n\t\t\t\t\t\t\t\t\t",HTML.SPAN({class:"weui-icon-success-no-circle"}),"\n\t\t\t\t\t\t\t\t"]})),"\n\t\t\t\t\t\t\t"),"\n\t\t\t\t\t\t\t"]})),"\n\t\t\t\t\t\t"),"\n\t\t\t\t\t"),"\n\t\t\t\t"),"\n\t\t\t"),"\n\t\t"),"\n\t")}))},"switch_space.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};Template.switchSpace.helpers({spaces:function(){return db.spaces.find()},current_space:function(e){return e===Session.get("spaceId")}}),Template.switchSpace.events({"click .switchSpace":function(e,t){return Steedos.setSpaceId(this._id),FlowRouter.go("/app")},"click .switch-space-back":function(e,t){var r;return r=urlQuery[urlQuery.length-2],urlQuery.pop(),t.$("#switch_space").animateCss("fadeOutRight",(function(){return Blaze.remove(t.view),r?FlowRouter.go(r):FlowRouter.go("/app")}))}})}},"core.coffee":function e(){var r=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{},o;Creator.Pages={},o=["owner","company_id","company_ids","locked"],Steedos.addPage=function(e,t){if(e)return Creator.Pages[e]=t},Creator.getLayout=function(e){return e||(e=Session.get("app_id")),"steedos"===e?"steedosLayout":"creatorLayout"},Creator.createObject=function(e,t){var r,o;return o=Creator.getObject(e),r="Creator.Collections."+e,Session.set("action_collection",r),Session.set("action_save_and_insert",!0),Session.set("action_collection_name",o.label),Session.set("action_object_name",e),Session.set("action_fields",void 0),Session.set("cmDoc",t),Meteor.defer((function(){return $(".creator-add").click()}))},Meteor.isClient&&(Creator.TabularSelectedIds={},Meteor.autorun((function(){var e,t;if(e=Session.get("list_view_id"),t=Session.get("object_name"))return Creator.TabularSelectedIds[t]=[]})),Creator.remainCheckboxState=function(e){var t,r,o,a,n,i,s;if((t=e.find(".select-all")).length&&(a=(o=null!=(n=t[0])?n.dataset:void 0).objectName,i=Creator.TabularSelectedIds[a]))return(r=e.find(".select-one")).each((function(e,t){var r;return r=i.indexOf(t.dataset.id)>-1,$(t).prop("checked",r)})),(s=i.length)>0&&r.length!==s?t.prop("indeterminate",!0):(t.prop("indeterminate",!1),0===s?t.prop("checked",!1):s===r.length?t.prop("checked",!0):void 0)},Creator.isListViewFilterEditable=function(e){return!e.shared||e.shared&&e.owner===Steedos.userId()},Creator.getODataFilter=function(e,t,r){var o,a,n,i,s,c,l,u,d,p,f,m,g;if(g=Meteor.userId(),m=Session.get("spaceId"),a=Creator.Collections.object_listviews.findOne(e))(l=Creator.isListViewFilterEditable(a))||((o={}).filter_scope=a.filter_scope,o.filters=a.filters);else if(o={},m&&g){if(!(u=Creator.getListView(t,e)))return["_id","=",-1];o.filter_scope=u.filter_scope,o.filters=u.filters}if(Creator.isCloudAdminSpace(m)&&_.include(["users","space_users","spaces"],t)&&delete o.filters,o&&(r?(o.filter_scope&&(r.filter_scope=o.filter_scope),_.isFunction(r.filters)||(null!=(d=r.filters)?d.length:void 0)?(_.isFunction(o.filters)||(null!=(p=o.filters)?p.length:void 0))&&(r.filters=[[r.filters,"and",o.filters]]):r.filters=o.filters):r=o),r||(r={}),n=r.filter_logic,i=r.filter_scope,s=r.filters,f=[],_.isFunction(s)&&(s=s()),a?n?(c=Creator.formatLogicFiltersToDev(s,n),f.length?f.push("and",c):f.push(c)):s&&s.length>0&&(f.length>0&&f.push("and"),(s=Creator.formatFiltersToDev(s,t))&&s.length>0&&(s=[s]),_.each(s,(function(e){return f.push(e)}))):m&&g&&("users"!==t||Creator.isCloudAdminSpace(m)||f.push(["_id","=",g]),s&&(s=Creator.formatFiltersToDev(s,t))&&s.length>0&&(s=[s],f.length>0&&f.push("and"),_.each(s,(function(e){if("spaces"!==t||e.length>0&&"_id"!==e[0])return f.push(e)})))),"mine"===i&&(f.length>0&&f.push("and"),f.push(["owner","=",g])),0!==f.length)return f},Creator.getODataRelatedFilter=function(e,t,r,o,a){var n,i,s,c,l,u,d,p,f,m,g,h,v,b,w,S,C;if(r&&(S=Steedos.spaceId(),C=Meteor.userId(),v=a?[a]:Creator.getRelatedList(e,r),h="",u="",w=[],n=function(e){return w.length>0&&w.push("and"),w.push(e)},_.each(v,(function(e){if(e.object_name===t)return e.filtersFunction?u=e.filtersFunction:h=e.related_field_name})),h||u)){if(h=h.replace(/\./g,"/"),o&&(i=Creator.getListView(t,o))){if(s=i.filter_logic,c=i.filter_scope,l=i.filters,u)return l=u(Creator.odata.get(e,r));s?(d=Creator.formatLogicFiltersToDev(l,s),n(d)):l&&l.length>0&&(l=_.map(l,(function(e){return _.isObject(e)&&!_.isArray(e)?Meteor.isClient&&_.isString(null!=e?e._value:void 0)?[e.field,e.operation,Creator.eval("("+e._value+")")()]:[e.field,e.operation,e.value]:e})),(l=Creator.formatFiltersToDev(l,t))&&l.length>0&&(l=[l]),_.each(l,(function(e){return n(e)})))}if("cfs.files.filerecord"===t&&n(["metadata/space","=",S]),m=Creator.getObject(t),p=t===e&&(null!=m?m.enable_tree:void 0),"cms_files"===t?(n(["parent/o","=",e]),n(["parent/ids","=",r])):"objects"===e?n([h,"=",r]):p||((b=null!=m?m.fields:void 0)&&(g=b[h]),g&&g.reference_to_field&&(f=Creator.odata.get(e,r,g.reference_to_field),"permission_fields"===t&&"object_fields"===e&&n(["object_name","=",f.object]),f&&f[g.reference_to_field]&&(r=f[g.reference_to_field])),!g||"master_detail"!==g.type&&"lookup"!==g.type?g&&"grid"===g.type?(n([h+".o","=",e]),n([h+".ids","=",r])):n([h,"=",r]):_.isFunction(g.reference_to)?_.isArray(g.reference_to())?n([h+".ids","=",r]):n([h,"=",r]):_.isArray(g.reference_to)?n([h+".ids","=",r]):n([h,"=",r])),"mine"===c&&n(["owner","=",C]),0!==w.length)return w}},Creator.getJsReportUrlQuery=function(){var e,t,r;return r="?space_id="+Steedos.getSpaceId(),(t=Tracker.nonreactive((function(){return Session.get("filter_items")})))&&(r+="&user_filters="+(e=encodeURI(JSON.stringify(t)))),r},Creator.getJsReportViewUrl=function(e){var t;return t=Creator.getRelativeUrl("/plugins/jsreport/web/viewer_db/"+e),t+=Creator.getJsReportUrlQuery()},Creator.getJsReportExcelUrl=function(e){var t;return t=Creator.getRelativeUrl("/plugins/jsreport/api/report_db/"+e+"/excel"),t+=Creator.getJsReportUrlQuery()},Creator.getJsReportPdfUrl=function(e){var t;return t=Creator.getRelativeUrl("/plugins/jsreport/api/report_db/"+e+"/pdf"),t+=Creator.getJsReportUrlQuery()},Creator.getStimulsoftReportViewUrl=function(e){var t;return t=Creator.getRelativeUrl("/plugins/stimulsoft/web/viewer_db/"+e),t+=Creator.getJsReportUrlQuery()},Creator.getStimulsoftReportDesignerUrl=function(e){var t;return t=Creator.getRelativeUrl("/plugins/stimulsoft/web/designer_db/"+e),t+=Creator.getJsReportUrlQuery()},Creator.objectOdataSelectFields=function(e){var t,r;return t=e.fields,r=(r=_.keys(t)).filter((function(e){return e.indexOf(".")<0})),e&&["default","meteor"].indexOf(e.database_name||"default")>-1&&(r=_.union(r.concat(o))),r.join(",")},Creator.objectOdataExpandFields=function(e,t){var r,o;return r=[],o=e.fields,t||(t=_.keys(o)),_.each(t,(function(e){var t,a,n;if(("master_detail"===(null!=(a=o[e])?a.type:void 0)||"lookup"===(null!=(n=o[e])?n.type:void 0))&&(o[e].reference_to?(t=o[e].reference_to,_.isFunction(t)&&(t=t())):_.isFunction(o[e].optionsFunction)&&(t=o[e].optionsFunction({}).getProperty("value")),_.isArray(t)||(t=[t]),t=_.map(t,(function(e){var t,r;return t=(null!=(r=Creator.getObject(e))?r.NAME_FIELD_KEY:void 0)||"name"})),t=_.compact(t),(t=(t=_.uniq(t)).join(","))&&e.indexOf("$")<0))return e.indexOf(".")<0?r.push(e):r.push(e.replace(".","/"))})),r.join(",")},Creator.relatedObjectFileUploadHandler=function(e,r){var o,a,n,i,s,c,l,u,d,p;for(u=null!=(o=e.currentTarget.dataset)?o.parent:void 0,s=e.currentTarget.files,c=0,d=Session.get("record_id"),l=Session.get("object_name"),p=Session.get("spaceId");c0&&(t=!0),!t})),t},Creator.pushCurrentPathToUrlQuery=function(){var e;if((e=FlowRouter.current().path)!==urlQuery[urlQuery.length-1])return urlQuery.push(e)},Creator.getStandardQuery=function(e,t){var r,o,a,n,i,s;if(o=Creator.getObject(e).fields,t&&t.query&&_.size(t.query)&&t.object_name===e)return a=t.object_name,i=t.query,s=[],t.is_mini?_.each(i,(function(e,t){var r,n,i,c;if(o[t])if(r=Creator.getFieldDataType(o,t),["currency","number"].includes(r)){if(!_.isString(e))return s.push([t,"=",e]);if(c=e.trim().split(" "),n=[],c.forEach((function(e){var r,o;try{if(o=Number(e),_.isNumber(o)&&!_.isNaN(o))return n.push([t,"=",o])}catch(a){return r=a,console.error(r)}})),n.length>0)return s.push(Creator.formatFiltersToDev(n,a,{is_logic_or:!1}))}else if(["text","textarea","html","select","autonumber","url","email"].includes(r))if(_.isString(e)){if(c=e.trim().split(" "),i=[],c.forEach((function(e){return e=encodeURIComponent(Creator.convertSpecialCharacter(e)),"select"===r&&o[t].multiple?i.push([t,"=",e]):i.push([t,"contains",e])})),i.length>0)return s.push(Creator.formatFiltersToDev(i,a,{is_logic_or:!1}))}else if(_.isArray(e))return s.push([t,"=",e])})):_.each(i,(function(e,t){var r,n,i,c,l,u;if(o[t]){if(n=Creator.getFieldDataType(o,t),["date","datetime","time","currency","number"].includes(n))return s.push([t,">=",e]);if(["text","textarea","html"].includes(n)){if(_.isString(e)){if(u=e.trim().split(" "),l=[],u.forEach((function(e){return e=encodeURIComponent(Creator.convertSpecialCharacter(e)),l.push([t,"contains",e])})),l.length>0)return s.push(Creator.formatFiltersToDev(l,a,{is_logic_or:!1}))}else if(_.isArray(e))return s.push([t,"=",e])}else{if(["boolean"].includes(n))return s.push([t,"=",JSON.parse(e)]);if(!["lookup","master_detail"].includes(n))return s.push([t,"=",e]);if(i=null!=(r=o[t])?r.reference_to:void 0,_.isFunction(i)&&(i=i()),!_.isArray(i))return s.push([t,"=",e]);if((null!=e?e.ids:void 0)&&s.push({field:t+".ids",operation:"=",value:null!=e?e.ids:void 0}),null!=e?e.o:void 0)return c=Creator.getObject(null!=e?e.o:void 0),s.push({field:t+".o",operation:"=",value:c._collection_name})}}else if(t=t.replace(/(_endLine)$/,""),n=Creator.getFieldDataType(o,t),o[t]&&["date","datetime","time","currency","number"].includes(n))return s.push([t,"<=",e])})),n={is_logic_or:r=!!t.is_mini},Creator.formatFiltersToDev(s,a,n);delete Session.keys.standard_query},Creator.getSafeObjectUrl=function(e,t,r){var o;return _.isString(e)?(o="users"===e?Creator.getObject("space_users"):Creator.getObject(e)).permissions.get().allowRead?Creator.getObjectUrl(e,t,r):void 0:""},Creator.formatFileSize=function(e){var t,r;return r="KB",(t=e/1024)>1024&&(t/=1024,r="MB"),t>1024&&(t/=1024,r="GB"),t.toFixed(2)+r},Creator.getTableCellData=function(e){var r,o,a,n,i,s,c,l,u,d,p,f,m,g,h,v,b,w,S,C,y,j,T,R;if(d=[],R=e.val,g=e.object_name,y=(j=Creator.getObject(g)).NAME_FIELD_KEY,"organizations"===g&&(y="name"),o=e.field){if(a=o.type,"formula"===o.type)a=o.data_type;else if("select"===o.type&&o.data_type&&"text"!==o.data_type)a=o.data_type;else if("summary"===o.type)if("count"===o.summary_type)a="number";else{if(!(C=Creator.getObject(o.summary_object)))throw new Meteor.Error(500,"The summary_object '"+o.summary_object+"' is not found for the field '"+o.name+"'");if(!(S=C.fields[o.summary_field]))throw new Meteor.Error(500,"The summary_field '"+o.summary_field+"' is not found for the field '"+o.name+"'");"formula"!==(a=S.type)&&"summary"!==a||(a=S.data_type),_.isNumber(o.scale)||(r=function(e){var t,o;return _.isNumber(e.scale)?e.scale:"summary"===e.type&&(o=Creator.getObject(e.summary_object))?(t=o.fields[e.summary_field])?r(t):null:void 0},o.scale=r(S))}return v=null!=(h=e.field)?h.reference_to:void 0,_.isFunction(v)&&(v=v()),"grid"===a?d.push({isTable:!0}):"location"===a?d.push({value:(null!=R?R.address:void 0)||"",id:e._id}):"lookup"!==a&&"master_detail"!==a||_.isEmpty(R)?"image"===a?"string"==typeof R?d.push({value:R,id:e._id,isImage:!0,baseUrl:Creator.getRelativeUrl("/api/files/images")}):d.push({value:R,id:e._id,isImages:!0,baseUrl:Creator.getRelativeUrl("/api/files/images")}):"avatar"===a?"string"==typeof R?d.push({value:R,id:e._id,isImage:!0,baseUrl:Creator.getRelativeUrl("/api/files/avatars")}):d.push({value:R,id:e._id,isImages:!0,baseUrl:Creator.getRelativeUrl("/api/files/avatars")}):"code"===a?(R=R?"...":"",d.push({value:R,id:e._id})):"password"===a?(R=R?"******":"",d.push({value:R,id:e._id})):"url"===a?((null!=(f=R)?f.startsWith("http"):void 0)||(f=Steedos.absoluteUrl(encodeURI(f))),d.push({value:R,href:f,id:e._id,isUrl:!0})):"email"===a?d.push({value:R,href:f,id:e._id,isEmail:!0}):"boolean"===a||"toggle"===a?(R=e.val?t("YES"):t("NO"),d.push({value:R,checked:e.val,id:e._id,isBoolean:!0})):"select"===a?(s=o.allOptions||o.options,u=e.doc||{},c=e.record_val,_.isFunction(o.options)&&(s=o.options(c||u)),_.isFunction(o.optionsFunction)&&(s=o.optionsFunction(c||u)),w=e.val,_.isArray(w)||(w=[w]),m=[],_.each(s,(function(e){if(_.indexOf(w,e.value)>-1)return m.push({label:e.label,value:e.value})})),R=(R=m.map((function(e){return e.label}))).join(","),d.push({value:R,items:m,id:e._id,isSelects:!0})):(R&&["datetime","date","time"].indexOf(a)>=0?"odata"===e.agreement?"datetime"===a?"string"==typeof e.val&&/\d+Z$/.test(e.val)?R=moment(e.val).format("YYYY-MM-DD H:mm"):(T=moment().utcOffset()/60,R=moment(e.val).add(T,"hours").format("YYYY-MM-DD H:mm")):"date"===a&&(R="string"==typeof e.val&&/\d+Z$/.test(e.val)?moment.utc(e.val).format("YYYY-MM-DD"):moment(e.val).format("YYYY-MM-DD")):"datetime"===a?R=moment(e.val).format("YYYY-MM-DD H:mm"):"date"===a?R=moment.utc(e.val).format("YYYY-MM-DD"):"time"===a&&(R=moment.utc(e.val).format("HH:mm")):null===e.val?R="":"lookup"===a?_.isFunction(o.optionsFunction)&&(u=e.doc||{},(l=R)&&(_.isArray(l)||(l=[l]),(b=_.filter(o.optionsFunction(u),(function(e){return l.indexOf(e.value)>-1})))&&(R=b.getProperty("label")))):"filesize"===a?R=Creator.formatFileSize(R):["number","currency","percent"].indexOf(a)>-1&&_.isNumber(R)?(p=0,p=_.isNumber(o.scale)?o.scale:"currency"===a?2:0,"percent"===a&&(R*=100),R=Steedos.numberToString(R,p),"percent"===a&&(R+="%")):"markdown"===a?_.isEmpty(R)||(R=Spacebars.SafeString(marked(R))):"html"===a?_.isEmpty(R)||(R=Spacebars.SafeString(R)):"textarea"===a&&R&&(R=(R=R.replace(/\n/g,"\n
")).replace(/ /g," ")),"record_details"!==e.parent_view&&e.field_name===y&&(f=Creator.getObjectUrl(e.object_name,e._id)),d.push({value:R,href:f,id:e._id,type:a})):_.isFunction(o.optionsFunction)&&"company"!==v?(u=e.doc||{},c=e.record_val,(l=R)&&(l=_.isArray(l)?l.map((function(e){return _.isObject(e)?e._id:e})):_.isObject(l)?[l._id]:[l],i=o.optionsFunction(c||u),(b=_.filter(i,(function(e){return l.indexOf(null!=e?e.value:void 0)>-1})))&&(R&&_.isArray(R)&&_.isArray(b)&&(b=Creator.getOrderlySetByIds(b,R,"value")),R=b.getProperty("label"))),v?"objects"===v?_.each(b,(function(t){var r,o,a;return a=t.label,(null!=(r=Creator.getObject(t.value))?r._id:void 0)?(o=Creator.getSafeObjectUrl(v,r._id),d.push({reference_to:v,rid:a,value:a,id:e._id,href:o})):d.push({value:R,id:e._id})})):(n=e.val,_.isArray(n)||(n=n?[n]:[]),_.each(n,(function(t){var r,o,a;return _.isString(t)?(b=_.filter(i,(function(e){return t===(null!=e?e.value:void 0)})),d.push({value:b.getProperty("label"),id:e._id})):(v=t["reference_to._o"]||v,o=t._id,a=t._NAME_FIELD_VALUE,r=Creator.getSafeObjectUrl(v,o),d.push({reference_to:v,rid:o,value:a,href:r,id:e._id}))}))):d.push({value:R,id:e._id})):(_.isArray(R)||(R=R?[R]:[]),_.each(R,(function(t){var r,o,a;if(t)return v=t["reference_to._o"]||v,o=t._id,a=t._NAME_FIELD_VALUE,_.isString(t)&&(o=t,a=t),r=Creator.getSafeObjectUrl(v,o),d.push({reference_to:v,rid:o,value:a,href:r,id:e._id})}))),d}},Creator.openSafeObjectUrl=function(e,t){var r;return Steedos.isMobile()||(r=Creator.getSafeObjectUrl(e,t,"-"))&&window.open(r,"_blank","width=800, height=600, left=50, top= 50, toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes"),"undefined"!=typeof event&&null!==event&&event.stopPropagation(),"undefined"!=typeof event&&null!==event&&event.preventDefault(),!1},Creator.getAppLabel=function(e){return e||(e=Creator.getApp()),e?e.label?t(e.label):t(e.name):""},Creator.measureWidth=_.memoize((function(e,t,r){var o,a,n,i;return(o=arguments.callee.canvas)||(o=document.createElement("canvas"),(n=document.createDocumentFragment()).appendChild(o),arguments.callee.canvas=o),(a=o.getContext("2d")).font=t,i=a.measureText(e).width,r&&i>r?r:i})),Creator.showPreviewButton=function(e){var t,r,o,a,n;return!!((null!=(n=null!=(t=Meteor.settings)&&null!=(r=t.public)?r.webservices:void 0)&&null!=(o=n.officeOnline)?o.url:void 0)&&Steedos.isOfficeFile(e)||(null!=n&&null!=(a=n.pdfOnline)?a.url:void 0)&&Steedos.isPdfFile(e))},Creator.officeOnlinePreview=function(e,t){var r,o,a,n,i,s,c,l,u,d,p,f,m,_,g,h;return a=null!=(s=Meteor.settings)&&null!=(c=s.public)&&null!=(l=c.webservices)&&null!=(u=l.officeOnline)?u.url:void 0,i=null!=(d=Meteor.settings)&&null!=(p=d.public)&&null!=(f=p.webservices)&&null!=(m=f.pdfOnline)?m.url:void 0,a&&""!==a||i&&""!==i?(h=Meteor.userId(),_=Steedos.spaceId(),r={authToken:o=Accounts._storedLoginToken()},e=e+"?token="+(g=window.btoa(JSON.stringify(r))),Steedos.isPdfFile(t)?(n=e,i&&""!==i&&(n=i+encodeURIComponent(e)),Steedos.openWindow(n)):(n=a+encodeURIComponent(e),Steedos.openWindow(n))):(toastr.error(TAPi18n.__("creator_office_online_web_url_required")),!1)},Creator.isImageAttachment=function(e){var t,r;return!(e.split(".").length<2)&&(t=e.split(".").pop().toLowerCase(),-1!==(r=["png","jpg","jpeg","bmp","gif","webp","psd","svg","tiff"]).indexOf(t))},Creator.isHtmlAttachment=function(e){var t,r;return!(e.split(".").length<2)&&(t=e.split(".").pop().toLowerCase(),-1!==(r=["html","htm"]).indexOf(t))}),Meteor.startup((function(){return $(document).on("click",(function(e){return $(e.target).closest(".slds-table td").length<1?$(".slds-table").addClass("slds-no-cell-focus"):$(".slds-table").removeClass("slds-no-cell-focus")})),$(window).resize((function(){if($(".list-table-container table.dataTable").length)return $(".list-table-container table.dataTable thead th").each((function(){var e;return e=$(this).outerWidth(),$(".slds-th__action",this).css("width",e+"px")}))})),$(document).keydown((function(e){if("13"===e.keyCode||"Enter"===e.key){if($(".modal").length>1)return;if("TEXTAREA"!==e.target.tagName||$(e.target).closest("div").hasClass("bootstrap-tagsinput")){if("update"===Session.get("cmOperation"))return e.preventDefault(),e.stopPropagation(),$(".creator-auotform-modals .btn-update").click();if("insert"===Session.get("cmOperation"))return e.preventDefault(),e.stopPropagation(),$(".creator-auotform-modals .btn-insert").click()}}}))}))},"colors.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{},r,o,a,n,i;n="border-radius: 10px;padding: 1px 6px;display: inline-block;",i=function(e){return 3===(e=e.slice(1)).length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),{r:Number.parseInt(e.slice(0,2),16),g:Number.parseInt(e.slice(2,4),16),b:Number.parseInt(e.slice(4,6),16)}},a=function(e,t,r){var o,a,n,s;return.299*(n=(s=i(e)).r)+.587*(a=s.g)+.114*(o=s.b)>186?r:t},o=function(e,t,r){var o,a,n,s,c,l,u;return(o=.2126*(n=(u=[(c=(l=i(e)).r)/255,(s=l.g)/255,(a=l.b)/255]).map((function(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)})))[0]+.7152*n[1]+.0722*n[2])>.179?r:t},r=function(e){var t,r;return r=[],t=e.fields,_.each(t,(function(t,a){var i;if(i=t.options,_.isFunction(i)&&(i=i({})),"select"===t.type&&(null!=i?i.length:void 0))return _.each(i,(function(t){var i,s;if(t.color)return i=t.color,/^#/.test(i)||(i="#"+i),s=o(i,"#fff","#333"),r.push(".creator-cell-color-"+e.name+"-"+a+"-"+t.value+"{"+n+"background:"+i+";color:"+s+";}")}))})),r},Creator.appendObjectFieldsColorStyles=function(){var e,t;return $("#object_fields_color_styles").remove(),t=[],_.each(Creator.Objects,(function(e){return t=_.union(t,r(e))})),t.push(".creator-cell-multiple-color{\n\tmargin-right:1px;\n}\n@media (max-width:767px) {\n\t.creator-cell-multiple-color{\n\t\tmargin-right:4px;\n\t}\n}"),e=$('"),$("head").append(e)}},"temp_navs.coffee":function e(){var r=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{},o,a,n,i,s,c,l,u,d,p;s=!1,a=function(){var e;if(e=sessionStorage.getItem("temp_navs"))return e.split(",").map((function(e){var t;return{name:(t=e.split(":"))[0],url:t[1],label:t[2],is_temp:!0}}))},n=function(e,t,r){return sessionStorage.getItem("temp_navs_id")},d=function(e){return sessionStorage.setItem("temp_navs_id",e)},p=function(e){var t,r;return e||(e=[]),t=(r=e.map((function(e){var t;return t=e.name,e.url&&(t+=":"+e.url),e.label&&(t+=":"+e.label),t}))).join(","),sessionStorage.setItem("temp_navs",t)},c=[],o=function(e,t){var r;return r=t||Creator.getObjectUrl(e),c.push(r)},u=function(e,t){var r,o;if(o=t||Creator.getObjectUrl(e),(r=c.indexOf(o))>-1)return c.splice(r,1)},i=function(e,t){var r,o,a,n,i,s;for(r=t||Creator.getObjectUrl(e),o=2,s=6,i=!1;!i&&o<8&&!((a=urlQuery.length-o)<0);)n=urlQuery[a],__meteor_runtime_config__.ROOT_URL_PATH_PREFIX+n!==r?(i=n&&c.indexOf(__meteor_runtime_config__.ROOT_URL_PATH_PREFIX+n)<0,o++):o++;return i?n:null},l=function(e,t,r,a){var n,s,c,l,u,d,p,f,m;return n=Session.get("object_name"),s=Session.get("record_id"),t?(l=(c=Creator.getObjectUrl(n,s))===t)||(l=FlowRouter.current().path===t):l=n===e,l?(d=i(e,t),o(e,t),d?(FlowRouter.go(d),urlQuery.pop(),urlQuery.pop()):((f=r[a])||(f=r[a-1]),f?(m=f.url?f.url:Creator.getObjectUrl(f.name),FlowRouter.redirect(m)):(u=(p=Creator.getAppMenus())[p.length-1],FlowRouter.redirect(u.path)))):o(e,t)},Creator.getTempNavs=function(){var e;return(e=Session.get("temp_navs"))||(e=a())&&Session.set("temp_navs",e),e},Creator.getTempNavsId=function(){var e;return(e=Session.get("temp_navs_id"))||(e=n())&&Session.set("temp_navs_id",e),e},Creator.createTempNav=function(e,t,r){var o,a;if(t||!(["users","cms_files","cfs.files.filerecord"].indexOf(e)>-1))return(a=Creator.getTempNavs())||(a=[]),(o=a.find((function(r){return t?r.name===e&&r.url===t:r.name===e})))?void 0:(a.push({name:e,url:t,label:r,is_temp:!0}),Session.set("temp_navs",a),p(a),u(e,t))},Creator.updateTempNavLabel=function(e,t,r){var o,a;if(t&&r)return(a=Creator.getTempNavs())||(a=[]),(o=a.find((function(r){return r.name===e&&r.url===t})))?(o.label=r,Session.set("temp_navs",a),p(a)):void 0},Creator.removeTempNavItem=function(e,t){var r,o,a;if((a=Session.get("temp_navs"))&&(o=null,r=a.filter((function(r,a){var n;return(n=t?r.name===e&&r.url===t:r.name===e)&&(o=a),!n})),_.isNumber(o)))return s=!0,l(e,t,r,o),Meteor.defer((function(){return Session.set("temp_navs",r),p(r),s=!1})),!0},Creator.resetTempNavsIfNeeded=function(){var e,t,r;if((t=(r=Creator.getTempNavsId())!==(e=Meteor.userId()+":"+Steedos.spaceId()+":"+Session.get("app_id")))&&(Session.set("temp_navs",null),p(null),c.length=0),t||!Session.get("temp_navs_id"))return Session.set("temp_navs_id",e),d(e)},Meteor.startup((function(){if(!Steedos.isMobile())return Tracker.autorun((function(){var e,t;if(Creator.bootstrapLoaded.get()&&(t=Session.get("spaceId"),e=Session.get("app_id"),t&&e))return Creator.resetTempNavsIfNeeded()})),Tracker.autorun((function(e){var r,o,a,n,i,c,l,u,d,p,f,m,g,h,v;if(u=Session.get("object_name"),h=Session.get("tab_name"),p=Session.get("record_id"),i=Creator.getAppMenus(),u&&i&&i.length&&(f=Session.get("record_name"),n=_.pluck(i,"id"),o=Session.get("temp_navs_force_create"),(null!=n?n.indexOf(u||h):void 0)<0||o)){if(o&&s)return void Session.set("temp_navs_force_create",!1);if(!(l=Creator.getObject(u)))return;if(p){if(!(d=Creator.getObjectRecord()))return;if(v=Creator.getObjectUrl(u,p),o&&(r=urlQuery[urlQuery.length-3])&&(g=new RegExp(r+"$")).test(v))return void Session.set("temp_navs_force_create",!1);a=f||("cfs.files.filerecord"===u?t("cfs_files_filerecord__object")+"-"+(null!=d&&null!=(m=d.original)?m.name:void 0):d[c=l.NAME_FIELD_KEY||"name"]),Creator.createTempNav(u,v,a)}else Creator.createTempNav(u);if(o)return Session.set("temp_navs_force_create",!1)}}))}))},"router.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{},r,o,a,n;this.urlQuery=new Array,o=function(e,t){var r,o;Meteor.userId()&&(Creator.pushCurrentPathToUrlQuery(),"-"!==(r=e.params.app_id)&&r&&Session.get("app_id")!==r?Session.set("app_id",r):"-"!==r||Session.get("app_id")||(o=Steedos.getFirstApp(),Session.set("app_id",o.id)))},n=function(e,t){var r,o,a,n;if(o=Tracker.nonreactive((function(){return Session.get("object_name")})),a=Tracker.nonreactive((function(){return Session.get("record_id")})),r=e.params.object_name,n=e.params.record_id,Session.set("object_name",r),Session.set("tab_name",null),Session.set("pageApiName",null),Session.set("record_id",n),Session.set("record_name",null),n&&(o&&o!==r||a&&n!==a))return Session.set("temp_navs_force_create",!0)},r=function(e,t){var r;if("admin"===(r=e.params.app_id)&&Steedos.isMobile())return t("/user_settings"),urlQuery.pop()},FlowRouter.route("/app",{triggersEnter:[o],action:function(e,t){return BlazeLayout.render(Creator.getLayout(),{main:"creator_app_home"})}}),FlowRouter.route("/app/menu",{triggersEnter:[o],action:function(e,t){var r;return r="app_object_menu",Session.set("hidden_header",!0),BlazeLayout.render(Creator.getLayout(),{main:r})},triggersExit:[function(e,t){if(Steedos.isMobile())return Session.set("hidden_header",void 0)}]}),FlowRouter.route("/app/:app_id",{triggersEnter:[o],action:function(e,t){var r,o,a;return"-"!==(o=FlowRouter.getParam("app_id"))&&(Session.set("object_name",null),Session.set("record_id",null),Session.set("app_id",o)),Session.set("admin_template_name",null),a=(r=Creator.getApp(o))&&r.is_use_iframe?"creator_app_iframe":"creator_app_home",BlazeLayout.render(Creator.getLayout(),{main:a})}}),FlowRouter.route("/app/:app_id/page/:page_id",{triggersEnter:[o],action:function(e,t){var r,o;return console.log("params",e),r=FlowRouter.getParam("app_id"),o=null!=e?e.page_id:void 0,Session.set("pageApiName",o),Session.set("object_name",null),BlazeLayout.render(Creator.getLayout(),{main:"page_template",regions:{appId:r,pageId:o}})},triggersExit:[function(e,t){return Session.set("pageApiName",null)}]}),FlowRouter.route("/page/:page_id/",{action:function(e,t){return BlazeLayout.render(Creator.getLayout(),{main:"page"})}}),FlowRouter.route("/app/:app_id/tab_iframe/:tab_id",{triggersEnter:[o],action:function(e,t){var r;return r=FlowRouter.getParam("tab_id"),Session.set("tab_name",r),Session.set("object_name",null),BlazeLayout.render(Creator.getLayout(),{main:"page_iframe",regions:{params:e,queryParams:t}})},triggersExit:[function(e,t){return Session.set("tab_name",null)}]}),(a=FlowRouter.group({prefix:"/app/:app_id/:object_name",name:"objectRoutes",triggersEnter:[o,n]})).route("/",{triggersEnter:[function(e,t){var r,o,a,n,i;return n=e.params.object_name,o=(null!=(a=window.getFirstListView(n))?a.name:void 0)||(null!=a?a._id:void 0),t(i="/app/"+(r=e.params.app_id)+"/"+n+"/grid/"+o)}],action:function(e,t){return BlazeLayout.render(Creator.getLayout(),{main:"object_home"})}}),a.route("/:record_id/:related_object_name/grid",{action:function(e,t){var r,o,a,n,i,s,c,l;return o={app_id:r=Session.get("app_id"),object_name:n=FlowRouter.getParam("object_name"),record_id:s=FlowRouter.getParam("record_id"),related_object_name:l=FlowRouter.getParam("related_object_name")},Session.set("related_object_name",l),a="related_object_list",(i=Steedos.Page.getPage("related_list",r,l))&&(a="page_related_list_view",c={page:i,appId:Session.get("app_id"),objectName:n,recordId:s,relatedObjectName:l,__timestamp:(new Date).getTime()}),Meteor.setTimeout((function(){return BlazeLayout.render(Creator.getLayout(),{main:a,regions:c})}),10)}}),a.route("/view/:record_id",{action:function(e,t){var r,o,a,n,i,s,c;return t["X-Space-Id"]&&Steedos.setSpaceId(t["X-Space-Id"]),o={app_id:r=FlowRouter.getParam("app_id"),object_name:n=FlowRouter.getParam("object_name"),record_id:s=FlowRouter.getParam("record_id")},ObjectRecent.insert(n,s),Session.set("detail_info_visible",!0),a="creator_view",(i=Steedos.Page.getPage("record",Session.get("app_id"),n,s))&&(a="page_object",c=window._.defaultsDeep({display:Steedos.Page.getDisplay(n)},FlowRouter.current().queryParams,{page:i,appId:Session.get("app_id"),recordId:s,objectName:n,pageType:"record",__timestamp:(new Date).getTime()})),Meteor.setTimeout((function(){return BlazeLayout.render(Creator.getLayout(),{main:a,regions:c})}),10)},triggersExit:[function(e,t){var r,o,a,n,i,s,c;if(console.log('Session.get("instance_change")',Session.get("instance_change")),console.log("context.params?.object_name",null!=(o=e.params)?o.object_name:void 0),console.log("context.queryParams?.side_listview_id",null!=(a=e.queryParams)?a.side_listview_id:void 0),c=null!=(n=e.queryParams)?n.side_listview_id:void 0,window._.isArray(c)&&(c=c[0]),console.log("side_listview_id",c),Session.get("instance_change")&&("instances"===(null!=(i=e.params)?i.object_name:void 0)&&"draft"===c||"instance_tasks"===(null!=(s=e.params)?s.object_name:void 0)&&"inbox"===c)&&(r=WorkflowManager.getInstance(),console.log("ins.state",r.state),console.log('Session.get("box")',Session.get("box")),"draft"===r.state||"draft"!==Session.get("box")))return InstanceManager.saveIns(!1)}]}),a.route("/grid/:list_view_id",{action:function(e,t){var r,o,a,n,i;return Session.set("record_id",null),Session.get("object_name")===FlowRouter.getParam("object_name")&&Session.get("list_view_id")===FlowRouter.getParam("list_view_id")||(Session.set("filter_target",null),Session.set("filter_items",null)),Session.get("object_name")!==FlowRouter.getParam("object_name")&&Session.set("list_view_id",null),"true"===(null!=t?t.hidden_header:void 0)&&Session.set("hidden_header",!0),"-"!==(r=FlowRouter.getParam("app_id"))&&Session.set("app_id",r),a=FlowRouter.getParam("object_name"),Session.set("object_name",a),Session.set("list_view_id",FlowRouter.getParam("list_view_id")),Session.set("list_view_visible",!1),Tracker.afterFlush((function(){return Session.set("list_view_visible",!0)})),(n=Steedos.Page.getPage("list",Session.get("app_id"),a))&&(o="page_object",i=window._.defaultsDeep({display:Steedos.Page.getDisplay(a)},FlowRouter.current().queryParams,{page:n,appId:Session.get("app_id"),objectName:a,listViewId:Session.get("list_view_id"),pageType:"list",__timestamp:(new Date).getTime()})),BlazeLayout.render(Creator.getLayout(),{main:o,regions:i})}}),FlowRouter.notFound={action:function(e,t){var r;try{throw new Error("404 not found:"+window.location.href)}catch(o){r=o,console.log(r,window.location.href)}return BlazeLayout.render("empty_layout",{main:"notFound"})}}},"tenant.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};$.getJSON("/accounts/settings",(function(e){return(null!=e?e.tenant:void 0)&&Session.set("tenant_settings",e.tenant),Steedos.settings=Object.assign(Steedos.settings,e.settings||{})}))},"animate.js":function e(){$.fn.extend({animateCss:function(e,t){var r=function(e){var t={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"mozAnimationEnd",WebkitAnimation:"webkitAnimationEnd"};for(var r in t)if(void 0!==e.style[r])return t[r]}(document.createElement("div"));return this.addClass("animated "+e).one(r,(function(){$(this).removeClass("animated "+e),"function"==typeof t&&t()})),this}})},"colResizable-1.6.js":function e(){!function(e){var t=e(document),r=e("head"),o=null,a={},n=0,i="id",s="px",c="JColResizer",l="JCLRFlex",u=parseInt,d=Math,p=navigator.userAgent.indexOf("Trident/4.0")>0,f;try{f=sessionStorage}catch(T){}r.append("");var m=function(t,o){var s=e(t);if(s.opt=o,s.mode=o.resizeMode,s.dc=s.opt.disabledColumns,s.opt.disable)return _(s);var l=s.id=s.attr(i)||c+n++;s.p=s.opt.postbackSafe,!s.is("table")||a[l]&&!s.opt.partialRefresh&&s.prev(".JCLRgrips").length>0||("col-resize"!==s.opt.hoverCursor&&r.append(""),s.addClass(c).attr(i,l).before(''),s.g=[],s.c=[],s.w=s.width(),s.gc=s.prev(),s.f=s.opt.fixed,o.marginLeft&&s.gc.css("marginLeft",o.marginLeft),o.marginRight&&s.gc.css("marginRight",o.marginRight),s.cs=u(p?t.cellSpacing||t.currentStyle.borderSpacing:s.css("border-spacing"))||2,s.b=u(p?t.border||t.currentStyle.borderLeftWidth:s.css("border-left-width"))||1,a[l]=s,g(s))},_=function(e){var t=e.attr(i),e;(e=a[t])&&e.is("table")&&(e.removeClass(c+" "+l).gc.remove(),delete a[t])},g=function(t){var r=t.find(">thead>tr:first>th,>thead>tr:first>td");r.length||(r=t.find(">tbody>tr:first>th,>tr:first>th,>tbody>tr:first>td, >tr:first>td")),r=r.filter(":visible"),t.cg=t.find("col"),t.ln=r.length,t.p&&f&&f[t.id]&&h(t,r),r.each((function(r){var o=e(this),a=-1!=t.dc.indexOf(r),n=e(t.gc.append('')[0].lastChild);n.append(a?"":t.opt.gripInnerHtml).append(''),r==t.ln-1&&(n.addClass("JCLRLastGrip"),t.f&&n.html("")),n.bind("touchstart mousedown",y),a?n.addClass("JCLRdisabledGrip"):n.removeClass("JCLRdisabledGrip").bind("touchstart mousedown",y),n.t=t,n.i=r,n.c=o,o.w=o.width(),t.g.push(n),t.c.push(o),o.width(o.w).removeAttr("width"),n.data(c,{i:r,t:t.attr(i),last:r==t.ln-1})})),t.cg.removeAttr("width"),t.find("td, th").not(r).not("table th, table td").each((function(){e(this).removeAttr("width")})),t.f||t.removeAttr("width").addClass(l),v(t)},h=function(e,t){var r,o=0,a=0,n=[],i;if(t){if(e.cg.removeAttr("width"),e.opt.flush)return void(f[e.id]="");for(i=(r=f[e.id].split(";"))[e.ln+1],!e.f&&i&&(e.width(i*=1),e.opt.overflow&&(e.css("min-width",i+s),e.w=i));a*{cursor:"+s.opt.dragCursor+"!important}"),l.addClass(s.opt.draggingClass),o=l,s.c[i.i].l)for(var d=0,p;d"+(r.label||a),value:t+"."+a,icon:null!=o?o.icon:void 0})})):void 0})),o&&(c=Creator.getRelatedObjects(e),_.each(c,(l=this,function(e){var t,r;return r=Creator.getObjectLookupFieldOptions(e.object_name,!1,!1,!1),t=Creator.getObject(e.object_name),_.each(r,(function(r){if(e.foreign_key!==r.value)return n.push({label:(t.label||t.name)+"=>"+r.label,value:t.name+"."+r.value,icon:null!=t?t.icon:void 0})}))}))),n):n},Creator.getObjectFilterFieldOptions=function(e){var t,r,o,a,n;return r=[],e?(o=null!=(t=Creator.getObject(e))?t.fields:void 0,n=Creator.getFields(e),a=null!=t?t.icon:void 0,_.forEach(o,(function(e,t){if(!_.include(["grid","object","[Object]","[object]","Object","avatar","image","markdown","html"],e.type)&&!e.hidden&&!/\w+\./.test(t)&&_.indexOf(n,t)>-1)return r.push({label:e.label||t,value:t,icon:a})})),r):r},Creator.getObjectFieldOptions=function(e){var t,r,o,a,n;return r=[],e?(o=null!=(t=Creator.getObject(e))?t.fields:void 0,n=Creator.getFields(e),a=null!=t?t.icon:void 0,_.forEach(o,(function(e,t){if(!_.include(["grid","object","[Object]","[object]","Object","markdown","html"],e.type)&&!/\w+\./.test(t)&&_.indexOf(n,t)>-1)return r.push({label:e.label||t,value:t,icon:a})})),r):r},Creator.getFiltersWithFilterFields=function(e,t,r){return e||(e=[]),r||(r=[]),(null!=r?r.length:void 0)&&r.forEach((function(r){if(_.isString(r)&&(r={field:r,required:!1}),t[r.field]&&!_.findWhere(e,{field:r.field}))return e.push({field:r.field,is_default:!0,is_required:r.required})})),e.forEach((function(e){var t;return t=r.find((function(t){return t===e.field||t.field===e.field})),_.isString(t)&&(t={field:t,required:!1}),t?(e.is_default=!0,e.is_required=t.required):(delete e.is_default,delete e.is_required)})),e},Creator.getObjectRecord=function(e,t,r,o){var a,n,i,s,c,l;if(e||(e=Session.get("object_name")),t||(t=Session.get("record_id")),Meteor.isClient){if(e!==Session.get("object_name")||t!==Session.get("record_id"))return Creator.odata.get(e,t,r,o);if(null!=(s=Template.instance())?s.record:void 0)return null!=(c=Template.instance())&&null!=(l=c.record)?l.get():void 0}if("meteor"!==(n=Creator.getObject(e)).database_name&&n.database_name){if(e&&t)return Creator.odata.get(e,t,r,o)}else if(a=Creator.getCollection(e))return i=a.findOne(t)},Creator.getObjectRecordName=function(e,t){var r,o;if(e||(e=Creator.getObjectRecord()),e&&(r="organizations"===t?"name":null!=(o=Creator.getObject(t))?o.NAME_FIELD_KEY:void 0,e&&r))return e.label||e[r]},Creator.getApp=function(e){var t,r;return(t=Session.get("_app_menus")||Session.get("app_menus"))?r=t.find((function(t){return t.id===e})):{}},Creator.getAppDashboard=function(e){var t,r;if(t=Creator.getApp(e))return r=null,_.each(Creator.Dashboards,(function(e,o){var a;if((null!=(a=e.apps)?a.indexOf(t._id):void 0)>-1)return r=e})),r},Creator.getAppDashboardComponent=function(e){var t;t=Creator.getApp(e)},Creator.getAppObjectNames=function(e){var t,r,o,a;if(t=Creator.getApp(e))return r=(o=Steedos.isMobile())?t.mobile_objects:t.objects,a=[],t&&_.each(r,(function(e){var t;if(null!=(t=Creator.getObject(e))?t.permissions.get().allowRead:void 0)return a.push(e)})),a},Creator.getUrlWithToken=function(e,t){var r,o,a;return(a={})["X-Space-Id"]=Steedos.spaceId(),a["X-User-Id"]=Steedos.userId(),a["X-Company-Ids"]=Steedos.getUserCompanyIds(),a["X-Auth-Token"]=Accounts._storedLoginToken(),Steedos.isExpression(e)&&(e=Steedos.parseSingleExpression(e,t,"#",Creator.USER_CONTEXT)),""+e+(o=(r=/(\#.+\?)|(\?[^#]*$)/g.test(e))?"&":"?")+$.param(a)},Creator.getAppMenu=function(e,t){var r;return(r=Creator.getAppMenus(e))&&r.find((function(e){return e.id===t}))},Creator.getAppMenuUrlForInternet=function(e){return Creator.getUrlWithToken(e.path,e)},Creator.getAppMenuUrl=function(e){var t;return t=e.path,"url"===e.type?e.target?Creator.getAppMenuUrlForInternet(e):"/app/-/tab_iframe/"+e.id:e.path},Creator.getAppMenus=function(e){var t,r;return(t=Session.get("_app_menus")||Session.get("app_menus"))?(r=t.find((function(t){return t.id===e})))?r.children:void 0:[]},Creator.loadAppsMenus=function(){var e,t,r;return e={},(t=Steedos.isMobile())&&(e.mobile=t),r={type:"get",data:e,success:function(e){return Session.set("app_menus",e)}},null!=Steedos?Steedos.authRequest("/service/api/apps/menus",r):void 0},Creator.creatorAppsSelector=function(e,t){var r,o,a;return r=void 0,a=void 0,_.each(e,(function(e,t){e._id||(e._id=t),e.is_creator||(e.visible=!1)})),a=_.sortBy(_.values(e),"sort"),o={},r={},_.each(a,(function(e){return"admin"===e._id?r=e:o[e._id]=e})),o.admin=r,t.length&&_.each(o,(function(e,r){t.indexOf(r)>-1?e.visible=e.is_creator:e.visible=!1})),o},Creator.visibleAppsSelector=function(e,t){var r;return null==t&&(t=!0),r=[],_.each(e,(function(e,o){(!1!==e.visible&&"admin"!==e._id||t&&"admin"===e._id)&&r.push(e)})),r},Creator.getVisibleApps=function(e){var t,r;return t=Creator._subApp.get(),r=Object.assign({},Creator.Apps,{apps:t}),Creator.visibleAppsSelector(r,e)},Creator.getVisibleAppsObjects=function(){var e,t,r;return e=Creator.getVisibleApps(),r=_.flatten(_.pluck(e,"objects")),t=(t=_.filter(Creator.Objects,(function(e){return!(r.indexOf(e.name)<0)}))).sort(Creator.sortingMethod.bind({key:"label"})),t=_.pluck(t,"name"),_.uniq(t)},Creator.getAppsObjects=function(){var e,t;return e=[],t=[],_.forEach(Creator.Apps,(function(r){return t=_.filter(r.objects,(function(e){return!e.hidden})),e=e.concat(t)})),_.uniq(e)},Creator.validateFilters=function(e,t){var r,o,a,n,i,s,c;if(a=_.map(e,(function(e){return!_.isEmpty(e)&&e})),a=_.compact(a),o="",n=a.length,t){if(t=t.replace(/\n/g,"").replace(/\s+/g," "),/[._\-!+]+/gi.test(t)&&(o="含有特殊字符。"),!o)if(s=t.match(/\d+/gi))for(s.forEach((function(e){if(e<1||e>n)return o="您的筛选条件引用了未定义的筛选器:"+e+"。"})),i=1;i<=n;)s.includes(""+i)||(o="有些筛选条件进行了定义,但未在高级筛选条件中被引用。"),i++;else o="有些筛选条件进行了定义,但未在高级筛选条件中被引用。";if(o||(c=t.match(/[a-zA-Z]+/gi))&&c.forEach((function(e){if(!/^(and|or)$/gi.test(e))return o="检查您的高级筛选条件中的拼写。"})),!o){try{Creator.eval(t.replace(/and/gi,"&&").replace(/or/gi,"||"))}catch(l){r=l,o="您的筛选器中含有特殊字符"}(/(AND)[^()]+(OR)/gi.test(t)||/(OR)[^()]+(AND)/gi.test(t))&&(o="您的筛选器必须在连续性的 AND 和 OR 表达式前后使用括号。")}}return!o||(console.log("error",o),Meteor.isClient&&toastr.error(o),!1)},Creator.formatFiltersToMongo=function(e,t){var r;if(null!=e?e.length:void 0)return e[0]instanceof Array||(e=_.map(e,(function(e){return[e.field,e.operation,e.value]}))),r=[],_.each(e,(function(e){var o,a,n,i,s;return o=e[0],a=e[1],s=Meteor.isClient?Creator.evaluateFormula(e[2]):Creator.evaluateFormula(e[2],null,t),(i={})[o]={},"="===a?i[o].$eq=s:"<>"===a?i[o].$ne=s:">"===a?i[o].$gt=s:">="===a?i[o].$gte=s:"<"===a?i[o].$lt=s:"<="===a?i[o].$lte=s:"startswith"===a?(n=new RegExp("^"+s,"i"),i[o].$regex=n):"contains"===a?(n=new RegExp(s,"i"),i[o].$regex=n):"notcontains"===a&&(n=new RegExp("^((?!"+s+").)*$","i"),i[o].$regex=n),r.push(i)})),r},Creator.isBetweenFilterOperation=function(e){var t;return"between"===e||!!(null!=(t=Creator.getBetweenTimeBuiltinValues(!0))?t[e]:void 0)},Creator.formatFiltersToDev=function(e,t,r){var o,a;if(e.length)return(null!=r?r.is_logic_or:void 0)&&(o=[],e.forEach((function(e){return o.push(e),o.push("or")})),o.pop(),e=o),a=SteedosFilters.formatFiltersToDev(e,Creator.USER_CONTEXT)},Creator.formatLogicFiltersToDev=function(e,t,r){var o;return o="["+(o=(o=t.replace(/\(\s+/gi,"(").replace(/\s+\)/gi,")").replace(/\(/g,"[").replace(/\)/g,"]").replace(/\s+/g,",").replace(/(and|or)/gi,"'$1'")).replace(/(\d)+/gi,(function(t){var o,a,n,i,s;return o=e[t-1],a=o.field,n=o.operation,s=Meteor.isClient?Creator.evaluateFormula(o.value):Creator.evaluateFormula(o.value,null,r),i=[],!0===_.isArray(s)?("="===n?_.each(s,(function(e){return i.push([a,n,e],"or")})):"<>"===n?_.each(s,(function(e){return i.push([a,n,e],"and")})):_.each(s,(function(e){return i.push([a,n,e],"or")})),"and"!==i[i.length-1]&&"or"!==i[i.length-1]||i.pop()):i=[a,n,s],JSON.stringify(i)})))+"]",Creator.eval(o)},Creator.getRelatedObjects=function(e,t,r){var o,a,n,i,s;return Meteor.isClient&&(e||(e=Session.get("object_name")),t||(t=Session.get("spaceId")),r||(r=Meteor.userId())),n=[],(o=Creator.getObject(e))?(i=Creator.getObjectRelateds(o._collection_name),0===(null!=(n=_.pluck(i,"object_name"))?n.length:void 0)?n:(s=(a=Creator.getPermissions(e,t,r)).unrelated_objects,n=_.difference(n,s),_.filter(i,(function(e){var o,i,s,c;return c=e.object_name,i=n.indexOf(c)>-1,o=null!=(s=Creator.getPermissions(c,t,r))?s.allowRead:void 0,"cms_files"===c&&(o=o&&a.allowReadFiles),i&&o})))):n},Creator.getRelatedObjectNames=function(e,t,r){var o;return o=Creator.getRelatedObjects(e,t,r),_.pluck(o,"object_name")},Creator.getRelatedObjectListActions=function(e,t,r){var o;return o=Creator.getActions(e,t,r),o=_.filter(o,(function(e){return"standard_follow"!==e.name&&("standard_query"!==e.name&&("list"===e.on&&("function"==typeof e.visible?e.visible():e.visible)))}))},Creator.getActions=function(e,t,r){var o,a,n,i,s,c;if(Meteor.isClient&&(e||(e=Session.get("object_name")),t||(t=Session.get("spaceId")),r||(r=Meteor.userId())),n=Creator.getObject(e))return i=Creator.getPermissions(e,t,r),a=i.disabled_actions,o=_.sortBy(_.values(n.actions),"sort"),_.has(n,"allow_customActions")&&(o=_.filter(o,(function(e){return _.include(n.allow_customActions,e.name)||_.include(_.keys(Creator.getObject("base").actions)||{},e.name)}))),_.has(n,"exclude_actions")&&(o=_.filter(o,(function(e){return!_.include(n.exclude_actions,e.name)}))),_.each(o,(function(e){if(Steedos.isMobile()&&["record","record_only"].indexOf(e.on)>-1&&"standard_edit"!==e.name)return"record_only"===e.on?e.on="record_only_more":e.on="record_more"})),Steedos.isMobile()&&["cms_files","cfs.files.filerecord"].indexOf(e)>-1&&(null!=(s=o.find((function(e){return"standard_edit"===e.name})))&&(s.on="record_more"),null!=(c=o.find((function(e){return"download"===e.name})))&&(c.on="record")),o=_.filter(o,(function(e){return _.indexOf(a,e.name)<0}))},Creator.getListViews=function(e,t,r){var o,a,n,i,s,c;if(Meteor.isClient&&(e||(e=Session.get("object_name")),t||(t=Session.get("spaceId")),r||(r=Meteor.userId())),e&&(s=Creator.getObject(e)))return o=(null!=(c=Creator.getPermissions(e,t,r))?c.disabled_list_views:void 0)||[],i=[],a=Steedos.isMobile(),_.each(s.list_views,(function(e,t){return e.name=t})),n=_.sortBy(_.values(s.list_views),"sort_no"),_.each(n,(function(e){var t;if(!a||"calendar"!==e.type)return"default"===e.name||(t=_.indexOf(o,e.name)>-1||e._id&&_.indexOf(o,e._id)>-1)&&e.owner!==r?void 0:i.push(e)})),i},Creator.getFields=function(e,t,r){var o,a,n;return Meteor.isClient&&(e||(e=Session.get("object_name")),t||(t=Session.get("spaceId")),r||(r=Meteor.userId())),o=Creator.getObjectFieldsName(e),n=null!=(a=Creator.getPermissions(e,t,r))?a.unreadable_fields:void 0,_.difference(o,n)},Creator.isloading=function(){return!Creator.bootstrapLoaded.get()},Creator.convertSpecialCharacter=function(e){return e.replace(/([\^\$\(\)\*\+\?\.\\\|\[\]\{\}])/g,"\\$1")},Creator.getDisabledFields=function(e){var t;return t=_.map(e,(function(e,t){return e.autoform&&e.autoform.disabled&&!e.autoform.omit&&t})),t=_.compact(t)},Creator.getHiddenFields=function(e){var t;return t=_.map(e,(function(e,t){return e.autoform&&"hidden"===e.autoform.type&&!e.autoform.omit&&t})),t=_.compact(t)},Creator.getFieldsWithNoGroup=function(e){var t;return t=_.map(e,(function(e,t){return(!e.autoform||!e.autoform.group||"-"===e.autoform.group)&&(!e.autoform||"hidden"!==e.autoform.type)&&t})),t=_.compact(t)},Creator.getSortedFieldGroupNames=function(e){var t;return t=_.map(e,(function(e){return e.autoform&&"-"!==e.autoform.group&&e.autoform.group})),t=_.compact(t),t=_.unique(t)},Creator.getFieldsForGroup=function(e,t){var r;return r=_.map(e,(function(e,r){return e.autoform&&e.autoform.group===t&&"hidden"!==e.autoform.type&&r})),r=_.compact(r)},Creator.getSystemBaseFields=function(){return["created","created_by","modified","modified_by"]},Creator.getFieldsWithoutSystemBase=function(e){return _.difference(e,Creator.getSystemBaseFields())},Creator.getFieldsWithoutOmit=function(e,t){return t=_.map(t,(function(t){var r,o;return(null==(o=(r=_.pick(e,t))[t].autoform)||!o.omit)&&t})),t=_.compact(t)},Creator.getFieldsInFirstLevel=function(e,t){return t=_.map(t,(function(t){return _.indexOf(e,t)>-1&&t})),t=_.compact(t)},Creator.getFieldsForReorder=function(e,t,r){var o,a,n,i,s,c,l,u;for(n=[],i=0,o=_.filter(t,(function(e){return!e.endsWith("_endLine")}));i-1&&(o=e[t].data_type),o):"text"},Meteor.isServer&&(Creator.getAllRelatedObjects=function(e){var t;return t=[],_.each(Creator.Objects,(function(r,o){return _.each(r.fields,(function(r,a){if("master_detail"===r.type&&r.reference_to&&r.reference_to===e)return t.push(o)}))})),Creator.getObject(e).enable_files&&t.push("cms_files"),t}),Meteor.isServer&&(Steedos.formatIndex=function(e){var t,r,o,a,n,i;return o={background:!0},(r=(null!=(a=Meteor.settings)&&null!=(n=a.datasources)&&null!=(i=n.default)?i.documentDB:void 0)||!1)&&e.length>0&&(t=e.join("."),o.name=t,t.length>52&&(o.name=t.substring(0,52))),o})},lib:{"apps.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};Creator.appsByName={}},"object_recent.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};this.ObjectRecent={},ObjectRecent.insert=function(e,t,r){return Meteor.call("object_recent_viewed",e,t,Session.get("spaceId"),(function(){if(r&&_.isFunction(r))return r()}))}},"filters_transform.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{},r;this.FiltersTransform={},r=function(e){return["date","datetime","time","currency","number"].includes(e)?"between":["text","textarea","html"].includes(e)?"contains":"="},FiltersTransform.queryToFilters=function(e){var t,o,a,n;if(e)return n=e.query,a=e.object_name,o=Creator.getObject(a).fields,t=[],_.each(n,(function(e,a){var n,i;if(o[a]){if(i=Creator.getFieldDataType(o,a),["date","datetime","time","currency","number"].includes(i))return t.push({field:a,operation:r(i),start_value:e,value:[e,null]});if(!["text","textarea","html"].includes(i))return["boolean"].includes(i)?t.push({field:a,operation:"=",value:e}):t.push({field:a,operation:r(i),value:e});if(_.isString(e))return t.push({field:a,operation:r(i),value:e});if(_.isArray(e))return t.push({field:a,operation:"=",value:e})}else if(a=a.replace(/(_endLine)$/,""),i=Creator.getFieldDataType(o,a),o[a]&&["date","datetime","time","currency","number"].includes(i))return(n=_.find(t,(function(e){return e.field===a})))?(n.end_value=e,n.value[1]=e):t.push({field:a,operation:r(i),end_value:e,value:[null,e]})})),t}},"form_manager.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{},r,o;this.FormManager={},SimpleSchema.messages({formValidate:"[value]"}),FormManager.getRelatedInitialValues=(o=this,function(e,t,r){var o,a,n,i,s;if(!_.isString(t))throw new Meteor.Error("main_record_id must be String");return o={},i="",Creator.getRelatedList(e,t).forEach((function(e){if(r===e.object_name)return i=e.related_field_name})),a="company_id",(s=Creator.getObject(r))&&i&&s.fields[i]&&s.fields[i].reference_to_field&&(a=a+","+s.fields[i].reference_to_field),(n=Creator.odata.get(e,t,a))&&i&&n[s.fields[i].reference_to_field]&&(t=n[s.fields[i].reference_to_field]),o={},i&&("objects"===e?o[i]=Creator.getObjectRecord().name:(s=Creator.getObject(r),_.isString(s.fields[i].reference_to)?s.fields[i].multiple?o[i]=[t]:o[i]=t:o[i]={o:e,ids:[t]})),!_.has(o,"company_id")&&(null!=n?n.company_id:void 0)&&(o.company_id=n.company_id),o=Object.assign({},o,FormManager.getInitialValues(r,o))}),FormManager.getInitialValues=function(e,t){var r,o,a;return o=null!=(r=Creator.getObject(e))&&null!=(a=r.form)?a.initialValues:void 0,_.isFunction(o)?o.apply({doc:t||{}}):{}},FormManager.validate=function(e,t){var r,o,a,n,i,s;if(a=null!=(o=Creator.getObject(e))&&null!=(n=o.form)?n.validate:void 0,_.isFunction(a))try{if(s=a.apply({},[null!=(i=AutoForm.getFormValues(t))?i.insertDoc:void 0]),_.isBoolean(s)&&!1===s)return!1;if(!_.isEmpty(s)&&_.isObject(s))return _.each(s,(function(e,r){return AutoForm.addStickyValidationError(t,r,"formValidate",e),toastr.error(e)})),!1}catch(c){return r=c,console.error(r),toastr.error(r.message),!1}return!0},FormManager.onSubmit=function(e,t){var r,o,a,n,i;return o=null!=(r=Creator.getObject(e))&&null!=(n=r.form)?n.onSubmit:void 0,!(_.isFunction(o)&&(a=o.apply({},[null!=(i=AutoForm.getFormValues(t))?i.insertDoc:void 0]),!_.isEmpty(a)&&_.isObject(a)))||(_.each(a,(function(e,r){return AutoForm.addStickyValidationError(t,r,"formValidate",e),toastr.error(e)})),!1)},r=function(e,t,r){var o,a,n;return o={userId:Meteor.userId(),spaceId:Session.get("spaceId"),object_name:e},_.has(r,"previousDoc")&&(o.previousDoc=r.previousDoc),t.endsWith("Delete")?(o.id=r._id,o.doc=Creator.odata.get(e,r._id),t.startsWith("error")&&(o.error=r.error)):t.startsWith("after")?(o.id=null!=(a=r.dbDoc)?a._id:void 0,o.doc=r.dbDoc):t.startsWith("before")?(t.endsWith("Insert")||(o.id=r._id),t.endsWith("Update")?o.doc=null!=(n=r.doc)?n.$set:void 0:o.doc=r.doc):t.startsWith("error")&&(o.id=r._id,o.doc=r.doc,o.error=r.error),o},FormManager.getPreviousDoc=function(e,t,r){var o,a,n,i,s;if(("update"===r||"delete"===r)&&(o="after",a="after"+r.charAt(0).toLocaleUpperCase()+_.rest(r.split("")).join(""),i=null!=(n=Creator.getObject(e))&&null!=(s=n.form)?s[a]:void 0,_.isFunction(i)))return Creator.odata.get(e,t)},FormManager.runHook=function(e,t,o,a){var n,i,s,c,l,u,d,p;if(l=""+o+t.charAt(0).toLocaleUpperCase()+_.rest(t.split("")).join(""),"view"===t||"edit"===t)return FormManager.runViewEditHook(e,l,a.schema,a.record,a.doc);if(s=a.formId,d=null!=(u=Creator.getObject(e))&&null!=(p=u.form)?p[l]:void 0,_.isFunction(d))try{if(n=r(e,l,a),c=d.apply(n),_.isBoolean(c)&&!1===c)return!1;if(s&&"before"===o&&!_.isEmpty(c)&&_.isObject(c))return _.each(c,(function(e,t){return AutoForm.addStickyValidationError(s,t,"formValidate",e),toastr.error(e)})),!1}catch(f){return i=f,console.error(i),toastr.error(i.message),!1}return!0},FormManager.runViewEditHook=function(e,t,r,o,a){var n,i,s,c,l,u,d;if(l=null!=(u=Creator.getObject(e))&&null!=(d=u.form)?d[t]:void 0,_.isFunction(l)&&(s=r.get(),c={id:(i=a||o.get())._id,userId:Meteor.userId(),spaceId:Session.get("spaceId"),object_name:e,doc:i,schema:s},!1!==(n=l.apply(c))))return r.set(s),o.set(i)}},"grid_export.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{},r,o;this.ObjectGrid={},this.GridExport={},r={equals:"=",notEqual:"!=",contains:"contains",notContains:"notcontains",startsWith:"startswith",endsWith:"=",lessThan:"<",lessThanOrEqual:"<=",greaterThan:">",greaterThanOrEqual:">=",empty:"empty"},o=function(e){var t;return t=[],_.forEach(e,(function(e,o){var a;return"between"===e.type?"number"===e.filterType?t.push([o,"between",[e.numberFrom,e.numberTo]]):e.filter?t.push([o,e.type,e.filter]):t.push([o,"between",[e.dateFrom,e.dateTo]]):_.isEmpty(e.filter)?e.operator?(a=[],e.condition1&&a.push([o,r[e.condition1.type],e.condition1.filter]),a.push(e.operator.toLocaleLowerCase()),e.condition2&&a.push([o,r[e.condition2.type],e.condition2.filter]),t.push(a)):void 0:(a=[o,r[e.type],e.filter],t.push(a))})),t},ObjectGrid.getFilters=function(e,t,r,a,n){var i,s,c,l,u,d;return s=Steedos.Page.Listview.getDefaultName(e,t),l=window.gridRefs&&window.gridRefs[s]&&window.gridRefs[s].current?window.gridRefs[s].current:window.gridRef.current,u=[],i=Creator.getListViewFilters(e,t,r,a,n),d=o(l.api.getFilterModel()),c=_.compact([].concat(i).concat(d))},GridExport.excel=function(e,t,r,a,n,i,s){var c,l,u,d,p,f,m,g,h,v,b,w,S;return u=Steedos.Page.Listview.getDefaultName(e,t),f=window.gridRefs&&window.gridRefs[u]&&window.gridRefs[u].current?window.gridRefs[u].current:window.gridRef.current,v=[],_.each(f.props.columnDefs,(function(e){if(e&&e.field)return v.push(e.field)})),b=[],_.forEach(f.api.getSortModel(),(function(e){return b.push([e.colId,e.sort])})),l=Creator.getListViewFilters(e,t,r,a,n,s),S=o(f.api.getFilterModel()),p=_.compact([].concat(l).concat(S)),c=SteedosFilters.formatFiltersToODataQuery(p),d=r?i+"-"+Creator.getObject(a).label:Creator.getObject(e).label+"-"+(null!=(h=Creator.getListView(e,t))?h.label:void 0),g=[],_.map(b,(function(e){var t;return t="desc"===e[1]?e[0]+" desc":e[0],g.push(t)})),m=g.join(","),d=encodeURIComponent(d),w=r?"/api/record/export/"+a+"?$select="+v.toString()+"&filename="+d:"/api/record/export/"+e+"?$select="+v.toString()+"&filename="+d,b.length>0&&(w=w+"&$orderby="+m),c&&(w=w+"&$filter="+c),Meteor.isCordova?Steedos.cordovaDownload(encodeURI(Steedos.absoluteUrl(w)),d+".xlsx"):window.open(w)}}},client:{"listview.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{},r,o,a,n,i;n=function(e,t,r){var o,a,n;return o=null!=t?t.columns:void 0,r&&((null!=t?t.mobile_columns:void 0)?o=t.mobile_columns:(null!=(n=Creator.getObjectFirstListView(e))?n.mobile_columns:void 0)?o=n.mobile_columns:o&&(o=Creator.pickObjectMobileColumns(e,o))),o||(a=Creator.getObjectFirstListViewColumns(e,r))&&(o=a),o},o=function(e,t,r){var o,a,i,s,c,l;return s=(c=Creator.getObject(e)).NAME_FIELD_KEY,"organizations"===c.name&&(s="name"),o=[s],(i=Creator.getCollection("object_listviews").findOne(t))?o=n(e,i,r):c.list_views&&(l=c.list_views[t],o=n(e,l,r)),o=o.map((function(e){var t,r;return t=_.isObject(e)?e.field:e,(null!=(r=c.fields[t])?r.type:void 0)?t:void 0})),Creator.isCommonSpace(Session.get("spaceId"))&&o.indexOf("space")<0&&o.push("space"),"cms_files"===e&&o.push("parent"),o=_.compact(o),a=Creator.getObjectFieldsName(e),_.intersection(o,a)},i=function(e,t,r,o){var a;return r?(a=Creator.getObject(e).fields,o&&(t=t.filter((function(e){var t,o;return"master_detail"!==(null!=(o=a[e])?o.type:void 0)||(!!a[e].multiple||(a[e].reference_to?(t=a[e].reference_to,_.isFunction(t)&&(t=t())):t=a[e].optionsFunction({}).getProperty("value"),!!_.isArray(t)||t!==r))}))),t):t},r=function(e,t){var r,o;return o=Creator.getObject(e).fields,r=[],_.each(t,(function(e){var t;if(null!=(t=o[e])?t.depend_on:void 0)return r=_.union(o[e].depend_on)})),r},a=function(e,t,r){var o,a;return a=_.intersection(["owner","company_id","company_ids","locked"],_.keys(e.fields)),!r&&e.enable_tree&&(a.push("parent"),a.push("children")),(o=Creator.getObjectDefaultExtraColumns(e.name))&&(a=_.union(a,o)),a},Creator.unionSelectColumnsWithExtraAndDepandOn=function(e,t,o,n){var i,s;return i=t.name,s=a(t,o,n),e=_.union(e,s),e=_.union(e,r(i,e))},Creator.getListViewFilters=function(e,t,r,o,a,n){var i,s,c,l,u,d,p,f,m,g;if(!e)return null;if(c=Creator.getObject(e),r)l=Creator.getODataRelatedFilter(e,o,a,t,n);else{if(d=Session.get("filter_logic"),p=Session.get("filter_scope"),u=Session.get("filter_items"),s=c.fields,u&&u.length>0&&window.lodash.isArray(u[0]))return l=u,(g=Creator.getStandardQuery(e,Session.get("standard_query")))&&g.length&&(l=l?[l,"and",g]:g),(m=Session.get("grid_sidebar_filters"))&&m.length&&(l=l?[l,"and",m]:m),l||(l=null),l;i=[],_.forEach(u,(function(t){var r,o,a,n,c,l,u,d,p,f,m;if(void 0!==t.value)if(r=s[null!=t?t.field:void 0],o=Creator.getFieldDataType(s,null!=t?t.field:void 0),["text","textarea","html","code"].includes(o)){if(_.isString(t.value)&&(m=t.value.trim().split(" "),l=[],m.forEach((function(e){return e=encodeURIComponent(Creator.convertSpecialCharacter(e)),l.push([t.field,t.operation,e])})),l.length>0))return c=!1,["<>","notcontains"].includes(t.operation)&&(c=!1),i.push(Creator.formatFiltersToDev(l,e,{is_logic_or:c}))}else{if(!["lookup","master_detail"].includes(o))return i.push(t);if(a=null!=r?r.reference_to:void 0,_.isFunction(a)&&(a=a()),!_.isArray(a))return i.push(t);if((null!=(u=t.value)?u.ids:void 0)&&i.push({field:t.field+".ids",operation:t.operation,value:null!=(d=t.value)?d.ids:void 0}),null!=(p=t.value)?p.o:void 0)return n=Creator.getObject(null!=(f=t.value)?f.o:void 0),i.push({field:t.field+".o",operation:t.operation,value:n._collection_name})}})),i.length>0&&(f={filter_logic:d,filter_scope:p,filters:i}),l=Creator.getODataFilter(t,e,f),(g=Creator.getStandardQuery(e,Session.get("standard_query")))&&g.length&&(l=l?[l,"and",g]:g),r||(m=Session.get("grid_sidebar_filters"))&&m.length&&(l=l?[l,"and",m]:m)}return l||(l=null),l},Creator.getODataEndpointUrl=function(e,t,r,o){var a,n;return r?(a=Creator.formatObjectName(o),n=Creator.getListViewIsRecent(e,t)?"/api/v4/"+a+"/recent":"/api/v4/"+a):(a=Creator.formatObjectName(e),n=Creator.getListViewIsRecent(e,t)?"/api/v4/"+a+"/recent":"/api/v4/"+a),Steedos.absoluteUrl(n)},Creator.getListviewColumns=function(e,t,r,a,n,s){var c,l;return c=e.name,l=Tracker.nonreactive((function(){return o(c,a,s)})),n&&n.customRelatedListObject&&(n.columns&&(l=n.columns),s&&n.mobile_columns&&(l=n.mobile_columns),l&&(l=l.map((function(e){return _.isObject(e)?e.field:_.isString(e)?e:void 0})),l=_.uniq(_.compact(l)))),l=i(c,l,t,r)}},views:{"_helpers.coffee":function e(){var r=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};Creator.helpers={object_name:function(){return Session.get("object_name")},object:function(){return Creator.getObject(Session.get("object_name"))},object_listviews:function(){return Creator.getObject("object_listviews")},objectLabel:function(e){return Creator.getObject(e).label},getOperationLabel:function(e){switch(e){case"=":return t("creator_filter_operation_equal");case"<>":return t("creator_filter_operation_unequal");case"<":return t("creator_filter_operation_less_than");case">":return t("creator_filter_operation_greater_than");case"<=":return t("creator_filter_operation_less_or_equal");case">=":return t("creator_filter_operation_greater_or_equal");case"contains":return t("creator_filter_operation_contains");case"notcontains":return t("creator_filter_operation_does_not_contain");case"startswith":return t("creator_filter_operation_starts_with");case"between":return t("creator_filter_operation_between")}},isMobile:function(){return Steedos.isMobile()}}},"template.page_template.js":function e(){Template.__checkName("page_template"),Template.page_template=new Template("Template.page_template",(function(){var e=this;return HTML.Raw('')}))},"page_template.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};Template.page_template.onRendered((function(){var e,t;return t=this,e=Session.get("app_id"),this.containerList=[],this.autorun((function(){var r;if(r=Steedos.Page.App.render(t,Session.get("pageApiName"),e))return t.containerList.push(r)}))})),Template.page_template.onDestroyed((function(){return _.each(this.containerList,(function(e){if(e)return ReactDOM.unmountComponentAtNode(e)}))}))},"template.page_object.js":function e(){Template.__checkName("page_object"),Template.page_object=new Template("Template.page_object",(function(){var e=this;return HTML.Raw('')}))},"page_object.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};Template.page_object.onRendered((function(){var e;return e=this,Steedos.Page.Object.Template.onRendered.apply(this)})),Template.page_object.onDestroyed((function(){var e;return e=this,Steedos.Page.Object.Template.onDestroyed.apply(this)}))},"template.page_record_view.js":function e(){Template.__checkName("page_record_view"),Template.page_record_view=new Template("Template.page_record_view",(function(){var e=this;return HTML.Raw('')}))},"page_record_view.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};Template.page_record_view.onRendered((function(){var e,t,r;return r=this,e=Session.get("object_name"),t=Session.get("record_id"),this.containerList=[],this.pageName=null,this.autorun((function(){var o,a,n,i,s,c,l,u,d,p;if(d=!0,(l=r.data.regions()).objectName!==(null!=(i=this.lastRegions)?i.objectName:void 0)&&(d=!1),this.lastRegions=l,d&&r.pageName)try{if(SteedosUI.refs[r.pageName])return(p={objectName:e}).recordId=Tracker.nonreactive((function(){return Session.get("record_id")})),n=(null!=(s=SteedosUI.refs[r.pageName])&&null!=(c=s.__$schema)?c.data:void 0)||{},SteedosUI.refs[r.pageName].updateProps({data:window._.defaultsDeep(p,n)})}catch(f){a=f,console.error(r.pageName+": "+a)}if(!d&&r.pageName&&SteedosUI.refs[r.pageName])try{SteedosUI.refs[r.pageName].unmount()}catch(f){a=f,console.error(r.pageName+": "+a)}if(r.data.regions&&(l=Tracker.nonreactive(r.data.regions),this.lastRegions=l,l&&l.page&&l.page.schema&&(u=l.page.schema,_.isString(u)&&(u=JSON.parse(u)),r.pageName=u.name)),e=Tracker.nonreactive((function(){return Session.get("object_name")})),t=Tracker.nonreactive((function(){return Session.get("record_id")})),o=Steedos.Page.Record.render(r,e,t))return r.containerList.push(o)}))})),Template.page_record_view.onDestroyed((function(){var e;try{SteedosUI.refs[this.pageName].unmount()}catch(t){e=t,console.error(this.pageName+": "+e)}return _.each(this.containerList,(function(e){if(e)return ReactDOM.unmountComponentAtNode(e)}))}))},"template.page_list_view.js":function e(){Template.__checkName("page_list_view"),Template.page_list_view=new Template("Template.page_list_view",(function(){var e=this;return HTML.Raw('')}))},"page_list_view.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};Template.page_list_view.onRendered((function(){var e,t;return t=this,e=Session.get("object_name"),this.containerList=[],this.pageName=null,this.autorun((function(){var r,o,a,n;if(t.pageName)try{SteedosUI.refs[t.pageName].unmount()}catch(i){o=i,console.error(t.pageName+": "+o)}if(t.data.regions&&(a=t.data.regions())&&a.page&&a.page.schema&&(n=a.page.schema,_.isString(n)&&(n=JSON.parse(n)),t.pageName=n.name),r=Steedos.Page.Listview.render(t,e))return t.containerList.push(r)}))})),Template.page_list_view.onDestroyed((function(){var e;try{SteedosUI.refs[this.pageName].unmount()}catch(t){e=t,console.error(this.pageName+": "+e)}return _.each(this.containerList,(function(e){if(e)return ReactDOM.unmountComponentAtNode(e)}))}))},"template.page_related_list_view.js":function e(){Template.__checkName("page_related_list_view"),Template.page_related_list_view=new Template("Template.page_related_list_view",(function(){var e=this;return HTML.Raw('')}))},"page_related_list_view.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};Template.page_related_list_view.onRendered((function(){var e,t,r;return r=this,e=Session.get("object_name"),t=Session.get("record_id"),this.containerList=[],this.pageName=null,this.autorun((function(){var o,a,n,i;if(r.pageName)try{SteedosUI.refs[r.pageName].unmount()}catch(s){a=s,console.error(r.pageName+": "+a)}if(r.data.regions&&(n=r.data.regions())&&n.page&&n.page.schema&&(i=n.page.schema,_.isString(i)&&(i=JSON.parse(i)),r.pageName=i.name),o=Steedos.Page.RelatedListview.render(r,e,t))return r.containerList.push(o)}))})),Template.page_related_list_view.onDestroyed((function(){var e;try{SteedosUI.refs[this.pageName].unmount()}catch(t){e=t,console.error(this.pageName+": "+e)}return _.each(this.containerList,(function(e){if(e)return ReactDOM.unmountComponentAtNode(e)}))}))},"template.app_home.js":function e(){Template.__checkName("creator_app_home"),Template.creator_app_home=new Template("Template.creator_app_home",(function(){var e=this;return""}))},"app_home.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{},r;r=function(e){var t,r,o,a,n;return(null!=(t=Creator.getApp(e))?t.isExternalUrl:void 0)?/^http(s?):\/\//.test(t.path)?t.blank?window.open(t.path):window.location.href=t.path:FlowRouter.go(t.path):(a=Creator.getAppMenus(e),(r=_.first(a))?"url"===(o=Object.assign({},r,{target:!1})).type&&o.is_use_iframe?FlowRouter.go(o.path):(n=Creator.getAppMenuUrl(o),FlowRouter.go(n)):FlowRouter.go("/app/"+e))},Template.creator_app_home.onRendered((function(){return this.autorun((function(){var e,t,o;if(o=Creator.bootstrapLoaded.get(),_.has(FlowRouter.current().params,"app_id")){if(e=Session.get("app_id"),o&&e)return r(e)}else if(t=Steedos.getFirstApp(),o&&t)return r(t.code||t.id)}))}))},"template.app_iframe.js":function e(){Template.__checkName("creator_app_iframe"),Template.creator_app_iframe=new Template("Template.creator_app_iframe",(function(){var e=this;return Blaze.If((function(){return Spacebars.call(e.lookup("subsReady"))}),(function(){return["\n\t\t",HTML.IFRAME({id:"app_iframe",src:function(){return Spacebars.mustache(e.lookup("url"))},style:"width: 100%; height: 100%;"}),"\n\t"]}))}))},"app_iframe.coffee":function module(){__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};var share=__coffeescriptShare;Template.creator_app_iframe.helpers({subsReady:function(){return Steedos.subsBootstrap.ready()},url:function(){var e,t;return t=Session.get("app_id"),(e=Creator.getApp(t))&&!e.on_click&&e.url?Creator.getUrlWithToken(e.url,e):""}}),Template.creator_app_iframe.events,Template.creator_app_iframe.onCreated((function(){})),Template.creator_app_iframe.onRendered((function(){var app,app_id,e,evalFunString,iframe;if(Steedos.forbidNodeContextmenu(window,"#app_iframe"),app_id=Session.get("app_id"),app=Creator.getApp(app_id),iframe=$("#app_iframe"),app&&app.on_click){evalFunString="(function(){"+app.on_click+"})()";try{return eval(evalFunString)}catch(error){return e=error,console.error("catch some error when eval the on_click script for app link:"),console.error(e.message+"\r\n"+e.stack)}}})),Template.creator_app_iframe.onDestroyed((function(){}))},"template.page_iframe.js":function e(){Template.__checkName("page_iframe"),Template.page_iframe=new Template("Template.page_iframe",(function(){var e=this;return HTML.IFRAME({name:"pageIframe",src:function(){return Spacebars.mustache(e.lookup("url"))},style:function(){return Spacebars.mustache(e.lookup("style"))},class:function(){return Spacebars.mustache(e.lookup("className"))}})}))},"page_iframe.js":function e(){var t=function(e){const{data:t}=e;"nav.click"===t.type&&FlowRouter.current().params.tab_id==t.data.id&&$("[name='pageIframe']").attr("src",$("[name='pageIframe']").attr("src"))};Template.page_iframe.helpers({url:()=>{if(Template.instance().data.regions){var e,t=Template.instance().data.regions().queryParams.url;return t.startsWith("https:/")&&!t.startsWith("https://")&&(t=t.replace("https:/","https://")),t.startsWith("http:/")&&!t.startsWith("http://")&&(t=t.replace("http:/","http://")),!Meteor.isCordova||t.startsWith("http:")||t.startsWith("!https:")||(t=Meteor.absoluteUrl(t)),t}},className:()=>{if(Template.instance().data.regions)return(regions=Template.instance().data.regions()).queryParams.className||""},style:()=>Template.instance().data.regions&&(regions=Template.instance().data.regions()).queryParams.style||"width: 100%; height: 100%;"}),Template.page_iframe.onCreated((function(){window.addEventListener("message",t)})),Template.page_iframe.onDestroyed((function(){window.removeEventListener("message",t)})),Template.page_iframe.onRendered((function(){window.Steedos.setDocumentTitle({pageName:null,tabName:null})}))},"template.initiate_approval.js":function e(){Template.__checkName("initiate_approval"),Template.initiate_approval=new Template("Template.initiate_approval",(function(){var e=this;return HTML.DIV({class:"modal fade creator-modal",id:"initiate_approval"},"\n\t\t",HTML.DIV({class:"modal-dialog slds-modal slds-fade-in-open"},"\n\t\t\t",HTML.DIV({class:"slds-modal__container"},"\n\t\t\t\t",HTML.HEADER({class:"slds-modal__header"},"\n\t\t\t\t\t",HTML.DIV({"data-dismiss":"modal"},"\n\t\t\t\t\t\t",Blaze._TemplateWith((function(){return{className:Spacebars.call("slds-modal__close slds-button__icon"),iconSize:Spacebars.call("large"),inverse:Spacebars.call(!0),iconCategory:Spacebars.call("utility"),iconName:Spacebars.call("close"),title:Spacebars.call(Spacebars.dataMustache(e.lookup("_"),"close")),variant:Spacebars.call("icon")}}),(function(){return Spacebars.include(e.lookupTemplate("steedos_button"))})),"\n\t\t\t\t\t"),"\n\t\t\t\t\t",HTML.Raw('\n\t\t\t\t\t\t选择流程发起审批\n\t\t\t\t\t
'),"\n\t\t\t\t"),"\n\n\t\t\t\t",HTML.DIV({class:"slds-modal__content slds-p-around_medium",style:"font-size: 17px;"},"\n\t\t\t\t\t",Blaze.Each((function(){return Spacebars.call(e.lookup("flows"))}),(function(){return["\n\t\t\t\t\t",HTML.DIV({class:"weui_cells_weui_cells_access"},"\n\t\t\t\t\t\t",HTML.A({class:"weui_cell","data-flow":function(){return Spacebars.mustache(e.lookup("flow_id"))}},"\n\t\t\t\t\t\t\t",HTML.I({class:"ion ion-ios-compose-outline"}),HTML.CharRef({html:" ",str:" "}),HTML.CharRef({html:" ",str:" "}),Blaze.View("lookup:flow_name",(function(){return Spacebars.mustache(e.lookup("flow_name"))})),"\n\t\t\t\t\t\t"),"\n\t\t\t\t\t"),"\n\t\t\t\t\t"]})),"\n\n\t\t\t\t"),"\n\n\t\t\t"),"\n\t\t"),"\n\t")}))},"initiate_approval.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};Template.initiate_approval.helpers({flows:function(){return _.where(Creator.object_workflows,{object_name:this.object_name,can_add:!0})}}),Template.initiate_approval.events({"click .weui_cell":function(e,t){var r,o,a,n,i,s,c;o=e.currentTarget.dataset.flow,a=t.data.object_name,n=t.data.record_id,i=[{o:a,ids:[n]}],(s={}).methodOverride="POST",s["X-User-Id"]=Meteor.userId(),s["X-Auth-Token"]=Accounts._storedLoginToken(),c=Steedos.absoluteUrl()+"api/object/workflow/drafts?"+$.param(s),r={Instances:[{flow:o,applicant:Meteor.userId(),space:Session.get("spaceId"),record_ids:i}]},r=JSON.stringify(r),$(document.body).addClass("loading"),$.ajax({url:c,type:"POST",async:!0,data:r,dataType:"json",processData:!1,contentType:"application/json",success:function(e,r){var o;$(document.body).removeClass("loading"),e.errors?e.errors.forEach((function(e){toastr.error(e.errorMessage)})):(o=e.inserts[0],Steedos.openWindow(Steedos.absoluteUrl("/app/"+FlowRouter.current().params.app_id+"/instances/view/"+o._id+"?display="+FlowRouter.current().queryParams.display+"&side_object=instances&side_listview_id=draft")),Modal.hide(t),SteedosUI.reloadRecord(a,n),FlowRouter.reload())},error:function(e,t,r){$(document.body).removeClass("loading"),toastr.error(t)}})}})},"template.amis_action.js":function e(){Template.__checkName("amis_action"),Template.amis_action=new Template("Template.amis_action",(function(){var e=this;return HTML.LI({class:function(){return["steedos-amis-button steedos-button-",Spacebars.mustache(e.lookup("objectName")),"-",Spacebars.mustache(e.lookup("name"))," ",Spacebars.mustache(e.lookup("buttonClassName"))]}})}))},"amis_action.js":function e(){const t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window.location;(e=e||"")&&"#"===e[0]?e=t.pathname+t.search+e:e&&"?"===e[0]&&(e=t.pathname+e);const r=e.indexOf("?"),o=e.indexOf("#");let a=~r?e.substring(0,r):~o?e.substring(0,o):e,n=~r?e.substring(r,~o?o:void 0):"",i=~o?e.substring(o):t.hash;if(a){if("/"!=a[0]&&!/^https?\:\/\//.test(a)){let e;const r=t.pathname.split("/");let o;for(r.pop();o=/^\.\.?\//.exec(a);)"../"===o[0]&&r.pop(),a=a.substring(o[0].length);a=r.concat(a).join("/")}}else a=t.pathname;return a+n+i},r=()=>({theme:"antd",getModalContainer:e=>{let t=document.querySelector("#amisModalContainer");return t||((t=document.createElement("div")).className="amis-scope",t.style.height="0px",t.id="amisModalContainer",document.body.appendChild(t)),t},notify:(e,t)=>{var r,o;(null===(r=t.props)||void 0===r?void 0:r.schema.tpl)?SteedosUI.message[e](null===(o=t.props)||void 0===o?void 0:o.schema.tpl):"string"==typeof t?SteedosUI.message[e](t):console.warn("notify",e,t)},confirm:e=>new Promise((t,r)=>SteedosUI.Modal.confirm({title:e,onOk:()=>{t(!0)},okText:"确认",cancelText:"取消"})),jumpTo:(e,r)=>{if("goBack"===e)return window.history.back();e=t(e),r&&"url"===r.actionType?!1===r.blank?FlowRouter.go(e):window.open(e):r&&e&&r.target?window.open(e,r.target):/^https?:\/\//.test(e)?window.location.replace(e):FlowRouter.go(e)},requestAdaptor:e=>(e.url&&!/^http[s]?:\/\//i.test(e.url)?(Meteor.isCordova&&(e.url=Meteor.absoluteUrl(e.url)),e.headers||(e.headers={}),!e.headers.Authorization&&Builder.settings.context&&Builder.settings.context.tenantId&&Builder.settings.context.authToken&&(e.headers.Authorization="Bearer ".concat(Builder.settings.context.tenantId,",").concat(Builder.settings.context.authToken))):e.url&&Meteor.isCordova&&Builder.settings.context&&Builder.settings.context.rootUrl&&e.url.startsWith(Builder.settings.context.rootUrl)&&Meteor.isCordova&&(e.headers||(e.headers={}),!e.headers.Authorization&&Builder.settings.context&&Builder.settings.context.tenantId&&Builder.settings.context.authToken&&(e.headers.Authorization="Bearer ".concat(Builder.settings.context.tenantId,",").concat(Builder.settings.context.authToken))),console.log("env.requestAdaptor=action==",e),e)});Template.amis_action.helpers({objectName:()=>{var e=Template.instance().data;return e.button.object||e.button.object_name},name:()=>{var e;return Template.instance().data.button.name},buttonClassName:()=>{var e;return Template.instance().data.buttonClassName}}),Template.amis_action.onRendered(()=>{var e=Template.instance().data,t=e.button,o=e.buttonClassName,a=e.inMore,n=e.data,i=e.env,s=".steedos-button-"+(t.object||e.button.object_name)+"-"+t.name;const c=()=>{var e=Creator.USER_CONTEXT?Creator.USER_CONTEXT.user.language:null;return e?e="cn"===(e="zh"===(e="en"===(e=e.replace("_","-"))?"en-US":e)?"zh-CN":e)?"zh-CN":e:"zh-CN"};Promise.all([waitForThing(window,"amis")]).then(()=>{var e=amisRequire("amis/embed"),o=t.amis_schema?_.isString(t.amis_schema)?JSON.parse(t.amis_schema):t.amis_schema:{type:"service",bodyClassName:"p-0",body:[{type:"button",label:t.label}],regions:["body"]};const a=__meteor_runtime_config__.ROOT_URL,l=lodash.defaultsDeep({},{data:n},{data:{app_id:n.appId,object_name:n.objectName,record_id:n.recordId,formFactor:Steedos.isMobile()?"SMALL":"LARGE",context:{rootUrl:Meteor.isCordova?a.endsWith("/")?a.substr(0,a.length-1):a:"",tenantId:Creator.USER_CONTEXT.spaceId,userId:Creator.USER_CONTEXT.userId,authToken:Creator.USER_CONTEXT.user.authToken,user:Creator.USER_CONTEXT.user},global:{userId:Creator.USER_CONTEXT.userId,spaceId:Creator.USER_CONTEXT.spaceId,user:Creator.USER_CONTEXT.user,now:new Date},scopeId:o.name||o.id,$scopeId:o.name||o.id}});return o=lodash.defaultsDeep(l,o),e.embed(s,o,{locale:c()},Object.assign(r(),i))})})}},layout:{"template.layout.js":function e(){Template.__checkName("creatorLayout"),Template.creatorLayout=new Template("Template.creatorLayout",(function(){var e=this;return Blaze.If((function(){return Spacebars.call(e.lookup("isloading"))}),(function(){return"\n\t"}),(function(){return["\n\t\t",HTML.DIV({class:"steedos skin-blue-light creator h-full flex flex-col relative overflow-hidden"},"\n\t\t\t\n\n\t\t\t",HTML.HEADER({id:"header",class:"steedos-global-header-root flex-none"}),"\n\n\t\t\t\t\n\t\t\t",HTML.DIV({id:"main",class:function(){return["creator-content-wrapper ",Blaze.If((function(){return Spacebars.call(e.lookup("split"))}),(function(){return"split"}))]}},"\n\n\n\n\t\t\t\t",HTML.Comment(' {{#if split}}\n\t\t\t\t\t\n\t\t\t\t\t\t{{> Template.dynamic template="creatorSidebar"}}\n\t\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t{{> Template.dynamic template=main}}\n\t\t\t\t\t
\n\t\t\t\t{{else}} '),"\n\t\t\t\t\t",Blaze._TemplateWith((function(){return{template:Spacebars.call(e.lookup("main"))}}),(function(){return Spacebars.include((function(){return Spacebars.call(Template.__dynamic)}))})),"\n\t\t\t\t",HTML.Comment(" {{/if}} "),"\n\t\t\t"),"\n\t\t\t",HTML.FOOTER({id:"footer",class:"steedos-global-footer-root flex-none"}),"\n\t\t"),"\n",HTML.Comment(' \n\t\t\n\t\t\t{{> status}}\n\t\t
'),"\n\t\t"]}))}))},"layout.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{},r,o;Template.creatorLayout.helpers(Creator.helpers),Template.creatorLayout.helpers({isloading:function(){return Creator.isloading()},collection:function(){return Session.get("action_collection")},fields:function(){return Session.get("action_fields")},collectionName:function(){return Session.get("action_collection_name")},doc:function(){return Session.get("action_record_id")},saveAndInsert:function(){var e,t,r,o;return!!(e=Session.get("action_save_and_insert"))&&(r=(t=Session.get("action_collection")).replace(/Creator.Collections./,""),null!=(o=Creator.getPermissions(r))?o.allowCreate:void 0)},split:function(){var e,t,r;return!(!(e=Creator.getApp())||"admin"!==e._id)&&(r=/\/app\/\w+\/search\//,t=Session.get("router-path"),!r.test(t))},object_name:function(){return Session.get("object_name")},recordId:function(){return Session.get("recordId")},title:function(){return"编辑"},triggerLabel:function(){return"编辑"},onAddFinish:function(){return function(e){var t,r,o,a,n;return a=e[0],n="/app/"+(t=Session.get("app_id"))+"/"+(r=Session.get("object_name"))+"/view/"+(o=a._id),FlowRouter.go(n),!0}},onEditFinish:function(){return function(){return setTimeout((function(){return FlowRouter.reload()}),1),!0}}}),Template.creatorLayout.onRendered((function(){var e;return e=Session.get("pageApiName")||Session.get("object_name")||Session.get("tab_name"),this.autorun((function(){return Steedos.Page.Header.render(Session.get("app_id"),e)})),this.autorun((function(){return Steedos.Page.Footer.render(Session.get("app_id"),e)})),this.autorun((function(){var e,t;if(t=Session.get("pageApiName")||Session.get("object_name")||Session.get("tab_name"),window.SteedosUI&&(e=SteedosUI.refs.globalHeader))return Meteor.setTimeout((function(){var t;try{return e.updateProps({location:FlowRouter.current()},(function(){return console.log("amisScope.updateProps callback.......")}))}catch(r){t=r}}),100)})),this.autorun((function(){var e,t;if(t=Session.get("pageApiName")||Session.get("object_name")||Session.get("tab_name"),window.SteedosUI&&(e=SteedosUI.refs.globalFooter))return Meteor.setTimeout((function(){var t;try{return e.updateProps({location:FlowRouter.current()},(function(){return console.log("amisScope.updateProps callback.......")}))}catch(r){t=r}}),100)}))})),r=function(){var e;return"calendar"===(null!=(e=Creator.getListView(Session.get("object_name",Session.get("list_view_id"))))?e.type:void 0)},AutoForm.hooks({creatorAddForm:{onSuccess:function(e,t){var o,a,n,i;if($("#afModal").modal("hide"),"/app/:app_id/:object_name/calendar/"!==FlowRouter._current.route.path&&!r())return"post"===t.type?(i="/app/"+(o=Session.get("app_id"))+"/"+(a=t.object_name)+"/view/"+(n=t._id),FlowRouter.go(i)):void 0}}},!1),AutoForm.hooks({creatorEditForm:{onSuccess:function(e,t){var o,a,n,i,s,c;if($("#afModal").modal("hide"),!r())return"post"===t.type&&(c="/app/"+(o=Session.get("app_id"))+"/"+(a=t.object_name)+"/view/"+(s=t._id),FlowRouter.go(c)),this.docId&&t.object_name?(i=Creator.getObjectUrl(t.object_name,this.docId),n=Creator.getObjectRecordName(this.updateDoc.$set,t.object_name),Creator.updateTempNavLabel(t.object_name,i,n)):void 0}}},!1),AutoForm.hooks({creatorCellEditForm:{onSuccess:function(e,t){var r,o;if($("#afModal").modal("hide"),this.docId&&t.object_name)return o=Creator.getObjectUrl(t.object_name,this.docId),r=Creator.getObjectRecordName(this.updateDoc.$set,t.object_name),Creator.updateTempNavLabel(t.object_name,o,r)}}},!1),o=function(e,t){return FlowRouter.current().route.path.endsWith("/:record_id")?FlowRouter.reload():window.refreshGrid()},AutoForm.hooks({creatorAddRelatedForm:{onSuccess:o}},!1)},"template.loading.js":function e(){Template.__checkName("creatorLoading"),Template.creatorLoading=new Template("Template.creatorLoading",(function(){var e=this;return HTML.Raw('')}))},"template.empty_layout.js":function e(){Template.__checkName("empty_layout"),Template.empty_layout=new Template("Template.empty_layout",(function(){var e=this;return Blaze._TemplateWith((function(){return{template:Spacebars.call(e.lookup("main"))}}),(function(){return Spacebars.include((function(){return Spacebars.call(Template.__dynamic)}))}))}))}},mobile:{"template.admin.js":function e(){Template.__checkName("adminMenu"),Template.adminMenu=new Template("Template.adminMenu",(function(){var e=this;return HTML.DIV({class:"admin-menu mobile-template-container",id:"admin_menu"},"\n\n ",HTML.DIV({class:"admin-menu-content mobile-template-content"},"\n\t\t\t",HTML.DIV({class:"weui-panel weui-panel_access user-info"},"\n\t\t\t\t",HTML.A({class:"weui-media-box weui-media-box_appmsg"},"\n\t\t\t\t\t",HTML.DIV({class:"weui-media-box__hd",style:function(){return["background: url(",Spacebars.mustache(e.lookup("avatarURL")),")"]}},"\n\t\t\t\t\t\t",HTML.Raw('\x3c!-- --\x3e'),"\n\t\t\t\t\t"),"\n\t\t\t\t\t",HTML.DIV({class:"weui-media-box__bd"},"\n\t\t\t\t\t\t",HTML.H4({class:"weui-media-box__title"},Blaze.View("lookup:name",(function(){return Spacebars.mustache(e.lookup("name"))}))),"\n\t\t\t\t\t\t",HTML.P({class:"weui-media-box__desc"},"\n\t\t\t\t\t\t\t",Blaze.View("lookup:_",(function(){return Spacebars.mustache(e.lookup("_"),"Company")})),":",Blaze.View("lookup:spaceName",(function(){return Spacebars.mustache(e.lookup("spaceName"))})),"\n\t\t\t\t\t\t"),"\n\t\t\t\t\t"),"\n\t\t\t\t"),"\n\t\t\t"),"\n\n\t\t\t",HTML.DIV({class:"weui-panel"},"\n\t\t\t\t",HTML.DIV({class:"weui-panel__bd"},"\n\t\t\t\t\t",HTML.DIV({class:"weui-media-box weui-media-box_small-appmsg"},"\n\t\t\t\t\t\t",HTML.DIV({class:"weui-cells"},"\n\t\t\t\t\t\t\t",HTML.A({class:"weui-cell weui-cell_access btn-switch-space"},"\n\t\t\t\t\t\t\t\t",HTML.DIV({class:"weui-cell__bd weui-cell_primary"},"\n\t\t\t\t\t\t\t\t\t",HTML.P(Blaze.View("lookup:_",(function(){return Spacebars.mustache(e.lookup("_"),"Switch Company")}))),"\n\t\t\t\t\t\t\t\t"),"\n\t\t\t\t\t\t\t\t",HTML.SPAN({class:"space-name"},Blaze.View("lookup:spaceName",(function(){return Spacebars.mustache(e.lookup("spaceName"))}))),"\n\t\t\t\t\t\t\t\t",HTML.Raw(''),"\n\t\t\t\t\t\t\t"),"\n\t\t\t\t\t\t"),"\n\t\t\t\t\t"),"\n\n\n\n\t\t\t\t\t",HTML.DIV({class:"weui-media-box weui-media-box_small-appmsg"},"\n\t\t\t\t\t\t",HTML.DIV({class:"weui-cells"},"\n\t\t\t\t\t\t\t",HTML.A({class:"weui-cell weui-cell_access btn-change-password"},"\n\t\t\t\t\t\t\t\t",HTML.DIV({class:"weui-cell__bd weui-cell_primary"},"\n\t\t\t\t\t\t\t\t\t",HTML.P(Blaze.View("lookup:_",(function(){return Spacebars.mustache(e.lookup("_"),"Change Password")}))),"\n\t\t\t\t\t\t\t\t"),"\n\t\t\t\t\t\t\t\t",HTML.Raw(''),"\n\t\t\t\t\t\t\t"),"\n\t\t\t\t\t\t"),"\n\t\t\t\t\t"),"\n\t\t\t"),"\n\t\t\t"),"\n\n ",HTML.DIV({class:"weui-panel"},"\n\t\t\t\t",HTML.DIV({class:"weui-panel__bd"},"\n\t\t\t\t\t",HTML.DIV({class:"weui-media-box weui-media-box_small-appmsg"},"\n\t\t\t\t\t\t",HTML.DIV({class:"weui-cells"},"\n\t\t\t\t\t\t\t",HTML.A({class:"weui-cell weui-cell_access log-out steedos-logout"},"\n\t\t\t\t\t\t\t\t",HTML.DIV({class:"weui-cell__bd weui-cell_primary"},"\n\t\t\t\t\t\t\t\t\t",HTML.P(Blaze.View("lookup:_",(function(){return Spacebars.mustache(e.lookup("_"),"Logout")}))),"\n\t\t\t\t\t\t\t\t"),"\n\t\t\t\t\t\t\t"),"\n\t\t\t\t\t\t"),"\n\t\t\t\t\t"),"\n\t\t\t\t"),"\n\t\t\t"),"\n "),"\n ")}))},"admin.coffee":function e(){var r=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};Template.adminMenu.helpers({avatarURL:function(e,t,r,o){var a,n;return n=Meteor.userId(),(e=null!=(a=Creator.getCollection("users").findOne({_id:n}))?a.avatar:void 0)?Steedos.absoluteUrl("avatar/"+Meteor.userId()+"?avatar="+e):Creator.getRelativeUrl("/images/default-avatar.png")},name:function(){var e;return null!=(e=Creator.getCollection("users").findOne())?e.name:void 0},logoutUrL:function(){return Creator.getRelativeUrl("/accounts/a/#/logout")},spaceName:function(){var e;return Session.get("spaceId")&&(e=db.spaces.findOne(Session.get("spaceId")))?e.name:t("none_space_selected_title")}}),Template.adminMenu.events({"click .steedos-logout":function(){return Steedos.logout()},"click .admin-menu-back":function(e,t){var r;return r=urlQuery[urlQuery.length-2],urlQuery.pop(),t.$("#admin_menu").animateCss("fadeOutRight",(function(){return Blaze.remove(t.view),r?FlowRouter.go(r):FlowRouter.go("/app")}))},"click .btn-switch-space":function(e,t){return FlowRouter.go("/user_settings/switchspace")},"click .btn-change-password":function(e,t){return Modal.show("reset_password_modal")},"click .btn-change-avatar":function(e,t){return t.$("#mobile-avator-upload").click()},"change #mobile-avator-upload":function(e,r){var o;if(o=e.target.files[0])return $("body").addClass("loading"),db.avatars.insert(o,(function(e,r){return e?(console.error(e),toastr.error(t(e.reason)),$(document.body).removeClass("loading")):setTimeout((function(){return Meteor.call("updateUserAvatar",r._id,(function(e,r){return(null!=r?r.error:void 0)?($(document.body).removeClass("loading"),toastr.error(t(r.message))):$(document.body).removeClass("loading")}))}),3e3)}))}})},"template.switch_space.js":function e(){Template.__checkName("switchSpace"),Template.switchSpace=new Template("Template.switchSpace",(function(){var e=this;return HTML.DIV({class:"switch-space mobile-template-container",id:"switch_space"},"\n\t\t\n\t\t",HTML.DIV({class:"switch-space-content mobile-template-content"},"\n\t\t\t",HTML.DIV({class:"weui-panel"},"\n\t\t\t\t",HTML.DIV({class:"weui-panel__bd"},"\n\t\t\t\t\t",HTML.DIV({class:"weui-media-box weui-media-box_small-appmsg"},"\n\t\t\t\t\t\t",HTML.DIV({class:"weui-cells"},"\n\t\t\t\t\t\t\t",Blaze.Each((function(){return Spacebars.call(e.lookup("spaces"))}),(function(){return["\n\t\t\t\t\t\t\t",HTML.A({class:"weui-cell weui-cell_access switchSpace"},"\n\t\t\t\t\t\t\t\t",HTML.DIV({class:"weui-cell__bd weui-cell_primary"},"\n\t\t\t\t\t\t\t\t\t",HTML.P(Blaze.View("lookup:name",(function(){return Spacebars.mustache(e.lookup("name"))}))),"\n\t\t\t\t\t\t\t\t"),"\n\t\t\t\t\t\t\t\t",Blaze.If((function(){return Spacebars.dataMustache(e.lookup("current_space"),e.lookup("_id"))}),(function(){return["\n\t\t\t\t\t\t\t\t\t",HTML.SPAN({class:"weui-icon-success-no-circle"}),"\n\t\t\t\t\t\t\t\t"]})),"\n\t\t\t\t\t\t\t"),"\n\t\t\t\t\t\t\t"]})),"\n\t\t\t\t\t\t"),"\n\t\t\t\t\t"),"\n\t\t\t\t"),"\n\t\t\t"),"\n\t\t"),"\n\t")}))},"switch_space.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};Template.switchSpace.helpers({spaces:function(){return db.spaces.find()},current_space:function(e){return e===Session.get("spaceId")}}),Template.switchSpace.events({"click .switchSpace":function(e,t){return Steedos.setSpaceId(this._id),FlowRouter.go("/app")},"click .switch-space-back":function(e,t){var r;return r=urlQuery[urlQuery.length-2],urlQuery.pop(),t.$("#switch_space").animateCss("fadeOutRight",(function(){return Blaze.remove(t.view),r?FlowRouter.go(r):FlowRouter.go("/app")}))}})}},"core.coffee":function e(){var r=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{},o;Creator.Pages={},o=["owner","company_id","company_ids","locked"],Steedos.addPage=function(e,t){if(e)return Creator.Pages[e]=t},Creator.getLayout=function(e){return e||(e=Session.get("app_id")),"steedos"===e?"steedosLayout":"creatorLayout"},Creator.createObject=function(e,t){var r,o;return o=Creator.getObject(e),r="Creator.Collections."+e,Session.set("action_collection",r),Session.set("action_save_and_insert",!0),Session.set("action_collection_name",o.label),Session.set("action_object_name",e),Session.set("action_fields",void 0),Session.set("cmDoc",t),Meteor.defer((function(){return $(".creator-add").click()}))},Meteor.isClient&&(Creator.TabularSelectedIds={},Meteor.autorun((function(){var e,t;if(e=Session.get("list_view_id"),t=Session.get("object_name"))return Creator.TabularSelectedIds[t]=[]})),Creator.remainCheckboxState=function(e){var t,r,o,a,n,i,s;if((t=e.find(".select-all")).length&&(a=(o=null!=(n=t[0])?n.dataset:void 0).objectName,i=Creator.TabularSelectedIds[a]))return(r=e.find(".select-one")).each((function(e,t){var r;return r=i.indexOf(t.dataset.id)>-1,$(t).prop("checked",r)})),(s=i.length)>0&&r.length!==s?t.prop("indeterminate",!0):(t.prop("indeterminate",!1),0===s?t.prop("checked",!1):s===r.length?t.prop("checked",!0):void 0)},Creator.isListViewFilterEditable=function(e){return!e.shared||e.shared&&e.owner===Steedos.userId()},Creator.getODataFilter=function(e,t,r){var o,a,n,i,s,c,l,u,d,p,f,m,g;if(g=Meteor.userId(),m=Session.get("spaceId"),a=Creator.Collections.object_listviews.findOne(e))(l=Creator.isListViewFilterEditable(a))||((o={}).filter_scope=a.filter_scope,o.filters=a.filters);else if(o={},m&&g){if(!(u=Creator.getListView(t,e)))return["_id","=",-1];o.filter_scope=u.filter_scope,o.filters=u.filters}if(Creator.isCloudAdminSpace(m)&&_.include(["users","space_users","spaces"],t)&&delete o.filters,o&&(r?(o.filter_scope&&(r.filter_scope=o.filter_scope),_.isFunction(r.filters)||(null!=(d=r.filters)?d.length:void 0)?(_.isFunction(o.filters)||(null!=(p=o.filters)?p.length:void 0))&&(r.filters=[[r.filters,"and",o.filters]]):r.filters=o.filters):r=o),r||(r={}),n=r.filter_logic,i=r.filter_scope,s=r.filters,f=[],_.isFunction(s)&&(s=s()),a?n?(c=Creator.formatLogicFiltersToDev(s,n),f.length?f.push("and",c):f.push(c)):s&&s.length>0&&(f.length>0&&f.push("and"),(s=Creator.formatFiltersToDev(s,t))&&s.length>0&&(s=[s]),_.each(s,(function(e){return f.push(e)}))):m&&g&&("users"!==t||Creator.isCloudAdminSpace(m)||f.push(["_id","=",g]),s&&(s=Creator.formatFiltersToDev(s,t))&&s.length>0&&(s=[s],f.length>0&&f.push("and"),_.each(s,(function(e){if("spaces"!==t||e.length>0&&"_id"!==e[0])return f.push(e)})))),"mine"===i&&(f.length>0&&f.push("and"),f.push(["owner","=",g])),0!==f.length)return f},Creator.getODataRelatedFilter=function(e,t,r,o,a){var n,i,s,c,l,u,d,p,f,m,g,h,v,b,w,S,C;if(r&&(S=Steedos.spaceId(),C=Meteor.userId(),v=a?[a]:Creator.getRelatedList(e,r),h="",u="",w=[],n=function(e){return w.length>0&&w.push("and"),w.push(e)},_.each(v,(function(e){if(e.object_name===t)return e.filtersFunction?u=e.filtersFunction:h=e.related_field_name})),h||u)){if(h=h.replace(/\./g,"/"),o&&(i=Creator.getListView(t,o))){if(s=i.filter_logic,c=i.filter_scope,l=i.filters,u)return l=u(Creator.odata.get(e,r));s?(d=Creator.formatLogicFiltersToDev(l,s),n(d)):l&&l.length>0&&(l=_.map(l,(function(e){return _.isObject(e)&&!_.isArray(e)?Meteor.isClient&&_.isString(null!=e?e._value:void 0)?[e.field,e.operation,Creator.eval("("+e._value+")")()]:[e.field,e.operation,e.value]:e})),(l=Creator.formatFiltersToDev(l,t))&&l.length>0&&(l=[l]),_.each(l,(function(e){return n(e)})))}if("cfs.files.filerecord"===t&&n(["metadata/space","=",S]),m=Creator.getObject(t),p=t===e&&(null!=m?m.enable_tree:void 0),"cms_files"===t?(n(["parent/o","=",e]),n(["parent/ids","=",r])):"objects"===e?n([h,"=",r]):p||((b=null!=m?m.fields:void 0)&&(g=b[h]),g&&g.reference_to_field&&(f=Creator.odata.get(e,r,g.reference_to_field),"permission_fields"===t&&"object_fields"===e&&n(["object_name","=",f.object]),f&&f[g.reference_to_field]&&(r=f[g.reference_to_field])),!g||"master_detail"!==g.type&&"lookup"!==g.type?g&&"grid"===g.type?(n([h+".o","=",e]),n([h+".ids","=",r])):n([h,"=",r]):_.isFunction(g.reference_to)?_.isArray(g.reference_to())?n([h+".ids","=",r]):n([h,"=",r]):_.isArray(g.reference_to)?n([h+".ids","=",r]):n([h,"=",r])),"mine"===c&&n(["owner","=",C]),0!==w.length)return w}},Creator.getJsReportUrlQuery=function(){var e,t,r;return r="?space_id="+Steedos.getSpaceId(),(t=Tracker.nonreactive((function(){return Session.get("filter_items")})))&&(r+="&user_filters="+(e=encodeURI(JSON.stringify(t)))),r},Creator.getJsReportViewUrl=function(e){var t;return t=Creator.getRelativeUrl("/plugins/jsreport/web/viewer_db/"+e),t+=Creator.getJsReportUrlQuery()},Creator.getJsReportExcelUrl=function(e){var t;return t=Creator.getRelativeUrl("/plugins/jsreport/api/report_db/"+e+"/excel"),t+=Creator.getJsReportUrlQuery()},Creator.getJsReportPdfUrl=function(e){var t;return t=Creator.getRelativeUrl("/plugins/jsreport/api/report_db/"+e+"/pdf"),t+=Creator.getJsReportUrlQuery()},Creator.getStimulsoftReportViewUrl=function(e){var t;return t=Creator.getRelativeUrl("/plugins/stimulsoft/web/viewer_db/"+e),t+=Creator.getJsReportUrlQuery()},Creator.getStimulsoftReportDesignerUrl=function(e){var t;return t=Creator.getRelativeUrl("/plugins/stimulsoft/web/designer_db/"+e),t+=Creator.getJsReportUrlQuery()},Creator.objectOdataSelectFields=function(e){var t,r;return t=e.fields,r=(r=_.keys(t)).filter((function(e){return e.indexOf(".")<0})),e&&["default","meteor"].indexOf(e.database_name||"default")>-1&&(r=_.union(r.concat(o))),r.join(",")},Creator.objectOdataExpandFields=function(e,t){var r,o;return r=[],o=e.fields,t||(t=_.keys(o)),_.each(t,(function(e){var t,a,n;if(("master_detail"===(null!=(a=o[e])?a.type:void 0)||"lookup"===(null!=(n=o[e])?n.type:void 0))&&(o[e].reference_to?(t=o[e].reference_to,_.isFunction(t)&&(t=t())):_.isFunction(o[e].optionsFunction)&&(t=o[e].optionsFunction({}).getProperty("value")),_.isArray(t)||(t=[t]),t=_.map(t,(function(e){var t,r;return t=(null!=(r=Creator.getObject(e))?r.NAME_FIELD_KEY:void 0)||"name"})),t=_.compact(t),(t=(t=_.uniq(t)).join(","))&&e.indexOf("$")<0))return e.indexOf(".")<0?r.push(e):r.push(e.replace(".","/"))})),r.join(",")},Creator.relatedObjectFileUploadHandler=function(e,r){var o,a,n,i,s,c,l,u,d,p;for(u=null!=(o=e.currentTarget.dataset)?o.parent:void 0,s=e.currentTarget.files,c=0,d=Session.get("record_id"),l=Session.get("object_name"),p=Session.get("spaceId");c0&&(t=!0),!t})),t},Creator.pushCurrentPathToUrlQuery=function(){var e;if((e=FlowRouter.current().path)!==urlQuery[urlQuery.length-1])return urlQuery.push(e)},Creator.getStandardQuery=function(e,t){var r,o,a,n,i,s;if(o=Creator.getObject(e).fields,t&&t.query&&_.size(t.query)&&t.object_name===e)return a=t.object_name,i=t.query,s=[],t.is_mini?_.each(i,(function(e,t){var r,n,i,c;if(o[t])if(r=Creator.getFieldDataType(o,t),["currency","number"].includes(r)){if(!_.isString(e))return s.push([t,"=",e]);if(c=e.trim().split(" "),n=[],c.forEach((function(e){var r,o;try{if(o=Number(e),_.isNumber(o)&&!_.isNaN(o))return n.push([t,"=",o])}catch(a){return r=a,console.error(r)}})),n.length>0)return s.push(Creator.formatFiltersToDev(n,a,{is_logic_or:!1}))}else if(["text","textarea","html","select","autonumber","url","email"].includes(r))if(_.isString(e)){if(c=e.trim().split(" "),i=[],c.forEach((function(e){return e=encodeURIComponent(Creator.convertSpecialCharacter(e)),"select"===r&&o[t].multiple?i.push([t,"=",e]):i.push([t,"contains",e])})),i.length>0)return s.push(Creator.formatFiltersToDev(i,a,{is_logic_or:!1}))}else if(_.isArray(e))return s.push([t,"=",e])})):_.each(i,(function(e,t){var r,n,i,c,l,u;if(o[t]){if(n=Creator.getFieldDataType(o,t),["date","datetime","time","currency","number"].includes(n))return s.push([t,">=",e]);if(["text","textarea","html"].includes(n)){if(_.isString(e)){if(u=e.trim().split(" "),l=[],u.forEach((function(e){return e=encodeURIComponent(Creator.convertSpecialCharacter(e)),l.push([t,"contains",e])})),l.length>0)return s.push(Creator.formatFiltersToDev(l,a,{is_logic_or:!1}))}else if(_.isArray(e))return s.push([t,"=",e])}else{if(["boolean"].includes(n))return s.push([t,"=",JSON.parse(e)]);if(!["lookup","master_detail"].includes(n))return s.push([t,"=",e]);if(i=null!=(r=o[t])?r.reference_to:void 0,_.isFunction(i)&&(i=i()),!_.isArray(i))return s.push([t,"=",e]);if((null!=e?e.ids:void 0)&&s.push({field:t+".ids",operation:"=",value:null!=e?e.ids:void 0}),null!=e?e.o:void 0)return c=Creator.getObject(null!=e?e.o:void 0),s.push({field:t+".o",operation:"=",value:c._collection_name})}}else if(t=t.replace(/(_endLine)$/,""),n=Creator.getFieldDataType(o,t),o[t]&&["date","datetime","time","currency","number"].includes(n))return s.push([t,"<=",e])})),n={is_logic_or:r=!!t.is_mini},Creator.formatFiltersToDev(s,a,n);delete Session.keys.standard_query},Creator.getSafeObjectUrl=function(e,t,r){var o;return _.isString(e)?(o="users"===e?Creator.getObject("space_users"):Creator.getObject(e)).permissions.get().allowRead?Creator.getObjectUrl(e,t,r):void 0:""},Creator.formatFileSize=function(e){var t,r;return r="KB",(t=e/1024)>1024&&(t/=1024,r="MB"),t>1024&&(t/=1024,r="GB"),t.toFixed(2)+r},Creator.getTableCellData=function(e){var r,o,a,n,i,s,c,l,u,d,p,f,m,g,h,v,b,w,S,C,y,j,T,R;if(d=[],R=e.val,g=e.object_name,y=(j=Creator.getObject(g)).NAME_FIELD_KEY,"organizations"===g&&(y="name"),o=e.field){if(a=o.type,"formula"===o.type)a=o.data_type;else if("select"===o.type&&o.data_type&&"text"!==o.data_type)a=o.data_type;else if("summary"===o.type)if("count"===o.summary_type)a="number";else{if(!(C=Creator.getObject(o.summary_object)))throw new Meteor.Error(500,"The summary_object '"+o.summary_object+"' is not found for the field '"+o.name+"'");if(!(S=C.fields[o.summary_field]))throw new Meteor.Error(500,"The summary_field '"+o.summary_field+"' is not found for the field '"+o.name+"'");"formula"!==(a=S.type)&&"summary"!==a||(a=S.data_type),_.isNumber(o.scale)||(r=function(e){var t,o;return _.isNumber(e.scale)?e.scale:"summary"===e.type&&(o=Creator.getObject(e.summary_object))?(t=o.fields[e.summary_field])?r(t):null:void 0},o.scale=r(S))}return v=null!=(h=e.field)?h.reference_to:void 0,_.isFunction(v)&&(v=v()),"grid"===a?d.push({isTable:!0}):"location"===a?d.push({value:(null!=R?R.address:void 0)||"",id:e._id}):"lookup"!==a&&"master_detail"!==a||_.isEmpty(R)?"image"===a?"string"==typeof R?d.push({value:R,id:e._id,isImage:!0,baseUrl:Creator.getRelativeUrl("/api/files/images")}):d.push({value:R,id:e._id,isImages:!0,baseUrl:Creator.getRelativeUrl("/api/files/images")}):"avatar"===a?"string"==typeof R?d.push({value:R,id:e._id,isImage:!0,baseUrl:Creator.getRelativeUrl("/api/files/avatars")}):d.push({value:R,id:e._id,isImages:!0,baseUrl:Creator.getRelativeUrl("/api/files/avatars")}):"code"===a?(R=R?"...":"",d.push({value:R,id:e._id})):"password"===a?(R=R?"******":"",d.push({value:R,id:e._id})):"url"===a?((null!=(f=R)?f.startsWith("http"):void 0)||(f=Steedos.absoluteUrl(encodeURI(f))),d.push({value:R,href:f,id:e._id,isUrl:!0})):"email"===a?d.push({value:R,href:f,id:e._id,isEmail:!0}):"boolean"===a||"toggle"===a?(R=e.val?t("YES"):t("NO"),d.push({value:R,checked:e.val,id:e._id,isBoolean:!0})):"select"===a?(s=o.allOptions||o.options,u=e.doc||{},c=e.record_val,_.isFunction(o.options)&&(s=o.options(c||u)),_.isFunction(o.optionsFunction)&&(s=o.optionsFunction(c||u)),w=e.val,_.isArray(w)||(w=[w]),m=[],_.each(s,(function(e){if(_.indexOf(w,e.value)>-1)return m.push({label:e.label,value:e.value})})),R=(R=m.map((function(e){return e.label}))).join(","),d.push({value:R,items:m,id:e._id,isSelects:!0})):(R&&["datetime","date","time"].indexOf(a)>=0?"odata"===e.agreement?"datetime"===a?"string"==typeof e.val&&/\d+Z$/.test(e.val)?R=moment(e.val).format("YYYY-MM-DD H:mm"):(T=moment().utcOffset()/60,R=moment(e.val).add(T,"hours").format("YYYY-MM-DD H:mm")):"date"===a&&(R="string"==typeof e.val&&/\d+Z$/.test(e.val)?moment.utc(e.val).format("YYYY-MM-DD"):moment(e.val).format("YYYY-MM-DD")):"datetime"===a?R=moment(e.val).format("YYYY-MM-DD H:mm"):"date"===a?R=moment.utc(e.val).format("YYYY-MM-DD"):"time"===a&&(R=moment.utc(e.val).format("HH:mm")):null===e.val?R="":"lookup"===a?_.isFunction(o.optionsFunction)&&(u=e.doc||{},(l=R)&&(_.isArray(l)||(l=[l]),(b=_.filter(o.optionsFunction(u),(function(e){return l.indexOf(e.value)>-1})))&&(R=b.getProperty("label")))):"filesize"===a?R=Creator.formatFileSize(R):["number","currency","percent"].indexOf(a)>-1&&_.isNumber(R)?(p=0,p=_.isNumber(o.scale)?o.scale:"currency"===a?2:0,"percent"===a&&(R*=100),R=Steedos.numberToString(R,p),"percent"===a&&(R+="%")):"markdown"===a?_.isEmpty(R)||(R=Spacebars.SafeString(marked(R))):"html"===a?_.isEmpty(R)||(R=Spacebars.SafeString(R)):"textarea"===a&&R&&(R=(R=R.replace(/\n/g,"\n
")).replace(/ /g," ")),"record_details"!==e.parent_view&&e.field_name===y&&(f=Creator.getObjectUrl(e.object_name,e._id)),d.push({value:R,href:f,id:e._id,type:a})):_.isFunction(o.optionsFunction)&&"company"!==v?(u=e.doc||{},c=e.record_val,(l=R)&&(l=_.isArray(l)?l.map((function(e){return _.isObject(e)?e._id:e})):_.isObject(l)?[l._id]:[l],i=o.optionsFunction(c||u),(b=_.filter(i,(function(e){return l.indexOf(null!=e?e.value:void 0)>-1})))&&(R&&_.isArray(R)&&_.isArray(b)&&(b=Creator.getOrderlySetByIds(b,R,"value")),R=b.getProperty("label"))),v?"objects"===v?_.each(b,(function(t){var r,o,a;return a=t.label,(null!=(r=Creator.getObject(t.value))?r._id:void 0)?(o=Creator.getSafeObjectUrl(v,r._id),d.push({reference_to:v,rid:a,value:a,id:e._id,href:o})):d.push({value:R,id:e._id})})):(n=e.val,_.isArray(n)||(n=n?[n]:[]),_.each(n,(function(t){var r,o,a;return _.isString(t)?(b=_.filter(i,(function(e){return t===(null!=e?e.value:void 0)})),d.push({value:b.getProperty("label"),id:e._id})):(v=t["reference_to._o"]||v,o=t._id,a=t._NAME_FIELD_VALUE,r=Creator.getSafeObjectUrl(v,o),d.push({reference_to:v,rid:o,value:a,href:r,id:e._id}))}))):d.push({value:R,id:e._id})):(_.isArray(R)||(R=R?[R]:[]),_.each(R,(function(t){var r,o,a;if(t)return v=t["reference_to._o"]||v,o=t._id,a=t._NAME_FIELD_VALUE,_.isString(t)&&(o=t,a=t),r=Creator.getSafeObjectUrl(v,o),d.push({reference_to:v,rid:o,value:a,href:r,id:e._id})}))),d}},Creator.openSafeObjectUrl=function(e,t){var r;return Steedos.isMobile()||(r=Creator.getSafeObjectUrl(e,t,"-"))&&window.open(r,"_blank","width=800, height=600, left=50, top= 50, toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes"),"undefined"!=typeof event&&null!==event&&event.stopPropagation(),"undefined"!=typeof event&&null!==event&&event.preventDefault(),!1},Creator.getAppLabel=function(e){return e||(e=Creator.getApp()),e?e.label?t(e.label):t(e.name):""},Creator.measureWidth=_.memoize((function(e,t,r){var o,a,n,i;return(o=arguments.callee.canvas)||(o=document.createElement("canvas"),(n=document.createDocumentFragment()).appendChild(o),arguments.callee.canvas=o),(a=o.getContext("2d")).font=t,i=a.measureText(e).width,r&&i>r?r:i})),Creator.showPreviewButton=function(e){var t,r,o,a,n;return!!((null!=(n=null!=(t=Meteor.settings)&&null!=(r=t.public)?r.webservices:void 0)&&null!=(o=n.officeOnline)?o.url:void 0)&&Steedos.isOfficeFile(e)||(null!=n&&null!=(a=n.pdfOnline)?a.url:void 0)&&Steedos.isPdfFile(e))},Creator.officeOnlinePreview=function(e,t){var r,o,a,n,i,s,c,l,u,d,p,f,m,_,g,h;return a=null!=(s=Meteor.settings)&&null!=(c=s.public)&&null!=(l=c.webservices)&&null!=(u=l.officeOnline)?u.url:void 0,i=null!=(d=Meteor.settings)&&null!=(p=d.public)&&null!=(f=p.webservices)&&null!=(m=f.pdfOnline)?m.url:void 0,a&&""!==a||i&&""!==i?(h=Meteor.userId(),_=Steedos.spaceId(),r={authToken:o=Accounts._storedLoginToken()},e=e+"?token="+(g=window.btoa(JSON.stringify(r))),Steedos.isPdfFile(t)?(n=e,i&&""!==i&&(n=i+encodeURIComponent(e)),Steedos.openWindow(n)):(n=a+encodeURIComponent(e),Steedos.openWindow(n))):(toastr.error(TAPi18n.__("creator_office_online_web_url_required")),!1)},Creator.isImageAttachment=function(e){var t,r;return!(e.split(".").length<2)&&(t=e.split(".").pop().toLowerCase(),-1!==(r=["png","jpg","jpeg","bmp","gif","webp","psd","svg","tiff"]).indexOf(t))},Creator.isHtmlAttachment=function(e){var t,r;return!(e.split(".").length<2)&&(t=e.split(".").pop().toLowerCase(),-1!==(r=["html","htm"]).indexOf(t))}),Meteor.startup((function(){return $(document).on("click",(function(e){return $(e.target).closest(".slds-table td").length<1?$(".slds-table").addClass("slds-no-cell-focus"):$(".slds-table").removeClass("slds-no-cell-focus")})),$(window).resize((function(){if($(".list-table-container table.dataTable").length)return $(".list-table-container table.dataTable thead th").each((function(){var e;return e=$(this).outerWidth(),$(".slds-th__action",this).css("width",e+"px")}))})),$(document).keydown((function(e){if("13"===e.keyCode||"Enter"===e.key){if($(".modal").length>1)return;if("TEXTAREA"!==e.target.tagName||$(e.target).closest("div").hasClass("bootstrap-tagsinput")){if("update"===Session.get("cmOperation"))return e.preventDefault(),e.stopPropagation(),$(".creator-auotform-modals .btn-update").click();if("insert"===Session.get("cmOperation"))return e.preventDefault(),e.stopPropagation(),$(".creator-auotform-modals .btn-insert").click()}}}))}))},"colors.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{},r,o,a,n,i;n="border-radius: 10px;padding: 1px 6px;display: inline-block;",i=function(e){return 3===(e=e.slice(1)).length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),{r:Number.parseInt(e.slice(0,2),16),g:Number.parseInt(e.slice(2,4),16),b:Number.parseInt(e.slice(4,6),16)}},a=function(e,t,r){var o,a,n,s;return.299*(n=(s=i(e)).r)+.587*(a=s.g)+.114*(o=s.b)>186?r:t},o=function(e,t,r){var o,a,n,s,c,l,u;return(o=.2126*(n=(u=[(c=(l=i(e)).r)/255,(s=l.g)/255,(a=l.b)/255]).map((function(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)})))[0]+.7152*n[1]+.0722*n[2])>.179?r:t},r=function(e){var t,r;return r=[],t=e.fields,_.each(t,(function(t,a){var i;if(i=t.options,_.isFunction(i)&&(i=i({})),"select"===t.type&&(null!=i?i.length:void 0))return _.each(i,(function(t){var i,s;if(t.color)return i=t.color,/^#/.test(i)||(i="#"+i),s=o(i,"#fff","#333"),r.push(".creator-cell-color-"+e.name+"-"+a+"-"+t.value+"{"+n+"background:"+i+";color:"+s+";}")}))})),r},Creator.appendObjectFieldsColorStyles=function(){var e,t;return $("#object_fields_color_styles").remove(),t=[],_.each(Creator.Objects,(function(e){return t=_.union(t,r(e))})),t.push(".creator-cell-multiple-color{\n\tmargin-right:1px;\n}\n@media (max-width:767px) {\n\t.creator-cell-multiple-color{\n\t\tmargin-right:4px;\n\t}\n}"),e=$('"),$("head").append(e)}},"temp_navs.coffee":function e(){var r=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{},o,a,n,i,s,c,l,u,d,p;s=!1,a=function(){var e;if(e=sessionStorage.getItem("temp_navs"))return e.split(",").map((function(e){var t;return{name:(t=e.split(":"))[0],url:t[1],label:t[2],is_temp:!0}}))},n=function(e,t,r){return sessionStorage.getItem("temp_navs_id")},d=function(e){return sessionStorage.setItem("temp_navs_id",e)},p=function(e){var t,r;return e||(e=[]),t=(r=e.map((function(e){var t;return t=e.name,e.url&&(t+=":"+e.url),e.label&&(t+=":"+e.label),t}))).join(","),sessionStorage.setItem("temp_navs",t)},c=[],o=function(e,t){var r;return r=t||Creator.getObjectUrl(e),c.push(r)},u=function(e,t){var r,o;if(o=t||Creator.getObjectUrl(e),(r=c.indexOf(o))>-1)return c.splice(r,1)},i=function(e,t){var r,o,a,n,i,s;for(r=t||Creator.getObjectUrl(e),o=2,s=6,i=!1;!i&&o<8&&!((a=urlQuery.length-o)<0);)n=urlQuery[a],__meteor_runtime_config__.ROOT_URL_PATH_PREFIX+n!==r?(i=n&&c.indexOf(__meteor_runtime_config__.ROOT_URL_PATH_PREFIX+n)<0,o++):o++;return i?n:null},l=function(e,t,r,a){var n,s,c,l,u,d,p,f,m;return n=Session.get("object_name"),s=Session.get("record_id"),t?(l=(c=Creator.getObjectUrl(n,s))===t)||(l=FlowRouter.current().path===t):l=n===e,l?(d=i(e,t),o(e,t),d?(FlowRouter.go(d),urlQuery.pop(),urlQuery.pop()):((f=r[a])||(f=r[a-1]),f?(m=f.url?f.url:Creator.getObjectUrl(f.name),FlowRouter.redirect(m)):(u=(p=Creator.getAppMenus())[p.length-1],FlowRouter.redirect(u.path)))):o(e,t)},Creator.getTempNavs=function(){var e;return(e=Session.get("temp_navs"))||(e=a())&&Session.set("temp_navs",e),e},Creator.getTempNavsId=function(){var e;return(e=Session.get("temp_navs_id"))||(e=n())&&Session.set("temp_navs_id",e),e},Creator.createTempNav=function(e,t,r){var o,a;if(t||!(["users","cms_files","cfs.files.filerecord"].indexOf(e)>-1))return(a=Creator.getTempNavs())||(a=[]),(o=a.find((function(r){return t?r.name===e&&r.url===t:r.name===e})))?void 0:(a.push({name:e,url:t,label:r,is_temp:!0}),Session.set("temp_navs",a),p(a),u(e,t))},Creator.updateTempNavLabel=function(e,t,r){var o,a;if(t&&r)return(a=Creator.getTempNavs())||(a=[]),(o=a.find((function(r){return r.name===e&&r.url===t})))?(o.label=r,Session.set("temp_navs",a),p(a)):void 0},Creator.removeTempNavItem=function(e,t){var r,o,a;if((a=Session.get("temp_navs"))&&(o=null,r=a.filter((function(r,a){var n;return(n=t?r.name===e&&r.url===t:r.name===e)&&(o=a),!n})),_.isNumber(o)))return s=!0,l(e,t,r,o),Meteor.defer((function(){return Session.set("temp_navs",r),p(r),s=!1})),!0},Creator.resetTempNavsIfNeeded=function(){var e,t,r;if((t=(r=Creator.getTempNavsId())!==(e=Meteor.userId()+":"+Steedos.spaceId()+":"+Session.get("app_id")))&&(Session.set("temp_navs",null),p(null),c.length=0),t||!Session.get("temp_navs_id"))return Session.set("temp_navs_id",e),d(e)},Meteor.startup((function(){if(!Steedos.isMobile())return Tracker.autorun((function(){var e,t;if(Creator.bootstrapLoaded.get()&&(t=Session.get("spaceId"),e=Session.get("app_id"),t&&e))return Creator.resetTempNavsIfNeeded()})),Tracker.autorun((function(e){var r,o,a,n,i,c,l,u,d,p,f,m,g,h,v;if(u=Session.get("object_name"),h=Session.get("tab_name"),p=Session.get("record_id"),i=Creator.getAppMenus(),u&&i&&i.length&&(f=Session.get("record_name"),n=_.pluck(i,"id"),o=Session.get("temp_navs_force_create"),(null!=n?n.indexOf(u||h):void 0)<0||o)){if(o&&s)return void Session.set("temp_navs_force_create",!1);if(!(l=Creator.getObject(u)))return;if(p){if(!(d=Creator.getObjectRecord()))return;if(v=Creator.getObjectUrl(u,p),o&&(r=urlQuery[urlQuery.length-3])&&(g=new RegExp(r+"$")).test(v))return void Session.set("temp_navs_force_create",!1);a=f||("cfs.files.filerecord"===u?t("cfs_files_filerecord__object")+"-"+(null!=d&&null!=(m=d.original)?m.name:void 0):d[c=l.NAME_FIELD_KEY||"name"]),Creator.createTempNav(u,v,a)}else Creator.createTempNav(u);if(o)return Session.set("temp_navs_force_create",!1)}}))}))},"router.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{},r,o,a,n;this.urlQuery=new Array,o=function(e,t){var r,o;Meteor.userId()&&(Creator.pushCurrentPathToUrlQuery(),"-"!==(r=e.params.app_id)&&r&&Session.get("app_id")!==r?Session.set("app_id",r):"-"!==r||Session.get("app_id")||(o=Steedos.getFirstApp(),Session.set("app_id",o.id)))},n=function(e,t){var r,o,a,n;if(o=Tracker.nonreactive((function(){return Session.get("object_name")})),a=Tracker.nonreactive((function(){return Session.get("record_id")})),r=e.params.object_name,n=e.params.record_id,Session.set("object_name",r),Session.set("tab_name",null),Session.set("pageApiName",null),Session.set("record_id",n),Session.set("record_name",null),n&&(o&&o!==r||a&&n!==a))return Session.set("temp_navs_force_create",!0)},r=function(e,t){var r;if("admin"===(r=e.params.app_id)&&Steedos.isMobile())return t("/user_settings"),urlQuery.pop()},FlowRouter.route("/app",{triggersEnter:[o],action:function(e,t){return BlazeLayout.render(Creator.getLayout(),{main:"creator_app_home"})}}),FlowRouter.route("/app/menu",{triggersEnter:[o],action:function(e,t){var r;return r="app_object_menu",Session.set("hidden_header",!0),BlazeLayout.render(Creator.getLayout(),{main:r})},triggersExit:[function(e,t){if(Steedos.isMobile())return Session.set("hidden_header",void 0)}]}),FlowRouter.route("/app/:app_id",{triggersEnter:[o],action:function(e,t){var r,o,a;return"-"!==(o=FlowRouter.getParam("app_id"))&&(Session.set("object_name",null),Session.set("record_id",null),Session.set("app_id",o)),Session.set("admin_template_name",null),a=(r=Creator.getApp(o))&&r.is_use_iframe?"creator_app_iframe":"creator_app_home",BlazeLayout.render(Creator.getLayout(),{main:a})}}),FlowRouter.route("/app/:app_id/page/:page_id",{triggersEnter:[o],action:function(e,t){var r,o;return console.log("params",e),r=FlowRouter.getParam("app_id"),o=null!=e?e.page_id:void 0,Session.set("pageApiName",o),Session.set("object_name",null),BlazeLayout.render(Creator.getLayout(),{main:"page_template",regions:{appId:r,pageId:o}})},triggersExit:[function(e,t){return Session.set("pageApiName",null)}]}),FlowRouter.route("/page/:page_id/",{action:function(e,t){return BlazeLayout.render(Creator.getLayout(),{main:"page"})}}),FlowRouter.route("/app/:app_id/tab_iframe/:tab_id",{triggersEnter:[o],action:function(e,t){var r;return r=FlowRouter.getParam("tab_id"),Session.set("tab_name",r),Session.set("object_name",null),BlazeLayout.render(Creator.getLayout(),{main:"page_iframe",regions:{params:e,queryParams:t}})},triggersExit:[function(e,t){return Session.set("tab_name",null)}]}),(a=FlowRouter.group({prefix:"/app/:app_id/:object_name",name:"objectRoutes",triggersEnter:[o,n]})).route("/",{triggersEnter:[function(e,t){var r,o,a,n,i;return n=e.params.object_name,o=(null!=(a=window.getFirstListView(n))?a.name:void 0)||(null!=a?a._id:void 0),t(i="/app/"+(r=e.params.app_id)+"/"+n+"/grid/"+o)}],action:function(e,t){return BlazeLayout.render(Creator.getLayout(),{main:"object_home"})}}),a.route("/:record_id/:related_object_name/grid",{action:function(e,t){var r,o,a,n,i,s,c,l;return o={app_id:r=Session.get("app_id"),object_name:n=FlowRouter.getParam("object_name"),record_id:s=FlowRouter.getParam("record_id"),related_object_name:l=FlowRouter.getParam("related_object_name")},Session.set("related_object_name",l),a="related_object_list",(i=Steedos.Page.getPage("related_list",r,l))&&(a="page_related_list_view",c={page:i,appId:Session.get("app_id"),objectName:n,recordId:s,relatedObjectName:l,__timestamp:(new Date).getTime()}),Meteor.setTimeout((function(){return BlazeLayout.render(Creator.getLayout(),{main:a,regions:c})}),10)}}),a.route("/view/:record_id",{action:function(e,t){var r,o,a,n,i,s,c;return t["X-Space-Id"]&&Steedos.setSpaceId(t["X-Space-Id"]),o={app_id:r=FlowRouter.getParam("app_id"),object_name:n=FlowRouter.getParam("object_name"),record_id:s=FlowRouter.getParam("record_id")},ObjectRecent.insert(n,s),Session.set("detail_info_visible",!0),a="creator_view",(i=Steedos.Page.getPage("record",Session.get("app_id"),n,s))&&(a="page_object",c=window._.defaultsDeep({display:Steedos.Page.getDisplay(n)},FlowRouter.current().queryParams,{page:i,appId:Session.get("app_id"),recordId:s,objectName:n,pageType:"record",__timestamp:(new Date).getTime()})),Meteor.setTimeout((function(){return BlazeLayout.render(Creator.getLayout(),{main:a,regions:c})}),10)},triggersExit:[function(e,t){var r,o,a,n,i;if(i=null!=(o=e.queryParams)?o.side_listview_id:void 0,window._.isArray(i)&&(i=i[0]),Session.get("instance_change")&&("instances"===(null!=(a=e.params)?a.object_name:void 0)&&"draft"===i||"instance_tasks"===(null!=(n=e.params)?n.object_name:void 0)&&"inbox"===i)&&("draft"===(r=WorkflowManager.getInstance()).state||"draft"!==Session.get("box")))return InstanceManager.saveIns(!1)}]}),a.route("/grid/:list_view_id",{action:function(e,t){var r,o,a,n,i;return Session.set("record_id",null),Session.get("object_name")===FlowRouter.getParam("object_name")&&Session.get("list_view_id")===FlowRouter.getParam("list_view_id")||(Session.set("filter_target",null),Session.set("filter_items",null)),Session.get("object_name")!==FlowRouter.getParam("object_name")&&Session.set("list_view_id",null),"true"===(null!=t?t.hidden_header:void 0)&&Session.set("hidden_header",!0),"-"!==(r=FlowRouter.getParam("app_id"))&&Session.set("app_id",r),a=FlowRouter.getParam("object_name"),Session.set("object_name",a),Session.set("list_view_id",FlowRouter.getParam("list_view_id")),Session.set("list_view_visible",!1),Tracker.afterFlush((function(){return Session.set("list_view_visible",!0)})),(n=Steedos.Page.getPage("list",Session.get("app_id"),a))&&(o="page_object",i=window._.defaultsDeep({display:Steedos.Page.getDisplay(a)},FlowRouter.current().queryParams,{page:n,appId:Session.get("app_id"),objectName:a,listViewId:Session.get("list_view_id"),pageType:"list",__timestamp:(new Date).getTime()})),BlazeLayout.render(Creator.getLayout(),{main:o,regions:i})}}),FlowRouter.notFound={action:function(e,t){var r;try{throw new Error("404 not found:"+window.location.href)}catch(o){r=o,console.log(r,window.location.href)}return BlazeLayout.render("empty_layout",{main:"notFound"})}}},"tenant.coffee":function e(){var t=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};$.getJSON("/accounts/settings",(function(e){return(null!=e?e.tenant:void 0)&&Session.set("tenant_settings",e.tenant),Steedos.settings=Object.assign(Steedos.settings,e.settings||{})}))},"animate.js":function e(){$.fn.extend({animateCss:function(e,t){var r=function(e){var t={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"mozAnimationEnd",WebkitAnimation:"webkitAnimationEnd"};for(var r in t)if(void 0!==e.style[r])return t[r]}(document.createElement("div"));return this.addClass("animated "+e).one(r,(function(){$(this).removeClass("animated "+e),"function"==typeof t&&t()})),this}})},"colResizable-1.6.js":function e(){!function(e){var t=e(document),r=e("head"),o=null,a={},n=0,i="id",s="px",c="JColResizer",l="JCLRFlex",u=parseInt,d=Math,p=navigator.userAgent.indexOf("Trident/4.0")>0,f;try{f=sessionStorage}catch(T){}r.append("");var m=function(t,o){var s=e(t);if(s.opt=o,s.mode=o.resizeMode,s.dc=s.opt.disabledColumns,s.opt.disable)return _(s);var l=s.id=s.attr(i)||c+n++;s.p=s.opt.postbackSafe,!s.is("table")||a[l]&&!s.opt.partialRefresh&&s.prev(".JCLRgrips").length>0||("col-resize"!==s.opt.hoverCursor&&r.append(""),s.addClass(c).attr(i,l).before(''),s.g=[],s.c=[],s.w=s.width(),s.gc=s.prev(),s.f=s.opt.fixed,o.marginLeft&&s.gc.css("marginLeft",o.marginLeft),o.marginRight&&s.gc.css("marginRight",o.marginRight),s.cs=u(p?t.cellSpacing||t.currentStyle.borderSpacing:s.css("border-spacing"))||2,s.b=u(p?t.border||t.currentStyle.borderLeftWidth:s.css("border-left-width"))||1,a[l]=s,g(s))},_=function(e){var t=e.attr(i),e;(e=a[t])&&e.is("table")&&(e.removeClass(c+" "+l).gc.remove(),delete a[t])},g=function(t){var r=t.find(">thead>tr:first>th,>thead>tr:first>td");r.length||(r=t.find(">tbody>tr:first>th,>tr:first>th,>tbody>tr:first>td, >tr:first>td")),r=r.filter(":visible"),t.cg=t.find("col"),t.ln=r.length,t.p&&f&&f[t.id]&&h(t,r),r.each((function(r){var o=e(this),a=-1!=t.dc.indexOf(r),n=e(t.gc.append('')[0].lastChild);n.append(a?"":t.opt.gripInnerHtml).append(''),r==t.ln-1&&(n.addClass("JCLRLastGrip"),t.f&&n.html("")),n.bind("touchstart mousedown",y),a?n.addClass("JCLRdisabledGrip"):n.removeClass("JCLRdisabledGrip").bind("touchstart mousedown",y),n.t=t,n.i=r,n.c=o,o.w=o.width(),t.g.push(n),t.c.push(o),o.width(o.w).removeAttr("width"),n.data(c,{i:r,t:t.attr(i),last:r==t.ln-1})})),t.cg.removeAttr("width"),t.find("td, th").not(r).not("table th, table td").each((function(){e(this).removeAttr("width")})),t.f||t.removeAttr("width").addClass(l),v(t)},h=function(e,t){var r,o=0,a=0,n=[],i;if(t){if(e.cg.removeAttr("width"),e.opt.flush)return void(f[e.id]="");for(i=(r=f[e.id].split(";"))[e.ln+1],!e.f&&i&&(e.width(i*=1),e.opt.overflow&&(e.css("min-width",i+s),e.w=i));a*{cursor:"+s.opt.dragCursor+"!important}"),l.addClass(s.opt.draggingClass),o=l,s.c[i.i].l)for(var d=0,p;d=1,a=arguments.length>=2;if(!(this instanceof r))return n?a?new r(t,e):new r(t):new r;if(void 0===t){if(n)throw new TypeError("undefined is not a valid argument for URI");t="undefined"!=typeof location?location.href+"":""}return this.href(t),void 0!==e?this.absoluteTo(e):this}r.version="1.17.0";var s=r.prototype,i=Object.prototype.hasOwnProperty;function l(t){return t.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function c(t){return void 0===t?"Undefined":String(Object.prototype.toString.call(t)).slice(8,-1)}function u(t){return"Array"===c(t)}function d(t,e){var n={},a,o;if("RegExp"===c(e))n=null;else if(u(e))for(a=0,o=e.length;a]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi,r.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?«»“”„‘’]+$/},r.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"},r.invalid_hostname_characters=/[^a-zA-Z0-9\.-]/,r.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src",audio:"src",video:"src"},r.getDomAttribute=function(t){if(t&&t.nodeName){var e=t.nodeName.toLowerCase();if("input"!==e||"image"===t.type)return r.domAttributes[e]}},r.encode=b,r.decode=decodeURIComponent,r.iso8859=function(){r.encode=escape,r.decode=unescape},r.unicode=function(){r.encode=b,r.decode=decodeURIComponent},r.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/gi,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/gi,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@","%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}},urnpath:{encode:{expression:/%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/gi,map:{"%21":"!","%24":"$","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"=","%40":"@"}},decode:{expression:/[\/\?#:]/g,map:{"/":"%2F","?":"%3F","#":"%23",":":"%3A"}}}},r.encodeQuery=function(t,e){var n=r.encode(t+"");return void 0===e&&(e=r.escapeQuerySpace),e?n.replace(/%20/g,"+"):n},r.decodeQuery=function(t,e){t+="",void 0===e&&(e=r.escapeQuerySpace);try{return r.decode(e?t.replace(/\+/g,"%20"):t)}catch(n){return t}};var g={encode:"encode",decode:"decode"},h,w=function(t,e){return function(n){try{return r[e](n+"").replace(r.characters[t][e].expression,(function(n){return r.characters[t][e].map[n]}))}catch(a){return n}}};for(h in g)r[h+"PathSegment"]=w("pathname",g[h]),r[h+"UrnPathSegment"]=w("urnpath",g[h]);var S=function(t,e,n){return function(a){var o;o=n?function(t){return r[e](r[n](t))}:r[e];for(var s=(a+"").split(t),i=0,l=s.length;i-1&&(e.fragment=t.substring(n+1)||null,t=t.substring(0,n)),(n=t.indexOf("?"))>-1&&(e.query=t.substring(n+1)||null,t=t.substring(0,n)),"//"===t.substring(0,2)?(e.protocol=null,t=t.substring(2),t=r.parseAuthority(t,e)):(n=t.indexOf(":"))>-1&&(e.protocol=t.substring(0,n)||null,e.protocol&&!e.protocol.match(r.protocol_expression)?e.protocol=void 0:"//"===t.substring(n+1,n+3)?(t=t.substring(n+3),t=r.parseAuthority(t,e)):(t=t.substring(n+1),e.urn=!0)),e.path=t,e},r.parseHost=function(t,e){var n=(t=t.replace(/\\/g,"/")).indexOf("/"),a,o;if(-1===n&&(n=t.length),"["===t.charAt(0))a=t.indexOf("]"),e.hostname=t.substring(1,a)||null,e.port=t.substring(a+2,n)||null,"/"===e.port&&(e.port=null);else{var r=t.indexOf(":"),s=t.indexOf("/"),i=t.indexOf(":",r+1);-1!==i&&(-1===s||i-1?n:t.length-1),o;return a>-1&&(-1===n||a-1||(null!=t?t.indexOf("{signature.traces."):void 0)>-1||(null!=t?t.indexOf("{yijianlan:"):void 0)>-1||(null!=t?t.indexOf('{"yijianlan":'):void 0)>-1||(null!=t?t.indexOf("{'yijianlan':"):void 0)>-1},InstanceSignText.includesOpinionField=function(t,e){var n,a,o;return a=new Array,n={},(o=(null!=(n=Meteor.isServer?uuflowManager.getFormVersion(db.forms.findOne({_id:t}),e):db.form_versions.findOne({_id:e,form:t}))?n.fields:void 0)||[]).forEach((function(t){var e;return"table"===t.type?console.log("ignore opinion field in table"):"section"===t.type?null!=t&&null!=(e=t.fields)?e.forEach((function(t){return a.push(t.formula)})):void 0:a.push(t.formula)})),_.some(a,(function(t){return InstanceformTemplate.helpers.isOpinionField_from_string(t)}))}},models:{"forms.coffee":function t(){var e=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{}},"flows.coffee":function t(){var e=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{}},"flow_roles.coffee":function t(){var e=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{}},"flow_positions.coffee":function t(){var e=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{}},"instance_tasks.coffee":function t(){var e=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};db.instance_tasks=new Meteor.Collection("instance_tasks"),db.instance_tasks._simpleSchema=new SimpleSchema({instance:{type:String},trace:{type:String},is_finished:{type:String},user:{type:String},user_name:{type:String},handler:{type:String},handler_name:{type:String},handler_organization:{type:String},handler_organization_name:{type:String},handler_organization_fullname:{type:String},start_date:{type:Date},due_date:{type:Date},is_read:{type:Boolean},is_error:{type:Boolean},values:{type:Object},deadline:{type:Date},remind_date:{type:Date},reminded_count:{type:Number},read_date:{type:Date},description:{type:String},modified:{type:Date},modified_by:{type:String},sign_show:{type:Boolean},judge:{type:String},next_steps:{type:Array},"next_steps.$":{type:Object},"next_steps.$.step":{type:String},"next_steps.$.users":{type:[String]},finish_date:{type:Date},cost_time:{type:Number},space:{type:String},instance_name:{type:String},submitter:{type:String},submitter_name:{type:String},applicant:{type:String},applicant_name:{type:String},applicant_organization_name:{type:String},submit_date:{type:Date},flow:{type:String},flow_name:{type:String},form:{type:String},step:{type:String},step_name:{type:String},category_name:{type:String},instance_state:{type:String},distribute_from_instance:{type:String},forward_from_instance:{type:String},keywords:{type:String},is_archived:{type:Boolean},category:{type:String}})},"instances.coffee":function t(){var e=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{}},"categories.coffee":function t(){var e=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{}},"spaces.coffee":function t(){var e=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{}},"deleted_instances.coffee":function t(){var e=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{}},"auth_tokens.coffee":function t(){var e=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};db.auth_tokens=new Meteor.Collection("auth_tokens")},"webhooks.coffee":function t(){var e=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{}},"space_user_signs.coffee":function t(){var e=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{}},"space_users.coffee":function t(){var e=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{}}},cfs:{"instances.coffee":function t(){var e=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{}}},"admin.coffee":function t(){var e=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{}}},client:{"api.js":function t(){Workflow.getInstance=function(){var t=WorkflowManager.getInstance();if(t){if("draft"==t.state){var e=InstanceManager.getInstanceFormApplicant();if(t.applicant!=e){var n=t.space,a=SteedosDataManager.spaceUserRemote.findOne({space:n,user:e},{fields:{organization:1,name:1}}),o=a.organization,r=SteedosDataManager.organizationRemote.findOne(o,{fields:{name:1,fullname:1}});t.applicant=e,t.applicant_name=a.name,t.applicant_organization=o,t.applicant_organization_name=r.name,t.applicant_organization_fullname=r.fullname}}return t}},Workflow.getMyApprove=function(){return InstanceManager.getMyApprove()},Workflow.getInstanceAttachments=function(t,e){return e?cfs.instances.find({"metadata.instance":t}).fetch():cfs.instances.find({"metadata.approve":e}).fetch()}},lib:{"traces_manager.coffee":function t(){var e=__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};TracesManager.getStepLastHandlers=function(t,e){var n,a,o;return n=[],o=_.clone(e.traces),(a=_.filter(o,(function(e){return e.step===t}))).reverse(),_.some(a,(function(t){var e;if(t.is_finished&&((e=(null!=t?t.approves:void 0)||[]).reverse(),e.forEach((function(t){if((null!=t?t.is_finished:void 0)&&"cc"!==(null!=t?t.type:void 0)&&"distribute"!==(null!=t?t.type:void 0)&&["approved","rejected","submitted","readed"].includes(t.judge))return n.push(t.handler)})),n.length>0))return!0})),n},TracesManager.getHandlerSignShowApproves=function(t,e,n){var a,o,r,s,i,l,c,u,d;if(a=InstanceManager.getCurrentApprove())return c=_.clone(t.traces),o=_.find(c,(function(t){return t._id===(null!=a?a.trace:void 0)})),i=[],o&&null!=(l=(u=_.groupBy(c,"step"))[o.step])&&l.forEach((function(t){return i=i.concat(t.approves)})),r=(d=_.groupBy(i,"handler"))[e],s=_.filter(r,(function(t){return n?t.is_finished&&!1!==t.sign_show&&t.description:t.is_finished&&t.description}))},TracesManager.getTracesListData=function(t){var e;return(null!=(e=db.instance_traces.findOne({_id:t._id}))?e.traces:void 0)||t.traces}},"instance_event.js":function module(){function getFlowEvent(t){var e=WorkflowManager.getFlow(t);if(e)return e.events}InstanceEvent={},InstanceEvent.before={},InstanceEvent.initEvents=function(flowId){$(".instance-form").unbind("instance-before-submit"),$(".instance-form").unbind("instance-before-save"),$("#ins_upload_main_attach").unbind("instance-before-upload"),$("#ins_attach_version").unbind("instance-before-upload"),$("#ins_upload_normal_attach").unbind("instance-before-upload"),$("#ins_attach_version").unbind("instance-before-upload"),$(".instance-forward-modal").unbind("onload"),$(".instance-distribute-modal").unbind("onload"),$("body").unbind("after-save");var eventStr=getFlowEvent(flowId);if(eventStr)try{eval(eventStr)}catch(e){toastr.error(TAPi18n.__("flows_events_error")+e),console.error("flow Event Error: "+e)}},InstanceEvent.run=function(t,e,n){var a=WorkflowManager.getInstance(),o;if(!a)return!0;if(!getFlowEvent(a.flow))return!0;n||(n={});var r=jQuery.Event(e,n);return t.trigger(r),!r.isDefaultPrevented()},InstanceEvent.before.instanceSubmit=function(){var t=WorkflowManager.getInstance(),e;if(!t)return!0;if(!getFlowEvent(t.flow))return!0;var n=jQuery.Event("instance-before-submit",{});return $(".instance-form").trigger(n),!n.isDefaultPrevented()}},"1_form_formula.js":function module(){function sum(t){var e=0;if(!t||0==t.length)return e;for(var n=0;n0?t.sort(sortNumber)[count(t)-1]:void 0}function min(t){if(!t||0==t.length)return"";for(var e=0;e0?t.sort(sortNumber)[0]:void 0}function numToRMB(t){if(isNaN(t))return"无效数值!";var e="";if(t<0&&(e="(负)"),(t=Math.abs(t))>=1e12)return"无效数值!";var n="",a="仟佰拾亿仟佰拾万仟佰拾元角分",o="零壹贰叁肆伍陆柒捌玖",r=(t+="00").indexOf(".");r>=0&&(t=t.substring(0,r)+t.substr(r+1,2)),a=a.substr(a.length-t.length);for(var s=0;s0?eval(form_script):console.log("脚本为空, 退出运算程序")}catch(e){console.log("初始化表单脚本出错,错误信息: \n"+e)}},Form_formula.runFormScripts=function(formKey,eventName){try{form_version=WorkflowManager.getInstanceFormVersion(),form_script=form_version.form_script,form_script&&form_script.replace(/\n/g,"").replace(/\s/g,"").length>0?(CoreForm.form_OnLoad instanceof Function&&eval("CoreForm.form_OnLoad();"),CoreForm[formKey]&&CoreForm[formKey][eventName]instanceof Function&&eval("CoreForm."+formKey+"."+eventName+"();")):console.log("脚本为空, 退出运算程序")}catch(e){console.log("初始化表单脚本出错,错误信息: \n"+e)}},Form_formula.prependPrefixForFormula=function(t,e){var n=1*new Date,a=/(\{[^{}]*\})/g;return rev=e.replace(a,(function(e,n){return t+n.replace(/\{\s*/,'["').replace(/\s*\}/,'"]').replace(/\s*\.\s*/g,'"]["')}))},Form_formula.getFormulaFieldVariable=function(t,e){var n=1*new Date;if(e){for(var a=new Array,o=0;o0;){for(c=0;cn.length)for(var a,o=(a=e.split(n)).length-2;o>=0;o--){var r=e.search(n),s=e.charAt(r-1),i=e.charAt(r+n.length);if(null==s.match(/\w/)&&null==i.match(/\w/))return!0}var l="{"+t+".";if(e.length>l.length)for(var a,o=(a=e.split(l)).length-2;o>=0;o--){var r=e.search(l),s;if(null==(s=e.charAt(r-1)).match(/\w/))return!0}}return!1},Form_formula.mixin=function(t,e){for(var n in e)t[n]=e[n];return t},Form_formula.field_values=null,Form_formula.run=function(code,field_prefix,formula_fields,autoFormDoc,fields){var startTrack=1*new Date,run=!1;if(formula_fields&&!(formula_fields.length<1)){Form_formula.field_values,console.debug("消耗时间s0 :"+(1*new Date-startTrack)+"ms"),Form_formula.field_values=Form_formula.init_formula_values(fields,autoFormDoc),console.debug("消耗时间s1 :"+(1*new Date-startTrack)+"ms");for(var i=0;i==/g,">=").replace(/\<==/g,"<=").replace(/\======/g,"===").replace(/\====/g,"=="),conditionStr=Form_formula.prependPrefixForFormula("Form_formula.field_values",conditionStr);try{eval(conditionStr.replace(/[\r\n]+/g,"\\n"))&&next_steps.push(WorkflowManager.getInstanceStep(line.to_step))}catch(err){console.log("脚本["+conditionStr+"]执行异常:"+err.message)}}})),next_steps},Form_formula.runFormulaScript=function(script,fieldValues){Form_formula.field_values=fieldValues;var conditionStr=script.toString();conditionStr=conditionStr.replace(/\=/g,"==").replace(/\>==/g,">=").replace(/\<==/g,"<=").replace(/\======/g,"===").replace(/\====/g,"=="),conditionStr=Form_formula.prependPrefixForFormula("Form_formula.field_values",conditionStr);try{if(eval(conditionStr.replace(/[\r\n]+/g,"\\n")))return!0}catch(err){console.log("脚本["+conditionStr+"]执行异常:"+err.message)}return!1},Form_formula.init_formula_values=function(t,e){var n=Meteor.userId(),a=InstanceManager.getApplicantUserId(),o;return a?o=Formula_data.getInstanceValues(t,e,n,a,Session.get("spaceId")):{}},Array.prototype.getEach=function(t){for(var e=[],n=0;n0){for(var e="0.",n=0;n0&&(r=o.split("\n"));var s="editable"==n.permission?"editable":"readonly",i=n.is_multiselect;"odata"!=n.type&&n.formula&&(s="readonly");var l={};switch("master_detail"===a&&(a="lookup"),a){case"input":t.type=String,l.disabled="readonly"==s,null!=o&&o.length>0?l.type="typeahead":n.is_textarea?(l.type="coreform-textarea",l.rows=n.rows):l.type="text";break;case"section":t.type=String,l.disabled=!0,l.type="section";break;case"geolocation":t.type=String,l.disabled="readonly"==s,l.type="text";break;case"number":t.type=Number,l.disabled="readonly"==s,l.type="coreform-number",l.step=e(n.digits),n.is_percent&&(l.type="steedos-field",l.fieldType="percent",l.config=JSON.stringify({scale:n.digits||2}));break;case"date":t.type=String,l.disabled="readonly"==s,Steedos.isMobile()||Steedos.isPad()?l.type="date":(l.type="coreform-datepicker",l.outFormat="yyyy-MM-dd",l.dateTimePickerOptions={showClear:!0,format:"YYYY-MM-DD",locale:Session.get("steedos-locale"),widgetPositioning:{}});break;case"dateTime":t.type=Date,l.disabled="readonly"==s,Steedos.isMobile()||Steedos.isPad()?l.type="datetime-local":(l.type="bootstrap-datetimepicker",l.dateTimePickerOptions={showClear:!0,format:"YYYY-MM-DD HH:mm",locale:Session.get("steedos-locale"),keepOpen:!0,widgetPositioning:{}});break;case"checkbox":t.type=Boolean,l.disabled="readonly"==s,l.type="coreform-checkbox";break;case"select":i?(t.type=[String],l.multiple=!0):t.type=String,l.readonly="readonly"==s,l.type="select",l.disabled="readonly"==s;break;case"radio":t.type=[String],l.disabled="readonly"==s,l.type="coreform-radio";break;case"multiSelect":t.type=[String],l.disabled="readonly"==s,l.type="coreform-multiSelect";break;case"user":i?(t.type=[String],l.multiple=!0):t.type=String,l.disabled="readonly"==s,l.type="selectuser";break;case"email":t.type=String,l.type="steedosEmail",l.readonly="readonly"==s,l.disabled="readonly"==s;break;case"url":t.type=String,l.type="steedosUrl",l.readonly="readonly"==s,l.disabled="readonly"==s;break;case"group":i?(t.type=[String],l.multiple=!0):t.type=String,l.disabled="readonly"==s,l.type="selectorg";break;case"odata":i?(t.type=[Object],l.multiple=!0):t.type=Object,t.blackbox=!0,l.type="steedos-selectize",l.readonly="readonly"===s,l.disabled="readonly"===s,l.related_object=n.related_object,l.url=n.url,l.detail_url=n.detail_url,l.filters=n.filters,l.formula=n.formula,l.search_field=n.search_field;break;case"html":t.type=String,l.readonly="readonly"===s,l.disabled="readonly"===s,l.type="steedosHtml";break;case"image":i?(t.type=[String],l.multiple=!0):t.type=String,l.readonly="readonly"==s,l.disabled="readonly"==s,l.type="steedos-field",l.fieldType="image";break;case"file":i?(t.type=[String],l.multiple=!0):t.type=String,l.readonly="readonly"==s,l.disabled="readonly"==s,l.type="steedos-field",l.fieldType="file";break;case"lookup":i?(t.type=[String],l.multiple=!0):t.type=String,l.readonly="readonly"==s,l.disabled="readonly"==s,l.type="steedos-field",l.fieldType="lookup",l.reference_to=n.reference_to,l.reference_to_field=n.reference_to_field,l.filters=n.filters,l.config=n.config;break;case"time":t.type=String,l.readonly="readonly"==s,l.disabled="readonly"==s,l.type="steedos-field",l.fieldType="time";break;default:t.type=String,l.readonly="readonly"==s,l.disabled="readonly"==s,l.type=a}if(null!=r&&r.length>0){for(var c=new Array,u=0;u1?itemSplits[0]:r[u],value:itemSplits.length>1?itemSplits[1]:r[u]});l.options=c}return l},a=function(t,e){var a=e.type,o=e.is_required;return(schema={}).label=t,schema.optional="readonly"==e.permission||!o,"email"==a?schema.regEx=SimpleSchema.RegEx.Email:"url"==a&&(schema.regEx=SimpleSchema.RegEx.Url),schema.autoform=new n(schema,e),0==schema.autoform.disabled&&((!e.default_value||_.isString(e.default_value)&&e.default_value.indexOf("auto_number(")<0)&&(schema.autoform.defaultValue=e.default_value),(InstanceMacro.check(e.default_value)||_.isFunction(e.default_value))&&(schema.autoform.defaultValue=InstanceMacro.run(e.default_value)),e.default_value&&_.isString(e.default_value)&&e.default_value.indexOf("auto_number(")>-1&&(schema.autoform["data-new-number"]=!0,schema.autoform["data-formula"]=e.default_value,schema.autoform.defaultValue="")),"section"===a&&(schema.autoform.description=e.description,schema.autoform.label=e.name),schema.autoform.title=e.description||schema.label,schema};(WorkflowManager_format={}).getTableItemSchema=function(t){var e={};if("table"==t.type){var n=null!=t.name&&t.name.length>0?t.name:t.code;e[t.code]={type:Object,optional:"readonly"==t.permission||!t.is_required,label:n},t.sfields.forEach((function(o){n=null!=o.name&&o.name.length>0?o.name:o.code,(sfields_schema=new a(n,o)).autoform.__formId=t.__formId,e[t.code+"."+o.code]=sfields_schema}))}return console.log("getTableItemSchema fieldSchema",e),e},WorkflowManager_format.getAutoformSchema=function(t){for(var e={},n=t.fields,o=ApproveManager.isReadOnly(),r=0;r0?s.name:s.code;if(o&&(s.permission="readonly"),"table"==s.type){let t=!1,n=s.sfields;if(n)for(let e=0;e0?c.name:c.code,tableField_schema=new a(i,c),e[s.code+".$."+c.code]=tableField_schema}}else e[s.code]=new a(i,s)}return e},WorkflowManager_format.getAutoformSchemaValues=function(){var t=InstanceManager.getCurrentValues();return t||(t={}),t}},"approve_manager.js":function e(n,a,e){let o;e.link("@babel/runtime/helpers/objectSpread2",{default(t){o=t}},0),(ApproveManager={}).error={nextSteps:"",nextStepUsers:""},ApproveManager.isReadOnly=function(){var t=WorkflowManager.getInstance();if(InstanceManager.isCC(t)&&!InstanceManager.ccHasEditPermission())return!0;if(Session.get("instancePrint"))return!0;if(!t)return!0;var e=db.flows.findOne(t.flow);return!e||("completed"==t.state||("draft"!=Session.get("box")||"enabled"!=e.state)&&"inbox"!=Session.get("box"))};var r=function(t,e){return _.contains(t.skip_steps,e._id)};ApproveManager.getNextSteps=function(t,e,n,a,o,s){if(ApproveManager.error.nextSteps="",!e)return;if(!t)return[];var i=new Array,l=e.lines;switch(e.step_type){case"condition":(i=Form_formula.getNextStepsFromCondition(e,a,o)).length||(ApproveManager.error.nextSteps="未能根据条件找到下一步");break;case"end":return i;case"sign":if("approved"==n)l.forEach((function(t){"approved"==t.state&&i.push(WorkflowManager.getInstanceStep(t.to_step))}));else if("rejected"==n){var c;l.forEach((function(t){if("rejected"==t.state){var e=WorkflowManager.getInstanceStep(t.to_step);e&&"condition"!=e.step_type&&i.push(e)}})),(c=t.traces).forEach((function(t){if(1==t.is_finished){var n=WorkflowManager.getInstanceStep(t.step);"condition"!=n.step_type&&e.id!=n.id&&i.push(n)}}));var u,d=(u=WorkflowManager.getInstanceSteps()).findPropertyByPK("step_type","end");i.push(d)}break;default:if("counterSign"===e.step_type&&e.oneClickRejection&&"rejected"===n){var c;l.forEach((function(t){if("rejected"==t.state){var e=WorkflowManager.getInstanceStep(t.to_step);e&&"condition"!=e.step_type&&i.push(e)}})),(c=t.traces).forEach((function(t){if(1==t.is_finished){var n=WorkflowManager.getInstanceStep(t.step);"condition"!=n.step_type&&e.id!=n.id&&i.push(n)}}));var u,d=(u=WorkflowManager.getInstanceSteps()).findPropertyByPK("step_type","end");i.push(d)}else l.forEach((function(t){if("submitted"==t.state){var e=WorkflowManager.getInstanceStep(t.to_step);e&&i.push(e)}}))}i=i.uniqById();var p=new Array;i.forEach((function(e){"condition"==e.step_type&&(n||"sign"!=e.step_type||(n="approved"),p=p.concat(ApproveManager.getNextSteps(t,e,n,a,o,s)))})),i=i.concat(p);var f=new Array;i.forEach((function(i){if("condition"!=i.step_type)if(!s&&r(t,i)){n||"sign"!=i.step_type||(n="approved");let r=ApproveManager.getNextSteps(t,i,n,a,o,s),l=[];for(const t of r)e.id!=t.id&&l.push(t);f=f.concat(l)}else f.push(i)})),f=f.uniqById(),"counterSign"==e.step_type&&f.length>1&&!e.oneClickRejection&&(f=[]);const m={},b={};for(const r of f)ApproveManager.caculateNextStepsByEnterStepCondition(t,r,a,o,m,b);if(!_.isEmpty(m)&&!_.isEmpty(b)){for(const t in b)if(Object.hasOwnProperty.call(b,t)){const e=f.findIndex(e=>e.id==t);-1===e&&f.push(b[t])}for(const t in m)if(Object.hasOwnProperty.call(m,t)){const e=f.findIndex(e=>e.id==t);-1!=e&&f.splice(e,1)}var g=new Array;f.forEach((function(e,r){"condition"==e.step_type&&(n||"sign"!=e.step_type||(n="approved"),g=g.concat(ApproveManager.getNextSteps(t,e,n,a,o,s)),f.splice(r,1))})),f=(f=f.concat(g)).uniqById()}return f},ApproveManager.caculateNextStepsByEnterStepCondition=function(t,e,n,a){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};if(!1===e.always_enter_step){const i=e.id,l=ApproveManager.getStepApproveUsers(t,i),c=t.space,u=[];l.forEach(t=>{u.push(Formula_data.getUser(c,t.id))});let d=e.enter_step_condition;const p=Form_formula.init_formula_values(a,n);let f;if(p.step=o({},e,{approvers:u}),!1===Form_formula.runFormulaScript(d,p)){if(r[e.id]=e,e.lines&&e.lines.length>0){const o=e.lines.map((function(t){return t.to_step}));for(const e of o){const o=WorkflowManager.getInstanceStep(e);o&&ApproveManager.caculateNextStepsByEnterStepCondition(t,o,n,a,r,s)}}}else s[e.id]=e}else s[e.id]=e},ApproveManager.getStepApproveUsers=function(e,n){var a=new Array,o=WorkflowManager.getInstanceStep(n);if(o){var r=InstanceManager.getApplicantUserId();switch(o.step_type){case"condition":break;case"start":var s=WorkflowManager.getUser(r);a.push(s);break;default:if(a=[],_.isEmpty(a))switch(o.deal_type){case"pickupAtRuntime":a=[];break;case"specifyUser":var i,l={specifyUserIds:o.approver_users};a=UUflow_api.caculate_nextstep_users("specifyUser",Session.get("spaceId"),l,n);break;case"applicantRole":var c,l={applicantId:r,approveRoleIds:o.approver_roles};(a=UUflow_api.caculate_nextstep_users("applicantRole",Session.get("spaceId"),l,n)).length||console.error("not find step",n,a);break;case"hrRole":var u,l={approveHrRoleIds:o.approver_hr_roles};(a=UUflow_api.caculate_nextstep_users("hrRole",Session.get("spaceId"),l,n)).length||console.error("not find step approve users",n,a);break;case"applicantSuperior":var l={applicantId:r};(a=UUflow_api.caculate_nextstep_users("applicantSuperior",Session.get("spaceId"),l,n))&&0!=a.length||console.error(TAPi18n.__("next_step_users_not_found.aplicant_superior"));break;case"applicant":var l={applicantId:r};a=UUflow_api.caculate_nextstep_users("applicant",Session.get("spaceId"),l,n);break;case"userField":var d=o.approver_user_field,p,f;if(p=InstanceManager.getFormField(d))if(f=InstanceManager.getFormFieldValue(p.code)){var l={userField:p,userFieldValue:f};a=UUflow_api.caculate_nextstep_users("userField",Session.get("spaceId"),l,n)}a.length||console.error("步骤: "+o.name+"fieldId is "+d);break;case"orgField":var m=o.approver_org_field,b=InstanceManager.getFormField(m),g=new Array;if(b){var h=InstanceManager.getFormFieldValue(b.code),w=new Array;if(h)var l={orgField:b,orgFieldValue:h};if(h){var l={orgField:b,orgFieldValue:h};a=(caculateNextstepUsers=UUflow_api.caculateNextstepUsers("orgField",Session.get("spaceId"),l,n)).nextStepUsers,caculateNextstepUsers.error&&console.error("caculateNextstepUsers.error",caculateNextstepUsers.error)}}a.length||(g.length?console.error(t("next_step_users_not_found.org_no_members",b.code)):console.error(t("next_step_users_not_found.field_value_empty")));break;case"specifyOrg":var S=o.approver_orgs,l={specifyOrgIds:S};if(!(a=UUflow_api.caculate_nextstep_users("specifyOrg",Session.get("spaceId"),l,n)).length){var v=WorkflowManager.getOrganizations(S),k=WorkflowManager.getOrganizationsChildrens(e.space,S);console.error(TAPi18n.__("next_step_users_not_found.org_no_members",{step_name:o.name,org_name:v.concat(k).getProperty("fullname").toString()}))}break;case"userFieldRole":var T=o.approver_roles,d=o.approver_user_field,p,f;if(p=InstanceManager.getFormField(d)){if(f=InstanceManager.getFormFieldValue(p.code))var l={userField:p,userFieldValue:f,approverRoleIds:T};if(f){var l={userField:p,userFieldValue:f,approverRoleIds:T};a=(caculateNextstepUsers=UUflow_api.caculateNextstepUsers("userFieldRole",Session.get("spaceId"),l,n)).nextStepUsers,caculateNextstepUsers.error&&console.error("caculateNextstepUsers.error",caculateNextstepUsers.error)}}if(!a.length)if(f){var M=WorkflowManager.getRoles(T);console.error('"'+M.getProperty("name").toString()+'"审批岗位未指定审批人')}else console.error('"'+p.code+'"字段没有值');break;case"orgFieldRole":var T=o.approver_roles,m=o.approver_org_field,b,h;if(b=InstanceManager.getFormField(m)){if(h=InstanceManager.getFormFieldValue(b.code))var l={orgField:b,orgFieldValue:h,approverRoleIds:T};if(h){var l={orgField:b,orgFieldValue:h,approverRoleIds:T};a=(caculateNextstepUsers=UUflow_api.caculateNextstepUsers("orgFieldRole",Session.get("spaceId"),l,n)).nextStepUsers,caculateNextstepUsers.error&&console.error("caculateNextstepUsers.error",caculateNextstepUsers.error)}}if(a<1)if(h){var M=WorkflowManager.getRoles(T);console.error('"'+M.getProperty("name").toString()+'"审批岗位未指定审批人')}else console.error('"'+b.code+'"字段没有值')}}return(a=a.uniqById()).sort((function(t,e){return t.name.localeCompare(e.name)})),a}},ApproveManager.getNextStepUsers=function(e,n,a){ApproveManager.error.nextStepUsers="",ApproveManager.error.type="",ApproveManager.error.code="",InstanceManager._setError_next_step_users("");var o=new Array,r=WorkflowManager.getInstanceStep(n);if(r){if(e.step_approve&&e.step_approve[n]){Session.set("next_step_users_showOrg",!1);var s=e.step_approve[n],i,l;if(_.isArray(s)||(s=[s]),i=InstanceManager.getCurrentApprove())(l=i.next_steps)&&l.length>0&&l[0].step==n&&"start"!=InstanceManager.getCurrentStep().step_type&&(s=_.uniq((l[0].users||[]).concat(s)));return WorkflowManager.getUsers(s)}var c=InstanceManager.getApplicantUserId();Session.set("next_step_users_showOrg",!1);var u="",d=r.name,p={};switch(r.step_type){case"condition":break;case"start":var f=WorkflowManager.getUser(c);o.push(f);break;default:if(o=[],_.isEmpty(o))switch(r.deal_type){case"pickupAtRuntime":var i;if(Session.set("next_step_users_showOrg",!0),!(i=InstanceManager.getCurrentApprove()))break;var l,m=(l=i.next_steps)&&l[0]?l[0].users:[];_.isEmpty(m)||(o=WorkflowManager.getUsers(m));break;case"specifyUser":var b,g={specifyUserIds:r.approver_users};o=UUflow_api.caculate_nextstep_users("specifyUser",Session.get("spaceId"),g,n);break;case"applicantRole":var h=r.approver_roles,g={applicantId:c,approveRoleIds:h};if(!(o=UUflow_api.caculate_nextstep_users("applicantRole",Session.get("spaceId"),g,n)).length){var w=WorkflowManager.remoteFlowRoles.find({_id:{$in:h}},{fields:{name:1}}),S=_.pluck(w,"name").toString();ApproveManager.error.nextStepUsers=TAPi18n.__("next_step_users_not_found.applicant_role",{step_name:r.name,role_name:S})}break;case"hrRole":var v=r.approver_hr_roles,g={approveHrRoleIds:v};if(!(o=UUflow_api.caculate_nextstep_users("hrRole",Session.get("spaceId"),g,n)).length){var w=WorkflowManager.remoteHrRoles.find({_id:{$in:v}},{fields:{name:1}}),k=_.pluck(w,"name").toString();ApproveManager.error.nextStepUsers=TAPi18n.__("next_step_users_not_found.hr_role",{step_name:r.name,role_name:k})}break;case"applicantSuperior":var g={applicantId:c};(o=UUflow_api.caculate_nextstep_users("applicantSuperior",Session.get("spaceId"),g,n))&&0!=o.length||(ApproveManager.error.nextStepUsers=TAPi18n.__("next_step_users_not_found.aplicant_superior"));break;case"applicant":var g={applicantId:c};o=UUflow_api.caculate_nextstep_users("applicant",Session.get("spaceId"),g,n);break;case"userField":var T=r.approver_user_field,M;if(M=InstanceManager.getFormField(T)){var y=null;if(y="relocate"==a?M.is_multiselect?lodash.map(e.values[M.code],"id"):lodash.get(e.values[M.code],"id"):InstanceManager.getFormFieldValue(M.code)){console.log("if ....");var g={userField:M,userFieldValue:y};o=UUflow_api.caculate_nextstep_users("userField",Session.get("spaceId"),g,n)}}o.length||(ApproveManager.error.nextStepUsers='"'+M.code+'"字段没有值',console.error("步骤: "+r.name+"fieldId is "+T));break;case"orgField":var I=r.approver_org_field,x=InstanceManager.getFormField(I),L=new Array;if(x){var H=InstanceManager.getFormFieldValue(x.code),A=new Array;if(H)var g={orgField:x,orgFieldValue:H};if(H){var g={orgField:x,orgFieldValue:H};o=(caculateNextstepUsers=UUflow_api.caculateNextstepUsers("orgField",Session.get("spaceId"),g,n)).nextStepUsers,ApproveManager.error.code=caculateNextstepUsers.error}}o.length||(L.length?ApproveManager.error.nextStepUsers=t("next_step_users_not_found.org_no_members",x.code):ApproveManager.error.nextStepUsers=t("next_step_users_not_found.field_value_empty"));break;case"specifyOrg":var B=r.approver_orgs,g={specifyOrgIds:B};if(!(o=UUflow_api.caculate_nextstep_users("specifyOrg",Session.get("spaceId"),g,n)).length){var C=WorkflowManager.getOrganizations(B),V=WorkflowManager.getOrganizationsChildrens(e.space,B);ApproveManager.error.nextStepUsers=TAPi18n.__("next_step_users_not_found.org_no_members",{step_name:r.name,org_name:C.concat(V).getProperty("fullname").toString()})}break;case"userFieldRole":var z=r.approver_roles,T=r.approver_user_field,M,y;if(M=InstanceManager.getFormField(T)){if(y=InstanceManager.getFormFieldValue(M.code))var g={userField:M,userFieldValue:y,approverRoleIds:z};if(y){var g={userField:M,userFieldValue:y,approverRoleIds:z};o=(caculateNextstepUsers=UUflow_api.caculateNextstepUsers("userFieldRole",Session.get("spaceId"),g,n)).nextStepUsers,ApproveManager.error.code=caculateNextstepUsers.error}}if(!o.length)if(y){var D=WorkflowManager.getRoles(z);ApproveManager.error.nextStepUsers='"'+D.getProperty("name").toString()+'"审批岗位未指定审批人'}else ApproveManager.error.nextStepUsers='"'+M.code+'"字段没有值';break;case"orgFieldRole":var z=r.approver_roles,I=r.approver_org_field,x,H;if(x=InstanceManager.getFormField(I)){if(H=InstanceManager.getFormFieldValue(x.code))var g={orgField:x,orgFieldValue:H,approverRoleIds:z};if(H){var g={orgField:x,orgFieldValue:H,approverRoleIds:z};o=(caculateNextstepUsers=UUflow_api.caculateNextstepUsers("orgFieldRole",Session.get("spaceId"),g,n)).nextStepUsers,ApproveManager.error.code=caculateNextstepUsers.error}}if(o<1)if(H){var D=WorkflowManager.getRoles(z);ApproveManager.error.nextStepUsers='"'+D.getProperty("name").toString()+'"审批岗位未指定审批人'}else ApproveManager.error.nextStepUsers='"'+x.code+'"字段没有值'}}return(o=o.uniqById()).sort((function(t,e){return t.name.localeCompare(e.name)})),ApproveManager.error.nextStepUsers&&(ApproveManager.error.type=r.deal_type),InstanceManager.handleErrorMessage(),o}},ApproveManager.getNextStepsSelectValue=function(){return $("[name=instance_suggestion_next_step]:checked").val()},ApproveManager.getNextStepUsersSelectValue=function(){var t=$("input[name='nextStepUsers']")[0].dataset.values;return t?t.split(","):[]},ApproveManager.checkAndSetCounterSignNextStepUsers=function(t){var e=new Array,n=InstanceManager.getCurrentStep();if(n&&"counterSign"==n.step_type){var a=WorkflowManager.getInstance(),o=TracesManager.getStepLastHandlers(t,a);e=WorkflowManager.getUsers(o)}return e},ApproveManager.getRelatedInstancesFromDescription=function(t){var e=new Array,n;t&&t.split(")").forEach((function(t){(foo2=t.indexOf(Meteor.absoluteUrl("workflow/space/")))>-1&&(foo3=t.substring(foo2,t.length),2==(foo4=foo3.split("/view/readonly/")).length&&e.push(foo4[1]))}));return e}},"instance_manager.js":function e(){function n(t,e){t.addClass("has-error"),$(".help-block",t).html(e),e&&e.length>0&&toastr.error(e)}function a(t,e){t.addClass("has-error"),$(".help-block",t).html(e)}function o(t){t.removeClass("has-error"),$(".help-block",t).html("")}function r(t,e){if(InstanceManager.isAmisForm()&&t.steedos_field)return e;if(!e&&0!=e)return e;var n;if(["number","multiSelect","radio","checkbox","dateTime","user","group"].includes(t.type))switch(t.type){case"number":case"multiSelect":case"radio":case"checkbox":e=e.toString();break;case"dateTime":e=e;break;case"group":e=CFDataManager.getFormulaOrganizations(e)||"";break;case"user":e=WorkflowManager.getFormulaUserObjects(e)||""}return e}(InstanceManager={}).runFormula=function(t){var e=WorkflowManager.getInstanceFormVersion(),n=[];e&&(n=Form_formula.getFormulaFieldVariable("Form_formula.field_values",e.fields));var a=AutoForm.getFormValues("instanceform",void 0,void 0,!1);Form_formula.run(t,"",n,a,e.fields),Session.set("instance_form_values",{instanceId:Session.get("instanceId"),values:a})},InstanceManager.isTableStyle=function(t){return!Steedos.isMobile()&&!(!(form=WorkflowManager.getForm(t))||"table"!=form.instance_style)},InstanceManager.getFormField=function(t){var e,n=WorkflowManager.getInstanceFields().filterProperty("_id",t);return n.length>0?n[0]:null},InstanceManager.getNextStepOptions=function(){if(ApproveManager.isReadOnly())return[];var t=WorkflowManager.getInstance(),e=InstanceManager.getCurrentApprove(),n;e&&(n=e.next_steps);var a=Session.get("judge"),o=InstanceManager.getCurrentStep(),r=WorkflowManager.getInstanceFormVersion(),s={},i=AutoForm.getFormValues("instanceform",void 0,void 0,!1);i?s=i:Session.get("instance_form_values")&&(s=Session.get("instance_form_values").values);var l=ApproveManager.getNextSteps(t,o,a,s,r&&r.fields),c=function(){return Session.get("next_step_id")},u=Tracker.nonreactive(c),d=[];if(l&&l.length>0){var p=u,f=null;l.forEach((function(t){var e={id:t.id,text:t.name,type:t.step_type};d.push(e)}));var m=_.find(d,(function(t){return t.id===u})),b=!_.isEmpty(m);if(1==d.length)d[0].selected="selected",p=d[0].id,Session.set("next_step_id",p);else if("rejected"!=Session.get("judge")||b){var g=$("[name=instance_suggestion_next_step]:checked"),h;if(g&&g.val()&&(h=d.findPropertyByPK("id",g.val())),_.isObject(h))p=g.val();else if(n&&n.length>0){var w=d.findPropertyByPK("id",n[0].step);_.isObject(w)&&(p=w.id,Session.set("next_step_id",p))}else"rejected"==Session.get("judge")||b||(p=o.lines[0].to_step,Session.set("next_step_id",p))}else start_option=d.findPropertyByPK("type","start"),p=start_option.id,Session.set("next_step_id",p);d.forEach((function(t){t.id==p&&(t.selected="selected",f=t.type)})),Session.set("next_step_multiple",!1),p&&("counterSign"==f?Session.set("next_user_multiple",!0):Session.set("next_user_multiple",!1))}else Session.set("next_step_id",null);return d},InstanceManager.nextStepUsersWillUpdate=function(t,e){"use strict";return!(!t||!e)&&("applicant"===t.name&&("applicant"===e.deal_type||"applicantRole"===e.deal_type||"applicantSuperior"===e.deal_type)||("user"===t.type&&t._id===e.approver_user_field&&("userField"===e.deal_type||"userFieldRole"===e.deal_type)||"group"===t.type&&t._id===e.approver_org_field&&("orgField"===e.deal_type||"orgFieldRole"===e.deal_type)))},InstanceManager.getStepApproveSelectedHandlerIds=function(){var t,e=WorkflowManager.getInstance();if(e){var n=e.step_approve;if(n){var a=InstanceManager.getCurrentStep();_.isEmpty(n[a._id])||(t=n[a._id])}}return t},InstanceManager.getNextUserOptions=function(){var t=[],e=Session.get("next_step_id"),n=Session.get("next_user_multiple"),a=InstanceManager.getStepApproveSelectedHandlerIds();if(e){var o=WorkflowManager.getInstance(),r=InstanceManager.getCurrentApprove();if(!r)return t;var s=r.next_steps,i=[],l=ApproveManager.getNextStepUsers(o,e),c=TracesManager.getStepLastHandlers(e,o);if(l){var u=WorkflowManager.getInstanceStep(e);0==l.length&&"pickupAtRuntime"==u.deal_type&&("counterSign"!=u.step_type?l=WorkflowManager.getUsers(c):a&&(l=a)),l.forEach((function(n){var o={id:n.id,name:n.name};s&&s.length>0?s[0].step==e&&_.contains(s[0].users,n.id)&&(o.selected=!0,i.push(n.id)):l.length>1&&("counterSign"!=u.step_type?c.includes(n.id)&&(o.selected=!0):a&&(o.selected=!0)),t.push(o)}))}}return t},InstanceManager.getFormFieldByCode=function(t){var e,n=WorkflowManager.getInstanceFields().filterProperty("code",t);return n.length>0?n[0]:null},InstanceManager.getApplicantUserId=function(){var t=WorkflowManager.getInstance();if(t){var e=$("#ins_applicant");return"draft"==t.state&&e&&1==e.length&&e[0]&&e[0].dataset.values?e[0].dataset.values:t.applicant}},InstanceManager.checkFormValue=async function(){if(ApproveManager.isReadOnly())return!0;if(!InstanceManager.isCC(WorkflowManager.getInstance())){if(InstanceManager.checkNextStep(),InstanceManager.checkNextStepUser(),InstanceManager.checkSuggestion(),InstanceManager.isAmisForm())return await SteedosUI.refs.instanceAmisView.getComponentById("instanceForm").validate();var t=WorkflowManager.getInstanceFieldPermission();for(var e in t)"editable"==t[e]&&InstanceManager.checkFormFieldValue($("[name='"+e+"']",$("#instanceform"))[0],e)}},InstanceManager.checkNextStep=function(){var t=$("[name=instance_suggestion_next_step]").closest(".form-group");if(""!=ApproveManager.error.nextSteps)return n(t,ApproveManager.error.nextSteps),void(ApproveManager.error.nextSteps="");var e=ApproveManager.getNextStepsSelectValue();e&&"-1"!=e?o(t):n(t,TAPi18n.__("instance_select_next_step"))},InstanceManager._setError_next_step_users=function(t,e,n){var a=$("input[name='nextStepUsers']");a.length>0&&(a[0].dataset.error=t,a[0].dataset.error_type=e,a[0].dataset.error_code=n)},InstanceManager.handleErrorMessage=function(){if(!($("input[name='nextStepUsers']").length<1)){var t=$("#nextStepUsers").closest(".form-group");return InstanceManager._setError_next_step_users("","",""),""!=ApproveManager.error.nextStepUsers?(t.addClass("has-error"),InstanceManager._setError_next_step_users(ApproveManager.error.nextStepUsers,ApproveManager.error.type,ApproveManager.error.code),void(ApproveManager.error.nextStepUsers="")):void 0}},InstanceManager.checkNextStepUser=function(){if(!($("input[name='nextStepUsers']").length<1)){var t=$("#nextStepUsers").closest(".form-group");if(!(t.length<1)){var e=ApproveManager.getNextStepUsersSelectValue(),a=ApproveManager.getNextStepsSelectValue(),r=WorkflowManager.getInstanceStep(a),s;if(e.length>0||r&&"end"==r.step_type)o(t);else"counterSign"==InstanceManager.getCurrentStep().step_type?n(t,TAPi18n.__("instance_next_step_user_countersign")):n(t,TAPi18n.__("instance_next_step_user"))}}},InstanceManager.nextStepUserErrorClass=function(){if(!($("input[name='nextStepUsers']").length<1)){var t=$("#nextStepUsers").closest(".form-group");if(!(t.length<1)){var e=ApproveManager.getNextStepUsersSelectValue(),n=ApproveManager.getNextStepsSelectValue(),r=WorkflowManager.getInstanceStep(n);e.length>0||r&&"end"==r.step_type?o(t):a(t,TAPi18n.__("instance_next_step_user"))}}},InstanceManager.checkSuggestion=function(t){var e=$("[name='judge']").filter(":checked").val(),r=$("#suggestion").parent();e&&"rejected"==e?$("#suggestion").val()?o(r):0==t?a(r,TAPi18n.__("instance_reasons_reject")):n(r,TAPi18n.__("instance_reasons_reject")):o(r)},InstanceManager.checkFormFieldValue=function(t,e,a){if(t){!t.name&&e&&(t.name=e);var r=/^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$/,s=$("#"+t.id).parent(),i="",l=$("[name='"+t.dataset.schemaKey+"']"),c=l.closest(".form-group");if(s.hasClass("twitter-typeahead")&&(s=s.parent().parent()),"table"!=l.attr("type")&&"true"==t.parentNode.dataset.required||("checkbox"==t.type||"radio"==t.type)&&"true"==t.parentNode.parentNode.parentNode.dataset.required||1==c.length&&"true"==c[0].dataset.required){var u="";if(!(u="checkbox"==t.type||"radio"==t.type?$("[name='"+t.name+"']:checked").val():t.value)&&e&&(u=a||InstanceManager.getInstanceValuesByAutoForm()[e]),!u||""==u||u.length<1){var d=InstanceManager.getFormFieldByCode(t.name),p=t.name;d&&(p=d.name?d.name:d.code),"rejected"!=Session.get("judge")&&(i=n(s,TAPi18n.__("instance_field")+"‘"+p+"’"+TAPi18n.__("instance_is_required")))}}if("table"==l.attr("type")&&"true"==t.parentNode.parentNode.parentNode.parentNode.dataset.required){var f=AutoForm.getFieldValue(t.dataset.schemaKey,"instanceform");s=l.parent().parent().parent().parent(),(!f||f.length<1)&&"rejected"!=Session.get("judge")&&(i=n(s,TAPi18n.__("instance_field")+"‘"+t.dataset.label+"’"+TAPi18n.__("instance_is_required")))}if("email"==t.type&&""!=t.value&&(r.test(t.value)||(i=TAPi18n.__("instance_email_format_error"))),"url"==t.type&&""!=t.value){var _=t.value,m;0!=t.value.indexOf("http")&&(_="http://"+encodeURI(_)),new URI(_).username()&&(i=TAPi18n.__("url_invalid"))}return""==i?(o(s),!0):(n(s,i),!1)}},InstanceManager.getFormFieldValue=function(t){if(InstanceManager.isAmisForm()){const e=InstanceManager.getInstanceFormValue()||{};return e[t]}return AutoForm.getFieldValue(t,"instanceform")},InstanceManager.getInstanceFormValue=function(){var t={};if(InstanceManager.isAmisForm()&&SteedosUI.refs.instanceAmisView)t=SteedosUI.refs.instanceAmisView.getComponentById("instanceForm")?SteedosUI.refs.instanceAmisView.getComponentById("instanceForm").props.data:SteedosUI.refs.instanceAmisView.parent.getComponentById("instanceForm").props.data;else{var e=AutoForm.getFormValues("instanceform");if(!e)return;t=_.extend(e.insertDoc,e.updateDoc.$unset);const n=WorkflowManager.getInstance();if(n&&"draft"==Session.get("box")&&"draft"!=n.state&&!t["文件标题"]&&("4c0acf34-aaa2-4834-a189-dd742e987382"==n.flow||"fd456ae72001cb119a7a9076"==n.flow)){const e=InstanceManager.getCurrentApprove();Sentry.captureMessage("申请单值丢失",{contexts:{flowId:n.flow,instanceId:n._id,userId:Meteor.userId(),box:Session.get("box"),currentApprove:e,autoFormValue:t,instanceValues:n.values},user:{id:Meteor.userId()},level:"error"})}}return t},InstanceManager.getInstanceValuesByAutoForm=function(){var t=WorkflowManager.getInstanceFields(),e=InstanceManager.getInstanceFormValue(),n={};return t.forEach((function(t){if("table"==t.type){if(t_values=new Array,t.sfields){if(!e[t.code])return void(n[t.code]=t_values);e[t.code].forEach((function(e){t.sfields.forEach((function(t){e[t.code]=r(t,e[t.code])})),t_values.push(e)}))}n[t.code]=t_values}else"section"!=t.type&&(n[t.code]=r(t,e[t.code]))})),n},InstanceManager.getCurrentStep=function(){var t=WorkflowManager.getInstance();if(t&&t.traces){var e,n=t.traces[t.traces.length-1].step;return WorkflowManager.getInstanceStep(n)}},InstanceManager.getCurrentTrace=function(){var t=WorkflowManager.getInstance();if(t&&t.traces)return t.traces[t.traces.length-1]},InstanceManager.getStartStep=function(){var t=WorkflowManager.getInstance();if(t&&t.traces)return WorkflowManager.getInstanceStep(t.traces[0].step)},InstanceManager.getCurrentValues=function(){var t=Session.get("box"),e,n,a=WorkflowManager.getInstance();if(InstanceManager.isCC(a))n=a.values;else if("draft"==t){if((e=InstanceManager.getCurrentApprove())&&e.values)return e.values}else if("inbox"==t){var o=InstanceManager.getCurrentStep();if(e=InstanceManager.getCurrentApprove(),o&&"counterSign"==o.step_type||InstanceManager.ccHasEditPermission())return e.values=InstanceManager.clone(a.values),e.values;if(e&&e.values)return _.isEmpty(e.values)&&(e.values=InstanceManager.clone(WorkflowManager.getInstance().values)),e.values}else n=a.values;return n},InstanceManager.clone=function(t){if(t)return JSON.parse(JSON.stringify(t))},InstanceManager.getCurrentApprove=function(){var t=WorkflowManager.getInstance();if(t&&t.traces&&!(t.traces.length<1)){var e=t.traces.filterProperty("is_finished",!1);if(e.length){var n=e[0].approves.filterProperty("is_finished",!1).filterProperty("handler",Meteor.userId()),a=n.length>0?n[0]:null;if(Session.get("instanceTaskId")){var o=_.find(n,t=>t._id===Session.get("instanceTaskId"));o&&(a=o)}}if(a&&"cc"!=a.type||(_.each(t.traces,(function(t){_.each(t.approves,(function(t){"cc"==t.type&&t.handler==Meteor.userId()&&0==t.is_finished&&(a=t)}))})),Session.get("instanceTaskId")&&_.each(t.traces,(function(t){_.each(t.approves,(function(t){t._id===Session.get("instanceTaskId")&&(a=t)}))}))),a)return a._id&&(a.id=a._id),a}},InstanceManager.getMyApprove=function(){var t=InstanceManager.getCurrentApprove();if(t){t.description=$("#suggestion").val();var e=$("[name='judge']").filter(":checked").val();e&&(t.judge=e);var n=ApproveManager.getNextStepsSelectValue();if(n){var a=ApproveManager.getNextStepUsersSelectValue(),o=new Array;a instanceof Array?a.forEach((function(t){o.push(t)})):a&&o.push(a),t.next_steps=[{step:n,users:o}]}return InstanceManager.isAmisForm()?t.values=InstanceManager.getInstanceFormValue():t.values=InstanceManager.getInstanceValuesByAutoForm(),t}return{}},InstanceManager.isAmisForm=function(){var t=WorkflowManager.getInstance();if(t){var e=db.flows.findOne({_id:t.flow},{fields:{enable_amisform:1}});return e&&e.enable_amisform}},InstanceManager.getInstanceFormApplicant=function(){var t;return InstanceManager.isAmisForm()?WorkflowManager.getInstance().applicant:$("input[name='ins_applicant']")[0].dataset.values},InstanceManager.setInstanceFormApplicant=function(t,e){$("input[name='ins_applicant']")[0].dataset.values=t,$("input[name='ins_applicant']").val(e)},InstanceManager.saveIns=function(t){t||$("body").addClass("loading");var e=WorkflowManager.getInstance(),n;if(e&&(n=InstanceManager.getInstanceValuesByAutoForm(),"draft"!=e.state&&InstanceManager.updateApproveSign("",$("#suggestion").val(),"update",InstanceSignText.helpers.getLastSignApprove()),InstanceManager.isCC(e))){var a=$("#suggestion").val(),o=InstanceManager.ccHasEditPermission(),r=InstanceManager.getMyApprove();Meteor.call("cc_save",e._id,a,r,o,(function(e,n){$("body").removeClass("loading"),!t&&e&&toastr.error(e),1==n&&(WorkflowManager.instanceModified.set(!1),t||toastr.success(TAPi18n.__("Saved successfully")))}))}else if(InstanceManager.getInstanceFormValue())if(e){var s=e.state;if("draft"==s){e.traces[0].approves[0]=InstanceManager.getMyApprove();var i=InstanceManager.getInstanceFormApplicant();if(e.applicant!=i){var l=e.space,c=SteedosDataManager.spaceUserRemote.findOne({space:l,user:i},{fields:{organization:1,name:1}}),u=c.organization,d=SteedosDataManager.organizationRemote.findOne(u,{fields:{name:1,fullname:1}});e.applicant=i,e.applicant_name=c.name,e.applicant_organization=u,e.applicant_organization_name=d.name,e.applicant_organization_fullname=d.fullname}Meteor.call("draft_save_instance",e,(function(e,n){$("body").removeClass("loading"),WorkflowManager.instanceModified.set(!1),1==n?t||toastr.success(TAPi18n.__("Saved successfully")):"upgraded"==n?(toastr.info(TAPi18n.__("Flow upgraded")),setTimeout((function(){FlowRouter.reload()}),2e3),console.log("upgraded")):(toastr.error(e.reason),FlowRouter.go("/workflow/space/"+Session.get("spaceId")+"/draft/"))}))}else if("pending"==s){var r;(r=InstanceManager.getMyApprove()).values=n,_.isEmpty(r)||_.isEmpty(r._id)?$("body").removeClass("loading"):Meteor.call("inbox_save_instance",r,(function(e,n){$("body").removeClass("loading"),WorkflowManager.instanceModified.set(!1),1==n?t||toastr.success(TAPi18n.__("Saved successfully")):(toastr.error(e.reason),FlowRouter.go("/workflow/space/"+Session.get("spaceId")+"/inbox/"))}))}}else $("body").removeClass("loading")},InstanceManager.newIns=function(t){UUflow_api.post_draft(t)},InstanceManager.deleteIns=function(){var t=WorkflowManager.getInstance();t&&UUflow_api.delete_draft(t._id)},InstanceManager.submitIns=function(){if(InstanceEvent.before.instanceSubmit()&&InstanceManager.isCCMustFinished()){var t=WorkflowManager.getInstance();if(t)if("draft"!=t.state&&InstanceManager.updateApproveSign("",$("#suggestion").val(),"update",InstanceSignText.helpers.getLastSignApprove()),InstanceManager.isCC(t)){if(Session.get("instance_submitting"))return;Session.set("instance_submitting",!0);var e=$("#suggestion").val(),n=InstanceManager.ccHasEditPermission(),a=InstanceManager.getMyApprove();$(document.body).addClass("loading"),Meteor.call("cc_submit",t._id,e,a,n,(function(t,e){$(document.body).removeClass("loading"),t&&(toastr.error(t),Session.set("instance_submitting",!1)),1==e&&(WorkflowManager.instanceModified.set(!1),toastr.success(TAPi18n.__("Submitted successfully")),Session.set("instance_submitting",!1),window.goBack(),Session.set("instanceId",null))}))}else{var o=t.state;if("draft"==o){var r=InstanceManager.getInstanceFormApplicant();if(t.applicant!=r){var s=t.space,i=SteedosDataManager.spaceUserRemote.findOne({space:s,user:r},{fields:{organization:1,name:1}}),l=i.organization,c=SteedosDataManager.organizationRemote.findOne(l,{fields:{name:1,fullname:1}});t.applicant=r,t.applicant_name=i.name,t.applicant_organization=l,t.applicant_organization_name=c.name,t.applicant_organization_fullname=c.fullname}t.traces[0].approves[0]=InstanceManager.getMyApprove(),UUflow_api.post_submit(t)}else if("pending"==o){var a;(a=InstanceManager.getMyApprove()).values=InstanceManager.getInstanceValuesByAutoForm(),UUflow_api.post_engine(a)}}}},InstanceManager.terminateIns=function(t){var e=WorkflowManager.getInstance();e&&UUflow_api.post_terminate({_id:e._id,terminate_reason:t})},InstanceManager.exportIns=function(t){spaceId=Session.get("spaceId"),flowId=Session.get("flowId"),spaceId&&flowId&&UUflow_api.get_export(spaceId,flowId,t)},InstanceManager.reassignIns=function(t,e){var n=WorkflowManager.getInstance();n&&(n.inbox_users=t,n.reassign_reason=e,UUflow_api.put_reassign(n))},InstanceManager.relocateIns=function(t,e,n){var a=WorkflowManager.getInstance();a&&UUflow_api.put_relocate({_id:a._id,relocate_next_step:t,relocate_inbox_users:e,relocate_comment:n})},InstanceManager.archiveIns=function(t){var e=WorkflowManager.getInstance();if(e){if(1==e.is_archived)return;UUflow_api.post_archive(t)}},InstanceManager.addAttach=function(t,e){var n=WorkflowManager.getInstance();if(n){var a=n.state,o=new Date,r=Meteor.userId(),s=t.name;s||(s=Session.get("filename"));var i=n.attachments||[],l=!1,c=Session.get("attach_id");if(i.forEach((function(n){if(n.filename==s||1==e&&n._id==c){l=!0;var a=n.historys;a instanceof Array||(a=[]);var i=InstanceManager.getMyApprove().id;n.current.approve!=i&&a.unshift(n.current),n.historys=a,n.current={_id:(new Mongo.ObjectID)._str,_rev:t._id,length:t.size,approve:i,created:o,created_by:r,created_by_name:Meteor.user().name,filename:s},n.filename=s}})),!l){var u={_id:(new Mongo.ObjectID)._str,filename:s,contentType:t.type,modified:o,modified_by:r,created:o,created_by:r,current:{_id:(new Mongo.ObjectID)._str,_rev:t._id,length:t.size,approve:InstanceManager.getMyApprove().id,created:o,created_by:r,created_by_name:Meteor.user().name,filename:s}};i?i.push(u):i=[u]}if(WorkflowManager.instanceModified.set(!0),"draft"==a)n.attachments=i,n.traces[0].approves[0]=InstanceManager.getMyApprove(),Meteor.call("draft_save_instance",n,(function(t,e){Session.set("change_date",new Date),WorkflowManager.instanceModified.set(!1),1==e?toastr.success(TAPi18n.__("Attachment was added successfully")):toastr.error(t)}));else if("pending"==a)if(InstanceManager.isCC(n))toastr.success(TAPi18n.__("Attachment was added successfully"));else{var d={};$.extend(d,InstanceManager.getMyApprove()),d.attachments=i,d.values=InstanceManager.getInstanceValuesByAutoForm(),Meteor.call("inbox_save_instance",d,(function(t,e){Session.set("change_date",new Date),WorkflowManager.instanceModified.set(!1),1==e?toastr.success(TAPi18n.__("Attachment was added successfully")):toastr.error(t)}))}}},InstanceManager.removeAttach=function(){var t=WorkflowManager.getInstance();if(t){var e=t.state,n=t.attachments,a=Session.get("file_id"),o=n.filter((function(t){if(t.current._rev!=a)return t;var e=t.historys;return e&&e.length>0?(t.current=t.historys.shift(),t.filename=t.current.filename,t):void 0}));if(WorkflowManager.instanceModified.set(!0),"draft"==e)t.attachments=o,t.traces[0].approves[0]=InstanceManager.getMyApprove(),Meteor.call("draft_save_instance",t,(function(t,e){Session.set("change_date",new Date),WorkflowManager.instanceModified.set(!1),1==e?toastr.success(TAPi18n.__("Attachment deleted successfully")):toastr.error(t)}));else if("pending"==e)if(InstanceManager.isCC(t))toastr.success(TAPi18n.__("Attachment deleted successfully"));else{t.attachments=o;var r={};$.extend(r,InstanceManager.getMyApprove()),r.attachments=o,r.values=InstanceManager.getInstanceValuesByAutoForm(),Meteor.call("inbox_save_instance",r,(function(t,e){Session.set("change_date",new Date),WorkflowManager.instanceModified.set(!1),1==e?toastr.success(TAPi18n.__("Attachment deleted successfully")):toastr.error(t)}))}}},InstanceManager.uploadAttach=function(e,n,a){var o,r;check(n,Boolean),check(a,Boolean),$(document.body).addClass("loading"),$(".loading-text").text(TAPi18n.__("workflow_attachment_uploading"));var s=100,i,l,c,u;for(Meteor.settings.public&&Meteor.settings.public.cfs&&Meteor.settings.public.cfs.size_limit&&(s=Meteor.settings.public.cfs.size_limit),o=1024*s*1024,r=t("workflow_attachment_paid_size_limit")+s+"MB",u=0;uo)return $("body").removeClass("loading"),$(".loading-text").text(""),void swal({title:r,type:"warning",confirmButtonText:t("OK"),closeOnConfirm:!0},(function(){$(document.body).removeClass("loading"),$(".loading-text").text("")}));l.name&&(c=l.name,["image.jpg","image.gif","image.jpeg","image.png"].includes(c.toLowerCase())&&(c="image-"+moment(new Date).format("YYYYMMDDHHmmss")+"."+c.split(".").pop()),Session.set("filename",c),$(".loading-text").text(TAPi18n.__("workflow_attachment_uploading")+c+"..."),(i=new FormData).append("Content-Type",cfs.getContentType(c)),i.append("file",l),i.append("instance",Session.get("instanceId")),i.append("space",Session.get("spaceId")),i.append("approve",InstanceManager.getMyApprove().id),i.append("owner",Meteor.userId()),i.append("owner_name",Meteor.user().name),i.append("is_private",l.is_private||!1),n&&(i.append("isAddVersion",n),i.append("parent",Session.get("attach_parent_id"))),a&&i.append("main",a),$.ajax({url:Steedos.absoluteUrl("api/v4/instances/s3/"),type:"POST",async:!0,data:i,dataType:"json",processData:!1,contentType:!1,beforeSend:function(t){t.setRequestHeader("Authorization","Bearer "+Session.get("spaceId")+","+Accounts._storedLoginToken())},success:function(t,e){var n;$(document.body).removeClass("loading"),$(".loading-text").text(""),t.errors?t.errors.forEach((function(t){toastr.error(t.errorMessage)})):toastr.success(TAPi18n.__("Attachment was added successfully"))},error:function(t,e,n){$(document.body).removeClass("loading"),$(".loading-text").text(""),toastr.error(e)}}),u++)}},InstanceManager.lockAttach=function(t){Meteor.call("cfs_instances_lock",t,Meteor.userId(),Meteor.user().name)},InstanceManager.isInbox=function(){var t=WorkflowManager.getInstance(),e=Meteor.userId();if(t&&e&&"inbox"==Session.get("box")){if(t.inbox_users&&t.inbox_users.includes(e))return!0;if(InstanceManager.isCC(t))return!0}return!1},InstanceManager.isCC=function(t){if(!t)return!1;var e=Meteor.userId(),n=InstanceManager.getCurrentApprove();return(!n||"cc"==n.type)&&!(!t.cc_users||!t.cc_users.includes(e))},InstanceManager.getCCApprove=function(t,e){var n=WorkflowManager.getInstance(),a=n.traces,o={};return a.forEach((function(n){n.approves&&n.approves.forEach((function(n){n.handler==t&&"cc"==n.type&&n.is_finished==e&&(o=n)}))})),Session.get("instanceTaskId")&&_.each(n.traces,(function(t){_.each(t.approves,(function(t){t._id===Session.get("instanceTaskId")&&(o=t)}))})),o},InstanceManager.unlockAttach=function(t){Meteor.call("cfs_instances_unlock",t)},InstanceManager.forwardIns=function(t,e,n,a,o,r,s,i,l){if(!Session.get("instance_submitting")){Session.set("instance_submitting",!0),$("body").addClass("loading");var c=WorkflowManager.getInstance(),u=null;InstanceManager.isInbox()&&"pending"==c.state?InstanceManager.getCurrentApprove()&&(u=InstanceManager.getCurrentApprove()._id):"outbox"==Session.get("box")&&"pending"==c.state&&InstanceManager.getLastCCApprove(c.traces)&&(u=InstanceManager.getLastCCApprove(c.traces)._id),Meteor.call("forward_instance",t,e,n,a,o,r,s,i,l,u,(function(t,e){$("body").removeClass("loading"),Session.set("instance_submitting",!1),t&&("no_permission"==t.error?"forward"==i?toastr.error(TAPi18n.__("instance_no_add_permission",{actiontype:TAPi18n.__("instance_forward_title"),usernames:t.details})):"distribute"==i&&toastr.error(TAPi18n.__("instance_no_add_permission",{actiontype:TAPi18n.__("instance_distribute_title"),usernames:t.details})):toastr.error(t.message)),_.isEmpty(e)||("forward"==i?toastr.success(TAPi18n.__("forward_instance_success")):"distribute"==i&&toastr.success(TAPi18n.__("instance_distribute_success")))}))}},InstanceManager.getUserInboxInstances=function(){var t={};return t.$or=[{inbox_users:Meteor.userId()},{cc_users:Meteor.userId()}],db.instances.find(t).fetch()},InstanceManager.retrieveIns=function(t){var e=WorkflowManager.getInstance();e&&(e.retrieve_comment=t,UUflow_api.post_retrieve(e))},InstanceManager.fixInstancePosition=function(t){if($(".instance-wrapper .instance-view").hasClass("suggestion-active")){var e=$(".instance-wrapper .instance-suggestion").height();$(".instance-wrapper .instance").css("bottom",e+2)}else $(".instance-wrapper .instance").css("bottom",0);t&&setTimeout((function(){$(".instance").scrollTop($(".instance .instance-form").height()+$(".instance-traces").height())}),1)},InstanceManager.setApproveHaveRead=function(t){var e=WorkflowManager.getInstance(),n=InstanceManager.getCurrentApprove();if(n&&!n.is_read)Meteor.call("set_approve_have_read",e._id,n.trace,n.id,(function(t,e){}));else{var a=InstanceManager.getCCApprove(Meteor.userId(),!1);_.isEmpty(a)||a.is_read||Meteor.call("cc_read",a,(function(t,e){console.log("set read")}))}},InstanceManager.instanceformChangeEvent=function(t){var e,n,a,o,r;if(!ApproveManager.isReadOnly()){if(e=t.target.name,"number"===(o=t.target.type)){r=t.target.value;try{r||(r=0),"string"==typeof r&&(r=parseFloat(r)),r=(a=t.target.step)?r.toFixed(a.length-2):r.toFixed(0),t.target.value=r}catch(l){n=l,console.log(r+n)}}if(InstanceManager.checkFormFieldValue(t.target),InstanceManager.runFormula(e),"ins_applicant"===e)Session.set("ins_applicant",InstanceManager.getApplicantUserId()),InstanceManager.nextStepUsersWillUpdate({name:"applicant"},WorkflowManager.getInstanceStep(Session.get("next_step_id")))&&Session.set("instance_next_user_recalculate",Random.id());else{var s,i=WorkflowManager.getInstanceFields().filterProperty("code",e);i.length>0&&InstanceManager.nextStepUsersWillUpdate(i[0],WorkflowManager.getInstanceStep(Session.get("next_step_id")))&&Session.set("instance_next_user_recalculate",Random.id())}}},InstanceManager.isCCMustFinished=function(){var t=InstanceManager.getCurrentStep();if(t&&1==t.cc_must_finished){var e=WorkflowManager.getInstance();if(e){var n=_.find(e.traces,(function(e){return e.step==t._id})),a=new Array,o=Meteor.userId();if(InstanceManager.isCC(e)?_.each(n.approves,(function(t){"cc"==t.type&&t.from_user==o&&1!=t.is_finished&&t.handler!=o&&a.push(t.handler_name)})):_.each(n.approves,(function(t){"cc"==t.type&&t.from_user==o&&1!=t.is_finished&&a.push(t.handler_name)})),!_.isEmpty(a))return toastr.error(TAPi18n.__("instance_cc_must_finished",{not_finished_users_name:a.toString()})),!1}}return!0},InstanceManager.getLastApprove=function(t){var e,n,a;for(a=Meteor.userId(),e=null,n=t.length-1;n>=0;)!e&&t[n].is_finished&&_.each(t[n].approves,(function(t){e||!t.is_finished||t.user!==a||t.type&&"reassign"!=t.type||!["approved","submitted","rejected"].includes(t.judge)||(e=t)})),n--;return e},InstanceManager.getLastTraceStepId=function(t){var e,n,a,o;for(o=Meteor.userId(),a=null,n=null,e=t.length-1;e>=0;)!a&&t[e].is_finished&&_.each(t[e].approves,(function(r){a||(!r.is_finished||r.user!==o||r.type&&"reassign"!=r.type||!["approved","submitted","rejected"].includes(r.judge)||(a=r.trace),a&&(n=t[e].step))})),e--;return n},InstanceManager.getLastCCTraceStepId=function(t){var e,n,a,o;for(o=Meteor.userId(),a=null,n=null,e=t.length-1;e>=0;)!a&&t[e].is_finished&&_.each(t[e].approves,(function(r){a||(!r.is_finished||r.user!==o||r.type&&"cc"!=r.type||!["approved","submitted","rejected"].includes(r.judge)||(a=r.trace),a&&(n=t[e].step))})),e--;return n},InstanceManager.getLastCCApprove=function(t){var e,n,a;for(a=Meteor.userId(),e=null,n=t.length-1;n>=0;)!e&&t[n].is_finished&&_.each(t[n].approves,(function(t){e||!t.is_finished||t.handler!==a||t.type&&"cc"!=t.type||!["approved","submitted","rejected"].includes(t.judge)||(e=t)})),n--;return e},InstanceManager.isAttachLocked=function(t,e){return!!cfs.instances.find({"metadata.instance":t,"metadata.current":!0,"metadata.locked_by":e}).count()},InstanceManager.getCCStep=function(){var t=InstanceManager.getCurrentApprove();if(!t)return!1;var e=WorkflowManager.getInstance(),n;if(!e)return!1;var a=_.find(e.traces,(function(e){return e._id==t.trace}));return a&&(n=WorkflowManager.getInstanceStep(a.step)),n},InstanceManager.updateApproveSign=function(t,e,n,a){!(myApprove=InstanceManager.getCurrentApprove())||1==myApprove.sign_show&&e||Meteor.call("update_approve_sign",myApprove.instance,myApprove.trace,myApprove._id,t,e,n||"update",a)},InstanceManager.getDistributeStep=function(){var t;if(InstanceManager.isInbox())t=InstanceManager.getCurrentStep();else if("outbox"==Session.get("box")){var e=WorkflowManager.getInstance();if(e&&"pending"==e.state){var n=InstanceManager.getLastTraceStepId(e.traces);n&&(t=WorkflowManager.getInstanceStep(n))}}return t};var s=function(t,e){var n=Session.get("instance_form_values");t||(t=InstanceManager.getStartStep()),e||(e=[]);var a=[],o="approved",r=WorkflowManager.getInstanceFormVersion(),i={},l=AutoForm.getFormValues("instanceform",void 0,void 0,!1);l?i=l:n&&(i=n.values),a.push(t);var c=ApproveManager.getNextSteps(WorkflowManager.getInstance(),t,o,i,r.fields,!0);return _.each(c,(function(t){_.contains(e,t._id)||(a=a.concat(s(t,e.concat(_.pluck(a,"_id")))))})),a=a.uniqById()};InstanceManager.pickApproveSteps=function(){return s()},InstanceManager.ccHasEditPermission=function(){var t=InstanceManager.getCCStep(),e=InstanceManager.getCurrentApprove();if(!e)return!1;var n=WorkflowManager.getInstance();if(!n)return!1;var a=_.find(n.traces,(function(t){return t._id==e.trace}));return t&&t.cc_has_edit_permission&&!a.is_finished},InstanceManager.getOpinionFieldsCode=function(){let t="",e=$("[name=opinion_fields_code]");if(e&&e.length>0){let n=0,a=e.length;for(;n0)return _.each(e.result,(function(t){t.alerts&&toastr.info(t.alerts)})),void(t.distribute_from_instance||t.distribute_from_instances.length>0?window.goBack():FlowRouter.go("/workflow/space/"+Session.get("spaceId")+"/draft/"));t.distribute_from_instance||t.distribute_from_instances.length>0?window.goBack():FlowRouter.go("/workflow/space/"+Session.get("spaceId")+"/"+Session.get("box")),toastr.success(TAPi18n.__("Submitted successfully")),Session.set("instance_submitting",!1);var a=SteedosUI.refs.serviceSteedosKeyvaluesSubscribe,o=a&&a.getComponentByName("serviceSteedosKeyvaluesSubscribe.buttonTriggerDataChange");o&&o.props.dispatchEvent("click",{})}},error:function(t,e,n){$(document.body).removeClass("loading"),toastr.error(e),Session.set("instance_submitting",!1)}})}},UUflow_api.post_engine=function(t){if(!Session.get("instance_submitting")){Session.set("instance_submitting",!0);var e={methodOverride:"POST"};e["X-User-Id"]=Meteor.userId(),e["X-Auth-Token"]=Accounts._storedLoginToken(),e.insId=t.instance;var n=Steedos.absoluteUrl()+"api/workflow/engine?"+$.param(e),a={Approvals:[t]};a=JSON.stringify(a),$(document.body).addClass("loading"),$.ajax({url:n,type:"POST",async:!0,data:a,dataType:"json",processData:!1,contentType:"application/json",beforeSend:function(t){t.setRequestHeader("Authorization","Bearer "+Session.get("spaceId")+","+Accounts._storedLoginToken())},success:function(t,e){$(document.body).removeClass("loading"),t.errors?t.errors.forEach((function(t){toastr.error(t.errorMessage)})):(Session.set("instance_change",!1),window.goBack(),toastr.success(TAPi18n.__("Submitted successfully")),Session.set("instance_submitting",!1))},error:function(t,e,n){$(document.body).removeClass("loading"),toastr.error(e),Session.set("instance_submitting",!1)}})}},UUflow_api.post_terminate=function(t){if(!Session.get("instance_submitting")){Session.set("instance_submitting",!0);var e={methodOverride:"POST"};e["X-User-Id"]=Meteor.userId(),e["X-Auth-Token"]=Accounts._storedLoginToken();var n=Steedos.absoluteUrl()+"api/workflow/terminate?"+$.param(e),a={Instances:[t]};a=JSON.stringify(a),$(document.body).addClass("loading"),$.ajax({url:n,type:"POST",async:!0,data:a,dataType:"json",processData:!1,contentType:"application/json",beforeSend:function(t){t.setRequestHeader("Authorization","Bearer "+Session.get("spaceId")+","+Accounts._storedLoginToken())},success:function(t,e){if($(document.body).removeClass("loading"),t.errors)t.errors.forEach((function(t){toastr.error(t.errorMessage)}));else{FlowRouter.go("/workflow/space/"+Session.get("spaceId")+"/"+Session.get("box")),toastr.success(TAPi18n.__("Canceled successfully")),Session.set("instance_submitting",!1);var n=SteedosUI.refs.serviceSteedosKeyvaluesSubscribe,a=n&&n.getComponentByName("serviceSteedosKeyvaluesSubscribe.buttonTriggerDataChange");a&&a.props.dispatchEvent("click",{})}},error:function(t,e,n){$(document.body).removeClass("loading"),toastr.error(e),Session.set("instance_submitting",!1)}})}},UUflow_api.put_reassign=function(t){if(!Session.get("instance_submitting")){Session.set("instance_submitting",!0);var e={methodOverride:"PUT"};e["X-User-Id"]=Meteor.userId(),e["X-Auth-Token"]=Accounts._storedLoginToken();var n=Steedos.absoluteUrl()+"api/workflow/reassign?"+$.param(e),a={Instances:[t]};a=JSON.stringify(a),$(document.body).addClass("loading"),$.ajax({url:n,type:"POST",async:!0,data:a,dataType:"json",processData:!1,contentType:"application/json",beforeSend:function(t){t.setRequestHeader("Authorization","Bearer "+Session.get("spaceId")+","+Accounts._storedLoginToken())},success:function(t,e){$(document.body).removeClass("loading"),t.errors?t.errors.forEach((function(t){toastr.error(t.errorMessage)})):(toastr.success(TAPi18n.__("Reasigned successfully")),Session.set("instance_submitting",!1))},error:function(t,e,n){$(document.body).removeClass("loading"),toastr.error(e),Session.set("instance_submitting",!1)}})}},UUflow_api.put_relocate=function(t){if(!Session.get("instance_submitting")){Session.set("instance_submitting",!0);var e={methodOverride:"PUT"};e["X-User-Id"]=Meteor.userId(),e["X-Auth-Token"]=Accounts._storedLoginToken();var n=Steedos.absoluteUrl()+"api/workflow/relocate?"+$.param(e),a={Instances:[t]};a=JSON.stringify(a),$(document.body).addClass("loading"),$.ajax({url:n,type:"POST",async:!0,data:a,dataType:"json",processData:!1,contentType:"application/json",beforeSend:function(t){t.setRequestHeader("Authorization","Bearer "+Session.get("spaceId")+","+Accounts._storedLoginToken())},success:function(t,e){$(document.body).removeClass("loading"),t.errors?t.errors.forEach((function(t){toastr.error(t.errorMessage)})):(toastr.success(TAPi18n.__("Relocated successfully")),Session.set("instance_submitting",!1))},error:function(t,e,n){$(document.body).removeClass("loading"),toastr.error(e),Session.set("instance_submitting",!1)}})}},UUflow_api.post_archive=function(t){var n={methodOverride:"POST"};n["X-User-Id"]=Meteor.userId(),n["X-Auth-Token"]=Accounts._storedLoginToken();var a=Steedos.absoluteUrl()+"api/workflow/archive?"+$.param(n),o={Instances:[{id:t}]};o=JSON.stringify(o),$(document.body).addClass("loading"),$.ajax({url:a,type:"POST",async:!0,data:o,dataType:"json",processData:!1,contentType:"application/json",beforeSend:e,success:function(t,e){$(document.body).removeClass("loading"),t.errors&&t.errors.forEach((function(t){toastr.error(t.errorMessage)}))},error:function(t,e,n){$(document.body).removeClass("loading"),toastr.error(e)}})},UUflow_api.get_export=function(t,e,n){var a={};a["X-User-Id"]=Meteor.userId(),a["X-Auth-Token"]=Accounts._storedLoginToken(),a.space_id=t,a.flow_id=e,a.timezoneoffset=(new Date).getTimezoneOffset(),a.type=n;var o=Steedos.absoluteUrl()+"api/workflow/export/instances?"+$.param(a);window.open(o,"_parent","EnableViewPortScale=yes")},UUflow_api.caculate_nextstep_users=function(t,e,n,a){var o={};o.deal_type=t,o.spaceId=e,o.insId=Session.get("instanceId"),o.nextStepId=a;var r=[],s=JSON.stringify(n);return $.ajax({url:Steedos.absoluteUrl("api/workflow/nextStepUsers")+"?"+$.param(o),type:"POST",async:!1,data:s,dataType:"json",processData:!1,contentType:"application/json",beforeSend:function(t){t.setRequestHeader("Authorization","Bearer "+e+","+Accounts._storedLoginToken())},success:function(t,e){t.errors?toastr.error(t.errors):r=t.nextStepUsers},error:function(t,e,n){toastr.error(e)}}),r},UUflow_api.caculateNextstepUsers=function(t,e,n,a){var o={};o.deal_type=t,o.spaceId=e,o.insId=Session.get("instanceId"),o.nextStepId=a;var r=[],s="",i=JSON.stringify(n);return $.ajax({url:Steedos.absoluteUrl("api/workflow/nextStepUsers")+"?"+$.param(o),type:"POST",async:!1,data:i,dataType:"json",processData:!1,contentType:"application/json",beforeSend:function(t){t.setRequestHeader("Authorization","Bearer "+e+","+Accounts._storedLoginToken())},success:function(t,e){t.errors?toastr.error(t.errors):(r=t.nextStepUsers,s=t.error)},error:function(t,e,n){toastr.error(e)}}),{nextStepUsers:r,error:s}},UUflow_api.getSpaceUsers=function(t,e){var n={};n.spaceId=t;var a={userIds:e},o;return a=JSON.stringify(a),$.ajax({url:Steedos.absoluteUrl("api/workflow/getSpaceUsers")+"?"+$.param(n),type:"POST",async:!1,data:a,dataType:"json",processData:!1,contentType:"application/json",beforeSend:function(e){e.setRequestHeader("Authorization","Bearer "+t+","+Accounts._storedLoginToken())},success:function(t,n){t.errors?toastr.error(t.errors):(_spaceUsers=t.spaceUsers,o=[],_.isArray(e)?_.each(e,(function(t){var e=_.find(_spaceUsers,(function(e){return e.id==t}));e&&o.push(e)})):o=_spaceUsers)},error:function(t,e,n){toastr.error(e)}}),o},UUflow_api.post_retrieve=function(t){if(!Session.get("instance_submitting")){Session.set("instance_submitting",!0);var n={methodOverride:"POST"};n["X-User-Id"]=Meteor.userId(),n["X-Auth-Token"]=Accounts._storedLoginToken();var a=Steedos.absoluteUrl()+"api/workflow/retrieve?"+$.param(n),o={Instances:[{_id:t._id,retrieve_comment:t.retrieve_comment}]};o=JSON.stringify(o),$(document.body).addClass("loading"),$.ajax({url:a,type:"POST",async:!0,data:o,dataType:"json",processData:!1,contentType:"application/json",beforeSend:e,success:function(t,e){$(document.body).removeClass("loading"),t.errors?t.errors.forEach((function(t){toastr.error(t.errorMessage)})):(FlowRouter.go("/workflow/space/"+Session.get("spaceId")+"/inbox"),toastr.success(TAPi18n.__("Retrieved successfully")),Session.set("instance_submitting",!1))},error:function(t,e,n){$(document.body).removeClass("loading"),toastr.error(e),Session.set("instance_submitting",!1)}})}},UUflow_api.getNameForUser=function(t){var n={},a={userId:t},o;return a=JSON.stringify(a),$.ajax({url:Steedos.absoluteUrl("api/workflow/getNameForUser")+"?"+$.param(n),type:"POST",async:!1,data:a,dataType:"json",processData:!1,contentType:"application/json",beforeSend:e,success:function(t,e){t.errors?toastr.error(t.errors):o=t.user},error:function(t,e,n){toastr.error(e)}}),o},UUflow_api.post_forward=function(t,n,a,o,r,s,i,l,c){if(!Session.get("instance_submitting")){Session.set("instance_submitting",!0),$("body").addClass("loading");var u=WorkflowManager.getInstance(),d=null;InstanceManager.isInbox()&&"pending"==u.state?InstanceManager.getCurrentApprove()&&(d=InstanceManager.getCurrentApprove()._id):"outbox"==Session.get("box")&&"pending"==u.state&&InstanceManager.getLastCCApprove(u.traces)&&(d=InstanceManager.getLastCCApprove(u.traces)._id);var p={methodOverride:"POST"};p["X-User-Id"]=Meteor.userId(),p["X-Auth-Token"]=Accounts._storedLoginToken();var f=Steedos.absoluteUrl()+"api/workflow/forward?"+$.param(p),_={instance_id:t,space_id:n,flow_id:a,hasSaveInstanceToAttachment:o,description:r,isForwardAttachments:s,selectedUsers:i,action_type:l,related:c,from_approve_id:d};_=JSON.stringify(_),$.ajax({url:f,type:"POST",async:!0,data:_,dataType:"json",processData:!1,contentType:"application/json",beforeSend:e,success:function(t,e){if(Session.set("instance_submitting",!1),$(document.body).removeClass("loading"),t.errors)t.errors.forEach((function(t){"no_permission"==t.error?"forward"==l?toastr.error(TAPi18n.__("instance_no_add_permission",{actiontype:TAPi18n.__("instance_forward_title"),usernames:t.details})):"distribute"==l&&toastr.error(TAPi18n.__("instance_no_add_permission",{actiontype:TAPi18n.__("instance_distribute_title"),usernames:t.details})):toastr.error(t.reason)}));else if("forward"==l){toastr.success(TAPi18n.__("forward_instance_success"));var n=t&&t.new_ins_ids&&t.new_ins_ids[0];if(n&&!Steedos.isMobile()){var a="/workflow/space/"+Steedos.getSpaceId()+"/inbox/"+n;a=Steedos.absoluteUrl(a),Steedos.openWindow(a)}}else"distribute"==l&&toastr.success(TAPi18n.__("instance_distribute_success"))},error:function(t,e,n){Session.set("instance_submitting",!1),$(document.body).removeClass("loading"),toastr.error(e)}})}},UUflow_api.getPDFData=function(t,e){$(document.body).addClass("loading");var n={attachmentId:t};n=JSON.stringify(n),$.ajax({url:Steedos.absoluteUrl("api/workflow/office_convert_to_pdf"),type:"POST",async:!0,data:n,dataType:"json",processData:!1,contentType:"application/json",success:function(n,a){n.errors?toastr.error(n.errors):($(document.body).removeClass("loading"),e(t,n.result.data))},error:function(t,e,n){$(document.body).removeClass("loading"),toastr.error(t.responseJSON.error)}})},UUflow_api.getContactInfoForUser=function(t,n){var a={userId:t,spaceId:n},o;return a=JSON.stringify(a),$.ajax({url:Steedos.absoluteUrl("api/workflow/getContactInfoForUser"),type:"POST",async:!1,data:a,dataType:"json",processData:!1,contentType:"application/json",beforeSend:e,success:function(t,e){t.errors?toastr.error(t.errors):o=t.user},error:function(t,e,n){toastr.error(e)}}),o}},"workflow_manager.js":function t(){WorkflowManager={instanceModified:new ReactiveVar(!1)},Meteor.isClient&&(WorkflowManager.remoteSpaceUsers=new AjaxCollection("space_users"),WorkflowManager.remoteOrganizations=new AjaxCollection("organizations"),WorkflowManager.remoteFlowRoles=new AjaxCollection("flow_roles"),WorkflowManager.remoteHrRoles=new AjaxCollection("roles")),WorkflowManager.getUrlForServiceName=function(t){var e;return{s3:"https://s3ws.steedos.com",workflow:"http://192.168.0.23"}[t]},WorkflowManager.getForm=function(t){return db.forms.findOne(t)},WorkflowManager.getFlow=function(t){return db.flows.findOne(t)},WorkflowManager.getSpaceOrganizations=function(t){var e=new Array,n;return db.organizations.find().forEach((function(t){t.id=t._id,e.push(t)})),e},WorkflowManager.getSpaceUsers=function(t){var e=new Array,n;return db.space_users.find({user_accepted:!0},{sort:{name:1}}).forEach((function(n){n.id=n.user,n.organization=WorkflowManager.getOrganization(n.organization),n.organization&&(n.roles=WorkflowManager.getUserRoles(t,n.organization.id,n.id),e.push(n))})),e},WorkflowManager.getSpacePositions=function(t){var e=new Array,n;return db.flow_positions.find().forEach((function(t){e.push(t)})),e},WorkflowManager.getSpaceRoles=function(t){var e=new Array,n;return db.flow_roles.find().forEach((function(t){t.id=t._id,e.push(t)})),e},WorkflowManager.getInstance=function(){return db.instances.findOne({_id:Session.get("instanceId")})},WorkflowManager.getInstanceFormVersion=function(){var t=[],e=null,n=WorkflowManager.getInstance();if(n){var e;if(!(e=db.form_versions.findOne({_id:n.form_version,form:n.form})))return;field_permission=WorkflowManager.getInstanceFieldPermission(),e.fields&&e.fields.forEach((function(e){e.permission="editable"==field_permission[e.code]?"editable":"readonly","table"==e.type&&(e.sfields=e.fields,e.sfields?(e.sfields.forEach((function(t){t.permission="editable"==field_permission[t.code]?"editable":"readonly"})),e.sfields.push({code:"_id",permission:"editable",type:"hidden",default_value:db.instances._makeNewID})):console.error("子表:"+e.code+" 没有字段"),delete e.fields),"section"==e.type?(t.push(e),e.fields&&e.fields.forEach((function(e){e.permission="editable"==field_permission[e.code]?"editable":"readonly",t.push(e)}))):t.push(e)})),e.fields=t}return e},WorkflowManager.getInstanceFlowVersion=function(){var t=WorkflowManager.getInstance();if(t)return db.flow_versions.findOne({_id:t.flow_version,flow:t.flow})},WorkflowManager.getInstanceFields=function(){var t;return WorkflowManager.getInstanceFormVersion().fields},WorkflowManager.getInstanceStep=function(t){var e=WorkflowManager.getInstanceFlowVersion(),n;return e?(e.steps.forEach((function(e){e._id!=t||((n=e).id=e._id)})),n):null},WorkflowManager.getInstanceSteps=function(){var t=WorkflowManager.getInstanceFlowVersion();if(!t)return null;var e=[];return t.steps.forEach((function(t){t.id=t._id,e.push(t)})),e},WorkflowManager.getInstanceFieldPermission=function(){var t=WorkflowManager.getInstance();if(!t)return{};if(InstanceManager.isCC(t)&&!InstanceManager.ccHasEditPermission())return{};var e="";t.traces&&t.traces.forEach((function(t){0!=t.is_finished||(e=t.step)}));var n=WorkflowManager.getInstanceStep(e);return n&&n.permissions||{}},WorkflowManager.getOrganizationChildrens=function(t,e){var n,a;return WorkflowManager.getSpaceOrganizations(t).filterProperty("parents",e)},WorkflowManager.getOrganizationsChildrens=function(t,e){var n=new Array;return e.forEach((function(e){n=n.concat(WorkflowManager.getOrganizationChildrens(t,e))})),n},WorkflowManager.getOrganizationsUsers=function(t,e){var n=WorkflowManager.getSpaceUsers(t),a=new Array;return e.forEach((function(t){a=a.concat(WorkflowManager.getUsers(t.users))})),a},WorkflowManager.getOrganization=function(t){if(t){var e=WorkflowManager.remoteOrganizations.findOne(t);if(e)return e.id=e._id,e}},WorkflowManager.getOrganizations=function(t){return t?"string"==typeof t?[WorkflowManager.getOrganization(t)]:WorkflowManager.remoteOrganizations.find({_id:{$in:t}}):[]},WorkflowManager.getRoles=function(t){if(!(t&&t instanceof Array))return[];var e=new Array;return t.forEach((function(t){e.push(WorkflowManager.getRole(t))})),e},WorkflowManager.getRole=function(t){if(t){var e=WorkflowManager.getSpaceRoles(),n={};return e.forEach((function(e){e.id!=t||(n=e)})),n}},WorkflowManager.getUser=function(t,e){if(t){if("string"!=typeof t)return WorkflowManager.getUsers(t,e);var n=UUflow_api.getSpaceUsers(e||Session.get("spaceId"),t);if(n){var a=n[0];if(a)return a}}},WorkflowManager.getUsers=function(t,e){if("string"==typeof t)return[WorkflowManager.getUser(t,e)];var n=new Array;return t&&(n=UUflow_api.getSpaceUsers(e||Session.get("spaceId"),t)),n},WorkflowManager.getUserRoles=function(t,e,n){var a=new Array,o,r;return WorkflowManager.getSpacePositions(t).filterProperty("users",n).forEach((function(t){a.push(WorkflowManager.getRole(t.role))})),a},WorkflowManager.getRoleUsersbyOrgAndRole=function(t,e,n){var a=new Array,o=WorkflowManager.getSpaceRoles(t),r,s,i=WorkflowManager.getSpacePositions(t).filterProperty("role",n).filterProperty("org",e);if(i.forEach((function(t){var e=t.users;a=a.concat(WorkflowManager.getUsers(e))})),0==i.length){var l=WorkflowManager.getOrganization(e);l&&""!=l.parent&&(a=a.concat(WorkflowManager.getRoleUsersbyOrgAndRole(t,l.parent,n)))}return a},WorkflowManager.getRoleUsersByOrgAndRoles=function(t,e,n){var a=new Array;return n.forEach((function(n){a=a.concat(WorkflowManager.getRoleUsersbyOrgAndRole(t,e,n))})),a},WorkflowManager.getRoleUsersByOrgsAndRoles=function(t,e,n){var a=new Array;return e&&n?(e.forEach((function(e){a=a.concat(WorkflowManager.getRoleUsersByOrgAndRoles(t,e,n))})),a):a},WorkflowManager.getRoleUsersByUsersAndRoles=function(t,e,n){var a=new Array,o;return e&&n?(WorkflowManager.getUsers(e).forEach((function(e){a=a.concat(WorkflowManager.getRoleUsersByOrgAndRoles(t,e.organization.id,n))})),a):a},WorkflowManager.getFormulaUserObjects=function(t){if(t)return CFDataManager.getFormulaSpaceUser(t)},WorkflowManager.getFormulaUserObject=function(t){return t instanceof Array?SteedosDataManager.getFormulaUserObjects(Session.get("spaceId"),t):SteedosDataManager.getFormulaUserObjects(Session.get("spaceId"),[t])[0]},WorkflowManager.getFormulaOrgObjects=function(t){if(t)return WorkflowManager.getFormulaOrgObject(t)},WorkflowManager.getFormulaOrgObject=function(t){if(t instanceof Array){var e=new Array,n;return WorkflowManager.getOrganizations(t).forEach((function(t){var n={};n.id=t._id,n.name=t.name,n.fullname=t.fullname,e.push(n)})),e}var a={},o=WorkflowManager.getOrganization(t);return o?(a.id=t,a.name=o.name,a.fullname=o.fullname,a):null},WorkflowManager.getSpaceCategories=function(t,e){var n={space:t};return _.isEmpty(e)||(n._id={$in:e}),db.categories.find(n,{sort:{sort_no:-1}}).fetch()},WorkflowManager.getCategoriesForms=function(t){return db.forms.find({category:t,state:"enabled"}).fetch()},WorkflowManager.getUnCategoriesForms=function(){return _.isEmpty(Session.get("workflow_categories"))?forms=db.forms.find({category:{$in:[null,""]},state:"enabled"}).fetch():[]},WorkflowManager.getFormFlows=function(t){return db.flows.find({form:t,state:"enabled"}).fetch()},WorkflowManager.getCompanyFlows=function(t,e){var n=e||Session.get("spaceId");return db.flows.find({space:n,company_id:t,state:"enabled"}).fetch()},WorkflowManager.getSpaceFlows=function(t){return db.flows.find({space:t}).fetch()},WorkflowManager.canAdd=function(t,e,n){var a=t.perms,o=!1;return a&&(a.users_can_add&&a.users_can_add.includes(Meteor.userId())?o=!0:a.orgs_can_add&&a.orgs_can_add.length>0&&(e&&e.organizations&&_.intersection(e.organizations,a.orgs_can_add).length>0?o=!0:n&&(o=_.some(n,(function(t){return t.parents&&_.intersection(t.parents,a.orgs_can_add).length>0}))))),o},WorkflowManager.canAdmin=function(t,e,n){var a=t.perms,o=!1;return a&&(a.users_can_admin&&a.users_can_admin.includes(Meteor.userId())?o=!0:a.orgs_can_admin&&a.orgs_can_admin.length>0&&(e&&e.organizations&&_.intersection(e.organizations,a.orgs_can_admin).length>0?o=!0:n&&(o=_.some(n,(function(t){return t.parents&&_.intersection(t.parents,a.orgs_can_admin).length>0}))))),o},WorkflowManager.canMonitor=function(t,e,n){var a=t.perms,o=!1;return a&&(a.users_can_monitor&&a.users_can_monitor.includes(Meteor.userId())?o=!0:a.orgs_can_monitor&&a.orgs_can_monitor.length>0&&(e&&e.organizations&&_.intersection(e.organizations,a.orgs_can_monitor).length>0?o=!0:n&&(o=_.some(n,(function(t){return t.parents&&_.intersection(t.parents,a.orgs_can_monitor).length>0}))))),o},WorkflowManager.getMyAdminOrMonitorFlows=function(){var t,e=[],n,a;return(n=db.space_users.findOne({space:Session.get("spaceId"),user:Meteor.userId()}))&&(organizations=db.organizations.find({_id:{$in:n.organizations}}).fetch(),(t=db.flows.find()).forEach((function(t){(WorkflowManager.canMonitor(t,n,organizations)||WorkflowManager.canAdmin(t,n,organizations))&&e.push(t._id)}))),e},WorkflowManager.getMyCanAddFlows=function(){var t,e=[],n,a;return n=db.space_users.findOne({space:Session.get("spaceId"),user:Meteor.userId()}),organizations=db.organizations.find({_id:{$in:n.organizations}}).fetch(),(t=db.flows.find()).forEach((function(t){WorkflowManager.canAdd(t,n,organizations)&&e.push(t._id)})),e},WorkflowManager.getCompanyFlowListData=function(t,e,n){if(!t)return console.error("WorkflowManager.getCompanyFlowListData 未传入company_id"),[];var a=n||Session.get("spaceId"),o=Meteor.userId(),r=db.space_users.findOne({space:a,user:o}),s=db.organizations.find({_id:{$in:r.organizations}}).fetch(),i={},l=[];if("distribute"==e){var c=InstanceManager.getDistributeStep();c&&1==c.allowDistribute&&(l=c.distribute_optional_flows||[])}if(l.length>0)i.distribute_optional_flows=db.flows.find({_id:{$in:l},company_id:t,state:"enabled"}).fetch();else{var u=Steedos.isSpaceAdmin(),d=WorkflowManager.getCompanyFlows(t,n);d.sortByName(),i.flows=new Array,d.forEach((function(t){WorkflowManager.canAdd(t,r,s)?i.flows.push(t):"show"==e&&(u?i.flows.push(t):WorkflowManager.canMonitor(t,r,s)?i.flows.push(t):WorkflowManager.canAdmin(t,r,s)&&i.flows.push(t))}))}return i},WorkflowManager.getFlowListData=function(t,e){var n=e||Session.get("spaceId"),a=Meteor.userId(),o=db.space_users.findOne({space:n,user:a}),r=db.organizations.find({_id:{$in:o.organizations}}).fetch(),s={},i=[];if("distribute"==t){var l=InstanceManager.getDistributeStep();l&&1==l.allowDistribute&&(i=l.distribute_optional_flows||[])}if(i.length>0)s.distribute_optional_flows=db.flows.find({_id:{$in:i},state:"enabled"}).fetch();else{s.categories=new Array;var c=WorkflowManager.getSpaceCategories(n,Session.get("workflow_categories")),u=Steedos.isSpaceAdmin();c.forEach((function(e){var n=WorkflowManager.getCategoriesForms(e._id);n.forEach((function(e){var n=WorkflowManager.getFormFlows(e._id);n.sortByName(),e.flows=new Array,n.forEach((function(n){e.sort_no=n.sort_no,e.name=n.name,WorkflowManager.canAdd(n,o,r)?e.flows.push(n):"show"==t&&(u?e.flows.push(n):WorkflowManager.canMonitor(n,o,r)?e.flows.push(n):WorkflowManager.canAdmin(n,o,r)&&e.flows.push(n))}))})),n.sortByName(),e.forms=n}));var d=WorkflowManager.getUnCategoriesForms();d.sortByName(),d.forEach((function(e){var n=WorkflowManager.getFormFlows(e._id);n.sortByName(),e.flows=new Array,n.forEach((function(n){WorkflowManager.canAdd(n,o,r)?e.flows.push(n):"show"==t&&(u?e.flows.push(n):WorkflowManager.canMonitor(n,o,r)?e.flows.push(n):WorkflowManager.canAdmin(n,o,r)&&e.flows.push(n))}))})),c=_.filter(c,(function(t){var e=0;return t.forms.forEach((function(t){e+=t.flows.length})),e>0})),s.categories=c;var p=0;d.forEach((function(t){p+=t.flows.length})),p>0&&s.categories.push({name:TAPi18n.__("workflow_no_category"),_id:"",forms:d})}return s},WorkflowManager.getSpaceForms=function(t){var e=new Array,n;return db.forms.find().forEach((function(t){e.push(t)})),e},WorkflowManager.isPaidSpace=function(t){var e=!1,n;return db.spaces.findOne({_id:t})&&(e=!0),e},WorkflowManager.isArrearageSpace=function(){var t=Session.get("spaceId"),e;return!db.spaces.findOne({_id:t})},Meteor.isClient&&(WorkflowManager.getStepDealTypeName=function(t){var e="";switch(t.deal_type){case"pickupAtRuntime":e="审批时指定人员";break;case"specifyUser":e="指定人员";break;case"applicantRole":e="指定审批岗位";break;case"applicantSuperior":e="提交人上级";break;case"applicant":e="提交人";break;case"orgField":e="指定部门"}return e}),WorkflowManager.hasFlowAdminPermission=function(t,e,n){var a=db.spaces.findOne(e);if(!a)return!1;if(a.admins&&a.admins.includes(n))return!0;var o=!1,r=db.space_users.findOne({space:e,user:n},{fields:{organizations:1,user:1}});if(r){var s=db.organizations.find({_id:{$in:r.organizations}},{fields:{parents:1}}).fetch(),i=db.flows.findOne({_id:t},{fields:{perms:1}});i&&s&&(o=WorkflowManager.canAdmin(i,r,s))}return o},WorkflowManager.alertFlowListModel=function(t){var e="flow_list_box_modal";Meteor.settings.public&&Meteor.settings.public.is_group_company&&(e="flow_list_box_modal"),Modal.show(e,t)}},"node_manager.js":function e(n){var a,o,r,s,i,l;NodeManager={},Steedos.isNode()&&(o=nw.require("path"),r=nw.require("fs"),s=nw.require("crypto"),a=nw.Window.get(),(l=nw.require("child_process"))&&(i=l.exec),a.disableClose=!1),NodeManager.uploadAttach=function(t,e,n){for(var a=Math.random().toString(16),s="\r\n----"+a+"--",i=t,l=e,c=0,u=new Array,d=0;d0||1==n)&&o.push({urlKey:"main",urlValue:!0});var s=[{urlKey:"file",urlValue:t}];OfficeOnline.uploadFile(o,s),Modal.hide("attachments_upload_modal")},NodeManager.signPdf=function(t,e){$(document.body).addClass("loading"),$(".loading-text").text(TAPi18n.__("workflow_attachment_uploading")+e+"...");var n=[{urlKey:"Content-Type",urlValue:cfs.getContentType(e)},{urlKey:"instance",urlValue:Session.get("attach_instance_id")},{urlKey:"space",urlValue:Session.get("attach_space_id")},{urlKey:"approve",urlValue:InstanceManager.getMyApprove().id},{urlKey:"owner",urlValue:Meteor.userId()},{urlKey:"owner_name",urlValue:Meteor.user().name},{urlKey:"upload_from",urlValue:"node"},{urlKey:"is_private",urlValue:!0}],a=[{urlKey:"file",urlValue:t}];OfficeOnline.uploadFile(n,a),Modal.hide("attachments_upload_modal")},NodeManager.getFileSHA1=function(t,e,n){var a=r.createReadStream(t),o=s.createHash("sha1");o.setEncoding("hex"),a.pipe(o),a.on("end",(function(){o.end();var t=o.read();n(t)}))},NodeManager.vbsEditFile=function(e,n,o){var s=e+n,l,c='"'+process.cwd()+'"\\vbs\\edit.vbs "'+s+'" '+Meteor.users.findOne().name;"Steedos.User.isSignature"==o?(c='start "" /wait "'+s+'"',Modal.show("attachments_sign_modal",{filePath:s})):Modal.show("attachments_upload_modal",{filePath:s});var u=100,d,p,f;Meteor.settings.public&&Meteor.settings.public.cfs&&Meteor.settings.public.cfs.size_limit&&(u=Meteor.settings.public.cfs.size_limit);var _=(null!=(d=Meteor.settings)&&null!=(p=d.public)&&null!=(f=p.workflow)?f.attachment_size_limit:void 0)||100,m,b;_&&(u=1024*_*1024),m=1024*u*1024,b=t("workflow_attachment_paid_size_limit")+u+"MB";var g=i(c);a.disableClose=!0,g.on("error",(function(t){toastr.error(t)})),g.on("close",(function(){"Steedos.User.isSignature"==o&&(s=e+(n="签章:"+n),r.exists(s,(function(e){0==e&&(Modal.hide("attachments_sign_modal"),InstanceManager.unlockAttach(Session.get("cfs_file_id")),toastr.warning(t("node_pdf_error")))}))),Modal.hide("attachments_upload_modal");var i=r.statSync(s);a.disableClose=!1,NodeManager.getFileSHA1(s,n,(function(a){if(NodeManager.fileSHA1!=a){var l={title:t("node_office_warning"),text:s,type:"warning",showCancelButton:!0,confirmButtonText:t("node_office_confirm"),cancelButtonText:t("node_office_cancel")};i.size>m&&(l.closeOnConfirm=!1),swal(l,(function(a){a?i.size>m?swal({title:b,type:"warning",confirmButtonText:t("node_office_confirm"),closeOnConfirm:!0},(function(){NodeManager.vbsEditFile(e,n)})):"Steedos.User.isNewFile"==o?NodeManager.setUploadRequests(s,n,!0,!0):InstanceManager.isAttachLocked(Session.get("attach_instance_id"),Meteor.userId())?"Steedos.User.isSignature"==o?r.exists(s,(function(e){1==e?NodeManager.signPdf(s,n):(Modal.hide("attachments_sign_modal"),InstanceManager.unlockAttach(Session.get("cfs_file_id")),toastr.error(t("node_pdf_error")))})):NodeManager.setUploadRequests(s,n,!1,!0):toastr.warning(t("steedos_desktop_edit_warning")):InstanceManager.unlockAttach(Session.get("cfs_file_id"))}))}else InstanceManager.unlockAttach(Session.get("cfs_file_id"))}))}))},NodeManager.downloadFile=function(t,e,n){var a=process.env.USERPROFILE+"\\Steedos\\";r.exists(a,(function(o){1==o?OfficeOnline.downloadFile(t,a,e,n):r.mkdir(a,(function(o){o?toastr.error(o):OfficeOnline.downloadFile(t,a,e,n)}))}))},NodeManager.isViewType=function(t){return!!(Steedos.isOfficeFile(t)||Steedos.isPdfFile(t)||Steedos.isExcelFile(t)||Steedos.isTiffFile(t)||Steedos.isPPTFile(t)||Steedos.isTextFile(t))}},"instance_readonly_template.coffee":function module(require){__coffeescriptShare="object"==typeof __coffeescriptShare?__coffeescriptShare:{};var share=__coffeescriptShare,_getLocale,_getRequiredFields,_getStartStepEditableFields,_getStartStepRequiredFields,_getTemplateData,_getViewHtml,getLinkText,marked;marked=require("marked"),InstanceReadOnlyTemplate={},InstanceReadOnlyTemplate.instance_attachment='\n\t\n\t\t{{this.name}}\n\t | \n
',InstanceReadOnlyTemplate.afSelectUserRead="{{value}}
",InstanceReadOnlyTemplate.afFormGroupRead='',InstanceReadOnlyTemplate.afFormGroup='\n{{#with getField this.name}}\n\t\t{{#if equals type \'section\'}}\n\t\t\t\n\t\t{{else}}\n\t\t\t{{#if equals type \'table\'}}\n\t\t\t\t\n\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t{{{description}}}\n\t\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t{{else}}\n\t\t\t\t{{#if equals type \'input\'}}\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t{{#if is_textarea}}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t{{/if}}\n\t\t\t\t\t\t{{#unless is_textarea}}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t{{/unless}}\n\t\t\t\t\t
\n\t\t\t\t{{else}}\n\t\t\t\t\t{{#if equals type \'number\'}}\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t{{else}}\n\t\t\t\t\t\t{{#if equals type \'date\'}}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t{{else}}\n\t\t\t\t\t\t\t{{#if equals type \'dateTime\'}}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t{{else}}\n\t\t\t\t\t\t\t\t{{#if equals type \'password\'}}\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t{{else}}\n\t\t\t\t\t\t\t\t\t{{#if equals type \'select\'}}\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t{{else}}\n\t\t\t\t\t\t\t\t\t\t{{#if equals type \'radio\'}}\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t{{else}}\n\t\t\t\t\t\t\t\t\t\t\t{{#if equals type \'multiSelect\'}}\n\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t{{else}}\n\t\t\t\t\t\t\t\t\t\t\t\t{{#if equals type \'url\'}}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\t\t\t{{else}}\n\t\t\t\t\t\t\t\t\t\t\t\t\t{{#if equals type \'email\'}}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\t\t\t\t{{else}}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{{#if equals type \'checkbox\'}}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{{else}}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{{/if}}\n\t\t\t\t\t\t\t\t\t\t\t\t\t{{/if}}\n\t\t\t\t\t\t\t\t\t\t\t\t{{/if}}\n\t\t\t\t\t\t\t\t\t\t\t{{/if}}\n\t\t\t\t\t\t\t\t\t\t{{/if}}\n\t\t\t\t\t\t\t\t\t{{/if}}\n\t\t\t\t\t\t\t\t{{/if}}\n\t\t\t\t\t\t\t{{/if}}\n\t\t\t\t\t\t{{/if}}\n\t\t\t\t\t{{/if}}\n\t\t\t\t{{/if}}\n\t\t\t{{/if}}\n\t\t{{/if}}\n\t{{/with}}',InstanceReadOnlyTemplate.create=function(tempalteName,steedosData){var template,templateCompiled,templateRenderFunction;return template=InstanceReadOnlyTemplate[tempalteName],templateCompiled=SpacebarsCompiler.compile(template,{isBody:!0}),templateRenderFunction=eval(templateCompiled),Template[tempalteName]=new Blaze.Template(tempalteName,templateRenderFunction),Template[tempalteName].steedosData=steedosData,Template[tempalteName].helpers(InstanceformTemplate.helpers)},InstanceReadOnlyTemplate.createInstanceSignText=function(steedosData){var instanceSignTextCompiled,instanceSignTextHtml,instanceSignTextRenderFunction;return instanceSignTextHtml=_getViewHtml("client/views/instance/instance_sign_text.html"),instanceSignTextCompiled=SpacebarsCompiler.compile(instanceSignTextHtml,{isBody:!0}),instanceSignTextRenderFunction=eval(instanceSignTextCompiled),Template.instanceSignText=new Blaze.Template("instanceSignText",instanceSignTextRenderFunction),Template.instanceSignText.steedosData=steedosData,Template.instanceSignText.helpers(InstanceSignText.helpers)},InstanceReadOnlyTemplate.createImageSign=function(steedosData){var imageSignCompiled,imageSignHtml,imageSignRenderFunction;return imageSignHtml=_getViewHtml("client/views/instance/image_sign.html"),imageSignCompiled=SpacebarsCompiler.compile(imageSignHtml,{isBody:!0}),imageSignRenderFunction=eval(imageSignCompiled),Template.imageSign=new Blaze.Template("imageSign",imageSignRenderFunction),Template.imageSign.steedosData=steedosData,Template.imageSign.helpers(ImageSign.helpers)},InstanceReadOnlyTemplate.createTracesHanlder=function(steedosData){var tracesHanlderCompiled,tracesHanlderHtml,tracesHanlderRenderFunction;return tracesHanlderHtml=_getViewHtml("client/views/instance/traces_handler.html"),tracesHanlderCompiled=SpacebarsCompiler.compile(tracesHanlderHtml,{isBody:!0}),tracesHanlderRenderFunction=eval(tracesHanlderCompiled),Template.instance_traces_handler=new Blaze.Template("instance_traces_handler",tracesHanlderRenderFunction),Template.instance_traces_handler.steedosData=steedosData,Template.instance_traces_handler.helpers(TracesHandler.helpers)},InstanceReadOnlyTemplate.init=function(t){if(InstanceReadOnlyTemplate.create("afSelectUserRead",t),Meteor.isServer&&InstanceReadOnlyTemplate.create("afFormGroup",t),InstanceReadOnlyTemplate.create("afFormGroupRead",t),Meteor.isServer)return InstanceReadOnlyTemplate.create("instance_attachment",{absolute:t.absolute}),InstanceReadOnlyTemplate.createImageSign(t),InstanceReadOnlyTemplate.createTracesHanlder(t),InstanceReadOnlyTemplate.createInstanceSignText(t)},getLinkText=function(t,e,n){return n?(n=n.replace("{_id}",t._id),/^http(s?):\/\//.test(n)||(n=Steedos.absoluteUrl(n)),''+e+""):e},InstanceReadOnlyTemplate.getValue=function(t,e,n,a){var o,r,s,i,l,c,u,d,p,f,m,b,g,h,w,S,v,k;if(!t&&!1!==t)return"";switch(["select","multiSelect","radio"].indexOf(e.type)>-1&&(i=e.options.split("\n").map((function(t){var e;return{label:(e=t.split(":"))[0],value:e[1]||t}}))),e.type){case"email":t=t?""+t+"":"";break;case"url":if(t)if(0===t.indexOf("http"))try{t=""+t+""}catch(T){s=T,t=""+t+""}else t=""+t+"";else t="";break;case"group":t=e.is_multiselect?null!=t?t.getProperty("fullname").toString():void 0:null!=t?t.fullname:void 0;break;case"user":t=e.is_multiselect?null!=t?t.getProperty("name").toString():void 0:null!=t?t.name:void 0;break;case"password":t="******";break;case"checkbox":t=t&&"false"!==t?TAPi18n.__("form_field_checkbox_yes",{},n):TAPi18n.__("form_field_checkbox_no",{},n);break;case"dateTime":t&&16===t.length?(w=(h=t.split("T"))[0].split("-"),S=h[1].split(":"),k=w[0],c=w[1],o=w[2],l=S[0],f=S[1],t=new Date(k,c-1,o,l,f)):t=new Date(t),t=InstanceReadOnlyTemplate.formatDate(t,a);break;case"time":t&&16===t.length?(w=(h=t.split("T"))[0].split("-"),S=h[1].split(":"),k=w[0],c=w[1],o=w[2],l=S[0],f=S[1],t=new Date(k,c-1,o,l,f)):t=new Date(t),t=InstanceReadOnlyTemplate.formatTime(t);break;case"input":e.is_textarea&&(t=t);break;case"select":case"radio":(m=i.find((function(e){return e.value===t})))&&(t=m.label);break;case"multiSelect":g=t.split(","),(b=i.filter((function(t){return g.indexOf(t.value)>-1}))).length&&(t=b.map((function(t){return t.label})).join(","));break;case"number":(t||0===t)&&(t=e.is_percent?Steedos.numberToPercentString(t,e.digits):Steedos.numberToString(t,e.digits));break;case"odata":r=e.detail_url,t=e.is_multiselect?_.map(t,(function(t){return getLinkText(t,t["@label"],r)})):getLinkText(t,t["@label"],r);break;case"image":t=e.is_multiselect?(t=_.map(t,(function(t){return''}))).join(""):'';break;case"file":t&&(e.is_multiselect||(t=[t]),Meteor.isClient?d=(p=Steedos.authRequest('/api/v1/cfs_files_filerecord?filters=[["_id","in", '+JSON.stringify(t)+']]&fields=["_id","original"]',{async:!1})).data.items:Meteor.isServer&&(d=Steedos.objectFind("cfs_files_filerecord",{filters:[["_id","in",t]],fields:["_id","original"]})),t=(t=_.map(d,(function(t){var e,n,a;return e=t.original.name,a=Steedos.absoluteUrl("/api/files/files/"+t._id),n="",[".pdf",".jpg",".jpeg",".png",".gif"].indexOf(e.toLowerCase().slice(-4))>-1&&(n=" 预览"),""+e+" "+(null!=n?n:{filePreviewHtml:""})+"
"}))).join(""));break;case"lookup":t&&(e.is_multiselect||(t=[t]),Meteor.isClient?(v=Creator.getObject(e.reference_to),u=(null!=v?v.NAME_FIELD_KEY:void 0)||"name",d=(p=Steedos.authRequest("/api/v1/"+e.reference_to+'?filters=[["'+(e.reference_to_field||"_id")+'","in", '+JSON.stringify(t)+']]&fields=["_id","'+u+'"]',{async:!1})).data.items):Meteor.isServer&&(u=Steedos.getObjectNameFieldKey(e.reference_to),d=Steedos.objectFind(e.reference_to,{filters:[[e.reference_to_field||"_id","in",t]],fields:["_id",u]})),t=(t=_.map(d,(function(t){return""+t[u]+""}))).join(" , "));break;case"html":t=t?''+t+"
":""}return t},InstanceReadOnlyTemplate.getLabel=function(t,e){var n;if(n=t.findPropertyByPK("code",e))return n.name?n.name:n.code},InstanceReadOnlyTemplate.getInstanceFormVersion=function(t){var e,n,a;return e=db.forms.findOne(t.form),a={},n=[],(a=e.current._id===t.form_version?e.current:_.where(e.historys,{_id:t.form_version})[0]).fields.forEach((function(t){return"section"!==t.type?"table"===t.type?(t.sfields=t.fields,delete t.fields,n.push(t)):n.push(t):(n.push(t),t.fields?t.fields.forEach((function(t){return n.push(t)})):void 0)})),a.fields=n,a},InstanceReadOnlyTemplate.getFlowVersion=function(t){var e,n;return n={},n=(e=db.flows.findOne(t.flow)).current._id===t.flow_version?e.current:_.where(e.historys,{_id:t.flow_version})[0]},_getViewHtml=function(t){var e;return(e=Assets.getText(t))&&(e=e.replace(//i,"").replace(/<\/template>/i,"")),e},_getLocale=function(t){var e,n,a;return e="zh-cn"===(null!=t&&null!=(n=t.locale)?n.toLocaleLowerCase():void 0)?"zh-CN":"en-us"===(null!=t&&null!=(a=t.locale)?a.toLocaleLowerCase():void 0)?"en":"zh-CN"},_getRequiredFields=function(t,e){return e||(e=[]),t.forEach((function(t){if("section"===t.type)return _getRequiredFields(t.fields,e);if("table"===t.type);else if(t.is_required)return e.push(t.code)})),e},_getStartStepEditableFields=function(t,e){var n,a;return a=e.findPropertyByPK("step_type","start"),n=[],_.keys(a.permissions).forEach((function(t){if("editable"===a.permissions[t])return n.push(t)})),n},_getStartStepRequiredFields=function(t,e){var n,a;return a=_getRequiredFields(t),n=_getStartStepEditableFields(t,e),_.intersection(a,n)},_getTemplateData=function(t,e,n,a){var o,r,s,i,l;return s=Meteor.isServer?InstanceReadOnlyTemplate.getInstanceFormVersion(n):WorkflowManager.getInstanceFormVersion(n),i=_getLocale(t),l={},Meteor.isClient&&((l=_.clone(WorkflowManager_format.getAutoformSchemaValues())).insname=n.name,l.ins_state=n.state,l.ins_final_decision=n.ins_final_decision,l.ins_code=n.code,l.ins_is_archived=n.is_archived,l.ins_is_deleted=n.ins_is_deleted,l.applicant_name=n.applicant_name,l.applicantContext=n.applicant_name),l.instance=n,l.form_version=s,l.locale=i,l.utcOffset=t.utcOffset,l.space=n.space,l.sessionUserId=t._id,Meteor.isServer&&(null!=a?a.editable:void 0)&&(r=db.forms.findOne({_id:n.form}),o=db.flows.findOne({_id:n.flow}),l.startStepEditableFields=_getStartStepEditableFields(r.current.fields,o.current.steps)),l},InstanceReadOnlyTemplate.formatDate=function(t,e){var n;return n=!Meteor.isServer,e||0===e||(e=8),moment(t).utcOffset(e,n).format("YYYY-MM-DD HH:mm")},InstanceReadOnlyTemplate.formatTime=function(t){var e;return e=0,moment(t).utcOffset(0).format("HH:mm")},InstanceReadOnlyTemplate.getInstanceView=function(user,space,instance,options){var body,instanceCompiled,instanceRenderFunction,instanceTemplate,steedosData;return steedosData=_getTemplateData(user,space,instance,options),steedosData.absolute=!1,(null!=options?options.absolute:void 0)&&(steedosData.absolute=!0),instanceTemplate=TemplateManager.getTemplate(instance,null!=options?options.templateName:void 0),instanceTemplate=instanceTemplate.replace(/afSelectUser/g,"afSelectUserRead"),(null!=options?options.editable:void 0)||(instanceTemplate=instanceTemplate.replace(/afFormGroup/g,"afFormGroupRead")),instanceCompiled=SpacebarsCompiler.compile(instanceTemplate,{isBody:!0}),instanceRenderFunction=eval(instanceCompiled),Template.instance_readonly_view=new Blaze.Template("instance_readonly_view",instanceRenderFunction),Template.instance_readonly_view.steedosData=steedosData,Template.instance_readonly_view.helpers(InstanceformTemplate.helpers),InstanceReadOnlyTemplate.init(steedosData),body=Blaze.toHTMLWithData(Template.instance_readonly_view,steedosData),"\n\t"+body+"\n
"},InstanceReadOnlyTemplate.getTracesView=function(user,space,instance,options){var body,form,steedosData,traceCompiled,traceRenderFunction,tracesHtml;return steedosData=_getTemplateData(user,space,instance),form=db.forms.findOne(instance.form),tracesHtml="table"===form.instance_style||"table"===(null!=options?options.templateName:void 0)?_getViewHtml("client/views/instance/traces_table.html"):_getViewHtml("client/views/instance/traces.html"),traceCompiled=SpacebarsCompiler.compile(tracesHtml,{isBody:!0}),traceRenderFunction=eval(traceCompiled),Template.trace_readonly_view=new Blaze.Template("trace_readonly_view",traceRenderFunction),Template.trace_readonly_view.steedosData=steedosData,Template.trace_readonly_view.helpers(TracesTemplate.helpers),body=Blaze.toHTMLWithData(Template.trace_readonly_view,instance.traces),body},InstanceReadOnlyTemplate.getAttachmentView=function(user,space,instance){var attachmentCompiled,attachmentHtml,attachmentRenderFunction,body,steedosData;return steedosData=_getTemplateData(user,space,instance),attachmentHtml=_getViewHtml("client/views/instance/instance_attachments.html"),attachmentCompiled=SpacebarsCompiler.compile(attachmentHtml,{isBody:!0}),attachmentRenderFunction=eval(attachmentCompiled),Template.attachments_readonly_view=new Blaze.Template("attachments_readonly_view",attachmentRenderFunction),Template.attachments_readonly_view.steedosData=steedosData,Template.attachments_readonly_view.helpers(InstanceAttachmentTemplate.helpers),body=Blaze.toHTMLWithData(Template.attachments_readonly_view),body},InstanceReadOnlyTemplate.getRelatedInstancesView=function(user,space,instance,options){var body,relatedInstancesCompiled,relatedInstancesHtml,relatedInstancesRenderFunction,steedosData;return steedosData=_getTemplateData(user,space,instance),steedosData.absolute=!1,(null!=options?options.absolute:void 0)&&(steedosData.absolute=!0),relatedInstancesHtml=_getViewHtml("client/views/instance/related_instances.html"),relatedInstancesCompiled=SpacebarsCompiler.compile(relatedInstancesHtml,{isBody:!0}),relatedInstancesRenderFunction=eval(relatedInstancesCompiled),Template.related_instances_view=new Blaze.Template("related_instances_view",relatedInstancesRenderFunction),Template.related_instances_view.steedosData=steedosData,Template.related_instances_view.helpers(RelatedInstances.helpers),body=Blaze.toHTMLWithData(Template.related_instances_view,steedosData),body},InstanceReadOnlyTemplate.getRelatedRecordsView=function(user,space,instance,options){var body,relatedRecordsCompiled,relatedRecordsHtml,relatedRecordsRenderFunction,steedosData;return steedosData=_getTemplateData(user,space,instance),steedosData.absolute=!1,(null!=options?options.absolute:void 0)&&(steedosData.absolute=!0),relatedRecordsHtml=_getViewHtml("client/views/instance/related_records.html"),relatedRecordsCompiled=SpacebarsCompiler.compile(relatedRecordsHtml,{isBody:!0}),relatedRecordsRenderFunction=eval(relatedRecordsCompiled),Template.related_records_view=new Blaze.Template("related_records_view",relatedRecordsRenderFunction),Template.related_records_view.steedosData=steedosData,Template.related_records_view.helpers(RelatedRecords.helpers),body=Blaze.toHTMLWithData(Template.related_records_view,steedosData),body},InstanceReadOnlyTemplate.getOnLoadScript=function(t){var e,n;return(e=(n=WorkflowManager.getFormVersion(t.form,t.form_version)).form_script)&&e.replace(/\n/g,"").replace(/\s/g,"").length>0?(e="CoreForm = {};CoreForm.instanceform = {};"+e)+";if(CoreForm.form_OnLoad){window.onload = CoreForm.form_OnLoad();}":""},InstanceReadOnlyTemplate.getInstanceHtml=function(t,e,n,a){var o,r,s,i,l,c,u,d,p,f,m,b,g,h,w,S,v,k,T,M,y,I,x,L,H;return s=InstanceReadOnlyTemplate.getInstanceView(t,e,n,a),w=InstanceReadOnlyTemplate.getOnLoadScript(n),i=null!=(v=Meteor.settings.public.webservices)&&null!=(k=v.creator)?k.url:void 0,f=n.record_ids,h=_getLocale(t),S='if(window.isNode && isNode()){\n\tattachs = document.getElementsByClassName("ins_attach_href");\n\tfor(var i = 0; i < attachs.length; i++){\n\t\tattach = attachs[i];\n\t\tattach.addEventListener("click", function(e){\n\t\t\tif(isImage(this.dataset.type) || isHtml(this.dataset.type)){\n\t\t\t\te.preventDefault();\n\t\t\t\topenWindow("/api/files/instances/" + this.dataset.id);\n\t\t\t}else if(nw_core.canOpenFile(this.dataset.name)){\n\t\t\t\te.preventDefault();\n\t\t\t\tnw_core.openFile(this.href, this.dataset.name)\n\t\t\t}\n\t\t});\n\t}\n}\n\nvar flow = "'+n.flow+'";\nvar space = "'+n.space+'";\n\nfunction getCookie(name){\n\tlet pattern = RegExp(name + "=.[^;]*")\n\tlet matched = document.cookie.match(pattern)\n\tif(matched){\n\t\tlet cookie = matched[0].split(\'=\')\n\t\treturn cookie[1]\n\t}\n\treturn \'\'\n}\n\nvar records = document.getElementsByClassName("ins-related-records");\nfor(var i = 0; i < records.length; i++){\n\t\tvar record = records[i];\n\t\trecord.addEventListener("click", function(e){\n\t\t\tvar creatorService = "'+i+'"\n\t\t\tvar ins_record_ids = '+JSON.stringify(f)+'\n\t\t\tif(creatorService && ins_record_ids && ins_record_ids.length > 0){\n\t\t\t\tvar objcetName = ins_record_ids[0].o\n\t\t\t\tvar id = ins_record_ids[0].ids[0]\n\t\t\t\tvar uobj = {};\n\t\t\t\tuobj["X-User-Id"] = getCookie("X-User-Id");\n\t\t\t\tuobj["X-Auth-Token"] = getCookie("X-Auth-Token");\n\t\t\t\tredirectUrl = creatorService + "app/-/" + objcetName + "/view/" + id + "?" + $.param(uobj);\n\t\t\t\topenWindow(redirectUrl);\n\t\t\t}\n\t\t});\n\t}\n',Steedos.isMobile()||"table"===(null!=(c=db.forms.findOne(n.form))?c.instance_style:void 0)&&(b="instance-table"),"table"===(null!=a?a.templateName:void 0)&&(b="instance-table"),(null!=a?a.instance_style:void 0)&&(b=a.instance_style),x=a&&!0!==a.showTrace?"":InstanceReadOnlyTemplate.getTracesView(t,e,n),m="",n&&n.final_decision&&("approved"===n.final_decision?m="box-success":"rejected"===n.final_decision&&(m="box-danger")),a&&!0!==a.showAttachments?(r="",T="",M=""):(r=InstanceReadOnlyTemplate.getAttachmentView(t,e,n),T=InstanceReadOnlyTemplate.getRelatedInstancesView(t,e,n,a),M=InstanceReadOnlyTemplate.getRelatedRecordsView(t,e,n,a)),H="960px",(null!=a?a.width:void 0)&&(H=""),l=Meteor.absoluteUrl("steedos-css"),g=Meteor.absoluteUrl("website/libs/jquery.min.js"),o='',L="",_.isEmpty(x)||(L="checked"),y="email"===(null!=a?a.tagger:void 0)||(null!=a?a.editable:void 0)?"":'",I="$( document ).ready(function(){\n\tvar b = document.getElementById('cbx-print-traces');\n\tvar t = document.getElementsByClassName('instance-traces')[0];\n\tif (b && b.checked && t){\n\t\tt.style = 'display: block;'\n\t} else if(t){\n\t\tt.style = 'display: none;'\n\t}\n\tif(b){\n\t\tb.addEventListener('change', function(e){\n\t\t\tif (e.target.checked){\n\t\t\t\tt.style = 'display: block;'\n\t\t\t} else {\n\t\t\t\tt.style = 'display: none;'\n\t\t\t}\n\t\t});\n\t}\n\n\n\tvar attachmentsCheckbox = document.getElementById('cbx-print-attachments');\n\tvar attachmentsView = document.getElementsByClassName('attachments-section')[0];\n\tif (attachmentsCheckbox && attachmentsCheckbox.checked && attachmentsView){\n\t\tattachmentsView.style = 'display: block;'\n\t} else if(attachmentsView){\n\t\tattachmentsView.style = 'display: none;'\n\t}\n\tif(attachmentsCheckbox){\n\t\tattachmentsCheckbox.addEventListener('change', function(e){\n\t\t\tif (e.target.checked){\n\t\t\t\tattachmentsView.style = 'display: block;'\n\t\t\t} else {\n\t\t\t\tattachmentsView.style = 'display: none;'\n\t\t\t}\n\t\t});\n\t}\n});\n",(null!=a?a.styles:void 0)&&(o=""),d="",(c=db.forms.findOne({_id:n.form}))&&(u=c.description)&&(d='"),p='\n\n\t\n\t\t\n\t\t'+o+'\n\t\t