page-harness 0.1.3 → 0.1.4

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.
@@ -1,4 +1,4 @@
1
- (function(){var e=[`bolder`,`quieter`,`polish`,`typeset`,`colorize`,`layout`,`distill`,`adapt`,`animate`,`delight`,`overdrive`,`freeform`],t=/^(padding|margin)(-|$)/;function n(e){return e.trim().replace(/\s+/g,` `)}function r(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1)}…`:n}function i(e){return/(?:^|[\s>+~])(?:ul|ol)(?![a-z-])/i.test(e)}function a(e){let t=n(e),r=t.match(/^(.*?)\s*(?:>\s*)?li(?![a-z-])/i);return r&&i(r[1])?n(r[1]):i(t)&&!/(?:^|[\s>+~])li(?![a-z-])/i.test(t)?t:null}function o(e,t){let r=n(e),i=n(t);if(!r||r===i||!i.startsWith(r))return!1;let a=i.charAt(r.length);return a===` `||a===`>`||a===`+`||a===`~`}function s(e){if(e.kind!==`patch`||!e.patch||e.patch.text!==void 0||e.patch.attrs)return!1;let n=Object.keys(e.patch.style??{});return n.length>0&&n.every(e=>t.test(e))}function c(e){if(e?.style)return Object.entries(e.style).map(([e,t])=>`${e}: ${t}`).join(`; `)||void 0}function l(e){let t={selector:e.selector},n=c(e.patch);return n&&(t.css=n),e.patch?.text!==void 0&&(t.text=e.anchor?.text?`${e.anchor.text} → ${e.patch.text}`:e.patch.text),e.patch?.attrs?.src&&(t.image=e.patch.attrs.src.startsWith(`data:`)?`(uploaded image)`:e.patch.attrs.src),t}function u(e){return e.patch?.style??{}}function d(e){let t=e.anchor?.text?.trim();if(t)return`「${r(t,42)}」这一块`;let n=(e.anchor?.tag||``).toLowerCase();if(n===`img`||/(?:^|[\s>+~])img(?![a-z-])/i.test(e.selector))return`这张照片`;if(/^h[1-6]$/.test(n)||/(?:^|[\s>+~])h[1-6](?![a-z-])/i.test(e.selector))return`这个标题`;let i=e.label?.replace(/^[a-z0-9-]+\s*/i,``).replace(/^"|"$/g,``).trim();return i?`「${r(i,42)}」这一块`:`页面上标出的这一块`}function f(e){return(e.anchor?.tag||``).toLowerCase()===`img`||/(?:^|[\s>+~])img(?![a-z-])/i.test(e.selector)||!!e.patch?.attrs?.src}function p(e){return/^h[1-6]$/i.test(e.anchor?.tag||``)||/(?:^|[\s>+~])h[1-6](?![a-z-])/i.test(e.selector)}function m(e){let t=e.map(e=>`${e.anchor?.text??``} ${e.label??``} ${e.note??``}`).join(` `);return/书目|书单|bibliography|\bC\+\+|Tour of|Programming:/i.test(t)}function h(e){let t=u(e),n=Object.values(t).join(` `),r=/#fff\b|#ffffff|white|rgb\(\s*255\s*,\s*255\s*,\s*255/i.test(n),i=!!(t.border||t[`border-width`]||t[`border-style`]||t[`border-color`]),a=/rotate\(\s*(-?[\d.]+)\s*deg/i.exec(t.transform||n),o=a?Number(a[1]):0,s=!!t[`box-shadow`],c=[];i&&c.push(r?`加上一圈白边`:`加上了边框`),a&&o<-.2?c.push(`微微向左倾斜`):a&&o>.2&&c.push(`微微向右倾斜`),s&&c.push(`底下多了一层阴影`);let l=r&&i&&!!a&&s,d=c.length?`这张照片${c.join(`,`)}${l?`,看起来像一张放在桌上的拍立得`:``}。`:`这张照片的外观改了,改前和改后的样子在下面。`,f=`照片的外观改了`;return l?f=`照片改成斜放的拍立得`:r&&i&&a?f=`照片加上白边并斜放`:c[0]&&(f=`照片${c[0]}`),{title:f,say:d}}function g(e){let t=e.anchor?.text?.trim(),n=e.patch?.text?.trim(),i=u(e)[`font-style`]===`italic`,a=!!t?.endsWith(`!`)&&!!n&&!n.endsWith(`!`),o=p(e)?`标题`:`这段文字`,s=[];return t&&n&&t!==n?s.push(`从「${r(t,80)}」改成了「${r(n,80)}」`):n&&s.push(`改成了「${r(n,80)}」`),i&&s.push(s.length?`并改成斜体`:`改成了斜体`),a&&s.push(`感叹号去掉了`),s.length?{title:i&&a?`${o}改成斜体,并去掉感叹号`:i?`${o}改成斜体`:a?`${o}去掉感叹号`:o===`标题`?`标题文字改了`:`这段文字改了`,say:`${o}${s.join(`,`)}。`}:x(e)}var _=[`零`,`一`,`两`,`三`,`四`,`五`,`六`,`七`,`八`,`九`,`十`],v=e=>e>=1&&e<=10?_[e]:String(e);function y(e){if(!e)return NaN;let t=parseFloat(e);return Number.isFinite(t)?t:NaN}function b(e){let t=m(e)?`书目`:`列表`,r=e.map(e=>{let t=Number(/nth-(?:child|of-type)\((\d+)\)/i.exec(e.selector)?.[1]??NaN),n=u(e);return{n:t,px:y(n[`font-size`]),border:!!(n[`border-bottom`]||n[`border-bottom-width`]),bold:Number(n[`font-weight`])>=600||/bold/i.test(n[`font-weight`]||``)}}).filter(e=>!Number.isNaN(e.n)&&!Number.isNaN(e.px)).sort((e,t)=>e.n-t.n),i=+!!r.length;for(let e=1;e<r.length&&r[e].px<r[e-1].px-.5;e++)i=e+1;let o=r.find(e=>e.border),s=o?r.indexOf(o)+1:i,c=r.slice(s).some(e=>e.bold),l=e.find(e=>a(e.selector)===n(e.selector)),d=[`整段${t}${/none/i.test(u(l??e[0])[`list-style`]||u(l??e[0])[`list-style-type`]||``)?`不再是同一号字的圆点列表`:`的字号层次改了`}`];return s>=2&&d.push(`前${v(s)}项由大到小排开`),o&&d.push(`第${v(o.n)}项下面加了一条线`),c&&d.push(`后面的项改成同一号的加粗字`),{title:s>=2?`${t}改成由大到小的字号阶梯`:`${t}的外观改了`,say:`${d.join(`,`)}。`}}function x(e){let t=u(e),n=[];t[`font-style`]===`italic`&&n.push(`改成了斜体`),(Number(t[`font-weight`])>=600||/bold/i.test(t[`font-weight`]||``))&&n.push(`改成了粗体`),t[`font-size`]&&n.push(`字号改成 ${t[`font-size`].replace(`px`,` 像素`)}`),t[`font-family`]&&n.push(`换了一套字体`),t.color&&n.push(`文字颜色改了`),(t[`background-color`]||t.background)&&n.push(`背景改了`),t[`border-radius`]&&n.push(`圆角改了`),(t.border||t[`border-color`])&&n.push(`边框改了`),(t[`text-decoration`]||t[`text-decoration-line`])&&n.push(`文字装饰改了`),t.opacity&&n.push(`透明度改了`);let r=d(e);return n.length?{title:`这一块的外观改了`,say:`${r}${n.join(`,`)}。`}:{title:`这一块的外观改了`,say:`${r}的外观改了,差别看下面的改前和改后。`}}function S(e){let t=e.note.trim();return{title:r(t.split(/[。.!!?\n]/)[0]?.trim()||`文字意见`,36),say:t,where:`关于${d(e)}`}}function C(e,t){if(t)return b(e);let n=e[0];return!n||n.kind===`note`?S(n):n.patch?.text===void 0?f(n)?h(n):x(n):g(n)}function w(e,t,r){let i=r?a(e[0].selector):null,o=r?e.find(e=>n(e.selector)===i)??[...e].sort((e,t)=>e.selector.length-t.selector.length||e.n-t.n)[0]:e[0],s=C(e,r),c=[...e].sort((e,t)=>e.n-t.n),u=[...c,...t].map(l);return{id:o.id,n:o.n,kind:o.kind,path:o.path,primary:o,members:c,extras:t,title:s.title,say:s.say,...s.where?{where:s.where}:{},status:e.every(e=>e.status===`resolved`)?`resolved`:`open`,authorName:o.author?.name||``,lines:u}}function T(e){let t=new Map;for(let n of e){let e=a(n.selector);if(!e)continue;let r=e;t.set(r,[...t.get(r)??[],n])}return[...t.values()].filter(e=>e.length>=2)}function E(e){let t=[...new Set(e.map(e=>e.path))],n=[];for(let r of t){let t=e.filter(e=>e.path===r),i=t.filter(e=>e.kind!==`patch`||!e.patch),a=t.filter(e=>e.kind===`patch`&&e.patch),c=T(a),l=new Set(c.flat().map(e=>e.id)),u=a.filter(e=>!l.has(e.id)),d=new Set(u.filter(e=>s(e)&&u.some(t=>t!==e&&o(e.selector,t.selector))||s(e)&&c.some(t=>t.some(t=>o(e.selector,t.selector)))).map(e=>e.id)),f=u.filter(e=>d.has(e.id)),p=u.filter(e=>!d.has(e.id)),m=[...i.map(e=>w([e],[],!1)),...c.map(e=>w(e,f.filter(t=>e.some(e=>o(t.selector,e.selector))),!0)),...p.map(e=>w([e],f.filter(t=>o(t.selector,e.selector)),!1))];n.push(...m)}return n.sort((e,t)=>Number(e.status===`resolved`)-Number(t.status===`resolved`)||e.n-t.n)}function D(e){return E(e.map((e,t)=>({id:`tmp_${t}`,n:t+1,kind:`patch`,path:`/`,selector:e.selector,note:``,patch:e.patch,author:{id:`tmp`,name:`tmp`,kind:`human`},status:`open`,replies:[],createdAt:0,host:``}))).map(e=>e.primary.selector)}var O=/^(css|sc|jsx|emotion|svelte|astro|data-v)-|[0-9a-f]{6,}|__[A-Za-z0-9]{5,}$|^_/,k=80,A=4e3,j=e=>e.replace(/\s+/g,` `).trim(),ee=e=>j(e.textContent??``);function te(e){return[...e.classList].filter(e=>!O.test(e)&&e.length<40).slice(0,6)}function M(e,t){if(e===t)return 1;if(!e||!t||e.length<2||t.length<2)return 0;let n=new Map;for(let t=0;t<e.length-1;t++){let r=e.slice(t,t+2);n.set(r,(n.get(r)??0)+1)}let r=0;for(let e=0;e<t.length-1;e++){let i=t.slice(e,e+2),a=n.get(i)??0;a>0&&(n.set(i,a-1),r++)}return 2*r/(e.length+t.length-2)}function ne(e,t,n=[]){if(e.tagName.toLowerCase()!==t.tag)return 0;let r=0,i=0,a=(e,t)=>{i+=e,r+=e*t};if(t.id&&a(3,+(e.id===t.id)),t.attrs)for(let[n,r]of Object.entries(t.attrs)){let t=e.getAttribute(n);a(n===`href`||n===`src`?1:2,t===r?1:t?M(t,r)*.5:0)}if(t.text!==void 0){let r=ee(e).slice(0,k);if(a(4,Math.max(M(r,t.text),...n.map(e=>M(r,j(e).slice(0,k))))),t.prefix||t.suffix){let n=e.parentElement?ee(e.parentElement):``,r=[t.prefix&&n.includes(t.prefix.slice(-12))?1:0,t.suffix&&n.includes(t.suffix.slice(0,12))?1:0];a(1,(r[0]+r[1])/(+!!t.prefix+ +!!t.suffix))}}if(t.classes?.length){let n=new Set(te(e));a(1,t.classes.filter(e=>n.has(e)).length/t.classes.length)}return i?r/i:1}function re(e,t,n={}){let r=n.root??document,i=n.isOwn??(()=>!1),a=[];try{a=[...r.querySelectorAll(e)].filter(e=>!i(e))}catch{}if(!t)return a[0]?{el:a[0],how:`selector`,score:1}:null;let o=null;for(let e of a.slice(0,50)){let r=ne(e,t,n.altTexts);r>=.35&&(!o||r>o.score)&&(o={el:e,how:`selector`,score:r})}if(o&&o.score>=.6)return o;let s=r.getElementsByTagName(t.tag),c=null;for(let e=0;e<s.length&&e<A;e++){let r=s[e];if(i(r))continue;let a=ne(r,t,n.altTexts);a>=.6&&(!c||a>c.score)&&(c={el:r,how:`fuzzy`,score:a})}return c&&(!o||c.score>o.score+.15)?c:o}var N=/^(css|sc|jsx|emotion|svelte|astro|data-v)-|[0-9a-f]{6,}|__[A-Za-z0-9]{5,}$|^_/;function P(e){return typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/[^\w-]/g,e=>`\\${e}`)}function F(e){return[...e.classList].filter(e=>!N.test(e)&&e.length<40).slice(0,3)}function ie(e){let t=e.ownerDocument;if(e.id&&!/\d{3,}/.test(e.id)){let n=`#${P(e.id)}`;try{if(t.querySelectorAll(n).length===1)return n}catch{}}let n=[],r=e;for(let e=0;r&&r!==t.documentElement&&e<6;e++){let e=r.tagName.toLowerCase();if(r.id&&!/\d{3,}/.test(r.id)){n.unshift(`#${P(r.id)}`);break}let i=F(r);i.length&&(e+=i.map(e=>`.${P(e)}`).join(``));let a=r.parentElement;if(a){let t=[...a.children].filter(e=>e.tagName===r.tagName);t.length>1&&(e+=`:nth-of-type(${t.indexOf(r)+1})`)}n.unshift(e);let o=n.join(` > `);try{if(t.querySelectorAll(o).length===1)return o}catch{}r=a}return n.join(` > `)}function I(e,t){return e.length>t?e.slice(0,t-1)+`…`:e}var L=e=>e.replace(/\s+/g,` `).trim(),ae=/^[ \t\n\r\f]*$/;function R(e){let t=L(e.innerText??e.textContent??``),n=t.split(` `);if(n.length<4||n.filter(e=>[...e].length===1).length/n.length<.6)return t;let r=L(z(e));return r.replace(/\s/g,``)===t.replace(/\s/g,``)?r:t}function z(e){let t=``,n=e=>{let r=getComputedStyle(e).display,i=/flex|grid/.test(r);for(let r of e.childNodes)if(r.nodeType===Node.TEXT_NODE){let e=r.nodeValue??``;t+=ae.test(e)?i?``:` `:e}else if(r.nodeType===Node.ELEMENT_NODE){let e=getComputedStyle(r).display;if(e===`none`)continue;let a=!e.startsWith(`inline`)&&e!==`contents`&&!i;a&&(t+=` `),n(r),a&&(t+=` `)}};return n(e),t}function oe(e,t,n={}){let r=n.gap??12,i=n.margin??12,a=innerWidth,o=innerHeight,s=Math.min(e.offsetWidth||320,a-i*2),c=Math.min(e.offsetHeight||200,o-i*2),l=(n.avoid??[]).filter(e=>e.width>0&&e.height>0),u=e=>Math.min(Math.max(i,e),a-s-i),d=e=>Math.min(Math.max(i,e),o-c-i),f=(e,t)=>e>=i-.5&&t>=i-.5&&e+s<=a-i+.5&&t+c<=o-i+.5,p=(e,t)=>l.some(n=>e<n.right&&e+s>n.left&&t<n.bottom&&t+c>n.top),m=e=>[u(t.left),...l.flatMap(t=>e<t.bottom&&e+c>t.top?[u(t.right+r),u(t.left-r-s)]:[])],h=t.bottom+r,g=t.top-r-c,_=[[t.right+r,d(t.top)],[t.left-r-s,d(t.top)],...m(h).map(e=>[e,h]),...m(g).map(e=>[e,g])],v=_.find(([e,t])=>f(e,t)&&!p(e,t))??_.find(([e,t])=>f(e,t))??[u(t.left),d(o-t.bottom>t.top?h:g)];e.style.left=`${Math.round(v[0])}px`,e.style.top=`${Math.round(v[1])}px`}function se(e,t=[]){let n=0,r=()=>{n||=requestAnimationFrame(()=>(n=0,e()))};addEventListener(`scroll`,r,{capture:!0,passive:!0}),addEventListener(`resize`,r);let i=typeof ResizeObserver<`u`?new ResizeObserver(r):null;for(let e of t)i?.observe(e);return()=>{removeEventListener(`scroll`,r,{capture:!0}),removeEventListener(`resize`,r),i?.disconnect(),n&&cancelAnimationFrame(n),n=0}}function B(e){let t=e.cloneNode(!0),n=t.matches?.(`input[type=password]`)?[t]:[...t.querySelectorAll(`input[type=password]`)];for(let e of n)e.removeAttribute(`value`);return t.outerHTML}var V=[`display`,`position`,`color`,`background-color`,`font-family`,`font-size`,`font-weight`,`line-height`,`letter-spacing`,`text-align`,`padding`,`margin`,`gap`,`border`,`border-radius`,`box-shadow`,`width`,`height`,`flex-direction`,`justify-content`,`align-items`,`grid-template-columns`];function ce(e){let t=getComputedStyle(e),n={};for(let e of V){let r=t.getPropertyValue(e);r&&r!==`none`&&r!==`normal`&&r!==`auto`&&r!==`0px`&&r!==`rgba(0, 0, 0, 0)`&&(n[e]=r)}return{selector:ie(e),tagName:e.tagName,id:e.id||void 0,classes:[...e.classList],text:I(R(e),300),outerHTML:I(B(e),6e3),styles:n,url:location.href}}function le(){return matchMedia(`(prefers-reduced-motion: reduce)`).matches}var ue=50;function de(){let e=new Map,t=new Map,n=e=>{let n=(t.get(e)??0)+1;return t.set(e,n),n<=ue},r=(t,n,r)=>{let i={el:n,style:{},shown:{}};for(let[e,t]of Object.entries(r.style??{}))i.style[e]=[n.style.getPropertyValue(e),n.style.getPropertyPriority(e)],n.style.setProperty(e,t,`important`),i.shown[e]=n.style.getPropertyValue(e);if(r.text!==void 0&&(i.children=[...n.childNodes],n.textContent=r.text,i.applied=n.innerHTML),r.attrs){i.attrs={};let e=(e,t)=>{t!==void 0&&(i.attrs[e]=n.getAttribute(e),n.setAttribute(e,t))};r.attrs.src!==void 0&&(i.attrs.srcset=n.getAttribute(`srcset`),n.removeAttribute(`srcset`)),e(`src`,r.attrs.src),e(`alt`,r.attrs.alt)}e.set(t,i)},i=t=>{let n=e.get(t);if(n&&(e.delete(t),n.el.isConnected)){for(let[e,[t,r]]of Object.entries(n.style))t?n.el.style.setProperty(e,t,r):n.el.style.removeProperty(e);n.children&&n.el.replaceChildren(...n.children);for(let[e,t]of Object.entries(n.attrs??{}))t===null?n.el.removeAttribute(e):n.el.setAttribute(e,t)}};return{elOf(t){let n=e.get(t);return n?.el.isConnected?n.el:void 0},ensure(t,i,a){let o=e.get(t);if(!o||!o.el.isConnected){e.delete(t);let o=a();return o&&n(t)&&r(t,o,i),o}let s=o.el.style;for(let[e,r]of Object.entries(i.style??{}))(s.getPropertyValue(e)!==o.shown[e]||s.getPropertyPriority(e)!==`important`)&&n(t)&&(s.setProperty(e,r,`important`),o.shown[e]=s.getPropertyValue(e));o.applied!==void 0&&o.el.innerHTML!==o.applied&&n(t)&&(o.children=[...o.el.childNodes],o.el.textContent=i.text??``,o.applied=o.el.innerHTML);let c=i.attrs?.src;return c!==void 0&&(o.el.getAttribute(`src`)!==c||o.el.hasAttribute(`srcset`))&&n(t)&&(o.el.removeAttribute(`srcset`),o.el.setAttribute(`src`,c)),i.attrs?.alt!==void 0&&o.el.getAttribute(`alt`)!==i.attrs.alt&&n(t)&&o.el.setAttribute(`alt`,i.attrs.alt),o.el},revert:i,revertOn(t){for(let[n,r]of[...e].reverse())r.el===t&&i(n)},prune(n){for(let t of[...e.keys()].reverse())n(t)||i(t);for(let e of[...t.keys()])n(e)||t.delete(e)}}}var H=`display.position.color.background-color.font-family.font-size.font-weight.font-style.line-height.letter-spacing.text-align.text-decoration.text-decoration-line.padding.margin.border.border-top.border-right.border-bottom.border-left.border-radius.box-shadow.width.height.max-width.transform.list-style.list-style-type.opacity.white-space.gap`.split(`.`),fe=new Set([`normal`,`auto`,`0px`,`rgba(0, 0, 0, 0)`,`static`]),U=new Set([`list-style`,`list-style-type`,`text-decoration`,`text-decoration-line`]),W=48;function pe(e){if(e.tagName===`LI`||e.closest(`li`)){let t=e.closest(`ul, ol`);if(t instanceof HTMLElement)return t}return e}function me(e){let t=e.cloneNode(!0),n=[e,...e.querySelectorAll(`*`)].slice(0,W),r=[t,...t.querySelectorAll(`*`)];for(let e=0;e<n.length;e++){let t=n[e],i=r[e];if(!(t instanceof HTMLElement)||!(i instanceof HTMLElement))continue;let a=getComputedStyle(t),o=[];for(let e of H){let t=a.getPropertyValue(e);t&&!fe.has(t)&&(t!==`none`||U.has(e))&&o.push(`${e}: ${t}`)}t instanceof HTMLImageElement&&(t.currentSrc||t.src)&&(i.src=t.currentSrc||t.src),o.length&&i.setAttribute(`style`,o.join(`; `))}t.querySelectorAll(`script, iframe, object`).forEach(e=>e.remove());let i=t.outerHTML;return i.length>4e4?i.slice(0,4e4):i}var G={pick:`取点`,pickTip:`点选页面元素:引用到对话、评论或修改(Shift+点击直接引用,Esc 退出)`,pickTipReviewer:`点选页面元素来评论或修改(Esc 退出)`,pickBusy:`Agent 正在操作页面,暂不能取点`,artifacts:`产物`,chat:`对话`,eye:`候选`,eyeTip:`按住看原版,单击隐藏候选`,notReady:`面板加载中…`,brand:`Page Harness`,theme:`切换明暗`,collapse:`收起`,close:`关闭`,bannerOn:`Agent 可操作此页面`,bannerBusy:`Agent 正在操作…`,stop:`停止`,picked:`已加入对话`,pickedQueued:`已暂存,面板就绪后加入对话`,pickLimit:`最多暂存 20 个元素`,sessionDead:`与 Page Harness 的连接已断开,请检查终端`,review:`意见`,reviewOnly:`仅评审`,reviewOffline:`连不上本机 page-harness。HTTPS 页面访问 http://127.0.0.1 常被浏览器拦截,请看主页说明。`,reviewTitle:`页面意见`,reviewEmpty:`还没有意见。`,showChanges:`显示修改`,exportMd:`导出`,copyPrompt:`复制 Prompt`,copyPromptTip:`复制一段说明,让本机 Agent 分页拉完未处理意见并逐条标记`,promptCopied:`✓ 已复制`,copyFailed:`复制失败,请检查浏览器的剪贴板权限`,clearAll:`清空`,clearConfirm:`再点一次确认清空`,sev_issue:`问题`,sev_suggestion:`建议`,sev_info:`说明`,kindPatch:`修改`,viewOriginal:`看原版`,viewChange:`看修改`,remove:`删除`,notFound:`页面上找不到这个元素`,reviewEmptyHere:`这个页面还没有意见,其他页面的在「全部」里。`,tabHere:`本页`,tabAll:`全部`,comment:`评论`,edit:`编辑`,commentPh:`这里有什么问题或建议?`,pickQuote:`引用到对话`,pickLive:`在线生成`,approveLabel:`本页结论`,reviewHow:`点底栏「取点」,选中元素后点「评论」。`,reviewHowEdit:`点底栏「取点」,选中元素后点「评论」或「编辑」。`,editSourceOnly:`有源码时请让 Agent 直接改代码;页面编辑只在评审模式可用`,save:`保存`,reply:`回复`,replyPh:`回复…(Enter 发送)`,replies:`{n} 条回复`,resolve:`标记解决`,reopen:`重新打开`,resolved:`已解决`,approve:`通过`,requestChanges:`需修改`,approvedBy:`✓ {name} 通过`,changesBy:`✎ {name} 需修改`,detached:`页面上找不到了`,goPage:`去`,fieldText:`文字`,fieldColor:`文字颜色`,fieldBg:`背景`,fieldSize:`字号 px`,fieldWeight:`字重`,fieldPadding:`内边距`,fieldRadius:`圆角`,fieldImage:`图片地址`,fieldNote:`说明(可选):为什么这么改`,textLocked:`这个元素里还有子元素,不能直接改文字;想改文字请选更里层的元素。`,noChanges:`还没有任何修改`,needName:`先在面板里填写你的名字`,newFrom:`{name} 添加了 #{n}`,reviewer:`评审`,modeSelect:`选元素`,modeInsert:`插入区块`,steerPlaceholder:`或描述整页要怎么改…`,steerGo:`生成`,quote:`引用`,designTitle:`设计候选`,promptPlaceholder:`补充说明(可选)`,insertPlaceholder:`描述要插入的区块…`,before:`之前`,after:`之后`,count:`数量`,display:`展示`,inplace:`原位切换`,compare:`并排对比`,marks:`批注`,draw:`圈画`,pin:`定位`,undo:`撤销`,clear:`清空`,notePlaceholder:`这里要怎么改?`,noteEmpty:`意见不能为空`,generate:`生成候选`,cancel:`取消`,original:`原版`,accept:`采用`,discard:`放弃`,retry:`重试`,retryAccept:`重试并采用`,refinePlaceholder:`细化当前候选…`,reload:`重新加载`,tellAgent:`告诉 Agent`,notMounted:`候选没有出现在页面上`,otherRoute:`候选在另一个页面`,goThere:`跳过去`,params:`参数`,status_generating:`生成中`,status_refining:`细化中`,status_accepting:`采用中`,status_discarding:`放弃中`,status_ready:`可挑选`,status_failed:`失败`,status_accepted:`已采用`,status_discarded:`已放弃`,maxMarks:`最多 8 处批注`,blockedNested:`这里已有候选,请先采用或放弃`,actions:{bolder:`加粗`,quieter:`减弱`,polish:`润色`,typeset:`排版`,colorize:`配色`,layout:`布局`,distill:`精简`,adapt:`适配`,animate:`动效`,delight:`惊喜`,overdrive:`大胆`,freeform:`自由`}},he={pick:`Pick`,pickTip:`Click an element to quote it in the chat, comment on it or change it (Shift+click quotes directly, Esc exits)`,pickTipReviewer:`Click an element to comment on it or change it (Esc exits)`,pickBusy:`The agent is operating the page`,artifacts:`Artifacts`,chat:`Chat`,eye:`Candidates`,eyeTip:`Hold to see the original, click to hide candidates`,notReady:`Panel is loading…`,brand:`Page Harness`,theme:`Toggle theme`,collapse:`Collapse`,close:`Close`,bannerOn:`The agent can operate this page`,bannerBusy:`The agent is operating…`,stop:`Stop`,picked:`Added to chat`,pickedQueued:`Saved; it will be added when the panel is ready`,pickLimit:`Up to 20 elements can be queued`,sessionDead:`Lost connection to Page Harness; check the terminal`,review:`Notes`,reviewOnly:`Review only`,reviewOffline:`Cannot reach page-harness on this machine. HTTPS pages often block http://127.0.0.1. See the home page for what works.`,reviewTitle:`Page notes`,reviewEmpty:`No notes yet.`,showChanges:`Show changes`,exportMd:`Export`,copyPrompt:`Copy prompt`,copyPromptTip:`Copy instructions that tell a local agent to page through open notes and mark each one`,promptCopied:`✓ Copied`,copyFailed:`Copy failed; check the clipboard permission`,clearAll:`Clear`,clearConfirm:`Click again to clear all`,sev_issue:`Issue`,sev_suggestion:`Suggestion`,sev_info:`Info`,kindPatch:`Change`,viewOriginal:`Original`,viewChange:`Changed`,remove:`Remove`,notFound:`This element is not on the page`,reviewEmptyHere:`No notes on this page yet; other pages are under All.`,tabHere:`This page`,tabAll:`All`,comment:`Comment`,edit:`Edit`,commentPh:`What is wrong here, or what would you suggest?`,pickQuote:`Quote in chat`,pickLive:`Live candidates`,approveLabel:`This page`,reviewHow:`Click Pick in the dock, choose an element, then Comment.`,reviewHowEdit:`Click Pick in the dock, choose an element, then Comment or Edit.`,editSourceOnly:`With source, ask the agent to change the code; page edits are for review mode`,save:`Save`,reply:`Reply`,replyPh:`Reply… (Enter to send)`,replies:`{n} replies`,resolve:`Resolve`,reopen:`Reopen`,resolved:`Resolved`,approve:`Approve`,requestChanges:`Request changes`,approvedBy:`✓ {name} approved`,changesBy:`✎ {name} requested changes`,detached:`not found on the page`,goPage:`Go to`,fieldText:`Text`,fieldColor:`Text color`,fieldBg:`Background`,fieldSize:`Size px`,fieldWeight:`Weight`,fieldPadding:`Padding`,fieldRadius:`Radius`,fieldImage:`Image URL`,fieldNote:`Why (optional)`,textLocked:`This element contains other elements, so its text cannot be edited here; pick an inner element.`,noChanges:`Nothing changed yet`,needName:`Enter your name in the panel first`,newFrom:`{name} added #{n}`,reviewer:`Review`,modeSelect:`Select`,modeInsert:`Insert block`,steerPlaceholder:`Or describe a page-wide change…`,steerGo:`Generate`,quote:`Quote`,designTitle:`Design candidates`,promptPlaceholder:`Extra instructions (optional)`,insertPlaceholder:`Describe the block to insert…`,before:`Before`,after:`After`,count:`Count`,display:`Display`,inplace:`In place`,compare:`Side by side`,marks:`Marks`,draw:`Circle`,pin:`Pin`,undo:`Undo`,clear:`Clear`,notePlaceholder:`What should change here?`,noteEmpty:`A note needs text`,generate:`Generate`,cancel:`Cancel`,original:`Original`,accept:`Accept`,discard:`Discard`,retry:`Retry`,retryAccept:`Retry & accept`,refinePlaceholder:`Refine this candidate…`,reload:`Reload`,tellAgent:`Tell the agent`,notMounted:`The candidates did not appear on the page`,otherRoute:`The candidates are on another page`,goThere:`Go there`,params:`Tune`,status_generating:`Generating`,status_refining:`Refining`,status_accepting:`Accepting`,status_discarding:`Discarding`,status_ready:`Ready`,status_failed:`Failed`,status_accepted:`Accepted`,status_discarded:`Discarded`,maxMarks:`Up to 8 marks`,blockedNested:`There are candidates here already; accept or discard them first`,actions:{bolder:`Bolder`,quieter:`Quieter`,polish:`Polish`,typeset:`Typeset`,colorize:`Colorize`,layout:`Layout`,distill:`Distill`,adapt:`Adapt`,animate:`Animate`,delight:`Delight`,overdrive:`Overdrive`,freeform:`Freeform`}};function ge(e){return e===`en`?he:G}var _e=`
1
+ (function(){var e=[`bolder`,`quieter`,`polish`,`typeset`,`colorize`,`layout`,`distill`,`adapt`,`animate`,`delight`,`overdrive`,`freeform`],t=/^(padding|margin)(-|$)/;function n(e){return e.trim().replace(/\s+/g,` `)}function r(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-1)}…`:n}function i(e){return/(?:^|[\s>+~])(?:ul|ol)(?![a-z-])/i.test(e)}function a(e){let t=n(e),r=t.match(/^(.*?)\s*(?:>\s*)?li(?![a-z-])/i);return r&&i(r[1])?n(r[1]):i(t)&&!/(?:^|[\s>+~])li(?![a-z-])/i.test(t)?t:null}function o(e,t){let r=n(e),i=n(t);if(!r||r===i||!i.startsWith(r))return!1;let a=i.charAt(r.length);return a===` `||a===`>`||a===`+`||a===`~`}function s(e){if(e.kind!==`patch`||!e.patch||e.patch.text!==void 0||e.patch.attrs)return!1;let n=Object.keys(e.patch.style??{});return n.length>0&&n.every(e=>t.test(e))}function c(e){if(e?.style)return Object.entries(e.style).map(([e,t])=>`${e}: ${t}`).join(`; `)||void 0}function l(e){let t={selector:e.selector},n=c(e.patch);return n&&(t.css=n),e.patch?.text!==void 0&&(t.text=e.anchor?.text?`${e.anchor.text} → ${e.patch.text}`:e.patch.text),e.patch?.attrs?.src&&(t.image=e.patch.attrs.src.startsWith(`data:`)?`(uploaded image)`:e.patch.attrs.src),t}function u(e){return e.patch?.style??{}}function d(e){let t=u(e),n=Object.values(t).join(` `),r=/#fff\b|#ffffff|white|rgb\(\s*255\s*,\s*255\s*,\s*255/i.test(n),i=!!(t.border||t[`border-width`]||t[`border-style`]||t[`border-color`]),a=/rotate\(\s*(-?[\d.]+)\s*deg/i.exec(t.transform||n),o=a?Number(a[1]):0,s=!!t[`box-shadow`],c=[];i&&c.push(r?`a white border`:`a border`),a&&o<-.2?c.push(`a slight tilt left`):a&&o>.2&&c.push(`a slight tilt right`),s&&c.push(`a shadow`);let l=r&&i&&!!a&&s,d=c.length?`This photo now has ${c.join(`, `)}${l?`, like a polaroid on a desk`:``}.`:`This photo looks different. Before and after are below.`,f=`Photo appearance changed`;return l?f=`Photo tilted like a polaroid`:r&&i&&a?f=`Photo has a white border and a tilt`:c[0]&&(f=`Photo has ${c[0]}`),{title:f,say:d}}function f(e){let t=e.anchor?.text?.trim(),n=e.patch?.text?.trim(),i=u(e)[`font-style`]===`italic`,a=!!t?.endsWith(`!`)&&!!n&&!n.endsWith(`!`),o=v(e)?`The heading`:`This text`,s=[];return t&&n&&t!==n?s.push(`changed from “${r(t,80)}” to “${r(n,80)}”`):n&&s.push(`changed to “${r(n,80)}”`),i&&s.push(s.length?`and is now italic`:`is now italic`),a&&s.push(`and the exclamation mark is gone`),s.length?{title:i&&a?`${o} is italic, without the exclamation mark`:i?`${o} is italic`:a?`${o} lost its exclamation mark`:o===`The heading`?`Heading text changed`:`Text changed`,say:`${o} ${s.join(`, `)}.`}:m(e)}function p(e){let t=y(e)?`bibliography`:`list`,r=e.map(e=>{let t=Number(/nth-(?:child|of-type)\((\d+)\)/i.exec(e.selector)?.[1]??NaN),n=u(e);return{n:t,px:w(n[`font-size`]),border:!!(n[`border-bottom`]||n[`border-bottom-width`]),bold:Number(n[`font-weight`])>=600||/bold/i.test(n[`font-weight`]||``)}}).filter(e=>!Number.isNaN(e.n)&&!Number.isNaN(e.px)).sort((e,t)=>e.n-t.n),i=+!!r.length;for(let e=1;e<r.length&&r[e].px<r[e-1].px-.5;e++)i=e+1;let o=r.find(e=>e.border),s=o?r.indexOf(o)+1:i,c=r.slice(s).some(e=>e.bold),l=e.find(e=>a(e.selector)===n(e.selector)),d=[`The ${t} ${/none/i.test(u(l??e[0])[`list-style`]||u(l??e[0])[`list-style-type`]||``)?`is no longer a same-size bulleted list`:`uses a new type scale`}`];return s>=2&&d.push(`the first ${s} items step down in size`),o&&d.push(`item ${o.n} has a line under it`),c&&d.push(`the later items are the same bold size`),{title:s>=2?`${t[0].toUpperCase()}${t.slice(1)} steps down in size`:`${t[0].toUpperCase()}${t.slice(1)} appearance changed`,say:`${d.join(`, `)}.`}}function m(e){let t=u(e),n=[];t[`font-style`]===`italic`&&n.push(`is italic`),(Number(t[`font-weight`])>=600||/bold/i.test(t[`font-weight`]||``))&&n.push(`is bold`),t[`font-size`]&&n.push(`size is ${t[`font-size`]}`),t[`font-family`]&&n.push(`uses a different font`),t.color&&n.push(`text color changed`),(t[`background-color`]||t.background)&&n.push(`background changed`),t[`border-radius`]&&n.push(`corners changed`),(t.border||t[`border-color`])&&n.push(`border changed`),(t[`text-decoration`]||t[`text-decoration-line`])&&n.push(`text decoration changed`),t.opacity&&n.push(`opacity changed`);let r=h(e);return n.length?{title:`Appearance changed`,say:`${r} ${n.join(`, `)}.`}:{title:`Appearance changed`,say:`${r} looks different. Before and after are below.`}}function h(e){let t=e.anchor?.text?.trim();if(t)return`“${r(t,42)}”`;let n=(e.anchor?.tag||``).toLowerCase();if(n===`img`||/(?:^|[\s>+~])img(?![a-z-])/i.test(e.selector))return`this photo`;if(/^h[1-6]$/.test(n)||/(?:^|[\s>+~])h[1-6](?![a-z-])/i.test(e.selector))return`this heading`;let i=e.label?.replace(/^[a-z0-9-]+\s*/i,``).replace(/^"|"$/g,``).trim();return i?`“${r(i,42)}”`:`this part of the page`}function g(e,t=`zh-CN`){if(t===`en`)return h(e);let n=e.anchor?.text?.trim();if(n)return`「${r(n,42)}」这一块`;let i=(e.anchor?.tag||``).toLowerCase();if(i===`img`||/(?:^|[\s>+~])img(?![a-z-])/i.test(e.selector))return`这张照片`;if(/^h[1-6]$/.test(i)||/(?:^|[\s>+~])h[1-6](?![a-z-])/i.test(e.selector))return`这个标题`;let a=e.label?.replace(/^[a-z0-9-]+\s*/i,``).replace(/^"|"$/g,``).trim();return a?`「${r(a,42)}」这一块`:`页面上标出的这一块`}function _(e){return(e.anchor?.tag||``).toLowerCase()===`img`||/(?:^|[\s>+~])img(?![a-z-])/i.test(e.selector)||!!e.patch?.attrs?.src}function v(e){return/^h[1-6]$/i.test(e.anchor?.tag||``)||/(?:^|[\s>+~])h[1-6](?![a-z-])/i.test(e.selector)}function y(e){let t=e.map(e=>`${e.anchor?.text??``} ${e.label??``} ${e.note??``}`).join(` `);return/书目|书单|bibliography|\bC\+\+|Tour of|Programming:/i.test(t)}function b(e,t=`zh-CN`){if(t===`en`)return d(e);let n=u(e),r=Object.values(n).join(` `),i=/#fff\b|#ffffff|white|rgb\(\s*255\s*,\s*255\s*,\s*255/i.test(r),a=!!(n.border||n[`border-width`]||n[`border-style`]||n[`border-color`]),o=/rotate\(\s*(-?[\d.]+)\s*deg/i.exec(n.transform||r),s=o?Number(o[1]):0,c=!!n[`box-shadow`],l=[];a&&l.push(i?`加上一圈白边`:`加上了边框`),o&&s<-.2?l.push(`微微向左倾斜`):o&&s>.2&&l.push(`微微向右倾斜`),c&&l.push(`底下多了一层阴影`);let f=i&&a&&!!o&&c,p=l.length?`这张照片${l.join(`,`)}${f?`,看起来像一张放在桌上的拍立得`:``}。`:`这张照片的外观改了,改前和改后的样子在下面。`,m=`照片的外观改了`;return f?m=`照片改成斜放的拍立得`:i&&a&&o?m=`照片加上白边并斜放`:l[0]&&(m=`照片${l[0]}`),{title:m,say:p}}function x(e,t=`zh-CN`){if(t===`en`)return f(e);let n=e.anchor?.text?.trim(),i=e.patch?.text?.trim(),a=u(e)[`font-style`]===`italic`,o=!!n?.endsWith(`!`)&&!!i&&!i.endsWith(`!`),s=v(e)?`标题`:`这段文字`,c=[];return n&&i&&n!==i?c.push(`从「${r(n,80)}」改成了「${r(i,80)}」`):i&&c.push(`改成了「${r(i,80)}」`),a&&c.push(c.length?`并改成斜体`:`改成了斜体`),o&&c.push(`感叹号去掉了`),c.length?{title:a&&o?`${s}改成斜体,并去掉感叹号`:a?`${s}改成斜体`:o?`${s}去掉感叹号`:s===`标题`?`标题文字改了`:`这段文字改了`,say:`${s}${c.join(`,`)}。`}:E(e)}var S=[`零`,`一`,`两`,`三`,`四`,`五`,`六`,`七`,`八`,`九`,`十`],C=e=>e>=1&&e<=10?S[e]:String(e);function w(e){if(!e)return NaN;let t=parseFloat(e);return Number.isFinite(t)?t:NaN}function T(e,t=`zh-CN`){if(t===`en`)return p(e);let r=y(e)?`书目`:`列表`,i=e.map(e=>{let t=Number(/nth-(?:child|of-type)\((\d+)\)/i.exec(e.selector)?.[1]??NaN),n=u(e);return{n:t,px:w(n[`font-size`]),border:!!(n[`border-bottom`]||n[`border-bottom-width`]),bold:Number(n[`font-weight`])>=600||/bold/i.test(n[`font-weight`]||``)}}).filter(e=>!Number.isNaN(e.n)&&!Number.isNaN(e.px)).sort((e,t)=>e.n-t.n),o=+!!i.length;for(let e=1;e<i.length&&i[e].px<i[e-1].px-.5;e++)o=e+1;let s=i.find(e=>e.border),c=s?i.indexOf(s)+1:o,l=i.slice(c).some(e=>e.bold),d=e.find(e=>a(e.selector)===n(e.selector)),f=[`整段${r}${/none/i.test(u(d??e[0])[`list-style`]||u(d??e[0])[`list-style-type`]||``)?`不再是同一号字的圆点列表`:`的字号层次改了`}`];return c>=2&&f.push(`前${C(c)}项由大到小排开`),s&&f.push(`第${C(s.n)}项下面加了一条线`),l&&f.push(`后面的项改成同一号的加粗字`),{title:c>=2?`${r}改成由大到小的字号阶梯`:`${r}的外观改了`,say:`${f.join(`,`)}。`}}function E(e,t=`zh-CN`){if(t===`en`)return m(e);let n=u(e),r=[];n[`font-style`]===`italic`&&r.push(`改成了斜体`),(Number(n[`font-weight`])>=600||/bold/i.test(n[`font-weight`]||``))&&r.push(`改成了粗体`),n[`font-size`]&&r.push(`字号改成 ${n[`font-size`].replace(`px`,` 像素`)}`),n[`font-family`]&&r.push(`换了一套字体`),n.color&&r.push(`文字颜色改了`),(n[`background-color`]||n.background)&&r.push(`背景改了`),n[`border-radius`]&&r.push(`圆角改了`),(n.border||n[`border-color`])&&r.push(`边框改了`),(n[`text-decoration`]||n[`text-decoration-line`])&&r.push(`文字装饰改了`),n.opacity&&r.push(`透明度改了`);let i=g(e,`zh-CN`);return r.length?{title:`这一块的外观改了`,say:`${i}${r.join(`,`)}。`}:{title:`这一块的外观改了`,say:`${i}的外观改了,差别看下面的改前和改后。`}}function D(e,t=`zh-CN`){let n=e.note.trim();return{title:r(n.split(/[。.!!?\n]/)[0]?.trim()||(t===`en`?`Note`:`文字意见`),36),say:n,where:t===`en`?`About ${g(e,`en`)}`:`关于${g(e,`zh-CN`)}`}}function O(e,t,n=`zh-CN`){if(t)return T(e,n);let r=e[0];return!r||r.kind===`note`?D(r,n):r.patch?.text===void 0?_(r)?b(r,n):E(r,n):x(r,n)}function k(e,t,r,i=`zh-CN`){let o=r?a(e[0].selector):null,s=r?e.find(e=>n(e.selector)===o)??[...e].sort((e,t)=>e.selector.length-t.selector.length||e.n-t.n)[0]:e[0],c=O(e,r,i),u=[...e].sort((e,t)=>e.n-t.n),d=[...u,...t].map(l);return{id:s.id,n:s.n,kind:s.kind,path:s.path,primary:s,members:u,extras:t,title:c.title,say:c.say,...c.where?{where:c.where}:{},status:e.every(e=>e.status===`resolved`)?`resolved`:`open`,authorName:s.author?.name||``,lines:d}}function A(e){let t=new Map;for(let n of e){let e=a(n.selector);if(!e)continue;let r=e;t.set(r,[...t.get(r)??[],n])}return[...t.values()].filter(e=>e.length>=2)}function j(e,t=`zh-CN`){let n=[...new Set(e.map(e=>e.path))],r=[];for(let i of n){let n=e.filter(e=>e.path===i),a=n.filter(e=>e.kind!==`patch`||!e.patch),c=n.filter(e=>e.kind===`patch`&&e.patch),l=A(c),u=new Set(l.flat().map(e=>e.id)),d=c.filter(e=>!u.has(e.id)),f=new Set(d.filter(e=>s(e)&&d.some(t=>t!==e&&o(e.selector,t.selector))||s(e)&&l.some(t=>t.some(t=>o(e.selector,t.selector)))).map(e=>e.id)),p=d.filter(e=>f.has(e.id)),m=d.filter(e=>!f.has(e.id)),h=[...a.map(e=>k([e],[],!1,t)),...l.map(e=>k(e,p.filter(t=>e.some(e=>o(t.selector,e.selector))),!0,t)),...m.map(e=>k([e],p.filter(t=>o(t.selector,e.selector)),!1,t))];r.push(...h)}return r.sort((e,t)=>Number(e.status===`resolved`)-Number(t.status===`resolved`)||e.n-t.n)}function ee(e){return j(e.map((e,t)=>({id:`tmp_${t}`,n:t+1,kind:`patch`,path:`/`,selector:e.selector,note:``,patch:e.patch,author:{id:`tmp`,name:`tmp`,kind:`human`},status:`open`,replies:[],createdAt:0,host:``}))).map(e=>e.primary.selector)}var te=/^(css|sc|jsx|emotion|svelte|astro|data-v)-|[0-9a-f]{6,}|__[A-Za-z0-9]{5,}$|^_/,M=80,ne=4e3,N=e=>e.replace(/\s+/g,` `).trim(),P=e=>N(e.textContent??``);function F(e){return[...e.classList].filter(e=>!te.test(e)&&e.length<40).slice(0,6)}function I(e,t){if(e===t)return 1;if(!e||!t||e.length<2||t.length<2)return 0;let n=new Map;for(let t=0;t<e.length-1;t++){let r=e.slice(t,t+2);n.set(r,(n.get(r)??0)+1)}let r=0;for(let e=0;e<t.length-1;e++){let i=t.slice(e,e+2),a=n.get(i)??0;a>0&&(n.set(i,a-1),r++)}return 2*r/(e.length+t.length-2)}function re(e,t,n=[]){if(e.tagName.toLowerCase()!==t.tag)return 0;let r=0,i=0,a=(e,t)=>{i+=e,r+=e*t};if(t.id&&a(3,+(e.id===t.id)),t.attrs)for(let[n,r]of Object.entries(t.attrs)){let t=e.getAttribute(n);a(n===`href`||n===`src`?1:2,t===r?1:t?I(t,r)*.5:0)}if(t.text!==void 0){let r=P(e).slice(0,M);if(a(4,Math.max(I(r,t.text),...n.map(e=>I(r,N(e).slice(0,M))))),t.prefix||t.suffix){let n=e.parentElement?P(e.parentElement):``,r=[t.prefix&&n.includes(t.prefix.slice(-12))?1:0,t.suffix&&n.includes(t.suffix.slice(0,12))?1:0];a(1,(r[0]+r[1])/(+!!t.prefix+ +!!t.suffix))}}if(t.classes?.length){let n=new Set(F(e));a(1,t.classes.filter(e=>n.has(e)).length/t.classes.length)}return i?r/i:1}function ie(e,t,n={}){let r=n.root??document,i=n.isOwn??(()=>!1),a=[];try{a=[...r.querySelectorAll(e)].filter(e=>!i(e))}catch{}if(!t)return a[0]?{el:a[0],how:`selector`,score:1}:null;let o=null;for(let e of a.slice(0,50)){let r=re(e,t,n.altTexts);r>=.35&&(!o||r>o.score)&&(o={el:e,how:`selector`,score:r})}if(o&&o.score>=.6)return o;let s=r.getElementsByTagName(t.tag),c=null;for(let e=0;e<s.length&&e<ne;e++){let r=s[e];if(i(r))continue;let a=re(r,t,n.altTexts);a>=.6&&(!c||a>c.score)&&(c={el:r,how:`fuzzy`,score:a})}return c&&(!o||c.score>o.score+.15)?c:o}var L=/^(css|sc|jsx|emotion|svelte|astro|data-v)-|[0-9a-f]{6,}|__[A-Za-z0-9]{5,}$|^_/;function R(e){return typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/[^\w-]/g,e=>`\\${e}`)}function z(e){return[...e.classList].filter(e=>!L.test(e)&&e.length<40).slice(0,3)}function ae(e){let t=e.ownerDocument;if(e.id&&!/\d{3,}/.test(e.id)){let n=`#${R(e.id)}`;try{if(t.querySelectorAll(n).length===1)return n}catch{}}let n=[],r=e;for(let e=0;r&&r!==t.documentElement&&e<6;e++){let e=r.tagName.toLowerCase();if(r.id&&!/\d{3,}/.test(r.id)){n.unshift(`#${R(r.id)}`);break}let i=z(r);i.length&&(e+=i.map(e=>`.${R(e)}`).join(``));let a=r.parentElement;if(a){let t=[...a.children].filter(e=>e.tagName===r.tagName);t.length>1&&(e+=`:nth-of-type(${t.indexOf(r)+1})`)}n.unshift(e);let o=n.join(` > `);try{if(t.querySelectorAll(o).length===1)return o}catch{}r=a}return n.join(` > `)}function B(e,t){return e.length>t?e.slice(0,t-1)+`…`:e}var V=e=>e.replace(/\s+/g,` `).trim(),oe=/^[ \t\n\r\f]*$/;function H(e){let t=V(e.innerText??e.textContent??``),n=t.split(` `);if(n.length<4||n.filter(e=>[...e].length===1).length/n.length<.6)return t;let r=V(se(e));return r.replace(/\s/g,``)===t.replace(/\s/g,``)?r:t}function se(e){let t=``,n=e=>{let r=getComputedStyle(e).display,i=/flex|grid/.test(r);for(let r of e.childNodes)if(r.nodeType===Node.TEXT_NODE){let e=r.nodeValue??``;t+=oe.test(e)?i?``:` `:e}else if(r.nodeType===Node.ELEMENT_NODE){let e=getComputedStyle(r).display;if(e===`none`)continue;let a=!e.startsWith(`inline`)&&e!==`contents`&&!i;a&&(t+=` `),n(r),a&&(t+=` `)}};return n(e),t}function ce(e,t,n={}){let r=n.gap??12,i=n.margin??12,a=innerWidth,o=innerHeight,s=Math.min(e.offsetWidth||320,a-i*2),c=Math.min(e.offsetHeight||200,o-i*2),l=(n.avoid??[]).filter(e=>e.width>0&&e.height>0),u=e=>Math.min(Math.max(i,e),a-s-i),d=e=>Math.min(Math.max(i,e),o-c-i),f=(e,t)=>e>=i-.5&&t>=i-.5&&e+s<=a-i+.5&&t+c<=o-i+.5,p=(e,t)=>l.some(n=>e<n.right&&e+s>n.left&&t<n.bottom&&t+c>n.top),m=e=>[u(t.left),...l.flatMap(t=>e<t.bottom&&e+c>t.top?[u(t.right+r),u(t.left-r-s)]:[])],h=t.bottom+r,g=t.top-r-c,_=[[t.right+r,d(t.top)],[t.left-r-s,d(t.top)],...m(h).map(e=>[e,h]),...m(g).map(e=>[e,g])],v=_.find(([e,t])=>f(e,t)&&!p(e,t))??_.find(([e,t])=>f(e,t))??[u(t.left),d(o-t.bottom>t.top?h:g)];e.style.left=`${Math.round(v[0])}px`,e.style.top=`${Math.round(v[1])}px`}function le(e,t=[]){let n=0,r=()=>{n||=requestAnimationFrame(()=>(n=0,e()))};addEventListener(`scroll`,r,{capture:!0,passive:!0}),addEventListener(`resize`,r);let i=typeof ResizeObserver<`u`?new ResizeObserver(r):null;for(let e of t)i?.observe(e);return()=>{removeEventListener(`scroll`,r,{capture:!0}),removeEventListener(`resize`,r),i?.disconnect(),n&&cancelAnimationFrame(n),n=0}}function U(e){let t=e.cloneNode(!0),n=t.matches?.(`input[type=password]`)?[t]:[...t.querySelectorAll(`input[type=password]`)];for(let e of n)e.removeAttribute(`value`);return t.outerHTML}var W=[`display`,`position`,`color`,`background-color`,`font-family`,`font-size`,`font-weight`,`line-height`,`letter-spacing`,`text-align`,`padding`,`margin`,`gap`,`border`,`border-radius`,`box-shadow`,`width`,`height`,`flex-direction`,`justify-content`,`align-items`,`grid-template-columns`];function ue(e){let t=getComputedStyle(e),n={};for(let e of W){let r=t.getPropertyValue(e);r&&r!==`none`&&r!==`normal`&&r!==`auto`&&r!==`0px`&&r!==`rgba(0, 0, 0, 0)`&&(n[e]=r)}return{selector:ae(e),tagName:e.tagName,id:e.id||void 0,classes:[...e.classList],text:B(H(e),300),outerHTML:B(U(e),6e3),styles:n,url:location.href}}function de(){return matchMedia(`(prefers-reduced-motion: reduce)`).matches}var G=50;function fe(){let e=new Map,t=new Map,n=e=>{let n=(t.get(e)??0)+1;return t.set(e,n),n<=G},r=(t,n,r)=>{let i={el:n,style:{},shown:{}};for(let[e,t]of Object.entries(r.style??{}))i.style[e]=[n.style.getPropertyValue(e),n.style.getPropertyPriority(e)],n.style.setProperty(e,t,`important`),i.shown[e]=n.style.getPropertyValue(e);if(r.text!==void 0&&(i.children=[...n.childNodes],n.textContent=r.text,i.applied=n.innerHTML),r.attrs){i.attrs={};let e=(e,t)=>{t!==void 0&&(i.attrs[e]=n.getAttribute(e),n.setAttribute(e,t))};r.attrs.src!==void 0&&(i.attrs.srcset=n.getAttribute(`srcset`),n.removeAttribute(`srcset`)),e(`src`,r.attrs.src),e(`alt`,r.attrs.alt)}e.set(t,i)},i=t=>{let n=e.get(t);if(n&&(e.delete(t),n.el.isConnected)){for(let[e,[t,r]]of Object.entries(n.style))t?n.el.style.setProperty(e,t,r):n.el.style.removeProperty(e);n.children&&n.el.replaceChildren(...n.children);for(let[e,t]of Object.entries(n.attrs??{}))t===null?n.el.removeAttribute(e):n.el.setAttribute(e,t)}};return{elOf(t){let n=e.get(t);return n?.el.isConnected?n.el:void 0},ensure(t,i,a){let o=e.get(t);if(!o||!o.el.isConnected){e.delete(t);let o=a();return o&&n(t)&&r(t,o,i),o}let s=o.el.style;for(let[e,r]of Object.entries(i.style??{}))(s.getPropertyValue(e)!==o.shown[e]||s.getPropertyPriority(e)!==`important`)&&n(t)&&(s.setProperty(e,r,`important`),o.shown[e]=s.getPropertyValue(e));o.applied!==void 0&&o.el.innerHTML!==o.applied&&n(t)&&(o.children=[...o.el.childNodes],o.el.textContent=i.text??``,o.applied=o.el.innerHTML);let c=i.attrs?.src;return c!==void 0&&(o.el.getAttribute(`src`)!==c||o.el.hasAttribute(`srcset`))&&n(t)&&(o.el.removeAttribute(`srcset`),o.el.setAttribute(`src`,c)),i.attrs?.alt!==void 0&&o.el.getAttribute(`alt`)!==i.attrs.alt&&n(t)&&o.el.setAttribute(`alt`,i.attrs.alt),o.el},revert:i,revertOn(t){for(let[n,r]of[...e].reverse())r.el===t&&i(n)},prune(n){for(let t of[...e.keys()].reverse())n(t)||i(t);for(let e of[...t.keys()])n(e)||t.delete(e)}}}var pe=`display.position.color.background-color.font-family.font-size.font-weight.font-style.line-height.letter-spacing.text-align.text-decoration.text-decoration-line.padding.margin.border.border-top.border-right.border-bottom.border-left.border-radius.box-shadow.width.height.max-width.transform.list-style.list-style-type.opacity.white-space.gap`.split(`.`),K=new Set([`normal`,`auto`,`0px`,`rgba(0, 0, 0, 0)`,`static`]),me=new Set([`list-style`,`list-style-type`,`text-decoration`,`text-decoration-line`]),he=48;function ge(e){if(e.tagName===`LI`||e.closest(`li`)){let t=e.closest(`ul, ol`);if(t instanceof HTMLElement)return t}return e}function _e(e){let t=e.cloneNode(!0),n=[e,...e.querySelectorAll(`*`)].slice(0,he),r=[t,...t.querySelectorAll(`*`)];for(let e=0;e<n.length;e++){let t=n[e],i=r[e];if(!(t instanceof HTMLElement)||!(i instanceof HTMLElement))continue;let a=getComputedStyle(t),o=[];for(let e of pe){let t=a.getPropertyValue(e);t&&!K.has(t)&&(t!==`none`||me.has(e))&&o.push(`${e}: ${t}`)}t instanceof HTMLImageElement&&(t.currentSrc||t.src)&&(i.src=t.currentSrc||t.src),o.length&&i.setAttribute(`style`,o.join(`; `))}t.querySelectorAll(`script, iframe, object`).forEach(e=>e.remove());let i=t.outerHTML;return i.length>4e4?i.slice(0,4e4):i}var ve={pick:`取点`,pickTip:`点选页面元素:引用到对话、评论或修改(Shift+点击直接引用,Esc 退出)`,pickTipReviewer:`点选页面元素来评论或修改(Esc 退出)`,pickBusy:`Agent 正在操作页面,暂不能取点`,artifacts:`产物`,chat:`对话`,eye:`候选`,eyeTip:`按住看原版,单击隐藏候选`,notReady:`面板加载中…`,brand:`Page Harness`,theme:`切换明暗`,collapse:`收起`,close:`关闭`,bannerOn:`Agent 可操作此页面`,bannerBusy:`Agent 正在操作…`,stop:`停止`,picked:`已加入对话`,pickedQueued:`已暂存,面板就绪后加入对话`,pickLimit:`最多暂存 20 个元素`,sessionDead:`与 Page Harness 的连接已断开,请检查终端`,review:`意见`,reviewOnly:`仅评审`,reviewOffline:`连不上本机 page-harness。HTTPS 页面访问 http://127.0.0.1 常被浏览器拦截,请看主页说明。`,reviewTitle:`页面意见`,reviewEmpty:`还没有意见。`,showChanges:`显示修改`,exportMd:`导出`,copyPrompt:`复制 Prompt`,copyPromptTip:`复制一段说明,让本机 Agent 分页拉完未处理意见并逐条标记`,promptCopied:`✓ 已复制`,copyFailed:`复制失败,请检查浏览器的剪贴板权限`,clearAll:`清空`,clearConfirm:`再点一次确认清空`,sev_issue:`问题`,sev_suggestion:`建议`,sev_info:`说明`,kindPatch:`修改`,viewOriginal:`看原版`,viewChange:`看修改`,remove:`删除`,removeConfirm:`再点一次删除`,anonymous:`匿名`,lookBefore:`改前`,lookAfter:`改后`,lookWhole:`整页`,lookPart:`局部`,zoomTitle:`点击放大`,elementGone:`元素已经不在页面上,下面仍是保存时的样子`,selectorStyle:`选择器和样式`,textLabel:`文字:`,imageLabel:`图片:`,notFound:`页面上找不到这个元素`,reviewEmptyHere:`这个页面还没有意见,其他页面的在「全部」里。`,tabHere:`本页`,tabAll:`全部`,comment:`评论`,edit:`编辑`,commentPh:`这里有什么问题或建议?`,pickQuote:`引用到对话`,pickLive:`在线生成`,approveLabel:`本页结论`,reviewHow:`点底栏「取点」,选中元素后点「评论」。`,reviewHowEdit:`点底栏「取点」,选中元素后点「评论」或「编辑」。`,editSourceOnly:`有源码时请让 Agent 直接改代码;页面编辑只在评审模式可用`,save:`保存`,reply:`回复`,replyPh:`回复…(Enter 发送)`,replies:`{n} 条回复`,replyOne:`1 条回复`,resolve:`标记解决`,reopen:`重新打开`,resolved:`已解决`,approve:`通过`,requestChanges:`需修改`,approvedBy:`✓ {name} 通过`,changesBy:`✎ {name} 需修改`,detached:`页面上找不到了`,goPage:`去`,fieldText:`文字`,fieldColor:`文字颜色`,fieldBg:`背景`,fieldSize:`字号 px`,fieldWeight:`字重`,fieldPadding:`内边距`,fieldRadius:`圆角`,fieldImage:`图片地址`,fieldNote:`说明(可选):为什么这么改`,textLocked:`这个元素里还有子元素,不能直接改文字;想改文字请选更里层的元素。`,noChanges:`还没有任何修改`,needName:`先在面板里填写你的名字`,newFrom:`{name} 添加了 #{n}`,reviewer:`评审`,modeSelect:`选元素`,modeInsert:`插入区块`,steerPlaceholder:`或描述整页要怎么改…`,steerGo:`生成`,quote:`引用`,designTitle:`设计候选`,promptPlaceholder:`补充说明(可选)`,insertPlaceholder:`描述要插入的区块…`,before:`之前`,after:`之后`,count:`数量`,display:`展示`,inplace:`原位切换`,compare:`并排对比`,marks:`批注`,draw:`圈画`,pin:`定位`,undo:`撤销`,clear:`清空`,notePlaceholder:`这里要怎么改?`,noteEmpty:`意见不能为空`,replyEmpty:`回复不能为空`,generate:`生成候选`,cancel:`取消`,original:`原版`,accept:`采用`,discard:`放弃`,retry:`重试`,retryAccept:`重试并采用`,refinePlaceholder:`细化当前候选…`,reload:`重新加载`,tellAgent:`告诉 Agent`,notMounted:`候选没有出现在页面上`,otherRoute:`候选在另一个页面`,goThere:`跳过去`,params:`参数`,status_generating:`生成中`,status_refining:`细化中`,status_accepting:`采用中`,status_discarding:`放弃中`,status_ready:`可挑选`,status_failed:`失败`,status_accepted:`已采用`,status_discarded:`已放弃`,maxMarks:`最多 8 处批注`,blockedNested:`这里已有候选,请先采用或放弃`,actions:{bolder:`加粗`,quieter:`减弱`,polish:`润色`,typeset:`排版`,colorize:`配色`,layout:`布局`,distill:`精简`,adapt:`适配`,animate:`动效`,delight:`惊喜`,overdrive:`大胆`,freeform:`自由`}},q={pick:`Pick`,pickTip:`Click an element to quote it in the chat, comment on it or change it (Shift+click quotes directly, Esc exits)`,pickTipReviewer:`Click an element to comment on it or change it (Esc exits)`,pickBusy:`The agent is operating the page`,artifacts:`Artifacts`,chat:`Chat`,eye:`Candidates`,eyeTip:`Hold to see the original, click to hide candidates`,notReady:`Panel is loading…`,brand:`Page Harness`,theme:`Toggle theme`,collapse:`Collapse`,close:`Close`,bannerOn:`The agent can operate this page`,bannerBusy:`The agent is operating…`,stop:`Stop`,picked:`Added to chat`,pickedQueued:`Saved; it will be added when the panel is ready`,pickLimit:`Up to 20 elements can be queued`,sessionDead:`Lost connection to Page Harness; check the terminal`,review:`Notes`,reviewOnly:`Review only`,reviewOffline:`Cannot reach page-harness on this machine. HTTPS pages often block http://127.0.0.1. See the home page for what works.`,reviewTitle:`Page notes`,reviewEmpty:`No notes yet.`,showChanges:`Show changes`,exportMd:`Export`,copyPrompt:`Copy prompt`,copyPromptTip:`Copy instructions that tell a local agent to page through open notes and mark each one`,promptCopied:`✓ Copied`,copyFailed:`Copy failed; check the clipboard permission`,clearAll:`Clear`,clearConfirm:`Click again to clear all`,sev_issue:`Issue`,sev_suggestion:`Suggestion`,sev_info:`Info`,kindPatch:`Change`,viewOriginal:`Original`,viewChange:`Changed`,remove:`Remove`,removeConfirm:`Click again to remove`,anonymous:`Anonymous`,lookBefore:`Before`,lookAfter:`After`,lookWhole:`Whole page`,lookPart:`Detail`,zoomTitle:`Click to enlarge`,elementGone:`This element is no longer on the page. The saved look is below.`,selectorStyle:`Selector and style`,textLabel:`Text:`,imageLabel:`Image:`,notFound:`This element is not on the page`,reviewEmptyHere:`No notes on this page yet; other pages are under All.`,tabHere:`This page`,tabAll:`All`,comment:`Comment`,edit:`Edit`,commentPh:`What is wrong here, or what would you suggest?`,pickQuote:`Quote in chat`,pickLive:`Live candidates`,approveLabel:`This page`,reviewHow:`Click Pick in the dock, choose an element, then Comment.`,reviewHowEdit:`Click Pick in the dock, choose an element, then Comment or Edit.`,editSourceOnly:`With source, ask the agent to change the code; page edits are for review mode`,save:`Save`,reply:`Reply`,replyPh:`Reply… (Enter to send)`,replies:`{n} replies`,replyOne:`1 reply`,resolve:`Resolve`,reopen:`Reopen`,resolved:`Resolved`,approve:`Approve`,requestChanges:`Request changes`,approvedBy:`✓ {name} approved`,changesBy:`✎ {name} requested changes`,detached:`not found on the page`,goPage:`Go to`,fieldText:`Text`,fieldColor:`Text color`,fieldBg:`Background`,fieldSize:`Size px`,fieldWeight:`Weight`,fieldPadding:`Padding`,fieldRadius:`Radius`,fieldImage:`Image URL`,fieldNote:`Why (optional)`,textLocked:`This element contains other elements, so its text cannot be edited here; pick an inner element.`,noChanges:`Nothing changed yet`,needName:`Enter your name in the panel first`,newFrom:`{name} added #{n}`,reviewer:`Review`,modeSelect:`Select`,modeInsert:`Insert block`,steerPlaceholder:`Or describe a page-wide change…`,steerGo:`Generate`,quote:`Quote`,designTitle:`Design candidates`,promptPlaceholder:`Extra instructions (optional)`,insertPlaceholder:`Describe the block to insert…`,before:`Before`,after:`After`,count:`Count`,display:`Display`,inplace:`In place`,compare:`Side by side`,marks:`Marks`,draw:`Circle`,pin:`Pin`,undo:`Undo`,clear:`Clear`,notePlaceholder:`What should change here?`,noteEmpty:`A note needs text`,replyEmpty:`A reply needs text`,generate:`Generate`,cancel:`Cancel`,original:`Original`,accept:`Accept`,discard:`Discard`,retry:`Retry`,retryAccept:`Retry & accept`,refinePlaceholder:`Refine this candidate…`,reload:`Reload`,tellAgent:`Tell the agent`,notMounted:`The candidates did not appear on the page`,otherRoute:`The candidates are on another page`,goThere:`Go there`,params:`Tune`,status_generating:`Generating`,status_refining:`Refining`,status_accepting:`Accepting`,status_discarding:`Discarding`,status_ready:`Ready`,status_failed:`Failed`,status_accepted:`Accepted`,status_discarded:`Discarded`,maxMarks:`Up to 8 marks`,blockedNested:`There are candidates here already; accept or discard them first`,actions:{bolder:`Bolder`,quieter:`Quieter`,polish:`Polish`,typeset:`Typeset`,colorize:`Colorize`,layout:`Layout`,distill:`Distill`,adapt:`Adapt`,animate:`Animate`,delight:`Delight`,overdrive:`Overdrive`,freeform:`Freeform`}};function ye(e){return e===`en`?q:ve}var be=`
2
2
  .lv-card { position: fixed; z-index: 2147483646; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); font-size: var(--fs); }
3
3
  .lv-card button { display: inline-flex; align-items: center; justify-content: center; gap: 4px; border: 1px solid var(--line); background: var(--bg); border-radius: var(--r); padding: 0 10px; height: var(--h); white-space: nowrap; transition: background .12s, border-color .12s; }
4
4
  .lv-card button:hover:not(:disabled) { background: var(--bg2); }
@@ -61,4 +61,4 @@
61
61
  .lv-params .p { display: flex; flex-direction: column; gap: 4px; }
62
62
  .lv-params .p .h { display: flex; justify-content: space-between; color: var(--fg2); font-size: var(--fs-sm); }
63
63
  .lv-params input[type=range] { padding: 0; height: auto; background: none; border: 0; box-shadow: none; accent-color: var(--accent); }
64
- `,ve=`ph:live-view`,ye=[`generating`,`refining`,`accepting`,`discarding`];function K(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))e===`class`?r.className=n:r.setAttribute(e,n);for(let e of n)r.append(e);return r}function q(e,t,n=``){let r=K(`button`,n?{class:n}:{},e);return r.addEventListener(`click`,e=>{e.stopPropagation(),t()}),r}function J(t){let n=document.createElement(`style`);n.textContent=_e,t.root.appendChild(n);let r=ge(t.lang()),i=[],a=!1,o=`select`,s={};try{s=JSON.parse(sessionStorage.getItem(ve)||`{}`)}catch{}let c=!1,l=!1,u=null,d=new Map,f=e=>{try{return!!e&&new URL(e,location.href).origin===location.origin}catch{return!1}},p=()=>{let e=Object.keys(s);if(e.length>20)for(let t of e.slice(0,e.length-20))delete s[t];try{sessionStorage.setItem(ve,JSON.stringify(s))}catch{}},m=e=>{let t=s[e.sid];return t||(t=s[e.sid]={current:e.variants[0]?.index??1,display:e.display,params:{}},p()),e.variants.length&&!e.variants.some(e=>e.index===t.current)&&t.current!==0&&(t.current=e.variants[0].index),t},h=e=>t.send({type:`ph:live`,request:e}),g=e=>{let n=m(e);t.send({type:`ph:live-view`,sid:e.sid,current:n.current,display:n.display})},_=K(`div`,{class:`lv-root`});t.layer.appendChild(_);let v=K(`div`),y=K(`div`);_.append(y,v);let b=null,x=()=>{if(b?.remove(),b=null,!a)return;t.patchMode()&&(o=`select`);let e=K(`div`,{class:`lv-seg`});e.append(q(r.modeSelect,()=>(o=`select`,x()),o===`select`?`on`:``)),t.patchMode()||e.append(q(r.modeInsert,()=>(o=`insert`,x()),o===`insert`?`on`:``));let n=K(`input`,{placeholder:r.steerPlaceholder}),i=q(r.steerGo,()=>{let e=n.value.trim();if(!e)return n.focus();h({op:`steer`,prompt:e,count:3,display:`inplace`,url:location.href,scope:`page`}),n.value=``,t.setPicking(!1)},`primary`);n.addEventListener(`keydown`,e=>{e.stopPropagation(),e.key===`Enter`&&!e.isComposing&&i.click()}),b=K(`div`,{class:`lv-card lv-pickbar`},e,n,i),_.appendChild(b)},S=null,C=null,w=()=>{S?.remove(),S=null,C?.(),C=null},T=(e,t,n=!0)=>{let r=e.offsetWidth||300,i=e.offsetHeight||40,a=Math.min(Math.max(8,t.left),innerWidth-r-8),o=n?t.bottom+8:t.top-i-8;o+i>innerHeight-8&&(o=t.top-i-8),o<8&&(o=Math.min(innerHeight-i-8,t.bottom+8)),o<8&&(o=8),a=Math.max(8,a),e.style.left=`${a}px`,e.style.top=`${o}px`},E=e=>{let t=e.closest(`[data-ph-live]`);if(!t)return!1;let n=t.getAttribute(`data-ph-live`);return i.some(e=>e.sid===n&&e.status!==`accepted`&&e.status!==`discarded`)},O=e=>{if(w(),E(e))return t.toast(`warn`,r.blockedNested),!0;if(o!==`insert`||t.patchMode())return!1;let n=e.getBoundingClientRect();S=K(`div`,{class:`lv-card lv-pop`},q(r.before,()=>(w(),L(e,`before`))),q(r.after,()=>(w(),L(e,`after`))),q(`✕`,w)),_.appendChild(S),T(S,n);let i=S;return C=se(()=>T(i,e.getBoundingClientRect()),[e]),!0},k=[],A=null,j=()=>{if(A?.remove(),A=null,!k.length||!N)return;A=K(`div`,{class:`lv-marks`});let e=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);for(let t of k)if(t.kind===`stroke`&&t.points){let n=document.createElementNS(`http://www.w3.org/2000/svg`,`polyline`);n.setAttribute(`points`,t.points.map(e=>e.join(`,`)).join(` `)),n.setAttribute(`fill`,`none`),n.style.stroke=`var(--err)`,n.setAttribute(`stroke-width`,`3`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`),e.appendChild(n)}A.appendChild(e);for(let e of k){let t=e.at??e.points?.[0];if(!t)continue;let n=K(`div`,{class:`lv-pin`},String(e.n));n.style.left=`${t[0]}px`,n.style.top=`${t[1]}px`,A.appendChild(n)}y.appendChild(A)},ee=e=>{let n=new Set;t.setUiHidden(!0);try{let r=Math.max(1,Math.floor(e.length/6));for(let i=0;i<e.length;i+=r){let r=document.elementsFromPoint(e[i][0],e[i][1]).find(e=>!t.isOwn(e)&&e!==document.documentElement&&e!==document.body);if(r&&n.add(ie(r)),n.size>=3)break}}finally{t.setUiHidden(!1)}return[...n]},te=(e,t,n)=>{let i=K(`input`,{placeholder:r.notePlaceholder}),a=K(`div`,{class:`lv-card lv-note`},i,q(`✓`,()=>o(),`primary`)),o=()=>{t.note=i.value.trim()||void 0,a.remove(),n()};i.addEventListener(`keydown`,e=>{e.stopPropagation(),e.key===`Enter`&&!e.isComposing&&o(),e.key===`Escape`&&o()}),_.appendChild(a),a.style.left=`${Math.min(e[0]+14,innerWidth-236)}px`,a.style.top=`${Math.min(e[1]+14,innerHeight-50)}px`,i.focus()},M=(e,n)=>{if(k.length>=8)return t.toast(`warn`,r.maxMarks);let i=K(`div`,{class:`lv-draw`}),a=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`),o=document.createElementNS(`http://www.w3.org/2000/svg`,`polyline`);o.setAttribute(`fill`,`none`),o.style.stroke=`var(--err)`,o.setAttribute(`stroke-width`,`3`),a.appendChild(o),i.appendChild(a),i.tabIndex=-1,_.appendChild(i),i.focus({preventScroll:!0});let s=[],c=e=>{if(i.remove(),!e)return n();k.push(e),j(),te(e.at??e.points[0],e,()=>{j(),n()})};if(i.addEventListener(`keydown`,e=>e.key===`Escape`&&c(null)),e===`pin`){i.addEventListener(`click`,e=>{let t=[e.clientX,e.clientY];c({n:k.length+1,kind:`pin`,at:t,targets:ee([t])})});return}i.addEventListener(`pointerdown`,e=>{i.setPointerCapture(e.pointerId),s.push([e.clientX,e.clientY]);let t=e=>{s.push([e.clientX,e.clientY]),o.setAttribute(`points`,s.map(e=>e.join(`,`)).join(` `))};i.addEventListener(`pointermove`,t),i.addEventListener(`pointerup`,()=>{if(i.removeEventListener(`pointermove`,t),s.length<3)return c(null);let e=s.filter((e,t)=>t%2==0).slice(0,200);c({n:k.length+1,kind:`stroke`,points:e,targets:ee(e)})},{once:!0})})},ne=()=>[...t.root.querySelectorAll(`.drawer, .dock`)].map(e=>e.getBoundingClientRect()).filter(e=>e.width&&e.height),N=null,P=null,F=()=>{N?.remove(),N=null,P?.(),P=null,k=[],j()},L=(n,i)=>{F(),t.setPicking(!1);let a=ce(n),o=i?`freeform`:`polish`,s=3,c=`inplace`,l=K(`div`,{class:`lv-card lv-design`}),u=K(`h4`,{},r.designTitle,K(`span`,{class:`sp`}),q(`✕`,F,`ghost icon`)),d=K(`div`,{class:`lv-target`,title:a.selector},...i?[K(`span`,{class:`pos`},i===`before`?r.before:r.after)]:[],K(`span`,{class:`tag`},a.tagName.toLowerCase()),K(`span`,{class:`txt`},I(a.text||a.selector,80))),f=K(`div`,{class:`lv-actions`}),p=()=>{f.replaceChildren(...e.map(e=>q(r.actions[e]??e,()=>(o=e,p()),e===o?`on`:``)))};i||p();let m=K(`textarea`,{placeholder:i?r.insertPlaceholder:r.promptPlaceholder,rows:`3`});m.addEventListener(`keydown`,e=>{e.stopPropagation(),e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!e.isComposing&&S()});let g=K(`span`,{class:`sp`}),v=()=>g.textContent=k.length?`${k.length}/8`:``,y=K(`div`,{class:`lv-row`},K(`label`,{},r.marks),q(r.draw,()=>M(`stroke`,v)),q(r.pin,()=>M(`pin`,v)),g,q(r.undo,()=>(k.pop(),j(),v()),`ghost`),q(r.clear,()=>(k=[],j(),v()),`ghost`)),b=K(`div`,{class:`lv-row`}),x=()=>{let e=K(`div`,{class:`lv-seg`},...[2,3,4].map(e=>q(String(e),()=>(s=e,x()),e===s?`on`:``)));if(t.patchMode())return b.replaceChildren(K(`label`,{},r.count),e);let n=K(`div`,{class:`lv-seg`},q(r.inplace,()=>(c=`inplace`,x()),c===`inplace`?`on`:``),q(r.compare,()=>(c=`compare`,x()),c===`compare`?`on`:``));b.replaceChildren(K(`label`,{},r.count),e,K(`span`,{class:`sp`}),K(`label`,{},r.display),n)};x();let S=()=>{let e=m.value.trim();if(i&&!e)return m.focus();let t=i?{op:`insert`,target:a,position:i,prompt:e,count:s,display:c,marks:k.length?k:void 0,url:location.href,scope:`element`}:{op:`generate`,target:a,action:o,prompt:e||void 0,count:s,display:c,marks:k.length?k:void 0,url:location.href,scope:`element`};h(t),F()},C=K(`div`,{class:`lv-foot`},q(r.cancel,F),q(r.generate,S,`primary`));l.append(u,d),i||l.append(f),l.append(m,y,b,C),N=l,_.appendChild(l);let w=()=>oe(l,n.getBoundingClientRect(),{avoid:ne()});w();let T=se(w,[n,l]),E=new MutationObserver(w),D=t.root.querySelector(`.drawer`);D&&E.observe(D,{attributes:!0,attributeFilter:[`style`,`hidden`]}),P=()=>(T(),E.disconnect()),m.focus()},ae=e=>{if(!e)return``;try{let t=new URL(e,location.href);return t.pathname+t.search}catch{return e}},R=e=>!e.url||ae(e.url)===location.pathname+location.search,z=e=>document.querySelector(`[data-ph-live="${CSS.escape(e)}"]`),B=e=>[...e.children].filter(e=>e instanceof HTMLElement&&e.hasAttribute(`data-ph-variant`)),V=e=>Number(e.getAttribute(`data-ph-variant`)),ue=e=>{let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e){let e=a.getBoundingClientRect();(e.width||e.height)&&(t=Math.min(t,e.left),n=Math.min(n,e.top),r=Math.max(r,e.right),i=Math.max(i,e.bottom))}return t===1/0?null:new DOMRect(t,n,r-t,i-n)},H=e=>{if(!e)return[];try{let t=JSON.parse(e.getAttribute(`data-ph-params`)||`[]`);return Array.isArray(t)?t.filter(e=>e&&typeof e.name==`string`&&/^[\w-]+$/.test(e.name)).slice(0,6):[]}catch{return[]}},fe=(e,t)=>t[e.name]===void 0?e.type===`toggle`?e.default===!1||e.default===`false`||e.default===0?`0`:`1`:e.type===`steps`?String(e.default??e.options?.[0]??``):String(e.default??e.min??0):t[e.name],U=de(),W=e=>e.source===`patch`,G=new Map,he=(e,t,n)=>`${e}:${t}:${n.selector}:${JSON.stringify(n.patch)}`,J=e=>{let n=e=>t.isOwn(e),r=re(e.selector,e.anchor,{isOwn:n,altTexts:e.patch.text===void 0?[]:[e.patch.text]})?.el??null;if(!r)try{r=[...document.querySelectorAll(e.selector)].find(e=>!n(e))??null}catch{}return r instanceof HTMLElement?r:null},be=e=>{let t=m(e),n=R(e)&&(e.status===`ready`||e.status===`refining`),r=n&&!c&&!l,i=n?e.variants.find(e=>e.index===t.current):void 0,a=new Set(r&&i?i.changes?.map(t=>he(e.sid,i.index,t))??[]:[]);U.prune(t=>!t.startsWith(`${e.sid}:`)||a.has(t));let o=[];for(let t of i?.changes??[]){let n=r?U.ensure(he(e.sid,i.index,t),t.patch,()=>J(t)):J(t);n&&o.push(n)}return G.set(e.sid,o),o.length>0},xe=e=>U.prune(t=>!t.startsWith(`${e}:`)),Se=e=>W(e)?!!G.get(e.sid)?.length:!!z(e.sid),Y=e=>{if(W(e))return be(e);let t=z(e.sid);if(!t)return!1;let n=m(e),r=B(t),i=c||l;for(let t of r){let r=V(t),a;a=e.status===`accepted`||e.status===`discarded`||i?r===0:n.display===`compare`||r===n.current,t.hidden===a&&(t.hidden=!a)}let a=r.find(e=>V(e)===n.current),o=n.params[n.current]??{};for(let e of H(a)){let n=fe(e,o),r=e.type===`range`?`${n}${e.unit??``}`:n;t.style.getPropertyValue(`--ph-${e.name}`)!==r&&t.style.setProperty(`--ph-${e.name}`,r),t.getAttribute(`data-ph-param-${e.name}`)!==n&&t.setAttribute(`data-ph-param-${e.name}`,n)}return!0},Ce=e=>{if(le())return;let t=W(e)?null:z(e.sid);(W(e)?G.get(e.sid)?.[0]:t&&B(t).find(t=>V(t)===m(e).current))?.animate?.([{opacity:0,transform:`translateY(4px)`},{opacity:1,transform:`none`}],{duration:180,easing:`ease-out`})},we=(e,t)=>{let n=m(e),r=e.variants.map(e=>e.index);r.length&&(n.current=r[(r.indexOf(n.current)+t+r.length)%r.length],n.display=`inplace`,p(),Y(e),Ce(e),g(e),X())},Te=e=>{let t=m(e),n;if(W(e)){let r=e.variants.find(e=>e.index===t.current)?.changes??[],i=D(r),a=new Map,o=e=>{let t=r.find(t=>t.selector===e),n=t?J(t):null;return n?pe(n):null};for(let e of i){let t=o(e);t&&a.set(e,me(t))}xe(e.sid),G.delete(e.sid),n=[];for(let e of i){let t=o(e),r=t?me(t):void 0,i=a.get(e);(r||i)&&n.push({selector:e,look:{beforeHtml:r,afterHtml:i}})}}h({op:`accept`,sid:e.sid,variant:t.current,params:t.params[t.current],looks:n})},Ee=null,De=(e,t)=>{Ee?.remove();let n=z(e.sid),i=m(e),a=n?B(n).find(e=>V(e)===i.current):void 0,o=H(a);if(!o.length)return;let s=i.params[i.current]??={},c=K(`div`,{class:`lv-card lv-params`},K(`h4`,{},r.params));for(let t of o){let n=fe(t,s),r=K(`div`,{class:`p`}),i=K(`span`,{},t.type===`range`?`${n}${t.unit??``}`:n);r.append(K(`div`,{class:`h`},K(`span`,{},t.label||t.name),i));let a=n=>{s[t.name]=n,i.textContent=t.type===`range`?`${n}${t.unit??``}`:n,p(),Y(e)};if(t.type===`range`){let e=K(`input`,{type:`range`,min:String(t.min??0),max:String(t.max??100),step:String(t.step??1),value:n});e.addEventListener(`input`,()=>a(e.value)),r.append(e)}else if(t.type===`steps`){let e=K(`div`,{class:`lv-seg`}),i=()=>e.replaceChildren(...(t.options??[]).map(e=>q(e,()=>(a(e),i()),(s[t.name]??n)===e?`on`:``)));i(),r.append(e)}else{let e=q(``,()=>{let r=(s[t.name]??n)===`1`?`0`:`1`;a(r),e.textContent=r===`1`?`ON`:`OFF`,e.classList.toggle(`on`,r===`1`)},n===`1`?`on`:``);e.textContent=n===`1`?`ON`:`OFF`,r.append(e)}c.append(r)}c.append(K(`div`,{class:`lv-foot`},q(`✓`,()=>(c.remove(),Ee=null)))),Ee=c,_.appendChild(c),T(c,t)},Oe=new Map,ke=0,Ae=new WeakMap,X=()=>{let e=new Map([...v.children].map(e=>[e.dataset.sid??``,e])),n=[];y.querySelectorAll(`.lv-shimmer, .lv-outline, .lv-badge`).forEach(e=>e.remove());let a=!1;for(let t of i){if(t.status===`accepted`||t.status===`discarded`)continue;let i=R(t),o=W(t),s=i&&!o?z(t.sid):null,_=i&&o?G.get(t.sid)??[]:[],b=o?_.length>0:!!s,x=m(t),S=s?B(s):[],C=S.filter(e=>!e.hidden),w=s?ue(C.length?C:S):_.length?ue(_):null;if(!w&&i&&t.target)try{let e=document.querySelector(t.target.selector);e&&(w=e.getBoundingClientRect())}catch{}let T=ye.includes(t.status);if(T&&w){let e=K(`div`,{class:`lv-shimmer`});Object.assign(e.style,{left:`${w.left}px`,top:`${w.top}px`,width:`${w.width}px`,height:`${w.height}px`}),y.appendChild(e)}if(b&&t.status===`ready`&&(a=!0),s&&t.status===`ready`&&x.display===`compare`&&!c&&!l)for(let e of S){let n=V(e),i=e.getBoundingClientRect();if(!i.width&&!i.height)continue;let a=K(`div`,{class:`lv-outline`});Object.assign(a.style,{left:`${i.left-2}px`,top:`${i.top-2}px`,width:`${i.width+4}px`,height:`${i.height+4}px`});let o=n===0?r.original:t.variants.find(e=>e.index===n)?.label??`#${n}`,s=K(`div`,{class:`lv-badge`},`${n===0?``:`${n} · `}${o}`);Object.assign(s.style,{right:`${innerWidth-i.right+4}px`,top:`${Math.max(0,i.top+4)}px`}),s.addEventListener(`click`,()=>{n!==0&&(x.current=n,x.display=`inplace`,p(),Y(t),g(t),X())}),y.append(a,s)}let E=K(`div`,{class:`lv-card lv-ctrl`,"data-sid":t.sid}),D=K(`span`,{class:`st ${T?`busy`:t.status===`failed`?`err`:``}`},r[`status_${t.status}`]??t.status);if(!i)E.append(D,K(`span`,{class:`msg`},r.otherRoute),q(r.goThere,()=>f(t.url)&&(location.href=t.url)),q(r.discard,()=>h({op:`discard`,sid:t.sid})));else if(t.status===`failed`)E.append(D,K(`span`,{class:`msg`,title:t.error??``},I(t.error??``,80)),q(r.retry,()=>h({op:`retry`,sid:t.sid}))),t.accepted!==void 0&&E.append(q(r.retryAccept,()=>h({op:`retry`,sid:t.sid,andAccept:!0}))),E.append(q(r.discard,()=>h({op:`discard`,sid:t.sid})));else if(T)E.append(D,K(`span`,{class:`lbl`},I(t.prompt||(t.action?r.actions[t.action]:``)||``,40))),(t.status===`generating`||t.status===`refining`)&&E.append(q(r.discard,()=>h({op:`discard`,sid:t.sid})));else if(t.status===`ready`&&!b){let e=d.get(t.sid)??Date.now();d.set(t.sid,e),Date.now()-e<4e3?(E.append(D),clearTimeout(ke),ke=window.setTimeout(X,4050-(Date.now()-e))):o?E.append(K(`span`,{class:`st err`},r.notFound),q(r.discard,()=>h({op:`discard`,sid:t.sid}))):E.append(K(`span`,{class:`st err`},r.notMounted),q(r.reload,()=>location.reload()),q(r.tellAgent,()=>h({op:`mount_failed`,sid:t.sid,url:location.href,reason:`wrapper [data-ph-live] not found in the DOM`})),q(r.discard,()=>h({op:`discard`,sid:t.sid})))}else if(t.status===`ready`&&b){d.delete(t.sid);let e=t.variants.length,n=t.variants.findIndex(e=>e.index===x.current),i=t.variants[n]?.label??``,a=q(r.original,()=>{});a.addEventListener(`pointerdown`,()=>(c=!0,Y(t)));let s=()=>{c&&(c=!1,Y(t),X())};a.addEventListener(`pointerup`,s),a.addEventListener(`pointerleave`,s),E.append(q(`‹`,()=>we(t,-1),`icon`),K(`span`,{class:`idx`},`${n+1}/${e}`),q(`›`,()=>we(t,1),`icon`),K(`span`,{class:`lbl`,title:i},i),a),o||E.append(x.display===`compare`?q(r.inplace,()=>(x.display=`inplace`,p(),Y(t),g(t),X())):q(r.compare,()=>(x.display=`compare`,p(),Y(t),g(t),X())));let l=S.find(e=>V(e)===x.current);H(l).length&&E.append(q(r.params,()=>De(t,E.getBoundingClientRect())));let f=K(`input`,{placeholder:r.refinePlaceholder});f.value=Oe.get(t.sid)??``,f.addEventListener(`input`,()=>Oe.set(t.sid,f.value)),f.addEventListener(`keydown`,e=>{e.stopPropagation(),e.key===`Enter`&&!e.isComposing&&f.value.trim()&&(h({op:`refine`,sid:t.sid,variant:x.current,prompt:f.value.trim()}),Oe.delete(t.sid))}),f.addEventListener(`focus`,()=>u=t.sid),E.append(f,q(r.discard,()=>h({op:`discard`,sid:t.sid})),q(r.accept,()=>Te(t),`primary`)),E.addEventListener(`pointerenter`,()=>u=t.sid)}else continue;E.dataset.v=`${t.updatedAt}:${c}:${l}`;let O=`${E.className}|${E.dataset.v}|${E.innerHTML}`,k=e.get(t.sid),A=k&&Ae.get(k)===O?k:E;Ae.set(A,O);let j=v.children[n.length];if(j!==A&&v.insertBefore(A,j??null),k&&k!==A&&k.remove(),n.push(A),w){let e=A.offsetWidth,t=Math.min(Math.max(8,w.right-e),innerWidth-e-8),n=w.top-A.offsetHeight-8;n<8&&(n=Math.min(w.bottom+8,innerHeight-A.offsetHeight-80)),A.style.left=`${t}px`,A.style.top=`${Math.max(8,n)}px`}else A.style.right=`16px`,A.style.bottom=`${72+n.length*44}px`}for(let e of[...v.children])n.includes(e)||e.remove();if(t.setEye(a),Z){let e=v.querySelector(`.lv-ctrl[data-sid="${Z.sid}"] input`);e&&(e.focus(),e.setSelectionRange(Z.pos,Z.pos))}},Z=null,Q=()=>{let e=t.root.activeElement,n=e?.closest?.(`.lv-ctrl`);Z=e&&n&&e.tagName===`INPUT`?{sid:n.dataset.sid,pos:e.selectionStart??0}:null,X(),Z=null},je=()=>{for(let e of i)R(e)&&Y(e)},Me=!1,$=()=>{Me||(Me=!0,requestAnimationFrame(()=>{Me=!1,je(),Q()}))},Ne=new MutationObserver(e=>{e.every(e=>t.isOwn(e.target))||i.some(e=>e.status!==`accepted`&&e.status!==`discarded`)&&$()});Ne.observe(document.documentElement,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:[`hidden`,`data-ph-live`,`data-ph-variant`,`style`,`src`]}),addEventListener(`scroll`,$,!0),addEventListener(`resize`,$);let Pe=setInterval(()=>i.some(e=>e.status===`ready`||ye.includes(e.status))&&$(),1e3),Fe=e=>{if(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;let t=e.composedPath()[0];if(t&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))||t&&t!==document.body&&t!==document.documentElement&&!(t.closest?.(`.lv-ctrl`)||e.composedPath().some(e=>e instanceof Element&&e.classList?.contains(`lv-ctrl`))))return;let n=i.filter(e=>e.status===`ready`&&R(e)&&Se(e)),r=n.find(e=>e.sid===u)??n[n.length-1];if(r){if(e.key===`ArrowLeft`)we(r,-1);else if(e.key===`ArrowRight`)we(r,1);else if(e.key===`Enter`)Te(r);else return;e.preventDefault(),e.stopPropagation()}};addEventListener(`keydown`,Fe,!0),window.__phLive={version:1,setSessions(e){let t=new Map(i.map(e=>[e.sid,e.status]));i=[...e].sort((e,t)=>e.createdAt-t.createdAt);let n=new Set(i.filter(e=>W(e)&&e.status!==`accepted`&&e.status!==`discarded`).map(e=>e.sid));U.prune(e=>n.has(e.slice(0,e.indexOf(`:`))));let r=new Set(i.filter(e=>e.status!==`accepted`&&e.status!==`discarded`).map(e=>e.sid));for(let e of[G,d,Oe])for(let t of[...e.keys()])r.has(t)||e.delete(t);for(let e of i)if(e.status===`ready`&&t.get(e.sid)!==`ready`){let t=m(e);e.variants.some(e=>e.index===t.current)||(t.current=e.variants[0]?.index??1),p(),u=e.sid}je(),Q()},nav(e,t,n){let r=i.find(t=>t.sid===e);if(!r)return;let a=m(r);t!==void 0&&(a.current=t),n&&(a.display=n),p(),Y(r),Ce(r),Q(),(W(r)?G.get(e)?.[0]:z(e))?.scrollIntoView?.({block:`nearest`,behavior:le()?`auto`:`smooth`})},onPick:O,design:e=>L(e),setPicking(e){a=e,e||w(),x()},setLang(e){r=ge(e),x(),Q()},eye(e){e===`down`?c=!0:e===`up`?c=!1:l=!l,je(),Q()},dispose(){Ne.disconnect(),clearInterval(Pe),removeEventListener(`scroll`,$,!0),removeEventListener(`resize`,$),removeEventListener(`keydown`,Fe,!0),U.prune(()=>!1),_.remove(),n.remove()}}}window.__phHost&&!window.__phLive&&J(window.__phHost)})();
64
+ `,xe=`ph:live-view`,Se=[`generating`,`refining`,`accepting`,`discarding`];function J(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))e===`class`?r.className=n:r.setAttribute(e,n);for(let e of n)r.append(e);return r}function Y(e,t,n=``){let r=J(`button`,n?{class:n}:{},e);return r.addEventListener(`click`,e=>{e.stopPropagation(),t()}),r}function Ce(t){let n=document.createElement(`style`);n.textContent=be,t.root.appendChild(n);let r=ye(t.lang()),i=[],a=!1,o=`select`,s={};try{s=JSON.parse(sessionStorage.getItem(xe)||`{}`)}catch{}let c=!1,l=!1,u=null,d=new Map,f=e=>{try{return!!e&&new URL(e,location.href).origin===location.origin}catch{return!1}},p=()=>{let e=Object.keys(s);if(e.length>20)for(let t of e.slice(0,e.length-20))delete s[t];try{sessionStorage.setItem(xe,JSON.stringify(s))}catch{}},m=e=>{let t=s[e.sid];return t||(t=s[e.sid]={current:e.variants[0]?.index??1,display:e.display,params:{}},p()),e.variants.length&&!e.variants.some(e=>e.index===t.current)&&t.current!==0&&(t.current=e.variants[0].index),t},h=e=>t.send({type:`ph:live`,request:e}),g=e=>{let n=m(e);t.send({type:`ph:live-view`,sid:e.sid,current:n.current,display:n.display})},_=J(`div`,{class:`lv-root`});t.layer.appendChild(_);let v=J(`div`),y=J(`div`);_.append(y,v);let b=null,x=()=>{if(b?.remove(),b=null,!a)return;t.patchMode()&&(o=`select`);let e=J(`div`,{class:`lv-seg`});e.append(Y(r.modeSelect,()=>(o=`select`,x()),o===`select`?`on`:``)),t.patchMode()||e.append(Y(r.modeInsert,()=>(o=`insert`,x()),o===`insert`?`on`:``));let n=J(`input`,{placeholder:r.steerPlaceholder}),i=Y(r.steerGo,()=>{let e=n.value.trim();if(!e)return n.focus();h({op:`steer`,prompt:e,count:3,display:`inplace`,url:location.href,scope:`page`}),n.value=``,t.setPicking(!1)},`primary`);n.addEventListener(`keydown`,e=>{e.stopPropagation(),e.key===`Enter`&&!e.isComposing&&i.click()}),b=J(`div`,{class:`lv-card lv-pickbar`},e,n,i),_.appendChild(b)},S=null,C=null,w=()=>{S?.remove(),S=null,C?.(),C=null},T=(e,t,n=!0)=>{let r=e.offsetWidth||300,i=e.offsetHeight||40,a=Math.min(Math.max(8,t.left),innerWidth-r-8),o=n?t.bottom+8:t.top-i-8;o+i>innerHeight-8&&(o=t.top-i-8),o<8&&(o=Math.min(innerHeight-i-8,t.bottom+8)),o<8&&(o=8),a=Math.max(8,a),e.style.left=`${a}px`,e.style.top=`${o}px`},E=e=>{let t=e.closest(`[data-ph-live]`);if(!t)return!1;let n=t.getAttribute(`data-ph-live`);return i.some(e=>e.sid===n&&e.status!==`accepted`&&e.status!==`discarded`)},D=e=>{if(w(),E(e))return t.toast(`warn`,r.blockedNested),!0;if(o!==`insert`||t.patchMode())return!1;let n=e.getBoundingClientRect();S=J(`div`,{class:`lv-card lv-pop`},Y(r.before,()=>(w(),I(e,`before`))),Y(r.after,()=>(w(),I(e,`after`))),Y(`✕`,w)),_.appendChild(S),T(S,n);let i=S;return C=le(()=>T(i,e.getBoundingClientRect()),[e]),!0},O=[],k=null,A=()=>{if(k?.remove(),k=null,!O.length||!N)return;k=J(`div`,{class:`lv-marks`});let e=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);for(let t of O)if(t.kind===`stroke`&&t.points){let n=document.createElementNS(`http://www.w3.org/2000/svg`,`polyline`);n.setAttribute(`points`,t.points.map(e=>e.join(`,`)).join(` `)),n.setAttribute(`fill`,`none`),n.style.stroke=`var(--err)`,n.setAttribute(`stroke-width`,`3`),n.setAttribute(`stroke-linecap`,`round`),n.setAttribute(`stroke-linejoin`,`round`),e.appendChild(n)}k.appendChild(e);for(let e of O){let t=e.at??e.points?.[0];if(!t)continue;let n=J(`div`,{class:`lv-pin`},String(e.n));n.style.left=`${t[0]}px`,n.style.top=`${t[1]}px`,k.appendChild(n)}y.appendChild(k)},j=e=>{let n=new Set;t.setUiHidden(!0);try{let r=Math.max(1,Math.floor(e.length/6));for(let i=0;i<e.length;i+=r){let r=document.elementsFromPoint(e[i][0],e[i][1]).find(e=>!t.isOwn(e)&&e!==document.documentElement&&e!==document.body);if(r&&n.add(ae(r)),n.size>=3)break}}finally{t.setUiHidden(!1)}return[...n]},te=(e,t,n)=>{let i=J(`input`,{placeholder:r.notePlaceholder}),a=J(`div`,{class:`lv-card lv-note`},i,Y(`✓`,()=>o(),`primary`)),o=()=>{t.note=i.value.trim()||void 0,a.remove(),n()};i.addEventListener(`keydown`,e=>{e.stopPropagation(),e.key===`Enter`&&!e.isComposing&&o(),e.key===`Escape`&&o()}),_.appendChild(a),a.style.left=`${Math.min(e[0]+14,innerWidth-236)}px`,a.style.top=`${Math.min(e[1]+14,innerHeight-50)}px`,i.focus()},M=(e,n)=>{if(O.length>=8)return t.toast(`warn`,r.maxMarks);let i=J(`div`,{class:`lv-draw`}),a=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`),o=document.createElementNS(`http://www.w3.org/2000/svg`,`polyline`);o.setAttribute(`fill`,`none`),o.style.stroke=`var(--err)`,o.setAttribute(`stroke-width`,`3`),a.appendChild(o),i.appendChild(a),i.tabIndex=-1,_.appendChild(i),i.focus({preventScroll:!0});let s=[],c=e=>{if(i.remove(),!e)return n();O.push(e),A(),te(e.at??e.points[0],e,()=>{A(),n()})};if(i.addEventListener(`keydown`,e=>e.key===`Escape`&&c(null)),e===`pin`){i.addEventListener(`click`,e=>{let t=[e.clientX,e.clientY];c({n:O.length+1,kind:`pin`,at:t,targets:j([t])})});return}i.addEventListener(`pointerdown`,e=>{i.setPointerCapture(e.pointerId),s.push([e.clientX,e.clientY]);let t=e=>{s.push([e.clientX,e.clientY]),o.setAttribute(`points`,s.map(e=>e.join(`,`)).join(` `))};i.addEventListener(`pointermove`,t),i.addEventListener(`pointerup`,()=>{if(i.removeEventListener(`pointermove`,t),s.length<3)return c(null);let e=s.filter((e,t)=>t%2==0).slice(0,200);c({n:O.length+1,kind:`stroke`,points:e,targets:j(e)})},{once:!0})})},ne=()=>[...t.root.querySelectorAll(`.drawer, .dock`)].map(e=>e.getBoundingClientRect()).filter(e=>e.width&&e.height),N=null,P=null,F=()=>{N?.remove(),N=null,P?.(),P=null,O=[],A()},I=(n,i)=>{F(),t.setPicking(!1);let a=ue(n),o=i?`freeform`:`polish`,s=3,c=`inplace`,l=J(`div`,{class:`lv-card lv-design`}),u=J(`h4`,{},r.designTitle,J(`span`,{class:`sp`}),Y(`✕`,F,`ghost icon`)),d=J(`div`,{class:`lv-target`,title:a.selector},...i?[J(`span`,{class:`pos`},i===`before`?r.before:r.after)]:[],J(`span`,{class:`tag`},a.tagName.toLowerCase()),J(`span`,{class:`txt`},B(a.text||a.selector,80))),f=J(`div`,{class:`lv-actions`}),p=()=>{f.replaceChildren(...e.map(e=>Y(r.actions[e]??e,()=>(o=e,p()),e===o?`on`:``)))};i||p();let m=J(`textarea`,{placeholder:i?r.insertPlaceholder:r.promptPlaceholder,rows:`3`});m.addEventListener(`keydown`,e=>{e.stopPropagation(),e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&!e.isComposing&&S()});let g=J(`span`,{class:`sp`}),v=()=>g.textContent=O.length?`${O.length}/8`:``,y=J(`div`,{class:`lv-row`},J(`label`,{},r.marks),Y(r.draw,()=>M(`stroke`,v)),Y(r.pin,()=>M(`pin`,v)),g,Y(r.undo,()=>(O.pop(),A(),v()),`ghost`),Y(r.clear,()=>(O=[],A(),v()),`ghost`)),b=J(`div`,{class:`lv-row`}),x=()=>{let e=J(`div`,{class:`lv-seg`},...[2,3,4].map(e=>Y(String(e),()=>(s=e,x()),e===s?`on`:``)));if(t.patchMode())return b.replaceChildren(J(`label`,{},r.count),e);let n=J(`div`,{class:`lv-seg`},Y(r.inplace,()=>(c=`inplace`,x()),c===`inplace`?`on`:``),Y(r.compare,()=>(c=`compare`,x()),c===`compare`?`on`:``));b.replaceChildren(J(`label`,{},r.count),e,J(`span`,{class:`sp`}),J(`label`,{},r.display),n)};x();let S=()=>{let e=m.value.trim();if(i&&!e)return m.focus();let t=i?{op:`insert`,target:a,position:i,prompt:e,count:s,display:c,marks:O.length?O:void 0,url:location.href,scope:`element`}:{op:`generate`,target:a,action:o,prompt:e||void 0,count:s,display:c,marks:O.length?O:void 0,url:location.href,scope:`element`};h(t),F()},C=J(`div`,{class:`lv-foot`},Y(r.cancel,F),Y(r.generate,S,`primary`));l.append(u,d),i||l.append(f),l.append(m,y,b,C),N=l,_.appendChild(l);let w=()=>ce(l,n.getBoundingClientRect(),{avoid:ne()});w();let T=le(w,[n,l]),E=new MutationObserver(w),D=t.root.querySelector(`.drawer`);D&&E.observe(D,{attributes:!0,attributeFilter:[`style`,`hidden`]}),P=()=>(T(),E.disconnect()),m.focus()},re=e=>{if(!e)return``;try{let t=new URL(e,location.href);return t.pathname+t.search}catch{return e}},L=e=>!e.url||re(e.url)===location.pathname+location.search,R=e=>document.querySelector(`[data-ph-live="${CSS.escape(e)}"]`),z=e=>[...e.children].filter(e=>e instanceof HTMLElement&&e.hasAttribute(`data-ph-variant`)),V=e=>Number(e.getAttribute(`data-ph-variant`)),oe=e=>{let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e){let e=a.getBoundingClientRect();(e.width||e.height)&&(t=Math.min(t,e.left),n=Math.min(n,e.top),r=Math.max(r,e.right),i=Math.max(i,e.bottom))}return t===1/0?null:new DOMRect(t,n,r-t,i-n)},H=e=>{if(!e)return[];try{let t=JSON.parse(e.getAttribute(`data-ph-params`)||`[]`);return Array.isArray(t)?t.filter(e=>e&&typeof e.name==`string`&&/^[\w-]+$/.test(e.name)).slice(0,6):[]}catch{return[]}},se=(e,t)=>t[e.name]===void 0?e.type===`toggle`?e.default===!1||e.default===`false`||e.default===0?`0`:`1`:e.type===`steps`?String(e.default??e.options?.[0]??``):String(e.default??e.min??0):t[e.name],U=fe(),W=e=>e.source===`patch`,G=new Map,pe=(e,t,n)=>`${e}:${t}:${n.selector}:${JSON.stringify(n.patch)}`,K=e=>{let n=e=>t.isOwn(e),r=ie(e.selector,e.anchor,{isOwn:n,altTexts:e.patch.text===void 0?[]:[e.patch.text]})?.el??null;if(!r)try{r=[...document.querySelectorAll(e.selector)].find(e=>!n(e))??null}catch{}return r instanceof HTMLElement?r:null},me=e=>{let t=m(e),n=L(e)&&(e.status===`ready`||e.status===`refining`),r=n&&!c&&!l,i=n?e.variants.find(e=>e.index===t.current):void 0,a=new Set(r&&i?i.changes?.map(t=>pe(e.sid,i.index,t))??[]:[]);U.prune(t=>!t.startsWith(`${e.sid}:`)||a.has(t));let o=[];for(let t of i?.changes??[]){let n=r?U.ensure(pe(e.sid,i.index,t),t.patch,()=>K(t)):K(t);n&&o.push(n)}return G.set(e.sid,o),o.length>0},he=e=>U.prune(t=>!t.startsWith(`${e}:`)),ve=e=>W(e)?!!G.get(e.sid)?.length:!!R(e.sid),q=e=>{if(W(e))return me(e);let t=R(e.sid);if(!t)return!1;let n=m(e),r=z(t),i=c||l;for(let t of r){let r=V(t),a;a=e.status===`accepted`||e.status===`discarded`||i?r===0:n.display===`compare`||r===n.current,t.hidden===a&&(t.hidden=!a)}let a=r.find(e=>V(e)===n.current),o=n.params[n.current]??{};for(let e of H(a)){let n=se(e,o),r=e.type===`range`?`${n}${e.unit??``}`:n;t.style.getPropertyValue(`--ph-${e.name}`)!==r&&t.style.setProperty(`--ph-${e.name}`,r),t.getAttribute(`data-ph-param-${e.name}`)!==n&&t.setAttribute(`data-ph-param-${e.name}`,n)}return!0},Ce=e=>{if(de())return;let t=W(e)?null:R(e.sid);(W(e)?G.get(e.sid)?.[0]:t&&z(t).find(t=>V(t)===m(e).current))?.animate?.([{opacity:0,transform:`translateY(4px)`},{opacity:1,transform:`none`}],{duration:180,easing:`ease-out`})},we=(e,t)=>{let n=m(e),r=e.variants.map(e=>e.index);r.length&&(n.current=r[(r.indexOf(n.current)+t+r.length)%r.length],n.display=`inplace`,p(),q(e),Ce(e),g(e),X())},Te=e=>{let t=m(e),n;if(W(e)){let r=e.variants.find(e=>e.index===t.current)?.changes??[],i=ee(r),a=new Map,o=e=>{let t=r.find(t=>t.selector===e),n=t?K(t):null;return n?ge(n):null};for(let e of i){let t=o(e);t&&a.set(e,_e(t))}he(e.sid),G.delete(e.sid),n=[];for(let e of i){let t=o(e),r=t?_e(t):void 0,i=a.get(e);(r||i)&&n.push({selector:e,look:{beforeHtml:r,afterHtml:i}})}}h({op:`accept`,sid:e.sid,variant:t.current,params:t.params[t.current],looks:n})},Ee=null,De=(e,t)=>{Ee?.remove();let n=R(e.sid),i=m(e),a=n?z(n).find(e=>V(e)===i.current):void 0,o=H(a);if(!o.length)return;let s=i.params[i.current]??={},c=J(`div`,{class:`lv-card lv-params`},J(`h4`,{},r.params));for(let t of o){let n=se(t,s),r=J(`div`,{class:`p`}),i=J(`span`,{},t.type===`range`?`${n}${t.unit??``}`:n);r.append(J(`div`,{class:`h`},J(`span`,{},t.label||t.name),i));let a=n=>{s[t.name]=n,i.textContent=t.type===`range`?`${n}${t.unit??``}`:n,p(),q(e)};if(t.type===`range`){let e=J(`input`,{type:`range`,min:String(t.min??0),max:String(t.max??100),step:String(t.step??1),value:n});e.addEventListener(`input`,()=>a(e.value)),r.append(e)}else if(t.type===`steps`){let e=J(`div`,{class:`lv-seg`}),i=()=>e.replaceChildren(...(t.options??[]).map(e=>Y(e,()=>(a(e),i()),(s[t.name]??n)===e?`on`:``)));i(),r.append(e)}else{let e=Y(``,()=>{let r=(s[t.name]??n)===`1`?`0`:`1`;a(r),e.textContent=r===`1`?`ON`:`OFF`,e.classList.toggle(`on`,r===`1`)},n===`1`?`on`:``);e.textContent=n===`1`?`ON`:`OFF`,r.append(e)}c.append(r)}c.append(J(`div`,{class:`lv-foot`},Y(`✓`,()=>(c.remove(),Ee=null)))),Ee=c,_.appendChild(c),T(c,t)},Oe=new Map,ke=0,Ae=new WeakMap,X=()=>{let e=new Map([...v.children].map(e=>[e.dataset.sid??``,e])),n=[];y.querySelectorAll(`.lv-shimmer, .lv-outline, .lv-badge`).forEach(e=>e.remove());let a=!1;for(let t of i){if(t.status===`accepted`||t.status===`discarded`)continue;let i=L(t),o=W(t),s=i&&!o?R(t.sid):null,_=i&&o?G.get(t.sid)??[]:[],b=o?_.length>0:!!s,x=m(t),S=s?z(s):[],C=S.filter(e=>!e.hidden),w=s?oe(C.length?C:S):_.length?oe(_):null;if(!w&&i&&t.target)try{let e=document.querySelector(t.target.selector);e&&(w=e.getBoundingClientRect())}catch{}let T=Se.includes(t.status);if(T&&w){let e=J(`div`,{class:`lv-shimmer`});Object.assign(e.style,{left:`${w.left}px`,top:`${w.top}px`,width:`${w.width}px`,height:`${w.height}px`}),y.appendChild(e)}if(b&&t.status===`ready`&&(a=!0),s&&t.status===`ready`&&x.display===`compare`&&!c&&!l)for(let e of S){let n=V(e),i=e.getBoundingClientRect();if(!i.width&&!i.height)continue;let a=J(`div`,{class:`lv-outline`});Object.assign(a.style,{left:`${i.left-2}px`,top:`${i.top-2}px`,width:`${i.width+4}px`,height:`${i.height+4}px`});let o=n===0?r.original:t.variants.find(e=>e.index===n)?.label??`#${n}`,s=J(`div`,{class:`lv-badge`},`${n===0?``:`${n} · `}${o}`);Object.assign(s.style,{right:`${innerWidth-i.right+4}px`,top:`${Math.max(0,i.top+4)}px`}),s.addEventListener(`click`,()=>{n!==0&&(x.current=n,x.display=`inplace`,p(),q(t),g(t),X())}),y.append(a,s)}let E=J(`div`,{class:`lv-card lv-ctrl`,"data-sid":t.sid}),D=J(`span`,{class:`st ${T?`busy`:t.status===`failed`?`err`:``}`},r[`status_${t.status}`]??t.status);if(!i)E.append(D,J(`span`,{class:`msg`},r.otherRoute),Y(r.goThere,()=>f(t.url)&&(location.href=t.url)),Y(r.discard,()=>h({op:`discard`,sid:t.sid})));else if(t.status===`failed`)E.append(D,J(`span`,{class:`msg`,title:t.error??``},B(t.error??``,80)),Y(r.retry,()=>h({op:`retry`,sid:t.sid}))),t.accepted!==void 0&&E.append(Y(r.retryAccept,()=>h({op:`retry`,sid:t.sid,andAccept:!0}))),E.append(Y(r.discard,()=>h({op:`discard`,sid:t.sid})));else if(T)E.append(D,J(`span`,{class:`lbl`},B(t.prompt||(t.action?r.actions[t.action]:``)||``,40))),(t.status===`generating`||t.status===`refining`)&&E.append(Y(r.discard,()=>h({op:`discard`,sid:t.sid})));else if(t.status===`ready`&&!b){let e=d.get(t.sid)??Date.now();d.set(t.sid,e),Date.now()-e<4e3?(E.append(D),clearTimeout(ke),ke=window.setTimeout(X,4050-(Date.now()-e))):o?E.append(J(`span`,{class:`st err`},r.notFound),Y(r.discard,()=>h({op:`discard`,sid:t.sid}))):E.append(J(`span`,{class:`st err`},r.notMounted),Y(r.reload,()=>location.reload()),Y(r.tellAgent,()=>h({op:`mount_failed`,sid:t.sid,url:location.href,reason:`wrapper [data-ph-live] not found in the DOM`})),Y(r.discard,()=>h({op:`discard`,sid:t.sid})))}else if(t.status===`ready`&&b){d.delete(t.sid);let e=t.variants.length,n=t.variants.findIndex(e=>e.index===x.current),i=t.variants[n]?.label??``,a=Y(r.original,()=>{});a.addEventListener(`pointerdown`,()=>(c=!0,q(t)));let s=()=>{c&&(c=!1,q(t),X())};a.addEventListener(`pointerup`,s),a.addEventListener(`pointerleave`,s),E.append(Y(`‹`,()=>we(t,-1),`icon`),J(`span`,{class:`idx`},`${n+1}/${e}`),Y(`›`,()=>we(t,1),`icon`),J(`span`,{class:`lbl`,title:i},i),a),o||E.append(x.display===`compare`?Y(r.inplace,()=>(x.display=`inplace`,p(),q(t),g(t),X())):Y(r.compare,()=>(x.display=`compare`,p(),q(t),g(t),X())));let l=S.find(e=>V(e)===x.current);H(l).length&&E.append(Y(r.params,()=>De(t,E.getBoundingClientRect())));let f=J(`input`,{placeholder:r.refinePlaceholder});f.value=Oe.get(t.sid)??``,f.addEventListener(`input`,()=>Oe.set(t.sid,f.value)),f.addEventListener(`keydown`,e=>{e.stopPropagation(),e.key===`Enter`&&!e.isComposing&&f.value.trim()&&(h({op:`refine`,sid:t.sid,variant:x.current,prompt:f.value.trim()}),Oe.delete(t.sid))}),f.addEventListener(`focus`,()=>u=t.sid),E.append(f,Y(r.discard,()=>h({op:`discard`,sid:t.sid})),Y(r.accept,()=>Te(t),`primary`)),E.addEventListener(`pointerenter`,()=>u=t.sid)}else continue;E.dataset.v=`${t.updatedAt}:${c}:${l}`;let O=`${E.className}|${E.dataset.v}|${E.innerHTML}`,k=e.get(t.sid),A=k&&Ae.get(k)===O?k:E;Ae.set(A,O);let j=v.children[n.length];if(j!==A&&v.insertBefore(A,j??null),k&&k!==A&&k.remove(),n.push(A),w){let e=A.offsetWidth,t=Math.min(Math.max(8,w.right-e),innerWidth-e-8),n=w.top-A.offsetHeight-8;n<8&&(n=Math.min(w.bottom+8,innerHeight-A.offsetHeight-80)),A.style.left=`${t}px`,A.style.top=`${Math.max(8,n)}px`}else A.style.right=`16px`,A.style.bottom=`${72+n.length*44}px`}for(let e of[...v.children])n.includes(e)||e.remove();if(t.setEye(a),Z){let e=v.querySelector(`.lv-ctrl[data-sid="${Z.sid}"] input`);e&&(e.focus(),e.setSelectionRange(Z.pos,Z.pos))}},Z=null,Q=()=>{let e=t.root.activeElement,n=e?.closest?.(`.lv-ctrl`);Z=e&&n&&e.tagName===`INPUT`?{sid:n.dataset.sid,pos:e.selectionStart??0}:null,X(),Z=null},je=()=>{for(let e of i)L(e)&&q(e)},Me=!1,$=()=>{Me||(Me=!0,requestAnimationFrame(()=>{Me=!1,je(),Q()}))},Ne=new MutationObserver(e=>{e.every(e=>t.isOwn(e.target))||i.some(e=>e.status!==`accepted`&&e.status!==`discarded`)&&$()});Ne.observe(document.documentElement,{subtree:!0,childList:!0,characterData:!0,attributes:!0,attributeFilter:[`hidden`,`data-ph-live`,`data-ph-variant`,`style`,`src`]}),addEventListener(`scroll`,$,!0),addEventListener(`resize`,$);let Pe=setInterval(()=>i.some(e=>e.status===`ready`||Se.includes(e.status))&&$(),1e3),Fe=e=>{if(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;let t=e.composedPath()[0];if(t&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))||t&&t!==document.body&&t!==document.documentElement&&!(t.closest?.(`.lv-ctrl`)||e.composedPath().some(e=>e instanceof Element&&e.classList?.contains(`lv-ctrl`))))return;let n=i.filter(e=>e.status===`ready`&&L(e)&&ve(e)),r=n.find(e=>e.sid===u)??n[n.length-1];if(r){if(e.key===`ArrowLeft`)we(r,-1);else if(e.key===`ArrowRight`)we(r,1);else if(e.key===`Enter`)Te(r);else return;e.preventDefault(),e.stopPropagation()}};addEventListener(`keydown`,Fe,!0),window.__phLive={version:1,setSessions(e){let t=new Map(i.map(e=>[e.sid,e.status]));i=[...e].sort((e,t)=>e.createdAt-t.createdAt);let n=new Set(i.filter(e=>W(e)&&e.status!==`accepted`&&e.status!==`discarded`).map(e=>e.sid));U.prune(e=>n.has(e.slice(0,e.indexOf(`:`))));let r=new Set(i.filter(e=>e.status!==`accepted`&&e.status!==`discarded`).map(e=>e.sid));for(let e of[G,d,Oe])for(let t of[...e.keys()])r.has(t)||e.delete(t);for(let e of i)if(e.status===`ready`&&t.get(e.sid)!==`ready`){let t=m(e);e.variants.some(e=>e.index===t.current)||(t.current=e.variants[0]?.index??1),p(),u=e.sid}je(),Q()},nav(e,t,n){let r=i.find(t=>t.sid===e);if(!r)return;let a=m(r);t!==void 0&&(a.current=t),n&&(a.display=n),p(),q(r),Ce(r),Q(),(W(r)?G.get(e)?.[0]:R(e))?.scrollIntoView?.({block:`nearest`,behavior:de()?`auto`:`smooth`})},onPick:D,design:e=>I(e),setPicking(e){a=e,e||w(),x()},setLang(e){r=ye(e),x(),Q()},eye(e){e===`down`?c=!0:e===`up`?c=!1:l=!l,je(),Q()},dispose(){Ne.disconnect(),clearInterval(Pe),removeEventListener(`scroll`,$,!0),removeEventListener(`resize`,$),removeEventListener(`keydown`,Fe,!0),U.prune(()=>!1),_.remove(),n.remove()}}}window.__phHost&&!window.__phLive&&Ce(window.__phHost)})();