(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[4862],{94288:e=>{e.exports={input:"input-RUSovanF","size-xxsmall":"size-xxsmall-RUSovanF","size-xsmall":"size-xsmall-RUSovanF","size-small":"size-small-RUSovanF","size-medium":"size-medium-RUSovanF","size-large":"size-large-RUSovanF","with-start-slot":"with-start-slot-RUSovanF","with-end-slot":"with-end-slot-RUSovanF"}},51284:e=>{e.exports={"tablet-normal-breakpoint":"(max-width: 768px)","small-height-breakpoint":"(max-height: 360px)","tablet-small-breakpoint":"(max-width: 440px)"}},29367:e=>{e.exports={dropTargetInside:"dropTargetInside-e_nPSSdZ",dropTarget:"dropTarget-e_nPSSdZ",before:"before-e_nPSSdZ",after:"after-e_nPSSdZ"}},84420:e=>{e.exports={sticky:"sticky-U0YaDVkl",hideSticky:"hideSticky-U0YaDVkl"}},69372:e=>{e.exports={wrap:"wrap-IEe5qpW4",selected:"selected-IEe5qpW4",childOfSelected:"childOfSelected-IEe5qpW4",disabled:"disabled-IEe5qpW4",expandHandle:"expandHandle-IEe5qpW4",expanded:"expanded-IEe5qpW4"}},13874:e=>{e.exports={separator:"separator-MgF6KBas",sticky:"sticky-MgF6KBas",accessible:"accessible-MgF6KBas",tree:"tree-MgF6KBas",overlayScrollWrap:"overlayScrollWrap-MgF6KBas",listContainer:"listContainer-MgF6KBas"}},85529:e=>{e.exports={dialog:"dialog-VUnQLSMH",buttons:"buttons-VUnQLSMH",button:"button-VUnQLSMH",disabled:"disabled-VUnQLSMH"}},93749:e=>{e.exports={title:"title-uNZ8yW1y",withoutIcon:"withoutIcon-uNZ8yW1y",buttons:"buttons-uNZ8yW1y",button:"button-uNZ8yW1y",disabled:"disabled-uNZ8yW1y",spacing:"spacing-uNZ8yW1y",toolbar:"toolbar-uNZ8yW1y"}},15620:e=>{e.exports={wrap:"wrap-C8ln3wvp",dialog:"dialog-C8ln3wvp",mobile:"mobile-C8ln3wvp",offset:"offset-C8ln3wvp",title:"title-C8ln3wvp",main:"main-C8ln3wvp",disabled:"disabled-C8ln3wvp",icon:"icon-C8ln3wvp",pathIcon:"pathIcon-C8ln3wvp",syncIconWrap:"syncIconWrap-C8ln3wvp",syncIcon:"syncIcon-C8ln3wvp",rightButtons:"rightButtons-C8ln3wvp",hover:"hover-C8ln3wvp",expandHandle:"expandHandle-C8ln3wvp",button:"button-C8ln3wvp",selected:"selected-C8ln3wvp",childOfSelected:"childOfSelected-C8ln3wvp",renameInput:"renameInput-C8ln3wvp",warn:"warn-C8ln3wvp",visible:"visible-C8ln3wvp"}},28456:e=>{e.exports={wrap:"wrap-ukH4sVzT",space:"space-ukH4sVzT",tree:"tree-ukH4sVzT"}},26591:e=>{e.exports={button:"button-w6lVe_oI",hovered:"hovered-w6lVe_oI",disabled:"disabled-w6lVe_oI"}},31261:(e,t,n)=>{"use strict";n.d(t,{InputControl:()=>_});var o=n(50959),r=n(97754),i=n.n(r),s=n(94489),l=n(90186),a=n(47201),c=n(48907),d=n(38528),u=n(48027),h=n(29202),f=n(45812),p=n(67029),g=n(78274),m=n(94288),v=n.n(m);function S(e){return!(0,l.isAriaAttribute)(e)&&!(0,l.isDataAttribute)(e)}function b(e){
const{id:t,title:n,role:r,tabIndex:a,placeholder:c,name:d,type:u,value:h,defaultValue:f,draggable:m,autoComplete:b,autoFocus:_,autoCapitalize:y,autoCorrect:C,maxLength:T,min:I,max:w,step:E,pattern:M,inputMode:D,onSelect:k,onFocus:x,onBlur:N,onKeyDown:A,onKeyUp:L,onKeyPress:O,onChange:B,onDragStart:R,size:F="small",className:P,inputClassName:z,disabled:j,readonly:V,containerTabIndex:H,startSlot:G,endSlot:U,reference:W,containerReference:K,onContainerFocus:q,dataQaId:Z,...$}=e,Q=(0,l.filterProps)($,S),X={...(0,l.filterAriaProps)($),...(0,l.filterDataProps)($),id:t,title:n,role:r,tabIndex:a,placeholder:c,name:d,type:u,value:h,defaultValue:f,draggable:m,autoComplete:b,autoFocus:_,autoCapitalize:y,autoCorrect:C,maxLength:T,min:I,max:w,step:E,pattern:M,inputMode:D,onSelect:k,onFocus:x,onBlur:N,onKeyDown:A,onKeyUp:L,onKeyPress:O,onChange:B,onDragStart:R};return o.createElement(p.ControlSkeleton,{...Q,disabled:j,readonly:V,tabIndex:H,className:i()(v().container,P),size:F,ref:K,onFocus:q,startSlot:G,middleSlot:o.createElement(g.MiddleSlot,null,o.createElement("input",{...X,className:i()(v().input,v()[`size-${F}`],z,G&&v()["with-start-slot"],U&&v()["with-end-slot"]),disabled:j,readOnly:V,ref:W,"data-qa-id":(0,s.dataQaIds)("ui-lib-Input-input",Z?`${Z}-input`:void 0)})),endSlot:U,"data-qa-id":(0,s.dataQaIds)("ui-lib-Input",Z)})}function _(e){e=(0,u.useControl)(e);const{disabled:t,autoSelectOnFocus:n,tabIndex:r=0,onFocus:i,onBlur:s,reference:l,containerReference:p=null,dataQaId:g}=e,m=(0,o.useRef)(null),v=(0,o.useRef)(null),[S,_]=(0,h.useFocus)(),y=t?void 0:S?-1:r,C=t?void 0:S?r:-1,{isMouseDown:T,handleMouseDown:I,handleMouseUp:w}=(0,f.useIsMouseDown)(),E=(0,a.createSafeMulticastEventHandler)(_.onFocus,(function(e){n&&!T.current&&(0,c.selectAllContent)(e.currentTarget)}),i),M=(0,a.createSafeMulticastEventHandler)(_.onBlur,s),D=(0,o.useCallback)((e=>{m.current=e,l&&("function"==typeof l&&l(e),"object"==typeof l&&(l.current=e))}),[m,l]);return o.createElement(b,{...e,isFocused:S,containerTabIndex:y,tabIndex:C,onContainerFocus:function(e){v.current===e.target&&null!==m.current&&m.current.focus()},onFocus:E,onBlur:M,reference:D,containerReference:(0,d.useMergedRefs)([v,p]),onMouseDown:I,onMouseUp:w,dataQaId:g})}},48027:(e,t,n)=>{"use strict";n.d(t,{useControl:()=>i});var o=n(47201),r=n(29202);function i(e){const{onFocus:t,onBlur:n,intent:i,highlight:s,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:i||(a?"primary":"default"),highlight:s??a,onFocus:d,onBlur:u}}},125:(e,t,n)=>{"use strict";n.d(t,{useForceUpdate:()=>r});var o=n(50959);const r=()=>{const[,e]=(0,o.useReducer)((e=>e+1),0);return e}},76974:(e,t,n)=>{"use strict";n.d(t,{useIsMounted:()=>r});var o=n(50959);const r=()=>{const e=(0,o.useRef)(!1);return(0,o.useEffect)((()=>(e.current=!0,()=>{e.current=!1})),[]),e}},45812:(e,t,n)=>{"use strict";n.d(t,{useIsMouseDown:()=>r});var o=n(50959);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}}},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})},73986:(e,t,n)=>{"use strict";n.d(t,{DialogBreakpoints:()=>r});var o=n(51284);const r={SmallHeight:o["small-height-breakpoint"],TabletSmall:o["tablet-small-breakpoint"],TabletNormal:o["tablet-normal-breakpoint"]}},73536:(e,t,n)=>{"use strict";n.r(t),n.d(t,{ObjectTreeDialogRenderer:()=>yr});var o=n(50959);async function r(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 r(e,t,(()=>Promise.resolve()))}var s=n(9343);const l=(0,s.getLogger)("DataSourcesIcons");let a=null;function c(){const e=n.c[44341];return e?Promise.resolve(e.exports.lineToolsIcons):n.e(1890).then(n.bind(n,44341)).then((e=>e.lineToolsIcons))}function d(){const e=n.c[99678];return e?Promise.resolve(e.exports.SERIES_ICONS):n.e(9685).then(n.bind(n,99678)).then((e=>e.SERIES_ICONS))}let u=null;function h(){return null===u&&(u=function(){const e=i(c,2).then((e=>e)).catch((e=>(l.logWarn(e),{}))),t=i(d,2).then((e=>e)).catch((e=>(l.logWarn(e),{})));return Promise.all([e,t])}()),u.then((e=>(a={linetool:e[0],series:e[1]},a)))}var f=n(11542),p=n(97754),g=n.n(p),m=n(125),v=n(76974),S=n(90692),b=n(79418),_=n(73986),y=n(29885),C=n(32563),T=n(68335),I=n(50151),w=n(9745),E=n(90397),M=n(34788),D=n(46043);const k=o.createContext(null);var x=n(58169),N=n(26981),A=n(22692),L=n(36296),O=n(74059),B=n(80465),R=n(93749),F=n(51768);function P(e){const{hideTitle:t}=e,{viewModel:r}=(0,I.ensureNotNull)((0,o.useContext)(k)),i=(0,D.useForceUpdate)(),s=r.selection();(0,o.useEffect)((()=>{const e={};return r.onChange().subscribe(e,(()=>i())),()=>{r.onChange().unsubscribeAll(e)}}),[r]),(0,o.useEffect)((()=>{const e={};return s.onChange().subscribe(e,(()=>i())),()=>{s.onChange().unsubscribeAll(e)}}),[s]),(0,o.useEffect)((()=>{(0,A.updateTabIndexes)()}),[]);const l=!r.canSelectionBeUnmerged(),a=r.isSelectionCopiable(),c=r.isSelectionCloneable(),d=!a&&!c,u=r.canSelectionBeGrouped(),h=!1;return o.createElement(N.Toolbar,{orientation:"horizontal",className:R.toolbar},!t&&o.createElement("div",{className:p(R.title,R.withoutIcon)},f.t(null,void 0,n(88616)),h),o.createElement("div",{className:R.buttons},o.createElement(x.ToolbarIconButton,{className:p(R.button,!u&&R.disabled),icon:B,onClick:function(){r.createGroupFromSelection()},isDisabled:!u,tooltip:f.t(null,void 0,n(83390)),"data-name":"group-button"}),o.createElement(M.ToolbarMenuButton,{className:p(R.button,d&&R.disabled),isDisabled:d,content:o.createElement(w.Icon,{icon:L}),tooltip:f.t(null,void 0,n(92389)),arrow:!1,isShowTooltip:!0,"data-name":"copy-clone-button"},a&&o.createElement(E.AccessibleMenuItem,{"data-name":"copy",label:f.t(null,void 0,n(49680)),
onClick:function(){r.copySelection()}}),c&&o.createElement(E.AccessibleMenuItem,{"data-name":"clone",label:f.t(null,void 0,n(12537)),onClick:function(){r.cloneSelection()}})),o.createElement(M.ToolbarMenuButton,{className:p(R.button,l&&R.disabled),isDisabled:l,content:o.createElement(w.Icon,{icon:O}),tooltip:f.t(null,void 0,n(35049)),arrow:!1,isShowTooltip:!0,"data-name":"move-to-button"},o.createElement(E.AccessibleMenuItem,{"aria-label":f.t(null,void 0,n(15512)),"data-name":"new-pane-above",label:f.t(null,void 0,n(15512)),onClick:function(){r.unmergeSelectionUp()}}),o.createElement(E.AccessibleMenuItem,{"aria-label":f.t(null,void 0,n(52160)),"data-name":"new-pane-below",label:f.t(null,void 0,n(52160)),onClick:function(){r.unmergeSelectionDown()}})),t&&o.createElement(o.Fragment,null,o.createElement("div",{className:R.spacing}),o.createElement(x.ToolbarIconButton,{className:R.button,icon:manageDrawingsIcon,tooltip:f.t(null,void 0,n(81031)),"data-name":"manage-drawings-button",onClick:g}))));function g(){h}}var z=n(46212),j=n(61123),V=n(10170),H=n(7809),G=n(94212);const U=(W="OBJECT_TREE",e=>W+"__"+e);var W;const K=U("SET_NODES"),q=U("SYNC_NODES"),Z=U("UPDATE_NODE"),$=U("UPDATE_NODES"),Q=U("RESET_TREE"),X=U("SET_SELECTED_IDS"),Y=U("DROP_SELECTION"),J=U("SELECT_PREVIOUS"),ee=U("SELECT_NEXT"),te=U("MULTI_SELECT_PREVIOUS"),ne=U("MULTI_SELECT_NEXT"),oe=U("PROCESS_DROP_TARGET"),re=U("UPDATE_DROP_TARGET"),ie=U("HIDE_DROP_TARGET"),se=U("START_MULTI_SELECT"),le=U("STOP_MULTI_SELECT"),ae=(U("REMOVE_NODE"),U("SET_FOCUSED_NODE")),ce=U("SCROLL_TO_ID"),de=U("SET_IS_SELECTED"),ue=U("SET_IS_EXPANDED"),he=U("SET_DISABLED_NODES"),fe=U("MOVE_NODES"),pe=(U("START_DRAG"),U("END_DRAG")),ge=()=>({type:J}),me=()=>({type:ee}),ve=()=>({type:te}),Se=()=>({type:ne}),be=(e,t,n,o,r)=>({type:oe,dropTarget:e,dropType:t,isHoveredLeft:n,boundBox:o,isLastChild:r}),_e=()=>({type:Y}),ye=e=>({type:X,ids:e}),Ce=(e,t,n)=>({type:fe,ids:e,targetId:t,dropType:n}),Te=()=>({type:se}),Ie=()=>({type:le}),we=e=>({type:ae,nodeId:e}),Ee=e=>({type:ce,nodeId:e}),Me=(e,t,n=0)=>({type:de,nodeId:e,isSelected:t,mode:n}),De=(e,t)=>({type:ue,nodeId:e,isExpanded:t}),ke=e=>({type:he,ids:e}),xe=()=>({type:pe});var Ne=n(77145);const Ae=e=>e.nodes,Le=e=>e.selection,Oe=e=>e.dropTarget,Be=e=>e.expanded,Re=e=>e.scrollToId,Fe=(e,t)=>t,Pe=(0,Ne.createSelector)([Ae,Fe],((e,t)=>e[t])),ze=(0,Ne.createSelector)([Le,Fe],((e,t)=>e.ids.includes(t))),je=(0,Ne.createSelector)([Be,Fe],((e,t)=>e.includes(t))),Ve=(0,Ne.createSelector)([e=>e.disabled,Le,Fe],((e,t,n)=>!t.ids.includes(n)&&e.includes(n))),He=(0,Ne.createSelector)(Ae,(e=>Object.keys(e))),Ge=(0,Ne.createSelector)(Le,(({ids:e})=>e)),Ue=(0,Ne.createSelector)(Le,(({lastFocusedNodeId:e})=>e)),We=(0,Ne.createSelector)(Le,(({isMultiSelecting:e})=>e)),Ke=(0,Ne.createSelector)([Ae,Ge],((e,t)=>t.map((t=>e[t])))),qe=(0,Ne.createSelector)(Ae,(e=>Object.values(e).filter((e=>0===e.level)))),Ze=(0,Ne.createSelector)([Ae,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)([Ae,qe,Be],((e,t,n)=>{const o=new Set(n);return t.reduce(((t,n)=>[...t,...Ye(e,(0,I.ensureDefined)(n),o)]),[])})),Xe=(0,Ne.createSelector)([Ae,Ge,Be],((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*Je(e){const{selectedIds:t,nodes:n}=yield(0,y.call)(e),o={};for(let e=0;e<n.length;++e){const t=n[e];o[t.id]=t}yield(0,y.put)((e=>({type:K,nodes:e}))(o)),yield(0,y.put)(ye(t));!Ue(yield(0,y.select)())&&t.length>0&&(yield(0,y.put)(we(t[0])),yield(0,y.put)(Ee(t[0])))}function*et(e){for(;;){if((yield(0,y.take)([se,le])).type===se){const t=He(yield(0,y.select)()).filter((t=>!e(t)));yield(0,y.put)(ke(t))}else yield(0,y.put)(ke([]))}}function*tt(){for(;;){const{type:e}=yield(0,y.take)([ne,te]),t=yield(0,y.select)(),n=Ze(t),o=n.length,r=Ue(t),i=[...Ge(t)],s=1===i.length&&i[0]!==r,l=n.findIndex((e=>e.id===(s?i[0]:r)));if(e===te&&0===l||e===ne&&l===o-1)continue;const a=at(t,e===ne?"next":"previous",n,l),{id:c}=a;i.includes(c)&&r?(yield(0,y.put)(Me(r,!1,1)),yield(0,y.put)(we(c))):yield(0,y.put)(Me(c,!0,1)),yield(0,y.put)(Ee(c))}}function*nt(e,t){for(;;){const{type:n}=yield(0,y.take)([ee,J]),o=yield(0,y.select)(),r=Ze(o),i=Ke(o),s=Ue(o);if(1===i.length&&i[0].id!==s&&!s){if(n===ee){yield(0,y.put)(we(i[0].id));continue}if(n===J){const e=r.findIndex((e=>e.id===i[0].id)),t=at(o,"previous",r,e);yield(0,y.put)(we(t.id));continue}}const l=r.findIndex((e=>e.id===s)),a=n===ee?"next":"previous",c=at(o,a,r,l),{id:d}=c;e?e([d],a):yield(0,y.put)(ye([d])),t&&t(d),yield(0,y.put)(we(d))}}function*ot(e,t=()=>!0){for(;;){const{mode:n,nodeId:o,isSelected:r}=yield(0,y.take)(de);let i=[...Ge(yield(0,y.select)())];const s=Ze(yield(0,y.select)());if(1===n)r?i.push(o):i.splice(i.indexOf(o),1);else if(2===n&&i.length>0){const e=Ue(yield(0,y.select)());let n=s.findIndex((t=>t.id===e));-1===n&&(n=s.reduce(((e,t,n)=>i.includes(t.id)?n:e),-1));const r=s.findIndex((e=>e.id===o));if(n!==r)for(let e=Math.min(n,r);e<=Math.max(n,r);e++){const n=s[e].id;!i.includes(n)&&t(n)&&i.push(n)}}else i=o?[o]:[];const l=new Set(i);i=s.reduce(((e,t)=>(l.has(t.id)&&e.push(t.id),e)),[]),e?e(i):yield(0,y.put)(ye(i)),yield(0,y.put)(we(o))}}function*rt(e=()=>!0,t){const{dropTarget:n,dropType:o,isHoveredLeft:r,boundBox:i,isLastChild:s}=t,l=Oe(yield(0,y.select)()),a=Pe(yield(0,y.select)(),(0,I.ensureDefined)(n.parentId)),c=s&&"after"===o,d=Ke(yield(0,y.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,y.put)({type:ie}):h&&e(d,u,o)&&(yield(0,y.put)(((e,t,n)=>({type:re,node:e,dropType:t,boundBox:n}))(u,o,i)))}function*it(e){yield(0,y.throttle)(0,oe,rt,e)}function*st(e){for(;;){yield(0,y.take)(Y);const t=Ke(yield(0,y.select)()),{node:n,dropType:o}=Oe(yield(0,y.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=Ge(yield(0,y.select)());yield(0,y.put)(Ce(e,n.id,o))}}}}function*lt(e){for(;;){yield(0,y.take)(fe);e(Ae(yield(0,y.select)()))}}function at(e,t,n,o){const r=n.length;let i;-1===o&&"previous"===t&&(o=r);let s=0;for(;!i||Math.abs(s)<r&&((l=i).level>1&&!je(e,(0,I.ensureDefined)(l.parentId)));)s+="next"===t?1:-1,i=n[(o+s+r)%r];var l;return i}function*ct(e={}){const{saga:t,onDrop:n,canMove:o,onMove:r,onSelect:i,onKeyboardSelect:s,initState:l,canBeAddedToSelection:a}=e,c=[(0,y.fork)(it,o),(0,y.fork)(st,n),(0,y.fork)(ot,i,a),(0,y.fork)(nt,i,s),(0,y.fork)(tt)];for(t&&c.push((0,y.fork)(t)),r&&c.push((0,y.fork)(lt,r)),a&&c.push((0,y.fork)(et,a));;){l&&(yield(0,y.call)(Je,l));const e=yield(0,y.all)(c);yield(0,y.take)(Q);for(const t of e)yield(0,y.cancel)(t)}}var dt=n(6047),ut=n(87465);const ht=(0,s.getLogger)("Platform.GUI.ObjectTree.CallApi");const ft={ids:[],lastFocusedNodeId:void 0,isMultiSelecting:!1};const pt={node:void 0,dropType:void 0,boundBox:void 0};const gt=(0,dt.combineReducers)({nodes:function(e={},t){switch(t.type){case K: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,ut.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 Z:{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,i=(0,I.ensureDefined)(e[o].parentId),s=e[i],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:i,level:s.level+1}}const a=s.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[i]={...e[i],children:a,isExpanded:!0},{...e,...l}}default:return e}},selection:function(e=ft,t){switch(t.type){case X:{const{ids:n}=t;return{...e,ids:n,lastFocusedNodeId:n.length>0?e.lastFocusedNodeId:void 0}}case se:return{...e,isMultiSelecting:!0};case le:return{...e,isMultiSelecting:!1};case ae: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=pt,t){switch(t.type){case re:{const{node:n,dropType:o,boundBox:r}=t;return{...e,node:n,dropType:o,boundBox:r}}case ie:case pe:case Q:return{...pt};default:return e}},
expanded:function(e=[],t){if(t.type===ue){const{nodeId:n,isExpanded:o}=t;if(o)return[...e,n];const r=[...e];return r.splice(e.indexOf(n),1),r}return e},disabled:function(e=[],t){return t.type===he?[...t.ids]:e},scrollToId:function(e=null,t){return t.type===ce?null===t.nodeId?null:{id:t.nodeId}:e}});var mt=n(68788),vt=n(69690),St=n(84952),bt=n(49483);var _t,yt,Ct=n(16812),Tt=n(98314),It=n(47201),wt=n(70412);!function(e){e[e.Normal=0]="Normal",e[e.Small=1]="Small"}(_t||(_t={})),function(e){e[e.Select=0]="Select",e[e.Click=1]="Click"}(yt||(yt={}));const Et=o.createContext({size:0,smallSizeTreeNodeAction:1}),Mt={[T.Modifiers.Mod]:1,[T.Modifiers.Shift]:2};var Dt=n(69533),kt=n(69372);const xt=()=>{};class Nt 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,Tt.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{return null}}(e,t);if(n)return n;const o=Array.from(t.changedTouches),r=Array.from(t.touches),i=Array.from(t.targetTouches);return new TouchEvent(e,{bubbles:!0,changedTouches:o,touches:r,targetTouches:i})},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 i=r;if(!n.isConnected){i.preventDefault();const e=t("touchend",i);document.body.dispatchEvent(e)}n.removeEventListener("touchend",o),n.removeEventListener("touchmove",e)};n.addEventListener("touchend",o),n.addEventListener("touchmove",e)}}}componentDidMount(){this._ref?.addEventListener("touchstart",this._handleTouchStart)}componentWillUnmount(){this._ref?.removeEventListener("touchstart",this._handleTouchStart)}render(){return o.createElement(At,{...this.props,reference:this._handleRef})}getNode(){return(0,I.ensureNotNull)(this._ref)}}const At=e=>{const{id:t,isSelected:n,isOffset:r,isExpandable:i,setIsSelected:s,isDisabled:l,isExpanded:a,onClick:c,parentId:d,setIsExpanded:u,reference:h,isFirstListItem:f,isLastListItem:g,nodeRenderer:m,isChildOfSelected:v=!1,isStuckNode:S}=e,{size:b,smallSizeTreeNodeAction:_}=(0,o.useContext)(Et),y=(0,o.useRef)(null),C=(0,It.createSafeMulticastEventHandler)((e=>y.current=e),h);let[I,E]=(0,wt.useHoverDeprecated)();return(bt.CheckMobile.any()||bt.CheckMobile.isIPad())&&(I=n,E={onMouseOut:xt,onMouseOver:xt}),o.createElement("div",{className:p(kt.wrap,n&&kt.selected,v&&kt.childOfSelected,l&&kt.disabled,i&&kt.expandable),onClick:1===b&&0===_?M:function(e){if(e.defaultPrevented)return;const o=Mt[(0,T.modifiersFromEvent)(e)]||0;!l&&s&&s(t,!n,o);c&&0===o&&c(e,t)},onContextMenu:M,ref:C,...E},i&&o.createElement(w.Icon,{icon:Dt,
className:p(kt.expandHandle,a&&kt.expanded),onClick:function(e){e.preventDefault(),i&&u(t,!a)},onMouseDown:function(e){e.preventDefault()}}),m({id:t,isOffset:r,parentId:d,isDisabled:l,isSelected:n,isChildOfSelected:v,isHovered:I,isExpanded:a,isFirstListItem:f,isLastListItem:g,isStuckNode:S}));function M(){l||n||!s||s(t,!0)}},Lt=o.createContext({});function Ot(e,t){const{id:n}=t,o=Pe(e,n),r=ze(e,n);let i=!1,s=o.parentId;for(;s&&!i;)i=ze(e,s),s=Pe(e,s).parentId;return{...o,isSelected:r,isChildOfSelected:i,isExpanded:o.children.length>0&&je(e,n),isExpandable:o.children.length>0,isDisabled:Ve(e,n)}}function Bt(e){return(0,dt.bindActionCreators)({setIsExpanded:De,processDropTarget:be,dropSelection:_e,selectNext:me,selectPrevious:ge,setIsSelected:Me,endDrag:xe},e)}const Rt=(0,j.connect)(Ot,Bt,null,{context:Lt})((function(e){const t=(0,o.useRef)(null),[,n,r]=(0,Ct.useDrag)({type:"node",item:t=>{const{id:n,isDisabled:o,isSelected:r}=e;return o||r||e.setIsSelected(n,!0),e},end:e=>{e.endDrag()}}),[,i]=(0,vt.useDrop)({accept:"node",hover:(n,o)=>{const r=t.current;if(!r)return;if(e.isStuckNode)return;const i=r.getNode(),s=i.getBoundingClientRect(),l=s.bottom-s.top,a=o.getClientOffset();if(a){const t=a.y-s.top;let n,o;if(n=0===e.children.length?t<l/2?"before":"after":t<l/3?"before":e.isExpanded||t>=l/3&&t<2*l/3?"inside":"after",void 0!==e.getContainerElement){const t=e.getContainerElement().getBoundingClientRect();o={top:s.top-t.top,left:s.left-t.left,bottom:s.top-t.top+s.height,right:s.left-t.left+s.width,height:s.height,width:s.width}}else o={top:i.offsetTop,left:i.offsetLeft,bottom:i.offsetTop+i.offsetHeight,right:i.offsetLeft+i.offsetWidth,height:i.offsetHeight,width:i.offsetWidth};e.processDropTarget(e,n,a.x-s.left<48,o,e.isLastChild)}}});return o.createElement(Nt,{...e,connectDragSource:n,connectDropTarget:i,connectDragPreview:r,ref:t})})),Ft=(0,j.connect)(Ot,Bt,null,{context:Lt})(At);var Pt=n(35749),zt=n(65982),jt=n(65718);function Vt(e){const t=e(),n=(0,o.useRef)(t);n.current=t;const[r,i]=(0,o.useState)(n.current),s=(0,o.useRef)(null);return(0,o.useEffect)((()=>{null===s.current&&(s.current=requestAnimationFrame((()=>{s.current=null,i(n.current)})))})),(0,o.useEffect)((()=>()=>{s.current&&cancelAnimationFrame(s.current)}),[]),r}function Ht(e){const{dropTargetOffset:t,mousePosition:n}=e;if(!t)return{display:"none"};const{x:o,y:r}=t,i=n&&t?n.y-t.y:0,s=`translate(${o+(n&&t?n.x-t.x:0)}px, ${r+i}px)`;return{transform:s,WebkitTransform:s}}const Gt={top:0,left:0,position:"fixed",pointerEvents:"none",zIndex:100,opacity:.5,width:300,backgroundColor:"red"};function Ut(e){return{isDragging:e.isDragging()&&"node"===e.getItemType(),mousePosition:e.getClientOffset(),dropTargetOffset:e.getSourceClientOffset()}}const Wt=(0,j.connect)((function(e){return{items:Xe(e)}}),null,null,{context:Lt})((function(e){const{items:t,isDragging:n,nodeRenderer:r,dragPreviewRenderer:i}=e;return Vt((function(){return n?o.createElement(jt.Portal,null,o.createElement("div",{style:{...Gt,...Ht(e)}},t.map((e=>{if(i){const t=i;return o.createElement(t,{
key:e.id,...e})}return o.createElement(Ft,{id:e.id,key:e.id,nodeRenderer:r,isDragPreview:!0,isOffset:e.level>1})})))):null}))}));function Kt(e){return o.createElement(Wt,{...e,...(0,zt.useDragLayer)(Ut)})}var qt=n(3085),Zt=n(33127);const $t=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%"}})}));function Qt(e){const t=(0,o.useRef)(null),[,n]=(0,vt.useDrop)({accept:"node",hover:(n,o)=>{if(!t.current)return;const r=o.getClientOffset();if(null===r)return;const i=e.getOrderedNodes();if(0===i.length)return;const s=t.current.getNode().getBoundingClientRect(),l=e.getContainerElement().getBoundingClientRect();if("first"===e.type){const t={top:s.top-l.top+s.height,left:s.left-l.left,bottom:s.top-l.top+s.height,right:s.left-l.left+s.width,height:0,width:s.width};e.processDropTarget(i[0],"before",!1,t,!1)}if("last"===e.type){const t=r.x-s.left<48,n=i[i.length-1],o=t&&2===n.level?(0,I.ensureDefined)(i.find((e=>e.id===n.parentId))):n,a={top:s.top-l.top,left:s.left-l.left,bottom:s.top-l.top,right:s.left-l.left+s.width,height:s.height,width:s.width};e.processDropTarget(o,"after",t,a,!1)}}});return o.createElement($t,{...e,connectDropTarget:n,ref:t})}const Xt=o.createContext({isOver:!1,transform:void 0});var Yt=n(29367);function Jt(e){const{dropType:t,boundBox:n}=e,{top:o,bottom:r,left:i}=(0,I.ensureDefined)(n);return[i,"before"===t||"inside"===t?o:r]}function en(e){return{isDragging:e.isDragging()}}const tn=(0,j.connect)((function(e){const{boundBox:t,dropType:n,node:o}=Oe(e);return{boundBox:t,dropType:n,level:o?o.level:void 0}}),null,null,{context:Lt})((function(e){const{dropType:t,boundBox:n,isDragging:r,level:i,transform:s=Jt}=e;return Vt((function(){if(!r||!t||!n)return null;const l={[Yt.dropTarget]:"inside"!==t,[Yt.dropTargetInside]:"inside"===t},{width:a,height:c}=n,[d,u]=s(e),h=`translate(${d}px, ${"inside"===t?u:u-1}px)`;return o.createElement("div",{className:p(l),style:{position:"absolute",transform:h,WebkitTransform:h,top:0,left:2===i?"46px":0,width:2===i?a-46+"px":a,height:"inside"===t?c:"2px"}})}))}));function nn(e){const{isDragging:t}=(0,zt.useDragLayer)(en);return o.createElement(tn,{...e,isDragging:t})}const on=o.createContext(null);var rn=n(84420),sn=n.n(rn);const ln=o.forwardRef(((e,t)=>{const n=(0,o.useContext)(Xt),r=(0,o.useContext)(on),i=(0,o.useMemo)((()=>r?.readOnly?Ft:Rt),[r?.readOnly]);return o.createElement("div",{...e,ref:t},r?.id?o.createElement("div",{className:g()(sn().sticky,!r.isShowStuck&&sn().hideSticky)},o.createElement(i,{id:r.id,key:r.id,isStuckNode:!0,nodeRenderer:r.nodeRenderer,readOnly:r.readOnly,onClick:r.onClick,getContainerElement:r.getContainerElement})):null,e.children,n.isOver&&o.createElement(nn,{transform:n.transform}))}));var an=n(24640),cn=n(13874);const dn=38+T.Modifiers.Shift,un=40+T.Modifiers.Shift;const hn=o.forwardRef((function(e,t){
const{navigationKeys:n,renderList:r,stopMultiSelect:i,startMultiSelect:s,isMultiSelecting:l,nodeRenderer:a,dragPreviewRenderer:c,className:d,connectDropTarget:u,readOnly:h,onClick:f,dropLayerTransform:p,setFocusedNode:m,scrollToId:v,rowHeight:S,onMultiSelectPrevious:b,onMultiSelectNext:_,onMoveCursorToNext:y,onMoveCursorToPrevious:C,onKeyDown:w,outerRef:E,width:M,height:D,isOver:x,processDropTarget:N,autofocus:A,accessibleScope:L}=e,[O,B]=(0,o.useState)(),[R,F]=(0,o.useState)(!0),[P,z]=(0,o.useState)(!1),j=(0,o.useContext)(k),V=(0,o.useRef)(null),H=(0,mt.useDragDropManager)();(0,o.useEffect)((()=>{const e=H.getMonitor();e.subscribeToStateChange((()=>F(!e.isDragging())))}),[]),(0,o.useEffect)((()=>{A&&V.current?.focus()}),[]),(0,o.useEffect)((()=>{const e=e=>{[T.Modifiers.Mod,T.Modifiers.Shift].includes((0,T.modifiersFromEvent)(e))&&s()},t=e=>{l&&![T.Modifiers.Mod,T.Modifiers.Shift].includes((0,T.modifiersFromEvent)(e))&&i()};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()=>{}}),[])}(V);const G=(0,o.useCallback)((()=>(0,I.ensureNotNull)(oe.current)),[]),U=(0,o.useCallback)((()=>r),[r]),W=(0,o.useMemo)((()=>{const e=h?Ft:Rt,t=[];let n,i;t.push({type:"padding",node:o.createElement(Qt,{type:"first",key:"padding-top",getContainerElement:G,getOrderedNodes:U,processDropTarget:N})});for(let s=0;s<r.length;s++){const l=r[s];l.isSticky&&(i=l.id),1===l.level&&(void 0!==n&&n!==l.parentId&&t.push({type:"separator",node:o.createElement("div",{key:n+"_separator",className:cn.separator})}),n=l.parentId),t.push({type:"node",stickyNodeId:i,isSticky:l.isSticky,node:o.createElement(e,{id:l.id,key:l.id,isFirstListItem:0===s,isLastListItem:s===r.length-1,isExpandable:l.children.length>0,nodeRenderer:a,readOnly:h,onClick:f,isOffset:l.level>1,getContainerElement:G})})}return t.push({type:"padding",node:o.createElement(Qt,{type:"last",key:"padding-bottom",getContainerElement:G,getOrderedNodes:U,processDropTarget:N})}),t}),[r]),K=(0,o.useMemo)((()=>{if(O){const e=W[O];return e&&"stickyNodeId"in e?e.stickyNodeId:void 0}}),[O,W]),q=(0,o.useRef)([]);q.current=W;const Z=(0,o.useCallback)((e=>{let{style:t}=e;const{index:n}=e,r=q.current[n];return n===q.current.length-1&&(t={...t,bottom:0,minHeight:t.height},delete t.height),"isSticky"in r&&r.isSticky&&(t={...t,zIndex:ee.current?.scrollTop&&t.top&&+t.top<=ee.current?.scrollTop?2:5}),o.createElement("div",{style:t},q.current[n].node)}),[]),$=(0,o.useCallback)((e=>{
const t=q.current[e];return"padding"===t.type?6:"function"==typeof S?S(e,t):S}),[S]),Q=(0,o.useCallback)((e=>(0,I.ensure)(q.current[e].node.key)),[]),X=(0,o.useMemo)((()=>null===v?{index:-1}:{index:q.current.findIndex((e=>e.node.key===v.id))}),[v]);u(V);const[Y,J,ee,te]=(0,Zt.useOverlayScroll)(),ne=(0,o.useRef)(null);(0,o.useEffect)((()=>(0,I.ensureNotNull)(ne.current).resetAfterIndex(0,!0)),[W]),(0,o.useEffect)((()=>{let e=X.index;const t=q.current[X.index];O&&e<=O&&t&&"stickyNodeId"in t&&t.stickyNodeId&&(e-=1),(0,I.ensureNotNull)(ne.current).scrollToItem(e)}),[X]);const oe=(0,o.useRef)(null),re=(0,o.useMemo)((()=>({isOver:x,transform:p})),[x,p]),ie=(0,o.useMemo)((()=>({id:K,nodeRenderer:a,getContainerElement:G,onClick:f,isShowStuck:R,readOnly:h})),[K,a,G,R,f,h]),se=(0,o.useRef)(null),le=(0,o.useRef)({startScroll(e){const t=()=>{null!==ee.current&&(se.current=requestAnimationFrame(t),ee.current.scrollBy({top:e}))};this.stopScroll(),t()},stopScroll(){null!==se.current&&(cancelAnimationFrame(se.current),se.current=null)},getListElement:()=>ee.current});return(0,o.useImperativeHandle)(t,(()=>le.current),[]),(0,o.useEffect)((()=>()=>le.current.stopScroll()),[x]),(0,o.useEffect)((()=>{if(!V.current)return;function e(e){if(!t.matches(":focus-visible"))return;if(!j)return;const{viewModel:n}=j,o=n.selection();e.defaultPrevented||e.currentTarget!==e.target||o.selected().length||y()}const t=V.current;return t.addEventListener("focus",e),()=>{t.removeEventListener("focus",e)}}),[V,y,j]),o.createElement(Xt.Provider,{value:re},o.createElement(on.Provider,{value:ie},o.createElement("div",{...J,className:g()(cn.tree,d,P&&cn.accessible),ref:V,onFocus:function(e){if(void 0===L)return;L(e)&&z(!0)},onBlur:function(e){z(!1)},"data-name":"tree",tabIndex:0,onKeyDown:function(e){z(!1);const t=(0,T.hashFromEvent)(e);if(e.defaultPrevented||(0,Pt.isNativeUIInteraction)(t,e.target))return;const o=(0,I.ensureDefined)(Y.scrollPosTop),r=(0,I.ensureDefined)(Y.contentHeight),i=(0,I.ensureDefined)(Y.containerHeight);if(i){const n=.875*i,s=o+i===r;switch(t){case 35:s||(e.preventDefault(),ae(r));break;case 36:0!==o&&(e.preventDefault(),ae(0));break;case 33:0!==o&&(e.preventDefault(),ae(Math.max(0,o-n)));break;case 34:s||(e.preventDefault(),ae(Math.min(o+n,r)))}}j||t!==dn||(e.preventDefault(),b());j||t!==un||(e.preventDefault(),_());(38===t||void 0!==n&&"previous"===n[t])&&(e.preventDefault(),C());(40===t||void 0!==n&&"next"===n[t])&&(e.preventDefault(),y());if((8===t||46===t)&&j){const{viewModel:e}=j,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]),m(o))}),!0)}w?.(e)}},o.createElement(qt.OverlayScrollContainer,{...Y,className:cn.overlayScrollWrap}),o.createElement(St.VariableSizeList,{ref:function(e){ne.current=e},className:cn.listContainer,width:M,height:D,itemCount:W.length,itemSize:$,children:Z,itemKey:Q,outerRef:function(e){ee.current=e,E&&E(e)},innerRef:function(e){oe.current=e},
innerElementType:ln,onItemsRendered:function({visibleStartIndex:e}){B(e),te()},overscanCount:20,direction:(0,an.isRtl)()?"rtl":"ltr"}),o.createElement(Kt,{dragPreviewRenderer:c,nodeRenderer:a}))));function ae(e){ee.current?.scrollTo({left:0,top:e})}}));const fn=(0,j.connect)((function(e){return{renderList:Qe(e),orderedNodes:Ze(e),isMultiSelecting:We(e),selectedIds:Ge(e),scrollToId:Re(e)}}),(function(e){return(0,dt.bindActionCreators)({startMultiSelect:Te,stopMultiSelect:Ie,setFocusedNode:we,processDropTarget:be,onMoveCursorToNext:me,onMoveCursorToPrevious:ge,onMultiSelectPrevious:ve,onMultiSelectNext:Se},e)}),null,{context:Lt})((function(e){const t=(0,o.useRef)(null),[{isOver:n},r]=(0,vt.useDrop)({accept:"node",drop:(n,o)=>{("touch"===e.drag||bt.isFF)&&t.current?.stopScroll(),o.getItem().dropSelection()},hover:(n,o)=>{if("touch"!==e.drag&&!bt.isFF)return;const r=o.getClientOffset();if(null===r)return;const i=t.current?.getListElement()??null;if(null===i)return;const s=i.getBoundingClientRect();((n,o,r)=>{const i=Math.abs(n-r),s=Math.abs(n-o);if(s>40&&i>40||i<=40&&s<=40)return void t.current?.stopScroll();var l,a,c,d;l=s>20&&s<=40,c=i<=20,d=s<=20,(a=i>20&&i<=40)||l?"touch"===e.drag?t.current?.startScroll(a?-5:5):t.current?.startScroll(a?-2:2):(c||d)&&("touch"===e.drag?t.current?.startScroll(c?-10:10):t.current?.startScroll(c?-5:5))})(r.y,s.bottom,s.top)},collect:e=>({isOver:e.isOver()})});return o.createElement(hn,{...e,isOver:n,connectDropTarget:r,ref:t})})),pn={delayTouchStart:100};function gn(e){const{canBeAddedToSelection:t,initState:n,onSelect:r,canMove:i,onDrop:s,onMove:l,nodes:a,selectedIds:c,onKeyboardSelect:d,saga:u,lastFocusedNodeObject:h,lastSyncTimestampRef:f,scrollToId:p,...g}=e,[m,v]=(0,o.useState)(null);return(0,o.useEffect)((()=>{const e=(0,z.default)();v(function(e){const t=(0,dt.applyMiddleware)(e);return(0,dt.createStore)(gt,t)}(e));const o=e.run(ct,{initState:n,onKeyboardSelect:d,saga:u,canMove:i,onMove:l,onDrop:s,onSelect:r,canBeAddedToSelection:t});return()=>o.cancel()}),[]),(0,o.useEffect)((()=>(null!==m&&a&&(f&&(f.current=performance.now()),m.dispatch((e=>({type:q,nodes:e}))(a))),()=>{})),[m,a]),(0,o.useEffect)((()=>{null!==m&&c&&m.dispatch(ye(c))}),[m,c]),(0,o.useEffect)((()=>{null!==m&&h?.id&&m.dispatch(we(h.id))}),[m,h]),null===m?null:o.createElement(mn,{store:m,scrollToId:p,...g})}const mn=o.memo((function(e){const{store:t,scrollToId:n,...r}=e,i="touch"===e.drag?H.TouchBackend:V.HTML5Backend;return(0,o.useEffect)((()=>{t.dispatch(Ee(n?.id??null))}),[n]),o.createElement(G.DndProvider,{backend:i,options:pn},o.createElement(j.Provider,{store:t,context:Lt},o.createElement(fn,{...r})))}));function vn(e,t){(0,F.trackEvent)("Object Tree",e,t)}function Sn(e){return e.length>1?"Multi select":e[0].gaLabel()}function bn(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(ye(e)))),()=>{e.onChange().unsubscribeAll(n),e.selection().onChange().unsubscribeAll(n),
e.onGroupCreated().unsubscribeAll(n)}}),z.buffers.expanding())}function*_n(){for(;;)yield(0,y.take)([ee,J]),vn("Select","Arrow")}function*yn(){for(;;){const{mode:e}=yield(0,y.take)(de);1===e&&vn("Multi select","Ctrl"),2===e&&vn("Multi select","Shift")}}function*Cn(e){for(;;){yield(0,y.take)(Y);const{node:t,dropType:n}=Oe(yield(0,y.select)());if(t){const o=Ke(yield(0,y.select)()),r=o.map((t=>(0,I.ensureNotNull)(e.entity(t.id))));let i="Drag";1===t.level&&"inside"!==n&&o.some((e=>2===e.level))?i="From the group":2!==t.level&&"inside"!==n||!o.some((e=>1===e.level))?1===o.length&&o[0].parentId!==t.parentId&&(i="Existing pane"):i="To the group",vn(i,Sn(r))}}}function*Tn(e){yield(0,y.fork)(_n),yield(0,y.fork)(yn),yield(0,y.fork)(Cn,e)}function*In(e){yield(0,y.fork)(Tn,e);const t=yield(0,y.call)(bn,e);ht.logNormal("Opened object tree data source channel");try{for(;;){const e=yield(0,y.take)(t);yield(0,y.put)(e)}}finally{ht.logNormal("Closed object tree data source channel"),t.close()}}const wn=o.createContext(null);var En=n(26867),Mn=n(898),Dn=n(28456);const kn=C.mobiletouch?"touch":"native";function xn(e){const{viewModel:t,showHeader:n=!0,nodeRenderer:r,isDialog:i=!1,hideHeaderTitle:s=!1}=e,l=(0,o.useRef)(null),a=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),[c,d]=(0,Mn.useDimensions)(),[u,h]=(0,o.useState)(null),f=(0,o.useMemo)((()=>({isTouch:C.touch,isDialog:i})),[i]);return o.createElement(wn.Provider,{value:f},o.createElement(k.Provider,{value:{viewModel:t}},o.createElement("div",{className:Dn.wrap,onContextMenu:En.preventDefaultForContextMenu},n&&o.createElement(P,{hideTitle:s}),o.createElement("div",{className:Dn.space,onClick:function(e){if(e.defaultPrevented)return;if(!(e.target instanceof Element)||null===l.current)return;e.target===l.current&&t.selection().set([])},ref:c},null!==d&&o.createElement(gn,{key:a,height:d.height,width:d.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:kn,rowHeight:Nn,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:u,saga:function*(){yield(0,y.fork)(In,t)},onKeyboardSelect:function(e){h({id:e})},outerRef:function(e){l.current=e},onKeyDown:function(e){if(13===(0,T.hashFromEvent)(e)){e.preventDefault();const n=t.selection().selected(),o=n.length>0?t.entity(n[0]):void 0;o&&t.openProperties(o)}},autofocus:i})))))}function Nn(e,t){switch(t.type){case"node":return 38;case"separator":return 13}}var An,Ln,On=n(37103);!function(e){e.Svg="svg",e.Url="url"}(An||(An={})),function(e){e[e.NoSync=0]="NoSync",
e[e.SyncInLayout=1]="SyncInLayout",e[e.GlobalSync=2]="GlobalSync"}(Ln||(Ln={}));var Bn=n(31261),Rn=n(26591);function Fn(e){const{className:t,disabled:n,...r}=e;return o.createElement(w.Icon,{className:g()(Rn.button,n&&Rn.disabled,t),...r})}var Pn=n(77975);const zn=f.t(null,void 0,n(83390)),jn=f.t(null,void 0,n(6321)),Vn=f.t(null,void 0,n(99894)),Hn=f.t(null,void 0,n(5837)),Gn=f.t(null,void 0,n(27298)),Un=f.t(null,void 0,n(98334)),Wn=f.t(null,void 0,n(67410));var Kn=n(70002),qn=n(84015),Zn=n(60925),$n=n(52870),Qn=n(49756),Xn=n(94007),Yn=n(62766),Jn=n(15620);On.enabled("saveload_separate_drawings_storage");function eo(e){const{id:t}=e,n=(0,o.useContext)(k),{viewModel:r}=(0,I.ensureNotNull)(n),i=r.entity(t);return null===i?null:o.createElement(ro,{...e,entity:i})}const to=500,no={},oo=null;function ro(e){const{id:t,isOffset:r,isDisabled:i,isSelected:s,isChildOfSelected:l,isHovered:a,parentId:c,entity:d,isExpanded:u}=e,h=(0,o.useContext)(k),{viewModel:g}=(0,I.ensureNotNull)(h),m=(0,o.useContext)(wn),{size:v}=(0,o.useContext)(Et),[S,b]=(0,o.useState)(!1),_=(0,o.useRef)(null),[y,C]=(0,o.useState)(d.title().value()),[E,M]=(0,o.useState)((()=>d.getIcon())),[D,x]=(0,o.useState)(d.isLocked()),[N,A]=(0,o.useState)(d.isVisible()),[L,O]=(0,o.useState)(d.isActualInterval()),[B,R]=(0,o.useState)(d.getDrawingSyncState()),[F,P]=(0,o.useState)(d.getModificationDate),[z,j]=(0,o.useState)(!1),[V,H]=((0,Pn.useWatchedValueReadonly)({watchedValue:g.getChartLayout()}),(0,o.useState)(!1)),G=(0,o.useRef)(null);(0,o.useEffect)((()=>{const e={};d.onLockChanged().subscribe(e,(()=>x(d.isLocked()))),d.onVisibilityChanged().subscribe(e,(()=>A(d.isVisible())));const t=d.title().spawn();t.subscribe((e=>C(e))),d.onIsActualIntervalChange().subscribe(e,(()=>O(d.isActualInterval()))),d.onSyncStateChanged().subscribe(e,ne),d.modificationDateChanged().subscribe(e,(()=>P(d.getModificationDate())));const n=d.onIconChanged?d.onIconChanged():void 0;return n&&n.subscribe(e,(()=>M(d.getIcon()))),()=>{d.onIsActualIntervalChange().unsubscribeAll(e),d.onLockChanged().unsubscribeAll(e),d.onVisibilityChanged().unsubscribeAll(e),d.onSyncStateChanged().unsubscribeAll(e),d.modificationDateChanged().unsubscribeAll(e),t.destroy(),G.current&&clearTimeout(G.current),n&&n.unsubscribeAll(e)}}),[d]),(0,o.useEffect)((()=>(window.loginStateChange&&(window.loginStateChange.subscribe(null,ne),oo?.stateChanged.subscribe(null,ne)),()=>{window.loginStateChange.unsubscribe(null,ne),oo?.stateChanged.unsubscribe(null,ne)})),[]),(0,o.useEffect)((()=>{S&&_.current&&(_.current.focus(),_.current.setSelectionRange(0,y.length))}),[S]),(0,o.useEffect)((()=>{const e={};return g.hoveredObjectChanged().subscribe(e,te),()=>{g.hoveredObjectChanged().unsubscribeAll(e)}}),[u]),(0,o.useEffect)((()=>{g.setHoveredObject(a?t:null)}),[a]),(0,o.useEffect)((()=>{!s&&G.current&&(clearTimeout(G.current),G.current=null),b(!1)}),[s]);const U={};if(c){const e=g.entity(c);e&&(U["data-parent-name"]=e.title().value()),U["data-type"]=d.hasChildren()?"group":"data-source"}
const W=On.enabled("test_show_object_tree_debug")?`<${d.id()}> (${d.zOrder()}) ${d.title()}`:d.title().value(),K=(null!==B&&no[B],a||z),q=S&&s,Z=!!m&&m.isTouch,$=!!m&&m.isDialog,Q=L&&N?Xn:Yn,X=d.hasChildren()?f.t(null,void 0,n(40983)):f.t(null,void 0,n(80014));let Y=null;return E&&(Y=E.type===An.Svg?o.createElement(w.Icon,{icon:E.content||"",className:Jn.icon}):o.createElement("img",{className:Jn.icon,src:E.href,decoding:"async",width:"28",height:"28",alt:"",draggable:!1,crossOrigin:"anonymous"})),o.createElement("span",{className:p(Jn.wrap,i&&Jn.disabled,s&&Jn.selected,r&&Jn.offset,l&&Jn.childOfSelected,z&&!i&&!s&&!l&&Jn.hover,$&&!i&&!s&&!l&&Jn.dialog,$&&!i&&!s&&!l&&(0,qn.isOnMobileAppPage)("any")&&Jn.mobile,!!F&&["apply-common-tooltip","common-tooltip-vertical"]),onMouseDown:function(e){S&&!(0,I.ensureNotNull)(_.current).contains(e.target)&&H(!0)},onClick:1===v?J:function(e){if(e.defaultPrevented)return;if(0!==(0,T.modifiersFromEvent)(e))return;if(G.current)e.preventDefault(),clearTimeout(G.current),G.current=null,g.openProperties(d),H(!1);else{const e=g.selection().selected();G.current=setTimeout((()=>{G.current=null,s&&!V&&1===e.length&&g.rename(d,(()=>b(!0))),H(!1)}),to)}},onContextMenu:0===v?J:void 0,"data-tooltip":F?f.t(null,{replace:{modificationDate:F}},n(63944)):void 0},!q&&o.createElement(o.Fragment,null,Y,!1,o.createElement("span",{className:p(Jn.title,g.isMain(d)&&Jn.main,(!d.isVisible()||!L)&&Jn.disabled),...U},W),o.createElement("span",{className:Jn.rightButtons},d.canBeLocked()&&o.createElement(Fn,{title:D?Vn:Hn,icon:D?$n:Qn,className:p(Jn.button,(K||D)&&Jn.visible,"apply-common-tooltip"),onClick:function(e){if(e.defaultPrevented)return;e.preventDefault(),g.setIsLocked(t,!d.isLocked())},"data-role":"button","data-name":"lock","data-active":D}),d.canBeHidden()&&o.createElement(Fn,{icon:Q,className:p(Jn.button,!L&&Jn.warn,(K||!N||!L)&&Jn.visible,"apply-common-tooltip"),onClick:L?function(e){if(e.defaultPrevented)return;e.preventDefault(),g.setIsVisible(t,!d.isVisible())}:function(e){if(e.defaultPrevented)return;e.preventDefault(),g.openProperties(d,Kn.TabNames.visibility)},title:function(){if(!L)return X;return N?Gn:Un}(),"data-role":"button","data-name":"hide","data-active":!N}),d.canBeRemoved()&&o.createElement(Fn,{title:Wn,icon:Zn,className:p(Jn.button,(Z||K)&&Jn.visible,"apply-common-tooltip"),onClick:function(e){if(e.defaultPrevented)return;e.preventDefault(),e.stopPropagation(),g.remove(t)},"data-role":"button","data-name":"remove"}))),q&&o.createElement(Bn.InputControl,{value:y,onChange:function(e){C(e.currentTarget.value)},onClick:En.preventDefault,className:Jn.renameInput,onKeyDown:function(e){27===(0,T.hashFromEvent)(e)?(e.preventDefault(),C(d.title().value()),b(!1)):13===(0,T.hashFromEvent)(e)&&(e.preventDefault(),ee())},reference:function(e){_.current=e},onBlur:ee,onDragStart:function(e){e.preventDefault(),e.stopPropagation()},draggable:!0,stretch:!0}));function J(e){e.defaultPrevented||S||!d.fullyConstructed()||(e.preventDefault(),e.persist(),g.openContextMenu(d,(()=>b(!0)),e))}
function ee(){""!==y&&d.setName(y),C(d.title().value()),b(!1)}function te(e){if(d.hasChildren()&&!u){const t=null!==e&&d.childrenIds().has(e);j(t)}else j(t===e)}function ne(){R(d.getDrawingSyncState())}}var io=n(21618),so=n(85529);function lo(e){const{viewModel:t,onClose:r,activeChartWidget:i}=e,[s,l]=(0,o.useState)(!1),[a,c]=(0,o.useState)(!1),[d,u]=(0,o.useState)(!1),h=(0,o.useRef)(null),g=(0,m.useForceUpdate)(),y=((0,v.useIsMounted)(),t.selection()),C=t.canSelectionBeGrouped();return(0,o.useEffect)((()=>{const e=window.matchMedia(_.DialogBreakpoints.TabletSmall);return e.addEventListener("change",T),()=>e.removeEventListener("change",T)}),[]),(0,o.useEffect)((()=>(y.onChange().subscribe(null,(()=>g())),()=>{y.onChange().unsubscribeAll(null)})),[y]),(0,o.useEffect)((()=>{const e=e=>u(e);return t.isContextMenuOpened().subscribe(e),()=>{t.isContextMenuOpened().unsubscribe(e)}}),[t]),o.createElement(o.Fragment,null,o.createElement(S.MatchMedia,{rule:_.DialogBreakpoints.TabletSmall},(e=>o.createElement(b.AdaptivePopupDialog,{additionalElementPos:"after",additionalHeaderElement:o.createElement("div",{className:so.buttons},o.createElement(io.ToolWidgetIconButton,{className:p(so.button,!C&&so.disabled),icon:B,onClick:I,isDisabled:!C,title:f.t(null,void 0,n(83390)),"data-name":"group-button"}),!1),className:so.dialog,dataName:"object-tree-dialog",isOpened:!0,onClickOutside:a||e||d?()=>{}:r,onClose:r,ref:h,render:()=>o.createElement(ao,{isSmallTablet:e,viewModel:t}),title:f.t(null,void 0,n(88616)),showSeparator:!0}))),!1);function T(){s&&!window.matchMedia(_.DialogBreakpoints.TabletSmall).matches&&l(!1)}function I(){t.createGroupFromSelection()}}function ao(e){const{isSmallTablet:t,viewModel:n}=e,r=(0,o.useMemo)((()=>({size:t?1:0,smallSizeTreeNodeAction:0})),[t]);return o.createElement(Et.Provider,{value:r},o.createElement(xn,{nodeRenderer:eo,showHeader:!1,viewModel:n,isDialog:!0}))}var co=n(16216),uo=n(60709),ho=n(48096);var fo=n(32112);function po(e,t,n){return`${e}:${t}:${n}`}function go(e){const t=e.split(":");return{paneId:t[0],persistentId:t[1],instanceId:t[2]}}class mo{constructor(e){this._onChange=new ho.Delegate,this._recalculate=()=>{const e=[];for(const t of this._groupModel.groups()){const n=t.lineTools();if(0===n.length)continue;const o=n[0],r=this._model.panes().filter((e=>e.sourcesByGroup().hasObjectTreeSource(o)));for(const n of r){const o=po(n.id(),t.id,t.instanceId());e.push(o)}}const 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 fo.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=>go(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(){const e=this._selectionApi.allSources().map((e=>this._model.dataSourceForId(e))).filter(ut.notNull).filter((e=>e.showInObjectTree())),t=[];for(const n of e){const e=this._model.panes().filter((e=>e.sourcesByGroup().hasObjectTreeSource(n)));for(const o of e){const e=po(o.id(),n.id(),n.instanceId());t.push(e)}}return t}}class vo{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().objectTreeSources().filter((e=>e.showInObjectTree()));e[t.id()]=So(t.id(),0);for(const n of this._groupModel.groups()){const o=po(t.id(),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=>po(t.id(),e.id(),e.instanceId())));e[r.id()]=So(r.id(),1,t.id(),o),e[t.id()].children.push(r.id());for(const t of o)e[t]=So(t,2,r.id())}}for(const o of n){const n=po(t.id(),o.id(),o.instanceId());e[n]||(e[n]=So(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 So(e,t,n,o=[]){return{id:e,level:t,parentId:n,children:o}}var bo=n(95804),_o=n(31932),yo=n(22613),Co=n(26610),To=n(2088),Io=n(55396),wo=n(47930),Eo=n(48126);var Mo=n(72207),Do=n(13896),ko=n(67455),xo=n(22455),No=n(78861),Ao=n(36313),Lo=n(7295),Oo=n(28824),Bo=n(57674);const Ro=new bo.TranslatedString("show {title}",f.t(null,void 0,n(51382))),Fo=new bo.TranslatedString("hide {title}",f.t(null,void 0,n(13017))),Po=new bo.TranslatedString("lock {title}",f.t(null,void 0,n(76104))),zo=new bo.TranslatedString("unlock {title}",f.t(null,void 0,n(12525))),jo=new bo.TranslatedString("change {sourceTitle} title to {newSourceTitle}",f.t(null,void 0,n(23687))),Vo=new bo.TranslatedString("insert source(s) after",f.t(null,void 0,n(10370)));function Ho(e,t){return t.every((t=>!(t.pane()!==e&&!t.allowsMovingBetweenPanes())))}function Go(e,t){if(!(t instanceof Mo.DataSource&&t.showInObjectTree()))return null;const n=e.find((e=>e.sourcesByGroup().hasObjectTreeSource(t)));return n?po(n.id(),t.id(),t.instanceId()):null}function Uo(e){return new bo.TranslatedString(e.name(),e.title(Ao.TitleDisplayTarget.DataWindow))}const Wo=new ho.Delegate,Ko=On.enabled("saveload_separate_drawings_storage");function qo(e){return 0===e?0:1===e?1:2}class Zo{constructor(e,t){
this._syncStateChanged=new ho.Delegate,this.getModificationDate=()=>(0,Co.isLineTool)(this._dataSource)?function(e){if(null===e)return null;const t=(0,Eo.getLocaleIso)();return`${(0,wo.formatTime)(e,t,"year","day")}\n${(0,wo.formatTime)(e,t,"hour","minute",{timeZoneName:!0})}`}(this._dataSource.serverUpdateTime()):null,this._updateSyncState=()=>{this._syncStateChanged.fire((0,I.ensureNotNull)(this.getDrawingSyncState()))},this._undoModel=e,this._dataSource=t,this._isWidgetPane=e.model().paneForSource(t)?.mode()===Io.PaneMode.Widget,(0,Co.isLineTool)(t)?(t.linkKey().subscribe(this._updateSyncState),t.sharingMode().subscribe(this._updateSyncState),this._title=(0,ko.createWVFromGetterAndSubscription)((()=>t.properties().title.value()||t.translatedType()),t.properties().title)):(0,xo.isSymbolSource)(t)?this._title=(0,ko.createWVFromGetterAndSubscriptions)((()=>t.symbolTitle(Ao.TitleDisplayTarget.DataWindow)),[t.symbolChanged(),t.symbolResolved(),t.onSymbolIntervalChanged()]):(0,To.isStudy)(t)?this._title=(0,ko.createWVFromGetterAndSubscriptions)((()=>t.title(Ao.TitleDisplayTarget.DataWindow)),[t.properties().childs().inputs,this._undoModel.model().properties().childs().paneProperties.childs().legendProperties.childs().showStudyArguments,t.properties().childs().showLegendInputs,t.onParentSourcesChanges(),t.series().symbolResolved()]):this._title=new yo.WatchedValue(t.title(Ao.TitleDisplayTarget.DataWindow)).spawn();const n=this._undoModel.lineBeingCreated();null!==n&&n===t&&n.isSynchronizable()&&No.isToolCreatingNow.subscribe(this._updateSyncState)}destroy(){(0,Co.isLineTool)(this._dataSource)&&(this._dataSource.linkKey().unsubscribe(this._updateSyncState),this._dataSource.sharingMode().unsubscribe(this._updateSyncState),this._dataSource.serverUpdateTimeChanged().unsubscribeAll(this)),this._title.destroy(),No.isToolCreatingNow.unsubscribe(this._updateSyncState)}id(){return po(this.pane().id(),this._dataSource.id(),this._dataSource.instanceId())}title(){return this._title}gaLabel(){return(0,To.isStudy)(this._dataSource)?"Study":(0,Co.isLineTool)(this._dataSource)?"Drawing":"Symbol"}canBeLocked(){return(0,Co.isLineTool)(this._dataSource)&&this._dataSource.userEditEnabled()}canBeRemoved(){return this._undoModel.mainSeries()!==this._dataSource&&this._dataSource.isUserDeletable()}canBeHidden(){return this._dataSource.canBeHidden()}canBeRenamed(){return(0,Co.isLineTool)(this._dataSource)}fullyConstructed(){return this._undoModel.lineBeingCreated()!==this._dataSource}isVisible(){return this._dataSource.properties().visible.value()}isActualInterval(){return!(0,Co.isLineTool)(this._dataSource)&&!(0,To.isStudy)(this._dataSource)||this._dataSource.isActualInterval()}onIsActualIntervalChange(){return(0,Co.isLineTool)(this._dataSource)||(0,To.isStudy)(this._dataSource)?this._dataSource.onIsActualIntervalChange():Wo}isLocked(){return!!(0,Co.isLineTool)(this._dataSource)&&this._dataSource.properties().frozen.value()}onVisibilityChanged(){return this._dataSource.properties().visible.listeners()}onLockChanged(){return(0,
Co.isLineTool)(this._dataSource)?this._dataSource.properties().frozen.listeners():Wo}getIcon(){const e=a,t=this._dataSource.getSourceIcon(),n=(0,To.isStudyStrategy)(this._dataSource);let o={type:An.Svg,content:n?Lo:Oo};if(e&&t)if("loadSvg"===t.type){const[n,r]=t.svgId.split("."),i="linetool"===n?e.linetool[r]:e.series[Number(r)];o={type:An.Svg,content:i||Oo}}else"svgContent"===t.type?o={type:An.Svg,content:t.content}:"url"===t.type&&(o={type:An.Url,href:t.href});return o}onIconChanged(){if(this._dataSource.onSourceIconChanged)return this._dataSource.onSourceIconChanged()}setVisible(e){const t=(e?Ro:Fo).format({title:Uo(this._dataSource)});this._undoModel.setProperty(this._dataSource.properties().visible,e,t,Do.lineToolsDoNotAffectChartInvalidation&&(0,Co.isLineTool)(this._dataSource))}setLocked(e){if((0,Co.isLineTool)(this._dataSource)){const t=(e?Po:zo).format({title:Uo(this._dataSource)});this._undoModel.setProperty(this._dataSource.properties().frozen,e,t,Do.lineToolsDoNotAffectChartInvalidation)}}setName(e){if((0,Co.isLineTool)(this._dataSource)){const t=jo.format({sourceTitle:this._dataSource.properties().title.value()||Uo(this._dataSource),newSourceTitle:e});this._undoModel.setProperty(this._dataSource.properties().title,e,t,Do.lineToolsDoNotAffectChartInvalidation)}}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))}alreadyRemoved(){return!this._undoModel.model().dataSourceForId(this._dataSource.id())}allowsMovingBetweenPanes(){return this._dataSource.allowsMovingBetweenPanes()}canBeAddedToGroup(){return(0,Co.isLineTool)(this._dataSource)&&this._dataSource.boundToSymbol()}canInsertBeforeThis(e){return!this._isWidgetPane&&this._canInsertBeforeOrAfter(e)}canInsertAfterThis(e){return!this._isWidgetPane&&this._canInsertBeforeOrAfter(e)}detachFromParent(){if((0,Co.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)}}canBeSyncedInLayout(){return(0,Co.isLineTool)(this._dataSource)&&this._dataSource.isSynchronizable()}onSyncStateChanged(){return this._syncStateChanged}
modificationDateChanged(){return(0,Co.isLineTool)(this._dataSource)?this._dataSource.serverUpdateTimeChanged():Wo}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.shareLineTools([t],1)}}getDrawingSyncState(){return this.canBeSyncedInLayout()?Ko?this.fullyConstructed()?qo(this._dataSource.sharingMode().value()):0:this.fullyConstructed()&&null!==this._dataSource.linkKey().value()?1:0:null}_canInsertBeforeOrAfter(e){const t=this._undoModel.model();if(!Ho(this.pane(),e))return!1;if((0,Co.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()))},i=e.reduce(((e,t)=>t.addSourcesToArray(e)),[]);if((0,Co.isLineTool)(this._dataSource)){const t=n.lineToolsGroupModel().groupForLineTool(this._dataSource);null!==t?((0,I.assert)(!e.some((e=>e.hasChildren()))),i.forEach((e=>{(0,Co.isLineTool)(e)&&(t.containsLineTool(e)||o.addLineToolToGroup(t,e))}))):r()}else r();t(i),this._undoModel.endUndoMacro()}}class $o{constructor(e,t){this._onVisibilityChanged=new ho.Delegate,this._onLockChanged=new ho.Delegate,this._onIsActualIntervalChanged=new ho.Delegate,this._syncStateChanged=new ho.Delegate,this._linkKeyChangedBound=this._linkKeyChanged.bind(this),this._undoModel=e,this._group=t,this._lineTools=t.lineTools(),this._pane=(0,I.ensureNotNull)(this._undoModel.model().paneForSource(this._lineTools[0]));const n=()=>{this._lineTools.forEach((e=>{e.properties().visible.subscribe(this,(()=>this._onVisibilityChanged.fire())),e.properties().frozen.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.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 po(this._pane.id(),this._group.id,this._group.instanceId())}title(){return this._group.name()}gaLabel(){return"Group"}getIcon(){return{type:An.Svg,content:Bo}}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}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];e.sort(((e,t)=>t.zorder()-e.zorder()));const t=this._pane.id();return new Set(e.map((e=>po(t,e.id(),e.instanceId()))))}hasChildren(){return!0}pane(){return this._pane}alreadyRemoved(){return this._undoModel.model().lineToolsGroupModel().groups().includes(this._group)}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.shareLineTools(t,1)}}getDrawingSyncState(){if(!this.canBeSyncedInLayout())return null;if(Ko){const e=this._lineTools[0]?.sharingMode().value();if(void 0===e)return null;let t=e;if(0!==t)for(const e of this._lineTools)if(e.sharingMode().value()!==t){t=0;break}return qo(t)}
return this._lineTools.every((e=>null!==e.linkKey().value()))?1:0}modificationDateChanged(){return Wo}getModificationDate(){return null}_linkKeyChanged(){this._syncStateChanged.fire((0,I.ensureNotNull)(this.getDrawingSyncState()))}_canInsertBeforeOrAfter(e){return Ho(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.unsubscribeAll(this),e.properties().frozen.unsubscribeAll(this),e.onIsActualIntervalChange().unsubscribeAll(this),e.linkKey().unsubscribe(this._linkKeyChangedBound),e.sharingMode().unsubscribe(this._linkKeyChangedBound)}))}}class Qo{constructor(e){this._hoveredObjectChanged=new ho.Delegate,this._entitiesCache=new Map,this._undoModel=e,this._undoModel.model().hoveredSourceChanged().subscribe(this,this._onModelHoveredSourceChanged)}destroy(){for(const e of this._entitiesCache.values())e?.destroy();this._undoModel.model().hoveredSourceChanged().unsubscribe(this,this._onModelHoveredSourceChanged)}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=>{e.has(t)||(this._entitiesCache.get(t)?.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,Co.isLineTool)(e)||!e.boundToSymbol())))return!1;const n=this._undoModel.model(),o=t.map((e=>n.paneForSource(e)));if(new Set(o).size>1)return!1;if(!Ko)return!0;const r=t.map((e=>e.sharingMode().value()));return 1===new Set(r).size}async contextMenuActions(e,t,n){const{ActionsProvider:o}=await(0,_o.actionsProviderModule)(),r=new o(e,n),i=[];return t.forEach((e=>e.addSourcesToArray(i))),r.contextMenuActionsForSources(i,(0,I.ensureNotNull)(this._undoModel.paneForSource(i[0])))}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 Go(this._undoModel.panes(),this._undoModel.model().hoveredSource())}hoveredObjectChanged(){return this._hoveredObjectChanged}_onModelHoveredSourceChanged(e){this._hoveredObjectChanged.fire(Go(this._undoModel.panes(),e))}_createObjectById(e){const t=go(e),n=t.persistentId,o=t.paneId,r=this._undoModel.model(),i=r.dataSourceForId(n),s=r.paneForId(o);if(null!==i&&null!==s)return new Zo(this._undoModel,i)
;const l=r.lineToolsGroupModel().groupForId(n);return null!==l&&null!==s?new $o(this._undoModel,l):null}}class Xo extends Error{constructor(){super("CancelToken")}}function Yo(e){let t=!1;return{promise:new Promise(((n,o)=>{e.then((e=>t?o(new Xo):n(e))),e.catch((e=>o(t?new Xo:e)))})),cancel(){t=!0}}}var Jo=n(67135),er=n(31269),tr=n(41706),nr=n(14429),or=n(2115),rr=n(16708),ir=n(97874),sr=n(2872),lr=n(84959),ar=n(91730),cr=n(93544);const dr=(0,s.getLogger)("Platform.GUI.ObjectTree");var ur;!function(e){e[e.Up=0]="Up",e[e.Down=1]="Down"}(ur||(ur={}));const hr=new bo.TranslatedString("move objects",f.t(null,void 0,n(36044))),fr=new bo.TranslatedString("lock objects",f.t(null,void 0,n(18942))),pr=new bo.TranslatedString("unlock objects",f.t(null,void 0,n(51198))),gr=new bo.TranslatedString("show objects",f.t(null,void 0,n(23771))),mr=new bo.TranslatedString("hide objects",f.t(null,void 0,n(93277))),vr=new bo.TranslatedString("remove objects",f.t(null,void 0,n(79688)));class Sr{constructor(e){this._nodes={},this._onChange=new ho.Delegate,this._onGroupCreated=new ho.Delegate,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 yo.WatchedValue(!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 Qo(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 mo(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,i]=this._normalizeTargetAndDropType(e,t);this._controller.withMacro(hr,(()=>{switch(i){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!e.alreadyRemoved()&&go(e.id()).persistentId===this._controller.mainSeries().id()}selection(){return this._selection}setIsLocked(e,t){const n=this._getObjectsToModify(e),o=t?fr:pr;this._controller.withMacro(o,(()=>{for(const e of n)e.setLocked(t)})),vn("Lock",Sn(n))}setIsVisible(e,t){const n=this._getObjectsToModify(e),o=t?gr:mr;this._controller.withMacro(o,(()=>{for(const e of n)e.setVisible(t)})),vn("Hide",Sn(n))}remove(e){const t=e=>{this._controller.withMacro(vr,(()=>{for(const t of n)t.isLocked()&&!e||t.remove()})),vn("Delete",Sn(n)),this._update()},n=this._getObjectsToModify(e),o=n.some((e=>!1)),r=n.some((e=>e.isLocked()));o?(null!==this._removeSourcesPromise&&this._removeSourcesPromise.cancel(),this._removeSourcesPromise=Yo(confirmDatasourceRemoving({hasLockedSources:r})),this._removeSourcesPromise.promise.then((e=>{e&&(this._removeSourcesPromise=null,t(!0))}))):r?(this._removeSourcesPromise?.cancel(),this._removeSourcesPromise=Yo((0,rr.confirmRemovingLockedLineTools)(rr.DeleteLockedLineToolReason.RemoveSelected)),this._removeSourcesPromise.promise.then((e=>{t(e)}))):t(!0)}canSelectionBeGrouped(){const e=this._getSelectedEntities();return this._facade.canBeGroupped(e)}createGroupFromSelection(){const e=this._groupController.createGroupFromSelection();vn("Create Group");const t=e.lineTools();(0,I.assert)(t.length>0);const n=t[0],o=this._model.panes().find((e=>e.sourcesByGroup().hasObjectTreeSource(n))),r=po((0,I.ensureDefined)(o).id(),e.id,e.instanceId());this.selection().set([this._ensuredEntity(r)]),this._onGroupCreated.fire(r),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(go(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(void 0,{shouldReturnFocus:!0}):((0,Co.isLineTool)(n)||(0,To.isStudy)(n))&&this._chart.value().showChartPropertiesForSource(n,t,{shouldReturnFocus:!0}):this._chart.value().showChartPropertiesForSources({sources:this._chart.value().model().selection().lineDataSources(),
title:e.title().value(),tabName:t,renamable:!0}))}canSelectionBeUnmerged(){const e=this._getSelectedEntities();return 1===e.length&&this.canNodeWithIdBeUnmerged(go(e[0].id()).persistentId)}canNodeWithIdBeUnmerged(e){const t=this._model.dataSourceForId(e);return null!==t&&(0,Jo.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(go(e.id()).persistentId))));this._chart.value().chartWidgetCollection().clipboard.uiRequestCopy(t),vn("Copy",Sn(e))}cloneSelection(){const e=this._getSelectedEntities(),t=e.map((e=>(0,I.ensureNotNull)(this._model.dataSourceForId(go(e.id()).persistentId))));t.every(Co.isLineTool)&&(this._controller.cloneLineTools([...t],!1),vn("Clone",Sn(e)))}rename(e,t){const n=this._getObjectsToModify(e.id());1===n.length&&n.some((e=>e.canBeRenamed()))&&(t(),vn("Rename",Sn(n)))}async openContextMenu(e,t,n){this._objects=this._getObjectsToModify(e.id());const o=this._facade.canBeGroupped(this._objects);let r;if(this._objects.some((e=>e.hasChildren())))r=await this._getActionsForGroupItem(e,t,o);else{const e=await this._facade.contextMenuActions(this._chart.value(),this._objects,this._options);if(r=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=r.findIndex((e=>"Copy"===e.id));r.splice(-1===e?r.length:e+1,0,this._getRenameAction(t))}const n=r.findIndex((e=>"Clone"===e.id)),i=r[n];if(-1!==n&&"action"===i.type&&i.update({shortcutHint:void 0}),o){const e=this._getGroupAction();if(-1!==n)r.splice(n,0,e);else{const t=r.findIndex((e=>"Copy"===e.id));r.splice(-1===t?0:t,0,e)}}}if(r.length>0){const t=go(e.id()).persistentId,o=this._model.dataSourceForId(t),i=o instanceof or.Series,s=0!==e.childrenIds().size;let l;l=i?{menuName:"ObjectTreeContextMenu",detail:{type:"series",id:o.instanceId()}}:(0,Co.isLineTool)(o)?{menuName:"ObjectTreeContextMenu",detail:{type:"shape",id:o?.id()??null}}:s?{menuName:"ObjectTreeContextMenu",detail:{type:"groupOfShapes",id:t||null}}:{menuName:"ObjectTreeContextMenu",detail:{type:"study",id:o?.id()||null}},er.ContextMenuManager.showMenu(r,n,{takeFocus:!0,returnFocus:!0},l,(()=>{this._isContextMenuOpened.setValue(!1)})).then((()=>{this._isContextMenuOpened.setValue(!0)}))}}setHoveredObject(e){const t=e?go(e).persistentId:null;this._facade.setHoveredObject(t)}hoveredObjectChanged(){return this._facade.hoveredObjectChanged()}getNextNodeIdAfterRemove(e){const{nodes:t}=this.getState(),n=go(e).persistentId,o=t.find((t=>t.id===e)),r=this.entity(e);if(!(o&&o.parentId&&r&&r.canBeRemoved()))return null;if(r.pane().mainDataSource()?.id()===n&&!this.canNodeWithIdBeUnmerged(n)){const e=t.filter((e=>0===e.level)).map((e=>e.id)),n=this._takeNextOrPrevElement(e,o.parentId);return(0,I.ensureDefined)(t.find((e=>e.id===n))).children[0]}const i=(0,
I.ensureDefined)(t.find((e=>e.id===o.parentId))).children;return 1===i.length?this.getNextNodeIdAfterRemove(o.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 nr.ActionWithStandardIcon({actionId:"ObjectsTree.CreateGroup",options:{label:zn,iconId:"ObjectsTree.CreateGroup",onExecute:()=>{this.createGroupFromSelection()}}})}_getRenameAction(e){return new nr.ActionWithStandardIcon({actionId:"ObjectsTree.RenameItem",options:{label:jn,iconId:"ObjectsTree.RenameItem",onExecute:()=>{e(),vn("Context menu rename",Sn(this._objects))}}})}async _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 tr.Separator),n&&r.unshift(this._getGroupAction(),new tr.Separator);const{createSyncDrawingActions:i}=await(0,_o.actionsProviderModule)(),s=i(this._chart.value(),o.filter(Co.isLineTool));s.length&&r.push(...s,new tr.Separator);const l=this._chart.value().actions().format.getState();return r.push(new tr.Action({actionId:"ObjectsTree.ToggleItemLocked",options:{label:e.isLocked()?Vn:Hn,icon:e.isLocked()?ir:sr,onExecute:()=>this.setIsLocked(e.id(),!e.isLocked())}}),new tr.Action({actionId:"ObjectsTree.ToggleItemVisibility",options:{label:e.isVisible()?Gn:Un,icon:e.isVisible()?lr:ar,onExecute:()=>this.setIsVisible(e.id(),!e.isVisible())}}),new tr.Action({actionId:"ObjectsTree.RemoveItem",options:{label:Wn,icon:cr,onExecute:()=>this.remove(e.id()),hotkeyHash:T.isMacKeyboard?8:46}}),new tr.Separator,new tr.Action({actionId:l.actionId,options:{label:l.label,icon:l.icon,onExecute:()=>this.openProperties(e)}})),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(go(n.id()).persistentId));if(!(0,Jo.isPriceDataSource)(o))throw new Error("Entity is not IPriceDataSource");(0===e?this._controller.unmergeSourceUp:this._controller.unmergeSourceDown).call(this._controller,o);vn(0===e?"New pane above":"New pane below",Sn([n]))}_recalculateTree(){const e=new vo(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&&dr.logWarn(`Detected dangling sources in selection. They will be ignored: ${JSON.stringify(t)}`),e}_getEntityById(e){return this._facade.getObjectById(e)}}var br=n(38414),_r=n(87896);class yr extends br.DialogRenderer{constructor(){super(),this._handleClose=()=>{
this._rootInstance?.unmount(),this._setVisibility(!1),null!==this._viewModel&&(this._viewModel.destroy(),this._viewModel=null)};const e=(0,co.service)(uo.CHART_WIDGET_COLLECTION_SERVICE);this._activeChartWidget=e.activeChartWidget.value(),this._viewModel=new Sr(e.activeChartWidget)}hide(){this._handleClose()}isVisible(){return this.visible().value()}show(){this.isVisible()||h().then((()=>{null!==this._viewModel&&(this._rootInstance=(0,_r.createReactRoot)(o.createElement(lo,{onClose:this._handleClose,viewModel:this._viewModel,activeChartWidget:this._activeChartWidget}),this._container),this._setVisibility(!0))}))}}},46043:(e,t,n)=>{"use strict";n.d(t,{useForceUpdate:()=>o.useForceUpdate});var o=n(125)},70412:(e,t,n)=>{"use strict";n.d(t,{hoverMouseEventFilter:()=>s,useAccurateHover:()=>l,useHover:()=>r,useHoverDeprecated:()=>i});var o=n(50959);function r(){const[e,t]=(0,o.useState)(!1);return[e,{onMouseEnter:function(e){t(!0)},onMouseLeave:function(e){t(!1)}}]}function i(){const[e,t]=(0,o.useState)(!1);return[e,{onMouseOver:function(e){s(e)&&t(!0)},onMouseOut:function(e){s(e)&&t(!1)}}]}function s(e){return!e.currentTarget.contains(e.relatedTarget)}function l(e){const[t,n]=(0,o.useState)(!1);return(0,o.useEffect)((()=>{const t=t=>{if(null===e.current)return;const o=e.current.contains(t.target);n(o)};return document.addEventListener("mouseover",t),()=>document.removeEventListener("mouseover",t)}),[]),t}},58169:(e,t,n)=>{"use strict";n.d(t,{ToolbarIconButton:()=>l});var o=n(50959),r=n(50238),i=n(21618);const s=(0,o.forwardRef)((function(e,t){const{tooltip:n,...r}=e;return o.createElement(i.ToolWidgetIconButton,{"aria-label":n,...r,tag:"button",ref:t,"data-tooltip":n,"data-tooltip-show-on-focus":"true"})})),l=(0,o.forwardRef)((function(e,t){const[n,i]=(0,r.useRovingTabindexElement)(t);return o.createElement(s,{...e,ref:n,tabIndex:i})}))},34788:(e,t,n)=>{"use strict";n.d(t,{ToolbarMenuButton:()=>d});var o=n(50959),r=n(39416),i=n(50238),s=n(99247),l=n(54374),a=n(73607);const c=(0,o.forwardRef)((function(e,t){const{tooltip:n,tag:i,buttonRef:s,reference:c,...d}=e,u=(0,r.useFunctionalRefObject)(c??null);return o.createElement(l.ToolWidgetMenu,{"aria-label":n,...d,ref:t,tag:i??"button",reference:s??u,"data-tooltip":n,onMenuKeyDown:a.handleAccessibleMenuKeyDown,onMenuFocus:e=>(0,a.handleAccessibleMenuFocus)(e,s??u)})})),d=(0,o.forwardRef)((function(e,t){const{tooltip:n,menuReference:l=null,...a}=e,[d,u]=(0,i.useRovingTabindexElement)(null),h=(0,r.useFunctionalRefObject)(l);return o.createElement(c,{"aria-label":n,"aria-haspopup":"menu",...s.MouseClickAutoBlurHandler.attributes(),...a,ref:t,tag:"button",buttonRef:d,tabIndex:u,menuReference:h,tooltip:n})}))},26981:(e,t,n)=>{"use strict";n.d(t,{Toolbar:()=>u});var o=n(50959),r=n(50151),i=n(47201),s=n(3343),l=n(22692),a=n(33647),c=n(39416),d=n(99247);const u=(0,o.forwardRef)((function(e,t){const{onKeyDown:n,orientation:u,blurOnEscKeydown:h=!0,blurOnClick:f=!0,...p}=e,g=(0,c.useFunctionalRefObject)(t);return(0,o.useLayoutEffect)((()=>{const e=(0,r.ensureNotNull)(g.current),t=()=>{
const t=(0,l.queryTabbableElements)(e).sort(l.navigationOrderComparator);if(0===t.length){const[t]=(0,l.queryFocusableElements)(e).sort(l.navigationOrderComparator);if(void 0===t)return;(0,a.becomeMainElement)(t)}if(t.length>1){const[,...e]=t;for(const t of e)(0,a.becomeSecondaryElement)(t)}};return window.addEventListener("keyboard-navigation-activation",t),()=>window.removeEventListener("keyboard-navigation-activation",t)}),[]),o.createElement("div",{...d.MouseClickAutoBlurHandler.attributes(f),...p,role:"toolbar","aria-orientation":u,ref:g,onKeyDown:(0,i.createSafeMulticastEventHandler)((function(e){if(e.defaultPrevented)return;if(!(document.activeElement instanceof HTMLElement))return;const t=(0,s.hashFromEvent)(e);if(h&&27===t)return e.preventDefault(),void document.activeElement.blur();if("vertical"!==u&&37!==t&&39!==t)return;if("vertical"===u&&38!==t&&40!==t)return;const n=e.currentTarget,o=(0,l.queryFocusableElements)(n).sort(l.navigationOrderComparator);if(0===o.length)return;const r=o.indexOf(document.activeElement);if(-1===r)return;e.preventDefault();const i=()=>{const e=(r+o.length-1)%o.length;(0,a.becomeSecondaryElement)(o[r]),(0,a.becomeMainElement)(o[e]),o[e].focus()},c=()=>{const e=(r+o.length+1)%o.length;(0,a.becomeSecondaryElement)(o[r]),(0,a.becomeMainElement)(o[e]),o[e].focus()};switch((0,l.mapKeyCodeToDirection)(t)){case"inlinePrev":"vertical"!==u&&i();break;case"inlineNext":"vertical"!==u&&c();break;case"blockPrev":"vertical"===u&&i();break;case"blockNext":"vertical"===u&&c()}}),n),"data-tooltip-show-on-focus":"true"})}))},36296: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>'},69533: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>'},57674: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>'},80465: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>'},94007: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>'},52870: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>'},74059: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>'},91730: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>'},7295: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>'},28824: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>'},49756: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>'},62766: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>'}}]);