@xopcai/xopc 0.0.272 → 0.0.273
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 +1 -5
- package/README.zh-CN.md +1 -5
- package/dist/browser-ext/dist/assets/{auth-C1QI-uMG.js → auth-DkwOUI6_.js} +101 -53
- package/dist/browser-ext/dist/background.js +1 -22
- package/dist/browser-ext/dist/sidepanel.html +1 -1
- package/dist/browser-ext/dist/sidepanel.js +24 -22
- package/dist/browser-ext/manifest.json +1 -12
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-DffqjeqQ.js → activity-store-cF7IX2RP.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Cwj4HCYY.js → agent-avatar-dicebear-BrgxX8nG.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-6CLfLxVc.js → agent-defaults-settings-panel-DvhuRCLA.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-B6mu64fY.js → agents-C0By2FIo.js} +1 -1
- package/dist/gateway/static/root/assets/{api-CGLdye4i.js → api-CYkdUpkx.js} +1 -1
- package/dist/gateway/static/root/assets/app-link-BiBXVEvp.js +1 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-BLujSbaw.js → app-management-settings-panel-DfoNzWIa.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BXMcueb8.js → appearance-settings-czbLdCqj.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-BEgy4hY3.js → apps-page-BSJXKWcE.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-D4bUampf.js → archive-plugin-D14P13mX.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CBGNA2Ys.js → attachment-load-Dok_B1Gv.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-dQyolNmy.js → automations-page-DM7ZEewI.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-DxRFrmrV.js → automations-workspace--1TsZf3O.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-bbvp81h2.js → binary-plugins-CxNg6InF.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-C8e6Wri4.js → block-editor-D22VcYnC.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automation-inputs-oJWJtQa6.js → browser-automation-inputs-6NWTLEpd.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-CAcJQSjN.js → browser-automations-page-BrqySdbW.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-TLAlqcPo.js → browser-settings-page-DOHgQer_.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-z-K_jrZz.js → capabilities-settings-panel-Bpse_5K-.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-Dzrk33aB.js → channels-settings-yHsY174W.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-status-swr-CfOPNnVr.js → channels-status-swr-BUZimNmp.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-9ZOl92kh.js → chat-terminal-dock-CZPBNpMI.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-B1dIoRNi.js → connectors-page-B_wLKGnH.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-Dj6FRLF9.js → date-picker-Da_0QyLe.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-D1q89tVc.js → dependency-picker-D_djqzy7.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-DfqZBvhp.js → desktop-pet-Celmbw-T.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-HCEh2MOm.js → desktop-pet-settings-CqNNgF45.js} +1 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-B5_w9qlm.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-C8cAWVoK.js → extension-debug-page-ku3kCjvH.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-5N87Vaym.js → extension-page-C7FpHwL4.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-D85SAUFP.js → extension-settings-page-OMj2tU2_.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-BjsDnB_n.js → gateway-config-swr-6eb1vKE1.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-Dqx8PmcT.js → gateway-settings-CH-6vkgN.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-BIf0eLWX.js → gateway-startup-retry-DUFFCU8H.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-BpDWGE1a.js → heartbeat-settings-CSFzOACM.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-DJaqpC8-.js → home-page-BJebAKB-.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-1m8xTVS_.js → image-generation-api-C1cHRBRp.js} +1 -1
- package/dist/gateway/static/root/assets/{index-C6PmD0cK.js → index-C6OWYFtQ.js} +9 -9
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-Byy8mCSq.js → keyboard-shortcuts-settings-BuvD3iv8.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-l2AEiG2C.js → local-app-workbench-page-CaC4-THD.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-BPo0wBgM.js → local-apps-page-DdJ8zwBp.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-CRNble2Z.js → locale-store-BBSCIl4I.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-X5FdLlXK.js → logs-page-BaR2he0K.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-DT6NoIjm.js → management-settings-r-iYWZFY.js} +1 -1
- package/dist/gateway/static/root/assets/markdown-view-c5vtnYe8.js +201 -0
- package/dist/gateway/static/root/assets/{media-plugins-Bzka9qXu.js → media-plugins-D_a6GDY6.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-DH_HCgmw.js → messages-DjuBdDCn.js} +2 -2
- package/dist/gateway/static/root/assets/{note-detail-panel-BUJPoaGZ.js → note-detail-panel-BV6nbgac.js} +3 -3
- package/dist/gateway/static/root/assets/{notes-page-BwFpWRuo.js → notes-page-BmLKoWwi.js} +1 -1
- package/dist/gateway/static/root/assets/{page-tabs-Ys0p65Lt.js → page-tabs-C7Le9bSI.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-iknB5xEp.js → preview-open-alternatives-B2pOxJBK.js} +1 -1
- package/dist/gateway/static/root/assets/{proactive-card-BPZDgNNR.js → proactive-card-BlQ1vCtV.js} +1 -1
- package/dist/gateway/static/root/assets/{proactive-page-CxdZR-p2.js → proactive-page-CghKTfYa.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-W1o3f-kz.js → product-open-page-DpjiHgwu.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-BU1RKAcy.js → project-detail-page-CV8Lh296.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-z0X0tL8G.js → projects-page-COweOaJP.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-DmYFpjsH.js → registry-api-CyQ4k1Ux.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-NNTut2I8.js → remote-access-hub-ChPPGVU5.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DP1XyYO8.js → runtime-tools-settings-panel-Bl4ArLHf.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-BMYKdzsH.js → schema-form-KQFmfWd4.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-B6SsHlz5.js → sessions-page-DgmHibOK.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DV7kMco2.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-2LGjz7bu.js → settings-form-section-Dbnls9ty.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-7DjpC9_C.js → settings-page-CDKirYRG.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-Dj9jFWJt.js → setup-status-panel-SQmtWoOs.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-BxYdSi8c.js → share-preview-page-DwgLjS1m.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-CMqE0KuK.js → shares-settings-Cs5bUrYw.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DyKrjq7F.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-DNEScMZH.js → skills-page-Bd0_ED_p.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-q88l65YU.js → skills-page.utils-rA-XT-YG.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-8NIssGKj.js → system-settings-panel-CSkMrHLz.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-L6dp9v2y.js → task-detail-page-CEQU-L_G.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-BXZG3S25.js → theme-store-DWpIEWen.js} +1 -1
- package/dist/gateway/static/root/assets/tunnel-api-COJcGnEi.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-BwQuoTQU.js → use-autosave-DkQAIAuB.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-D4BucMrZ.js → user-model-page-BQAU55lf.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-Bd03Ic0s.js → voice-api-key-field-BrqcH0P-.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-gggUp3u9.js → voice-config-api-BJ95Z3pT.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-DF8PR_pK.js → work-discovery-overlay-vfTWKm13.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BiAAWlir.js → workflow-run-setup-panel-CHdr_ng9.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-DryKUMfA.js → workflows-page-hwRJD7vR.js} +1 -1
- package/dist/gateway/static/root/index.html +10 -9
- package/dist/package.js +1 -1
- package/dist/src/browser/providers/browser-ext-install.d.ts +6 -0
- package/dist/src/browser/providers/browser-ext-install.js +16 -1
- package/dist/src/cli/commands/gateway/run-foreground.js +8 -5
- package/dist/src/cli/commands/gateway/service.js +4 -3
- package/dist/src/cli/commands/gateway/token.js +28 -1
- package/dist/src/gateway/device-routes.js +4 -3
- package/dist/src/gateway/hono/routes/browser.js +26 -0
- package/dist/src/storage/sqlite/device-pairing-approval.js +1 -3
- package/package.json +4 -4
- package/dist/browser-ext/dist/pairing-handoff.js +0 -51
- package/dist/gateway/static/root/assets/device-pairing-wizard-CPth92s6.js +0 -1
- package/dist/gateway/static/root/assets/markdown-view-AglreSOj.js +0 -201
- package/dist/gateway/static/root/assets/settings-advanced-gate-BQu8bAcN.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-BXqSJymN.js +0 -1
- package/dist/gateway/static/root/assets/tunnel-api-CWsRPM84.js +0 -1
package/dist/gateway/static/root/assets/{binary-plugins-bbvp81h2.js → binary-plugins-CxNg6InF.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-preview-renderer-BDTD8YUe.js","assets/preload-helper-zJ_50EbN.js","assets/excel-worksheet-utils-EyvwNT4X.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{t as a}from"./messages-DH_HCgmw.js";import{ea as o,ta as s}from"./index-C6PmD0cK.js";import{t as c}from"./preview-open-alternatives-iknB5xEp.js";import{t as l}from"./use-blob-object-url-D4BFuzZB.js";var u=e(t(),1),d=n();function f(e){let t=e.trim(),n=t.match(/^<pptx\s+filename="([^"]*)">\s*/),r=t;n&&(r=t.slice(n[0].length),r=r.replace(/\s*<\/pptx>\s*$/u,``).trim());let i=[],a=/<slide number="(\d+)">([\s\S]*?)<\/slide>/gu,o;for(;(o=a.exec(r))!==null;){let e=Number.parseInt(o[1],10),t=o[2].trim();i.push({slideNumber:e,text:t})}let s=[],c=/<!--([\s\S]*?)-->/gu,l;for(;(l=c.exec(r))!==null;)s.push(l[1].trim());return i.length===0?{ok:!1,raw:e}:{ok:!0,slides:i,notes:s}}var p=r();function m(e){let t=(0,d.c)(13),{text:n,slideLabel:r,emptySlideLabel:i}=e,a;t[0]===n?a=t[1]:(a=f(n),t[0]=n,t[1]=a);let o=a;if(!o.ok){let e;return t[2]===o.raw?e=t[3]:(e=(0,p.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg`,children:o.raw}),t[2]=o.raw,t[3]=e),e}let s;if(t[4]!==i||t[5]!==o.notes||t[6]!==o.slides||t[7]!==r){let e=[];if(o.notes.length>0){let n;t[9]===o.notes?n=t[10]:(n=o.notes.map(h),t[9]=o.notes,t[10]=n);let r;t[11]===n?r=t[12]:(r=(0,p.jsx)(`div`,{className:`mb-2 border-b border-edge-subtle pb-2 dark:border-edge`,role:`status`,children:n},`notes`),t[11]=n,t[12]=r),e.push(r)}for(let t of o.slides)e.push((0,p.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel p-3 dark:border-edge`,children:[(0,p.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-fg`,children:r(t.slideNumber)}),(0,p.jsx)(`div`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-fg`,children:t.text.length>0?t.text:i})]},t.slideNumber));s=(0,p.jsx)(`div`,{className:`flex flex-col gap-3`,children:e}),t[4]=i,t[5]=o.notes,t[6]=o.slides,t[7]=r,t[8]=s}else s=t[8];return s}function h(e){return(0,p.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e},e)}function g(e,t){return t===`pdf`?a(e).chat.attachmentPreviewPdfRendering:e===`zh`?t===`excel`?`正在加载电子表格…`:`正在加载文档…`:t===`excel`?`Loading spreadsheet...`:`Loading document...`}function _(e,t){e.innerHTML=``;let n=document.createElement(`p`);n.className=`p-4 text-sm text-fg-muted`,n.textContent=t,e.appendChild(n)}function v({language:e,buffer:t,kind:n,fileKey:r,containerEl:o,onPdfPageCount:s}){let c=(0,u.useRef)(null),[l,d]=(0,u.useState)(null),[f,p]=(0,u.useState)(!1);return(0,u.useLayoutEffect)(()=>{if(c.current?.(),c.current=null,d(null),p(!1),!t||!n||!o||!r)return;let l=!1;return _(o,g(e,n)),(async()=>{try{let r=await i(()=>import(`./attachment-preview-renderer-BDTD8YUe.js`),__vite__mapDeps([0,1,2]));if(l)return;let u=a(e).chat;if(n===`pdf`){let{cleanup:e}=await r.renderPdfInContainer(o,t,{loadingText:u.attachmentPreviewPdfRendering,loadMoreHint:u.attachmentPreviewPdfLoadMore,onPageCount:s});c.current=e}else if(n===`excel`){let{cleanup:e,truncated:n}=await r.renderExcelInContainer(o,t,{truncationNotice:u.attachmentPreviewExcelTruncated.replaceAll(`{rows}`,`500`).replaceAll(`{cols}`,`64`)});c.current=e,l||p(n)}else if(n===`docx`){let{cleanup:e}=await r.renderDocxInContainer(o,t);c.current=e}}catch(e){l||d(e instanceof Error?e.message:String(e))}})(),()=>{l=!0,c.current?.(),c.current=null}},[t,n,o,r,e,s]),{error:l,excelTruncated:f}}function y(e){let t=(0,d.c)(12),{props:n,message:r}=e,i;t[0]===n.language?i=t[1]:(i=a(n.language),t[0]=n.language,t[1]=i);let o=i,s=n.descriptor.context===`workspace`,l=!!n.actions.onOpenWithSystemApp&&(n.actions.canOpenWithSystemApp??!0)&&s,u=s?o.workspace.openSystemApp:void 0,f=s?o.workspace.chooseApp:void 0,m;return t[2]!==o.chat.attachmentPreviewDownloadFull||t[3]!==r||t[4]!==n.actions.canChooseOpenWithApp||t[5]!==n.actions.onChooseOpenWithApp||t[6]!==n.actions.onDownload||t[7]!==n.actions.onOpenWithSystemApp||t[8]!==l||t[9]!==u||t[10]!==f?(m=(0,p.jsx)(c,{message:r,downloadLabel:o.chat.attachmentPreviewDownloadFull,onDownload:n.actions.onDownload,openSystemLabel:u,onOpenWithSystemApp:n.actions.onOpenWithSystemApp,canOpenWithSystemApp:l,chooseAppLabel:f,onChooseOpenWithApp:n.actions.onChooseOpenWithApp,canChooseOpenWithApp:n.actions.canChooseOpenWithApp}),t[2]=o.chat.attachmentPreviewDownloadFull,t[3]=r,t[4]=n.actions.canChooseOpenWithApp,t[5]=n.actions.onChooseOpenWithApp,t[6]=n.actions.onDownload,t[7]=n.actions.onOpenWithSystemApp,t[8]=l,t[9]=u,t[10]=f,t[11]=m):m=t[11],m}function b(e){let t=a(e.language);return e.descriptor.context===`workspace`?t.workspace.openElsewhereHint:t.chat.attachmentPreviewOpenElsewhereHint}function x(e){let t=(0,d.c)(24),n;bb0:{if(!e.binaryBuffer){n=null;break bb0}let r;if(t[0]!==e.binaryBuffer||t[1]!==e.descriptor.fileName||t[2]!==e.descriptor.mimeType){let n=s(e.descriptor.fileName)??e.descriptor.mimeType??`image/png`;r=new Blob([e.binaryBuffer],{type:n}),t[0]=e.binaryBuffer,t[1]=e.descriptor.fileName,t[2]=e.descriptor.mimeType,t[3]=r}else r=t[3];n=r}let r=l(n),i;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(i={x:0,y:0},t[4]=i):i=t[4];let[a,o]=(0,u.useState)(i),c=(0,u.useRef)(null),f=(0,u.useRef)(null),m=e.controls?.zoom??1,h=e.controls?.rotation??0,g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{o({x:0,y:0})},t[5]=g):g=t[5];let _;if(t[6]!==e.descriptor.id||t[7]!==h?(_=[e.descriptor.id,h],t[6]=e.descriptor.id,t[7]=h,t[8]=_):_=t[8],(0,u.useEffect)(g,_),!r)return null;let v;t[9]!==a.x||t[10]!==a.y?(v=e=>{e.button===0&&(c.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,ox:a.x,oy:a.y},e.currentTarget.setPointerCapture(e.pointerId))},t[9]=a.x,t[10]=a.y,t[11]=v):v=t[11];let y,b,x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{let t=c.current;!t||t.pointerId!==e.pointerId||o({x:t.ox+e.clientX-t.x,y:t.oy+e.clientY-t.y})},b=e=>{c.current?.pointerId===e.pointerId&&(c.current=null)},x=e=>{c.current?.pointerId===e.pointerId&&(c.current=null)},t[12]=y,t[13]=b,t[14]=x):(y=t[12],b=t[13],x=t[14]);let S=`translate(${a.x}px, ${a.y}px) scale(${m}) rotate(${h}deg)`,C=m>1?`grab`:`default`,w;t[15]!==S||t[16]!==C?(w={transform:S,cursor:C},t[15]=S,t[16]=C,t[17]=w):w=t[17];let T;t[18]!==r||t[19]!==w?(T=(0,p.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`max-h-full max-w-full select-none object-contain transition-transform duration-100`,style:w}),t[18]=r,t[19]=w,t[20]=T):T=t[20];let E;return t[21]!==T||t[22]!==v?(E=(0,p.jsx)(`div`,{ref:f,className:`flex min-h-0 flex-1 touch-none items-center justify-center overflow-hidden bg-surface-base px-3 py-4 dark:bg-surface-hover/20`,onPointerDown:v,onPointerMove:y,onPointerUp:b,onPointerCancel:x,children:T}),t[21]=T,t[22]=v,t[23]=E):E=t[23],E}function S(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`pdf`}),t[0]=e,t[1]=n),n}function C(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`docx`}),t[0]=e,t[1]=n),n}function w(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`excel`}),t[0]=e,t[1]=n),n}function T(e){let t=(0,d.c)(31),n=(0,u.useRef)(null),[r,i]=(0,u.useState)(null),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=e=>{n.current=e,i(e)},t[0]=o):o=t[0];let s=o,c=e.kind===`pdf`?e.controls?.setPageCount:void 0,l;t[1]!==r||t[2]!==e.binaryBuffer||t[3]!==e.descriptor.id||t[4]!==e.kind||t[5]!==e.language||t[6]!==c?(l={language:e.language,buffer:e.binaryBuffer,kind:e.kind,fileKey:e.descriptor.id,containerEl:r,onPdfPageCount:c},t[1]=r,t[2]=e.binaryBuffer,t[3]=e.descriptor.id,t[4]=e.kind,t[5]=e.language,t[6]=c,t[7]=l):l=t[7];let{error:f,excelTruncated:m}=v(l),h=a(e.language),g=e.kind===`pdf`?e.controls?.zoom??1:1,_=e.kind===`pdf`?e.controls?.rotation??0:0,x=e.kind===`pdf`?e.controls?.page??1:1,S,C;t[8]!==e.kind||t[9]!==_||t[10]!==g?(S=()=>{e.kind!==`pdf`||!n.current||(n.current.style.setProperty(`--xopc-preview-pdf-zoom`,String(g)),n.current.style.setProperty(`--xopc-preview-pdf-rotation`,`${_}deg`),n.current.querySelectorAll(`[data-pdf-page]`).forEach(e=>{let t=e.dataset.pdfBaseHeight??(e.offsetHeight>0?String(e.offsetHeight):void 0);t&&(e.dataset.pdfBaseHeight=t,e.style.height=`${Number(t)*g}px`),e.style.transformOrigin=`top center`,e.style.transform=`scale(${g}) rotate(${_}deg)`,e.style.marginBottom=g===1?``:`${Math.max(16,24*g)}px`}))},C=[e.kind,_,g],t[8]=e.kind,t[9]=_,t[10]=g,t[11]=S,t[12]=C):(S=t[11],C=t[12]),(0,u.useEffect)(S,C);let w,T;if(t[13]!==x||t[14]!==e.kind?(w=()=>{e.kind!==`pdf`||!n.current||n.current.querySelector(`[data-pdf-page="${x}"]`)?.scrollIntoView({block:`start`})},T=[x,e.kind],t[13]=x,t[14]=e.kind,t[15]=w,t[16]=T):(w=t[15],T=t[16]),(0,u.useEffect)(w,T),f){let n;t[17]===e?n=t[18]:(n=b(e),t[17]=e,t[18]=n);let r;t[19]!==e||t[20]!==n?(r=(0,p.jsx)(y,{props:e,message:n}),t[19]=e,t[20]=n,t[21]=r):r=t[21];let i;t[22]===f?i=t[23]:(i=(0,p.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:f}),t[22]=f,t[23]=i);let a;return t[24]!==r||t[25]!==i?(a=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:[r,i]}),t[24]=r,t[25]=i,t[26]=a):a=t[26],a}if(e.kind===`excel`){let n=m?(0,p.jsx)(y,{props:e,message:h.chat.attachmentPreviewExcelTruncated.replaceAll(`{rows}`,`500`).replaceAll(`{cols}`,`64`)}):null,r;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,p.jsx)(`div`,{ref:s,className:`docx-preview-host min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-panel p-2 dark:border-edge`}),t[27]=r):r=t[27];let i;return t[28]===n?i=t[29]:(i=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:[n,r]}),t[28]=n,t[29]=i),i}let E;return t[30]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,p.jsx)(`div`,{ref:s,className:`docx-preview-host min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-panel p-2 dark:border-edge`}),t[30]=E):E=t[30],E}function E(e){let t=(0,d.c)(23),n;t[0]===e.language?n=t[1]:(n=a(e.language),t[0]=e.language,t[1]=n);let r=n,i=e.extractedText||r.chat.attachmentPreviewNoText,s=!!e.extractedTextTruncated||i.length>3e5,c;t[2]===i?c=t[3]:(c=i.length>3e5?i.slice(0,o):i,t[2]=i,t[3]=c);let l=c,u;t[4]!==r.chat.attachmentPreviewOpenElsewhereTruncated||t[5]!==e||t[6]!==s?(u=s?(0,p.jsx)(y,{props:e,message:r.chat.attachmentPreviewOpenElsewhereTruncated}):null,t[4]=r.chat.attachmentPreviewOpenElsewhereTruncated,t[5]=e,t[6]=s,t[7]=u):u=t[7];let f;t[8]!==r.chat.attachmentPreviewPptxTruncated||t[9]!==s?(f=s?(0,p.jsx)(`p`,{className:`mb-2 border-b border-edge-subtle pb-2 text-xs text-fg-muted dark:border-edge`,children:r.chat.attachmentPreviewPptxTruncated}):null,t[8]=r.chat.attachmentPreviewPptxTruncated,t[9]=s,t[10]=f):f=t[10];let h;t[11]===r.chat.attachmentPreviewPptxSlide?h=t[12]:(h=e=>r.chat.attachmentPreviewPptxSlide.replaceAll(`{n}`,String(e)),t[11]=r.chat.attachmentPreviewPptxSlide,t[12]=h);let g;t[13]!==r.chat.attachmentPreviewPptxEmptySlide||t[14]!==h||t[15]!==l?(g=(0,p.jsx)(m,{text:l,slideLabel:h,emptySlideLabel:r.chat.attachmentPreviewPptxEmptySlide}),t[13]=r.chat.attachmentPreviewPptxEmptySlide,t[14]=h,t[15]=l,t[16]=g):g=t[16];let _;t[17]!==f||t[18]!==g?(_=(0,p.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:[f,g]}),t[17]=f,t[18]=g,t[19]=_):_=t[19];let v;return t[20]!==u||t[21]!==_?(v=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:[u,_]}),t[20]=u,t[21]=_,t[22]=v):v=t[22],v}export{C as DocxPreviewPluginView,x as InteractiveImagePreview,S as PdfPreviewPluginView,E as PptxPreviewPluginView,w as SpreadsheetPreviewPluginView};
|
|
2
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{t as a}from"./messages-DjuBdDCn.js";import{ea as o,ta as s}from"./index-C6OWYFtQ.js";import{t as c}from"./preview-open-alternatives-B2pOxJBK.js";import{t as l}from"./use-blob-object-url-D4BFuzZB.js";var u=e(t(),1),d=n();function f(e){let t=e.trim(),n=t.match(/^<pptx\s+filename="([^"]*)">\s*/),r=t;n&&(r=t.slice(n[0].length),r=r.replace(/\s*<\/pptx>\s*$/u,``).trim());let i=[],a=/<slide number="(\d+)">([\s\S]*?)<\/slide>/gu,o;for(;(o=a.exec(r))!==null;){let e=Number.parseInt(o[1],10),t=o[2].trim();i.push({slideNumber:e,text:t})}let s=[],c=/<!--([\s\S]*?)-->/gu,l;for(;(l=c.exec(r))!==null;)s.push(l[1].trim());return i.length===0?{ok:!1,raw:e}:{ok:!0,slides:i,notes:s}}var p=r();function m(e){let t=(0,d.c)(13),{text:n,slideLabel:r,emptySlideLabel:i}=e,a;t[0]===n?a=t[1]:(a=f(n),t[0]=n,t[1]=a);let o=a;if(!o.ok){let e;return t[2]===o.raw?e=t[3]:(e=(0,p.jsx)(`pre`,{className:`whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-fg`,children:o.raw}),t[2]=o.raw,t[3]=e),e}let s;if(t[4]!==i||t[5]!==o.notes||t[6]!==o.slides||t[7]!==r){let e=[];if(o.notes.length>0){let n;t[9]===o.notes?n=t[10]:(n=o.notes.map(h),t[9]=o.notes,t[10]=n);let r;t[11]===n?r=t[12]:(r=(0,p.jsx)(`div`,{className:`mb-2 border-b border-edge-subtle pb-2 dark:border-edge`,role:`status`,children:n},`notes`),t[11]=n,t[12]=r),e.push(r)}for(let t of o.slides)e.push((0,p.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-panel p-3 dark:border-edge`,children:[(0,p.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-fg`,children:r(t.slideNumber)}),(0,p.jsx)(`div`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-fg`,children:t.text.length>0?t.text:i})]},t.slideNumber));s=(0,p.jsx)(`div`,{className:`flex flex-col gap-3`,children:e}),t[4]=i,t[5]=o.notes,t[6]=o.slides,t[7]=r,t[8]=s}else s=t[8];return s}function h(e){return(0,p.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e},e)}function g(e,t){return t===`pdf`?a(e).chat.attachmentPreviewPdfRendering:e===`zh`?t===`excel`?`正在加载电子表格…`:`正在加载文档…`:t===`excel`?`Loading spreadsheet...`:`Loading document...`}function _(e,t){e.innerHTML=``;let n=document.createElement(`p`);n.className=`p-4 text-sm text-fg-muted`,n.textContent=t,e.appendChild(n)}function v({language:e,buffer:t,kind:n,fileKey:r,containerEl:o,onPdfPageCount:s}){let c=(0,u.useRef)(null),[l,d]=(0,u.useState)(null),[f,p]=(0,u.useState)(!1);return(0,u.useLayoutEffect)(()=>{if(c.current?.(),c.current=null,d(null),p(!1),!t||!n||!o||!r)return;let l=!1;return _(o,g(e,n)),(async()=>{try{let r=await i(()=>import(`./attachment-preview-renderer-BDTD8YUe.js`),__vite__mapDeps([0,1,2]));if(l)return;let u=a(e).chat;if(n===`pdf`){let{cleanup:e}=await r.renderPdfInContainer(o,t,{loadingText:u.attachmentPreviewPdfRendering,loadMoreHint:u.attachmentPreviewPdfLoadMore,onPageCount:s});c.current=e}else if(n===`excel`){let{cleanup:e,truncated:n}=await r.renderExcelInContainer(o,t,{truncationNotice:u.attachmentPreviewExcelTruncated.replaceAll(`{rows}`,`500`).replaceAll(`{cols}`,`64`)});c.current=e,l||p(n)}else if(n===`docx`){let{cleanup:e}=await r.renderDocxInContainer(o,t);c.current=e}}catch(e){l||d(e instanceof Error?e.message:String(e))}})(),()=>{l=!0,c.current?.(),c.current=null}},[t,n,o,r,e,s]),{error:l,excelTruncated:f}}function y(e){let t=(0,d.c)(12),{props:n,message:r}=e,i;t[0]===n.language?i=t[1]:(i=a(n.language),t[0]=n.language,t[1]=i);let o=i,s=n.descriptor.context===`workspace`,l=!!n.actions.onOpenWithSystemApp&&(n.actions.canOpenWithSystemApp??!0)&&s,u=s?o.workspace.openSystemApp:void 0,f=s?o.workspace.chooseApp:void 0,m;return t[2]!==o.chat.attachmentPreviewDownloadFull||t[3]!==r||t[4]!==n.actions.canChooseOpenWithApp||t[5]!==n.actions.onChooseOpenWithApp||t[6]!==n.actions.onDownload||t[7]!==n.actions.onOpenWithSystemApp||t[8]!==l||t[9]!==u||t[10]!==f?(m=(0,p.jsx)(c,{message:r,downloadLabel:o.chat.attachmentPreviewDownloadFull,onDownload:n.actions.onDownload,openSystemLabel:u,onOpenWithSystemApp:n.actions.onOpenWithSystemApp,canOpenWithSystemApp:l,chooseAppLabel:f,onChooseOpenWithApp:n.actions.onChooseOpenWithApp,canChooseOpenWithApp:n.actions.canChooseOpenWithApp}),t[2]=o.chat.attachmentPreviewDownloadFull,t[3]=r,t[4]=n.actions.canChooseOpenWithApp,t[5]=n.actions.onChooseOpenWithApp,t[6]=n.actions.onDownload,t[7]=n.actions.onOpenWithSystemApp,t[8]=l,t[9]=u,t[10]=f,t[11]=m):m=t[11],m}function b(e){let t=a(e.language);return e.descriptor.context===`workspace`?t.workspace.openElsewhereHint:t.chat.attachmentPreviewOpenElsewhereHint}function x(e){let t=(0,d.c)(24),n;bb0:{if(!e.binaryBuffer){n=null;break bb0}let r;if(t[0]!==e.binaryBuffer||t[1]!==e.descriptor.fileName||t[2]!==e.descriptor.mimeType){let n=s(e.descriptor.fileName)??e.descriptor.mimeType??`image/png`;r=new Blob([e.binaryBuffer],{type:n}),t[0]=e.binaryBuffer,t[1]=e.descriptor.fileName,t[2]=e.descriptor.mimeType,t[3]=r}else r=t[3];n=r}let r=l(n),i;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(i={x:0,y:0},t[4]=i):i=t[4];let[a,o]=(0,u.useState)(i),c=(0,u.useRef)(null),f=(0,u.useRef)(null),m=e.controls?.zoom??1,h=e.controls?.rotation??0,g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{o({x:0,y:0})},t[5]=g):g=t[5];let _;if(t[6]!==e.descriptor.id||t[7]!==h?(_=[e.descriptor.id,h],t[6]=e.descriptor.id,t[7]=h,t[8]=_):_=t[8],(0,u.useEffect)(g,_),!r)return null;let v;t[9]!==a.x||t[10]!==a.y?(v=e=>{e.button===0&&(c.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,ox:a.x,oy:a.y},e.currentTarget.setPointerCapture(e.pointerId))},t[9]=a.x,t[10]=a.y,t[11]=v):v=t[11];let y,b,x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>{let t=c.current;!t||t.pointerId!==e.pointerId||o({x:t.ox+e.clientX-t.x,y:t.oy+e.clientY-t.y})},b=e=>{c.current?.pointerId===e.pointerId&&(c.current=null)},x=e=>{c.current?.pointerId===e.pointerId&&(c.current=null)},t[12]=y,t[13]=b,t[14]=x):(y=t[12],b=t[13],x=t[14]);let S=`translate(${a.x}px, ${a.y}px) scale(${m}) rotate(${h}deg)`,C=m>1?`grab`:`default`,w;t[15]!==S||t[16]!==C?(w={transform:S,cursor:C},t[15]=S,t[16]=C,t[17]=w):w=t[17];let T;t[18]!==r||t[19]!==w?(T=(0,p.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`max-h-full max-w-full select-none object-contain transition-transform duration-100`,style:w}),t[18]=r,t[19]=w,t[20]=T):T=t[20];let E;return t[21]!==T||t[22]!==v?(E=(0,p.jsx)(`div`,{ref:f,className:`flex min-h-0 flex-1 touch-none items-center justify-center overflow-hidden bg-surface-base px-3 py-4 dark:bg-surface-hover/20`,onPointerDown:v,onPointerMove:y,onPointerUp:b,onPointerCancel:x,children:T}),t[21]=T,t[22]=v,t[23]=E):E=t[23],E}function S(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`pdf`}),t[0]=e,t[1]=n),n}function C(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`docx`}),t[0]=e,t[1]=n),n}function w(e){let t=(0,d.c)(2),n;return t[0]===e?n=t[1]:(n=(0,p.jsx)(T,{...e,kind:`excel`}),t[0]=e,t[1]=n),n}function T(e){let t=(0,d.c)(31),n=(0,u.useRef)(null),[r,i]=(0,u.useState)(null),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=e=>{n.current=e,i(e)},t[0]=o):o=t[0];let s=o,c=e.kind===`pdf`?e.controls?.setPageCount:void 0,l;t[1]!==r||t[2]!==e.binaryBuffer||t[3]!==e.descriptor.id||t[4]!==e.kind||t[5]!==e.language||t[6]!==c?(l={language:e.language,buffer:e.binaryBuffer,kind:e.kind,fileKey:e.descriptor.id,containerEl:r,onPdfPageCount:c},t[1]=r,t[2]=e.binaryBuffer,t[3]=e.descriptor.id,t[4]=e.kind,t[5]=e.language,t[6]=c,t[7]=l):l=t[7];let{error:f,excelTruncated:m}=v(l),h=a(e.language),g=e.kind===`pdf`?e.controls?.zoom??1:1,_=e.kind===`pdf`?e.controls?.rotation??0:0,x=e.kind===`pdf`?e.controls?.page??1:1,S,C;t[8]!==e.kind||t[9]!==_||t[10]!==g?(S=()=>{e.kind!==`pdf`||!n.current||(n.current.style.setProperty(`--xopc-preview-pdf-zoom`,String(g)),n.current.style.setProperty(`--xopc-preview-pdf-rotation`,`${_}deg`),n.current.querySelectorAll(`[data-pdf-page]`).forEach(e=>{let t=e.dataset.pdfBaseHeight??(e.offsetHeight>0?String(e.offsetHeight):void 0);t&&(e.dataset.pdfBaseHeight=t,e.style.height=`${Number(t)*g}px`),e.style.transformOrigin=`top center`,e.style.transform=`scale(${g}) rotate(${_}deg)`,e.style.marginBottom=g===1?``:`${Math.max(16,24*g)}px`}))},C=[e.kind,_,g],t[8]=e.kind,t[9]=_,t[10]=g,t[11]=S,t[12]=C):(S=t[11],C=t[12]),(0,u.useEffect)(S,C);let w,T;if(t[13]!==x||t[14]!==e.kind?(w=()=>{e.kind!==`pdf`||!n.current||n.current.querySelector(`[data-pdf-page="${x}"]`)?.scrollIntoView({block:`start`})},T=[x,e.kind],t[13]=x,t[14]=e.kind,t[15]=w,t[16]=T):(w=t[15],T=t[16]),(0,u.useEffect)(w,T),f){let n;t[17]===e?n=t[18]:(n=b(e),t[17]=e,t[18]=n);let r;t[19]!==e||t[20]!==n?(r=(0,p.jsx)(y,{props:e,message:n}),t[19]=e,t[20]=n,t[21]=r):r=t[21];let i;t[22]===f?i=t[23]:(i=(0,p.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:f}),t[22]=f,t[23]=i);let a;return t[24]!==r||t[25]!==i?(a=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-auto p-4`,children:[r,i]}),t[24]=r,t[25]=i,t[26]=a):a=t[26],a}if(e.kind===`excel`){let n=m?(0,p.jsx)(y,{props:e,message:h.chat.attachmentPreviewExcelTruncated.replaceAll(`{rows}`,`500`).replaceAll(`{cols}`,`64`)}):null,r;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,p.jsx)(`div`,{ref:s,className:`docx-preview-host min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-panel p-2 dark:border-edge`}),t[27]=r):r=t[27];let i;return t[28]===n?i=t[29]:(i=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:[n,r]}),t[28]=n,t[29]=i),i}let E;return t[30]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,p.jsx)(`div`,{ref:s,className:`docx-preview-host min-h-0 flex-1 overflow-auto rounded-lg border border-edge-subtle bg-surface-panel p-2 dark:border-edge`}),t[30]=E):E=t[30],E}function E(e){let t=(0,d.c)(23),n;t[0]===e.language?n=t[1]:(n=a(e.language),t[0]=e.language,t[1]=n);let r=n,i=e.extractedText||r.chat.attachmentPreviewNoText,s=!!e.extractedTextTruncated||i.length>3e5,c;t[2]===i?c=t[3]:(c=i.length>3e5?i.slice(0,o):i,t[2]=i,t[3]=c);let l=c,u;t[4]!==r.chat.attachmentPreviewOpenElsewhereTruncated||t[5]!==e||t[6]!==s?(u=s?(0,p.jsx)(y,{props:e,message:r.chat.attachmentPreviewOpenElsewhereTruncated}):null,t[4]=r.chat.attachmentPreviewOpenElsewhereTruncated,t[5]=e,t[6]=s,t[7]=u):u=t[7];let f;t[8]!==r.chat.attachmentPreviewPptxTruncated||t[9]!==s?(f=s?(0,p.jsx)(`p`,{className:`mb-2 border-b border-edge-subtle pb-2 text-xs text-fg-muted dark:border-edge`,children:r.chat.attachmentPreviewPptxTruncated}):null,t[8]=r.chat.attachmentPreviewPptxTruncated,t[9]=s,t[10]=f):f=t[10];let h;t[11]===r.chat.attachmentPreviewPptxSlide?h=t[12]:(h=e=>r.chat.attachmentPreviewPptxSlide.replaceAll(`{n}`,String(e)),t[11]=r.chat.attachmentPreviewPptxSlide,t[12]=h);let g;t[13]!==r.chat.attachmentPreviewPptxEmptySlide||t[14]!==h||t[15]!==l?(g=(0,p.jsx)(m,{text:l,slideLabel:h,emptySlideLabel:r.chat.attachmentPreviewPptxEmptySlide}),t[13]=r.chat.attachmentPreviewPptxEmptySlide,t[14]=h,t[15]=l,t[16]=g):g=t[16];let _;t[17]!==f||t[18]!==g?(_=(0,p.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:[f,g]}),t[17]=f,t[18]=g,t[19]=_):_=t[19];let v;return t[20]!==u||t[21]!==_?(v=(0,p.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-hidden px-2 pb-2 pt-1 sm:px-4`,children:[u,_]}),t[20]=u,t[21]=_,t[22]=v):v=t[22],v}export{C as DocxPreviewPluginView,x as InteractiveImagePreview,S as PdfPreviewPluginView,E as PptxPreviewPluginView,w as SpreadsheetPreviewPluginView};
|
package/dist/gateway/static/root/assets/{block-editor-C8e6Wri4.js → block-editor-D22VcYnC.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,n as t,t as n}from"./rolldown-runtime-aKtaBQYM.js";import{a as r,i,n as a,t as o}from"./vendor-react-BOUWij0V.js";import{t as s}from"./check-DUBLcKHA.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{t as l}from"./external-link-DjqjBmc3.js";import{m as u,t as d,u as f}from"./markdown-view-AglreSOj.js";import{t as p}from"./loader-circle-CifKLtgG.js";import{t as m}from"./copy-to-clipboard-HOJ79TWv.js";import{t as h}from"./messages-DH_HCgmw.js";import{n as g}from"./locale-store-CRNble2Z.js";import{t as _}from"./cn-JdwAhgNB.js";import{s as v}from"./vendor-swr-BIWyz7Rc.js";import{a as y,d as b,i as x,l as S,n as C,o as w,r as T,s as E,t as D,u as O}from"./floating-ui.dom-B7uQOZZW.js";import{$c as ee,Cl as te,Hs as k,Jl as A,Mc as ne,Oc as re,Pc as ie,Qn as ae,Sc as oe,Sl as se,Su as ce,Vs as le,Wc as ue,Yn as de,Ys as fe,Zc as pe,Zn as me,_l as he,cr as ge,el as _e,ir as ve,nl as ye,pl as be,wl as xe,xc as Se}from"./index-C6PmD0cK.js";import{C as Ce,S as we}from"./vendor-codemirror-DFxP3B9T.js";import{t as Te}from"./with-selector-aYPsXwdl.js";import{a as Ee}from"./note-detail-panel-BUJPoaGZ.js";var j=e(r(),1),De=e(i(),1),M=o(),Oe=v(),ke=Object.defineProperty,Ae=(e,t)=>{let n={};for(var r in e)ke(n,r,{get:e[r],enumerable:!0});return t||ke(n,Symbol.toStringTag,{value:`Module`}),n};function N(e){this.content=e}N.prototype={constructor:N,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new N(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new N(n)},addToStart:function(e,t){return new N([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new N(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new N(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=N.from(e),e.size?new N(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=N.from(e),e.size?new N(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=N.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},N.from=function(e){if(e instanceof N)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new N(t)};function je(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&Pe(e.charCodeAt(r-1))&&Ne(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=je(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function Me(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&Pe(e.charCodeAt(i-1))&&Ne(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=Me(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function Ne(e){return e>=56320&&e<57344}function Pe(e){return e>=55296&&e<56320}var P=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return je(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Me(this,e,t,n)}findIndex(e){if(e==0)return Ie(0,e);if(e==this.size)return Ie(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?Ie(t+1,i):Ie(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};P.empty=new P([],0);var Fe={index:0,offset:0};function Ie(e,t){return Fe.index=e,Fe.offset=t,Fe}function Le(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Le(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Le(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var F=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Le(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};F.none=[];var Re=class extends Error{},I=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Be(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(ze(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(P.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};I.empty=new I(P.empty,0,0);function ze(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(ze(a.content,t-i-1,n-i-1)))}function Be(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=Be(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function Ve(e,t,n){if(n.openStart>e.depth)throw new Re(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Re(`Inconsistent open depths`);return He(e,t,n,0)}function He(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=He(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return qe(a,Ye(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return qe(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=Xe(n,e);return qe(a,Je(e,i,o,t,r))}}function Ue(e,t){if(!t.type.compatibleContent(e.type))throw new Re(`Cannot join `+t.type.name+` onto `+e.type.name)}function We(e,t,n){let r=e.node(n);return Ue(r,t.node(n)),r}function Ge(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function Ke(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(Ge(e.nodeAfter,r),a++));for(let e=a;e<o;e++)Ge(i.child(e),r);t&&t.depth==n&&t.textOffset&&Ge(t.nodeBefore,r)}function qe(e,t){if(!e.type.validContent(t))throw new Re(`Invalid content for node `+e.type.name);return e.copy(t)}function Je(e,t,n,r,i){let a=e.depth>i&&We(e,t,i+1),o=r.depth>i&&We(n,r,i+1),s=[];return Ke(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(Ue(a,o),Ge(qe(a,Je(e,t,n,r,i+1)),s)):(a&&Ge(qe(a,Ye(e,t,i+1)),s),Ke(t,n,i,s),o&&Ge(qe(o,Ye(n,r,i+1)),s)),Ke(r,null,i,s),new P(s)}function Ye(e,t,n){let r=[];return Ke(null,e,n,r),e.depth>n&&Ge(qe(We(e,t,n+1),Ye(e,t,n+1)),r),Ke(t,null,n,r),new P(r)}function Xe(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(P.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Ze=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return F.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new tt(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=et.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else et.set(t,r=new Qe);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%$e,i}},Qe=class{constructor(){this.elts=[],this.i=0}},$e=12,et=new WeakMap,tt=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},nt=Object.create(null),rt=class e{constructor(e,t,n,r=F.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||P.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Le(this.attrs,t||e.defaultAttrs||nt)&&F.sameSet(this.marks,n||F.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return I.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new I(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return Ve(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Ze.resolveCached(this,e)}resolveNoCache(e){return Ze.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),at(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=P.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=F.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!F.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=P.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};rt.prototype.text=void 0;var it=class e extends rt{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):at(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function at(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var ot=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new st(t,n);if(r.next==null)return e.empty;let i=ct(r);r.next&&r.err(`Unexpected trailing text`);let a=vt(ht(i));return yt(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return P.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
1
|
+
import{i as e,n as t,t as n}from"./rolldown-runtime-aKtaBQYM.js";import{a as r,i,n as a,t as o}from"./vendor-react-BOUWij0V.js";import{t as s}from"./check-DUBLcKHA.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{t as l}from"./external-link-DjqjBmc3.js";import{m as u,t as d,u as f}from"./markdown-view-c5vtnYe8.js";import{t as p}from"./loader-circle-CifKLtgG.js";import{t as m}from"./copy-to-clipboard-HOJ79TWv.js";import{t as h}from"./messages-DjuBdDCn.js";import{n as g}from"./locale-store-BBSCIl4I.js";import{t as _}from"./cn-JdwAhgNB.js";import{s as v}from"./vendor-swr-BIWyz7Rc.js";import{a as y,d as b,i as x,l as S,n as C,o as w,r as T,s as E,t as D,u as O}from"./floating-ui.dom-B7uQOZZW.js";import{$c as ee,Cl as te,Hs as k,Jl as A,Mc as ne,Oc as re,Pc as ie,Qn as ae,Sc as oe,Sl as se,Su as ce,Vs as le,Wc as ue,Yn as de,Ys as fe,Zc as pe,Zn as me,_l as he,cr as ge,el as _e,ir as ve,nl as ye,pl as be,wl as xe,xc as Se}from"./index-C6OWYFtQ.js";import{C as Ce,S as we}from"./vendor-codemirror-DFxP3B9T.js";import{t as Te}from"./with-selector-aYPsXwdl.js";import{a as Ee}from"./note-detail-panel-BV6nbgac.js";var j=e(r(),1),De=e(i(),1),M=o(),Oe=v(),ke=Object.defineProperty,Ae=(e,t)=>{let n={};for(var r in e)ke(n,r,{get:e[r],enumerable:!0});return t||ke(n,Symbol.toStringTag,{value:`Module`}),n};function N(e){this.content=e}N.prototype={constructor:N,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new N(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new N(n)},addToStart:function(e,t){return new N([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new N(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new N(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=N.from(e),e.size?new N(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=N.from(e),e.size?new N(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=N.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},N.from=function(e){if(e instanceof N)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new N(t)};function je(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&Pe(e.charCodeAt(r-1))&&Ne(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=je(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function Me(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&Pe(e.charCodeAt(i-1))&&Ne(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=Me(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function Ne(e){return e>=56320&&e<57344}function Pe(e){return e>=55296&&e<56320}var P=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return je(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Me(this,e,t,n)}findIndex(e){if(e==0)return Ie(0,e);if(e==this.size)return Ie(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?Ie(t+1,i):Ie(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};P.empty=new P([],0);var Fe={index:0,offset:0};function Ie(e,t){return Fe.index=e,Fe.offset=t,Fe}function Le(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!Le(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!Le(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var F=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Le(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};F.none=[];var Re=class extends Error{},I=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Be(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(ze(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(P.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};I.empty=new I(P.empty,0,0);function ze(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(ze(a.content,t-i-1,n-i-1)))}function Be(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=Be(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function Ve(e,t,n){if(n.openStart>e.depth)throw new Re(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Re(`Inconsistent open depths`);return He(e,t,n,0)}function He(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=He(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return qe(a,Ye(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return qe(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=Xe(n,e);return qe(a,Je(e,i,o,t,r))}}function Ue(e,t){if(!t.type.compatibleContent(e.type))throw new Re(`Cannot join `+t.type.name+` onto `+e.type.name)}function We(e,t,n){let r=e.node(n);return Ue(r,t.node(n)),r}function Ge(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function Ke(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(Ge(e.nodeAfter,r),a++));for(let e=a;e<o;e++)Ge(i.child(e),r);t&&t.depth==n&&t.textOffset&&Ge(t.nodeBefore,r)}function qe(e,t){if(!e.type.validContent(t))throw new Re(`Invalid content for node `+e.type.name);return e.copy(t)}function Je(e,t,n,r,i){let a=e.depth>i&&We(e,t,i+1),o=r.depth>i&&We(n,r,i+1),s=[];return Ke(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(Ue(a,o),Ge(qe(a,Je(e,t,n,r,i+1)),s)):(a&&Ge(qe(a,Ye(e,t,i+1)),s),Ke(t,n,i,s),o&&Ge(qe(o,Ye(n,r,i+1)),s)),Ke(r,null,i,s),new P(s)}function Ye(e,t,n){let r=[];return Ke(null,e,n,r),e.depth>n&&Ge(qe(We(e,t,n+1),Ye(e,t,n+1)),r),Ke(t,null,n,r),new P(r)}function Xe(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(P.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Ze=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return F.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new tt(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=et.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else et.set(t,r=new Qe);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%$e,i}},Qe=class{constructor(){this.elts=[],this.i=0}},$e=12,et=new WeakMap,tt=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},nt=Object.create(null),rt=class e{constructor(e,t,n,r=F.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||P.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Le(this.attrs,t||e.defaultAttrs||nt)&&F.sameSet(this.marks,n||F.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return I.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new I(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return Ve(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return Ze.resolveCached(this,e)}resolveNoCache(e){return Ze.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),at(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=P.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=F.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!F.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=P.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};rt.prototype.text=void 0;var it=class e extends rt{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):at(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function at(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var ot=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new st(t,n);if(r.next==null)return e.empty;let i=ct(r);r.next&&r.err(`Unexpected trailing text`);let a=vt(ht(i));return yt(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return P.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
|
|
2
2
|
`)}};ot.empty=new ot(!0);var st=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function ct(e){let t=[];do t.push(lt(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function lt(e){let t=[];do t.push(ut(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function ut(e){let t=mt(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=ft(e,t);else break;return t}function dt(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function ft(e,t){let n=dt(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:dt(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function pt(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function mt(e){if(e.eat(`(`)){let t=ct(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=pt(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function ht(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function gt(e,t){return t-e}function _t(e,t){let n=[];return r(t),n.sort(gt);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function vt(e){let t=Object.create(null);return n(_t(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);_t(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new ot(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(gt);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function yt(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function bt(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function xt(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function St(e,t,n,r){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}function Ct(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Et(e,r,t[r]);return n}var wt=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=Ct(e,n.attrs),this.defaultAttrs=bt(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ot.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:xt(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new rt(this,this.computeAttrs(e),P.from(t),F.setFrom(n))}createChecked(e=null,t,n){return t=P.from(t),this.checkContent(t),new rt(this,this.computeAttrs(e),t,F.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=P.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(P.empty,!0);return i?new rt(this,e,t.append(i),F.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){St(this.attrs,e,`node`,this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:F.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function Tt(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var Et=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?Tt(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},Dt=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Ct(e,r.attrs),this.excluded=null;let i=bt(this.attrs);this.instance=i?new F(this,i):null}create(e=null){return!e&&this.instance?this.instance:new F(this,xt(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){St(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},Ot=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=N.from(e.nodes),t.marks=N.from(e.marks||{}),this.nodes=wt.compile(this.spec.nodes,this),this.marks=Dt.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=ot.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?kt(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:kt(this,n.split(` `))}this.nodeFromJSON=e=>rt.fromJSON(this,e),this.markFromJSON=e=>F.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof wt))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new it(n,n.defaultAttrs,e,F.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function kt(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function At(e){return e.tag!=null}function jt(e){return e.style!=null}var Mt=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(At(e))this.tags.push(e);else if(jt(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new Vt(this,t,!1);return n.addAll(e,F.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new Vt(this,t,!0);return n.addAll(e,F.none,t.from,t.to),I.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Ut(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Wt(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Wt(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},Nt={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Pt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ft={ol:!0,ul:!0},It=1,Lt=2,Rt=4;function zt(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?It:0)|(t===`full`?Lt:0)}var Bt=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=F.none,this.match=i||(a&Rt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(P.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&It)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=P.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(P.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Nt.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Vt=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=zt(null,t.preserveWhitespace,0)|(n?Rt:0);i=r?new Bt(r.type,r.attrs,F.none,!0,t.topMatch||r.type.contentMatch,a):n?new Bt(null,null,F.none,!0,null,a):new Bt(e.schema.topNodeType,null,F.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&Lt?`full`:this.localPreserveWS||(r.options&It)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
|
|
3
3
|
`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;Ft.hasOwnProperty(a)&&this.parser.normalizeLists&&Ht(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:Pt.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(Nt.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
4
4
|
`),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=F.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):Gt(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=zt(e,i,a.options);a.options&Rt&&a.content.length==0&&(o|=Rt);let s=F.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):Gt(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new Bt(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=It);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function Ht(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&Ft.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function Ut(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Wt(e){let t={};for(let n in e)t[n]=e[n];return t}function Gt(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var Kt=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=Jt(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return Jt(t).createTextNode(e.text);let{dom:n,contentDOM:r}=Qt(Jt(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Qt(Jt(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:Qt(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=qt(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return qt(e.marks)}};function qt(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Jt(e){return e.document||window.document}var Yt=new WeakMap;function Xt(e){let t=Yt.get(e);return t===void 0&&Yt.set(e,t=Zt(e)),t}function Zt(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function Qt(e,t,n,r){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=Xt(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=Qt(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var $t=a(),en=65535,tn=2**16;function nn(e,t){return e+t*tn}function rn(e){return e&en}function an(e){return(e-(e&en))/tn}var on=1,sn=2,cn=4,ln=8,un=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&ln)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&cn)>0}},dn=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=rn(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+an(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:nn(o/3,e-s),f=e==s?sn:e==u?on:cn;return(t<0?e!=s:e!=u)&&(f|=ln),new un(a,f,d)}r+=l-c}return n?e+r:new un(e+r,0,null)}touches(e,t){let n=0,r=rn(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};dn.empty=new dn([]);var fn=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new un(e,r,null)}},pn=Object.create(null),mn=class{getMap(){return dn.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=pn[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in pn)throw RangeError(`Duplicate use of step JSON ID `+e);return pn[e]=t,t.prototype.jsonID=e,t}},hn=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof Re)return e.fail(t.message);throw t}}};function gn(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(gn(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return P.fromArray(r)}var _n=class e extends mn{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new I(gn(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return hn.fromReplace(e,this.from,this.to,i)}invert(){return new vn(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};mn.jsonID(`addMark`,_n);var vn=class e extends mn{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new I(gn(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return hn.fromReplace(e,this.from,this.to,n)}invert(){return new _n(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};mn.jsonID(`removeMark`,vn);var yn=class e extends mn{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return hn.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return hn.fromReplace(e,this.pos,this.pos+1,new I(P.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new bn(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};mn.jsonID(`addNodeMark`,yn);var bn=class e extends mn{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return hn.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return hn.fromReplace(e,this.pos,this.pos+1,new I(P.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new yn(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};mn.jsonID(`removeNodeMark`,bn);var xn=class e extends mn{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&Cn(e,this.from,this.to)?hn.fail(`Structure replace would overwrite content`):hn.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new dn([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?I.empty:new I(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?I.empty:new I(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,I.fromJSON(t,n.slice),!!n.structure)}};xn.MAP_BIAS=1,mn.jsonID(`replace`,xn);var Sn=class e extends mn{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(Cn(e,this.from,this.gapFrom)||Cn(e,this.gapTo,this.to)))return hn.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return hn.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?hn.fromReplace(e,this.from,this.to,n):hn.fail(`Content does not fit in gap`)}getMap(){return new dn([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,I.fromJSON(t,n.slice),n.insert,!!n.structure)}};mn.jsonID(`replaceAround`,Sn);function Cn(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function wn(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new vn(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new _n(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function Tn(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof Dt){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new vn(t.from,t.to,t.style)))}function En(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new xn(s,l,I.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new vn(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new I(P.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new xn(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(P.empty,!0);e.replace(s,s,new I(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function Dn(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function On(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!Dn(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function kn(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=P.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=P.from(r.node(e).copy(u)),d++):c--;let f=P.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=P.from(i.node(e).copy(f)),p++):l++;e.step(new Sn(c,l,o,s,new I(u.append(f),d,p),u.size-d,!0))}function An(e,t,n=null,r=e){let i=Mn(e,t),a=i&&Nn(r,t);return a?i.map(jn).concat({type:t,attrs:n}).concat(a.map(jn)):null}function jn(e){return{type:e,attrs:null}}function Mn(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function Nn(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function Pn(e,t,n){let r=P.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=P.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new Sn(i,a,i,a,new I(r,0,0),n.length,!0))}function Fn(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&Rn(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&Ln(e,t,n,a),En(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new Sn(c,l,c+1,l-1,new I(P.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&In(e,t,n,a),!1}})}function In(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function Ln(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./popover-select-Dz_Qis2R.js";import{a as r,r as i}from"./locale-store-
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./popover-select-Dz_Qis2R.js";import{a as r,r as i}from"./locale-store-BBSCIl4I.js";function a(e){return{id:e.id,name:e.definition.name,description:e.definition.description,enabled:e.status===`enabled`,risk:e.definition.risk,domains:e.definition.allowedDomains,inputs:e.definition.inputs,createdAtMs:e.createdAtMs,updatedAtMs:e.updatedAtMs}}var o={list:async()=>({automations:(await r(i(`/api/browser/automations`))).automations.map(a)}),setEnabled:async(e,t)=>({automation:a((await r(i(`/api/browser/automations/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({status:t?`enabled`:`disabled`})})).automation)}),remove:e=>r(i(`/api/browser/automations/${encodeURIComponent(e)}`),{method:`DELETE`}),run:(e,t)=>r(i(`/api/browser/automations/${encodeURIComponent(e)}/run`),{method:`POST`,body:JSON.stringify({inputs:t})}),getRun:e=>r(i(`/api/browser/automation-runs/${encodeURIComponent(e)}`)),listRuns:e=>r(i(`/api/browser/automation-runs?automationId=${encodeURIComponent(e)}`)),cancel:e=>r(i(`/api/browser/automation-runs/${encodeURIComponent(e)}/cancel`),{method:`POST`})};function s(e){return Object.fromEntries(Object.entries(e.inputs).flatMap(([e,t])=>t.default===void 0?[]:[[e,t.default]]))}function c(e,t){return!Object.entries(e.inputs).some(([e,n])=>n.required&&(t[e]===void 0||t[e]===``))}var l=e(),u=t();function d(e){let t=(0,l.c)(53),{name:r,input:i,value:a,yes:o,no:s,onChange:c}=e,d;t[0]!==i.description||t[1]!==r?(d=i.description?.trim()||r,t[0]=i.description,t[1]=r,t[2]=d):d=t[2];let p=d;if(i.choices?.length){let e;t[3]===i.choices?e=t[4]:(e=i.choices.map(f),t[3]=i.choices,t[4]=e);let r=e,o=i.required?` *`:``,s;t[5]!==p||t[6]!==o?(s=(0,u.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,o]}),t[5]=p,t[6]=o,t[7]=s):s=t[7];let l;t[8]===a?l=t[9]:(l=a===void 0?``:JSON.stringify(a),t[8]=a,t[9]=l);let d;t[10]===c?d=t[11]:(d=e=>c(JSON.parse(e)),t[10]=c,t[11]=d);let m;t[12]!==p||t[13]!==r||t[14]!==l||t[15]!==d?(m=(0,u.jsx)(n,{value:l,options:r,placeholder:p,onChange:d}),t[12]=p,t[13]=r,t[14]=l,t[15]=d,t[16]=m):m=t[16];let h;return t[17]!==s||t[18]!==m?(h=(0,u.jsxs)(`label`,{className:`block text-sm text-fg`,children:[s,m]}),t[17]=s,t[18]=m,t[19]=h):h=t[19],h}if(i.type===`boolean`){let e=i.required?` *`:``,r;t[20]!==p||t[21]!==e?(r=(0,u.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,e]}),t[20]=p,t[21]=e,t[22]=r):r=t[22];let l=typeof a==`boolean`?String(a):``,d;t[23]===o?d=t[24]:(d={value:`true`,label:o},t[23]=o,t[24]=d);let f;t[25]===s?f=t[26]:(f={value:`false`,label:s},t[25]=s,t[26]=f);let m;t[27]!==d||t[28]!==f?(m=[d,f],t[27]=d,t[28]=f,t[29]=m):m=t[29];let h;t[30]===c?h=t[31]:(h=e=>c(e===`true`),t[30]=c,t[31]=h);let g;t[32]!==p||t[33]!==l||t[34]!==m||t[35]!==h?(g=(0,u.jsx)(n,{value:l,options:m,placeholder:p,onChange:h}),t[32]=p,t[33]=l,t[34]=m,t[35]=h,t[36]=g):g=t[36];let _;return t[37]!==r||t[38]!==g?(_=(0,u.jsxs)(`label`,{className:`block text-sm text-fg`,children:[r,g]}),t[37]=r,t[38]=g,t[39]=_):_=t[39],_}let m=i.type===`number`,h=i.required?` *`:``,g;t[40]!==p||t[41]!==h?(g=(0,u.jsxs)(`span`,{className:`mb-1.5 block font-medium`,children:[p,h]}),t[40]=p,t[41]=h,t[42]=g):g=t[42];let _=m?`number`:`text`,v=a===void 0?``:String(a),y;t[43]!==m||t[44]!==c?(y=e=>c(m?e.target.value===``?void 0:Number(e.target.value):e.target.value),t[43]=m,t[44]=c,t[45]=y):y=t[45];let b;t[46]!==_||t[47]!==v||t[48]!==y?(b=(0,u.jsx)(`input`,{type:_,value:v,onChange:y,className:`h-10 w-full rounded-lg border border-edge bg-surface-subtle px-3 text-sm text-fg outline-none focus:border-accent`}),t[46]=_,t[47]=v,t[48]=y,t[49]=b):b=t[49];let x;return t[50]!==g||t[51]!==b?(x=(0,u.jsxs)(`label`,{className:`block text-sm text-fg`,children:[g,b]}),t[50]=g,t[51]=b,t[52]=x):x=t[52],x}function f(e){return{value:JSON.stringify(e),label:String(e)}}function p(e){let t=(0,l.c)(7),{automation:n,values:r,language:i,onChange:a}=e,o;t[0]===n.inputs?o=t[1]:(o=Object.entries(n.inputs),t[0]=n.inputs,t[1]=o);let s;return t[2]!==i||t[3]!==a||t[4]!==o||t[5]!==r?(s=(0,u.jsx)(`div`,{className:`grid gap-4`,children:o.map(e=>{let[t,n]=e;return(0,u.jsx)(d,{name:t,input:n,value:r[t],yes:i===`zh`?`是`:`Yes`,no:i===`zh`?`否`:`No`,onChange:e=>a({...r,[t]:e})},t)})}),t[2]=i,t[3]=a,t[4]=o,t[5]=r,t[6]=s):s=t[6],s}export{o as i,c as n,s as r,p as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{d as r}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as i}from"./clock-3-DnrAnuyZ.js";import{n as a}from"./locale-store-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{d as r}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as i}from"./clock-3-DnrAnuyZ.js";import{n as a}from"./locale-store-BBSCIl4I.js";import{t as o}from"./button-B11EPpor.js";import{t as s}from"./skeleton-BwbyijEw.js";import{Hl as c,Mc as l,Oc as u,Ws as d,au as f,ec as p,iu as m,lo as h,vu as g}from"./index-C6OWYFtQ.js";import{i as _,n as v,r as y,t as b}from"./browser-automation-inputs-6NWTLEpd.js";var x=e(t(),1),S=n(),C={en:{title:`Browser automations`,subtitle:`Let your assistant repeat routine actions on the web.`,emptyTitle:`No browser automations yet`,emptyBody:`Tell your assistant what to do on the web. Once it works, save it and run it again whenever you need.`,create:`Create with assistant`,edit:`Edit with assistant`,run:`Run now`,stop:`Stop`,enable:`Enable`,pause:`Pause`,enabled:`Enabled`,paused:`Paused`,inputs:`Before running`,noInputs:`This automation is ready to run.`,history:`Recent activity`,delete:`Delete automation`,confirmDelete:`Delete this browser automation?`,required:`Please complete all required fields.`,queued:`Waiting to start`,running:`Running`,succeeded:`Completed`,failed:`Needs attention`,cancelled:`Stopped`,result:`Result`,read:`Reads information`,draft:`Edits the page locally`,external_effect:`Affects an external system`,destructive:`Destructive action`,sensitive:`Sensitive action`,createPrompt:`Help me create a reusable browser automation. Ask what I want the browser to do, perform it once with me, then save the successful steps. Keep all technical details hidden.`,editPrompt:`Help me update the browser automation "{name}" (id: {id}). Ask what should change, test the new browser steps, then save it.`},zh:{title:`浏览器自动化`,subtitle:`让助手自动重复完成网页上的固定操作。`,emptyTitle:`还没有浏览器自动化`,emptyBody:`告诉助手你希望在网页上自动完成什么。成功执行一次后,即可保存并重复运行。`,create:`让助手帮我创建`,edit:`让助手帮我修改`,run:`立即运行`,stop:`停止`,enable:`启用`,pause:`暂停`,enabled:`已启用`,paused:`已暂停`,inputs:`运行前需要填写`,noInputs:`这个自动化可以直接运行。`,history:`最近运行`,delete:`删除自动化`,confirmDelete:`确定删除这个浏览器自动化吗?`,required:`请填写所有必填内容。`,queued:`等待开始`,running:`正在运行`,succeeded:`已完成`,failed:`需要处理`,cancelled:`已停止`,result:`运行结果`,read:`仅读取信息`,draft:`仅在页面内编辑`,external_effect:`会影响外部系统`,destructive:`破坏性操作`,sensitive:`包含敏感操作`,createPrompt:`请帮我创建一个可重复运行的浏览器自动化。先询问我希望浏览器完成什么,陪我实际执行成功一次,然后保存成功步骤。不要让我处理技术细节。`,editPrompt:`请帮我修改浏览器自动化“{name}”(id:{id})。先询问我要修改什么,实际测试新的浏览器步骤,然后保存。`}};function w(e){return e!==`queued`&&e!==`running`}function T(e){return e==null?`-`:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?e.map(e=>`• ${T(e)}`).join(`
|
|
2
2
|
`):typeof e==`object`?Object.entries(e).map(([e,t])=>`${e}: ${T(t)}`).join(`
|
|
3
3
|
`):String(e)}function E(){let e=a(e=>e.language),t=C[e],n=r(),E=h(e=>e.setPageHeader),D=h(e=>e.clearPageHeader),[O,k]=(0,x.useState)(null),[A,j]=(0,x.useState)(),[M,N]=(0,x.useState)({}),[P,F]=(0,x.useState)([]),[I,L]=(0,x.useState)(),[R,z]=(0,x.useState)(``),[B,V]=(0,x.useState)(!1),H=(0,x.useMemo)(()=>O?.find(e=>e.id===A),[A,O]),U=(0,x.useCallback)(async()=>{let e=await _.list();k(e.automations),j(t=>t&&e.automations.some(e=>e.id===t)?t:e.automations[0]?.id)},[]);(0,x.useEffect)(()=>{U().catch(e=>z(String(e)))},[U]),(0,x.useEffect)(()=>{H&&(N(y(H)),L(void 0),z(``),_.listRuns(H.id).then(e=>F(e.runs)).catch(e=>z(String(e))))},[H]),(0,x.useEffect)(()=>{if(!I||w(I.status))return;let e=window.setInterval(()=>{_.getRun(I.id).then(({run:e})=>{L(e),w(e.status)&&H&&_.listRuns(H.id).then(e=>F(e.runs))}).catch(e=>z(String(e)))},700);return()=>window.clearInterval(e)},[I,H]);let W=(0,x.useCallback)(e=>{n(`/chat/new?draft=${encodeURIComponent(e)}`)},[n]),G=(0,x.useMemo)(()=>(0,S.jsxs)(o,{onClick:()=>W(t.createPrompt),children:[(0,S.jsx)(g,{className:`size-4`}),t.create]}),[W,t.create,t.createPrompt]);(0,x.useLayoutEffect)(()=>(E({startExtra:null,main:(0,S.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),end:G}),()=>D()),[D,G,E,t.title]);let K=async()=>{if(H){V(!0);try{await _.setEnabled(H.id,!H.enabled),await U()}catch(e){z(String(e))}finally{V(!1)}}},q=async()=>{if(H){if(!v(H,M)){z(t.required);return}V(!0);try{let{run:e}=await _.run(H.id,M);L(e),z(``)}catch(e){z(String(e))}finally{V(!1)}}},J=async()=>{if(!(!H||!window.confirm(t.confirmDelete))){V(!0);try{await _.remove(H.id),j(void 0),F([]),await U()}catch(e){z(String(e))}finally{V(!1)}}};return O===null?(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,S.jsx)(s,{className:`h-[420px] rounded-xl`}),(0,S.jsx)(s,{className:`h-[420px] rounded-xl`})]})}):O.length===0?(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`m-auto max-w-md py-12 text-center`,children:[(0,S.jsx)(g,{className:`mx-auto size-10 text-accent`}),(0,S.jsx)(`h2`,{className:`mt-4 text-lg font-semibold text-fg`,children:t.emptyTitle}),(0,S.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:t.emptyBody}),(0,S.jsxs)(o,{className:`mt-5`,onClick:()=>W(t.createPrompt),children:[(0,S.jsx)(g,{className:`size-4`}),t.create]})]})}):(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-surface-panel p-4 sm:p-6`,children:(0,S.jsxs)(`div`,{className:`grid min-h-0 flex-1 gap-4 lg:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,S.jsx)(`aside`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge bg-surface-base p-2`,children:O.map(e=>(0,S.jsxs)(`button`,{onClick:()=>j(e.id),className:`mb-1 w-full rounded-lg p-3 text-left ${A===e.id?`bg-accent-soft text-accent-fg`:`hover:bg-surface-hover`}`,children:[(0,S.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.name}),(0,S.jsxs)(`span`,{className:`mt-1 flex items-center gap-1.5 text-xs text-fg-muted`,children:[e.enabled?(0,S.jsx)(m,{className:`size-3.5 text-emerald-600`}):(0,S.jsx)(f,{className:`size-3.5`}),e.enabled?t.enabled:t.paused]})]},e.id))}),H&&(0,S.jsxs)(`main`,{className:`min-h-0 overflow-y-auto rounded-xl border border-edge bg-surface-base p-5 sm:p-6`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:H.name}),H.description&&(0,S.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:H.description}),(0,S.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs`,children:[(0,S.jsx)(`span`,{className:`rounded-full bg-surface-subtle px-2.5 py-1 text-fg-muted`,children:t[H.risk]}),H.domains.map(e=>(0,S.jsxs)(`span`,{className:`flex items-center gap-1 rounded-full bg-surface-subtle px-2.5 py-1 text-fg-muted`,children:[(0,S.jsx)(c,{className:`size-3`}),e]},e))]})]}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsxs)(o,{variant:`secondary`,disabled:B,onClick:()=>void K(),children:[H.enabled?(0,S.jsx)(f,{className:`size-4`}):(0,S.jsx)(m,{className:`size-4`}),H.enabled?t.pause:t.enable]}),(0,S.jsxs)(o,{variant:`secondary`,onClick:()=>W(t.editPrompt.replace(`{name}`,H.name).replace(`{id}`,H.id)),children:[(0,S.jsx)(l,{className:`size-4`}),t.edit]})]})]}),(0,S.jsxs)(`section`,{className:`mt-7 max-w-xl`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.inputs}),Object.keys(H.inputs).length===0?(0,S.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:t.noInputs}):(0,S.jsx)(`div`,{className:`mt-3`,children:(0,S.jsx)(b,{automation:H,values:M,language:e,onChange:N})}),(0,S.jsxs)(`div`,{className:`mt-5 flex gap-2`,children:[(0,S.jsxs)(o,{variant:`primary`,disabled:!H.enabled||B||!!(I&&!w(I.status)),onClick:()=>void q(),children:[(0,S.jsx)(u,{className:`size-4`}),t.run]}),I&&!w(I.status)&&(0,S.jsxs)(o,{variant:`secondary`,onClick:()=>void _.cancel(I.id),children:[(0,S.jsx)(p,{className:`size-4`}),t.stop]})]}),R&&(0,S.jsx)(`p`,{className:`mt-3 text-sm text-red-700 dark:text-red-300`,children:R})]}),I&&(0,S.jsxs)(`section`,{className:`mt-7 rounded-xl border border-edge bg-surface-subtle p-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,S.jsx)(i,{className:`size-4`}),t[I.status]]}),I.error&&(0,S.jsx)(`p`,{className:`mt-2 text-sm text-red-700 dark:text-red-300`,children:I.error}),I.status===`succeeded`&&I.result!==void 0&&(0,S.jsxs)(`div`,{className:`mt-3`,children:[(0,S.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:t.result}),(0,S.jsx)(`pre`,{className:`mt-2 max-h-64 overflow-auto whitespace-pre-wrap text-sm text-fg`,children:T(I.result)})]})]}),(0,S.jsxs)(`section`,{className:`mt-8`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.history}),(0,S.jsx)(`div`,{className:`mt-2 divide-y divide-edge`,children:P.slice(0,10).map(e=>(0,S.jsxs)(`button`,{className:`flex w-full items-center justify-between gap-3 py-3 text-left text-sm hover:text-accent`,onClick:()=>L(e),children:[(0,S.jsx)(`span`,{children:t[e.status]}),(0,S.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[new Date(e.createdAtMs).toLocaleString(),e.durationMs?` · ${Math.max(1,Math.round(e.durationMs/1e3))}s`:``]})]},e.id))})]}),(0,S.jsx)(`div`,{className:`mt-8 border-t border-edge pt-4`,children:(0,S.jsxs)(o,{variant:`ghost`,className:`text-red-700 dark:text-red-300`,disabled:B,onClick:()=>void J(),children:[(0,S.jsx)(d,{className:`size-4`}),t.delete]})})]})]})})}export{E as BrowserAutomationsPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,h as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as o}from"./popover-select-Dz_Qis2R.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./download-Dk-ZjtO6.js";import{t as l}from"./external-link-DjqjBmc3.js";import{t as u}from"./loader-circle-CifKLtgG.js";import{t as d}from"./messages-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,h as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as o}from"./popover-select-Dz_Qis2R.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./download-Dk-ZjtO6.js";import{t as l}from"./external-link-DjqjBmc3.js";import{t as u}from"./loader-circle-CifKLtgG.js";import{t as d}from"./messages-DjuBdDCn.js";import{a as f,c as p,i as m,n as h,r as g}from"./locale-store-BBSCIl4I.js";import{i as _}from"./vendor-swr-BIWyz7Rc.js";import{t as v}from"./button-B11EPpor.js";import{n as y,r as b}from"./gateway-config-swr-6eb1vKE1.js";import{t as x}from"./skeleton-BwbyijEw.js";import{El as S,Hc as C,Us as w,Wl as T,Xc as ee,Xi as E,Yi as D,bc as te,kc as ne,kl as re,zl as O}from"./index-C6OWYFtQ.js";import{n as ie,r as k}from"./settings-page-layout-DYelDcMV.js";import{n as A}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as j,t as ae}from"./use-autosave-DkQAIAuB.js";import{t as M}from"./settings-advanced-gate-DV7kMco2.js";var N=e(t(),1),P=n();function F(){return f(g(`/api/browser/status`))}function I(){return f(g(`/api/browser/test`),{method:`POST`})}function oe(e=!1){return f(g(`/api/browser/extension/install`),{method:`POST`,body:JSON.stringify({force:e})})}function L(e){return f(g(`/api/browser/extension/open`),{method:`POST`,body:JSON.stringify({action:e})})}async function R(e,t){let n=await m(g(`/api/browser/playwright/install/stream`),{method:`POST`,headers:{Accept:`text/event-stream`},signal:t});if(!n.ok||!n.body)throw Error(`Chromium install request failed (HTTP ${n.status}).`);let r=n.body.getReader(),i=new TextDecoder,a=``,o;try{for(;!o;){let t=await r.read();if(t.done)break;a+=i.decode(t.value,{stream:!0}),a=a.replace(/\r\n/g,`
|
|
2
2
|
`);let n=a.split(`
|
|
3
3
|
|
|
4
4
|
`);a=n.pop()??``;for(let t of n){let n=t.split(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-swr-BIWyz7Rc.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{d as a,h as o,p as s,r as c,t as l}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{a as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./dist-CpzYSoz7.js";import{n as _,r as v,t as y}from"./popover-select-Dz_Qis2R.js";import{t as b}from"./circle-check-C23XjkUj.js";import{t as x}from"./external-link-DjqjBmc3.js";import{t as S}from"./globe-DSSGFWFn.js";import{t as C}from"./loader-circle-CifKLtgG.js";import{t as w}from"./plus-Q2yW6OE7.js";import{t as T}from"./x-B_N4OPjy.js";import{t as E}from"./messages-
|
|
2
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{d as a,h as o,p as s,r as c,t as l}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{a as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./dist-CpzYSoz7.js";import{n as _,r as v,t as y}from"./popover-select-Dz_Qis2R.js";import{t as b}from"./circle-check-C23XjkUj.js";import{t as x}from"./external-link-DjqjBmc3.js";import{t as S}from"./globe-DSSGFWFn.js";import{t as C}from"./loader-circle-CifKLtgG.js";import{t as w}from"./plus-Q2yW6OE7.js";import{t as T}from"./x-B_N4OPjy.js";import{t as E}from"./messages-DjuBdDCn.js";import{a as D,c as O,i as k,n as A,r as j}from"./locale-store-BBSCIl4I.js";import{t as M}from"./cn-JdwAhgNB.js";import{i as N}from"./vendor-swr-BIWyz7Rc.js";import{t as P}from"./button-B11EPpor.js";import{n as F,r as I}from"./gateway-config-swr-6eb1vKE1.js";import{t as L}from"./skeleton-BwbyijEw.js";import{i as R,o as z}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as B,t as V}from"./registry-api-CyQ4k1Ux.js";import{Ao as H,At as U,B as W,Co as G,Ct as K,Dc as ee,Do as te,Du as ne,Et as re,Fo as q,Ft as J,Is as Y,It as ie,J as ae,Mc as X,Mo as oe,Mt as se,Nt as ce,Oc as le,Ot as ue,Ou as de,Po as fe,Pt as pe,R as me,So as he,St as ge,Tt as _e,Us as ve,Wc as ye,Ws as be,X as xe,Xi as Se,Xl as Ce,Y as we,Yc as Te,Yi as Ee,_t as De,at as Oe,bc as ke,bt as Ae,ct as je,do as Me,ds as Ne,dt as Pe,ec as Fe,fc as Ie,fl as Le,fo as Re,ft as ze,gl as Be,go as Ve,gt as He,hc as Ue,ho as We,ht as Ge,it as Ke,jo as qe,jt as Je,ko as Ye,kt as Xe,lt as Ze,lu as Qe,mn as $e,mt as et,oc as tt,ot as nt,pt as rt,qi as it,st as at,uo as ot,us as st,ut as ct,vo as lt,vt as ut,wo as dt,wt as ft,wu as pt,xt as mt,yo as ht,z as gt,zl as _t}from"./index-C6OWYFtQ.js";import{n as vt,r as yt}from"./settings-page-layout-DYelDcMV.js";import{n as bt,t as xt}from"./settings-form-section-Dbnls9ty.js";import{t as St}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as Ct,t as wt}from"./use-autosave-DkQAIAuB.js";import{a as Tt,c as Et,d as Dt,f as Ot,h as kt,i as At,l as jt,n as Mt,o as Nt,p as Pt,r as Ft,t as It,u as Lt}from"./voice-config-api-BJ95Z3pT.js";import{t as Rt}from"./voice-api-key-field-BrqcH0P-.js";import{t as zt}from"./page-tabs-C7Le9bSI.js";import{t as Bt}from"./settings-advanced-gate-DV7kMco2.js";import{a as Vt,i as Ht,n as Ut,o as Wt,r as Gt,t as Kt}from"./image-generation-api-C1cHRBRp.js";var Z=n(),Q=e(t(),1),$=r(),qt={en:{addTitle:`Add image service`,editTitle:`Manage image service`,intro:`Connect an endpoint that implements the OpenAI Images protocol.`,connection:`Connection`,providerId:`Provider ID`,providerIdHint:`Lowercase letters, numbers, hyphens, or underscores.`,name:`Display name`,baseUrl:`Base URL`,auth:`Authentication`,bearer:`Bearer token`,header:`Custom API key header`,none:`No authentication`,headerName:`Header name`,apiKey:`API key`,apiKeyHint:`Stored in the local credential store, separate from models.json.`,apiKeyUrl:`API key page (optional)`,docsUrl:`Documentation page (optional)`,openKeyPage:`Create API key`,paths:`Protocol and network`,generationsPath:`Generations path`,editsPath:`Edits path`,allowedHosts:`Allowed private hosts (optional)`,allowedHostsHint:`One exact hostname or IP per line. Private endpoints stay blocked unless listed here.`,staticHeaders:`Static headers (optional)`,staticHeadersHint:`One per line: X-Tenant: value. Credential headers are rejected.`,models:`Image models`,addModel:`Add model`,modelId:`Model ID`,modelName:`Name (optional)`,defaultModel:`Default model`,maxCount:`Max images`,defaultCount:`Default count`,defaultSize:`Default size`,format:`Output format`,supportsSize:`Supports size`,edit:`Supports edits`,remove:`Remove`,cancel:`Cancel`,save:`Save service`,saving:`Saving…`,test:`Test generation`,testing:`Generating…`,delete:`Delete service`,confirmDelete:`Delete permanently`,saved:`Image service saved.`,deleted:`Image service deleted.`,testReady:`Test image generated.`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`,revealFailed:`Unable to reveal the saved key.`,notRevealable:`No revealable key is stored locally.`,required:`Complete the required connection and model fields.`,duplicateModels:`Model IDs must be unique.`,invalidHeaders:`Static headers must use “Name: value”, one per line.`},zh:{addTitle:`添加图片服务`,editTitle:`管理图片服务`,intro:`连接一个严格实现 OpenAI Images 协议的服务端点。`,connection:`连接信息`,providerId:`Provider ID`,providerIdHint:`仅支持小写字母、数字、连字符和下划线。`,name:`显示名称`,baseUrl:`Base URL`,auth:`认证方式`,bearer:`Bearer Token`,header:`自定义 API Key Header`,none:`无需认证`,headerName:`Header 名称`,apiKey:`API Key`,apiKeyHint:`密钥单独保存在本机凭据存储,不写入 models.json。`,apiKeyUrl:`API Key 创建页面(可选)`,docsUrl:`协议文档页面(可选)`,openKeyPage:`去创建 API Key`,paths:`协议与网络`,generationsPath:`生成路径`,editsPath:`编辑路径`,allowedHosts:`允许访问的私有主机(可选)`,allowedHostsHint:`每行一个精确主机名或 IP;未列出的私网端点保持阻止。`,staticHeaders:`静态 Headers(可选)`,staticHeadersHint:`每行一个:X-Tenant: value。认证 Header 会被拒绝。`,models:`图片模型`,addModel:`添加模型`,modelId:`模型 ID`,modelName:`名称(可选)`,defaultModel:`默认模型`,maxCount:`单次最大张数`,defaultCount:`默认张数`,defaultSize:`默认尺寸`,format:`输出格式`,supportsSize:`支持尺寸参数`,edit:`支持图片编辑`,remove:`移除`,cancel:`取消`,save:`保存服务`,saving:`保存中…`,test:`测试生成`,testing:`生成中…`,delete:`删除服务`,confirmDelete:`确认永久删除`,saved:`图片服务已保存。`,deleted:`图片服务已删除。`,testReady:`测试图片生成成功。`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`,revealFailed:`无法查看已保存的密钥。`,notRevealable:`本机没有可查看的密钥。`,required:`请补全必填的连接和模型信息。`,duplicateModels:`模型 ID 不能重复。`,invalidHeaders:`静态 Header 必须使用“名称: 值”格式,每行一个。`}},Jt=`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`;function Yt(e){let t=e??{id:``,capabilities:{generate:{maxCount:1,supportsSize:!0},edit:{enabled:!1}}};return{original:t,id:t.id,name:t.name??``,maxCount:String(t.capabilities.generate?.maxCount??1),defaultCount:t.defaults?.count?String(t.defaults.count):``,defaultSize:t.defaults?.size??``,outputFormat:t.defaults?.outputFormat??``,supportsSize:t.capabilities.generate?.supportsSize??!1,editEnabled:t.capabilities.edit?.enabled??!1}}function Xt(e){let t=e.split(`
|
|
3
3
|
`).map(e=>e.trim()).filter(Boolean);if(t.length===0)return;let n=t.map(e=>{let t=e.indexOf(`:`);if(t<=0||!e.slice(t+1).trim())throw Error(`invalid_headers`);return[e.slice(0,t).trim(),e.slice(t+1).trim()]});return Object.fromEntries(n)}function Zt({open:e,onOpenChange:t,provider:n,configured:r,language:i,onSaved:a}){let o=qt[i],[s,c]=(0,Q.useState)(``),[l,_]=(0,Q.useState)(``),[v,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(`bearer`),[E,D]=(0,Q.useState)(`x-api-key`),[O,k]=(0,Q.useState)(``),[A,j]=(0,Q.useState)(``),[N,F]=(0,Q.useState)(``),[I,L]=(0,Q.useState)(`/images/generations`),[B,V]=(0,Q.useState)(`/images/edits`),[H,U]=(0,Q.useState)(``),[W,G]=(0,Q.useState)(``),[K,ee]=(0,Q.useState)([Yt()]),[te,re]=(0,Q.useState)(``),[q,J]=(0,Q.useState)(),[Y,ie]=(0,Q.useState)(!1),[ae,X]=(0,Q.useState)(),[oe,ce]=(0,Q.useState)(),[le,ue]=(0,Q.useState)();(0,Q.useEffect)(()=>{if(!e)return;let t=n?.imageGeneration;c(n?.providerId??``),_(t?.name??``),b(n?.baseUrl??``),S(t?.auth.type??`bearer`),D(t?.auth.type===`header`?t.auth.headerName:`x-api-key`),k(r?`••••••••••••`:``),j(t?.apiKeyUrl??``),F(t?.documentationUrl??``),L(t?.paths?.generations??`/images/generations`),V(t?.paths?.edits??`/images/edits`),U(t?.network?.allowedHosts.join(`
|
|
4
4
|
`)??``),G(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
|
|
5
5
|
`)),ee(t?.models.map(Yt)??[Yt()]),re(t?.defaultModel??``),ce(void 0),J(void 0),ie(!1),X(void 0),ue(void 0)},[r,e,n]);let de=(0,Q.useMemo)(()=>K.filter(e=>e.id.trim()).map(e=>({value:e.id.trim(),label:e.name.trim()||e.id.trim()})),[K]),fe=(e,t)=>{ee(n=>n.map((n,r)=>r===e?{...n,...t}:n))},pe=()=>{let e=s.trim(),t=K.map(e=>({...e,id:e.id.trim(),name:e.name.trim()}));if(!e||!l.trim()||!v.trim()||t.some(e=>!e.id))throw Error(o.required);if(new Set(t.map(e=>e.id)).size!==t.length)throw Error(o.duplicateModels);let n=te||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(o.required);let r;try{r=Xt(W)}catch{throw Error(o.invalidHeaders)}return{providerId:e,input:{baseUrl:v.trim(),...r?{headers:r}:{},imageGeneration:{api:`openai-images`,name:l.trim(),...N.trim()?{documentationUrl:N.trim()}:{},...A.trim()?{apiKeyUrl:A.trim()}:{},defaultModel:n,auth:x===`header`?{type:`header`,headerName:E.trim()}:{type:x},paths:{...I.trim()?{generations:I.trim()}:{},...B.trim()?{edits:B.trim()}:{}},...H.trim()?{network:{allowedHosts:H.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,p as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{a as o,i as s,n as c,o as l,r as u,s as d,t as f}from"./dist-CpzYSoz7.js";import{t as p}from"./popover-select-Dz_Qis2R.js";import{t as m}from"./circle-check-C23XjkUj.js";import{t as h}from"./external-link-DjqjBmc3.js";import{t as g}from"./loader-circle-CifKLtgG.js";import{t as _}from"./x-B_N4OPjy.js";import{t as v}from"./messages-DH_HCgmw.js";import{a as y,c as b,i as x,n as S,r as C}from"./locale-store-CRNble2Z.js";import{t as w}from"./cn-JdwAhgNB.js";import{i as T}from"./vendor-swr-BIWyz7Rc.js";import{t as E}from"./button-B11EPpor.js";import{t as D}from"./skeleton-BwbyijEw.js";import{i as O,o as k}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as A}from"./settings-shell-layer-context-DCp6ykjQ.js";import{Cc as j,Ki as M,Qs as N,Us as P,Wr as F,_n as I,aa as L,an as R,cu as z,fc as B,gn as ee,hn as te,lo as ne,oa as re,us as ie,yc as ae}from"./index-C6PmD0cK.js";import{n as oe,r as se}from"./settings-page-layout-DYelDcMV.js";import{t as ce}from"./browser-BLJWD7WI.js";import{n as le}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as ue}from"./schema-form-BMYKdzsH.js";import{n as de,t as fe}from"./channels-status-swr-CfOPNnVr.js";var V=e(t(),1),H=n();function pe(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var me=e(ce(),1),U=r();async function he(e){let t=await x(C(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function W(e){return e?.type===`poll`&&e.phase===`done`}function G(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function K(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function q(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ge({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,V.useMemo)(()=>pe(e),[e]),o=(0,V.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[s,c]=(0,V.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,V.useEffect)(()=>{c({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let l=(0,V.useCallback)(async(n,i)=>{c(e=>({...e,busy:!0,error:null}));try{let a=await he({channelId:e.id,actionId:n,locale:t,input:i});c(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){c(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,V.useEffect)(()=>{let t=K(s.payload,e.id);if(!t){c(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return c(e=>e.generatedQr?{...e,generatedQr:null}:e),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||c(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,s.payload]),(0,V.useEffect)(()=>{let n=s.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||he({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(c(t=>({...t,payload:e,poll:W(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),W(e)&&window.clearInterval(a))}).catch(e=>{i||c(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,s.poll]);let u=a?.[1].label??(e.configured?n.reconnect:n.connect),d=e.actions?.[`doctor.run`]?.label??n.diagnose,f=G(s.payload),p=K(s.payload,e.id),_=p?s.generatedQr:q(s.payload),v=a?.[1].result===`qr`&&(s.busy||s.payload?.type===`qr`||s.payload?.type===`poll`),y=s.payload?.type===`form`?s.payload:null,b=s.payload?.type===`diagnostics`?s.payload.checks:null;return(0,U.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:w(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,U.jsxs)(E,{type:`button`,variant:`primary`,disabled:s.busy,onClick:()=>void l(a[0]),children:[s.busy?(0,U.jsx)(g,{className:`size-4 animate-spin`}):(0,U.jsx)(j,{className:`size-4`}),u]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(E,{type:`button`,variant:`secondary`,disabled:s.busy,onClick:()=>void l(`doctor.run`),children:[(0,U.jsx)(N,{className:`size-4`}),d]}):null]})]}),f?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:f}):null,s.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:s.error}):null,v?(0,U.jsxs)(`div`,{className:w(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,U.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:_?(0,U.jsx)(`img`,{src:_,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,U.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,U.jsx)(D,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:w(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[_?(0,U.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,U.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,U.jsx)(D,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(D,{className:`h-4 w-36 max-w-full`})]}),p?(0,U.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:p,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,U.jsx)(h,{className:`size-3.5`})]}):null]})]}):null,s.payload?.type===`poll`&&s.payload.phase===`done`?(0,U.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,U.jsx)(m,{className:s.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,U.jsx)(`span`,{className:s.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:s.payload.message??(s.payload.ok?n.complete:n.failed)})]}):null,y?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(ue,{schema:y.schema,values:s.formDraft,onChange:e=>c(t=>({...t,formDraft:e})),disabled:s.busy,labels:o}),(0,U.jsx)(E,{type:`button`,variant:`primary`,disabled:s.busy,onClick:()=>void l(y.submitAction,s.formDraft),children:n.saveSetup})]}):null,b?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:b.map((e,t)=>(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var _e=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ve(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function ye(e,t,n){let r=J(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:_e,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function be(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function xe(e,t,n){let r=be(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Se(e,t=!1){return e===`drawer`?w(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,O):w(`fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,O,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function Ce(e){let t=(0,H.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:p,srTitle:m,srDescription:h,closeAriaLabel:g,children:v,footer:y,wide:b,headerExtra:x}=e,S=b===void 0?!1:b,C=n===`drawer`,[T,D]=(0,V.useState)(null),O;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,U.jsx)(o,{className:w(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,k)}),t[0]=O):O=t[0];let j;t[1]!==n||t[2]!==S?(j=Se(n,S),t[1]=n,t[2]=S,t[3]=j):j=t[3];let M;t[4]===m?M=t[5]:(M=m?(0,U.jsx)(d,{className:`sr-only`,children:m}):null,t[4]=m,t[5]=M);let N;t[6]===h?N=t[7]:(N=h?(0,U.jsx)(s,{className:`sr-only`,children:h}):null,t[6]=h,t[7]=N);let P;t[8]!==g||t[9]!==p||t[10]!==x||t[11]!==C||t[12]!==a?(P=C?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,U.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,p?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:p}):null]}),(0,U.jsx)(c,{asChild:!0,children:(0,U.jsx)(E,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":g,children:(0,U.jsx)(_,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(c,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:w(ie,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":g,children:(0,U.jsx)(_,{className:`size-4`})})}),x]}),t[8]=g,t[9]=p,t[10]=x,t[11]=C,t[12]=a,t[13]=P):P=t[13];let F=C?`p-4`:`p-6`,I;t[14]===F?I=t[15]:(I=w(`min-h-0 flex-1 overflow-y-auto`,F),t[14]=F,t[15]=I);let L;t[16]!==v||t[17]!==I?(L=(0,U.jsx)(`div`,{className:I,children:v}),t[16]=v,t[17]=I,t[18]=L):L=t[18];let R;t[19]!==y||t[20]!==T||t[21]!==M||t[22]!==N||t[23]!==P||t[24]!==L?(R=(0,U.jsxs)(A,{layer:`modal`,portalContainer:T,children:[M,N,P,L,y]}),t[19]=y,t[20]=T,t[21]=M,t[22]=N,t[23]=P,t[24]=L,t[25]=R):R=t[25];let z;t[26]!==R||t[27]!==j?(z=(0,U.jsxs)(l,{children:[O,(0,U.jsx)(u,{ref:D,className:j,onOpenAutoFocus:we,children:R})]}),t[26]=R,t[27]=j,t[28]=z):z=t[28];let B;return t[29]!==i||t[30]!==r||t[31]!==z?(B=(0,U.jsx)(f,{open:r,onOpenChange:i,children:z}),t[29]=i,t[30]=r,t[31]=z,t[32]=B):B=t[32],B}function we(e){return e.preventDefault()}var Te=(0,V.memo)(function(e){let t=(0,H.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,U.jsx)(M,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,U.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function Ee(e){let t=(0,H.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,U.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,U.jsx)(E,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,U.jsx)(E,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,U.jsx)(E,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,U.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function De(e){return C(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function Oe(e){return(await y(De(e))).payload?.channels??[]}function ke(e,t){let n=(0,H.c)(14),r;n[0]!==e||n[1]!==t?(r=e?De(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>Oe(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=T(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var Ae=`channels-status`;function je(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Me(e){let t=t=>e(t.detail);return window.addEventListener(Ae,t),()=>window.removeEventListener(Ae,t)}function Ne(e,t){let n=(0,H.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Me(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,V.useEffect)(i,a)}function Pe(e){return e?C(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Fe(e){return(await y(C(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Ie=[`enabled`];async function Le(){let e=await y(C(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Re(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function ze(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function Y(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Be(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Ve(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function He(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function Ue(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Ie.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Ie.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function We(e,t){let n={...Z(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ge(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ge(n)&&delete t[e];return Object.keys(t).length===0}function Ke(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ge(n),n}function qe(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Je(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function Ye(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Q(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Xe(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push(et(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Q(e,Je(t,e),n);i&&r.push(i)}let a=Ye(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Ze(e,t){let n=Y(e),r=pe(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function Qe(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function $e(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function et(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function tt({entry:e}){let[t,n]=(0,V.useState)(!1),r=(0,V.useMemo)(()=>!e.ui?.icon||t?null:new URL(C(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Re(e.ui.icon)}`)).toString(),[t,e.extensionId,e.ui?.icon]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:r?(0,U.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>n(!0)}):(0,U.jsx)(re,{sourceChannel:e.id,className:`size-7`})})}function nt(e){let t=(0,H.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,l;t[2]!==s||t[3]!==c?(l=w(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=l):l=t[4];let u=n?`translate-x-5`:`translate-x-0.5`,d;t[5]===u?d=t[6]:(d=w(`size-5 rounded-full bg-white shadow-surface transition-transform`,u),t[5]=u,t[6]=d);let f;t[7]===d?f=t[8]:(f=(0,U.jsx)(`span`,{className:d}),t[7]=d,t[8]=f);let p;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==l||t[14]!==f?(p=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:l,children:f}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=l,t[14]=f,t[15]=p):p=t[15],p}function rt(e){let t=(0,H.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:s,onOpen:c,onToggle:l,onRestart:u}=e,d;t[0]===n?d=t[1]:(d=Y(n),t[0]=n,t[1]=d);let f=d,p,m,h,_,v,y,b;if(t[2]!==a||t[3]!==s||t[4]!==r||t[5]!==n||t[6]!==c||t[7]!==u||t[8]!==l||t[9]!==i||t[10]!==f.enabled||t[11]!==f.ready){let e=Xe(n,r,s),o=$e(n,s);p=!f.enabled&&f.ready?l:i===`stopped`?u:c,y=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let d;t[19]===n?d=t[20]:(d=(0,U.jsx)(tt,{entry:n}),t[19]=n,t[20]=d);let g;t[21]===n.label?g=t[22]:(g=(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=g);let x;t[23]===i?x=t[24]:(x=w(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,He(i)),t[23]=i,t[24]=x);let S;t[25]!==s||t[26]!==i?(S=Be(i,s),t[25]=s,t[26]=i,t[27]=S):S=t[27];let C;t[28]!==x||t[29]!==S?(C=(0,U.jsx)(`span`,{className:x,children:S}),t[28]=x,t[29]=S,t[30]=C):C=t[30];let T;t[31]!==C||t[32]!==g?(T=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[g,C]}),t[31]=C,t[32]=g,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==d?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[d,T]}),t[34]=T,t[35]=d,t[36]=E):E=t[36];let D=f.enabled,O;t[37]!==s.toggleChannel||t[38]!==n.label?(O=s.toggleChannel.replace(`{{channel}}`,n.label),t[37]=s.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==l||t[42]!==f.enabled||t[43]!==O?(k=(0,U.jsx)(nt,{checked:D,disabled:a,label:O,onToggle:l}),t[40]=a,t[41]=l,t[42]=f.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(b=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=b):b=t[47],m=`button`,h=c,_=`mt-5 min-h-[6.25rem] text-left`,v=f.ready?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,U.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map($)}):null]}):(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Qe(n,s)}),o.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(it)}):null]}),t[2]=a,t[3]=s,t[4]=r,t[5]=n,t[6]=c,t[7]=u,t[8]=l,t[9]=i,t[10]=f.enabled,t[11]=f.ready,t[12]=p,t[13]=m,t[14]=h,t[15]=_,t[16]=v,t[17]=y,t[18]=b}else p=t[12],m=t[13],h=t[14],_=t[15],v=t[16],y=t[17],b=t[18];let x;t[48]!==m||t[49]!==h||t[50]!==_||t[51]!==v?(x=(0,U.jsx)(`button`,{type:m,onClick:h,className:_,children:v}),t[48]=m,t[49]=h,t[50]=_,t[51]=v,t[52]=x):x=t[52];let S=a||o,C;t[53]!==a||t[54]!==o?(C=a||o?(0,U.jsx)(g,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=C):C=t[55];let T;t[56]!==s||t[57]!==n||t[58]!==o||t[59]!==i?(T=o?s.restartingChannel:i===`stopped`?s.restartChannel:Ze(n,s),t[56]=s,t[57]=n,t[58]=o,t[59]=i,t[60]=T):T=t[60];let D;t[61]!==p||t[62]!==C||t[63]!==T||t[64]!==S?(D=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(E,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:p,disabled:S,children:[C,T]})}),t[61]=p,t[62]=C,t[63]=T,t[64]=S,t[65]=D):D=t[65];let O;return t[66]!==D||t[67]!==y||t[68]!==b||t[69]!==x?(O=(0,U.jsxs)(`article`,{className:y,children:[b,x,D]}),t[66]=D,t[67]=y,t[68]=b,t[69]=x,t[70]=O):O=t[70],O}function it(e){return(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function $(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function at(e){let t=(0,H.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:o,ch:s,onRestart:c,onCheck:l,onManageConnection:u}=e,d=n===`running`?m:n===`stopped`||n===`needs_setup`?z:g,f=n===`running`&&`text-emerald-600 dark:text-emerald-400`,p=n===`stopped`&&`text-red-600 dark:text-red-400`,h=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,_=n===`disabled`&&`text-fg-muted`,v=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,y;t[0]!==f||t[1]!==p||t[2]!==h||t[3]!==_||t[4]!==v?(y=w(`mt-0.5 size-5 shrink-0`,f,p,h,_,v),t[0]=f,t[1]=p,t[2]=h,t[3]=_,t[4]=v,t[5]=y):y=t[5];let b;t[6]!==d||t[7]!==y?(b=(0,U.jsx)(d,{className:y}),t[6]=d,t[7]=y,t[8]=b):b=t[8];let x;t[9]===s.connectionStatus?x=t[10]:(x=(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:s.connectionStatus}),t[9]=s.connectionStatus,t[10]=x);let S;t[11]!==s||t[12]!==n?(S=Ve(n,s),t[11]=s,t[12]=n,t[13]=S):S=t[13];let C;t[14]===S?C=t[15]:(C=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S}),t[14]=S,t[15]=C);let T;t[16]!==C||t[17]!==x?(T=(0,U.jsxs)(`div`,{children:[x,C]}),t[16]=C,t[17]=x,t[18]=T):T=t[18];let D;t[19]!==T||t[20]!==b?(D=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,T]}),t[19]=T,t[20]=b,t[21]=D):D=t[21];let O=i||r,k;t[22]===i?k=t[23]:(k=i?(0,U.jsx)(g,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=k);let A=i?s.checkingConnection:s.checkConnection,j;t[24]!==l||t[25]!==O||t[26]!==k||t[27]!==A?(j=(0,U.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:O,onClick:l,children:[k,A]}),t[24]=l,t[25]=O,t[26]=k,t[27]=A,t[28]=j):j=t[28];let M;t[29]!==s.restartChannel||t[30]!==s.restartingChannel||t[31]!==i||t[32]!==c||t[33]!==r||t[34]!==n?(M=n===`stopped`?(0,U.jsxs)(E,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:c,children:[r?(0,U.jsx)(g,{className:`size-4 animate-spin`}):(0,U.jsx)(ae,{className:`size-4`}),r?s.restartingChannel:s.restartChannel]}):null,t[29]=s.restartChannel,t[30]=s.restartingChannel,t[31]=i,t[32]=c,t[33]=r,t[34]=n,t[35]=M):M=t[35];let N;t[36]!==o||t[37]!==s.connectionOptions||t[38]!==s.hideConnectionOptions||t[39]!==i||t[40]!==u||t[41]!==r||t[42]!==a?(N=o?(0,U.jsx)(E,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:u,children:a?s.hideConnectionOptions:s.connectionOptions}):null,t[36]=o,t[37]=s.connectionOptions,t[38]=s.hideConnectionOptions,t[39]=i,t[40]=u,t[41]=r,t[42]=a,t[43]=N):N=t[43];let P;t[44]!==j||t[45]!==M||t[46]!==N?(P=(0,U.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[j,M,N]}),t[44]=j,t[45]=M,t[46]=N,t[47]=P):P=t[47];let F;return t[48]!==D||t[49]!==P?(F=(0,U.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[D,P]})}),t[48]=D,t[49]=P,t[50]=F):F=t[50],F}function ot(e){let t=(0,H.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Y(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-amber-950 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,U.jsx)(P,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,U.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,U.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,U.jsx)(`li`,{children:et(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,U.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,U.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,U.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,U.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function st(){let e=S(e=>e.language),t=v(e),n=b(e=>!!e.sessionKey),r=i(),{channelId:o}=a(),s=I(o),c=ke(n,e),l=c.entries,{data:u,mutate:d,isValidating:f}=T(n?fe():null,de,{revalidateOnFocus:!0}),{data:m,mutate:g}=T(n?`channels-config-map`:null,Le,{revalidateOnFocus:!1}),_=m?.channels??{},y=m?.bindings??[],{data:E}=T(n?`channel-routing-agents`:null,L,{revalidateOnFocus:!1}),D=ne(e=>e.setPageHeader),O=ne(e=>e.clearPageHeader),k=(0,V.useMemo)(()=>l.find(e=>e.id===s),[s,l]),A=k?ze(k):null,{data:j,mutate:M}=T(n&&A?Pe(A):null,()=>Fe(A)),[N,P]=(0,V.useState)(null),[z,re]=(0,V.useState)(!1),[ie,ae]=(0,V.useState)(null),[ce,H]=(0,V.useState)(null),[me,he]=(0,V.useState)(!1),[W,G]=(0,V.useState)(null),[K,q]=(0,V.useState)(null),_e=N??j??{},J=t.channelsSettings,be=(0,V.useMemo)(()=>k?.configSchema??{type:`object`,properties:{}},[k?.configSchema]),Se=(0,V.useMemo)(()=>Ke(be,Ie),[be]),we=(0,V.useMemo)(()=>Ue(k),[k]),De=(0,V.useMemo)(()=>We(Se,we),[we,Se]),Oe=(0,V.useMemo)(()=>Ke(Se,we),[we,Se]),Ae=(0,V.useMemo)(()=>qe(De),[De]),Me=k?K??ve(y,k.id):``,Re=(0,V.useMemo)(()=>(E?.items??[]).map(e=>{let n=R(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[E?.items,t.agentsSettings]),Ve=E?.items.find(e=>e.id===E.defaultId),X=Ve?R(Ve,t.agentsSettings):E?.defaultId??``,Z=(0,V.useMemo)(()=>({defaultBooleanLabel:J.schemaBooleanDefault,unsupportedArrayType:J.schemaUnsupportedArrayType,arrayAddPlaceholder:J.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>J.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[J]),Ge=(0,V.useMemo)(()=>new Map((u??[]).map(e=>[e.name,e])),[u]),Je=u!==void 0,Ye=(0,V.useCallback)(e=>xe(e,Ge.get(e.id),Je),[Ge,Je]),Q=(0,V.useCallback)(async()=>{await Promise.all([c.mutate(),d()])},[c,d]);Ne((0,V.useCallback)(e=>{let t=je(e);t&&d(t,!1)},[d]),n);let Xe=(0,V.useMemo)(()=>n?(0,U.jsx)(Te,{ch:J,refreshing:c.isValidating||f,saveOk:!1,onRefresh:()=>void Q()}):null,[c.isValidating,J,n,f,Q]);(0,V.useLayoutEffect)(()=>(D({startExtra:null,main:(0,U.jsx)(`div`,{className:`min-w-0`,children:(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>O()),[O,Xe,t.settingsSections.channels,D]);let Ze=(0,V.useCallback)(e=>{r(ee(e)),P(null),q(null),G(null)},[r]),Qe=(0,V.useCallback)(()=>{r(te),P(null),q(null),G(null)},[r]),$e=(0,V.useCallback)(async e=>{H(e.id),G(null);try{let t=await x(C(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){G(e instanceof Error?e.message:String(e))}finally{H(null)}},[Q]);(0,V.useEffect)(()=>{q(null),he(!1)},[k?.id]);let et=(0,V.useCallback)(async()=>{if(!k||!N&&K===null)return!1;let e=ze(k);re(!0),G(null);try{let t=await x(C(`/api/config`),{method:`PATCH`,body:JSON.stringify({...N?{channels:{[e]:N}}:{},...K===null?{}:{bindings:ye(y,k.id,K)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return N&&await M(N,!1),await g(),await c.mutate(),P(null),q(null),!0}catch(e){return G(e instanceof Error?e.message:String(e)),!1}finally{re(!1)}},[k,K,y,c,N,g,M]),it=(0,V.useCallback)(async e=>{let t=Y(e),n=ze(e),r=k?.id===e.id?N:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ae(e.id),G(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await x(C(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await c.mutate(),await g(),await d(),k?.id===e.id&&(await M(),P(null))}catch(e){G(e instanceof Error?e.message:String(e))}finally{ae(null)}},[k?.id,c,N,g,M,d,Ze]),$=k?.ui?.modal,st=$?.placement!==`replace-config`,ct=k?Ye(k):`checking`,lt=k?!Y(k).ready||me:!1;return n?(0,U.jsxs)(se,{gap:`gap-4`,className:`max-w-6xl`,padding:`px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[c.isLoading?(0,U.jsx)(le,{sections:2}):c.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(c.error)}):(0,U.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:l.map(e=>(0,U.jsx)(rt,{entry:e,config:_[ze(e)]?.config,runtime:Ye(e),busy:ie===e.id,restarting:ce===e.id,ch:J,onOpen:()=>Ze(e.id),onToggle:()=>void it(e),onRestart:()=>void $e(e)},e.id))}),W?(0,U.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:W}):null,(0,U.jsx)(Ce,{presentation:`modal`,open:!!k,onOpenChange:e=>{e||Qe()},closeAriaLabel:J.close,srTitle:k?.label??J.selectChannel,srDescription:k?.description,wide:!0,footer:k?(0,U.jsx)(Ee,{ch:J,dirty:!!N||K!==null,saving:z,onCancel:Qe,onDiscard:()=>{P(null),q(null)},onSave:et}):null,children:k?(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,U.jsx)(tt,{entry:k}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:k.label}),(0,U.jsx)(`span`,{className:w(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,He(ct)),children:Be(ct,J)})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(k).ready&&pe(k)?.[1].result===`qr`?J.scanLoginHint.replace(`{{channel}}`,k.label):k.description}),k.docsPath?(0,U.jsxs)(`a`,{href:k.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[J.docs,(0,U.jsx)(h,{className:`size-3.5`})]}):null]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,U.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(k).enabled?J.enabledLabel:J.disabledLabel}),(0,U.jsx)(nt,{checked:Y(k).enabled,disabled:ie===k.id,label:J.toggleChannel.replace(`{{channel}}`,k.label),onToggle:()=>void it(k)})]})]})}),(0,U.jsx)(at,{runtime:ct,restarting:ce===k.id,checking:f,showConnectionOptions:me,canManageConnection:Y(k).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void $e(k),onCheck:()=>void Q(),onManageConnection:()=>he(e=>!e)}),(0,U.jsx)(ot,{entry:k,ch:J}),lt&&$?.placement!==`replace-config`?(0,U.jsx)(ge,{entry:k,locale:e,messages:J,compact:!0,onChanged:async()=>{await M(),await Q(),await g()}},k.id):null,$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(F,{extensionId:k.extensionId,extensionName:k.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:k.id,entry:k,config:_e}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,U.jsx)(F,{extensionId:k.extensionId,extensionName:k.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:k.id,entry:k,config:_e}}):null,st&&Ae?(0,U.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`mb-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.basicConfiguration}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.basicConfigurationHint})]}),(0,U.jsx)(ue,{schema:De,values:_e,onChange:e=>P(e),disabled:z,labels:Z})]}):null,(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(B,{className:`size-4 text-fg-muted`}),J.messageHandling]}),(0,U.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,U.jsxs)(`div`,{className:`mb-3`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.agentRouting}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.messageHandlingHint})]}),(0,U.jsx)(p,{value:Me,options:Re,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,X||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:z||!E,onChange:e=>q(e)})]})]}),st&&qe(Oe)?(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(B,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(ue,{schema:Oe,values:_e,onChange:e=>P(e),disabled:z,labels:Z})})]}):null,W?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:W}):null]}):null})]}):(0,U.jsxs)(se,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(oe,{title:t.settingsSections.channels}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:J.tokenRequired})]})}export{st as ChannelsSettingsPanel};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,p as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{a as o,i as s,n as c,o as l,r as u,s as d,t as f}from"./dist-CpzYSoz7.js";import{t as p}from"./popover-select-Dz_Qis2R.js";import{t as m}from"./circle-check-C23XjkUj.js";import{t as h}from"./external-link-DjqjBmc3.js";import{t as g}from"./loader-circle-CifKLtgG.js";import{t as _}from"./x-B_N4OPjy.js";import{t as v}from"./messages-DjuBdDCn.js";import{a as y,c as b,i as x,n as S,r as C}from"./locale-store-BBSCIl4I.js";import{t as w}from"./cn-JdwAhgNB.js";import{i as T}from"./vendor-swr-BIWyz7Rc.js";import{t as E}from"./button-B11EPpor.js";import{t as D}from"./skeleton-BwbyijEw.js";import{i as O,o as k}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as A}from"./settings-shell-layer-context-DCp6ykjQ.js";import{Cc as j,Ki as M,Qs as N,Us as P,Wr as F,_n as I,aa as L,an as R,cu as z,fc as B,gn as ee,hn as te,lo as ne,oa as re,us as ie,yc as ae}from"./index-C6OWYFtQ.js";import{n as oe,r as se}from"./settings-page-layout-DYelDcMV.js";import{t as ce}from"./browser-BLJWD7WI.js";import{n as le}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as ue}from"./schema-form-KQFmfWd4.js";import{n as de,t as fe}from"./channels-status-swr-BUZimNmp.js";var V=e(t(),1),H=n();function pe(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var me=e(ce(),1),U=r();async function he(e){let t=await x(C(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function W(e){return e?.type===`poll`&&e.phase===`done`}function G(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function K(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function q(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ge({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,V.useMemo)(()=>pe(e),[e]),o=(0,V.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[s,c]=(0,V.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,V.useEffect)(()=>{c({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let l=(0,V.useCallback)(async(n,i)=>{c(e=>({...e,busy:!0,error:null}));try{let a=await he({channelId:e.id,actionId:n,locale:t,input:i});c(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){c(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,V.useEffect)(()=>{let t=K(s.payload,e.id);if(!t){c(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return c(e=>e.generatedQr?{...e,generatedQr:null}:e),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||c(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,s.payload]),(0,V.useEffect)(()=>{let n=s.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||he({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(c(t=>({...t,payload:e,poll:W(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),W(e)&&window.clearInterval(a))}).catch(e=>{i||c(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,s.poll]);let u=a?.[1].label??(e.configured?n.reconnect:n.connect),d=e.actions?.[`doctor.run`]?.label??n.diagnose,f=G(s.payload),p=K(s.payload,e.id),_=p?s.generatedQr:q(s.payload),v=a?.[1].result===`qr`&&(s.busy||s.payload?.type===`qr`||s.payload?.type===`poll`),y=s.payload?.type===`form`?s.payload:null,b=s.payload?.type===`diagnostics`?s.payload.checks:null;return(0,U.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:w(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,U.jsxs)(E,{type:`button`,variant:`primary`,disabled:s.busy,onClick:()=>void l(a[0]),children:[s.busy?(0,U.jsx)(g,{className:`size-4 animate-spin`}):(0,U.jsx)(j,{className:`size-4`}),u]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(E,{type:`button`,variant:`secondary`,disabled:s.busy,onClick:()=>void l(`doctor.run`),children:[(0,U.jsx)(N,{className:`size-4`}),d]}):null]})]}),f?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:f}):null,s.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:s.error}):null,v?(0,U.jsxs)(`div`,{className:w(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,U.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:_?(0,U.jsx)(`img`,{src:_,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,U.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,U.jsx)(D,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:w(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[_?(0,U.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,U.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,U.jsx)(D,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(D,{className:`h-4 w-36 max-w-full`})]}),p?(0,U.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:p,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,U.jsx)(h,{className:`size-3.5`})]}):null]})]}):null,s.payload?.type===`poll`&&s.payload.phase===`done`?(0,U.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,U.jsx)(m,{className:s.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,U.jsx)(`span`,{className:s.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:s.payload.message??(s.payload.ok?n.complete:n.failed)})]}):null,y?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(ue,{schema:y.schema,values:s.formDraft,onChange:e=>c(t=>({...t,formDraft:e})),disabled:s.busy,labels:o}),(0,U.jsx)(E,{type:`button`,variant:`primary`,disabled:s.busy,onClick:()=>void l(y.submitAction,s.formDraft),children:n.saveSetup})]}):null,b?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:b.map((e,t)=>(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var _e=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ve(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function ye(e,t,n){let r=J(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:_e,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function be(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function xe(e,t,n){let r=be(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Se(e,t=!1){return e===`drawer`?w(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,O):w(`fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,O,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function Ce(e){let t=(0,H.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:p,srTitle:m,srDescription:h,closeAriaLabel:g,children:v,footer:y,wide:b,headerExtra:x}=e,S=b===void 0?!1:b,C=n===`drawer`,[T,D]=(0,V.useState)(null),O;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,U.jsx)(o,{className:w(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,k)}),t[0]=O):O=t[0];let j;t[1]!==n||t[2]!==S?(j=Se(n,S),t[1]=n,t[2]=S,t[3]=j):j=t[3];let M;t[4]===m?M=t[5]:(M=m?(0,U.jsx)(d,{className:`sr-only`,children:m}):null,t[4]=m,t[5]=M);let N;t[6]===h?N=t[7]:(N=h?(0,U.jsx)(s,{className:`sr-only`,children:h}):null,t[6]=h,t[7]=N);let P;t[8]!==g||t[9]!==p||t[10]!==x||t[11]!==C||t[12]!==a?(P=C?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,U.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,p?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:p}):null]}),(0,U.jsx)(c,{asChild:!0,children:(0,U.jsx)(E,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":g,children:(0,U.jsx)(_,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(c,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:w(ie,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":g,children:(0,U.jsx)(_,{className:`size-4`})})}),x]}),t[8]=g,t[9]=p,t[10]=x,t[11]=C,t[12]=a,t[13]=P):P=t[13];let F=C?`p-4`:`p-6`,I;t[14]===F?I=t[15]:(I=w(`min-h-0 flex-1 overflow-y-auto`,F),t[14]=F,t[15]=I);let L;t[16]!==v||t[17]!==I?(L=(0,U.jsx)(`div`,{className:I,children:v}),t[16]=v,t[17]=I,t[18]=L):L=t[18];let R;t[19]!==y||t[20]!==T||t[21]!==M||t[22]!==N||t[23]!==P||t[24]!==L?(R=(0,U.jsxs)(A,{layer:`modal`,portalContainer:T,children:[M,N,P,L,y]}),t[19]=y,t[20]=T,t[21]=M,t[22]=N,t[23]=P,t[24]=L,t[25]=R):R=t[25];let z;t[26]!==R||t[27]!==j?(z=(0,U.jsxs)(l,{children:[O,(0,U.jsx)(u,{ref:D,className:j,onOpenAutoFocus:we,children:R})]}),t[26]=R,t[27]=j,t[28]=z):z=t[28];let B;return t[29]!==i||t[30]!==r||t[31]!==z?(B=(0,U.jsx)(f,{open:r,onOpenChange:i,children:z}),t[29]=i,t[30]=r,t[31]=z,t[32]=B):B=t[32],B}function we(e){return e.preventDefault()}var Te=(0,V.memo)(function(e){let t=(0,H.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,U.jsx)(M,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,U.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function Ee(e){let t=(0,H.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,U.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,U.jsx)(E,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,U.jsx)(E,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,U.jsx)(E,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,U.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function De(e){return C(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function Oe(e){return(await y(De(e))).payload?.channels??[]}function ke(e,t){let n=(0,H.c)(14),r;n[0]!==e||n[1]!==t?(r=e?De(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>Oe(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=T(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var Ae=`channels-status`;function je(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Me(e){let t=t=>e(t.detail);return window.addEventListener(Ae,t),()=>window.removeEventListener(Ae,t)}function Ne(e,t){let n=(0,H.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Me(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,V.useEffect)(i,a)}function Pe(e){return e?C(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Fe(e){return(await y(C(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Ie=[`enabled`];async function Le(){let e=await y(C(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Re(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function ze(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function Y(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Be(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Ve(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function He(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function Ue(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Ie.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Ie.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function We(e,t){let n={...Z(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ge(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ge(n)&&delete t[e];return Object.keys(t).length===0}function Ke(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ge(n),n}function qe(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Je(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function Ye(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Q(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Xe(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push(et(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Q(e,Je(t,e),n);i&&r.push(i)}let a=Ye(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Ze(e,t){let n=Y(e),r=pe(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function Qe(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function $e(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function et(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function tt({entry:e}){let[t,n]=(0,V.useState)(!1),r=(0,V.useMemo)(()=>!e.ui?.icon||t?null:new URL(C(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Re(e.ui.icon)}`)).toString(),[t,e.extensionId,e.ui?.icon]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:r?(0,U.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>n(!0)}):(0,U.jsx)(re,{sourceChannel:e.id,className:`size-7`})})}function nt(e){let t=(0,H.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,l;t[2]!==s||t[3]!==c?(l=w(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=l):l=t[4];let u=n?`translate-x-5`:`translate-x-0.5`,d;t[5]===u?d=t[6]:(d=w(`size-5 rounded-full bg-white shadow-surface transition-transform`,u),t[5]=u,t[6]=d);let f;t[7]===d?f=t[8]:(f=(0,U.jsx)(`span`,{className:d}),t[7]=d,t[8]=f);let p;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==l||t[14]!==f?(p=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:l,children:f}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=l,t[14]=f,t[15]=p):p=t[15],p}function rt(e){let t=(0,H.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:s,onOpen:c,onToggle:l,onRestart:u}=e,d;t[0]===n?d=t[1]:(d=Y(n),t[0]=n,t[1]=d);let f=d,p,m,h,_,v,y,b;if(t[2]!==a||t[3]!==s||t[4]!==r||t[5]!==n||t[6]!==c||t[7]!==u||t[8]!==l||t[9]!==i||t[10]!==f.enabled||t[11]!==f.ready){let e=Xe(n,r,s),o=$e(n,s);p=!f.enabled&&f.ready?l:i===`stopped`?u:c,y=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let d;t[19]===n?d=t[20]:(d=(0,U.jsx)(tt,{entry:n}),t[19]=n,t[20]=d);let g;t[21]===n.label?g=t[22]:(g=(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=g);let x;t[23]===i?x=t[24]:(x=w(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,He(i)),t[23]=i,t[24]=x);let S;t[25]!==s||t[26]!==i?(S=Be(i,s),t[25]=s,t[26]=i,t[27]=S):S=t[27];let C;t[28]!==x||t[29]!==S?(C=(0,U.jsx)(`span`,{className:x,children:S}),t[28]=x,t[29]=S,t[30]=C):C=t[30];let T;t[31]!==C||t[32]!==g?(T=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[g,C]}),t[31]=C,t[32]=g,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==d?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[d,T]}),t[34]=T,t[35]=d,t[36]=E):E=t[36];let D=f.enabled,O;t[37]!==s.toggleChannel||t[38]!==n.label?(O=s.toggleChannel.replace(`{{channel}}`,n.label),t[37]=s.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==l||t[42]!==f.enabled||t[43]!==O?(k=(0,U.jsx)(nt,{checked:D,disabled:a,label:O,onToggle:l}),t[40]=a,t[41]=l,t[42]=f.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(b=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=b):b=t[47],m=`button`,h=c,_=`mt-5 min-h-[6.25rem] text-left`,v=f.ready?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,U.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map($)}):null]}):(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Qe(n,s)}),o.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(it)}):null]}),t[2]=a,t[3]=s,t[4]=r,t[5]=n,t[6]=c,t[7]=u,t[8]=l,t[9]=i,t[10]=f.enabled,t[11]=f.ready,t[12]=p,t[13]=m,t[14]=h,t[15]=_,t[16]=v,t[17]=y,t[18]=b}else p=t[12],m=t[13],h=t[14],_=t[15],v=t[16],y=t[17],b=t[18];let x;t[48]!==m||t[49]!==h||t[50]!==_||t[51]!==v?(x=(0,U.jsx)(`button`,{type:m,onClick:h,className:_,children:v}),t[48]=m,t[49]=h,t[50]=_,t[51]=v,t[52]=x):x=t[52];let S=a||o,C;t[53]!==a||t[54]!==o?(C=a||o?(0,U.jsx)(g,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=C):C=t[55];let T;t[56]!==s||t[57]!==n||t[58]!==o||t[59]!==i?(T=o?s.restartingChannel:i===`stopped`?s.restartChannel:Ze(n,s),t[56]=s,t[57]=n,t[58]=o,t[59]=i,t[60]=T):T=t[60];let D;t[61]!==p||t[62]!==C||t[63]!==T||t[64]!==S?(D=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(E,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:p,disabled:S,children:[C,T]})}),t[61]=p,t[62]=C,t[63]=T,t[64]=S,t[65]=D):D=t[65];let O;return t[66]!==D||t[67]!==y||t[68]!==b||t[69]!==x?(O=(0,U.jsxs)(`article`,{className:y,children:[b,x,D]}),t[66]=D,t[67]=y,t[68]=b,t[69]=x,t[70]=O):O=t[70],O}function it(e){return(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function $(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function at(e){let t=(0,H.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:o,ch:s,onRestart:c,onCheck:l,onManageConnection:u}=e,d=n===`running`?m:n===`stopped`||n===`needs_setup`?z:g,f=n===`running`&&`text-emerald-600 dark:text-emerald-400`,p=n===`stopped`&&`text-red-600 dark:text-red-400`,h=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,_=n===`disabled`&&`text-fg-muted`,v=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,y;t[0]!==f||t[1]!==p||t[2]!==h||t[3]!==_||t[4]!==v?(y=w(`mt-0.5 size-5 shrink-0`,f,p,h,_,v),t[0]=f,t[1]=p,t[2]=h,t[3]=_,t[4]=v,t[5]=y):y=t[5];let b;t[6]!==d||t[7]!==y?(b=(0,U.jsx)(d,{className:y}),t[6]=d,t[7]=y,t[8]=b):b=t[8];let x;t[9]===s.connectionStatus?x=t[10]:(x=(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:s.connectionStatus}),t[9]=s.connectionStatus,t[10]=x);let S;t[11]!==s||t[12]!==n?(S=Ve(n,s),t[11]=s,t[12]=n,t[13]=S):S=t[13];let C;t[14]===S?C=t[15]:(C=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S}),t[14]=S,t[15]=C);let T;t[16]!==C||t[17]!==x?(T=(0,U.jsxs)(`div`,{children:[x,C]}),t[16]=C,t[17]=x,t[18]=T):T=t[18];let D;t[19]!==T||t[20]!==b?(D=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,T]}),t[19]=T,t[20]=b,t[21]=D):D=t[21];let O=i||r,k;t[22]===i?k=t[23]:(k=i?(0,U.jsx)(g,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=k);let A=i?s.checkingConnection:s.checkConnection,j;t[24]!==l||t[25]!==O||t[26]!==k||t[27]!==A?(j=(0,U.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:O,onClick:l,children:[k,A]}),t[24]=l,t[25]=O,t[26]=k,t[27]=A,t[28]=j):j=t[28];let M;t[29]!==s.restartChannel||t[30]!==s.restartingChannel||t[31]!==i||t[32]!==c||t[33]!==r||t[34]!==n?(M=n===`stopped`?(0,U.jsxs)(E,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:c,children:[r?(0,U.jsx)(g,{className:`size-4 animate-spin`}):(0,U.jsx)(ae,{className:`size-4`}),r?s.restartingChannel:s.restartChannel]}):null,t[29]=s.restartChannel,t[30]=s.restartingChannel,t[31]=i,t[32]=c,t[33]=r,t[34]=n,t[35]=M):M=t[35];let N;t[36]!==o||t[37]!==s.connectionOptions||t[38]!==s.hideConnectionOptions||t[39]!==i||t[40]!==u||t[41]!==r||t[42]!==a?(N=o?(0,U.jsx)(E,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:u,children:a?s.hideConnectionOptions:s.connectionOptions}):null,t[36]=o,t[37]=s.connectionOptions,t[38]=s.hideConnectionOptions,t[39]=i,t[40]=u,t[41]=r,t[42]=a,t[43]=N):N=t[43];let P;t[44]!==j||t[45]!==M||t[46]!==N?(P=(0,U.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[j,M,N]}),t[44]=j,t[45]=M,t[46]=N,t[47]=P):P=t[47];let F;return t[48]!==D||t[49]!==P?(F=(0,U.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[D,P]})}),t[48]=D,t[49]=P,t[50]=F):F=t[50],F}function ot(e){let t=(0,H.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Y(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-amber-950 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,U.jsx)(P,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,U.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,U.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,U.jsx)(`li`,{children:et(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,U.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,U.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,U.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,U.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function st(){let e=S(e=>e.language),t=v(e),n=b(e=>!!e.sessionKey),r=i(),{channelId:o}=a(),s=I(o),c=ke(n,e),l=c.entries,{data:u,mutate:d,isValidating:f}=T(n?fe():null,de,{revalidateOnFocus:!0}),{data:m,mutate:g}=T(n?`channels-config-map`:null,Le,{revalidateOnFocus:!1}),_=m?.channels??{},y=m?.bindings??[],{data:E}=T(n?`channel-routing-agents`:null,L,{revalidateOnFocus:!1}),D=ne(e=>e.setPageHeader),O=ne(e=>e.clearPageHeader),k=(0,V.useMemo)(()=>l.find(e=>e.id===s),[s,l]),A=k?ze(k):null,{data:j,mutate:M}=T(n&&A?Pe(A):null,()=>Fe(A)),[N,P]=(0,V.useState)(null),[z,re]=(0,V.useState)(!1),[ie,ae]=(0,V.useState)(null),[ce,H]=(0,V.useState)(null),[me,he]=(0,V.useState)(!1),[W,G]=(0,V.useState)(null),[K,q]=(0,V.useState)(null),_e=N??j??{},J=t.channelsSettings,be=(0,V.useMemo)(()=>k?.configSchema??{type:`object`,properties:{}},[k?.configSchema]),Se=(0,V.useMemo)(()=>Ke(be,Ie),[be]),we=(0,V.useMemo)(()=>Ue(k),[k]),De=(0,V.useMemo)(()=>We(Se,we),[we,Se]),Oe=(0,V.useMemo)(()=>Ke(Se,we),[we,Se]),Ae=(0,V.useMemo)(()=>qe(De),[De]),Me=k?K??ve(y,k.id):``,Re=(0,V.useMemo)(()=>(E?.items??[]).map(e=>{let n=R(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[E?.items,t.agentsSettings]),Ve=E?.items.find(e=>e.id===E.defaultId),X=Ve?R(Ve,t.agentsSettings):E?.defaultId??``,Z=(0,V.useMemo)(()=>({defaultBooleanLabel:J.schemaBooleanDefault,unsupportedArrayType:J.schemaUnsupportedArrayType,arrayAddPlaceholder:J.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>J.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[J]),Ge=(0,V.useMemo)(()=>new Map((u??[]).map(e=>[e.name,e])),[u]),Je=u!==void 0,Ye=(0,V.useCallback)(e=>xe(e,Ge.get(e.id),Je),[Ge,Je]),Q=(0,V.useCallback)(async()=>{await Promise.all([c.mutate(),d()])},[c,d]);Ne((0,V.useCallback)(e=>{let t=je(e);t&&d(t,!1)},[d]),n);let Xe=(0,V.useMemo)(()=>n?(0,U.jsx)(Te,{ch:J,refreshing:c.isValidating||f,saveOk:!1,onRefresh:()=>void Q()}):null,[c.isValidating,J,n,f,Q]);(0,V.useLayoutEffect)(()=>(D({startExtra:null,main:(0,U.jsx)(`div`,{className:`min-w-0`,children:(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>O()),[O,Xe,t.settingsSections.channels,D]);let Ze=(0,V.useCallback)(e=>{r(ee(e)),P(null),q(null),G(null)},[r]),Qe=(0,V.useCallback)(()=>{r(te),P(null),q(null),G(null)},[r]),$e=(0,V.useCallback)(async e=>{H(e.id),G(null);try{let t=await x(C(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){G(e instanceof Error?e.message:String(e))}finally{H(null)}},[Q]);(0,V.useEffect)(()=>{q(null),he(!1)},[k?.id]);let et=(0,V.useCallback)(async()=>{if(!k||!N&&K===null)return!1;let e=ze(k);re(!0),G(null);try{let t=await x(C(`/api/config`),{method:`PATCH`,body:JSON.stringify({...N?{channels:{[e]:N}}:{},...K===null?{}:{bindings:ye(y,k.id,K)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return N&&await M(N,!1),await g(),await c.mutate(),P(null),q(null),!0}catch(e){return G(e instanceof Error?e.message:String(e)),!1}finally{re(!1)}},[k,K,y,c,N,g,M]),it=(0,V.useCallback)(async e=>{let t=Y(e),n=ze(e),r=k?.id===e.id?N:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ae(e.id),G(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await x(C(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await c.mutate(),await g(),await d(),k?.id===e.id&&(await M(),P(null))}catch(e){G(e instanceof Error?e.message:String(e))}finally{ae(null)}},[k?.id,c,N,g,M,d,Ze]),$=k?.ui?.modal,st=$?.placement!==`replace-config`,ct=k?Ye(k):`checking`,lt=k?!Y(k).ready||me:!1;return n?(0,U.jsxs)(se,{gap:`gap-4`,className:`max-w-6xl`,padding:`px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[c.isLoading?(0,U.jsx)(le,{sections:2}):c.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(c.error)}):(0,U.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:l.map(e=>(0,U.jsx)(rt,{entry:e,config:_[ze(e)]?.config,runtime:Ye(e),busy:ie===e.id,restarting:ce===e.id,ch:J,onOpen:()=>Ze(e.id),onToggle:()=>void it(e),onRestart:()=>void $e(e)},e.id))}),W?(0,U.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:W}):null,(0,U.jsx)(Ce,{presentation:`modal`,open:!!k,onOpenChange:e=>{e||Qe()},closeAriaLabel:J.close,srTitle:k?.label??J.selectChannel,srDescription:k?.description,wide:!0,footer:k?(0,U.jsx)(Ee,{ch:J,dirty:!!N||K!==null,saving:z,onCancel:Qe,onDiscard:()=>{P(null),q(null)},onSave:et}):null,children:k?(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,U.jsx)(tt,{entry:k}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:k.label}),(0,U.jsx)(`span`,{className:w(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,He(ct)),children:Be(ct,J)})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(k).ready&&pe(k)?.[1].result===`qr`?J.scanLoginHint.replace(`{{channel}}`,k.label):k.description}),k.docsPath?(0,U.jsxs)(`a`,{href:k.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[J.docs,(0,U.jsx)(h,{className:`size-3.5`})]}):null]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,U.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(k).enabled?J.enabledLabel:J.disabledLabel}),(0,U.jsx)(nt,{checked:Y(k).enabled,disabled:ie===k.id,label:J.toggleChannel.replace(`{{channel}}`,k.label),onToggle:()=>void it(k)})]})]})}),(0,U.jsx)(at,{runtime:ct,restarting:ce===k.id,checking:f,showConnectionOptions:me,canManageConnection:Y(k).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void $e(k),onCheck:()=>void Q(),onManageConnection:()=>he(e=>!e)}),(0,U.jsx)(ot,{entry:k,ch:J}),lt&&$?.placement!==`replace-config`?(0,U.jsx)(ge,{entry:k,locale:e,messages:J,compact:!0,onChanged:async()=>{await M(),await Q(),await g()}},k.id):null,$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(F,{extensionId:k.extensionId,extensionName:k.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:k.id,entry:k,config:_e}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,U.jsx)(F,{extensionId:k.extensionId,extensionName:k.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:k.id,entry:k,config:_e}}):null,st&&Ae?(0,U.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`mb-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.basicConfiguration}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.basicConfigurationHint})]}),(0,U.jsx)(ue,{schema:De,values:_e,onChange:e=>P(e),disabled:z,labels:Z})]}):null,(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(B,{className:`size-4 text-fg-muted`}),J.messageHandling]}),(0,U.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,U.jsxs)(`div`,{className:`mb-3`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.agentRouting}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.messageHandlingHint})]}),(0,U.jsx)(p,{value:Me,options:Re,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,X||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:z||!E,onChange:e=>q(e)})]})]}),st&&qe(Oe)?(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(B,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(ue,{schema:Oe,values:_e,onChange:e=>P(e),disabled:z,labels:Z})})]}):null,W?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:W}):null]}):null})]}):(0,U.jsxs)(se,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(oe,{title:t.settingsSections.channels}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:J.tokenRequired})]})}export{st as ChannelsSettingsPanel};
|