/*
    *
    * Wijmo Library 5.20181.462
    * http://wijmo.com/
    *
    * Copyright(c) GrapeCity, Inc.  All rights reserved.
    *
    * Licensed under the GrapeCity Commercial License.
    * sales@wijmo.com
    * wijmo.com/products/wijmo-5/license/
    *
    */
import*as wjcCore from"wijmo/wijmo";import*as wjcSelfRef from"wijmo/wijmo.vue2.base";var wjcSelf=wjcSelfRef||exports;window.wijmo=window.wijmo||{},window.wijmo.vue2=window.wijmo.vue2||{},window.wijmo.vue2.base=wjcSelf;import VueModuleDefault from"vue";import*as VueModule from"vue";export var Vue=VueModuleDefault||VueModule;export var WjVueBase=Vue.extend({beforeCreate:function(){let t=this.$options[WjComponentBehavior._behClassProp];t&&(this[WjComponentBehavior._behProp]=t._attach(this))},mounted:function(){this[WjComponentBehavior._behProp].lhMounted()},destroyed:function(){this[WjComponentBehavior._behProp].lhDestroyed()}});export class WjComponentBehavior{constructor(t){this._isMounted=!1,this._mountedCBs=[],this.component=t}static _attach(t){return new this(t)}static register(){let t={extends:WjVueBase,template:this.template,props:_getProps(this.className),[WjComponentBehavior._behClassProp]:this};return Vue.component(this.tag,t)}lhMounted(){if(this._isChild()){let t=this.component.$parent;t&&(this.parent=t[WjComponentBehavior._behProp],this.parent._mountedCB(()=>{this._prepareControl(),this._initParent()}))}else this._prepareControl()}lhDestroyed(){this._siblingInsertedEH&&this._getElement().removeEventListener("DOMNodeInserted",this._siblingInsertedEH);let t=this.control;if(t)if(this._isChild()){let e=this._getParentProp();if(e){let i=this.parent.control[e];if(wjcCore.isArray(i)){let e=i.indexOf(t);e>-1&&i.splice(e,1)}}}else t instanceof wjcCore.Control&&t.dispose()}_createControl(){let t=this._isChild()?this._isParentInCtor()?this.parent.control:void 0:this._getElement();return new(this.constructor._getControlType())(t)}_initParent(){let t=this._getParentProp();if(t){let e=this.parent.control,i=e[t];if(wjcCore.isArray(i)){let t=this._getSiblingIndex();(t<0||t>=i.length)&&(t=i.length),i.splice(t,0,this.control),this._siblingInsertedEH=this._siblingInserted.bind(this),this._getElement().addEventListener("DOMNodeInserted",this._siblingInsertedEH)}else e[t]=this.control}}_prepareControl(){let t=this.control=this._createControl(),e=this._getElement(),i=(wjcCore.Control,this.constructor);this._siblingId||(null==i.siblingId&&(i.siblingId=++i._siblingDirId+""),this._siblingId=i.siblingId),e.setAttribute(i._typeSiblingIdAttr,this._siblingId),this._isMounted=!0;let o=this._mountedCBs;this._mountedCBs=[];for(let t of o)t();_initialize(this.component,t)}_isChild(){let t=this.constructor;return null!=t.parentProp||null!=t.parentInCtor}_isParentInCtor(){return!0===this.constructor.parentInCtor}_getParentProp(){return this.component.$options.propsData.wjProperty||this.constructor.parentProp}_getSiblingIndex(){var t=this._getElement(),e=t.parentElement;if(!e)return-1;for(var i=e.childNodes,o=-1,n=this._siblingId,r=0;r<i.length;r++){var s=i[r];if(1==s.nodeType&&s.getAttribute(WjComponentBehavior._typeSiblingIdAttr)==n&&(++o,s===t))return o}return-1}_siblingInserted(t){if(t.target===this._getElement()){var e=this._getSiblingIndex(),i=this.control,o=this.parent.control[this._getParentProp()],n=o.indexOf(i);e>=0&&n>=0&&e!==n&&(o.splice(n,1),e=Math.min(e,o.length),o.splice(e,0,i))}}_getElement(){return this.component.$el}static _getControlType(){return this.classCtor()}_mountedCB(t){this._isMounted?t():this._mountedCBs.push(t)}};WjComponentBehavior._typeSiblingIdAttr="_wjSiblingId",WjComponentBehavior._behClassProp="_wjBehCl",WjComponentBehavior._behProp="__wjBeh",WjComponentBehavior._siblingDirId=0;export function _getProps(t,e){for(var i=window,o=t.split("."),n=0;n<o.length&&null!=i;n++)i=i[o[n]];if(!i)return null;for(var r=["control","initialized","wjProperty"],s=i.prototype;s!=Object.prototype;s=Object.getPrototypeOf(s))for(var l=Object.getOwnPropertyNames(s),n=0;n<l.length;n++){var h=l[n],a=Object.getOwnPropertyDescriptor(s,h),p=h.match(/^on[A-Z]/);(a.set||p)&&(p&&(h=h[2].toLowerCase()+h.substr(3)),r.indexOf(h)<0&&!h.match(/disabled|required/)&&r.push(h))}return e&&Array.prototype.push.apply(r,e),r};export function _initialize(t,e){function i(t){this.ctl[this.prop]=t}var o=[];for(var n in t.$options.propsData)o.push(n);return o.sort(),o.forEach(o=>{!(o in e)||e[o]instanceof wjcCore.Event||wjcCore.isUndefined(t[o])||(e[o]=t[o],t.$watch(o,i.bind({ctl:e,prop:o})))}),o.forEach(i=>{if(e[i]instanceof wjcCore.Event){var o=e[i];wjcCore.isFunction(t[i])&&o.addHandler(t[i],e)}}),t.control&&t.$parent&&(t.$parent[t.control]=e),wjcCore.isFunction(t.initialized)&&t.initialized(e),e};