define(["gpui-style-inject","react","mobx"],(function(e,t,r){"use strict";e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;var n="default"in t?t.default:t,o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};
/*! *****************************************************************************
    Copyright (c) Microsoft Corporation.

    Permission to use, copy, modify, and/or distribute this software for any
    purpose with or without fee is hereby granted.

    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
    REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
    AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
    INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
    LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
    OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
    PERFORMANCE OF THIS SOFTWARE.
    ***************************************************************************** */var a=function(){return(a=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function i(e,t,r,n){var o,a=arguments.length,i=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,n);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(i=(a<3?o(i):a>3?o(t,r,i):o(t,r))||i);return a>3&&i&&Object.defineProperty(t,r,i),i}function c(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function c(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,c)}s((n=n.apply(e,t||[])).next())}))}function s(e,t){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}if(e("html, body, #root {\n  width: 100%;\n  height: 100%;\n  margin: 0;\n  padding: 0;\n  overflow: hidden;\n}\n\n.amap-logo {\n  display: none !important;\n}\n\n.amap-copyright {\n  display: none !important;\n}\n"),!t.useState)throw new Error("mobx-react-lite requires React with Hooks support");if(!r.spy)throw new Error("mobx-react-lite requires mobx at least version 4 to be available");function l(){return(l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function u(){var e=t.useState(0)[1];return t.useCallback((function(){e((function(e){return e+1}))}),[])}function p(e){return r.getDependencyTree(e)}var f,d=1e4,y=new Set;function m(){void 0===f&&(f=setTimeout(h,1e4))}function h(){f=void 0;var e=Date.now();y.forEach((function(t){var r=t.current;r&&e>=r.cleanAt&&(r.reaction.dispose(),t.current=null,y.delete(t))})),y.size>0&&m()}var v={};function b(e){return"observer"+e}function w(e,t,o){void 0===t&&(t="observed"),void 0===o&&(o=v);var a,i=(o.useForceUpdate||u)(),c=n.useRef(null);if(!c.current){var s=new r.Reaction(b(t),(function(){l.mounted?i():(s.dispose(),c.current=null)})),l=function(e){return{cleanAt:Date.now()+d,reaction:e}}(s);c.current=l,a=c,y.add(a),m()}var f,h,w=c.current.reaction;if(n.useDebugValue(w,p),n.useEffect((function(){var e;return e=c,y.delete(e),c.current?c.current.mounted=!0:(c.current={reaction:new r.Reaction(b(t),(function(){i()})),cleanAt:1/0},i()),function(){c.current.reaction.dispose(),c.current=null}}),[]),w.track((function(){try{f=e()}catch(e){h=e}})),h)throw h;return f}function g(e,r){var n,o,a,i=l({forwardRef:!1},r),c=e.displayName||e.name,s=function(t,r){return w((function(){return e(t,r)}),c)};return s.displayName=c,n=i.forwardRef?t.memo(t.forwardRef(s)):t.memo(s),o=e,a=n,Object.keys(o).forEach((function(e){O[e]||Object.defineProperty(a,e,Object.getOwnPropertyDescriptor(o,e))})),n.displayName=c,n}var O={$$typeof:!0,render:!0,compare:!0,type:!0};function E(e){var t=e.children,r=e.render,n=t||r;return"function"!=typeof n?null:w(n)}function R(e,t,r,n,o){var a="children"===t?"render":"children",i="function"==typeof e[t],c="function"==typeof e[a];return i&&c?new Error("MobX Observer: Do not use children and render in the same time in`"+r):i||c?null:new Error("Invalid prop `"+o+"` of type `"+typeof e[t]+"` supplied to `"+r+"`, expected `function`.")}E.propTypes={children:R,render:R},E.displayName="Observer";var S=0;var _={};function k(e){return _[e]||(_[e]=function(e){if("function"==typeof Symbol)return Symbol(e);var t="__$mobx-react "+e+" ("+S+")";return S++,t}(e)),_[e]}function j(e,t){if(x(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(var o=0;o<r.length;o++)if(!Object.hasOwnProperty.call(t,r[o])||!x(e[r[o]],t[r[o]]))return!1;return!0}function x(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function P(e,t,r){Object.hasOwnProperty.call(e,t)?e[t]=r:Object.defineProperty(e,t,{enumerable:!1,configurable:!0,writable:!0,value:r})}var C=k("patchMixins"),M=k("patchedDefinition");function T(e,t){for(var r=this,n=arguments.length,o=new Array(n>2?n-2:0),a=2;a<n;a++)o[a-2]=arguments[a];t.locks++;try{var i;return null!=e&&(i=e.apply(this,o)),i}finally{t.locks--,0===t.locks&&t.methods.forEach((function(e){e.apply(r,o)}))}}function A(e,t){return function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];T.call.apply(T,[this,e,t].concat(n))}}function D(e,t,r){var n=function(e,t){var r=e[C]=e[C]||{},n=r[t]=r[t]||{};return n.locks=n.locks||0,n.methods=n.methods||[],n}(e,t);n.methods.indexOf(r)<0&&n.methods.push(r);var o=Object.getOwnPropertyDescriptor(e,t);if(!o||!o[M]){var a=e[t],i=function e(t,r,n,o,a){var i,c=A(a,o);return(i={})[M]=!0,i.get=function(){return c},i.set=function(a){if(this===t)c=A(a,o);else{var i=e(this,r,n,o,a);Object.defineProperty(this,r,i)}},i.configurable=!0,i.enumerable=n,i}(e,t,o?o.enumerable:void 0,n,a);Object.defineProperty(e,t,i)}}var L=r.$mobx||"$mobx",I=k("isUnmounted"),U=k("skipRender"),$=k("isForcingUpdate");function F(e){var r=e.prototype;if(r.componentWillReact)throw new Error("The componentWillReact life-cycle event is no longer supported");if(e.__proto__!==t.PureComponent)if(r.shouldComponentUpdate){if(r.shouldComponentUpdate!==q)throw new Error("It is not allowed to use shouldComponentUpdate in observer based components.")}else r.shouldComponentUpdate=q;H(r,"props"),H(r,"state");var n=r.render;return r.render=function(){return N.call(this,n)},D(r,"componentWillUnmount",(function(){this.render[L]&&this.render[L].dispose(),this[I]=!0})),e}function N(e){var n=this;P(this,U,!1),P(this,$,!1);var o,a=(o=this).displayName||o.name||o.constructor&&(o.constructor.displayName||o.constructor.name)||"<component>",i=e.bind(this),c=!1,s=new r.Reaction(a+".render()",(function(){if(!c&&(c=!0,!0!==n[I])){var e=!0;try{P(n,$,!0),n[U]||t.Component.prototype.forceUpdate.call(n),e=!1}finally{P(n,$,!1),e&&s.dispose()}}}));function l(){c=!1;var e=void 0,t=void 0;if(s.track((function(){try{t=r._allowStateChanges(!1,i)}catch(t){e=t}})),e)throw e;return t}return s.reactComponent=this,l[L]=s,this.render=l,l.call(this)}function q(e,t){return this.state!==t||!j(this.props,e)}function H(e,t){var n=k("reactProp_"+t+"_valueHolder"),o=k("reactProp_"+t+"_atomHolder");function a(){return this[o]||P(this,o,r.createAtom("reactive "+t)),this[o]}Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:function(){var e=!1;return r._allowStateReadsStart&&r._allowStateReadsEnd&&(e=r._allowStateReadsStart(!0)),a.call(this).reportObserved(),r._allowStateReadsStart&&r._allowStateReadsEnd&&r._allowStateReadsEnd(e),this[n]},set:function(e){this[$]||j(this[n],e)?P(this,n,e):(P(this,n,e),P(this,U,!0),a.call(this).reportChanged(),P(this,U,!1))}})}var W="function"==typeof Symbol&&Symbol.for,z=W?Symbol.for("react.forward_ref"):"function"==typeof t.forwardRef&&t.forwardRef((function(e){return null})).$$typeof,B=W?Symbol.for("react.memo"):"function"==typeof t.memo&&t.memo((function(e){return null})).$$typeof;function G(e){if(!0===e.isMobxInjector&&console.warn("Mobx observer: You are trying to use 'observer' on a component that already has 'inject'. Please apply 'observer' before applying 'inject'"),B&&e.$$typeof===B)throw new Error("Mobx observer: You are trying to use 'observer' on a function component wrapped in either another observer or 'React.memo'. The observer already applies 'React.memo' for you.");if(z&&e.$$typeof===z){var r=e.render;if("function"!=typeof r)throw new Error("render property of ForwardRef was not a function");return t.forwardRef((function(){var e=arguments;return t.createElement(E,null,(function(){return r.apply(void 0,e)}))}))}return"function"!=typeof e||e.prototype&&e.prototype.render||e.isReactClass||Object.prototype.isPrototypeOf.call(t.Component,e)?F(e):g(e)}if(!t.Component)throw new Error("mobx-react requires React to be available");if(!r.observable)throw new Error("mobx-react requires mobx to be available");var J=0,X=[];function Y(){return c(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new Promise((function(e,t){switch(J){case 0:J=1,X.push({resolve:e,reject:t}),(r=window.document.createElement("script")).type="text/javascript",r.async=!0,r.src="../../esmap-1.6.min.js",window.document.head.appendChild(r),r.onload=function(){for(J=2;X.length>0;)(0,X.pop().resolve)(window.esmap)},r.onerror=function(e){for(J=0;X.length>0;)(0,X.pop().reject)(e)};break;case 1:X.push({resolve:e,reject:t});break;case 2:e(window.esmap);break;default:t()}var r}))]}))}))}return function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.ref=n.createRef(),t.tmOfLayer={},t.isReady=!1,t.autoplay=function(){t.props.gpui.params.interval>0&&(t.map.rotateAngle=t.map.rotateAngle-.1,t.timer=setTimeout(t.autoplay,t.props.gpui.params.interval/10))},t.clearAutoplay=function(){clearTimeout(t.timer)},t.connect=function(e){var r=e.wsAddress,n=e.buildingId,o=e.floor;t.disconnect();var a=t.map.getFloor(o);if(t.props.gpui.params.wsAddress){var i=new WebSocket(r);i.addEventListener("open",(function(){i.send(JSON.stringify({building:n,floor:a.floorName}))})),i.addEventListener("message",(function(e){var r=JSON.parse(e.data),n=t.props.gpui.params.scale||1;switch(r.type){case"INIT_RESOURCE":var i=new t.EsMap.ESLayer(t.EsMap.ESLayerType.TEXT_MARKER);i.name="layer",a.addLayer(i),t.layer={floor:o,instance:i},t.tmOfLayer={},r.items.forEach((function(e){t.addTextMarker({item:e,scale:n,layer:i,floorLayer:a})}));break;case"DELETE_RESOURCE":t.removeTextMarker({item:r.resource});break;case"ADD_RESOURCE":case"UPDATE_RESOURCE":t.removeTextMarker({item:r.resource}),t.addTextMarker({item:r.resource,scale:n,layer:t.layer.instance,floorLayer:a})}})),t.socket=i}},t.addTextMarker=function(e){var r=e.item,n=e.scale,o=e.layer,a=e.floorLayer;if("device"===r.type&&Reflect.has(r.attrs,"coordinate_x")&&Reflect.has(r.attrs,"coordinate_y")){var i=parseFloat(r.room_info.position.x)+parseFloat(r.attrs.coordinate_x),c=parseFloat(r.room_info.position.y)+parseFloat(r.attrs.coordinate_y),s=new t.EsMap.ESTextMarker({id:r.id,image:"../../image/user.png",imageAlign:"bottom",imageSize:64,x:a.mapCoord.x+i*n,y:a.mapCoord.y+c*n,name:r.attrs.resource_name+"（"+r.attrs.using_status+"）\n"+r.attrs.network_status,spritify:!0,height:1.5,showLevel:20,scale:1,fillcolor:"255,0,0",fontsize:"12.0"}),l=function(){s&&(s.fillcolor="0,255,0"===s.fillcolor?"255,0,0":"0,255,0",setTimeout(l,1e3))};o.addMarker(s),l(),t.tmOfLayer[r.id]=s}},t.removeTextMarker=function(e){var r=e.item;"device"===r.type&&t.tmOfLayer[r.id]&&t.layer.instance.remove(t.tmOfLayer[r.id])},t.disconnect=function(){t.layer&&(t.layer.instance.removeAll(),t.map.getFloor(t.layer.floor).removeLayersByNames(t.layer.instance.name),t.layer=null,t.tmOfLayer={}),t.socket&&(t.socket.close(),t.socket=null)},t}return function(e,t){function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),t.prototype.componentDidMount=function(){var e=this;r.reaction((function(){return e.props.gpui.params.esMap||{}}),(function(t){return c(e,void 0,void 0,(function(){var e,r,n,o,i,c,l=this;return s(this,(function(s){switch(s.label){case 0:return e=t.token,r=t.mapId,n=t.themeID,o=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}(t,["token","mapId","themeID"]),!this.isReady&&e&&r&&n?this.EsMap?[3,2]:(i=this,[4,Y()]):[3,3];case 1:i.EsMap=s.sent(),s.label=2;case 2:c=a({container:this.ref.current,mapDataSrc:"../../data",mapThemeSrc:"../../data/theme",visibleFloors:"all",themeID:n,token:e},o),this.map=this.map||new this.EsMap.ESMap(c),this.map.openMapById(r),this.map.on("loadComplete",(function(){var e=new l.EsMap.ESControlOptions({position:l.EsMap.ESControlPositon.RIGHT_TOP,showBtnCount:7,imgURL:"../../image/wedgets/"});new l.EsMap.ESScrollFloorsControl(l.map,e),l.autoplay(),l.map.on("visibleFloorNumsChanged",(function(e){1===e.length?(l.clearAutoplay(),l.connect({wsAddress:l.props.gpui.params.wsAddress,buildingId:l.props.gpui.params.buildingId,floor:e[0]})):(l.autoplay(),l.disconnect())}))})),this.isReady=!0,s.label=3;case 3:return[2]}}))}))}),{fireImmediately:!0})},t.prototype.render=function(){return n.createElement("div",{style:{width:"100%",height:"100%"}},n.createElement("div",{ref:this.ref,style:{width:"100%",height:"100%"}}))},i([r.observable],t.prototype,"isReady",void 0),t=i([G],t)}(n.Component)}));
