zcode-app-cli 3.16.2-38 → 3.16.3-40
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/LICENSES/README.md +1 -1
- package/README.md +19 -4
- package/bin/zcode.js +47 -16
- package/docs/CONFIGURATION.md +2 -1
- package/docs/CONFIGURATION.zh-CN.md +2 -1
- package/docs/THIRD_PARTY_CONTENT.md +2 -2
- package/package.json +2 -2
- package/vendor/cli-config.cjs +21 -0
- package/vendor/extraction.json +9 -4
- package/vendor/node_modules/@zcode/tui/dist/index.js +79 -22
- package/vendor/packages/documents-plugin/.zcode-plugin/plugin.json +3 -2
- package/vendor/packages/documents-plugin/dist/server.mjs +201 -152
- package/vendor/packages/documents-plugin/dist/ui/bundle-0.txt +1 -1
- package/vendor/packages/documents-plugin/dist/ui/panel.html +1 -1
- package/vendor/packages/documents-plugin/package.json +1 -1
- package/vendor/packages/node-repl-host/dist/mcp/server.js +1 -1
- package/vendor/packages/pdf-plugin/.zcode-plugin/plugin.json +3 -2
- package/vendor/packages/pdf-plugin/dist/server.mjs +201 -152
- package/vendor/packages/pdf-plugin/dist/ui/bundle-0.txt +1 -1
- package/vendor/packages/pdf-plugin/dist/ui/panel.html +1 -1
- package/vendor/packages/pdf-plugin/package.json +1 -1
- package/vendor/packages/presentations-plugin/.zcode-plugin/plugin.json +3 -2
- package/vendor/packages/presentations-plugin/dist/server.mjs +201 -152
- package/vendor/packages/presentations-plugin/dist/ui/bundle-0.txt +1 -1
- package/vendor/packages/presentations-plugin/dist/ui/panel.html +1 -1
- package/vendor/packages/presentations-plugin/package.json +1 -1
- package/vendor/packages/spreadsheets-plugin/.zcode-plugin/plugin.json +3 -2
- package/vendor/packages/spreadsheets-plugin/dist/server.mjs +201 -152
- package/vendor/packages/spreadsheets-plugin/dist/ui/bundle-0.txt +1 -1
- package/vendor/packages/spreadsheets-plugin/dist/ui/panel.html +1 -1
- package/vendor/packages/spreadsheets-plugin/package.json +1 -1
- package/vendor/zcode.cjs +1033 -1031
- package/zcode-runtime.lock.json +3 -3
|
@@ -106,7 +106,7 @@ Boolean requesting whether a visible border and background is provided by the ho
|
|
|
106
106
|
- omitted: host decides border`)}),gG=R.object({method:R.literal("ui/request-display-mode"),params:R.object({mode:jm.describe("The display mode being requested.")})}),FB=R.object({mode:jm.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),GB=R.union([R.literal("model"),R.literal("app")]).describe("Tool visibility scope - who can access the tool."),vG=R.object({resourceUri:R.string().optional(),visibility:R.array(GB).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
107
107
|
- "model": Tool visible to and callable by the agent
|
|
108
108
|
- "app": Tool callable by the app from this server only`),csp:R.never().optional(),permissions:R.never().optional()}),bG=R.object({mimeTypes:R.array(R.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),yG=R.object({method:R.literal("ui/download-file"),params:R.object({contents:R.array(R.union([ss,ls])).describe("Resource contents to download \u2014 embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),SG=R.object({method:R.literal("ui/message"),params:R.object({role:R.literal("user").describe('Message role, currently only "user" is supported.'),content:R.array(yi).describe("Message content blocks (text, image, etc.).")})}),_G=R.object({method:R.literal("ui/notifications/sandbox-resource-ready"),params:R.object({html:R.string().describe("HTML content to load into the inner iframe."),sandbox:R.string().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:zx.optional().describe("CSP configuration from resource metadata."),permissions:kx.optional().describe("Sandbox permissions from resource metadata.")})}),KB=R.object({method:R.literal("ui/notifications/tool-result"),params:no.describe("Standard MCP tool execution result.")}),uP=R.object({toolInfo:R.object({id:Qr.optional().describe("JSON-RPC id of the tools/call request."),tool:to.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:IB.optional().describe("Current color theme preference."),styles:qB.optional().describe("Style configuration for theming the app."),displayMode:jm.optional().describe("How the UI is currently displayed."),availableDisplayModes:R.array(jm).optional().describe("Display modes the host supports."),containerDimensions:R.union([R.object({height:R.number().describe("Fixed container height in pixels.")}),R.object({maxHeight:R.union([R.number(),R.undefined()]).optional().describe("Maximum container height in pixels.")})]).and(R.union([R.object({width:R.number().describe("Fixed container width in pixels.")}),R.object({maxWidth:R.union([R.number(),R.undefined()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
109
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:R.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:R.string().optional().describe("User's timezone in IANA format."),userAgent:R.string().optional().describe("Host application identifier."),platform:R.union([R.literal("web"),R.literal("desktop"),R.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:R.object({touch:R.boolean().optional().describe("Whether the device supports touch input."),hover:R.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:R.object({top:R.number().describe("Top safe area inset in pixels."),right:R.number().describe("Right safe area inset in pixels."),bottom:R.number().describe("Bottom safe area inset in pixels."),left:R.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),JB=R.object({method:R.literal("ui/notifications/host-context-changed"),params:uP.describe("Partial context update containing only changed fields.")}),wG=R.object({method:R.literal("ui/update-model-context"),params:R.object({content:R.array(yi).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:R.record(R.string(),R.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),$G=R.object({method:R.literal("ui/initialize"),params:R.object({appInfo:vi.describe("App identification (name and version)."),appCapabilities:ZB.describe("Features and capabilities this app provides."),protocolVersion:R.string().describe("Protocol version this app supports.")})}),YB=R.object({protocolVersion:R.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:vi.describe("Host application identification and version."),hostCapabilities:VB.describe("Features and capabilities provided by the host."),hostContext:uP.describe("Rich context about the host environment.")}).passthrough(),XB={target:"draft-2020-12"};async function lP(e,t){let n=e["~standard"];if(n.jsonSchema)return n.jsonSchema[t](XB);throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function cP(e,t,n=""){let i=await e["~standard"].validate(t);if(i.issues){let r=i.issues.map(a=>{let o=a.path?.map(s=>typeof s=="object"?s.key:s).join(".");return o?`${o}: ${a.message}`:a.message}).join("; ");throw Error(n+r)}return i.value}function dP(e,t=document.documentElement){for(let[n,i]of Object.entries(e))i!==void 0&&t.style.setProperty(n,i)}function WB(e,t){let n={...e,...t};return t.experimental!==void 0&&(n.experimental={...e.experimental,...t.experimental}),t.tools!==void 0&&(n.tools={...e.tools,...t.tools}),n}var Tb=class e extends _x{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new wx;_methods=new $x;setRequestHandler=(...t)=>{let[n,...i]=oP("request",t)??t;this._methods.claim(n,"setRequestHandler"),super.setRequestHandler.call(this,n,...i)};setNotificationHandler=(...t)=>{let[n,...i]=oP("notification",t)??t;this._methods.claim(n,"setNotificationHandler"),super.setNotificationHandler.call(this,n,...i)};removeRequestHandler=t=>{this._methods.release(t),super.removeRequestHandler(t)};removeNotificationHandler=t=>{this._methods.release(t),super.removeNotificationHandler(t)};replaceRequestHandler=(t,...n)=>{this._methods.replace(t),super.setRequestHandler.call(this,t,...n)};_assertInitialized(t){if(this._initializedSent)return;let n=`[ext-apps] App.${t}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(n);console.warn(`${n}. This will throw in a future release.`)}eventSchemas={toolinput:DB,toolinputpartial:jB,toolresult:KB,toolcancelled:UB,hostcontextchanged:JB};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(t){if(!e.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let n=`[ext-apps] "${String(t)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(t,n){n&&this._assertHandlerTiming(t),this._ensureEventSlot(t),this._events.setHandler(t,n)}addEventListener(t,n){this._assertHandlerTiming(t),this._ensureEventSlot(t),this._events.addEventListener(t,n)}removeEventListener(t,n){this._events.removeEventListener(t,n)}_ensureEventSlot(t){if(this._registeredEvents.has(t))return;let n=this.eventSchemas[t];if(!n)throw Error(`Unknown event: ${String(t)}`);this.setNotificationHandler(n.shape.method.value,{params:n.shape.params},i=>{let r=i;t==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...r}),this._events.dispatch(t,r)}),this._registeredEvents.add(t)}getEventHandler(t){return this._events.getHandler(t)}warnIfRequestHandlerReplaced(t,n,i){n&&i&&console.warn(`[MCP Apps] ${t} handler replaced. Previous handler will no longer be called.`)}constructor(t,n={},i={autoResize:!0}){super(i),this._appInfo=t,this._appCapabilities=n,this.options=i,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),!i.allowUnsafeEval&&R.config({jitless:!0}),this.replaceRequestHandler("ping",r=>(console.log("Received ping:",r.params),{})),this.setEventHandler("hostcontextchanged",void 0)}buildContext(t){return t}registerAppCapabilities(t){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._appCapabilities=WB(this._appCapabilities,t)}registerTool(t,n,i){if(this._registeredTools[t])throw Error(`Tool ${t} is already registered`);let r=this,a=()=>{r._initializedSent&&r._appCapabilities.tools?.listChanged&&r.sendToolListChanged()},o=n.inputSchema!==void 0,s={title:n.title,description:n.description,inputSchema:n.inputSchema,outputSchema:n.outputSchema,annotations:n.annotations,_meta:n._meta,enabled:!0,enable(){this.enabled=!0,a()},disable(){this.enabled=!1,a()},update(l){Object.assign(this,l),a()},remove(){r._registeredTools[t]===s&&(delete r._registeredTools[t],a())},handler:async(l,c)=>{if(!s.enabled)throw Error(`Tool ${t} is disabled`);let u;if(o){let d=s.inputSchema,f=d?await cP(d,l??{},`Invalid input for tool ${t}: `):l??{};u=await i(f,c)}else u=await i(c);return s.outputSchema&&!u.isError&&(u.structuredContent=await cP(s.outputSchema,u.structuredContent,`Invalid output for tool ${t}: `)),u}};return this._registeredTools[t]=s,!this._appCapabilities.tools&&!this.transport&&this.registerAppCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),a(),s}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(t,n)=>{let i=this._registeredTools[t.name];if(!i)throw Error(`Tool ${t.name} not found`);return i.handler(t.arguments,n)},this.onlisttools=async(t,n)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([i,r])=>r.enabled).map(async([i,r])=>{let a={name:i,title:r.title,description:r.description,inputSchema:r.inputSchema?await lP(r.inputSchema,"input"):{type:"object",properties:{}}};return r.outputSchema&&(a.outputSchema=await lP(r.outputSchema,"output")),r.annotations&&(a.annotations=r.annotations),r._meta&&(a._meta=r._meta),a}))}))}async sendToolListChanged(t={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:t})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(t){this.setEventHandler("toolinput",t)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(t){this.setEventHandler("toolinputpartial",t)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(t){this.setEventHandler("toolresult",t)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(t){this.setEventHandler("toolcancelled",t)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(t){this.setEventHandler("hostcontextchanged",t)}_onteardown;get onteardown(){return this._onteardown}set onteardown(t){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,t),this._onteardown=t,this.replaceRequestHandler("ui/resource-teardown",{params:BB.shape.params,result:HB},(n,i)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(n,i)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(t){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,t),this._oncalltool=t,this.replaceRequestHandler("tools/call",(n,i)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,i)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(t){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,t),this._onlisttools=t,this.replaceRequestHandler("tools/list",(n,i)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(n.params,i)})}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${t})`);break}}assertRequestHandlerCapability(t){switch(t){case"tools/call":case"tools/list":if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${t})`);return;default:return}}assertNotificationCapability(t){}async callServerTool(t,n){if(this._assertInitialized("callServerTool"),typeof t=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${t}"). Did you mean: callServerTool({ name: "${t}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:t},{onprogress:()=>{},resetTimeoutOnProgress:!0,...n})}async readServerResource(t,n){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:t},n)}async listServerResources(t,n){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:t},n)}async createSamplingMessage(t,n){return this._assertInitialized("createSamplingMessage"),await this.request({method:"sampling/createMessage",params:t},n)}sendMessage(t,n){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:t},MB,n)}sendLog(t){return this.notification({method:"notifications/message",params:t})}updateModelContext(t,n){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:t},eo,n)}openLink(t,n){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:t},AB,n)}sendOpenLink=this.openLink;downloadFile(t,n){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:t},PB,n)}requestTeardown(t={}){return this.notification({method:"ui/notifications/request-teardown",params:t})}requestDisplayMode(t,n){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:t},FB,n)}sendSizeChanged(t){return this.notification({method:"ui/notifications/size-changed",params:t})}setupSizeChangedNotifications(){let t=!1,n=0,i=0,r=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let o=document.documentElement,s=o.style.height;o.style.height="max-content";let l=Math.ceil(o.getBoundingClientRect().height);o.style.height=s;let c=Math.ceil(window.innerWidth);(c!==n||l!==i)&&(n=c,i=l,this.sendSizeChanged({width:c,height:l}))}))};r();let a=new ResizeObserver(r);return a.observe(document.documentElement),a.observe(document.body),()=>a.disconnect()}async connect(t=new Dm(window.parent,window.parent),n){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1;try{await super.connect(t);let i=await this.request({method:"ui/initialize",params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:EB}},YB,n);if(i===void 0)throw Error(`Server sent invalid initialize result: ${i}`);this._hostCapabilities=i.hostCapabilities,this._hostInfo=i.hostInfo,this._hostContext=i.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(i){throw this.close(),i}}};var zt={name:"documents",version:"0.2.0",title:{en:"Documents","zh-CN":"Word \u6587\u6863"},kinds:["docx"]};var fP=zt.version,mP=zt.name,IG=zt.name,NG=`ui://${zt.name}/panel.html`,QB=`ui://${zt.name}/assets/`,pP=`ui://${zt.name}/file/`;var ei=zt.kinds,Lm=100*1024*1024,OG=512*1024*1024,xx=4*1024*1024,AG=24*1024,Um=class extends Error{constructor(n,i){super(i);this.code=n;this.name="OfficeError"}};function qm(e){let t=e.toLowerCase().match(/\.([a-z]+)$/)?.[1];return ei.includes(t??"")?t:null}var eH={en:{sep:", ",and:" and ",or:" or "},"zh-CN":{sep:"\u3001",and:"\u548C",or:"\u6216"}};function Mr(e,t="en",n="and"){let i=eH[t];if(e.length<2)return e.join("");let r=e[e.length-1],a=t==="zh-CN"&&/^[\x20-\x7e]/.test(r)?` ${i[n]} `:i[n];return`${e.slice(0,-1).join(i.sep)}${a}${r}`}function ps(e="en",t="and"){return Mr(ei.map(n=>`.${n}`),e,t)}var _i=(e,t)=>new Um("invalid_anchor",`Cannot read location "${e}". ${t}`),wi={docx:"Use p:N, p:N-M, t:N or t:N/rRcC.",pptx:"Use slide:N, slide:N-M or slide:N/shape:ID.",pdf:"Use page:N or page:N-M.",xlsx:"Use Sheet, Sheet!A1 or Sheet!A1:C9 (quote names with spaces: 'My sheet'!A1)."};function Rx(e,t,n){if(!t)throw _i(e,wi[n]);let i=Number(t[1]),r=t[2]===void 0?i:Number(t[2]);if(!(i>=1)||!(r>=i)||r>1e6)throw _i(e,wi[n]);return{from:i,to:r}}function hP(e){let t=/^\$?([A-Za-z]{1,3})\$?(\d{1,7})$/.exec(e);if(!t)return null;let n=0;for(let r of t[1].toUpperCase())n=n*26+(r.charCodeAt(0)-64);let i=Number(t[2]);return i<1||i>1048576||n>16384?null:{row:i,col:n}}function tH(e){let t,n;if(e.startsWith("'")){let s=1;for(t="";s<e.length;s++)if(e[s]==="'")if(e[s+1]==="'")t+="'",s++;else break;else t+=e[s];if(s>=e.length||(n=e.slice(s+1),n&&!n.startsWith("!")))throw _i(e,wi.xlsx);n=n.slice(1)}else{let s=e.lastIndexOf("!");t=s<0?e:e.slice(0,s),n=s<0?"":e.slice(s+1)}if(!t||t.length>64)throw _i(e,wi.xlsx);if(!n)return{kind:"xlsx",sheet:t};let[i,r=i]=n.split(":"),a=hP(i),o=hP(r);if(!a||!o)throw _i(e,wi.xlsx);return{kind:"xlsx",sheet:t,range:{start:{row:Math.min(a.row,o.row),col:Math.min(a.col,o.col)},end:{row:Math.max(a.row,o.row),col:Math.max(a.col,o.col)}}}}function gP(e,t){let n=t.trim();if(!n||n.length>300)throw _i(t,wi[e]);switch(e){case"docx":{let i=/^t:(\d+)(?:\/r(\d+)c(\d+))?$/i.exec(n);if(i){let r=Number(i[1]);if(r<1)throw _i(n,wi.docx);if(i[2]===void 0)return{kind:e,type:"table",table:r};let a={row:Number(i[2]),col:Number(i[3])};if(a.row<1||a.col<1)throw _i(n,wi.docx);return{kind:e,type:"table",table:r,cell:a}}return{kind:e,type:"paragraph",...Rx(n,/^p:(\d+)(?:-(?:p:)?(\d+))?$/i.exec(n),e)}}case"pptx":{let i=/^slide:(\d+)\/shape:([\w-]{1,32})$/i.exec(n);if(i){let r=Number(i[1]);if(r<1)throw _i(n,wi.pptx);return{kind:e,from:r,to:r,shape:i[2]}}return{kind:e,...Rx(n,/^slide:(\d+)(?:-(?:slide:)?(\d+))?$/i.exec(n),e)}}case"pdf":return{kind:e,...Rx(n,/^page:(\d+)(?:-(?:page:)?(\d+))?$/i.exec(n),e)};case"xlsx":return tH(n)}}function vP(e){let t=/^(.*?\.(?:docx|xlsx|pptx|pdf))(?:#(.*))?$/i.exec(e.trim());if(!t)throw new Um("invalid_anchor",`"${e}" is not a document anchor. Use <path>.docx|.xlsx|.pptx|.pdf optionally followed by #<location>.`);return{path:t[1],at:t[2]?.trim()?t[2].trim():null}}function Bm(e,t){return t?`${e}#${t}`:e}var bP=e=>e>=55296&&e<=56319,yP=e=>e>=56320&&e<=57343;function Cb(e,t,n=e.length){let i=Math.max(0,Math.min(t,e.length)),r=Math.max(i,Math.min(n,e.length));return i>0&&yP(e.charCodeAt(i))&&bP(e.charCodeAt(i-1))&&i--,r<e.length&&yP(e.charCodeAt(r))&&bP(e.charCodeAt(r-1))&&r--,e.slice(i,r)}var nH=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,Ib=e=>e.replace(nH,"\uFFFD");function Eb(e){return typeof e=="string"?Ib(e):Array.isArray(e)?e.map(t=>Eb(t)):e&&typeof e=="object"&&Object.getPrototypeOf(e)===Object.prototype?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Eb(n)])):e}var SP=`${zt.name}:windows:v1`,rH=128;function _P(e){try{let t=JSON.parse(e.getItem(SP)??"{}");return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function Tx(e,t){let n=_P(e)[t];return!n||typeof n!="object"?{}:{...typeof n.path=="string"?{path:n.path}:{},...Array.isArray(n.recent)?{recent:n.recent.filter(i=>typeof i?.path=="string"&&qm(i.path)===i.kind)}:{}}}function wP(e,t,n){try{let i=_P(e),r={...Tx(e,t),...n};delete i[t],i[t]=r;for(let a of Object.keys(i).slice(0,-rH))delete i[a];e.setItem(SP,JSON.stringify(i))}catch{}}var kc=e=>e.filter(([t])=>ei.includes(t)).map(([,t])=>t),iH={docx:"Word",xlsx:"Excel",pptx:"PowerPoint",pdf:"PDF"},$P=ei.filter(e=>e!=="pdf"),zP=[...$P.length===3?["Office"]:$P.map(e=>iH[e]),...ei.includes("pdf")?["PDF"]:[]],Hm=zt.title.en,VG=(()=>{let e=Mr(zP,"en","or");return`${/^[AEIOU]/.test(e)?"an":"a"} ${e} file`})(),ZG=`${Mr(zP)} files`,FG=ps("en","or"),GG=kc([["docx","report.docx#p:12"],["xlsx","model.xlsx#Revenue!B2:F9"],["pptx","deck.pptx#slide:3"],["pdf","paper.pdf#page:5"]]).join(", "),KG=kc([["docx","p:12"],["pptx","slide:3"],["pdf","page:5"],["xlsx","Revenue!B2:F9"]]).join(", "),JG=kc([["docx","Word paragraphs and tables (markdown)"],["xlsx","spreadsheet cells as a grid with formulas"],["pptx","slides with their shapes and speaker notes"],["pdf","PDF page text"]]).join(", "),YG=Mr(kc([["docx","paragraph"],["xlsx","cell range"],["pptx","slide"],["pptx","shape"],["pdf","page"]]),"en","or"),XG=Mr(kc([["pdf","PDF pages"],["docx","long paragraphs"]]))||"long passages",kP=Mr(kc([["pptx","deck.pptx#slide:3"],["pdf","paper.pdf#page:2"],["docx","report.docx#p:12"],["xlsx","model.xlsx#Revenue!A1:H30"]]),"en","or");var xP=[{name:"capture_view",title:`Capture ${Hm} view`,description:`Take a picture of a rendered document location in the ${Hm} panel so you can see layout, charts, images and formatting that text extraction misses. Pass an anchor such as ${kP} (the document must be open in the panel; call open_document first), or omit it to capture what the user currently sees.`,inputSchema:{type:"object",properties:{anchor:{type:"string",maxLength:1200,description:"Location to capture; defaults to the visible view."},maxWidth:{type:"integer",minimum:320,maximum:2e3,description:"Maximum image width in pixels (default 1600)."}},additionalProperties:!1},annotations:{readOnlyHint:!0,idempotentHint:!0}}];function aH(){let e=crypto.randomUUID(),t=()=>n.getHostCapabilities()?.experimental?.["zcode/surface"]?.stateKey??e,n=new Tb({name:mP,version:fP},{tools:{listChanged:!0},availableDisplayModes:["inline","fullscreen"]},{autoResize:!1}),i=[],r=new Map,a=new Set,o,s=c=>void window.dispatchEvent(new Event(`office:${c}`));return n.ontoolresult=c=>{i.push(c),i.length>20&&i.shift(),s("toolresult")},n.onhostcontextchanged=()=>s("hostchange"),n.onlisttools=async()=>({tools:xP}),n.oncalltool=async(c,u)=>{if(!xP.some(d=>d.name===c.name))return{isError:!0,content:[{type:"text",text:`The ${Hm} page has no tool ${c.name}.`}]};try{let d=Date.now()+2e4;for(;!r.has(c.name)&&Date.now()<d;)await new Promise(p=>{let h=()=>(a.delete(h),p());a.add(h),setTimeout(h,500)});let f=r.get(c.name);if(!f)throw new Error(`The ${Hm} panel is still loading; try again in a moment.`);let m=u;return await f(c.arguments??{},m.mcpReq?.signal??m.signal)}catch(d){return{isError:!0,content:[{type:"text",text:d instanceof Error?d.message:String(d)}]}}},window.addEventListener("pagehide",()=>{n.callServerTool({name:"release_view",arguments:{viewId:t()}}).catch(()=>{})}),{app:n,get viewId(){return t()},ready:()=>o??=n.connect(new Dm(window.parent,window.parent)).then(()=>s("hostchange")),readWindow(){let c=n.getHostCapabilities()?.experimental?.["zcode/surface"];if(!c?.stateKey)return{};try{return Tx(localStorage,c.stateKey)}catch{return{}}},saveWindow(c){let u=n.getHostCapabilities()?.experimental?.["zcode/surface"];if(u?.stateKey)try{wP(localStorage,u.stateKey,c)}catch{}},readDocument(){return this.readWindow().path??null},saveDocument(c){this.saveWindow({path:c})},takeResults:()=>i.splice(0,i.length),handleTool(c,u){r.set(c,u);for(let d of a)d()},get context(){return n.getHostContext()},get capabilities(){return n.getHostCapabilities()}}}function Dr(){return window.__officeHost??=aH()}async function oH(e){let t=Dr();await t.ready();let i=(await t.app.readServerResource({uri:e})).contents[0];if(!i)throw new Error(`Empty resource ${e}`);return i}function sH(e){let t=atob(e),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n}async function RP(e,t){let n=new Uint8Array(e.bytes),i=0;for(let r=0;r<e.chunks;r++){t?.throwIfAborted();let a=await oH(`${pP}${e.token}/${r}`);if(typeof a.blob!="string")throw new Error("File chunk is not binary");let o=sH(a.blob);n.set(o,i),i+=o.byteLength}if(i!==e.bytes)throw new Error("The file changed while it was loading; reload it.");return n.buffer}var Nb=ht(ir(),1);var Vm=class extends Error{constructor(n,i){super(n);this.code=i;this.name="CallError"}};async function $i(e,t={}){let n=Dr();await n.ready();let i=await n.app.callServerTool({name:e,arguments:t}),r=i.structuredContent,a=r?.error;if(i.isError||a){let o=i.content?.[0]?.text;throw new Vm(a?.message??o??`${e} failed`,a?.code)}return r}var hs=e=>e.slice(e.lastIndexOf("/")+1),TP=e=>{let t=e.lastIndexOf("/");return t>0?e.slice(0,t):""};async function EP(e){let{id:t}=await $i("begin_file_import",{name:e.name,size:e.size});try{for(let i=0;i<e.size;i+=xx){let r=await new Promise((a,o)=>{let s=new FileReader;s.onload=()=>a(String(s.result).split(",")[1]),s.onerror=()=>o(s.error),s.readAsDataURL(e.slice(i,i+xx))});await $i("write_file_import",{id:t,offset:i,data:r})}return(await $i("finish_file_import",{id:t})).path}catch(n){throw await $i("cancel_file_import",{id:t}).catch(()=>{}),n}}var Ob=(e,t)=>e.length>t?`${Cb(e,0,t-1)}\u2026`:e;function Ex(){return Dr().readWindow().recent??[]}function CP(e){Dr().saveWindow({recent:e})}function Zm(e,t,n){let i=t instanceof Vm?t.code:t?.name==="PasswordException"?"password":void 0,[r,a]=i&&e.errors[i]||e.errors.generic,o=t instanceof Error?t.message:String(t);return{path:n,title:r,detail:a||o}}function IP(){let[,e]=(0,Nb.useState)(0);return(0,Nb.useEffect)(()=>{let t=()=>e(n=>n+1);return window.addEventListener("office:hostchange",t),()=>window.removeEventListener("office:hostchange",t)},[]),Dr().context}var lH={docx:"Word",xlsx:"Excel",pptx:"PowerPoint",pdf:"PDF"},OP=ei.map(e=>lH[e]),xc=e=>ei.includes(e),NP=xc("docx")||xc("pdf"),AP={en:`any ${Mr([...NP?["passage"]:[],...xc("xlsx")?["cell"]:[],...xc("pptx")?["slide"]:[]],"en","or")}`,zh:Mr([...NP?["\u6BB5\u843D"]:[],...xc("xlsx")?["\u5355\u5143\u683C"]:[],...xc("pptx")?["\u5E7B\u706F\u7247"]:[]],"zh-CN","or")},Cx=zt.title["zh-CN"].replace(/[\x20-\x7e]$/,"$& "),cH={title:zt.title.en,openTitle:"Open a document",openFile:"Open file",emptyTitle:`Open your ${Mr(OP)} file`,emptyDescription:`Read alongside your conversation and discuss ${AP.en}.`,emptyCaption:`Choose a local file \xB7 ${ps("en","or")}`,importing:"Importing\u2026",importTooLarge:`Choose a file no larger than ${Lm/1024/1024} MiB.`,recent:"Recent",switchDocument:"Switch document",pagesAndOutline:"Pages and outline",outlineOnly:"Outline",pages:"Pages",slides:"Slides",outline:"Outline",find:"Find",findPlaceholder:"Find in document",findCount:(e,t)=>`${e} of ${t}`,noResults:"No results",previousMatch:"Previous match (\u21E7Enter)",nextMatch:"Next match (Enter)",closeFind:"Close (Esc)",more:"More",fitWidth:"Fit width",fitPage:"Fit page",actualSize:"Actual size",reload:"Reload from disk",previousPage:"Previous page",nextPage:"Next page",pageNumber:"Page number",ofPages:e=>`of ${e}`,zoomIn:"Zoom in (\u2318+)",zoomOut:"Zoom out (\u2318\u2212)",fit:"Fit",addToChat:"Add to chat",addShort:"Add",addToChatHint:"Attach this to your next message (\u2318/Ctrl+Enter)",added:"Added to chat",ask:"Ask",askPlaceholder:"Ask about this\u2026",send:"Send",cancel:"Cancel",sendKey:"send",cancelKey:"cancel",copy:"Copy",copied:"Copied",agent:"Agent",agentOf:(e,t)=>`Agent \xB7 ${e} of ${t}`,nextTarget:"Next",moreOn:(e,t)=>e===1?`1 more on ${t}`:`${e} more`,close:"Close",changed:"This file changed on disk.",reloadShort:"Reload",dismiss:"Dismiss",openAnother:"Open another file",sidePanel:"Open in side panel",meta:{pdf:e=>e===1?"1 page":`${e} pages`,pptx:e=>e===1?"1 slide":`${e} slides`,xlsx:e=>e===1?"1 sheet":`${e} sheets`,docx:e=>""},errors:{generic:["Couldn\u2019t open this document",""],password:["This PDF is password protected",`${zt.title.en} can\u2019t open encrypted files yet.`],not_found:["This file no longer exists","It may have been moved or deleted."],file_too_large:["This file is too large to open",""],corrupt_file:["This file appears to be damaged",`${zt.title.en} couldn\u2019t read its contents.`],unsupported_type:["This kind of file isn\u2019t supported",`${zt.title.en} opens ${ps()} files.`],path_outside_workspace:["This file is outside the workspace",""]},sendFailed:"The message was not sent.",contextFailed:"ZCode did not accept the reference.",where:{page:e=>`Page ${e}`,pages:(e,t)=>`Pages ${e}\u2013${t}`,pageLower:e=>`page ${e}`,slide:e=>`Slide ${e}`,slides:(e,t)=>`Slides ${e}\u2013${t}`,slideLower:e=>`slide ${e}`,shape:e=>`Slide ${e} \xB7 Shape`,paragraph:e=>`Paragraph ${e}`,paragraphs:(e,t)=>`Paragraphs ${e}\u2013${t}`,paragraphLower:e=>`paragraph ${e}`,table:e=>`Table ${e}`,cell:(e,t,n)=>`Table ${e} \xB7 R${t}C${n}`}},uH={title:zt.title["zh-CN"],openTitle:"\u6253\u5F00\u6587\u6863",openFile:"\u6253\u5F00\u6587\u4EF6",emptyTitle:`\u6253\u5F00\u4F60\u7684 ${Mr(OP,"zh-CN")} \u6587\u4EF6`,emptyDescription:`\u8FB9\u770B\u8FB9\u804A\uFF0C\u9009\u4E2D${AP.zh}\u5373\u53EF\u5E26\u5165\u5BF9\u8BDD\u3002`,emptyCaption:`\u9009\u62E9\u672C\u5730\u6587\u4EF6 \xB7 ${ps("zh-CN","or")}`,importing:"\u6B63\u5728\u5BFC\u5165\u2026",importTooLarge:`\u8BF7\u9009\u62E9\u4E0D\u8D85\u8FC7 ${Lm/1024/1024} MiB \u7684\u6587\u4EF6\u3002`,recent:"\u6700\u8FD1",switchDocument:"\u5207\u6362\u6587\u6863",pagesAndOutline:"\u9875\u9762\u4E0E\u76EE\u5F55",outlineOnly:"\u76EE\u5F55",pages:"\u9875\u9762",slides:"\u5E7B\u706F\u7247",outline:"\u76EE\u5F55",find:"\u67E5\u627E",findPlaceholder:"\u5728\u6587\u6863\u4E2D\u67E5\u627E",findCount:(e,t)=>`${e} / ${t}`,noResults:"\u65E0\u7ED3\u679C",previousMatch:"\u4E0A\u4E00\u4E2A\uFF08\u21E7Enter\uFF09",nextMatch:"\u4E0B\u4E00\u4E2A\uFF08Enter\uFF09",closeFind:"\u5173\u95ED\uFF08Esc\uFF09",more:"\u66F4\u591A",fitWidth:"\u9002\u5E94\u5BBD\u5EA6",fitPage:"\u9002\u5E94\u9875\u9762",actualSize:"\u5B9E\u9645\u5927\u5C0F",reload:"\u4ECE\u78C1\u76D8\u91CD\u65B0\u52A0\u8F7D",previousPage:"\u4E0A\u4E00\u9875",nextPage:"\u4E0B\u4E00\u9875",pageNumber:"\u9875\u7801",ofPages:e=>`/ ${e}`,zoomIn:"\u653E\u5927\uFF08\u2318+\uFF09",zoomOut:"\u7F29\u5C0F\uFF08\u2318\u2212\uFF09",fit:"\u9002\u5E94",addToChat:"\u6DFB\u52A0\u5230\u5BF9\u8BDD",addShort:"\u6DFB\u52A0",addToChatHint:"\u9644\u52A0\u5230\u4E0B\u4E00\u6761\u6D88\u606F\uFF08\u2318/Ctrl+Enter\uFF09",added:"\u5DF2\u6DFB\u52A0\u5230\u5BF9\u8BDD",ask:"\u63D0\u95EE",askPlaceholder:"\u5C31\u8FD9\u91CC\u63D0\u95EE\u2026",send:"\u53D1\u9001",cancel:"\u53D6\u6D88",sendKey:"\u53D1\u9001",cancelKey:"\u53D6\u6D88",copy:"\u590D\u5236",copied:"\u5DF2\u590D\u5236",agent:"Agent",agentOf:(e,t)=>`Agent \xB7 \u7B2C ${e} \u5904\uFF0C\u5171 ${t} \u5904`,nextTarget:"\u4E0B\u4E00\u5904",moreOn:(e,t)=>e===1?`${t}\u8FD8\u6709 1 \u5904`:`\u8FD8\u6709 ${e} \u5904`,close:"\u5173\u95ED",changed:"\u6587\u4EF6\u5DF2\u5728\u78C1\u76D8\u4E0A\u66F4\u6539\u3002",reloadShort:"\u91CD\u65B0\u52A0\u8F7D",dismiss:"\u5FFD\u7565",openAnother:"\u6253\u5F00\u5176\u4ED6\u6587\u4EF6",sidePanel:"\u5728\u4FA7\u680F\u6253\u5F00",meta:{pdf:e=>`${e} \u9875`,pptx:e=>`${e} \u5F20\u5E7B\u706F\u7247`,xlsx:e=>`${e} \u4E2A\u5DE5\u4F5C\u8868`,docx:()=>""},errors:{generic:["\u65E0\u6CD5\u6253\u5F00\u8BE5\u6587\u6863",""],password:["\u8BE5 PDF \u53D7\u5BC6\u7801\u4FDD\u62A4",`${Cx}\u6682\u4E0D\u652F\u6301\u6253\u5F00\u52A0\u5BC6\u6587\u4EF6\u3002`],not_found:["\u8BE5\u6587\u4EF6\u5DF2\u4E0D\u5B58\u5728","\u5B83\u53EF\u80FD\u5DF2\u88AB\u79FB\u52A8\u6216\u5220\u9664\u3002"],file_too_large:["\u6587\u4EF6\u592A\u5927\uFF0C\u65E0\u6CD5\u6253\u5F00",""],corrupt_file:["\u8BE5\u6587\u4EF6\u4F3C\u4E4E\u5DF2\u635F\u574F",`${Cx}\u65E0\u6CD5\u8BFB\u53D6\u5176\u5185\u5BB9\u3002`],unsupported_type:["\u4E0D\u652F\u6301\u8FD9\u79CD\u6587\u4EF6",`${Cx}\u53EF\u4EE5\u6253\u5F00 ${ps("zh-CN")} \u6587\u4EF6\u3002`],path_outside_workspace:["\u8BE5\u6587\u4EF6\u4E0D\u5728\u5DE5\u4F5C\u533A\u5185",""]},sendFailed:"\u6D88\u606F\u672A\u53D1\u9001\u3002",contextFailed:"ZCode \u672A\u63A5\u53D7\u8BE5\u5F15\u7528\u3002",where:{page:e=>`\u7B2C ${e} \u9875`,pages:(e,t)=>`\u7B2C ${e}\u2013${t} \u9875`,pageLower:e=>`\u7B2C ${e} \u9875`,slide:e=>`\u7B2C ${e} \u5F20\u5E7B\u706F\u7247`,slides:(e,t)=>`\u7B2C ${e}\u2013${t} \u5F20\u5E7B\u706F\u7247`,slideLower:e=>`\u7B2C ${e} \u5F20\u5E7B\u706F\u7247`,shape:e=>`\u7B2C ${e} \u5F20\u5E7B\u706F\u7247 \xB7 \u5F62\u72B6`,paragraph:e=>`\u7B2C ${e} \u6BB5`,paragraphs:(e,t)=>`\u7B2C ${e}\u2013${t} \u6BB5`,paragraphLower:e=>`\u7B2C ${e} \u6BB5`,table:e=>`\u8868\u683C ${e}`,cell:(e,t,n)=>`\u8868\u683C ${e} \xB7 R${t}C${n}`}},PP=e=>e?.toLowerCase().startsWith("zh")?uH:cH;function Ab(e,t,n=!1){let i=t.where,r;if(r=/^page:(\d+)(?:-(\d+))?$/.exec(e))return r[2]?i.pages(r[1],r[2]):n?i.pageLower(r[1]):i.page(r[1]);if(r=/^slide:(\d+)\/shape:/.exec(e))return i.shape(r[1]);if(r=/^slide:(\d+)(?:-(\d+))?$/.exec(e))return r[2]?i.slides(r[1],r[2]):n?i.slideLower(r[1]):i.slide(r[1]);if(r=/^p:(\d+)(?:-(\d+))?$/.exec(e))return r[2]?i.paragraphs(r[1],r[2]):n?i.paragraphLower(r[1]):i.paragraph(r[1]);if(r=/^t:(\d+)\/r(\d+)c(\d+)$/.exec(e))return i.cell(r[1],r[2],r[3]);if(r=/^t:(\d+)$/.exec(e))return i.table(r[1]);let a=e.lastIndexOf("!");return a>0?`${e.slice(0,a).replace(/^'(.*)'$/,"$1").replace(/''/g,"'")} \xB7 ${e.slice(a+1)}`:e.replace(/^'(.*)'$/,"$1")}var Ix=ht(Pn(),1),mH={search:'<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>',x:'<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',"chevron-up":'<path d="m18 15-6-6-6 6"/>',"chevron-down":'<path d="m6 9 6 6 6-6"/>',minus:'<path d="M5 12h14"/>',plus:'<path d="M5 12h14"/><path d="M12 5v14"/>',ellipsis:'<circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>',"panel-left":'<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M9 3v18"/>',"file-text":'<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M10 9H8"/><path d="M16 13H8"/><path d="M16 17H8"/>',copy:'<rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/>',"message-square-plus":'<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/><path d="M12 7v6"/><path d="M9 10h6"/>',"message-circle-question":'<path d="M7.9 20A9 9 0 1 0 4 16.1L2 22Z"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><path d="M12 17h.01"/>',check:'<path d="M20 6 9 17l-5-5"/>',"rotate-cw":'<path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/>',"arrow-down":'<path d="M12 5v14"/><path d="m19 12-7 7-7-7"/>',"arrow-up":'<path d="m5 12 7-7 7 7"/><path d="M12 19V5"/>',"folder-open":'<path d="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"/>',"maximize-2":'<polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" x2="14" y1="3" y2="10"/><line x1="3" x2="10" y1="21" y2="14"/>'};function We({name:e,size:t=14,className:n}){return(0,Ix.jsx)("svg",{className:`icon${n?` ${n}`:""}`,width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",dangerouslySetInnerHTML:{__html:mH[e]}})}var pH={pdf:"PDF",docx:"W",xlsx:"X",pptx:"P"};function UP({kind:e}){return(0,Ix.jsx)("span",{className:`filetype ${e}`,"aria-hidden":"true",children:pH[e]})}var aa=ht(ir(),1);var Ae=ht(Pn(),1);function hH({handle:e,page:t,width:n,ratio:i,current:r,onPick:a,root:o}){let s=(0,aa.useRef)(null);return(0,aa.useEffect)(()=>{let l=s.current;if(!l||!e.thumbnail)return;let c=!1,u=new IntersectionObserver(d=>{c||!d.some(f=>f.isIntersecting)||(c=!0,u.disconnect(),e.thumbnail(t,n).then(f=>{l.replaceChildren(f),l.style.height=""},()=>{}))},{root:o.current,rootMargin:"300px 0px"});return u.observe(l),()=>u.disconnect()},[e,t,n,o]),(0,Ae.jsxs)("button",{type:"button",className:`thumb${r?" on":""}`,"aria-current":r?"page":void 0,onClick:()=>a(t),"data-page":t,children:[(0,Ae.jsx)("div",{ref:s,className:"mini",style:{width:n,height:Math.round(n*i)}}),(0,Ae.jsx)("span",{children:t})]})}var LP=e=>/^(?:page|slide):(\d+)/.exec(e)?.[1]??"";function qP({t:e,info:t,handle:n,page:i,tab:r,docked:a,onTab:o,onPage:s,onOutline:l}){let c=(0,aa.useRef)(null),u=!!(n?.thumbnail&&i),d=t.outline.length>0,f=u&&(r==="pages"||!d)?"pages":"outline",m=t.kind==="pptx"?9/16:1.294;(0,aa.useEffect)(()=>{let h=c.current?.querySelector("[aria-current=page]");h&&c.current&&(c.current.scrollTop=h.offsetTop-c.current.clientHeight/3)},[f]);let p=(()=>{if(!i)return-1;let h=-1;return t.outline.forEach((_,g)=>{let b=Number(LP(_.at));b&&b<=i.current&&(h=g)}),h})();return(0,Ae.jsxs)("nav",{className:`drawer${a?" docked":""}`,"aria-label":e.pagesAndOutline,children:[u&&d?(0,Ae.jsxs)("div",{className:"seg",role:"tablist",children:[(0,Ae.jsx)("button",{type:"button",role:"tab","aria-selected":f==="pages",className:f==="pages"?"on":"",onClick:()=>o("pages"),children:t.kind==="pptx"?e.slides:e.pages}),(0,Ae.jsx)("button",{type:"button",role:"tab","aria-selected":f==="outline",className:f==="outline"?"on":"",onClick:()=>o("outline"),children:e.outline})]}):null,(0,Ae.jsx)("div",{ref:c,className:f==="pages"?"thumbs":"outline",children:f==="pages"&&n&&i?Array.from({length:i.count},(h,_)=>(0,Ae.jsx)(hH,{handle:n,page:_+1,width:136,ratio:m,current:i.current===_+1,onPick:s,root:c},_)):t.outline.map((h,_)=>(0,Ae.jsxs)("button",{type:"button",className:`oi level-${Math.min(3,Math.max(1,h.level))}${_===p?" on":""}`,"aria-current":_===p?"page":void 0,title:h.label,onClick:()=>l(h.at),children:[(0,Ae.jsx)("span",{className:"label",children:h.label}),(0,Ae.jsx)("span",{className:"n",children:LP(h.at)})]},`${h.at}-${_}`))})]})}function BP({t:e,onBrowse:t,importing:n}){return(0,Ae.jsx)("div",{className:"empty",children:(0,Ae.jsxs)("div",{className:"empty-content",children:[(0,Ae.jsx)("h3",{children:e.emptyTitle}),(0,Ae.jsx)("p",{className:"empty-description",children:e.emptyDescription}),(0,Ae.jsxs)("button",{type:"button",className:"btn empty-open",onClick:t,disabled:n,children:[(0,Ae.jsx)(We,{name:"folder-open",size:16}),n?e.importing:e.openFile]}),(0,Ae.jsx)("p",{className:"empty-caption",children:e.emptyCaption})]})})}var gH=["title","subtitle","line","line","short","heading","line","line","line","mid","figure"];function Mb({kind:e}){if(e==="xlsx")return(0,Ae.jsx)("div",{className:"skeleton sheet","aria-busy":"true",children:Array.from({length:18},(n,i)=>(0,Ae.jsx)("div",{className:"skel-row"},i))});let t=e==="pptx";return(0,Ae.jsx)("div",{className:"skeleton","aria-busy":"true",children:[0,1].map(n=>(0,Ae.jsxs)("div",{className:`skelpage${t?" slide":""}`,children:[n===0&&!t?gH.map((i,r)=>(0,Ae.jsx)("div",{className:`skel ${i}`},r)):null,n===0&&t?(0,Ae.jsxs)(Ae.Fragment,{children:[(0,Ae.jsx)("div",{className:"skel title left"}),(0,Ae.jsx)("div",{className:"skel line"}),(0,Ae.jsx)("div",{className:"skel mid"})]}):null]},n))})}function Db({t:e,title:t,detail:n,onOpenAnother:i}){return(0,Ae.jsxs)("div",{className:"failed",role:"alert",children:[(0,Ae.jsx)(We,{name:"file-text",size:28,className:"subtlest"}),(0,Ae.jsxs)("div",{children:[(0,Ae.jsx)("h3",{children:t}),n?(0,Ae.jsx)("p",{children:n}):null]}),(0,Ae.jsx)("button",{type:"button",className:"btn secondary",onClick:i,children:e.openAnother})]})}function HP({t:e,onReload:t,onDismiss:n}){return(0,Ae.jsxs)("div",{className:"banner",role:"status",children:[(0,Ae.jsx)("span",{children:e.changed}),(0,Ae.jsx)("button",{type:"button",className:"btn sm primary",onClick:t,children:e.reloadShort}),(0,Ae.jsx)("button",{type:"button",className:"btn icon sm dim",title:e.dismiss,"aria-label":e.dismiss,onClick:n,children:(0,Ae.jsx)(We,{name:"x"})})]})}function vH({inputRef:e,t,importing:n,onImporting:i,onOpen:r,onError:a}){return(0,Ae.jsx)("input",{ref:e,type:"file",hidden:!0,accept:ei.map(o=>`.${o}`).join(","),disabled:n,onChange:async o=>{let s=o.currentTarget.files?.[0];if(o.currentTarget.value="",!!s){i(!0);try{if(s.size>Lm)throw new Error(t.importTooLarge);r(await EP(s))}catch(l){a(l,s.name)}finally{i(!1)}}}})}function VP(e,t,n){let i=(0,aa.useRef)(null),[r,a]=(0,aa.useState)(!1);return{importing:r,browse:()=>i.current?.click(),input:(0,Ae.jsx)(vH,{inputRef:i,t:e,importing:r,onImporting:a,onOpen:t,onError:n})}}var zn=ht(Pn(),1);function ZP({appRef:e,canvasRef:t,t:n,path:i,info:r,kind:a,showSkeleton:o,failure:s,nothing:l,onExpand:c,children:u}){return(0,zn.jsxs)("div",{ref:e,className:"app inline",children:[(0,zn.jsxs)("header",{className:"docbar",children:[(0,zn.jsxs)("div",{className:"doctitle static",title:i??void 0,children:[(0,zn.jsx)("span",{className:"name",children:i?hs(i):n.title}),r&&n.meta[r.kind](r.units)?(0,zn.jsx)("span",{className:"meta",children:n.meta[r.kind](r.units)}):null]}),(0,zn.jsx)("span",{className:"spacer"}),(0,zn.jsxs)("button",{type:"button",className:"btn sm",title:n.sidePanel,onClick:c,children:[(0,zn.jsx)(We,{name:"maximize-2",size:12}),n.sidePanel]})]}),(0,zn.jsx)("div",{className:"stage",children:(0,zn.jsxs)("div",{ref:t,className:"canvas",children:[u,o?(0,zn.jsx)(Mb,{kind:a}):null,s?(0,zn.jsx)(Db,{t:n,title:s.title,detail:s.detail,onOpenAnother:c}):null,l?(0,zn.jsx)("div",{className:"failed muted",children:n.openTitle}):null,(0,zn.jsx)("button",{type:"button",className:"glance-cover","aria-label":n.sidePanel,onClick:c})]})})]})}var er=ht(ir(),1);var jb=ht(ir(),1),gs=8;function Nx(e,t,n){let i=(0,jb.useRef)(null),{side:r,offset:a=8,dock:o=!1}=n;return(0,jb.useLayoutEffect)(()=>{let s=i.current,l=e.current;if(!s||!l)return;let c=0,u=()=>{c=0;let p=l.getBoundingClientRect(),h=s.offsetWidth,_=s.offsetHeight,g=t?.()??null,b=(F,k,D,w)=>{s.style.visibility="",s.style.left=`${Math.round(F)}px`,s.style.top=`${Math.round(k)}px`,s.dataset.side=D,s.style.setProperty("--tip",`${Math.round(Math.max(14,Math.min(h-14,w-F)))}px`)};if(!g){o?b((p.width-h)/2,gs,"none",p.width/2):s.style.visibility="hidden";return}if(g.bottom<p.top+4||g.top>p.bottom-4){s.style.visibility="hidden";return}let S=(g.left+g.right)/2-p.left,$=Math.max(gs,Math.min(p.width-h-gs,S-h/2)),C=g.top-p.top-_-a,z=g.bottom-p.top+a,T=C>=gs,M=z+_<=p.height-gs;(r==="top"||!M)&&T?b($,C,"top",S):M?b($,z,"bottom",S):b($,r==="top"?gs:p.height-_-gs,"none",S)},d=()=>{c||(c=requestAnimationFrame(u))};u(),l.addEventListener("scroll",d,{capture:!0,passive:!0});let f=new ResizeObserver(d);f.observe(l),f.observe(s);let m=setInterval(d,250);return()=>{l.removeEventListener("scroll",d,{capture:!0}),f.disconnect(),clearInterval(m),c&&cancelAnimationFrame(c)}},[e,t,r,a,o]),i}var de=ht(Pn(),1);function Ox({className:e,onClose:t,children:n,label:i}){let r=(0,er.useRef)(null);(0,er.useEffect)(()=>{let o=l=>{let c=l.target;!r.current?.contains(c)&&!c.closest?.("[data-menu-trigger]")&&t()},s=l=>{l.key==="Escape"&&(l.stopPropagation(),t())};return document.addEventListener("pointerdown",o,!0),document.addEventListener("keydown",s,!0),r.current?.querySelector("[role^=menuitem]")?.focus(),()=>{document.removeEventListener("pointerdown",o,!0),document.removeEventListener("keydown",s,!0)}},[t]);let a=o=>{if(o.key!=="ArrowDown"&&o.key!=="ArrowUp")return;o.preventDefault();let s=[...r.current?.querySelectorAll("[role^=menuitem]")??[]],l=s.indexOf(document.activeElement);s[(l+(o.key==="ArrowDown"?1:-1)+s.length)%s.length]?.focus()};return(0,de.jsx)("div",{ref:r,className:`menu ${e}`,role:"menu","aria-label":i,onKeyDown:a,children:n})}function ro({icon:e,checked:t,children:n,hint:i,onSelect:r}){return(0,de.jsxs)("button",{type:"button",role:t===void 0?"menuitem":"menuitemradio","aria-checked":t,className:"mi",onClick:r,children:[(0,de.jsx)("span",{className:"mi-icon",children:t?(0,de.jsx)(We,{name:"check",size:16}):e}),(0,de.jsx)("span",{className:"mi-label",children:n}),i?(0,de.jsx)("span",{className:"mi-hint",children:i}):null]})}function GP({t:e,query:t,total:n,index:i,onQuery:r,onStep:a,onClose:o}){let s=(0,er.useRef)(null);(0,er.useEffect)(()=>{s.current?.focus(),s.current?.select()},[]);let l=!t.trim()||n===null?"":n?e.findCount(i+1,n):e.noResults;return(0,de.jsxs)("div",{className:"docbar findbar",role:"search",children:[(0,de.jsxs)("label",{className:"findfield",children:[(0,de.jsx)(We,{name:"search",className:"muted"}),(0,de.jsx)("input",{ref:s,className:"find-input",type:"text","aria-label":e.find,placeholder:e.findPlaceholder,value:t,onChange:c=>r(c.target.value),onKeyDown:c=>{c.key==="Enter"?(c.preventDefault(),a(c.shiftKey?-1:1)):c.key==="Escape"&&(c.preventDefault(),c.stopPropagation(),o())}}),(0,de.jsx)("span",{className:"count","aria-live":"polite",children:l})]}),(0,de.jsx)("button",{type:"button",className:"btn icon dim",title:e.previousMatch,"aria-label":e.previousMatch,disabled:!n,onClick:()=>a(-1),children:(0,de.jsx)(We,{name:"chevron-up"})}),(0,de.jsx)("button",{type:"button",className:"btn icon dim",title:e.nextMatch,"aria-label":e.nextMatch,disabled:!n,onClick:()=>a(1),children:(0,de.jsx)(We,{name:"chevron-down"})}),(0,de.jsx)("button",{type:"button",className:"btn icon dim",title:e.closeFind,"aria-label":e.closeFind,onClick:o,children:(0,de.jsx)(We,{name:"x"})})]})}var bH=1500;function KP({t:e,frame:t,page:n,zoom:i,onPage:r,onZoom:a,onFit:o}){let s=(0,er.useRef)(null),[l,c]=(0,er.useState)(!0),[u,d]=(0,er.useState)(null),f=(0,er.useRef)(!1);(0,er.useEffect)(()=>{let p=t.current;if(!p)return;let h=0,_=()=>{clearTimeout(h),h=window.setTimeout(()=>{!f.current&&!s.current?.contains(document.activeElement)&&c(!1)},bH)},g=()=>{c(!0),_()},b=S=>{let $=p.getBoundingClientRect();S.clientY>$.bottom-80&&g()};return p.addEventListener("scroll",g,{capture:!0,passive:!0}),p.addEventListener("pointermove",b,{passive:!0}),_(),()=>{clearTimeout(h),p.removeEventListener("scroll",g,{capture:!0}),p.removeEventListener("pointermove",b)}},[t]);let m=()=>{let p=Number(u);d(null),Number.isInteger(p)&&p>=1&&r(Math.min(p,n.count))};return(0,de.jsxs)("div",{ref:s,className:`pill${l?"":" faded"}`,onPointerEnter:()=>{f.current=!0,c(!0)},onPointerLeave:()=>{f.current=!1},onFocus:()=>c(!0),children:[(0,de.jsx)("button",{type:"button",className:"btn icon sm dim",title:e.previousPage,"aria-label":e.previousPage,disabled:n.current<=1,onClick:()=>r(n.current-1),children:(0,de.jsx)(We,{name:"chevron-up"})}),(0,de.jsxs)("span",{className:"pg",children:[(0,de.jsx)("input",{className:"pgin","aria-label":e.pageNumber,inputMode:"numeric",style:{width:`${Math.max(2,String(n.count).length)+1.6}ch`},value:u??String(n.current),onFocus:p=>{d(String(n.current)),p.target.select()},onChange:p=>d(p.target.value.replace(/\D/g,"")),onBlur:()=>d(null),onKeyDown:p=>{p.key==="Enter"?(m(),p.currentTarget.blur()):p.key==="Escape"&&(p.stopPropagation(),d(null),p.currentTarget.blur())}}),(0,de.jsx)("span",{children:e.ofPages(n.count)})]}),(0,de.jsx)("button",{type:"button",className:"btn icon sm dim",title:e.nextPage,"aria-label":e.nextPage,disabled:n.current>=n.count,onClick:()=>r(n.current+1),children:(0,de.jsx)(We,{name:"chevron-down"})}),i?(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)("span",{className:"vsep"}),(0,de.jsx)("button",{type:"button",className:"btn icon sm dim",title:e.zoomOut,"aria-label":e.zoomOut,disabled:i.mode!=="width"&&i.percent<=25,onClick:()=>a(-1),children:(0,de.jsx)(We,{name:"minus"})}),(0,de.jsx)("button",{type:"button",className:"zoom",title:e.fitWidth,onClick:o,children:i.mode==="width"?e.fit:`${i.percent}%`}),(0,de.jsx)("button",{type:"button",className:"btn icon sm dim",title:e.zoomIn,"aria-label":e.zoomIn,disabled:i.mode!=="width"&&i.percent>=400,onClick:()=>a(1),children:(0,de.jsx)(We,{name:"plus"})})]}):null]})}var FP=e=>{e.target.closest("textarea")||e.preventDefault()};function JP({t:e,frame:t,locate:n,text:i,label:r,quote:a,short:o,mode:s,canAsk:l,copied:c,onAdd:u,onAsk:d,onCopy:f,onCancelAsk:m,onSend:p}){let h=s==="ask",_=Nx(t,n,{side:h?"bottom":"top",dock:!0}),[g,b]=(0,er.useState)(""),[S,$]=(0,er.useState)(!1),C=async()=>{if(!g.trim()||S)return;$(!0);let z=await p(g.trim());$(!1),z&&b("")};return h?(0,de.jsxs)("div",{ref:_,className:"pop ask",role:"dialog","aria-label":e.ask,onMouseDown:FP,children:[(0,de.jsxs)("div",{className:"ctx",children:[(0,de.jsx)("span",{className:"where",children:r}),a?(0,de.jsxs)("span",{className:"q",children:["\u201C",a,"\u201D"]}):null]}),(0,de.jsx)("textarea",{autoFocus:!0,className:"textarea",rows:2,"aria-label":e.askPlaceholder,placeholder:e.askPlaceholder,value:g,onChange:z=>b(z.target.value),onKeyDown:z=>{z.key==="Enter"&&!z.shiftKey&&!z.nativeEvent.isComposing?(z.preventDefault(),C()):z.key==="Escape"&&(z.preventDefault(),z.stopPropagation(),m())}}),(0,de.jsxs)("div",{className:"row",children:[(0,de.jsxs)("span",{className:"hint",children:[(0,de.jsx)("kbd",{children:"\u21B5"})," ",e.sendKey]}),(0,de.jsx)("button",{type:"button",className:"btn sm",onClick:m,children:e.cancel}),(0,de.jsx)("button",{type:"button",className:"btn sm primary",disabled:!g.trim()||S,onClick:()=>void C(),children:e.send})]})]}):(0,de.jsxs)("div",{ref:_,className:"pop bar",role:"toolbar","aria-label":r,onMouseDown:FP,children:[i?null:(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)("span",{className:"where",children:r}),(0,de.jsx)("span",{className:"vsep"})]}),(0,de.jsx)("button",{type:"button",className:"btn lg",title:e.addToChatHint,onClick:u,disabled:s==="added",children:s==="added"?(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(We,{name:"check",size:16,className:"ok"}),e.added]}):(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(We,{name:"message-square-plus",size:16}),o?e.addShort:e.addToChat]})}),l?(0,de.jsxs)("button",{type:"button",className:"btn lg",onClick:d,children:[(0,de.jsx)(We,{name:"message-circle-question",size:16}),e.ask]}):null,i?(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)("span",{className:"vsep"}),(0,de.jsx)("button",{type:"button",className:"btn icon lg dim",title:c?e.copied:e.copy,"aria-label":c?e.copied:e.copy,onClick:f,children:(0,de.jsx)(We,{name:c?"check":"copy"})})]}):null]})}function YP({t:e,frame:t,locate:n,note:i,index:r,total:a,onNext:o,onClose:s}){let l=Nx(t,n,{side:"bottom",offset:6,dock:!0});return(0,de.jsxs)("div",{ref:l,className:"callout",role:"note",children:[(0,de.jsxs)("div",{className:"body",children:[(0,de.jsxs)("div",{className:"who",children:[(0,de.jsx)("span",{className:"dot"}),a>1?e.agentOf(r+1,a):e.agent]}),i?(0,de.jsx)("div",{className:"text",children:i}):null]}),a>1?(0,de.jsx)("button",{type:"button",className:"btn icon sm dim",title:e.nextTarget,"aria-label":e.nextTarget,onClick:o,children:(0,de.jsx)(We,{name:"chevron-down"})}):null,(0,de.jsx)("button",{type:"button",className:"btn icon sm dim",title:e.close,"aria-label":e.close,onClick:s,children:(0,de.jsx)(We,{name:"x"})})]})}function XP({text:e,down:t,raised:n,onClick:i}){return(0,de.jsxs)("button",{type:"button",className:`chip offscreen${n?" raised":""}`,onClick:i,children:[(0,de.jsx)("span",{className:"dot"}),e,(0,de.jsx)(We,{name:t?"arrow-down":"arrow-up",size:12})]})}function WP(e,t){return e.moreOn(t.length,Ab(t[0],e,!0))}var Ot=ht(Pn(),1);function QP({t:e,recent:t,currentPath:n,onOpen:i,onBrowse:r,onClose:a}){return(0,Ot.jsxs)(Ox,{className:"switcher",label:e.switchDocument,onClose:a,children:[t.length?(0,Ot.jsx)("div",{className:"mlabel",children:e.recent}):null,t.map(o=>(0,Ot.jsx)(ro,{icon:(0,Ot.jsx)(UP,{kind:o.kind}),hint:o.path===n?(0,Ot.jsx)(We,{name:"check",size:16}):hs(TP(o.path)),onSelect:()=>o.path===n?a():i(o.path),children:hs(o.path)},o.path)),t.length?(0,Ot.jsx)("div",{className:"msep"}):null,(0,Ot.jsx)(ro,{icon:(0,Ot.jsx)(We,{name:"folder-open",size:16}),onSelect:r,children:e.openFile})]})}function eM({t:e,zoomable:t,zoomMode:n,onFit:i,onFind:r,onReload:a,onClose:o}){return(0,Ot.jsxs)(Ox,{className:"more",label:e.more,onClose:o,children:[t?(0,Ot.jsxs)(Ot.Fragment,{children:[(0,Ot.jsx)(ro,{checked:n==="width",onSelect:()=>i("width"),children:e.fitWidth}),(0,Ot.jsx)(ro,{checked:n==="page",onSelect:()=>i("page"),children:e.fitPage}),(0,Ot.jsx)(ro,{checked:n==="actual",hint:"100%",onSelect:()=>i("actual"),children:e.actualSize}),(0,Ot.jsx)("div",{className:"msep"})]}):null,(0,Ot.jsx)(ro,{icon:(0,Ot.jsx)(We,{name:"search",size:16}),hint:"\u2318F",onSelect:r,children:e.find}),(0,Ot.jsx)(ro,{icon:(0,Ot.jsx)(We,{name:"rotate-cw",size:16}),onSelect:a,children:e.reload})]})}var ti=ht(ir(),1),Fm={open:!1,query:"",total:null,index:-1};function tM({viewer:e,docRef:t,ready:n,onOpen:i}){let[r,a]=(0,ti.useState)(Fm),o=(0,ti.useRef)(0),s=(0,ti.useCallback)(()=>{t.current&&(i(),a(d=>({...d,open:!0})),requestAnimationFrame(()=>{let d=document.querySelector(".findbar .find-input");d?.focus(),d?.select()}))},[t,i]),l=(0,ti.useCallback)(()=>{o.current++,e.current?.clearFind(),a(Fm)},[e]),c=(0,ti.useCallback)(d=>{a(f=>({...f,query:d,total:d.trim()?f.total:null}))},[]);(0,ti.useEffect)(()=>{if(!r.open||!n)return;let d=++o.current,f=setTimeout(async()=>{let m=e.current;if(!m)return;let p=await m.find(r.query).catch(()=>0);d===o.current&&(a(h=>({...h,total:p,index:p?0:-1})),p&&m.findGo(0))},200);return()=>clearTimeout(f)},[r.open,r.query,n,e]);let u=(0,ti.useCallback)(d=>{if(!r.total)return;let f=(r.index+d+r.total)%r.total;a(m=>({...m,index:f})),e.current?.findGo(f)},[r.total,r.index,e]);return{find:r,setFind:a,openFind:s,closeFind:l,queryFind:c,stepFind:u}}var nM=ht(ir(),1);function rM(e,t){(0,nM.useEffect)(()=>{Dr().handleTool("capture_view",async i=>{let r=e.current;if(!r||!t.current)throw new Error(`No document is open in the ${zt.title.en} panel. Call open_document first.`);let a=null;if(typeof i.anchor=="string"&&i.anchor.trim()){let l=vP(i.anchor);if(l.path.replace(/^\.\//,"")!==r.info.path)throw new Error(`The panel shows ${r.info.path}, not ${l.path}. Call open_document with that path first.`);a=l.at}let o=typeof i.maxWidth=="number"?Math.min(2e3,Math.max(320,i.maxWidth)):1600,s=await t.current.capture(a,o);return{content:[{type:"image",data:s.data,mimeType:"image/png"},{type:"text",text:`Captured ${Bm(r.info.path,s.at)} (${s.width}\xD7${s.height} px).`}]}})},[e,t])}var Ub=ht(ir(),1);function iM(e,t){let[n,i]=(0,Ub.useState)(null);return(0,Ub.useEffect)(()=>{let r=e.current;if(!r||!t||t.targets.length<2){i(null);return}let a=0,o=()=>{a=0;let c=r.getBoundingClientRect(),u=[],d=[];t.targets.forEach((m,p)=>{if(p===t.index)return;let h=m.locate();h&&(h.top>c.bottom-8?u.push(p):h.bottom<c.top+8&&d.push(p))});let f=u.length?{indexes:u,down:!0}:d.length?{indexes:d,down:!1}:null;i(m=>JSON.stringify(m)===JSON.stringify(f)?m:f)},s=()=>{a||(a=requestAnimationFrame(o))};o(),r.addEventListener("scroll",s,{capture:!0,passive:!0});let l=setInterval(s,500);return()=>{r.removeEventListener("scroll",s,{capture:!0}),clearInterval(l),a&&cancelAnimationFrame(a)}},[t,e]),[n,i]}var aM=ht(ir(),1);function oM({docRef:e,viewer:t,picked:n,addReference:i,openFind:r,closeFind:a,clearSelection:o,paged:s,page:l,goToPage:c,drawer:u,setDrawer:d,docked:f,find:m,agent:p,setAgent:h}){(0,aM.useEffect)(()=>{let _=g=>{if(g.defaultPrevented)return;let b=g.metaKey||g.ctrlKey,S=g.target?.closest?.("input, textarea, [contenteditable]"),$=g.key.toLowerCase();if(b&&$==="f"&&e.current)g.preventDefault(),r();else if(b&&g.key==="Enter"&&n)g.preventDefault(),i();else if(b&&(g.key==="="||g.key==="+"))g.preventDefault(),t.current?.zoom(1);else if(b&&g.key==="-")g.preventDefault(),t.current?.zoom(-1);else if(b&&g.key==="0")g.preventDefault(),t.current?.fit("width");else if(!b&&!S&&s&&l&&["ArrowLeft","ArrowRight","PageUp","PageDown"].includes(g.key)){g.preventDefault();let C=g.key==="ArrowLeft"||g.key==="PageUp";c(l.current+(C?-1:1))}else if(g.key==="Escape"&&!S){if(n)o();else if(u.open&&!f)d(C=>({...C,open:!1}));else if(m.open)a();else if(p?.visible)h({...p,visible:!1});else return;g.preventDefault()}};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[n,i,r,a,o,s,l,c,u.open,f,m.open,p,e,t,d,h])}var At=ht(ir(),1);var vM=ht(lM(),1);var Ut;(function(e){e.OfficeDocument="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",e.FontTable="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",e.Image="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",e.Numbering="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",e.Styles="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",e.StylesWithEffects="http://schemas.microsoft.com/office/2007/relationships/stylesWithEffects",e.Theme="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",e.Settings="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",e.WebSettings="http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings",e.Hyperlink="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",e.Footnotes="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",e.Endnotes="http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes",e.Footer="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",e.Header="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",e.ExtendedProperties="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",e.CoreProperties="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",e.CustomProperties="http://schemas.openxmlformats.org/package/2006/relationships/metadata/custom-properties",e.Comments="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",e.CommentsExtended="http://schemas.microsoft.com/office/2011/relationships/commentsExtended",e.AltChunk="http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk"})(Ut||(Ut={}));function yH(e,t){return t.elements(e).map(n=>({id:t.attr(n,"Id"),type:t.attr(n,"Type"),target:t.attr(n,"Target"),targetMode:t.attr(n,"TargetMode")}))}function SH(e){return e?.replace(/[ .]+/g,"-").replace(/[&]+/g,"and").toLowerCase()}function Dx(e){return/^[^"'].*\s.*[^"']$/.test(e)?`'${e}'`:e}function qb(e){let t=e.lastIndexOf("/")+1,n=t==0?"":e.substring(0,t),i=t==0?e:e.substring(t);return[n,i]}function Px(e,t){try{let n="http://docx/";return new URL(e,n+t).toString().substring(n.length)}catch{return`${t}${e}`}}function io(e,t){return e.reduce((n,i)=>(n[t(i)]=i,n),{})}function _H(e){return new Promise((t,n)=>{let i=new FileReader;i.onloadend=()=>t(i.result),i.onerror=()=>n(),i.readAsDataURL(e)})}function Mx(e){return e&&typeof e=="object"&&!Array.isArray(e)}function jx(e){return typeof e=="string"||e instanceof String}function Hb(e,...t){if(!t.length)return e;let n=t.shift();if(Mx(e)&&Mx(n))for(let i in n)if(Mx(n[i])){let r=e[i]??(e[i]={});Hb(r,n[i])}else e[i]=n[i];return Hb(e,...t)}function Gm(e){return Array.isArray(e)?e:[e]}function wH(e,t,n){return t>e?t:n<e?n:e}var bM={wordml:"http://schemas.openxmlformats.org/wordprocessingml/2006/main"},Zt={Dxa:{mul:.05,unit:"pt"},Emu:{mul:1/12700,unit:"pt"},FontSize:{mul:.5,unit:"pt"},Border:{mul:.125,unit:"pt",min:.25,max:12},Point:{mul:1,unit:"pt"},Percent:{mul:.02,unit:"%"}};function yM(e,t=Zt.Dxa){if(e==null||/.+(p[xt]|[%])$/.test(e))return e;var n=parseInt(e)*t.mul;return t.min&&t.max&&(n=wH(n,t.min,t.max)),`${n.toFixed(2)}${t.unit}`}function $H(e,t=!1){switch(e){case"1":return!0;case"0":return!1;case"on":return!0;case"off":return!1;case"true":return!0;case"false":return!1;default:return t}}function SM(e,t,n){if(e.namespaceURI!=bM.wordml)return!1;switch(e.localName){case"color":t.color=n.attr(e,"val");break;case"sz":t.fontSize=n.lengthAttr(e,"val",Zt.FontSize);break;default:return!1}return!0}function zH(e,t=!1){t&&(e=e.replace(/<[?].*[?]>/,"")),e=xH(e);let n=new DOMParser().parseFromString(e,"application/xml"),i=kH(n);if(i)throw new Error(i);return n}function kH(e){return e.getElementsByTagName("parsererror")[0]?.textContent}function xH(e){return e.charCodeAt(0)===65279?e.substring(1):e}function RH(e){return new XMLSerializer().serializeToString(e)}var Vb=class{elements(t,n=null){let i=[];for(let r=0,a=t.childNodes.length;r<a;r++){let o=t.childNodes.item(r);o.nodeType==Node.ELEMENT_NODE&&(n==null||o.localName==n)&&i.push(o)}return i}element(t,n){for(let i=0,r=t.childNodes.length;i<r;i++){let a=t.childNodes.item(i);if(a.nodeType==1&&a.localName==n)return a}return null}elementAttr(t,n,i){var r=this.element(t,n);return r?this.attr(r,i):void 0}attrs(t){return Array.from(t.attributes)}attr(t,n){for(let i=0,r=t.attributes.length;i<r;i++){let a=t.attributes.item(i);if(a.localName==n)return a.value}return null}intAttr(t,n,i=null){var r=this.attr(t,n);return r?parseInt(r):i}hexAttr(t,n,i=null){var r=this.attr(t,n);return r?parseInt(r,16):i}floatAttr(t,n,i=null){var r=this.attr(t,n);return r?parseFloat(r):i}boolAttr(t,n,i=null){return $H(this.attr(t,n),i)}lengthAttr(t,n,i=Zt.Dxa){return yM(this.attr(t,n),i)}},N=new Vb,Mn=class{constructor(t,n){this._package=t,this.path=n}async load(){this.rels=await this._package.loadRelationships(this.path);let t=await this._package.load(this.path),n=this._package.parseXmlDocument(t);this._package.options.keepOrigin&&(this._xmlDocument=n),this.parseXml(n.firstElementChild)}save(){this._package.update(this.path,RH(this._xmlDocument))}parseXml(t){}},TH={embedRegular:"regular",embedBold:"bold",embedItalic:"italic",embedBoldItalic:"boldItalic"};function EH(e,t){return t.elements(e).map(n=>CH(n,t))}function CH(e,t){let n={name:t.attr(e,"name"),embedFontRefs:[]};for(let i of t.elements(e))switch(i.localName){case"family":n.family=t.attr(i,"val");break;case"altName":n.altName=t.attr(i,"val");break;case"embedRegular":case"embedBold":case"embedItalic":case"embedBoldItalic":n.embedFontRefs.push(IH(i,t));break}return n}function IH(e,t){return{id:t.attr(e,"id"),key:t.attr(e,"fontKey"),type:TH[e.localName]}}var Ux=class extends Mn{parseXml(t){this.fonts=EH(t,this._package.xmlParser)}};function NH(e,t){return t.elements(e).map(n=>({extension:t.attr(n,"Extension"),partName:t.attr(n,"PartName"),contentType:t.attr(n,"ContentType")}))}var Lx=class e{constructor(t,n){this._zip=t,this.options=n,this.xmlParser=new Vb}get(t){let n=OH(t);return this._zip.files[n]??this._zip.files[n.replace(/\//g,"\\")]}update(t,n){this._zip.file(t,n)}static async load(t,n){let i=await vM.default.loadAsync(t);return new e(i,n)}save(t="blob"){return this._zip.generateAsync({type:t})}load(t,n="string"){return this.get(t)?.async(n)??Promise.resolve(null)}async loadRelationships(t=null){let n="_rels/.rels";if(t!=null){let[r,a]=qb(t);n=`${r}_rels/${a}.rels`}let i=await this.load(n);return i?yH(this.parseXmlDocument(i).firstElementChild,this.xmlParser):null}async loadContentTypes(){let t=await this.load("[Content_Types].xml");return t?NH(this.parseXmlDocument(t).firstElementChild,this.xmlParser):[]}parseXmlDocument(t){return zH(t,this.options.trimXmlDeclaration)}};function OH(e){return e.startsWith("/")?e.substr(1):e}var qx=class extends Mn{constructor(t,n,i){super(t,n),this._documentParser=i}parseXml(t){this.body=this._documentParser.parseDocumentFile(t)}};function Lb(e,t){return{type:t.attr(e,"val"),color:t.attr(e,"color"),size:t.lengthAttr(e,"sz",Zt.Border),offset:t.lengthAttr(e,"space",Zt.Point),frame:t.boolAttr(e,"frame"),shadow:t.boolAttr(e,"shadow")}}function AH(e,t){var n={};for(let i of t.elements(e))switch(i.localName){case"left":n.left=Lb(i,t);break;case"top":n.top=Lb(i,t);break;case"right":n.right=Lb(i,t);break;case"bottom":n.bottom=Lb(i,t);break}return n}var cM;(function(e){e.Continuous="continuous",e.NextPage="nextPage",e.NextColumn="nextColumn",e.EvenPage="evenPage",e.OddPage="oddPage"})(cM||(cM={}));function _M(e,t=N){var n={};for(let i of t.elements(e))switch(i.localName){case"pgSz":n.pageSize={width:t.lengthAttr(i,"w"),height:t.lengthAttr(i,"h"),orientation:t.attr(i,"orient")};break;case"type":n.type=t.attr(i,"val");break;case"pgMar":n.pageMargins={left:t.lengthAttr(i,"left"),right:t.lengthAttr(i,"right"),top:t.lengthAttr(i,"top"),bottom:t.lengthAttr(i,"bottom"),header:t.lengthAttr(i,"header"),footer:t.lengthAttr(i,"footer"),gutter:t.lengthAttr(i,"gutter")};break;case"cols":n.columns=PH(i,t);break;case"headerReference":(n.headerRefs??(n.headerRefs=[])).push(uM(i,t));break;case"footerReference":(n.footerRefs??(n.footerRefs=[])).push(uM(i,t));break;case"titlePg":n.titlePage=t.boolAttr(i,"val",!0);break;case"pgBorders":n.pageBorders=AH(i,t);break;case"pgNumType":n.pageNumber=MH(i,t);break}return n}function PH(e,t){return{numberOfColumns:t.intAttr(e,"num"),space:t.lengthAttr(e,"space"),separator:t.boolAttr(e,"sep"),equalWidth:t.boolAttr(e,"equalWidth",!0),columns:t.elements(e,"col").map(n=>({width:t.lengthAttr(n,"w"),space:t.lengthAttr(n,"space")}))}}function MH(e,t){return{chapSep:t.attr(e,"chapSep"),chapStyle:t.attr(e,"chapStyle"),format:t.attr(e,"fmt"),start:t.intAttr(e,"start")}}function uM(e,t){return{id:t.attr(e,"id"),type:t.attr(e,"type")}}function DH(e,t){return{before:t.lengthAttr(e,"before"),after:t.lengthAttr(e,"after"),line:t.intAttr(e,"line"),lineRule:t.attr(e,"lineRule")}}function p1(e,t){let n={};for(let i of t.elements(e))jH(i,n,t);return n}function jH(e,t,n){return!!SM(e,t,n)}function wM(e,t){let n={};for(let i of t.elements(e))$M(i,n,t);return n}function $M(e,t,n){if(e.namespaceURI!=bM.wordml)return!1;if(SM(e,t,n))return!0;switch(e.localName){case"tabs":t.tabs=UH(e,n);break;case"sectPr":t.sectionProps=_M(e,n);break;case"numPr":t.numbering=LH(e,n);break;case"spacing":return t.lineSpacing=DH(e,n),!1;case"textAlignment":return t.textAlignment=n.attr(e,"val"),!1;case"keepLines":t.keepLines=n.boolAttr(e,"val",!0);break;case"keepNext":t.keepNext=n.boolAttr(e,"val",!0);break;case"pageBreakBefore":t.pageBreakBefore=n.boolAttr(e,"val",!0);break;case"outlineLvl":t.outlineLevel=n.intAttr(e,"val");break;case"pStyle":t.styleName=n.attr(e,"val");break;case"rPr":t.runProps=p1(e,n);break;default:return!1}return!0}function UH(e,t){return t.elements(e,"tab").map(n=>({position:t.lengthAttr(n,"pos"),leader:t.attr(n,"leader"),style:t.attr(n,"val")}))}function LH(e,t){var n={};for(let i of t.elements(e))switch(i.localName){case"numId":n.id=t.attr(i,"val");break;case"ilvl":n.level=t.intAttr(i,"val");break}return n}function qH(e,t){let n={numberings:[],abstractNumberings:[],bulletPictures:[]};for(let i of t.elements(e))switch(i.localName){case"num":n.numberings.push(BH(i,t));break;case"abstractNum":n.abstractNumberings.push(HH(i,t));break;case"numPicBullet":n.bulletPictures.push(ZH(i,t));break}return n}function BH(e,t){let n={id:t.attr(e,"numId"),overrides:[]};for(let i of t.elements(e))switch(i.localName){case"abstractNumId":n.abstractId=t.attr(i,"val");break;case"lvlOverride":n.overrides.push(VH(i,t));break}return n}function HH(e,t){let n={id:t.attr(e,"abstractNumId"),levels:[]};for(let i of t.elements(e))switch(i.localName){case"name":n.name=t.attr(i,"val");break;case"multiLevelType":n.multiLevelType=t.attr(i,"val");break;case"numStyleLink":n.numberingStyleLink=t.attr(i,"val");break;case"styleLink":n.styleLink=t.attr(i,"val");break;case"lvl":n.levels.push(zM(i,t));break}return n}function zM(e,t){let n={level:t.intAttr(e,"ilvl")};for(let i of t.elements(e))switch(i.localName){case"start":n.start=t.attr(i,"val");break;case"lvlRestart":n.restart=t.intAttr(i,"val");break;case"numFmt":n.format=t.attr(i,"val");break;case"lvlText":n.text=t.attr(i,"val");break;case"lvlJc":n.justification=t.attr(i,"val");break;case"lvlPicBulletId":n.bulletPictureId=t.attr(i,"val");break;case"pStyle":n.paragraphStyle=t.attr(i,"val");break;case"pPr":n.paragraphProps=wM(i,t);break;case"rPr":n.runProps=p1(i,t);break}return n}function VH(e,t){let n={level:t.intAttr(e,"ilvl")};for(let i of t.elements(e))switch(i.localName){case"startOverride":n.start=t.intAttr(i,"val");break;case"lvl":n.numberingLevel=zM(i,t);break}return n}function ZH(e,t){var n=t.element(e,"pict"),i=n&&t.element(n,"shape"),r=i&&t.element(i,"imagedata");return r?{id:t.attr(e,"numPicBulletId"),referenceId:t.attr(r,"id"),style:t.attr(i,"style")}:null}var Bx=class extends Mn{constructor(t,n,i){super(t,n),this._documentParser=i}parseXml(t){Object.assign(this,qH(t,this._package.xmlParser)),this.domNumberings=this._documentParser.parseNumberingFile(t)}},Hx=class extends Mn{constructor(t,n,i){super(t,n),this._documentParser=i}parseXml(t){this.styles=this._documentParser.parseStylesFile(t)}},Z;(function(e){e.Document="document",e.Paragraph="paragraph",e.Run="run",e.Break="break",e.NoBreakHyphen="noBreakHyphen",e.Table="table",e.Row="row",e.Cell="cell",e.Hyperlink="hyperlink",e.SmartTag="smartTag",e.Drawing="drawing",e.Image="image",e.Text="text",e.Tab="tab",e.Symbol="symbol",e.BookmarkStart="bookmarkStart",e.BookmarkEnd="bookmarkEnd",e.Footer="footer",e.Header="header",e.FootnoteReference="footnoteReference",e.EndnoteReference="endnoteReference",e.Footnote="footnote",e.Endnote="endnote",e.SimpleField="simpleField",e.ComplexField="complexField",e.Instruction="instruction",e.VmlPicture="vmlPicture",e.MmlMath="mmlMath",e.MmlMathParagraph="mmlMathParagraph",e.MmlFraction="mmlFraction",e.MmlFunction="mmlFunction",e.MmlFunctionName="mmlFunctionName",e.MmlNumerator="mmlNumerator",e.MmlDenominator="mmlDenominator",e.MmlRadical="mmlRadical",e.MmlBase="mmlBase",e.MmlDegree="mmlDegree",e.MmlSuperscript="mmlSuperscript",e.MmlSubscript="mmlSubscript",e.MmlPreSubSuper="mmlPreSubSuper",e.MmlSubArgument="mmlSubArgument",e.MmlSuperArgument="mmlSuperArgument",e.MmlNary="mmlNary",e.MmlDelimiter="mmlDelimiter",e.MmlRun="mmlRun",e.MmlEquationArray="mmlEquationArray",e.MmlLimit="mmlLimit",e.MmlLimitLower="mmlLimitLower",e.MmlMatrix="mmlMatrix",e.MmlMatrixRow="mmlMatrixRow",e.MmlBox="mmlBox",e.MmlBar="mmlBar",e.MmlGroupChar="mmlGroupChar",e.VmlElement="vmlElement",e.Inserted="inserted",e.Deleted="deleted",e.DeletedText="deletedText",e.Comment="comment",e.CommentReference="commentReference",e.CommentRangeStart="commentRangeStart",e.CommentRangeEnd="commentRangeEnd",e.AltChunk="altChunk"})(Z||(Z={}));var oa=class{constructor(){this.children=[],this.cssStyle={}}},Vx=class extends oa{constructor(){super(...arguments),this.type=Z.Header}},Zx=class extends oa{constructor(){super(...arguments),this.type=Z.Footer}},Zb=class extends Mn{constructor(t,n,i){super(t,n),this._documentParser=i}parseXml(t){this.rootElement=this.createRootElement(),this.rootElement.children=this._documentParser.parseBodyElements(t)}},Fx=class extends Zb{createRootElement(){return new Vx}},Gx=class extends Zb{createRootElement(){return new Zx}};function FH(e,t){let n={};for(let i of t.elements(e))switch(i.localName){case"Template":n.template=i.textContent;break;case"Pages":n.pages=Km(i.textContent);break;case"Words":n.words=Km(i.textContent);break;case"Characters":n.characters=Km(i.textContent);break;case"Application":n.application=i.textContent;break;case"Lines":n.lines=Km(i.textContent);break;case"Paragraphs":n.paragraphs=Km(i.textContent);break;case"Company":n.company=i.textContent;break;case"AppVersion":n.appVersion=i.textContent;break}return n}function Km(e){if(!(typeof e>"u"))return parseInt(e)}var Kx=class extends Mn{parseXml(t){this.props=FH(t,this._package.xmlParser)}};function GH(e,t){let n={};for(let i of t.elements(e))switch(i.localName){case"title":n.title=i.textContent;break;case"description":n.description=i.textContent;break;case"subject":n.subject=i.textContent;break;case"creator":n.creator=i.textContent;break;case"keywords":n.keywords=i.textContent;break;case"language":n.language=i.textContent;break;case"lastModifiedBy":n.lastModifiedBy=i.textContent;break;case"revision":i.textContent&&(n.revision=parseInt(i.textContent));break}return n}var Jx=class extends Mn{parseXml(t){this.props=GH(t,this._package.xmlParser)}},Yx=class{};function KH(e,t){var n=new Yx,i=t.element(e,"themeElements");for(let r of t.elements(i))switch(r.localName){case"clrScheme":n.colorScheme=JH(r,t);break;case"fontScheme":n.fontScheme=YH(r,t);break}return n}function JH(e,t){var n={name:t.attr(e,"name"),colors:{}};for(let a of t.elements(e)){var i=t.element(a,"srgbClr"),r=t.element(a,"sysClr");i?n.colors[a.localName]=t.attr(i,"val"):r&&(n.colors[a.localName]=t.attr(r,"lastClr"))}return n}function YH(e,t){var n={name:t.attr(e,"name")};for(let i of t.elements(e))switch(i.localName){case"majorFont":n.majorFont=dM(i,t);break;case"minorFont":n.minorFont=dM(i,t);break}return n}function dM(e,t){return{latinTypeface:t.elementAttr(e,"latin","typeface"),eaTypeface:t.elementAttr(e,"ea","typeface"),csTypeface:t.elementAttr(e,"cs","typeface")}}var Xx=class extends Mn{constructor(t,n){super(t,n)}parseXml(t){this.theme=KH(t,this._package.xmlParser)}},Fb=class{},Wx=class extends Fb{constructor(){super(...arguments),this.type=Z.Footnote}},Qx=class extends Fb{constructor(){super(...arguments),this.type=Z.Endnote}},Gb=class extends Mn{constructor(t,n,i){super(t,n),this._documentParser=i}},e1=class extends Gb{constructor(t,n,i){super(t,n,i)}parseXml(t){this.notes=this._documentParser.parseNotes(t,"footnote",Wx)}},t1=class extends Gb{constructor(t,n,i){super(t,n,i)}parseXml(t){this.notes=this._documentParser.parseNotes(t,"endnote",Qx)}};function XH(e,t){var n={};for(let i of t.elements(e))switch(i.localName){case"defaultTabStop":n.defaultTabStop=t.lengthAttr(i,"val");break;case"footnotePr":n.footnoteProps=fM(i,t);break;case"endnotePr":n.endnoteProps=fM(i,t);break;case"autoHyphenation":n.autoHyphenation=t.boolAttr(i,"val");break}return n}function fM(e,t){var n={defaultNoteIds:[]};for(let i of t.elements(e))switch(i.localName){case"numFmt":n.nummeringFormat=t.attr(i,"val");break;case"footnote":case"endnote":n.defaultNoteIds.push(t.attr(i,"id"));break}return n}var n1=class extends Mn{constructor(t,n){super(t,n)}parseXml(t){this.settings=XH(t,this._package.xmlParser)}};function WH(e,t){return t.elements(e,"property").map(n=>{let i=n.firstChild;return{formatId:t.attr(n,"fmtid"),name:t.attr(n,"name"),type:i.nodeName,value:i.textContent}})}var r1=class extends Mn{parseXml(t){this.props=WH(t,this._package.xmlParser)}},i1=class extends Mn{constructor(t,n,i){super(t,n),this._documentParser=i}parseXml(t){this.comments=this._documentParser.parseComments(t),this.commentMap=io(this.comments,n=>n.id)}},a1=class extends Mn{constructor(t,n){super(t,n),this.comments=[]}parseXml(t){let n=this._package.xmlParser;for(let i of n.elements(t,"commentEx"))this.comments.push({paraId:n.attr(i,"paraId"),paraIdParent:n.attr(i,"paraIdParent"),done:n.boolAttr(i,"done")});this.commentMap=io(this.comments,i=>i.paraId)}},QH=[{type:Ut.OfficeDocument,target:"word/document.xml"},{type:Ut.ExtendedProperties,target:"docProps/app.xml"},{type:Ut.CoreProperties,target:"docProps/core.xml"},{type:Ut.CustomProperties,target:"docProps/custom.xml"}],o1=class e{constructor(){this.parts=[],this.partsMap={},this.contentTypes=[]}static async load(t,n,i){var r=new e;return r._options=i,r._parser=n,r._package=await Lx.load(t,i),r.rels=await r._package.loadRelationships(),r.contentTypes=await r._package.loadContentTypes(),await Promise.all(QH.map(a=>{let o=r.rels.find(s=>s.type===a.type)??a;return r.loadRelationshipPart(o.target,o.type)})),r}save(t="blob"){return this._package.save(t)}async loadRelationshipPart(t,n){if(this.partsMap[t])return this.partsMap[t];if(!this._package.get(t))return null;let i=null;switch(n){case Ut.OfficeDocument:this.documentPart=i=new qx(this._package,t,this._parser);break;case Ut.FontTable:this.fontTablePart=i=new Ux(this._package,t);break;case Ut.Numbering:this.numberingPart=i=new Bx(this._package,t,this._parser);break;case Ut.Styles:this.stylesPart=i=new Hx(this._package,t,this._parser);break;case Ut.Theme:this.themePart=i=new Xx(this._package,t);break;case Ut.Footnotes:this.footnotesPart=i=new e1(this._package,t,this._parser);break;case Ut.Endnotes:this.endnotesPart=i=new t1(this._package,t,this._parser);break;case Ut.Footer:i=new Gx(this._package,t,this._parser);break;case Ut.Header:i=new Fx(this._package,t,this._parser);break;case Ut.CoreProperties:this.corePropsPart=i=new Jx(this._package,t);break;case Ut.ExtendedProperties:this.extendedPropsPart=i=new Kx(this._package,t);break;case Ut.CustomProperties:i=new r1(this._package,t);break;case Ut.Settings:this.settingsPart=i=new n1(this._package,t);break;case Ut.Comments:this.commentsPart=i=new i1(this._package,t,this._parser);break;case Ut.CommentsExtended:this.commentsExtendedPart=i=new a1(this._package,t);break}if(i==null)return Promise.resolve(null);if(this.partsMap[t]=i,this.parts.push(i),await i.load(),i.rels?.length>0){let[r]=qb(i.path);await Promise.all(i.rels.map(a=>this.loadRelationshipPart(Px(a.target,r),a.type)))}return i}async loadDocumentImage(t,n){let i=this.getPathById(n??this.documentPart,t);return i?this.blobToURL(await this._package.load(i,"blob"),i):null}async loadNumberingImage(t){let n=this.getPathById(this.numberingPart,t);return n?this.blobToURL(await this._package.load(n,"blob"),n):null}async loadFont(t,n){let i=this.getPathById(this.fontTablePart,t);if(!i)return null;let r=await this._package.load(i,"uint8array");return r&&this.blobToURL(new Blob([eV(r,n)]),i)}async loadAltChunk(t,n){let i=this.getPathById(n??this.documentPart,t);return i?this._package.load(i,"string"):Promise.resolve(null)}blobToURL(t,n){if(!t)return null;if(n){let i=this.contentTypes.find(r=>r.partName===n||r.extension&&n.endsWith(`.${r.extension}`));t=i?new Blob([t],{type:i.contentType}):t}return this._options.useBase64URL?_H(t):URL.createObjectURL(t)}findPartByRelId(t,n=null){var i=(n.rels??this.rels).find(a=>a.id==t);let r=n?qb(n.path)[0]:"";return i?this.partsMap[Px(i.target,r)]:null}getPathById(t,n){let i=t.rels.find(a=>a.id==n),[r]=qb(t.path);return i?Px(i.target,r):null}};function eV(e,t){let i=t.replace(/{|}|-/g,""),r=new Array(16);for(let a=0;a<16;a++)r[16-a-1]=parseInt(i.substring(a*2,a*2+2),16);for(let a=0;a<32;a++)e[a]=e[a]^r[a%16];return e}function tV(e,t){return{type:Z.BookmarkStart,id:t.attr(e,"id"),name:t.attr(e,"name"),colFirst:t.intAttr(e,"colFirst"),colLast:t.intAttr(e,"colLast")}}function nV(e,t){return{type:Z.BookmarkEnd,id:t.attr(e,"id")}}var s1=class extends oa{constructor(){super(...arguments),this.type=Z.VmlElement,this.attrs={}}};function kM(e,t){var n=new s1;switch(e.localName){case"rect":n.tagName="rect",Object.assign(n.attrs,{width:"100%",height:"100%"});break;case"oval":n.tagName="ellipse",Object.assign(n.attrs,{cx:"50%",cy:"50%",rx:"50%",ry:"50%"});break;case"line":n.tagName="line";break;case"shape":n.tagName="g";break;case"textbox":n.tagName="foreignObject",Object.assign(n.attrs,{width:"100%",height:"100%"});break;default:return null}for(let i of N.attrs(e))switch(i.localName){case"style":n.cssStyleText=i.value;break;case"fillcolor":n.attrs.fill=i.value;break;case"from":let[r,a]=mM(i.value);Object.assign(n.attrs,{x1:r,y1:a});break;case"to":let[o,s]=mM(i.value);Object.assign(n.attrs,{x2:o,y2:s});break}for(let i of N.elements(e))switch(i.localName){case"stroke":Object.assign(n.attrs,rV(i));break;case"fill":Object.assign(n.attrs,iV());break;case"imagedata":n.tagName="image",Object.assign(n.attrs,{width:"100%",height:"100%"}),n.imageHref={id:N.attr(i,"id"),title:N.attr(i,"title")};break;case"txbxContent":n.children.push(...t.parseBodyElements(i));break;default:let r=kM(i,t);r&&n.children.push(r);break}return n}function rV(e){return{stroke:N.attr(e,"color"),"stroke-width":N.lengthAttr(e,"weight",Zt.Emu)??"1px"}}function iV(e){return{}}function mM(e){return e.split(",")}var l1=class extends oa{constructor(){super(...arguments),this.type=Z.Comment}},c1=class extends oa{constructor(t){super(),this.id=t,this.type=Z.CommentReference}},u1=class extends oa{constructor(t){super(),this.id=t,this.type=Z.CommentRangeStart}},d1=class extends oa{constructor(t){super(),this.id=t,this.type=Z.CommentRangeEnd}},Bb={shd:"inherit",color:"black",borderColor:"black",highlight:"transparent"},aV=[],pM={oMath:Z.MmlMath,oMathPara:Z.MmlMathParagraph,f:Z.MmlFraction,func:Z.MmlFunction,fName:Z.MmlFunctionName,num:Z.MmlNumerator,den:Z.MmlDenominator,rad:Z.MmlRadical,deg:Z.MmlDegree,e:Z.MmlBase,sSup:Z.MmlSuperscript,sSub:Z.MmlSubscript,sPre:Z.MmlPreSubSuper,sup:Z.MmlSuperArgument,sub:Z.MmlSubArgument,d:Z.MmlDelimiter,nary:Z.MmlNary,eqArr:Z.MmlEquationArray,lim:Z.MmlLimit,limLow:Z.MmlLimitLower,m:Z.MmlMatrix,mr:Z.MmlMatrixRow,box:Z.MmlBox,bar:Z.MmlBar,groupChr:Z.MmlGroupChar},f1=class{constructor(t){this.options={ignoreWidth:!1,debug:!1,...t}}parseNotes(t,n,i){var r=[];for(let a of N.elements(t,n)){let o=new i;o.id=N.attr(a,"id"),o.noteType=N.attr(a,"type"),o.children=this.parseBodyElements(a),r.push(o)}return r}parseComments(t){var n=[];for(let i of N.elements(t,"comment")){let r=new l1;r.id=N.attr(i,"id"),r.author=N.attr(i,"author"),r.initials=N.attr(i,"initials"),r.date=N.attr(i,"date"),r.children=this.parseBodyElements(i),n.push(r)}return n}parseDocumentFile(t){var n=N.element(t,"body"),i=N.element(t,"background"),r=N.element(n,"sectPr");return{type:Z.Document,children:this.parseBodyElements(n),props:r?_M(r,N):{},cssStyle:i?this.parseBackground(i):{}}}parseBackground(t){var n={},i=ao.colorAttr(t,"color");return i&&(n["background-color"]=i),n}parseBodyElements(t){var n=[];for(let i of N.elements(t))switch(i.localName){case"p":n.push(this.parseParagraph(i));break;case"altChunk":n.push(this.parseAltChunk(i));break;case"tbl":n.push(this.parseTable(i));break;case"sdt":n.push(...this.parseSdt(i,r=>this.parseBodyElements(r)));break}return n}parseStylesFile(t){var n=[];for(let i of N.elements(t))switch(i.localName){case"style":n.push(this.parseStyle(i));break;case"docDefaults":n.push(this.parseDefaultStyles(i));break}return n}parseDefaultStyles(t){var n={id:null,name:null,target:null,basedOn:null,styles:[]};for(let a of N.elements(t))switch(a.localName){case"rPrDefault":var i=N.element(a,"rPr");i&&n.styles.push({target:"span",values:this.parseDefaultProperties(i,{})});break;case"pPrDefault":var r=N.element(a,"pPr");r&&n.styles.push({target:"p",values:this.parseDefaultProperties(r,{})});break}return n}parseStyle(t){var n={id:N.attr(t,"styleId"),isDefault:N.boolAttr(t,"default"),name:null,target:null,basedOn:null,styles:[],linked:null};switch(N.attr(t,"type")){case"paragraph":n.target="p";break;case"table":n.target="table";break;case"character":n.target="span";break}for(let i of N.elements(t))switch(i.localName){case"basedOn":n.basedOn=N.attr(i,"val");break;case"name":n.name=N.attr(i,"val");break;case"link":n.linked=N.attr(i,"val");break;case"next":n.next=N.attr(i,"val");break;case"aliases":n.aliases=N.attr(i,"val").split(",");break;case"pPr":n.styles.push({target:"p",values:this.parseDefaultProperties(i,{})}),n.paragraphProps=wM(i,N);break;case"rPr":n.styles.push({target:"span",values:this.parseDefaultProperties(i,{})}),n.runProps=p1(i,N);break;case"tblPr":case"tcPr":n.styles.push({target:"td",values:this.parseDefaultProperties(i,{})});break;case"tblStylePr":for(let r of this.parseTableStyle(i))n.styles.push(r);break;case"rsid":case"qFormat":case"hidden":case"semiHidden":case"unhideWhenUsed":case"autoRedefine":case"uiPriority":break;default:this.options.debug&&console.warn(`DOCX: Unknown style element: ${i.localName}`)}return n}parseTableStyle(t){var n=[],i=N.attr(t,"type"),r="",a="";switch(i){case"firstRow":a=".first-row",r="tr.first-row td";break;case"lastRow":a=".last-row",r="tr.last-row td";break;case"firstCol":a=".first-col",r="td.first-col";break;case"lastCol":a=".last-col",r="td.last-col";break;case"band1Vert":a=":not(.no-vband)",r="td.odd-col";break;case"band2Vert":a=":not(.no-vband)",r="td.even-col";break;case"band1Horz":a=":not(.no-hband)",r="tr.odd-row";break;case"band2Horz":a=":not(.no-hband)",r="tr.even-row";break;default:return[]}for(let o of N.elements(t))switch(o.localName){case"pPr":n.push({target:`${r} p`,mod:a,values:this.parseDefaultProperties(o,{})});break;case"rPr":n.push({target:`${r} span`,mod:a,values:this.parseDefaultProperties(o,{})});break;case"tblPr":case"tcPr":n.push({target:r,mod:a,values:this.parseDefaultProperties(o,{})});break}return n}parseNumberingFile(t){let n=[],i=[],r=[];for(let a of N.elements(t))switch(a.localName){case"abstractNum":n.push(...this.parseAbstractNumbering(a,r));break;case"numPicBullet":r.push(this.parseNumberingPicBullet(a));break;case"num":i.push({numId:N.attr(a,"numId"),abstractNumId:N.elementAttr(a,"abstractNumId","val")});break}return i.flatMap(a=>n.filter(o=>a.abstractNumId==o.id).map(o=>({...o,id:a.numId})))}parseNumberingPicBullet(t){var n=N.element(t,"pict"),i=n&&N.element(n,"shape"),r=i&&N.element(i,"imagedata");return r?{id:N.intAttr(t,"numPicBulletId"),src:N.attr(r,"id"),style:N.attr(i,"style")}:null}parseAbstractNumbering(t,n){var i=[],r=N.attr(t,"abstractNumId");for(let a of N.elements(t))switch(a.localName){case"lvl":i.push(this.parseNumberingLevel(r,a,n));break}return i}parseNumberingLevel(t,n,i){var r={id:t,level:N.intAttr(n,"ilvl"),start:1,pStyleName:void 0,pStyle:{},rStyle:{},suff:"tab"};for(let o of N.elements(n))switch(o.localName){case"start":r.start=N.intAttr(o,"val");break;case"pPr":this.parseDefaultProperties(o,r.pStyle);break;case"rPr":this.parseDefaultProperties(o,r.rStyle);break;case"lvlPicBulletId":var a=N.intAttr(o,"val");r.bullet=i.find(s=>s?.id==a);break;case"lvlText":r.levelText=N.attr(o,"val");break;case"pStyle":r.pStyleName=N.attr(o,"val");break;case"numFmt":r.format=N.attr(o,"val");break;case"suff":r.suff=N.attr(o,"val");break}return r}parseSdt(t,n){let i=N.element(t,"sdtContent");return i?n(i):[]}parseChange(t,n,i){return{type:t,children:i(n)?.children??[],id:N.attr(n,"id"),author:N.attr(n,"author"),date:N.attr(n,"date")}}parseAltChunk(t){return{type:Z.AltChunk,children:[],id:N.attr(t,"id")}}parseParagraph(t){var n={type:Z.Paragraph,children:[]};for(let i of N.elements(t))switch(i.localName){case"pPr":this.parseParagraphProperties(i,n);break;case"r":n.children.push(this.parseRun(i,n));break;case"hyperlink":n.children.push(this.parseHyperlink(i,n));break;case"smartTag":n.children.push(this.parseSmartTag(i,n));break;case"bookmarkStart":n.children.push(tV(i,N));break;case"bookmarkEnd":n.children.push(nV(i,N));break;case"commentRangeStart":n.children.push(new u1(N.attr(i,"id")));break;case"commentRangeEnd":n.children.push(new d1(N.attr(i,"id")));break;case"oMath":case"oMathPara":n.children.push(this.parseMathElement(i));break;case"sdt":n.children.push(...this.parseSdt(i,r=>this.parseParagraph(r).children));break;case"ins":n.children.push(this.parseChange(Z.Inserted,i,r=>this.parseParagraph(r)));break;case"del":n.children.push(this.parseChange(Z.Deleted,i,r=>this.parseParagraph(r)));break}return n}parseParagraphProperties(t,n){this.parseDefaultProperties(t,n.cssStyle={},null,i=>{if($M(i,n,N))return!0;switch(i.localName){case"pStyle":n.styleName=N.attr(i,"val");break;case"cnfStyle":n.className=pt.classNameOfCnfStyle(i);break;case"framePr":this.parseFrame(i,n);break;case"rPr":break;default:return!1}return!0})}parseFrame(t,n){var i=N.attr(t,"dropCap");i=="drop"&&(n.cssStyle.float="left")}parseHyperlink(t,n){var i={type:Z.Hyperlink,parent:n,children:[]};i.anchor=N.attr(t,"anchor"),i.id=N.attr(t,"id");for(let r of N.elements(t))switch(r.localName){case"r":i.children.push(this.parseRun(r,i));break}return i}parseSmartTag(t,n){var i={type:Z.SmartTag,parent:n,children:[]},r=N.attr(t,"uri"),a=N.attr(t,"element");r&&(i.uri=r),a&&(i.element=a);for(let o of N.elements(t))switch(o.localName){case"r":i.children.push(this.parseRun(o,i));break;case"smartTag":i.children.push(this.parseSmartTag(o,i));break}return i}parseRun(t,n){var i={type:Z.Run,parent:n,children:[]};for(let r of N.elements(t))switch(r=this.checkAlternateContent(r),r.localName){case"t":i.children.push({type:Z.Text,text:r.textContent});break;case"delText":i.children.push({type:Z.DeletedText,text:r.textContent});break;case"commentReference":i.children.push(new c1(N.attr(r,"id")));break;case"fldSimple":i.children.push({type:Z.SimpleField,instruction:N.attr(r,"instr"),lock:N.boolAttr(r,"lock",!1),dirty:N.boolAttr(r,"dirty",!1)});break;case"instrText":i.fieldRun=!0,i.children.push({type:Z.Instruction,text:r.textContent});break;case"fldChar":i.fieldRun=!0,i.children.push({type:Z.ComplexField,charType:N.attr(r,"fldCharType"),lock:N.boolAttr(r,"lock",!1),dirty:N.boolAttr(r,"dirty",!1)});break;case"noBreakHyphen":i.children.push({type:Z.NoBreakHyphen});break;case"br":i.children.push({type:Z.Break,break:N.attr(r,"type")||"textWrapping"});break;case"lastRenderedPageBreak":i.children.push({type:Z.Break,break:"lastRenderedPageBreak"});break;case"sym":i.children.push({type:Z.Symbol,font:Dx(N.attr(r,"font")),char:N.hexAttr(r,"char")});break;case"tab":i.children.push({type:Z.Tab});break;case"footnoteReference":i.children.push({type:Z.FootnoteReference,id:N.attr(r,"id")});break;case"endnoteReference":i.children.push({type:Z.EndnoteReference,id:N.attr(r,"id")});break;case"drawing":let a=this.parseDrawing(r);a&&i.children.push(a);break;case"pict":i.children.push(this.parseVmlPicture(r));break;case"rPr":this.parseRunProperties(r,i);break}return i}parseMathElement(t){let n=`${t.localName}Pr`,i={type:pM[t.localName],children:[]};for(let a of N.elements(t))if(pM[a.localName])i.children.push(this.parseMathElement(a));else if(a.localName=="r"){var r=this.parseRun(a);r.type=Z.MmlRun,i.children.push(r)}else a.localName==n&&(i.props=this.parseMathProperies(a));return i}parseMathProperies(t){let n={};for(let i of N.elements(t))switch(i.localName){case"chr":n.char=N.attr(i,"val");break;case"vertJc":n.verticalJustification=N.attr(i,"val");break;case"pos":n.position=N.attr(i,"val");break;case"degHide":n.hideDegree=N.boolAttr(i,"val");break;case"begChr":n.beginChar=N.attr(i,"val");break;case"endChr":n.endChar=N.attr(i,"val");break}return n}parseRunProperties(t,n){this.parseDefaultProperties(t,n.cssStyle={},null,i=>{switch(i.localName){case"rStyle":n.styleName=N.attr(i,"val");break;case"vertAlign":n.verticalAlign=pt.valueOfVertAlign(i,!0);break;default:return!1}return!0})}parseVmlPicture(t){let n={type:Z.VmlPicture,children:[]};for(let i of N.elements(t)){let r=kM(i,this);r&&n.children.push(r)}return n}checkAlternateContent(t){if(t.localName!="AlternateContent")return t;var n=N.element(t,"Choice");if(n){var i=N.attr(n,"Requires"),r=t.lookupNamespaceURI(i);if(aV.includes(r))return n.firstElementChild}return N.element(t,"Fallback")?.firstElementChild}parseDrawing(t){for(var n of N.elements(t))switch(n.localName){case"inline":case"anchor":return this.parseDrawingWrapper(n)}}parseDrawingWrapper(t){var n={type:Z.Drawing,children:[],cssStyle:{}},i=t.localName=="anchor";let r=null,a=N.boolAttr(t,"simplePos");N.boolAttr(t,"behindDoc");let o={relative:"page",align:"left",offset:"0"},s={relative:"page",align:"top",offset:"0"};for(var l of N.elements(t))switch(l.localName){case"simplePos":a&&(o.offset=N.lengthAttr(l,"x",Zt.Emu),s.offset=N.lengthAttr(l,"y",Zt.Emu));break;case"extent":n.cssStyle.width=N.lengthAttr(l,"cx",Zt.Emu),n.cssStyle.height=N.lengthAttr(l,"cy",Zt.Emu);break;case"positionH":case"positionV":if(!a){let f=l.localName=="positionH"?o:s;var c=N.element(l,"align"),u=N.element(l,"posOffset");f.relative=N.attr(l,"relativeFrom")??f.relative,c&&(f.align=c.textContent),u&&(f.offset=yM(u.textContent,Zt.Emu))}break;case"wrapTopAndBottom":r="wrapTopAndBottom";break;case"wrapNone":r="wrapNone";break;case"graphic":var d=this.parseGraphic(l);d&&n.children.push(d);break}return r=="wrapTopAndBottom"?(n.cssStyle.display="block",o.align&&(n.cssStyle["text-align"]=o.align,n.cssStyle.width="100%")):r=="wrapNone"?(n.cssStyle.display="block",n.cssStyle.position="relative",n.cssStyle.width="0px",n.cssStyle.height="0px",o.offset&&(n.cssStyle.left=o.offset),s.offset&&(n.cssStyle.top=s.offset)):i&&(o.align=="left"||o.align=="right")&&(n.cssStyle.float=o.align),n}parseGraphic(t){var n=N.element(t,"graphicData");for(let i of N.elements(n))switch(i.localName){case"pic":return this.parsePicture(i)}return null}parsePicture(t){var n={type:Z.Image,src:"",cssStyle:{}},i=N.element(t,"blipFill"),r=N.element(i,"blip"),a=N.element(i,"srcRect");n.src=N.attr(r,"embed"),a&&(n.srcRect=[N.intAttr(a,"l",0)/1e5,N.intAttr(a,"t",0)/1e5,N.intAttr(a,"r",0)/1e5,N.intAttr(a,"b",0)/1e5]);var o=N.element(t,"spPr"),s=N.element(o,"xfrm");if(n.cssStyle.position="relative",s){n.rotation=N.intAttr(s,"rot",0)/6e4;for(var l of N.elements(s))switch(l.localName){case"ext":n.cssStyle.width=N.lengthAttr(l,"cx",Zt.Emu),n.cssStyle.height=N.lengthAttr(l,"cy",Zt.Emu);break;case"off":n.cssStyle.left=N.lengthAttr(l,"x",Zt.Emu),n.cssStyle.top=N.lengthAttr(l,"y",Zt.Emu);break}}return n}parseTable(t){var n={type:Z.Table,children:[]};for(let i of N.elements(t))switch(i.localName){case"tr":n.children.push(this.parseTableRow(i));break;case"tblGrid":n.columns=this.parseTableColumns(i);break;case"tblPr":this.parseTableProperties(i,n);break}return n}parseTableColumns(t){var n=[];for(let i of N.elements(t))switch(i.localName){case"gridCol":n.push({width:N.lengthAttr(i,"w")});break}return n}parseTableProperties(t,n){switch(n.cssStyle={},n.cellStyle={},this.parseDefaultProperties(t,n.cssStyle,n.cellStyle,i=>{switch(i.localName){case"tblStyle":n.styleName=N.attr(i,"val");break;case"tblLook":n.className=pt.classNameOftblLook(i);break;case"tblpPr":this.parseTablePosition(i,n);break;case"tblStyleColBandSize":n.colBandSize=N.intAttr(i,"val");break;case"tblStyleRowBandSize":n.rowBandSize=N.intAttr(i,"val");break;case"hidden":n.cssStyle.display="none";break;default:return!1}return!0}),n.cssStyle["text-align"]){case"center":delete n.cssStyle["text-align"],n.cssStyle["margin-left"]="auto",n.cssStyle["margin-right"]="auto";break;case"right":delete n.cssStyle["text-align"],n.cssStyle["margin-left"]="auto";break}}parseTablePosition(t,n){var i=N.lengthAttr(t,"topFromText"),r=N.lengthAttr(t,"bottomFromText"),a=N.lengthAttr(t,"rightFromText"),o=N.lengthAttr(t,"leftFromText");n.cssStyle.float="left",n.cssStyle["margin-bottom"]=pt.addSize(n.cssStyle["margin-bottom"],r),n.cssStyle["margin-left"]=pt.addSize(n.cssStyle["margin-left"],o),n.cssStyle["margin-right"]=pt.addSize(n.cssStyle["margin-right"],a),n.cssStyle["margin-top"]=pt.addSize(n.cssStyle["margin-top"],i)}parseTableRow(t){var n={type:Z.Row,children:[]};for(let i of N.elements(t))switch(i.localName){case"tc":n.children.push(this.parseTableCell(i));break;case"trPr":case"tblPrEx":this.parseTableRowProperties(i,n);break}return n}parseTableRowProperties(t,n){n.cssStyle=this.parseDefaultProperties(t,{},null,i=>{switch(i.localName){case"cnfStyle":n.className=pt.classNameOfCnfStyle(i);break;case"tblHeader":n.isHeader=N.boolAttr(i,"val");break;case"gridBefore":n.gridBefore=N.intAttr(i,"val");break;case"gridAfter":n.gridAfter=N.intAttr(i,"val");break;default:return!1}return!0})}parseTableCell(t){var n={type:Z.Cell,children:[]};for(let i of N.elements(t))switch(i.localName){case"tbl":n.children.push(this.parseTable(i));break;case"p":n.children.push(this.parseParagraph(i));break;case"tcPr":this.parseTableCellProperties(i,n);break}return n}parseTableCellProperties(t,n){n.cssStyle=this.parseDefaultProperties(t,{},null,i=>{switch(i.localName){case"gridSpan":n.span=N.intAttr(i,"val",null);break;case"vMerge":n.verticalMerge=N.attr(i,"val")??"continue";break;case"cnfStyle":n.className=pt.classNameOfCnfStyle(i);break;default:return!1}return!0}),this.parseTableCellVerticalText(t,n)}parseTableCellVerticalText(t,n){let i={btLr:{writingMode:"vertical-rl",transform:"rotate(180deg)"},lrTb:{writingMode:"vertical-lr",transform:"none"},tbRl:{writingMode:"vertical-rl",transform:"none"}};for(let r of N.elements(t))if(r.localName==="textDirection"){let a=N.attr(r,"val"),o=i[a]||{writingMode:"horizontal-tb"};n.cssStyle["writing-mode"]=o.writingMode,n.cssStyle.transform=o.transform}}parseDefaultProperties(t,n=null,i=null,r=null){n=n||{};for(let a of N.elements(t))if(!r?.(a))switch(a.localName){case"jc":n["text-align"]=pt.valueOfJc(a);break;case"textAlignment":n["vertical-align"]=pt.valueOfTextAlignment(a);break;case"color":n.color=ao.colorAttr(a,"val",null,Bb.color);break;case"sz":n["font-size"]=n["min-height"]=N.lengthAttr(a,"val",Zt.FontSize);break;case"shd":n["background-color"]=ao.colorAttr(a,"fill",null,Bb.shd);break;case"highlight":n["background-color"]=ao.colorAttr(a,"val",null,Bb.highlight);break;case"vertAlign":break;case"position":n.verticalAlign=N.lengthAttr(a,"val",Zt.FontSize);break;case"tcW":if(this.options.ignoreWidth)break;case"tblW":n.width=pt.valueOfSize(a,"w");break;case"trHeight":this.parseTrHeight(a,n);break;case"strike":n["text-decoration"]=N.boolAttr(a,"val",!0)?"line-through":"none";break;case"b":n["font-weight"]=N.boolAttr(a,"val",!0)?"bold":"normal";break;case"i":n["font-style"]=N.boolAttr(a,"val",!0)?"italic":"normal";break;case"caps":n["text-transform"]=N.boolAttr(a,"val",!0)?"uppercase":"none";break;case"smallCaps":n["font-variant"]=N.boolAttr(a,"val",!0)?"small-caps":"none";break;case"u":this.parseUnderline(a,n);break;case"ind":case"tblInd":this.parseIndentation(a,n);break;case"rFonts":this.parseFont(a,n);break;case"tblBorders":this.parseBorderProperties(a,i||n);break;case"tblCellSpacing":n["border-spacing"]=pt.valueOfMargin(a),n["border-collapse"]="separate";break;case"pBdr":this.parseBorderProperties(a,n);break;case"bdr":n.border=pt.valueOfBorder(a);break;case"tcBorders":this.parseBorderProperties(a,n);break;case"vanish":N.boolAttr(a,"val",!0)&&(n.display="none");break;case"kern":break;case"noWrap":break;case"tblCellMar":case"tcMar":this.parseMarginProperties(a,i||n);break;case"tblLayout":n["table-layout"]=pt.valueOfTblLayout(a);break;case"vAlign":n["vertical-align"]=pt.valueOfTextAlignment(a);break;case"spacing":t.localName=="pPr"&&this.parseSpacing(a,n);break;case"wordWrap":N.boolAttr(a,"val")&&(n["overflow-wrap"]="break-word");break;case"suppressAutoHyphens":n.hyphens=N.boolAttr(a,"val",!0)?"none":"auto";break;case"lang":n.$lang=N.attr(a,"val");break;case"rtl":case"bidi":N.boolAttr(a,"val",!0)&&(n.direction="rtl");break;case"bCs":case"iCs":case"szCs":case"tabs":case"outlineLvl":case"contextualSpacing":case"tblStyleColBandSize":case"tblStyleRowBandSize":case"webHidden":case"pageBreakBefore":case"suppressLineNumbers":case"keepLines":case"keepNext":case"widowControl":case"noProof":break;default:this.options.debug&&console.warn(`DOCX: Unknown document element: ${t.localName}.${a.localName}`);break}return n}parseUnderline(t,n){var i=N.attr(t,"val");if(i!=null){switch(i){case"dash":case"dashDotDotHeavy":case"dashDotHeavy":case"dashedHeavy":case"dashLong":case"dashLongHeavy":case"dotDash":case"dotDotDash":n["text-decoration"]="underline dashed";break;case"dotted":case"dottedHeavy":n["text-decoration"]="underline dotted";break;case"double":n["text-decoration"]="underline double";break;case"single":case"thick":n["text-decoration"]="underline";break;case"wave":case"wavyDouble":case"wavyHeavy":n["text-decoration"]="underline wavy";break;case"words":n["text-decoration"]="underline";break;case"none":n["text-decoration"]="none";break}var r=ao.colorAttr(t,"color");r&&(n["text-decoration-color"]=r)}}parseFont(t,n){var i=N.attr(t,"ascii"),r=pt.themeValue(t,"asciiTheme"),a=N.attr(t,"eastAsia"),o=[i,r,a].filter(s=>s).map(s=>Dx(s));o.length>0&&(n["font-family"]=[...new Set(o)].join(", "))}parseIndentation(t,n){var i=N.lengthAttr(t,"firstLine"),r=N.lengthAttr(t,"hanging"),a=N.lengthAttr(t,"left"),o=N.lengthAttr(t,"start"),s=N.lengthAttr(t,"right"),l=N.lengthAttr(t,"end");i&&(n["text-indent"]=i),r&&(n["text-indent"]=`-${r}`),(a||o)&&(n["margin-inline-start"]=a||o),(s||l)&&(n["margin-inline-end"]=s||l)}parseSpacing(t,n){var i=N.lengthAttr(t,"before"),r=N.lengthAttr(t,"after"),a=N.intAttr(t,"line",null),o=N.attr(t,"lineRule");if(i&&(n["margin-top"]=i),r&&(n["margin-bottom"]=r),a!==null)switch(o){case"auto":n["line-height"]=`${(a/240).toFixed(2)}`;break;case"atLeast":n["line-height"]=`calc(100% + ${a/20}pt)`;break;default:n["line-height"]=n["min-height"]=`${a/20}pt`;break}}parseMarginProperties(t,n){for(let i of N.elements(t))switch(i.localName){case"left":n["padding-left"]=pt.valueOfMargin(i);break;case"right":n["padding-right"]=pt.valueOfMargin(i);break;case"top":n["padding-top"]=pt.valueOfMargin(i);break;case"bottom":n["padding-bottom"]=pt.valueOfMargin(i);break}}parseTrHeight(t,n){switch(N.attr(t,"hRule")){case"exact":n.height=N.lengthAttr(t,"val");break;case"atLeast":default:n.height=N.lengthAttr(t,"val");break}}parseBorderProperties(t,n){for(let i of N.elements(t))switch(i.localName){case"start":case"left":n["border-left"]=pt.valueOfBorder(i);break;case"end":case"right":n["border-right"]=pt.valueOfBorder(i);break;case"top":n["border-top"]=pt.valueOfBorder(i);break;case"bottom":n["border-bottom"]=pt.valueOfBorder(i);break}}},oV=["black","blue","cyan","darkBlue","darkCyan","darkGray","darkGreen","darkMagenta","darkRed","darkYellow","green","lightGray","magenta","none","red","white","yellow"],ao=class{static colorAttr(t,n,i=null,r="black"){var a=N.attr(t,n);if(a)return a=="auto"?r:oV.includes(a)?a:`#${a}`;var o=N.attr(t,"themeColor");return o?`var(--docx-${o}-color)`:i}},pt=class e{static themeValue(t,n){var i=N.attr(t,n);return i?`var(--docx-${i}-font)`:null}static valueOfSize(t,n){var i=Zt.Dxa;switch(N.attr(t,"type")){case"dxa":break;case"pct":i=Zt.Percent;break;case"auto":return"auto"}return N.lengthAttr(t,n,i)}static valueOfMargin(t){return N.lengthAttr(t,"w")}static valueOfBorder(t){var n=e.parseBorderType(N.attr(t,"val"));if(n=="none")return"none";var i=ao.colorAttr(t,"color"),r=N.lengthAttr(t,"sz",Zt.Border);return`${r} ${n} ${i=="auto"?Bb.borderColor:i}`}static parseBorderType(t){switch(t){case"single":return"solid";case"dashDotStroked":return"solid";case"dashed":return"dashed";case"dashSmallGap":return"dashed";case"dotDash":return"dotted";case"dotDotDash":return"dotted";case"dotted":return"dotted";case"double":return"double";case"doubleWave":return"double";case"inset":return"inset";case"nil":return"none";case"none":return"none";case"outset":return"outset";case"thick":return"solid";case"thickThinLargeGap":return"solid";case"thickThinMediumGap":return"solid";case"thickThinSmallGap":return"solid";case"thinThickLargeGap":return"solid";case"thinThickMediumGap":return"solid";case"thinThickSmallGap":return"solid";case"thinThickThinLargeGap":return"solid";case"thinThickThinMediumGap":return"solid";case"thinThickThinSmallGap":return"solid";case"threeDEmboss":return"solid";case"threeDEngrave":return"solid";case"triple":return"double";case"wave":return"solid"}return"solid"}static valueOfTblLayout(t){var n=N.attr(t,"val");return n=="fixed"?"fixed":"auto"}static classNameOfCnfStyle(t){let n=N.attr(t,"val"),i=["first-row","last-row","first-col","last-col","odd-col","even-col","odd-row","even-row","ne-cell","nw-cell","se-cell","sw-cell"];if(n)return i.filter((a,o)=>n[o]=="1").join(" ");let r=["firstRow","lastRow","firstColumn","lastColumn","oddVBand","evenVBand","oddHBand","evenHBand","firstRowLastColumn","firstRowFirstColumn","lastRowLastColumn","lastRowFirstColumn"];return i.filter((a,o)=>N.boolAttr(t,r[o])).join(" ")}static valueOfJc(t){var n=N.attr(t,"val");switch(n){case"start":case"left":return"left";case"center":return"center";case"end":case"right":return"right";case"both":return"justify"}return n}static valueOfVertAlign(t,n=!1){var i=N.attr(t,"val");switch(i){case"subscript":return"sub";case"superscript":return n?"sup":"super"}return n?null:i}static valueOfTextAlignment(t){var n=N.attr(t,"val");switch(n){case"auto":case"baseline":return"baseline";case"top":return"top";case"center":return"middle";case"bottom":return"bottom"}return n}static addSize(t,n){return t==null?n:n==null?t:`calc(${t} + ${n})`}static classNameOftblLook(t){let n=N.hexAttr(t,"val",0),i="";return(N.boolAttr(t,"firstRow")||n&32)&&(i+=" first-row"),(N.boolAttr(t,"lastRow")||n&64)&&(i+=" last-row"),(N.boolAttr(t,"firstColumn")||n&128)&&(i+=" first-col"),(N.boolAttr(t,"lastColumn")||n&256)&&(i+=" last-col"),(N.boolAttr(t,"noHBand")||n&512)&&(i+=" no-hband"),(N.boolAttr(t,"noVBand")||n&1024)&&(i+=" no-vband"),i.trim()}},hM={pos:0,leader:"none",style:"left"},sV=50;function lV(e=document.body){let t=document.createElement("div");t.style.width="100pt",e.appendChild(t);let n=100/t.offsetWidth;return e.removeChild(t),n}function cV(e,t,n,i=72/96){let r=e.closest("p"),a=e.getBoundingClientRect(),o=r.getBoundingClientRect(),s=getComputedStyle(r),l=t?.length>0?t.map(b=>({pos:gM(b.position),leader:b.leader,style:b.style})).sort((b,S)=>b.pos-S.pos):[hM],c=l[l.length-1],u=o.width*i,d=gM(n),f=c.pos+d;if(f<u)for(;f<u&&l.length<sV;f+=d)l.push({...hM,pos:f});let m=parseFloat(s.marginLeft),p=o.left+m,h=(a.left-p)*i,_=l.find(b=>b.style!="clear"&&b.pos>h);if(_==null)return;let g=1;if(_.style=="right"||_.style=="center"){let b=Array.from(r.querySelectorAll(`.${e.className}`)),S=b.indexOf(e)+1,$=document.createRange();$.setStart(e,1),S<b.length?$.setEndBefore(b[S]):$.setEndAfter(r);let C=_.style=="center"?.5:1,z=$.getBoundingClientRect(),T=z.left+C*z.width-(o.left-m);g=_.pos-T*i}else g=_.pos-h;switch(e.innerHTML=" ",e.style.textDecoration="inherit",e.style.wordSpacing=`${g.toFixed(0)}pt`,_.leader){case"dot":case"middleDot":e.style.textDecoration="underline",e.style.textDecorationStyle="dotted";break;case"hyphen":case"heavy":case"underscore":e.style.textDecoration="underline";break}}function gM(e){return parseFloat(e)}var at;(function(e){e.html="http://www.w3.org/1999/xhtml",e.svg="http://www.w3.org/2000/svg",e.mathML="http://www.w3.org/1998/Math/MathML"})(at||(at={}));function Kb(e){if(jx(e))return document.createTextNode(e);if(e instanceof Node)return e;let{ns:t,tagName:n,className:i,style:r,children:a,...o}=e;if(n==="#fragment")return document.createDocumentFragment();if(n==="#comment")return document.createComment(a[0]);let s=t?document.createElementNS(t,n):document.createElement(n);if(i&&s.setAttribute("class",i),r&&(jx(r)?s.setAttribute("style",r):Object.assign(s.style,r)),o)for(let[l,c]of Object.entries(o))c!==void 0&&(s[l]=c);return a&&a.forEach(l=>s.appendChild(Kb(l))),s}function uV(...e){return e.filter(Boolean).join(" ")}var m1=class{constructor(){this.className="docx",this.styleMap={},this.currentPart=null,this.tableVerticalMerges=[],this.currentVerticalMerge=null,this.tableCellPositions=[],this.currentCellPosition=null,this.footnoteMap={},this.endnoteMap={},this.currentEndnoteIds=[],this.usedHederFooterParts=[],this.currentTabs=[],this.commentMap={},this.tasks=[],this.postRenderTasks=[],this.h=Kb}async render(t,n){this.document=t,this.options=n,this.className=n.className,this.rootSelector=n.inWrapper?`.${this.className}-wrapper`:":root",this.h=n.h??Kb,this.styleMap=null,this.tasks=[],this.options.renderComments&&globalThis.Highlight&&(this.commentHighlight=new Highlight);let i=[...this.renderDefaultStyle()];t.themePart&&i.push(...this.renderTheme(t.themePart)),t.stylesPart!=null&&(this.styleMap=this.processStyles(t.stylesPart.styles),i.push(...this.renderStyles(t.stylesPart.styles))),t.numberingPart&&(this.prodessNumberings(t.numberingPart.domNumberings),i.push(...await this.renderNumbering(t.numberingPart.domNumberings))),t.footnotesPart&&(this.footnoteMap=io(t.footnotesPart.notes,a=>a.id)),t.endnotesPart&&(this.endnoteMap=io(t.endnotesPart.notes,a=>a.id)),t.settingsPart&&(this.defaultTabSize=t.settingsPart.settings?.defaultTabStop),!n.ignoreFonts&&t.fontTablePart&&i.push(...await this.renderFontTable(t.fontTablePart));var r=this.renderSections(t.documentPart.body);return this.options.inWrapper?i.push(this.renderWrapper(r)):i.push(...r),this.commentHighlight&&n.renderComments&&CSS.highlights.set(`${this.className}-comments`,this.commentHighlight),this.postRenderTasks.forEach(a=>a()),await Promise.allSettled(this.tasks),this.refreshTabStops(),i}renderTheme(t){let n={},i=t.theme?.fontScheme;i&&(i.majorFont&&(n["--docx-majorHAnsi-font"]=i.majorFont.latinTypeface),i.minorFont&&(n["--docx-minorHAnsi-font"]=i.minorFont.latinTypeface));let r=t.theme?.colorScheme;if(r)for(let[o,s]of Object.entries(r.colors))n[`--docx-${o}-color`]=`#${s}`;let a=this.styleToString(`.${this.className}`,n);return[this.h({tagName:"#comment",children:["docxjs document theme values"]}),this.h({tagName:"style",children:[a]})]}async renderFontTable(t){let n=[];for(let i of t.fonts)for(let r of i.embedFontRefs)try{let a=await this.document.loadFont(r.id,r.key),o={"font-family":Dx(i.name),src:`url(${a})`};(r.type=="bold"||r.type=="boldItalic")&&(o["font-weight"]="bold"),(r.type=="italic"||r.type=="boldItalic")&&(o["font-style"]="italic"),n.push(this.h({tagName:"#comment",children:[`docxjs ${i.name} font`]})),n.push(this.h({tagName:"style",children:[this.styleToString("@font-face",o)]}))}catch{this.options.debug&&console.warn(`Can't load font with id ${r.id} and key ${r.key}`)}return n}processStyleName(t){return t?`${this.className}_${SH(t)}`:this.className}processStyles(t){let n=io(t.filter(r=>r.id!=null),r=>r.id);for(let r of t.filter(a=>a.basedOn)){var i=n[r.basedOn];if(i){r.paragraphProps=Hb(r.paragraphProps,i.paragraphProps),r.runProps=Hb(r.runProps,i.runProps);for(let a of i.styles){let o=r.styles.find(s=>s.target==a.target);o?this.copyStyleProperties(a.values,o.values):r.styles.push({...a,values:{...a.values}})}}else this.options.debug&&console.warn(`Can't find base style ${r.basedOn}`)}for(let r of t)r.cssName=this.processStyleName(r.id);return n}prodessNumberings(t){for(let n of t.filter(i=>i.pStyleName)){let i=this.findStyle(n.pStyleName);i?.paragraphProps?.numbering&&(i.paragraphProps.numbering.level=n.level)}}processElement(t){if(t.children)for(var n of t.children)n.parent=t,n.type==Z.Table?this.processTable(n):this.processElement(n)}processTable(t){for(var n of t.children)for(var i of n.children)i.cssStyle=this.copyStyleProperties(t.cellStyle,i.cssStyle,["border-left","border-right","border-top","border-bottom","padding-left","padding-right","padding-top","padding-bottom"]),this.processElement(i)}copyStyleProperties(t,n,i=null){if(!t)return n;n==null&&(n={}),i==null&&(i=Object.getOwnPropertyNames(t));for(var r of i)t.hasOwnProperty(r)&&!n.hasOwnProperty(r)&&(n[r]=t[r]);return n}createPageElement(t,n,i){let r={...i};return n&&(n.pageMargins&&(r.paddingLeft=n.pageMargins.left,r.paddingRight=n.pageMargins.right,r.paddingTop=n.pageMargins.top,r.paddingBottom=n.pageMargins.bottom),n.pageSize&&(this.options.ignoreWidth||(r.width=n.pageSize.width),this.options.ignoreHeight||(r.minHeight=n.pageSize.height))),this.h({tagName:"section",className:t,style:r})}createSectionContent(t){let n={};return t.columns&&t.columns.numberOfColumns&&(n.columnCount=`${t.columns.numberOfColumns}`,n.columnGap=t.columns.space,t.columns.separator&&(n.columnRule="1px solid black")),this.h({tagName:"article",style:n})}renderSections(t){let n=[];this.processElement(t);let i=this.splitBySection(t.children,t.props),r=this.groupByPageBreaks(i),a=null;for(let s=0,l=r.length;s<l;s++){this.currentFootnoteIds=[];let u=r[s][0].sectProps,d=this.createPageElement(this.className,u,t.cssStyle);this.options.renderHeaders&&this.renderHeaderFooter(u.headerRefs,u,n.length,a!=u,d);for(let f of r[s]){var o=this.createSectionContent(f.sectProps);this.renderElements(f.elements,o),d.appendChild(o),u=f.sectProps}if(this.options.renderFootnotes){let f=this.renderNotes(this.currentFootnoteIds,this.footnoteMap);f&&d.appendChild(f)}if(this.options.renderEndnotes&&s==l-1){let f=this.renderNotes(this.currentEndnoteIds,this.endnoteMap);f&&d.appendChild(f)}this.options.renderFooters&&this.renderHeaderFooter(u.footerRefs,u,n.length,a!=u,d),n.push(d),a=u}return n}renderHeaderFooter(t,n,i,r,a){if(t){var o=(n.titlePage&&r?t.find(l=>l.type=="first"):null)??(i%2==1?t.find(l=>l.type=="even"):null)??t.find(l=>l.type=="default"),s=o&&this.document.findPartByRelId(o.id,this.document.documentPart);if(s){this.currentPart=s,this.usedHederFooterParts.includes(s.path)||(this.processElement(s.rootElement),this.usedHederFooterParts.push(s.path));let[l]=this.renderElements([s.rootElement],a);n?.pageMargins&&(s.rootElement.type===Z.Header?(l.style.marginTop=`calc(${n.pageMargins.header} - ${n.pageMargins.top})`,l.style.minHeight=`calc(${n.pageMargins.top} - ${n.pageMargins.header})`):s.rootElement.type===Z.Footer&&(l.style.marginBottom=`calc(${n.pageMargins.footer} - ${n.pageMargins.bottom})`,l.style.minHeight=`calc(${n.pageMargins.bottom} - ${n.pageMargins.footer})`)),this.currentPart=null}}}isPageBreakElement(t){return t.type!=Z.Break?!1:t.break=="lastRenderedPageBreak"?!this.options.ignoreLastRenderedPageBreak:t.break=="page"}isPageBreakSection(t,n){return!t||!n?!1:t.pageSize?.orientation!=n.pageSize?.orientation||t.pageSize?.width!=n.pageSize?.width||t.pageSize?.height!=n.pageSize?.height}splitBySection(t,n){var i={sectProps:null,elements:[],pageBreak:!1},r=[i];for(let d of t)if(d.type==Z.Paragraph&&this.findStyle(d.styleName)?.paragraphProps?.pageBreakBefore&&(i.sectProps=a,i.pageBreak=!0,i={sectProps:null,elements:[],pageBreak:!1},r.push(i)),i.elements.push(d),d.type==Z.Paragraph){let f=d;var a=f.sectionProps,o=-1,s=-1;if(this.options.breakPages&&f.children&&(o=f.children.findIndex(m=>(s=m.children?.findIndex(this.isPageBreakElement.bind(this))??-1,s!=-1))),(a||o!=-1)&&(i.sectProps=a,i.pageBreak=o!=-1,i={sectProps:null,elements:[],pageBreak:!1},r.push(i)),o!=-1){let m=f.children[o],p=s<m.children.length-1;if(o<f.children.length-1||p){var l=d.children,c={...d,children:l.slice(o)};if(d.children=l.slice(0,o),i.elements.push(c),p){let h=m.children,_={...m,children:h.slice(0,s)};d.children.push(_),m.children=h.slice(s)}}}}let u=null;for(let d=r.length-1;d>=0;d--)r[d].sectProps==null?r[d].sectProps=u??n:u=r[d].sectProps;return r}groupByPageBreaks(t){let n=[],i,r=[n];for(let a of t)n.push(a),(this.options.ignoreLastRenderedPageBreak||a.pageBreak||this.isPageBreakSection(i,a.sectProps))&&r.push(n=[]),i=a.sectProps;return r.filter(a=>a.length>0)}renderWrapper(t){return this.h({tagName:"div",className:`${this.className}-wrapper`,children:t})}renderDefaultStyle(){var t=this.className,n=`
|
|
109
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:R.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:R.string().optional().describe("User's timezone in IANA format."),userAgent:R.string().optional().describe("Host application identifier."),platform:R.union([R.literal("web"),R.literal("desktop"),R.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:R.object({touch:R.boolean().optional().describe("Whether the device supports touch input."),hover:R.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:R.object({top:R.number().describe("Top safe area inset in pixels."),right:R.number().describe("Right safe area inset in pixels."),bottom:R.number().describe("Bottom safe area inset in pixels."),left:R.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),JB=R.object({method:R.literal("ui/notifications/host-context-changed"),params:uP.describe("Partial context update containing only changed fields.")}),wG=R.object({method:R.literal("ui/update-model-context"),params:R.object({content:R.array(yi).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:R.record(R.string(),R.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),$G=R.object({method:R.literal("ui/initialize"),params:R.object({appInfo:vi.describe("App identification (name and version)."),appCapabilities:ZB.describe("Features and capabilities this app provides."),protocolVersion:R.string().describe("Protocol version this app supports.")})}),YB=R.object({protocolVersion:R.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:vi.describe("Host application identification and version."),hostCapabilities:VB.describe("Features and capabilities provided by the host."),hostContext:uP.describe("Rich context about the host environment.")}).passthrough(),XB={target:"draft-2020-12"};async function lP(e,t){let n=e["~standard"];if(n.jsonSchema)return n.jsonSchema[t](XB);throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function cP(e,t,n=""){let i=await e["~standard"].validate(t);if(i.issues){let r=i.issues.map(a=>{let o=a.path?.map(s=>typeof s=="object"?s.key:s).join(".");return o?`${o}: ${a.message}`:a.message}).join("; ");throw Error(n+r)}return i.value}function dP(e,t=document.documentElement){for(let[n,i]of Object.entries(e))i!==void 0&&t.style.setProperty(n,i)}function WB(e,t){let n={...e,...t};return t.experimental!==void 0&&(n.experimental={...e.experimental,...t.experimental}),t.tools!==void 0&&(n.tools={...e.tools,...t.tools}),n}var Tb=class e extends _x{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new wx;_methods=new $x;setRequestHandler=(...t)=>{let[n,...i]=oP("request",t)??t;this._methods.claim(n,"setRequestHandler"),super.setRequestHandler.call(this,n,...i)};setNotificationHandler=(...t)=>{let[n,...i]=oP("notification",t)??t;this._methods.claim(n,"setNotificationHandler"),super.setNotificationHandler.call(this,n,...i)};removeRequestHandler=t=>{this._methods.release(t),super.removeRequestHandler(t)};removeNotificationHandler=t=>{this._methods.release(t),super.removeNotificationHandler(t)};replaceRequestHandler=(t,...n)=>{this._methods.replace(t),super.setRequestHandler.call(this,t,...n)};_assertInitialized(t){if(this._initializedSent)return;let n=`[ext-apps] App.${t}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(n);console.warn(`${n}. This will throw in a future release.`)}eventSchemas={toolinput:DB,toolinputpartial:jB,toolresult:KB,toolcancelled:UB,hostcontextchanged:JB};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(t){if(!e.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let n=`[ext-apps] "${String(t)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(t,n){n&&this._assertHandlerTiming(t),this._ensureEventSlot(t),this._events.setHandler(t,n)}addEventListener(t,n){this._assertHandlerTiming(t),this._ensureEventSlot(t),this._events.addEventListener(t,n)}removeEventListener(t,n){this._events.removeEventListener(t,n)}_ensureEventSlot(t){if(this._registeredEvents.has(t))return;let n=this.eventSchemas[t];if(!n)throw Error(`Unknown event: ${String(t)}`);this.setNotificationHandler(n.shape.method.value,{params:n.shape.params},i=>{let r=i;t==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...r}),this._events.dispatch(t,r)}),this._registeredEvents.add(t)}getEventHandler(t){return this._events.getHandler(t)}warnIfRequestHandlerReplaced(t,n,i){n&&i&&console.warn(`[MCP Apps] ${t} handler replaced. Previous handler will no longer be called.`)}constructor(t,n={},i={autoResize:!0}){super(i),this._appInfo=t,this._appCapabilities=n,this.options=i,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),!i.allowUnsafeEval&&R.config({jitless:!0}),this.replaceRequestHandler("ping",r=>(console.log("Received ping:",r.params),{})),this.setEventHandler("hostcontextchanged",void 0)}buildContext(t){return t}registerAppCapabilities(t){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._appCapabilities=WB(this._appCapabilities,t)}registerTool(t,n,i){if(this._registeredTools[t])throw Error(`Tool ${t} is already registered`);let r=this,a=()=>{r._initializedSent&&r._appCapabilities.tools?.listChanged&&r.sendToolListChanged()},o=n.inputSchema!==void 0,s={title:n.title,description:n.description,inputSchema:n.inputSchema,outputSchema:n.outputSchema,annotations:n.annotations,_meta:n._meta,enabled:!0,enable(){this.enabled=!0,a()},disable(){this.enabled=!1,a()},update(l){Object.assign(this,l),a()},remove(){r._registeredTools[t]===s&&(delete r._registeredTools[t],a())},handler:async(l,c)=>{if(!s.enabled)throw Error(`Tool ${t} is disabled`);let u;if(o){let d=s.inputSchema,f=d?await cP(d,l??{},`Invalid input for tool ${t}: `):l??{};u=await i(f,c)}else u=await i(c);return s.outputSchema&&!u.isError&&(u.structuredContent=await cP(s.outputSchema,u.structuredContent,`Invalid output for tool ${t}: `)),u}};return this._registeredTools[t]=s,!this._appCapabilities.tools&&!this.transport&&this.registerAppCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),a(),s}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(t,n)=>{let i=this._registeredTools[t.name];if(!i)throw Error(`Tool ${t.name} not found`);return i.handler(t.arguments,n)},this.onlisttools=async(t,n)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([i,r])=>r.enabled).map(async([i,r])=>{let a={name:i,title:r.title,description:r.description,inputSchema:r.inputSchema?await lP(r.inputSchema,"input"):{type:"object",properties:{}}};return r.outputSchema&&(a.outputSchema=await lP(r.outputSchema,"output")),r.annotations&&(a.annotations=r.annotations),r._meta&&(a._meta=r._meta),a}))}))}async sendToolListChanged(t={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:t})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(t){this.setEventHandler("toolinput",t)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(t){this.setEventHandler("toolinputpartial",t)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(t){this.setEventHandler("toolresult",t)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(t){this.setEventHandler("toolcancelled",t)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(t){this.setEventHandler("hostcontextchanged",t)}_onteardown;get onteardown(){return this._onteardown}set onteardown(t){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,t),this._onteardown=t,this.replaceRequestHandler("ui/resource-teardown",{params:BB.shape.params,result:HB},(n,i)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(n,i)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(t){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,t),this._oncalltool=t,this.replaceRequestHandler("tools/call",(n,i)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,i)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(t){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,t),this._onlisttools=t,this.replaceRequestHandler("tools/list",(n,i)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(n.params,i)})}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${t})`);break}}assertRequestHandlerCapability(t){switch(t){case"tools/call":case"tools/list":if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${t})`);return;default:return}}assertNotificationCapability(t){}async callServerTool(t,n){if(this._assertInitialized("callServerTool"),typeof t=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${t}"). Did you mean: callServerTool({ name: "${t}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:t},{onprogress:()=>{},resetTimeoutOnProgress:!0,...n})}async readServerResource(t,n){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:t},n)}async listServerResources(t,n){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:t},n)}async createSamplingMessage(t,n){return this._assertInitialized("createSamplingMessage"),await this.request({method:"sampling/createMessage",params:t},n)}sendMessage(t,n){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:t},MB,n)}sendLog(t){return this.notification({method:"notifications/message",params:t})}updateModelContext(t,n){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:t},eo,n)}openLink(t,n){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:t},AB,n)}sendOpenLink=this.openLink;downloadFile(t,n){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:t},PB,n)}requestTeardown(t={}){return this.notification({method:"ui/notifications/request-teardown",params:t})}requestDisplayMode(t,n){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:t},FB,n)}sendSizeChanged(t){return this.notification({method:"ui/notifications/size-changed",params:t})}setupSizeChangedNotifications(){let t=!1,n=0,i=0,r=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let o=document.documentElement,s=o.style.height;o.style.height="max-content";let l=Math.ceil(o.getBoundingClientRect().height);o.style.height=s;let c=Math.ceil(window.innerWidth);(c!==n||l!==i)&&(n=c,i=l,this.sendSizeChanged({width:c,height:l}))}))};r();let a=new ResizeObserver(r);return a.observe(document.documentElement),a.observe(document.body),()=>a.disconnect()}async connect(t=new Dm(window.parent,window.parent),n){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1;try{await super.connect(t);let i=await this.request({method:"ui/initialize",params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:EB}},YB,n);if(i===void 0)throw Error(`Server sent invalid initialize result: ${i}`);this._hostCapabilities=i.hostCapabilities,this._hostInfo=i.hostInfo,this._hostContext=i.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(i){throw this.close(),i}}};var zt={name:"documents",version:"0.2.1",title:{en:"Documents","zh-CN":"Word \u6587\u6863"},kinds:["docx"]};var fP=zt.version,mP=zt.name,IG=zt.name,NG=`ui://${zt.name}/panel.html`,QB=`ui://${zt.name}/assets/`,pP=`ui://${zt.name}/file/`;var ei=zt.kinds,Lm=100*1024*1024,OG=512*1024*1024,xx=4*1024*1024,AG=24*1024,Um=class extends Error{constructor(n,i){super(i);this.code=n;this.name="OfficeError"}};function qm(e){let t=e.toLowerCase().match(/\.([a-z]+)$/)?.[1];return ei.includes(t??"")?t:null}var eH={en:{sep:", ",and:" and ",or:" or "},"zh-CN":{sep:"\u3001",and:"\u548C",or:"\u6216"}};function Mr(e,t="en",n="and"){let i=eH[t];if(e.length<2)return e.join("");let r=e[e.length-1],a=t==="zh-CN"&&/^[\x20-\x7e]/.test(r)?` ${i[n]} `:i[n];return`${e.slice(0,-1).join(i.sep)}${a}${r}`}function ps(e="en",t="and"){return Mr(ei.map(n=>`.${n}`),e,t)}var _i=(e,t)=>new Um("invalid_anchor",`Cannot read location "${e}". ${t}`),wi={docx:"Use p:N, p:N-M, t:N or t:N/rRcC.",pptx:"Use slide:N, slide:N-M or slide:N/shape:ID.",pdf:"Use page:N or page:N-M.",xlsx:"Use Sheet, Sheet!A1 or Sheet!A1:C9 (quote names with spaces: 'My sheet'!A1)."};function Rx(e,t,n){if(!t)throw _i(e,wi[n]);let i=Number(t[1]),r=t[2]===void 0?i:Number(t[2]);if(!(i>=1)||!(r>=i)||r>1e6)throw _i(e,wi[n]);return{from:i,to:r}}function hP(e){let t=/^\$?([A-Za-z]{1,3})\$?(\d{1,7})$/.exec(e);if(!t)return null;let n=0;for(let r of t[1].toUpperCase())n=n*26+(r.charCodeAt(0)-64);let i=Number(t[2]);return i<1||i>1048576||n>16384?null:{row:i,col:n}}function tH(e){let t,n;if(e.startsWith("'")){let s=1;for(t="";s<e.length;s++)if(e[s]==="'")if(e[s+1]==="'")t+="'",s++;else break;else t+=e[s];if(s>=e.length||(n=e.slice(s+1),n&&!n.startsWith("!")))throw _i(e,wi.xlsx);n=n.slice(1)}else{let s=e.lastIndexOf("!");t=s<0?e:e.slice(0,s),n=s<0?"":e.slice(s+1)}if(!t||t.length>64)throw _i(e,wi.xlsx);if(!n)return{kind:"xlsx",sheet:t};let[i,r=i]=n.split(":"),a=hP(i),o=hP(r);if(!a||!o)throw _i(e,wi.xlsx);return{kind:"xlsx",sheet:t,range:{start:{row:Math.min(a.row,o.row),col:Math.min(a.col,o.col)},end:{row:Math.max(a.row,o.row),col:Math.max(a.col,o.col)}}}}function gP(e,t){let n=t.trim();if(!n||n.length>300)throw _i(t,wi[e]);switch(e){case"docx":{let i=/^t:(\d+)(?:\/r(\d+)c(\d+))?$/i.exec(n);if(i){let r=Number(i[1]);if(r<1)throw _i(n,wi.docx);if(i[2]===void 0)return{kind:e,type:"table",table:r};let a={row:Number(i[2]),col:Number(i[3])};if(a.row<1||a.col<1)throw _i(n,wi.docx);return{kind:e,type:"table",table:r,cell:a}}return{kind:e,type:"paragraph",...Rx(n,/^p:(\d+)(?:-(?:p:)?(\d+))?$/i.exec(n),e)}}case"pptx":{let i=/^slide:(\d+)\/shape:([\w-]{1,32})$/i.exec(n);if(i){let r=Number(i[1]);if(r<1)throw _i(n,wi.pptx);return{kind:e,from:r,to:r,shape:i[2]}}return{kind:e,...Rx(n,/^slide:(\d+)(?:-(?:slide:)?(\d+))?$/i.exec(n),e)}}case"pdf":return{kind:e,...Rx(n,/^page:(\d+)(?:-(?:page:)?(\d+))?$/i.exec(n),e)};case"xlsx":return tH(n)}}function vP(e){let t=/^(.*?\.(?:docx|xlsx|pptx|pdf))(?:#(.*))?$/i.exec(e.trim());if(!t)throw new Um("invalid_anchor",`"${e}" is not a document anchor. Use <path>.docx|.xlsx|.pptx|.pdf optionally followed by #<location>.`);return{path:t[1],at:t[2]?.trim()?t[2].trim():null}}function Bm(e,t){return t?`${e}#${t}`:e}var bP=e=>e>=55296&&e<=56319,yP=e=>e>=56320&&e<=57343;function Cb(e,t,n=e.length){let i=Math.max(0,Math.min(t,e.length)),r=Math.max(i,Math.min(n,e.length));return i>0&&yP(e.charCodeAt(i))&&bP(e.charCodeAt(i-1))&&i--,r<e.length&&yP(e.charCodeAt(r))&&bP(e.charCodeAt(r-1))&&r--,e.slice(i,r)}var nH=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,Ib=e=>e.replace(nH,"\uFFFD");function Eb(e){return typeof e=="string"?Ib(e):Array.isArray(e)?e.map(t=>Eb(t)):e&&typeof e=="object"&&Object.getPrototypeOf(e)===Object.prototype?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Eb(n)])):e}var SP=`${zt.name}:windows:v1`,rH=128;function _P(e){try{let t=JSON.parse(e.getItem(SP)??"{}");return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function Tx(e,t){let n=_P(e)[t];return!n||typeof n!="object"?{}:{...typeof n.path=="string"?{path:n.path}:{},...Array.isArray(n.recent)?{recent:n.recent.filter(i=>typeof i?.path=="string"&&qm(i.path)===i.kind)}:{}}}function wP(e,t,n){try{let i=_P(e),r={...Tx(e,t),...n};delete i[t],i[t]=r;for(let a of Object.keys(i).slice(0,-rH))delete i[a];e.setItem(SP,JSON.stringify(i))}catch{}}var kc=e=>e.filter(([t])=>ei.includes(t)).map(([,t])=>t),iH={docx:"Word",xlsx:"Excel",pptx:"PowerPoint",pdf:"PDF"},$P=ei.filter(e=>e!=="pdf"),zP=[...$P.length===3?["Office"]:$P.map(e=>iH[e]),...ei.includes("pdf")?["PDF"]:[]],Hm=zt.title.en,VG=(()=>{let e=Mr(zP,"en","or");return`${/^[AEIOU]/.test(e)?"an":"a"} ${e} file`})(),ZG=`${Mr(zP)} files`,FG=ps("en","or"),GG=kc([["docx","report.docx#p:12"],["xlsx","model.xlsx#Revenue!B2:F9"],["pptx","deck.pptx#slide:3"],["pdf","paper.pdf#page:5"]]).join(", "),KG=kc([["docx","p:12"],["pptx","slide:3"],["pdf","page:5"],["xlsx","Revenue!B2:F9"]]).join(", "),JG=kc([["docx","Word paragraphs and tables (markdown)"],["xlsx","spreadsheet cells as a grid with formulas"],["pptx","slides with their shapes and speaker notes"],["pdf","PDF page text"]]).join(", "),YG=Mr(kc([["docx","paragraph"],["xlsx","cell range"],["pptx","slide"],["pptx","shape"],["pdf","page"]]),"en","or"),XG=Mr(kc([["pdf","PDF pages"],["docx","long paragraphs"]]))||"long passages",kP=Mr(kc([["pptx","deck.pptx#slide:3"],["pdf","paper.pdf#page:2"],["docx","report.docx#p:12"],["xlsx","model.xlsx#Revenue!A1:H30"]]),"en","or");var xP=[{name:"capture_view",title:`Capture ${Hm} view`,description:`Take a picture of a rendered document location in the ${Hm} panel so you can see layout, charts, images and formatting that text extraction misses. Pass an anchor such as ${kP} (the document must be open in the panel; call open_document first), or omit it to capture what the user currently sees.`,inputSchema:{type:"object",properties:{anchor:{type:"string",maxLength:1200,description:"Location to capture; defaults to the visible view."},maxWidth:{type:"integer",minimum:320,maximum:2e3,description:"Maximum image width in pixels (default 1600)."}},additionalProperties:!1},annotations:{readOnlyHint:!0,idempotentHint:!0}}];function aH(){let e=crypto.randomUUID(),t=()=>n.getHostCapabilities()?.experimental?.["zcode/surface"]?.stateKey??e,n=new Tb({name:mP,version:fP},{tools:{listChanged:!0},availableDisplayModes:["inline","fullscreen"]},{autoResize:!1}),i=[],r=new Map,a=new Set,o,s=c=>void window.dispatchEvent(new Event(`office:${c}`));return n.ontoolresult=c=>{i.push(c),i.length>20&&i.shift(),s("toolresult")},n.onhostcontextchanged=()=>s("hostchange"),n.onlisttools=async()=>({tools:xP}),n.oncalltool=async(c,u)=>{if(!xP.some(d=>d.name===c.name))return{isError:!0,content:[{type:"text",text:`The ${Hm} page has no tool ${c.name}.`}]};try{let d=Date.now()+2e4;for(;!r.has(c.name)&&Date.now()<d;)await new Promise(p=>{let h=()=>(a.delete(h),p());a.add(h),setTimeout(h,500)});let f=r.get(c.name);if(!f)throw new Error(`The ${Hm} panel is still loading; try again in a moment.`);let m=u;return await f(c.arguments??{},m.mcpReq?.signal??m.signal)}catch(d){return{isError:!0,content:[{type:"text",text:d instanceof Error?d.message:String(d)}]}}},window.addEventListener("pagehide",()=>{n.callServerTool({name:"release_view",arguments:{viewId:t()}}).catch(()=>{})}),{app:n,get viewId(){return t()},ready:()=>o??=n.connect(new Dm(window.parent,window.parent)).then(()=>s("hostchange")),readWindow(){let c=n.getHostCapabilities()?.experimental?.["zcode/surface"];if(!c?.stateKey)return{};try{return Tx(localStorage,c.stateKey)}catch{return{}}},saveWindow(c){let u=n.getHostCapabilities()?.experimental?.["zcode/surface"];if(u?.stateKey)try{wP(localStorage,u.stateKey,c)}catch{}},readDocument(){return this.readWindow().path??null},saveDocument(c){this.saveWindow({path:c})},takeResults:()=>i.splice(0,i.length),handleTool(c,u){r.set(c,u);for(let d of a)d()},get context(){return n.getHostContext()},get capabilities(){return n.getHostCapabilities()}}}function Dr(){return window.__officeHost??=aH()}async function oH(e){let t=Dr();await t.ready();let i=(await t.app.readServerResource({uri:e})).contents[0];if(!i)throw new Error(`Empty resource ${e}`);return i}function sH(e){let t=atob(e),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n}async function RP(e,t){let n=new Uint8Array(e.bytes),i=0;for(let r=0;r<e.chunks;r++){t?.throwIfAborted();let a=await oH(`${pP}${e.token}/${r}`);if(typeof a.blob!="string")throw new Error("File chunk is not binary");let o=sH(a.blob);n.set(o,i),i+=o.byteLength}if(i!==e.bytes)throw new Error("The file changed while it was loading; reload it.");return n.buffer}var Nb=ht(ir(),1);var Vm=class extends Error{constructor(n,i){super(n);this.code=i;this.name="CallError"}};async function $i(e,t={}){let n=Dr();await n.ready();let i=await n.app.callServerTool({name:e,arguments:t}),r=i.structuredContent,a=r?.error;if(i.isError||a){let o=i.content?.[0]?.text;throw new Vm(a?.message??o??`${e} failed`,a?.code)}return r}var hs=e=>e.slice(e.lastIndexOf("/")+1),TP=e=>{let t=e.lastIndexOf("/");return t>0?e.slice(0,t):""};async function EP(e){let{id:t}=await $i("begin_file_import",{name:e.name,size:e.size});try{for(let i=0;i<e.size;i+=xx){let r=await new Promise((a,o)=>{let s=new FileReader;s.onload=()=>a(String(s.result).split(",")[1]),s.onerror=()=>o(s.error),s.readAsDataURL(e.slice(i,i+xx))});await $i("write_file_import",{id:t,offset:i,data:r})}return(await $i("finish_file_import",{id:t})).path}catch(n){throw await $i("cancel_file_import",{id:t}).catch(()=>{}),n}}var Ob=(e,t)=>e.length>t?`${Cb(e,0,t-1)}\u2026`:e;function Ex(){return Dr().readWindow().recent??[]}function CP(e){Dr().saveWindow({recent:e})}function Zm(e,t,n){let i=t instanceof Vm?t.code:t?.name==="PasswordException"?"password":void 0,[r,a]=i&&e.errors[i]||e.errors.generic,o=t instanceof Error?t.message:String(t);return{path:n,title:r,detail:a||o}}function IP(){let[,e]=(0,Nb.useState)(0);return(0,Nb.useEffect)(()=>{let t=()=>e(n=>n+1);return window.addEventListener("office:hostchange",t),()=>window.removeEventListener("office:hostchange",t)},[]),Dr().context}var lH={docx:"Word",xlsx:"Excel",pptx:"PowerPoint",pdf:"PDF"},OP=ei.map(e=>lH[e]),xc=e=>ei.includes(e),NP=xc("docx")||xc("pdf"),AP={en:`any ${Mr([...NP?["passage"]:[],...xc("xlsx")?["cell"]:[],...xc("pptx")?["slide"]:[]],"en","or")}`,zh:Mr([...NP?["\u6BB5\u843D"]:[],...xc("xlsx")?["\u5355\u5143\u683C"]:[],...xc("pptx")?["\u5E7B\u706F\u7247"]:[]],"zh-CN","or")},Cx=zt.title["zh-CN"].replace(/[\x20-\x7e]$/,"$& "),cH={title:zt.title.en,openTitle:"Open a document",openFile:"Open file",emptyTitle:`Open your ${Mr(OP)} file`,emptyDescription:`Read alongside your conversation and discuss ${AP.en}.`,emptyCaption:`Choose a local file \xB7 ${ps("en","or")}`,importing:"Importing\u2026",importTooLarge:`Choose a file no larger than ${Lm/1024/1024} MiB.`,recent:"Recent",switchDocument:"Switch document",pagesAndOutline:"Pages and outline",outlineOnly:"Outline",pages:"Pages",slides:"Slides",outline:"Outline",find:"Find",findPlaceholder:"Find in document",findCount:(e,t)=>`${e} of ${t}`,noResults:"No results",previousMatch:"Previous match (\u21E7Enter)",nextMatch:"Next match (Enter)",closeFind:"Close (Esc)",more:"More",fitWidth:"Fit width",fitPage:"Fit page",actualSize:"Actual size",reload:"Reload from disk",previousPage:"Previous page",nextPage:"Next page",pageNumber:"Page number",ofPages:e=>`of ${e}`,zoomIn:"Zoom in (\u2318+)",zoomOut:"Zoom out (\u2318\u2212)",fit:"Fit",addToChat:"Add to chat",addShort:"Add",addToChatHint:"Attach this to your next message (\u2318/Ctrl+Enter)",added:"Added to chat",ask:"Ask",askPlaceholder:"Ask about this\u2026",send:"Send",cancel:"Cancel",sendKey:"send",cancelKey:"cancel",copy:"Copy",copied:"Copied",agent:"Agent",agentOf:(e,t)=>`Agent \xB7 ${e} of ${t}`,nextTarget:"Next",moreOn:(e,t)=>e===1?`1 more on ${t}`:`${e} more`,close:"Close",changed:"This file changed on disk.",reloadShort:"Reload",dismiss:"Dismiss",openAnother:"Open another file",sidePanel:"Open in side panel",meta:{pdf:e=>e===1?"1 page":`${e} pages`,pptx:e=>e===1?"1 slide":`${e} slides`,xlsx:e=>e===1?"1 sheet":`${e} sheets`,docx:e=>""},errors:{generic:["Couldn\u2019t open this document",""],password:["This PDF is password protected",`${zt.title.en} can\u2019t open encrypted files yet.`],not_found:["This file no longer exists","It may have been moved or deleted."],file_too_large:["This file is too large to open",""],corrupt_file:["This file appears to be damaged",`${zt.title.en} couldn\u2019t read its contents.`],unsupported_type:["This kind of file isn\u2019t supported",`${zt.title.en} opens ${ps()} files.`],path_outside_workspace:["This file is outside the workspace",""]},sendFailed:"The message was not sent.",contextFailed:"ZCode did not accept the reference.",where:{page:e=>`Page ${e}`,pages:(e,t)=>`Pages ${e}\u2013${t}`,pageLower:e=>`page ${e}`,slide:e=>`Slide ${e}`,slides:(e,t)=>`Slides ${e}\u2013${t}`,slideLower:e=>`slide ${e}`,shape:e=>`Slide ${e} \xB7 Shape`,paragraph:e=>`Paragraph ${e}`,paragraphs:(e,t)=>`Paragraphs ${e}\u2013${t}`,paragraphLower:e=>`paragraph ${e}`,table:e=>`Table ${e}`,cell:(e,t,n)=>`Table ${e} \xB7 R${t}C${n}`}},uH={title:zt.title["zh-CN"],openTitle:"\u6253\u5F00\u6587\u6863",openFile:"\u6253\u5F00\u6587\u4EF6",emptyTitle:`\u6253\u5F00\u4F60\u7684 ${Mr(OP,"zh-CN")} \u6587\u4EF6`,emptyDescription:`\u8FB9\u770B\u8FB9\u804A\uFF0C\u9009\u4E2D${AP.zh}\u5373\u53EF\u5E26\u5165\u5BF9\u8BDD\u3002`,emptyCaption:`\u9009\u62E9\u672C\u5730\u6587\u4EF6 \xB7 ${ps("zh-CN","or")}`,importing:"\u6B63\u5728\u5BFC\u5165\u2026",importTooLarge:`\u8BF7\u9009\u62E9\u4E0D\u8D85\u8FC7 ${Lm/1024/1024} MiB \u7684\u6587\u4EF6\u3002`,recent:"\u6700\u8FD1",switchDocument:"\u5207\u6362\u6587\u6863",pagesAndOutline:"\u9875\u9762\u4E0E\u76EE\u5F55",outlineOnly:"\u76EE\u5F55",pages:"\u9875\u9762",slides:"\u5E7B\u706F\u7247",outline:"\u76EE\u5F55",find:"\u67E5\u627E",findPlaceholder:"\u5728\u6587\u6863\u4E2D\u67E5\u627E",findCount:(e,t)=>`${e} / ${t}`,noResults:"\u65E0\u7ED3\u679C",previousMatch:"\u4E0A\u4E00\u4E2A\uFF08\u21E7Enter\uFF09",nextMatch:"\u4E0B\u4E00\u4E2A\uFF08Enter\uFF09",closeFind:"\u5173\u95ED\uFF08Esc\uFF09",more:"\u66F4\u591A",fitWidth:"\u9002\u5E94\u5BBD\u5EA6",fitPage:"\u9002\u5E94\u9875\u9762",actualSize:"\u5B9E\u9645\u5927\u5C0F",reload:"\u4ECE\u78C1\u76D8\u91CD\u65B0\u52A0\u8F7D",previousPage:"\u4E0A\u4E00\u9875",nextPage:"\u4E0B\u4E00\u9875",pageNumber:"\u9875\u7801",ofPages:e=>`/ ${e}`,zoomIn:"\u653E\u5927\uFF08\u2318+\uFF09",zoomOut:"\u7F29\u5C0F\uFF08\u2318\u2212\uFF09",fit:"\u9002\u5E94",addToChat:"\u6DFB\u52A0\u5230\u5BF9\u8BDD",addShort:"\u6DFB\u52A0",addToChatHint:"\u9644\u52A0\u5230\u4E0B\u4E00\u6761\u6D88\u606F\uFF08\u2318/Ctrl+Enter\uFF09",added:"\u5DF2\u6DFB\u52A0\u5230\u5BF9\u8BDD",ask:"\u63D0\u95EE",askPlaceholder:"\u5C31\u8FD9\u91CC\u63D0\u95EE\u2026",send:"\u53D1\u9001",cancel:"\u53D6\u6D88",sendKey:"\u53D1\u9001",cancelKey:"\u53D6\u6D88",copy:"\u590D\u5236",copied:"\u5DF2\u590D\u5236",agent:"Agent",agentOf:(e,t)=>`Agent \xB7 \u7B2C ${e} \u5904\uFF0C\u5171 ${t} \u5904`,nextTarget:"\u4E0B\u4E00\u5904",moreOn:(e,t)=>e===1?`${t}\u8FD8\u6709 1 \u5904`:`\u8FD8\u6709 ${e} \u5904`,close:"\u5173\u95ED",changed:"\u6587\u4EF6\u5DF2\u5728\u78C1\u76D8\u4E0A\u66F4\u6539\u3002",reloadShort:"\u91CD\u65B0\u52A0\u8F7D",dismiss:"\u5FFD\u7565",openAnother:"\u6253\u5F00\u5176\u4ED6\u6587\u4EF6",sidePanel:"\u5728\u4FA7\u680F\u6253\u5F00",meta:{pdf:e=>`${e} \u9875`,pptx:e=>`${e} \u5F20\u5E7B\u706F\u7247`,xlsx:e=>`${e} \u4E2A\u5DE5\u4F5C\u8868`,docx:()=>""},errors:{generic:["\u65E0\u6CD5\u6253\u5F00\u8BE5\u6587\u6863",""],password:["\u8BE5 PDF \u53D7\u5BC6\u7801\u4FDD\u62A4",`${Cx}\u6682\u4E0D\u652F\u6301\u6253\u5F00\u52A0\u5BC6\u6587\u4EF6\u3002`],not_found:["\u8BE5\u6587\u4EF6\u5DF2\u4E0D\u5B58\u5728","\u5B83\u53EF\u80FD\u5DF2\u88AB\u79FB\u52A8\u6216\u5220\u9664\u3002"],file_too_large:["\u6587\u4EF6\u592A\u5927\uFF0C\u65E0\u6CD5\u6253\u5F00",""],corrupt_file:["\u8BE5\u6587\u4EF6\u4F3C\u4E4E\u5DF2\u635F\u574F",`${Cx}\u65E0\u6CD5\u8BFB\u53D6\u5176\u5185\u5BB9\u3002`],unsupported_type:["\u4E0D\u652F\u6301\u8FD9\u79CD\u6587\u4EF6",`${Cx}\u53EF\u4EE5\u6253\u5F00 ${ps("zh-CN")} \u6587\u4EF6\u3002`],path_outside_workspace:["\u8BE5\u6587\u4EF6\u4E0D\u5728\u5DE5\u4F5C\u533A\u5185",""]},sendFailed:"\u6D88\u606F\u672A\u53D1\u9001\u3002",contextFailed:"ZCode \u672A\u63A5\u53D7\u8BE5\u5F15\u7528\u3002",where:{page:e=>`\u7B2C ${e} \u9875`,pages:(e,t)=>`\u7B2C ${e}\u2013${t} \u9875`,pageLower:e=>`\u7B2C ${e} \u9875`,slide:e=>`\u7B2C ${e} \u5F20\u5E7B\u706F\u7247`,slides:(e,t)=>`\u7B2C ${e}\u2013${t} \u5F20\u5E7B\u706F\u7247`,slideLower:e=>`\u7B2C ${e} \u5F20\u5E7B\u706F\u7247`,shape:e=>`\u7B2C ${e} \u5F20\u5E7B\u706F\u7247 \xB7 \u5F62\u72B6`,paragraph:e=>`\u7B2C ${e} \u6BB5`,paragraphs:(e,t)=>`\u7B2C ${e}\u2013${t} \u6BB5`,paragraphLower:e=>`\u7B2C ${e} \u6BB5`,table:e=>`\u8868\u683C ${e}`,cell:(e,t,n)=>`\u8868\u683C ${e} \xB7 R${t}C${n}`}},PP=e=>e?.toLowerCase().startsWith("zh")?uH:cH;function Ab(e,t,n=!1){let i=t.where,r;if(r=/^page:(\d+)(?:-(\d+))?$/.exec(e))return r[2]?i.pages(r[1],r[2]):n?i.pageLower(r[1]):i.page(r[1]);if(r=/^slide:(\d+)\/shape:/.exec(e))return i.shape(r[1]);if(r=/^slide:(\d+)(?:-(\d+))?$/.exec(e))return r[2]?i.slides(r[1],r[2]):n?i.slideLower(r[1]):i.slide(r[1]);if(r=/^p:(\d+)(?:-(\d+))?$/.exec(e))return r[2]?i.paragraphs(r[1],r[2]):n?i.paragraphLower(r[1]):i.paragraph(r[1]);if(r=/^t:(\d+)\/r(\d+)c(\d+)$/.exec(e))return i.cell(r[1],r[2],r[3]);if(r=/^t:(\d+)$/.exec(e))return i.table(r[1]);let a=e.lastIndexOf("!");return a>0?`${e.slice(0,a).replace(/^'(.*)'$/,"$1").replace(/''/g,"'")} \xB7 ${e.slice(a+1)}`:e.replace(/^'(.*)'$/,"$1")}var Ix=ht(Pn(),1),mH={search:'<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>',x:'<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',"chevron-up":'<path d="m18 15-6-6-6 6"/>',"chevron-down":'<path d="m6 9 6 6 6-6"/>',minus:'<path d="M5 12h14"/>',plus:'<path d="M5 12h14"/><path d="M12 5v14"/>',ellipsis:'<circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>',"panel-left":'<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M9 3v18"/>',"file-text":'<path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M10 9H8"/><path d="M16 13H8"/><path d="M16 17H8"/>',copy:'<rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/>',"message-square-plus":'<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/><path d="M12 7v6"/><path d="M9 10h6"/>',"message-circle-question":'<path d="M7.9 20A9 9 0 1 0 4 16.1L2 22Z"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><path d="M12 17h.01"/>',check:'<path d="M20 6 9 17l-5-5"/>',"rotate-cw":'<path d="M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/>',"arrow-down":'<path d="M12 5v14"/><path d="m19 12-7 7-7-7"/>',"arrow-up":'<path d="m5 12 7-7 7 7"/><path d="M12 19V5"/>',"folder-open":'<path d="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"/>',"maximize-2":'<polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" x2="14" y1="3" y2="10"/><line x1="3" x2="10" y1="21" y2="14"/>'};function We({name:e,size:t=14,className:n}){return(0,Ix.jsx)("svg",{className:`icon${n?` ${n}`:""}`,width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",dangerouslySetInnerHTML:{__html:mH[e]}})}var pH={pdf:"PDF",docx:"W",xlsx:"X",pptx:"P"};function UP({kind:e}){return(0,Ix.jsx)("span",{className:`filetype ${e}`,"aria-hidden":"true",children:pH[e]})}var aa=ht(ir(),1);var Ae=ht(Pn(),1);function hH({handle:e,page:t,width:n,ratio:i,current:r,onPick:a,root:o}){let s=(0,aa.useRef)(null);return(0,aa.useEffect)(()=>{let l=s.current;if(!l||!e.thumbnail)return;let c=!1,u=new IntersectionObserver(d=>{c||!d.some(f=>f.isIntersecting)||(c=!0,u.disconnect(),e.thumbnail(t,n).then(f=>{l.replaceChildren(f),l.style.height=""},()=>{}))},{root:o.current,rootMargin:"300px 0px"});return u.observe(l),()=>u.disconnect()},[e,t,n,o]),(0,Ae.jsxs)("button",{type:"button",className:`thumb${r?" on":""}`,"aria-current":r?"page":void 0,onClick:()=>a(t),"data-page":t,children:[(0,Ae.jsx)("div",{ref:s,className:"mini",style:{width:n,height:Math.round(n*i)}}),(0,Ae.jsx)("span",{children:t})]})}var LP=e=>/^(?:page|slide):(\d+)/.exec(e)?.[1]??"";function qP({t:e,info:t,handle:n,page:i,tab:r,docked:a,onTab:o,onPage:s,onOutline:l}){let c=(0,aa.useRef)(null),u=!!(n?.thumbnail&&i),d=t.outline.length>0,f=u&&(r==="pages"||!d)?"pages":"outline",m=t.kind==="pptx"?9/16:1.294;(0,aa.useEffect)(()=>{let h=c.current?.querySelector("[aria-current=page]");h&&c.current&&(c.current.scrollTop=h.offsetTop-c.current.clientHeight/3)},[f]);let p=(()=>{if(!i)return-1;let h=-1;return t.outline.forEach((_,g)=>{let b=Number(LP(_.at));b&&b<=i.current&&(h=g)}),h})();return(0,Ae.jsxs)("nav",{className:`drawer${a?" docked":""}`,"aria-label":e.pagesAndOutline,children:[u&&d?(0,Ae.jsxs)("div",{className:"seg",role:"tablist",children:[(0,Ae.jsx)("button",{type:"button",role:"tab","aria-selected":f==="pages",className:f==="pages"?"on":"",onClick:()=>o("pages"),children:t.kind==="pptx"?e.slides:e.pages}),(0,Ae.jsx)("button",{type:"button",role:"tab","aria-selected":f==="outline",className:f==="outline"?"on":"",onClick:()=>o("outline"),children:e.outline})]}):null,(0,Ae.jsx)("div",{ref:c,className:f==="pages"?"thumbs":"outline",children:f==="pages"&&n&&i?Array.from({length:i.count},(h,_)=>(0,Ae.jsx)(hH,{handle:n,page:_+1,width:136,ratio:m,current:i.current===_+1,onPick:s,root:c},_)):t.outline.map((h,_)=>(0,Ae.jsxs)("button",{type:"button",className:`oi level-${Math.min(3,Math.max(1,h.level))}${_===p?" on":""}`,"aria-current":_===p?"page":void 0,title:h.label,onClick:()=>l(h.at),children:[(0,Ae.jsx)("span",{className:"label",children:h.label}),(0,Ae.jsx)("span",{className:"n",children:LP(h.at)})]},`${h.at}-${_}`))})]})}function BP({t:e,onBrowse:t,importing:n}){return(0,Ae.jsx)("div",{className:"empty",children:(0,Ae.jsxs)("div",{className:"empty-content",children:[(0,Ae.jsx)("h3",{children:e.emptyTitle}),(0,Ae.jsx)("p",{className:"empty-description",children:e.emptyDescription}),(0,Ae.jsxs)("button",{type:"button",className:"btn empty-open",onClick:t,disabled:n,children:[(0,Ae.jsx)(We,{name:"folder-open",size:16}),n?e.importing:e.openFile]}),(0,Ae.jsx)("p",{className:"empty-caption",children:e.emptyCaption})]})})}var gH=["title","subtitle","line","line","short","heading","line","line","line","mid","figure"];function Mb({kind:e}){if(e==="xlsx")return(0,Ae.jsx)("div",{className:"skeleton sheet","aria-busy":"true",children:Array.from({length:18},(n,i)=>(0,Ae.jsx)("div",{className:"skel-row"},i))});let t=e==="pptx";return(0,Ae.jsx)("div",{className:"skeleton","aria-busy":"true",children:[0,1].map(n=>(0,Ae.jsxs)("div",{className:`skelpage${t?" slide":""}`,children:[n===0&&!t?gH.map((i,r)=>(0,Ae.jsx)("div",{className:`skel ${i}`},r)):null,n===0&&t?(0,Ae.jsxs)(Ae.Fragment,{children:[(0,Ae.jsx)("div",{className:"skel title left"}),(0,Ae.jsx)("div",{className:"skel line"}),(0,Ae.jsx)("div",{className:"skel mid"})]}):null]},n))})}function Db({t:e,title:t,detail:n,onOpenAnother:i}){return(0,Ae.jsxs)("div",{className:"failed",role:"alert",children:[(0,Ae.jsx)(We,{name:"file-text",size:28,className:"subtlest"}),(0,Ae.jsxs)("div",{children:[(0,Ae.jsx)("h3",{children:t}),n?(0,Ae.jsx)("p",{children:n}):null]}),(0,Ae.jsx)("button",{type:"button",className:"btn secondary",onClick:i,children:e.openAnother})]})}function HP({t:e,onReload:t,onDismiss:n}){return(0,Ae.jsxs)("div",{className:"banner",role:"status",children:[(0,Ae.jsx)("span",{children:e.changed}),(0,Ae.jsx)("button",{type:"button",className:"btn sm primary",onClick:t,children:e.reloadShort}),(0,Ae.jsx)("button",{type:"button",className:"btn icon sm dim",title:e.dismiss,"aria-label":e.dismiss,onClick:n,children:(0,Ae.jsx)(We,{name:"x"})})]})}function vH({inputRef:e,t,importing:n,onImporting:i,onOpen:r,onError:a}){return(0,Ae.jsx)("input",{ref:e,type:"file",hidden:!0,accept:ei.map(o=>`.${o}`).join(","),disabled:n,onChange:async o=>{let s=o.currentTarget.files?.[0];if(o.currentTarget.value="",!!s){i(!0);try{if(s.size>Lm)throw new Error(t.importTooLarge);r(await EP(s))}catch(l){a(l,s.name)}finally{i(!1)}}}})}function VP(e,t,n){let i=(0,aa.useRef)(null),[r,a]=(0,aa.useState)(!1);return{importing:r,browse:()=>i.current?.click(),input:(0,Ae.jsx)(vH,{inputRef:i,t:e,importing:r,onImporting:a,onOpen:t,onError:n})}}var zn=ht(Pn(),1);function ZP({appRef:e,canvasRef:t,t:n,path:i,info:r,kind:a,showSkeleton:o,failure:s,nothing:l,onExpand:c,children:u}){return(0,zn.jsxs)("div",{ref:e,className:"app inline",children:[(0,zn.jsxs)("header",{className:"docbar",children:[(0,zn.jsxs)("div",{className:"doctitle static",title:i??void 0,children:[(0,zn.jsx)("span",{className:"name",children:i?hs(i):n.title}),r&&n.meta[r.kind](r.units)?(0,zn.jsx)("span",{className:"meta",children:n.meta[r.kind](r.units)}):null]}),(0,zn.jsx)("span",{className:"spacer"}),(0,zn.jsxs)("button",{type:"button",className:"btn sm",title:n.sidePanel,onClick:c,children:[(0,zn.jsx)(We,{name:"maximize-2",size:12}),n.sidePanel]})]}),(0,zn.jsx)("div",{className:"stage",children:(0,zn.jsxs)("div",{ref:t,className:"canvas",children:[u,o?(0,zn.jsx)(Mb,{kind:a}):null,s?(0,zn.jsx)(Db,{t:n,title:s.title,detail:s.detail,onOpenAnother:c}):null,l?(0,zn.jsx)("div",{className:"failed muted",children:n.openTitle}):null,(0,zn.jsx)("button",{type:"button",className:"glance-cover","aria-label":n.sidePanel,onClick:c})]})})]})}var er=ht(ir(),1);var jb=ht(ir(),1),gs=8;function Nx(e,t,n){let i=(0,jb.useRef)(null),{side:r,offset:a=8,dock:o=!1}=n;return(0,jb.useLayoutEffect)(()=>{let s=i.current,l=e.current;if(!s||!l)return;let c=0,u=()=>{c=0;let p=l.getBoundingClientRect(),h=s.offsetWidth,_=s.offsetHeight,g=t?.()??null,b=(F,k,D,w)=>{s.style.visibility="",s.style.left=`${Math.round(F)}px`,s.style.top=`${Math.round(k)}px`,s.dataset.side=D,s.style.setProperty("--tip",`${Math.round(Math.max(14,Math.min(h-14,w-F)))}px`)};if(!g){o?b((p.width-h)/2,gs,"none",p.width/2):s.style.visibility="hidden";return}if(g.bottom<p.top+4||g.top>p.bottom-4){s.style.visibility="hidden";return}let S=(g.left+g.right)/2-p.left,$=Math.max(gs,Math.min(p.width-h-gs,S-h/2)),C=g.top-p.top-_-a,z=g.bottom-p.top+a,T=C>=gs,M=z+_<=p.height-gs;(r==="top"||!M)&&T?b($,C,"top",S):M?b($,z,"bottom",S):b($,r==="top"?gs:p.height-_-gs,"none",S)},d=()=>{c||(c=requestAnimationFrame(u))};u(),l.addEventListener("scroll",d,{capture:!0,passive:!0});let f=new ResizeObserver(d);f.observe(l),f.observe(s);let m=setInterval(d,250);return()=>{l.removeEventListener("scroll",d,{capture:!0}),f.disconnect(),clearInterval(m),c&&cancelAnimationFrame(c)}},[e,t,r,a,o]),i}var de=ht(Pn(),1);function Ox({className:e,onClose:t,children:n,label:i}){let r=(0,er.useRef)(null);(0,er.useEffect)(()=>{let o=l=>{let c=l.target;!r.current?.contains(c)&&!c.closest?.("[data-menu-trigger]")&&t()},s=l=>{l.key==="Escape"&&(l.stopPropagation(),t())};return document.addEventListener("pointerdown",o,!0),document.addEventListener("keydown",s,!0),r.current?.querySelector("[role^=menuitem]")?.focus(),()=>{document.removeEventListener("pointerdown",o,!0),document.removeEventListener("keydown",s,!0)}},[t]);let a=o=>{if(o.key!=="ArrowDown"&&o.key!=="ArrowUp")return;o.preventDefault();let s=[...r.current?.querySelectorAll("[role^=menuitem]")??[]],l=s.indexOf(document.activeElement);s[(l+(o.key==="ArrowDown"?1:-1)+s.length)%s.length]?.focus()};return(0,de.jsx)("div",{ref:r,className:`menu ${e}`,role:"menu","aria-label":i,onKeyDown:a,children:n})}function ro({icon:e,checked:t,children:n,hint:i,onSelect:r}){return(0,de.jsxs)("button",{type:"button",role:t===void 0?"menuitem":"menuitemradio","aria-checked":t,className:"mi",onClick:r,children:[(0,de.jsx)("span",{className:"mi-icon",children:t?(0,de.jsx)(We,{name:"check",size:16}):e}),(0,de.jsx)("span",{className:"mi-label",children:n}),i?(0,de.jsx)("span",{className:"mi-hint",children:i}):null]})}function GP({t:e,query:t,total:n,index:i,onQuery:r,onStep:a,onClose:o}){let s=(0,er.useRef)(null);(0,er.useEffect)(()=>{s.current?.focus(),s.current?.select()},[]);let l=!t.trim()||n===null?"":n?e.findCount(i+1,n):e.noResults;return(0,de.jsxs)("div",{className:"docbar findbar",role:"search",children:[(0,de.jsxs)("label",{className:"findfield",children:[(0,de.jsx)(We,{name:"search",className:"muted"}),(0,de.jsx)("input",{ref:s,className:"find-input",type:"text","aria-label":e.find,placeholder:e.findPlaceholder,value:t,onChange:c=>r(c.target.value),onKeyDown:c=>{c.key==="Enter"?(c.preventDefault(),a(c.shiftKey?-1:1)):c.key==="Escape"&&(c.preventDefault(),c.stopPropagation(),o())}}),(0,de.jsx)("span",{className:"count","aria-live":"polite",children:l})]}),(0,de.jsx)("button",{type:"button",className:"btn icon dim",title:e.previousMatch,"aria-label":e.previousMatch,disabled:!n,onClick:()=>a(-1),children:(0,de.jsx)(We,{name:"chevron-up"})}),(0,de.jsx)("button",{type:"button",className:"btn icon dim",title:e.nextMatch,"aria-label":e.nextMatch,disabled:!n,onClick:()=>a(1),children:(0,de.jsx)(We,{name:"chevron-down"})}),(0,de.jsx)("button",{type:"button",className:"btn icon dim",title:e.closeFind,"aria-label":e.closeFind,onClick:o,children:(0,de.jsx)(We,{name:"x"})})]})}var bH=1500;function KP({t:e,frame:t,page:n,zoom:i,onPage:r,onZoom:a,onFit:o}){let s=(0,er.useRef)(null),[l,c]=(0,er.useState)(!0),[u,d]=(0,er.useState)(null),f=(0,er.useRef)(!1);(0,er.useEffect)(()=>{let p=t.current;if(!p)return;let h=0,_=()=>{clearTimeout(h),h=window.setTimeout(()=>{!f.current&&!s.current?.contains(document.activeElement)&&c(!1)},bH)},g=()=>{c(!0),_()},b=S=>{let $=p.getBoundingClientRect();S.clientY>$.bottom-80&&g()};return p.addEventListener("scroll",g,{capture:!0,passive:!0}),p.addEventListener("pointermove",b,{passive:!0}),_(),()=>{clearTimeout(h),p.removeEventListener("scroll",g,{capture:!0}),p.removeEventListener("pointermove",b)}},[t]);let m=()=>{let p=Number(u);d(null),Number.isInteger(p)&&p>=1&&r(Math.min(p,n.count))};return(0,de.jsxs)("div",{ref:s,className:`pill${l?"":" faded"}`,onPointerEnter:()=>{f.current=!0,c(!0)},onPointerLeave:()=>{f.current=!1},onFocus:()=>c(!0),children:[(0,de.jsx)("button",{type:"button",className:"btn icon sm dim",title:e.previousPage,"aria-label":e.previousPage,disabled:n.current<=1,onClick:()=>r(n.current-1),children:(0,de.jsx)(We,{name:"chevron-up"})}),(0,de.jsxs)("span",{className:"pg",children:[(0,de.jsx)("input",{className:"pgin","aria-label":e.pageNumber,inputMode:"numeric",style:{width:`${Math.max(2,String(n.count).length)+1.6}ch`},value:u??String(n.current),onFocus:p=>{d(String(n.current)),p.target.select()},onChange:p=>d(p.target.value.replace(/\D/g,"")),onBlur:()=>d(null),onKeyDown:p=>{p.key==="Enter"?(m(),p.currentTarget.blur()):p.key==="Escape"&&(p.stopPropagation(),d(null),p.currentTarget.blur())}}),(0,de.jsx)("span",{children:e.ofPages(n.count)})]}),(0,de.jsx)("button",{type:"button",className:"btn icon sm dim",title:e.nextPage,"aria-label":e.nextPage,disabled:n.current>=n.count,onClick:()=>r(n.current+1),children:(0,de.jsx)(We,{name:"chevron-down"})}),i?(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)("span",{className:"vsep"}),(0,de.jsx)("button",{type:"button",className:"btn icon sm dim",title:e.zoomOut,"aria-label":e.zoomOut,disabled:i.mode!=="width"&&i.percent<=25,onClick:()=>a(-1),children:(0,de.jsx)(We,{name:"minus"})}),(0,de.jsx)("button",{type:"button",className:"zoom",title:e.fitWidth,onClick:o,children:i.mode==="width"?e.fit:`${i.percent}%`}),(0,de.jsx)("button",{type:"button",className:"btn icon sm dim",title:e.zoomIn,"aria-label":e.zoomIn,disabled:i.mode!=="width"&&i.percent>=400,onClick:()=>a(1),children:(0,de.jsx)(We,{name:"plus"})})]}):null]})}var FP=e=>{e.target.closest("textarea")||e.preventDefault()};function JP({t:e,frame:t,locate:n,text:i,label:r,quote:a,short:o,mode:s,canAsk:l,copied:c,onAdd:u,onAsk:d,onCopy:f,onCancelAsk:m,onSend:p}){let h=s==="ask",_=Nx(t,n,{side:h?"bottom":"top",dock:!0}),[g,b]=(0,er.useState)(""),[S,$]=(0,er.useState)(!1),C=async()=>{if(!g.trim()||S)return;$(!0);let z=await p(g.trim());$(!1),z&&b("")};return h?(0,de.jsxs)("div",{ref:_,className:"pop ask",role:"dialog","aria-label":e.ask,onMouseDown:FP,children:[(0,de.jsxs)("div",{className:"ctx",children:[(0,de.jsx)("span",{className:"where",children:r}),a?(0,de.jsxs)("span",{className:"q",children:["\u201C",a,"\u201D"]}):null]}),(0,de.jsx)("textarea",{autoFocus:!0,className:"textarea",rows:2,"aria-label":e.askPlaceholder,placeholder:e.askPlaceholder,value:g,onChange:z=>b(z.target.value),onKeyDown:z=>{z.key==="Enter"&&!z.shiftKey&&!z.nativeEvent.isComposing?(z.preventDefault(),C()):z.key==="Escape"&&(z.preventDefault(),z.stopPropagation(),m())}}),(0,de.jsxs)("div",{className:"row",children:[(0,de.jsxs)("span",{className:"hint",children:[(0,de.jsx)("kbd",{children:"\u21B5"})," ",e.sendKey]}),(0,de.jsx)("button",{type:"button",className:"btn sm",onClick:m,children:e.cancel}),(0,de.jsx)("button",{type:"button",className:"btn sm primary",disabled:!g.trim()||S,onClick:()=>void C(),children:e.send})]})]}):(0,de.jsxs)("div",{ref:_,className:"pop bar",role:"toolbar","aria-label":r,onMouseDown:FP,children:[i?null:(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)("span",{className:"where",children:r}),(0,de.jsx)("span",{className:"vsep"})]}),(0,de.jsx)("button",{type:"button",className:"btn lg",title:e.addToChatHint,onClick:u,disabled:s==="added",children:s==="added"?(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(We,{name:"check",size:16,className:"ok"}),e.added]}):(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)(We,{name:"message-square-plus",size:16}),o?e.addShort:e.addToChat]})}),l?(0,de.jsxs)("button",{type:"button",className:"btn lg",onClick:d,children:[(0,de.jsx)(We,{name:"message-circle-question",size:16}),e.ask]}):null,i?(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)("span",{className:"vsep"}),(0,de.jsx)("button",{type:"button",className:"btn icon lg dim",title:c?e.copied:e.copy,"aria-label":c?e.copied:e.copy,onClick:f,children:(0,de.jsx)(We,{name:c?"check":"copy"})})]}):null]})}function YP({t:e,frame:t,locate:n,note:i,index:r,total:a,onNext:o,onClose:s}){let l=Nx(t,n,{side:"bottom",offset:6,dock:!0});return(0,de.jsxs)("div",{ref:l,className:"callout",role:"note",children:[(0,de.jsxs)("div",{className:"body",children:[(0,de.jsxs)("div",{className:"who",children:[(0,de.jsx)("span",{className:"dot"}),a>1?e.agentOf(r+1,a):e.agent]}),i?(0,de.jsx)("div",{className:"text",children:i}):null]}),a>1?(0,de.jsx)("button",{type:"button",className:"btn icon sm dim",title:e.nextTarget,"aria-label":e.nextTarget,onClick:o,children:(0,de.jsx)(We,{name:"chevron-down"})}):null,(0,de.jsx)("button",{type:"button",className:"btn icon sm dim",title:e.close,"aria-label":e.close,onClick:s,children:(0,de.jsx)(We,{name:"x"})})]})}function XP({text:e,down:t,raised:n,onClick:i}){return(0,de.jsxs)("button",{type:"button",className:`chip offscreen${n?" raised":""}`,onClick:i,children:[(0,de.jsx)("span",{className:"dot"}),e,(0,de.jsx)(We,{name:t?"arrow-down":"arrow-up",size:12})]})}function WP(e,t){return e.moreOn(t.length,Ab(t[0],e,!0))}var Ot=ht(Pn(),1);function QP({t:e,recent:t,currentPath:n,onOpen:i,onBrowse:r,onClose:a}){return(0,Ot.jsxs)(Ox,{className:"switcher",label:e.switchDocument,onClose:a,children:[t.length?(0,Ot.jsx)("div",{className:"mlabel",children:e.recent}):null,t.map(o=>(0,Ot.jsx)(ro,{icon:(0,Ot.jsx)(UP,{kind:o.kind}),hint:o.path===n?(0,Ot.jsx)(We,{name:"check",size:16}):hs(TP(o.path)),onSelect:()=>o.path===n?a():i(o.path),children:hs(o.path)},o.path)),t.length?(0,Ot.jsx)("div",{className:"msep"}):null,(0,Ot.jsx)(ro,{icon:(0,Ot.jsx)(We,{name:"folder-open",size:16}),onSelect:r,children:e.openFile})]})}function eM({t:e,zoomable:t,zoomMode:n,onFit:i,onFind:r,onReload:a,onClose:o}){return(0,Ot.jsxs)(Ox,{className:"more",label:e.more,onClose:o,children:[t?(0,Ot.jsxs)(Ot.Fragment,{children:[(0,Ot.jsx)(ro,{checked:n==="width",onSelect:()=>i("width"),children:e.fitWidth}),(0,Ot.jsx)(ro,{checked:n==="page",onSelect:()=>i("page"),children:e.fitPage}),(0,Ot.jsx)(ro,{checked:n==="actual",hint:"100%",onSelect:()=>i("actual"),children:e.actualSize}),(0,Ot.jsx)("div",{className:"msep"})]}):null,(0,Ot.jsx)(ro,{icon:(0,Ot.jsx)(We,{name:"search",size:16}),hint:"\u2318F",onSelect:r,children:e.find}),(0,Ot.jsx)(ro,{icon:(0,Ot.jsx)(We,{name:"rotate-cw",size:16}),onSelect:a,children:e.reload})]})}var ti=ht(ir(),1),Fm={open:!1,query:"",total:null,index:-1};function tM({viewer:e,docRef:t,ready:n,onOpen:i}){let[r,a]=(0,ti.useState)(Fm),o=(0,ti.useRef)(0),s=(0,ti.useCallback)(()=>{t.current&&(i(),a(d=>({...d,open:!0})),requestAnimationFrame(()=>{let d=document.querySelector(".findbar .find-input");d?.focus(),d?.select()}))},[t,i]),l=(0,ti.useCallback)(()=>{o.current++,e.current?.clearFind(),a(Fm)},[e]),c=(0,ti.useCallback)(d=>{a(f=>({...f,query:d,total:d.trim()?f.total:null}))},[]);(0,ti.useEffect)(()=>{if(!r.open||!n)return;let d=++o.current,f=setTimeout(async()=>{let m=e.current;if(!m)return;let p=await m.find(r.query).catch(()=>0);d===o.current&&(a(h=>({...h,total:p,index:p?0:-1})),p&&m.findGo(0))},200);return()=>clearTimeout(f)},[r.open,r.query,n,e]);let u=(0,ti.useCallback)(d=>{if(!r.total)return;let f=(r.index+d+r.total)%r.total;a(m=>({...m,index:f})),e.current?.findGo(f)},[r.total,r.index,e]);return{find:r,setFind:a,openFind:s,closeFind:l,queryFind:c,stepFind:u}}var nM=ht(ir(),1);function rM(e,t){(0,nM.useEffect)(()=>{Dr().handleTool("capture_view",async i=>{let r=e.current;if(!r||!t.current)throw new Error(`No document is open in the ${zt.title.en} panel. Call open_document first.`);let a=null;if(typeof i.anchor=="string"&&i.anchor.trim()){let l=vP(i.anchor);if(l.path.replace(/^\.\//,"")!==r.info.path)throw new Error(`The panel shows ${r.info.path}, not ${l.path}. Call open_document with that path first.`);a=l.at}let o=typeof i.maxWidth=="number"?Math.min(2e3,Math.max(320,i.maxWidth)):1600,s=await t.current.capture(a,o);return{content:[{type:"image",data:s.data,mimeType:"image/png"},{type:"text",text:`Captured ${Bm(r.info.path,s.at)} (${s.width}\xD7${s.height} px).`}]}})},[e,t])}var Ub=ht(ir(),1);function iM(e,t){let[n,i]=(0,Ub.useState)(null);return(0,Ub.useEffect)(()=>{let r=e.current;if(!r||!t||t.targets.length<2){i(null);return}let a=0,o=()=>{a=0;let c=r.getBoundingClientRect(),u=[],d=[];t.targets.forEach((m,p)=>{if(p===t.index)return;let h=m.locate();h&&(h.top>c.bottom-8?u.push(p):h.bottom<c.top+8&&d.push(p))});let f=u.length?{indexes:u,down:!0}:d.length?{indexes:d,down:!1}:null;i(m=>JSON.stringify(m)===JSON.stringify(f)?m:f)},s=()=>{a||(a=requestAnimationFrame(o))};o(),r.addEventListener("scroll",s,{capture:!0,passive:!0});let l=setInterval(s,500);return()=>{r.removeEventListener("scroll",s,{capture:!0}),clearInterval(l),a&&cancelAnimationFrame(a)}},[t,e]),[n,i]}var aM=ht(ir(),1);function oM({docRef:e,viewer:t,picked:n,addReference:i,openFind:r,closeFind:a,clearSelection:o,paged:s,page:l,goToPage:c,drawer:u,setDrawer:d,docked:f,find:m,agent:p,setAgent:h}){(0,aM.useEffect)(()=>{let _=g=>{if(g.defaultPrevented)return;let b=g.metaKey||g.ctrlKey,S=g.target?.closest?.("input, textarea, [contenteditable]"),$=g.key.toLowerCase();if(b&&$==="f"&&e.current)g.preventDefault(),r();else if(b&&g.key==="Enter"&&n)g.preventDefault(),i();else if(b&&(g.key==="="||g.key==="+"))g.preventDefault(),t.current?.zoom(1);else if(b&&g.key==="-")g.preventDefault(),t.current?.zoom(-1);else if(b&&g.key==="0")g.preventDefault(),t.current?.fit("width");else if(!b&&!S&&s&&l&&["ArrowLeft","ArrowRight","PageUp","PageDown"].includes(g.key)){g.preventDefault();let C=g.key==="ArrowLeft"||g.key==="PageUp";c(l.current+(C?-1:1))}else if(g.key==="Escape"&&!S){if(n)o();else if(u.open&&!f)d(C=>({...C,open:!1}));else if(m.open)a();else if(p?.visible)h({...p,visible:!1});else return;g.preventDefault()}};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[n,i,r,a,o,s,l,c,u.open,f,m.open,p,e,t,d,h])}var At=ht(ir(),1);var vM=ht(lM(),1);var Ut;(function(e){e.OfficeDocument="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",e.FontTable="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",e.Image="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",e.Numbering="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",e.Styles="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",e.StylesWithEffects="http://schemas.microsoft.com/office/2007/relationships/stylesWithEffects",e.Theme="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",e.Settings="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",e.WebSettings="http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings",e.Hyperlink="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",e.Footnotes="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",e.Endnotes="http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes",e.Footer="http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",e.Header="http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",e.ExtendedProperties="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",e.CoreProperties="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",e.CustomProperties="http://schemas.openxmlformats.org/package/2006/relationships/metadata/custom-properties",e.Comments="http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",e.CommentsExtended="http://schemas.microsoft.com/office/2011/relationships/commentsExtended",e.AltChunk="http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk"})(Ut||(Ut={}));function yH(e,t){return t.elements(e).map(n=>({id:t.attr(n,"Id"),type:t.attr(n,"Type"),target:t.attr(n,"Target"),targetMode:t.attr(n,"TargetMode")}))}function SH(e){return e?.replace(/[ .]+/g,"-").replace(/[&]+/g,"and").toLowerCase()}function Dx(e){return/^[^"'].*\s.*[^"']$/.test(e)?`'${e}'`:e}function qb(e){let t=e.lastIndexOf("/")+1,n=t==0?"":e.substring(0,t),i=t==0?e:e.substring(t);return[n,i]}function Px(e,t){try{let n="http://docx/";return new URL(e,n+t).toString().substring(n.length)}catch{return`${t}${e}`}}function io(e,t){return e.reduce((n,i)=>(n[t(i)]=i,n),{})}function _H(e){return new Promise((t,n)=>{let i=new FileReader;i.onloadend=()=>t(i.result),i.onerror=()=>n(),i.readAsDataURL(e)})}function Mx(e){return e&&typeof e=="object"&&!Array.isArray(e)}function jx(e){return typeof e=="string"||e instanceof String}function Hb(e,...t){if(!t.length)return e;let n=t.shift();if(Mx(e)&&Mx(n))for(let i in n)if(Mx(n[i])){let r=e[i]??(e[i]={});Hb(r,n[i])}else e[i]=n[i];return Hb(e,...t)}function Gm(e){return Array.isArray(e)?e:[e]}function wH(e,t,n){return t>e?t:n<e?n:e}var bM={wordml:"http://schemas.openxmlformats.org/wordprocessingml/2006/main"},Zt={Dxa:{mul:.05,unit:"pt"},Emu:{mul:1/12700,unit:"pt"},FontSize:{mul:.5,unit:"pt"},Border:{mul:.125,unit:"pt",min:.25,max:12},Point:{mul:1,unit:"pt"},Percent:{mul:.02,unit:"%"}};function yM(e,t=Zt.Dxa){if(e==null||/.+(p[xt]|[%])$/.test(e))return e;var n=parseInt(e)*t.mul;return t.min&&t.max&&(n=wH(n,t.min,t.max)),`${n.toFixed(2)}${t.unit}`}function $H(e,t=!1){switch(e){case"1":return!0;case"0":return!1;case"on":return!0;case"off":return!1;case"true":return!0;case"false":return!1;default:return t}}function SM(e,t,n){if(e.namespaceURI!=bM.wordml)return!1;switch(e.localName){case"color":t.color=n.attr(e,"val");break;case"sz":t.fontSize=n.lengthAttr(e,"val",Zt.FontSize);break;default:return!1}return!0}function zH(e,t=!1){t&&(e=e.replace(/<[?].*[?]>/,"")),e=xH(e);let n=new DOMParser().parseFromString(e,"application/xml"),i=kH(n);if(i)throw new Error(i);return n}function kH(e){return e.getElementsByTagName("parsererror")[0]?.textContent}function xH(e){return e.charCodeAt(0)===65279?e.substring(1):e}function RH(e){return new XMLSerializer().serializeToString(e)}var Vb=class{elements(t,n=null){let i=[];for(let r=0,a=t.childNodes.length;r<a;r++){let o=t.childNodes.item(r);o.nodeType==Node.ELEMENT_NODE&&(n==null||o.localName==n)&&i.push(o)}return i}element(t,n){for(let i=0,r=t.childNodes.length;i<r;i++){let a=t.childNodes.item(i);if(a.nodeType==1&&a.localName==n)return a}return null}elementAttr(t,n,i){var r=this.element(t,n);return r?this.attr(r,i):void 0}attrs(t){return Array.from(t.attributes)}attr(t,n){for(let i=0,r=t.attributes.length;i<r;i++){let a=t.attributes.item(i);if(a.localName==n)return a.value}return null}intAttr(t,n,i=null){var r=this.attr(t,n);return r?parseInt(r):i}hexAttr(t,n,i=null){var r=this.attr(t,n);return r?parseInt(r,16):i}floatAttr(t,n,i=null){var r=this.attr(t,n);return r?parseFloat(r):i}boolAttr(t,n,i=null){return $H(this.attr(t,n),i)}lengthAttr(t,n,i=Zt.Dxa){return yM(this.attr(t,n),i)}},N=new Vb,Mn=class{constructor(t,n){this._package=t,this.path=n}async load(){this.rels=await this._package.loadRelationships(this.path);let t=await this._package.load(this.path),n=this._package.parseXmlDocument(t);this._package.options.keepOrigin&&(this._xmlDocument=n),this.parseXml(n.firstElementChild)}save(){this._package.update(this.path,RH(this._xmlDocument))}parseXml(t){}},TH={embedRegular:"regular",embedBold:"bold",embedItalic:"italic",embedBoldItalic:"boldItalic"};function EH(e,t){return t.elements(e).map(n=>CH(n,t))}function CH(e,t){let n={name:t.attr(e,"name"),embedFontRefs:[]};for(let i of t.elements(e))switch(i.localName){case"family":n.family=t.attr(i,"val");break;case"altName":n.altName=t.attr(i,"val");break;case"embedRegular":case"embedBold":case"embedItalic":case"embedBoldItalic":n.embedFontRefs.push(IH(i,t));break}return n}function IH(e,t){return{id:t.attr(e,"id"),key:t.attr(e,"fontKey"),type:TH[e.localName]}}var Ux=class extends Mn{parseXml(t){this.fonts=EH(t,this._package.xmlParser)}};function NH(e,t){return t.elements(e).map(n=>({extension:t.attr(n,"Extension"),partName:t.attr(n,"PartName"),contentType:t.attr(n,"ContentType")}))}var Lx=class e{constructor(t,n){this._zip=t,this.options=n,this.xmlParser=new Vb}get(t){let n=OH(t);return this._zip.files[n]??this._zip.files[n.replace(/\//g,"\\")]}update(t,n){this._zip.file(t,n)}static async load(t,n){let i=await vM.default.loadAsync(t);return new e(i,n)}save(t="blob"){return this._zip.generateAsync({type:t})}load(t,n="string"){return this.get(t)?.async(n)??Promise.resolve(null)}async loadRelationships(t=null){let n="_rels/.rels";if(t!=null){let[r,a]=qb(t);n=`${r}_rels/${a}.rels`}let i=await this.load(n);return i?yH(this.parseXmlDocument(i).firstElementChild,this.xmlParser):null}async loadContentTypes(){let t=await this.load("[Content_Types].xml");return t?NH(this.parseXmlDocument(t).firstElementChild,this.xmlParser):[]}parseXmlDocument(t){return zH(t,this.options.trimXmlDeclaration)}};function OH(e){return e.startsWith("/")?e.substr(1):e}var qx=class extends Mn{constructor(t,n,i){super(t,n),this._documentParser=i}parseXml(t){this.body=this._documentParser.parseDocumentFile(t)}};function Lb(e,t){return{type:t.attr(e,"val"),color:t.attr(e,"color"),size:t.lengthAttr(e,"sz",Zt.Border),offset:t.lengthAttr(e,"space",Zt.Point),frame:t.boolAttr(e,"frame"),shadow:t.boolAttr(e,"shadow")}}function AH(e,t){var n={};for(let i of t.elements(e))switch(i.localName){case"left":n.left=Lb(i,t);break;case"top":n.top=Lb(i,t);break;case"right":n.right=Lb(i,t);break;case"bottom":n.bottom=Lb(i,t);break}return n}var cM;(function(e){e.Continuous="continuous",e.NextPage="nextPage",e.NextColumn="nextColumn",e.EvenPage="evenPage",e.OddPage="oddPage"})(cM||(cM={}));function _M(e,t=N){var n={};for(let i of t.elements(e))switch(i.localName){case"pgSz":n.pageSize={width:t.lengthAttr(i,"w"),height:t.lengthAttr(i,"h"),orientation:t.attr(i,"orient")};break;case"type":n.type=t.attr(i,"val");break;case"pgMar":n.pageMargins={left:t.lengthAttr(i,"left"),right:t.lengthAttr(i,"right"),top:t.lengthAttr(i,"top"),bottom:t.lengthAttr(i,"bottom"),header:t.lengthAttr(i,"header"),footer:t.lengthAttr(i,"footer"),gutter:t.lengthAttr(i,"gutter")};break;case"cols":n.columns=PH(i,t);break;case"headerReference":(n.headerRefs??(n.headerRefs=[])).push(uM(i,t));break;case"footerReference":(n.footerRefs??(n.footerRefs=[])).push(uM(i,t));break;case"titlePg":n.titlePage=t.boolAttr(i,"val",!0);break;case"pgBorders":n.pageBorders=AH(i,t);break;case"pgNumType":n.pageNumber=MH(i,t);break}return n}function PH(e,t){return{numberOfColumns:t.intAttr(e,"num"),space:t.lengthAttr(e,"space"),separator:t.boolAttr(e,"sep"),equalWidth:t.boolAttr(e,"equalWidth",!0),columns:t.elements(e,"col").map(n=>({width:t.lengthAttr(n,"w"),space:t.lengthAttr(n,"space")}))}}function MH(e,t){return{chapSep:t.attr(e,"chapSep"),chapStyle:t.attr(e,"chapStyle"),format:t.attr(e,"fmt"),start:t.intAttr(e,"start")}}function uM(e,t){return{id:t.attr(e,"id"),type:t.attr(e,"type")}}function DH(e,t){return{before:t.lengthAttr(e,"before"),after:t.lengthAttr(e,"after"),line:t.intAttr(e,"line"),lineRule:t.attr(e,"lineRule")}}function p1(e,t){let n={};for(let i of t.elements(e))jH(i,n,t);return n}function jH(e,t,n){return!!SM(e,t,n)}function wM(e,t){let n={};for(let i of t.elements(e))$M(i,n,t);return n}function $M(e,t,n){if(e.namespaceURI!=bM.wordml)return!1;if(SM(e,t,n))return!0;switch(e.localName){case"tabs":t.tabs=UH(e,n);break;case"sectPr":t.sectionProps=_M(e,n);break;case"numPr":t.numbering=LH(e,n);break;case"spacing":return t.lineSpacing=DH(e,n),!1;case"textAlignment":return t.textAlignment=n.attr(e,"val"),!1;case"keepLines":t.keepLines=n.boolAttr(e,"val",!0);break;case"keepNext":t.keepNext=n.boolAttr(e,"val",!0);break;case"pageBreakBefore":t.pageBreakBefore=n.boolAttr(e,"val",!0);break;case"outlineLvl":t.outlineLevel=n.intAttr(e,"val");break;case"pStyle":t.styleName=n.attr(e,"val");break;case"rPr":t.runProps=p1(e,n);break;default:return!1}return!0}function UH(e,t){return t.elements(e,"tab").map(n=>({position:t.lengthAttr(n,"pos"),leader:t.attr(n,"leader"),style:t.attr(n,"val")}))}function LH(e,t){var n={};for(let i of t.elements(e))switch(i.localName){case"numId":n.id=t.attr(i,"val");break;case"ilvl":n.level=t.intAttr(i,"val");break}return n}function qH(e,t){let n={numberings:[],abstractNumberings:[],bulletPictures:[]};for(let i of t.elements(e))switch(i.localName){case"num":n.numberings.push(BH(i,t));break;case"abstractNum":n.abstractNumberings.push(HH(i,t));break;case"numPicBullet":n.bulletPictures.push(ZH(i,t));break}return n}function BH(e,t){let n={id:t.attr(e,"numId"),overrides:[]};for(let i of t.elements(e))switch(i.localName){case"abstractNumId":n.abstractId=t.attr(i,"val");break;case"lvlOverride":n.overrides.push(VH(i,t));break}return n}function HH(e,t){let n={id:t.attr(e,"abstractNumId"),levels:[]};for(let i of t.elements(e))switch(i.localName){case"name":n.name=t.attr(i,"val");break;case"multiLevelType":n.multiLevelType=t.attr(i,"val");break;case"numStyleLink":n.numberingStyleLink=t.attr(i,"val");break;case"styleLink":n.styleLink=t.attr(i,"val");break;case"lvl":n.levels.push(zM(i,t));break}return n}function zM(e,t){let n={level:t.intAttr(e,"ilvl")};for(let i of t.elements(e))switch(i.localName){case"start":n.start=t.attr(i,"val");break;case"lvlRestart":n.restart=t.intAttr(i,"val");break;case"numFmt":n.format=t.attr(i,"val");break;case"lvlText":n.text=t.attr(i,"val");break;case"lvlJc":n.justification=t.attr(i,"val");break;case"lvlPicBulletId":n.bulletPictureId=t.attr(i,"val");break;case"pStyle":n.paragraphStyle=t.attr(i,"val");break;case"pPr":n.paragraphProps=wM(i,t);break;case"rPr":n.runProps=p1(i,t);break}return n}function VH(e,t){let n={level:t.intAttr(e,"ilvl")};for(let i of t.elements(e))switch(i.localName){case"startOverride":n.start=t.intAttr(i,"val");break;case"lvl":n.numberingLevel=zM(i,t);break}return n}function ZH(e,t){var n=t.element(e,"pict"),i=n&&t.element(n,"shape"),r=i&&t.element(i,"imagedata");return r?{id:t.attr(e,"numPicBulletId"),referenceId:t.attr(r,"id"),style:t.attr(i,"style")}:null}var Bx=class extends Mn{constructor(t,n,i){super(t,n),this._documentParser=i}parseXml(t){Object.assign(this,qH(t,this._package.xmlParser)),this.domNumberings=this._documentParser.parseNumberingFile(t)}},Hx=class extends Mn{constructor(t,n,i){super(t,n),this._documentParser=i}parseXml(t){this.styles=this._documentParser.parseStylesFile(t)}},Z;(function(e){e.Document="document",e.Paragraph="paragraph",e.Run="run",e.Break="break",e.NoBreakHyphen="noBreakHyphen",e.Table="table",e.Row="row",e.Cell="cell",e.Hyperlink="hyperlink",e.SmartTag="smartTag",e.Drawing="drawing",e.Image="image",e.Text="text",e.Tab="tab",e.Symbol="symbol",e.BookmarkStart="bookmarkStart",e.BookmarkEnd="bookmarkEnd",e.Footer="footer",e.Header="header",e.FootnoteReference="footnoteReference",e.EndnoteReference="endnoteReference",e.Footnote="footnote",e.Endnote="endnote",e.SimpleField="simpleField",e.ComplexField="complexField",e.Instruction="instruction",e.VmlPicture="vmlPicture",e.MmlMath="mmlMath",e.MmlMathParagraph="mmlMathParagraph",e.MmlFraction="mmlFraction",e.MmlFunction="mmlFunction",e.MmlFunctionName="mmlFunctionName",e.MmlNumerator="mmlNumerator",e.MmlDenominator="mmlDenominator",e.MmlRadical="mmlRadical",e.MmlBase="mmlBase",e.MmlDegree="mmlDegree",e.MmlSuperscript="mmlSuperscript",e.MmlSubscript="mmlSubscript",e.MmlPreSubSuper="mmlPreSubSuper",e.MmlSubArgument="mmlSubArgument",e.MmlSuperArgument="mmlSuperArgument",e.MmlNary="mmlNary",e.MmlDelimiter="mmlDelimiter",e.MmlRun="mmlRun",e.MmlEquationArray="mmlEquationArray",e.MmlLimit="mmlLimit",e.MmlLimitLower="mmlLimitLower",e.MmlMatrix="mmlMatrix",e.MmlMatrixRow="mmlMatrixRow",e.MmlBox="mmlBox",e.MmlBar="mmlBar",e.MmlGroupChar="mmlGroupChar",e.VmlElement="vmlElement",e.Inserted="inserted",e.Deleted="deleted",e.DeletedText="deletedText",e.Comment="comment",e.CommentReference="commentReference",e.CommentRangeStart="commentRangeStart",e.CommentRangeEnd="commentRangeEnd",e.AltChunk="altChunk"})(Z||(Z={}));var oa=class{constructor(){this.children=[],this.cssStyle={}}},Vx=class extends oa{constructor(){super(...arguments),this.type=Z.Header}},Zx=class extends oa{constructor(){super(...arguments),this.type=Z.Footer}},Zb=class extends Mn{constructor(t,n,i){super(t,n),this._documentParser=i}parseXml(t){this.rootElement=this.createRootElement(),this.rootElement.children=this._documentParser.parseBodyElements(t)}},Fx=class extends Zb{createRootElement(){return new Vx}},Gx=class extends Zb{createRootElement(){return new Zx}};function FH(e,t){let n={};for(let i of t.elements(e))switch(i.localName){case"Template":n.template=i.textContent;break;case"Pages":n.pages=Km(i.textContent);break;case"Words":n.words=Km(i.textContent);break;case"Characters":n.characters=Km(i.textContent);break;case"Application":n.application=i.textContent;break;case"Lines":n.lines=Km(i.textContent);break;case"Paragraphs":n.paragraphs=Km(i.textContent);break;case"Company":n.company=i.textContent;break;case"AppVersion":n.appVersion=i.textContent;break}return n}function Km(e){if(!(typeof e>"u"))return parseInt(e)}var Kx=class extends Mn{parseXml(t){this.props=FH(t,this._package.xmlParser)}};function GH(e,t){let n={};for(let i of t.elements(e))switch(i.localName){case"title":n.title=i.textContent;break;case"description":n.description=i.textContent;break;case"subject":n.subject=i.textContent;break;case"creator":n.creator=i.textContent;break;case"keywords":n.keywords=i.textContent;break;case"language":n.language=i.textContent;break;case"lastModifiedBy":n.lastModifiedBy=i.textContent;break;case"revision":i.textContent&&(n.revision=parseInt(i.textContent));break}return n}var Jx=class extends Mn{parseXml(t){this.props=GH(t,this._package.xmlParser)}},Yx=class{};function KH(e,t){var n=new Yx,i=t.element(e,"themeElements");for(let r of t.elements(i))switch(r.localName){case"clrScheme":n.colorScheme=JH(r,t);break;case"fontScheme":n.fontScheme=YH(r,t);break}return n}function JH(e,t){var n={name:t.attr(e,"name"),colors:{}};for(let a of t.elements(e)){var i=t.element(a,"srgbClr"),r=t.element(a,"sysClr");i?n.colors[a.localName]=t.attr(i,"val"):r&&(n.colors[a.localName]=t.attr(r,"lastClr"))}return n}function YH(e,t){var n={name:t.attr(e,"name")};for(let i of t.elements(e))switch(i.localName){case"majorFont":n.majorFont=dM(i,t);break;case"minorFont":n.minorFont=dM(i,t);break}return n}function dM(e,t){return{latinTypeface:t.elementAttr(e,"latin","typeface"),eaTypeface:t.elementAttr(e,"ea","typeface"),csTypeface:t.elementAttr(e,"cs","typeface")}}var Xx=class extends Mn{constructor(t,n){super(t,n)}parseXml(t){this.theme=KH(t,this._package.xmlParser)}},Fb=class{},Wx=class extends Fb{constructor(){super(...arguments),this.type=Z.Footnote}},Qx=class extends Fb{constructor(){super(...arguments),this.type=Z.Endnote}},Gb=class extends Mn{constructor(t,n,i){super(t,n),this._documentParser=i}},e1=class extends Gb{constructor(t,n,i){super(t,n,i)}parseXml(t){this.notes=this._documentParser.parseNotes(t,"footnote",Wx)}},t1=class extends Gb{constructor(t,n,i){super(t,n,i)}parseXml(t){this.notes=this._documentParser.parseNotes(t,"endnote",Qx)}};function XH(e,t){var n={};for(let i of t.elements(e))switch(i.localName){case"defaultTabStop":n.defaultTabStop=t.lengthAttr(i,"val");break;case"footnotePr":n.footnoteProps=fM(i,t);break;case"endnotePr":n.endnoteProps=fM(i,t);break;case"autoHyphenation":n.autoHyphenation=t.boolAttr(i,"val");break}return n}function fM(e,t){var n={defaultNoteIds:[]};for(let i of t.elements(e))switch(i.localName){case"numFmt":n.nummeringFormat=t.attr(i,"val");break;case"footnote":case"endnote":n.defaultNoteIds.push(t.attr(i,"id"));break}return n}var n1=class extends Mn{constructor(t,n){super(t,n)}parseXml(t){this.settings=XH(t,this._package.xmlParser)}};function WH(e,t){return t.elements(e,"property").map(n=>{let i=n.firstChild;return{formatId:t.attr(n,"fmtid"),name:t.attr(n,"name"),type:i.nodeName,value:i.textContent}})}var r1=class extends Mn{parseXml(t){this.props=WH(t,this._package.xmlParser)}},i1=class extends Mn{constructor(t,n,i){super(t,n),this._documentParser=i}parseXml(t){this.comments=this._documentParser.parseComments(t),this.commentMap=io(this.comments,n=>n.id)}},a1=class extends Mn{constructor(t,n){super(t,n),this.comments=[]}parseXml(t){let n=this._package.xmlParser;for(let i of n.elements(t,"commentEx"))this.comments.push({paraId:n.attr(i,"paraId"),paraIdParent:n.attr(i,"paraIdParent"),done:n.boolAttr(i,"done")});this.commentMap=io(this.comments,i=>i.paraId)}},QH=[{type:Ut.OfficeDocument,target:"word/document.xml"},{type:Ut.ExtendedProperties,target:"docProps/app.xml"},{type:Ut.CoreProperties,target:"docProps/core.xml"},{type:Ut.CustomProperties,target:"docProps/custom.xml"}],o1=class e{constructor(){this.parts=[],this.partsMap={},this.contentTypes=[]}static async load(t,n,i){var r=new e;return r._options=i,r._parser=n,r._package=await Lx.load(t,i),r.rels=await r._package.loadRelationships(),r.contentTypes=await r._package.loadContentTypes(),await Promise.all(QH.map(a=>{let o=r.rels.find(s=>s.type===a.type)??a;return r.loadRelationshipPart(o.target,o.type)})),r}save(t="blob"){return this._package.save(t)}async loadRelationshipPart(t,n){if(this.partsMap[t])return this.partsMap[t];if(!this._package.get(t))return null;let i=null;switch(n){case Ut.OfficeDocument:this.documentPart=i=new qx(this._package,t,this._parser);break;case Ut.FontTable:this.fontTablePart=i=new Ux(this._package,t);break;case Ut.Numbering:this.numberingPart=i=new Bx(this._package,t,this._parser);break;case Ut.Styles:this.stylesPart=i=new Hx(this._package,t,this._parser);break;case Ut.Theme:this.themePart=i=new Xx(this._package,t);break;case Ut.Footnotes:this.footnotesPart=i=new e1(this._package,t,this._parser);break;case Ut.Endnotes:this.endnotesPart=i=new t1(this._package,t,this._parser);break;case Ut.Footer:i=new Gx(this._package,t,this._parser);break;case Ut.Header:i=new Fx(this._package,t,this._parser);break;case Ut.CoreProperties:this.corePropsPart=i=new Jx(this._package,t);break;case Ut.ExtendedProperties:this.extendedPropsPart=i=new Kx(this._package,t);break;case Ut.CustomProperties:i=new r1(this._package,t);break;case Ut.Settings:this.settingsPart=i=new n1(this._package,t);break;case Ut.Comments:this.commentsPart=i=new i1(this._package,t,this._parser);break;case Ut.CommentsExtended:this.commentsExtendedPart=i=new a1(this._package,t);break}if(i==null)return Promise.resolve(null);if(this.partsMap[t]=i,this.parts.push(i),await i.load(),i.rels?.length>0){let[r]=qb(i.path);await Promise.all(i.rels.map(a=>this.loadRelationshipPart(Px(a.target,r),a.type)))}return i}async loadDocumentImage(t,n){let i=this.getPathById(n??this.documentPart,t);return i?this.blobToURL(await this._package.load(i,"blob"),i):null}async loadNumberingImage(t){let n=this.getPathById(this.numberingPart,t);return n?this.blobToURL(await this._package.load(n,"blob"),n):null}async loadFont(t,n){let i=this.getPathById(this.fontTablePart,t);if(!i)return null;let r=await this._package.load(i,"uint8array");return r&&this.blobToURL(new Blob([eV(r,n)]),i)}async loadAltChunk(t,n){let i=this.getPathById(n??this.documentPart,t);return i?this._package.load(i,"string"):Promise.resolve(null)}blobToURL(t,n){if(!t)return null;if(n){let i=this.contentTypes.find(r=>r.partName===n||r.extension&&n.endsWith(`.${r.extension}`));t=i?new Blob([t],{type:i.contentType}):t}return this._options.useBase64URL?_H(t):URL.createObjectURL(t)}findPartByRelId(t,n=null){var i=(n.rels??this.rels).find(a=>a.id==t);let r=n?qb(n.path)[0]:"";return i?this.partsMap[Px(i.target,r)]:null}getPathById(t,n){let i=t.rels.find(a=>a.id==n),[r]=qb(t.path);return i?Px(i.target,r):null}};function eV(e,t){let i=t.replace(/{|}|-/g,""),r=new Array(16);for(let a=0;a<16;a++)r[16-a-1]=parseInt(i.substring(a*2,a*2+2),16);for(let a=0;a<32;a++)e[a]=e[a]^r[a%16];return e}function tV(e,t){return{type:Z.BookmarkStart,id:t.attr(e,"id"),name:t.attr(e,"name"),colFirst:t.intAttr(e,"colFirst"),colLast:t.intAttr(e,"colLast")}}function nV(e,t){return{type:Z.BookmarkEnd,id:t.attr(e,"id")}}var s1=class extends oa{constructor(){super(...arguments),this.type=Z.VmlElement,this.attrs={}}};function kM(e,t){var n=new s1;switch(e.localName){case"rect":n.tagName="rect",Object.assign(n.attrs,{width:"100%",height:"100%"});break;case"oval":n.tagName="ellipse",Object.assign(n.attrs,{cx:"50%",cy:"50%",rx:"50%",ry:"50%"});break;case"line":n.tagName="line";break;case"shape":n.tagName="g";break;case"textbox":n.tagName="foreignObject",Object.assign(n.attrs,{width:"100%",height:"100%"});break;default:return null}for(let i of N.attrs(e))switch(i.localName){case"style":n.cssStyleText=i.value;break;case"fillcolor":n.attrs.fill=i.value;break;case"from":let[r,a]=mM(i.value);Object.assign(n.attrs,{x1:r,y1:a});break;case"to":let[o,s]=mM(i.value);Object.assign(n.attrs,{x2:o,y2:s});break}for(let i of N.elements(e))switch(i.localName){case"stroke":Object.assign(n.attrs,rV(i));break;case"fill":Object.assign(n.attrs,iV());break;case"imagedata":n.tagName="image",Object.assign(n.attrs,{width:"100%",height:"100%"}),n.imageHref={id:N.attr(i,"id"),title:N.attr(i,"title")};break;case"txbxContent":n.children.push(...t.parseBodyElements(i));break;default:let r=kM(i,t);r&&n.children.push(r);break}return n}function rV(e){return{stroke:N.attr(e,"color"),"stroke-width":N.lengthAttr(e,"weight",Zt.Emu)??"1px"}}function iV(e){return{}}function mM(e){return e.split(",")}var l1=class extends oa{constructor(){super(...arguments),this.type=Z.Comment}},c1=class extends oa{constructor(t){super(),this.id=t,this.type=Z.CommentReference}},u1=class extends oa{constructor(t){super(),this.id=t,this.type=Z.CommentRangeStart}},d1=class extends oa{constructor(t){super(),this.id=t,this.type=Z.CommentRangeEnd}},Bb={shd:"inherit",color:"black",borderColor:"black",highlight:"transparent"},aV=[],pM={oMath:Z.MmlMath,oMathPara:Z.MmlMathParagraph,f:Z.MmlFraction,func:Z.MmlFunction,fName:Z.MmlFunctionName,num:Z.MmlNumerator,den:Z.MmlDenominator,rad:Z.MmlRadical,deg:Z.MmlDegree,e:Z.MmlBase,sSup:Z.MmlSuperscript,sSub:Z.MmlSubscript,sPre:Z.MmlPreSubSuper,sup:Z.MmlSuperArgument,sub:Z.MmlSubArgument,d:Z.MmlDelimiter,nary:Z.MmlNary,eqArr:Z.MmlEquationArray,lim:Z.MmlLimit,limLow:Z.MmlLimitLower,m:Z.MmlMatrix,mr:Z.MmlMatrixRow,box:Z.MmlBox,bar:Z.MmlBar,groupChr:Z.MmlGroupChar},f1=class{constructor(t){this.options={ignoreWidth:!1,debug:!1,...t}}parseNotes(t,n,i){var r=[];for(let a of N.elements(t,n)){let o=new i;o.id=N.attr(a,"id"),o.noteType=N.attr(a,"type"),o.children=this.parseBodyElements(a),r.push(o)}return r}parseComments(t){var n=[];for(let i of N.elements(t,"comment")){let r=new l1;r.id=N.attr(i,"id"),r.author=N.attr(i,"author"),r.initials=N.attr(i,"initials"),r.date=N.attr(i,"date"),r.children=this.parseBodyElements(i),n.push(r)}return n}parseDocumentFile(t){var n=N.element(t,"body"),i=N.element(t,"background"),r=N.element(n,"sectPr");return{type:Z.Document,children:this.parseBodyElements(n),props:r?_M(r,N):{},cssStyle:i?this.parseBackground(i):{}}}parseBackground(t){var n={},i=ao.colorAttr(t,"color");return i&&(n["background-color"]=i),n}parseBodyElements(t){var n=[];for(let i of N.elements(t))switch(i.localName){case"p":n.push(this.parseParagraph(i));break;case"altChunk":n.push(this.parseAltChunk(i));break;case"tbl":n.push(this.parseTable(i));break;case"sdt":n.push(...this.parseSdt(i,r=>this.parseBodyElements(r)));break}return n}parseStylesFile(t){var n=[];for(let i of N.elements(t))switch(i.localName){case"style":n.push(this.parseStyle(i));break;case"docDefaults":n.push(this.parseDefaultStyles(i));break}return n}parseDefaultStyles(t){var n={id:null,name:null,target:null,basedOn:null,styles:[]};for(let a of N.elements(t))switch(a.localName){case"rPrDefault":var i=N.element(a,"rPr");i&&n.styles.push({target:"span",values:this.parseDefaultProperties(i,{})});break;case"pPrDefault":var r=N.element(a,"pPr");r&&n.styles.push({target:"p",values:this.parseDefaultProperties(r,{})});break}return n}parseStyle(t){var n={id:N.attr(t,"styleId"),isDefault:N.boolAttr(t,"default"),name:null,target:null,basedOn:null,styles:[],linked:null};switch(N.attr(t,"type")){case"paragraph":n.target="p";break;case"table":n.target="table";break;case"character":n.target="span";break}for(let i of N.elements(t))switch(i.localName){case"basedOn":n.basedOn=N.attr(i,"val");break;case"name":n.name=N.attr(i,"val");break;case"link":n.linked=N.attr(i,"val");break;case"next":n.next=N.attr(i,"val");break;case"aliases":n.aliases=N.attr(i,"val").split(",");break;case"pPr":n.styles.push({target:"p",values:this.parseDefaultProperties(i,{})}),n.paragraphProps=wM(i,N);break;case"rPr":n.styles.push({target:"span",values:this.parseDefaultProperties(i,{})}),n.runProps=p1(i,N);break;case"tblPr":case"tcPr":n.styles.push({target:"td",values:this.parseDefaultProperties(i,{})});break;case"tblStylePr":for(let r of this.parseTableStyle(i))n.styles.push(r);break;case"rsid":case"qFormat":case"hidden":case"semiHidden":case"unhideWhenUsed":case"autoRedefine":case"uiPriority":break;default:this.options.debug&&console.warn(`DOCX: Unknown style element: ${i.localName}`)}return n}parseTableStyle(t){var n=[],i=N.attr(t,"type"),r="",a="";switch(i){case"firstRow":a=".first-row",r="tr.first-row td";break;case"lastRow":a=".last-row",r="tr.last-row td";break;case"firstCol":a=".first-col",r="td.first-col";break;case"lastCol":a=".last-col",r="td.last-col";break;case"band1Vert":a=":not(.no-vband)",r="td.odd-col";break;case"band2Vert":a=":not(.no-vband)",r="td.even-col";break;case"band1Horz":a=":not(.no-hband)",r="tr.odd-row";break;case"band2Horz":a=":not(.no-hband)",r="tr.even-row";break;default:return[]}for(let o of N.elements(t))switch(o.localName){case"pPr":n.push({target:`${r} p`,mod:a,values:this.parseDefaultProperties(o,{})});break;case"rPr":n.push({target:`${r} span`,mod:a,values:this.parseDefaultProperties(o,{})});break;case"tblPr":case"tcPr":n.push({target:r,mod:a,values:this.parseDefaultProperties(o,{})});break}return n}parseNumberingFile(t){let n=[],i=[],r=[];for(let a of N.elements(t))switch(a.localName){case"abstractNum":n.push(...this.parseAbstractNumbering(a,r));break;case"numPicBullet":r.push(this.parseNumberingPicBullet(a));break;case"num":i.push({numId:N.attr(a,"numId"),abstractNumId:N.elementAttr(a,"abstractNumId","val")});break}return i.flatMap(a=>n.filter(o=>a.abstractNumId==o.id).map(o=>({...o,id:a.numId})))}parseNumberingPicBullet(t){var n=N.element(t,"pict"),i=n&&N.element(n,"shape"),r=i&&N.element(i,"imagedata");return r?{id:N.intAttr(t,"numPicBulletId"),src:N.attr(r,"id"),style:N.attr(i,"style")}:null}parseAbstractNumbering(t,n){var i=[],r=N.attr(t,"abstractNumId");for(let a of N.elements(t))switch(a.localName){case"lvl":i.push(this.parseNumberingLevel(r,a,n));break}return i}parseNumberingLevel(t,n,i){var r={id:t,level:N.intAttr(n,"ilvl"),start:1,pStyleName:void 0,pStyle:{},rStyle:{},suff:"tab"};for(let o of N.elements(n))switch(o.localName){case"start":r.start=N.intAttr(o,"val");break;case"pPr":this.parseDefaultProperties(o,r.pStyle);break;case"rPr":this.parseDefaultProperties(o,r.rStyle);break;case"lvlPicBulletId":var a=N.intAttr(o,"val");r.bullet=i.find(s=>s?.id==a);break;case"lvlText":r.levelText=N.attr(o,"val");break;case"pStyle":r.pStyleName=N.attr(o,"val");break;case"numFmt":r.format=N.attr(o,"val");break;case"suff":r.suff=N.attr(o,"val");break}return r}parseSdt(t,n){let i=N.element(t,"sdtContent");return i?n(i):[]}parseChange(t,n,i){return{type:t,children:i(n)?.children??[],id:N.attr(n,"id"),author:N.attr(n,"author"),date:N.attr(n,"date")}}parseAltChunk(t){return{type:Z.AltChunk,children:[],id:N.attr(t,"id")}}parseParagraph(t){var n={type:Z.Paragraph,children:[]};for(let i of N.elements(t))switch(i.localName){case"pPr":this.parseParagraphProperties(i,n);break;case"r":n.children.push(this.parseRun(i,n));break;case"hyperlink":n.children.push(this.parseHyperlink(i,n));break;case"smartTag":n.children.push(this.parseSmartTag(i,n));break;case"bookmarkStart":n.children.push(tV(i,N));break;case"bookmarkEnd":n.children.push(nV(i,N));break;case"commentRangeStart":n.children.push(new u1(N.attr(i,"id")));break;case"commentRangeEnd":n.children.push(new d1(N.attr(i,"id")));break;case"oMath":case"oMathPara":n.children.push(this.parseMathElement(i));break;case"sdt":n.children.push(...this.parseSdt(i,r=>this.parseParagraph(r).children));break;case"ins":n.children.push(this.parseChange(Z.Inserted,i,r=>this.parseParagraph(r)));break;case"del":n.children.push(this.parseChange(Z.Deleted,i,r=>this.parseParagraph(r)));break}return n}parseParagraphProperties(t,n){this.parseDefaultProperties(t,n.cssStyle={},null,i=>{if($M(i,n,N))return!0;switch(i.localName){case"pStyle":n.styleName=N.attr(i,"val");break;case"cnfStyle":n.className=pt.classNameOfCnfStyle(i);break;case"framePr":this.parseFrame(i,n);break;case"rPr":break;default:return!1}return!0})}parseFrame(t,n){var i=N.attr(t,"dropCap");i=="drop"&&(n.cssStyle.float="left")}parseHyperlink(t,n){var i={type:Z.Hyperlink,parent:n,children:[]};i.anchor=N.attr(t,"anchor"),i.id=N.attr(t,"id");for(let r of N.elements(t))switch(r.localName){case"r":i.children.push(this.parseRun(r,i));break}return i}parseSmartTag(t,n){var i={type:Z.SmartTag,parent:n,children:[]},r=N.attr(t,"uri"),a=N.attr(t,"element");r&&(i.uri=r),a&&(i.element=a);for(let o of N.elements(t))switch(o.localName){case"r":i.children.push(this.parseRun(o,i));break;case"smartTag":i.children.push(this.parseSmartTag(o,i));break}return i}parseRun(t,n){var i={type:Z.Run,parent:n,children:[]};for(let r of N.elements(t))switch(r=this.checkAlternateContent(r),r.localName){case"t":i.children.push({type:Z.Text,text:r.textContent});break;case"delText":i.children.push({type:Z.DeletedText,text:r.textContent});break;case"commentReference":i.children.push(new c1(N.attr(r,"id")));break;case"fldSimple":i.children.push({type:Z.SimpleField,instruction:N.attr(r,"instr"),lock:N.boolAttr(r,"lock",!1),dirty:N.boolAttr(r,"dirty",!1)});break;case"instrText":i.fieldRun=!0,i.children.push({type:Z.Instruction,text:r.textContent});break;case"fldChar":i.fieldRun=!0,i.children.push({type:Z.ComplexField,charType:N.attr(r,"fldCharType"),lock:N.boolAttr(r,"lock",!1),dirty:N.boolAttr(r,"dirty",!1)});break;case"noBreakHyphen":i.children.push({type:Z.NoBreakHyphen});break;case"br":i.children.push({type:Z.Break,break:N.attr(r,"type")||"textWrapping"});break;case"lastRenderedPageBreak":i.children.push({type:Z.Break,break:"lastRenderedPageBreak"});break;case"sym":i.children.push({type:Z.Symbol,font:Dx(N.attr(r,"font")),char:N.hexAttr(r,"char")});break;case"tab":i.children.push({type:Z.Tab});break;case"footnoteReference":i.children.push({type:Z.FootnoteReference,id:N.attr(r,"id")});break;case"endnoteReference":i.children.push({type:Z.EndnoteReference,id:N.attr(r,"id")});break;case"drawing":let a=this.parseDrawing(r);a&&i.children.push(a);break;case"pict":i.children.push(this.parseVmlPicture(r));break;case"rPr":this.parseRunProperties(r,i);break}return i}parseMathElement(t){let n=`${t.localName}Pr`,i={type:pM[t.localName],children:[]};for(let a of N.elements(t))if(pM[a.localName])i.children.push(this.parseMathElement(a));else if(a.localName=="r"){var r=this.parseRun(a);r.type=Z.MmlRun,i.children.push(r)}else a.localName==n&&(i.props=this.parseMathProperies(a));return i}parseMathProperies(t){let n={};for(let i of N.elements(t))switch(i.localName){case"chr":n.char=N.attr(i,"val");break;case"vertJc":n.verticalJustification=N.attr(i,"val");break;case"pos":n.position=N.attr(i,"val");break;case"degHide":n.hideDegree=N.boolAttr(i,"val");break;case"begChr":n.beginChar=N.attr(i,"val");break;case"endChr":n.endChar=N.attr(i,"val");break}return n}parseRunProperties(t,n){this.parseDefaultProperties(t,n.cssStyle={},null,i=>{switch(i.localName){case"rStyle":n.styleName=N.attr(i,"val");break;case"vertAlign":n.verticalAlign=pt.valueOfVertAlign(i,!0);break;default:return!1}return!0})}parseVmlPicture(t){let n={type:Z.VmlPicture,children:[]};for(let i of N.elements(t)){let r=kM(i,this);r&&n.children.push(r)}return n}checkAlternateContent(t){if(t.localName!="AlternateContent")return t;var n=N.element(t,"Choice");if(n){var i=N.attr(n,"Requires"),r=t.lookupNamespaceURI(i);if(aV.includes(r))return n.firstElementChild}return N.element(t,"Fallback")?.firstElementChild}parseDrawing(t){for(var n of N.elements(t))switch(n.localName){case"inline":case"anchor":return this.parseDrawingWrapper(n)}}parseDrawingWrapper(t){var n={type:Z.Drawing,children:[],cssStyle:{}},i=t.localName=="anchor";let r=null,a=N.boolAttr(t,"simplePos");N.boolAttr(t,"behindDoc");let o={relative:"page",align:"left",offset:"0"},s={relative:"page",align:"top",offset:"0"};for(var l of N.elements(t))switch(l.localName){case"simplePos":a&&(o.offset=N.lengthAttr(l,"x",Zt.Emu),s.offset=N.lengthAttr(l,"y",Zt.Emu));break;case"extent":n.cssStyle.width=N.lengthAttr(l,"cx",Zt.Emu),n.cssStyle.height=N.lengthAttr(l,"cy",Zt.Emu);break;case"positionH":case"positionV":if(!a){let f=l.localName=="positionH"?o:s;var c=N.element(l,"align"),u=N.element(l,"posOffset");f.relative=N.attr(l,"relativeFrom")??f.relative,c&&(f.align=c.textContent),u&&(f.offset=yM(u.textContent,Zt.Emu))}break;case"wrapTopAndBottom":r="wrapTopAndBottom";break;case"wrapNone":r="wrapNone";break;case"graphic":var d=this.parseGraphic(l);d&&n.children.push(d);break}return r=="wrapTopAndBottom"?(n.cssStyle.display="block",o.align&&(n.cssStyle["text-align"]=o.align,n.cssStyle.width="100%")):r=="wrapNone"?(n.cssStyle.display="block",n.cssStyle.position="relative",n.cssStyle.width="0px",n.cssStyle.height="0px",o.offset&&(n.cssStyle.left=o.offset),s.offset&&(n.cssStyle.top=s.offset)):i&&(o.align=="left"||o.align=="right")&&(n.cssStyle.float=o.align),n}parseGraphic(t){var n=N.element(t,"graphicData");for(let i of N.elements(n))switch(i.localName){case"pic":return this.parsePicture(i)}return null}parsePicture(t){var n={type:Z.Image,src:"",cssStyle:{}},i=N.element(t,"blipFill"),r=N.element(i,"blip"),a=N.element(i,"srcRect");n.src=N.attr(r,"embed"),a&&(n.srcRect=[N.intAttr(a,"l",0)/1e5,N.intAttr(a,"t",0)/1e5,N.intAttr(a,"r",0)/1e5,N.intAttr(a,"b",0)/1e5]);var o=N.element(t,"spPr"),s=N.element(o,"xfrm");if(n.cssStyle.position="relative",s){n.rotation=N.intAttr(s,"rot",0)/6e4;for(var l of N.elements(s))switch(l.localName){case"ext":n.cssStyle.width=N.lengthAttr(l,"cx",Zt.Emu),n.cssStyle.height=N.lengthAttr(l,"cy",Zt.Emu);break;case"off":n.cssStyle.left=N.lengthAttr(l,"x",Zt.Emu),n.cssStyle.top=N.lengthAttr(l,"y",Zt.Emu);break}}return n}parseTable(t){var n={type:Z.Table,children:[]};for(let i of N.elements(t))switch(i.localName){case"tr":n.children.push(this.parseTableRow(i));break;case"tblGrid":n.columns=this.parseTableColumns(i);break;case"tblPr":this.parseTableProperties(i,n);break}return n}parseTableColumns(t){var n=[];for(let i of N.elements(t))switch(i.localName){case"gridCol":n.push({width:N.lengthAttr(i,"w")});break}return n}parseTableProperties(t,n){switch(n.cssStyle={},n.cellStyle={},this.parseDefaultProperties(t,n.cssStyle,n.cellStyle,i=>{switch(i.localName){case"tblStyle":n.styleName=N.attr(i,"val");break;case"tblLook":n.className=pt.classNameOftblLook(i);break;case"tblpPr":this.parseTablePosition(i,n);break;case"tblStyleColBandSize":n.colBandSize=N.intAttr(i,"val");break;case"tblStyleRowBandSize":n.rowBandSize=N.intAttr(i,"val");break;case"hidden":n.cssStyle.display="none";break;default:return!1}return!0}),n.cssStyle["text-align"]){case"center":delete n.cssStyle["text-align"],n.cssStyle["margin-left"]="auto",n.cssStyle["margin-right"]="auto";break;case"right":delete n.cssStyle["text-align"],n.cssStyle["margin-left"]="auto";break}}parseTablePosition(t,n){var i=N.lengthAttr(t,"topFromText"),r=N.lengthAttr(t,"bottomFromText"),a=N.lengthAttr(t,"rightFromText"),o=N.lengthAttr(t,"leftFromText");n.cssStyle.float="left",n.cssStyle["margin-bottom"]=pt.addSize(n.cssStyle["margin-bottom"],r),n.cssStyle["margin-left"]=pt.addSize(n.cssStyle["margin-left"],o),n.cssStyle["margin-right"]=pt.addSize(n.cssStyle["margin-right"],a),n.cssStyle["margin-top"]=pt.addSize(n.cssStyle["margin-top"],i)}parseTableRow(t){var n={type:Z.Row,children:[]};for(let i of N.elements(t))switch(i.localName){case"tc":n.children.push(this.parseTableCell(i));break;case"trPr":case"tblPrEx":this.parseTableRowProperties(i,n);break}return n}parseTableRowProperties(t,n){n.cssStyle=this.parseDefaultProperties(t,{},null,i=>{switch(i.localName){case"cnfStyle":n.className=pt.classNameOfCnfStyle(i);break;case"tblHeader":n.isHeader=N.boolAttr(i,"val");break;case"gridBefore":n.gridBefore=N.intAttr(i,"val");break;case"gridAfter":n.gridAfter=N.intAttr(i,"val");break;default:return!1}return!0})}parseTableCell(t){var n={type:Z.Cell,children:[]};for(let i of N.elements(t))switch(i.localName){case"tbl":n.children.push(this.parseTable(i));break;case"p":n.children.push(this.parseParagraph(i));break;case"tcPr":this.parseTableCellProperties(i,n);break}return n}parseTableCellProperties(t,n){n.cssStyle=this.parseDefaultProperties(t,{},null,i=>{switch(i.localName){case"gridSpan":n.span=N.intAttr(i,"val",null);break;case"vMerge":n.verticalMerge=N.attr(i,"val")??"continue";break;case"cnfStyle":n.className=pt.classNameOfCnfStyle(i);break;default:return!1}return!0}),this.parseTableCellVerticalText(t,n)}parseTableCellVerticalText(t,n){let i={btLr:{writingMode:"vertical-rl",transform:"rotate(180deg)"},lrTb:{writingMode:"vertical-lr",transform:"none"},tbRl:{writingMode:"vertical-rl",transform:"none"}};for(let r of N.elements(t))if(r.localName==="textDirection"){let a=N.attr(r,"val"),o=i[a]||{writingMode:"horizontal-tb"};n.cssStyle["writing-mode"]=o.writingMode,n.cssStyle.transform=o.transform}}parseDefaultProperties(t,n=null,i=null,r=null){n=n||{};for(let a of N.elements(t))if(!r?.(a))switch(a.localName){case"jc":n["text-align"]=pt.valueOfJc(a);break;case"textAlignment":n["vertical-align"]=pt.valueOfTextAlignment(a);break;case"color":n.color=ao.colorAttr(a,"val",null,Bb.color);break;case"sz":n["font-size"]=n["min-height"]=N.lengthAttr(a,"val",Zt.FontSize);break;case"shd":n["background-color"]=ao.colorAttr(a,"fill",null,Bb.shd);break;case"highlight":n["background-color"]=ao.colorAttr(a,"val",null,Bb.highlight);break;case"vertAlign":break;case"position":n.verticalAlign=N.lengthAttr(a,"val",Zt.FontSize);break;case"tcW":if(this.options.ignoreWidth)break;case"tblW":n.width=pt.valueOfSize(a,"w");break;case"trHeight":this.parseTrHeight(a,n);break;case"strike":n["text-decoration"]=N.boolAttr(a,"val",!0)?"line-through":"none";break;case"b":n["font-weight"]=N.boolAttr(a,"val",!0)?"bold":"normal";break;case"i":n["font-style"]=N.boolAttr(a,"val",!0)?"italic":"normal";break;case"caps":n["text-transform"]=N.boolAttr(a,"val",!0)?"uppercase":"none";break;case"smallCaps":n["font-variant"]=N.boolAttr(a,"val",!0)?"small-caps":"none";break;case"u":this.parseUnderline(a,n);break;case"ind":case"tblInd":this.parseIndentation(a,n);break;case"rFonts":this.parseFont(a,n);break;case"tblBorders":this.parseBorderProperties(a,i||n);break;case"tblCellSpacing":n["border-spacing"]=pt.valueOfMargin(a),n["border-collapse"]="separate";break;case"pBdr":this.parseBorderProperties(a,n);break;case"bdr":n.border=pt.valueOfBorder(a);break;case"tcBorders":this.parseBorderProperties(a,n);break;case"vanish":N.boolAttr(a,"val",!0)&&(n.display="none");break;case"kern":break;case"noWrap":break;case"tblCellMar":case"tcMar":this.parseMarginProperties(a,i||n);break;case"tblLayout":n["table-layout"]=pt.valueOfTblLayout(a);break;case"vAlign":n["vertical-align"]=pt.valueOfTextAlignment(a);break;case"spacing":t.localName=="pPr"&&this.parseSpacing(a,n);break;case"wordWrap":N.boolAttr(a,"val")&&(n["overflow-wrap"]="break-word");break;case"suppressAutoHyphens":n.hyphens=N.boolAttr(a,"val",!0)?"none":"auto";break;case"lang":n.$lang=N.attr(a,"val");break;case"rtl":case"bidi":N.boolAttr(a,"val",!0)&&(n.direction="rtl");break;case"bCs":case"iCs":case"szCs":case"tabs":case"outlineLvl":case"contextualSpacing":case"tblStyleColBandSize":case"tblStyleRowBandSize":case"webHidden":case"pageBreakBefore":case"suppressLineNumbers":case"keepLines":case"keepNext":case"widowControl":case"noProof":break;default:this.options.debug&&console.warn(`DOCX: Unknown document element: ${t.localName}.${a.localName}`);break}return n}parseUnderline(t,n){var i=N.attr(t,"val");if(i!=null){switch(i){case"dash":case"dashDotDotHeavy":case"dashDotHeavy":case"dashedHeavy":case"dashLong":case"dashLongHeavy":case"dotDash":case"dotDotDash":n["text-decoration"]="underline dashed";break;case"dotted":case"dottedHeavy":n["text-decoration"]="underline dotted";break;case"double":n["text-decoration"]="underline double";break;case"single":case"thick":n["text-decoration"]="underline";break;case"wave":case"wavyDouble":case"wavyHeavy":n["text-decoration"]="underline wavy";break;case"words":n["text-decoration"]="underline";break;case"none":n["text-decoration"]="none";break}var r=ao.colorAttr(t,"color");r&&(n["text-decoration-color"]=r)}}parseFont(t,n){var i=N.attr(t,"ascii"),r=pt.themeValue(t,"asciiTheme"),a=N.attr(t,"eastAsia"),o=[i,r,a].filter(s=>s).map(s=>Dx(s));o.length>0&&(n["font-family"]=[...new Set(o)].join(", "))}parseIndentation(t,n){var i=N.lengthAttr(t,"firstLine"),r=N.lengthAttr(t,"hanging"),a=N.lengthAttr(t,"left"),o=N.lengthAttr(t,"start"),s=N.lengthAttr(t,"right"),l=N.lengthAttr(t,"end");i&&(n["text-indent"]=i),r&&(n["text-indent"]=`-${r}`),(a||o)&&(n["margin-inline-start"]=a||o),(s||l)&&(n["margin-inline-end"]=s||l)}parseSpacing(t,n){var i=N.lengthAttr(t,"before"),r=N.lengthAttr(t,"after"),a=N.intAttr(t,"line",null),o=N.attr(t,"lineRule");if(i&&(n["margin-top"]=i),r&&(n["margin-bottom"]=r),a!==null)switch(o){case"auto":n["line-height"]=`${(a/240).toFixed(2)}`;break;case"atLeast":n["line-height"]=`calc(100% + ${a/20}pt)`;break;default:n["line-height"]=n["min-height"]=`${a/20}pt`;break}}parseMarginProperties(t,n){for(let i of N.elements(t))switch(i.localName){case"left":n["padding-left"]=pt.valueOfMargin(i);break;case"right":n["padding-right"]=pt.valueOfMargin(i);break;case"top":n["padding-top"]=pt.valueOfMargin(i);break;case"bottom":n["padding-bottom"]=pt.valueOfMargin(i);break}}parseTrHeight(t,n){switch(N.attr(t,"hRule")){case"exact":n.height=N.lengthAttr(t,"val");break;case"atLeast":default:n.height=N.lengthAttr(t,"val");break}}parseBorderProperties(t,n){for(let i of N.elements(t))switch(i.localName){case"start":case"left":n["border-left"]=pt.valueOfBorder(i);break;case"end":case"right":n["border-right"]=pt.valueOfBorder(i);break;case"top":n["border-top"]=pt.valueOfBorder(i);break;case"bottom":n["border-bottom"]=pt.valueOfBorder(i);break}}},oV=["black","blue","cyan","darkBlue","darkCyan","darkGray","darkGreen","darkMagenta","darkRed","darkYellow","green","lightGray","magenta","none","red","white","yellow"],ao=class{static colorAttr(t,n,i=null,r="black"){var a=N.attr(t,n);if(a)return a=="auto"?r:oV.includes(a)?a:`#${a}`;var o=N.attr(t,"themeColor");return o?`var(--docx-${o}-color)`:i}},pt=class e{static themeValue(t,n){var i=N.attr(t,n);return i?`var(--docx-${i}-font)`:null}static valueOfSize(t,n){var i=Zt.Dxa;switch(N.attr(t,"type")){case"dxa":break;case"pct":i=Zt.Percent;break;case"auto":return"auto"}return N.lengthAttr(t,n,i)}static valueOfMargin(t){return N.lengthAttr(t,"w")}static valueOfBorder(t){var n=e.parseBorderType(N.attr(t,"val"));if(n=="none")return"none";var i=ao.colorAttr(t,"color"),r=N.lengthAttr(t,"sz",Zt.Border);return`${r} ${n} ${i=="auto"?Bb.borderColor:i}`}static parseBorderType(t){switch(t){case"single":return"solid";case"dashDotStroked":return"solid";case"dashed":return"dashed";case"dashSmallGap":return"dashed";case"dotDash":return"dotted";case"dotDotDash":return"dotted";case"dotted":return"dotted";case"double":return"double";case"doubleWave":return"double";case"inset":return"inset";case"nil":return"none";case"none":return"none";case"outset":return"outset";case"thick":return"solid";case"thickThinLargeGap":return"solid";case"thickThinMediumGap":return"solid";case"thickThinSmallGap":return"solid";case"thinThickLargeGap":return"solid";case"thinThickMediumGap":return"solid";case"thinThickSmallGap":return"solid";case"thinThickThinLargeGap":return"solid";case"thinThickThinMediumGap":return"solid";case"thinThickThinSmallGap":return"solid";case"threeDEmboss":return"solid";case"threeDEngrave":return"solid";case"triple":return"double";case"wave":return"solid"}return"solid"}static valueOfTblLayout(t){var n=N.attr(t,"val");return n=="fixed"?"fixed":"auto"}static classNameOfCnfStyle(t){let n=N.attr(t,"val"),i=["first-row","last-row","first-col","last-col","odd-col","even-col","odd-row","even-row","ne-cell","nw-cell","se-cell","sw-cell"];if(n)return i.filter((a,o)=>n[o]=="1").join(" ");let r=["firstRow","lastRow","firstColumn","lastColumn","oddVBand","evenVBand","oddHBand","evenHBand","firstRowLastColumn","firstRowFirstColumn","lastRowLastColumn","lastRowFirstColumn"];return i.filter((a,o)=>N.boolAttr(t,r[o])).join(" ")}static valueOfJc(t){var n=N.attr(t,"val");switch(n){case"start":case"left":return"left";case"center":return"center";case"end":case"right":return"right";case"both":return"justify"}return n}static valueOfVertAlign(t,n=!1){var i=N.attr(t,"val");switch(i){case"subscript":return"sub";case"superscript":return n?"sup":"super"}return n?null:i}static valueOfTextAlignment(t){var n=N.attr(t,"val");switch(n){case"auto":case"baseline":return"baseline";case"top":return"top";case"center":return"middle";case"bottom":return"bottom"}return n}static addSize(t,n){return t==null?n:n==null?t:`calc(${t} + ${n})`}static classNameOftblLook(t){let n=N.hexAttr(t,"val",0),i="";return(N.boolAttr(t,"firstRow")||n&32)&&(i+=" first-row"),(N.boolAttr(t,"lastRow")||n&64)&&(i+=" last-row"),(N.boolAttr(t,"firstColumn")||n&128)&&(i+=" first-col"),(N.boolAttr(t,"lastColumn")||n&256)&&(i+=" last-col"),(N.boolAttr(t,"noHBand")||n&512)&&(i+=" no-hband"),(N.boolAttr(t,"noVBand")||n&1024)&&(i+=" no-vband"),i.trim()}},hM={pos:0,leader:"none",style:"left"},sV=50;function lV(e=document.body){let t=document.createElement("div");t.style.width="100pt",e.appendChild(t);let n=100/t.offsetWidth;return e.removeChild(t),n}function cV(e,t,n,i=72/96){let r=e.closest("p"),a=e.getBoundingClientRect(),o=r.getBoundingClientRect(),s=getComputedStyle(r),l=t?.length>0?t.map(b=>({pos:gM(b.position),leader:b.leader,style:b.style})).sort((b,S)=>b.pos-S.pos):[hM],c=l[l.length-1],u=o.width*i,d=gM(n),f=c.pos+d;if(f<u)for(;f<u&&l.length<sV;f+=d)l.push({...hM,pos:f});let m=parseFloat(s.marginLeft),p=o.left+m,h=(a.left-p)*i,_=l.find(b=>b.style!="clear"&&b.pos>h);if(_==null)return;let g=1;if(_.style=="right"||_.style=="center"){let b=Array.from(r.querySelectorAll(`.${e.className}`)),S=b.indexOf(e)+1,$=document.createRange();$.setStart(e,1),S<b.length?$.setEndBefore(b[S]):$.setEndAfter(r);let C=_.style=="center"?.5:1,z=$.getBoundingClientRect(),T=z.left+C*z.width-(o.left-m);g=_.pos-T*i}else g=_.pos-h;switch(e.innerHTML=" ",e.style.textDecoration="inherit",e.style.wordSpacing=`${g.toFixed(0)}pt`,_.leader){case"dot":case"middleDot":e.style.textDecoration="underline",e.style.textDecorationStyle="dotted";break;case"hyphen":case"heavy":case"underscore":e.style.textDecoration="underline";break}}function gM(e){return parseFloat(e)}var at;(function(e){e.html="http://www.w3.org/1999/xhtml",e.svg="http://www.w3.org/2000/svg",e.mathML="http://www.w3.org/1998/Math/MathML"})(at||(at={}));function Kb(e){if(jx(e))return document.createTextNode(e);if(e instanceof Node)return e;let{ns:t,tagName:n,className:i,style:r,children:a,...o}=e;if(n==="#fragment")return document.createDocumentFragment();if(n==="#comment")return document.createComment(a[0]);let s=t?document.createElementNS(t,n):document.createElement(n);if(i&&s.setAttribute("class",i),r&&(jx(r)?s.setAttribute("style",r):Object.assign(s.style,r)),o)for(let[l,c]of Object.entries(o))c!==void 0&&(s[l]=c);return a&&a.forEach(l=>s.appendChild(Kb(l))),s}function uV(...e){return e.filter(Boolean).join(" ")}var m1=class{constructor(){this.className="docx",this.styleMap={},this.currentPart=null,this.tableVerticalMerges=[],this.currentVerticalMerge=null,this.tableCellPositions=[],this.currentCellPosition=null,this.footnoteMap={},this.endnoteMap={},this.currentEndnoteIds=[],this.usedHederFooterParts=[],this.currentTabs=[],this.commentMap={},this.tasks=[],this.postRenderTasks=[],this.h=Kb}async render(t,n){this.document=t,this.options=n,this.className=n.className,this.rootSelector=n.inWrapper?`.${this.className}-wrapper`:":root",this.h=n.h??Kb,this.styleMap=null,this.tasks=[],this.options.renderComments&&globalThis.Highlight&&(this.commentHighlight=new Highlight);let i=[...this.renderDefaultStyle()];t.themePart&&i.push(...this.renderTheme(t.themePart)),t.stylesPart!=null&&(this.styleMap=this.processStyles(t.stylesPart.styles),i.push(...this.renderStyles(t.stylesPart.styles))),t.numberingPart&&(this.prodessNumberings(t.numberingPart.domNumberings),i.push(...await this.renderNumbering(t.numberingPart.domNumberings))),t.footnotesPart&&(this.footnoteMap=io(t.footnotesPart.notes,a=>a.id)),t.endnotesPart&&(this.endnoteMap=io(t.endnotesPart.notes,a=>a.id)),t.settingsPart&&(this.defaultTabSize=t.settingsPart.settings?.defaultTabStop),!n.ignoreFonts&&t.fontTablePart&&i.push(...await this.renderFontTable(t.fontTablePart));var r=this.renderSections(t.documentPart.body);return this.options.inWrapper?i.push(this.renderWrapper(r)):i.push(...r),this.commentHighlight&&n.renderComments&&CSS.highlights.set(`${this.className}-comments`,this.commentHighlight),this.postRenderTasks.forEach(a=>a()),await Promise.allSettled(this.tasks),this.refreshTabStops(),i}renderTheme(t){let n={},i=t.theme?.fontScheme;i&&(i.majorFont&&(n["--docx-majorHAnsi-font"]=i.majorFont.latinTypeface),i.minorFont&&(n["--docx-minorHAnsi-font"]=i.minorFont.latinTypeface));let r=t.theme?.colorScheme;if(r)for(let[o,s]of Object.entries(r.colors))n[`--docx-${o}-color`]=`#${s}`;let a=this.styleToString(`.${this.className}`,n);return[this.h({tagName:"#comment",children:["docxjs document theme values"]}),this.h({tagName:"style",children:[a]})]}async renderFontTable(t){let n=[];for(let i of t.fonts)for(let r of i.embedFontRefs)try{let a=await this.document.loadFont(r.id,r.key),o={"font-family":Dx(i.name),src:`url(${a})`};(r.type=="bold"||r.type=="boldItalic")&&(o["font-weight"]="bold"),(r.type=="italic"||r.type=="boldItalic")&&(o["font-style"]="italic"),n.push(this.h({tagName:"#comment",children:[`docxjs ${i.name} font`]})),n.push(this.h({tagName:"style",children:[this.styleToString("@font-face",o)]}))}catch{this.options.debug&&console.warn(`Can't load font with id ${r.id} and key ${r.key}`)}return n}processStyleName(t){return t?`${this.className}_${SH(t)}`:this.className}processStyles(t){let n=io(t.filter(r=>r.id!=null),r=>r.id);for(let r of t.filter(a=>a.basedOn)){var i=n[r.basedOn];if(i){r.paragraphProps=Hb(r.paragraphProps,i.paragraphProps),r.runProps=Hb(r.runProps,i.runProps);for(let a of i.styles){let o=r.styles.find(s=>s.target==a.target);o?this.copyStyleProperties(a.values,o.values):r.styles.push({...a,values:{...a.values}})}}else this.options.debug&&console.warn(`Can't find base style ${r.basedOn}`)}for(let r of t)r.cssName=this.processStyleName(r.id);return n}prodessNumberings(t){for(let n of t.filter(i=>i.pStyleName)){let i=this.findStyle(n.pStyleName);i?.paragraphProps?.numbering&&(i.paragraphProps.numbering.level=n.level)}}processElement(t){if(t.children)for(var n of t.children)n.parent=t,n.type==Z.Table?this.processTable(n):this.processElement(n)}processTable(t){for(var n of t.children)for(var i of n.children)i.cssStyle=this.copyStyleProperties(t.cellStyle,i.cssStyle,["border-left","border-right","border-top","border-bottom","padding-left","padding-right","padding-top","padding-bottom"]),this.processElement(i)}copyStyleProperties(t,n,i=null){if(!t)return n;n==null&&(n={}),i==null&&(i=Object.getOwnPropertyNames(t));for(var r of i)t.hasOwnProperty(r)&&!n.hasOwnProperty(r)&&(n[r]=t[r]);return n}createPageElement(t,n,i){let r={...i};return n&&(n.pageMargins&&(r.paddingLeft=n.pageMargins.left,r.paddingRight=n.pageMargins.right,r.paddingTop=n.pageMargins.top,r.paddingBottom=n.pageMargins.bottom),n.pageSize&&(this.options.ignoreWidth||(r.width=n.pageSize.width),this.options.ignoreHeight||(r.minHeight=n.pageSize.height))),this.h({tagName:"section",className:t,style:r})}createSectionContent(t){let n={};return t.columns&&t.columns.numberOfColumns&&(n.columnCount=`${t.columns.numberOfColumns}`,n.columnGap=t.columns.space,t.columns.separator&&(n.columnRule="1px solid black")),this.h({tagName:"article",style:n})}renderSections(t){let n=[];this.processElement(t);let i=this.splitBySection(t.children,t.props),r=this.groupByPageBreaks(i),a=null;for(let s=0,l=r.length;s<l;s++){this.currentFootnoteIds=[];let u=r[s][0].sectProps,d=this.createPageElement(this.className,u,t.cssStyle);this.options.renderHeaders&&this.renderHeaderFooter(u.headerRefs,u,n.length,a!=u,d);for(let f of r[s]){var o=this.createSectionContent(f.sectProps);this.renderElements(f.elements,o),d.appendChild(o),u=f.sectProps}if(this.options.renderFootnotes){let f=this.renderNotes(this.currentFootnoteIds,this.footnoteMap);f&&d.appendChild(f)}if(this.options.renderEndnotes&&s==l-1){let f=this.renderNotes(this.currentEndnoteIds,this.endnoteMap);f&&d.appendChild(f)}this.options.renderFooters&&this.renderHeaderFooter(u.footerRefs,u,n.length,a!=u,d),n.push(d),a=u}return n}renderHeaderFooter(t,n,i,r,a){if(t){var o=(n.titlePage&&r?t.find(l=>l.type=="first"):null)??(i%2==1?t.find(l=>l.type=="even"):null)??t.find(l=>l.type=="default"),s=o&&this.document.findPartByRelId(o.id,this.document.documentPart);if(s){this.currentPart=s,this.usedHederFooterParts.includes(s.path)||(this.processElement(s.rootElement),this.usedHederFooterParts.push(s.path));let[l]=this.renderElements([s.rootElement],a);n?.pageMargins&&(s.rootElement.type===Z.Header?(l.style.marginTop=`calc(${n.pageMargins.header} - ${n.pageMargins.top})`,l.style.minHeight=`calc(${n.pageMargins.top} - ${n.pageMargins.header})`):s.rootElement.type===Z.Footer&&(l.style.marginBottom=`calc(${n.pageMargins.footer} - ${n.pageMargins.bottom})`,l.style.minHeight=`calc(${n.pageMargins.bottom} - ${n.pageMargins.footer})`)),this.currentPart=null}}}isPageBreakElement(t){return t.type!=Z.Break?!1:t.break=="lastRenderedPageBreak"?!this.options.ignoreLastRenderedPageBreak:t.break=="page"}isPageBreakSection(t,n){return!t||!n?!1:t.pageSize?.orientation!=n.pageSize?.orientation||t.pageSize?.width!=n.pageSize?.width||t.pageSize?.height!=n.pageSize?.height}splitBySection(t,n){var i={sectProps:null,elements:[],pageBreak:!1},r=[i];for(let d of t)if(d.type==Z.Paragraph&&this.findStyle(d.styleName)?.paragraphProps?.pageBreakBefore&&(i.sectProps=a,i.pageBreak=!0,i={sectProps:null,elements:[],pageBreak:!1},r.push(i)),i.elements.push(d),d.type==Z.Paragraph){let f=d;var a=f.sectionProps,o=-1,s=-1;if(this.options.breakPages&&f.children&&(o=f.children.findIndex(m=>(s=m.children?.findIndex(this.isPageBreakElement.bind(this))??-1,s!=-1))),(a||o!=-1)&&(i.sectProps=a,i.pageBreak=o!=-1,i={sectProps:null,elements:[],pageBreak:!1},r.push(i)),o!=-1){let m=f.children[o],p=s<m.children.length-1;if(o<f.children.length-1||p){var l=d.children,c={...d,children:l.slice(o)};if(d.children=l.slice(0,o),i.elements.push(c),p){let h=m.children,_={...m,children:h.slice(0,s)};d.children.push(_),m.children=h.slice(s)}}}}let u=null;for(let d=r.length-1;d>=0;d--)r[d].sectProps==null?r[d].sectProps=u??n:u=r[d].sectProps;return r}groupByPageBreaks(t){let n=[],i,r=[n];for(let a of t)n.push(a),(this.options.ignoreLastRenderedPageBreak||a.pageBreak||this.isPageBreakSection(i,a.sectProps))&&r.push(n=[]),i=a.sectProps;return r.filter(a=>a.length>0)}renderWrapper(t){return this.h({tagName:"div",className:`${this.className}-wrapper`,children:t})}renderDefaultStyle(){var t=this.className,n=`
|
|
110
110
|
.${t}-wrapper { background: gray; padding: 30px; padding-bottom: 0px; display: flex; flex-flow: column; align-items: center; }
|
|
111
111
|
.${t}-wrapper>section.${t} { background: white; box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); margin-bottom: 30px; }`;this.options.hideWrapperOnPrint&&(n=`@media not print { ${n} }`);var i=`${n}
|
|
112
112
|
.${t} { color: black; hyphens: auto; text-underline-position: from-font; }
|