define(["gpui-style-inject","react","mobx"],(function(e,t,r){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var a=n(e),i=n(t),s=o(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.
    ***************************************************************************** */
function l(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 s=e.length-1;s>=0;s--)(o=e[s])&&(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{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}l((n=n.apply(e,t||[])).next())}))}a.default("html, body, #root {\n  width: 100%;\n  height: 100%;\n  margin: 0;\n  padding: 0;\n  overflow: hidden; }\n\n.g__index {\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  height: 100%; }\n");var u="index-module_board__rSTu7",d="index-module_ring__gGi-m",f="index-module_ring__border__8r-9U",p="index-module_ring__content__5AA3c",h="index-module_data__HMGtQ",m="index-module_unit__AVNjj",v="index-module_name__RHgeB";if(a.default(".index-module_board__rSTu7 {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  width: 100%;\n  height: 100%; }\n  .index-module_board__rSTu7 .index-module_ring__gGi-m {\n    cursor: pointer;\n    position: relative;\n    width: 80vw;\n    height: 80vw;\n    border-radius: 50%;\n    overflow: hidden; }\n    .index-module_board__rSTu7 .index-module_ring__border__8r-9U {\n      position: absolute;\n      top: 0;\n      left: 0;\n      width: 100%;\n      height: 100%; }\n    .index-module_board__rSTu7 .index-module_ring__content__5AA3c {\n      display: flex;\n      flex-direction: column;\n      justify-content: center;\n      align-items: center;\n      width: 100%;\n      height: 100%;\n      border-radius: 50%; }\n      .index-module_board__rSTu7 .index-module_ring__content__5AA3c .index-module_data__HMGtQ {\n        position: relative;\n        line-height: 12vh;\n        font-size: 12vh; }\n        .index-module_board__rSTu7 .index-module_ring__content__5AA3c .index-module_data__HMGtQ .index-module_unit__AVNjj {\n          padding-left: 2vh;\n          font-size: 6.5vh; }\n  .index-module_board__rSTu7 .index-module_name__RHgeB {\n    margin-top: 8vh;\n    line-height: 8vh;\n    font-size: 8vh;\n    color: #cde0ff; }\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 y(){return y=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},y.apply(this,arguments)}function b(){var e=t.useState(0)[1];return t.useCallback((function(){e((function(e){return e+1}))}),[])}function _(e){return r.getDependencyTree(e)}var g,w=1e4,O=1e4,x=new Set;function j(){void 0===g&&(g=setTimeout(P,O))}function P(){g=void 0;var e=Date.now();x.forEach((function(t){var r=t.current;r&&e>=r.cleanAt&&(r.reaction.dispose(),t.current=null,x.delete(t))})),x.size>0&&j()}var E={};function C(e){return"observer"+e}function T(e,t,n){void 0===t&&(t="observed"),void 0===n&&(n=E);var o,a=(n.useForceUpdate||b)(),s=i.default.useRef(null);if(!s.current){var l=new r.Reaction(C(t),(function(){c.mounted?a():(l.dispose(),s.current=null)})),c=function(e){return{cleanAt:Date.now()+w,reaction:e}}(l);s.current=c,o=s,x.add(o),j()}var u,d,f=s.current.reaction;if(i.default.useDebugValue(f,_),i.default.useEffect((function(){var e;return e=s,x.delete(e),s.current?s.current.mounted=!0:(s.current={reaction:new r.Reaction(C(t),(function(){a()})),cleanAt:1/0},a()),function(){s.current.reaction.dispose(),s.current=null}}),[]),f.track((function(){try{u=e()}catch(e){d=e}})),d)throw d;return u}function k(e,r){var n,o,a,i=y({forwardRef:!1},r),s=e.displayName||e.name,l=function(t,r){return T((function(){return e(t,r)}),s)};return l.displayName=s,n=i.forwardRef?t.memo(t.forwardRef(l)):t.memo(l),o=e,a=n,Object.keys(o).forEach((function(e){S[e]||Object.defineProperty(a,e,Object.getOwnPropertyDescriptor(o,e))})),n.displayName=s,n}var S={$$typeof:!0,render:!0,compare:!0,type:!0};function A(e){var t=e.children,r=e.render,n=t||r;return"function"!=typeof n?null:T(n)}function R(e,t,r,n,o){var a="children"===t?"render":"children",i="function"==typeof e[t],s="function"==typeof e[a];return i&&s?new Error("MobX Observer: Do not use children and render in the same time in`"+r):i||s?null:new Error("Invalid prop `"+o+"` of type `"+typeof e[t]+"` supplied to `"+r+"`, expected `function`.")}A.propTypes={children:R,render:R},A.displayName="Observer";var $=0;var D={};function M(e){return D[e]||(D[e]=function(e){if("function"==typeof Symbol)return Symbol(e);var t="__$mobx-react "+e+" ("+$+")";return $++,t}(e)),D[e]}function N(e,t){if(U(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])||!U(e[r[o]],t[r[o]]))return!1;return!0}function U(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function H(e,t,r){Object.hasOwnProperty.call(e,t)?e[t]=r:Object.defineProperty(e,t,{enumerable:!1,configurable:!0,writable:!0,value:r})}var G=M("patchMixins"),K=M("patchedDefinition");function I(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 z(e,t){return function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];I.call.apply(I,[this,e,t].concat(n))}}function F(e,t,r){var n=function(e,t){var r=e[G]=e[G]||{},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[K]){var a=e[t],i=W(e,t,o?o.enumerable:void 0,n,a);Object.defineProperty(e,t,i)}}function W(e,t,r,n,o){var a,i=z(o,n);return(a={})[K]=!0,a.get=function(){return i},a.set=function(o){if(this===e)i=z(o,n);else{var a=W(this,t,r,n,o);Object.defineProperty(this,t,a)}},a.configurable=!0,a.enumerable=r,a}var B=r.$mobx||"$mobx",X=M("isUnmounted"),q=M("skipRender"),L=M("isForcingUpdate");function Q(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!==Y)throw new Error("It is not allowed to use shouldComponentUpdate in observer based components.")}else r.shouldComponentUpdate=Y;J(r,"props"),J(r,"state");var n=r.render;return r.render=function(){return V.call(this,n)},F(r,"componentWillUnmount",(function(){this.render[B]&&this.render[B].dispose(),this[X]=!0})),e}function V(e){var n=this;H(this,q,!1),H(this,L,!1);var o,a=(o=this).displayName||o.name||o.constructor&&(o.constructor.displayName||o.constructor.name)||"<component>",i=e.bind(this),s=!1,l=new r.Reaction(a+".render()",(function(){if(!s&&(s=!0,!0!==n[X])){var e=!0;try{H(n,L,!0),n[q]||t.Component.prototype.forceUpdate.call(n),e=!1}finally{H(n,L,!1),e&&l.dispose()}}}));function c(){s=!1;var e=void 0,t=void 0;if(l.track((function(){try{t=r._allowStateChanges(!1,i)}catch(t){e=t}})),e)throw e;return t}return l.reactComponent=this,c[B]=l,this.render=c,c.call(this)}function Y(e,t){return this.state!==t||!N(this.props,e)}function J(e,t){var n=M("reactProp_"+t+"_valueHolder"),o=M("reactProp_"+t+"_atomHolder");function a(){return this[o]||H(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[L]||N(this[n],e)?H(this,n,e):(H(this,n,e),H(this,q,!0),a.call(this).reportChanged(),H(this,q,!1))}})}var Z="function"==typeof Symbol&&Symbol.for,ee=Z?Symbol.for("react.forward_ref"):"function"==typeof t.forwardRef&&t.forwardRef((function(e){return null})).$$typeof,te=Z?Symbol.for("react.memo"):"function"==typeof t.memo&&t.memo((function(e){return null})).$$typeof;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");function re(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function ne(e){var t={exports:{}};return e(t,t.exports),t.exports}var oe=ne((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,n=(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},r(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=function(e){function t(t,r){void 0===r&&(r=500);var n=e.call(this,t)||this;return n._code=r,n}return n(t,e),Object.defineProperty(t.prototype,"code",{get:function(){return this._code},enumerable:!1,configurable:!0}),t}(Error);t.default=o})),ae=re(oe),ie=ne((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,n=(r=oe)&&r.__esModule?r:{default:r};var o=function(){return o=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},o.apply(this,arguments)},a=function(e,t){void 0===t&&(t={});var r=t.timeout,o=void 0===r?2e4:r,a=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,["timeout"]);return i(a),new Promise((function(t,r){fetch(e,a).then((function(e){return t(e)})).catch((function(e){return r(e)})),setTimeout((function(){r(new n.default("Timeout: "+o+"ms exceeded: \n\t"+e+"\t\n"+JSON.stringify(a)+" ",404))}),o)}))};a.onlyAllowedGetAndPost=!1;var i=function(e){switch(void 0===e&&(e={}),(e.method||"GET").toLocaleUpperCase()){case"PUT":a.onlyAllowedGetAndPost&&(e.method="POST",e.headers=o(o({},e.headers),{"X-HTTP-Method-Override":"PUT"}));break;case"DELETE":a.onlyAllowedGetAndPost&&(e.method="POST",e.headers=o(o({},e.headers),{"X-HTTP-Method-Override":"DELETE"}));break;case"PATCH":a.onlyAllowedGetAndPost&&(e.method="POST",e.headers=o(o({},e.headers),{"X-HTTP-Method-Override":"PATCH"}))}},s=a;t.default=s})),se=ne((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,n=(r=ie)&&r.__esModule?r:{default:r};var o=function(){return o=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},o.apply(this,arguments)},a=function(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}l((n=n.apply(e,t||[])).next())}))},i=function(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:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){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,s])}}},s=!1,l=[],c=function e(t,r){return void 0===r&&(r={}),a(void 0,void 0,Promise,(function(){var o,a;return i(this,(function(i){switch(i.label){case 0:return r=u(r),[4,(0,n.default)(t,r)];case 1:return 401!==(o=i.sent()).status?[2,o]:s?[4,new Promise((function(n){l.push((function(){n(e(t,r))}))}))]:[3,3];case 2:return[2,i.sent()];case 3:return e.refreshAccessToken?(s=!0,[4,e.refreshAccessToken()]):[3,6];case 4:return i.sent()?(r=u(r),[4,(0,n.default)(t,r)]):(l=[],s=!1,[2]);case 5:a=i.sent(),l.forEach((function(e){return e()})),l=[],s=!1,i.label=6;case 6:return a?[3,8]:(r=u(r),[4,(0,n.default)(t,r)]);case 7:a=i.sent(),i.label=8;case 8:return 401!==a.status?[2,a]:[2]}}))}))};c.additionalHeaders=void 0,c.refreshAccessToken=void 0;var u=function(e){return o(o({},e),{headers:o(o({},e.headers||{}),c.additionalHeaders)})},d=c;t.default=d})),le=re(se);let ce=class extends s.Component{constructor(e){super(e),this.padding="7vh 2vh 2vh",this.startColor="#0096ff",this.endColor="#00d8ff",this.setKey="",this.data={count:0,amount:0},this.getData=()=>c(this,void 0,void 0,(function*(){const{base_url:e,set_id:t,deviceToken:r}=this.props.gpui.params;if(e&&t&&r){this.timer&&(clearTimeout(this.timer),this.timer=null);try{le.additionalHeaders={"X-Gapper-OAuth-Token":r};const o=yield(n=`${e}/v1/chart/${t}/data`,c(void 0,void 0,void 0,(function*(){var e;if(!n)return;const t=yield le(`${n}`,{method:"POST",headers:{"Content-Type":"application/json;charset=UTF-8"}}),r=yield t.json();if(!t.ok)throw new ae(null===(e=r.error)||void 0===e?void 0:e.message,t.status);return r}))),a=o[this.setKey].data[0].length>=3?o[this.setKey].data[0][0]:"其他",i=o[this.setKey].data[0].length>=3?o[this.setKey].data[0][1]:o[this.setKey].data[0][0],s=o[this.setKey].data[0].length>=3?o[this.setKey].data[0][2]:o[this.setKey].data[0][1],[l,u]=((e,t=6)=>{if(!e)return["0",""];let r;return[[1,""],[1e4,"万"],[1e8,"亿"]].map((n=>{const[o,a]=n,i=e/o;if(i>=1){let e="";const n=i.toString();if(n.indexOf(".")>0){const r=i.toFixed(2),n=r.split(".");e=r.length>t?n[0].replace(/(?!^)(?=(\d{3})+$)/g,","):`${n[0].replace(/(?!^)(?=(\d{3})+$)/g,",")}.${n[1]}`}else e=n.replace(/(?!^)(?=(\d{3})+$)/g,",");r=[e,a]}})),r})(Number(s));this.data={name:a,count:i,amount:Math.round(100*s/1e4)/100,num:l,unit:u}}catch(e){console.error("@components:wall-iharbour/data-display-board: 组件渲染时发生错误",e)}var n;this.props.gpui.params.interval>0&&(this.timer=setTimeout(this.getData,this.props.gpui.params.interval))}})),this.gotoDetail=e=>{const t=this.props.gpui.params;this.props.gpui.root.navigate("@component:godiva/set",{base_url:t.base_url,set_id:t.page.set_id,share_id:t.page.share_id,"@theme":"normal",showSearchBar:!0,criteria:[{id:"__1",alias:"设备分区",key:t.page.filter_key,type:"string",level:!1,filter:{name:"",show:!1,type:"select",params:{isMultiple:!1,searchMode:"contain",default:e}}}],defaultTextColor:"#D4D4D4",padding:t.page.padding},{styles:{"@theme":"page"},mode:"replace"})},r.reaction((()=>e.gpui.params.padding),(e=>{this.padding=e||"7vh 2vh 2vh"}),{fireImmediately:!0}),r.reaction((()=>({startColor:e.gpui.params.startColor,endColor:e.gpui.params.endColor,setKey:e.gpui.params.key})),(({startColor:e,endColor:t,setKey:r})=>{this.startColor=e||"#0096ff",this.endColor=t||"#00d8ff",this.setKey=r||""}),{fireImmediately:!0}),r.reaction((()=>({baseURL:this.props.gpui.params.base_url,setId:this.props.gpui.params.set_id,deviceToken:this.props.gpui.params.deviceToken,interval:this.props.gpui.params.interval})),(()=>{this.getData()}),{fireImmediately:!0})}get fontColor(){return{backgroundImage:`linear-gradient(to bottom, ${this.startColor}, ${this.endColor})`,WebkitTextFillColor:"transparent",WebkitBackgroundClip:"text"}}render(){return s.createElement("div",{className:"g__index",style:{padding:this.padding}},s.createElement("div",{className:u},s.createElement("div",{className:d,onClick:()=>this.gotoDetail(this.props.gpui.params.name)},s.createElement("div",{className:f},s.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",version:"1.1",viewBox:"0 0 100 100"},s.createElement("defs",null,s.createElement("linearGradient",{id:"grad1",x1:"0%",y1:"0%",x2:"100%",y2:"100%"},s.createElement("stop",{offset:"0%",style:{stopColor:this.startColor,stopOpacity:1}}),s.createElement("stop",{offset:"100%",style:{stopColor:this.endColor,stopOpacity:1}}))),s.createElement("circle",{cx:"50",cy:"50",r:"50",stroke:"url(#grad1)",strokeWidth:"4",fill:"transparent"}))),s.createElement("div",{className:p},s.createElement("div",{className:h},s.createElement("span",{style:this.fontColor},this.data.count),s.createElement("span",{className:m,style:this.fontColor},this.props.gpui.params.topDataUnit)),s.createElement("div",{className:h},s.createElement("span",{style:this.fontColor},this.data.num),s.createElement("span",{className:m,style:this.fontColor},this.data.unit,this.props.gpui.params.bottomDataUnit)))),s.createElement("div",{className:v},this.data.name)))}};return l([r.observable],ce.prototype,"padding",void 0),l([r.observable],ce.prototype,"startColor",void 0),l([r.observable],ce.prototype,"endColor",void 0),l([r.observable],ce.prototype,"setKey",void 0),l([r.observable],ce.prototype,"data",void 0),l([r.computed],ce.prototype,"fontColor",null),ce=l([function(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'"),te&&e.$$typeof===te)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(ee&&e.$$typeof===ee){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(A,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)?Q(e):k(e)}],ce),ce}));
