(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[4862],{21103:e=>{e.exports={container:"container-pgo9gj31","intent-default":"intent-default-pgo9gj31",focused:"focused-pgo9gj31",readonly:"readonly-pgo9gj31",disabled:"disabled-pgo9gj31","with-highlight":"with-highlight-pgo9gj31",grouped:"grouped-pgo9gj31","adjust-position":"adjust-position-pgo9gj31","first-row":"first-row-pgo9gj31","first-col":"first-col-pgo9gj31",stretch:"stretch-pgo9gj31","font-size-medium":"font-size-medium-pgo9gj31","font-size-large":"font-size-large-pgo9gj31","size-small":"size-small-pgo9gj31","size-medium":"size-medium-pgo9gj31","size-large":"size-large-pgo9gj31","intent-success":"intent-success-pgo9gj31","intent-warning":"intent-warning-pgo9gj31","intent-danger":"intent-danger-pgo9gj31","intent-primary":"intent-primary-pgo9gj31","border-none":"border-none-pgo9gj31","border-thin":"border-thin-pgo9gj31","border-thick":"border-thick-pgo9gj31","no-corner-top-left":"no-corner-top-left-pgo9gj31","no-corner-top-right":"no-corner-top-right-pgo9gj31","no-corner-bottom-right":"no-corner-bottom-right-pgo9gj31","no-corner-bottom-left":"no-corner-bottom-left-pgo9gj31",highlight:"highlight-pgo9gj31",shown:"shown-pgo9gj31"}},10306:e=>{e.exports={"inner-slot":"inner-slot-QpAAIiaV",interactive:"interactive-QpAAIiaV",icon:"icon-QpAAIiaV","inner-middle-slot":"inner-middle-slot-QpAAIiaV","before-slot":"before-slot-QpAAIiaV","after-slot":"after-slot-QpAAIiaV"}},66579:e=>{e.exports={input:"input-uGWFLwEy","with-start-slot":"with-start-slot-uGWFLwEy","with-end-slot":"with-end-slot-uGWFLwEy"}},64547:e=>{e.exports={button:"button-SS83RYhy"}},62461:e=>{e.exports={dropTargetInside:"dropTargetInside-HaSQHZAC",dropTarget:"dropTarget-HaSQHZAC",before:"before-HaSQHZAC",after:"after-HaSQHZAC"}},91069:e=>{e.exports={wrap:"wrap-XdW9S1Ib",selected:"selected-XdW9S1Ib",childOfSelected:"childOfSelected-XdW9S1Ib",disabled:"disabled-XdW9S1Ib",expandHandle:"expandHandle-XdW9S1Ib",expanded:"expanded-XdW9S1Ib"}},34244:e=>{e.exports={separator:"separator-KFALCIeR",tree:"tree-KFALCIeR",overlayScrollWrap:"overlayScrollWrap-KFALCIeR",listContainer:"listContainer-KFALCIeR"}},9267:e=>{e.exports={title:"title-f0amBBvb",empty:"empty-f0amBBvb",image:"image-f0amBBvb",spinner:"spinner-f0amBBvb",contentList:"contentList-f0amBBvb"}},32713:e=>{e.exports={dialog:"dialog-W0U3ul53",button:"button-W0U3ul53"}},41223:e=>{e.exports={title:"title-0UFIVbgR",withoutIcon:"withoutIcon-0UFIVbgR",buttons:"buttons-0UFIVbgR",button:"button-0UFIVbgR",disabled:"disabled-0UFIVbgR"}},89559:e=>{e.exports={wrap:"wrap-hEebyvPo",dialog:"dialog-hEebyvPo",offset:"offset-hEebyvPo",title:"title-hEebyvPo",main:"main-hEebyvPo",disabled:"disabled-hEebyvPo",icon:"icon-hEebyvPo",textIcon:"textIcon-hEebyvPo",syncIconWrap:"syncIconWrap-hEebyvPo",syncIcon:"syncIcon-hEebyvPo",rightButtons:"rightButtons-hEebyvPo",hover:"hover-hEebyvPo",expandHandle:"expandHandle-hEebyvPo",button:"button-hEebyvPo",selected:"selected-hEebyvPo",childOfSelected:"childOfSelected-hEebyvPo",renameInput:"renameInput-hEebyvPo",
warn:"warn-hEebyvPo",visible:"visible-hEebyvPo"}},48247:e=>{e.exports={wrap:"wrap-gUfy4kTJ",space:"space-gUfy4kTJ",tree:"tree-gUfy4kTJ"}},30608:e=>{e.exports={button:"button-IulLF4sY",disabled:"disabled-IulLF4sY"}},86332:(e,t,n)=>{"use strict";n.d(t,{ControlGroupContext:()=>o});const o=n(59496).createContext({isGrouped:!1,cellState:{isTop:!0,isRight:!0,isBottom:!0,isLeft:!0}})},95604:(e,t,n)=>{"use strict";function o(e){let t=0;return e.isTop&&e.isLeft||(t+=1),e.isTop&&e.isRight||(t+=2),e.isBottom&&e.isLeft||(t+=8),e.isBottom&&e.isRight||(t+=4),t}n.d(t,{getGroupCellRemoveRoundBorders:()=>o})},67029:(e,t,n)=>{"use strict";n.d(t,{ControlSkeleton:()=>_,InputClasses:()=>g});var o=n(59496),r=n(97754),s=n(88537),i=n(66092),l=n(90186),a=n(86332),c=n(95604);var d=n(21103),u=n.n(d);function h(e){let t="";return 0!==e&&(1&e&&(t=r(t,u()["no-corner-top-left"])),2&e&&(t=r(t,u()["no-corner-top-right"])),4&e&&(t=r(t,u()["no-corner-bottom-right"])),8&e&&(t=r(t,u()["no-corner-bottom-left"]))),t}function p(e,t,n,o){const{removeRoundBorder:s,className:i,intent:l="default",borderStyle:a="thin",size:d,highlight:p,disabled:f,readonly:g,stretch:m,noReadonlyStyles:v,isFocused:_}=e,b=h(null!=s?s:(0,c.getGroupCellRemoveRoundBorders)(n));return r(u().container,u()["intent-"+l],u()["border-"+a],d&&u()["size-"+d],b,p&&u()["with-highlight"],f&&u().disabled,g&&!v&&u().readonly,_&&u().focused,m&&u().stretch,t&&u().grouped,!o&&u()["adjust-position"],n.isTop&&u()["first-row"],n.isLeft&&u()["first-col"],i)}function f(e,t){const{highlight:n,highlightRemoveRoundBorder:o}=e;if(!n)return u().highlight;const s=h(null!=o?o:(0,c.getGroupCellRemoveRoundBorders)(t));return r(u().highlight,u().shown,s)}const g={FontSizeMedium:(0,s.ensureDefined)(u()["font-size-medium"]),FontSizeLarge:(0,s.ensureDefined)(u()["font-size-large"])},m={passive:!1};function v(e,t){const{id:n,role:r,onFocus:s,onBlur:c,onMouseOver:d,onMouseOut:u,onMouseDown:h,onMouseUp:g,onKeyDown:v,onClick:_,tabIndex:b,startSlot:S,middleSlot:y,endSlot:C,onWheel:w,onWheelNoPassive:T=null}=e,{isGrouped:I,cellState:E,disablePositionAdjustment:M=!1}=(0,o.useContext)(a.ControlGroupContext),x=function(e,t=null,n){const r=(0,o.useRef)(null),s=(0,o.useRef)(null),i=(0,o.useCallback)(()=>{if(null===r.current||null===s.current)return;const[e,t,n]=s.current;null!==t&&r.current.addEventListener(e,t,n)},[]),l=(0,o.useCallback)(()=>{if(null===r.current||null===s.current)return;const[e,t,n]=s.current;null!==t&&r.current.removeEventListener(e,t,n)},[]),a=(0,o.useCallback)(e=>{l(),r.current=e,i()},[]);return(0,o.useEffect)(()=>(s.current=[e,t,n],i(),l),[e,t,n]),a}("wheel",T,m);return o.createElement("span",{id:n,role:r,className:p(e,I,E,M),tabIndex:b,ref:(0,i.useMergedRefs)([t,x]),onFocus:s,onBlur:c,onMouseOver:d,onMouseOut:u,onMouseDown:h,onMouseUp:g,onKeyDown:v,onClick:_,onWheel:w,...(0,l.filterDataProps)(e),...(0,l.filterAriaProps)(e)},S,y,C,o.createElement("span",{className:f(e,E)}))}v.displayName="ControlSkeleton";const _=o.forwardRef(v)},78274:(e,t,n)=>{"use strict";n.d(t,{StartSlot:()=>l,MiddleSlot:()=>a,
EndSlot:()=>c,AfterSlot:()=>d});var o=n(59496),r=n(97754),s=n(10306),i=n.n(s);function l(e){const{className:t,interactive:n=!0,icon:s=!1,children:l}=e;return o.createElement("span",{className:r(i()["inner-slot"],n&&i().interactive,s&&i().icon,t)},l)}function a(e){const{className:t,children:n}=e;return o.createElement("span",{className:r(i()["inner-slot"],i()["inner-middle-slot"],t)},n)}function c(e){const{className:t,interactive:n=!0,icon:s=!1,children:l}=e;return o.createElement("span",{className:r(i()["inner-slot"],n&&i().interactive,s&&i().icon,t)},l)}function d(e){const{className:t,children:n}=e;return o.createElement("span",{className:r(i()["after-slot"],t)},n)}},31261:(e,t,n)=>{"use strict";n.d(t,{InputControl:()=>_});var o=n(59496),r=n(97754),s=n(90186),i=n(47201),l=n(48907),a=n(66092),c=n(48027),d=n(29202),u=n(45812),h=n(67029),p=n(78274),f=n(66579),g=n.n(f);function m(e){return!(0,s.isAriaAttribute)(e)&&!(0,s.isDataAttribute)(e)}function v(e){const{id:t,title:n,role:i,tabIndex:l,placeholder:a,name:c,type:d,value:u,defaultValue:f,draggable:v,autoComplete:_,autoFocus:b,maxLength:S,min:y,max:C,step:w,pattern:T,inputMode:I,onSelect:E,onFocus:M,onBlur:x,onKeyDown:D,onKeyUp:A,onKeyPress:L,onChange:N,onDragStart:k,size:O="medium",className:B,inputClassName:R,disabled:F,readonly:P,containerTabIndex:j,startSlot:z,endSlot:V,reference:H,containerReference:G,onContainerFocus:W,...U}=e,K=(0,s.filterProps)(U,m),Z={...(0,s.filterAriaProps)(U),...(0,s.filterDataProps)(U),id:t,title:n,role:i,tabIndex:l,placeholder:a,name:c,type:d,value:u,defaultValue:f,draggable:v,autoComplete:_,autoFocus:b,maxLength:S,min:y,max:C,step:w,pattern:T,inputMode:I,onSelect:E,onFocus:M,onBlur:x,onKeyDown:D,onKeyUp:A,onKeyPress:L,onChange:N,onDragStart:k};return o.createElement(h.ControlSkeleton,{...K,disabled:F,readonly:P,tabIndex:j,className:r(g().container,B),size:O,ref:G,onFocus:W,startSlot:z,middleSlot:o.createElement(p.MiddleSlot,null,o.createElement("input",{...Z,className:r(g().input,R,z&&g()["with-start-slot"],V&&g()["with-end-slot"]),disabled:F,readOnly:P,ref:H})),endSlot:V})}function _(e){e=(0,c.useControl)(e);const{disabled:t,autoSelectOnFocus:n,tabIndex:r=0,onFocus:s,onBlur:h,reference:p,containerReference:f=null}=e,g=(0,o.useRef)(null),m=(0,o.useRef)(null),[_,b]=(0,d.useFocus)(),S=t?void 0:_?-1:r,y=t?void 0:_?r:-1,{isMouseDown:C,handleMouseDown:w,handleMouseUp:T}=(0,u.useIsMouseDown)(),I=(0,i.createSafeMulticastEventHandler)(b.onFocus,(function(e){n&&!C.current&&(0,l.selectAllContent)(e.currentTarget)}),s),E=(0,i.createSafeMulticastEventHandler)(b.onBlur,h),M=(0,o.useCallback)(e=>{g.current=e,p&&("function"==typeof p&&p(e),"object"==typeof p&&(p.current=e))},[g,p]);return o.createElement(v,{...e,isFocused:_,containerTabIndex:S,tabIndex:y,onContainerFocus:function(e){m.current===e.target&&null!==g.current&&g.current.focus()},onFocus:I,onBlur:E,reference:M,containerReference:(0,a.useMergedRefs)([m,f]),onMouseDown:w,onMouseUp:T})}},48027:(e,t,n)=>{"use strict";n.d(t,{useControl:()=>s});var o=n(47201),r=n(29202);function s(e){
const{onFocus:t,onBlur:n,intent:s,highlight:i,disabled:l}=e,[a,c]=(0,r.useFocus)(void 0,l),d=(0,o.createSafeMulticastEventHandler)(l?void 0:c.onFocus,t),u=(0,o.createSafeMulticastEventHandler)(l?void 0:c.onBlur,n);return{...e,intent:s||(a?"primary":"default"),highlight:null!=i?i:a,onFocus:d,onBlur:u}}},29202:(e,t,n)=>{"use strict";n.d(t,{useFocus:()=>r});var o=n(59496);function r(e,t){const[n,r]=(0,o.useState)(!1);(0,o.useEffect)(()=>{t&&n&&r(!1)},[t,n]);const s={onFocus:(0,o.useCallback)((function(t){void 0!==e&&e.current!==t.target||r(!0)}),[e]),onBlur:(0,o.useCallback)((function(t){void 0!==e&&e.current!==t.target||r(!1)}),[e])};return[n,s]}},45812:(e,t,n)=>{"use strict";n.d(t,{useIsMouseDown:()=>r});var o=n(59496);function r(){const e=(0,o.useRef)(!1),t=(0,o.useCallback)(()=>{e.current=!0},[e]),n=(0,o.useCallback)(()=>{e.current=!1},[e]);return{isMouseDown:e,handleMouseDown:t,handleMouseUp:n}}},66092:(e,t,n)=>{"use strict";n.d(t,{useMergedRefs:()=>r});var o=n(59496);function r(e){return(0,o.useCallback)(function(e){return t=>{e.forEach(e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)})}}(e),e)}},48907:(e,t,n)=>{"use strict";function o(e){null!==e&&e.setSelectionRange(0,e.value.length)}n.d(t,{selectAllContent:()=>o})},47201:(e,t,n)=>{"use strict";function o(...e){return t=>{for(const n of e)void 0!==n&&n(t)}}n.d(t,{createSafeMulticastEventHandler:()=>o})},14593:(e,t,n)=>{"use strict";n.d(t,{ToolWidgetIconButton:()=>l});var o=n(59496),r=n(97754),s=n(4825),i=n(64547);const l=o.forwardRef((e,t)=>{const{className:n,id:l,...a}=e;return o.createElement(s.ToolWidgetButton,{"data-name":l,...a,ref:t,className:r(n,i.button)})})},94250:(e,t,n)=>{"use strict";n.d(t,{ManageDrawings:()=>C});var o=n(59496),r=n(88537),s=n(9745),i=n(26843),l=n(45345),a=n(28353),c=n(24980),d=n(98125),u=n(14291),h=n(64530),p=n(80643),f=n(61074),g=n(72802),m=n(70029),v=n(9267);(0,d.getLogger)("Chart.ManageDrawings");const _=new c.TranslatedString("remove all line tools for {symbol}",(0,a.t)("remove all line tools for {symbol}")),b=e=>(0,a.t)("{drawingsCount} drawing",{plural:"{drawingsCount} drawings",count:e}).format({drawingsCount:e.toString()}),S=(0,a.t)("Remove all drawings for this symbol"),y=(0,a.t)("No drawings yet");class C extends o.PureComponent{constructor(e){super(e),this._totalCount=0,this._model=null,this._symbolDrawingsMap=null,this._storageContentLoadingPromise=null,this._onItemClick=e=>{""!==e&&(this.props.chartWidget.setSymbol(e),null!==this._model&&this.setState({currentSymbol:e}),this.props.onClose&&this.props.onClose())},this._onRemove=async e=>{if(this._model&&this._symbolDrawingsMap){const t=this._symbolDrawingsMap.get(e);if(t){const n=Array.from(t).map(e=>(0,r.ensureNotNull)(this._model).model().dataSourceForId(e)).filter(p.notNull);n.length>0&&this._model.removeSources(n,!1,_.format({symbol:e})),this._updateItems()}}},this._updateItems=async()=>{if(null!==this._model){const e=await this._getItems(this._model.model().dataSources());this.setState({items:e})}},this._updateTheme=()=>{const e=l.watchedTheme.value()
;this.setState({theme:e})},this.state={currentSymbol:null,items:null,theme:l.watchedTheme.value()}}componentDidMount(){this.props.chartWidget.withModel(this,async()=>{this._model=this.props.chartWidget.model(),this._model.model().dataSourceCollectionChanged().subscribe(this,this._updateItems);const e=await this._getItems(this._model.model().dataSources());this.setState({currentSymbol:this._model.mainSeries().symbol(),items:e},()=>{var e,t;return null===(t=(e=this.props).onInitialized)||void 0===t?void 0:t.call(e)})}),l.watchedTheme.subscribe(this._updateTheme)}componentWillUnmount(){l.watchedTheme.unsubscribe(this._updateTheme),null!==this._model&&this._model.model().dataSourceCollectionChanged().unsubscribe(this,this._updateItems)}render(){const{isMobile:e}=this.props,{currentSymbol:t,items:n}=this.state,r=this._symbolDrawingsMap?this._symbolDrawingsMap.size:0,s=`${i=r,(0,a.t)("{symbolsCount} symbol",{plural:"{symbolsCount} symbols",context:"symbols_and_drawings_count",count:i}).format({symbolsCount:i.toString()})} ${(e=>(0,a.t)("with {drawingsCount} drawing",{plural:"with {drawingsCount} drawings",context:"symbols_and_drawings_count",count:e}).format({drawingsCount:e.toString()}))(this._totalCount)}`;var i;return o.createElement(o.Fragment,null,n&&n.length>0&&o.createElement("div",{className:v.title},s),null===n||0===n.length?this._renderEmptyContent():n.map(n=>o.createElement(h.DialogContentItem,{key:n.symbol,title:n.symbol,subtitle:b(n.drawingsCount),removeBtnLabel:S,isActive:n.symbol===t,isMobile:e,onClick:this._onItemClick.bind(this,n.symbol),onClickRemove:this._onRemove.bind(this,n.symbol),showFavorite:!1})))}_renderEmptyContent(){const{theme:e}=this.state,t=e===i.StdTheme.Dark?m:g;return null===this._symbolDrawingsMap?o.createElement(f.Spinner,{className:v.spinner}):o.createElement("div",{className:v.empty},o.createElement(s.Icon,{className:v.image,icon:t}),o.createElement("span",null,y))}async _getStorageContent(){return new Map}async _getItems(e){const t=[],n=this._getSymbolDrawingsMap(e);return(await this._getStorageContent()).forEach((e,t)=>{const o=n.get(t)||new Set;e.forEach(e=>o.add(e)),n.set(t,o)}),this._symbolDrawingsMap=n,this._totalCount=0,this._symbolDrawingsMap.forEach((e,n)=>{t.push({symbol:n,drawingsCount:e.size}),this._totalCount=this._totalCount+e.size}),t.sort((e,t)=>e.drawingsCount===t.drawingsCount?e.symbol.localeCompare(t.symbol):e.drawingsCount>t.drawingsCount?-1:1)}_getSymbolDrawingsMap(e){const t=new Map;return e.forEach(e=>{var n;if((0,u.isLineTool)(e)&&e.showInObjectTree()){const o=null!==(n=e.symbol())&&void 0!==n?n:"",r=t.get(o)||new Set;r.add(e.id()),t.set(o,r)}}),t}}},49469:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ObjectTreeDialogRenderer:()=>Jo});var o=n(59496),r=n(87995);async function s(e,t,n){let o;for(let r=0;r<t;++r)try{return await e(o)}catch(e){o=e,await n(r)}throw o}async function i(e,t){return s(e,t,()=>Promise.resolve())}var l=n(98125);const a=(0,l.getLogger)("DataSourcesIcons");let c=null;function d(){const e=n.c[45749]
;return e?Promise.resolve(e.exports.lineToolsIcons):n.e(1890).then(n.bind(n,45749)).then(e=>e.lineToolsIcons)}function u(){const e=n.c[37466];return e?Promise.resolve(e.exports.SERIES_ICONS):n.e(3718).then(n.bind(n,37466)).then(e=>e.SERIES_ICONS)}let h=null;function p(){return null===h&&(h=function(){const e=i(d,2).then(e=>e).catch(e=>(a.logWarn(e),{})),t=i(u,2).then(e=>e).catch(e=>(a.logWarn(e),{}));return Promise.all([e,t])}()),h.then(e=>(c={linetool:e[0],series:e[1]},c))}var f=n(41590),g=n(37558),m=n(90692),v=n(28353),_=n(85457),b=n(24437),S=n(94250);var y=n(9837),C=n.n(y),w=n(36349),T=n(32563),I=n(88537),E=n(97754),M=n.n(E),x=n(9745),D=n(16396),A=n(35390),L=n(36947);const N=o.createContext(null);var k=n(14593),O=n(16788),B=n(36666),R=n(38593),F=n(41223),P=n(51768);function j(e){const{viewModel:t}=(0,I.ensureNotNull)((0,o.useContext)(N)),n=(0,L.useForceUpdate)(),r=t.selection();(0,o.useEffect)(()=>{const e={};return t.onChange().subscribe(e,()=>n()),()=>{t.onChange().unsubscribeAll(e)}},[t]),(0,o.useEffect)(()=>{const e={};return r.onChange().subscribe(e,()=>n()),()=>{r.onChange().unsubscribeAll(e)}},[r]);const s=!t.canSelectionBeUnmerged(),i=t.isSelectionCopiable(),l=t.isSelectionCloneable(),a=!i&&!l,c=t.canSelectionBeGrouped();return o.createElement(o.Fragment,null,o.createElement("div",{className:E(F.title,F.withoutIcon)},(0,v.t)("Object tree"),!1),o.createElement("div",{className:F.buttons},o.createElement(k.ToolWidgetIconButton,{className:E(F.button,!c&&F.disabled),icon:R,onClick:function(){t.createGroupFromSelection()},isDisabled:!c,title:(0,v.t)("Create a group of drawings"),"data-name":"group-button"}),o.createElement(A.ToolWidgetMenu,{className:E(F.button,a&&F.disabled),isDisabled:a,content:o.createElement(x.Icon,{icon:O}),title:(0,v.t)("Clone, Copy"),arrow:!1,isShowTooltip:!0,"data-name":"copy-clone-button"},i&&o.createElement(D.PopupMenuItem,{"data-name":"copy",label:(0,v.t)("Copy"),onClick:function(){t.copySelection()}}),l&&o.createElement(D.PopupMenuItem,{"data-name":"clone",label:(0,v.t)("Clone"),onClick:function(){t.cloneSelection()}})),o.createElement(A.ToolWidgetMenu,{className:E(F.button,s&&F.disabled),isDisabled:s,content:o.createElement(x.Icon,{icon:B}),title:(0,v.t)("Move to"),arrow:!1,isShowTooltip:!0,"data-name":"move-to-button"},o.createElement(D.PopupMenuItem,{"data-name":"new-pane-above",label:(0,v.t)("New pane above"),onClick:function(){t.unmergeSelectionUp()}}),o.createElement(D.PopupMenuItem,{"data-name":"new-pane-below",label:(0,v.t)("New pane below"),onClick:function(){t.unmergeSelectionDown()}}))))}var z=n(54773),V=n(79049),H=n(11307),G=n(36028),W=n(86416);const U=(K="OBJECT_TREE",e=>K+"__"+e);var K
;const Z=U("SET_NODES"),Q=U("SYNC_NODES"),X=U("UPDATE_NODE"),$=U("UPDATE_NODES"),q=U("RESET_TREE"),J=U("SET_SELECTED_IDS"),Y=U("DROP_SELECTION"),ee=U("SELECT_PREVIOUS"),te=U("SELECT_NEXT"),ne=U("MULTI_SELECT_PREVIOUS"),oe=U("MULTI_SELECT_NEXT"),re=U("PROCESS_DROP_TARGET"),se=U("UPDATE_DROP_TARGET"),ie=U("HIDE_DROP_TARGET"),le=U("START_MULTI_SELECT"),ae=U("STOP_MULTI_SELECT"),ce=(U("REMOVE_NODE"),U("SET_FOCUSED_NODE")),de=U("SCROLL_TO_ID"),ue=U("SET_IS_SELECTED"),he=U("SET_IS_EXPANDED"),pe=U("SET_DISABLED_NODES"),fe=U("MOVE_NODES"),ge=(U("START_DRAG"),U("END_DRAG")),me=()=>({type:ee}),ve=()=>({type:te}),_e=()=>({type:ne}),be=()=>({type:oe}),Se=(e,t,n,o,r)=>({type:re,dropTarget:e,dropType:t,isHoveredLeft:n,boundBox:o,isLastChild:r}),ye=()=>({type:Y}),Ce=e=>({type:J,ids:e}),we=(e,t,n)=>({type:fe,ids:e,targetId:t,dropType:n}),Te=()=>({type:le}),Ie=()=>({type:ae}),Ee=e=>({type:ce,nodeId:e}),Me=e=>({type:de,nodeId:e}),xe=(e,t,n=0)=>({type:ue,nodeId:e,isSelected:t,mode:n}),De=(e,t)=>({type:he,nodeId:e,isExpanded:t}),Ae=e=>({type:pe,ids:e}),Le=()=>({type:ge});var Ne=n(77145);const ke=e=>e.nodes,Oe=e=>e.selection,Be=e=>e.dropTarget,Re=e=>e.expanded,Fe=e=>e.scrollToId,Pe=(e,t)=>t,je=(0,Ne.createSelector)([ke,Pe],(e,t)=>e[t]),ze=(0,Ne.createSelector)([Oe,Pe],(e,t)=>e.ids.includes(t)),Ve=(0,Ne.createSelector)([Re,Pe],(e,t)=>e.includes(t)),He=(0,Ne.createSelector)([e=>e.disabled,Oe,Pe],(e,t,n)=>!t.ids.includes(n)&&e.includes(n)),Ge=(0,Ne.createSelector)(ke,e=>Object.keys(e)),We=(0,Ne.createSelector)(Oe,({ids:e})=>e),Ue=(0,Ne.createSelector)(Oe,({lastFocusedNodeId:e})=>e),Ke=(0,Ne.createSelector)(Oe,({isMultiSelecting:e})=>e),Ze=(0,Ne.createSelector)([ke,We],(e,t)=>t.map(t=>e[t])),Qe=(0,Ne.createSelector)(ke,e=>Object.values(e).filter(e=>0===e.level)),Xe=(0,Ne.createSelector)([ke,Qe],(e,t)=>t.reduce((t,n)=>[...t,...$e(e,(0,I.ensureDefined)(n))],[]));function $e(e,t){const n=[];for(const o of t.children)n.push(e[o]),n.push(...$e(e,e[o]));return n}const qe=(0,Ne.createSelector)([ke,Qe,Re],(e,t,n)=>{const o=new Set(n);return t.reduce((t,n)=>[...t,...Ye(e,(0,I.ensureDefined)(n),o)],[])}),Je=(0,Ne.createSelector)([ke,We,Re],(e,t,n)=>{const o=new Set(n);return[{id:"drag-list",level:-1,children:t}].reduce((t,n)=>[...t,...Ye(e,(0,I.ensureDefined)(n),o)],[])});function Ye(e,t,n){const o=[];for(const r of t.children){const t=e[r];void 0!==t&&(o.push(t),n.has(r)&&o.push(...Ye(e,t,n)))}return o}function*et(e){const{selectedIds:t,nodes:n}=yield(0,w.call)(e),o={};for(let e=0;e<n.length;++e){const t=n[e];o[t.id]=t}yield(0,w.put)((e=>({type:Z,nodes:e}))(o)),yield(0,w.put)(Ce(t));!Ue(yield(0,w.select)())&&t.length>0&&(yield(0,w.put)(Ee(t[0])),yield(0,w.put)(Me(t[0])))}function*tt(e){for(;;){if((yield(0,w.take)([le,ae])).type===le){const t=Ge(yield(0,w.select)()).filter(t=>!e(t));yield(0,w.put)(Ae(t))}else yield(0,w.put)(Ae([]))}}function*nt(){for(;;){const{type:e}=yield(0,w.take)([oe,ne]),t=yield(0,w.select)(),n=Xe(t),o=n.length,r=Ue(t),s=[...We(t)],i=1===s.length&&s[0]!==r,l=n.findIndex(e=>e.id===(i?s[0]:r))
;if(e===ne&&0===l||e===oe&&l===o-1)continue;const a=ct(t,e===oe?"next":"previous",n,l),{id:c}=a;s.includes(c)&&r?(yield(0,w.put)(xe(r,!1,1)),yield(0,w.put)(Ee(c))):yield(0,w.put)(xe(c,!0,1)),yield(0,w.put)(Me(c))}}function*ot(e,t){for(;;){const{type:n}=yield(0,w.take)([te,ee]),o=yield(0,w.select)(),r=Xe(o),s=Ze(o),i=Ue(o);if(1===s.length&&s[0].id!==i&&!i){if(n===te){yield(0,w.put)(Ee(s[0].id));continue}if(n===ee){const e=r.findIndex(e=>e.id===s[0].id),t=ct(o,"previous",r,e);yield(0,w.put)(Ee(t.id));continue}}const l=r.findIndex(e=>e.id===i),a=n===te?"next":"previous",c=ct(o,a,r,l),{id:d}=c;e?e([d],a):yield(0,w.put)(Ce([d])),t&&t(d),yield(0,w.put)(Ee(d))}}function*rt(e,t=(()=>!0)){for(;;){const{mode:n,nodeId:o,isSelected:r}=yield(0,w.take)(ue);let s=[...We(yield(0,w.select)())];const i=Xe(yield(0,w.select)());if(1===n)r?s.push(o):s.splice(s.indexOf(o),1);else if(2===n&&s.length>0){const e=Ue(yield(0,w.select)());let n=i.findIndex(t=>t.id===e);-1===n&&(n=i.reduce((e,t,n)=>s.includes(t.id)?n:e,-1));const r=i.findIndex(e=>e.id===o);if(n!==r)for(let e=Math.min(n,r);e<=Math.max(n,r);e++){const n=i[e].id;!s.includes(n)&&t(n)&&s.push(n)}}else s=o?[o]:[];const l=new Set(s);s=i.reduce((e,t)=>(l.has(t.id)&&e.push(t.id),e),[]),e?e(s):yield(0,w.put)(Ce(s)),yield(0,w.put)(Ee(o))}}function*st(e=(()=>!0),t){const{dropTarget:n,dropType:o,isHoveredLeft:r,boundBox:s,isLastChild:i}=t,l=Be(yield(0,w.select)()),a=je(yield(0,w.select)(),(0,I.ensureDefined)(n.parentId)),c=i&&"after"===o,d=Ze(yield(0,w.select)()),u=!c||!r&&e(d,n,o)?n:a,h=l.node&&l.node.id!==u.id||l.dropType!==o;d.map(e=>e.id).includes(u.id)?yield(0,w.put)({type:ie}):h&&e(d,u,o)&&(yield(0,w.put)(((e,t,n)=>({type:se,node:e,dropType:t,boundBox:n}))(u,o,s)))}function*it(e){yield(0,w.throttle)(0,re,st,e)}function*lt(e){for(;;){yield(0,w.take)(Y);const t=Ze(yield(0,w.select)()),{node:n,dropType:o}=Be(yield(0,w.select)());if(n&&o){const r=new CustomEvent("tree-node-drop",{detail:{nodes:t,target:n.id,type:o}});if(e&&e(r),!r.defaultPrevented){const e=We(yield(0,w.select)());yield(0,w.put)(we(e,n.id,o))}}}}function*at(e){for(;;){yield(0,w.take)(fe);e(ke(yield(0,w.select)()))}}function ct(e,t,n,o){const r=n.length;let s;-1===o&&"previous"===t&&(o=r);let i=0;for(;!s||Math.abs(i)<r&&((l=s).level>1&&!Ve(e,(0,I.ensureDefined)(l.parentId)));)i+="next"===t?1:-1,s=n[(o+i+r)%r];var l;return s}function*dt(e={}){const{saga:t,onDrop:n,canMove:o,onMove:r,onSelect:s,onKeyboardSelect:i,initState:l,canBeAddedToSelection:a}=e,c=[(0,w.fork)(it,o),(0,w.fork)(lt,n),(0,w.fork)(rt,s,a),(0,w.fork)(ot,s,i),(0,w.fork)(nt)];for(t&&c.push((0,w.fork)(t)),r&&c.push((0,w.fork)(at,r)),a&&c.push((0,w.fork)(tt,a));;){l&&(yield(0,w.call)(et,l));const e=yield(0,w.all)(c);yield(0,w.take)(q);for(const t of e)yield(0,w.cancel)(t)}}var ut=n(83243),ht=n(80643);const pt=(0,l.getLogger)("Platform.GUI.ObjectTree.CallApi");const ft={ids:[],lastFocusedNodeId:void 0,isMultiSelecting:!1};const gt={node:void 0,dropType:void 0,boundBox:void 0};const mt=(0,ut.combineReducers)({nodes:function(e={},t){switch(t.type){case Z:
return t.nodes;case Q:{const{nodes:n}=t,o=n.map(e=>e.id),r={...e};for(const t of Object.keys(e))if(!o.includes(t)){const{parentId:e}=r[t];e&&(r[e]={...r[e],children:r[e].children.filter(e=>e!==t)}),delete r[t]}for(const e of n){const t=e.id;if(r.hasOwnProperty(t)){!(0,ht.deepEquals)(r[t].children,e.children)[0]&&(r[t]={...r[t],children:[...e.children]})}else{r[t]=e;const{parentId:n}=e;if(n&&!r[n].children.includes(t))throw new Error("Not implemented")}}return r}case X:{const{type:n,nodeId:o,...r}=t;return{...e,[o]:{...e[o],...r}}}case $:{const{nodes:n}=t,o={...e};return Object.keys(n).forEach(e=>{o[e]={...o[e],...n[e]}}),{...e,...o}}case fe:{const{ids:n,targetId:o,dropType:r}=t,s=(0,I.ensureDefined)(e[o].parentId),i=e[s],l={};for(const t of n){const n=e[t];if(n.parentId){const o=l[n.parentId]||e[n.parentId];l[n.parentId]={...o,children:o.children.filter(e=>e!==t)}}l[t]={...n,parentId:s,level:i.level+1}}const a=i.children.filter(e=>!n.includes(e));return a.splice(((e,t,n)=>{switch(n){case"before":return e.indexOf((0,I.ensureDefined)(t));case"inside":return e.length;case"after":return e.indexOf((0,I.ensureDefined)(t))+1;default:return 0}})(a,o,r),0,...n),l[s]={...e[s],children:a,isExpanded:!0},{...e,...l}}default:return e}},selection:function(e=ft,t){switch(t.type){case J:{const{ids:n}=t;return{...e,ids:n,lastFocusedNodeId:n.length>0?e.lastFocusedNodeId:void 0}}case le:return{...e,isMultiSelecting:!0};case ae:return{...e,isMultiSelecting:!1};case ce:return{...e,lastFocusedNodeId:t.nodeId};case Q:{const n=new Set(t.nodes.map(e=>e.id));return e.lastFocusedNodeId&&!n.has(e.lastFocusedNodeId)&&delete e.lastFocusedNodeId,{...e,ids:e.ids.filter(e=>n.has(e))}}default:return e}},dropTarget:function(e=gt,t){switch(t.type){case se:{const{node:n,dropType:o,boundBox:r}=t;return{...e,node:n,dropType:o,boundBox:r}}case ie:case ge:case q:return{...gt};default:return e}},expanded:function(e=[],t){switch(t.type){case he:{const{nodeId:n,isExpanded:o}=t;if(o)return[...e,n];const r=[...e];return r.splice(e.indexOf(n),1),r}default:return e}},disabled:function(e=[],t){switch(t.type){case pe:return[...t.ids];default:return e}},scrollToId:function(e=null,t){switch(t.type){case de:return null===t.nodeId?null:{id:t.nodeId};default:return e}}});var vt=n(35126),_t=n(83199),bt=n(49483);var St=n(61625),yt=n(53408),Ct=n(68335),wt=n(47201),Tt=n(70412);const It=o.createContext({size:0,smallSizeTreeNodeAction:1}),Et={[Ct.Modifiers.Mod]:1,[Ct.Modifiers.Shift]:2};var Mt=n(88142),xt=n(91069);const Dt=()=>{};class At extends o.PureComponent{constructor(){super(...arguments),this._ref=null,this._handleRef=e=>{this._ref=e;const{connectDragSource:t,connectDropTarget:n,connectDragPreview:o}=this.props;(0,I.ensureDefined)(n)(this._ref),(0,I.ensureDefined)(t)(this._ref),(0,I.ensureDefined)(o)((0,yt.getEmptyImage)(),{captureDraggingState:!0})},this._handleTouchStart=e=>{const t=(e,t)=>{const n=function(e,t){try{const n=document.createEvent("TouchEvent")
;return n.initTouchEvent(e,!0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,t.touches,t.targetTouches,t.changedTouches),n}catch(e){return null}}(e,t);if(n)return n;const o=Array.from(t.changedTouches),r=Array.from(t.touches),s=Array.from(t.targetTouches);return new TouchEvent(e,{bubbles:!0,changedTouches:o,touches:r,targetTouches:s})},n=e.target;if(n instanceof Element){const e=e=>{const o=e;if(!n.isConnected){o.preventDefault();const e=t("touchmove",o);document.body.dispatchEvent(e)}},o=r=>{const s=r;if(!n.isConnected){s.preventDefault();const e=t("touchend",s);document.body.dispatchEvent(e)}n.removeEventListener("touchend",o),n.removeEventListener("touchmove",e)};n.addEventListener("touchend",o),n.addEventListener("touchmove",e)}}}componentDidMount(){var e;null===(e=this._ref)||void 0===e||e.addEventListener("touchstart",this._handleTouchStart)}componentWillUnmount(){var e;null===(e=this._ref)||void 0===e||e.removeEventListener("touchstart",this._handleTouchStart)}render(){return o.createElement(Lt,{...this.props,reference:this._handleRef})}getNode(){return(0,I.ensureNotNull)(this._ref)}}const Lt=e=>{const{id:t,isSelected:n,isOffset:r,isExpandable:s,setIsSelected:i,isDisabled:l,isExpanded:a,onClick:c,parentId:d,setIsExpanded:u,reference:h,isFirstListItem:p,isLastListItem:f,nodeRenderer:g,isChildOfSelected:m=!1}=e,{size:v,smallSizeTreeNodeAction:_}=(0,o.useContext)(It),b=(0,o.useRef)(null),S=(0,wt.createSafeMulticastEventHandler)(e=>b.current=e,h);let[y,C]=(0,Tt.useHover)();return(bt.CheckMobile.any()||bt.CheckMobile.isIPad())&&(y=n,C={onMouseOut:Dt,onMouseOver:Dt}),o.createElement("div",{className:E(xt.wrap,n&&xt.selected,m&&xt.childOfSelected,l&&xt.disabled,s&&xt.expandable),onClick:1===v&&0===_?w:function(e){if(e.defaultPrevented)return;const o=Et[(0,Ct.modifiersFromEvent)(e)]||0;!l&&i&&i(t,!n,o);c&&0===o&&c(e,t)},onContextMenu:w,ref:S,...C},s&&o.createElement(x.Icon,{icon:Mt,className:E(xt.expandHandle,a&&xt.expanded),onClick:function(e){e.preventDefault(),s&&u(t,!a)},onMouseDown:function(e){e.preventDefault()}}),g({id:t,isOffset:r,parentId:d,isDisabled:l,isSelected:n,isChildOfSelected:m,isHovered:y,isExpanded:a,isFirstListItem:p,isLastListItem:f}));function w(){l||n||!i||i(t,!0)}},Nt=o.createContext({});function kt(e,t){const{id:n}=t,o=je(e,n),r=ze(e,n);let s=!1,i=o.parentId;for(;i&&!s;)s=ze(e,i),i=je(e,i).parentId;return{...o,isSelected:r,isChildOfSelected:s,isExpanded:o.children.length>0&&Ve(e,n),isExpandable:o.children.length>0,isDisabled:He(e,n)}}function Ot(e){return(0,ut.bindActionCreators)({setIsExpanded:De,processDropTarget:Se,dropSelection:ye,selectNext:ve,selectPrevious:me,setIsSelected:xe,endDrag:Le},e)}const Bt=(0,St.DragSource)("node",{beginDrag:e=>{const{id:t,isDisabled:n,isSelected:o}=e;return n||o||e.setIsSelected(t,!0),e},endDrag:e=>e.endDrag()},e=>({connectDragSource:e.dragSource(),connectDragPreview:e.dragPreview()})),Rt=(0,vt.DropTarget)("node",{hover:(e,t,n)=>{if(!n)return;const o=n.getNode(),r=o.getBoundingClientRect(),s=r.bottom-r.top,i=t.getClientOffset()
;if(i){const t=i.y-r.top;let n,l;if(n=0===e.children.length?t<s/2?"before":"after":t<s/3?"before":e.isExpanded||t>=s/3&&t<2*s/3?"inside":"after",void 0!==e.getContainerElement){const t=e.getContainerElement().getBoundingClientRect();l={top:r.top-t.top,left:r.left-t.left,bottom:r.top-t.top+r.height,right:r.left-t.left+r.width,height:r.height,width:r.width}}else l={top:o.offsetTop,left:o.offsetLeft,bottom:o.offsetTop+o.offsetHeight,right:o.offsetLeft+o.offsetWidth,height:o.offsetHeight,width:o.offsetWidth};e.processDropTarget(e,n,i.x-r.left<48,l,e.isLastChild)}}},e=>({connectDropTarget:e.dropTarget()})),Ft=(0,V.connect)(kt,Ot,null,{context:Nt})(Bt(Rt(At))),Pt=(0,V.connect)(kt,Ot,null,{context:Nt})(Lt);var jt=n(35749),zt=n(53614),Vt=n(65718);function Ht(e){const t=e(),n=(0,o.useRef)(t);n.current=t;const[r,s]=(0,o.useState)(n.current),i=(0,o.useRef)(null);return(0,o.useEffect)(()=>{null===i.current&&(i.current=requestAnimationFrame(()=>{i.current=null,s(n.current)}))}),(0,o.useEffect)(()=>()=>{i.current&&cancelAnimationFrame(i.current)},[]),r}function Gt(e){const{dropTargetOffset:t,mousePosition:n}=e;if(!t)return{display:"none"};const{x:o,y:r}=t,s=n&&t?n.y-t.y:0,i=`translate(${o+(n&&t?n.x-t.x:0)}px, ${r+s}px)`;return{transform:i,WebkitTransform:i}}const Wt={top:0,left:0,position:"fixed",pointerEvents:"none",zIndex:100,opacity:.5,width:300,backgroundColor:"red"};const Ut=(0,zt.DragLayer)((function(e){return{isDragging:e.isDragging()&&"node"===e.getItemType(),mousePosition:e.getClientOffset(),dropTargetOffset:e.getSourceClientOffset()}}))((0,V.connect)((function(e){return{items:Je(e)}}),null,null,{context:Nt})((function(e){const{items:t,isDragging:n,nodeRenderer:r,dragPreviewRenderer:s}=e;return Ht((function(){return n?o.createElement(Vt.Portal,null,o.createElement("div",{style:{...Wt,...Gt(e)}},t.map(e=>{if(s){const t=s;return o.createElement(t,{key:e.id,...e})}return o.createElement(Pt,{id:e.id,key:e.id,nodeRenderer:r,isDragPreview:!0,isOffset:e.level>1})}))):null}))})));var Kt=n(3085),Zt=n(33127);const Qt=o.forwardRef((e,t)=>{const n=(0,o.useRef)(null);return e.connectDropTarget(n),(0,o.useImperativeHandle)(t,()=>({getNode:()=>(0,I.ensureNotNull)(n.current)}),[]),o.createElement("div",{ref:n,style:{height:"100%",width:"100%"}})}),Xt=(0,vt.DropTarget)("node",{hover:(e,t,n)=>{if(!n)return;const o=t.getClientOffset();if(null===o)return;const r=e.getOrderedNodes();if(0===r.length)return;const s=n.getNode().getBoundingClientRect(),i=e.getContainerElement().getBoundingClientRect();if("first"===e.type){const t={top:s.top-i.top+s.height,left:s.left-i.left,bottom:s.top-i.top+s.height,right:s.left-i.left+s.width,height:0,width:s.width};e.processDropTarget(r[0],"before",!1,t,!1)}if("last"===e.type){const t=o.x-s.left<48,n=r[r.length-1],l=t&&2===n.level?(0,I.ensureDefined)(r.find(e=>e.id===n.parentId)):n,a={top:s.top-i.top,left:s.left-i.left,bottom:s.top-i.top,right:s.left-i.left+s.width,height:s.height,width:s.width};e.processDropTarget(l,"after",t,a,!1)}}},e=>({connectDropTarget:e.dropTarget()}))(Qt),$t=o.createContext({
isOver:!1,transform:void 0});var qt=n(62461);function Jt(e){const{dropType:t,boundBox:n}=e,{top:o,bottom:r,left:s}=(0,I.ensureDefined)(n);return[s,"before"===t||"inside"===t?o:r]}const Yt=(0,zt.DragLayer)((function(e){return{isDragging:e.isDragging()}}))((0,V.connect)((function(e){const{boundBox:t,dropType:n,node:o}=Be(e);return{boundBox:t,dropType:n,level:o?o.level:void 0}}),null,null,{context:Nt})((function(e){const{dropType:t,boundBox:n,isDragging:r,level:s,transform:i=Jt}=e;return Ht((function(){if(!r||!t||!n)return null;const l={[qt.dropTarget]:"inside"!==t,[qt.dropTargetInside]:"inside"===t},{width:a,height:c}=n,[d,u]=i(e),h=`translate(${d}px, ${u}px)`;return o.createElement("div",{className:E(l),style:{position:"absolute",transform:h,WebkitTransform:h,top:0,left:2===s?"46px":0,width:2===s?a-46+"px":a,height:"inside"===t?c:"2px"}})}))}))),en=o.forwardRef((e,t)=>{const n=(0,o.useContext)($t);return o.createElement("div",{...e,ref:t},e.children,n.isOver&&o.createElement(Yt,{transform:n.transform}))});var tn=n(62820),nn=n(34244);const on=38+Ct.Modifiers.Shift,rn=40+Ct.Modifiers.Shift;const sn=o.forwardRef((function(e,t){const{navigationKeys:n,renderList:r,stopMultiSelect:s,startMultiSelect:i,isMultiSelecting:l,nodeRenderer:a,dragPreviewRenderer:c,className:d,connectDropTarget:u,readOnly:h,onClick:p,dropLayerTransform:f,setFocusedNode:g,scrollToId:m,rowHeight:v,onMultiSelectPrevious:_,onMultiSelectNext:b,onMoveCursorToNext:S,onMoveCursorToPrevious:y,outerRef:C,width:w,height:T,isOver:E,processDropTarget:x}=e,D=(0,o.useContext)(N),A=(0,o.useRef)(null);(0,o.useEffect)(()=>{const e=e=>{[Ct.Modifiers.Mod,Ct.Modifiers.Shift].includes((0,Ct.modifiersFromEvent)(e))&&i()},t=e=>{l&&![Ct.Modifiers.Mod,Ct.Modifiers.Shift].includes((0,Ct.modifiersFromEvent)(e))&&s()};return document.addEventListener("keydown",e),document.addEventListener("keyup",t),document.addEventListener("mousemove",t),()=>{document.removeEventListener("keydown",e),document.removeEventListener("keyup",t),document.removeEventListener("mousemove",t)}},[l]),function(e){(0,o.useEffect)(()=>{if(bt.isEdge){let t=null;const n=(0,I.ensureNotNull)(e.current),o=e=>{if(e.target instanceof Element){const n=(0,I.ensureNotNull)(e.target.closest("[draggable]"));n instanceof HTMLElement&&(n.style.opacity="0",t=requestAnimationFrame(()=>n.style.opacity="1"))}};return n.addEventListener("dragstart",o),()=>{n.removeEventListener("dragstart",o),null!==t&&cancelAnimationFrame(t)}}return()=>{}},[])}(A);const L=(0,o.useCallback)(()=>(0,I.ensureNotNull)(U.current),[]),k=(0,o.useCallback)(()=>r,[r]),O=(0,o.useMemo)(()=>{const e=h?Pt:Ft,t=[];let n;t.push({type:"padding",node:o.createElement(Xt,{type:"first",key:"padding-top",getContainerElement:L,getOrderedNodes:k,processDropTarget:x})});for(let s=0;s<r.length;s++){const i=r[s];1===i.level&&(void 0!==n&&n!==i.parentId&&t.push({type:"separator",node:o.createElement("div",{key:n+"_separator",className:nn.separator})}),n=i.parentId),t.push({type:"node",node:o.createElement(e,{id:i.id,key:i.id,isFirstListItem:0===s,
isLastListItem:s===r.length-1,isExpandable:i.children.length>0,nodeRenderer:a,readOnly:h,onClick:p,isOffset:i.level>1,getContainerElement:L})})}return t.push({type:"padding",node:o.createElement(Xt,{type:"last",key:"padding-bottom",getContainerElement:L,getOrderedNodes:k,processDropTarget:x})}),t},[r]),B=(0,o.useRef)([]);B.current=O;const R=(0,o.useCallback)(e=>{let{style:t}=e;const{index:n}=e;return n===B.current.length-1&&(t={...t,bottom:0,minHeight:t.height},delete t.height),o.createElement("div",{style:t},B.current[n].node)},[]),F=(0,o.useCallback)(e=>{const t=B.current[e];return"padding"===t.type?6:"function"==typeof v?v(e,t):v},[v]),P=(0,o.useCallback)(e=>(0,I.ensure)(B.current[e].node.key),[]),j=(0,o.useMemo)(()=>null===m?{index:-1}:{index:B.current.findIndex(e=>e.node.key===m.id)},[m]);u(A);const[z,V,H,G]=(0,Zt.useOverlayScroll)(),W=(0,o.useRef)(null);(0,o.useEffect)(()=>(0,I.ensureNotNull)(W.current).resetAfterIndex(0,!0),[O]),(0,o.useEffect)(()=>(0,I.ensureNotNull)(W.current).scrollToItem(j.index),[j]);const U=(0,o.useRef)(null),K=(0,o.useMemo)(()=>({isOver:E,transform:f}),[E,f]),Z=(0,o.useRef)(null),Q=(0,o.useRef)({startScroll(e){const t=()=>{null!==H.current&&(Z.current=requestAnimationFrame(t),H.current.scrollBy({top:e}))};this.stopScroll(),t()},stopScroll(){null!==Z.current&&(cancelAnimationFrame(Z.current),Z.current=null)},getListElement:()=>H.current});return(0,o.useImperativeHandle)(t,()=>Q.current,[]),(0,o.useEffect)(()=>()=>Q.current.stopScroll(),[E]),o.createElement($t.Provider,{value:K},o.createElement("div",{...V,className:M()(nn.tree,d),ref:A,tabIndex:-1,onKeyDown:function(e){const t=(0,Ct.hashFromEvent)(e);if(e.defaultPrevented||(0,jt.isNativeUIInteraction)(t,e.target))return;D||t!==on||(e.preventDefault(),_());D||t!==rn||(e.preventDefault(),b());(38===t||void 0!==n&&"previous"===n[t])&&(e.preventDefault(),y());(40===t||void 0!==n&&"next"===n[t])&&(e.preventDefault(),S());if((8===t||46===t)&&D){const{viewModel:e}=D,t=e.selection(),n=t.selected();if(1!==n.length)return;const o=e.getNextNodeIdAfterRemove(n[0]);if(null===o)return;e.onChange().subscribe(null,()=>{if(t.selected().length)return;const n=e.entity(o);n&&(t.set([n]),g(o))},!0)}}},o.createElement(Kt.OverlayScrollContainer,{...z,className:nn.overlayScrollWrap}),o.createElement(_t.VariableSizeList,{ref:function(e){W.current=e},className:nn.listContainer,width:w,height:T,itemCount:O.length,itemSize:F,children:R,itemKey:P,outerRef:function(e){H.current=e,C&&C(e)},innerRef:function(e){U.current=e},innerElementType:en,onItemsRendered:function(){G()},overscanCount:20,direction:(0,tn.isRtl)()?"rtl":"ltr"}),o.createElement(Ut,{dragPreviewRenderer:c,nodeRenderer:a})))})),ln=(0,vt.DropTarget)("node",{drop:(e,t,n)=>{("touch"===e.drag||bt.isFF)&&n.stopScroll(),t.getItem().dropSelection()},hover:(e,t,n)=>{if("touch"!==e.drag&&!bt.isFF)return;const o=t.getClientOffset();if(null===o)return;const r=n.getListElement();if(null===r)return;const s=r.getBoundingClientRect();((t,o,r)=>{const s=Math.abs(t-r),i=Math.abs(t-o)
;if(i>40&&s>40||s<=40&&i<=40)return void n.stopScroll();var l,a,c,d;l=i>20&&i<=40,c=s<=20,d=i<=20,(a=s>20&&s<=40)||l?"touch"===e.drag?n.startScroll(a?-5:5):n.startScroll(a?-2:2):(c||d)&&("touch"===e.drag?n.startScroll(c?-10:10):n.startScroll(c?-5:5))})(o.y,s.bottom,s.top)}},(e,t)=>({connectDropTarget:e.dropTarget(),isOver:t.isOver()}))(sn);const an=(0,V.connect)((function(e){return{renderList:qe(e),orderedNodes:Xe(e),isMultiSelecting:Ke(e),selectedIds:We(e),scrollToId:Fe(e)}}),(function(e){return(0,ut.bindActionCreators)({startMultiSelect:Te,stopMultiSelect:Ie,setFocusedNode:Ee,processDropTarget:Se,onMoveCursorToNext:ve,onMoveCursorToPrevious:me,onMultiSelectPrevious:_e,onMultiSelectNext:be},e)}),null,{context:Nt})(ln),cn={delayTouchStart:100};function dn(e){const{canBeAddedToSelection:t,initState:n,onSelect:r,canMove:s,onDrop:i,onMove:l,nodes:a,selectedIds:c,onKeyboardSelect:d,saga:u,lastFocusedNodeObject:h,lastSyncTimestampRef:p,scrollToId:f,...g}=e,[m,v]=(0,o.useState)(null);return(0,o.useEffect)(()=>{const e=(0,z.default)();v(function(e){const t=(0,ut.applyMiddleware)(e);return(0,ut.createStore)(mt,t)}(e));const o=e.run(dt,{initState:n,onKeyboardSelect:d,saga:u,canMove:s,onMove:l,onDrop:i,onSelect:r,canBeAddedToSelection:t});return()=>o.cancel()},[]),(0,o.useEffect)(()=>(null!==m&&a&&(p&&(p.current=performance.now()),m.dispatch((e=>({type:Q,nodes:e}))(a))),()=>{}),[m,a]),(0,o.useEffect)(()=>{null!==m&&c&&m.dispatch(Ce(c))},[m,c]),(0,o.useEffect)(()=>{null!==m&&(null==h?void 0:h.id)&&m.dispatch(Ee(h.id))},[m,h]),null===m?null:o.createElement(un,{store:m,scrollToId:f,...g})}const un=o.memo((function(e){const{store:t,scrollToId:n,...r}=e,s="touch"===e.drag?G.TouchBackend:H.HTML5Backend;return(0,o.useEffect)(()=>{var e;t.dispatch(Me(null!==(e=null==n?void 0:n.id)&&void 0!==e?e:null))},[n]),o.createElement(W.DndProvider,{backend:s,options:cn},o.createElement(V.Provider,{store:t,context:Nt},o.createElement(an,{...r})))}));function hn(e,t){(0,P.trackEvent)("Object Tree",e,t)}function pn(e){return e.length>1?"Multi select":e[0].gaLabel()}function fn(e){return(0,z.eventChannel)(t=>{const n={};return e.onChange().subscribe(n,()=>t({type:q})),e.onGroupCreated().subscribe(n,e=>t(De(e,!0))),e.selection().onChange().subscribe(n,e=>t(Ce(e))),()=>{e.onChange().unsubscribeAll(n),e.selection().onChange().unsubscribeAll(n),e.onGroupCreated().unsubscribeAll(n)}},z.buffers.expanding())}function*gn(){for(;;)yield(0,w.take)([te,ee]),hn("Select","Arrow")}function*mn(){for(;;){const{mode:e}=yield(0,w.take)(ue);1===e&&hn("Multi select","Ctrl"),2===e&&hn("Multi select","Shift")}}function*vn(e){for(;;){yield(0,w.take)(Y);const{node:t,dropType:n}=Be(yield(0,w.select)());if(t){const o=Ze(yield(0,w.select)()),r=o.map(t=>(0,I.ensureNotNull)(e.entity(t.id)));let s="Drag";1===t.level&&"inside"!==n&&o.some(e=>2===e.level)?s="From the group":2!==t.level&&"inside"!==n||!o.some(e=>1===e.level)?1===o.length&&o[0].parentId!==t.parentId&&(s="Existing pane"):s="To the group",hn(s,pn(r))}}}function*_n(e){yield(0,w.fork)(gn),yield(0,w.fork)(mn),yield(0,
w.fork)(vn,e)}function*bn(e){yield(0,w.fork)(_n,e);const t=yield(0,w.call)(fn,e);pt.logNormal("Opened object tree data source channel");try{for(;;){const e=yield(0,w.take)(t);yield(0,w.put)(e)}}finally{pt.logNormal("Closed object tree data source channel"),t.close()}}const Sn=o.createContext(null);var yn=n(54475),Cn=n(898),wn=n(48247);const Tn=T.mobiletouch?"touch":"native";function In(e){const{viewModel:t,showHeader:n=!0,nodeRenderer:r,isDialog:s=!1}=e,i=(0,o.useRef)(null),l=function(e){const[t,n]=(0,o.useState)(e.getChartId()),r=(0,o.useRef)(t);return r.current=t,(0,o.useEffect)(()=>{return e.onChange().subscribe(null,t),()=>{e.onChange().unsubscribe(null,t)};function t(){const t=e.getChartId();r.current!==t&&n(t)}},[]),t}(t),[a,c]=(0,Cn.useDimensions)(),[d,u]=(0,o.useState)(null),h=(0,o.useMemo)(()=>({isTouch:T.touch,isDialog:s}),[s]);return o.createElement(Sn.Provider,{value:h},o.createElement(N.Provider,{value:{viewModel:t}},o.createElement("div",{className:wn.wrap,onContextMenu:yn.preventDefaultForContextMenu},n&&o.createElement(j,null),o.createElement(C(),{onMeasure:a},o.createElement("div",{className:wn.space,onClick:function(e){if(e.defaultPrevented)return;if(!(e.target instanceof Element)||null===i.current)return;e.target===i.current&&t.selection().set([])}},null!==c&&o.createElement(dn,{key:l,height:c.height,width:c.width,canBeAddedToSelection:function(e){const n=t.entity(e);return t.selection().canBeAddedToSelection(n)},nodeRenderer:r,initState:function(){const{nodes:e,selection:n}=t.getState();return{selectedIds:n,nodes:e}},canMove:function(e,n,o){return t.isSelectionDropable(n.id,o)},drag:Tn,rowHeight:En,onSelect:function(e){const n=e.map(e=>t.entity(e)).filter(e=>null!==e);t.selection().set(n)},onDrop:function(e){e.preventDefault();const{detail:{target:n,type:o}}=e;t.insertSelection(n,o)},scrollToId:d,saga:function*(){yield(0,w.fork)(bn,t)},onKeyboardSelect:function(e){u({id:e})},outerRef:function(e){i.current=e}}))))))}function En(e,t){switch(t.type){case"node":return 38;case"separator":return 13}}var Mn;!function(e){e.Svg="svg",e.Text="text"}(Mn||(Mn={}));var xn=n(31261),Dn=n(30608);function An(e){const{className:t,disabled:n,...r}=e;return o.createElement(x.Icon,{className:M()(Dn.button,n&&Dn.disabled,t),...r})}var Ln=n(77975),Nn=n(73591),kn=n(73366),On=n(20077),Bn=n(3589),Rn=n(68256),Fn=n(82308),Pn=n(89559);function jn(e){const{id:t}=e,n=(0,o.useContext)(N),{viewModel:r}=(0,I.ensureNotNull)(n),s=r.entity(t);return null===s?null:o.createElement(zn,{...e,entity:s})}function zn(e){const{id:t,isOffset:n,isDisabled:r,isSelected:s,isChildOfSelected:i,isHovered:l,parentId:a,entity:c,isExpanded:d}=e,u=(0,o.useContext)(N),{viewModel:h}=(0,I.ensureNotNull)(u),p=(0,o.useContext)(Sn),{size:f}=(0,o.useContext)(It),[g,m]=(0,o.useState)(!1),_=(0,o.useRef)(null),[b,S]=(0,o.useState)(c.title()),[y,C]=(0,o.useState)(c.isLocked()),[w,T]=(0,o.useState)(c.isVisible()),[M,D]=(0,o.useState)(c.isActualInterval()),[A,L]=(0,o.useState)(c.getDrawingSyncState()),[k,O]=(0,o.useState)(!1),[B,R]=((0,Ln.useWatchedValueReadonly)({
watchedValue:h.getChartLayout()}),(0,o.useState)(!1)),F=(0,o.useRef)(null);(0,o.useEffect)(()=>{const e={};c.onLockChanged().subscribe(e,()=>C(c.isLocked())),c.onVisibilityChanged().subscribe(e,()=>T(c.isVisible()));const t=c.onTitleChanged();return t&&t.subscribe(e,()=>S(c.title())),c.onIsActualIntervalChange().subscribe(e,()=>D(c.isActualInterval())),c.onSyncStateChanged().subscribe(e,()=>L(c.getDrawingSyncState())),()=>{c.onIsActualIntervalChange().unsubscribeAll(e),c.onLockChanged().unsubscribeAll(e),c.onVisibilityChanged().unsubscribeAll(e),c.onSyncStateChanged().unsubscribeAll(e),t&&t.unsubscribeAll(e),F.current&&clearTimeout(F.current)}},[c]),(0,o.useEffect)(()=>{g&&_.current&&(_.current.focus(),_.current.setSelectionRange(0,b.length))},[g]),(0,o.useEffect)(()=>{const e={};return h.hoveredObjectChanged().subscribe(e,X),()=>{h.hoveredObjectChanged().unsubscribeAll(e)}},[d]),(0,o.useEffect)(()=>{h.setHoveredObject(l?t:null)},[l]),(0,o.useEffect)(()=>{!s&&F.current&&(clearTimeout(F.current),F.current=null),m(!1)},[s]);const P=c.getIcon(),j={};if(a){const e=h.entity(a);e&&(j["data-parent-name"]=e.title()),j["data-type"]=c.hasChildren()?"group":"data-source"}const z=c.title(),V=l||k,H=g&&s,G=!!p&&p.isTouch,W=!!p&&p.isDialog,U=M&&w?Rn:Fn,K=c.hasChildren()?(0,v.t)("Group is hidden on current interval"):(0,v.t)("Drawing is hidden on current interval");return o.createElement("span",{className:E(Pn.wrap,r&&Pn.disabled,s&&Pn.selected,n&&Pn.offset,i&&Pn.childOfSelected,k&&!r&&!s&&!i&&Pn.hover,W&&!r&&!s&&!i&&Pn.dialog),onMouseDown:function(e){g&&!(0,I.ensureNotNull)(_.current).contains(e.target)&&R(!0)},onClick:1===f?Z:function(e){if(e.defaultPrevented)return;if(0!==(0,Ct.modifiersFromEvent)(e))return;if(F.current)e.preventDefault(),clearTimeout(F.current),F.current=null,h.openProperties(c),R(!1);else{const e=h.selection().selected();F.current=setTimeout(()=>{F.current=null,s&&!B&&1===e.length&&h.rename(c,()=>m(!0)),R(!1)},500)}},onContextMenu:G?void 0:Z},!H&&o.createElement(o.Fragment,null,P&&P.type===Mn.Svg&&o.createElement(x.Icon,{icon:P.content||"",className:Pn.icon}),P&&P.type===Mn.Text&&o.createElement("span",{className:E(Pn.icon,Pn.textIcon)},P.content),!1,o.createElement("span",{className:E(Pn.title,h.isMain(c)&&Pn.main,(!c.isVisible()||!M)&&Pn.disabled),...j},z),o.createElement("span",{className:Pn.rightButtons},c.canBeLocked()&&o.createElement(An,{icon:y?On:Bn,className:E(Pn.button,(V||y)&&Pn.visible),onClick:function(e){if(e.defaultPrevented)return;e.preventDefault(),h.setIsLocked(t,!c.isLocked())},"data-role":"button","data-name":"lock","data-active":y}),o.createElement(An,{icon:U,className:E(Pn.button,!M&&[Pn.warn,"apply-common-tooltip"],(V||!w||!M)&&Pn.visible),onClick:M?function(e){if(e.defaultPrevented)return;e.preventDefault(),h.setIsVisible(t,!c.isVisible())}:function(e){if(e.defaultPrevented)return;e.preventDefault(),h.openProperties(c,Nn.TabNames.visibility)},title:M?void 0:K,"data-role":"button","data-name":"hide","data-active":!w}),c.canBeRemoved()&&o.createElement(An,{icon:kn,
className:E(Pn.button,(G||V)&&Pn.visible),onClick:function(e){if(e.defaultPrevented)return;e.preventDefault(),e.stopPropagation(),h.remove(t)},"data-role":"button","data-name":"remove"}))),H&&o.createElement(xn.InputControl,{value:b,onChange:function(e){S(e.currentTarget.value)},onClick:yn.preventDefault,className:Pn.renameInput,onKeyDown:function(e){27===(0,Ct.hashFromEvent)(e)?(e.preventDefault(),S(c.title()),m(!1)):13===(0,Ct.hashFromEvent)(e)&&(e.preventDefault(),Q())},reference:function(e){_.current=e},onBlur:Q,onDragStart:function(e){e.preventDefault(),e.stopPropagation()},draggable:!0,stretch:!0}));function Z(e){e.defaultPrevented||g||!c.fullyConstructed()||(e.preventDefault(),e.persist(),h.openContextMenu(c,()=>m(!0),e))}function Q(){""!==b&&c.setName(b),S(c.title()),m(!1)}function X(e){if(c.hasChildren()&&!d){const t=null!==e&&c.childrenIds().has(e);O(t)}else O(t===e)}}var Vn=n(32713);class Hn extends o.PureComponent{constructor(e){super(e),this._isMounted=!1,this._dialogRef=o.createRef(),this._renderChildren=e=>o.createElement(Gn,{isSmallTablet:e,viewModel:this.props.viewModel}),this._handleMediaChange=()=>{this.state.showDrawer&&!window.matchMedia(b.DialogBreakpoints.TabletSmall).matches&&this.setState({showDrawer:!1})},this._onManageDrawings=e=>{throw new Error("not supported")},this._closeDrawer=()=>{this.setState({showDrawer:!1})},this._handleContextMenuOpened=e=>{this.setState({isContextMenuOpened:e})},this._matchMedia=window.matchMedia(b.DialogBreakpoints.TabletSmall),this.state={showDrawer:!1,showDialog:!1,isContextMenuOpened:!1}}componentDidMount(){this._isMounted=!0,this._matchMedia.addListener(this._handleMediaChange),this.props.viewModel.isContextMenuOpened().subscribe(this._handleContextMenuOpened)}componentWillUnmount(){this._isMounted=!1,this._matchMedia.removeListener(this._handleMediaChange),this.props.viewModel.isContextMenuOpened().unsubscribe(this._handleContextMenuOpened)}render(){return o.createElement(o.Fragment,null,o.createElement(m.MatchMedia,{rule:b.DialogBreakpoints.TabletSmall},e=>o.createElement(_.AdaptivePopupDialog,{additionalElementPos:"after",additionalHeaderElement:!1,className:Vn.dialog,dataName:"object-tree-dialog",isOpened:!0,onClickOutside:this.state.showDialog||e||this.state.isContextMenuOpened?()=>{}:this.props.onClose,onClose:this.props.onClose,ref:this._dialogRef,render:()=>this._renderChildren(e),title:(0,v.t)("Object tree"),showSeparator:!0})),o.createElement(g.DrawerManager,null,this.state.showDrawer&&o.createElement(f.Drawer,{onClose:this._closeDrawer,position:"Bottom"},o.createElement(S.ManageDrawings,{onClose:this._closeDrawer,chartWidget:this.props.activeChartWidget,isMobile:!0}))))}}function Gn(e){const{isSmallTablet:t,viewModel:n}=e,r=(0,o.useMemo)(()=>({size:t?1:0,smallSizeTreeNodeAction:0}),[t]);return o.createElement(It.Provider,{value:r},o.createElement(In,{nodeRenderer:jn,showHeader:!1,viewModel:n,isDialog:!0}))}var Wn=n(16216),Un=n(54427),Kn=n(2872),Zn=n.n(Kn);var Qn=n(32112);function Xn(e,t){return`${e}:${t}`}function $n(e){const t=e.split(":")
;return{persistentId:t[0],instanceId:t[1]}}class qn{constructor(e){this._onChange=new(Zn()),this._recalculate=()=>{const e=this._groupModel.groups().map(e=>Xn(e.id,e.instanceId())),t=this._selectionApi.allSources();this._selected=this._selected.filter(n=>e.includes(n)||t.includes(n)),this._onChange.fire(this._selected)},this._model=e,this._selectionApi=new Qn.SelectionApi(this._model),this._groupModel=this._model.lineToolsGroupModel(),this._selected=this._getSelectedIds(),this._selectionApi.onChanged().subscribe(this,()=>{this._selected=this._getSelectedIds(),this._onChange.fire(this._selected)}),this._groupModel.onChanged().subscribe(this,this._recalculate)}destroy(){this._selectionApi.onChanged().unsubscribeAll(this),this._groupModel.onChanged().unsubscribeAll(this)}set(e){const t=[];let n=e.map(e=>e.id());for(const o of e)if(o.hasChildren()){const e=o.childrenIds();t.push(...Array.from(e.values())),n=n.filter(t=>!e.has(t))}else t.push(o.id());this._selectionApi.set(t.map(e=>$n(e).persistentId)),this._selected=n,this._onChange.fire(this._selected)}canBeAddedToSelection(e){return null!==e&&e.canBeAddedToSelection()}onChange(){return this._onChange}selected(){return this._selected}_getSelectedIds(){return this._selectionApi.allSources().map(e=>this._model.dataSourceForId(e)).filter(ht.notNull).filter(e=>e.showInObjectTree()).map(e=>Xn(e.id(),e.instanceId()))}}class Jn{constructor(e,t){this._controller=e,this._facade=t,this._groupModel=e.model().lineToolsGroupModel()}buildTree(){const e={};for(const t of this._controller.model().panes()){const n=t.sourcesByGroup().all().filter(e=>e.showInObjectTree());e[t.id()]=Yn(t.id(),0);for(const n of this._groupModel.groups()){const o=Xn(n.id,n.instanceId()),r=(0,I.ensureNotNull)(this._facade.getObjectById(o));if(r.pane()===t){const o=[...n.lineTools()].sort((e,t)=>e.zorder()>t.zorder()?-1:1).map(e=>Xn(e.id(),e.instanceId()));e[r.id()]=Yn(r.id(),1,t.id(),o),e[t.id()].children.push(r.id());for(const t of o)e[t]=Yn(t,2,r.id())}}for(const o of n){const n=Xn(o.id(),o.instanceId());e[n]||(e[n]=Yn(n,1,t.id()),e[t.id()].children.push(n))}e[t.id()].children.sort((e,t)=>{const n=(0,I.ensureNotNull)(this._facade.getObjectById(e)),o=(0,I.ensureNotNull)(this._facade.getObjectById(t));return(0,I.ensureNotNull)(o.zOrder())-(0,I.ensureNotNull)(n.zOrder())})}return this._facade.invalidateCache(new Set(Object.keys(e))),e}}function Yn(e,t,n,o=[]){return{id:e,level:t,parentId:n,children:o}}var eo=n(24980),to=n(14291),no=n(81851),oo=n(62443),ro=n(56972),so=n(61671),io=n(85733),lo=n(13696),ao=n(55247),co=n(28337),uo=n(46627);const ho=new eo.TranslatedString("show {title}",(0,v.t)("show {title}")),po=new eo.TranslatedString("hide {title}",(0,v.t)("hide {title}")),fo=new eo.TranslatedString("lock {title}",(0,v.t)("lock {title}")),go=new eo.TranslatedString("unlock {title}",(0,v.t)("unlock {title}")),mo=new eo.TranslatedString("change {sourceTitle} title to {newSourceTitle}",(0,v.t)("change {sourceTitle} title to {newSourceTitle}")),vo=new eo.TranslatedString("insert source(s) after",(0,
v.t)("insert source(s) after"));function _o(e,t){return t.every(t=>!(t.pane()!==e&&!t.allowsMovingbetweenPanes()))}function bo(e){return e instanceof oo.DataSource&&e.showInObjectTree()?Xn(e.id(),e.instanceId()):null}function So(e){return new eo.TranslatedString(e.name(),e.title())}const yo=new(Zn());class Co{constructor(e,t){this._syncStateChanged=new(Zn()),this._lineToolsAffectChartInvalidation=new uo.FeatureToggleWatchedValue("do_not_invalidate_chart_on_changing_line_tools",!1),this._updateSyncState=()=>{this._syncStateChanged.fire((0,I.ensureNotNull)(this.getDrawingSyncState()))},this._undoModel=e,this._dataSource=t,(0,to.isLineTool)(this._dataSource)&&(this._dataSource.linkKey().subscribe(this._updateSyncState),this._dataSource.sharingMode().subscribe(this._updateSyncState));const n=this._undoModel.lineBeingCreated();null!==n&&n===t&&n.isSynchronizable()&&io.isToolCreatingNow.subscribe(this._updateSyncState)}destroy(){(0,to.isLineTool)(this._dataSource)&&(this._dataSource.linkKey().unsubscribe(this._updateSyncState),this._dataSource.sharingMode().unsubscribe(this._updateSyncState)),io.isToolCreatingNow.unsubscribe(this._updateSyncState)}id(){return Xn(this._dataSource.id(),this._dataSource.instanceId())}title(){const e=this._dataSource;return(0,to.isLineTool)(e)?e.properties().title.value()||e.translatedType():(0,ro.isSeries)(e)&&this._undoModel.mainSeries()===e?e.symbolTitle(void 0,void 0,(0,bt.onWidget)()?"exchange":"listed_exchange"):e.title()}gaLabel(){return(0,no.isStudy)(this._dataSource)?"Study":(0,to.isLineTool)(this._dataSource)?"Drawing":"Symbol"}canBeLocked(){return(0,to.isLineTool)(this._dataSource)&&this._dataSource.userEditEnabled()}canBeRemoved(){return this._undoModel.mainSeries()!==this._dataSource&&this._dataSource.isUserDeletable()}canBeHidden(){return this._dataSource.canBeHidden()}canBeRenamed(){return(0,to.isLineTool)(this._dataSource)}fullyConstructed(){return this._undoModel.lineBeingCreated()!==this._dataSource}isVisible(){return this._dataSource.properties().visible.value()}isActualInterval(){return!(0,to.isLineTool)(this._dataSource)&&!(0,no.isStudy)(this._dataSource)||this._dataSource.isActualInterval()}onIsActualIntervalChange(){return(0,to.isLineTool)(this._dataSource)||(0,no.isStudy)(this._dataSource)?this._dataSource.onIsActualIntervalChange():yo}isLocked(){return!!(0,to.isLineTool)(this._dataSource)&&this._dataSource.properties().frozen.value()}onVisibilityChanged(){return this._dataSource.properties().visible.listeners()}onLockChanged(){return(0,to.isLineTool)(this._dataSource)?this._dataSource.properties().frozen.listeners():yo}getIcon(){const e=c,t=this._dataSource.getSourceIcon(),n=(0,no.isStudyStrategy)(this._dataSource);let o={type:Mn.Svg,content:n?lo:ao};if(e&&t)if("loadSvg"===t.type){const[n,r]=t.svgId.split("."),s="linetool"===n?e.linetool[r]:e.series[Number(r)];o={type:Mn.Svg,content:s||ao}}else"text"===t.type&&(o={type:Mn.Text,content:t.text});return o}setVisible(e){const t=(e?ho:po).format({title:So(this._dataSource)})
;this._undoModel.setProperty(this._dataSource.properties().visible,e,t)}setLocked(e){if((0,to.isLineTool)(this._dataSource)){const t=(e?fo:go).format({title:So(this._dataSource)});this._undoModel.setProperty(this._dataSource.properties().frozen,e,t)}}setName(e){if((0,to.isLineTool)(this._dataSource)){const t=mo.format({sourceTitle:this._dataSource.properties().title.value()||So(this._dataSource),newSourceTitle:e});this._undoModel.setProperty(this._dataSource.properties().title,e,t,this._lineToolsAffectChartInvalidation.value())}}isCopiable(){return this._dataSource.copiable()}isClonable(){return this._dataSource.cloneable()}zOrder(){return this._dataSource.zorder()}remove(){this._undoModel.removeSource(this._dataSource,!1)}canBeAddedToSelection(){return this._undoModel.selection().canBeAddedToSelection(this._dataSource)}setAsSelection(){this._undoModel.model().selectionMacro(e=>{e.clearSelection(),e.addSourceToSelection(this._dataSource)})}addToSelection(){this._undoModel.model().selectionMacro(e=>{e.addSourceToSelection(this._dataSource)})}addSourcesToArray(e){return e.push(this._dataSource),e}insertSourcesBeforeThis(e){this._insertSources(e,e=>this._undoModel.insertBefore(e,this._dataSource))}insertSourcesAfterThis(e){this._insertSources(e,e=>this._undoModel.insertAfter(e,this._dataSource))}childrenIds(){return new Set}hasChildren(){return!1}pane(){return(0,I.ensureNotNull)(this._undoModel.model().paneForSource(this._dataSource))}allowsMovingbetweenPanes(){return!(0,to.isLineTool)(this._dataSource)}canBeAddedToGroup(){return(0,to.isLineTool)(this._dataSource)&&this._dataSource.boundToSymbol()}canInsertBeforeThis(e){return this._canInsertBeforeOrAfter(e)}canInsertAfterThis(e){return this._canInsertBeforeOrAfter(e)}detachFromParent(){if((0,to.isLineTool)(this._dataSource)){const e=this._undoModel.model(),t=this._undoModel.lineToolsGroupController(),n=e.lineToolsGroupModel().groupForLineTool(this._dataSource);null!==n&&t.excludeLineToolFromGroup(n,this._dataSource)}}onTitleChanged(){const e=this._dataSource.properties().title;return e?e.listeners():void 0}canBeSyncedInLayout(){return(0,to.isLineTool)(this._dataSource)&&this._dataSource.isSynchronizable()}onSyncStateChanged(){return this._syncStateChanged}setDrawingSyncState(e){if(!this.canBeSyncedInLayout()||!this.fullyConstructed())return;const t=this._dataSource;switch(e){case 0:if(null===t.linkKey().value())return;this._undoModel.unlinkLines([t]);break;case 1:if(null!==t.linkKey().value())return;this._undoModel.copyToOtherCharts([t])}}getDrawingSyncState(){return this.canBeSyncedInLayout()?this.fullyConstructed()&&null!==this._dataSource.linkKey().value()?1:0:null}doNotAffectChartInvalidation(){return(0,to.isLineTool)(this._dataSource)&&this._lineToolsAffectChartInvalidation.value()}_canInsertBeforeOrAfter(e){const t=this._undoModel.model();if(!_o(this.pane(),e))return!1;if((0,to.isLineTool)(this._dataSource)){if(null!==t.lineToolsGroupModel().groupForLineTool(this._dataSource)&&e.some(e=>!e.canBeAddedToGroup()))return!1}return!0}_insertSources(e,t){
const n=this._undoModel.model(),o=this._undoModel.lineToolsGroupController();this._undoModel.beginUndoMacro(vo);const r=()=>{e.forEach(e=>e.detachFromParent())},s=e.reduce((e,t)=>t.addSourcesToArray(e),[]);if((0,to.isLineTool)(this._dataSource)){const t=n.lineToolsGroupModel().groupForLineTool(this._dataSource);null!==t?((0,I.assert)(!e.some(e=>e.hasChildren())),s.forEach(e=>{(0,to.isLineTool)(e)&&(t.containsLineTool(e)||o.addLineToolToGroup(t,e))})):r()}else r();t(s),this._undoModel.endUndoMacro()}}class wo{constructor(e,t){this._onTitleChanged=new(Zn()),this._onVisibilityChanged=new(Zn()),this._onLockChanged=new(Zn()),this._onIsActualIntervalChanged=new(Zn()),this._syncStateChanged=new(Zn()),this._linkKeyChangedBound=this._linkKeyChanged.bind(this),this._lineToolsAffectChartInvalidation=new uo.FeatureToggleWatchedValue("do_not_invalidate_chart_on_changing_line_tools",!1),this._undoModel=e,this._group=t,this._lineTools=t.lineTools(),this._paneId=(0,I.ensureNotNull)(e.model().paneForSource(this._lineTools[0])).id();const n=()=>{this._lineTools.forEach(e=>{e.properties().visible.listeners().subscribe(this,()=>this._onVisibilityChanged.fire()),e.properties().frozen.listeners().subscribe(this,()=>this._onLockChanged.fire()),e.onIsActualIntervalChange().subscribe(this,()=>this._onIsActualIntervalChanged.fire()),e.linkKey().subscribe(this._linkKeyChangedBound),e.sharingMode().subscribe(this._linkKeyChangedBound)})};this._group.onChanged().subscribe(this,e=>{this._unsubscribeFromAllLineTools(),this._lineTools=this._group.lineTools(),n(),e.lockedChanged&&this._onLockChanged.fire(),e.visibilityChanged&&this._onVisibilityChanged.fire(),e.titleChanged&&this._onTitleChanged.fire(),e.isActualIntervalChanged&&this._onIsActualIntervalChanged.fire();const t=this.getDrawingSyncState();null!==t&&this._syncStateChanged.fire(t)}),n(),this._lastActualZOrder=this.zOrder(),this._lastIsVisible=this.isVisible(),this._lastIsActualInterval=this.isActualInterval(),this._lastIsLocked=this.isLocked()}destroy(){this._unsubscribeFromAllLineTools(),this._group.onChanged().unsubscribeAll(this)}id(){return Xn(this._group.id,this._group.instanceId())}title(){return this._group.name()}gaLabel(){return"Group"}getIcon(){return{type:Mn.Svg,content:co}}canBeRemoved(){return!0}canBeHidden(){return!0}canBeLocked(){return!0}canBeRenamed(){return!0}fullyConstructed(){return!0}isVisible(){return this._group.lineTools().length>0&&(this._lastIsVisible="Invisible"!==this._group.visibility()),this._lastIsVisible}isActualInterval(){return this._group.lineTools().length>0&&(this._lastIsActualInterval=this._group.lineTools().some(e=>e.isActualInterval())),this._lastIsActualInterval}onIsActualIntervalChange(){return this._onIsActualIntervalChanged}isLocked(){return this._group.lineTools().length>0&&(this._lastIsLocked="Locked"===this._group.locked()),this._lastIsLocked}onTitleChanged(){return this._onTitleChanged}onVisibilityChanged(){return this._onVisibilityChanged}onLockChanged(){return this._onLockChanged}setVisible(e){
this._undoModel.lineToolsGroupController().setGroupVisibility(this._group,e)}setLocked(e){this._undoModel.lineToolsGroupController().setGroupLock(this._group,e)}setName(e){this._undoModel.lineToolsGroupController().setGroupName(this._group,e)}isCopiable(){return!1}isClonable(){return!1}zOrder(){return this._group.lineTools().length>0&&(this._lastActualZOrder=this._group.lineTools()[0].zorder()),this._lastActualZOrder}remove(){this._undoModel.lineToolsGroupController().removeGroup(this._group)}canBeAddedToSelection(){const e=this._undoModel.model();return this._lineTools.every(t=>e.selection().canBeAddedToSelection(t))}setAsSelection(){this._undoModel.model().selectionMacro(e=>{e.clearSelection(),this._lineTools.forEach(t=>e.addSourceToSelection(t))})}addToSelection(){this._undoModel.model().selectionMacro(e=>{this._lineTools.forEach(t=>e.addSourceToSelection(t))})}addSourcesToArray(e){return e.push(...this._lineTools),e}detachFromParent(){}insertSourcesBeforeThis(e){const t=this._insertBeforeTarget();this._insertSources(e,e=>this._undoModel.insertBefore(e,t))}insertSourcesAfterThis(e){const t=this._insertAfterTarget();this._insertSources(e,e=>this._undoModel.insertAfter(e,t))}childrenIds(){const e=[...this._lineTools];return e.sort((e,t)=>t.zorder()-e.zorder()),new Set(e.map(e=>Xn(e.id(),e.instanceId())))}hasChildren(){return!0}pane(){return(0,I.ensureDefined)(this._undoModel.model().panes().find(e=>e.id()===this._paneId))}allowsMovingbetweenPanes(){return!1}canBeAddedToGroup(){return!1}canInsertBeforeThis(e){return this._canInsertBeforeOrAfter(e)}canInsertAfterThis(e){return this._canInsertBeforeOrAfter(e)}canBeSyncedInLayout(){return this._lineTools.length>0&&this._lineTools[0].isSynchronizable()}onSyncStateChanged(){return this._syncStateChanged}setDrawingSyncState(e){if(this.canBeSyncedInLayout())switch(e){case 0:const e=this._lineTools.filter(e=>null!==e.linkKey().value());e.length>0&&this._undoModel.unlinkLines(e);break;case 1:const t=this._lineTools.filter(e=>null===e.linkKey().value());t.length>0&&this._undoModel.copyToOtherCharts(t)}}getDrawingSyncState(){return this.canBeSyncedInLayout()?this._lineTools.every(e=>null!==e.linkKey().value())?1:0:null}doNotAffectChartInvalidation(){return this._lineToolsAffectChartInvalidation.value()}_linkKeyChanged(){this._syncStateChanged.fire((0,I.ensureNotNull)(this.getDrawingSyncState()))}_canInsertBeforeOrAfter(e){return _o(this.pane(),e)}_insertSources(e,t){this._undoModel.beginUndoMacro(vo);const n=e.reduce((e,t)=>t.addSourcesToArray(e),[]);e.forEach(e=>e.detachFromParent()),t(n),this._undoModel.endUndoMacro()}_insertBeforeTarget(){return(0,I.ensureNotNull)(this._lineTools.reduce((e,t)=>null===e?t:e.zorder()<t.zorder()?e:t,null))}_insertAfterTarget(){return(0,I.ensureNotNull)(this._lineTools.reduce((e,t)=>null===e?t:e.zorder()>t.zorder()?e:t,null))}_unsubscribeFromAllLineTools(){this._lineTools.forEach(e=>{e.properties().visible.listeners().unsubscribeAll(this),e.properties().frozen.listeners().unsubscribeAll(this),e.onIsActualIntervalChange().unsubscribeAll(this),
e.linkKey().unsubscribe(this._linkKeyChangedBound),e.sharingMode().unsubscribe(this._linkKeyChangedBound)})}}class To{constructor(e){this._hoveredObjectChanged=new(Zn()),this._entitiesCache=new Map,this._undoModel=e,this._undoModel.model().hoveredSourceChanged().subscribe(this,this._onModelHoveredSourceChanged)}destroy(){for(const e of this._entitiesCache.values())null==e||e.destroy()}getObjectById(e){if(this._entitiesCache.has(e))return(0,I.ensureDefined)(this._entitiesCache.get(e));const t=this._createObjectById(e);return this._entitiesCache.set(e,t),t}invalidateCache(e){Array.from(this._entitiesCache.keys()).forEach(t=>{var n;e.has(t)||(null===(n=this._entitiesCache.get(t))||void 0===n||n.destroy(),this._entitiesCache.delete(t))})}canBeGroupped(e){if(0===e.length||1===e.length&&e[0].hasChildren())return!1;const t=[];if(e.forEach(e=>e.addSourcesToArray(t)),t.some(e=>!(0,to.isLineTool)(e)||!e.boundToSymbol()))return!1;const n=this._undoModel.model(),o=t.map(e=>n.paneForSource(e));return!(new Set(o).size>1)}contextMenuActions(e,t,n){const o=new so.ActionsProvider(e,n),r=[];return t.forEach(e=>e.addSourcesToArray(r)),o.contextMenuActionsForSources(r)}insertBefore(e,t){t.insertSourcesAfterThis(e)}insertAfter(e,t){t.insertSourcesBeforeThis(e)}setHoveredObject(e){const t=this._undoModel.model();if(null===e)return void t.setHoveredSource(null,null);const n=t.dataSourceForId(e);null!==n&&t.setHoveredSource(n,null)}hoveredObjectId(){return bo(this._undoModel.model().hoveredSource())}hoveredObjectChanged(){return this._hoveredObjectChanged}_onModelHoveredSourceChanged(e){this._hoveredObjectChanged.fire(bo(e))}_createObjectById(e){const t=$n(e).persistentId,n=this._undoModel.model(),o=n.dataSourceForId(t);if(null!==o)return new Co(this._undoModel,o);const r=n.lineToolsGroupModel().groupForId(t);return null!==r?new wo(this._undoModel,r):null}}var Io=n(22932),Eo=n(97056),Mo=n(28296),xo=n(52714),Do=n.n(xo),Ao=n(76576),Lo=n(54859),No=n(48111),ko=n(57914),Oo=n(94669),Bo=n(78679);const Ro=(0,l.getLogger)("Platform.GUI.ObjectTree");const Fo=new eo.TranslatedString("move objects",(0,v.t)("move objects")),Po=new eo.TranslatedString("lock objects",(0,v.t)("lock objects")),jo=new eo.TranslatedString("unlock objects",(0,v.t)("unlock objects")),zo=new eo.TranslatedString("show objects",(0,v.t)("show objects")),Vo=new eo.TranslatedString("hide objects",(0,v.t)("hide objects")),Ho=new eo.TranslatedString("remove objects",(0,v.t)("remove objects")),Go=(0,v.t)("Create a group of drawings"),Wo=(0,v.t)("Rename"),Uo=(0,v.t)("Unlock"),Ko=(0,v.t)("Lock"),Zo=(0,v.t)("Hide"),Qo=(0,v.t)("Show"),Xo=(0,v.t)("Remove");class $o{constructor(e){this._nodes={},this._onChange=new(Zn()),this._onGroupCreated=new(Zn()),this._subscriptions=[],this._removeSourcesPromise=null,this._timeout=null,this._objects=[],this._options={general:!0,mainSeries:!0,mainSeriesTrade:!0,esdStudies:!0,fundamentals:!0,studies:!0,lineTools:!0,publishedCharts:!0,ordersAndPositions:!0,alerts:!1,chartEvents:!0,objectTree:!1,gotoLineTool:!0},this._isContextMenuOpened=new(Do())(!1),
this._getObjectsToModify=e=>{const t=this.selection().selected();return t.find(t=>t===e)?t.map(this._ensuredEntity):[this._ensuredEntity(e)]},this._onActiveChartChanged=()=>{this._cleanup(),this._init()},this._cleanup=()=>{null!==this._timeout&&(clearTimeout(this._timeout),this._timeout=null),this._subscriptions.forEach(e=>{e.unsubscribeAll(this)}),this._selection.destroy(),this._chart.unsubscribe(this._onActiveChartChanged),null!==this._removeSourcesPromise&&this._removeSourcesPromise.cancel(),this._facade.destroy()},this._init=()=>{const e=this._chart.value();e.hasModel()&&(this._controller=e.model(),this._groupController=this._controller.lineToolsGroupController(),this._model=this._controller.model(),this._groupModel=this._model.lineToolsGroupModel(),this._facade=new To(this._controller),this._subscriptions=[this._model.mainSeries().onStyleChanged(),this._model.mainSeries().dataEvents().symbolResolved(),this._model.mainSeries().onIntervalChanged(),this._model.panesCollectionChanged(),this._model.dataSourceCollectionChanged(),this._groupModel.onChanged()],this._subscriptions.forEach(e=>{e.subscribe(this,this._update)}),this._chart.subscribe(this._onActiveChartChanged),this._selection=new qn(this._model),this._update())},this._update=()=>{null===this._timeout&&(this._timeout=setTimeout(()=>{this._recalculateTree(),this._onChange.fire(),this._timeout=null}))},this._ensuredEntity=e=>(0,I.ensureNotNull)(this._getEntityById(e)),this._chart=e,this._init()}destroy(){this._cleanup()}getState(){return{nodes:Object.values(this._nodes),selection:this._selection.selected()}}getChartId(){return this._chart.value().id()}insertSelection(e,t){const n=this._facade,o=this.selection().selected().map(this._ensuredEntity),[r,s]=this._normalizeTargetAndDropType(e,t);this._controller.withMacro(Fo,()=>{switch(s){case"before":n.insertBefore(o,r);break;case"after":n.insertAfter(o,r)}}),this._update()}entity(e){return this._facade.getObjectById(e)}isMain(e){return $n(e.id()).persistentId===this._controller.mainSeries().id()}selection(){return this._selection}setIsLocked(e,t){const n=this._getObjectsToModify(e),o=n.every(e=>e.doNotAffectChartInvalidation()),r=t?Po:jo;this._controller.withMacro(r,()=>{for(const e of n)e.setLocked(t)},o),hn("Lock",pn(n))}setIsVisible(e,t){const n=this._getObjectsToModify(e),o=n.every(e=>e.doNotAffectChartInvalidation()),r=t?zo:Vo;this._controller.withMacro(r,()=>{for(const e of n)e.setVisible(t)},o),hn("Hide",pn(n))}remove(e){const t=()=>{const e=n.every(e=>e.doNotAffectChartInvalidation());this._controller.withMacro(Ho,()=>{for(const e of n)e.remove()},e),hn("Delete",pn(n)),this._update()},n=this._getObjectsToModify(e);t()}canSelectionBeGrouped(){const e=this._getSelectedEntities();return this._facade.canBeGroupped(e)}createGroupFromSelection(){const e=this._groupController.createGroupFromSelection();hn("Create Group");const t=Xn(e.id,e.instanceId());this.selection().set([this._ensuredEntity(t)]),this._onGroupCreated.fire(t),this._update()}isSelectionDropable(e,t){
const n=this.selection().selected().map(this._ensuredEntity),[o,r]=this._normalizeTargetAndDropType(e,t);switch(r){case"after":return o.canInsertAfterThis(n);case"before":return o.canInsertBeforeThis(n)}}onChange(){return this._onChange}onGroupCreated(){return this._onGroupCreated}isSelectionCloneable(){const e=this._getSelectedEntities();return e.length>0&&e.every(e=>e.isClonable())}isSelectionCopiable(){const e=this._getSelectedEntities();return e.length>0&&e.every(e=>e.isCopiable())}openProperties(e,t){const n=this._model.dataSourceForId($n(e.id()).persistentId);this.selection().selected().length>1&&this.selection().selected().includes(e.id())?this._chart.value().showSelectedSourcesProperties(t):(this.selection().set([e]),null!==n?this._controller.mainSeries()===n?this._chart.value().showGeneralChartProperties():((0,to.isLineTool)(n)||(0,no.isStudy)(n))&&this._chart.value().showChartPropertiesForSource(n,t):this._chart.value().showChartPropertiesForSources({sources:this._chart.value().model().selection().lineDataSources(),title:e.title(),tabName:t,renamable:!0}))}canSelectionBeUnmerged(){const e=this._getSelectedEntities();return 1===e.length&&this.canNodeWithIdBeUnmerged($n(e[0].id()).persistentId)}canNodeWithIdBeUnmerged(e){const t=this._model.dataSourceForId(e);return null!==t&&(0,Io.isPriceDataSource)(t)&&this._model.isUnmergeAvailableForSource(t)}unmergeSelectionUp(){this._unmergeSelection(0)}unmergeSelectionDown(){this._unmergeSelection(1)}copySelection(){const e=this._getSelectedEntities(),t=e.map(e=>(0,I.ensureNotNull)(this._model.dataSourceForId($n(e.id()).persistentId)));this._chart.value().chartWidgetCollection().clipboard.uiRequestCopy(t),hn("Copy",pn(e))}cloneSelection(){const e=this._getSelectedEntities(),t=e.map(e=>(0,I.ensureNotNull)(this._model.dataSourceForId($n(e.id()).persistentId)));t.every(to.isLineTool)&&(this._controller.cloneLineTools([...t],!1),hn("Clone",pn(e)))}rename(e,t){const n=this._getObjectsToModify(e.id());1===n.length&&n.some(e=>e.canBeRenamed())&&(t(),hn("Rename",pn(n)))}async openContextMenu(e,t,n){var o;this._objects=this._getObjectsToModify(e.id());const r=this._facade.canBeGroupped(this._objects);let s;if(this._objects.some(e=>e.hasChildren()))s=this._getActionsForGroupItem(e,t,r);else{const e=await this._facade.contextMenuActions(this._chart.value(),this._objects,this._options);if(s=Array.from(e).filter((e,t,n)=>"separator"!==e.type||!n[t+1]||"separator"!==n[t+1].type),1===this._objects.length&&this._objects[0].canBeRenamed()){const e=s.findIndex(e=>"Copy"===e.id);s.splice(-1===e?s.length:e+1,0,this._getRenameAction(t))}if(r){const e=s.findIndex(e=>"Clone"===e.id);s.splice(-1===e?0:e,0,this._getGroupAction())}}if(s.length>0){this._chart.value().updateActions();const t=$n(e.id()).persistentId,r=this._model.dataSourceForId(t),i=r instanceof ro.Series,l=0!==e.childrenIds().size;let a;a=i?{menuName:"ObjectTreeContextMenu",detail:{type:"series",id:r.instanceId()}}:(0,to.isLineTool)(r)?{menuName:"ObjectTreeContextMenu",detail:{type:"shape",
id:null!==(o=null==r?void 0:r.id())&&void 0!==o?o:null}}:l?{menuName:"ObjectTreeContextMenu",detail:{type:"groupOfShapes",id:t||null}}:{menuName:"ObjectTreeContextMenu",detail:{type:"study",id:(null==r?void 0:r.id())||null}},Eo.ContextMenuManager.showMenu(s,n,{takeFocus:!0,returnFocus:!0},a,()=>{this._isContextMenuOpened.setValue(!1)}).then(()=>{this._isContextMenuOpened.setValue(!0)})}}setHoveredObject(e){this._facade.setHoveredObject(e)}hoveredObjectChanged(){return this._facade.hoveredObjectChanged()}getNextNodeIdAfterRemove(e){var t;const{nodes:n}=this.getState(),o=$n(e).persistentId,r=n.find(t=>t.id===e),s=this.entity(e);if(!(r&&r.parentId&&s&&s.canBeRemoved()))return null;if((null===(t=s.pane().mainDataSource())||void 0===t?void 0:t.id())===o&&!this.canNodeWithIdBeUnmerged(o)){const e=n.filter(e=>0===e.level).map(e=>e.id),t=this._takeNextOrPrevElement(e,r.parentId);return(0,I.ensureDefined)(n.find(e=>e.id===t)).children[0]}const i=(0,I.ensureDefined)(n.find(e=>e.id===r.parentId)).children;return 1===i.length?this.getNextNodeIdAfterRemove(r.parentId):this._takeNextOrPrevElement(i,e)}isContextMenuOpened(){return this._isContextMenuOpened.readonly()}getChartLayout(){return this._chart.value().chartWidgetCollection().layout}_takeNextOrPrevElement(e,t){const n=e.indexOf(t);return e[n===e.length-1?n-1:n+1]}_getGroupAction(){return new Mo.Action({actionId:"ObjectsTree.CreateGroup",label:Go,icon:R,onExecute:()=>{this.createGroupFromSelection()}})}_getRenameAction(e){return new Mo.Action({actionId:"ObjectsTree.RenameItem",label:Wo,icon:Oo,onExecute:()=>{e(),hn("Context menu rename",pn(this._objects))}})}_getActionsForGroupItem(e,t,n){const o=[];this._objects.forEach(e=>e.addSourcesToArray(o));const r=[];1===this._objects.length&&r.unshift(this._getRenameAction(t),new Mo.Separator),n&&r.unshift(this._getGroupAction(),new Mo.Separator);const s=(0,so.createSyncDrawingActions)(this._chart.value(),o.filter(to.isLineTool));return s.length&&(s.shift(),s.push(new Mo.Separator),r.push(...s)),r.push(new Mo.Action({actionId:"ObjectsTree.ToggleItemLocked",label:e.isLocked()?Uo:Ko,icon:e.isLocked()?Ao:Lo,onExecute:()=>this.setIsLocked(e.id(),!e.isLocked())}),new Mo.Action({actionId:"ObjectsTree.ToggleItemVisibility",label:e.isVisible()?Zo:Qo,icon:e.isVisible()?No:ko,onExecute:()=>this.setIsVisible(e.id(),!e.isVisible())}),new Mo.Action({actionId:"ObjectsTree.RemoveItem",label:Xo,icon:Bo,onExecute:()=>this.remove(e.id()),hotkeyHash:Ct.isMacKeyboard?8:46}),new Mo.Separator,this._chart.value().actions().format),r}_unmergeSelection(e){const t=this._getSelectedEntities();if(1!==t.length)throw new Error("Only one object can be unmerged");const n=t[0],o=(0,I.ensureNotNull)(this._model.dataSourceForId($n(n.id()).persistentId));if(!(0,Io.isPriceDataSource)(o))throw new Error("Entity is not IPriceDataSource");(0===e?this._controller.unmergeSourceUp:this._controller.unmergeSourceDown).call(this._controller,o);hn(0===e?"New pane above":"New pane below",pn([n]))}_recalculateTree(){const e=new Jn(this._controller,this._facade)
;this._nodes=e.buildTree()}_normalizeTargetAndDropType(e,t){let n=this._ensuredEntity(e);return"inside"===t&&(t="before",n=(0,I.ensureNotNull)(this.entity([...n.childrenIds()].shift()||""))),[n,t]}_getSelectedEntities(){const{selected:e,removed:t}=this._selection.selected().reduce((e,t)=>{const n=this._getEntityById(t);return n?(e.selected.push(n),e):(e.removed.push(t),e)},{selected:[],removed:[]});return t.length&&Ro.logWarn("Detected dangling sources in selection. They will be ignored: "+JSON.stringify(t)),e}_getEntityById(e){return this._facade.getObjectById(e)}}var qo=n(22729);class Jo extends qo.DialogRenderer{constructor(){super(),this._handleClose=()=>{r.unmountComponentAtNode(this._container),this._setVisibility(!1),null!==this._viewModel&&(this._viewModel.destroy(),this._viewModel=null)};const e=(0,Wn.service)(Un.CHART_WIDGET_COLLECTION_SERVICE);this._activeChartWidget=e.activeChartWidget.value(),this._viewModel=new $o(e.activeChartWidget)}hide(){this._handleClose()}isVisible(){return this.visible().value()}show(){p().then(()=>{null!==this._viewModel&&(r.render(o.createElement(Hn,{onClose:this._handleClose,viewModel:this._viewModel,activeChartWidget:this._activeChartWidget}),this._container),this._setVisibility(!0))})}}},36947:(e,t,n)=>{"use strict";n.d(t,{useForceUpdate:()=>r});var o=n(59496);const r=()=>{const[,e]=(0,o.useReducer)((e,t)=>e+1,0);return e}},77975:(e,t,n)=>{"use strict";n.d(t,{useWatchedValueReadonly:()=>r});var o=n(59496);const r=(e,t=!1)=>{const n="watchedValue"in e?e.watchedValue:void 0,r="defaultValue"in e?e.defaultValue:e.watchedValue.value(),[s,i]=(0,o.useState)(n?n.value():r);return(t?o.useLayoutEffect:o.useEffect)(()=>{if(n){i(n.value());const e=e=>i(e);return n.subscribe(e),()=>n.unsubscribe(e)}return()=>{}},[n]),s}},61074:(e,t,n)=>{"use strict";n.d(t,{Spinner:()=>i});var o=n(59496),r=n(97754),s=n(33134);n(24780);function i(e){const t=r(e.className,"tv-spinner","tv-spinner--shown","tv-spinner--size_"+s.spinnerSizeMap[e.size||s.DEFAULT_SIZE]);return o.createElement("div",{className:t,style:e.style,role:"progressbar"})}},70029:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120" width="120" height="120"><path fill="#B2B5BE" fill-rule="evenodd" d="M23 39a36 36 0 0 1 72 0v13.15l15.1 8.44 2.16 1.2-1.64 1.86-12.85 14.59 3.73 4.03L98.57 85 95 81.13V117H77v-12H67v9H50V95H40v22H23V81.28l-3.8 3.61-2.76-2.9 4.05-3.84-12.77-14.5-1.64-1.86 2.16-1.2L23 52.34V39Zm72 36.33 10.98-12.46L95 56.73v18.6ZM23 56.92v18.03L12.35 62.87 23 56.92ZM59 7a32 32 0 0 0-32 32v74h9V91h18v19h9v-9h18v12h10V39A32 32 0 0 0 59 7Zm-7 36a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm19 3a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"/></svg>'},72802:e=>{
e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120" width="120" height="120"><path fill="#131722" fill-rule="evenodd" d="M23 39a36 36 0 0 1 72 0v13.15l15.1 8.44 2.16 1.2-1.64 1.86-12.85 14.59 3.73 4.03L98.57 85 95 81.13V117H77v-12H67v9H50V95H40v22H23V81.28l-3.8 3.61-2.76-2.9 4.05-3.84-12.77-14.5-1.64-1.86 2.16-1.2L23 52.34V39Zm72 36.33 10.98-12.46L95 56.73v18.6ZM23 56.92v18.03L12.35 62.87 23 56.92ZM59 7a32 32 0 0 0-32 32v74h9V91h18v19h9v-9h18v12h10V39A32 32 0 0 0 59 7Zm-7 36a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm19 3a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"/></svg>'},16788:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" fill="none"><path stroke="currentColor" d="M8 9.5H6.5a1 1 0 0 0-1 1v11a1 1 0 0 0 1 1h11a1 1 0 0 0 1-1V20m-8-1.5h11a1 1 0 0 0 1-1v-11a1 1 0 0 0-1-1h-11a1 1 0 0 0-1 1v11a1 1 0 0 0 1 1z"/></svg>'},94669:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" fill="none"><path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M17.086 6.207a2 2 0 0 1 2.828 0l1.879 1.879a2 2 0 0 1 0 2.828l-.94.94-9 9-1 1-.146.146H6v-4.707l.146-.146 1-1 9-9 .94-.94zm2.121.707a1 1 0 0 0-1.414 0l-.586.586 1.647 1.646 1.646 1.647.586-.586a1 1 0 0 0 0-1.414l-1.879-1.879zm.586 4.586L18.5 10.207 10.207 18.5l1.293 1.293 8.293-8.293zm-9 9l-1.647-1.646L7.5 17.207l-.5.5V21h3.293l.5-.5zm-2.586-4L9.5 17.793 17.793 9.5 16.5 8.207 8.207 16.5z"/></svg>'},88142:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="none"><path stroke="currentColor" d="M8 5l3.5 3.5L8 12"/></svg>'},28337:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" fill="none"><path stroke="currentColor" d="M5.5 11.5v8a1 1 0 0 0 1 1h15a1 1 0 0 0 1-1v-8m-17 0v-4a1 1 0 0 1 1-1h4l2 2h9a1 1 0 0 1 1 1v2m-17 0h17"/></svg>'},38593:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="28" height="28" fill="none"><path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M5.5 6C4.67 6 4 6.67 4 7.5V20.5c0 .83.67 1.5 1.5 1.5H16v-1H5.5a.5.5 0 0 1-.5-.5V12h16v1h1V9.5c0-.83-.67-1.5-1.5-1.5h-8.8L9.86 6.15 9.71 6H5.5zM21 11H5V7.5c0-.28.22-.5.5-.5h3.8l1.85 1.85.14.15h9.21c.28 0 .5.22.5.5V11zm1 11v-3h3v-1h-3v-3h-1v3h-3v1h3v3h1z"/></svg>'},68256:e=>{
e.exports='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="none"><path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M2.448 10.124a10.82 10.82 0 0 1-.336-.609L2.105 9.5l.007-.015a12.159 12.159 0 0 1 1.686-2.466C5.002 5.665 6.752 4.373 9.05 4.373c2.297 0 4.047 1.292 5.25 2.646a12.166 12.166 0 0 1 1.687 2.466l.007.015-.007.015a12.163 12.163 0 0 1-1.686 2.466c-1.204 1.354-2.954 2.646-5.251 2.646-2.298 0-4.048-1.292-5.252-2.646a12.16 12.16 0 0 1-1.35-1.857zm14.558-.827l-.456.203.456.203v.002l-.003.005-.006.015-.025.052a11.813 11.813 0 0 1-.461.857 13.163 13.163 0 0 1-1.463 2.011c-1.296 1.46-3.296 2.982-5.998 2.982-2.703 0-4.703-1.522-6-2.982a13.162 13.162 0 0 1-1.83-2.677 7.883 7.883 0 0 1-.118-.243l-.007-.015-.002-.005v-.001l.456-.204-.456-.203v-.002l.002-.005.007-.015a4.66 4.66 0 0 1 .119-.243 13.158 13.158 0 0 1 1.83-2.677c1.296-1.46 3.296-2.982 5.999-2.982 2.702 0 4.702 1.522 5.998 2.981a13.158 13.158 0 0 1 1.83 2.678 8.097 8.097 0 0 1 .119.243l.006.015.003.005v.001zm-.456.203l.456-.203.09.203-.09.203-.456-.203zM1.092 9.297l.457.203-.457.203-.09-.203.09-.203zm9.958.203c0 1.164-.917 2.07-2 2.07-1.084 0-2-.906-2-2.07 0-1.164.916-2.07 2-2.07 1.083 0 2 .906 2 2.07zm1 0c0 1.695-1.344 3.07-3 3.07-1.657 0-3-1.375-3-3.07 0-1.695 1.343-3.07 3-3.07 1.656 0 3 1.375 3 3.07z"/></svg>'},20077:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="none"><path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M7 5.5a2.5 2.5 0 0 1 5 0V7H7V5.5zM6 7V5.5a3.5 3.5 0 1 1 7 0V7a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2zm8 2a1 1 0 0 0-1-1H6a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h7a1 1 0 0 0 1-1V9zm-3 2.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0z"/></svg>'},36666:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" fill="none"><path stroke="currentColor" d="M21.106 12.5H6.894a.5.5 0 0 1-.318-.886L14 5.5l7.424 6.114a.5.5 0 0 1-.318.886zM21.106 16.5H6.894a.5.5 0 0 0-.318.886L14 23.5l7.424-6.114a.5.5 0 0 0-.318-.886z"/></svg>'},57914:e=>{
e.exports='<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" fill="none"><path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M4.605 14.089A10.052 10.052 0 0 1 4.56 14l.046-.089a17.18 17.18 0 0 1 2.329-3.327C8.58 8.758 10.954 7 14 7c3.046 0 5.421 1.757 7.066 3.585A17.18 17.18 0 0 1 23.44 14l-.046.089a17.18 17.18 0 0 1-2.329 3.327C19.42 19.242 17.046 21 14 21c-3.046 0-5.421-1.757-7.066-3.584a17.18 17.18 0 0 1-2.329-3.327zm19.848-.3L24 14l.453.212-.001.002-.003.005-.009.02a16.32 16.32 0 0 1-.662 1.195c-.44.72-1.1 1.684-1.969 2.65C20.08 20.008 17.454 22 14 22c-3.454 0-6.079-1.993-7.81-3.916a18.185 18.185 0 0 1-2.469-3.528 10.636 10.636 0 0 1-.161-.318l-.01-.019-.002-.005v-.002L4 14a55.06 55.06 0 0 1-.453-.212l.001-.002.003-.005.009-.02.033-.067a16.293 16.293 0 0 1 .629-1.126c.44-.723 1.1-1.686 1.969-2.652C7.92 7.993 10.546 6 14 6c3.454 0 6.079 1.993 7.81 3.916a18.183 18.183 0 0 1 2.469 3.528 10.588 10.588 0 0 1 .161.318l.01.019.002.005v.002zM24 14l.453-.211.099.211-.099.211L24 14zm-20.453-.211L4 14l-.453.211L3.448 14l.099-.211zM11 14a3 3 0 1 1 6 0 3 3 0 0 1-6 0zm3-4a4 4 0 1 0 0 8 4 4 0 0 0 0-8zm0 5a1 1 0 1 0 0-2 1 1 0 0 0 0 2z"/></svg>'},13696:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" fill="none"><path stroke="currentColor" d="M4.5 12.5l4.59-4.59a2 2 0 0 1 2.83 0l3.17 3.17a2 2 0 0 0 2.83 0L22.5 6.5m-8 9.5v5.5M12 19l2.5 2.5L17 19m4.5 3v-5.5M19 19l2.5-2.5L24 19"/></svg>'},55247:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="28" height="28" fill="none"><path stroke="currentColor" d="M5.5 16.5l4.586-4.586a2 2 0 0 1 2.828 0l3.172 3.172a2 2 0 0 0 2.828 0L23.5 10.5"/></svg>'},3589:e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="none"><path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M11.5 4A2.5 2.5 0 0 0 7 5.5V7h6a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2V5.5a3.5 3.5 0 0 1 6.231-2.19c-.231.19-.73.69-.73.69zM13 8H6a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1h7a1 1 0 0 0 1-1V9a1 1 0 0 0-1-1zm-2 3.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0z"/></svg>'},82308:e=>{
e.exports='<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="none"><path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M14.692 3.012l-12 12.277.715.699 12-12.277-.715-.699zM9.05 15.627a7.042 7.042 0 0 1-3.144-.741l.742-.76c.72.311 1.52.5 2.402.5 2.297 0 4.047-1.29 5.25-2.645a12.168 12.168 0 0 0 1.687-2.466l.007-.015-.007-.015A12.166 12.166 0 0 0 14.3 7.019c-.11-.124-.225-.247-.344-.37l.699-.715c.137.14.268.28.392.42a13.16 13.16 0 0 1 1.83 2.678 8.117 8.117 0 0 1 .119.243l.006.015.003.005v.001l-.456.204.456.203v.002l-.003.005-.006.015-.025.052a11.762 11.762 0 0 1-.461.857 13.158 13.158 0 0 1-1.463 2.011c-1.296 1.46-3.296 2.982-5.998 2.982zm7.5-6.127l.456-.203.09.203-.09.203-.456-.203zm-7.5 3.07c-.27 0-.53-.037-.778-.105l.879-.899c.999-.052 1.833-.872 1.895-1.938l.902-.923c.066.253.102.52.102.795 0 1.695-1.344 3.07-3 3.07zM6.15 10.294l.902-.923c.063-1.066.896-1.886 1.895-1.938l.879-.9a2.94 2.94 0 0 0-.777-.103c-1.657 0-3 1.374-3 3.069 0 .275.035.541.101.795zM9.05 4.373c.88 0 1.68.19 2.4.5l.743-.759a7.043 7.043 0 0 0-3.143-.74c-2.703 0-4.703 1.521-6 2.98a13.159 13.159 0 0 0-1.83 2.678 7.886 7.886 0 0 0-.118.243l-.007.015-.002.005v.001l.456.204-.457-.203-.09.203.09.203.457-.203-.456.203v.002l.002.005.007.015a4.5 4.5 0 0 0 .119.243 13.152 13.152 0 0 0 1.83 2.677c.124.14.255.28.392.42l.7-.715c-.12-.122-.235-.245-.345-.369a12.156 12.156 0 0 1-1.686-2.466L2.105 9.5l.007-.015a12.158 12.158 0 0 1 1.686-2.466C5.002 5.665 6.752 4.373 9.05 4.373z"/></svg>'}}]);