@nuniapp/widget 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/index.d.ts +143 -1
- package/dist/index.js +2272 -324
- package/dist/{mark-BeysEAHp.js → mark-B8wojiFu.js} +25 -1
- package/dist/nuni-screenshot.global.js +2 -2
- package/dist/nuni.global.js +177 -8
- package/dist/{screenshot-B2x2-nI_.js → screenshot-DcJ_SzKF.js} +4 -4
- package/package.json +1 -1
|
@@ -32,7 +32,18 @@ const LIMITS = {
|
|
|
32
32
|
unclaimedCommentCap: 500,
|
|
33
33
|
maxOriginsPerProject: 20,
|
|
34
34
|
sessionTtlMs: 2592e6,
|
|
35
|
+
/** CLI and MCP sessions, created by `nuni login`. */
|
|
36
|
+
cliSessionTtlMs: 7776e6,
|
|
37
|
+
/** How long a project transfer link works. */
|
|
38
|
+
transferTtlMs: 6048e5,
|
|
39
|
+
/** Comments changed at once from the dashboard. */
|
|
40
|
+
bulkMax: 100,
|
|
41
|
+
/** How long a `nuni login` code waits for approval in the dashboard. */
|
|
42
|
+
cliLoginTtlMs: 6e5,
|
|
35
43
|
anchorTextMaxLength: 120,
|
|
44
|
+
/** Selected text kept with a text comment, and the context around it. */
|
|
45
|
+
quoteMaxLength: 500,
|
|
46
|
+
quoteContextLength: 32,
|
|
36
47
|
/** Per page, the widget loads this many newest open and resolved comments. */
|
|
37
48
|
pageOpenLimit: 1e3,
|
|
38
49
|
pageResolvedLimit: 200,
|
|
@@ -42,9 +53,22 @@ const LIMITS = {
|
|
|
42
53
|
/** Trimmed outerHTML of the commented element. */
|
|
43
54
|
domSnippetMaxLength: 4e3,
|
|
44
55
|
screenshotMaxBytes: 6e5,
|
|
56
|
+
/** Replies kept per comment thread. */
|
|
57
|
+
repliesPerComment: 200,
|
|
58
|
+
/** Reactions kept per thread (the comment and its replies). */
|
|
59
|
+
reactionsPerComment: 2e3,
|
|
45
60
|
/** How long after posting the author can still attach the screenshot. */
|
|
46
61
|
screenshotUploadWindowMs: 3e5
|
|
47
62
|
};
|
|
63
|
+
/** The reactions anyone can add to a comment or reply. */
|
|
64
|
+
const REACTIONS = [
|
|
65
|
+
"👍",
|
|
66
|
+
"❤️",
|
|
67
|
+
"🎉",
|
|
68
|
+
"👀",
|
|
69
|
+
"✅",
|
|
70
|
+
"😄"
|
|
71
|
+
];
|
|
48
72
|
//#endregion
|
|
49
73
|
//#region ../shared/src/privacy.ts
|
|
50
74
|
/**
|
|
@@ -63,4 +87,4 @@ const MASK_SELECTOR = `[${MASK_ATTRIBUTE}]`;
|
|
|
63
87
|
*/
|
|
64
88
|
const CAPTURE_MARK = Symbol.for("nuni.capture");
|
|
65
89
|
//#endregion
|
|
66
|
-
export {
|
|
90
|
+
export { REACTIONS as a, LIMITS as i, MASK_ATTRIBUTE as n, generateSecret as o, MASK_SELECTOR as r, isProjectId as s, CAPTURE_MARK as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){let e={bodyMaxLength:2e3,nameMaxLength:50,unclaimedCommentCap:500,maxOriginsPerProject:20,sessionTtlMs:2592e6,anchorTextMaxLength:120,pageOpenLimit:1e3,pageResolvedLimit:200,contextEntryMax:20,contextMessageMaxLength:500,domSnippetMaxLength:4e3,screenshotMaxBytes:6e5,screenshotUploadWindowMs:3e5},t=`data-nuni-mask`,n=`[modern-screenshot]`,r=typeof window<`u`,i=r&&`Worker`in window;r&&`atob`in window,r&&`btoa`in window;let a=r?window.navigator?.userAgent:``,o=a.includes(`Chrome`),s=a.includes(`AppleWebKit`)&&!o,c=a.includes(`Firefox`),l=e=>e&&`__CONTEXT__`in e,u=e=>e.constructor.name===`CSSFontFaceRule`,d=e=>e.constructor.name===`CSSImportRule`,f=e=>e.constructor.name===`CSSLayerBlockRule`,p=e=>e.nodeType===1,m=e=>typeof e.className==`object`,h=e=>e.tagName===`image`,g=e=>e.tagName===`use`,_=e=>p(e)&&e.style!==void 0&&!m(e),v=e=>e.nodeType===8,y=e=>e.nodeType===3,b=e=>e.tagName===`IMG`,x=e=>e.tagName===`VIDEO`,S=e=>e.tagName===`CANVAS`,C=e=>e.tagName===`TEXTAREA`,ee=e=>e.tagName===`INPUT`,te=e=>e.tagName===`STYLE`,ne=e=>e.tagName===`SCRIPT`,w=e=>e.tagName===`SELECT`,re=e=>e.tagName===`SLOT`,ie=e=>e.tagName===`IFRAME`,ae=(...e)=>console.warn(n,...e);function oe(e){let t=e?.createElement?.(`canvas`);return t&&(t.height=t.width=1),!!t&&`toDataURL`in t&&!!t.toDataURL(`image/webp`).includes(`image/webp`)}let T=e=>e.startsWith(`data:`);function E(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(r&&e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i)||!r)return e;let n=D().implementation.createHTMLDocument(),i=n.createElement(`base`),a=n.createElement(`a`);return n.head.appendChild(i),n.body.appendChild(a),t&&(i.href=t),a.href=e,a.href}function D(e){return(e&&p(e)?e?.ownerDocument:e)??window.document}let O=`http://www.w3.org/2000/svg`;function se(e,t,n){let r=D(n).createElementNS(O,`svg`);return r.setAttributeNS(null,`width`,e.toString()),r.setAttributeNS(null,`height`,t.toString()),r.setAttributeNS(null,`viewBox`,`0 0 ${e} ${t}`),r}function ce(e,t){let n=new XMLSerializer().serializeToString(e);return t&&(n=n.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu,``)),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`}function le(e,t){return new Promise((n,r)=>{let i=new FileReader;i.onload=()=>n(i.result),i.onerror=()=>r(i.error),i.onabort=()=>r(/* @__PURE__ */ Error(`Failed read blob to ${t}`)),t===`dataUrl`?i.readAsDataURL(e):t===`arrayBuffer`&&i.readAsArrayBuffer(e)})}let ue=e=>le(e,`dataUrl`);function k(e,t){let n=D(t).createElement(`img`);return n.decoding=`sync`,n.loading=`eager`,n.src=e,n}function A(e,t){return new Promise(n=>{let{timeout:r,ownerDocument:i,onError:a,onWarn:o}=t??{},s=typeof e==`string`?k(e,D(i)):e,c=null,l=null;function u(){n(s),c&&clearTimeout(c),l?.()}if(r&&(c=setTimeout(u,r)),x(s)){let e=s.currentSrc||s.src;if(!e)return s.poster?A(s.poster,t).then(n):u();if(s.readyState>=2)return u();let r=u,i=t=>{o?.(`Failed video load`,e,t),a?.(t),u()};l=()=>{s.removeEventListener(`loadeddata`,r),s.removeEventListener(`error`,i)},s.addEventListener(`loadeddata`,r,{once:!0}),s.addEventListener(`error`,i,{once:!0})}else{let e=h(s)?s.href.baseVal:s.currentSrc||s.src;if(!e)return u();let t=async()=>{if(b(s)&&`decode`in s)try{await s.decode()}catch(t){o?.(`Failed to decode image, trying to render anyway`,s.dataset.originalSrc||e,t)}u()},n=t=>{o?.(`Failed image load`,s.dataset.originalSrc||e,t),u()};if(b(s)&&s.complete)return t();l=()=>{s.removeEventListener(`load`,t),s.removeEventListener(`error`,n)},s.addEventListener(`load`,t,{once:!0}),s.addEventListener(`error`,n,{once:!0})}})}async function de(e,t){_(e)&&(b(e)||x(e)?await A(e,t):await Promise.all([`img`,`video`].flatMap(n=>Array.from(e.querySelectorAll(n)).map(e=>A(e,t)))))}let j=/* @__PURE__ */ function(){let e=0,t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)}();function M(e){return e?.split(`,`).map(e=>e.trim().replace(/"|'/g,``).toLowerCase()).filter(Boolean)}let N=0;function fe(e){let t=`${n}[#${N}]`;return N++,{time:n=>e&&console.time(`${t} ${n}`),timeEnd:n=>e&&console.timeEnd(`${t} ${n}`),warn:(...t)=>e&&ae(...t)}}function pe(e){return{cache:e?`no-cache`:`force-cache`}}async function P(e,t){return l(e)?e:me(e,{...t,autoDestruct:!0})}async function me(e,t){let{scale:n=1,workerUrl:a,workerNumber:o=1}=t||{},s=!!t?.debug,c=t?.features??!0,l=e.ownerDocument??(r?window.document:void 0),u=e.ownerDocument?.defaultView??(r?window:void 0),d=/* @__PURE__ */ new Map,f={width:0,height:0,quality:1,type:`image/png`,scale:n,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:3e4,progress:null,debug:s,fetch:{requestInit:pe(t?.fetch?.bypassingCache),placeholderImage:`data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7`,bypassingCache:!1,...t?.fetch},fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:o,onCloneEachNode:null,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:!1,...t,__CONTEXT__:!0,log:fe(s),node:e,ownerDocument:l,ownerWindow:u,dpi:n===1?null:96*n,svgStyleElement:F(l),svgDefsElement:l?.createElementNS(O,`defs`),svgStyles:/* @__PURE__ */ new Map,defaultComputedStyles:/* @__PURE__ */ new Map,workers:[...Array.from({length:i&&a&&o?o:0})].map(()=>{try{let e=new Worker(a);return e.onmessage=async e=>{let{url:t,result:n}=e.data;n?d.get(t)?.resolve?.(n):d.get(t)?.reject?.(/* @__PURE__ */ Error(`Error receiving message from worker: ${t}`))},e.onmessageerror=e=>{let{url:t}=e.data;d.get(t)?.reject?.(/* @__PURE__ */ Error(`Error receiving message from worker: ${t}`))},e}catch(e){return f.log.warn(`Failed to new Worker`,e),null}}).filter(Boolean),fontFamilies:/* @__PURE__ */ new Map,fontCssTexts:/* @__PURE__ */ new Map,acceptOfImage:`${[oe(l)&&`image/webp`,`image/svg+xml`,`image/*`,`*/*`].filter(Boolean).join(`,`)};q=0.8`,requests:d,drawImageCount:0,tasks:[],features:c,isEnable:e=>e===`restoreScrollPosition`?typeof c==`boolean`?!1:c[e]??!1:typeof c==`boolean`?c:c[e]??!0,shadowRoots:[]};f.log.time(`wait until load`),await de(e,{timeout:f.timeout,onWarn:f.log.warn}),f.log.timeEnd(`wait until load`);let{width:p,height:m}=he(e,f);return f.width=p,f.height=m,f}function F(e){if(!e)return;let t=e.createElement(`style`),n=t.ownerDocument.createTextNode(`
|
|
1
|
+
(function(){let e={bodyMaxLength:2e3,nameMaxLength:50,unclaimedCommentCap:500,maxOriginsPerProject:20,sessionTtlMs:2592e6,cliSessionTtlMs:7776e6,transferTtlMs:6048e5,bulkMax:100,cliLoginTtlMs:6e5,anchorTextMaxLength:120,quoteMaxLength:500,quoteContextLength:32,pageOpenLimit:1e3,pageResolvedLimit:200,contextEntryMax:20,contextMessageMaxLength:500,domSnippetMaxLength:4e3,screenshotMaxBytes:6e5,repliesPerComment:200,reactionsPerComment:2e3,screenshotUploadWindowMs:3e5},t=`data-nuni-mask`,n=`[modern-screenshot]`,r=typeof window<`u`,i=r&&`Worker`in window;r&&`atob`in window,r&&`btoa`in window;let a=r?window.navigator?.userAgent:``,o=a.includes(`Chrome`),s=a.includes(`AppleWebKit`)&&!o,c=a.includes(`Firefox`),l=e=>e&&`__CONTEXT__`in e,u=e=>e.constructor.name===`CSSFontFaceRule`,d=e=>e.constructor.name===`CSSImportRule`,f=e=>e.constructor.name===`CSSLayerBlockRule`,p=e=>e.nodeType===1,m=e=>typeof e.className==`object`,h=e=>e.tagName===`image`,g=e=>e.tagName===`use`,_=e=>p(e)&&e.style!==void 0&&!m(e),v=e=>e.nodeType===8,y=e=>e.nodeType===3,b=e=>e.tagName===`IMG`,x=e=>e.tagName===`VIDEO`,S=e=>e.tagName===`CANVAS`,C=e=>e.tagName===`TEXTAREA`,ee=e=>e.tagName===`INPUT`,te=e=>e.tagName===`STYLE`,ne=e=>e.tagName===`SCRIPT`,w=e=>e.tagName===`SELECT`,re=e=>e.tagName===`SLOT`,ie=e=>e.tagName===`IFRAME`,ae=(...e)=>console.warn(n,...e);function oe(e){let t=e?.createElement?.(`canvas`);return t&&(t.height=t.width=1),!!t&&`toDataURL`in t&&!!t.toDataURL(`image/webp`).includes(`image/webp`)}let T=e=>e.startsWith(`data:`);function E(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(r&&e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i)||!r)return e;let n=D().implementation.createHTMLDocument(),i=n.createElement(`base`),a=n.createElement(`a`);return n.head.appendChild(i),n.body.appendChild(a),t&&(i.href=t),a.href=e,a.href}function D(e){return(e&&p(e)?e?.ownerDocument:e)??window.document}let O=`http://www.w3.org/2000/svg`;function se(e,t,n){let r=D(n).createElementNS(O,`svg`);return r.setAttributeNS(null,`width`,e.toString()),r.setAttributeNS(null,`height`,t.toString()),r.setAttributeNS(null,`viewBox`,`0 0 ${e} ${t}`),r}function ce(e,t){let n=new XMLSerializer().serializeToString(e);return t&&(n=n.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu,``)),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`}function le(e,t){return new Promise((n,r)=>{let i=new FileReader;i.onload=()=>n(i.result),i.onerror=()=>r(i.error),i.onabort=()=>r(/* @__PURE__ */ Error(`Failed read blob to ${t}`)),t===`dataUrl`?i.readAsDataURL(e):t===`arrayBuffer`&&i.readAsArrayBuffer(e)})}let ue=e=>le(e,`dataUrl`);function k(e,t){let n=D(t).createElement(`img`);return n.decoding=`sync`,n.loading=`eager`,n.src=e,n}function A(e,t){return new Promise(n=>{let{timeout:r,ownerDocument:i,onError:a,onWarn:o}=t??{},s=typeof e==`string`?k(e,D(i)):e,c=null,l=null;function u(){n(s),c&&clearTimeout(c),l?.()}if(r&&(c=setTimeout(u,r)),x(s)){let e=s.currentSrc||s.src;if(!e)return s.poster?A(s.poster,t).then(n):u();if(s.readyState>=2)return u();let r=u,i=t=>{o?.(`Failed video load`,e,t),a?.(t),u()};l=()=>{s.removeEventListener(`loadeddata`,r),s.removeEventListener(`error`,i)},s.addEventListener(`loadeddata`,r,{once:!0}),s.addEventListener(`error`,i,{once:!0})}else{let e=h(s)?s.href.baseVal:s.currentSrc||s.src;if(!e)return u();let t=async()=>{if(b(s)&&`decode`in s)try{await s.decode()}catch(t){o?.(`Failed to decode image, trying to render anyway`,s.dataset.originalSrc||e,t)}u()},n=t=>{o?.(`Failed image load`,s.dataset.originalSrc||e,t),u()};if(b(s)&&s.complete)return t();l=()=>{s.removeEventListener(`load`,t),s.removeEventListener(`error`,n)},s.addEventListener(`load`,t,{once:!0}),s.addEventListener(`error`,n,{once:!0})}})}async function de(e,t){_(e)&&(b(e)||x(e)?await A(e,t):await Promise.all([`img`,`video`].flatMap(n=>Array.from(e.querySelectorAll(n)).map(e=>A(e,t)))))}let j=/* @__PURE__ */ function(){let e=0,t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)}();function M(e){return e?.split(`,`).map(e=>e.trim().replace(/"|'/g,``).toLowerCase()).filter(Boolean)}let N=0;function fe(e){let t=`${n}[#${N}]`;return N++,{time:n=>e&&console.time(`${t} ${n}`),timeEnd:n=>e&&console.timeEnd(`${t} ${n}`),warn:(...t)=>e&&ae(...t)}}function pe(e){return{cache:e?`no-cache`:`force-cache`}}async function P(e,t){return l(e)?e:me(e,{...t,autoDestruct:!0})}async function me(e,t){let{scale:n=1,workerUrl:a,workerNumber:o=1}=t||{},s=!!t?.debug,c=t?.features??!0,l=e.ownerDocument??(r?window.document:void 0),u=e.ownerDocument?.defaultView??(r?window:void 0),d=/* @__PURE__ */ new Map,f={width:0,height:0,quality:1,type:`image/png`,scale:n,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:3e4,progress:null,debug:s,fetch:{requestInit:pe(t?.fetch?.bypassingCache),placeholderImage:`data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7`,bypassingCache:!1,...t?.fetch},fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:o,onCloneEachNode:null,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:!1,...t,__CONTEXT__:!0,log:fe(s),node:e,ownerDocument:l,ownerWindow:u,dpi:n===1?null:96*n,svgStyleElement:F(l),svgDefsElement:l?.createElementNS(O,`defs`),svgStyles:/* @__PURE__ */ new Map,defaultComputedStyles:/* @__PURE__ */ new Map,workers:[...Array.from({length:i&&a&&o?o:0})].map(()=>{try{let e=new Worker(a);return e.onmessage=async e=>{let{url:t,result:n}=e.data;n?d.get(t)?.resolve?.(n):d.get(t)?.reject?.(/* @__PURE__ */ Error(`Error receiving message from worker: ${t}`))},e.onmessageerror=e=>{let{url:t}=e.data;d.get(t)?.reject?.(/* @__PURE__ */ Error(`Error receiving message from worker: ${t}`))},e}catch(e){return f.log.warn(`Failed to new Worker`,e),null}}).filter(Boolean),fontFamilies:/* @__PURE__ */ new Map,fontCssTexts:/* @__PURE__ */ new Map,acceptOfImage:`${[oe(l)&&`image/webp`,`image/svg+xml`,`image/*`,`*/*`].filter(Boolean).join(`,`)};q=0.8`,requests:d,drawImageCount:0,tasks:[],features:c,isEnable:e=>e===`restoreScrollPosition`?typeof c==`boolean`?!1:c[e]??!1:typeof c==`boolean`?c:c[e]??!0,shadowRoots:[]};f.log.time(`wait until load`),await de(e,{timeout:f.timeout,onWarn:f.log.warn}),f.log.timeEnd(`wait until load`);let{width:p,height:m}=he(e,f);return f.width=p,f.height=m,f}function F(e){if(!e)return;let t=e.createElement(`style`),n=t.ownerDocument.createTextNode(`
|
|
2
2
|
.______background-clip--text {
|
|
3
3
|
background-clip: text;
|
|
4
4
|
-webkit-background-clip: text;
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
`)} {
|
|
12
12
|
${n}
|
|
13
13
|
}
|
|
14
|
-
`}),o.appendChild(r.createTextNode(e))}i.timeEnd(`clone node`),await f?.(_),l!==!1&&p(_)&&(i.time(`embed web font`),await Be(_,n),i.timeEnd(`embed web font`)),i.time(`embed node`),J(_,n);let v=a.length,y=0,b=async()=>{for(;;){let e=a.pop();if(!e)break;try{await e}catch(e){n.log.warn(`Failed to run task`,e)}u?.(++y,v)}};u?.(y,v),await Promise.all([...Array.from({length:4})].map(b)),i.timeEnd(`embed node`),await h?.(_);let x=Je(_,n);return s&&x.insertBefore(s,x.children[0]),o&&x.insertBefore(o,x.children[0]),d&&U(n),await g?.(x),x}function Je(e,t){let{width:n,height:r}=t,i=se(n,r,e.ownerDocument),a=i.ownerDocument.createElementNS(i.namespaceURI,`foreignObject`);return a.setAttributeNS(null,`x`,`0%`),a.setAttributeNS(null,`y`,`0%`),a.setAttributeNS(null,`width`,`100%`),a.setAttributeNS(null,`height`,`100%`),a.append(e),i.appendChild(a),i}async function Ye(e,t){let n=await P(e,t),r=await qe(n),i=ce(r,n.isEnable(`removeControlCharacter`));return n.autoDestruct||(n.svgStyleElement=F(n.ownerDocument),n.svgDefsElement=n.ownerDocument?.createElementNS(O,`defs`),n.svgStyles.clear()),await ge(k(i,r.ownerDocument),n)}let Xe=Symbol.for(`nuni.capture`),Q=4096,Ze=/* @__PURE__ */ new Set([`text`,`file`,`email`,`tel`,`url`,`search`,`password`,`number`,`date`,`datetime-local`,`month`,`week`,`time`]),$=e=>({left:e.left-48,top:e.top-48,right:e.right+48,bottom:e.bottom+48});function Qe(e){let t=e.ownerDocument,n=$(e.getBoundingClientRect()),r=e;for(;r.parentElement&&r.parentElement!==t.body;){let e=r.getBoundingClientRect();if(e.left<=n.left&&e.top<=n.top&&e.right>=n.right&&e.bottom>=n.bottom)break;r=r.parentElement}return r}function $e(e,t){let{display:
|
|
14
|
+
`}),o.appendChild(r.createTextNode(e))}i.timeEnd(`clone node`),await f?.(_),l!==!1&&p(_)&&(i.time(`embed web font`),await Be(_,n),i.timeEnd(`embed web font`)),i.time(`embed node`),J(_,n);let v=a.length,y=0,b=async()=>{for(;;){let e=a.pop();if(!e)break;try{await e}catch(e){n.log.warn(`Failed to run task`,e)}u?.(++y,v)}};u?.(y,v),await Promise.all([...Array.from({length:4})].map(b)),i.timeEnd(`embed node`),await h?.(_);let x=Je(_,n);return s&&x.insertBefore(s,x.children[0]),o&&x.insertBefore(o,x.children[0]),d&&U(n),await g?.(x),x}function Je(e,t){let{width:n,height:r}=t,i=se(n,r,e.ownerDocument),a=i.ownerDocument.createElementNS(i.namespaceURI,`foreignObject`);return a.setAttributeNS(null,`x`,`0%`),a.setAttributeNS(null,`y`,`0%`),a.setAttributeNS(null,`width`,`100%`),a.setAttributeNS(null,`height`,`100%`),a.append(e),i.appendChild(a),i}async function Ye(e,t){let n=await P(e,t),r=await qe(n),i=ce(r,n.isEnable(`removeControlCharacter`));return n.autoDestruct||(n.svgStyleElement=F(n.ownerDocument),n.svgDefsElement=n.ownerDocument?.createElementNS(O,`defs`),n.svgStyles.clear()),await ge(k(i,r.ownerDocument),n)}let Xe=Symbol.for(`nuni.capture`),Q=4096,Ze=/* @__PURE__ */ new Set([`text`,`file`,`email`,`tel`,`url`,`search`,`password`,`number`,`date`,`datetime-local`,`month`,`week`,`time`]),$=e=>({left:e.left-48,top:e.top-48,right:e.right+48,bottom:e.bottom+48});function Qe(e){let t=e.ownerDocument,n=$(e.getBoundingClientRect()),r=e;for(;r.parentElement&&r.parentElement!==t.body;){let e=r.getBoundingClientRect();if(e.left<=n.left&&e.top<=n.top&&e.right>=n.right&&e.bottom>=n.bottom)break;r=r.parentElement}return r}function $e(e,t,n){let{display:r}=getComputedStyle(e),i=r===`block`||r===`list-item`,a=e.getAttribute(`style`);i&&e.setAttribute(`style`,`${a?`${a};`:``}display: flow-root !important`);try{let r=e.getBoundingClientRect(),i=n?.()??t.getBoundingClientRect(),a=$(i);return{box:r,target:i,masks:tt(e),crop:{left:Math.max(r.left,a.left),top:Math.max(r.top,a.top),right:Math.min(r.right,a.right),bottom:Math.min(r.bottom,a.bottom)}}}finally{i&&(a===null?e.removeAttribute(`style`):e.setAttribute(`style`,a))}}function et(e){let t=e.getBoundingClientRect(),n=getComputedStyle(e),r=e=>parseFloat(e)||0;return{left:t.left+r(n.borderLeftWidth)+r(n.paddingLeft),top:t.top+r(n.borderTopWidth)+r(n.paddingTop),right:t.right-r(n.borderRightWidth)-r(n.paddingRight),bottom:t.bottom-r(n.borderBottomWidth)-r(n.paddingBottom)}}function tt(e){let n=[],r=e.querySelectorAll(`input, textarea, select, [${t}]`),i=e.closest(`[${t}]`);if(i)return[i.getBoundingClientRect()];for(let t of[e,...Array.from(r)]){if(t.hasAttribute(`data-nuni-mask`)){n.push(t.getBoundingClientRect());continue}let e=t.tagName;(t instanceof HTMLInputElement&&Ze.has(t.type)||e===`TEXTAREA`||e===`SELECT`)&&n.push(et(t))}return n}function nt(e,t,n){return new Promise(r=>e.toBlob(r,t,n))}window.__nuniScreenshot=async(t,n)=>{let r=Qe(t),{box:i,target:a,masks:o,crop:s}=$e(r,t,n.focus),c=s.right-s.left,l=s.bottom-s.top;if(c<1||l<1)return null;let u=Math.min(window.devicePixelRatio||1,1280/c,1600/l,Q/i.width,Q/i.height),d=getComputedStyle(t.ownerDocument.body).backgroundColor||`rgb(255, 255, 255)`,f=await Ye(r,{width:i.width,height:i.height,scale:u,backgroundColor:d===`rgba(0, 0, 0, 0)`?`rgb(255, 255, 255)`:d,filter:e=>e!==n.exclude,timeout:8e3,fetch:{requestInit:{cache:`force-cache`,[Xe]:!0}}}),p=t.ownerDocument.createElement(`canvas`);p.width=Math.max(1,Math.round(c*u)),p.height=Math.max(1,Math.round(l*u));let m=p.getContext(`2d`);if(!m)return null;m.drawImage(f,(s.left-i.left)*u,(s.top-i.top)*u,p.width,p.height,0,0,p.width,p.height);let h=e=>({x:(e.left-s.left)*u,y:(e.top-s.top)*u,w:(e.right-e.left)*u,h:(e.bottom-e.top)*u});m.fillStyle=`#a1a1aa`;for(let e of o){let{x:t,y:n,w:r,h:i}=h(e);r>0&&i>0&&m.fillRect(t,n,r,i)}let g=Math.max(2,3*u),_=g/2,v=4*u,y=h(a),b=Math.max(_,y.x-v),x=Math.max(_,y.y-v),S=Math.min(p.width-_,y.x+y.w+v),C=Math.min(p.height-_,y.y+y.h+v);m.strokeStyle=n.accent,m.lineWidth=g,S>b&&C>x&&m.strokeRect(b,x,S-b,C-x);for(let[t,n]of[[`image/webp`,.82],[`image/jpeg`,.8],[`image/jpeg`,.55]]){let r=await nt(p,t,n);if(r&&r.type===t&&r.size<=e.screenshotMaxBytes)return r}return null}})();
|