mirror of
https://github.com/lxsang/antd-web-apps
synced 2024-11-20 02:18:20 +01:00
1 line
64 KiB
JavaScript
1 line
64 KiB
JavaScript
var OS;!function(t){let e;!function(t){t.zindex=10;class e extends HTMLElement{constructor(){super(),this.observable||(this.observable=new Ant.OS.API.Announcer),this._mounted=!1,this.refs={}}set(t){for(let e in t){let s=this.descriptor_of(e);s&&s.set&&(this[e]=t[e])}}set tooltip(t){t&&$(this).attr("tooltip",t)}descriptor_of(t){let e,s=this;do{e=Object.getOwnPropertyDescriptor(s,t)}while(!e&&(s=Object.getPrototypeOf(s)));return e}set aid(t){$(this).attr("data-id",t)}get aid(){return $(this).attr("data-id")}sync(){this._mounted||(this._mounted=!0,this.mount(),super.sync())}afxml(t){t&&(this.observable=t),this.aid||(this.aid=(Math.floor(1e5*Math.random())+1).toString());const e=$(this).children();for(let t of this.layout()){const e=this.mkui(t);e&&$(e).appendTo(this)}if(this.refs.yield)for(let t of e)$(t).detach().appendTo(this.refs.yield);const s={};for(let t=0;t<this.attributes.length;t++){const e=this.attributes[t];let i=this.descriptor_of(e.nodeName);if(i&&i.set){let t="";try{t=JSON.parse(e.nodeValue)}catch(s){t=e.nodeValue}s[e.nodeName]=t}}super.afxml(this.observable),this.init();for(let t in s)this[t]=s[t]}update(t){this.reload(t),super.update(t)}calibrate(){}mkui(t){if(!t)return;const e=$(`<${t.el}>`);if(t.class&&$(e).addClass(t.class),t.id&&$(e).attr("data-id",t.id),t.height&&$(e).attr("data-height",t.height),t.width&&$(e).attr("data-width",t.width),t.tooltip&&$(e).attr("tooltip",t.tooltip.__()),t.children)for(let s of t.children)$(this.mkui(s)).appendTo(e);return t.ref&&(this.refs[t.ref]=e[0]),e[0]}attsw(t,e,s){t?this.atton(e,s):this.attoff(e,s)}atton(t,e){$(e||this).attr(t,"")}attoff(t,e){(e||this).removeAttribute(t)}hasattr(t,e){return(e||this).hasAttribute(t)}}let s;t.AFXTag=e,HTMLElement.prototype.update=function(t){$(this).children().each((function(){if(this.update)return this.update(t)}))},HTMLElement.prototype.sync=function(){$(this).children().each((function(){return this.sync()}))},HTMLElement.prototype.afxml=function(t){$(this).children().each((function(){return this.afxml(t)}))},HTMLElement.prototype.uify=function(t,e){this.afxml(t),this.sync(),t&&e&&t.trigger("mounted",this.aid)},function(t){t.define=function(t,e){try{customElements.define(t,e)}catch(s){const i=customElements.get(t);if(e){const t=Object.getOwnPropertyNames(e.prototype);for(let s of t)i.prototype[s]=e.prototype[s];return}throw s}}}(s=t.tag||(t.tag={}))}(e=t.GUI||(t.GUI={}))}(OS||(OS={})),function(t){let e;!function(t){let e;!function(e){class s extends t.AFXTag{constructor(){super()}init(){this._shown=!1,this._isMaxi=!1,this._history={},this.desktop=t.workspace,this._desktop_pos=$(this.desktop).offset(),this.minimizable=!0,this.resizable=!0,this.apptitle="Untitled"}calibrate(){}reload(t){}set width(t){this._width=t,t&&this.setsize({w:t,h:this.height})}get width(){return this._width}set height(t){this._height=t,t&&this.setsize({w:this.width,h:t})}get height(){return this._height}set minimizable(t){this.attsw(t,"minimizable"),t?$(this.refs.minbt).show():$(this.refs.minbt).hide()}get minimizable(){return this.hasattr("minimizable")}set resizable(t){this.attsw(t,"resizable"),t?($(this.refs.maxbt).show(),$(this.refs.grip).show()):($(this.refs.maxbt).hide(),$(this.refs.grip).hide())}get resizable(){return this.hasattr("resizable")}set apptitle(t){$(this).attr("apptitle",t.__()),t&&(this.refs.txtTitle.text=t)}get apptitle(){return $(this).attr("apptitle")}resize(){const t=$(this.refs.yield).height()/$(this.refs.yield).children().length;$(this.refs.yield).children().each((function(e){$(this).css("height",t+"px")}))}mount(){this.contextmenuHandle=function(t){},$(this.refs.minbt).click(t=>this.observable.trigger("hide",{id:this.aid})),$(this.refs.maxbt).click(t=>this.toggle_window()),$(this.refs.closebt).click(t=>this.observable.trigger("exit",{id:this.aid}));const t=($(this.desktop).width()-this.width)/2,e=($(this.desktop).height()-this.height)/2;return $(this).css("position","absolute").css("left",t+"px").css("top",e+"px").css("z-index",Ant.OS.GUI.zindex++),$(this).on("mousedown",t=>{if(!this._shown)return this.observable.trigger("focus",{id:this.aid})}),$(this.refs.dragger).dblclick(t=>this.toggle_window()),this.observable.on("resize",t=>this.resize()),this.observable.on("focus",()=>{Ant.OS.GUI.zindex++,$(this).show().css("z-index",Ant.OS.GUI.zindex).removeClass("unactive"),this._shown=!0}),this.observable.on("blur",()=>(this._shown=!1,$(this).addClass("unactive"))),this.observable.on("hide",()=>($(this).hide(),this._shown=!1)),this.observable.on("toggle",()=>this._shown?this.observable.trigger("hide",{id:this.aid}):this.observable.trigger("focus",{id:this.aid})),this.enable_dragging(),this.enable_resize(),this.setsize({w:this.width,h:this.height}),this.observable.trigger("rendered",{id:this.aid})}setsize(t){t&&(this._width=t.w,this._height=t.h,$(this).css("width",t.w+"px").css("height",t.h+"px"),$(this.refs.winwrapper).css("height",t.h+"px"),this.observable.trigger("resize",{id:this.aid,data:t}))}enable_dragging(){$(this.refs.dragger).css("user-select","none").css("cursor","default"),$(this.refs.dragger).on("mousedown",t=>{t.preventDefault();const e=$(this).offset();return e.top=t.clientY-e.top,e.left=t.clientX-e.left,$(window).on("mousemove",t=>{let s,i;if(this._isMaxi){this.toggle_window(),i=0;t.clientX,$(this).width();e.top=10,e.left=$(this).width()/2}else i=t.clientY-e.top-this._desktop_pos.top,s=t.clientX-this._desktop_pos.top-e.left,s=s<0?0:s,i=i<0?0:i;return $(this).css("top",i+"px").css("left",s+"px")}),$(window).on("mouseup",(function(t){return $(window).unbind("mousemove",null),$(window).unbind("mouseup",null)}))})}enable_resize(){$(this.refs.grip).css("user-select","none").css("cursor","default").css("position","absolute").css("bottom","0").css("right","0").css("cursor","nwse-resize"),$(this.refs.grip).on("mousedown",t=>{t.preventDefault();const e={top:0,left:0};e.top=t.clientY,e.left=t.clientX,$(window).on("mousemove",t=>{let s=$(this).width()+t.clientX-e.left,i=$(this).height()+t.clientY-e.top;s=s<100?100:s,i=i<100?100:i,e.top=t.clientY,e.left=t.clientX,this._isMaxi=!1,this.setsize({w:s,h:i})}),$(window).on("mouseup",(function(t){return $(window).unbind("mousemove",null),$(window).unbind("mouseup",null)}))})}toggle_window(){let t,e;this.resizable&&(!1===this._isMaxi?(this._history={top:$(this).css("top"),left:$(this).css("left"),width:$(this).css("width"),height:$(this).css("height")},e=$(this.desktop).width(),t=$(this.desktop).height(),$(this).css("top","0").css("left","0"),this.setsize({w:e,h:t}),this._isMaxi=!0):(this._isMaxi=!1,$(this).css("top",this._history.top).css("left",this._history.left),this.setsize({w:parseInt(this._history.width),h:parseInt(this._history.height)})))}layout(){return[{el:"div",class:"afx-window-wrapper",ref:"winwrapper",children:[{el:"ul",class:"afx-window-top",children:[{el:"li",class:"afx-window-close",ref:"closebt"},{el:"li",class:"afx-window-minimize",ref:"minbt"},{el:"li",class:"afx-window-maximize",ref:"maxbt"},{el:"li",class:"afx-window-title",ref:"dragger",children:[{el:"afx-label",ref:"txtTitle"}]}]},{el:"div",class:"afx-clear"},{el:"div",ref:"yield",class:"afx-window-content"},{el:"div",ref:"grip",class:"afx-window-grip"}]}]}}e.WindowTag=s,e.define("afx-app-window",s)}(e=t.tag||(t.tag={}))}(e=t.GUI||(t.GUI={}))}(OS||(OS={})),function(t){let e;!function(t){let e;!function(e){class s extends t.AFXTag{constructor(){super()}init(){}reload(t){}set name(t){t&&($(this).attr("name",t),$(this.refs.yield).removeClass().addClass(`afx-${t}-container`),this.calibrate())}get name(){return $(this).attr("name")}set dir(t){t&&($(this).attr("dir",t),$(this.refs.yield).css("flex-direction",t),this.calibrate())}get dir(){return $(this).attr("dir")}mount(){return $(this).css("display","block"),$(this.refs.yield).css("display","flex").css("width","100%").css("height","100%"),this.observable.on("resize",t=>this.calibrate()),this.calibrate()}calibrate(){return"row"===this.dir?this.hcalibrate():"column"===this.dir?this.vcalibrate():void 0}hcalibrate(){const t=[];let e=0;const s=$(this).height(),i=$(this).width();$(this.refs.yield).children().each((function(s){$(this).css("height","100%");let r=$(this).attr("data-width"),a=0;r&&"grow"!==r?(a="%"===r[r.length-1]?parseInt(r.slice(0,-1))*i/100:parseInt(r),$(this).css("width",a+"px"),e+=a):($(this).css("flex-grow","1"),t.push(this))}));const r=(i-e)/t.length;return r>0&&$.each(t,(t,e)=>$(e).css("width",r+"px")),this.observable.trigger("hboxchange",{id:this.aid,data:{w:i,h:s}})}vcalibrate(){const t=[];let e=0;const s=$(this).height(),i=$(this).width();$(this.refs.yield).children().each((function(i){let r=0;$(this).css("width","100%");let a=$(this).attr("data-height");a&&"grow"!==a?(r="%"===a[a.length-1]?parseInt(a.slice(0,-1))*s/100:parseInt(a),$(this).css("height",r+"px"),e+=r):($(this).css("flex-grow","1"),t.push(this))}));const r=(s-e)/t.length;return r>0&&$.each(t,(t,e)=>$(e).css("height",r+"px")),this.observable.trigger("vboxchange",{id:this.aid,data:{w:i,h:s}})}layout(){return[{el:"div",ref:"yield"}]}}e.TileLayoutTag=s;class i extends s{constructor(){super()}mount(){super.mount(),this.dir="row",this.name="hbox"}}e.HBoxTag=i;class r extends s{constructor(){super()}mount(){super.mount(),this.dir="column",this.name="vbox"}}e.VBoxTag=r,e.define("afx-tile",s),e.define("afx-hbox",i),e.define("afx-vbox",r)}(e=t.tag||(t.tag={}))}(e=t.GUI||(t.GUI={}))}(OS||(OS={})),function(t){let e;!function(t){let e;!function(e){class s extends t.AFXTag{constructor(){super()}init(){this._resizable_el=void 0,this._parent=$(this).parent().parent()[0],this._minsize=0}reload(t){}set dir(t){let e;$(this).attr("dir",t),$(this).unbind("mousedown",null),"hz"===t?($(this).css("cursor","col-resize"),$(this).addClass("horizontal"),this._resizable_el&&(e=$(this._resizable_el).attr("min-width"),e&&(this._minsize=parseInt(e)))):"ve"===t&&($(this).css("cursor","row-resize"),$(this).addClass("vertical"),this._resizable_el&&(e=$(this._resizable_el).attr("min-height"),e&&(this._minsize=parseInt(e)))),0===this._minsize&&(this._minsize=10),this.make_draggable()}get dir(){return $(this).attr("dir")}get attachnext(){return this.hasattr("attachnext")}set attachnext(t){this.attsw(t,"attachnext")}set onelresize(t){this._onresize=t}get onelresize(){return this._onresize}mount(){$(this).css(" display","block");const t=$(this._parent).prop("tagName");this.attachnext?this._resizable_el=1===$(this).next().length?$(this).next()[0]:void 0:this._resizable_el=1===$(this).prev().length?$(this).prev()[0]:void 0,this.dir="AFX-HBOX"===t?"hz":"AFX-VBOX"===t?"ve":"hz"}make_draggable(){$(this).css("user-select","none"),this.dir&&"none"!=this.dir&&$(this).on("mousedown",t=>(t.preventDefault(),$(window).on("mousemove",t=>{if(this._resizable_el)return"hz"===this.dir?this.horizontalResize(t):"ve"===this.dir?this.verticalResize(t):void 0}),$(window).on("mouseup",(function(t){return $(window).unbind("mousemove",null),$(window).unbind("mouseup",null),$(window).unbind("mouseup",null)}))))}horizontalResize(t){if(!this._resizable_el)return;const e=$(this._resizable_el).offset();let s=0;s=this.attachnext?Math.round(e.left+$(this._resizable_el).width()-t.clientX):Math.round(t.clientX-e.left),s<this._minsize&&(s=this._minsize),$(this._resizable_el).attr("data-width",s.toString());let i={id:this.aid,data:{w:s}};this.onelresize&&this.onelresize(i),this.observable.trigger("resize",i)}verticalResize(t){if(!this._resizable_el)return;const e=$(this._resizable_el).offset();let s=0;s=this.attachnext?Math.round(e.top+$(this._resizable_el).height()-t.clientY):Math.round(t.clientY-e.top),s<this._minsize&&(s=this._minsize),$(this._resizable_el).attr("data-height",s.toString());let i={id:this.aid,data:{h:s}};return this.onelresize&&this.onelresize(i),this.observable.trigger("resize",i)}layout(){return[]}}e.ResizerTag=s,e.define("afx-resizer",s)}(e=t.tag||(t.tag={}))}(e=t.GUI||(t.GUI={}))}(OS||(OS={})),function(t){let e;!function(e){let s;!function(s){class i extends e.AFXTag{constructor(){super()}mount(){}reload(t){this.text=this.text}init(){this.icon=void 0,this.iconclass=void 0,this.text=void 0}calibrate(){}set icon(e){$(this.refs.i).attr("style",""),$(this).attr("icon",e),e?($(this.refs.i).css("background",`url(${t.API.handle.get}/${e})`).css("background-size","100% 100%").css("background-repeat","no-repeat"),$(this.refs.i).show()):$(this.refs.i).hide()}set iconclass(t){$(this).attr("iconclass",t),$(this.refs.iclass).removeClass(),t?($(this.refs.iclass).addClass(t),$(this.refs.iclass).show()):$(this.refs.iclass).hide()}set text(t){this._text=t,t&&""!==t?($(this.refs.text).show(),$(this.refs.text).html(t.__())):$(this.refs.text).hide()}get text(){return this._text}layout(){return[{el:"span",ref:"container",children:[{el:"i",ref:"iclass"},{el:"i",ref:"i",class:"icon-style"},{el:"i",ref:"text",class:"label-text"}]}]}}s.LabelTag=i,s.define("afx-label",i)}(s=e.tag||(e.tag={}))}(e=t.GUI||(t.GUI={}))}(OS||(OS={})),function(t){let e;!function(t){let e;!function(e){class s extends t.AFXTag{constructor(){super()}set onbtclick(t){this._onbtclick=t}set icon(t){$(this).attr("icon",t),this.refs.label.icon=t}set iconclass(t){$(this).attr("iconclass",t),this.refs.label.iconclass=t}set text(t){this.refs.label.text=t}get text(){return this.refs.label.text}set enable(t){$(this.refs.button).prop("disabled",!t)}get enable(){return!$(this.refs.button).prop("disabled")}set selected(t){$(this.refs.button).removeClass(),this.attsw(t,"selected"),t&&$(this.refs.button).addClass("selected")}get selected(){return this.hasattr("selected")}set toggle(t){this.attsw(t,"toggle")}get toggle(){return this.hasattr("toggle")}mount(){$(this.refs.button).click(t=>{this.toggle&&(this.selected=!this.selected);const e={id:this.aid,data:t};this._onbtclick(e),this.observable.trigger("btclick",e)})}init(){this.enable=!0,this.toggle=!1,this._onbtclick=t=>{}}calibrate(){}reload(t){}layout(){return[{el:"Button",ref:"button",children:[{el:"afx-label",ref:"label"}]}]}}e.ButtonTag=s,e.define("afx-button",s)}(e=t.tag||(t.tag={}))}(e=t.GUI||(t.GUI={}))}(OS||(OS={})),function(t){let e;!function(t){let e;!function(e){class s extends t.AFXTag{constructor(){super(),this._onselect=this._onctxmenu=this._onclick=this._ondbclick=this._onclose=t=>{}}set closable(t){this.attsw(t,"closable"),t?$(this.refs.btcl).show():$(this.refs.btcl).hide()}get closable(){return this.hasattr("closable")}set onitemselect(t){this._onselect=t}set selected(t){this.attsw(t,"selected"),$(this.refs.item).removeClass(),this._data.selected=t,t&&($(this.refs.item).addClass("selected"),this._onselect({id:this.aid,data:this}))}get selected(){return this.hasattr("selected")}set onctxmenu(t){this._onctxmenu=t}set onitemclick(t){this._onclick=t}set onitemdbclick(t){this._ondbclick=t}set onitemclose(t){this._onclose=t}mount(){$(this.refs.item).attr("dataref","afx-list-item"),$(this.refs.item).contextmenu(t=>{this._onctxmenu({id:this.aid,data:this})}),$(this.refs.item).click(t=>{this._onclick({id:this.aid,data:this})}),$(this.refs.item).dblclick(t=>{this._ondbclick({id:this.aid,data:this})}),$(this.refs.btcl).click(t=>{this._onclose({id:this.aid,data:this}),t.preventDefault(),t.stopPropagation()})}layout(){return[{el:"li",ref:"item",children:[this.itemlayout(),{el:"i",class:"closable",ref:"btcl"}]}]}set data(t){this._data=t,this.ondatachange()}get data(){return this._data}}e.ListViewItemTag=s;class i extends s{constructor(){super()}init(){this.closable=!1,this.data={}}calibrate(){}ondatachange(){const t=this.data;if(!t)return;this.refs.label.set(t),t.selected&&(this.selected=t.selected),t.closable&&(this.closable=t.closable)}reload(){this.data=this.data}itemlayout(){return{el:"afx-label",ref:"label"}}}e.SimpleListItemTag=i;class r extends t.AFXTag{constructor(){super(),this._onlistdbclick=this._onlistselect=this._ondragndrop=t=>{},this._onitemclose=t=>!0,this._onmousedown=this._onmouseup=this._onmousemove=t=>{},this._selectedItems=[],this._selectedItem=void 0}init(){this.data=[],this.multiselect=!1,this.dropdown=!1,this.selected=-1,this.dragndrop=!1,$(this).css("display","flex").css("flex-direction","column"),this.itemtag="afx-list-item"}reload(t){}set dropdown(t){this.attsw(t,"dropdown"),$(this.refs.container).removeAttr("style"),$(this.refs.mlist).removeAttr("style"),$(this.refs.container).css("flex",1),$(this).removeClass("dropdown");const e=t=>this.dropoff(t),s=t=>this.showlist(t);t?($(this).addClass("dropdown"),$(this.refs.current).show(),$(document).on("click",e),$(this.refs.current).on("click",s),$(this.refs.container).css("position","absolute").css("display","inline-block"),$(this.refs.mlist).css("position","absolute").css("display","none").css("top","100%").css("left","0"),this.calibrate()):($(this.refs.current).hide(),$(document).off("click",e),$(this.refs.current).off("click",s))}set ondragndrop(t){this._ondragndrop=t}set onlistselect(t){this._onlistselect=t}set onlistdbclick(t){this._onlistdbclick=t}set onitemclose(t){this._onitemclose=t}get dropdown(){return this.hasAttribute("dropdown")}set itemtag(t){$(this).attr("itemtag",t)}get itemtag(){return $(this).attr("itemtag")}set multiselect(t){this.attsw(t,"multiselect")}get multiselect(){return!this.dropdown&&this.hasattr("multiselect")}set dragndrop(t){this.attsw(t,"dragndrop")}get dragndrop(){return this.hasattr("dragndrop")}set buttons(t){if(!this.dropdown&&t&&t.length>0){$(this.refs.btlist).empty();for(let e of t){$(this.refs.btlist).show();const t=$("<afx-button>").appendTo(this.refs.btlist);t[0].uify(this.observable),t[0].set(e)}}}get data(){return this._data}set data(t){this._data=t,this._selectedItem=void 0,this._selectedItems=[],$(this.refs.mlist).empty();for(let e of t)this.push(e,!1);$(this.refs.container).off("mousedown",this._onmousedown),this.dragndrop&&!this.dropdown&&$(this.refs.container).on("mousedown",this._onmousedown),this.ondatachange()}ondatachange(){}set selected(t){if(!this.data)return;const e=t=>{if(t<0)return void this.unselect();const e=this.data;if(t>=e.length)return;e[t].domel.selected=!0};if(Array.isArray(t)){if(this.multiselect)for(const s of t)e(s)}else e(t)}get selectedItem(){return this._selectedItem}get selectedItems(){return this._selectedItems}get selected(){return this.multiselect?this.selectedItems.map((function(t){return $(t).index()})):$(this.selectedItem).index()}unshift(t){return this.push(t,!0)}has_data(t){return this.data&&this.data.includes(t)}push(t,e){let s=this.itemtag;t.tag&&(s=t.tag);const i=$(`<${s}>`);e?(this.has_data(t)||this.data.unshift(t),$(this.refs.mlist).prepend(i[0])):(this.has_data(t)||this.data.push(t),i.appendTo(this.refs.mlist)),i[0].uify(this.observable);const r=i[0];return r.onctxmenu=t=>this.iclick(t,!0),r.onitemdbclick=t=>{this.idbclick(t),this.iclick(t,!1)},r.onitemclick=t=>this.iclick(t,!1),r.onitemselect=t=>this.iselect(t),r.onitemclose=t=>this.iclose(t),r.data=t,t.domel=i[0],r}delete(t){const e=t.data,s=this.data;this.selectedItem===t&&(this._selectedItem=void 0);const i=this.selectedItems;i.includes(t)&&i.splice(i.indexOf(t),1),s.includes(e)&&s.splice(s.indexOf(e),1),$(t).remove()}selectNext(){if(this.multiselect)return;const t=this.selectedItem;let e=0;t&&(e=$(t).index()+1),this.selected=e}selectPrev(){if(this.multiselect)return;const t=this.selectedItem;let e=0;t&&(e=$(t).index()-1),this.selected=e}unselect(){for(let t of this.selectedItems)t.selected=!1;this._selectedItems=[],this._selectedItem=void 0}iclick(t,e){if(!t.data)return;const s=this.selectedItems;if(this.multiselect&&s.includes(t.data)&&!e)return s.splice(s.indexOf(t.data),1),void(t.data.selected=!1);t.data.selected=!0}idbclick(t){const e={id:this.aid,data:{item:t.data}};return this._onlistdbclick(e),this.observable.trigger("listdbclick",e)}iselect(t){if(!t.data)return;var e={item:t.data,items:[]};if(this.multiselect){if(this.selectedItems.includes(t.data))return;this._selectedItem=t.data,this.selectedItems.push(t.data),e.items=this.selectedItems}else{if(this.selectedItem===t.data)return;this.selectedItem&&(this.selectedItem.selected=!1),this._selectedItem=t.data,this._selectedItems=[t.data],e.items=[t.data];const s=$(t.data).children()[0],i=$(this.refs.container).offset(),r=$(this.refs.container).scrollTop();$(s).offset().top+$(s).height()>$(this.refs.container).height()+i.top?$(this.refs.container).scrollTop(r+$(this.refs.container).height()-$(s).height()):$(s).offset().top<i.top&&$(this.refs.container).scrollTop(r-$(this.refs.container).height()+$(s).height())}if(this.dropdown){this.refs.drlabel.set(t.data.data),$(this.refs.mlist).hide()}const s={id:this.aid,data:e};return this._onlistselect(s),this.observable.trigger("listselect",s)}mount(){return this._dnd={from:void 0,to:void 0},this._onmousedown=t=>{let e=$(t.target).closest("li[dataref='afx-list-item']");0!==e.length&&(e=e.parent()[0],this._dnd.from=e,this._dnd.to=void 0,$(window).on("mouseup",this._onmouseup),$(window).on("mousemove",this._onmousemove))},this._onmouseup=t=>{$(window).off("mouseup",this._onmouseup),$(window).off("mousemove",this._onmousemove),$("#systooltip").hide();let e=$(t.target).closest("li[dataref='afx-list-item']");0!==e.length&&(e=e.parent()[0],e!==this._dnd.from&&(this._dnd.to=e,this._ondragndrop({id:this.aid,data:this._dnd}),this._dnd={from:void 0,to:void 0}))},this._onmousemove=t=>{if(!t)return;if(!this._dnd.from)return;const e=this._dnd.from.data,s=$("#systooltip"),i=t.clientY+5,r=t.clientX+5;s.show();return s[0].set(e),s.css("top",i+"px").css("left",r+"px")},$(this.refs.btlist).hide(),this.observable.on("resize",t=>this.calibrate()),this.calibrate()}iclose(t){if(!t.data)return;const e={id:this.aid,data:{item:t.data}};return this._onitemclose(e)?(this.observable.trigger("itemclose",e),this.delete(t.data)):void 0}showlist(t){if(!this.dropdown)return;const e=$(Ant.OS.GUI.workspace).height();$(this).offset().top+$(this.refs.mlist).height()>e?$(this.refs.mlist).css("top",`-${$(this.refs.mlist).outerHeight()}px`):$(this.refs.mlist).css("top","100%"),$(this.refs.mlist).show()}dropoff(t){0===$(t.target).closest(this.refs.container).length&&$(this.refs.mlist).hide()}calibrate(){if(!this.dropdown)return;const t=$(this).width()+"px";$(this.refs.container).css("width",t),$(this.refs.current).css("width",t),$(this.refs.mlist).css("width",t)}layout(){return[{el:"div",class:"list-container",ref:"container",children:[{el:"div",ref:"current",children:[{el:"afx-label",ref:"drlabel"}]},{el:"ul",ref:"mlist"}]},{el:"div",class:"button_container",ref:"btlist"}]}}e.ListViewTag=r,e.define("afx-list-view",r),e.define("afx-list-item",i)}(e=t.tag||(t.tag={}))}(e=t.GUI||(t.GUI={}))}(OS||(OS={})),function(t){let e;!function(t){let e;!function(e){class s extends t.AFXTag{set swon(t){this.attsw(t,"swon"),$(this.refs.switch).removeClass(),t&&$(this.refs.switch).addClass("swon")}get swon(){return this.hasattr("swon")}set enable(t){this.attsw(t,"enable")}get enable(){return this.hasattr("enable")}set onswchange(t){this._onchange=t}mount(){$(this.refs.switch).click(t=>this.makechange(t))}makechange(t){if(!this.enable)return;this.swon=!this.swon;const e={id:this.aid,data:this.swon};return this._onchange(e),this.observable.trigger("switch",e)}layout(){return[{el:"span",ref:"switch"}]}init(){this.swon=!1,this.enable=!0,this._onchange=t=>{}}calibrate(){}reload(t){}}e.SwitchTag=s,e.define("afx-switch",s)}(e=t.tag||(t.tag={}))}(e=t.GUI||(t.GUI={}))}(OS||(OS={})),function(t){let e;!function(t){let e;!function(e){class s extends t.AFXTag{constructor(){super(),this._onchange=t=>{}}init(){this._value=0,this.step=1}reload(t){}set onvaluechange(t){this._onchange=t}mount(){$(this.refs.holder).attr("type","text"),$(this.refs.incr).click(t=>{this.value=this.value+this.step}),$(this.refs.decr).click(t=>{this.value=this.value-this.step}),this.observable.on("resize",()=>this.calibrate()),$(this.refs.holder).on("keyup",t=>{if(13===t.keyCode){let t=parseInt(this.refs.holder.value);if(!isNaN(t))return t<0&&(t=this.value),this.value=t}}),this.calibrate()}calibrate(){$(this.refs.holder).css("width",$(this).width()-20+"px"),$(this.refs.holder).css("height",$(this).height()+"px"),$(this.refs.spinner).css("width","20px").css("height",$(this).height()+"px"),$(this.refs.incr).css("height",$(this).height()/2-2+"px").css("position","relative"),$(this.refs.decr).css("height",$(this).height()/2-2+"px").css("position","relative"),$(this.refs.spinner).find("li").css("display","block").css("text-align","center").css("vertical-align","middle"),$(this.refs.spinner).find("i").css("font-size","16px").css("position","absolute");const t=function(t,e){const s=$(t).find("i");s.css(e,($(t).height()-s.height())/2+"px").css("left",($(t).width()-s.width())/2+"px")};t(this.refs.decr,"bottom"),t(this.refs.incr,"top")}set value(t){if(this._value===t||isNaN(t))return;this._value=t,$(this.refs.holder).val(this._value);const e={id:this.aid,data:t};this._onchange(e),this.observable.trigger("nspin",e)}get value(){return this._value}layout(){return[{el:"input",ref:"holder"},{el:"ul",ref:"spinner",children:[{el:"li",class:"incr",ref:"incr",children:[{el:"i"}]},{el:"li",class:"decr",ref:"decr",children:[{el:"i"}]}]}]}}e.NSpinnerTag=s,e.define("afx-nspinner",s)}(e=t.tag||(t.tag={}))}(e=t.GUI||(t.GUI={}))}(OS||(OS={})),function(t){let e;!function(t){let e;!function(e){class s extends t.AFXTag{constructor(){super(),this._onmenuselect=this._onchildselect=t=>{}}init(){this.nodes=void 0}set onmenuselect(t){this._onmenuselect=t}set onchildselect(t){this._onchildselect=t}get onchildselect(){return this._onchildselect}set data(t){this._data=t,this.set(t)}get data(){return this._data}has_nodes(){const t=this.nodes;return t&&t.length>0}is_root(){return!this.parent}layout(){return[{el:"li",ref:"container",children:[{el:"a",ref:"entry",children:this.itemlayout()},{el:"afx-menu",ref:"submenu"}]}]}set nodes(t){if($(this.refs.container).removeClass("afx_submenu"),!(t&&t.length>0))return void $(this.refs.submenu).hide();$(this.refs.container).addClass("afx_submenu"),$(this.refs.submenu).show().attr("style","");const e=this.refs.submenu;e.parent=this,e.root=this.root,e.items=t,this._data.nodes=t,this.is_root()&&$(this.refs.container).mouseleave(t=>$(this.refs.submenu).attr("style",""))}get nodes(){if(this.data&&this.data.nodes)return this.data.nodes}mount(){$(this.refs.entry).click(t=>this.select(t))}submenuoff(){const t=this.parent;if(t)return t.submenuoff();$(this.refs.submenu).attr("style","")}select(t){const e={id:this.aid,data:{item:this,event:t}};t.preventDefault(),this.is_root()&&this.has_nodes()?$(this.refs.submenu).show():this.submenuoff(),this._onmenuselect(e),this.parent&&this.parent.onchildselect(e),this.root&&this.root.onmenuitemselect(e)}}e.MenuEntryTag=s;class i extends s{constructor(){super()}init(){super.init(),this.switch=!1,this.radio=!1,this.checked=!1}calibrate(){}reload(t){}set switch(t){this.attsw(t,"switch"),this.radio||t?$(this.refs.switch).show():$(this.refs.switch).hide()}get switch(){return this.hasattr("switch")}set radio(t){this.attsw(t,"radio"),this.switch||t?$(this.refs.switch).show():$(this.refs.switch).hide()}get radio(){return this.hasattr("radio")}set checked(t){this.attsw(t,"checked"),this.data&&(this.data.checked=t),(this.radio||this.switch)&&(this.refs.switch.swon=t)}get checked(){return this.hasattr("checked")}set icon(t){if($(this.refs.container).removeClass("fix_padding"),!t)return;this.refs.label.icon=t,$(this.refs.container).addClass("fix_padding")}set iconclass(t){if(!t)return;this.refs.label.iconclass=t}set text(t){if(void 0===t)return;this.refs.label.text=t}set shortcut(t){$(this.refs.shortcut).hide(),t&&($(this.refs.shortcut).show(),$(this.refs.shortcut).text(t))}reset_radio(){if(this.has_nodes())for(let t of this.nodes)t.domel.radio&&(t.domel.checked=!1)}mount(){super.mount(),this.refs.switch.enable=!1}select(t){if(this.switch)this.checked=!this.checked;else if(this.radio){const t=this.parent;t&&t.reset_radio(),this.checked=!this.checked}return super.select(t)}itemlayout(){return[{el:"afx-switch",ref:"switch"},{el:"afx-label",ref:"label"},{el:"span",class:"shortcut",ref:"shortcut"}]}}e.SimpleMenuEntryTag=i;class r extends t.AFXTag{constructor(){super()}init(){this.contentag="afx-menu-entry",this.context=!1,this._items=[],this._onmenuselect=t=>{}}calibrate(){}reload(t){}set items(t){this._items=t,$(this.refs.container).empty(),t.map(t=>this.push(t,!1))}get items(){return this._items}set context(t){this.attsw(t,"context"),$(this.refs.wrapper).removeClass("context"),t&&($(this.refs.wrapper).addClass("context"),$(this).hide())}get context(){return this.hasattr("context")}set onmenuselect(t){this._onmenuselect=t}set contentag(t){$(this).attr("contentag",t)}get contentag(){return $(this).attr("contentag")}get onmenuitemselect(){return this.handleselect}handleselect(t){this.context&&$(this).hide(),t.id=this.aid,this._onmenuselect(t),this.observable.trigger("menuselect",t)}show(t){this.context&&$(this).css("top",t.clientY-15+"px").css("left",t.clientX-5+"px").show()}is_root(){return void 0===this.root}mount(){$(this.refs.container).css("display","contents"),this.context&&$(this.refs.wrapper).mouseleave(t=>{if(this.is_root())return $(this).hide()})}unshift(t){this.push(t,!0)}delete(t){const e=t.data,s=this.items;s.includes(e)&&s.splice(s.indexOf(e),1),$(t).remove()}push(t,e){let s=this.contentag;t.tag&&(s=t.tag);const i=$(`<${s}>`);e?($(this.refs.container).prepend(i[0]),this.items.includes(t)||this.items.unshift(t)):(i.appendTo(this.refs.container),this.items.includes(t)||this.items.push(t));const r=i[0];return r.uify(this.observable),r.parent=this.parent,r.root=this.parent?this.parent.root:this,r.data=t,t.domel=r,r}layout(){return[{el:"ul",ref:"wrapper",children:[{el:"li",class:"afx-corner-fix"},{el:"div",ref:"container"},{el:"li",class:"afx-corner-fix"}]}]}}e.MenuTag=r,e.define("afx-menu",r),e.define("afx-menu-entry",i)}(e=t.tag||(t.tag={}))}(e=t.GUI||(t.GUI={}))}(OS||(OS={})),function(t){let e;!function(t){let e;!function(e){class s extends t.AFXTag{constructor(){super(),this.refs.yield=this}mount(){}init(){this.data=[]}layout(){return[]}calibrate(){}reload(t){}}e.GridRowTag=s;class i extends t.AFXTag{constructor(){super()}set oncellselect(t){this._oncellselect=t}set oncelldbclick(t){this._oncelldbclick=t}set data(t){t&&(this._data=t,this.ondatachange(),t.selected&&(this.selected=t.selected))}get data(){return this._data}set selected(t){this.attsw(t,"selected"),this._data&&(this._data.selected=t),t&&this.cellselect({id:this.aid,data:this},!1)}get selected(){return this.hasattr("selected")}reload(t){this.data=this.data}mount(){$(this).attr("class","afx-grid-cell"),this.oncelldbclick=this.oncellselect=t=>{},this.selected=!1,$(this).css("display","block"),$(this).click(t=>{let e={id:this.aid,data:this};return this.cellselect(e,!1)}),$(this).dblclick(t=>{let e={id:this.aid,data:this};return this.cellselect(e,!0)})}cellselect(t,e){const s={id:this.aid,data:{item:t.data}};return e?this._oncelldbclick(s):this._oncellselect(s)}}e.GridCellPrototype=i;class r extends i{constructor(){super()}ondatachange(){this.refs.cell.set(this.data)}init(){}calibrate(){}layout(){return[{el:"afx-label",ref:"cell"}]}}e.SimpleGridCellTag=r;class a extends t.AFXTag{constructor(){super()}init(){this._header=[],this.headeritem="afx-grid-cell",this.cellitem="afx-grid-cell",this._selectedCell=void 0,this._selectedRows=[],this._selectedRow=void 0,this._rows=[],this.resizable=!1,this._oncellselect=this._onrowselect=this._oncelldbclick=t=>{}}reload(t){}set oncellselect(t){this._oncellselect=t}set onrowselect(t){this._onrowselect=t}set oncelldbclick(t){this._oncelldbclick=t}set headeritem(t){$(this).attr("headeritem",t)}get headeritem(){return $(this).attr("headeritem")}set cellitem(t){$(this).attr("cellitem",t)}get cellitem(){return $(this).attr("cellitem")}get header(){return this._header}set header(t){if(this._header=t,!t||0===t.length)return void $(this.refs.header).hide();$(this.refs.header).empty();let e=0;for(let s of t){const i=$(`<${this.headeritem}>`).appendTo(this.refs.header)[0];if(i.uify(this.observable),i.data=s,s.domel=i,e++,this.resizable&&e!=t.length){const i=$("<afx-resizer>").appendTo(this.refs.header)[0];$(i).css("width","3px");let r=void 0;e<t.length&&(r=t[e]),i.onelresize=t=>{s.width=t.data.w+3,r&&delete r.width},i.uify(this.observable)}}this.calibrate()}get selectedRows(){return this._selectedRows}get selectedRow(){return this._selectedRow}get selectedCell(){return this._selectedCell}set rows(t){$(this.refs.grid).empty(),this._rows=t,t.map(t=>this.push(t,!1))}get rows(){return this._rows}set multiselect(t){this.attsw(t,"multiselect")}get multiselect(){return this.hasattr("multiselect")}set resizable(t){this.attsw(t,"resizable")}get resizable(){return this.hasattr("resizable")}delete(t){if(!t)return;const e=t.data,s=this.rows;this.selectedRow===t&&(this._selectedRow=void 0),$(this.selectedCell).parent()[0]===t&&(this._selectedCell=void 0);const i=this.selectedRows;i.includes(t)&&i.splice(i.indexOf(t),1),s.includes(e)&&s.splice(s.indexOf(e),1),$(t).remove()}push(t,e){const s=$("<afx-grid-row>").css("display","contents");e?($(this.refs.grid).prepend(s[0]),this.rows.includes(t)||this.rows.unshift(t)):(s.appendTo(this.refs.grid),this.rows.includes(t)||this.rows.push(t));const i=s[0];s[0].uify(this.observable),i.data=t,t.domel=s[0];for(let e of t){let t=this.cellitem;e.tag&&({tag:t}=e);const i=$(`<${t}>`).appendTo(s);e.domel=i[0];const r=i[0];r.uify(this.observable),r.oncellselect=t=>this.cellselect(t,!1),r.oncelldbclick=t=>this.cellselect(t,!0),r.data=e}}unshift(t){this.push(t,!0)}cellselect(t,e){return t.id=this.aid,this.selectedCell&&$(this.selectedCell).attr("class","afx-grid-cell"),this._selectedCell=t.data.item,$(t.data.item).addClass("afx-grid-cell-selected"),e?(this.observable.trigger("celldbclick",t),this._oncelldbclick(t)):(this.observable.trigger("cellselect",t),this._oncellselect(t),this.rowselect(t))}rowselect(t){if(!t.data.item)return;const e={id:this.aid,data:{item:void 0,items:[]}},s=$(t.data.item).parent()[0];if(this.multiselect)this.selectedRows.includes(s)?(this.selectedRows.splice(this.selectedRows.indexOf(s),1),$(s).removeClass()):(this.selectedRows.push(s),$(s).removeClass().addClass("afx-grid-row-selected")),e.data.items=this.selectedRows;else{if(this.selectedRow===s)return;$(this.selectedRow).removeClass(),this._selectedRows=[s],e.data.item=s,e.data.items=[s],$(s).removeClass().addClass("afx-grid-row-selected"),this._selectedRows=[s]}return this._selectedRow=s,this._onrowselect(e),this.observable.trigger("rowselect",e)}has_header(){const t=this._header;return t&&t.length>0}calibrate(){this.calibrate_header(),this.has_header()?$(this.refs.container).css("height",$(this).height()-$(this.refs.header).height()+"px"):$(this.refs.container).css("height",$(this).height()+"px")}calibrate_header(){if(!this.has_header())return;const t=[];let e=0,s=0;const i=$(this).parent().width();if($.each(this._header,(function(i,r){return r.width?(t.push(r.width),e+=r.width):(t.push(-1),s++)})),s>0){const r=Math.round((i-e)/s);$.each(t,(function(e,s){if(-1===s)return t[e]=r}))}let r="",a="",h=0;for(let e of t)r+=e+"px ",h++,a+=e+"px ",h<t.length&&this.resizable&&(a+="3px ");$(this.refs.grid).css("grid-template-columns",r),$(this.refs.header).css("grid-template-columns",a)}mount(){return $(this).css("overflow","hidden"),$(this.refs.grid).css("display","grid"),$(this.refs.header).css("display","grid"),this.observable.on("resize",t=>this.calibrate()),$(this.refs.container).css("width","100%").css("overflow-x","hidden").css("overflow-y","auto"),this.calibrate()}layout(){return[{el:"div",ref:"header",class:"grid_row_header"},{el:"div",ref:"container",children:[{el:"div",ref:"grid"}]}]}}e.GridViewTag=a,e.define("afx-grid-view",a),e.define("afx-grid-cell",r),e.define("afx-grid-row",s)}(e=t.tag||(t.tag={}))}(e=t.GUI||(t.GUI={}))}(OS||(OS={})),function(t){let e;!function(t){let e;!function(e){class s extends t.AFXTag{constructor(){super(),this._ontabclose=t=>!0,this._ontabselect=t=>{}}init(){this.selected=-1}reload(t){}set closable(t){this.attsw(t,"closable")}get closable(){return this.hasattr("closable")}push(t){return t.closable=this.closable,this.refs.list.push(t)}delete(t){this.refs.list.delete(t)}unshift(t){return t.closable=this.closable,this.refs.list.unshift(t)}set items(t){for(let e of t)e.closable=this.closable;this.refs.list.data=t}get items(){return this.refs.list.data}set selected(t){this.refs.list.selected=t}get selected(){return this.refs.list.selected}set ontabclose(t){this._ontabclose=t}set ontabselect(t){this._ontabselect=t}mount(){$(this.refs.list).css("height","100%"),this.refs.list.onitemclose=t=>(t.id=this.aid,this._ontabclose(t)),this.refs.list.onlistselect=t=>(this._ontabselect(t),this.observable.trigger("tabselect",t))}layout(){return[{el:"afx-list-view",ref:"list"}]}}e.TabBarTag=s,e.define("afx-tab-bar",s)}(e=t.tag||(t.tag={}))}(e=t.GUI||(t.GUI={}))}(OS||(OS={})),function(t){let e;!function(t){let e;!function(e){class s extends t.AFXTag{constructor(){super(),this._ontabselect=t=>{}}init(){this.dir="column"}reload(t){}set ontabselect(t){this._ontabselect=t}get tabs(){return this.refs.bar.items}set selectedIndex(t){this.refs.bar.selected=t}set dir(t){$(this).attr("dir",t),t&&(this.refs.wrapper.dir=t)}get dir(){return $(this).attr("dir")}set selectedTab(t){if(!t)return;const e=this._selectedTab;this._selectedTab=t,e&&$(e.container).hide(),$(t.container).show(),this.observable.trigger("resize",void 0),$(t.container).attr("tabindex",-1).css("outline","none").trigger("focus")}get selectedTab(){return this._selectedTab}set tabbarwidth(t){t&&($(this.refs.bar).attr("data-width",""+t),this.refs.wrapper.calibrate())}set tabbarheight(t){$(this.refs.bar).attr("data-height",""+t),this.refs.wrapper.calibrate()}addTab(t,e){e&&$(this.refs.yield).append(t.container),$(t.container).css("width","100%").css("height","100%").hide();const s=this.refs.bar.push(t);return s.selected=!0,s}removeTab(t){t.data.container&&$(t.data.container).remove(),this.refs.bar.delete(t)}mount(){this.refs.bar.ontabselect=t=>{const e=t.data.item.data;return this.selectedTab=e,this._ontabselect({data:e,id:this.aid})},this.observable.one("mounted",t=>{$(this.refs.yield).children().each((t,e)=>{const s={};$(e).attr("tabname")&&(s.text=$(e).attr("tabname")),$(e).attr("icon")&&(s.icon=$(e).attr("icon")),$(e).attr("iconclass")&&(s.iconclass=$(e).attr("iconclass")),s.container=e,this.addTab(s,!1)})}),this.observable.on("resize",t=>this.calibrate()),this.calibrate()}calibrate(){$(this.refs.wrapper).css("height",$(this).height()+"px")}layout(){return[{el:"afx-tile",ref:"wrapper",children:[{el:"afx-tab-bar",ref:"bar"},{el:"div",ref:"yield"}]}]}}e.TabContainerTag=s,e.define("afx-tab-container",s)}(e=t.tag||(t.tag={}))}(e=t.GUI||(t.GUI={}))}(OS||(OS={})),function(t){let e;!function(e){let s;!function(s){class i extends e.AFXTag{constructor(){super()}reload(t){if(t&&"string"==typeof t)switch(t){case"expand":this.open=!0;break;case"collapse":this.open=!1;break;default:if(t!==this.treepath)return;this.open=!0}}set data(t){this._data=t,t&&(this.open=t.open,t.path&&(this.treepath=t.path),this.selected=t.selected,t.domel=this,this.ondatachange())}get data(){return this._data}set selected(t){this._data&&(this.attsw(t,"selected"),$(this.refs.wrapper).removeClass(),this._data.selected=t,t&&(this.treeroot.unselect(),this.treeroot.itemclick(this._evt),this._evt.data.dblclick=!1,$(this.refs.wrapper).addClass("afx_tree_item_selected")))}get selected(){return this.hasattr("selected")}set open(e){this.is_folder()&&(this.attsw(e,"open"),$(this.refs.toggle).removeClass(),e?(this.fetch?this.fetch(this).then(t=>{if(t)return this.nodes=t}).catch(e=>t.announcer.oserror(e.toString(),e)):this.nodes=this.nodes,$(this.refs.childnodes).show()):$(this.refs.childnodes).hide(),e?$(this.refs.toggle).addClass("afx-tree-view-folder-open"):$(this.refs.toggle).addClass("afx-tree-view-folder-close"))}get open(){return this.hasattr("open")}get indent(){return this._indent}set indent(t){t&&(this._indent=t,$(this.refs.padding).css("display","inline-block").css("height","1px").css("padding",0).css("margin",0).css("background-color","transparent").css("width",15*t+"px"))}is_folder(){return!!this.nodes}get nodes(){if(this._data)return this._data.nodes}set nodes(t){if(!t||!this.data)return;this._data.nodes=t,$(this.refs.childnodes).empty(),$(this.refs.wrapper).addClass("afx_folder_item");const e=this.treeroot;for(let s of t){const t=$("<afx-tree-view>").appendTo(this.refs.childnodes);t[0].uify(this.observable);const i=t[0];i.treeroot=e,i.indent=this.indent+1,i.open=this.open,i.parent=this.parent,i.treepath=`${this.treepath}/${i.aid}`,i.fetch=this.fetch,i.data=s}}init(){this.treeroot=void 0,this.treepath=this.aid.toString(),this._evt={id:this.aid,data:{item:this,dblclick:!1}},this._indent=0}mount(){$(this.refs.container).css("padding",0).css("margin",0).css("white-space","nowrap"),$(this.refs.itemholder).css("display","inline-block"),$(this.refs.wrapper).click(t=>{this.selected=!0}),$(this.refs.wrapper).dblclick(t=>{this._evt.data.dblclick=!0,this.selected=!0}),$(this.refs.toggle).css("display","inline-block").css("width","15px").addClass("afx-tree-view-item").click(t=>(this.open=!this.open,t.preventDefault(),t.stopPropagation()))}layout(){return[{el:"div",ref:"wrapper",children:[{el:"ul",ref:"container",children:[{el:"li",ref:"padding"},{el:"li",ref:"toggle"},{el:"li",ref:"itemholder",class:"itemname",children:this.itemlayout()}]}]},{el:"ul",ref:"childnodes"}]}}s.TreeViewItemPrototype=i;class r extends i{constructor(){super()}ondatachange(){if(!this.data)return;const t=this.data;this.refs.label.set(t)}itemlayout(){return[{el:"afx-label",ref:"label"}]}}s.SimpleTreeViewItem=r;class a extends e.AFXTag{constructor(){super()}init(){this.itemtag="afx-tree-view-item",this._ontreeselect=this._ondragndrop=this._ontreedbclick=t=>{},this.indent=0,this.open=!0,this.treepath=this.aid.toString()}layout(){return[]}reload(t){}set dragndrop(t){this.attsw(t,"dragndrop")}get dragndrop(){return this.hasattr("dragndrop")}set ontreeselect(t){this._ontreeselect=t}set ontreedbclick(t){this._ontreedbclick=t}set itemtag(t){$(this).attr("itemtag",t)}get itemtag(){return $(this).attr("itemtag")}unselect(){this.selectedItem&&(this._selectedItem.selected=!1)}get selectedItem(){return this._selectedItem}set selectedItem(t){t&&t!==this.selectedItem&&(t.selected=!0)}expandAll(){if(!this.is_leaf())return this.update("expand")}collapseAll(){if(!this.is_leaf())return this.update("collapse")}itemclick(t){if(!t||!t.data)return;if(t.data.item===this.selectedItem&&!t.data.dblclick)return;this._selectedItem=t.data.item;const e={id:this.aid,data:t.data};return t.data.dblclick?(this._ontreedbclick(e),this.observable.trigger("treedbclick",e)):(this._ontreeselect(e),this.observable.trigger("treeselect",e))}is_root(){return void 0===this.treeroot}is_leaf(){const t=this.data;return!t||!t.nodes}set ondragndrop(t){this._ondragndrop=t}set data(t){if(this._selectedItem=void 0,!t)return;this._data=t,$(this).empty(),t.path&&(this.treepath=t.path);let e=this.itemtag;t.tag&&(e=t.tag);const s=$(`<${e}>`).appendTo(this);s[0].uify(this.observable);const i=s[0];i.treeroot=this.is_root()?this:this.treeroot,i.indent=this.indent,i.treepath=this.treepath,i.open=this.open,i.fetch=this.fetch,i.parent=this,i.data=t,this.is_root()&&($(this).off("mousedown",this._treemousedown),this.dragndrop&&$(this).on("mousedown",this._treemousedown))}get data(){return this._data}mount(){this._dnd={from:void 0,to:void 0},this._treemousedown=t=>{let e=$(t.target).closest("afx-tree-view");if(0===e.length)return;let s=e[0];return s!==this?(this._dnd.from=s,this._dnd.to=void 0,$(window).on("mouseup",this._treemouseup),$(window).on("mousemove",this._treemousemove)):void 0},this._treemouseup=t=>{$(window).off("mouseup",this._treemouseup),$(window).off("mousemove",this._treemousemove),$("#systooltip").hide();let e=$(t.target).closest("afx-tree-view");if(0===e.length)return;let s=e[0];s.is_leaf()&&(s=s.parent),s!==this._dnd.from&&s!==this._dnd.from.parent&&(this._dnd.to=s,this._ondragndrop({id:this.aid,data:this._dnd}),this._dnd={from:void 0,to:void 0})},this._treemousemove=t=>{if(!t)return;if(!this._dnd.from)return;const e=this._dnd.from.data,s=$("#systooltip"),i=t.clientY+5,r=t.clientX+5;s.show();s[0].set(e),s.css("top",i+"px").css("left",r+"px")}}}s.TreeViewTag=a,s.define("afx-tree-view",a),s.define("afx-tree-view-item",r)}(s=e.tag||(e.tag={}))}(e=t.GUI||(t.GUI={}))}(OS||(OS={})),function(t){let e;!function(t){let e;!function(e){class s extends t.AFXTag{constructor(){super()}init(){this.enable=!0,this._max=100,this._value=0,this._onchange=this._onchanging=()=>{}}reload(t){}set onvaluechange(t){this._onchange=t}set onvaluechanging(t){this._onchanging=t}set enable(t){this.attsw(t,"enable"),t?$(this).mouseover(()=>$(this.refs.point).show()).mouseout(()=>$(this.refs.point).hide()):($(this.refs.point).hide(),$(this).unbind("mouseover").unbind("mouseout"))}get enable(){return this.hasattr("enable")}set value(t){this._value=t,this.calibrate()}get value(){return this._value}set max(t){this._max=t,this.calibrate()}get max(){return this._max}mount(){this.enable_dragging(),$(this.refs.point).css("position","absolute"),$(this.refs.point).hide(),this.observable.on("resize",t=>this.calibrate()),$(this.refs.container).click(t=>{const e=$(this.refs.container).offset(),s=t.clientX-e.left,i=$(this.refs.container).width();this.value=s*this.max/i,this.calibrate();const r={id:this.aid,data:this.value};return this._onchange(r),this._onchanging(r)}),this.calibrate()}calibrate(){this.value>this.max&&(this.value=this.max),$(this.refs.container).css("width",$(this).width()+"px");const t=$(this.refs.container).width()*this.value/this.max;if($(this.refs.prg).css("width",t+"px").css("height",$(this.refs.container).height()+"px"),this.enable){const e=t-$(this.refs.point).width()/2,s=Math.floor(($(this.refs.prg).height()-$(this.refs.point).height())/2);$(this.refs.point).css("left",e+"px").css("top",s+"px")}}enable_dragging(){$(this.refs.point).css("user-select","none").css("cursor","default"),$(this.refs.point).on("mousedown",t=>{t.preventDefault();const e=$(this.refs.container).offset();$(window).on("mousemove",t=>{let s=t.clientX-e.left;s=s<0?0:s;const i=$(this.refs.container).width();return s=s>i?i:s,this.value=s*this.max/i,this.calibrate(),this._onchanging({id:this.aid,data:this.value})}),$(window).on("mouseup",t=>(this._onchange({id:this.aid,data:this.value}),$(window).unbind("mousemove",null),$(window).unbind("mouseup",null)))})}layout(){return[{el:"div",class:"container",ref:"container",children:[{el:"div",class:"progress",ref:"prg"},{el:"div",class:"dragpoint",ref:"point"}]}]}}e.SliderTag=s,e.define("afx-slider",s)}(e=t.tag||(t.tag={}))}(e=t.GUI||(t.GUI={}))}(OS||(OS={})),function(t){let e;!function(t){let e;!function(t){class e extends t.ListViewTag{constructor(){super()}reload(t){}set onready(t){this._onready=t}set dir(t){$(this).attr("dir",t),this.calibrate()}get dir(){return $(this).attr("dir")}set dropdown(t){}set buttons(t){}showlist(t){}dropoff(t){}ondatachange(){this.calibrate()}mount(){if($(this.refs.container).css("width","100%").css("height","100%"),$(this.refs.mlist).css("position","absolute").css("display","block").css("width","100%"),this.observable.on("resize",t=>this.calibrate()),this._onready)return this._onready(this)}push(t){const e=super.push(t);return this.enable_drag(e),e}enable_drag(t){$(t).css("user-select","none").css("cursor","default").css("display","block").css("position","absolute").on("mousedown",e=>{const s=$(this.refs.mlist).offset();e.preventDefault();const i=$(t).offset();i.top=e.clientY-i.top,i.left=e.clientX-i.left;const r=function(e){let r=e.clientY-i.top-s.top,a=e.clientX-s.left-i.left;return a=a<0?0:a,r=r<0?0:r,$(t).css("top",r+"px").css("left",a+"px")};var a=function(t){return $(window).unbind("mousemove",r),$(window).unbind("mouseup",a)};return $(window).on("mousemove",r),$(window).on("mouseup",a)})}calibrate(){let t=20,e=20;$(this.refs.mlist).css("height",$(this.refs.container).height()+"px");const s=$(this.refs.mlist).width(),i=$(this.refs.mlist).height();$(this.refs.mlist).children().each((r,a)=>{$(a).css("top",t+"px").css("left",e+"px");const h=$(a).width(),n=$(a).height();"vertical"===this.dir?(t+=n+20,t+n>i&&(t=20,e+=h+20)):(e+=h+20,e+h>s&&(e=20,t+=n+20))})}}t.FloatListTag=e,t.define("afx-float-list",e)}(e=t.tag||(t.tag={}))}(e=t.GUI||(t.GUI={}))}(OS||(OS={})),function(t){let e;!function(t){let e;!function(e){class s extends t.AFXTag{constructor(){super(),this._day=0,this._month=0,this._year=0,this._ondateselect=t=>{}}init(){$(this).css("height","100%"),$(this.refs.grid).css("width","100%")}reload(t){}get selectedDate(){return this._selectedDate}set ondateselect(t){this._ondateselect=t}mount(){$(this.refs.prev).click(t=>this.prevmonth()),$(this.refs.next).click(t=>this.nextmonth());const t=this.refs.grid;t.header=[{text:"__(Sun)"},{text:"__(Mon)"},{text:"__(Tue)"},{text:"__(Wed)"},{text:"__(Thu)"},{text:"__(Fri)"},{text:"__(Sat)"}],t.oncellselect=t=>{this.dateselect(t)},this.observable.on("resize",t=>this.calibrate()),this.calibrate(),this.calendar(null)}dateselect(t){if(!t.data.item)return;const e=t.data.item.data.text;if(""===e)return;const s={id:this.aid,data:new Date(this._year,this._month,parseInt(e))};return this._ondateselect(s),this._selectedDate=s.data,this.observable.trigger("dateselect",s)}calibrate(){$(this.refs.grid).css("height",$(this).height()-$(this.refs.ctrl).height()+"px")}prevmonth(){this._selectedDate=void 0,this._month--,this._month<0&&(this._month=11,this._year--),this.calendar(new Date(this._year,this._month,1))}nextmonth(){return this._selectedDate=void 0,this._month++,this._month>11&&(this._month=0,this._year++),this.calendar(new Date(this._year,this._month,1))}calendar(t){let e,s,i;t||(t=new Date),this._day=t.getDate(),this._month=t.getMonth(),this._year=t.getFullYear();const r=(new Date).getDate(),a=(new Date).getMonth(),h=(new Date).getFullYear(),n=[__("January"),__("February"),__("March"),__("April"),__("May"),__("June"),__("July"),__("August"),__("September"),__("October"),__("November"),__("December")],o=new Date(this._year,this._month,1),l=new Date(this._year,this._month+1,1),c=o.getDay(),d=Math.round((l.getTime()-o.getTime())/864e5),f=[];let u=[];for(e=0,i=c-1,s=0<=i;s?e<=i:e>=i;s?e++:e--)u.push({text:""});e=c;for(let t=1,s=d,i=1<=s;i?t<=s:t>=s;i?t++:t--)e%=7,0===e&&(f.push(u),u=[]),r===t&&this._month===a&&this._year===h?u.push({text:t,selected:!0}):u.push({text:t}),e++;for(let t=0,e=7-u.length,s=0<=e;s?t<=e:t>=e;s?t++:t--)u.push({text:""});f.push(u);this.refs.grid.rows=f,this.refs.mlbl.text=`${n[this._month]} ${this._year}`}layout(){return[{el:"div",ref:"ctrl",children:[{el:"i",class:"prevmonth",ref:"prev"},{el:"afx-label",ref:"mlbl"},{el:"i",class:"nextmonth",ref:"next"}]},{el:"afx-grid-view",ref:"grid"}]}}e.CalendarTag=s,e.define("afx-calendar-view",s)}(e=t.tag||(t.tag={}))}(e=t.GUI||(t.GUI={}))}(OS||(OS={})),function(t){let e;!function(t){let e;!function(e){class s extends t.AFXTag{constructor(){super(),this._oncolorselect=t=>{}}init(){}reload(t){}get selectedColor(){return this._selectedColor}set oncolorselect(t){this._oncolorselect=t}mount(){$(this.refs.wrapper).css("width","310px").css("height","190px").css("display","block").css("padding","3px"),$(this.refs.palette).css("width","284px").css("height","155px").css("float","left"),$(this.refs.colorval).css("width","15px").css("height","155px").css("text-align","center").css("margin-left","3px").css("display","block").css("float","left"),$(this.refs.inputwrp).css("margin-top","3px"),$(this.refs.hextext).css("width","70px").css("margin-left","3px").css("margin-right","5px"),this.build_palette()}build_palette(){const t=$(this.refs.palette).get(0).getContext("2d");let e=t.createLinearGradient(0,0,$(this.refs.palette).width(),0);e.addColorStop(0,"rgb(255, 0, 0)"),e.addColorStop(.15,"rgb(255, 0, 255)"),e.addColorStop(.33,"rgb(0, 0, 255)"),e.addColorStop(.49,"rgb(0, 255, 255)"),e.addColorStop(.67,"rgb(0, 255, 0)"),e.addColorStop(.84,"rgb(255, 255, 0)"),e.addColorStop(1,"rgb(255, 0, 0)"),e.addColorStop(0,"rgb(0, 0, 0)"),t.fillStyle=e,t.fillRect(0,0,t.canvas.width,t.canvas.height),e=t.createLinearGradient(0,0,0,$(this.refs.palette).width()),e.addColorStop(0,"rgba(255, 255, 255, 1)"),e.addColorStop(.5,"rgba(255, 255, 255, 0)"),e.addColorStop(.5,"rgba(0, 0, 0, 0)"),e.addColorStop(1,"rgba(0, 0, 0, 1)"),t.fillStyle=e,t.fillRect(0,0,t.canvas.width,t.canvas.height);const s=function(t){let e=t.toString(16);return 1===e.length&&(e="0"+e),e},i=e=>{$(this.refs.palette).css("cursor","crosshair");const i=$(this.refs.palette).offset(),r=e.pageX-i.left,a=e.pageY-i.top,h=t.getImageData(r,a,1,1);return{r:h.data[0],g:h.data[1],b:h.data[2],text:"rgb("+h.data[0]+", "+h.data[1]+", "+h.data[2]+")",hex:"#"+s(h.data[0])+s(h.data[1])+s(h.data[2])}},r=t=>{const e=i(t);return $(this.refs.colorval).css("background-color",e.text)};$(this.refs.palette).mouseenter(t=>$(this.refs.palette).on("mousemove",r)),$(this.refs.palette).mouseout(t=>{if($(this.refs.palette).unbind("mousemove",r),this.selectedColor)return $(this.refs.colorval).css("background-color",this.selectedColor.text)}),$(this.refs.palette).on("click",t=>{const e=i(t);$(this.refs.rgbtext).html(e.text),$(this.refs.hextext).val(e.hex),this._selectedColor=e;const s={id:this.aid,data:e};return this._oncolorselect(s),this.observable.trigger("colorselect",e)})}layout(){return[{el:"div",ref:"wrapper",children:[{el:"canvas",class:"color-palette",ref:"palette"},{el:"color-sample",ref:"colorval"},{el:"div",class:"afx-clear"},{el:"div",ref:"inputwrp",children:[{el:"input",ref:"hextext"},{el:"span",ref:"rgbtext"}]}]}]}}e.ColorPickerTag=s,e.define("afx-color-picker",s)}(e=t.tag||(t.tag={}))}(e=t.GUI||(t.GUI={}))}(OS||(OS={})),function(t){let e;!function(e){let s;!function(s){class i extends e.AFXTag{constructor(){super()}init(){this.data=[],this.status=!0,this.showhidden=!1,this.chdir=!0,this.view="list",this._onfileopen=this._onfileselect=t=>{},this._header=[{text:"__(File name)"},{text:"__(Type)"},{text:"__(Size)"}]}reload(t){}set fetch(t){this._fetch=t}set onfileselect(t){this._onfileselect=t}set onfileopen(t){this._onfileopen=t}set view(t){$(this).attr("view",t),this.switchView()}get view(){return $(this).attr("view")}set chdir(t){this.attsw(t,"chdir")}get chdir(){return this.hasattr("chdir")}set status(t){this.attsw(t,"status"),t?$(this.refs.status).show():$(this.refs.status).hide()}get status(){return this.hasattr("status")}set showhidden(t){this.attsw(t,"showhidden"),this.data&&this.switchView()}get showhidden(){return this.hasattr("showhidden")}get selectedFile(){return this._selectedFile}set path(e){e&&(this._path=e,this._fetch&&this._fetch(e).then(t=>{t&&(this.data=t.sort(this.sortByName).sort(this.sortByType),this.status&&(this.refs.status.text=" "))}).catch(e=>t.announcer.oserror(e.toString(),e)))}get path(){return this._path}set data(t){t&&(this._data=t,this.refreshData())}get data(){return this._data}set ondragndrop(t){this.refs.treeview.ondragndrop=t,this.refs.listview.ondragndrop=t}sortByType(t,e){return t.type||(t.type="none"),e.type||(e.type="none"),t.type.toLowerCase().localeCompare(e.type.toLowerCase())}sortByName(t,e){return t.filename&&(t.name=t.filename),e.filename&&(e.name=e.filename),t.name.toLowerCase().localeCompare(e.name.toLowerCase())}calibrate(){let t=$(this).outerHeight();const e=$(this).width();this.status&&(t-=$(this.refs.status).height()+10),$(this.refs.listview).css("height",t+"px"),$(this.refs.gridview).css("height",t+"px"),$(this.refs.treecontainer).css("height",t+"px"),$(this.refs.listview).css("width",e+"px"),$(this.refs.gridview).css("width",e+"px"),$(this.refs.treecontainer).css("width",e+"px")}refreshList(){const t=[];$.each(this.data,(e,s)=>{("."!==s.filename[0]||this.showhidden)&&(s.text=s.filename,s.text.length>10&&(s.text=s.text.substring(0,9)+"..."),s.iconclass=s.iconclass?s.iconclass:s.type,s.icon=s.icon,t.push(s))}),this.refs.listview.data=t}refreshGrid(){const t=[];$.each(this.data,(e,s)=>{if("."===s.filename[0]&&!this.showhidden)return;s.text=s.filename,s.iconclass=s.iconclass?s.iconclass:s.type;const i=[s,{text:s.mime,data:s},{text:s.size,data:s}];return t.push(i)}),this.refs.gridview.rows=t}refreshTree(){const t={text:this.path,path:this.path,open:!0,nodes:this.getTreeData(this.data)};this.refs.treeview.data=t}getTreeData(t){const e=[];return $.each(t,(t,s)=>{if("."!==s.filename[0]||this.showhidden)return s.text=s.filename,"dir"===s.type&&(s.nodes=[],s.open=!1),s.iconclass=s.iconclass?s.iconclass:s.type,s.icon=s.icon,e.push(s)}),e}refreshData(){if(this.data)switch(this.data.sort(this.sortByName).sort(this.sortByType),this.view){case"icon":return this.refreshList();case"list":return this.refreshGrid();default:return this.refreshTree()}}switchView(){switch($(this.refs.listview).hide(),$(this.refs.gridview).hide(),$(this.refs.treecontainer).hide(),this._selectedFile=void 0,this.view){case"icon":$(this.refs.listview).show();break;case"list":$(this.refs.gridview).show();break;default:$(this.refs.treecontainer).show()}this.refreshData(),this.calibrate(),this.status&&(this.refs.status.text=" ")}fileselect(t){t.path===this.path&&(t.type="dir",t.mime="dir"),this.status&&(this.refs.status.text=__("Selected: {0} ({1} bytes)",t.filename,t.size?t.size:"0"));const e={id:this.aid,data:t};this._selectedFile=t,this._onfileselect(e),this.observable.trigger("fileselect",e)}filedbclick(t){if(t.path===this.path&&(t.type="dir",t.mime="dir"),"dir"===t.type&&this.chdir)this.path=t.path;else{const e={id:this.aid,data:t};this._onfileopen(e),this.observable.trigger("fileopen",e)}}mount(){this.observable.on("resize",t=>this.calibrate());const t=this.refs.treeview;t.fetch=t=>new Promise((e,s)=>this._fetch&&t.data.path?this._fetch(t.data.path).then(t=>e(this.getTreeData(t.sort(this.sortByName).sort(this.sortByType)))).catch(t=>s(__e(t))):e(void 0));const e=this.refs.gridview,s=this.refs.listview;e.resizable=!0,e.header=this._header,t.dragndrop=!0,s.dragndrop=!0,s.onlistselect=t=>{this.fileselect(t.data.item.data)},e.onrowselect=t=>{this.fileselect($(t.data.item).children()[0].data)},t.ontreeselect=t=>{this.fileselect(t.data.item.data)},s.onlistdbclick=t=>{this.filedbclick(t.data.item.data)},e.oncelldbclick=t=>{this.filedbclick(t.data.item.data)},t.ontreedbclick=t=>{this.filedbclick(t.data.item.data)},this.switchView()}layout(){return[{el:"afx-list-view",ref:"listview"},{el:"div",class:"treecontainer",ref:"treecontainer",children:[{el:"afx-tree-view",ref:"treeview"}]},{el:"afx-grid-view",ref:"gridview"},{el:"afx-label",class:"status",ref:"status"}]}}s.FileViewTag=i,s.define("afx-file-view",i)}(s=e.tag||(e.tag={}))}(e=t.GUI||(t.GUI={}))}(OS||(OS={})),function(t){let e;!function(t){let e;!function(e){class s extends t.AFXTag{constructor(){super()}init(){$(this.refs.yield).css("position","relative").css("width","100%").css("height","100%"),$(this).css("position","absolute").css("z-index",1e6)}reload(t){}set width(t){t&&(this._width=t,this.calibrate())}get width(){return this._width}set height(t){t&&(this._height=t,this.calibrate())}get height(){return this._height}mount(){return this.calibrate()}calibrate(){return $(this).css("width",this.width).css("height",this.height),this.observable.trigger("resize",{id:this.aid,data:{w:this.width,h:this.height}})}layout(){return[{el:"afx-vbox",ref:"yield"}]}}e.OverlayTag=s,e.define("afx-overlay",s)}(e=t.tag||(t.tag={}))}(e=t.GUI||(t.GUI={}))}(OS||(OS={})),function(t){let e;!function(e){let s;!function(s){class i extends e.AFXTag{constructor(){super(),this._onappselect=t=>{}}reload(t){}init(){this._items=[]}layout(){return[]}get items(){return this._items}set selectedApp(t){this._selectedApp=t;let e=void 0;for(let s of this.items)s.app.blur(),$(s.domel).removeClass(),t&&t===s.app&&(e=s.domel);e&&($(e).addClass("selected"),$(Ant.OS.GUI.workspace)[0].unselect())}get selectedApp(){return this._selectedApp}newapp(t){this.items.push(t);const e=$("<afx-button>"),s=e[0];e.appendTo(this),e[0].uify(this.observable),s.set(t),s.data=t.app,e.attr("tooltip","cr:"+t.app.title()),t.domel=s,s.onbtclick=e=>{e.id=this.aid,this._onappselect(e),t.app.show()},this.selectedApp=t.app}removeapp(t){let e=-1;const s=this.items;for(let i=0;i<s.length;i++){if(s[i].app.pid===t.pid){e=i;break}}-1!==e&&(delete this.items[e].app,this.items.splice(e,1),$($(this).children()[e]).remove())}mount(){this.contextmenuHandle=(t,e)=>{if(t.target===this)return;const s=$(t.target).closest("afx-button")[0].data;return e.items=[{text:"__(Show)",dataid:"show"},{text:"__(Hide)",dataid:"hide"},{text:"__(Close)",dataid:"quit"}],e.onmenuselect=function(t){const e=t.data.item.data;if(s[e.dataid])return s[e.dataid]()},e.show(t)},t.announcer.trigger("sysdockloaded",void 0)}}s.AppDockTag=i,s.define("afx-apps-dock",i)}(s=e.tag||(e.tag={}))}(e=t.GUI||(t.GUI={}))}(OS||(OS={})),function(t){let e;!function(t){let e;!function(e){class s extends t.AFXTag{constructor(){super(),this._osmenu={text:__("Start"),iconclass:"fa fa-circle"},this._view=!1}init(){}reload(t){}attachservice(t){return this.refs.systray.unshift(t),t.attach(this.refs.systray)}open(){const t=this.refs.applist,e=t.selectedItem;e&&e.data&&"header"!==e.data.dataid&&(this.toggle(!1),Ant.OS.GUI.openWith(e.data),t.unselect())}search(t){const e=this.refs.applist;switch(t.which){case 27:return this.toggle(!1);case 37:return t.preventDefault();case 38:return e.selectPrev(),t.preventDefault();case 39:return t.preventDefault();case 40:return e.selectNext(),t.preventDefault();case 13:return t.preventDefault(),this.open();default:var s=this.refs.search.value;if(!(s.length>=3))return this.refreshAppList();var i=Ant.OS.API.search(s);if(0===i.length)return;e.data=i}}detachservice(t){this.refs.systray.delete(t.domel)}layout(){return[{el:"div",ref:"panel",children:[{el:"afx-menu",ref:"osmenu",class:"afx-panel-os-menu"},{el:"afx-menu",id:"appmenu",ref:"appmenu",class:"afx-panel-os-app"},{el:"afx-menu",id:"systray",ref:"systray",class:"afx-panel-os-stray"}]},{el:"afx-overlay",id:"start-panel",ref:"overlay",children:[{el:"afx-hbox",height:30,children:[{el:"div",width:30,id:"searchicon"},{el:"input",ref:"search"}]},{el:"afx-list-view",id:"applist",ref:"applist"},{el:"afx-hbox",id:"btlist",height:30,children:[{el:"afx-button",ref:"btscreen",tooltip:__("ct:Toggle fullscreen")},{el:"afx-button",ref:"btuser",tooltip:__("ct:User: {0}",Ant.OS.setting.user.username)},{el:"afx-button",ref:"btlogout",tooltip:__("ct:Logout")}]}]}]}refreshAppList(){let t,e;const s=[];for(t in Ant.OS.setting.system.packages)e=Ant.OS.setting.system.packages[t],e&&e.app&&s.push(e);for(t in Ant.OS.setting.system.menu)e=Ant.OS.setting.system.menu[t],s.push(e);s.sort((function(t,e){return t.text<e.text?-1:t.text>e.text?1:0})),this.refs.applist.data=s}toggle(t){this._view=t,t?($(this.refs.overlay).show(),this.refreshAppList(),this.calibrate(),$(document).on("click",this._cb),this.refs.search.value="",$(this.refs.search).focus()):($(this.refs.overlay).hide(),$(document).unbind("click",this._cb))}calibrate(){this.refs.overlay.height=$(window).height()-$(this.refs.panel).height()+"px"}mount(){this.refs.osmenu.items=[this._osmenu],this._cb=t=>$(t.target).closest($(this.refs.overlay)).length||$(t.target).closest(this.refs.osmenu).length?$(this.refs.search).focus():this.toggle(!1),$(this.refs.appmenu).css("z-index",1e6),$(this.refs.systray).css("z-index",1e6),this.refs.btscreen.set({iconclass:"fa fa-tv",onbtclick:t=>(this.toggle(!1),Ant.OS.GUI.toggleFullscreen())}),this.refs.btuser.set({iconclass:"fa fa-user-circle-o",onbtclick:t=>(this.toggle(!1),Ant.OS.GUI.openDialog("InfoDialog",Ant.OS.setting.user))}),this.refs.btlogout.set({iconclass:"fa fa-power-off",onbtclick:t=>(this.toggle(!1),Ant.OS.exit())}),this.refs.osmenu.onmenuselect=t=>this.toggle(!0),$(this.refs.search).keyup(t=>this.search(t)),$(this.refs.applist).click(t=>this.open()),Ant.OS.GUI.bindKey("CTRL- ",t=>!1===this._view?this.toggle(!0):this.toggle(!1)),Ant.OS.announcer.trigger("syspanelloaded",void 0),$(this.refs.overlay).css("left",0).css("top",$(this.refs.panel).height()+"px").css("bottom","0").hide()}}e.SystemPanelTag=s,e.define("afx-sys-panel",s)}(e=t.tag||(t.tag={}))}(e=t.GUI||(t.GUI={}))}(OS||(OS={})),function(t){let e,s;!function(t){t.Announcer=class{constructor(){this.observable={},this.enable=!0}disable(){return this.off("*"),this.enable=!1}on(t,e){this.enable&&(this.observable[t]||(this.observable[t]={one:new Set,many:new Set}),this.observable[t].many.add(e))}one(t,e){this.enable&&(this.observable[t]||(this.observable[t]={one:new Set,many:new Set}),this.observable[t].one.add(e))}off(t,e){const s=(t,e)=>{if(this.observable[t])return e?(this.observable[t].one.delete(e),this.observable[t].many.delete(e)):this.observable[t]?delete this.observable[t]:void 0};if("*"===t)for(let t in this.observable)s(t,e);else s(t,e)}trigger(t,e){const s=(t,e)=>{const s=[t,"*"];for(let t of s)this.observable[t]&&(this.observable[t].one.forEach(t=>t(e)),this.observable[t].one=new Set,this.observable[t].many.forEach(t=>t(e)))};if("*"!==t)return s(t,e);for(let t in this.observable){this.observable[t];"*"!==t&&s(t,e)}}}}(e=t.API||(t.API={})),function(t){t.observable=new e.Announcer,t.listeners={},t.on=function(e,s,i){t.listeners[i.pid]||(t.listeners[i.pid]=[]),t.listeners[i.pid].push({e:e,f:s}),t.observable.on(e,s)},t.trigger=function(e,s){t.observable.trigger(e,s)},t.osfail=function(e,s){t.ostrigger("fail",{m:e,e:s})},t.oserror=function(e,s){t.ostrigger("error",{m:e,e:s})},t.osinfo=function(e){t.ostrigger("info",{m:e,e:null})},t.ostrigger=function(e,s){t.trigger(e,{id:0,data:s,name:"OS"})},t.unregister=function(e){if(t.listeners[e.pid]&&t.listeners[e.pid].length>0){for(let s of t.listeners[e.pid])t.observable.off(s.e,s.f);delete t.listeners[e.pid]}},t.getMID=function(){return t.quota+=1,t.quota}}(s=t.announcer||(t.announcer={}))}(OS||(OS={}));var Ant=this; |