"use strict";var D=Object.create;var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var P=Object.getPrototypeOf;var S=Object.prototype.hasOwnProperty;var c=(s,e)=>a(s,"name",{value:e,configurable:true});var R=(s,e)=>{for(var t in e)a(s,t,{get:e[t],enumerable:true})};var w=(s,e,t,o)=>{if(e&&typeof e==="object"||typeof e==="function"){for(let i of E(e))if(!S.call(s,i)&&i!==t)a(s,i,{get:()=>e[i],enumerable:!(o=b(e,i))||o.enumerable})}return s};var v=(s,e,t)=>(t=s!=null?D(P(s)):{},w(e||!s||!s.__esModule?a(t,"default",{value:s,enumerable:true}):t,s));var W=s=>w(a({},"__esModule",{value:true}),s);var f=(s,e,t,o)=>{var i=o>1?void 0:o?b(e,t):e;for(var r=s.length-1,n;r>=0;r--)if(n=s[r])i=(o?n(e,t,i):n(i))||i;if(o&&i)a(e,t,i);return i};var C={};R(C,{default:()=>A});module.exports=W(C);var l=require("react/jsx-runtime");var z=v(require("classnames"));var L=require("mobx-react");var p=require("react");var T=v(require("react-electron-web-view"));var I=v(require("react-jss"));var M=require("../../../config");const x=c(s=>({root:{background:s.colorBackground,position:"relative",borderLeft:[1,"solid",s.todos.todosLayer.borderLeftColor],zIndex:300,transform:({isVisible:e,width:t,isTodosServiceActive:o})=>`translateX(${e||o?0:t}px)`,"& webview":{height:"100%"}},resizeHandler:{position:"absolute",left:0,marginLeft:-5,width:10,zIndex:400,cursor:"col-resize"},dragIndicator:{position:"absolute",left:0,width:5,zIndex:400,background:s.todos.dragIndicator.background},isTodosServiceActive:{width:"calc(100% - 368px)",position:"absolute",right:0,zIndex:0,borderLeftWidth:0},hidden:{borderLeftWidth:0}}),"styles");let d=class extends p.Component{node=(0,p.createRef)();webview;constructor(e){super(e);this.state={isDragging:false,width:300,initialPos:0,delta:0};this.resizePanel=this.resizePanel.bind(this);this.stopResize=this.stopResize.bind(this)}componentDidMount(){this.setState({width:this.props.width});if(this.node.current){this.node.current.addEventListener("mousemove",this.resizePanel);this.node.current.addEventListener("mouseup",this.stopResize);this.node.current.addEventListener("mouseleave",this.stopResize)}}componentWillUnmount(){if(this.node.current){this.node.current.removeEventListener("mousemove",this.resizePanel);this.node.current.removeEventListener("mouseup",this.stopResize);this.node.current.removeEventListener("mouseleave",this.stopResize)}this.stopListeningToIpcMessages()}startResize=e=>{this.setState({isDragging:true,initialPos:e.clientX,delta:0})};resizePanel=e=>{const{minWidth:t}=this.props;const{isDragging:o,initialPos:i}=this.state;if(o&&Math.abs(e.clientX-window.innerWidth)>t){const r=e.clientX-i;this.setState({delta:r})}};stopResize=()=>{const{resize:e,minWidth:t}=this.props;const{isDragging:o,delta:i,width:r}=this.state;if(o){let n=r+(i<0?Math.abs(i):-Math.abs(i));if(n<t){n=t}this.setState({isDragging:false,delta:0,width:n});e(n)}};startListeningToIpcMessages=()=>{if(!this.webview){return}const{handleClientMessage:e}=this.props;this.webview.addEventListener("ipc-message",t=>{e(t.channel,t.args[0])})};stopListeningToIpcMessages=()=>{if(!this.webview){return}const{handleClientMessage:e}=this.props;this.webview.removeEventListener("ipc-message",e)};render(){const{classes:e,isTodosServiceActive:t,isVisible:o,userAgent:i,todoUrl:r,isTodoUrlValid:n}=this.props;const{width:y,delta:g,isDragging:u}=this.state;let m=o?y:0;if(t){m=0}return(0,l.jsxs)("div",{className:(0,z.default)({[e.root]:true,[e.isTodosServiceActive]:t,"todos__todos-panel--expanded":t,[e.hidden]:!o}),style:{width:m},onMouseUp:()=>this.stopResize(),ref:this.node,id:"todos-panel",children:[(0,l.jsx)("div",{className:e.resizeHandler,style:{left:g,...u?{width:600,marginLeft:-200}:{}},onMouseDown:this.startResize}),u&&(0,l.jsx)("div",{className:e.dragIndicator,style:{left:g}}),n&&(0,l.jsx)(T.default,{onDidAttach:()=>{const{setTodosWebview:h}=this.props;h(this.webview);this.startListeningToIpcMessages()},partition:M.TODOS_PARTITION_ID,preload:"./features/todos/preload.js",ref:h=>{this.webview=h?h.view:null},useragent:i,src:r,allowpopups:true})]})}};c(d,"TodosWebview");d=f([L.observer],d);var A=(0,I.default)(x,{injectTheme:true})(d);
