UNPKG

@cinc101/electron-capture

Version:

Electron multi-screen screenshot plugin with annotation and multi-language support.

1 lines 65.1 kB
(()=>{var t={641:t=>{t.exports='\x3c!-- capture.html --\x3e\r\n<!doctype html>\r\n<html lang="en">\r\n<head>\r\n <meta charset="UTF-8"/>\r\n <title>Capture Screen Area</title>\r\n <style>\r\n .panels {\r\n display: flex;\r\n column-gap: 16px;\r\n }\r\n .color-block {\r\n width: 16px;\r\n height: 16px;\r\n cursor: pointer;\r\n box-sizing: border-box;\r\n position: relative;\r\n }\r\n\r\n .color-block::after {\r\n content: \'\';\r\n display: none;\r\n position: absolute;\r\n width: 8px;\r\n height: 8px;\r\n background: #fff;\r\n top: 4px;\r\n left: 4px;\r\n }\r\n\r\n .color-block:hover::after {\r\n display: block;\r\n }\r\n\r\n .color-block.selected::after {\r\n display: block;\r\n }\r\n\r\n .line-dot {\r\n border-radius: 50%;\r\n background: gray;\r\n cursor: pointer;\r\n }\r\n\r\n .line-dot.selected, .line-dot:hover {\r\n background-color: #00b400;\r\n }\r\n\r\n #screenshot-editor-toolbar button {\r\n background: none;\r\n border: none;\r\n cursor: pointer;\r\n width: 20px;\r\n height: 20px;\r\n box-sizing: content-box;\r\n margin-right: 15px;\r\n }\r\n\r\n #screenshot-editor-toolbar button img {\r\n width: 20px;\r\n height: 20px;\r\n }\r\n\r\n #screenshot-editor-toolbar button[disabled] {\r\n cursor: not-allowed;\r\n }\r\n\r\n #screenshot-editor-toolbar button[disabled] img {\r\n filter: grayscale(100%) brightness(1.4);\r\n }\r\n </style>\r\n</head>\r\n<body>\r\n<div\r\n id="overlay"\r\n style="\r\n position: fixed;\r\n top: 0;\r\n left: 0;\r\n width: 100vw;\r\n height: 100vh;\r\n box-sizing: border-box;\r\n background-color: transparent;\r\n "\r\n></div>\r\n<div id="draw-config-panel" style="\r\n position: absolute;\r\n display: none;\r\n background: #fff;\r\n border: 1px solid #ccc;\r\n border-radius: 4px;\r\n padding: 8px;\r\n z-index: 99999;\r\n font-size: 12px;\r\n box-shadow: 0 2px 10px rgba(0,0,0,0.15);\r\n">\r\n <div class="panels">\r\n <div id="lineWidthOptions" style="display: flex; gap: 10px; align-items: center;">\r\n <div class="line-dot" data-width="2" style="width: 7px; height: 7px;"></div>\r\n <div class="line-dot" data-width="4" style="width: 10px; height: 10px;"></div>\r\n <div class="line-dot" data-width="6" style="width: 13px; height: 13px;"></div>\r\n </div>\r\n <div id="colorOptions" style="display: flex; gap: 6px;">\r\n <div class="color-block" data-color="#ff4d4f" style="background: #ff4d4f;"></div>\r\n <div class="color-block" data-color="#fadb14" style="background: #fadb14;"></div>\r\n <div class="color-block" data-color="#1890ff" style="background: #1890ff;"></div>\r\n <div class="color-block" data-color="#52c41a" style="background: #52c41a;"></div>\r\n <div class="color-block" data-color="#000000" style="background: #000000;"></div>\r\n </div>\r\n </div>\r\n</div>\r\n<script>var CaptureApp;(()=>{"use strict";var t={819:t=>{t.exports=require("electron")}},e={};function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var o,i,a,c,l=[],r=!0,d=!1;try{if(a=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;r=!1}else for(;!(r=(o=a.call(n)).done)&&(l.push(o.value),l.length!==e);r=!0);}catch(t){d=!0,i=t}finally{try{if(!r&&null!=n.return&&(c=n.return(),Object(c)!==c))return}finally{if(d)throw i}}return l}}(t,e)||i(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=i(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var o=0,a=function(){};return{s:a,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(t){throw t},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,l=!0,r=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return l=t.done,t},e:function(t){r=!0,c=t},f:function(){try{l||null==n.return||n.return()}finally{if(r)throw c}}}}function i(t,e){if(t){if("string"==typeof t)return a(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=Array(e);n<e;n++)o[n]=t[n];return o}var c,l,r,d,s,u,p,h=function n(o){var i=e[o];if(void 0!==i)return i.exports;var a=e[o]={exports:{}};return t[o](a,a.exports,n),a.exports}(819).ipcRenderer,m=function(t){return"screenshot-plugin/".concat(t)},g="zh",y={zh:{rect:"方框",ellipse:"椭圆",arrow:"箭头",pen:"画笔",mosaic:"马赛克",text:"文字",undo:"撤销",download:"下载",cancel:"退出",confirm:"完成",fontSizeSmall:"小",fontSizeMedium:"中",fontSizeLarge:"大"},en:{rect:"Rectangle",ellipse:"Ellipse",arrow:"Arrow",pen:"Pen",mosaic:"Mosaic",text:"Text",undo:"Undo",download:"Download",cancel:"Cancel",confirm:"Confirm",fontSizeSmall:"Small",fontSizeMedium:"Medium",fontSizeLarge:"Large"}},w=null,f=null,v=!1,b=!1,x=!1,I=null,M=0,C=0,S=null,k=0,z=0,D=!1,T=[],N=!1,W=0,P=0,A=[],L={strokeColor:"#ff4d4f",lineWidth:2,fontSize:18},Y=!1,Z=!1,E=null,H=!1,R=0,j=0,_=null,B=null,J="#07c160",G=null;window.onload=function(){console.log("1111"),v=!0,pt(),ht(),h.send(m("capture-window-ready"))};var X=lt("div","screenshot-editor-toolbar",{position:"absolute",zIndex:99999,background:"#fff",borderRadius:"6px",padding:"10px 0 10px 15px",boxShadow:"0 2px 10px rgba(0,0,0,0.2)",display:"none",color:"#333",fontFamily:"sans-serif",height:"20px",minWidth:"320px",whiteSpace:"nowrap",overflow:"visible"});document.body.appendChild(X);var O=lt("div","text-config-panel",{position:"absolute",zIndex:99999,background:"#fff",border:"1px solid #ccc",padding:"6px 10px",borderRadius:"4px",display:"none",fontSize:"14px"});document.body.appendChild(O),ht();var Q=document.getElementById("overlay"),V=null,U=lt("canvas",null,{position:"fixed",border:"none",zIndex:9999,pointerEvents:"none",display:"block"});U.width=150,U.height=190,document.body.appendChild(U);var F=U.getContext("2d"),q=document.querySelectorAll("#colorOptions .color-block");q.forEach((function(t){t.addEventListener("click",(function(){q.forEach((function(t){return t.classList.remove("selected")})),t.classList.add("selected"),L.strokeColor=t.dataset.color}))}));var K=document.querySelectorAll("#lineWidthOptions .line-dot");function $(){var t=document.getElementById("draw-config-panel");t&&(t.style.display="none")}function tt(){console.log("[capture] exitScreenshot 开始执行"),_&&(_.remove(),_=null,B=null),w&&(w.remove(),w=null,f=null),window._markupContainer&&(window._markupContainer.remove(),window._markupContainer=null),A=[],(T=[]).push(JSON.parse(JSON.stringify(A))),u&&(u.remove(),u=null),U&&(U.style.display="none"),X.style.display="none",window._captureMaskCanvas&&(window._captureMaskCanvas.remove(),window._captureMaskCanvas=null,window._captureMaskCtx=null),Y=!1,Z=!1,H=!1,E="",L={strokeColor:"red",lineWidth:2},b=!1,c=0,l=0,r=0,d=0,window._captureTempData=null,document.body.style.backgroundImage="none",console.log("[capture] DOM 和状态清理完成,准备发送消息"),h.send(m("screenshot-window-unlock")),console.log("[capture] 已发送 screenshot-window-unlock"),setTimeout((function(){console.log("[capture] 准备发送 capture-cancel"),h.send(m("capture-cancel")),console.log("[capture] 已发送 capture-cancel")}),0)}function et(t){var e=window._captureMaskCanvas,n=window._captureMaskCtx;e&&n&&(e.width=window.innerWidth,e.height=window.innerHeight,n.clearRect(0,0,e.width,e.height),n.fillStyle="rgba(0, 0, 0, 0.2)",n.fillRect(0,0,e.width,e.height),n.globalCompositeOperation="destination-out",n.fillStyle="rgba(0, 0, 0, 1)",n.fillRect(t.x,t.y,t.width,t.height),n.globalCompositeOperation="source-over",n.strokeStyle=J||"#409EFF",n.lineWidth=2,n.strokeRect(t.x+1,t.y+1,t.width-2,t.height-2))}function nt(){var t=window._markupContainer;if(t){t.innerHTML="";var e,i=o(A);try{var a=function(){var i=e.value,a=lt("div",null,{position:"absolute",left:"".concat(i.x,"px"),top:"".concat(i.y,"px"),cursor:"move",pointerEvents:"auto"});if(a.className="markup-item",a.setAttribute("draggable","false"),a.dataset.index=A.indexOf(i),a.addEventListener("mousedown",(function(t){t.stopPropagation();var e=a.getBoundingClientRect();(t.clientX<=e.left+6||t.clientX>=e.right-6||t.clientY<=e.top+6||t.clientY>=e.bottom-6)&&(S=a,k=t.clientX-a.offsetLeft,z=t.clientY-a.offsetTop,D=!0)})),"rect"===i.mode)a.style.left="".concat(i.x,"px"),a.style.top="".concat(i.y,"px"),a.style.width="".concat(i.w,"px"),a.style.height="".concat(i.h,"px"),a.style.border="".concat(i.width,"px solid ").concat(i.color),a.style.background="transparent",a.style.pointerEvents="none",a.style.boxSizing="border-box",a.style.cursor="default";else if("ellipse"===i.mode)a.style.width="".concat(i.w,"px"),a.style.height="".concat(i.h,"px"),a.style.border="".concat(i.width,"px solid ").concat(i.color),a.style.borderRadius="50%",a.style.background="transparent",a.style.pointerEvents="none",a.style.boxSizing="border-box",a.style.cursor="default";else if("text"===i.mode)a.textContent=i.text,a.style.font="".concat(i.fontWeight||"400"," ").concat(i.fontSize,"px sans-serif"),a.style.color=i.color,a.style.background="transparent",a.style.padding="2px 4px";else if("arrow"===i.mode){var c=document.createElement("canvas");c.width=window.innerWidth,c.height=window.innerHeight,c.style.cssText="\\n position: absolute;\\n left: 0;\\n top: 0;\\n pointer-events: none;\\n z-index: 9986;\\n ";var l=c.getContext("2d");l.strokeStyle=i.color,l.lineWidth=i.width,rt(l,i.x1,i.y1,i.x2,i.y2,i.color,i.width),t.appendChild(c)}else if("pen"===i.mode){var r=document.createElement("canvas");r.width=window.innerWidth,r.height=window.innerHeight,r.style.cssText="\\n position: absolute;\\n left: 0;\\n top: 0;\\n pointer-events: none;\\n z-index: 9986;\\n ";var d=r.getContext("2d");if(d.strokeStyle=i.color,d.lineWidth=i.width,d.beginPath(),i.path&&i.path.length>0){d.moveTo(i.path[0].x,i.path[0].y);for(var u=1;u<i.path.length;u++)d.lineTo(i.path[u].x,i.path[u].y)}d.stroke(),t.appendChild(r)}else if("mosaic"===i.mode){var p=document.createElement("canvas");p.width=window.innerWidth,p.height=window.innerHeight,p.style.cssText="\\n position: absolute;\\n left: 0;\\n top: 0;\\n pointer-events: none;\\n z-index: 9986;\\n ";var h=p.getContext("2d"),m=window._captureHiddenCtx,g=4*i.width;if(i.path&&m){var y,w=o(i.path);try{for(w.s();!(y=w.n()).done;){var f=y.value,v=Math.floor(f.x*s),b=Math.floor(f.y*s),x=n(m.getImageData(v,b,1,1).data,3),I=x[0],M=x[1],C=x[2];h.fillStyle="rgb(".concat(I,", ").concat(M,", ").concat(C,")"),h.fillRect(f.x-g/2,f.y-g/2,g,g)}}catch(t){w.e(t)}finally{w.f()}}t.appendChild(p)}t.appendChild(a)};for(i.s();!(e=i.n()).done;)a()}catch(t){i.e(t)}finally{i.f()}}}function ot(){var t=document.getElementById("undoBtn");t&&(t.disabled=0===A.length)}function it(t,e){var n=X.getBoundingClientRect(),o=t.offsetHeight||50,i=n.bottom+6,a=n.top-o-6,c=i+o>window.innerHeight?a:i,l=e.offsetLeft,r=n.left+l;t.style.left="".concat(r,"px"),t.style.top="".concat(c,"px")}function at(){var t,e=null===(t=u)||void 0===t?void 0:t.getBoundingClientRect();return e?{x:Math.round(e.left),y:Math.round(e.top),width:Math.round(e.width),height:Math.round(e.height)}:null}function ct(t,e,n,o){var i=X.offsetWidth||200,a=X.offsetHeight||40,c=t+n/2,l=e+o+10;l+a>window.innerHeight&&(l=e-a-10);var r=window.innerWidth-i-10,d=!0;c-i/2<10?(c=10,d=!1):c+i/2>window.innerWidth-10&&(c=r,d=!1),X.style.left="".concat(c,"px"),X.style.top="".concat(l,"px"),X.style.transform=d?"translateX(-50%)":"none"}function lt(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=document.createElement(t);return e&&(o.id=e),Object.assign(o.style,n),o}function rt(t,e,n,o,i,a,c){var l=10+1.5*c,r=Math.atan2(i-n,o-e),d=Math.PI/9,s=o-.5*l*Math.cos(r),u=i-.5*l*Math.sin(r);t.beginPath(),t.moveTo(e,n),t.lineTo(s,u),t.strokeStyle=a,t.lineWidth=c,t.stroke(),t.beginPath(),t.moveTo(o,i),t.lineTo(o-l*Math.cos(r-d),i-l*Math.sin(r-d)),t.lineTo(o-l*Math.cos(r+d),i-l*Math.sin(r+d)),t.closePath(),t.fillStyle=a,t.fill()}function dt(t){var e=5*t,n=document.createElement("canvas");n.width=e,n.height=e;var o=n.getContext("2d");return o.clearRect(0,0,e,e),o.beginPath(),o.arc(e/2,e/2,e/2-2,0,2*Math.PI),o.strokeStyle="rgba(0, 0, 0, 0.7)",o.lineWidth=2,o.stroke(),n.toDataURL("image/png")}function st(){var t=(window._captureTempData||{}).cropRegion,e=window._captureHiddenCanvas;if(!e||!t)return console.warn("缺少截图源或区域"),null;var i=document.createElement("canvas");i.width=t.width,i.height=t.height;var a=i.getContext("2d"),c=t.x*s,l=t.y*s,r=t.width*s,d=t.height*s;return console.log("[截图] 逻辑坐标: (".concat(t.x,", ").concat(t.y,", ").concat(t.width,"x").concat(t.height,")")),console.log("[截图] 物理坐标: (".concat(c,", ").concat(l,", ").concat(r,"x").concat(d,"), scaleFactor: ").concat(s)),a.drawImage(e,c,l,r,d,0,0,t.width,t.height),window._markupContainer&&window._markupContainer.querySelectorAll(".markup-item").forEach((function(e){var i=parseInt(e.dataset.index,10),c=A[i];if(c){var l=c.x-t.x,r=c.y-t.y;if(a.save(),"rect"===c.mode)a.strokeStyle=c.color,a.lineWidth=c.width,a.strokeRect(l,r,c.w,c.h);else if("ellipse"===c.mode)a.strokeStyle=c.color,a.lineWidth=c.width,a.beginPath(),a.ellipse(l+c.w/2,r+c.h/2,c.w/2,c.h/2,0,0,2*Math.PI),a.stroke();else if("text"===c.mode)a.font="".concat(c.fontWeight||"400"," ").concat(c.fontSize,"px sans-serif"),a.fillStyle=c.color,a.fillText(c.text,l,r+c.fontSize);else if("arrow"===c.mode)a.strokeStyle=c.color,a.lineWidth=c.width,rt(a,c.x1-t.x,c.y1-t.y,c.x2-t.x,c.y2-t.y,c.color,c.width);else if("pen"===c.mode){if(a.strokeStyle=c.color,a.lineWidth=c.width,a.beginPath(),c.path&&c.path.length>0){a.moveTo(c.path[0].x-t.x,c.path[0].y-t.y);for(var d=1;d<c.path.length;d++)a.lineTo(c.path[d].x-t.x,c.path[d].y-t.y)}a.stroke()}else if("mosaic"===c.mode){var u=window._captureHiddenCtx,p=4*c.width;if(c.path&&u){var h,m=o(c.path);try{for(m.s();!(h=m.n()).done;){var g=h.value,y=Math.floor(g.x*s),w=Math.floor(g.y*s),f=n(u.getImageData(y,w,1,1).data,3),v=f[0],b=f[1],x=f[2];a.fillStyle="rgb(".concat(v,", ").concat(b,", ").concat(x,")"),a.fillRect(g.x-t.x-p/2,g.y-t.y-p/2,p,p)}}catch(t){m.e(t)}finally{m.f()}}}a.restore()}})),i.toDataURL("image/png")}function ut(){console.log("[capture] handleCompleteCapture 开始执行"),window._captureMaskCanvas&&(window._captureMaskCanvas.remove(),window._captureMaskCanvas=null,window._captureMaskCtx=null),X.style.display="none";var t=(window._captureTempData||{}).cropRegion;if(window._captureHiddenCanvas&&t){var e=st();e&&(console.log("[capture] 图片生成成功,调用 exitScreenshot"),tt(),setTimeout((function(){console.log("[capture] 准备发送 capture-done"),h.send(m("capture-done"),e),console.log("[capture] 已发送 capture-done")}),0))}else console.warn("缺少截图源或区域")}function pt(){var t=G?\'<button data-action="custom" title="\'.concat(G.title,\'"><img src="\').concat(G.icon,\'" /></button>\'):"";X.innerHTML=\'\\n <button data-action="rect" title="\'.concat(y[g].rect,\'"><img src="\').concat("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGNsYXNzPSJpb25pY29uIiB2aWV3Qm94PSIwIDAgNTEyIDUxMiI+PHBhdGggZD0iTTQxNiA0NDhIOTZhMzIuMDkgMzIuMDkgMCAwMS0zMi0zMlY5NmEzMi4wOSAzMi4wOSAwIDAxMzItMzJoMzIwYTMyLjA5IDMyLjA5IDAgMDEzMiAzMnYzMjBhMzIuMDkgMzIuMDkgMCAwMS0zMiAzMnoiIGZpbGw9Im5vbmUiIHN0cm9rZT0iY3VycmVudENvbG9yIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0cm9rZS13aWR0aD0iMzIiLz48L3N2Zz4=",\'" /></button>\\n <button data-action="ellipse" title="\').concat(y[g].ellipse,\'"><img src="\').concat("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGNsYXNzPSJpb25pY29uIiB2aWV3Qm94PSIwIDAgNTEyIDUxMiI+PHBhdGggZD0iTTQ0OCAyNTZjMC0xMDYtODYtMTkyLTE5Mi0xOTJTNjQgMTUwIDY0IDI1NnM4NiAxOTIgMTkyIDE5MiAxOTItODYgMTkyLTE5MnoiIGZpbGw9Im5vbmUiIHN0cm9rZT0iY3VycmVudENvbG9yIiBzdHJva2UtbWl0ZXJsaW1pdD0iMTAiIHN0cm9rZS13aWR0aD0iMzIiLz48L3N2Zz4=",\'" /></button>\\n <button data-action="arrow" title="\').concat(y[g].arrow,\'"><img src="\').concat("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGNsYXNzPSJpb25pY29uIiB2aWV3Qm94PSIwIDAgNTEyIDUxMiI+PHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSI0OCIgZD0iTTExMiAyNDRsMTQ0LTE0NCAxNDQgMTQ0TTI1NiAxMjB2MjkyIi8+PC9zdmc+",\'" /></button>\\n <button data-action="pen" title="\').concat(y[g].pen,\'"><img src="\').concat("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGNsYXNzPSJpb25pY29uIiB2aWV3Qm94PSIwIDAgNTEyIDUxMiI+PHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIzMiIgZD0iTTM2NC4xMyAxMjUuMjVMODcgNDAzbC0yMyA0NSA0NC45OS0yMyAyNzcuNzYtMjc3LjEzLTIyLjYyLTIyLjYyek00MjAuNjkgNjguNjlsLTIyLjYyIDIyLjYyIDIyLjYyIDIyLjYzIDIyLjYyLTIyLjYzYTE2IDE2IDAgMDAwLTIyLjYyaDBhMTYgMTYgMCAwMC0yMi42MiAweiIvPjwvc3ZnPg==",\'" /></button>\\n <button data-action="mosaic" title="\').concat(y[g].mosaic,\'"><img src="\').concat("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGNsYXNzPSJpb25pY29uIiB2aWV3Qm94PSIwIDAgNTEyIDUxMiI+PGNpcmNsZSBjeD0iMjU2IiBjeT0iMTg0IiByPSIxMjAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iY3VycmVudENvbG9yIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBzdHJva2Utd2lkdGg9IjMyIi8+PGNpcmNsZSBjeD0iMzQ0IiBjeT0iMzI4IiByPSIxMjAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iY3VycmVudENvbG9yIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBzdHJva2Utd2lkdGg9IjMyIi8+PGNpcmNsZSBjeD0iMTY4IiBjeT0iMzI4IiByPSIxMjAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iY3VycmVudENvbG9yIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBzdHJva2Utd2lkdGg9IjMyIi8+PC9zdmc+",\'" /></button>\\n <button data-action="text" title="\').concat(y[g].text,\'"><img src="\').concat("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGNsYXNzPSJpb25pY29uIiB2aWV3Qm94PSIwIDAgNTEyIDUxMiI+PHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIzMiIgZD0iTTMyIDQxNS41bDEyMC0zMjAgMTIwIDMyME0yMzAgMzAzLjVINzRNMzI2IDIzOS41YzEyLjE5LTI4LjY5IDQxLTQ4IDc0LTQ4aDBjNDYgMCA4MCAzMiA4MCA4MHYxNDQiLz48cGF0aCBkPSJNMzIwIDM1OC41YzAgMzYgMjYuODYgNTggNjAgNTggNTQgMCAxMDAtMjcgMTAwLTEwNnYtMTVjLTIwIDAtNTggMS05MiA1LTMyLjc3IDMuODYtNjggMTktNjggNTh6IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBzdHJva2Utd2lkdGg9IjMyIi8+PC9zdmc+",\'" /></button>\\n <button data-action="undo" id="undoBtn" title="\').concat(y[g].undo,\'" disabled><img src="\').concat("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGNsYXNzPSJpb25pY29uIiB2aWV3Qm94PSIwIDAgNTEyIDUxMiI+PHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIzMiIgZD0iTTExMiAxNjBsLTY0IDY0IDY0IDY0Ii8+PHBhdGggZD0iTTY0IDIyNGgyOTRjNTguNzYgMCAxMDYgNDkuMzMgMTA2IDEwOHYyMCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIzMiIvPjwvc3ZnPg==",\'" /></button>\\n \').concat(t,\'\\n <button data-action="download" title="\').concat(y[g].download,\'"><img src="\').concat("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGNsYXNzPSJpb25pY29uIiB2aWV3Qm94PSIwIDAgNTEyIDUxMiI+PHBhdGggZD0iTTMzNiAxNzZoNDBhNDAgNDAgMCAwMTQwIDQwdjIwOGE0MCA0MCAwIDAxLTQwIDQwSDEzNmE0MCA0MCAwIDAxLTQwLTQwVjIxNmE0MCA0MCAwIDAxNDAtNDBoNDAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iY3VycmVudENvbG9yIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0cm9rZS13aWR0aD0iMzIiLz48cGF0aCBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBzdHJva2Utd2lkdGg9IjMyIiBkPSJNMTc2IDI3Mmw4MCA4MCA4MC04ME0yNTYgNDh2Mjg4Ii8+PC9zdmc+",\'" /></button>\\n <button data-action="cancel" title="\').concat(y[g].cancel,\'" style="color: red;"><img src="\').concat("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGNsYXNzPSJpb25pY29uIiB2aWV3Qm94PSIwIDAgNTEyIDUxMiI+DQogICAgPHBhdGggZmlsbD0ibm9uZSIgc3Ryb2tlPSIjZmY0ZDRmIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0cm9rZS13aWR0aD0iMzIiDQogICAgICAgICAgZD0iTTQxNiA0MTZMOTYgOTZNNDE2IDk2TDk2IDQxNiIvPg0KPC9zdmc+",\'" /></button>\\n <button data-action="confirm" title="\').concat(y[g].confirm,\'"><img src="\').concat("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj4NCiAgICA8cGF0aCBmaWxsPSJub25lIiBzdHJva2U9ImdyZWVuIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0cm9rZS13aWR0aD0iMzIiDQogICAgICAgICAgZD0iTTQzMiAxNDRMMTc2IDQzMmwtOTYtOTYiLz4NCjwvc3ZnPg0K",\'" /></button>\\n \')}function ht(){var t=y[g];O.innerHTML=\'\\n <div style="display: flex; column-gap: 10px; align-items: center">\\n <label style="margin-right: 12px;">\\n <select id="textFontSize">\\n <option value="14">\'.concat(t.fontSizeSmall,\'</option>\\n <option value="18">\').concat(t.fontSizeMedium,\'</option>\\n <option value="24">\').concat(t.fontSizeLarge,\'</option>\\n </select>\\n </label>\\n <div id="colorOptions" style="display: flex; gap: 6px;">\\n <div class="color-block" data-color="#ff4d4f" style="background: #ff4d4f;"></div>\\n <div class="color-block" data-color="#fadb14" style="background: #fadb14;"></div>\\n <div class="color-block" data-color="#1890ff" style="background: #1890ff;"></div>\\n <div class="color-block" data-color="#52c41a" style="background: #52c41a;"></div>\\n <div class="color-block" data-color="#000000" style="background: #000000;"></div>\\n </div>\\n </div>\\n \'),document.getElementById("textFontSize").value=L.fontSize,document.getElementById("textFontSize").addEventListener("change",(function(t){L.fontSize=parseInt(t.target.value,10)}))}K.forEach((function(t){t.addEventListener("click",(function(){if(K.forEach((function(t){return t.classList.remove("selected")})),t.classList.add("selected"),L.lineWidth=parseInt(t.dataset.width,10),"mosaic"===E){var e=dt(L.lineWidth);document.body.style.cursor="url(".concat(e,") ").concat(2*L.lineWidth," ").concat(2*L.lineWidth,", auto"),u&&(u.style.cursor="url(".concat(e,") ").concat(2*L.lineWidth," ").concat(2*L.lineWidth,", auto"))}}))})),h.on(m("set-main-color"),(function(t,e){"string"==typeof e&&(J=e)})),h.on(m("set-lang"),(function(t,e){y[e]&&(g=e,pt(),ht())})),h.on(m("set-custom-button"),(function(t,e){G=e,pt()})),h.on(m("request-close-screenshot"),(function(){console.log("[capture] 收到主进程的关闭请求,开始清理"),_&&(_.remove(),_=null,B=null),w&&(w.remove(),w=null,f=null),window._markupContainer&&(window._markupContainer.remove(),window._markupContainer=null),A=[],T=[],u&&(u.remove(),u=null),U&&(U.style.display="none"),X.style.display="none",window._captureMaskCanvas&&(window._captureMaskCanvas.remove(),window._captureMaskCanvas=null,window._captureMaskCtx=null),Y=!1,Z=!1,H=!1,E="",L={strokeColor:"red",lineWidth:2},b=!1,c=0,l=0,r=0,d=0,window._captureTempData=null,document.body.style.backgroundImage="none",h.send(m("screenshot-window-unlock")),console.log("[capture] 渲染进程清理完成")})),h.on(m("reset-capture-state"),(function(){if(console.log("[optimize] 快速清理状态(复用窗口)"),_&&(B&&B.clearRect(0,0,_.width,_.height),_.style.display="none"),w&&(f&&f.clearRect(0,0,w.width,w.height),w.style.display="none"),window._markupContainer&&(window._markupContainer.innerHTML="",window._markupContainer.style.display="none"),u&&(u.remove(),u=null),window._captureMaskCanvas){var t=window._captureMaskCtx;t&&t.clearRect(0,0,window._captureMaskCanvas.width,window._captureMaskCanvas.height)}I&&(I.remove(),I=null),document.body.style.backgroundImage="none",document.body.style.backgroundColor="transparent",A=[],T=[],Y=!1,Z=!1,H=!1,D=!1,N=!1,E=null,S=null,c=l=r=d=0,b=!1,X.style.display="none",$(),U&&(U.style.display="none"),console.log("[optimize] ✅ 状态清理完成")})),h.on(m("set-window-index"),(function(t,e){V=e})),h.on(m("set-crop-limit"),(function(t,e){window._captureTempData=window._captureTempData||{},window._captureTempData.cropRegionLimit=e})),h.on(m("highlight-border"),(function(t,e){V===e?(Q.style.border="2px solid ".concat(J),Q.style.background="rgba(0, 0, 0, 0.2)",U&&!Z&&(U.style.display="block")):(Q.style.border="none",Q.style.background="rgba(0, 0, 0, 0.4)",U&&(U.style.display="none"))})),h.on(m("screenshot-lock-state"),(function(t,e){var n=e.locked,o=e.isSelf;x=n&&!o})),h.on(m("display-screenshot"),(function(t,e,n,o){console.log("[optimize] 接收截图数据"),_&&(_.remove(),_=null,B=null),w&&(w.remove(),w=null,f=null),window._markupContainer&&(window._markupContainer.remove(),window._markupContainer=null),s=n,p=o,window._screenshotImage?console.log("[optimize] 复用 Image 对象"):(console.log("[optimize] 创建 Image 对象(首次)"),window._screenshotImage=new Image);var i=window._screenshotImage;u&&(document.body.removeChild(u),u=null),X.style.display="none",$(),c=l=r=d=0;var a=!1,g=function(){if(!a){a=!0,console.log("[optimize] 图片加载完成,设置背景"),document.body.style.backgroundImage="url(".concat(e,")"),document.body.style.backgroundSize="cover",document.body.style.userSelect="none",document.body.style.backgroundColor="transparent";var t=document.createElement("canvas");t.width=i.width,t.height=i.height;var n=t.getContext("2d");n.imageSmoothingEnabled=!1,n.webkitImageSmoothingEnabled=!1,n.mozImageSmoothingEnabled=!1,n.msImageSmoothingEnabled=!1,n.drawImage(i,0,0),window._captureHiddenCanvas=t,window._captureHiddenCtx=n;var o=lt("canvas","maskCanvas",{position:"fixed",left:"0",top:"0",pointerEvents:"none",zIndex:9980,backgroundColor:"transparent"});document.body.appendChild(o),window._captureMaskCanvas=o,window._captureMaskCtx=o.getContext("2d"),U.style.display="block",h.send(m("screenshot-background-ready")),setTimeout((function(){b=!0,console.log("[capture] 窗口交互已就绪")}),100)}};i.onload=g,i.src=e,i.complete&&i.naturalWidth>0&&g()})),document.addEventListener("mousedown",(function(t){var e,n,i;if(v&&0===t.button)if(b){h.send(m("user-interaction-start"));var a,s=o(document.querySelectorAll(".markup-item"));try{for(s.s();!(a=s.n()).done;){var p=a.value,g=p.getBoundingClientRect();if(t.clientX>=g.left&&t.clientX<=g.right&&t.clientY>=g.top&&t.clientY<=g.bottom&&(Math.abs(t.clientX-g.left)<=6||Math.abs(t.clientX-g.right)<=6||Math.abs(t.clientY-g.top)<=6||Math.abs(t.clientY-g.bottom)<=6))return S=p,k=t.clientX-p.offsetLeft,z=t.clientY-p.offsetTop,D=!0,void t.preventDefault()}}catch(t){s.e(t)}finally{s.f()}if(t.target.classList.contains("markup-item"))return S=t.target,k=t.clientX-S.offsetLeft,z=t.clientY-S.offsetTop,D=!0,void t.preventDefault();var y=null===(e=u)||void 0===e||null===(n=e.getBoundingClientRect)||void 0===n?void 0:n.call(e),w=y&&t.clientX>=y.left&&t.clientX<=y.right&&t.clientY>=y.top&&t.clientY<=y.bottom;if(Z&&w&&!E&&0===A.length&&0===t.button)return N=!0,W=t.clientX-y.left,void(P=t.clientY-y.top);if(!t.target.closest("#screenshot-editor-toolbar")&&!t.target.closest("#text-config-panel")&&!(I&&I.contains(t.target)||D)){var f=null===(i=window._captureTempData)||void 0===i?void 0:i.cropRegion,M=t.clientX,C=t.clientY;if("text"===E&&Z&&0===t.button){if(!(M>=f.x&&M<=f.x+f.width&&C>=f.y&&C<=f.y+f.height))return;var _=L.fontSize,G=L.strokeColor,O=lt("input",null,{position:"fixed",left:"".concat(M,"px"),top:"".concat(C,"px"),zIndex:99999,border:"1px solid red",backgroundColor:"transparent",outline:"none",padding:"2px 4px",borderRadius:"4px",caretColor:G,fontWeight:"bold",font:"".concat(L.fontWeight||"400"," ").concat(_,"px sans-serif"),color:G});return O.type="text",document.body.appendChild(O),setTimeout((function(){O.focus()}),0),I=O,O.addEventListener("keydown",(function(t){if("Enter"===t.key){var e=O.value.trim();if(""!==e){var n={mode:"text",x:parseInt(O.style.left,10),y:parseInt(O.style.top,10),text:e,color:O.style.color,fontSize:_,fontWeight:L.fontWeight||"400"};A.push(n),ot(),T.push(JSON.parse(JSON.stringify(A))),B.font="".concat(n.fontWeight||"400"," ").concat(n.fontSize,"px sans-serif"),B.fillStyle=n.color,nt()}O.remove(),I=null}})),void O.addEventListener("blur",(function(){if(!O.value.trim())return O.remove(),void(I=null);var t=O.value.trim(),e={mode:"text",x:parseInt(O.style.left,10),y:parseInt(O.style.top,10),text:t,color:O.style.color,fontSize:L.fontSize,fontWeight:L.fontWeight||"400"};A.push(e),ot(),T.push(JSON.parse(JSON.stringify(A))),B.font="".concat(e.fontWeight||"400"," ").concat(e.fontSize,"px sans-serif"),B.fillStyle=e.color,nt(),O.remove(),I=null}))}if(["rect","ellipse","arrow","pen","mosaic"].includes(E)&&Z){var Q,V=null===(Q=window._captureTempData)||void 0===Q?void 0:Q.cropRegion;if(M>=V.x&&M<=V.x+V.width&&C>=V.y&&C<=V.y+V.height){H=!0;var U=L.lineWidth/2;R=M+U,j=C+U,"pen"!==E&&"mosaic"!==E||(window._currentPenPath=[{x:M,y:C}])}}else if(!Z||0!==t.button){if(x&&0===t.button)return t.preventDefault(),void t.stopPropagation();if(E&&Z){var F,q=null===(F=window._captureTempData)||void 0===F?void 0:F.cropRegion;t.clientX>=q.x&&t.clientX<=q.x+q.width&&t.clientY>=q.y&&t.clientY<=q.y+q.height&&(H=!0,R=t.clientX,j=t.clientY)}else{if(!window._captureMaskCanvas){var K=lt("canvas","maskCanvas",{position:"fixed",left:"0",top:"0",pointerEvents:"none",zIndex:9980,backgroundColor:"transparent"});document.body.appendChild(K),window._captureMaskCanvas=K,window._captureMaskCtx=K.getContext("2d")}var tt;u&&(document.body.removeChild(u),u=null),0===t.button&&(X.style.display="none",$()),0===t.button&&(Y=!0,c=t.clientX,l=t.clientY,r=t.clientX,d=t.clientY,tt=l,u=lt("div","selectionBox",{position:"absolute",left:"".concat(c,"px"),top:"".concat(tt,"px"),border:"2px solid ".concat(J),background:"rgba(255, 255, 255, 0)",zIndex:9982,boxSizing:"border-box",pointerEvents:"none",width:"1px",height:"1px"}),document.body.appendChild(u))}}}}else console.warn("[capture] 窗口尚未准备好接收交互,忽略 mousedown")})),window.addEventListener("mousemove",(function(t){var e;if(v){var i,a=!1,p=o(document.querySelectorAll(".markup-item"));try{for(p.s();!(i=p.n()).done;){var g=i.value.getBoundingClientRect();if(t.clientX>=g.left&&t.clientX<=g.right&&t.clientY>=g.top&&t.clientY<=g.bottom&&(Math.abs(t.clientX-g.left)<=6||Math.abs(t.clientX-g.right)<=6||Math.abs(t.clientY-g.top)<=6||Math.abs(t.clientY-g.bottom)<=6)){document.body.style.cursor="move",a=!0;break}}}catch(t){p.e(t)}finally{p.f()}if(a||"mosaic"===E||(document.body.style.cursor="default"),S){var y,b=null===(y=window._captureTempData)||void 0===y?void 0:y.cropRegion;if(!b)return;var x=t.clientX-k,I=t.clientY-z,D=S.offsetWidth,T=S.offsetHeight;return x=Math.max(b.x,Math.min(b.x+b.width-D,x)),I=Math.max(b.y,Math.min(b.y+b.height-T,I)),S.style.left="".concat(x,"px"),void(S.style.top="".concat(I,"px"))}if(Z&&u&&(t.target.classList.contains("markup-item")?u.style.cursor="default":!E&&0===A.length&&u.contains(t.target)?u.style.cursor="move":u.style.cursor="default"),N&&u){var _,B=(null===(_=window._captureTempData)||void 0===_?void 0:_.cropRegionLimit)||{x:0,y:0,width:window.innerWidth,height:window.innerHeight},G=u.offsetWidth,X=u.offsetHeight,O=t.clientX-W,Q=t.clientY-P;O=Math.max(B.x,Math.min(B.x+B.width-G,O)),Q=Math.max(B.y,Math.min(B.y+B.height-X,Q)),u.style.left="".concat(O,"px"),u.style.top="".concat(Q,"px"),u.style.opacity="0.8",u.style.boxShadow="0 0 0 1px rgba(0,0,0,0.15)",window._captureTempData.cropRegion={x:O,y:Q,width:G,height:X},et(window._captureTempData.cropRegion),ct(O,Q,G,X)}var V={x:t.screenX,y:t.screenY};h.send(m("check-display"),V);var q=window._captureHiddenCanvas,K=window._captureHiddenCtx;if(M=t.clientX,C=t.clientY,q&&K){var $=50,tt=150;U.width=tt,U.height=190,U.style.width="".concat(U.width,"px"),U.style.height="".concat(U.height,"px");var nt=Math.floor(t.clientX),ot=Math.floor(t.clientY),it=Math.floor(nt*s),lt=Math.floor(ot*s),dt=K.getImageData(it-25,lt-25,$,$),st=document.createElement("canvas");st.width=$,st.height=$,st.getContext("2d").putImageData(dt,0,0),F.clearRect(0,0,U.width,U.height),F.imageSmoothingEnabled=!1,F.drawImage(st,0,0,$,$,0,0,tt,tt),F.strokeStyle=J,F.lineWidth=1,F.strokeRect(0,0,tt,tt),F.beginPath(),F.moveTo(75,0),F.lineTo(75,tt),F.moveTo(0,75),F.lineTo(tt,75),F.strokeStyle=J,F.stroke();var ut=window.innerWidth,pt=window.innerHeight,ht=t.clientX+20,mt=t.clientY+20;ht+U.width>ut&&(ht=t.clientX-U.width-20),mt+U.height>pt&&(mt=t.clientY-U.height-20),U.style.left="".concat(ht,"px"),U.style.top="".concat(mt,"px");var gt=function(t,e,o){var i=t.canvas;if(e<0||o<0||e>=i.width||o>=i.height)return{r:0,g:0,b:0,rgb:"rgb(0, 0, 0)",hex:"#000000"};var a=n(t.getImageData(e,o,1,1).data,3),c=a[0],l=a[1],r=a[2],d=function(t){return t>=253?255:t};c=d(c),l=d(l),r=d(r);var s=function(t){return t.toString(16).padStart(2,"0")},u="#".concat(s(c)).concat(s(l)).concat(s(r));return{r:c,g:l,b:r,rgb:"rgb(".concat(c,", ").concat(l,", ").concat(r,")"),hex:u}}(K,it,lt),yt=gt.r,wt=gt.g,ft=gt.b;F.font="14px sans-serif";var vt="x: ".concat(nt,", y: ").concat(ot),bt="rgb(".concat(yt,", ").concat(wt,", ").concat(ft,")"),xt=F.measureText(vt).width,It=F.measureText(bt).width;F.fillStyle="#000",F.fillRect(0,152,xt+8,16),F.fillStyle="#fff",F.fillText(vt,4,164),F.fillStyle="#000",F.fillRect(0,170,It+8,16),F.fillStyle="#fff",F.fillText(bt,4,182)}if(H&&E&&f){var Mt,Ct=null===(Mt=window._captureTempData)||void 0===Mt?void 0:Mt.cropRegion,St=Math.min(Math.max(M,Ct.x),Ct.x+Ct.width),kt=Math.min(Math.max(C,Ct.y),Ct.y+Ct.height),zt=Math.min(R,St),Dt=Math.min(j,kt),Tt=Math.abs(St-R),Nt=Math.abs(kt-j);if(f.clearRect(0,0,w.width,w.height),f.strokeStyle=L.strokeColor,f.lineWidth=L.lineWidth,"rect"===E)f.strokeRect(zt,Dt,Tt,Nt);else if("ellipse"===E)f.beginPath(),f.ellipse(zt+Tt/2,Dt+Nt/2,Tt/2,Nt/2,0,0,2*Math.PI),f.stroke();else if("arrow"===E)rt(f,R,j,St,kt,L.strokeColor,L.lineWidth);else if("pen"===E){var Wt,Pt=null===(Wt=window._captureTempData)||void 0===Wt?void 0:Wt.cropRegion,At=Math.min(Math.max(M,Pt.x),Pt.x+Pt.width),Lt=Math.min(Math.max(C,Pt.y),Pt.y+Pt.height);window._currentPenPath.push({x:At,y:Lt}),f.clearRect(0,0,w.width,w.height),f.strokeStyle=L.strokeColor,f.lineWidth=L.lineWidth,f.beginPath();var Yt=window._currentPenPath;f.moveTo(Yt[0].x,Yt[0].y);for(var Zt=1;Zt<Yt.length;Zt++)f.lineTo(Yt[Zt].x,Yt[Zt].y);f.stroke()}else if("mosaic"===E){for(var Et,Ht=null===(Et=window._captureTempData)||void 0===Et?void 0:Et.cropRegion,Rt=Math.min(Math.max(M,Ht.x),Ht.x+Ht.width),jt=Math.min(Math.max(C,Ht.y),Ht.y+Ht.height),_t=window._currentPenPath[window._currentPenPath.length-1],Bt=Rt-_t.x,Jt=jt-_t.y,Gt=Math.sqrt(Bt*Bt+Jt*Jt),Xt=2*L.lineWidth,Ot=Math.floor(Gt/Xt),Qt=1;Qt<=Ot;Qt++){var Vt=_t.x+Bt*Qt/Ot,Ut=_t.y+Jt*Qt/Ot;window._currentPenPath.push({x:Vt,y:Ut})}window._currentPenPath.push({x:Rt,y:jt}),f.clearRect(0,0,w.width,w.height);var Ft=4*L.lineWidth,qt=window._captureHiddenCtx;if(!qt)return;var Kt,$t=o(window._currentPenPath);try{for($t.s();!(Kt=$t.n()).done;){var te=Kt.value,ee=Math.floor(te.x*s),ne=Math.floor(te.y*s),oe=n(qt.getImageData(ee,ne,1,1).data,3),ie=oe[0],ae=oe[1],ce=oe[2];f.fillStyle="rgb(".concat(ie,", ").concat(ae,", ").concat(ce,")"),f.fillRect(te.x-Ft/2,te.y-Ft/2,Ft,Ft)}}catch(t){$t.e(t)}finally{$t.f()}}}if(Y&&1===t.buttons){var le=(null===(e=window._captureTempData)||void 0===e?void 0:e.cropRegionLimit)||{x:0,y:0,width:window.innerWidth,height:window.innerHeight};r=Math.min(Math.max(t.clientX,le.x),le.x+le.width),d=Math.min(Math.max(t.clientY,le.y),le.y+le.height);var re=Math.min(c,r),de=Math.min(l,d),se=Math.abs(r-c),ue=Math.abs(d-l);u.style.left="".concat(re,"px"),u.style.top="".concat(de,"px"),u.style.width="".concat(se,"px"),u.style.height="".concat(ue,"px"),et(at())}}})),window.addEventListener("mouseup",(function(t){if(v&&0===t.button){if(h.send(m("user-interaction-end")),N=!1,S){var e=parseInt(S.dataset.index,10);isNaN(e)||(A[e].x=parseInt(S.style.left,10),A[e].y=parseInt(S.style.top,10)),S=null,D=!1,T.push(JSON.parse(JSON.stringify(A))),ot()}if(H){var n;H=!1;var o=null===(n=window._captureTempData)||void 0===n?void 0:n.cropRegion,i=L.lineWidth/2,a=Math.min(Math.max(t.clientX,o.x+1),o.x+o.width-1),s=Math.min(Math.max(t.clientY,o.y+1),o.y+o.height-1),g=Math.min(R,a)-i,y=Math.min(j,s)-i,b=Math.abs(a-R)+2*i,x=Math.abs(s-j)+2*i;return"pen"===E?(A.push({mode:"pen",path:window._currentPenPath||[],color:L.strokeColor,width:L.lineWidth}),window._currentPenPath=null):"arrow"===E?A.push({mode:"arrow",x1:R,y1:j,x2:a,y2:s,color:L.strokeColor,width:L.lineWidth}):"mosaic"===E?(A.push({mode:"mosaic",path:window._currentPenPath||[],width:L.lineWidth}),window._currentPenPath=null):A.push({mode:E,x:g,y,w:b,h:x,color:L.strokeColor,width:L.lineWidth}),ot(),nt(),f&&f.clearRect(0,0,w.width,w.height),T.push(JSON.parse(JSON.stringify(A))),void ot()}if(Y){Y=!1,U.style.display="none";var I=at();if(c===r&&l===d);else{window._captureTempData={cropRegion:I,thumbnailSize:p,currentWindowIndex:V};var M=Math.min(c,r),C=Math.min(l,d),k=Math.abs(r-c),z=Math.abs(d-l);if(!_){(_=lt("canvas",null,{position:"fixed",left:"0",top:"0",pointerEvents:"none",zIndex:9985})).id="markupCanvas",_.width=window.innerWidth,_.height=window.innerHeight,document.body.appendChild(_),B=_.getContext("2d");var W=document.createElement("div");W.id="markup-container",W.style.cssText="\\n position: fixed;\\n left: 0;\\n top: 0;\\n width: 100%;\\n height: 100%;\\n z-index: 9986;\\n pointer-events: none;\\n ",document.body.appendChild(W),window._markupContainer=W,w||((w=lt("canvas","previewCanvas",{position:"fixed",left:"0",top:"0",pointerEvents:"none",zIndex:9986})).width=window.innerWidth,w.height=window.innerHeight,document.body.appendChild(w),f=w.getContext("2d"))}X.style.display="block",ct(M,C,k,z),Z=!0,u.style.opacity="",u.style.boxShadow="",h.send(m("force-window-top")),h.send(m("screenshot-window-lock"),V)}}}})),document.addEventListener("contextmenu",(function(t){if(t.preventDefault(),Z){if(A.length>0)return;if(E)return;return Z=!1,u&&(u.remove(),u=null),window._captureMaskCanvas&&(window._captureMaskCanvas.remove(),window._captureMaskCanvas=null,window._captureMaskCtx=null),B&&B.clearRect(0,0,_.width,_.height),X.style.display="none",$(),U.style.display="block",void h.send(m("screenshot-window-unlock"))}tt()})),document.addEventListener("keydown",(function(t){"Escape"===t.key&&tt()})),X.addEventListener("click",(function(t){var e=t.target.closest("button[data-action]");if(e){h.send(m("force-window-top"));var n=e.dataset.action;if("cancel"===n&&(console.log("[capture] cancel 按钮被点击"),tt()),"confirm"===n&&(console.log("[capture] confirm 按钮被点击"),ut()),"text"===n){var o=document.getElementById("text-config-panel");if("text"===E)E=null,o.style.display="none",nt();else{E="text",$(),it(o,e),o.style.display="block";var i=o.querySelectorAll(".color-block");i.forEach((function(t){t.addEventListener("click",(function(){i.forEach((function(t){return t.classList.remove("selected")})),t.classList.add("selected"),L.strokeColor=t.dataset.color}))})),u&&(u.style.cursor="default"),document.getElementById("textFontSize").value=L.fontSize,document.getElementById("textFontSize").addEventListener("change",(function(t){L.fontSize=parseInt(t.target.value,10)}))}}if(["rect","ellipse","arrow","pen","mosaic"].includes(n))if(document.getElementById("text-config-panel").style.display="none",E===n)E=null,$(),nt();else if(E=n,function(t){var e=document.getElementById("draw-config-panel");it(e,t),e.style.display="block";var n=document.getElementById("colorOptions");n&&(n.style.display="mosaic"===E?"none":"flex"),document.querySelectorAll("#colorOptions .color-block").forEach((function(t){t.classList.toggle("selected",t.dataset.color.toLowerCase()===L.strokeColor.toLowerCase())})),document.querySelectorAll("#lineWidthOptions .line-dot").forEach((function(t){t.classList.toggle("selected",parseInt(t.dataset.width)===L.lineWidth)}))}(e),"mosaic"===E){var a=dt(L.lineWidth);document.body.style.cursor="url(".concat(a,") ").concat(2*L.lineWidth," ").concat(2*L.lineWidth,", auto"),u&&(u.style.cursor="url(".concat(a,") ").concat(2*L.lineWidth," ").concat(2*L.lineWidth,", auto"))}else document.body.style.cursor="default",u&&(u.style.cursor="default");if("undo"===n&&T.length>0){T.pop();var c=T[T.length-1]||[];A=JSON.parse(JSON.stringify(c)),nt(),ot()}if("download"===n){var l=st();l&&h.invoke(m("save-capture-image"),{base64Data:l,windowIndex:V}).then((function(t){t?tt():console.log("用户取消保存,保持截图状态")}))}if("custom"===n){console.log("[capture] custom 按钮被点击");var r=st();r&&(console.log("[capture] 图片生成成功,发送 custom-button-click"),h.send(m("custom-button-click"),r),console.log("[capture] 已发送 custom-button-click"))}}})),document.addEventListener("dblclick",(function(t){var e;if(v&&b&&Z){var n=null===(e=window._captureTempData)||void 0===e?void 0:e.cropRegion;if(n){var o=t.clientX,i=t.clientY;o>=n.x&&o<=n.x+n.width&&i>=n.y&&i<=n.y+n.height&&(h.send(m("force-window-top")),ut())}}})),CaptureApp={}})();<\/script></body>\r\n</html>\r\n'},781:(t,e,n)=>{function o(){"use strict";o=function(){return e};var t,e={},n=Object.prototype,r=n.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},c=i.iterator||"@@iterator",l=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function d(t,e,n,o){return Object.defineProperty(t,e,{value:n,enumerable:!o,configurable:!o,writable:!o})}try{d({},"")}catch(t){d=function(t,e,n){return t[e]=n}}function u(e,n,o,r){var i=n&&n.prototype instanceof f?n:f,a=Object.create(i.prototype);return d(a,"_invoke",function(e,n,o){var r=1;return function(i,a){if(3===r)throw Error("Generator is already running");if(4===r){if("throw"===i)throw a;return{value:t,done:!0}}for(o.method=i,o.arg=a;;){var c=o.delegate;if(c){var l=M(c,o);if(l){if(l===h)continue;return l}}if("next"===o.method)o.sent=o._sent=o.arg;else if("throw"===o.method){if(1===r)throw r=4,o.arg;o.dispatchException(o.arg)}else"return"===o.method&&o.abrupt("return",o.arg);r=3;var s=p(e,n,o);if("normal"===s.type){if(r=o.done?4:2,s.arg===h)continue;return{value:s.arg,done:o.done}}"throw"===s.type&&(r=4,o.method="throw",o.arg=s.arg)}}}(e,o,new S(r||[])),!0),a}function p(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=u;var h={};function f(){}function g(){}function y(){}var m={};d(m,c,(function(){return this}));var v=Object.getPrototypeOf,w=v&&v(v(T([])));w&&w!==n&&r.call(w,c)&&(m=w);var b=y.prototype=f.prototype=Object.create(m);function x(t){["next","throw","return"].forEach((function(e){d(t,e,(function(t){return this._invoke(e,t)}))}))}function I(t,e){function n(o,i,c,l){var s=p(t[o],t,i);if("throw"!==s.type){var d=s.arg,u=d.value;return u&&"object"==a(u)&&r.call(u,"__await")?e.resolve(u.__await).then((function(t){n("next",t,c,l)}),(function(t){n("throw",t,c,l)})):e.resolve(u).then((function(t){d.value=t,c(d)}),(function(t){return n("throw",t,c,l)}))}l(s.arg)}var o;d(this,"_invoke",(function(t,r){function i(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(i,i):i()}),!0)}function M(e,n){var o=n.method,r=e.i[o];if(r===t)return n.delegate=null,"throw"===o&&e.i.return&&(n.method="return",n.arg=t,M(e,n),"throw"===n.method)||"return"!==o&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+o+"' method")),h;var i=p(r,e.i,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,h;var a=i.arg;return a?a.done?(n[e.r]=a.value,n.next=e.n,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,h):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,h)}function k(t){this.tryEntries.push(t)}function C(e){var n=e[4]||{};n.type="normal",n.arg=t,e[4]=n}function S(t){this.tryEntries=[[-1]],t.forEach(k,this),this.reset(!0)}function T(e){if(null!=e){var n=e[c];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function n(){for(;++o<e.length;)if(r.call(e,o))return n.value=e[o],n.done=!1,n;return n.value=t,n.done=!0,n};return i.next=i}}throw new TypeError(a(e)+" is not iterable")}return g.prototype=y,d(b,"constructor",y),d(y,"constructor",g),g.displayName=d(y,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,d(t,s,"GeneratorFunction")),t.prototype=Object.create(b),t},e.awrap=function(t){return{__await:t}},x(I.prototype),d(I.prototype,l,(function(){return this})),e.AsyncIterator=I,e.async=function(t,n,o,r,i){void 0===i&&(i=Promise);var a=new I(u(t,n,o,r),i);return e.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},x(b),d(b,s,"Generator"),d(b,c,(function(){return this})),d(b,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var o in e)n.unshift(o);return function t(){for(;n.length;)if((o=n.pop())in e)return t.value=o,t.done=!1,t;return t.done=!0,t}},e.values=T,S.prototype={constructor:S,reset:function(e){if(this.prev=this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(C),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0][4];if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function o(t){a.type="throw",a.arg=e,n.next=t}for(var r=n.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r],a=i[4],c=this.prev,l=i[1],s=i[2];if(-1===i[0])return o("end"),!1;if(!l&&!s)throw Error("try statement without catch or finally");if(null!=i[0]&&i[0]<=c){if(c<l)return this.method="next",this.arg=t,o(l),!0;if(c<s)return o(s),!1}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o[0]>-1&&o[0]<=this.prev&&this.prev<o[2]){var r=o;break}}r&&("break"===t||"continue"===t)&&r[0]<=e&&e<=r[2]&&(r=null);var i=r?r[4]:{};return i.type=t,i.arg=e,r?(this.method="next",this.next=r[2],h):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n[2]===t)return this.complete(n[4],n[3]),C(n),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n[0]===t){var o=n[4];if("throw"===o.type){var r=o.arg;C(n)}return r}}throw Error("illegal catch attempt")},delegateYield:function(e,n,o){return this.delegate={i:T(e),r:n,n:o},"next"===this.method&&(this.arg=t),h}},e}function r(t){return function(t){if(Array.isArray(t))return i(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(t,e):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=Array(e);n<e;n++)o[n]=t[n];return o}function a(t){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}function c(t,e,n,o,r,i,a){try{var c=t[i](a),l=c.value}catch(t){return void n(t)}c.done?e(l):Promise.resolve(l).then(o,r)}function l(t){return function(){var e=this,n=arguments;return new Promise((function(o,r){var i=t.apply(e,n);function a(t){c(i,o,r,a,l,"next",t)}function l(t){c(i,o,r,a,l,"throw",t)}a(void 0)}))}}function s(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,o)}return n}function d(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?s(Object(n),!0).forEach((function(e){u(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function u(t,e,n){return(e=function(t){var e=function(t,e){if("object"!=a(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,e||"default");if("object"!=a(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==a(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}n(928);var p=