dsh-office-kit 0.0.0-stage → 0.2.0

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.
@@ -0,0 +1,110 @@
1
+ ---
2
+ description: Create, inspect, edit, recalculate, and render Excel .xlsx workbooks with the bundled Office helper CLI.
3
+ ---
4
+
5
+ # Spreadsheets (.xlsx)
6
+
7
+ Build local Excel workbooks with values, formulas, styles, charts, and images; inspect existing workbooks; recalculate with Excel when cached values are required. This skill does not use `@oai/artifact-tool` and does not edit Google Sheets.
8
+
9
+ ## Before any file work
10
+
11
+ 1. Call the `office_status` tool.
12
+ 2. Use the `python` and `cli` values from the `## Office runtime` JSON block at the end of this file.
13
+ 3. If no compatible Python is reported, stop and tell the user.
14
+
15
+ ## Create
16
+
17
+ ```bash
18
+ "<python>" "<cli>" xlsx create --spec "<spec.json>" --out "<output.xlsx>"
19
+ ```
20
+
21
+ ```json
22
+ {
23
+ "sheets": [{
24
+ "name": "Summary",
25
+ "rows": [
26
+ ["Quarter", "Revenue", "Cost", "Gross profit"],
27
+ ["Q1", 100, 60, "=B2-C2"],
28
+ ["Q2", 128, 70, "=B3-C3"],
29
+ [null, "=SUM(B2:B3)"]
30
+ ],
31
+ "styles": {
32
+ "A1:D1": { "bold": true, "fill": "#E8EEF7", "align": "center" },
33
+ "B2:D4": { "number_format": "#,##0" }
34
+ },
35
+ "widths": { "A": 12, "B": 14, "C": 12, "D": 14 },
36
+ "freeze": "A2",
37
+ "charts": [{
38
+ "type": "column",
39
+ "title": "Quarterly revenue",
40
+ "anchor": "F2",
41
+ "data": { "min_col": 2, "min_row": 1, "max_col": 2, "max_row": 3, "titles_from_data": true },
42
+ "categories": { "min_col": 1, "min_row": 2, "max_row": 3 }
43
+ }]
44
+ }]
45
+ }
46
+ ```
47
+
48
+ Rows are written from A1. A string starting with `=` is a formula, not text. Styles support `bold`, `italic`, `size`, `color` (hex), `fill` (hex), `number_format`, and `align` (`left`/`center`/`right`). Chart types: `bar`, `column`, `line`, `pie`; data/category references are 1-based.
49
+
50
+ ## Read
51
+
52
+ ```bash
53
+ "<python>" "<cli>" xlsx read --input "<file.xlsx>"
54
+ "<python>" "<cli>" xlsx read --input "<file.xlsx>" --data-only
55
+ ```
56
+
57
+ Default read returns formulas. `--data-only` returns cached values, which are only present if Excel (or another producer) stored them. A formula created by openpyxl has no cached value until recalculated.
58
+
59
+ ## Edit
60
+
61
+ ```bash
62
+ "<python>" "<cli>" xlsx edit --input "<file.xlsx>" --spec "<edit.json>" --out "<file-edited.xlsx>"
63
+ ```
64
+
65
+ ```json
66
+ {
67
+ "operations": [
68
+ { "action": "set_cells", "sheet": "Summary", "cells": { "E2": "Reviewed", "E3": "Pending" } },
69
+ { "action": "append_rows", "sheet": "Summary", "rows": [["Q3", 150, 80, "=B4-C4"]] },
70
+ { "action": "style", "sheet": "Summary", "cells": { "E2:E3": { "bold": true } } },
71
+ { "action": "add_sheet", "name": "Notes" },
72
+ { "action": "rename_sheet", "from": "Notes", "to": "Appendix" },
73
+ { "action": "delete_sheet", "name": "Appendix" }
74
+ ]
75
+ }
76
+ ```
77
+
78
+ Actions: `set_cells`, `append_rows` (or `rows`), `style`, `chart`, `image`, `add_sheet`, `delete_sheet`, `rename_sheet`. The input is never modified. Existing formulas/styles outside the edited cells are preserved by openpyxl, but charts created by other tools may be dropped when the workbook is re-saved; verify before replacing a production file.
79
+
80
+ ## Recalculate formulas
81
+
82
+ ```bash
83
+ "<python>" "<cli>" xlsx recalc --input "<file.xlsx>" --out "<file-recalculated.xlsx>"
84
+ ```
85
+
86
+ This requires Microsoft Excel on Windows. It opens the workbook, forces a full calculation, saves with cached values, and closes Excel. On other systems the CLI fails explicitly; there is no bundled formula engine. Without recalculation, Excel normally computes formulas when the file is opened, but `--data-only` reads will stay empty.
87
+
88
+ ## Render and verify
89
+
90
+ ```bash
91
+ "<python>" "<cli>" xlsx render --input "<file.xlsx>" --out-dir "<render-dir>"
92
+ ```
93
+
94
+ The renderer prefers Microsoft Excel COM on Windows (exports each sheet to PDF) and LibreOffice otherwise, then rasterizes pages to PNG. Check values, number formats, column widths, frozen panes, merged cells, chart legends/categories, and clipping. `read` complements the visual check for exact cell values.
95
+
96
+ ## Quality rules
97
+
98
+ - Put raw inputs and calculated cells on the same sheet, or clearly document the calculation chain.
99
+ - Use formulas instead of hard-coded results when the workbook should stay live.
100
+ - Use number formats for currency/percent/dates instead of embedding symbols in text.
101
+ - Keep one header row, avoid merged cells in data ranges, and leave a frozen header.
102
+ - Verify every formula you authored with `read` (formula) and, where possible, `recalc` + `--data-only` (value).
103
+
104
+ ## Not supported
105
+
106
+ - Google Sheets / Google Drive editing.
107
+ - Pivot tables, Power Query, macros/VBA, data validation, conditional formatting, slicers, external workbook links.
108
+ - Formula evaluation without Microsoft Excel; `recalc` is Windows + Excel only.
109
+ - Exact Excel rendering fidelity on LibreOffice; charts from foreign producers may not survive editing.
110
+ - `@oai/artifact-tool` helpers or artifact-tool workbook gates.
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: dsh-office-kit
3
+ name: dsh-office-kit
package/dist/client.js ADDED
@@ -0,0 +1,267 @@
1
+ window.__ModuleLoader__.load({id:"dsh-office-kit",factory:(require)=>{var module={exports:{}};var exports=module.exports;
2
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@deepseek-ai/dsh-client-ui-primitives"),t=require("react"),n=require("react/jsx-runtime");const r=[{id:`documents`,label:`Documents`,description:`Create, edit, render, and verify Word documents (.docx).`,hint:`DOCX`,skill:`office-documents`,command:`documents`,extensions:[`.docx`]},{id:`pdf`,label:`PDF`,description:`Create, read, edit, render, and verify PDF files.`,hint:`PDF`,skill:`office-pdf`,command:`pdf`,extensions:[`.pdf`]},{id:`presentations`,label:`Presentations`,description:`Create, edit, render, and verify slide decks (.pptx).`,hint:`PPTX`,skill:`office-presentations`,command:`presentations`,extensions:[`.pptx`]},{id:`spreadsheets`,label:`Spreadsheets`,description:`Create, edit, recalculate, render, and verify workbooks (.xlsx).`,hint:`XLSX`,skill:`office-spreadsheets`,command:`spreadsheets`,extensions:[`.xlsx`]}];function i(e){return r.find(t=>t.id===e)}function a(e){return r.find(t=>t.command===e)}const o=`dsh-office-kit`,s=`office`,c=`office`,l=`conversation.user.text.node`,u=`sidebar.right.tab.document.actions`,d=`officeAnnotation`,f=`<office-annotations>`,p=`</office-annotations>`,m=`canvas[role="img"][aria-label]`,h=2e4;function g(e,t){return e.replace(/\{(\w+)\}/gu,(e,n)=>t[n]??e)}function _(e){let t=[];for(let n of e.replace(/\r\n?/gu,`
3
+ `).split(`
4
+ `)){let e=n.replace(/\s+/gu,` `).trim();e.length>0&&t.push(e)}return t.join(`
5
+ `)}function v(e,t){let n=Math.min(e.left,t.left),r=Math.min(e.top,t.top);return{left:n,top:r,width:Math.max(e.left+e.width,t.left+t.width)-n,height:Math.max(e.top+e.height,t.top+t.height)-r}}function y(e,t){let n=Math.max(e.left,t.left),r=Math.max(e.top,t.top),i=Math.min(e.left+e.width,t.left+t.width)-n,a=Math.min(e.top+e.height,t.top+t.height)-r;return i>0&&a>0?{left:n,top:r,width:i,height:a}:void 0}function b(e,t){return y({left:e.left-3,top:e.top-3,width:e.width+6,height:e.height+6},t)}function x(e,t,n){return t>=e.left&&t<=e.left+e.width&&n>=e.top&&n<=e.top+e.height}function S(e,t,n){return{left:Math.max(8,Math.min(e.left,n.width-t.width-8)),top:Math.max(8,Math.min(e.top>=t.height+8?e.top-t.height:e.top+e.height,n.height-t.height-8))}}function ee(e,t,n){let r;for(let i of e){let e=i.box;(i.rects??[e]).some(e=>t>=e.left-8&&t<=e.left+e.width+8&&n>=e.top-4&&n<=e.top+e.height+4)&&(!r||e.width*e.height<r.box.width*r.box.height)&&(r=i)}return r}function C(e){let t=[];for(let n of[...e].sort((e,t)=>e.box.top-t.box.top||e.box.left-t.box.left)){if(!n.text.trim()||n.box.width<=0||n.box.height<=0)continue;let e=t.find(e=>Math.abs(e.box.top-n.box.top)<Math.min(e.box.height,n.box.height)*.45&&n.box.left>=e.box.left&&n.box.left-(e.box.left+e.box.width)<n.box.height*2);e?(e.text+=` ${n.text}`,e.box=v(e.box,n.box),e.rects.push(n.box)):t.push({text:n.text,box:n.box,rects:[n.box]})}let n=[];for(let e of t){let t=n.findLast(t=>{let n=e.box.top-(t.last.top+t.last.height),r=Math.min(t.last.left+t.last.width,e.box.left+e.box.width)-Math.max(t.last.left,e.box.left);return n>=-e.box.height*.2&&n<=Math.min(t.last.height,e.box.height)*.7&&r>0&&Math.abs(t.last.left-e.box.left)<e.box.height*2&&Math.max(t.last.height,e.box.height)/Math.min(t.last.height,e.box.height)<1.4});t?(t.text+=`\n${e.text}`,t.box=v(t.box,e.box),t.rects.push(...e.rects),t.last=e.box):n.push({...e,last:e.box})}return n.map(({text:e,box:t,rects:n})=>({text:_(e),box:t,rects:n}))}function w(e){let t=e.parentElement;if(!t)return[];let n=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),r=[];for(let e=n.nextNode();e;e=n.nextNode()){if(!e.textContent?.trim())continue;let t=document.createRange();t.selectNodeContents(e);let n=t.getBoundingClientRect();n.width>0&&n.height>0&&r.push({text:e.textContent,box:{left:n.left,top:n.top,width:n.width,height:n.height}})}return C(r)}function te(e){let t=e.parentElement;for(;t&&getComputedStyle(t).display===`contents`;)t=t.parentElement;return t?.parentElement?{header:t,root:t.parentElement}:void 0}function ne(e,t,n){let r=[...e.querySelectorAll(m)],i=r.findIndex(e=>x(e.getBoundingClientRect(),t,n)&&e.getBoundingClientRect().width>0);return i<0?void 0:{canvas:r[i],page:i+1}}function re(e,t){if(t.width<=0||t.height<=0)throw Error(`annotation.emptyPage`);let n=y(e,t);if(!n)throw Error(`annotation.emptyRegion`);return{left:(n.left-t.left)/t.width,top:(n.top-t.top)/t.height,width:n.width/t.width,height:n.height/t.height}}async function ie(e,t,n=4e6,r=1/0){let i=e.canvas;if(!i||i.width<=0||i.height<=0)throw Error(`annotation.captureFailed`);let a=i.getBoundingClientRect(),o=e.region??re(e.box,a),s=i.width*o.width,c=i.height*o.height,l=Math.min(1,Math.sqrt(n/(s*c)),r/s,r/c);if(!Number.isFinite(l)||l<=0)throw Error(`annotation.captureFailed`);let u=document.createElement(`canvas`);u.width=Math.max(1,Math.floor(s*l)),u.height=Math.max(1,Math.floor(c*l));let d=u.getContext(`2d`);if(!d)throw Error(`annotation.captureFailed`);d.drawImage(i,o.left*i.width,o.top*i.height,s,c,0,0,u.width,u.height);let f=await new Promise((e,t)=>u.toBlob(n=>n?e(n):t(Error(`annotation.captureFailed`)),`image/png`));return new File([f],t,{type:`image/png`})}function T(e){if(typeof e!=`object`||!e)return!1;let t=e,n=(e,t)=>typeof e==`string`&&e.length<=t;if(!n(t.target,2e4)||!n(t.fileName,1e3)||!n(t.text,2e4)||!n(t.requirement,2e4)||!t.requirement.trim()||t.page!==void 0&&(!Number.isSafeInteger(t.page)||t.page<1)||t.imageName!==void 0&&!n(t.imageName,1e3))return!1;if(t.region!==void 0){let e=t.region;if(!e||![`left`,`top`,`width`,`height`].every(t=>typeof e[t]==`number`&&Number.isFinite(e[t])&&e[t]>=0&&e[t]<=1)||e.width<=0||e.height<=0||e.left+e.width>1.000001||e.top+e.height>1.000001)return!1}return!0}function E(e){if(!e.length||e.length>50||!e.every(T))throw Error(`annotation.invalid`);let t=JSON.stringify(e).replace(/</gu,`\\u003c`);if(t.length>12e5)throw Error(`annotation.tooLarge`);return`${f}\n${t}\n${p}`}const D={id:d,order:10,match(e,t){for(let n=e.indexOf(f,t);n>=0;n=e.indexOf(f,n+20)){let t=e.indexOf(p,n+20);if(t<0)return;let r=e.slice(n+20,t).trim();if(!(r.length>12e5))try{let e=JSON.parse(r);if(Array.isArray(e)&&e.length>0&&e.length<=50&&e.every(T))return{id:d,start:n,end:t+21,data:{items:e}}}catch{}}}};function ae({items:e,inputActions:t,intake:n,limits:r,existingImages:i,deferSubmit:a}){let o=E(e.map(e=>e.annotation)),s=e.flatMap(e=>e.file?[e.file]:[]);if(s.length&&!n)throw Error(`annotation.intakeUnavailable`);if(s.length&&r&&(s.some(e=>!r.mediaTypes.includes(e.type)||e.size>r.maxImageBytes)||i.length+s.length>r.maxImagesPerMessage||[...i,...s].reduce((e,t)=>e+t.size,0)>r.maxMessageImageBytes))throw Error(`annotation.imageLimit`);let c=t.captureInsertion(),l=s.length?n.create(s):[];if(l.length&&!t.addAttachments(l.map(e=>e.id)))throw n.release(l),Error(`annotation.sendFailed`);if(!t.insertText(`\n${o}\n`,{...c,start:c.end})){for(let e of l)t.removeAttachment(e.id);throw n?.release(l),Error(`annotation.sendFailed`)}try{return t.persistDraft(),a?`draft`:(t.submit(),`sent`)}catch{return`draft`}}function O({node:e,interactive:r,openAnnotation:i,t:a}){let o=(0,t.useId)(),s=(0,t.useRef)(null),c=(0,t.useRef)(null),[l,u]=(0,t.useState)(!1),d=g(a(`annotation.count`),{count:String(e.data.items.length)});return(0,t.useLayoutEffect)(()=>{let e=c.current,t=s.current;if(!e||!t)return;if(!l){e.hidePopover?.();return}e.showPopover?.();let n=()=>{let n={width:document.documentElement.clientWidth,height:window.innerHeight},{left:r,top:i}=S(t.getBoundingClientRect(),e.getBoundingClientRect(),n);e.style.left=`${r}px`,e.style.top=`${i}px`},r=t=>{t.target instanceof Node&&e.contains(t.target)||u(!1)},i=new ResizeObserver(n);return i.observe(t),i.observe(e),window.addEventListener(`resize`,n),document.addEventListener(`scroll`,r,!0),n(),()=>{e.hidePopover?.(),i.disconnect(),window.removeEventListener(`resize`,n),document.removeEventListener(`scroll`,r,!0)}},[l]),(0,n.jsxs)(`span`,{ref:s,className:`dsh-office-annotation-reference`,onPointerEnter:()=>u(!0),onPointerLeave:e=>{(!(e.relatedTarget instanceof Node)||!e.currentTarget.contains(e.relatedTarget))&&u(!1)},onFocus:()=>u(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||u(!1)},onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),c.current?.contains(e.target)&&s.current?.querySelector(`button`)?.focus(),u(!1))},children:[(0,n.jsx)(`button`,{type:`button`,id:`${o}-trigger`,"aria-haspopup":`dialog`,"aria-controls":o,"aria-expanded":l,children:d}),(0,n.jsx)(`span`,{ref:c,popover:`manual`,className:`dsh-office-annotation-popover`,"data-open":l,id:o,role:`dialog`,"aria-labelledby":`${o}-trigger`,children:(0,n.jsx)(`span`,{className:`dsh-office-annotation-list`,children:e.data.items.map((e,t)=>(0,n.jsxs)(`span`,{className:`dsh-office-annotation-item`,children:[(0,n.jsx)(`span`,{className:`dsh-office-annotation-source`,children:r?(0,n.jsx)(`button`,{type:`button`,onClick:()=>i(e.target),title:e.target,children:e.fileName}):(0,n.jsx)(`span`,{children:e.fileName})}),(0,n.jsx)(`span`,{className:`dsh-office-annotation-requirement`,children:e.requirement})]},t))})})]})}function k(e){return/\.(?:pdf|docx?)$/iu.test(e.absolutePath)?(0,n.jsx)(A,{...e},e.absolutePath):null}function A({absolutePath:e,pendingAnnotations:r,intake:i,inputActions:a,useInput:o,useProjection:s,t:c}){let l=(0,t.useRef)(null),u=(0,t.useRef)(null),d=(0,t.useRef)(null),f=(0,t.useRef)(),[p,_]=(0,t.useState)(),[v,x]=(0,t.useState)(!1),[S,C]=(0,t.useState)(),[T,E]=(0,t.useState)(),[D,O]=(0,t.useState)(``),[k,A]=(0,t.useState)(),[j,M]=(0,t.useState)(!1),[N,P]=(0,t.useState)(!1),[F,I]=(0,t.useState)(()=>r.get(e)??[]),[oe,L]=(0,t.useState)(!1),R=(0,t.useId)(),[z,B]=(0,t.useState)(``),V=o(e=>e),H=s(`imageLimits`),U=/\.pdf$/iu.test(e),W=e.replace(/\\/gu,`/`).split(`/`).pop()??e,G=(0,t.useRef)(0),K=(0,t.useRef)(),q=(0,t.useRef)(),J=(0,t.useRef)(),se=V.phase!==`plain`;(0,t.useEffect)(()=>{F.length?r.set(e,F):r.delete(e)},[e,F,r]);function Y(){G.current++,E(void 0),A(void 0),M(!1),O(``)}function X(){clearTimeout(K.current),q.current=void 0,P(!1),C(void 0)}(0,t.useEffect)(()=>{let e=l.current,t=e&&te(e);if(!t)return;let{header:n,root:r}=t;f.current=r;let i=0,a=()=>{cancelAnimationFrame(i),i=requestAnimationFrame(()=>{J.current=void 0;let e=r.getBoundingClientRect(),t=Math.max(e.top,n.getBoundingClientRect().bottom,0),i=Math.min(e.bottom,window.innerHeight),a=Math.max(0,e.left),o=Math.min(e.right,window.innerWidth),s=[...r.querySelectorAll(m)].find(e=>e.getBoundingClientRect().width>0),c=r.isConnected&&!r.closest(`[hidden], [aria-hidden="true"]`)&&getComputedStyle(r).visibility===`visible`;_(c&&e.height>40&&s&&o>a&&i>t?{left:a,top:t,width:o-a,height:i-t}:void 0),E(e=>{if(!e?.canvas||!e.region)return e;let t=e.canvas.getBoundingClientRect(),n=e.region,r={left:t.left+n.left*t.width,top:t.top+n.top*t.height,width:n.width*t.width,height:n.height*t.height};return Object.keys(r).every(t=>r[t]===e.box[t])?e:{...e,box:r}})})},o=new ResizeObserver(a);o.observe(r);let s=new MutationObserver(t=>{t.some(t=>!e.contains(t.target))&&a()});s.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`hidden`,`aria-hidden`,`class`,`style`]});for(let e=r.parentElement;e;e=e.parentElement)s.observe(e,{attributes:!0});return window.addEventListener(`resize`,a),r.addEventListener(`transitionend`,a),r.addEventListener(`scroll`,a,!0),a(),()=>{G.current++,clearTimeout(K.current),cancelAnimationFrame(i),o.disconnect(),s.disconnect(),window.removeEventListener(`resize`,a),r.removeEventListener(`transitionend`,a),r.removeEventListener(`scroll`,a,!0),f.current=void 0}},[]),(0,t.useEffect)(()=>{if(!T)return;let e=e=>{e.target instanceof Node&&!u.current?.contains(e.target)&&Y()};return document.addEventListener(`pointerdown`,e,!0),u.current?.querySelector(`input`)?.focus(),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[T]),(0,t.useEffect)(()=>{v&&d.current?.focus()},[v]);function ce(e,t){let n=f.current;if(!n)return;let r=n.querySelector(m)?.parentElement;for(;r&&r!==n&&!/auto|scroll/u.test(getComputedStyle(r).overflowY);)r=r.parentElement;r?.scrollBy({left:e,top:t}),C(void 0)}(0,t.useEffect)(()=>{let e=d.current;if(!v||!e||!p)return;let t=e=>{e.preventDefault();let t=e.deltaMode===1?16:e.deltaMode===2?p.height:1;ce(e.deltaX*t,e.deltaY*t)};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[v,p]);function le(e,t){if(!f.current)return;let n=ne(f.current,e,t);if(!n)return;let r=n.canvas.getBoundingClientRect();(J.current?.canvas!==n.canvas||J.current.box.left!==r.left||J.current.box.top!==r.top||J.current.box.width!==r.width||J.current.box.height!==r.height)&&(J.current={canvas:n.canvas,box:r,paragraphs:w(n.canvas)});let i=ee(J.current.paragraphs,e,t);return i?{...i,...n}:void 0}function Z(e,t){let n=q.current;if(!n)return;let r=y({left:Math.min(n.x,e),top:Math.min(n.y,t),width:Math.abs(e-n.x),height:Math.abs(t-n.y)},n.canvas.getBoundingClientRect());if(!r)return;let i=J.current?.canvas===n.canvas?J.current.paragraphs:w(n.canvas);return{canvas:n.canvas,page:n.page,box:r,region:re(r,n.canvas.getBoundingClientRect()),text:i.filter(e=>(e.rects??[e.box]).some(e=>y(e,r))).map(e=>e.text).join(`
6
+ `).slice(0,h)}}function ue(e){if(e.button!==0||!f.current||U&&!i)return;let t=ne(f.current,e.clientX,e.clientY);if(!t)return;e.preventDefault(),Y();let n={...t,x:e.clientX,y:e.clientY,lastX:e.clientX,lastY:e.clientY,region:!1};q.current=n,e.currentTarget.setPointerCapture(e.pointerId),K.current=setTimeout(()=>{q.current===n&&(n.region=!0,P(!0),C(Z(n.lastX,n.lastY)))},350)}function de(e){let t=q.current;t&&(t.lastX=e.clientX,t.lastY=e.clientY,!t.region&&Math.hypot(e.clientX-t.x,e.clientY-t.y)>=6&&(clearTimeout(K.current),t.region=!0,P(!0))),C(t?.region?Z(e.clientX,e.clientY):le(e.clientX,e.clientY))}async function fe(e){Y();let t=G.current;B(``);let n=e.canvas?.getBoundingClientRect(),r=n?b(e.box,n):e.box;if(!r)return;let i=n?re(r,n):e.region,a={...e,box:r,region:i};if(E(a),U){M(!0);try{let n=await ie(a,`${W}-p${e.page}-${Date.now()}.png`,H?.maxImagePixels,H?.maxImageDimension);G.current===t&&A(n)}catch{G.current===t&&B(c(`annotation.captureFailed`))}finally{G.current===t&&M(!1)}}}function pe(e){let t=q.current;if(clearTimeout(K.current),!t)return;let n=t.region?Z(e.clientX,e.clientY):le(e.clientX,e.clientY),r=Math.hypot(e.clientX-t.x,e.clientY-t.y);X(),n&&(t.region?n.box.width>=6&&n.box.height>=6:r<6)&&fe(n)}function me(){if(!T||!D.trim()||U&&!k||F.length>=50)return;let t={target:e,fileName:W,page:T.page,text:T.text.slice(0,h),requirement:D.trim(),region:T.region,imageName:k?.name};I(e=>[...e,{annotation:t,file:k}]),Y()}function he(){if(!se)try{let e=ae({items:F,inputActions:a,intake:i,limits:H,existingImages:i?.images(V.attachmentIds)??[],deferSubmit:!!V.draft.trim()||V.attachmentIds.length>0});I([]),L(!1),x(!1),Y(),B(e===`draft`?c(`annotation.draftReady`):``)}catch(e){let t=e instanceof Error?e.message:`annotation.sendFailed`;B(c(t.startsWith(`annotation.`)?t:`annotation.sendFailed`))}}let Q=T??S,ge=Q&&!T&&!N&&Q.canvas?b(Q.box,Q.canvas.getBoundingClientRect()):Q?.box,$=ge&&p?y(ge,p):void 0,_e=p?Math.min(360,p.width-16):0,ve=p&&T?Math.max(p.left+8,Math.min(T.box.left,p.left+p.width-_e-8)):0,ye=p&&T?Math.max(p.top+4,Math.min(T.box.top+T.box.height+6,p.top+p.height-56)):0;return(0,n.jsxs)(`span`,{ref:l,className:`dsh-office-annotate`,onKeyDown:e=>{if(!v||e.key!==`Escape`)return;e.preventDefault(),e.stopPropagation();let t=!!T||!!q.current;Y(),X(),t?d.current?.focus():(x(!1),l.current?.querySelector(`button`)?.focus())},children:[(0,n.jsx)(`button`,{type:`button`,className:`dsh-office-annotate-toggle`,"aria-pressed":v,disabled:!p||U&&!i,title:c(U&&!i?`annotation.intakeUnavailable`:p?`annotation.help`:`annotation.unavailable`),onClick:()=>{x(e=>!e),Y(),X()},children:c(`annotation.ask`)}),U&&!i&&(0,n.jsx)(`span`,{role:`status`,className:`dsh-office-annotate-unavailable`,children:c(`annotation.intakeUnavailable`)}),v&&p&&(0,n.jsx)(`div`,{ref:d,className:`dsh-office-annotate-surface`,tabIndex:0,style:{left:p.left,top:p.top,width:p.width,height:p.height},role:`region`,"aria-label":c(`annotation.help`),onPointerDown:ue,onPointerMove:de,onPointerUp:pe,onPointerCancel:X,onLostPointerCapture:X,onKeyDown:e=>{if(e.key===`PageDown`||e.key===`PageUp`)e.preventDefault(),ce(0,p.height*(e.key===`PageDown`?.8:-.8));else if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=[...f.current.querySelectorAll(`canvas[role="img"][aria-label]`)].flatMap((e,t)=>w(e).filter(e=>y(e.box,p)).map(n=>({...n,canvas:e,page:t+1}))),n=t.findIndex(e=>e.canvas===S?.canvas&&e.text===S.text&&e.box.top===S.box.top),r=n<0?e.key===`ArrowDown`?0:t.length-1:Math.max(0,Math.min(t.length-1,n+(e.key===`ArrowDown`?1:-1)));C(t[r])}else(e.key===`Enter`||e.key===` `)&&S&&(e.preventDefault(),fe(S))},onPointerLeave:()=>{q.current||C(void 0)}}),v&&$&&(0,n.jsx)(`span`,{className:`dsh-office-annotate-highlight`,"data-selected":T||N?`true`:void 0,style:{left:$.left,top:$.top,width:$.width,height:$.height}}),v&&T&&p&&(0,n.jsxs)(`form`,{ref:u,className:`dsh-office-annotate-composer`,style:{left:ve,top:ye,width:_e},"aria-label":c(`annotation.ask`),"aria-busy":j,onSubmit:e=>{e.preventDefault(),me()},children:[(0,n.jsx)(`input`,{type:`text`,"aria-label":c(`annotation.placeholder`),placeholder:c(`annotation.placeholder`),value:D,maxLength:2e4,onChange:e=>O(e.target.value),onKeyDown:e=>{e.key===`Enter`&&e.nativeEvent.isComposing&&e.preventDefault()}}),(0,n.jsx)(`button`,{type:`submit`,"aria-label":c(j?`annotation.capturing`:`annotation.add`),title:c(j?`annotation.capturing`:`annotation.add`),disabled:!D.trim()||j||U&&!k||F.length>=50,children:(0,n.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:(0,n.jsx)(`path`,{d:`m5 12 4 4L19 6`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})})]}),(v||F.length>0||z)&&p&&(0,n.jsx)(`div`,{className:`dsh-office-annotate-rail-position`,style:{left:p.left,width:p.width,bottom:Math.max(0,window.innerHeight-p.top-p.height)+12,"--dsh-office-annotation-width":`${p.width}px`,"--dsh-office-annotation-height":`${p.height}px`},children:(0,n.jsxs)(`div`,{className:`dsh-office-annotate-rail`,children:[z&&(0,n.jsx)(`p`,{role:`alert`,children:z}),(0,n.jsxs)(`div`,{className:`dsh-office-annotate-rail-actions`,children:[(0,n.jsxs)(`div`,{className:`dsh-office-annotate-summary`,"data-dismissed":oe?`true`:void 0,onPointerEnter:()=>L(!1),onFocus:()=>L(!1),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),e.currentTarget.querySelector(`button`)?.focus(),L(!0))},children:[(0,n.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,"aria-controls":R,disabled:!F.length,children:g(c(`annotation.count`),{count:String(F.length)})}),F.length>0&&(0,n.jsx)(`div`,{id:R,role:`dialog`,"aria-label":g(c(`annotation.count`),{count:String(F.length)}),className:`dsh-office-annotate-popover`,children:(0,n.jsx)(`ul`,{children:F.map((e,t)=>(0,n.jsx)(`li`,{children:(0,n.jsxs)(`div`,{children:[(0,n.jsxs)(`span`,{className:`dsh-office-annotation-source`,children:[(0,n.jsx)(`span`,{title:e.annotation.target,children:e.annotation.fileName}),e.annotation.page&&(0,n.jsx)(`span`,{children:g(c(`annotation.page`),{page:String(e.annotation.page)})})]}),e.annotation.text&&(0,n.jsx)(`span`,{className:`dsh-office-annotation-original`,children:e.annotation.text}),(0,n.jsx)(`span`,{className:`dsh-office-annotation-requirement`,title:e.annotation.requirement,children:e.annotation.requirement})]})},e.annotation.imageName??t))})})]}),(0,n.jsx)(`button`,{type:`button`,onClick:()=>{I([]),x(!1),L(!1),B(``),Y(),X()},children:c(`annotation.cancel`)}),(0,n.jsx)(`button`,{type:`button`,className:`dsh-office-annotate-primary`,disabled:!F.length||se,onClick:he,children:c(`annotation.send`)})]})]})})]})}function j(e){let{size:t=16,...n}=e;return{width:t,height:t,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,...n}}function M(e){return(0,n.jsx)(`svg`,{...j(e),children:(0,n.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`,d:`M5 13.5h6a1.5 1.5 0 0 0 1.5-1.5V7.243a1.5 1.5 0 0 0-.44-1.061L8.819 2.939a1.5 1.5 0 0 0-1.06-.439H5A1.5 1.5 0 0 0 3.5 4v8A1.5 1.5 0 0 0 5 13.5m9-6.257a3 3 0 0 0-.879-2.122L9.88 1.88A3 3 0 0 0 7.757 1H5a3 3 0 0 0-3 3v8a3 3 0 0 0 3 3h6a3 3 0 0 0 3-3zM5 8.25a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 0 1.5h-4.5A.75.75 0 0 1 5 8.25m.75 2.25a.75.75 0 0 0 0 1.5h2.5a.75.75 0 0 0 0-1.5z`})})}function N(e){return(0,n.jsx)(`svg`,{...j(e),children:(0,n.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`,d:`M11 13.5H5A1.5 1.5 0 0 1 3.5 12V4A1.5 1.5 0 0 1 5 2.5h2.757a1.5 1.5 0 0 1 1.061.44l3.243 3.242a1.5 1.5 0 0 1 .439 1.06V12a1.5 1.5 0 0 1-1.5 1.5m2.121-8.379A3 3 0 0 1 14 7.243V12a3 3 0 0 1-3 3H5a3 3 0 0 1-3-3V4a3 3 0 0 1 3-3h2.757a3 3 0 0 1 2.122.879zM6.5 6.5a.75.75 0 0 0-.75.75v4a.75.75 0 0 0 1.5 0v-.75H8.5a2 2 0 1 0 0-4zm2 2.5H7.25V8H8.5a.5.5 0 0 1 0 1`})})}function P(e){return(0,n.jsx)(`svg`,{...j(e),children:(0,n.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`,d:`M12 3H4a1.5 1.5 0 0 0-1.5 1.5v4A1.5 1.5 0 0 0 4 10h8a1.5 1.5 0 0 0 1.5-1.5v-4A1.5 1.5 0 0 0 12 3M4 1.5a3 3 0 0 0-3 3v4a3 3 0 0 0 3 3h3.25V13h-2.5a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-2.5v-1.5H12a3 3 0 0 0 3-3v-4a3 3 0 0 0-3-3z`})})}function F(e){return(0,n.jsx)(`svg`,{...j(e),children:(0,n.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`,d:`M9.25 3.5h-2.5v2h2.5zM4 3.5h1.25v2H2.5V5A1.5 1.5 0 0 1 4 3.5M2.5 7h2.75v2H2.5zm0 3.5v.5A1.5 1.5 0 0 0 4 12.5h1.25v-2zm4.25 0v2h2.5v-2zm4 0v2H12a1.5 1.5 0 0 0 1.5-1.5v-.5zM13.5 9h-2.75V7h2.75zM9.25 9h-2.5V7h2.5zm1.5-5.5v2h2.75V5A1.5 1.5 0 0 0 12 3.5zM4 2a3 3 0 0 0-3 3v6a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3V5a3 3 0 0 0-3-3z`})})}const I={documents:M,pdf:N,presentations:P,spreadsheets:F};function oe({node:e,raw:t,interactive:r,openOffice:a,officeLabel:o}){let s=i(e.data.feature);if(s==null)return(0,n.jsx)(`span`,{children:t});let c=I[s.id],l=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(c,{className:`dsh-office-ref-icon`,size:14}),(0,n.jsx)(`span`,{children:o(s.id)})]});return r?(0,n.jsx)(`button`,{type:`button`,className:`dsh-office-ref`,title:t,"data-interactive":!0,onClick:()=>a(s.id),children:l}):(0,n.jsx)(`span`,{className:`dsh-office-ref`,title:t,children:l})}function L(){if(typeof document>`u`)return()=>{};let e=document.querySelector(`style[data-plugin-css="dsh-office-kit/reference.css"]`)??document.createElement(`style`);return e.dataset.plugin=o,e.dataset.pluginCss=`dsh-office-kit/reference.css`,e.textContent=`
7
+ .dsh-office-ref {
8
+ display: inline-flex;
9
+ align-items: center;
10
+ gap: 4px;
11
+ max-width: 100%;
12
+ height: calc(20px + var(--dsh-content-font-delta, 0px));
13
+ padding: 0 6px;
14
+ border: 0.5px solid var(--dsw-alias-border-l3);
15
+ border-radius: var(--dsw-radius-sm);
16
+ background: var(--dsw-alias-bg-base);
17
+ color: var(--dsw-alias-label-secondary);
18
+ font: inherit;
19
+ line-height: 1;
20
+ vertical-align: baseline;
21
+ white-space: nowrap;
22
+ overflow: hidden;
23
+ text-overflow: ellipsis;
24
+ }
25
+ .dsh-office-ref[data-interactive] { cursor: pointer; }
26
+ .dsh-office-ref[data-interactive]:hover {
27
+ background: var(--dsw-alias-interactive-bg-hover-solid);
28
+ color: var(--dsw-alias-label-primary);
29
+ }
30
+ .dsh-office-ref[data-interactive]:focus-visible {
31
+ outline: 2px solid var(--dsw-alias-state-business-primary);
32
+ outline-offset: 1px;
33
+ }
34
+ .dsh-office-ref-icon { flex: none; color: var(--dsw-alias-label-tertiary); }
35
+ .dsh-office-ref[data-interactive]:hover .dsh-office-ref-icon { color: inherit; }
36
+ .dsh-office-annotate { display: inline-flex; flex: none; }
37
+ .dsh-office-annotate,
38
+ .dsh-office-annotation-reference { font: 400 12px/18px var(--dsw-font-family, system-ui, sans-serif); }
39
+ .dsh-office-annotate *,
40
+ .dsh-office-annotation-reference * { box-sizing: border-box; }
41
+ .dsh-office-annotate button,
42
+ .dsh-office-annotation-reference button {
43
+ border: 0.5px solid var(--dsw-alias-border-l2);
44
+ border-radius: var(--dsw-radius-md);
45
+ padding: 5px 9px;
46
+ color: var(--dsw-alias-label-primary);
47
+ background: var(--dsw-alias-bg-base);
48
+ font: inherit;
49
+ font-size: 12px;
50
+ line-height: 1.4;
51
+ cursor: pointer;
52
+ }
53
+ .dsh-office-annotate button:disabled { opacity: .45; cursor: not-allowed; }
54
+ .dsh-office-annotate button:hover:not(:disabled),
55
+ .dsh-office-annotation-reference button:hover { background: var(--dsw-alias-interactive-bg-hover-solid); }
56
+ .dsh-office-annotate button:focus-visible,
57
+ .dsh-office-annotation-reference button:focus-visible {
58
+ outline: 2px solid var(--dsw-alias-state-business-primary);
59
+ outline-offset: 2px;
60
+ }
61
+ .dsh-office-annotate .dsh-office-annotate-toggle {
62
+ display: inline-flex;
63
+ align-items: center;
64
+ justify-content: center;
65
+ height: 24px;
66
+ padding: 0 8px;
67
+ line-height: 1;
68
+ }
69
+ .dsh-office-annotate .dsh-office-annotate-toggle[aria-pressed="true"],
70
+ .dsh-office-annotate .dsh-office-annotate-primary {
71
+ color: var(--dsw-alias-state-business-primary);
72
+ border-color: var(--dsw-alias-state-business-primary);
73
+ background: color-mix(in srgb, var(--dsw-alias-state-business-primary) 10%, var(--dsw-alias-bg-base));
74
+ }
75
+ .dsh-office-annotate .dsh-office-annotate-surface {
76
+ position: fixed;
77
+ z-index: 40;
78
+ touch-action: none;
79
+ user-select: none;
80
+ outline: none;
81
+ cursor: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2220%22%20height%3D%2220%22%20fill%3D%22none%22%20viewBox%3D%220%200%2016%2016%22%3E%3Cpath%20fill%3D%22%23466eff%22%20fill-rule%3D%22evenodd%22%20d%3D%22M8%2013c3.866%200%207-2%207-6s-3.134-6-7-6-7%202-7%206c0%202.16.914%203.737%202.364%204.73l.09%202.161a1.157%201.157%200%200%200%201.857.872l2.322-1.77Q7.816%2013%208%2013%22%20clip-rule%3D%22evenodd%22%2F%3E%3C%2Fsvg%3E") 4 18, crosshair;
82
+ }
83
+ .dsh-office-annotate .dsh-office-annotate-highlight {
84
+ position: fixed;
85
+ z-index: 41;
86
+ box-sizing: border-box;
87
+ pointer-events: none;
88
+ border: 1.25px solid var(--dsw-alias-state-business-primary);
89
+ border-radius: 3px;
90
+ }
91
+ .dsh-office-annotate .dsh-office-annotate-highlight[data-selected="true"] {
92
+ border-style: dashed;
93
+ background: color-mix(in srgb, var(--dsw-alias-state-business-primary) 8%, transparent);
94
+ }
95
+ .dsh-office-annotate .dsh-office-annotate-composer {
96
+ position: fixed;
97
+ z-index: 42;
98
+ box-sizing: border-box;
99
+ border: 0.5px solid var(--dsw-alias-border-l2);
100
+ border-radius: var(--dsw-radius-md);
101
+ background: var(--dsw-alias-bg-layer-2);
102
+ color: var(--dsw-alias-label-primary);
103
+ box-shadow: var(--dsw-shadow-lv2);
104
+ }
105
+ .dsh-office-annotate .dsh-office-annotate-composer {
106
+ display: flex;
107
+ align-items: center;
108
+ gap: 4px;
109
+ padding: 4px;
110
+ border-radius: 999px;
111
+ }
112
+ .dsh-office-annotate .dsh-office-annotate-composer input:focus-visible { outline: none; }
113
+ .dsh-office-annotate .dsh-office-annotate-composer input {
114
+ box-sizing: border-box;
115
+ min-width: 0;
116
+ width: 100%;
117
+ padding: 6px 10px;
118
+ border: 0;
119
+ border-radius: 999px;
120
+ color: var(--dsw-alias-label-primary);
121
+ background: transparent;
122
+ font: inherit;
123
+ font-size: 12px;
124
+ line-height: 1.5;
125
+ }
126
+ .dsh-office-annotate .dsh-office-annotate-composer button {
127
+ display: inline-flex;
128
+ flex: none;
129
+ align-items: center;
130
+ justify-content: center;
131
+ width: 28px;
132
+ height: 28px;
133
+ padding: 0;
134
+ border: 0;
135
+ border-radius: 50%;
136
+ color: var(--dsw-alias-state-business-primary);
137
+ background: color-mix(in srgb, var(--dsw-alias-state-business-primary) 10%, var(--dsw-alias-bg-base));
138
+ }
139
+ .dsh-office-annotate .dsh-office-annotate-composer button svg { width: 14px; height: 14px; }
140
+ .dsh-office-annotate .dsh-office-annotate-rail-position {
141
+ position: fixed;
142
+ z-index: 42;
143
+ display: flex;
144
+ justify-content: center;
145
+ padding: 0 8px;
146
+ pointer-events: none;
147
+ }
148
+ .dsh-office-annotate .dsh-office-annotate-rail {
149
+ position: relative;
150
+ width: max-content;
151
+ max-width: 100%;
152
+ padding: 4px 6px;
153
+ border-radius: 10px;
154
+ background: var(--dsw-alias-toast-bg);
155
+ color: var(--dsw-alias-toast-label);
156
+ font: 500 12px/18px var(--dsw-font-family, system-ui, sans-serif);
157
+ box-shadow: var(--dsw-shadow-lv3);
158
+ pointer-events: auto;
159
+ }
160
+ .dsh-office-annotate .dsh-office-annotate-rail-actions { display: flex; align-items: center; justify-content: center; gap: 4px; }
161
+ .dsh-office-annotate .dsh-office-annotate-rail-actions > button,
162
+ .dsh-office-annotate .dsh-office-annotate-summary > button {
163
+ height: 26px;
164
+ padding: 0 8px;
165
+ border: 0;
166
+ border-radius: 8px;
167
+ background: transparent;
168
+ color: inherit;
169
+ font: inherit;
170
+ white-space: nowrap;
171
+ }
172
+ .dsh-office-annotate .dsh-office-annotate-summary { padding-right: 4px; border-right: 1px solid color-mix(in srgb, var(--dsw-alias-toast-label) 25%, transparent); }
173
+ .dsh-office-annotate .dsh-office-annotate-rail-actions > button:hover:not(:disabled),
174
+ .dsh-office-annotate .dsh-office-annotate-summary > button:hover:not(:disabled) { background: color-mix(in srgb, var(--dsw-alias-toast-label) 12%, transparent); }
175
+ .dsh-office-annotate .dsh-office-annotate-rail-actions > .dsh-office-annotate-primary { background: var(--dsw-alias-state-business-primary); color: var(--dsw-alias-toast-label); }
176
+ .dsh-office-annotate .dsh-office-annotate-rail-actions > .dsh-office-annotate-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--dsw-alias-state-business-primary) 85%, var(--dsw-alias-toast-label)); }
177
+ .dsh-office-annotate .dsh-office-annotate-rail p { max-width: min(360px, calc(var(--dsh-office-annotation-width) - 48px)); margin: 0 0 6px; font-size: 12px; overflow-wrap: anywhere; }
178
+ .dsh-office-annotate .dsh-office-annotate-popover {
179
+ display: none;
180
+ position: absolute;
181
+ bottom: 100%;
182
+ left: 50%;
183
+ width: min(320px, calc(var(--dsh-office-annotation-width, 100vw) - 16px), calc(100vw - 16px));
184
+ box-sizing: border-box;
185
+ padding-bottom: 8px;
186
+ transform: translateX(-50%);
187
+ }
188
+ .dsh-office-annotate .dsh-office-annotate-summary:not([data-dismissed="true"]):is(:hover, :focus-within) > .dsh-office-annotate-popover { display: block; }
189
+ .dsh-office-annotation-reference { display: inline-block; position: relative; max-width: 100%; vertical-align: baseline; font: inherit; }
190
+ .dsh-office-annotation-reference > button {
191
+ max-width: 100%;
192
+ padding: 0;
193
+ border: 0;
194
+ border-radius: 0;
195
+ background: transparent;
196
+ color: var(--dsw-alias-link);
197
+ font: inherit;
198
+ font-family: var(--dsw-font-markdown-code-font-family);
199
+ font-weight: 500;
200
+ overflow: hidden;
201
+ text-overflow: ellipsis;
202
+ white-space: nowrap;
203
+ vertical-align: baseline;
204
+ }
205
+ .dsh-office-annotation-reference > button:hover {
206
+ background: transparent;
207
+ text-decoration: underline dotted;
208
+ text-underline-offset: 3px;
209
+ }
210
+ .dsh-office-annotation-reference .dsh-office-annotation-popover {
211
+ display: none;
212
+ position: fixed;
213
+ z-index: 44;
214
+ inset: auto;
215
+ width: min(320px, calc(100vw - 16px));
216
+ max-height: calc(100vh - 16px);
217
+ box-sizing: border-box;
218
+ margin: 0;
219
+ padding: 4px 0;
220
+ border: 0;
221
+ background: transparent;
222
+ color: var(--dsw-alias-label-primary);
223
+ overflow: visible;
224
+ text-align: left;
225
+ font: 400 12px/18px var(--dsw-font-family, system-ui, sans-serif);
226
+ }
227
+ .dsh-office-annotation-reference .dsh-office-annotation-popover[data-open="true"] { display: block; }
228
+ .dsh-office-annotation-reference .dsh-office-annotation-popover::backdrop { pointer-events: none; }
229
+ .dsh-office-annotate .dsh-office-annotate-popover > ul,
230
+ .dsh-office-annotation-reference .dsh-office-annotation-list {
231
+ display: flex;
232
+ flex-direction: column;
233
+ box-sizing: border-box;
234
+ max-height: min(340px, 45vh);
235
+ margin: 0;
236
+ padding: 0 8px;
237
+ font: 400 12px/18px var(--dsw-font-family, system-ui, sans-serif);
238
+ text-align: left;
239
+ overflow: auto;
240
+ list-style: none;
241
+ border: 0.5px solid var(--dsw-alias-border-l2);
242
+ border-radius: var(--dsw-radius-md);
243
+ background: var(--dsw-alias-bg-layer-2);
244
+ color: var(--dsw-alias-label-primary);
245
+ box-shadow: var(--dsw-shadow-lv2);
246
+ }
247
+ .dsh-office-annotate .dsh-office-annotate-popover > ul { max-height: min(340px, 45vh, max(40px, calc(var(--dsh-office-annotation-height, 100vh) - 80px))); }
248
+ .dsh-office-annotate .dsh-office-annotate-popover li,
249
+ .dsh-office-annotation-reference .dsh-office-annotation-item { display: flex; flex: none; flex-direction: column; gap: 3px; min-width: 0; padding: 8px 0; }
250
+ .dsh-office-annotate .dsh-office-annotate-popover li > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
251
+ .dsh-office-annotate .dsh-office-annotate-popover .dsh-office-annotation-requirement { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
252
+ .dsh-office-annotate .dsh-office-annotate-popover li + li,
253
+ .dsh-office-annotation-reference .dsh-office-annotation-item + .dsh-office-annotation-item { border-top: .5px solid var(--dsw-alias-border-l3); }
254
+ .dsh-office-annotate .dsh-office-annotation-source,
255
+ .dsh-office-annotation-reference .dsh-office-annotation-source { display: flex; align-items: baseline; gap: 8px; color: var(--dsw-alias-label-tertiary); font-size: 12px; }
256
+ .dsh-office-annotation-reference .dsh-office-annotation-source button { padding: 0; border: 0; color: var(--dsw-alias-state-business-primary); text-align: left; }
257
+ .dsh-office-annotate .dsh-office-annotation-source > :first-child,
258
+ .dsh-office-annotation-reference .dsh-office-annotation-source > :first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
259
+ .dsh-office-annotate .dsh-office-annotation-source > :not(:first-child),
260
+ .dsh-office-annotation-reference .dsh-office-annotation-source > :not(:first-child) { flex: none; }
261
+ .dsh-office-annotate .dsh-office-annotation-original,
262
+ .dsh-office-annotation-reference .dsh-office-annotation-original { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dsw-alias-label-tertiary); font-size: 12px; }
263
+ .dsh-office-annotate .dsh-office-annotation-requirement,
264
+ .dsh-office-annotation-reference .dsh-office-annotation-requirement { display: block; white-space: pre-wrap; overflow-wrap: anywhere; }
265
+ `,document.head.appendChild(e),()=>e.remove()}const R=[`inputTriggers`,`sessions`,`slots`,`locale`,`remote`,`remote.skills`,`sidebarRight`,`uiConversation`,`conversation`],z={"menu.group":`办公`,"menu.documents.label":`文档`,"menu.documents.description":`创建、读取、编辑和渲染 DOCX 文档`,"menu.pdf.label":`PDF 文档`,"menu.pdf.description":`读取、创建、检查、渲染和验证 PDF`,"menu.presentations.label":`演示文稿`,"menu.presentations.description":`创建、编辑、渲染和导出 PPTX 演示文稿`,"menu.spreadsheets.label":`电子表格`,"menu.spreadsheets.description":`创建、编辑、计算和导出 XLSX 电子表格`,"annotation.ask":`请求修改`,"annotation.cancel":`取消`,"annotation.send":`发送`,"annotation.add":`添加标注`,"annotation.placeholder":`说明要怎么改…`,"annotation.page":`第 {page} 页`,"annotation.count":`{count} 条注释`,"annotation.remove":`删除第 {index} 条注释`,"annotation.image":`位置截图:{name}`,"annotation.help":`悬停吸附段落,点击输入要求;长按拖动框选区域,松开添加标注。方向键选择,Enter 确认,Esc 退出。`,"annotation.unavailable":`等待文档页面渲染;当前预览不支持标注`,"annotation.capturing":`正在截图…`,"annotation.captureFailed":`截图失败,请重新选择区域`,"annotation.intakeUnavailable":`当前 DSH 版本不支持从侧栏添加截图附件,PDF 标注已禁用`,"annotation.imageLimit":`截图超过当前模型的数量或大小限制,请减少标注后重试`,"annotation.sendFailed":`未能加入会话,请重试;标注仍保留`,"annotation.draftReady":`标注和截图已保留在会话输入框,请在那里确认发送`,"annotation.invalid":`标注内容无效,请重新添加`,"annotation.tooLarge":`标注内容过长,请减少后重试`,"annotation.emptyPage":`页面尚未渲染,请重试`,"annotation.emptyRegion":`请选择页面内的区域`},B={"menu.group":`Office`,"menu.documents.label":`Documents`,"menu.documents.description":`Create, read, edit, and render DOCX documents`,"menu.pdf.label":`PDF documents`,"menu.pdf.description":`Read, create, inspect, render, and verify PDFs`,"menu.presentations.label":`Presentations`,"menu.presentations.description":`Create, edit, render, and export PPTX decks`,"menu.spreadsheets.label":`Spreadsheets`,"menu.spreadsheets.description":`Create, edit, calculate, and export XLSX workbooks`,"annotation.ask":`Request changes`,"annotation.cancel":`Cancel`,"annotation.send":`Send`,"annotation.add":`Add annotation`,"annotation.placeholder":`Describe the change…`,"annotation.page":`page {page}`,"annotation.count":`{count} annotations`,"annotation.remove":`Remove annotation {index}`,"annotation.image":`Location screenshot: {name}`,"annotation.help":`Hover to select a paragraph; click to comment. Hold and drag to select a region. Arrow keys select, Enter confirms, Esc exits.`,"annotation.unavailable":`Waiting for rendered pages; this preview cannot be annotated yet`,"annotation.capturing":`Capturing…`,"annotation.captureFailed":`Screenshot failed; please select the region again`,"annotation.intakeUnavailable":`This DSH version cannot add screenshots from the sidebar; PDF annotation is disabled`,"annotation.imageLimit":`Screenshots exceed the current model’s count or size limits; remove some annotations and retry`,"annotation.sendFailed":`Could not add annotations to the conversation; your annotations are retained`,"annotation.draftReady":`Annotations and screenshots are kept in the conversation input; confirm sending there`,"annotation.invalid":`Invalid annotation; please add it again`,"annotation.tooLarge":`Annotations are too long; remove some and retry`,"annotation.emptyPage":`The page has not rendered yet; please retry`,"annotation.emptyRegion":`Select a region inside the page`};function V(e){return encodeURIComponent(e).replace(/%3A/gi,`:`)}function H(e){return e.split(`/`).map(V).join(`/`)}function U(e,t){let n=t.replace(/\\/g,`/`).replace(/^(?:\.\/)+/u,``);return`dsh-resource://file/session/${V(e)}/${H(n)}`}function W(e,t,n){let r=n.replace(/\\/g,`/`),i=t?.replace(/\\/g,`/`).replace(/\/+$/u,``)??``;return/^(?:\/|[A-Za-z]:\/|\\\\)/u.test(r)&&i!==``&&r.startsWith(`${i}/`)?U(e,r.slice(i.length+1)):U(e,r)}function G(t){let n=t.sessions,f=t.remote.skills,p=t.locale.bind(o),m=new Map,h=new Map;t.effect(()=>L(),`office-suite: styles`),t.effect(()=>t.locale.register(o,{zh:z,en:B}),`office-suite: dictionaries`);function g(e){let t=m.get(e);if(t!==void 0)return t;let r=new AbortController,i=(async()=>{if(n.binding(e)===void 0)throw Error(`office catalog requires a retained session "${e}"`);return n.using(e,{source:`officeCatalog`,signal:r.signal},async t=>{r.signal.throwIfAborted();let n=t.binding.session.getSnapshot();if(n.openState!==`open`)throw n.openError??Error(`session "${e}" is not open`);let i=await f.list({sessionId:e},r.signal);if(r.signal.throwIfAborted(),!i.ok)throw Error(`skills/list failed: ${i.error.code}: ${i.error.message}`);return i.value.skills})})(),a={abort:r,promise:i};return m.set(e,a),i.then(e=>{a.settled=e},()=>{m.get(e)===a&&m.delete(e)}),a}function _(e,r,a){let o=i(r);if(o===void 0)return!1;let s=a.find(e=>e.name===o.skill);if(s?.path===void 0)return!1;let c=n.list.getSnapshot().byId[e]?.cwd;try{return t.sidebarRight.openResource(W(e,c,s.path)),!0}catch(e){return console.error(`[dsh-office-kit] reference preview failed:`,e),!1}}let v={trigger:`/`,name:s,order:1,async candidates(t,{query:n,signal:i}){if(i.aborted)return[];let a=r.map(e=>{let t=I[e.id];return{name:e.command,label:p(`menu.${e.id}.label`),description:p(`menu.${e.id}.description`),section:p(`menu.group`),icon:t}});return n.length===0?a:(0,e.rankByName)(a,n)},lexicon(){return r.map(e=>e.command)},openReference(e,{ref:t}){let n=i(t);if(n===void 0)return!1;let r=m.get(e.sessionId)?.settled;if(r!==void 0)return _(e.sessionId,n.id,r);let a=g(e.sessionId);return a.promise.then(t=>{a.abort.signal.aborted||_(e.sessionId,n.id,t)}).catch(e=>{a.abort.signal.aborted||console.error(`[dsh-office-kit] reference preview failed:`,e)}),!0},onPick({candidate:e}){let t=a(e.name);if(t!==void 0)return{insert:{source:s,ref:t.id,label:p(`menu.${t.id}.label`),appearance:`file`,clipboardText:`/${t.command}`}}},codec:{clipboardText(e){let t=i(e);return t===void 0?`/${e}`:`/${t.command}`},async serialize(e){let t=i(e);return t===void 0?`/documents`:`/${t.command}\n\nUse the "${t.skill}" skill for this request and follow its instructions before creating, editing, or rendering files.`}}},y={id:c,order:20,match(e,t){let n=/(?<!\S)\/([\w-]+)(?!\S)/gu;n.lastIndex=t;for(let t=n.exec(e);t!==null;t=n.exec(e)){let e=a(t[1]??``);if(e!==void 0)return{id:c,start:t.index,end:t.index+t[0].length,data:{feature:e.id}}}}};t.effect(()=>t.uiConversation.userText.register(y),`office-suite: transcript chip`),t.effect(()=>t.slots.inject(l,()=>t.slots.register({name:l,key:c,priority:100,inject:e=>({openOffice:t=>{v.openReference?.({sessionId:e},{ref:t,appearance:`file`})},officeLabel:e=>p(`menu.${e}.label`)})},oe)),`office-suite: transcript chip slot`);function b(e){let r=t.conversation,i=typeof r.createDrafts==`function`&&typeof r.releaseDraftAttachments==`function`&&typeof r.resolveDraftAttachments==`function`,a=h.get(e);return a||(a=new Map,h.set(e,a)),{pendingAnnotations:a,intake:i?{create:t=>r.createDrafts(e,t),release:e=>r.releaseDraftAttachments(e),images:e=>r.resolveDraftAttachments(e).filter(e=>e.kind===`image`).map(e=>e.file)}:void 0,openAnnotation:r=>{try{let i=n.list.getSnapshot().byId[e]?.cwd;t.sidebarRight.openResource(W(e,i,r))}catch(e){console.error(`[dsh-office-kit] annotation preview failed:`,e)}}}}t.effect(()=>t.uiConversation.userText.register(D),`office-suite: annotations`),t.effect(()=>t.slots.inject(l,()=>t.slots.register({name:l,key:d,priority:100,locale:o,inject:b},O)),`office-suite: annotation references`),t.effect(()=>t.slots.inject(u,()=>t.slots.register({name:u,id:`office-annotations`,order:20,locale:o,inject:b},k)),`office-suite: annotation tool`);let x=t.inputTriggers;t.effect(()=>{let e=x.registerSource(v);return()=>{e();for(let e of m.values())e.abort.abort();m.clear(),h.clear()}},`office-suite: slash source`)}exports.apply=G,exports.inject=R;
266
+ return module.exports;}});
267
+ //# sourceMappingURL=client.js.map