Files
YG_FT/frontend/dist/assets/DataProcessCreateView-jyj-tLuh.js
2026-07-24 14:36:11 +08:00

58 lines
553 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
var ew=Object.defineProperty;var lv=u=>{throw TypeError(u)};var sw=(u,t,e)=>t in u?ew(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e;var M=(u,t,e)=>sw(u,typeof t!="symbol"?t+"":t,e),Wp=(u,t,e)=>t.has(u)||lv("Cannot "+e);var n=(u,t,e)=>(Wp(u,t,"read from private field"),e?e.call(u):t.get(u)),m=(u,t,e)=>t.has(u)?lv("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(u):t.set(u,e),p=(u,t,e,s)=>(Wp(u,t,"write to private field"),s?s.call(u,e):t.set(u,e),e),v=(u,t,e)=>(Wp(u,t,"access private method"),e);var qt=(u,t,e,s)=>({set _(i){p(u,t,i,e)},get _(){return n(u,t,s)}});import{E as Hu}from"./index-D23K2h6y.js";import{d as _i,o as N,c as G,q as E,s as U,n as we,aa as j,g as vt,j as ut,x as ft,w as et,M as ye,ad as ni,e as Vt,A as yt,y as rt,D as xi,H as jv,al as iw,aQ as nw,P as Wf,t as cv,aL as Xp,z as ig,ag as rw,aR as aw,G as ow,f as Ls,aB as lw,v as cw}from"./index-CxbBjZKo.js";import{A as hw}from"./AppConfirmDialog-D93e215T.js";import{E as Wv,a as Xv}from"./el-form-item-BA3ZlfqF.js";import{E as bh}from"./index-zJ9bqPrh.js";import{a as qv,E as Pp}from"./el-checkbox-C_TzqU9u.js";import{E as zu}from"./el-input-number-Ba6IqA7Z.js";/* empty css */import{_ as ki}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{E as Mp,a as Ip}from"./el-select-CeiDjMzB.js";import{E as dw}from"./el-slider-CPsf2yeE.js";import{E as uw}from"./el-switch-EBBsaB1p.js";import"./el-popper-OAwpEmER.js";import"./el-tooltip-l0sNRNKZ.js";import"./el-scrollbar-B0E7ZTt3.js";/* empty css */import{E as Yv}from"./el-pagination-ByKJEnCx.js";import{E as Kv}from"./el-progress-Br676mBH.js";import{E as fw}from"./el-upload-CLbTdSbQ.js";import{a as pw,b as gw,s as mw,c as vw,r as bw,u as yw,e as ww,f as hv,h as Aw,i as Sw,j as Qv,k as xw,l as Ew,m as Cw,n as dv,t as _w,p as kw,o as Tw,q as Pw,v as Mw}from"./dataProcess-DXC9XrKo.js";import{E as Iw}from"./index-BjlLyKON.js";import{u as Dw}from"./models-WwcwjK0u.js";import"./castArray-CwVgzdTt.js";import"./_baseClone-B6d4qZbo.js";import"./raf-Bjl8yy5U.js";import"./index-C4wGR5UT.js";import"./index-DxP0p4ch.js";import"./omit-CbHF-OEy.js";import"./index-ZKnv_mga.js";import"./index-DHcidAHK.js";import"./vnode-DIVHEdsp.js";import"./index-Bzaib5AU.js";import"./scroll-Dvb2mTx8.js";import"./clamp-Ow4I6lPc.js";import"./toNumber-Yuob3eJv.js";import"./_baseIteratee-C6JbNheX.js";import"./debounce-BJxjS5F3.js";import"./validator-AVoXfk3G.js";import"./model-B9dq9fy6.js";const Lw={class:"generation-option-row dataset-split-row"},Fw={class:"dataset-split-config"},Ow={class:"dataset-split-grid"},Rw={class:"dataset-split-field"},Nw={class:"dataset-split-input"},Bw={class:"dataset-split-field"},$w={class:"dataset-split-input"},Uw={class:"dataset-split-field"},Hw={class:"dataset-split-input"},zw={key:0,role:"alert"},Vw=_i({__name:"DatasetSplitEditor",props:{modelValue:{},ariaLabelPrefix:{default:""}},emits:["update:modelValue"],setup(u,{emit:t}){const e=u,s=t,i=ut(()=>{const{train:o,validation:l,test:c}=e.modelValue;return o+l+c});function r(o,l){s("update:modelValue",{...e.modelValue,[o]:Math.min(100,Math.max(0,Number(l)||0))})}function a(o){return`${e.ariaLabelPrefix}${o}比例`}return(o,l)=>{const c=zu;return N(),G("div",Lw,[l[9]||(l[9]=E("div",{class:"generation-option-copy"},[E("strong",null,"数据集划分"),E("small",null,"按比例将生成后的问答对随机划分为训练集、验证集和测试集")],-1)),E("div",Fw,[E("div",Ow,[E("label",Rw,[l[4]||(l[4]=E("span",null,"训练集",-1)),E("span",Nw,[U(c,{"model-value":u.modelValue.train,min:0,max:100,step:1,precision:0,"controls-position":"right","aria-label":a("训练集"),"onUpdate:modelValue":l[0]||(l[0]=h=>r("train",h))},null,8,["model-value","aria-label"]),l[3]||(l[3]=E("span",null,"%",-1))])]),E("label",Bw,[l[6]||(l[6]=E("span",null,"验证集",-1)),E("span",$w,[U(c,{"model-value":u.modelValue.validation,min:0,max:100,step:1,precision:0,"controls-position":"right","aria-label":a("验证集"),"onUpdate:modelValue":l[1]||(l[1]=h=>r("validation",h))},null,8,["model-value","aria-label"]),l[5]||(l[5]=E("span",null,"%",-1))])]),E("label",Uw,[l[8]||(l[8]=E("span",null,"测试集",-1)),E("span",Hw,[U(c,{"model-value":u.modelValue.test,min:0,max:100,step:1,precision:0,"controls-position":"right","aria-label":a("测试集"),"onUpdate:modelValue":l[2]||(l[2]=h=>r("test",h))},null,8,["model-value","aria-label"]),l[7]||(l[7]=E("span",null,"%",-1))])])]),E("div",{class:we(["dataset-split-summary",{"is-invalid":i.value!==100}])},[E("span",null,"总计 "+j(i.value)+"%",1),i.value!==100?(N(),G("span",zw," 训练集、验证集和测试集比例总和必须为 100% ")):vt("",!0)],2)])])}}}),Jv=ki(Vw,[["__scopeId","data-v-f479d5fe"]]),Gw={key:0,class:"generation-config-group model-config-group"},jw={class:"model-field"},Ww={class:"model-option"},Xw={class:"model-field"},qw={class:"advanced-settings-grid"},Yw={class:"config-field"},Kw={class:"config-field"},Qw={class:"unit-input"},Jw={class:"json-mode-row"},Zw={key:0,class:"generation-validation-message",role:"alert"},tA={key:1,class:"generation-config-group quality-config-group"},eA={class:"quality-switch-row"},sA={key:0,class:"quality-rule-panel"},iA={key:0,class:"minimum-length-field"},nA={class:"minimum-length-input"},rA={key:1,class:"quality-rule-warning",role:"alert"},aA={key:1,class:"generation-validation-message",role:"alert"},oA=_i({__name:"GenerationOptionsPanel",props:{options:{},models:{},section:{},validationMessage:{}},emits:["update:options"],setup(u,{emit:t}){const e=u,s=t;function i(c,h){s("update:options",{...e.options,[c]:h})}function r(c){const h=c.filter(d=>typeof d=="string");s("update:options",{...e.options,filterLowQuality:h.includes("low_quality"),filterShortContent:h.includes("short_content")})}const a=()=>[e.options.filterLowQuality?"low_quality":"",e.options.filterShortContent?"short_content":""].filter(Boolean);function o(){if(!e.validationMessage)return"";const c=e.validationMessage.includes("数据生成模型");return e.section==="model"?c?e.validationMessage:"":c?"":e.validationMessage}function l(c){const h=c.model_source==="api"||c.model_source==="online"?"在线模型":c.model_source==="local"?"本地模型":c.model_source||"模型管理";return c.type?`${h} · ${c.type}`:h}return(c,h)=>{const d=Ip,f=Mp,g=bh,y=dw,b=zu,S=uw,w=Pp,x=qv;return u.section==="model"?(N(),G("div",Gw,[E("div",jw,[h[8]||(h[8]=E("div",{class:"field-copy"},[E("strong",null,[ft("数据生成模型 "),E("em",null,"*")]),E("small",null,"选择负责生成问答、指令或结构化内容的大模型")],-1)),U(f,{class:"model-select","model-value":u.options.generationModelId,filterable:"",placeholder:"请选择用于生成数据的模型","aria-label":"数据生成模型","onUpdate:modelValue":h[0]||(h[0]=A=>i("generationModelId",A))},{empty:et(()=>[...h[7]||(h[7]=[E("div",{class:"model-empty"},"暂无模型,请先在模型管理中添加",-1)])]),default:et(()=>[(N(!0),G(ye,null,ni(u.models||[],A=>(N(),Vt(d,{key:A.id,label:A.name,value:A.id},{default:et(()=>[E("div",Ww,[E("span",null,j(A.name),1),E("small",null,j(l(A)),1)])]),_:2},1032,["label","value"]))),128))]),_:1},8,["model-value"])]),E("div",Xw,[h[9]||(h[9]=E("div",{class:"field-copy"},[E("strong",null,"默认提示语"),E("small",null,"用于约束生成内容的格式、语气和完整性,可按任务需要修改")],-1)),U(g,{class:"prompt-input","model-value":u.options.generationPrompt,type:"textarea",rows:4,maxlength:"500","show-word-limit":"",resize:"vertical",placeholder:"请输入模型生成内容时需要遵循的要求","aria-label":"模型默认提示语","onUpdate:modelValue":h[1]||(h[1]=A=>i("generationPrompt",A))},null,8,["model-value"]),h[10]||(h[10]=E("div",{class:"prompt-variables-hint"},[ft(" 提示:可在文本中通过 "),E("code",{textContent:"{{ content }}"}),ft(" 引用当前正在处理的数据内容。 ")],-1))]),E("div",qw,[E("label",Yw,[h[11]||(h[11]=E("span",{class:"config-field-label"},"生成温度 (Temperature)",-1)),U(y,{"model-value":u.options.temperature,min:0,max:1,step:.1,"show-input":"","onUpdate:modelValue":h[2]||(h[2]=A=>i("temperature",Number(A)||0))},null,8,["model-value"]),h[12]||(h[12]=E("small",null,"较低值输出更确定、保守,较高值输出更多样、有创造性",-1))]),E("label",Kw,[h[14]||(h[14]=E("span",{class:"config-field-label"},"最大输出长度 (Max Tokens)",-1)),E("span",Qw,[U(b,{"model-value":u.options.maxTokens,min:100,max:8192,step:256,"controls-position":"right","onUpdate:modelValue":h[3]||(h[3]=A=>i("maxTokens",Number(A)||1024))},null,8,["model-value"]),h[13]||(h[13]=E("span",null,"Token",-1))]),h[15]||(h[15]=E("small",null,"限制单次生成的最大内容长度,防止过度发散",-1))])]),E("div",Jw,[h[16]||(h[16]=E("div",{class:"field-copy"},[E("strong",null,"强制 JSON 格式输出"),E("small",null,"要求大模型返回纯 JSON 对象,有助于提高下游结构化提取的稳定性")],-1)),U(S,{"model-value":u.options.jsonMode,"inline-prompt":"","active-text":"开","inactive-text":"关","onUpdate:modelValue":h[4]||(h[4]=A=>i("jsonMode",!!A))},null,8,["model-value"])]),o()?(N(),G("p",Zw,j(o()),1)):vt("",!0)])):(N(),G("div",tA,[E("div",eA,[h[17]||(h[17]=E("div",{class:"config-group-heading"},[E("div",null,[E("h4",null,"质量筛选"),E("p",null,"生成后自动过滤不符合要求的内容,不影响源数据预处理")])],-1)),U(S,{"model-value":u.options.qualityFilterEnabled,"inline-prompt":"","active-text":"开","inactive-text":"关","aria-label":"质量筛选","onUpdate:modelValue":h[5]||(h[5]=A=>i("qualityFilterEnabled",!!A))},null,8,["model-value"])]),u.options.qualityFilterEnabled?(N(),G("div",sA,[U(x,{"model-value":a(),class:"quality-rule-list","onUpdate:modelValue":r},{default:et(()=>[U(w,{value:"low_quality"},{default:et(()=>[...h[18]||(h[18]=[E("span",{class:"rule-copy"},[E("strong",null,"过滤低质量内容"),E("small",null,"按相关性、完整性和可读性过滤明显不合格的生成结果")],-1)])]),_:1}),U(w,{value:"short_content"},{default:et(()=>[...h[19]||(h[19]=[E("span",{class:"rule-copy"},[E("strong",null,"过滤过短内容"),E("small",null,"过滤正文长度低于指定字数的生成结果")],-1)])]),_:1})]),_:1},8,["model-value"]),u.options.filterShortContent?(N(),G("label",iA,[h[21]||(h[21]=E("span",null,"最少字数",-1)),E("span",nA,[U(b,{"model-value":u.options.minOutputLength,min:1,max:1e3,step:5,precision:0,"controls-position":"right","aria-label":"生成内容最少字数","onUpdate:modelValue":h[6]||(h[6]=A=>i("minOutputLength",Number(A)||1))},null,8,["model-value"]),h[20]||(h[20]=E("span",null,"字",-1))]),h[22]||(h[22]=E("small",null,"少于该字数的生成结果将被过滤",-1))])):vt("",!0),!u.options.filterLowQuality&&!u.options.filterShortContent?(N(),G("p",rA," 请至少选择一项质量筛选规则 ")):vt("",!0)])):vt("",!0),o()?(N(),G("p",aA,j(o()),1)):vt("",!0)]))}}}),Um=ki(oA,[["__scopeId","data-v-e6fd162c"]]),lA={class:"form-section structured-options-section"},cA={class:"preprocess-option-copy"},hA={class:"form-section generation-options-section"},dA={class:"generation-option-list"},uA={class:"generation-option-row"},fA=_i({__name:"StructuredOptionsPanel",props:{options:{},validationAttempted:{type:Boolean},qualityValidationMessage:{}},emits:["update:options"],setup(u,{emit:t}){const e=u,s=t,i=[{value:"clean_invalid",label:"清理无效数据",description:"清理全空列,并剔除关键字段残缺的数据行"},{value:"detect_structure",label:"识别表格结构",description:"识别多级表头与合并单元格,并将嵌套字段展平"},{value:"deduplicate",label:"重复数据去重",description:"基于整行精确匹配和关键字段组合删除重复记录"},{value:"normalize_format",label:"数据格式标准化",description:"按所选规则统一编码、空白、字段名及 JSON 序列化格式"},{value:"filter_anomaly",label:"异常数据过滤",description:"使用 IQR 识别数值离群值,并过滤乱码等异常记录"},{value:"desensitize",label:"敏感信息脱敏",description:"识别并脱敏姓名、手机号、邮箱和身份证号"}];function r(l,c){s("update:options",{...e.options,[l]:c})}function a(l){s("update:options",{...e.options,...l})}function o(l){const c=new Set(i.map(d=>d.value)),h=Array.from(new Set(l.filter(d=>typeof d=="string"&&c.has(d))));r("preprocessOptions",h)}return(l,c)=>{const h=Pp,d=qv,f=zu;return N(),G(ye,null,[E("div",lA,[c[2]||(c[2]=E("div",{class:"section-title-row"},[E("div",null,[E("h3",null,"预处理选项"),E("p",null,"选择在生成问答对之前需要执行的数据处理方式")])],-1)),U(d,{"model-value":u.options.preprocessOptions,class:"preprocess-option-grid","onUpdate:modelValue":o},{default:et(()=>[(N(),G(ye,null,ni(i,g=>U(h,{key:g.value,value:g.value,class:"preprocess-option"},{default:et(()=>[E("span",cA,[E("strong",null,j(g.label),1),E("small",null,j(g.description),1)])]),_:2},1032,["value"])),64))]),_:1},8,["model-value"])]),E("div",hA,[c[4]||(c[4]=E("div",{class:"section-title-row"},[E("div",null,[E("h3",null,"生成选项"),E("p",null,"配置每条结构化记录生成问答对的方式和数量")])],-1)),E("div",dA,[U(Um,{options:u.options,section:"quality","validation-message":u.validationAttempted?u.qualityValidationMessage:"","onUpdate:options":a},null,8,["options","validation-message"]),E("div",uA,[c[3]||(c[3]=E("div",{class:"generation-option-copy"},[E("strong",null,"每行生成数量"),E("small",null,"每行结构化数据生成的问答对数量")],-1)),U(f,{"model-value":u.options.qaPairsPerRow,min:1,max:5,step:1,"controls-position":"right","onUpdate:modelValue":c[0]||(c[0]=g=>r("qaPairsPerRow",Number(g)||1))},null,8,["model-value"])]),U(Jv,{"model-value":u.options.datasetSplit,"onUpdate:modelValue":c[1]||(c[1]=g=>r("datasetSplit",g))},null,8,["model-value"])])])],64)}}}),pA=ki(fA,[["__scopeId","data-v-c48db990"]]),gA={class:"form-section unstructured-options-section"},mA={class:"preprocess-option-grid"},vA={class:"form-section chunk-options-section"},bA={class:"chunk-settings-grid is-basic"},yA={class:"config-field"},wA={class:"config-field"},AA={class:"unit-input"},SA={class:"config-field"},xA={class:"unit-input"},EA={class:"config-field"},CA={class:"unit-input"},_A={key:0,class:"config-field"},kA={key:0,class:"option-validation-message",role:"alert"},TA={class:"form-section generation-options-section"},PA={class:"generation-option-list"},MA={class:"generation-option-row"},IA=_i({__name:"UnstructuredOptionsPanel",props:{options:{},validationAttempted:{type:Boolean},qualityValidationMessage:{},chunkValidationMessage:{}},emits:["update:options"],setup(u,{expose:t,emit:e}){const s=u,i=e,r=["clean_invalid_content","detect_document_structure","merge_short_content","filter_low_quality","deduplicate_content","preserve_context"],a=[{value:"structure",label:"文档结构"},{value:"fixed",label:"固定 Token"},{value:"custom",label:"自定义分隔符"}],o={chunkSize:{min:200,max:2e3},chunkOverlap:{min:0,max:500},minChunkSize:{min:20,max:500},qaPairsPerChunk:{min:1,max:3}},l=ut(()=>r.every(x=>s.options.preprocessOptions.includes(x))),c=ut(()=>s.options.preprocessOptions.includes("desensitize")),h=ut(()=>s.options.preserveTables&&s.options.preserveCodeBlocks&&s.options.preserveLists);function d(x,A){i("update:options",{...s.options,[x]:A})}function f(x){i("update:options",{...s.options,...x})}function g(x){const A=!!x,C=Array.from(new Set(s.options.preprocessOptions.filter(_=>!r.includes(_))));d("preprocessOptions",A?[...r,...C]:C)}function y(x){const A=Array.from(new Set(s.options.preprocessOptions.filter(C=>C!=="desensitize")));x&&A.push("desensitize"),d("preprocessOptions",A)}function b(x){const A=!!x;i("update:options",{...s.options,preserveTables:A,preserveCodeBlocks:A,preserveLists:A})}function S(x,A){const C=o[x],_=Number(A),k=Number.isFinite(_)?_:C.min;d(x,Math.min(C.max,Math.max(C.min,k)))}function w(){}return t({revealValidation:w}),(x,A)=>{const C=Pp,_=Ip,k=Mp,I=zu,L=bh;return N(),G(ye,null,[E("div",gA,[A[10]||(A[10]=E("div",{class:"section-title-row"},[E("div",null,[E("h3",null,"预处理选项"),E("p",null,"默认启用结构感知的推荐策略,只需决定是否需要脱敏")])],-1)),E("div",mA,[E("label",{class:we(["preprocess-option",{"is-checked":l.value}])},[U(C,{"model-value":l.value,"onUpdate:modelValue":g},null,8,["model-value"]),A[7]||(A[7]=E("span",{class:"preprocess-option-copy"},[E("strong",null,"智能预处理"),E("small",null,"清理无效内容、感知文档结构、合并短块、预过滤低质量内容、近重复去重,并通过重叠保护上下文")],-1))],2),E("label",{class:we(["preprocess-option",{"is-checked":c.value}])},[U(C,{"model-value":c.value,"onUpdate:modelValue":y},null,8,["model-value"]),A[8]||(A[8]=E("span",{class:"preprocess-option-copy"},[E("strong",null,"敏感信息脱敏"),E("small",null,"识别并脱敏姓名、手机号、邮箱和身份证号")],-1))],2),E("label",{class:we(["preprocess-option",{"is-checked":h.value}])},[U(C,{"model-value":h.value,"onUpdate:modelValue":b},null,8,["model-value"]),A[9]||(A[9]=E("span",{class:"preprocess-option-copy"},[E("strong",null,"保护表格、代码和列表"),E("small",null,"避免切分点破坏特殊内容块的完整性")],-1))],2)])]),E("div",vA,[A[24]||(A[24]=E("div",{class:"section-title-row"},[E("div",null,[E("h3",null,"切分选项"),E("p",null,"按文档结构、固定 Token 或自定义分隔符拆分长文档")])],-1)),E("div",bA,[E("label",yA,[A[11]||(A[11]=E("span",{class:"config-field-label"},"切分方式",-1)),U(k,{"model-value":u.options.chunkMethod,"aria-label":"切分方式","onUpdate:modelValue":A[0]||(A[0]=P=>d("chunkMethod",P))},{default:et(()=>[(N(),G(ye,null,ni(a,P=>U(_,{key:P.value,label:P.label,value:P.value},null,8,["label","value"])),64))]),_:1},8,["model-value"]),A[12]||(A[12]=E("small",null,"推荐使用文档结构,按标题、段落和句子边界保留完整内容块",-1))]),E("label",wA,[A[14]||(A[14]=E("span",{class:"config-field-label"},"切片长度",-1)),E("span",AA,[U(I,{"model-value":u.options.chunkSize,min:200,max:2e3,step:50,precision:0,"controls-position":"right","aria-label":"切片长度","onUpdate:modelValue":A[1]||(A[1]=P=>S("chunkSize",P))},null,8,["model-value"]),A[13]||(A[13]=E("span",null,"Token",-1))]),A[15]||(A[15]=E("small",null,"单个切片的目标上限,默认 800 Token",-1))]),E("label",SA,[A[17]||(A[17]=E("span",{class:"config-field-label"},"重叠长度",-1)),E("span",xA,[U(I,{"model-value":u.options.chunkOverlap,min:0,max:500,step:10,precision:0,"controls-position":"right","aria-label":"重叠长度","onUpdate:modelValue":A[2]||(A[2]=P=>S("chunkOverlap",P))},null,8,["model-value"]),A[16]||(A[16]=E("span",null,"Token",-1))]),A[18]||(A[18]=E("small",null,"在相邻切片中最多重复保留的上下文,默认 100 Token",-1))]),E("label",EA,[A[20]||(A[20]=E("span",{class:"config-field-label"},"最小切片长度",-1)),E("span",CA,[U(I,{"model-value":u.options.minChunkSize,min:20,max:500,step:10,precision:0,"controls-position":"right","aria-label":"最小切片长度","onUpdate:modelValue":A[3]||(A[3]=P=>S("minChunkSize",P))},null,8,["model-value"]),A[19]||(A[19]=E("span",null,"Token",-1))]),A[21]||(A[21]=E("small",null,"过短的尾部内容会尽量并入前一个切片",-1))]),u.options.chunkMethod==="custom"?(N(),G("label",_A,[A[22]||(A[22]=E("span",{class:"config-field-label"},"自定义分隔符",-1)),U(L,{"model-value":u.options.customDelimiter,maxlength:"40","show-word-limit":"",placeholder:"例如:--- 或 ###","aria-label":"自定义分隔符","onUpdate:modelValue":A[4]||(A[4]=P=>d("customDelimiter",P))},null,8,["model-value"]),A[23]||(A[23]=E("small",null,"系统会优先在分隔符位置结束当前切片",-1))])):vt("",!0)]),A[25]||(A[25]=E("p",{class:"chunk-estimation-note"}," Token 数为轻量估算值,实际长度以训练使用的模型分词器为准。 ",-1)),u.chunkValidationMessage?(N(),G("p",kA,j(u.chunkValidationMessage),1)):vt("",!0)]),E("div",TA,[A[27]||(A[27]=E("div",{class:"section-title-row"},[E("div",null,[E("h3",null,"生成选项"),E("p",null,"只保留会直接影响输出的核心设置")])],-1)),E("div",PA,[U(Um,{options:u.options,section:"quality","validation-message":u.validationAttempted?u.qualityValidationMessage:"","onUpdate:options":f},null,8,["options","validation-message"]),E("div",MA,[A[26]||(A[26]=E("div",{class:"generation-option-copy"},[E("strong",null,"每个切片生成数量"),E("small",null,"每个内容切片最多生成 3 个不同角度的问答对")],-1)),U(I,{"model-value":u.options.qaPairsPerChunk,min:1,max:3,step:1,precision:0,"controls-position":"right","aria-label":"每个切片生成数量","onUpdate:modelValue":A[5]||(A[5]=P=>S("qaPairsPerChunk",P))},null,8,["model-value"])]),U(Jv,{"model-value":u.options.datasetSplit,"aria-label-prefix":"非结构化","onUpdate:modelValue":A[6]||(A[6]=P=>d("datasetSplit",P))},null,8,["model-value"])])])],64)}}}),DA=ki(IA,[["__scopeId","data-v-e95f1c94"]]),LA={class:"task-setup-step"},FA={class:"form-section"},OA={class:"basic-grid"},RA={class:"form-section"},NA={class:"type-options"},BA=_i({__name:"TaskSetupStep",props:{name:{},description:{},processType:{},structuredOptions:{},unstructuredOptions:{}},emits:["update:name","update:description","update:processType","update:structuredOptions","update:unstructuredOptions"],setup(u,{expose:t,emit:e}){const s=u,i=e,r=rt(),a=rt(),o=rt(!1),l=ut(()=>({name:s.name,processType:s.processType})),c=ut(()=>{const{train:S,validation:w,test:x}=s.structuredOptions.datasetSplit;return S+w+x}),h=ut(()=>{const{train:S,validation:w,test:x}=s.unstructuredOptions.datasetSplit;return S+w+x}),d=ut(()=>s.processType==="structured"?s.structuredOptions:s.processType==="unstructured"?s.unstructuredOptions:null),f=ut(()=>{const S=d.value;return S?S.qualityFilterEnabled&&!S.filterLowQuality&&!S.filterShortContent?"开启质量筛选后,请至少选择一项筛选规则":S.qualityFilterEnabled&&S.filterShortContent&&S.minOutputLength<1?"最少字数必须大于 0":"":""}),g=ut(()=>s.unstructuredOptions.chunkOverlap>=s.unstructuredOptions.chunkSize?"重叠长度必须小于切片长度":s.unstructuredOptions.minChunkSize>s.unstructuredOptions.chunkSize?"最小切片长度不能大于切片长度":s.unstructuredOptions.chunkOverlap+s.unstructuredOptions.minChunkSize>s.unstructuredOptions.chunkSize?"重叠长度与最小切片长度之和不能大于切片长度":s.unstructuredOptions.chunkMethod==="custom"&&!s.unstructuredOptions.customDelimiter.trim()?"请输入自定义分隔符":""),y={name:[{required:!0,message:"请输入任务名称",trigger:"blur"},{max:50,message:"任务名称不能超过 50 个字符",trigger:"blur"}],processType:[{required:!0,message:"请选择数据处理类型",trigger:"change"}]};async function b(){var S;if(o.value=!0,!r.value)return!1;try{if(await r.value.validate(),s.processType==="structured"&&c.value!==100)return yt.error("结构化数据处理:数据集划分比例总和必须为 100%"),!1;if(s.processType==="unstructured"){if(h.value!==100)return yt.error("非结构化数据处理:数据集划分比例总和必须为 100%"),!1;if(g.value)return(S=a.value)==null||S.revealValidation(),yt.error(g.value),!1}return f.value?(yt.error(f.value),!1):!0}catch{return yt.error("请完善标红的必填项"),!1}}return t({validate:b}),(S,w)=>{const x=bh,A=Xv,C=Wv;return N(),G("section",LA,[U(C,{ref_key:"formRef",ref:r,model:l.value,rules:y,"label-position":"top","scroll-to-error":""},{default:et(()=>[E("div",FA,[w[7]||(w[7]=E("h3",null,"基本信息",-1)),E("div",OA,[U(A,{label:"任务名称",prop:"name",required:""},{default:et(()=>[U(x,{"model-value":u.name,maxlength:"50","show-word-limit":"",placeholder:"例如:金融问答清洗任务","onUpdate:modelValue":w[0]||(w[0]=_=>i("update:name",_))},null,8,["model-value"])]),_:1}),U(A,{label:"任务描述(选填)"},{default:et(()=>[U(x,{"model-value":u.description,type:"textarea",rows:3,maxlength:"200","show-word-limit":"",placeholder:"简要说明本次数据处理目标","onUpdate:modelValue":w[1]||(w[1]=_=>i("update:description",_))},null,8,["model-value"])]),_:1})])]),E("div",RA,[w[11]||(w[11]=E("div",{class:"section-title-row"},[E("div",null,[E("h3",null,"处理类型"),E("p",null,"类型会影响下一步支持的数据源格式和后续预览方式")])],-1)),U(A,{prop:"processType",class:"type-form-item"},{default:et(()=>[E("div",NA,[E("button",{type:"button",class:we(["type-option",{"is-active":u.processType==="structured"}]),onClick:w[2]||(w[2]=_=>i("update:processType","structured"))},[...w[8]||(w[8]=[E("span",{class:"type-icon"},[E("i",{class:"fa fa-table"})],-1),E("span",null,[E("strong",null,"结构化数据"),E("small",null,"适用于 CSV、Excel、JSONL 等固定字段数据")],-1),E("i",{class:"fa fa-check-circle selection-mark"},null,-1)])],2),E("button",{type:"button",class:we(["type-option",{"is-active":u.processType==="unstructured"}]),onClick:w[3]||(w[3]=_=>i("update:processType","unstructured"))},[...w[9]||(w[9]=[E("span",{class:"type-icon"},[E("i",{class:"fa fa-file-text-o"})],-1),E("span",null,[E("strong",null,"非结构化数据"),E("small",null,"适用于文档、文本、问答等需要切分的数据")],-1),E("i",{class:"fa fa-check-circle selection-mark"},null,-1)])],2),E("button",{type:"button",class:we(["type-option",{"is-active":u.processType==="external"}]),onClick:w[4]||(w[4]=_=>i("update:processType","external"))},[...w[10]||(w[10]=[E("span",{class:"type-icon"},[E("i",{class:"fa fa-cloud-download"})],-1),E("span",null,[E("strong",null,"外来数据源拉取"),E("small",null,"适用于数据库、API 接口等需远程拉取的外部数据")],-1),E("i",{class:"fa fa-check-circle selection-mark"},null,-1)])],2)])]),_:1})]),u.processType==="structured"?(N(),Vt(pA,{key:0,options:u.structuredOptions,"validation-attempted":o.value,"quality-validation-message":f.value,"onUpdate:options":w[5]||(w[5]=_=>i("update:structuredOptions",_))},null,8,["options","validation-attempted","quality-validation-message"])):vt("",!0),u.processType==="unstructured"?(N(),Vt(DA,{key:1,ref_key:"unstructuredOptionsPanelRef",ref:a,options:u.unstructuredOptions,"validation-attempted":o.value,"quality-validation-message":f.value,"chunk-validation-message":g.value,"onUpdate:options":w[6]||(w[6]=_=>i("update:unstructuredOptions",_))},null,8,["options","validation-attempted","quality-validation-message","chunk-validation-message"])):vt("",!0)]),_:1},8,["model"])])}}}),$A=ki(BA,[["__scopeId","data-v-d4ef10ff"]]),UA={class:"model-selection-step","aria-labelledby":"model-selection-title"},HA={class:"form-section"},zA={class:"model-form-content"},VA=_i({__name:"ModelSelectionStep",props:{options:{},models:{}},emits:["update:options"],setup(u,{expose:t,emit:e}){const s=u,i=e,r=rt(!1),a=ut(()=>s.options.generationModelId===""?"请选择数据生成模型":"");function o(){return r.value=!0,a.value?(yt.error(a.value),!1):!0}return t({validate:o}),(l,c)=>(N(),G("section",UA,[E("div",HA,[c[1]||(c[1]=E("div",{class:"section-title-row"},[E("div",null,[E("h3",{id:"model-selection-title"},"大模型选择"),E("p",null,"选择本次数据生成使用的模型,并设置统一的输出要求")])],-1)),E("div",zA,[U(Um,{options:u.options,models:u.models,section:"model","validation-message":r.value?a.value:"","onUpdate:options":c[0]||(c[0]=h=>i("update:options",h))},null,8,["options","models","validation-message"])])])]))}}),GA=ki(VA,[["__scopeId","data-v-77825278"]]),jA={class:"source-upload-step","aria-labelledby":"source-upload-title"},WA={key:0,class:"form-section external-section"},XA={class:"external-form"},qA={class:"external-actions"},YA={key:0,class:"external-status is-connected",role:"status"},KA={key:0,class:"uploaded-file-list","aria-label":"已拉取数据列表"},QA={class:"uploaded-file-list-header"},JA={class:"uploaded-file-items"},ZA={class:"file-main"},tS=["title"],eS=["title"],sS={class:"file-status",role:"status","aria-live":"polite"},iS={class:"file-progress-value"},nS={key:0,class:"file-preview-error"},rS={key:1,class:"form-section upload-section"},aS={class:"section-title-row"},oS={class:"el-upload__tip"},lS={key:1,class:"uploaded-file-list","aria-label":"已上传文件列表"},cS={class:"uploaded-file-list-header"},hS={key:0,class:"upload-queue-status"},dS={class:"continue-upload"},uS={class:"uploaded-file-items"},fS={class:"file-main"},pS=["title"],gS=["title"],mS={class:"file-status",role:"status","aria-live":"polite"},vS={class:"file-progress-value"},bS={key:0,class:"file-preview-error"},Fa=10,yS=_i({__name:"SourceUploadStep",props:{processType:{},uploadedFiles:{},externalSource:{},externalPulling:{type:Boolean},externalConnected:{type:Boolean},previewBuilding:{type:Boolean},sourceUploading:{type:Boolean}},emits:["update:externalSource","file-change","remove-file","use-sample","test-connection","pull-data"],setup(u,{emit:t}){const e=u,s=t,i=[{value:"postgresql",label:"PostgreSQL"}],r=[{value:"none",label:"免鉴权"},{value:"basic",label:"账号密码"}],a=rt(1),o={queued:{label:"等待上传",icon:"fa-clock-o"},uploading:{label:"正在上传",icon:"fa-cloud-upload"},waiting:{label:"等待切分",icon:"fa-clock-o"},processing:{label:"正在切分",icon:"fa-spinner fa-spin"},success:{label:"切分完成",icon:"fa-check-circle"},"upload-failed":{label:"上传失败",icon:"fa-exclamation-circle"},"preview-failed":{label:"切分失败",icon:"fa-exclamation-circle"}},l=ut(()=>e.processType==="external"),c=ut(()=>e.processType==="unstructured"?".txt,.md,.markdown,.pdf,.docx,.pptx,.json,.jsonl,.ndjson":".json,.jsonl,.ndjson,.csv,.tsv,.xlsx"),h=ut(()=>{const C=(a.value-1)*Fa;return e.uploadedFiles.slice(C,C+Fa)});xi(()=>e.uploadedFiles.length,(C,_)=>{const k=Math.max(1,Math.ceil(C/Fa));if(C>_){a.value=k;return}a.value=Math.min(a.value,k)}),xi(()=>e.processType,()=>{a.value=1});function d(C,_){s("update:externalSource",{...e.externalSource,[C]:_})}function f(C){return C?C>=1024*1024?`${(C/1024/1024).toFixed(1)} MB`:`${(C/1024).toFixed(1)} KB`:"0 KB"}function g(C){return C.status==="queued"||C.status==="uploading"?C.status:C.status==="failed"?"upload-failed":C.previewStatus==="processing"||C.previewStatus==="success"?C.previewStatus:C.previewStatus==="failed"?"preview-failed":"waiting"}function y(C){const _=g(C),k=_==="queued"||_==="uploading"||_==="upload-failed"?C.uploadProgress:_==="waiting"?100:C.previewProgress??0;return Math.min(100,Math.max(0,k))}function b(C){return g(C)==="processing"}function S(C){return b(C)?100:y(C)}function w(C){const _=g(C);if(_==="waiting"||_==="success")return"success";if(_==="upload-failed"||_==="preview-failed")return"exception"}function x(C){return b(C)?"处理中":g(C)==="waiting"?"已上传":`${y(C)}%`}function A(C){return C.uploadError||C.previewError}return(C,_)=>{const k=Ip,I=Mp,L=Xv,P=bh,D=zu,R=Wv,K=Hu,W=Kv,Q=Yv,ht=fw;return N(),G("section",jA,[l.value?(N(),G("div",WA,[_[18]||(_[18]=E("div",{class:"section-title-row"},[E("div",null,[E("h3",{id:"source-upload-title"},"数据源配置"),E("p",null,"配置并验证外部数据源,拉取成功后可在下一步预览数据内容")])],-1)),E("div",XA,[U(R,{"label-position":"top",class:"external-grid"},{default:et(()=>[U(L,{label:"数据源类型"},{default:et(()=>[U(I,{"model-value":u.externalSource.type,placeholder:"请选择数据源类型","aria-label":"数据源类型","onUpdate:modelValue":_[0]||(_[0]=T=>d("type",T))},{default:et(()=>[(N(),G(ye,null,ni(i,T=>U(k,{key:T.value,label:T.label,value:T.value},null,8,["label","value"])),64))]),_:1},8,["model-value"])]),_:1}),U(L,{label:"地址 / URL"},{default:et(()=>[U(P,{"model-value":u.externalSource.url,placeholder:"例如postgresql://db.example.com:5432/my_database","aria-label":"数据源地址或 URL","onUpdate:modelValue":_[1]||(_[1]=T=>d("url",T))},null,8,["model-value"])]),_:1}),U(L,{label:"鉴权方式"},{default:et(()=>[U(I,{"model-value":u.externalSource.authMode,"aria-label":"鉴权方式","onUpdate:modelValue":_[2]||(_[2]=T=>d("authMode",T))},{default:et(()=>[(N(),G(ye,null,ni(r,T=>U(k,{key:T.value,label:T.label,value:T.value},null,8,["label","value"])),64))]),_:1},8,["model-value"])]),_:1}),u.externalSource.authMode==="basic"?(N(),Vt(L,{key:0,label:"账号"},{default:et(()=>[U(P,{"model-value":u.externalSource.username,autocomplete:"username",placeholder:"请输入账号","aria-label":"数据源账号","onUpdate:modelValue":_[3]||(_[3]=T=>d("username",T))},null,8,["model-value"])]),_:1})):vt("",!0),u.externalSource.authMode==="basic"?(N(),Vt(L,{key:1,label:"密码"},{default:et(()=>[U(P,{"model-value":u.externalSource.password,type:"password","show-password":"",autocomplete:"current-password",placeholder:"请输入密码","aria-label":"数据源密码","onUpdate:modelValue":_[4]||(_[4]=T=>d("password",T))},null,8,["model-value"])]),_:1})):vt("",!0),U(L,{label:"拉取条数"},{default:et(()=>[U(D,{"model-value":u.externalSource.limit,min:1,max:1e5,step:100,"controls-position":"right","aria-label":"数据拉取条数","onUpdate:modelValue":_[5]||(_[5]=T=>d("limit",Number(T)||0))},null,8,["model-value"])]),_:1}),U(L,{label:"只读查询语句",class:"external-query-field"},{default:et(()=>[U(P,{"model-value":u.externalSource.query,type:"textarea",rows:4,maxlength:"20000","show-word-limit":"",placeholder:"例如SELECT question, answer FROM qa_data ORDER BY id","aria-label":"外部数据源只读查询语句","onUpdate:modelValue":_[6]||(_[6]=T=>d("query",T))},null,8,["model-value"]),_[12]||(_[12]=E("small",null,"只允许单条 SELECT 或 WITH 查询后端会拒绝写入、DDL 和多语句。",-1))]),_:1})]),_:1}),E("div",qA,[U(K,{loading:u.externalPulling&&!u.externalConnected,disabled:u.externalPulling||u.previewBuilding,plain:"",onClick:_[7]||(_[7]=T=>s("test-connection"))},{default:et(()=>[..._[13]||(_[13]=[ft(" 测试连接 ",-1)])]),_:1},8,["loading","disabled"]),U(K,{type:"primary",loading:u.externalPulling,disabled:u.externalPulling||u.previewBuilding,onClick:_[8]||(_[8]=T=>s("pull-data"))},{default:et(()=>[..._[14]||(_[14]=[ft(" 拉取数据 ",-1)])]),_:1},8,["loading","disabled"]),u.externalConnected?(N(),G("span",YA,[..._[15]||(_[15]=[E("i",{class:"fa fa-check-circle","aria-hidden":"true"},null,-1),ft(" 连接正常 ",-1)])])):vt("",!0)]),u.uploadedFiles.length?(N(),G("section",KA,[E("div",QA,[E("span",null,"已拉取 "+j(u.uploadedFiles.length)+" 个数据集",1)]),E("div",JA,[(N(!0),G(ye,null,ni(h.value,T=>(N(),G("div",{key:T.uid,class:"uploaded-file"},[_[17]||(_[17]=E("span",{class:"file-icon"},[E("i",{class:"fa fa-cloud-download","aria-hidden":"true"})],-1)),E("div",ZA,[E("strong",{title:T.name},j(T.name),9,tS),E("span",null,[ft(j(f(T.size))+" ",1),T.count?(N(),G(ye,{key:0},[ft(" · "+j(T.count.toLocaleString())+" 条",1)],64)):vt("",!0)])]),E("div",{class:we(["file-preview-progress",`is-${g(T)}`]),title:A(T)},[E("div",sS,[E("span",null,[E("i",{class:we(["fa",o[g(T)].icon]),"aria-hidden":"true"},null,2),ft(" "+j(o[g(T)].label),1)]),E("span",iS,j(x(T)),1)]),U(W,{percentage:S(T),indeterminate:b(T),duration:1.5,"stroke-width":5,"show-text":!1,status:w(T),"aria-valuenow":b(T)?void 0:y(T),"aria-valuetext":b(T)?"正在切分,进度未知":x(T)},null,8,["percentage","indeterminate","status","aria-valuenow","aria-valuetext"]),A(T)?(N(),G("small",nS,j(A(T)),1)):vt("",!0)],10,eS),U(K,{link:"",type:"danger",disabled:u.previewBuilding||T.status==="uploading","aria-label":`删除数据集 ${T.name}`,onClick:q=>s("remove-file",T.uid)},{default:et(()=>[..._[16]||(_[16]=[ft(" 删除 ",-1)])]),_:1},8,["disabled","aria-label","onClick"])]))),128))]),u.uploadedFiles.length>Fa?(N(),Vt(Q,{key:0,"current-page":a.value,"onUpdate:currentPage":_[9]||(_[9]=T=>a.value=T),"page-size":Fa,total:u.uploadedFiles.length,"pager-count":5,small:"",background:"",layout:"prev, pager, next",class:"uploaded-file-pagination","aria-label":"已拉取数据分页"},null,8,["current-page","total"])):vt("",!0)])):vt("",!0)])])):(N(),G("div",rS,[E("div",aS,[_[20]||(_[20]=E("div",null,[E("h3",{id:"source-upload-title"},"源数据上传"),E("p",null,"上传后可在下一步检查内容和切分效果,支持同时添加多个文件")],-1)),u.uploadedFiles.length===0?(N(),Vt(K,{key:0,link:"",type:"primary",disabled:u.previewBuilding,onClick:_[10]||(_[10]=T=>s("use-sample"))},{default:et(()=>[..._[19]||(_[19]=[ft(" 使用示例数据 ",-1)])]),_:1},8,["disabled"])):vt("",!0)]),u.uploadedFiles.length===0?(N(),Vt(ht,{key:0,drag:"",multiple:"",accept:c.value,disabled:u.previewBuilding,"auto-upload":!1,"show-file-list":!1,"on-change":T=>s("file-change",T),"aria-label":"选择或拖拽源数据文件"},{tip:et(()=>[E("div",oS,j(u.processType==="unstructured"?"支持 TXT、MD、MARKDOWN、PDF、DOCX、PPTX、JSON、JSONL、NDJSON旧版 DOC/PPT 请先转换,单文件不超过 200MB":"支持 JSON、JSONL、NDJSON、CSV、TSV、XLSX旧版 XLS 请先转换,单文件不超过 200MB"),1)]),default:et(()=>[_[21]||(_[21]=E("i",{class:"fa fa-cloud-upload upload-icon","aria-hidden":"true"},null,-1)),_[22]||(_[22]=E("div",{class:"el-upload__text"},[ft("拖拽文件到此处,或"),E("em",null,"点击选择文件")],-1))]),_:1},8,["accept","disabled","on-change"])):(N(),G("section",lS,[E("div",cS,[E("span",null,[ft(" 已选择 "+j(u.uploadedFiles.length)+" 个文件 ",1),u.sourceUploading?(N(),G("small",hS," · 正在逐个上传")):vt("",!0)]),E("div",dS,[U(ht,{multiple:"",accept:c.value,disabled:u.previewBuilding,"auto-upload":!1,"show-file-list":!1,"on-change":T=>s("file-change",T),"aria-label":"继续添加源数据文件"},{default:et(()=>[U(K,{size:"small",type:"primary",disabled:u.previewBuilding},{default:et(()=>[..._[23]||(_[23]=[ft("继续上传",-1)])]),_:1},8,["disabled"])]),_:1},8,["accept","disabled","on-change"])])]),E("div",uS,[(N(!0),G(ye,null,ni(h.value,T=>(N(),G("div",{key:T.uid,class:"uploaded-file"},[_[25]||(_[25]=E("span",{class:"file-icon"},[E("i",{class:"fa fa-file-text-o","aria-hidden":"true"})],-1)),E("div",fS,[E("strong",{title:T.name},j(T.name),9,pS),E("span",null,[ft(j(f(T.size))+" ",1),T.count?(N(),G(ye,{key:0},[ft(" · "+j(T.count.toLocaleString())+" 条",1)],64)):vt("",!0)])]),E("div",{class:we(["file-preview-progress",`is-${g(T)}`]),title:A(T)},[E("div",mS,[E("span",null,[E("i",{class:we(["fa",o[g(T)].icon]),"aria-hidden":"true"},null,2),ft(" "+j(o[g(T)].label),1)]),E("span",vS,j(x(T)),1)]),U(W,{percentage:S(T),indeterminate:b(T),duration:1.5,"stroke-width":5,"show-text":!1,status:w(T),"aria-valuenow":b(T)?void 0:y(T),"aria-valuetext":b(T)?"正在切分,进度未知":x(T)},null,8,["percentage","indeterminate","status","aria-valuenow","aria-valuetext"]),A(T)?(N(),G("small",bS,j(A(T)),1)):vt("",!0)],10,gS),U(K,{link:"",type:"danger",disabled:u.previewBuilding||T.status==="uploading","aria-label":`删除文件 ${T.name}`,onClick:q=>s("remove-file",T.uid)},{default:et(()=>[..._[24]||(_[24]=[ft(" 删除 ",-1)])]),_:1},8,["disabled","aria-label","onClick"])]))),128))]),u.uploadedFiles.length>Fa?(N(),Vt(Q,{key:0,"current-page":a.value,"onUpdate:currentPage":_[11]||(_[11]=T=>a.value=T),"page-size":Fa,total:u.uploadedFiles.length,"pager-count":5,small:"",background:"",layout:"prev, pager, next",class:"uploaded-file-pagination","aria-label":"已上传文件分页"},null,8,["current-page","total"])):vt("",!0)]))]))])}}}),wS=ki(yS,[["__scopeId","data-v-77d607a9"]]),ei=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),mr=[1/0,1/0,-1/0,-1/0],ja=new Float32Array(mr),ng=[.001,0,0,.001,0,0],qp=1.35,Rs="http://www.w3.org/2000/svg",ti={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Cr={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Bl="pdfjs_internal_id_",Kh="pdfjs_internal_editor_",ot={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},dt={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},AS={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},xe={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},rf={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},oe={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26,RICHMEDIA:27},Ll={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Dp={ERRORS:0,WARNINGS:1,INFOS:5},Ki={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},wh={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},SS={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Lp=Dp.WARNINGS;function xS(u){Number.isInteger(u)&&(Lp=u)}function ES(){return Lp}function Fp(u){Lp>=Dp.INFOS&&console.info(`Info: ${u}`)}function lt(u){Lp>=Dp.WARNINGS&&console.warn(`Warning: ${u}`)}function Ct(u){throw new Error(u)}function ne(u,t){u||Ct(t)}function CS(u){switch(u==null?void 0:u.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Zv(u,t=null,e=null){if(!u)return null;if(e&&typeof u=="string"){if(e.addDefaultProtocol&&u.startsWith("www.")){const i=u.match(/\./g);(i==null?void 0:i.length)>=2&&(u=`http://${u}`)}if(e.tryConvertEncoding)try{u=TS(u)}catch{}}const s=t?URL.parse(u,t):URL.parse(u);return CS(s)?s:null}function tb(u,t,e=!1){const s=URL.parse(u);return s?(s.hash=t,s.href):e&&Zv(u,"http://example.com")?u.split("#",1)[0]+`${t?`#${t}`:""}`:""}function rg(u){return u.substring(u.lastIndexOf("/")+1)}function at(u,t,e,s=!1){return Object.defineProperty(u,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Tl=(function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})();class ag extends Tl{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Yp extends Tl{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class og extends Tl{constructor(t){super(t,"InvalidPDFException")}}class Xf extends Tl{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class _S extends Tl{constructor(t){super(t,"FormatError")}}class _a extends Tl{constructor(t){super(t,"AbortException")}}function kS(u){(typeof u!="object"||(u==null?void 0:u.length)===void 0)&&Ct("Invalid argument for bytesToString");const t=u.length,e=8192;if(t<e)return String.fromCharCode.apply(null,u);const s=[];for(let i=0;i<t;i+=e){const r=Math.min(i+e,t),a=u.subarray(i,r);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function Op(u){typeof u!="string"&&Ct("Invalid argument for stringToBytes");const t=u.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=u.charCodeAt(s)&255;return e}class $t{static get isLittleEndian(){const t=new Uint8Array(4);t[0]=1;const e=new Uint32Array(t.buffer,0,1);return at(this,"isLittleEndian",e[0]===1)}static get isOffscreenCanvasSupported(){return at(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return at(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return at(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return at(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return at(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCanvasFilterSupported(){let t;return this.isOffscreenCanvasSupported?t=new OffscreenCanvas(1,1).getContext("2d"):typeof document<"u"&&(t=document.createElement("canvas").getContext("2d")),at(this,"isCanvasFilterSupported",(t==null?void 0:t.filter)!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>"u")return at(this,"isAlphaColorInputSupported",!1);const t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",at(this,"isAlphaColorInputSupported",t.value!=="#ff0000")}static get isBackdropFilterSupported(){return at(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}}var vr,af,lg;class B{static get hexNums(){return at(this,"hexNums",Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0")))}static makeHexColor(t,e,s){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[s]}`}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,s=0){const i=t[s],r=t[s+1];t[s]=i*e[0]+r*e[2]+e[4],t[s+1]=i*e[1]+r*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){const i=e[0],r=e[1],a=e[2],o=e[3],l=e[4],c=e[5];for(let h=0;h<6;h+=2){const d=t[s+h],f=t[s+h+1];t[s+h]=d*i+f*a+l,t[s+h+1]=d*r+f*o+c}}static applyInverseTransform(t,e){const s=t[0],i=t[1],r=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/r,t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/r}static axialAlignedBoundingBox(t,e,s){const i=e[0],r=e[1],a=e[2],o=e[3],l=e[4],c=e[5],h=t[0],d=t[1],f=t[2],g=t[3];let y=i*h+l,b=y,S=i*f+l,w=S,x=o*d+c,A=x,C=o*g+c,_=C;if(r!==0||a!==0){const k=r*h,I=r*f,L=a*d,P=a*g;y+=L,w+=L,S+=P,b+=P,x+=k,_+=k,C+=I,A+=I}s[0]=Math.min(s[0],y,S,b,w),s[1]=Math.min(s[1],x,C,A,_),s[2]=Math.max(s[2],y,S,b,w),s[3]=Math.max(s[3],x,C,A,_)}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){const s=t[0],i=t[1],r=t[2],a=t[3],o=s**2+i**2,l=s*r+i*a,c=r**2+a**2,h=(o+c)/2,d=Math.sqrt(h**2-(o*c-l**2));e[0]=Math.sqrt(h+d||1),e[1]=Math.sqrt(h-d||1)}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;const r=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return r>a?null:[s,r,i,a]}static pointBoundingBox(t,e,s){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}static rectBoundingBox(t,e,s,i,r){r[0]=Math.min(r[0],t,s),r[1]=Math.min(r[1],e,i),r[2]=Math.max(r[2],t,s),r[3]=Math.max(r[3],e,i)}static bezierBoundingBox(t,e,s,i,r,a,o,l,c){c[0]=Math.min(c[0],t,o),c[1]=Math.min(c[1],e,l),c[2]=Math.max(c[2],t,o),c[3]=Math.max(c[3],e,l),v(this,vr,lg).call(this,t,s,r,o,e,i,a,l,3*(-t+3*(s-r)+o),6*(t-2*s+r),3*(s-t),c),v(this,vr,lg).call(this,t,s,r,o,e,i,a,l,3*(-e+3*(i-a)+l),6*(e-2*i+a),3*(i-e),c)}}vr=new WeakSet,af=function(t,e,s,i,r,a,o,l,c,h){if(c<=0||c>=1)return;const d=1-c,f=c*c,g=f*c,y=d*(d*(d*t+3*c*e)+3*f*s)+g*i,b=d*(d*(d*r+3*c*a)+3*f*o)+g*l;h[0]=Math.min(h[0],y),h[1]=Math.min(h[1],b),h[2]=Math.max(h[2],y),h[3]=Math.max(h[3],b)},lg=function(t,e,s,i,r,a,o,l,c,h,d,f){if(Math.abs(c)<1e-12){Math.abs(h)>=1e-12&&v(this,vr,af).call(this,t,e,s,i,r,a,o,l,-d/h,f);return}const g=h**2-4*d*c;if(g<0)return;const y=Math.sqrt(g),b=2*c;v(this,vr,af).call(this,t,e,s,i,r,a,o,l,(-h+y)/b,f),v(this,vr,af).call(this,t,e,s,i,r,a,o,l,(-h-y)/b,f)},m(B,vr);function TS(u){return decodeURIComponent(escape(u))}let Kp=null,uv=null;function PS(u){return Kp||(Kp=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,uv=new Map([["ſt","ſt"]])),u.replaceAll(Kp,(t,e,s)=>e?e.normalize("NFKC"):uv.get(s))}function eb(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const u=new Uint8Array(32);return crypto.getRandomValues(u),kS(u)}function MS(u,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,i,...r]=e;if(!u(s)&&!Number.isInteger(s)||!t(i))return!1;const a=r.length;let o=!0;switch(i.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return a===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(a!==4)return!1;o=!1;break;default:return!1}for(const l of r)if(!(typeof l=="number"||o&&l===null))return!1;return!0}const Vu=()=>[],Hm=()=>new Map,cg=()=>Object.create(null);function Qt(u,t,e){return Math.min(Math.max(u,t),e)}class Gu{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:r=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=r,this.offsetY=a,s*=e;const l=(t[2]+t[0])/2,c=(t[3]+t[1])/2;let h,d,f,g;switch(i%=360,i<0&&(i+=360),i){case 180:h=-1,d=0,f=0,g=1;break;case 90:h=0,d=1,f=1,g=0;break;case 270:h=0,d=-1,f=-1,g=0;break;case 0:h=1,d=0,f=0,g=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(f=-f,g=-g);let y,b,S,w;h===0?(y=Math.abs(c-t[1])*s+r,b=Math.abs(l-t[0])*s+a,S=(t[3]-t[1])*s,w=(t[2]-t[0])*s):(y=Math.abs(l-t[0])*s+r,b=Math.abs(c-t[1])*s+a,S=(t[2]-t[0])*s,w=(t[3]-t[1])*s),this.transform=[h*s,d*s,f*s,g*s,y-h*s*l-f*s*c,b-d*s*l-g*s*c],this.width=S,this.height=w}get rawDims(){const t=this.viewBox;return at(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:r=!1}={}){return new Gu({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:r})}convertToViewportPoint(t,e){const s=[t,e];return B.applyTransform(s,this.transform),s}convertToPdfPoint(t,e){const s=[t,e];return B.applyInverseTransform(s,this.transform),s}}class Qh{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(r){var l;if(!r)return;let a=null;const o=r.name;if(o==="#text")a=r.value;else if(Qh.shouldBuildText(o))(l=r==null?void 0:r.attributes)!=null&&l.textContent?a=r.attributes.textContent:r.value&&(a=r.value);else return;if(a!==null&&e.push({str:a}),!!r.children)for(const c of r.children)i(c)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}class sb{static setupStorage(t,e,s,i,r){const a=i.getValue(e,{value:null});switch(s.name){case"textarea":if(a.value!==null&&(t.textContent=a.value),r==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(a.value===s.attributes.xfaOn?t.setAttribute("checked",!0):a.value===s.attributes.xfaOff&&t.removeAttribute("checked"),r==="print")break;t.addEventListener("change",o=>{i.setValue(e,{value:o.target.checked?o.target.getAttribute("xfaOn"):o.target.getAttribute("xfaOff")})})}else{if(a.value!==null&&t.setAttribute("value",a.value),r==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})})}break;case"select":if(a.value!==null){t.setAttribute("value",a.value);for(const o of s.children)o.attributes.value===a.value?o.attributes.selected=!0:Object.hasOwn(o.attributes,"selected")&&delete o.attributes.selected}t.addEventListener("input",o=>{const l=o.target.options,c=l.selectedIndex===-1?"":l[l.selectedIndex].value;i.setValue(e,{value:c})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:r}){const{attributes:a}=e,o=t instanceof HTMLAnchorElement;a.type==="radio"&&(a.name=`${a.name}-${i}`);for(const[l,c]of Object.entries(a))if(c!=null)switch(l){case"class":c.length&&t.setAttribute(l,c.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",c);break;case"style":Object.assign(t.style,c);break;case"textContent":t.textContent=c;break;default:(!o||l!=="href"&&l!=="newWindow")&&t.setAttribute(l,c)}o&&r.addLinkAttributes(t,a.href,a.newWindow),s&&a.dataId&&this.setupStorage(t,a.dataId,e,s)}static render(t){var d,f;const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,r=t.intent||"display",a=document.createElement(i.name);i.attributes&&this.setAttributes({html:a,element:i,intent:r,linkService:s});const o=r!=="richText",l=t.div;if(l.append(a),t.viewport){const g=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=g}o&&l.setAttribute("class","xfaLayer xfaFont");const c=[];if(i.children.length===0){if(i.value){const g=document.createTextNode(i.value);a.append(g),o&&Qh.shouldBuildText(i.name)&&c.push(g)}return{textDivs:c}}const h=[[i,-1,a]];for(;h.length>0;){const[g,y,b]=h.at(-1);if(y+1===g.children.length){h.pop();continue}const S=g.children[++h.at(-1)[1]];if(S===null)continue;const{name:w}=S;if(w==="#text"){const A=document.createTextNode(S.value);c.push(A),b.append(A);continue}const x=(d=S==null?void 0:S.attributes)!=null&&d.xmlns?document.createElementNS(S.attributes.xmlns,w):document.createElement(w);if(b.append(x),S.attributes&&this.setAttributes({html:x,element:S,storage:e,intent:r,linkService:s}),((f=S.children)==null?void 0:f.length)>0)h.push([S,-1,x]);else if(S.value){const A=document.createTextNode(S.value);o&&Qh.shouldBuildText(w)&&c.push(A),x.append(A)}}for(const g of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))g.setAttribute("readOnly",!0);return{textDivs:c}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}static getPageViewport(t,{scale:e=1,rotation:s=0}){const{width:i,height:r}=t.attributes.style;return new Gu({viewBox:[0,0,parseInt(i,10),parseInt(r,10)],userUnit:1,scale:e,rotation:s})}}const za=class za{};M(za,"CSS",96),M(za,"PDF",72),M(za,"PDF_TO_CSS_UNITS",za.CSS/za.PDF);let ka=za;async function zm(u,t="text"){if(Wh(u,document.baseURI)){const e=await fetch(u);if(!e.ok)throw new Error(e.statusText);switch(t){case"blob":return e.blob();case"bytes":return e.bytes();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const i=new XMLHttpRequest;i.open("GET",u,!0),i.responseType=t==="bytes"?"arraybuffer":t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"bytes":e(new Uint8Array(i.response));return;case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class Vm extends Tl{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Rp(u){const t=u.length;let e=0;for(;e<t&&u[e].trim()==="";)e++;return u.substring(e,e+5).toLowerCase()==="data:"}function Gm(u){return typeof u=="string"&&/\.pdf$/i.test(u)}function IS(u){return[u]=u.split(/[#?]/,1),rg(u)}function DS(u,t="document.pdf"){if(typeof u!="string")return t;if(Rp(u))return lt('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const s=(o=>{try{return new URL(o)}catch{}try{return new URL(decodeURIComponent(o))}catch{}try{return new URL(o,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(o),"https://foo.bar")}catch{}return null})(u);if(!s)return t;const i=o=>{try{let l=decodeURIComponent(o);return l.includes("/")&&(l=rg(l),l.length===4&&r.test(l))?o:l}catch{return o}},r=/\.pdf$/i,a=rg(s.pathname);if(r.test(a))return i(a);if(s.searchParams.size>0){const o=c=>[...c].findLast(h=>r.test(h)),l=o(s.searchParams.values())??o(s.searchParams.keys());if(l)return i(l)}if(s.hash){const l=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(s.hash);if(l)return i(l[0])}return t}var _r;class fv{constructor(){m(this,_r,new Map);M(this,"times",[])}time(t){n(this,_r).has(t)&&lt(`Timer is already running for ${t}`),n(this,_r).set(t,Date.now())}timeEnd(t){n(this,_r).has(t)||lt(`Timer has not been started for ${t}`),this.times.push({name:t,start:n(this,_r).get(t),end:Date.now()}),n(this,_r).delete(t)}toString(){const t=Math.max(...this.times.map(e=>e.name.length));return this.times.map(e=>`${e.name.padEnd(t)} ${e.end-e.start}ms
`).join("")}}_r=new WeakMap;function Wh(u,t){const e=t?URL.parse(u,t):URL.parse(u);return/https?:/.test((e==null?void 0:e.protocol)??"")}function Ci(u){u.preventDefault()}function ie(u){u.preventDefault(),u.stopPropagation()}var ed;class qf{static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;n(this,ed)||p(this,ed,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?"));const e=n(this,ed).exec(t);if(!e)return null;const s=parseInt(e[1],10);let i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(e[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(e[6],10);l=l>=0&&l<=59?l:0;const c=e[7]||"Z";let h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,c==="-"?(a+=h,o+=d):c==="+"&&(a-=h,o-=d),new Date(Date.UTC(s,i,r,a,o,l))}}ed=new WeakMap,m(qf,ed);function ju(u){if(u.startsWith("#")){const e=u.slice(1);return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16),e.length>=8?parseInt(e.slice(6,8),16)/255:1]}if(u.startsWith("rgb(")){const[e,s,i]=u.slice(4,-1).split(",").map(r=>parseInt(r,10));return[e,s,i,1]}if(u.startsWith("rgba(")){const e=u.slice(5,-1).split(",");return[parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10),parseFloat(e[3])]}const t=u.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return t?[Math.round(parseFloat(t[1])*255),Math.round(parseFloat(t[2])*255),Math.round(parseFloat(t[3])*255),t[4]!==void 0&&t[4]!=="none"?parseFloat(t[4]):1]:null}function Wu(u){const t=ju(u);return t?t.slice(0,3):(lt(`Not a valid color format: "${u}"`),[0,0,0])}function LS(u){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const e of u.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;u.set(e,Wu(s))}t.remove()}function Wt(u){const{a:t,b:e,c:s,d:i,e:r,f:a}=u.getTransform();return[t,e,s,i,r,a]}function Xi(u){const{a:t,b:e,c:s,d:i,e:r,f:a}=u.getTransform().invertSelf();return[t,e,s,i,r,a]}function xl(u,t,e=!1,s=!0){if(t instanceof Gu){const{pageWidth:i,pageHeight:r}=t.rawDims,{style:a}=u,o=`round(down, var(--total-scale-factor) * ${i}px, var(--scale-round-x))`,l=`round(down, var(--total-scale-factor) * ${r}px, var(--scale-round-y))`;!e||t.rotation%180===0?(a.width=o,a.height=l):(a.width=l,a.height=o)}s&&u.setAttribute("data-main-rotation",t.rotation)}class En{constructor(){const{pixelRatio:t}=En;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,s,i,r=-1){let a=1/0,o=1/0,l=1/0;s=En.capPixels(s,r),s>0&&(a=Math.sqrt(s/(t*e))),i!==-1&&(o=i/t,l=i/e);const c=Math.min(a,o,l);return this.sx>c||this.sy>c?(this.sx=c,this.sy=c,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,s):s}return t}}const hg=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class FS{static get isDarkMode(){var t;return at(this,"isDarkMode",!!((t=window==null?void 0:window.matchMedia)!=null&&t.call(window,"(prefers-color-scheme: dark)").matches))}}class OS{static get commentForegroundColor(){const t=document.createElement("span");t.classList.add("comment","sidebar");const{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);const{color:s}=window.getComputedStyle(t);return t.remove(),at(this,"commentForegroundColor",Wu(s))}}function RS(u,t){t=Qt(t??1,0,1);const e=255*(1-t);return u.map(s=>Math.round(s*t+e))}function pv(u,t){const e=u[0]/255,s=u[1]/255,i=u[2]/255,r=Math.max(e,s,i),a=Math.min(e,s,i),o=(r+a)/2;if(r===a)t[0]=t[1]=0;else{const l=r-a;switch(t[1]=o<.5?l/(r+a):l/(2-r-a),r){case e:t[0]=((s-i)/l+(s<i?6:0))*60;break;case s:t[0]=((i-e)/l+2)*60;break;case i:t[0]=((e-s)/l+4)*60;break}}t[2]=o}function dg(u,t){const e=u[0],s=u[1],i=u[2],r=(1-Math.abs(2*i-1))*s,a=r*(1-Math.abs(e/60%2-1)),o=i-r/2;switch(Math.floor(e/60)){case 0:t[0]=r+o,t[1]=a+o,t[2]=o;break;case 1:t[0]=a+o,t[1]=r+o,t[2]=o;break;case 2:t[0]=o,t[1]=r+o,t[2]=a+o;break;case 3:t[0]=o,t[1]=a+o,t[2]=r+o;break;case 4:t[0]=a+o,t[1]=o,t[2]=r+o;break;case 5:case 6:t[0]=r+o,t[1]=o,t[2]=a+o;break}}function gv(u){return u<=.03928?u/12.92:((u+.055)/1.055)**2.4}function mv(u,t,e){dg(u,e),e.map(gv);const s=.2126*e[0]+.7152*e[1]+.0722*e[2];dg(t,e),e.map(gv);const i=.2126*e[0]+.7152*e[1]+.0722*e[2];return s>i?(s+.05)/(i+.05):(i+.05)/(s+.05)}const vv=new Map;function NS(u,t){const e=u[0]+u[1]*256+u[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776;let s=vv.get(e);if(s)return s;const i=new Float32Array(9),r=i.subarray(0,3),a=i.subarray(3,6);pv(u,a);const o=i.subarray(6,9);pv(t,o);const l=o[2]<.5,c=l?12:4.5;if(a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]),mv(a,o,r)<c){let h,d;l?(h=a[2],d=1):(h=0,d=a[2]);const f=.005;for(;d-h>f;){const g=a[2]=(h+d)/2;l===mv(a,o,r)<c?h=g:d=g}a[2]=l?d:h}return dg(a,r),s=B.makeHexColor(Math.round(r[0]*255),Math.round(r[1]*255),Math.round(r[2]*255)),vv.set(e,s),s}function ib({html:u,dir:t,className:e},s){const i=document.createDocumentFragment();if(typeof u=="string"){const r=document.createElement("p");r.dir=t||"auto";const a=u.split(/\r\n?|\n/);for(let o=0,l=a.length;o<l;++o){const c=a[o];r.append(document.createTextNode(c)),o<l-1&&r.append(document.createElement("br"))}i.append(r)}else sb.render({xfaHtml:u,div:i,intent:"richText"});i.firstElementChild.classList.add("richText",e),s.append(i)}function nb(u){const t=new Path2D;if(!u)return t;for(let e=0,s=u.length;e<s;)switch(u[e++]){case wh.moveTo:t.moveTo(u[e++],u[e++]);break;case wh.lineTo:t.lineTo(u[e++],u[e++]);break;case wh.curveTo:t.bezierCurveTo(u[e++],u[e++],u[e++],u[e++],u[e++],u[e++]);break;case wh.quadraticCurveTo:t.quadraticCurveTo(u[e++],u[e++],u[e++],u[e++]);break;case wh.closePath:t.closePath();break;default:lt(`Unrecognized drawing path operator: ${u[e-1]}`);break}return t}var kr,Tr,li,ci,sd,Pr,zl,Vl,id,ip,rb,qe,ab,ob,Fl,Eh;const Mn=class Mn{constructor(t){m(this,qe);m(this,kr,null);m(this,Tr,null);m(this,li);m(this,ci,null);m(this,sd,null);m(this,Pr,null);m(this,zl,null);m(this,Vl,null);p(this,li,t),n(Mn,id)||p(Mn,id,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"}))}render(){const t=p(this,kr,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=n(this,li)._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",Ci,{signal:e}),t.addEventListener("pointerdown",v(Mn,ip,rb),{signal:e}));const s=p(this,ci,document.createElement("div"));s.className="buttons",t.append(s);const i=n(this,li).toolbarPosition;if(i){const{style:r}=t,a=n(this,li)._uiManager.direction==="ltr"?1-i[0]:i[0];r.insetInlineEnd=`${100*a}%`,r.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return n(this,kr)}hide(){var t;n(this,kr).classList.add("hidden"),(t=n(this,Tr))==null||t.hideDropdown()}show(){var t,e;n(this,kr).classList.remove("hidden"),(t=n(this,sd))==null||t.shown(),(e=n(this,Pr))==null||e.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=n(this,li),s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",n(Mn,id)[t]),v(this,qe,Fl).call(this,s)&&s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),n(this,ci).append(s)}async addAltText(t){const e=await t.render();v(this,qe,Fl).call(this,e),n(this,ci).append(e,n(this,qe,Eh)),p(this,sd,t)}addComment(t,e=null){if(n(this,Pr))return;const s=t.renderForToolbar();if(!s)return;v(this,qe,Fl).call(this,s);const i=p(this,zl,n(this,qe,Eh));e?(n(this,ci).insertBefore(s,e),n(this,ci).insertBefore(i,e)):n(this,ci).append(s,i),p(this,Pr,t),t.toolbar=this}addColorPicker(t){if(n(this,Tr))return;p(this,Tr,t);const e=t.renderButton();v(this,qe,Fl).call(this,e),n(this,ci).append(e,n(this,qe,Eh))}async addEditSignatureButton(t){const e=p(this,Vl,await t.renderEditButton(n(this,li)));v(this,qe,Fl).call(this,e),n(this,ci).append(e,n(this,qe,Eh))}removeButton(t){var e,s;switch(t){case"comment":(e=n(this,Pr))==null||e.removeToolbarCommentButton(),p(this,Pr,null),(s=n(this,zl))==null||s.remove(),p(this,zl,null);break}}async addButton(t,e){switch(t){case"colorPicker":e&&this.addColorPicker(e);break;case"altText":e&&await this.addAltText(e);break;case"editSignature":e&&await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":e&&this.addComment(e);break}}async addButtonBefore(t,e,s){if(!e&&t==="comment")return;const i=n(this,ci).querySelector(s);i&&t==="comment"&&this.addComment(e,i)}updateEditSignatureButton(t){n(this,Vl)&&(n(this,Vl).title=t)}remove(){var t;n(this,kr).remove(),(t=n(this,Tr))==null||t.destroy(),p(this,Tr,null)}};kr=new WeakMap,Tr=new WeakMap,li=new WeakMap,ci=new WeakMap,sd=new WeakMap,Pr=new WeakMap,zl=new WeakMap,Vl=new WeakMap,id=new WeakMap,ip=new WeakSet,rb=function(t){t.stopPropagation()},qe=new WeakSet,ab=function(t){n(this,li)._focusEventsAllowed=!1,ie(t)},ob=function(t){n(this,li)._focusEventsAllowed=!0,ie(t)},Fl=function(t){const e=n(this,li)._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",v(this,qe,ab).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",v(this,qe,ob).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Ci,{signal:e}),!0)},Eh=function(){const t=document.createElement("div");return t.className="divider",t},m(Mn,ip),m(Mn,id,null);let ug=Mn;var nd,Wa,Dn,yr,lb,cb,fg;class BS{constructor(t){m(this,yr);m(this,nd,null);m(this,Wa,null);m(this,Dn);p(this,Dn,t)}show(t,e,s){const[i,r]=v(this,yr,cb).call(this,e,s),{style:a}=n(this,Wa)||p(this,Wa,v(this,yr,lb).call(this));t.append(n(this,Wa)),a.insetInlineEnd=`${100*i}%`,a.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){n(this,Wa).remove()}}nd=new WeakMap,Wa=new WeakMap,Dn=new WeakMap,yr=new WeakSet,lb=function(){const t=p(this,Wa,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar");const e=n(this,Dn)._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",Ci,{signal:e});const s=p(this,nd,document.createElement("div"));return s.className="buttons",t.append(s),n(this,Dn).hasCommentManager()&&v(this,yr,fg).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{n(this,Dn).commentSelection("floating_button")}),v(this,yr,fg).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{n(this,Dn).highlightSelection("floating_button")}),t},cb=function(t,e){let s=0,i=0;for(const r of t){const a=r.y+r.height;if(a<s)continue;const o=r.x+(e?r.width:0);if(a>s){i=o,s=a;continue}e?o>i&&(i=o):o<i&&(i=o)}return[e?1-i:i,s]},fg=function(t,e,s,i){const r=document.createElement("button");r.classList.add("basic",t),r.tabIndex=0,r.setAttribute("data-l10n-id",e);const a=document.createElement("span");r.append(a),a.className="visuallyHidden",a.setAttribute("data-l10n-id",s);const o=n(this,Dn)._signal;o instanceof AbortSignal&&!o.aborted&&(r.addEventListener("contextmenu",Ci,{signal:o}),r.addEventListener("click",i,{signal:o})),n(this,nd).append(r)};const $S="068f09d6-5b37-4f77-a97a-f8ff4f253b68",Qp=Object.freeze({internal:$S});function hb(u,t,e){for(const s of e)t.addEventListener(s,u[s].bind(u))}var Xa,qa,Gl,Ya;const Ft=class Ft{static initializeAndAddPointerId(t){(n(Ft,qa)||p(Ft,qa,new Set)).add(t)}static setPointer(t,e){n(Ft,Xa)||p(Ft,Xa,e),n(Ft,Ya)??p(Ft,Ya,t)}static setTimeStamp(t){p(Ft,Gl,t)}static isSamePointerId(t){return n(Ft,Xa)===t}static isSamePointerIdOrRemove(t){var e;return n(Ft,Xa)===t?!0:((e=n(Ft,qa))==null||e.delete(t),!1)}static isSamePointerType(t){return n(Ft,Ya)===t}static isInitializedAndDifferentPointerType(t){return n(Ft,Ya)!==null&&!Ft.isSamePointerType(t)}static isSameTimeStamp(t){return n(Ft,Gl)===t}static isUsingMultiplePointers(){var t;return((t=n(Ft,qa))==null?void 0:t.size)>=1}static clearPointerType(){p(Ft,Ya,null)}static clearPointerIds(){p(Ft,Xa,NaN),p(Ft,qa,null)}static clearTimeStamp(){p(Ft,Gl,NaN)}};Xa=new WeakMap,qa=new WeakMap,Gl=new WeakMap,Ya=new WeakMap,m(Ft,Xa,NaN),m(Ft,qa,null),m(Ft,Gl,NaN),m(Ft,Ya,null);let Je=Ft;var np;class US{constructor(){m(this,np,0)}get id(){return`${Kh}${qt(this,np)._++}`}}np=new WeakMap;var jl,rd,Ze,Wl,of;const Qm=class Qm{constructor(){m(this,Wl);m(this,jl,eb());m(this,rd,0);m(this,Ze,null)}static get _isSVGFittingCanvas(){const t=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${Rs}"><rect width="1" height="1" style="fill:red;"/></svg>`,s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;const r=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return at(this,"_isSVGFittingCanvas",r)}async getFromFile(t){const{lastModified:e,name:s,size:i,type:r}=t;return v(this,Wl,of).call(this,`${e}_${s}_${i}_${r}`,t)}async getFromUrl(t){return v(this,Wl,of).call(this,t,t)}async getFromBlob(t,e){const s=await e;return v(this,Wl,of).call(this,t,s)}async getFromId(t){n(this,Ze)||p(this,Ze,new Map);const e=n(this,Ze).get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){n(this,Ze)||p(this,Ze,new Map);let s=n(this,Ze).get(t);if(s!=null&&s.bitmap)return s.refCounter+=1,s;const i=new OffscreenCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${n(this,jl)}_${qt(this,rd)._++}`,refCounter:1,isSvg:!1},n(this,Ze).set(t,s),n(this,Ze).set(s.id,s),s}getSvgUrl(t){const e=n(this,Ze).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var i;n(this,Ze)||p(this,Ze,new Map);const e=n(this,Ze).get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const r=new OffscreenCanvas(s.width,s.height);r.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=r.convertToBlob()}(i=s.close)==null||i.call(s),e.bitmap=null}isValidId(t){return t.startsWith(`image_${n(this,jl)}_`)}};jl=new WeakMap,rd=new WeakMap,Ze=new WeakMap,Wl=new WeakSet,of=async function(t,e){n(this,Ze)||p(this,Ze,new Map);let s=n(this,Ze).get(t);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${n(this,jl)}_${qt(this,rd)._++}`,refCounter:0,isSvg:!1});let i;if(typeof e=="string"?(s.url=e,i=await zm(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const r=Qm._isSVGFittingCanvas,a=new FileReader,o=new Image,l=new Promise((c,h)=>{o.onload=()=>{s.bitmap=o,s.isSvg=!0,c()},a.onload=async()=>{const d=s.svgUrl=a.result;o.src=await r?`${d}#svgView(preserveAspectRatio(none))`:d},o.onerror=a.onerror=h});a.readAsDataURL(i),await l}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){lt(i),s=null}return n(this,Ze).set(t,s),s&&n(this,Ze).set(s.id,s),s};let pg=Qm;var fe,Mr,ad,ee;class HS{constructor(t=128){m(this,fe,[]);m(this,Mr,!1);m(this,ad);m(this,ee,-1);p(this,ad,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:r=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(i&&t(),n(this,Mr))return;const l={cmd:t,undo:e,post:s,type:r};if(n(this,ee)===-1){n(this,fe).length>0&&(n(this,fe).length=0),p(this,ee,0),n(this,fe).push(l);return}if(a&&n(this,fe)[n(this,ee)].type===r){o&&(l.undo=n(this,fe)[n(this,ee)].undo),n(this,fe)[n(this,ee)]=l;return}const c=n(this,ee)+1;c===n(this,ad)?n(this,fe).splice(0,1):(p(this,ee,c),c<n(this,fe).length&&n(this,fe).splice(c)),n(this,fe).push(l)}undo(){if(n(this,ee)===-1)return;p(this,Mr,!0);const{undo:t,post:e}=n(this,fe)[n(this,ee)];t(),e==null||e(),p(this,Mr,!1),p(this,ee,n(this,ee)-1)}redo(){if(n(this,ee)<n(this,fe).length-1){p(this,ee,n(this,ee)+1),p(this,Mr,!0);const{cmd:t,post:e}=n(this,fe)[n(this,ee)];t(),e==null||e(),p(this,Mr,!1)}}hasSomethingToUndo(){return n(this,ee)!==-1}hasSomethingToRedo(){return n(this,ee)<n(this,fe).length-1}cleanType(t){if(n(this,ee)!==-1){for(let e=n(this,ee);e>=0;e--)if(n(this,fe)[e].type!==t){n(this,fe).splice(e+1,n(this,ee)-e),p(this,ee,e);return}n(this,fe).length=0,p(this,ee,-1)}}destroy(){p(this,fe,null)}}fe=new WeakMap,Mr=new WeakMap,ad=new WeakMap,ee=new WeakMap;var mh,db,ub;const bs=class bs{constructor(t){var s;this.callbacks=new Map;const{isMac:e}=$t.platform;for(const[i,r,a={}]of t){const o=i.some(l=>l.startsWith("mac+"));for(const l of i){let c=l;if(o){const f=l.startsWith("mac+");if(e!==f)continue;f&&(c=l.slice(4))}const[h,d]=v(s=bs,mh,db).call(s,c);h!==null&&this.callbacks.getOrInsertComputed(h,Vu).push({callback:r,options:a,modifiers:d})}}}exec(t,e){var h;let s=this.callbacks.get(e.key);if(!s){if(/^[a-z]$/i.test(e.key))return;const d=v(h=bs,mh,ub).call(h,e.code);if(d===null||d===e.key||(s=this.callbacks.get(d),!s))return}const i=(e.altKey?bs.ALT:0)|(e.ctrlKey?bs.CTRL:0)|(e.metaKey?bs.META:0)|(e.shiftKey?bs.SHIFT:0),r=s.find(d=>d.modifiers===i);if(!r)return;const{callback:a,options:{bubbles:o=!1,args:l=[],checker:c=null}}=r;c&&!c(t,e)||(a.bind(t,...l,e)(),o||ie(e))}};mh=new WeakSet,db=function(t){let e=null,s=0;for(let i of t.split("+")){if(i=i.trim(),!i)continue;const r=i.toUpperCase(),a=bs[r];if(a){s|=a;continue}if(e!==null){lt(`KeyboardManager: multiple keys in shortcut "${t}"`);break}e=r==="SPACE"?" ":i}return e===null&&lt(`KeyboardManager: no key found in shortcut "${t}"`),[e,s]},ub=function(t){var s;const e=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(t);return e?((s=e[1])==null?void 0:s.toLowerCase())??e[2]:null},m(bs,mh),M(bs,"ALT",1),M(bs,"CTRL",2),M(bs,"META",4),M(bs,"SHIFT",8);let El=bs;const rp=class rp{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return LS(t),at(this,"_colors",t)}convert(t){const e=Wu(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((r,a)=>r===e[a]))return rp._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?B.makeHexColor(...e):t}};M(rp,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let gg=rp;var Xl,Ns,ql,ce,se,Yl,Kl,os,Ql,hi,Pe,Ir,Dr,Lr,Fr,Qi,di,Ka,od,ld,Jl,cd,Ji,Or,Zl,Rr,Zi,ap,Ln,tc,hd,Nr,Qa,ec,Br,dd,be,Ot,Fn,$r,Ur,ud,sc,fd,Hr,tn,On,pd,gd,ui,z,lf,mg,fb,pb,gb,Ch,mb,vb,bb,vg,yb,wb,Ab,Sb,rs,Tn,xb,Eb,bg,Cb,_h,yg;const $l=class $l{constructor(t,e,s,i,r,a,o,l,c,h,d,f,g,y,b,S){m(this,z);m(this,Xl,new AbortController);m(this,Ns,null);m(this,ql,null);m(this,ce,new Map);m(this,se,new Map);m(this,Yl,null);m(this,Kl,null);m(this,os,null);m(this,Ql,null);m(this,hi,new HS);m(this,Pe,null);m(this,Ir,null);m(this,Dr,null);m(this,Lr,0);m(this,Fr,new Set);m(this,Qi,null);m(this,di,null);m(this,Ka,new Set);M(this,"_editorUndoBar",null);m(this,od,!1);m(this,ld,!1);m(this,Jl,!1);m(this,cd,null);m(this,Ji,null);m(this,Or,null);m(this,Zl,null);m(this,Rr,!1);m(this,Zi,null);m(this,ap,new US);m(this,Ln,!1);m(this,tc,!1);m(this,hd,!1);m(this,Nr,null);m(this,Qa,null);m(this,ec,null);m(this,Br,null);m(this,dd,null);m(this,be,ot.NONE);m(this,Ot,new Set);m(this,Fn,null);m(this,$r,null);m(this,Ur,null);m(this,ud,null);m(this,sc,null);m(this,fd,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});m(this,Hr,[0,0]);m(this,tn,null);m(this,On,null);m(this,pd,null);m(this,gd,null);m(this,ui,null);const w=this._signal=n(this,Xl).signal;p(this,On,t),p(this,pd,e),p(this,gd,s),p(this,Kl,i),p(this,Pe,r),p(this,$r,a),p(this,sc,l),this._eventBus=o;const x={signal:w,...Qp};o.on("editingaction",this.onEditingAction.bind(this),x),o.on("pagechanging",this.onPageChanging.bind(this),x),o.on("scalechanging",this.onScaleChanging.bind(this),x),o.on("rotationchanging",this.onRotationChanging.bind(this),x),o.on("setpreference",this.onSetPreference.bind(this),x),o.on("switchannotationeditorparams",A=>this.updateParams(A.type,A.value),x),window.addEventListener("pointerdown",()=>{p(this,tc,!0)},{capture:!0,signal:w}),window.addEventListener("pointerup",()=>{p(this,tc,!1)},{capture:!0,signal:w}),window.addEventListener("beforeunload",v(this,z,fb).bind(this),{capture:!0,signal:w}),v(this,z,mb).call(this),v(this,z,Sb).call(this),v(this,z,vg).call(this),p(this,os,l.annotationStorage),p(this,cd,l.filterFactory),p(this,Ur,c),p(this,Zl,h||null),p(this,od,d),p(this,ld,f),p(this,Jl,g),p(this,dd,y||null),this.viewParameters={realScale:ka.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=b||null,this._supportsPinchToZoom=S!==!1,r==null||r.setSidebarUiManager(this)}static get _keyboardManager(){const t=$l.prototype,e=a=>n(a,On).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&a.hasSomethingToControl(),s=(a,{target:o})=>{if(o instanceof HTMLInputElement){const{type:l}=o;return l!=="text"&&l!=="number"}return!0},i=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return at(this,"_keyboardManager",new El([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:s}],[["Enter"],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&n(a,On).contains(o)&&!a.isEnterHandled}],[["Space"],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&n(a,On).contains(document.activeElement)}],[["Escape"],t.unselectAll],[["ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}]]))}destroy(){var t,e,s,i,r,a,o,l,c;(t=n(this,ui))==null||t.resolve(),p(this,ui,null),(e=n(this,Xl))==null||e.abort(),p(this,Xl,null),this._signal=null;for(const h of n(this,se).values())h.destroy();n(this,se).clear(),n(this,ce).clear(),n(this,Ka).clear(),(s=n(this,Br))==null||s.clear(),p(this,Ns,null),n(this,Ot).clear(),n(this,hi).destroy(),(i=n(this,Kl))==null||i.destroy(),(r=n(this,Pe))==null||r.destroy(),(a=n(this,$r))==null||a.destroy(),(o=n(this,Zi))==null||o.hide(),p(this,Zi,null),(l=n(this,ec))==null||l.destroy(),p(this,ec,null),p(this,ql,null),n(this,Ji)&&(clearTimeout(n(this,Ji)),p(this,Ji,null)),n(this,tn)&&(clearTimeout(n(this,tn)),p(this,tn,null)),(c=this._editorUndoBar)==null||c.destroy(),p(this,sc,null)}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return n(this,dd)}get useNewAltTextFlow(){return n(this,ld)}get useNewAltTextWhenAddingImage(){return n(this,Jl)}get hcmFilter(){return at(this,"hcmFilter",n(this,Ur)?n(this,cd).addHCMFilter(n(this,Ur).foreground,n(this,Ur).background):"none")}get direction(){return at(this,"direction",getComputedStyle(n(this,On)).direction)}get _highlightColors(){return at(this,"_highlightColors",n(this,Zl)?new Map(n(this,Zl).split(",").map(t=>(t=t.split("=").map(e=>e.trim()),t[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return at(this,"highlightColors",null);const e=new Map,s=!!n(this,Ur);for(const[i,r]of t){const a=i.endsWith("_HCM");if(s&&a){e.set(i.replace("_HCM",""),r);continue}!s&&!a&&e.set(i,r)}return at(this,"highlightColors",e)}get highlightColorNames(){return at(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),p(this,Dr,t)}setMainHighlightColorPicker(t){p(this,ec,t)}editAltText(t,e=!1){var s;(s=n(this,Kl))==null||s.editAltText(this,t,e)}hasCommentManager(){return!!n(this,Pe)}editComment(t,e,s,i){var r;(r=n(this,Pe))==null||r.showDialog(this,t,e,s,i)}selectComment(t,e){const s=n(this,se).get(t),i=s==null?void 0:s.getEditorByUID(e);i==null||i.toggleComment(!0,!0)}updateComment(t){var e;(e=n(this,Pe))==null||e.updateComment(t.getData())}updatePopupColor(t){var e;(e=n(this,Pe))==null||e.updatePopupColor(t)}removeComment(t){var e;(e=n(this,Pe))==null||e.removeComments([t.uid])}deleteComment(t,e){const s=()=>{t.comment=e},i=()=>{var r;(r=this._editorUndoBar)==null||r.show(s,"comment"),this.toggleComment(null),t.comment=null};this.addCommands({cmd:i,undo:s,mustExec:!0})}toggleComment(t,e,s=void 0){var i;(i=n(this,Pe))==null||i.toggleCommentPopup(t,e,s)}makeCommentColor(t,e){var s;return t&&((s=n(this,Pe))==null?void 0:s.makeCommentColor(t,e))||null}getCommentDialogElement(){var t;return((t=n(this,Pe))==null?void 0:t.dialogElement)||null}async waitForEditorsRendered(t){if(n(this,se).has(t-1))return;const{resolve:e,promise:s}=Promise.withResolvers(),i=r=>{r.pageNumber===t&&(this._eventBus.off("editorsrendered",i),e())};this._eventBus.on("editorsrendered",i,Qp),await s}getSignature(t){var e;(e=n(this,$r))==null||e.getSignature({uiManager:this,editor:t})}get signatureManager(){return n(this,$r)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal,...Qp}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){switch(t){case"enableNewAltTextWhenAddingImage":p(this,Jl,e);break}}onPageChanging({pageNumber:t}){p(this,Lr,t-1)}deletePage(t){for(const e of this.getEditors(t))e.remove();n(this,se).delete(t),n(this,Lr)===t&&p(this,Lr,0)}focusMainContainer(){n(this,On).focus()}findParent(t,e){for(const s of n(this,se).values()){const{x:i,y:r,width:a,height:o}=s.div.getBoundingClientRect();if(t>=i&&t<=i+a&&e>=r&&e<=r+o)return s}return null}disableUserSelect(t=!1){n(this,pd).classList.toggle("noUserSelect",t)}addShouldRescale(t){n(this,Ka).add(t)}removeShouldRescale(t){n(this,Ka).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*ka.PDF_TO_CSS_UNITS;for(const s of n(this,Ka))s.onScaleChanging();(e=n(this,Dr))==null||e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t="",e=!1){const s=document.getSelection();if(!s||s.isCollapsed)return;const{anchorNode:i,anchorOffset:r,focusNode:a,focusOffset:o}=s,l=s.toString(),h=v(this,z,lf).call(this,s).closest(".textLayer"),d=this.getSelectionBoxes(h);if(!d)return;s.empty();const f=v(this,z,mg).call(this,h),g=n(this,be)===ot.NONE,y=()=>{const b=f==null?void 0:f.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:d,anchorNode:i,anchorOffset:r,focusNode:a,focusOffset:o,text:l});g&&this.showAllEditors("highlight",!0,!0),e&&(b==null||b.editComment())};if(g){this.switchToMode(ot.HIGHLIGHT,y);return}y()}commentSelection(t=""){this.highlightSelection(t,!0)}getAndRemoveDataFromAnnotationStorage(t){if(!n(this,os))return null;const e=`${Kh}${t}`,s=n(this,os).getRawValue(e);return s&&n(this,os).remove(e),s}addToAnnotationStorage(t){!t.isEmpty()&&n(this,os)&&!n(this,os).has(t.id)&&n(this,os).setValue(t.id,t)}a11yAlert(t,e=null){const s=n(this,gd);s&&(s.setAttribute("data-l10n-id",t),e?s.setAttribute("data-l10n-args",JSON.stringify(e)):s.removeAttribute("data-l10n-args"))}blur(){if(this.isShiftKeyDown=!1,n(this,Rr)&&(p(this,Rr,!1),v(this,z,Ch).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of n(this,Ot))if(e.div.contains(t)){p(this,Qa,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!n(this,Qa))return;const[t,e]=n(this,Qa);p(this,Qa,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){v(this,z,vg).call(this),this.setEditingState(!0)}removeEditListeners(){v(this,z,yb).call(this),this.setEditingState(!1)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of n(this,di))if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of n(this,di))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=n(this,Ns))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];for(const i of n(this,Ot)){const r=i.serialize(!0);r&&e.push(r)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const r of e.items)for(const a of n(this,di))if(a.isHandlingMimeForPasting(r.type)){a.paste(r,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(r){lt(`paste: "${r.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const r=[];for(const l of s){const c=await i.deserialize(l);if(!c)return;r.push(c)}const a=()=>{for(const l of r)v(this,z,bg).call(this,l);v(this,z,yg).call(this,r)},o=()=>{for(const l of r)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(r){lt(`paste: "${r.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),n(this,be)!==ot.NONE&&!this.isEditorHandlingKeyboard&&$l._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,n(this,Rr)&&(p(this,Rr,!1),v(this,z,Ch).call(this,"main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}updatePageIndex(t,e){for(const i of this.getEditors(t))i.pageIndex=e;const s=n(this,Yl).get(t);s&&(s.pageIndex=e,n(this,se).set(e,s),n(this,Ln)?s.enable():s.disable())}startUpdatePages(){p(this,Yl,new Map(n(this,se))),n(this,se).clear()}endUpdatePages(){p(this,Yl,null)}clonePage(t,e){for(const s of this.getEditors(t)){const i=s.serialize(s.mode!==ot.HIGHLIGHT);i&&(i.pageIndex=e,i.id=this.getId(),i.isClone=!0,delete i.popupRef,n(this,os).setValue(i.id,i))}}findClonesForPage(t){const e=[],{pageIndex:s}=t;for(const[i,r]of n(this,os))r.pageIndex===s&&r.isClone&&(n(this,os).remove(i),e.push(t.deserialize(r).then(a=>{a&&(a.isClone=!0,t.addOrRebuild(a))})));return Promise.all(e)}setEditingState(t){t?(v(this,z,vb).call(this),v(this,z,wb).call(this),v(this,z,rs).call(this,{isEditing:n(this,be)!==ot.NONE,isEmpty:v(this,z,_h).call(this),hasSomethingToUndo:n(this,hi).hasSomethingToUndo(),hasSomethingToRedo:n(this,hi).hasSomethingToRedo(),hasSelectedEditor:!1})):(v(this,z,bb).call(this),v(this,z,Ab).call(this),v(this,z,rs).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!n(this,di)){p(this,di,t);for(const e of n(this,di))v(this,z,Tn).call(this,e.defaultPropertiesToUpdate)}}getId(){return n(this,ap).id}get currentLayer(){return n(this,se).get(n(this,Lr))}getLayer(t){return n(this,se).get(t)}get currentPageIndex(){return n(this,Lr)}addLayer(t){n(this,se).set(t.pageIndex,t),n(this,Ln)?t.enable():t.disable()}removeLayer(t){n(this,se).delete(t.pageIndex)}async updateMode(t,e=null,s=!1,i=!1,r=!1,a=!1){var o,l,c,h,d,f;if(n(this,be)!==t&&!(n(this,ui)&&(await n(this,ui).promise,!n(this,ui)))){if(p(this,ui,Promise.withResolvers()),(o=n(this,Dr))==null||o.commitOrRemove(),n(this,be)===ot.POPUP&&((l=n(this,Pe))==null||l.hideSidebar()),(c=n(this,Pe))==null||c.destroyPopup(),p(this,be,t),t===ot.NONE){this.setEditingState(!1),v(this,z,Eb).call(this);for(const g of n(this,ce).values())g.hideStandaloneCommentButton();(h=this._editorUndoBar)==null||h.hide(),this.toggleComment(null),n(this,ui).resolve();return}for(const g of n(this,ce).values())g.addStandaloneCommentButton();t===ot.SIGNATURE&&await((d=n(this,$r))==null?void 0:d.loadSignatures()),s&&Je.clearPointerType(),this.setEditingState(!0),await v(this,z,xb).call(this),this.unselectAll();for(const g of n(this,se).values())g.updateMode(t);if(t===ot.POPUP){n(this,ql)||p(this,ql,await n(this,sc).getAnnotationsByType(new Set(n(this,di).map(b=>b._editorType))));const g=new Set,y=[];for(const b of n(this,ce).values()){const{annotationElementId:S,hasComment:w,deleted:x}=b;S&&g.add(S),w&&!x&&y.push(b.getData())}for(const b of n(this,ql)){const{id:S,popupRef:w,contentsObj:x}=b;w&&(x!=null&&x.str)&&!g.has(S)&&!n(this,Fr).has(S)&&y.push(b)}(f=n(this,Pe))==null||f.showSidebar(y)}if(!e){i&&this.addNewEditorFromKeyboard(),n(this,ui).resolve();return}for(const g of n(this,ce).values())g.uid===e?(this.setSelected(g),a?g.editComment():r?g.enterInEditMode():g.focus()):g.unselect();n(this,ui).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==n(this,be)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(n(this,di)){switch(t){case dt.CREATE:this.currentLayer.addNewEditor(e);return;case dt.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(n(this,ud)||p(this,ud,new Map)).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(const s of n(this,Ot))s.updateParams(t,e);else for(const s of n(this,di))s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var r;for(const a of n(this,ce).values())a.editorType===t&&a.show(e);(((r=n(this,ud))==null?void 0:r.get(dt.HIGHLIGHT_SHOW_ALL))??!0)!==e&&v(this,z,Tn).call(this,[[dt.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(n(this,hd)!==t){p(this,hd,t);for(const e of n(this,se).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}*getEditors(t){for(const e of n(this,ce).values())e.pageIndex===t&&(yield e)}getEditor(t){return n(this,ce).get(t)}addEditor(t){n(this,ce).set(t.id,t)}removeEditor(t){var e,s;t.div.contains(document.activeElement)&&(n(this,Ji)&&clearTimeout(n(this,Ji)),p(this,Ji,setTimeout(()=>{this.focusMainContainer(),p(this,Ji,null)},0))),n(this,ce).delete(t.id),t.annotationElementId&&((e=n(this,Br))==null||e.delete(t.annotationElementId)),this.unselect(t),(!t.annotationElementId||!n(this,Fr).has(t.annotationElementId))&&((s=n(this,os))==null||s.remove(t.id))}addDeletedAnnotationElement(t){n(this,Fr).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return n(this,Fr).has(t)}removeDeletedAnnotationElement(t){n(this,Fr).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){n(this,Ns)!==t&&(p(this,Ns,t),t&&v(this,z,Tn).call(this,t.propertiesToUpdate))}updateUI(t){n(this,z,Cb)===t&&v(this,z,Tn).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){v(this,z,Tn).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(n(this,Ot).has(t)){n(this,Ot).delete(t),t.unselect(),v(this,z,rs).call(this,{hasSelectedEditor:this.hasSelection});return}n(this,Ot).add(t),t.select(),v(this,z,Tn).call(this,t.propertiesToUpdate),v(this,z,rs).call(this,{hasSelectedEditor:!0})}setSelected(t){var e,s;this.updateToolbar({mode:t.mode,editId:t.uid}),(e=n(this,Dr))==null||e.commitOrRemove();for(const i of n(this,Ot))i!==t&&i.unselect();(s=n(this,Pe))==null||s.destroyPopup(),n(this,Ot).clear(),n(this,Ot).add(t),t.select(),v(this,z,Tn).call(this,t.propertiesToUpdate),v(this,z,rs).call(this,{hasSelectedEditor:!0})}get firstSelectedEditor(){return n(this,Ot).values().next().value}unselect(t){t.unselect(),n(this,Ot).delete(t),v(this,z,rs).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return n(this,Ot).size!==0}get isEnterHandled(){return n(this,Ot).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var t;n(this,hi).undo(),v(this,z,rs).call(this,{hasSomethingToUndo:n(this,hi).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:v(this,z,_h).call(this)}),(t=this._editorUndoBar)==null||t.hide()}redo(){n(this,hi).redo(),v(this,z,rs).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:n(this,hi).hasSomethingToRedo(),isEmpty:v(this,z,_h).call(this)})}addCommands(t){n(this,hi).add(t),v(this,z,rs).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:v(this,z,_h).call(this)})}cleanUndoStack(t){n(this,hi).cleanType(t)}delete(){var r;this.commitOrRemove();const t=(r=this.currentLayer)==null?void 0:r.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...n(this,Ot)],s=()=>{var a;(a=this._editorUndoBar)==null||a.show(i,e.length===1?e[0].editorType:e.length);for(const o of e)o.remove()},i=()=>{for(const a of e)v(this,z,bg).call(this,a)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){var t;(t=n(this,Ns))==null||t.commitOrRemove()}hasSomethingToControl(){return n(this,Ns)||this.hasSelection}selectAll(){for(const t of n(this,Ot))t.commit();v(this,z,yg).call(this,n(this,ce).values())}unselectAll(){var t,e;if(!(n(this,Ns)&&(n(this,Ns).commitOrRemove(),n(this,be)!==ot.NONE))&&!((t=n(this,Dr))!=null&&t.commitOrRemove())&&((e=n(this,Pe))==null||e.destroyPopup(),!!this.hasSelection)){for(const s of n(this,Ot))s.unselect();n(this,Ot).clear(),v(this,z,rs).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;n(this,Hr)[0]+=t,n(this,Hr)[1]+=e;const[i,r]=n(this,Hr),a=[...n(this,Ot)],o=1e3;n(this,tn)&&clearTimeout(n(this,tn)),p(this,tn,setTimeout(()=>{p(this,tn,null),n(this,Hr)[0]=n(this,Hr)[1]=0,this.addCommands({cmd:()=>{for(const l of a)n(this,ce).has(l.id)&&(l.translateInPage(i,r),l.translationDone())},undo:()=>{for(const l of a)n(this,ce).has(l.id)&&(l.translateInPage(-i,-r),l.translationDone())},mustExec:!1})},o));for(const l of a)l.translateInPage(t,e),l.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),p(this,Qi,new Map);for(const t of n(this,Ot))n(this,Qi).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!n(this,Qi))return!1;this.disableUserSelect(!1);const t=n(this,Qi);p(this,Qi,null);let e=!1;for(const[{x:i,y:r,pageIndex:a},o]of t)o.newX=i,o.newY=r,o.newPageIndex=a,e||(e=i!==o.savedX||r!==o.savedY||a!==o.savedPageIndex);if(!e)return!1;const s=(i,r,a,o)=>{if(n(this,ce).has(i.id)){const l=n(this,se).get(o);l?i._setParentAndPosition(l,r,a):(i.pageIndex=o,i.x=r,i.y=a)}};return this.addCommands({cmd:()=>{for(const[i,{newX:r,newY:a,newPageIndex:o}]of t)s(i,r,a,o)},undo:()=>{for(const[i,{savedX:r,savedY:a,savedPageIndex:o}]of t)s(i,r,a,o)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(n(this,Qi))for(const s of n(this,Qi).keys())s.drag(t,e)}rebuild(t){if(t.parent===null){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return((t=this.getActive())==null?void 0:t.shouldGetKeyboardEvents())||n(this,Ot).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return n(this,Ns)===t}getActive(){return n(this,Ns)}getMode(){return n(this,be)}isEditingMode(){return n(this,be)!==ot.NONE}get imageManager(){return at(this,"imageManager",new pg)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let c=0,h=e.rangeCount;c<h;c++)if(!t.contains(e.getRangeAt(c).commonAncestorContainer))return null;const{x:s,y:i,width:r,height:a}=t.getBoundingClientRect();let o;switch(t.getAttribute("data-main-rotation")){case"90":o=(c,h,d,f)=>({x:(h-i)/a,y:1-(c+d-s)/r,width:f/a,height:d/r});break;case"180":o=(c,h,d,f)=>({x:1-(c+d-s)/r,y:1-(h+f-i)/a,width:d/r,height:f/a});break;case"270":o=(c,h,d,f)=>({x:1-(h+f-i)/a,y:(c-s)/r,width:f/a,height:d/r});break;default:o=(c,h,d,f)=>({x:(c-s)/r,y:(h-i)/a,width:d/r,height:f/a});break}const l=[];for(let c=0,h=e.rangeCount;c<h;c++){const d=e.getRangeAt(c);if(!d.collapsed)for(const{x:f,y:g,width:y,height:b}of d.getClientRects())y===0||b===0||l.push(o(f,g,y,b))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:t,id:e}){(n(this,Ql)||p(this,Ql,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;(e=n(this,Ql))==null||e.delete(t)}renderAnnotationElement(t){var i;const e=(i=n(this,Ql))==null?void 0:i.get(t.data.id);if(!e)return;const s=n(this,os).getRawValue(e);s&&(n(this,be)===ot.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}setMissingCanvas(t,e,s){var r;const i=(r=n(this,Br))==null?void 0:r.get(t);i&&(i.setCanvas(e,s),n(this,Br).delete(t))}addMissingCanvas(t,e){(n(this,Br)||p(this,Br,new Map)).set(t,e)}};Xl=new WeakMap,Ns=new WeakMap,ql=new WeakMap,ce=new WeakMap,se=new WeakMap,Yl=new WeakMap,Kl=new WeakMap,os=new WeakMap,Ql=new WeakMap,hi=new WeakMap,Pe=new WeakMap,Ir=new WeakMap,Dr=new WeakMap,Lr=new WeakMap,Fr=new WeakMap,Qi=new WeakMap,di=new WeakMap,Ka=new WeakMap,od=new WeakMap,ld=new WeakMap,Jl=new WeakMap,cd=new WeakMap,Ji=new WeakMap,Or=new WeakMap,Zl=new WeakMap,Rr=new WeakMap,Zi=new WeakMap,ap=new WeakMap,Ln=new WeakMap,tc=new WeakMap,hd=new WeakMap,Nr=new WeakMap,Qa=new WeakMap,ec=new WeakMap,Br=new WeakMap,dd=new WeakMap,be=new WeakMap,Ot=new WeakMap,Fn=new WeakMap,$r=new WeakMap,Ur=new WeakMap,ud=new WeakMap,sc=new WeakMap,fd=new WeakMap,Hr=new WeakMap,tn=new WeakMap,On=new WeakMap,pd=new WeakMap,gd=new WeakMap,ui=new WeakMap,z=new WeakSet,lf=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},mg=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of n(this,se).values())if(s.hasTextLayer(t))return s;return null},fb=function(t){var e;this.commitOrRemove(),(e=this.currentLayer)==null||e.endDrawingSession(!1)},pb=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=v(this,z,lf).call(this,t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(n(this,Zi)||p(this,Zi,new BS(this)),n(this,Zi).show(s,i,this.direction==="ltr"))},gb=function(){var r,a,o;const t=document.getSelection();if(!t||t.isCollapsed){n(this,Fn)&&((r=n(this,Zi))==null||r.hide(),p(this,Fn,null),v(this,z,rs).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===n(this,Fn))return;const i=v(this,z,lf).call(this,t).closest(".textLayer");if(!i){n(this,Fn)&&((a=n(this,Zi))==null||a.hide(),p(this,Fn,null),v(this,z,rs).call(this,{hasSelectedText:!1}));return}if((o=n(this,Zi))==null||o.hide(),p(this,Fn,e),v(this,z,rs).call(this,{hasSelectedText:!0}),!(n(this,be)!==ot.HIGHLIGHT&&n(this,be)!==ot.NONE)&&(n(this,be)===ot.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),p(this,Rr,this.isShiftKeyDown),!this.isShiftKeyDown)){const l=n(this,be)===ot.HIGHLIGHT?v(this,z,mg).call(this,i):null;if(l==null||l.toggleDrawing(),n(this,tc)){const c=new AbortController,h=this.combinedSignal(c),d=f=>{f.type==="pointerup"&&f.button!==0||(c.abort(),l==null||l.toggleDrawing(!0),f.type==="pointerup"&&v(this,z,Ch).call(this,"main_toolbar"))};window.addEventListener("pointerup",d,{signal:h}),window.addEventListener("blur",d,{signal:h})}else l==null||l.toggleDrawing(!0),v(this,z,Ch).call(this,"main_toolbar")}},Ch=function(t=""){n(this,be)===ot.HIGHLIGHT?this.highlightSelection(t):n(this,od)&&v(this,z,pb).call(this)},mb=function(){document.addEventListener("selectionchange",v(this,z,gb).bind(this),{signal:this._signal})},vb=function(){if(n(this,Or))return;p(this,Or,new AbortController);const t=this.combinedSignal(n(this,Or));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},bb=function(){var t;(t=n(this,Or))==null||t.abort(),p(this,Or,null)},vg=function(){if(n(this,Nr))return;p(this,Nr,new AbortController);const t=this.combinedSignal(n(this,Nr));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},yb=function(){var t;(t=n(this,Nr))==null||t.abort(),p(this,Nr,null)},wb=function(){if(n(this,Ir))return;p(this,Ir,new AbortController);const t=this.combinedSignal(n(this,Ir));document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})},Ab=function(){var t;(t=n(this,Ir))==null||t.abort(),p(this,Ir,null)},Sb=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},rs=function(t){Object.entries(t).some(([s,i])=>n(this,fd)[s]!==i)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(n(this,fd),t)}),n(this,be)===ot.HIGHLIGHT&&t.hasSelectedEditor===!1&&v(this,z,Tn).call(this,[[dt.HIGHLIGHT_FREE,!0]]))},Tn=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},xb=async function(){if(!n(this,Ln)){p(this,Ln,!0);const t=[];for(const e of n(this,se).values())t.push(e.enable());await Promise.all(t);for(const e of n(this,ce).values())e.enable()}},Eb=function(){if(this.unselectAll(),n(this,Ln)){p(this,Ln,!1);for(const t of n(this,se).values())t.disable();for(const t of n(this,ce).values())t.disable()}},bg=function(t){const e=n(this,se).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},Cb=function(){let t=null;for(t of n(this,Ot));return t},_h=function(){if(n(this,ce).size===0)return!0;if(n(this,ce).size===1)for(const t of n(this,ce).values())return t.isEmpty();return!1},yg=function(t){for(const e of n(this,Ot))e.unselect();n(this,Ot).clear();for(const e of t)e.isEmpty()||(n(this,Ot).add(e),e.select());v(this,z,rs).call(this,{hasSelectedEditor:this.hasSelection})},M($l,"TRANSLATE_SMALL",1),M($l,"TRANSLATE_BIG",10);let Cl=$l;var Me,en,Ii,ic,sn,Bs,nc,nn,ws,Rn,Ja,rn,zr,ji,kh,cf;const as=class as{constructor(t){m(this,ji);m(this,Me,null);m(this,en,!1);m(this,Ii,null);m(this,ic,null);m(this,sn,null);m(this,Bs,null);m(this,nc,!1);m(this,nn,null);m(this,ws,null);m(this,Rn,null);m(this,Ja,null);m(this,rn,!1);p(this,ws,t),p(this,rn,t._uiManager.useNewAltTextFlow),n(as,zr)||p(as,zr,Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(t){as._l10n??(as._l10n=t)}async render(){const t=p(this,Ii,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=p(this,ic,document.createElement("span"));t.append(e),n(this,rn)?(t.classList.add("new"),t.setAttribute("data-l10n-id",n(as,zr).missing),e.setAttribute("data-l10n-id",n(as,zr)["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=n(this,ws)._uiManager._signal;t.addEventListener("contextmenu",Ci,{signal:s}),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),n(this,ws)._uiManager.editAltText(n(this,ws)),n(this,rn)&&n(this,ws)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:n(this,ji,kh)}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(p(this,nc,!0),i(r))},{signal:s}),await v(this,ji,cf).call(this),t}finish(){n(this,Ii)&&(n(this,Ii).focus({focusVisible:n(this,nc)}),p(this,nc,!1))}isEmpty(){return n(this,rn)?n(this,Me)===null:!n(this,Me)&&!n(this,en)}hasData(){return n(this,rn)?n(this,Me)!==null||!!n(this,Rn):this.isEmpty()}get guessedText(){return n(this,Rn)}async setGuessedText(t){n(this,Me)===null&&(p(this,Rn,t),p(this,Ja,await as._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),v(this,ji,cf).call(this))}toggleAltTextBadge(t=!1){var e;if(!n(this,rn)||n(this,Me)){(e=n(this,nn))==null||e.remove(),p(this,nn,null);return}if(!n(this,nn)){const s=p(this,nn,document.createElement("div"));s.className="noAltTextBadge",n(this,ws).div.append(s)}n(this,nn).classList.toggle("hidden",!t)}serialize(t){let e=n(this,Me);return!t&&n(this,Rn)===e&&(e=n(this,Ja)),{altText:e,decorative:n(this,en),guessedText:n(this,Rn),textWithDisclaimer:n(this,Ja)}}get data(){return{altText:n(this,Me),decorative:n(this,en)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:r=!1}){s&&(p(this,Rn,s),p(this,Ja,i)),!(n(this,Me)===t&&n(this,en)===e)&&(r||(p(this,Me,t),p(this,en,e)),v(this,ji,cf).call(this))}toggle(t=!1){n(this,Ii)&&(!t&&n(this,Bs)&&(clearTimeout(n(this,Bs)),p(this,Bs,null)),n(this,Ii).disabled=!t)}shown(){n(this,ws)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:n(this,ji,kh)}})}destroy(){var t,e;(t=n(this,Ii))==null||t.remove(),p(this,Ii,null),p(this,ic,null),p(this,sn,null),(e=n(this,nn))==null||e.remove(),p(this,nn,null)}};Me=new WeakMap,en=new WeakMap,Ii=new WeakMap,ic=new WeakMap,sn=new WeakMap,Bs=new WeakMap,nc=new WeakMap,nn=new WeakMap,ws=new WeakMap,Rn=new WeakMap,Ja=new WeakMap,rn=new WeakMap,zr=new WeakMap,ji=new WeakSet,kh=function(){return n(this,Me)&&"added"||n(this,Me)===null&&this.guessedText&&"review"||"missing"},cf=async function(){var i,r,a;const t=n(this,Ii);if(!t)return;if(n(this,rn)){if(t.classList.toggle("done",!!n(this,Me)),t.setAttribute("data-l10n-id",n(as,zr)[n(this,ji,kh)]),(i=n(this,ic))==null||i.setAttribute("data-l10n-id",n(as,zr)[`${n(this,ji,kh)}-label`]),!n(this,Me)){(r=n(this,sn))==null||r.remove();return}}else{if(!n(this,Me)&&!n(this,en)){t.classList.remove("done"),(a=n(this,sn))==null||a.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=n(this,sn);if(!e){p(this,sn,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${n(this,ws).id}`;const o=100,l=n(this,ws)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(n(this,Bs)),p(this,Bs,null)},{once:!0}),t.addEventListener("mouseenter",()=>{p(this,Bs,setTimeout(()=>{p(this,Bs,null),n(this,sn).classList.add("show"),n(this,ws)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),t.addEventListener("mouseleave",()=>{var c;n(this,Bs)&&(clearTimeout(n(this,Bs)),p(this,Bs,null)),(c=n(this,sn))==null||c.classList.remove("show")},{signal:l})}n(this,en)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=n(this,Me)),e.parentNode||t.append(e);const s=n(this,ws).getElementForAltText();s==null||s.setAttribute("aria-describedby",e.id)},m(as,zr,null),M(as,"_l10n",null);let Yf=as;var $e,fi,Za,jt,md,Vr,pi,Gr,jr,to,vd,wg;class qu{constructor(t){m(this,vd);m(this,$e,null);m(this,fi,null);m(this,Za,!1);m(this,jt,null);m(this,md,null);m(this,Vr,null);m(this,pi,null);m(this,Gr,null);m(this,jr,!1);m(this,to,null);p(this,jt,t)}renderForToolbar(){const t=p(this,fi,document.createElement("button"));return t.className="comment",v(this,vd,wg).call(this,t,!1)}renderForStandalone(){const t=p(this,$e,document.createElement("button"));t.className="annotationCommentButton";const e=n(this,jt).commentButtonPosition;if(e){const{style:s}=t;s.insetInlineEnd=`calc(${100*(n(this,jt)._uiManager.direction==="ltr"?1-e[0]:e[0])}% - var(--comment-button-dim))`,s.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const i=n(this,jt).commentButtonColor;i&&(s.backgroundColor=i)}return v(this,vd,wg).call(this,t,!0)}focusButton(){setTimeout(()=>{var t;(t=n(this,$e)??n(this,fi))==null||t.focus()},0)}onUpdatedColor(){if(!n(this,$e))return;const t=n(this,jt).commentButtonColor;t&&(n(this,$e).style.backgroundColor=t),n(this,jt)._uiManager.updatePopupColor(n(this,jt))}get commentButtonWidth(){var t;return(((t=n(this,$e))==null?void 0:t.getBoundingClientRect().width)??0)/n(this,jt).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(n(this,to))return n(this,to);if(!n(this,$e))return null;const{x:t,y:e,height:s}=n(this,$e).getBoundingClientRect(),{x:i,y:r,width:a,height:o}=n(this,jt).parent.boundingClientRect;return[(t-i)/a,(e+s-r)/o]}set commentPopupPositionInLayer(t){p(this,to,t)}hasDefaultPopupPosition(){return n(this,to)===null}removeStandaloneCommentButton(){var t;(t=n(this,$e))==null||t.remove(),p(this,$e,null)}removeToolbarCommentButton(){var t;(t=n(this,fi))==null||t.remove(),p(this,fi,null)}setCommentButtonStates({selected:t,hasPopup:e}){n(this,$e)&&(n(this,$e).classList.toggle("selected",t),n(this,$e).ariaExpanded=e)}edit(t){const e=this.commentPopupPositionInLayer;let s,i;if(e)[s,i]=e;else{[s,i]=n(this,jt).commentButtonPosition;const{width:h,height:d,x:f,y:g}=n(this,jt);s=f+s*h,i=g+i*d}const r=n(this,jt).parent.boundingClientRect,{x:a,y:o,width:l,height:c}=r;n(this,jt)._uiManager.editComment(n(this,jt),a+s*l,o+i*c,{...t,parentDimensions:r})}finish(){n(this,fi)&&(n(this,fi).focus({focusVisible:n(this,Za)}),p(this,Za,!1))}isDeleted(){return n(this,jr)||n(this,pi)===""}isEmpty(){return n(this,pi)===null}hasBeenEdited(){return this.isDeleted()||n(this,pi)!==n(this,md)}serialize(){return this.data}get data(){return{text:n(this,pi),richText:n(this,Vr),date:n(this,Gr),deleted:this.isDeleted()}}set data(t){if(t!==n(this,pi)&&p(this,Vr,null),t===null){p(this,pi,""),p(this,jr,!0);return}p(this,pi,t),p(this,Gr,new Date),p(this,jr,!1)}restoreData({text:t,richText:e,date:s}){p(this,pi,t),p(this,Vr,e),p(this,Gr,s),p(this,jr,!1)}setInitialText(t,e=null){p(this,md,t),this.data=t,p(this,Gr,null),p(this,Vr,e)}shown(){}destroy(){var t,e;(t=n(this,fi))==null||t.remove(),p(this,fi,null),(e=n(this,$e))==null||e.remove(),p(this,$e,null),p(this,pi,""),p(this,Vr,null),p(this,Gr,null),p(this,jt,null),p(this,Za,!1),p(this,jr,!1)}}$e=new WeakMap,fi=new WeakMap,Za=new WeakMap,jt=new WeakMap,md=new WeakMap,Vr=new WeakMap,pi=new WeakMap,Gr=new WeakMap,jr=new WeakMap,to=new WeakMap,vd=new WeakSet,wg=function(t,e){if(!n(this,jt)._uiManager.hasCommentManager())return null;t.tabIndex="0",t.ariaHasPopup="dialog",e?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControlsElements=[n(this,jt)._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const s=n(this,jt)._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;t.addEventListener("contextmenu",Ci,{signal:s}),e&&(t.addEventListener("focusin",r=>{n(this,jt)._focusEventsAllowed=!1,ie(r)},{capture:!0,signal:s}),t.addEventListener("focusout",r=>{n(this,jt)._focusEventsAllowed=!0,ie(r)},{capture:!0,signal:s})),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),t===n(this,fi)?this.edit():n(this,jt).toggleComment(!0)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(p(this,Za,!0),i(r))},{signal:s}),t.addEventListener("pointerenter",()=>{n(this,jt).toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{n(this,jt).toggleComment(!1,!1)},{signal:s}),t};var rc,eo,bd,yd,wd,Ad,Sd,Nn,so,Bn,io,$n,Ta,_b,kb,Tb;const Jm=class Jm{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:r=null,onPinchEnd:a=null,signal:o}){m(this,Ta);m(this,rc);m(this,eo,!1);m(this,bd,null);m(this,yd);m(this,wd);m(this,Ad);m(this,Sd);m(this,Nn,null);m(this,so);m(this,Bn,null);m(this,io);m(this,$n,null);p(this,rc,t),p(this,bd,s),p(this,yd,e),p(this,wd,i),p(this,Ad,r),p(this,Sd,a),p(this,io,new AbortController),p(this,so,AbortSignal.any([o,n(this,io).signal])),t.addEventListener("touchstart",v(this,Ta,_b).bind(this),{passive:!1,signal:n(this,so)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/En.pixelRatio}destroy(){var t,e;(t=n(this,io))==null||t.abort(),p(this,io,null),(e=n(this,Nn))==null||e.abort(),p(this,Nn,null)}};rc=new WeakMap,eo=new WeakMap,bd=new WeakMap,yd=new WeakMap,wd=new WeakMap,Ad=new WeakMap,Sd=new WeakMap,Nn=new WeakMap,so=new WeakMap,Bn=new WeakMap,io=new WeakMap,$n=new WeakMap,Ta=new WeakSet,_b=function(t){var i,r,a;if((i=n(this,yd))!=null&&i.call(this))return;if(t.touches.length===1){if(n(this,Nn))return;const o=p(this,Nn,new AbortController),l=AbortSignal.any([n(this,so),o.signal]),c=n(this,rc),h={capture:!0,signal:l,passive:!1},d=f=>{var g;f.pointerType==="touch"&&((g=n(this,Nn))==null||g.abort(),p(this,Nn,null))};c.addEventListener("pointerdown",f=>{f.pointerType==="touch"&&(ie(f),d(f))},h),c.addEventListener("pointerup",d,h),c.addEventListener("pointercancel",d,h);return}if(!n(this,$n)){p(this,$n,new AbortController);const o=AbortSignal.any([n(this,so),n(this,$n).signal]),l=n(this,rc),c={signal:o,capture:!1,passive:!1};l.addEventListener("touchmove",v(this,Ta,kb).bind(this),c);const h=v(this,Ta,Tb).bind(this);l.addEventListener("touchend",h,c),l.addEventListener("touchcancel",h,c),c.capture=!0,l.addEventListener("pointerdown",ie,c),l.addEventListener("pointermove",ie,c),l.addEventListener("pointercancel",ie,c),l.addEventListener("pointerup",ie,c),(r=n(this,wd))==null||r.call(this)}if(ie(t),t.touches.length!==2||(a=n(this,bd))!=null&&a.call(this)){p(this,Bn,null);return}let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]),p(this,Bn,{touch0X:e.screenX,touch0Y:e.screenY,touch1X:s.screenX,touch1Y:s.screenY})},kb=function(t){var C;if(!n(this,Bn)||t.touches.length!==2)return;ie(t);let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]);const{screenX:i,screenY:r}=e,{screenX:a,screenY:o}=s,l=n(this,Bn),{touch0X:c,touch0Y:h,touch1X:d,touch1Y:f}=l,g=d-c,y=f-h,b=a-i,S=o-r,w=Math.hypot(b,S)||1,x=Math.hypot(g,y)||1;if(!n(this,eo)&&Math.abs(x-w)<=Jm.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=i,l.touch0Y=r,l.touch1X=a,l.touch1Y=o,!n(this,eo)){p(this,eo,!0);return}const A=[(i+a)/2,(r+o)/2];(C=n(this,Ad))==null||C.call(this,A,x,w)},Tb=function(t){var e;t.touches.length>=2||(n(this,$n)&&(n(this,$n).abort(),p(this,$n,null),(e=n(this,Sd))==null||e.call(this)),n(this,Bn)&&(ie(t),p(this,Bn,null),p(this,eo,!1)))};let Kf=Jm;var no,Di,Jt,It,Un,ac,Wr,xd,Ue,ro,Hn,gi,Xr,Ed,ao,$s,Cd,oo,zn,an,oc,lc,mi,lo,_d,op,it,Ag,kd,Sg,hf,Pb,Mb,xg,df,Eg,Ib,Db,Lb,Cg,Fb,_g,Ob,Rb,Nb,kg,Th;const nt=class nt{constructor(t){m(this,it);m(this,no,null);m(this,Di,null);m(this,Jt,null);m(this,It,null);m(this,Un,null);m(this,ac,!1);m(this,Wr,null);m(this,xd,"");m(this,Ue,null);m(this,ro,null);m(this,Hn,null);m(this,gi,null);m(this,Xr,null);m(this,Ed,"");m(this,ao,!1);m(this,$s,null);m(this,Cd,!1);m(this,oo,!1);m(this,zn,!1);m(this,an,null);m(this,oc,0);m(this,lc,0);m(this,mi,null);m(this,lo,null);M(this,"isSelected",!1);M(this,"_isCopy",!1);M(this,"_editToolbar",null);M(this,"_initialOptions",Object.create(null));M(this,"_initialData",null);M(this,"_isVisible",!0);M(this,"_uiManager",null);M(this,"_focusEventsAllowed",!0);m(this,_d,!1);m(this,op,nt._zIndex++);this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;const{rotation:e,rawDims:{pageWidth:s,pageHeight:i,pageX:r,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[r,a];const[o,l]=this.parentDimensions;this.x=t.x/o,this.y=t.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const t=nt.prototype._resizeWithKeyboard,e=Cl.TRANSLATE_SMALL,s=Cl.TRANSLATE_BIG;return at(this,"_resizerKeyboardManager",new El([[["ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape"],nt.prototype._stopResizingWithKeyboard]]))}updatePageIndex(t){this.pageIndex=t}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return at(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new zS({id:t._uiManager.getId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(nt._l10n??(nt._l10n=t),nt._l10nAlert??(nt._l10nAlert=Object.freeze({highlight:"pdfjs-editor-highlight-added-alert",freetext:"pdfjs-editor-freetext-added-alert",ink:"pdfjs-editor-ink-added-alert",stamp:"pdfjs-editor-stamp-added-alert",signature:"pdfjs-editor-signature-added-alert"})),nt._l10nResizer??(nt._l10nResizer=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"})),nt._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);nt._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){Ct("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return n(this,_d)}set _isDraggable(t){var e;p(this,_d,t),(e=this.div)==null||e.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=n(this,op)}setParent(t){var e;t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(v(this,it,Th).call(this),(e=n(this,gi))==null||e.remove(),p(this,gi,null)),this.parent=t}focusin(t){this._focusEventsAllowed&&(n(this,ao)?p(this,ao,!1):this.parent.setSelected(this))}focusout(t){var s;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const e=t.relatedTarget;e!=null&&e.closest(`#${this.id}`)||(t.preventDefault(),(s=this.parent)!=null&&s.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){const[r,a]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/r,this.y=(e+i)/a,this.fixAndSetPosition()}_moveAfterPaste(t,e){if(this.isClone){delete this.isClone;return}const[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i),this._onTranslated()}translate(t,e){v(this,it,Ag).call(this,this.parentDimensions,t,e)}translateInPage(t,e){n(this,$s)||p(this,$s,[this.x,this.y,this.width,this.height]),v(this,it,Ag).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){n(this,$s)||p(this,$s,[this.x,this.y,this.width,this.height]);const{div:s,parentDimensions:[i,r]}=this;if(this.x+=t/i,this.y+=e/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:d,y:f}=this.div.getBoundingClientRect();this.parent.findNewParent(this,d,f)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this;const[l,c]=this.getBaseTranslation();a+=l,o+=c;const{style:h}=s;h.left=`${(100*a).toFixed(2)}%`,h.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o),s.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!n(this,$s)&&(n(this,$s)[0]!==this.x||n(this,$s)[1]!==this.y)}get _hasBeenResized(){return!!n(this,$s)&&(n(this,$s)[2]!==this.width||n(this,$s)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=nt,i=s/t,r=s/e;switch(this.rotation){case 90:return[-i,r];case 180:return[i,r];case 270:return[i,-r];default:return[-i,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[s,i]}=this;let{x:r,y:a,width:o,height:l}=this;if(o*=s,l*=i,r*=s,a*=i,this._mustFixPosition)switch(t){case 0:r=Qt(r,0,s-o),a=Qt(a,0,i-l);break;case 90:r=Qt(r,0,s-l),a=Qt(a,o,i);break;case 180:r=Qt(r,o,s),a=Qt(a,l,i);break;case 270:r=Qt(r,l,s),a=Qt(a,0,i-o);break}this.x=r/=s,this.y=a/=i;const[c,h]=this.getBaseTranslation();r+=c,a+=h,e.left=`${(100*r).toFixed(2)}%`,e.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){var s;return v(s=nt,kd,Sg).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return v(s=nt,kd,Sg).call(s,t,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(){const{div:{style:t},width:e,height:s}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*s).toFixed(2)}%`}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(t*1e4)/1e4}_onResizing(){}altTextFinish(){var t;(t=n(this,Jt))==null||t.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||n(this,oo))return this._editToolbar;this._editToolbar=new ug(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[e,s]of t)await this._editToolbar.addButton(e,s);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){var t;(t=this._editToolbar)==null||t.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){var t;(t=this._editToolbar)==null||t.removeButton("comment")}removeEditToolbar(){var t,e;(t=this._editToolbar)==null||t.remove(),this._editToolbar=null,(e=n(this,Jt))==null||e.destroy()}addContainer(t){var s;const e=(s=this._editToolbar)==null?void 0:s.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return n(this,Jt)||(Yf.initialize(nt._l10n),p(this,Jt,new Yf(this)),n(this,no)&&(n(this,Jt).data=n(this,no),p(this,no,null))),n(this,Jt)}get altTextData(){var t;return(t=n(this,Jt))==null?void 0:t.data}set altTextData(t){n(this,Jt)&&(n(this,Jt).data=t)}get guessedAltText(){var t;return(t=n(this,Jt))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=n(this,Jt))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=n(this,Jt))==null?void 0:e.serialize(t)}hasAltText(){return!!n(this,Jt)&&!n(this,Jt).isEmpty()}hasAltTextData(){var t;return((t=n(this,Jt))==null?void 0:t.hasData())??!1}focusCommentButton(){var t;(t=n(this,It))==null||t.focusButton()}addCommentButton(){return this.canAddComment?n(this,It)||p(this,It,new qu(this)):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(n(this,Un)){this._uiManager.isEditingMode()&&n(this,Un).classList.remove("hidden");return}this.hasComment&&(p(this,Un,n(this,It).renderForStandalone()),this.div.append(n(this,Un)))}}removeStandaloneCommentButton(){n(this,It).removeStandaloneCommentButton(),p(this,Un,null)}hideStandaloneCommentButton(){var t;(t=n(this,Un))==null||t.classList.add("hidden")}get comment(){if(!n(this,It))return null;const{data:{richText:t,text:e,date:s,deleted:i}}=n(this,It);return{text:e,richText:t,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){n(this,It)||p(this,It,new qu(this)),typeof t=="object"&&t!==null?n(this,It).restoreData(t):n(this,It).data=t,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:t,popupRef:e,richText:s}){if(!e||(n(this,It)||p(this,It,new qu(this)),n(this,It).setInitialText(t,s),!this.annotationElementId))return;const i=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);i&&this.updateFromAnnotationLayer(i)}get hasEditedComment(){var t;return(t=n(this,It))==null?void 0:t.hasBeenEdited()}get hasDeletedComment(){var t;return(t=n(this,It))==null?void 0:t.isDeleted()}get hasComment(){return!!n(this,It)&&!n(this,It).isEmpty()&&!n(this,It).isDeleted()}async editComment(t){n(this,It)||p(this,It,new qu(this)),n(this,It).edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){n(this,It).setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const[,,,i]=t.rect,[r]=this.pageDimensions,[a]=this.pageTranslation,o=a+r+1,l=i-100,c=o+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[o,l,c,i]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){n(this,It).data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){var a;const t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=n(this,ac)?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),v(this,it,_g).call(this);const[e,s]=this.parentDimensions;this.parentRotation%180!==0&&(t.style.maxWidth=`${(100*s/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[i,r]=this.getInitialTranslation();return this.translate(i,r),hb(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(n(this,lo)||p(this,lo,new Kf({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:v(this,it,Ib).bind(this),onPinching:v(this,it,Db).bind(this),onPinchEnd:v(this,it,Lb).bind(this),signal:this._uiManager._signal}))),this.addStandaloneCommentButton(),(a=this._uiManager._editorUndoBar)==null||a.hide(),t}pointerdown(t){const{isMac:e}=$t.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(p(this,ao,!0),this._isDraggable){v(this,it,Fb).call(this,t);return}v(this,it,Cg).call(this,t)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){n(this,an)&&clearTimeout(n(this,an)),p(this,an,setTimeout(()=>{var t;p(this,an,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){const i=this.parentScale,[r,a]=this.pageDimensions,[o,l]=this.pageTranslation,c=t/i,h=e/i,d=this.x*r,f=this.y*a,g=this.width*r,y=this.height*a;switch(s){case 0:return[d+c+o,a-f-h-y+l,d+c+g+o,a-f-h+l];case 90:return[d+h+o,a-f+c+l,d+h+y+o,a-f+c+g+l];case 180:return[d-c-g+o,a-f+h+l,d-c+o,a-f+h+y+l];case 270:return[d-h-y+o,a-f-c-g+l,d-h+o,a-f-c+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,r,a]=t,o=r-s,l=a-i;switch(this.rotation){case 0:return[s,e-a,o,l];case 90:return[s,e-i,l,o];case 180:return[r,e-i,o,l];case 270:return[r,e-a,l,o];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&nt._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){var t;(t=n(this,It))==null||t.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:s,opacity:i,deleted:r,richText:a},uid:o,pageIndex:l,creationDate:c,modificationDate:h}=this;return{id:o,pageIndex:l,rect:this.getPDFRect(),richText:a,contentsObj:{str:t},creationDate:c,modificationDate:s||h,popupRef:!r,color:e,opacity:i}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),p(this,oo,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),p(this,oo,!1),!0):!1}isInEditMode(){return n(this,oo)}shouldGetKeyboardEvents(){return n(this,zn)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:r,innerWidth:a}=window;return e<a&&i>0&&t<r&&s>0}rebuild(){v(this,it,_g).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((t=this._initialData)==null?void 0:t.popupRef)||""}}serialize(t=!1,e=null){var s;return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:((s=this._initialData)==null?void 0:s.popupRef)||""}}static async deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:s.getId(),uiManager:s,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});i.rotation=t.rotation,p(i,no,t.accessibilityData),i._isCopy=t.isCopy||!1;const[r,a]=i.pageDimensions,[o,l,c,h]=i.getRectInCurrentCoords(t.rect,a);return i.x=o/r,i.y=l/a,i.width=c/r,i.height=h/a,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t,e,s;if((t=n(this,Xr))==null||t.abort(),p(this,Xr,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),n(this,an)&&(clearTimeout(n(this,an)),p(this,an,null)),v(this,it,Th).call(this),this.removeEditToolbar(),n(this,mi)){for(const i of n(this,mi).values())clearTimeout(i);p(this,mi,null)}this.parent=null,(e=n(this,lo))==null||e.destroy(),p(this,lo,null),(s=n(this,gi))==null||s.remove(),p(this,gi,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(v(this,it,Pb).call(this),n(this,Ue).classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[t,e]}=this,[s,i,r,a]=this.getPDFRect();return[nt._round(s+(r-s)*t),nt._round(i+(a-i)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return n(this,It).commentPopupPositionInLayer}set commentPopupPosition(t){n(this,It).commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return n(this,It).hasDefaultPopupPosition()}get commentButtonWidth(){return n(this,It).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){var e;(e=n(this,It))==null||e.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),p(this,Hn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=n(this,Ue).children;if(!n(this,Di)){p(this,Di,Array.from(e));const a=v(this,it,Ob).bind(this),o=v(this,it,Rb).bind(this),l=this._uiManager._signal;for(const c of n(this,Di)){const h=c.getAttribute("data-resizer-name");c.setAttribute("role","spinbutton"),c.addEventListener("keydown",a,{signal:l}),c.addEventListener("blur",o,{signal:l}),c.addEventListener("focus",v(this,it,Nb).bind(this,h),{signal:l}),c.setAttribute("data-l10n-id",nt._l10nResizer[h])}}const s=n(this,Di)[0];let i=0;for(const a of e){if(a===s)break;i++}const r=(360-this.rotation+this.parentRotation)%360/90*(n(this,Di).length/4);if(r!==i){if(r<i)for(let o=0;o<i-r;o++)n(this,Ue).append(n(this,Ue).firstElementChild);else if(r>i)for(let o=0;o<r-i;o++)n(this,Ue).firstElementChild.before(n(this,Ue).lastElementChild);let a=0;for(const o of e){const c=n(this,Di)[a++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",nt._l10nResizer[c])}}v(this,it,kg).call(this,0),p(this,zn,!0),n(this,Ue).firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){n(this,zn)&&v(this,it,Eg).call(this,n(this,Ed),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){v(this,it,Th).call(this),this.div.focus()}select(){var t,e,s;if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),(t=this.div)==null||t.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{var i,r;(i=this.div)!=null&&i.classList.contains("selectedEditor")&&((r=this._editToolbar)==null||r.show())});return}(e=this._editToolbar)==null||e.show(),(s=n(this,Jt))==null||s.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>{var t;return(t=this.div)==null?void 0:t.focus({preventScroll:!0})},0)}unselect(){var t,e,s,i,r;this.isSelected&&(this.isSelected=!1,(t=n(this,Ue))==null||t.classList.add("hidden"),(e=this.div)==null||e.classList.remove("selectedEditor"),(s=this.div)!=null&&s.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(i=this._editToolbar)==null||i.hide(),(r=n(this,Jt))==null||r.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){t.target.nodeName!=="BUTTON"&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return n(this,Cd)}set isEditing(t){p(this,Cd,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){n(this,mi)||p(this,mi,new Map);const{action:s}=t;let i=n(this,mi).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),n(this,mi).delete(s),n(this,mi).size===0&&p(this,mi,null)},nt._telemetryTimeout),n(this,mi).set(s,i);return}t.type||(t.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),p(this,ac,!1)}disable(){this.div&&(this.div.tabIndex=-1),p(this,ac,!0)}updateFakeAnnotationElement(t){if(!n(this,gi)&&!this.deleted){p(this,gi,t.addFakeAnnotation(this));return}if(this.deleted){n(this,gi).remove(),p(this,gi,null);return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&n(this,gi).updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){const{firstElementChild:e}=t.container;(e==null?void 0:e.nodeName)==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}};no=new WeakMap,Di=new WeakMap,Jt=new WeakMap,It=new WeakMap,Un=new WeakMap,ac=new WeakMap,Wr=new WeakMap,xd=new WeakMap,Ue=new WeakMap,ro=new WeakMap,Hn=new WeakMap,gi=new WeakMap,Xr=new WeakMap,Ed=new WeakMap,ao=new WeakMap,$s=new WeakMap,Cd=new WeakMap,oo=new WeakMap,zn=new WeakMap,an=new WeakMap,oc=new WeakMap,lc=new WeakMap,mi=new WeakMap,lo=new WeakMap,_d=new WeakMap,op=new WeakMap,it=new WeakSet,Ag=function([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},kd=new WeakSet,Sg=function(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}},hf=function(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}},Pb=function(){if(n(this,Ue))return;p(this,Ue,document.createElement("div")),n(this,Ue).classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const s of t){const i=document.createElement("div");n(this,Ue).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",v(this,it,Mb).bind(this,s),{signal:e}),i.addEventListener("contextmenu",Ci,{signal:e}),i.tabIndex=-1}this.div.prepend(n(this,Ue))},Mb=function(t,e){var h;e.preventDefault();const{isMac:s}=$t.platform;if(e.button!==0||e.ctrlKey&&s)return;(h=n(this,Jt))==null||h.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,p(this,ro,[e.screenX,e.screenY]);const r=new AbortController,a=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",v(this,it,Eg).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",ie,{passive:!1,signal:a}),window.addEventListener("contextmenu",Ci,{signal:a}),p(this,Hn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const c=()=>{var d;r.abort(),this.parent.togglePointerEvents(!0),(d=n(this,Jt))==null||d.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=o,this.div.style.cursor=l,v(this,it,df).call(this)};window.addEventListener("pointerup",c,{signal:a}),window.addEventListener("blur",c,{signal:a})},xg=function(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()},df=function(){if(!n(this,Hn))return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=n(this,Hn);p(this,Hn,null);const r=this.x,a=this.y,o=this.width,l=this.height;r===t&&a===e&&o===s&&l===i||this.addCommands({cmd:v(this,it,xg).bind(this,r,a,o,l),undo:v(this,it,xg).bind(this,t,e,s,i),mustExec:!0})},Eg=function(t,e){const[s,i]=this.parentDimensions,r=this.x,a=this.y,o=this.width,l=this.height,c=nt.MIN_SIZE/s,h=nt.MIN_SIZE/i,d=v(this,it,hf).call(this,this.rotation),f=(T,q)=>[d[0]*T+d[2]*q,d[1]*T+d[3]*q],g=v(this,it,hf).call(this,360-this.rotation),y=(T,q)=>[g[0]*T+g[2]*q,g[1]*T+g[3]*q];let b,S,w=!1,x=!1;switch(t){case"topLeft":w=!0,b=(T,q)=>[0,0],S=(T,q)=>[T,q];break;case"topMiddle":b=(T,q)=>[T/2,0],S=(T,q)=>[T/2,q];break;case"topRight":w=!0,b=(T,q)=>[T,0],S=(T,q)=>[0,q];break;case"middleRight":x=!0,b=(T,q)=>[T,q/2],S=(T,q)=>[0,q/2];break;case"bottomRight":w=!0,b=(T,q)=>[T,q],S=(T,q)=>[0,0];break;case"bottomMiddle":b=(T,q)=>[T/2,q],S=(T,q)=>[T/2,0];break;case"bottomLeft":w=!0,b=(T,q)=>[0,q],S=(T,q)=>[T,0];break;case"middleLeft":x=!0,b=(T,q)=>[0,q/2],S=(T,q)=>[T,q/2];break}const A=b(o,l),C=S(o,l);let _=f(...C);const k=nt._round(r+_[0]),I=nt._round(a+_[1]);let L=1,P=1,D,R;if(e.fromKeyboard)({deltaX:D,deltaY:R}=e);else{const{screenX:T,screenY:q}=e,[Lt,mt]=n(this,ro);[D,R]=this.screenToPageTranslation(T-Lt,q-mt),n(this,ro)[0]=T,n(this,ro)[1]=q}if([D,R]=y(D/s,R/i),w){const T=Math.hypot(o,l);L=P=Math.max(Math.min(Math.hypot(C[0]-A[0]-D,C[1]-A[1]-R)/T,1/o,1/l),c/o,h/l)}else x?L=Qt(Math.abs(C[0]-A[0]-D),c,1)/o:P=Qt(Math.abs(C[1]-A[1]-R),h,1)/l;const K=nt._round(o*L),W=nt._round(l*P);_=f(...S(K,W));const Q=k-_[0],ht=I-_[1];n(this,$s)||p(this,$s,[this.x,this.y,this.width,this.height]),this.width=K,this.height=W,this.x=Q,this.y=ht,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Ib=function(){var t;p(this,Hn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(t=n(this,Jt))==null||t.toggle(!1),this.parent.togglePointerEvents(!1)},Db=function(t,e,s){let r=.7*(s/e)+1-.7;if(r===1)return;const a=v(this,it,hf).call(this,this.rotation),o=(k,I)=>[a[0]*k+a[2]*I,a[1]*k+a[3]*I],[l,c]=this.parentDimensions,h=this.x,d=this.y,f=this.width,g=this.height,y=nt.MIN_SIZE/l,b=nt.MIN_SIZE/c;r=Math.max(Math.min(r,1/f,1/g),y/f,b/g);const S=nt._round(f*r),w=nt._round(g*r);if(S===f&&w===g)return;n(this,$s)||p(this,$s,[h,d,f,g]);const x=o(f/2,g/2),A=nt._round(h+x[0]),C=nt._round(d+x[1]),_=o(S/2,w/2);this.x=A-_[0],this.y=C-_[1],this.width=S,this.height=w,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Lb=function(){var t;(t=n(this,Jt))==null||t.toggle(!0),this.parent.togglePointerEvents(!0),v(this,it,df).call(this)},Cg=function(t){const{isMac:e}=$t.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Fb=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1;const i=new AbortController,r=this._uiManager.combinedSignal(i),a={capture:!0,passive:!1,signal:r},o=c=>{i.abort(),p(this,Wr,null),p(this,ao,!1),this._uiManager.endDragSession()||v(this,it,Cg).call(this,c),s&&this._onStopDragging()};e&&(p(this,oc,t.clientX),p(this,lc,t.clientY),p(this,Wr,t.pointerId),p(this,xd,t.pointerType),window.addEventListener("pointermove",c=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:h,clientY:d,pointerId:f}=c;if(f!==n(this,Wr)){ie(c);return}const[g,y]=this.screenToPageTranslation(h-n(this,oc),d-n(this,lc));p(this,oc,h),p(this,lc,d),this._uiManager.dragSelectedEditors(g,y)},a),window.addEventListener("touchmove",ie,a),window.addEventListener("pointerdown",c=>{c.pointerType===n(this,xd)&&(n(this,lo)||c.isPrimary)&&o(c),ie(c)},a));const l=c=>{if(!n(this,Wr)||n(this,Wr)===c.pointerId){o(c);return}ie(c)};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})},_g=function(){if(n(this,Xr)||!this.div)return;p(this,Xr,new AbortController);const t=this._uiManager.combinedSignal(n(this,Xr));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},Ob=function(t){nt._resizerKeyboardManager.exec(this,t)},Rb=function(t){var e;n(this,zn)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==n(this,Ue)&&v(this,it,Th).call(this)},Nb=function(t){p(this,Ed,n(this,zn)?t:"")},kg=function(t){if(n(this,Di))for(const e of n(this,Di))e.tabIndex=t},Th=function(){p(this,zn,!1),v(this,it,kg).call(this,-1),v(this,it,df).call(this)},m(nt,kd),M(nt,"_l10n",null),M(nt,"_l10nAlert",null),M(nt,"_l10nResizer",null),M(nt,"_borderLineWidth",-1),M(nt,"_colorManager",new gg),M(nt,"_zIndex",1),M(nt,"_telemetryTimeout",1e3);let Pt=nt;class zS extends Pt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const bv=3285377520,ai=4294901760,qi=65535;class Tg{constructor(t){this.h1=t?t&4294967295:bv,this.h2=t?t&4294967295:bv}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let b=0,S=t.length;b<S;b++){const w=t.charCodeAt(b);w<=255?e[s++]=w:(e[s++]=w>>>8,e[s++]=w&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,r=s-i*4,a=new Uint32Array(e.buffer,0,i);let o=0,l=0,c=this.h1,h=this.h2;const d=3432918353,f=461845907,g=d&qi,y=f&qi;for(let b=0;b<i;b++)b&1?(o=a[b],o=o*d&ai|o*g&qi,o=o<<15|o>>>17,o=o*f&ai|o*y&qi,c^=o,c=c<<13|c>>>19,c=c*5+3864292196):(l=a[b],l=l*d&ai|l*g&qi,l=l<<15|l>>>17,l=l*f&ai|l*y&qi,h^=l,h=h<<13|h>>>19,h=h*5+3864292196);switch(o=0,r){case 3:o^=e[i*4+2]<<16;case 2:o^=e[i*4+1]<<8;case 1:o^=e[i*4],o=o*d&ai|o*g&qi,o=o<<15|o>>>17,o=o*f&ai|o*y&qi,i&1?c^=o:h^=o}this.h1=c,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&ai|t*36045&qi,e=e*4283543511&ai|((e<<16|t>>>16)*2950163797&ai)>>>16,t^=e>>>1,t=t*444984403&ai|t*60499&qi,e=e*3301882366&ai|((e<<16|t>>>16)*3120437893&ai)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Jh=Object.freeze({map:null,hash:"",transfer:void 0});var co,ho,Vn,He,lp,Bb;class jm{constructor(){m(this,lp);m(this,co,!1);m(this,ho,null);m(this,Vn,null);m(this,He,new Map);M(this,"onSetModified",null);M(this,"onResetModified",null);M(this,"onAnnotationEditor",null)}getValue(t,e){const s=n(this,He).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return n(this,He).get(t)}remove(t){var s;const e=n(this,He).get(t);e!==void 0&&(e instanceof Pt&&n(this,Vn).delete(e.annotationElementId),n(this,He).delete(t),n(this,He).size===0&&this.resetModified(),!n(this,He).values().some(i=>i instanceof Pt)&&((s=this.onAnnotationEditor)==null||s.call(this,null)))}setValue(t,e){var r;const s=n(this,He).get(t);let i=!1;if(s!==void 0)for(const[a,o]of Object.entries(e))s[a]!==o&&(i=!0,s[a]=o);else i=!0,n(this,He).set(t,e);i&&v(this,lp,Bb).call(this),e instanceof Pt&&((n(this,Vn)||p(this,Vn,new Map)).set(e.annotationElementId,e),(r=this.onAnnotationEditor)==null||r.call(this,e.constructor._type))}has(t){return n(this,He).has(t)}get size(){return n(this,He).size}resetModified(){var t;n(this,co)&&(p(this,co,!1),(t=this.onResetModified)==null||t.call(this))}get print(){return new $b(this)}get serializable(){if(n(this,He).size===0)return Jh;const t=new Map,e=new Tg,s=[],i=Object.create(null);let r=!1;for(const[a,o]of n(this,He)){const l=o instanceof Pt?o.serialize(!1,i):o;o.page&&(o.pageIndex=o.page._pageIndex,delete o.page),l&&(t.set(a,l),e.update(`${a}:${JSON.stringify(l)}`),r||(r=!!l.bitmap))}if(r)for(const a of t.values())a.bitmap&&s.push(a.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:Jh}get editorStats(){let t=null;const e=new Map;let s=0,i=0;for(const r of n(this,He).values()){if(!(r instanceof Pt)){r.popup&&(r.popup.deleted?i+=1:s+=1);continue}r.isCommentDeleted?i+=1:r.hasEditedComment&&(s+=1);const a=r.telemetryFinalData;if(!a)continue;const{type:o}=a;e.getOrInsertComputed(o,()=>Object.getPrototypeOf(r).constructor),t||(t=Object.create(null));const l=t[o]||(t[o]=new Map);for(const[c,h]of Object.entries(a)){if(c==="type")continue;const d=l.getOrInsertComputed(c,Hm);d.set(h,(d.get(h)??0)+1)}}if((i>0||s>0)&&(t||(t=Object.create(null)),t.comments={deleted:i,edited:s}),!t)return null;for(const[r,a]of e)t[r]=a.computeTelemetryFinalData(t[r]);return t}resetModifiedIds(){p(this,ho,null)}updateEditor(t,e){var i;const s=(i=n(this,Vn))==null?void 0:i.get(t);return s?(s.updateFromAnnotationLayer(e),!0):!1}getEditor(t){var e;return((e=n(this,Vn))==null?void 0:e.get(t))||null}get modifiedIds(){if(n(this,ho))return n(this,ho);const t=[];if(n(this,Vn))for(const s of n(this,Vn).values())s.serialize()&&t.push(s.annotationElementId);let e="";if(t.length){const s=new Tg;s.update(t.join(",")),e=s.hexdigest()}return p(this,ho,{ids:new Set(t),hash:e})}[Symbol.iterator](){return n(this,He).entries()}}co=new WeakMap,ho=new WeakMap,Vn=new WeakMap,He=new WeakMap,lp=new WeakSet,Bb=function(){var t;n(this,co)||(p(this,co,!0),(t=this.onSetModified)==null||t.call(this))};var Td;class $b extends jm{constructor(e){super();m(this,Td,Jh);const{serializable:s}=e;if(s===Jh)return;const{map:i,hash:r,transfer:a}=s,o=structuredClone(i,a?{transfer:a}:null);p(this,Td,{map:o,hash:r,transfer:[]})}get print(){Ct("Should not call PrintAnnotationStorage.print")}get serializable(){return n(this,Td)}get modifiedIds(){return at(this,"modifiedIds",{ids:new Set,hash:""})}}Td=new WeakMap;const Dl="__forcedDependency",{floor:yv,ceil:wv}=Math;function Av(u,t,e,s,i,r){u[t*4+0]=Math.min(u[t*4+0],e),u[t*4+1]=Math.min(u[t*4+1],s),u[t*4+2]=Math.max(u[t*4+2],i),u[t*4+3]=Math.max(u[t*4+3],r)}function VS(u,t,e,s,i){let r;u?(u<0&&(r=i[0],i[0]=i[2],i[2]=r),i[0]*=u,i[2]*=u,t<0&&(r=i[1],i[1]=i[3],i[3]=r),i[1]*=t,i[3]*=t):i.fill(0),i[0]+=e,i[1]+=s,i[2]+=e,i[3]+=s}const Pg=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];var cc,qr;class GS{constructor(t,e){m(this,cc);m(this,qr);p(this,cc,t),p(this,qr,e)}get length(){return n(this,cc).length}isEmpty(t){return n(this,cc)[t]===Pg}minX(t){return n(this,qr)[t*4+0]/256}minY(t){return n(this,qr)[t*4+1]/256}maxX(t){return(n(this,qr)[t*4+2]+1)/256}maxY(t){return(n(this,qr)[t*4+3]+1)/256}}cc=new WeakMap,qr=new WeakMap;const Sv=(u,t)=>u==null?void 0:u.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1}));var Gn,Tt,Kt,uo,fo,po,ts,Pd,Mg;class jS{constructor(t,e){m(this,Pd);m(this,Gn,[[1,0,0,1,0,0]]);m(this,Tt,[-1/0,-1/0,1/0,1/0]);m(this,Kt,new Float64Array(mr));M(this,"_pendingBBoxIdx",-1);m(this,uo);m(this,fo);m(this,po);m(this,ts);M(this,"_savesStack",[]);M(this,"_markedContentStack",[]);p(this,uo,t.width),p(this,fo,t.height),v(this,Pd,Mg).call(this,e)}growOperationsCount(t){t>=n(this,ts).length&&v(this,Pd,Mg).call(this,t,n(this,ts))}get clipBox(){return n(this,Tt)}save(t){return p(this,Tt,{__proto__:n(this,Tt)}),this._savesStack.push(t),this}restore(t,e){const s=Object.getPrototypeOf(n(this,Tt));if(s===null)return this;p(this,Tt,s);const i=this._savesStack.pop();return i!==void 0&&(e==null||e(i,t),n(this,ts)[t]=n(this,ts)[i]),this}recordOpenMarker(t){return this._savesStack.push(t),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(t,e){const s=this._savesStack.pop();return s!==void 0&&(e==null||e(s,t),n(this,ts)[t]=n(this,ts)[s]),this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,e){const s=this._markedContentStack.pop();return s!==void 0&&(e==null||e(s,t),n(this,ts)[t]=n(this,ts)[s]),this}pushBaseTransform(t){return n(this,Gn).push(B.multiplyByDOMMatrix(n(this,Gn).at(-1),t.getTransform())),this}popBaseTransform(){return n(this,Gn).length>1&&n(this,Gn).pop(),this}resetBBox(t){return this._pendingBBoxIdx!==t&&(this._pendingBBoxIdx=t,n(this,Kt).set(mr,0)),this}recordClipBox(t,e,s,i,r,a){const o=B.multiplyByDOMMatrix(n(this,Gn).at(-1),e.getTransform()),l=mr.slice();B.axialAlignedBoundingBox([s,r,i,a],o,l);const c=B.intersect(n(this,Tt),l);return c?(n(this,Tt)[0]=c[0],n(this,Tt)[1]=c[1],n(this,Tt)[2]=c[2],n(this,Tt)[3]=c[3]):(n(this,Tt)[0]=n(this,Tt)[1]=1/0,n(this,Tt)[2]=n(this,Tt)[3]=-1/0),this}recordBBox(t,e,s,i,r,a){const o=n(this,Tt);if(o[0]===1/0)return this;const l=B.multiplyByDOMMatrix(n(this,Gn).at(-1),e.getTransform());if(o[0]===-1/0)return B.axialAlignedBoundingBox([s,r,i,a],l,n(this,Kt)),this;const c=mr.slice();return B.axialAlignedBoundingBox([s,r,i,a],l,c),n(this,Kt)[0]=Qt(c[0],o[0],n(this,Kt)[0]),n(this,Kt)[1]=Qt(c[1],o[1],n(this,Kt)[1]),n(this,Kt)[2]=Qt(c[2],n(this,Kt)[2],o[2]),n(this,Kt)[3]=Qt(c[3],n(this,Kt)[3],o[3]),this}recordFullPageBBox(t){return n(this,Kt)[0]=Math.max(0,n(this,Tt)[0]),n(this,Kt)[1]=Math.max(0,n(this,Tt)[1]),n(this,Kt)[2]=Math.min(n(this,uo),n(this,Tt)[2]),n(this,Kt)[3]=Math.min(n(this,fo),n(this,Tt)[3]),this}recordOperation(t,e=!1,s){if(this._pendingBBoxIdx!==t)return this;const i=yv(n(this,Kt)[0]*256/n(this,uo)),r=yv(n(this,Kt)[1]*256/n(this,fo)),a=wv(n(this,Kt)[2]*256/n(this,uo)),o=wv(n(this,Kt)[3]*256/n(this,fo));if(Av(n(this,po),t,i,r,a,o),s)for(const l of s)for(const c of l)c!==t&&Av(n(this,po),c,i,r,a,o);return e||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(t){return this._pendingBBoxIdx===t&&(this._pendingBBoxIdx=-1,n(this,Tt)[0]=Math.max(n(this,Tt)[0],n(this,Kt)[0]),n(this,Tt)[1]=Math.max(n(this,Tt)[1],n(this,Kt)[1]),n(this,Tt)[2]=Math.min(n(this,Tt)[2],n(this,Kt)[2]),n(this,Tt)[3]=Math.min(n(this,Tt)[3],n(this,Kt)[3])),this}take(){return new GS(n(this,ts),n(this,po))}takeDebugMetadata(){throw new Error("Unreachable")}recordSimpleData(t,e){return this}recordIncrementalData(t,e){return this}resetIncrementalData(t,e){return this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this}recordFutureForcedDependency(t,e){return this}inheritSimpleDataAsFutureForcedDependencies(t){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(t,e,s,i=1,r=0,a=0,o){return this}getSimpleIndex(t){}recordDependencies(t,e){return this}recordNamedDependency(t,e){return this}recordShowTextOperation(t,e=!1){return this}}Gn=new WeakMap,Tt=new WeakMap,Kt=new WeakMap,uo=new WeakMap,fo=new WeakMap,po=new WeakMap,ts=new WeakMap,Pd=new WeakSet,Mg=function(t,e){const s=new ArrayBuffer(t*4);p(this,po,new Uint8ClampedArray(s)),p(this,ts,new Uint32Array(s)),e&&e.length>0?(n(this,ts).set(e),n(this,ts).fill(Pg,e.length)):n(this,ts).fill(Pg)};var As,Ss,go,Li,hc,Yr,Kr,Rt;class WS{constructor(t,e=!1){m(this,As,{__proto__:null});m(this,Ss,{__proto__:null,transform:[],moveText:[],sameLineText:[],[Dl]:[]});m(this,go,new Map);m(this,Li,new Set);m(this,hc,new Map);m(this,Yr);m(this,Kr);m(this,Rt);p(this,Rt,t),e&&(p(this,Yr,new Map),p(this,Kr,(s,i)=>{Sv(n(this,Yr),i).dependencies.add(s)}))}get clipBox(){return n(this,Rt).clipBox}growOperationsCount(t){n(this,Rt).growOperationsCount(t)}save(t){return p(this,As,{__proto__:n(this,As)}),p(this,Ss,{__proto__:n(this,Ss),transform:{__proto__:n(this,Ss).transform},moveText:{__proto__:n(this,Ss).moveText},sameLineText:{__proto__:n(this,Ss).sameLineText},[Dl]:{__proto__:n(this,Ss)[Dl]}}),n(this,Rt).save(t),this}restore(t){n(this,Rt).restore(t,n(this,Kr));const e=Object.getPrototypeOf(n(this,As));return e===null?this:(p(this,As,e),p(this,Ss,Object.getPrototypeOf(n(this,Ss))),this)}recordOpenMarker(t){return n(this,Rt).recordOpenMarker(t,n(this,Kr)),this}getOpenMarker(){return n(this,Rt).getOpenMarker()}recordCloseMarker(t){return n(this,Rt).recordCloseMarker(t,n(this,Kr)),this}beginMarkedContent(t){return n(this,Rt).beginMarkedContent(t),this}endMarkedContent(t){return n(this,Rt).endMarkedContent(t,n(this,Kr)),this}pushBaseTransform(t){return n(this,Rt).pushBaseTransform(t),this}popBaseTransform(){return n(this,Rt).popBaseTransform(),this}recordSimpleData(t,e){return n(this,As)[t]=e,this}recordIncrementalData(t,e){return n(this,Ss)[t].push(e),this}resetIncrementalData(t,e){return n(this,Ss)[t].length=0,this}recordNamedData(t,e){return n(this,go).set(t,e),this}recordSimpleDataFromNamed(t,e,s){n(this,As)[t]=n(this,go).get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(Dl,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in n(this,As)&&this.recordFutureForcedDependency(e,n(this,As)[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of n(this,Li))this.recordFutureForcedDependency(Dl,t);return this}resetBBox(t){return n(this,Rt).resetBBox(t),this}recordClipBox(t,e,s,i,r,a){return n(this,Rt).recordClipBox(t,e,s,i,r,a),this}recordBBox(t,e,s,i,r,a){return n(this,Rt).recordBBox(t,e,s,i,r,a),this}recordCharacterBBox(t,e,s,i=1,r=0,a=0,o){const l=s.bbox;let c,h;if(l&&(c=l[2]!==l[0]&&l[3]!==l[1]&&n(this,hc).get(s),c!==!1&&(h=[0,0,0,0],B.axialAlignedBoundingBox(l,s.fontMatrix,h),(i!==1||r!==0||a!==0)&&VS(i,-i,r,a,h),c)))return this.recordBBox(t,e,h[0],h[2],h[1],h[3]);if(!o)return this.recordFullPageBBox(t);const d=o();return l&&h&&c===void 0&&(c=h[0]<=r-d.actualBoundingBoxLeft&&h[2]>=r+d.actualBoundingBoxRight&&h[1]<=a-d.actualBoundingBoxAscent&&h[3]>=a+d.actualBoundingBoxDescent,n(this,hc).set(s,c),c)?this.recordBBox(t,e,h[0],h[2],h[1],h[3]):this.recordBBox(t,e,r-d.actualBoundingBoxLeft,r+d.actualBoundingBoxRight,a-d.actualBoundingBoxAscent,a+d.actualBoundingBoxDescent)}recordFullPageBBox(t){return n(this,Rt).recordFullPageBBox(t),this}getSimpleIndex(t){return n(this,As)[t]}recordDependencies(t,e){const s=n(this,Li),i=n(this,As),r=n(this,Ss);for(const a of e)a in n(this,As)?s.add(i[a]):a in r&&r[a].forEach(s.add,s);return this}recordNamedDependency(t,e){return n(this,go).has(e)&&n(this,Li).add(n(this,go).get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[Dl]),n(this,Yr)){const i=Sv(n(this,Yr),t),{dependencies:r}=i;n(this,Li).forEach(r.add,r),n(this,Rt)._savesStack.forEach(r.add,r),n(this,Rt)._markedContentStack.forEach(r.add,r),r.delete(t),i.isRenderingOperation=!0}const s=!e&&t===n(this,Rt)._pendingBBoxIdx;return n(this,Rt).recordOperation(t,e,[n(this,Li),n(this,Rt)._savesStack,n(this,Rt)._markedContentStack]),s&&n(this,Li).clear(),this}recordShowTextOperation(t,e=!1){const s=Array.from(n(this,Li));this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const i of s)this.recordIncrementalData("sameLineText",i);return this}bboxToClipBoxDropOperation(t,e=!1){const s=!e&&t===n(this,Rt)._pendingBBoxIdx;return n(this,Rt).bboxToClipBoxDropOperation(t),s&&n(this,Li).clear(),this}take(){return n(this,hc).clear(),n(this,Rt).take()}takeDebugMetadata(){return n(this,Yr)}}As=new WeakMap,Ss=new WeakMap,go=new WeakMap,Li=new WeakMap,hc=new WeakMap,Yr=new WeakMap,Kr=new WeakMap,Rt=new WeakMap;var Nt,he,Fi,dc,uc;const Zm=class Zm{constructor(t,e,s){m(this,Nt);m(this,he);m(this,Fi);m(this,dc,0);m(this,uc,0);if(t instanceof Zm&&n(t,Fi)===!!s)return t;p(this,Nt,t),p(this,he,e),p(this,Fi,!!s)}get clipBox(){return n(this,Nt).clipBox}growOperationsCount(){throw new Error("Unreachable")}save(t){return qt(this,uc)._++,n(this,Nt).save(n(this,he)),this}restore(t){return n(this,uc)>0&&(n(this,Nt).restore(n(this,he)),qt(this,uc)._--),this}recordOpenMarker(t){return qt(this,dc)._++,this}getOpenMarker(){return n(this,dc)>0?n(this,he):n(this,Nt).getOpenMarker()}recordCloseMarker(t){return qt(this,dc)._--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return n(this,Nt).pushBaseTransform(t),this}popBaseTransform(){return n(this,Nt).popBaseTransform(),this}recordSimpleData(t,e){return n(this,Nt).recordSimpleData(t,n(this,he)),this}recordIncrementalData(t,e){return n(this,Nt).recordIncrementalData(t,n(this,he)),this}resetIncrementalData(t,e){return n(this,Nt).resetIncrementalData(t,n(this,he)),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return n(this,Nt).recordSimpleDataFromNamed(t,e,n(this,he)),this}recordFutureForcedDependency(t,e){return n(this,Nt).recordFutureForcedDependency(t,n(this,he)),this}inheritSimpleDataAsFutureForcedDependencies(t){return n(this,Nt).inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return n(this,Nt).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return n(this,Fi)||n(this,Nt).resetBBox(n(this,he)),this}recordClipBox(t,e,s,i,r,a){return n(this,Fi)||n(this,Nt).recordClipBox(n(this,he),e,s,i,r,a),this}recordBBox(t,e,s,i,r,a){return n(this,Fi)||n(this,Nt).recordBBox(n(this,he),e,s,i,r,a),this}recordCharacterBBox(t,e,s,i,r,a,o){return n(this,Fi)||n(this,Nt).recordCharacterBBox(n(this,he),e,s,i,r,a,o),this}recordFullPageBBox(t){return n(this,Fi)||n(this,Nt).recordFullPageBBox(n(this,he)),this}getSimpleIndex(t){return n(this,Nt).getSimpleIndex(t)}recordDependencies(t,e){return n(this,Nt).recordDependencies(n(this,he),e),this}recordNamedDependency(t,e){return n(this,Nt).recordNamedDependency(n(this,he),e),this}recordOperation(t){return n(this,Nt).recordOperation(n(this,he),!0),this}recordShowTextOperation(t){return n(this,Nt).recordShowTextOperation(n(this,he),!0),this}bboxToClipBoxDropOperation(t){return n(this,Fi)||n(this,Nt).bboxToClipBoxDropOperation(n(this,he),!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}};Nt=new WeakMap,he=new WeakMap,Fi=new WeakMap,dc=new WeakMap,uc=new WeakMap;let Zh=Zm;const oi={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]};var mo,vo,bo,yo,wo,Md;const qh=class qh{constructor(t){m(this,mo);m(this,vo);m(this,bo,4);m(this,yo,0);m(this,wo,new(n(qh,Md))(n(this,bo)*6));p(this,mo,t.width),p(this,vo,t.height)}record(t,e,s,i){if(n(this,yo)===n(this,bo)){p(this,bo,n(this,bo)*2);const o=new(n(qh,Md))(n(this,bo)*6);o.set(n(this,wo)),p(this,wo,o)}const r=Wt(t);let a;if(i[0]!==1/0){const o=mr.slice();B.axialAlignedBoundingBox([0,-s,e,0],r,o);const l=B.intersect(i,o);if(!l)return;const[c,h,d,f]=l;if(c!==o[0]||h!==o[1]||d!==o[2]||f!==o[3]){const g=Math.atan2(r[1],r[0]),y=Math.abs(Math.sin(g)),b=Math.abs(Math.cos(g));if(y<1e-6||b<1e-6||Math.abs(y-b)<1e-6)a=[c,h,c,f,d,h];else{const S=d-c,w=f-h,x=y*y,A=b*b,C=b*y,_=A-x,k=(w*A-S*C)/_,I=(w*C-S*x)/_;a=[c+I,h,c,h+k,d,f-k]}}}a||(a=[0,-s,0,0,e,-s],B.applyTransform(a,r,0),B.applyTransform(a,r,2),B.applyTransform(a,r,4)),a[0]/=n(this,mo),a[1]/=n(this,vo),a[2]/=n(this,mo),a[3]/=n(this,vo),a[4]/=n(this,mo),a[5]/=n(this,vo),n(this,wo).set(a,n(this,yo)*6),qt(this,yo)._++}take(){return n(this,wo).subarray(0,n(this,yo)*6)}};mo=new WeakMap,vo=new WeakMap,bo=new WeakMap,yo=new WeakMap,wo=new WeakMap,Md=new WeakMap,m(qh,Md,$t.isFloat16ArraySupported?Float16Array:Float32Array);let Ig=qh;var fc,Oi,cp,Ub;class XS{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){m(this,cp);m(this,fc,new Set);m(this,Oi,null);this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){const e=v(this,cp,Ub).call(this);e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);if(this.nativeFontFaces.clear(),n(this,fc).clear(),n(this,Oi)){const{adoptedStyleSheets:t}=this._document;t!=null&&t.includes(n(this,Oi))&&(this._document.adoptedStyleSheets=t.filter(e=>e!==n(this,Oi))),p(this,Oi,null)}this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!(!t||n(this,fc).has(t.loadedName))){if(ne(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:r,style:a}=t,o=new FontFace(i,r,a);this.addNativeFontFace(o);try{await o.load(),n(this,fc).add(i),s==null||s(t)}catch{lt(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}Ct("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw lt(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){var e;const t=!!((e=this._document)!=null&&e.fonts);return at(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return at(this,"isSyncFontLoadingSupported",ei||$t.platform.isFirefox)}_queueLoadingCallback(t){function e(){for(ne(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const r=s.shift();setTimeout(r.callback,0)}}const{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return at(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(_,k){return _.charCodeAt(k)<<24|_.charCodeAt(k+1)<<16|_.charCodeAt(k+2)<<8|_.charCodeAt(k+3)&255}function i(_){return String.fromCharCode(_>>24&255,_>>16&255,_>>8&255,_&255)}function r(_,k,I,L){const P=_.substring(0,k),D=_.substring(k+I);return P+L+D}let a,o;const l=this._document.createElement("canvas");l.width=1,l.height=1;const c=l.getContext("2d");let h=0;function d(_,k){if(++h>30){lt("Load test font never loaded."),k();return}if(c.font="30px "+_,c.fillText(".",0,20),c.getImageData(0,0,1,1).data[3]>0){k();return}setTimeout(d.bind(null,_,k))}const f=`lt${Date.now()}${this.loadTestFontId++}`;let g=this._loadTestFont;g=r(g,976,f.length,f);const b=16,S=1482184792;let w=s(g,b);for(a=0,o=f.length-3;a<o;a+=4)w=w-S+s(f,a)|0;a<f.length&&(w=w-S+s(f+"XXX",a)|0),g=r(g,b,4,i(w));const x=`url(data:font/opentype;base64,${btoa(g)});`,A=`@font-face {font-family:"${f}";src:${x}}`;this.insertRule(A);const C=this._document.createElement("div");C.style.visibility="hidden",C.style.width=C.style.height="10px",C.style.position="absolute",C.style.top=C.style.left="0px";for(const _ of[t.loadedName,f]){const k=this._document.createElement("span");k.textContent="Hi",k.style.fontFamily=_,C.append(k)}this._document.body.append(C),d(f,()=>{C.remove(),e.complete()})}}fc=new WeakMap,Oi=new WeakMap,cp=new WeakSet,Ub=function(){var e;if(n(this,Oi))return n(this,Oi);const t=((e=this._document.defaultView)==null?void 0:e.CSSStyleSheet)||globalThis.CSSStyleSheet;if(!this.styleElement&&t){const{adoptedStyleSheets:s}=this._document;if(s){const i=new t;return s.push(i),p(this,Oi,i)}}return this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement)),p(this,Oi,this.styleElement.sheet)};var Bt;class qS{constructor(t,e=null,s,i){M(this,"compiledGlyphs",Object.create(null));m(this,Bt);p(this,Bt,t),this._inspectFont=e,s&&(this.charProcOperatorList=s),i&&Object.assign(this,i)}createNativeFontFace(){var e;if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const s={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(s.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,s)}return(e=this._inspectFont)==null||e.call(this,this),t}createFontFaceRule(){var s;if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${this.data.toBase64()});`;let e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${t}}`}return(s=this._inspectFont)==null||s.call(this,this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];const s=this.loadedName+"_path_"+e;let i;try{i=t.get(s)}catch(a){lt(`getPathGenerator - ignoring character: "${a}".`)}const r=nb(i==null?void 0:i.path);return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=r}get black(){return n(this,Bt).black}get bold(){return n(this,Bt).bold}get disableFontFace(){return n(this,Bt).disableFontFace}set disableFontFace(t){at(this,"disableFontFace",!!t)}get fontExtraProperties(){return n(this,Bt).fontExtraProperties}get isInvalidPDFjsFont(){return n(this,Bt).isInvalidPDFjsFont}get isType3Font(){return n(this,Bt).isType3Font}get italic(){return n(this,Bt).italic}get missingFile(){return n(this,Bt).missingFile}get remeasure(){return n(this,Bt).remeasure}get vertical(){return n(this,Bt).vertical}get ascent(){return n(this,Bt).ascent}get defaultWidth(){return n(this,Bt).defaultWidth}get descent(){return n(this,Bt).descent}get bbox(){return n(this,Bt).bbox}get fontMatrix(){return n(this,Bt).fontMatrix}get fallbackName(){return n(this,Bt).fallbackName}get loadedName(){return n(this,Bt).loadedName}get mimetype(){return n(this,Bt).mimetype}get name(){return n(this,Bt).name}get data(){return n(this,Bt).data}clearData(){n(this,Bt).clearData()}get cssFontInfo(){return n(this,Bt).cssFontInfo}get systemFontInfo(){return n(this,Bt).systemFontInfo}get defaultVMetrics(){return n(this,Bt).defaultVMetrics}}Bt=new WeakMap;class Hb{}M(Hb,"strings",["fontFamily","fontWeight","italicAngle"]);class zb{}M(zb,"strings",["css","loadedName","baseFontName","src"]);const Qe=class Qe{};M(Qe,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]),M(Qe,"numbers",["ascent","defaultWidth","descent"]),M(Qe,"strings",["fallbackName","loadedName","mimetype","name"]),M(Qe,"OFFSET_NUMBERS",Math.ceil(Qe.bools.length*2/8)),M(Qe,"OFFSET_BBOX",Qe.OFFSET_NUMBERS+Qe.numbers.length*8),M(Qe,"OFFSET_FONT_MATRIX",Qe.OFFSET_BBOX+1+8),M(Qe,"OFFSET_DEFAULT_VMETRICS",Qe.OFFSET_FONT_MATRIX+1+48),M(Qe,"OFFSET_STRINGS",Qe.OFFSET_DEFAULT_VMETRICS+1+6);let Fs=Qe;class fs{}M(fs,"KIND",0),M(fs,"HAS_BBOX",1),M(fs,"HAS_BACKGROUND",2),M(fs,"SHADING_TYPE",3),M(fs,"N_COORD",4),M(fs,"N_COLOR",8),M(fs,"N_STOP",12),M(fs,"N_FIGURES",16);var Id,hp,pc,gc,uf;class YS{constructor(t){m(this,gc);m(this,Id);m(this,hp,new TextDecoder);m(this,pc);p(this,Id,t),p(this,pc,new DataView(t))}get fontFamily(){return v(this,gc,uf).call(this,0)}get fontWeight(){return v(this,gc,uf).call(this,1)}get italicAngle(){return v(this,gc,uf).call(this,2)}}Id=new WeakMap,hp=new WeakMap,pc=new WeakMap,gc=new WeakSet,uf=function(t){ne(t<Hb.strings.length,"Invalid string index");let e=0;for(let i=0;i<t;i++)e+=n(this,pc).getUint32(e)+4;const s=n(this,pc).getUint32(e);return n(this,hp).decode(new Uint8Array(n(this,Id),e+4,s))};var Ao,mc,on,So,Ph;class KS{constructor(t){m(this,So);m(this,Ao);m(this,mc,new TextDecoder);m(this,on);p(this,Ao,t),p(this,on,new DataView(t))}get guessFallback(){return n(this,on).getUint8(0)!==0}get css(){return v(this,So,Ph).call(this,0)}get loadedName(){return v(this,So,Ph).call(this,1)}get baseFontName(){return v(this,So,Ph).call(this,2)}get src(){return v(this,So,Ph).call(this,3)}get style(){let t=1;t+=4+n(this,on).getUint32(t);const e=n(this,on).getUint32(t),s=n(this,mc).decode(new Uint8Array(n(this,Ao),t+4,e));t+=4+e;const i=n(this,on).getUint32(t),r=n(this,mc).decode(new Uint8Array(n(this,Ao),t+4,i));return{style:s,weight:r}}}Ao=new WeakMap,mc=new WeakMap,on=new WeakMap,So=new WeakSet,Ph=function(t){ne(t<zb.strings.length,"Invalid string index");let e=5;for(let i=0;i<t;i++)e+=n(this,on).getUint32(e)+4;const s=n(this,on).getUint32(e);return n(this,mc).decode(new Uint8Array(n(this,Ao),e+4,s))};var Ri,dp,pe,Dt,Pi,ff,pf,Mh,Dg;class QS{constructor({buffer:t,extra:e}){m(this,Dt);m(this,Ri);m(this,dp,new TextDecoder);m(this,pe);p(this,Ri,t),p(this,pe,new DataView(t)),e&&Object.assign(this,e)}get black(){return v(this,Dt,Pi).call(this,0)}get bold(){return v(this,Dt,Pi).call(this,1)}get disableFontFace(){return v(this,Dt,Pi).call(this,2)}get fontExtraProperties(){return v(this,Dt,Pi).call(this,3)}get isInvalidPDFjsFont(){return v(this,Dt,Pi).call(this,4)}get isType3Font(){return v(this,Dt,Pi).call(this,5)}get italic(){return v(this,Dt,Pi).call(this,6)}get missingFile(){return v(this,Dt,Pi).call(this,7)}get remeasure(){return v(this,Dt,Pi).call(this,8)}get vertical(){return v(this,Dt,Pi).call(this,9)}get ascent(){return v(this,Dt,ff).call(this,0)}get defaultWidth(){return v(this,Dt,ff).call(this,1)}get descent(){return v(this,Dt,ff).call(this,2)}get bbox(){return v(this,Dt,pf).call(this,Fs.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return v(this,Dt,pf).call(this,Fs.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return v(this,Dt,pf).call(this,Fs.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}get fallbackName(){return v(this,Dt,Mh).call(this,0)}get loadedName(){return v(this,Dt,Mh).call(this,1)}get mimetype(){return v(this,Dt,Mh).call(this,2)}get name(){return v(this,Dt,Mh).call(this,3)}get data(){const{offset:t,length:e}=v(this,Dt,Dg).call(this);return e===0?void 0:new Uint8Array(n(this,Ri),t+4,e)}clearData(){const{offset:t,length:e}=v(this,Dt,Dg).call(this);e!==0&&(n(this,pe).setUint32(t,0),p(this,Ri,new Uint8Array(n(this,Ri),0,t+4).slice().buffer),p(this,pe,new DataView(n(this,Ri))))}get cssFontInfo(){let t=Fs.OFFSET_STRINGS;const e=n(this,pe).getUint32(t);t+=4+e;const s=n(this,pe).getUint32(t);t+=4+s;const i=n(this,pe).getUint32(t);if(i===0)return null;const r=new Uint8Array(i);return r.set(new Uint8Array(n(this,Ri),t+4,i)),new YS(r.buffer)}get systemFontInfo(){let t=Fs.OFFSET_STRINGS;const e=n(this,pe).getUint32(t);t+=4+e;const s=n(this,pe).getUint32(t);if(s===0)return null;const i=new Uint8Array(s);return i.set(new Uint8Array(n(this,Ri),t+4,s)),new KS(i.buffer)}}Ri=new WeakMap,dp=new WeakMap,pe=new WeakMap,Dt=new WeakSet,Pi=function(t){ne(t<Fs.bools.length,"Invalid boolean index");const e=Math.floor(t/4),s=t*2%8,i=n(this,pe).getUint8(e)>>s&3;return i===0?void 0:i===2},ff=function(t){return ne(t<Fs.numbers.length,"Invalid number index"),n(this,pe).getFloat64(Fs.OFFSET_NUMBERS+t*8)},pf=function(t,e,s,i){const r=n(this,pe).getUint8(t);if(r===0)return;ne(r===e,"Invalid array length."),t+=1;const a=new Array(r);for(let o=0;o<r;o++)a[o]=n(this,pe)[s](t,!0),t+=i;return a},Mh=function(t){ne(t<Fs.strings.length,"Invalid string index");let e=Fs.OFFSET_STRINGS+4;for(let i=0;i<t;i++)e+=n(this,pe).getUint32(e)+4;const s=n(this,pe).getUint32(e);return n(this,dp).decode(new Uint8Array(n(this,Ri),e+4,s))},Dg=function(){let t=Fs.OFFSET_STRINGS;const e=n(this,pe).getUint32(t);t+=4+e;const s=n(this,pe).getUint32(t);t+=4+s;const i=n(this,pe).getUint32(t);t+=4+i;const r=n(this,pe).getUint32(t);return{offset:t,length:r}};class JS{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}getIR(){const t=this.view,e=this.data[fs.KIND],s=!!this.data[fs.HAS_BBOX],i=!!this.data[fs.HAS_BACKGROUND],r=t.getUint32(fs.N_COORD,!0),a=t.getUint32(fs.N_COLOR,!0),o=t.getUint32(fs.N_STOP,!0);let l=20;const c=new Float32Array(this.buffer,l,r*2);l+=r*8;const h=new Uint8Array(this.buffer,l,a*4);l+=a*4;const d=[];for(let y=0;y<o;++y){const b=t.getFloat32(l,!0);l+=4;const S=t.getUint32(l,!0);l+=4,d.push([b,`#${S.toString(16).padStart(6,"0")}`])}let f=null;if(s){f=[];for(let y=0;y<4;++y)f.push(t.getFloat32(l,!0)),l+=4}let g=null;if(i&&(g=new Uint8Array(this.buffer,l,3),l+=3),e===1)return["RadialAxial","axial",f,d,Array.from(c.slice(0,2)),Array.from(c.slice(2,4)),null,null];if(e===2)return["RadialAxial","radial",f,d,[c[0],c[1]],[c[3],c[4]],c[2],c[5]];if(e===3){const y=this.data[fs.SHADING_TYPE];let b=null;if(c.length>0){b=mr.slice();for(let S=0,w=c.length;S<w;S+=2)B.pointBoundingBox(c[S],c[S+1],b)}return["Mesh",y,c,h,r,b,f,g]}throw new Error(`Unsupported pattern kind: ${e}`)}}var vc;class ZS{constructor(t){m(this,vc);p(this,vc,t)}get path(){return $t.isFloat16ArraySupported?new Float16Array(n(this,vc)):new Float32Array(n(this,vc))}}vc=new WeakMap;function t1(u){if(u instanceof URL)return u;if(typeof u=="string"){if(ei){if(/^[a-z][a-z0-9\-+.]+:/i.test(u))return new URL(u);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(u))}const t=URL.parse(u,window.location);if(t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function e1(u){if(ei&&typeof Buffer<"u"&&u instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(u instanceof Uint8Array&&u.byteLength===u.buffer.byteLength)return u;if(typeof u=="string")return Op(u);if(u instanceof ArrayBuffer||ArrayBuffer.isView(u)||typeof u=="object"&&!isNaN(u==null?void 0:u.length))return new Uint8Array(u);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function Yu(u){if(typeof u!="string")return null;if(u.endsWith("/"))return u;throw new Error(`Invalid factory url: "${u}" must include trailing slash.`)}const Lg=u=>typeof u=="object"&&Number.isInteger(u==null?void 0:u.num)&&u.num>=0&&Number.isInteger(u==null?void 0:u.gen)&&u.gen>=0,s1=u=>typeof u=="object"&&typeof(u==null?void 0:u.name)=="string",i1=MS.bind(null,Lg,s1);var jn,up;class n1{constructor(){m(this,jn,new Map);m(this,up,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};n(this,up).then(()=>{for(const[i]of n(this,jn))i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:r}=s;if(r.aborted){lt("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(t,e);i=()=>r.removeEventListener("abort",a),r.addEventListener("abort",a)}n(this,jn).set(e,i)}removeEventListener(t,e){const s=n(this,jn).get(e);s==null||s(),n(this,jn).delete(e)}terminate(){for(const[,t]of n(this,jn))t==null||t();n(this,jn).clear()}}jn=new WeakMap,up=new WeakMap;const Ku={DATA:1,ERROR:2},ve={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function xv(){}function vs(u){if(u instanceof _a||u instanceof og||u instanceof ag||u instanceof Xf||u instanceof Yp)return u;switch(u instanceof Error||typeof u=="object"&&u!==null||Ct('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),u.name){case"AbortException":return new _a(u.message);case"InvalidPDFException":return new og(u.message);case"PasswordException":return new ag(u.message,u.code);case"ResponseException":return new Xf(u.message,u.status,u.missing);case"UnknownErrorException":return new Yp(u.message,u.details)}return new Yp(u.message,u.toString())}var bc,Ei,Vb,Gb,jb,gf;class Ih{constructor(t,e,s){m(this,Ei);m(this,bc,new AbortController);this.sourceName=t,this.targetName=e,this.comObj=s,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),s.addEventListener("message",v(this,Ei,Vb).bind(this),{signal:n(this,bc).signal})}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const i=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[i]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(a){r.reject(a)}return r.promise}sendWithStream(t,e,s,i){const r=this.streamId++,a=this.sourceName,o=this.targetName,l=this.comObj;return new ReadableStream({start:c=>{const h=Promise.withResolvers();return this.streamControllers[r]={controller:c,startCall:h,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:a,targetName:o,action:t,streamId:r,data:e,desiredSize:c.desiredSize},i),h.promise},pull:c=>{const h=Promise.withResolvers();return this.streamControllers[r].pullCall=h,l.postMessage({sourceName:a,targetName:o,stream:ve.PULL,streamId:r,desiredSize:c.desiredSize}),h.promise},cancel:c=>{ne(c instanceof Error,"cancel must have a valid reason");const h=Promise.withResolvers();return this.streamControllers[r].cancelCall=h,this.streamControllers[r].isClosed=!0,l.postMessage({sourceName:a,targetName:o,stream:ve.CANCEL,streamId:r,reason:vs(c)}),h.promise}},s)}destroy(){var t;(t=n(this,bc))==null||t.abort(),p(this,bc,null)}}bc=new WeakMap,Ei=new WeakSet,Vb=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){v(this,Ei,jb).call(this,t);return}if(t.callback){const s=t.callbackId,i=this.callbackCapabilities[s];if(!i)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===Ku.DATA)i.resolve(t.data);else if(t.callback===Ku.ERROR)i.reject(vs(t.reason));else throw new Error("Unexpected callback case");return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=this.sourceName,i=t.sourceName,r=this.comObj;Promise.try(e,t.data).then(function(a){r.postMessage({sourceName:s,targetName:i,callback:Ku.DATA,callbackId:t.callbackId,data:a})},function(a){r.postMessage({sourceName:s,targetName:i,callback:Ku.ERROR,callbackId:t.callbackId,reason:vs(a)})});return}if(t.streamId){v(this,Ei,Gb).call(this,t);return}e(t.data)},Gb=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,r=this.comObj,a=this,o=this.actionHandler[t.action],l={enqueue(c,h=1,d){if(this.isCancelled)return;const f=this.desiredSize;this.desiredSize-=h,f>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:s,targetName:i,stream:ve.ENQUEUE,streamId:e,chunk:c},d)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:ve.CLOSE,streamId:e}),delete a.streamSinks[e])},error(c){ne(c instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:ve.ERROR,streamId:e,reason:vs(c)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[e]=l,Promise.try(o,t.data,l).then(function(){r.postMessage({sourceName:s,targetName:i,stream:ve.START_COMPLETE,streamId:e,success:!0})},function(c){r.postMessage({sourceName:s,targetName:i,stream:ve.START_COMPLETE,streamId:e,reason:vs(c)})})},jb=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,r=this.comObj,a=this.streamControllers[e],o=this.streamSinks[e];switch(t.stream){case ve.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject(vs(t.reason));break;case ve.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject(vs(t.reason));break;case ve.PULL:if(!o){r.postMessage({sourceName:s,targetName:i,stream:ve.PULL_COMPLETE,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,Promise.try(o.onPull||xv).then(function(){r.postMessage({sourceName:s,targetName:i,stream:ve.PULL_COMPLETE,streamId:e,success:!0})},function(c){r.postMessage({sourceName:s,targetName:i,stream:ve.PULL_COMPLETE,streamId:e,reason:vs(c)})});break;case ve.ENQUEUE:if(ne(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case ve.CLOSE:if(ne(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),v(this,Ei,gf).call(this,a,e);break;case ve.ERROR:ne(a,"error should have stream controller"),a.controller.error(vs(t.reason)),v(this,Ei,gf).call(this,a,e);break;case ve.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject(vs(t.reason)),v(this,Ei,gf).call(this,a,e);break;case ve.CANCEL:if(!o)break;const l=vs(t.reason);Promise.try(o.onCancel||xv,l).then(function(){r.postMessage({sourceName:s,targetName:i,stream:ve.CANCEL_COMPLETE,streamId:e,success:!0})},function(c){r.postMessage({sourceName:s,targetName:i,stream:ve.CANCEL_COMPLETE,streamId:e,reason:vs(c)})}),o.sinkCapability.reject(l),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},gf=async function(t,e){var s,i,r;await Promise.allSettled([(s=t.startCall)==null?void 0:s.promise,(i=t.pullCall)==null?void 0:i.promise,(r=t.cancelCall)==null?void 0:r.promise]),delete this.streamControllers[e]};var fp;class Wb{constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:s=null}){m(this,fp,Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"}));this.cMapUrl=t,this.standardFontDataUrl=e,this.wasmUrl=s}async fetch({kind:t,filename:e}){switch(t){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:Ct(`Not implemented: ${t}`)}const s=this[t];if(!s)throw new Error(`Ensure that the \`${t}\` API parameter is provided.`);const i=`${s}${e}`;return this._fetch(i,t).catch(r=>{throw new Error(`Unable to load ${n(this,fp)[t]} data at: ${i}`)})}async _fetch(t,e){Ct("Abstract method `_fetch` called.")}}fp=new WeakMap;class Ev extends Wb{async _fetch(t,e){const s=e==="cMapUrl"&&!t.endsWith(".bcmap")?"text":"bytes",i=await zm(t,s);return i instanceof Uint8Array?i:Op(i)}}var Dd;class Xb{constructor({enableHWA:t=!1}){m(this,Dd,!1);p(this,Dd,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!n(this,Dd)})}}reset({canvas:t},e,s){if(!t)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.width=e,t.height=s}destroy(t){const{canvas:e}=t;if(!e)throw new Error("Canvas is not specified");e.width=e.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){Ct("Abstract method `_createCanvas` called.")}}Dd=new WeakMap;class r1 extends Xb{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}class qb{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addKnockoutFilter(t=0){return"none"}addHighlightHCMFilter(t,e,s,i,r){return"none"}addSelectionHCMFilter(t,e){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(t=null){return null}destroy(t=!1){}}var xo,yc,Wn,ln,Ie,Eo,Qr,H,Te,Dh,xr,mf,Ra,Yb,Fg,Na,Lh,Fh,Og,Oh,Kb,Qb;class a1 extends qb{constructor({docId:e,ownerDocument:s=globalThis.document}){super();m(this,H);m(this,xo);m(this,yc);m(this,Wn);m(this,ln);m(this,Ie);m(this,Eo);m(this,Qr,0);p(this,ln,e),p(this,Ie,s)}addFilter(e){if(!e)return"none";let s=n(this,H,Te).get(e);if(s)return s;const[i,r,a]=v(this,H,mf).call(this,e),o=e.length===1?i:`${i}${r}${a}`;if(s=n(this,H,Te).get(o),s)return n(this,H,Te).set(e,s),s;const l=`g_${n(this,ln)}_transfer_map_${qt(this,Qr)._++}`,c=v(this,H,Ra).call(this,l);n(this,H,Te).set(e,c),n(this,H,Te).set(o,c);const h=v(this,H,Na).call(this,l);return v(this,H,Fh).call(this,i,r,a,h),c}addHCMFilter(e,s){var y;const i=`${e}-${s}`,r="base";let a=n(this,H,Dh).get(r);if((a==null?void 0:a.key)===i||(a?((y=a.filter)==null||y.remove(),a.key=i,a.url="none",a.filter=null):(a={key:i,url:"none",filter:null},n(this,H,Dh).set(r,a)),!e||!s))return a.url;const o=v(this,H,Oh).call(this,e);e=B.makeHexColor(...o);const l=v(this,H,Oh).call(this,s);if(s=B.makeHexColor(...l),n(this,H,xr).style.color="",e==="#000000"&&s==="#ffffff"||e===s)return a.url;const c=new Array(256);for(let b=0;b<=255;b++){const S=b/255;c[b]=S<=.03928?S/12.92:((S+.055)/1.055)**2.4}const h=c.join(","),d=`g_${n(this,ln)}_hcm_filter`,f=a.filter=v(this,H,Na).call(this,d);v(this,H,Fh).call(this,h,h,h,f),v(this,H,Fg).call(this,f);const g=(b,S)=>{const w=o[b]/255,x=l[b]/255,A=new Array(S+1);for(let C=0;C<=S;C++)A[C]=w+C/S*(x-w);return A.join(",")};return v(this,H,Fh).call(this,g(0,5),g(1,5),g(2,5),f),a.url=v(this,H,Ra).call(this,d),a.url}addSelectionHCMFilter(e,s){return this.addHighlightHCMFilter("selection",e,s,"HighlightText","Highlight")}addSelectionFilter(){return this.addHighlightHCMFilter("selection_default","black","white","HighlightText","Highlight")}createSelectionStyle(e=null){const s=e?this.addSelectionHCMFilter(e.foreground,e.background):this.addSelectionFilter();return s==="none"||!$t.platform.isFirefox?null:{"backdrop-filter":s,"background-color":"transparent"}}addAlphaFilter(e){let s=n(this,H,Te).get(e);if(s)return s;const[i]=v(this,H,mf).call(this,[e]),r=`alpha_${i}`;if(s=n(this,H,Te).get(r),s)return n(this,H,Te).set(e,s),s;const a=`g_${n(this,ln)}_alpha_map_${qt(this,Qr)._++}`,o=v(this,H,Ra).call(this,a);n(this,H,Te).set(e,o),n(this,H,Te).set(r,o);const l=v(this,H,Na).call(this,a);return v(this,H,Og).call(this,i,l),o}addLuminosityFilter(e){let s=n(this,H,Te).get(e||"luminosity");if(s)return s;let i,r;if(e?([i]=v(this,H,mf).call(this,[e]),r=`luminosity_${i}`):r="luminosity",s=n(this,H,Te).get(r),s)return n(this,H,Te).set(e,s),s;const a=`g_${n(this,ln)}_luminosity_map_${qt(this,Qr)._++}`,o=v(this,H,Ra).call(this,a);n(this,H,Te).set(e,o),n(this,H,Te).set(r,o);const l=v(this,H,Na).call(this,a);return v(this,H,Yb).call(this,l),e&&v(this,H,Og).call(this,i,l),o}addKnockoutFilter(e=0){const s=e>0?Math.min(1/e,1e6):1e6,i=`knockout_${s}`,r=n(this,H,Te).get(i);if(r)return r;const a=`g_${n(this,ln)}_knockout_filter_${qt(this,Qr)._++}`,o=v(this,H,Ra).call(this,a);n(this,H,Te).set(i,o);const l=v(this,H,Na).call(this,a),c=n(this,Ie).createElementNS(Rs,"feComponentTransfer");l.append(c);const h=n(this,Ie).createElementNS(Rs,"feFuncA");return h.setAttribute("type","linear"),h.setAttribute("slope",`${s}`),h.setAttribute("intercept","0"),c.append(h),o}addHighlightHCMFilter(e,s,i,r,a){var x;const o=`${s}-${i}-${r}-${a}`;let l=n(this,H,Dh).get(e);if((l==null?void 0:l.key)===o||(l?((x=l.filter)==null||x.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},n(this,H,Dh).set(e,l)),!s||!i))return l.url;const[c,h]=[s,i].map(v(this,H,Oh).bind(this));let d=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),f=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),[g,y]=[r,a].map(v(this,H,Qb).bind(this));f<d&&([d,f,g,y]=[f,d,y,g]),n(this,H,xr).style.color="";const b=(A,C,_)=>{const k=new Array(256),I=(f-d)/_,L=A/255,P=(C-A)/(255*_);let D=0;for(let R=0;R<=_;R++){const K=Math.round(d+R*I),W=L+R*P;for(let Q=D;Q<=K;Q++)k[Q]=W;D=K+1}for(let R=D;R<256;R++)k[R]=k[D-1];return k.join(",")},S=`g_${n(this,ln)}_hcm_${e}_filter`,w=l.filter=v(this,H,Na).call(this,S);return v(this,H,Fg).call(this,w),v(this,H,Fh).call(this,b(g[0],y[0],5),b(g[1],y[1],5),b(g[2],y[2],5),w),l.url=v(this,H,Ra).call(this,S),l.url}destroy(e=!1){var s,i,r,a;e&&((s=n(this,Eo))!=null&&s.size)||((i=n(this,Wn))==null||i.parentNode.parentNode.remove(),p(this,Wn,null),(r=n(this,yc))==null||r.clear(),p(this,yc,null),(a=n(this,Eo))==null||a.clear(),p(this,Eo,null),p(this,Qr,0))}}xo=new WeakMap,yc=new WeakMap,Wn=new WeakMap,ln=new WeakMap,Ie=new WeakMap,Eo=new WeakMap,Qr=new WeakMap,H=new WeakSet,Te=function(){return n(this,yc)||p(this,yc,new Map)},Dh=function(){return n(this,Eo)||p(this,Eo,new Map)},xr=function(){if(!n(this,Wn)){const e=n(this,Ie).createElement("div"),{style:s}=e;s.colorScheme="only light",s.visibility="hidden",s.contain="strict",s.width=s.height=0,s.position="absolute",s.top=s.left=0,s.zIndex=-1;const i=n(this,Ie).createElementNS(Rs,"svg");i.setAttribute("width",0),i.setAttribute("height",0),p(this,Wn,n(this,Ie).createElementNS(Rs,"defs")),e.append(i),i.append(n(this,Wn)),n(this,Ie).body.append(e)}return n(this,Wn)},mf=function(e){if(e.length===1){const c=e[0],h=new Array(256);for(let f=0;f<256;f++)h[f]=c[f]/255;const d=h.join(",");return[d,d,d]}const[s,i,r]=e,a=new Array(256),o=new Array(256),l=new Array(256);for(let c=0;c<256;c++)a[c]=s[c]/255,o[c]=i[c]/255,l[c]=r[c]/255;return[a.join(","),o.join(","),l.join(",")]},Ra=function(e){if(n(this,xo)===void 0){p(this,xo,"");const s=n(this,Ie).URL;s!==n(this,Ie).baseURI&&(Rp(s)?lt('#createUrl: ignore "data:"-URL for performance reasons.'):p(this,xo,tb(s,"")))}return`url(${n(this,xo)}#${e})`},Yb=function(e){const s=n(this,Ie).createElementNS(Rs,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),e.append(s)},Fg=function(e){const s=n(this,Ie).createElementNS(Rs,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(s)},Na=function(e){const s=n(this,Ie).createElementNS(Rs,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),n(this,H,xr).append(s),s},Lh=function(e,s,i){const r=n(this,Ie).createElementNS(Rs,s);r.setAttribute("type","discrete"),r.setAttribute("tableValues",i),e.append(r)},Fh=function(e,s,i,r){const a=n(this,Ie).createElementNS(Rs,"feComponentTransfer");r.append(a),v(this,H,Lh).call(this,a,"feFuncR",e),v(this,H,Lh).call(this,a,"feFuncG",s),v(this,H,Lh).call(this,a,"feFuncB",i)},Og=function(e,s){const i=n(this,Ie).createElementNS(Rs,"feComponentTransfer");s.append(i),v(this,H,Lh).call(this,i,"feFuncA",e)},Oh=function(e){return n(this,H,xr).style.color=e,Wu(getComputedStyle(n(this,H,xr)).getPropertyValue("color"))},Kb=function(e){return n(this,H,xr).style.color=e,ju(getComputedStyle(n(this,H,xr)).getPropertyValue("color"))},Qb=function(e){const[s,i,r,a]=v(this,H,Kb).call(this,e);if(a===1)return[s,i,r];const[o,l,c]=v(this,H,Oh).call(this,"Canvas");return[Jp(s,o,a),Jp(i,l,a),Jp(r,c,a)]};function Jp(u,t,e){return Math.round(e*u+(1-e)*t)}ei&&lt("Please use the `legacy` build in Node.js environments.");async function o1(u){const e=await process.getBuiltinModule("fs/promises").readFile(u);return new Uint8Array(e)}class l1 extends qb{}class c1 extends Xb{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class h1 extends Wb{async _fetch(t,e){return o1(t)}}function Jb({src:u,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=$t.isLittleEndian?4278190080:255,[l,c]=a?[r,o]:[o,r],h=s>>3,d=s&7,f=l^c,g=u.length;e=new Uint32Array(e.buffer);let y=0;for(let b=0;b<i;++b){for(const w=t+h;t<w;++t,y+=8){const x=u[t];e[y]=l^-(x>>7&1)&f,e[y+1]=l^-(x>>6&1)&f,e[y+2]=l^-(x>>5&1)&f,e[y+3]=l^-(x>>4&1)&f,e[y+4]=l^-(x>>3&1)&f,e[y+5]=l^-(x>>2&1)&f,e[y+6]=l^-(x>>1&1)&f,e[y+7]=l^-(x&1)&f}if(d===0)continue;const S=t<g?u[t++]:255;for(let w=0;w<d;++w,++y)e[y]=l^-(S>>7-w&1)&f}return{srcPos:t,destPos:y}}function d1({src:u,srcPos:t=0,dest:e,destPos:s=0,width:i,height:r}){let a=0;const o=i*r*3,l=o>>2,c=new Uint32Array(u.buffer,t,l),h=$t.isLittleEndian?4278190080:255;if($t.isLittleEndian){for(;a<l-2;a+=3,s+=4){const d=c[a],f=c[a+1],g=c[a+2];e[s]=d|h,e[s+1]=d>>>24|f<<8|h,e[s+2]=f>>>16|g<<16|h,e[s+3]=g>>>8|h}for(let d=a*4,f=t+o;d<f;d+=3)e[s++]=u[d]|u[d+1]<<8|u[d+2]<<16|h}else{for(;a<l-2;a+=3,s+=4){const d=c[a],f=c[a+1],g=c[a+2];e[s]=d|h,e[s+1]=d<<24|f>>>8|h,e[s+2]=f<<16|g>>>16|h,e[s+3]=g<<8|h}for(let d=a*4,f=t+o;d<f;d+=3)e[s++]=u[d]<<24|u[d+1]<<16|u[d+2]<<8|h}return{srcPos:t+o,destPos:s}}const u1=`
struct Uniforms {
offsetX : f32,
offsetY : f32,
scaleX : f32,
scaleY : f32,
paddedWidth : f32,
paddedHeight : f32,
borderSize : f32,
_pad : f32,
};
@group(0) @binding(0) var<uniform> u : Uniforms;
struct VertexInput {
@location(0) position : vec2<f32>,
@location(1) color : vec4<f32>,
};
struct VertexOutput {
@builtin(position) position : vec4<f32>,
@location(0) color : vec3<f32>,
};
@vertex
fn vs_main(in : VertexInput) -> VertexOutput {
var out : VertexOutput;
let cx = (in.position.x + u.offsetX) * u.scaleX;
let cy = (in.position.y + u.offsetY) * u.scaleY;
out.position = vec4<f32>(
((cx + u.borderSize) / u.paddedWidth) * 2.0 - 1.0,
1.0 - ((cy + u.borderSize) / u.paddedHeight) * 2.0,
0.0,
1.0
);
out.color = in.color.rgb;
return out;
}
@fragment
fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
return vec4<f32>(in.color, 1.0);
}
`;var pp,Xn,Co,wc,gp,Zb;class f1{constructor(){m(this,gp);m(this,pp,null);m(this,Xn,null);m(this,Co,null);m(this,wc,null)}init(){return n(this,pp)||p(this,pp,v(this,gp,Zb).call(this))}get isReady(){return n(this,Xn)!==null}loadMeshShader(){if(!n(this,Xn)||n(this,Co))return;const t=n(this,Xn).createShaderModule({code:u1});p(this,Co,n(this,Xn).createRenderPipeline({layout:"auto",vertex:{module:t,entryPoint:"vs_main",buffers:[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:t,entryPoint:"fs_main",targets:[{format:n(this,wc)}]},primitive:{topology:"triangle-list"}}))}draw(t,e,s,i,r,a,o,l){this.loadMeshShader();const c=n(this,Xn),{offsetX:h,offsetY:d,scaleX:f,scaleY:g}=i,y=c.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});t.byteLength>0&&c.queue.writeBuffer(y,0,t);const b=c.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});e.byteLength>0&&c.queue.writeBuffer(b,0,e);const S=c.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});c.queue.writeBuffer(S,0,new Float32Array([h,d,f,g,a,o,l,0]));const w=c.createBindGroup({layout:n(this,Co).getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:S}}]}),x=new OffscreenCanvas(a,o),A=x.getContext("webgpu");A.configure({device:c,format:n(this,wc),alphaMode:r?"opaque":"premultiplied"});const C=r?{r:r[0]/255,g:r[1]/255,b:r[2]/255,a:1}:{r:0,g:0,b:0,a:0},_=c.createCommandEncoder(),k=_.beginRenderPass({colorAttachments:[{view:A.getCurrentTexture().createView(),clearValue:C,loadOp:"clear",storeOp:"store"}]});return s>0&&(k.setPipeline(n(this,Co)),k.setBindGroup(0,w),k.setVertexBuffer(0,y),k.setVertexBuffer(1,b),k.draw(s)),k.end(),c.queue.submit([_.finish()]),y.destroy(),b.destroy(),S.destroy(),x.transferToImageBitmap()}}pp=new WeakMap,Xn=new WeakMap,Co=new WeakMap,wc=new WeakMap,gp=new WeakSet,Zb=async function(){var t;if(!((t=globalThis.navigator)!=null&&t.gpu))return!1;try{const e=await navigator.gpu.requestAdapter();return e?(p(this,wc,navigator.gpu.getPreferredCanvasFormat()),p(this,Xn,await e.requestDevice()),!0):!1}catch{return!1}};const Np=new f1;function p1(){return Np.init()}function g1(){return Np.isReady}function m1(){Np.loadMeshShader()}function v1(u,t,e,s,i,r,a,o){return Np.draw(u,t,e,s,i,r,a,o)}const We={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function vf(u,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],e,s),u.clip(i)}class Wm{isModifyingCurrentTransform(){return!1}getPattern(){Ct("Abstract method `getPattern` called.")}}class b1 extends Wm{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}isOriginBased(){return this._p0[0]===0&&this._p0[1]===0&&(!this.isRadial()||this._p1[0]===0&&this._p1[1]===0)}isRadial(){return this._type==="radial"}areConic(){if(!this.isRadial())return!1;const t=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return t+this._r1>this._r0&&t+this._r0>this._r1}_createGradient(t,e=null){let s,i=this._p0,r=this._p1;if(e&&(i=i.slice(),r=r.slice(),B.applyTransform(i,e),B.applyTransform(r,e)),this._type==="axial")s=t.createLinearGradient(i[0],i[1],r[0],r[1]);else if(this._type==="radial"){let a=this._r0,o=this._r1;if(e){const l=new Float32Array(2);B.singularValueDecompose2dScale(e,l),a*=l[0],o*=l[0]}s=t.createRadialGradient(i[0],i[1],a,r[0],r[1],o)}for(const a of this._colorStops)s.addColorStop(a[0],a[1]);return s}_createReversedGradient(t,e=null){let s=this._p1,i=this._p0;e&&(s=s.slice(),i=i.slice(),B.applyTransform(s,e),B.applyTransform(i,e));let r=this._r1,a=this._r0;if(e){const c=new Float32Array(2);B.singularValueDecompose2dScale(e,c),r*=c[0],a*=c[0]}const o=t.createRadialGradient(s[0],s[1],r,i[0],i[1],a),l=this._colorStops.map(([c,h])=>[1-c,h]).reverse();for(const[c,h]of l)o.addColorStop(c,h);return o}getPattern(t,e,s,i){let r;if(i===We.STROKE||i===We.FILL){if(this.isOriginBased()){let f=B.transform(s,e.baseTransform);this.matrix&&(f=B.transform(f,this.matrix));const g=.001,y=Math.hypot(f[0],f[1]),b=Math.hypot(f[2],f[3]),S=(f[0]*f[2]+f[1]*f[3])/(y*b);if(Math.abs(S)<g)if(this.isRadial()){if(Math.abs(y-b)<g)return this._createGradient(t,f)}else return this._createGradient(t,f)}const a=e.current.getClippedPathBoundingBox(i,Wt(t))||[0,0,0,0],o=Math.ceil(a[2]-a[0])||1,l=Math.ceil(a[3]-a[1])||1,c=e.canvasFactory.create(o,l),h=c.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-a[0],-a[1]),s=B.transform(s,[1,0,0,1,a[0],a[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),vf(h,this._bbox),this.areConic()&&(h.fillStyle=this._createReversedGradient(h),h.fill()),h.fillStyle=this._createGradient(h),h.fill(),r=t.createPattern(c.canvas,"no-repeat"),e.canvasFactory.destroy(c);const d=new DOMMatrix(s);r.setTransform(d)}else this.areConic()&&(t.save(),vf(t,this._bbox),t.fillStyle=this._createReversedGradient(t),t.fillRect(-1e10,-1e10,2e10,2e10),t.restore()),vf(t,this._bbox),r=this._createGradient(t);return r}}function y1(u,t,e,s,i,r,a,o){const l=t.coords,c=t.colors,h=u.data,d=u.width*4;let f;l[e*2+1]>l[s*2+1]&&(f=e,e=s,s=f,f=r,r=a,a=f),l[s*2+1]>l[i*2+1]&&(f=s,s=i,i=f,f=a,a=o,o=f),l[e*2+1]>l[s*2+1]&&(f=e,e=s,s=f,f=r,r=a,a=f);const g=(l[e*2]+t.offsetX)*t.scaleX,y=(l[e*2+1]+t.offsetY)*t.scaleY,b=(l[s*2]+t.offsetX)*t.scaleX,S=(l[s*2+1]+t.offsetY)*t.scaleY,w=(l[i*2]+t.offsetX)*t.scaleX,x=(l[i*2+1]+t.offsetY)*t.scaleY;if(y>=x)return;const A=c[r*4],C=c[r*4+1],_=c[r*4+2],k=c[a*4],I=c[a*4+1],L=c[a*4+2],P=c[o*4],D=c[o*4+1],R=c[o*4+2],K=Math.round(y),W=Math.round(x);let Q,ht,T,q,Lt,mt,_e,re;for(let Gt=K;Gt<=W;Gt++){if(Gt<S){const J=Gt<y?0:(y-Gt)/(y-S);Q=g-(g-b)*J,ht=A-(A-k)*J,T=C-(C-I)*J,q=_-(_-L)*J}else{let J;Gt>x?J=1:S===x?J=0:J=(S-Gt)/(S-x),Q=b-(b-w)*J,ht=k-(k-P)*J,T=I-(I-D)*J,q=L-(L-R)*J}let V;Gt<y?V=0:Gt>x?V=1:V=(y-Gt)/(y-x),Lt=g-(g-w)*V,mt=A-(A-P)*V,_e=C-(C-D)*V,re=_-(_-R)*V;const $=Math.round(Math.min(Q,Lt)),Et=Math.round(Math.max(Q,Lt));let ct=d*Gt+$*4;for(let J=$;J<=Et;J++)V=(Q-J)/(Q-Lt),V<0?V=0:V>1&&(V=1),h[ct++]=ht-(ht-mt)*V|0,h[ct++]=T-(T-_e)*V|0,h[ct++]=q-(q-re)*V|0,h[ct++]=255}}class w1 extends Wm{constructor(t){super(),this._posData=t[2],this._colData=t[3],this._vertexCount=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null,m1()}_createMeshCanvas(t,e,s){const o=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),c=Math.ceil(this._bounds[2])-o,h=Math.ceil(this._bounds[3])-l,d=Math.min(Math.ceil(Math.abs(c*t[0]*1.1)),3e3)||1,f=Math.min(Math.ceil(Math.abs(h*t[1]*1.1)),3e3)||1,g=c?c/d:1,y=h?h/f:1,b={coords:this._posData,colors:this._colData,offsetX:-o,offsetY:-l,scaleX:1/g,scaleY:1/y},S=d+4,w=f+4,x=s.create(S,w);if(g1()&&this._vertexCount>48)x.context.drawImage(v1(this._posData,this._colData,this._vertexCount,b,e,S,w,2),0,0);else{const A=x.context.createImageData(d,f);if(e){const C=A.data;for(let _=0,k=C.length;_<k;_+=4)C[_]=e[0],C[_+1]=e[1],C[_+2]=e[2],C[_+3]=255}for(let C=0,_=this._vertexCount;C<_;C+=3)y1(A,b,C,C+1,C+2,C,C+1,C+2);x.context.putImageData(A,2,2)}return{canvas:x.canvas,offsetX:o-2*g,offsetY:l-2*y,scaleX:g,scaleY:y}}isModifyingCurrentTransform(){return!0}getPattern(t,e,s,i){vf(t,this._bbox);const r=new Float32Array(2);if(i===We.SHADING)B.singularValueDecompose2dScale(Wt(t),r);else if(this.matrix){B.singularValueDecompose2dScale(this.matrix,r);const[l,c]=r;B.singularValueDecompose2dScale(e.baseTransform,r),r[0]*=l,r[1]*=c}else B.singularValueDecompose2dScale(e.baseTransform,r);const a=this._createMeshCanvas(r,i===We.SHADING?null:this._background,e.canvasFactory);i!==We.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(a.offsetX,a.offsetY),t.scale(a.scaleX,a.scaleY);const o=t.createPattern(a.canvas,"no-repeat");return e.canvasFactory.destroy(a),o}}class A1 extends Wm{getPattern(){return"hotpink"}}function S1(u){switch(u[0]){case"RadialAxial":return new b1(u);case"Mesh":return new w1(u);case"Dummy":return new A1}throw new Error(`Unknown IR type: ${u[0]}`)}const Cv={COLORED:1,UNCOLORED:2},mp=class mp{constructor(t,e,s,i){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.needsIsolation=t[9]??!0,this.ctx=e,this.canvasGraphicsFactory=s,this.baseTransform=i,this.patternBaseMatrix=this.matrix?B.transform(i,this.matrix):i}canSkipPatternCanvas([t,e,s,i]){const[r,a,o,l]=this.bbox,c=Math.abs(this.xstep),h=Math.abs(this.ystep);if(t>c+1e-6||e>h+1e-6)return null;const d=Math.floor((s-o)/c)+1,f=Math.ceil((s+t-r)/c)-1,g=Math.floor((i-l)/h)+1,y=Math.ceil((i+e-a)/h)-1;return f<=d&&y<=g?[d,g]:null}updatePatternDims(t,e){const s=B.inverseTransform(this.patternBaseMatrix),i=[t[0],t[1]],r=[t[2],t[3]];B.applyTransform(i,s),B.applyTransform(r,s),e[0]=Math.abs(r[0]-i[0]),e[1]=Math.abs(r[1]-i[1]),e[2]=Math.min(i[0],r[0]),e[3]=Math.min(i[1],r[1])}_renderTileCanvas(t,e,s,i){var f,g;const[r,a,o,l]=this.bbox,c=t.canvasFactory.create(s.size,i.size),h=c.context,d=this.canvasGraphicsFactory.createCanvasGraphics(h,e);return d.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(d,this.paintType,this.color),h.translate(-s.scale*r,-i.scale*a),d.transform(0,s.scale,0,0,i.scale,0,0),h.save(),(f=d.dependencyTracker)==null||f.save(),this.clipBbox(d,r,a,o,l),d.baseTransform=Wt(d.ctx),d.executeOperatorList(this.operatorList),d.endDrawing(),(g=d.dependencyTracker)==null||g.restore(),h.restore(),c}_getCombinedScales(){const t=new Float32Array(2);B.singularValueDecompose2dScale(this.matrix,t);const[e,s]=t;return B.singularValueDecompose2dScale(this.baseTransform,t),[e*t[0],s*t[1]]}drawPattern(t,e,s=!1,[i,r],a){const[o,l,c,h]=this.bbox,d=t.dependencyTracker;if(d&&(t.dependencyTracker=new Zh(d,a)),t.save(),s?t.ctx.clip(e,"evenodd"):t.ctx.clip(e),t.ctx.setTransform(...this.patternBaseMatrix),t.ctx.translate(i*this.xstep,r*this.ystep),this.needsIsolation||t.ctx.globalAlpha!==1||t.ctx.globalCompositeOperation!=="source-over"||t.inSMaskMode){const f=c-o,g=h-l,[y,b]=this._getCombinedScales(),S=this.getSizeAndScale(f,this.ctx.canvas.width,y),w=this.getSizeAndScale(g,this.ctx.canvas.height,b),x=this._renderTileCanvas(t,a,S,w);t.ctx.drawImage(x.canvas,o,l,f,g),t.canvasFactory.destroy(x)}else this.setFillAndStrokeStyleToContext(t,this.paintType,this.color),this.clipBbox(t,o,l,c,h),t.baseTransformStack.push(t.baseTransform),t.baseTransform=Wt(t.ctx),t.executeOperatorList(this.operatorList),t.baseTransform=t.baseTransformStack.pop();t.restore(),d&&(t.dependencyTracker=d)}createPatternCanvas(t,e){const[s,i,r,a]=this.bbox,o=r-s,l=a-i;let{xstep:c,ystep:h}=this;c=Math.abs(c),h=Math.abs(h),Fp("TilingType: "+this.tilingType);const[d,f]=this._getCombinedScales();let g=o,y=l,b=!1,S=!1;Math.ceil(c*d)>=Math.ceil(o*d)?g=c:b=!0,Math.ceil(h*f)>=Math.ceil(l*f)?y=h:S=!0;const w=this.getSizeAndScale(g,this.ctx.canvas.width,d),x=this.getSizeAndScale(y,this.ctx.canvas.height,f),A=this._renderTileCanvas(t,e,w,x);if(b||S){const C=A.canvas;b&&(g=c),S&&(y=h);const _=this.getSizeAndScale(g,this.ctx.canvas.width,d),k=this.getSizeAndScale(y,this.ctx.canvas.height,f),I=_.size,L=k.size,P=t.canvasFactory.create(I,L),D=P.context,R=b?Math.floor(o/c):0,K=S?Math.floor(l/h):0;for(let W=0;W<=R;W++)for(let Q=0;Q<=K;Q++)D.drawImage(C,I*W,L*Q,I,L,0,0,I,L);return t.canvasFactory.destroy(A),{canvas:P.canvas,canvasEntry:P,scaleX:_.scale,scaleY:k.scale,offsetX:s,offsetY:i}}return{canvas:A.canvas,canvasEntry:A,scaleX:w.scale,scaleY:x.scale,offsetX:s,offsetY:i}}getSizeAndScale(t,e,s){const i=Math.max(mp.MAX_PATTERN_SIZE,e);let r=Math.ceil(t*s);return r>=i?r=i:s=r/t,{scale:s,size:r}}clipBbox(t,e,s,i,r){const a=i-e,o=r-s,l=new Path2D;l.rect(e,s,a,o),B.axialAlignedBoundingBox([e,s,i,r],Wt(t.ctx),t.current.minMax),t.ctx.clip(l),t.current.updateClipFromPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,r=t.current;switch(r.patternFill=r.patternStroke=!1,e){case Cv.COLORED:const{fillStyle:a,strokeStyle:o}=this.ctx;i.fillStyle=r.fillColor=a,i.strokeStyle=r.strokeColor=o;break;case Cv.UNCOLORED:i.fillStyle=i.strokeStyle=s,r.fillColor=r.strokeColor=s;break;default:throw new _S(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,i,r){const a=i!==We.SHADING?B.transform(s,this.patternBaseMatrix):s,o=this.createPatternCanvas(e,r);let l=new DOMMatrix(a);l=l.translate(o.offsetX,o.offsetY),l=l.scale(1/o.scaleX,1/o.scaleY);const c=t.createPattern(o.canvas,"repeat");return e.canvasFactory.destroy(o.canvasEntry),c.setTransform(l),c}};M(mp,"MAX_PATTERN_SIZE",3e3);let Xh=mp;const x1=16,E1=100,C1=15,_v=10,_s=16,Zp=new DOMMatrix,si=new Float32Array(2);function kv(u,t){if(u._removeMirroring)throw new Error("Context is already forwarding operations.");const e=new Map;for(const s of["save","restore","rotate","scale","translate","transform","setTransform","resetTransform","clip","moveTo","lineTo","bezierCurveTo","quadraticCurveTo","arc","arcTo","ellipse","rect","roundRect","closePath","beginPath"]){const i=u[s];typeof i!="function"||typeof t[s]!="function"||(e.set(s,i),u[s]=function(...r){return t[s](...r),i.apply(this,r)})}u._removeMirroring=()=>{for(const[s,i]of e)u[s]=i;delete u._removeMirroring}}function Qu(u,t,e,s,i,r,a,o,l,c){const[h,d,f,g,y,b]=Wt(u);if(d===0&&f===0){const x=a*h+y,A=Math.round(x),C=o*g+b,_=Math.round(C),k=(a+l)*h+y,I=Math.abs(Math.round(k)-A)||1,L=(o+c)*g+b,P=Math.abs(Math.round(L)-_)||1;return u.setTransform(Math.sign(h),0,0,Math.sign(g),A,_),u.drawImage(t,e,s,i,r,0,0,I,P),u.setTransform(h,d,f,g,y,b),[I,P]}if(h===0&&g===0){const x=o*f+y,A=Math.round(x),C=a*d+b,_=Math.round(C),k=(o+c)*f+y,I=Math.abs(Math.round(k)-A)||1,L=(a+l)*d+b,P=Math.abs(Math.round(L)-_)||1;return u.setTransform(0,Math.sign(d),Math.sign(f),0,A,_),u.drawImage(t,e,s,i,r,0,0,P,I),u.setTransform(h,d,f,g,y,b),[P,I]}u.drawImage(t,e,s,i,r,a,o,l,c);const S=Math.hypot(h,d),w=Math.hypot(f,g);return[S*l,w*c]}class Tv{constructor(t,e){M(this,"alphaIsShape",!1);M(this,"fontSize",0);M(this,"fontSizeScale",1);M(this,"textMatrix",null);M(this,"textMatrixScale",1);M(this,"fontMatrix",ng);M(this,"leading",0);M(this,"x",0);M(this,"y",0);M(this,"lineX",0);M(this,"lineY",0);M(this,"charSpacing",0);M(this,"wordSpacing",0);M(this,"textHScale",1);M(this,"textRenderingMode",xe.FILL);M(this,"textRise",0);M(this,"fillColor","#000000");M(this,"strokeColor","#000000");M(this,"tilingPatternDims",null);M(this,"patternFill",!1);M(this,"patternStroke",!1);M(this,"fillAlpha",1);M(this,"strokeAlpha",1);M(this,"lineWidth",1);M(this,"activeSMask",null);M(this,"transferMaps","none");M(this,"minMax",ja.slice());this.clipBox=new Float32Array([0,0,t,e])}clone(){var e;const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t.tilingPatternDims=(e=this.tilingPatternDims)==null?void 0:e.slice(),t}getPathBoundingBox(t=We.FILL,e=null){const s=this.minMax.slice();if(t===We.STROKE){e||Ct("Stroke bounding box must include transform."),B.singularValueDecompose2dScale(e,si);const i=si[0]*this.lineWidth/2,r=si[1]*this.lineWidth/2;s[0]-=i,s[1]-=r,s[2]+=i,s[3]+=r}return s}updateClipFromPath(){const t=B.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(ja,0)}getClippedPathBoundingBox(t=We.FILL,e=null){return B.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Pv(u,t){const{width:e,height:s,kind:i}=t,r=s%_s,a=(s-r)/_s,o=r===0?a:a+1,l=u.createImageData(e,_s);let c=0;const h=t.data,d=l.data;let f;if(i===rf.GRAYSCALE_1BPP)for(f=0;f<o;f++)({srcPos:c}=Jb({src:h,srcPos:c,dest:d,width:e,height:f<a?_s:r})),u.putImageData(l,0,f*_s);else if(i===rf.RGBA_32BPP){let g=0,y=e*_s*4;for(f=0;f<a;f++)d.set(h.subarray(c,c+y)),c+=y,u.putImageData(l,0,g),g+=_s;f<o&&(y=e*r*4,d.set(h.subarray(c,c+y)),u.putImageData(l,0,g))}else if(i===rf.RGB_24BPP)for(f=0;f<o;f++)({srcPos:c}=d1({src:h,srcPos:c,dest:new Uint32Array(d.buffer),width:e,height:f<a?_s:r})),u.putImageData(l,0,f*_s);else throw new Error(`bad image kind: ${i}`)}function Mv(u,t){if(t.bitmap){u.drawImage(t.bitmap,0,0);return}const{width:e,height:s}=t,i=s%_s,r=(s-i)/_s,a=i===0?r:r+1,o=u.createImageData(e,_s);let l=0;const c=t.data,h=o.data;for(let d=0;d<a;d++)({srcPos:l}=Jb({src:c,srcPos:l,dest:h,width:e,height:d<r?_s:i,nonBlackColor:0})),u.putImageData(o,0,d*_s)}function Oa(u,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)u[s]!==void 0&&(t[s]=u[s]);u.setLineDash!==void 0&&(t.setLineDash(u.getLineDash()),t.lineDashOffset=u.lineDashOffset)}function Ju(u){u.strokeStyle=u.fillStyle="#000000",u.fillRule="nonzero",u.globalAlpha=1,u.lineWidth=1,u.lineCap="butt",u.lineJoin="miter",u.miterLimit=10,u.globalCompositeOperation="source-over",u.font="10px sans-serif",u.setLineDash!==void 0&&(u.setLineDash([]),u.lineDashOffset=0);const{filter:t}=u;t!=="none"&&t!==""&&(u.filter="none")}function Iv(u,t){if(t)return!0;B.singularValueDecompose2dScale(u,si);const e=Math.fround(En.pixelRatio*ka.PDF_TO_CSS_UNITS);return si[0]<=e&&si[1]<=e}const _1=["butt","round","square"],k1=["miter","round","bevel"],T1={},Dv={};var Us,Jr,_o,ko,To,Po,Mo,Io,Do,cn,Z,Rg,Ng,Bg,$g,Ug,ms,Ke,Hg,ty,bf;const tv=class tv{constructor(t,e,s,i,r,{optionalContentConfig:a,markedContentStack:o=null},l,c,h,d){m(this,Z);m(this,Us,0);m(this,Jr,0);m(this,_o,null);m(this,ko,null);m(this,To,null);m(this,Po,null);m(this,Mo,1);m(this,Io);m(this,Do,null);m(this,cn,[]);this.ctx=t,this.current=new Tv(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=e,this.objs=s,this.canvasFactory=i,this.filterFactory=r,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.tempSMask=null,this.smaskGroupCanvases=[],this.smaskPreparedEntry=null,this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=a,this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=c,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=h??null,this.imagesTracker=d??null}getObject(t,e,s=null){var i;return typeof e=="string"?((i=this.dependencyTracker)==null||i.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):s}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const r=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,r,a),this.ctx.fillStyle=o,s){const l=this.transparentCanvasEntry=this.canvasFactory.create(r,a);this.compositeCtx=this.ctx,{canvas:this.transparentCanvas,context:this.ctx}=l,this.ctx.save(),this.ctx.transform(...Wt(this.compositeCtx))}this.ctx.save(),Ju(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[3]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=Wt(this.ctx)}executeOperatorList(t,e,s,i,r){var w;const a=t.argsArray,o=t.fnArray;let l=e||0;const c=a.length;if(c===l)return l;const h=c-l>_v&&typeof s=="function",d=h?Date.now()+C1:0;let f=0;const g=this.commonObjs,y=this.objs;let b,S;for(;;){if(i!==void 0){if(l===i.nextBreakPoint)return i.breakIt(l,s),l;if(i.shouldSkip(l)){if(++l===c)return l;continue}}if(!r||r(l))if(b=o[l],S=a[l]??null,b!==Ki.dependency)S===null?this[b](l):this[b](l,...S);else for(const x of S){(w=this.dependencyTracker)==null||w.recordNamedData(x,l);const A=x.startsWith("g_")?g:y;if(!A.has(x))return A.get(x,s),l}if(l++,l===c)return l;if(h&&++f>_v){if(Date.now()>d)return s(),l;f=0}}}endDrawing(){v(this,Z,Rg).call(this);for(const t of this.smaskGroupCanvases)this.canvasFactory.destroy(t);this.smaskGroupCanvases.length=0,this._clearPreparedSMask(),this.tempSMask=null,this.smaskStack.length=0;for(const t of n(this,cn))v(this,Z,bf).call(this,t);n(this,cn).length=0,p(this,_o,null),p(this,ko,null),p(this,To,null),p(this,Po,null),p(this,Mo,1),p(this,Do,null),p(this,Jr,0),p(this,Us,0),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),v(this,Z,Ng).call(this)}_scaleImage(t,e){const s=t.width??t.displayWidth,i=t.height??t.displayHeight,r=Math.max(Math.hypot(e[0],e[1]),1),a=Math.max(Math.hypot(e[2],e[3]),1),o=[];let l=r,c=a,h=s,d=i;for(;l>2&&h>1||c>2&&d>1;){let w=h,x=d;l>2&&h>1&&(w=Math.ceil(h/2),l/=h/w),c>2&&d>1&&(x=Math.ceil(d/2),c/=d/x),o.push({newWidth:w,newHeight:x}),h=w,d=x}if(o.length===0)return{img:t,paintWidth:s,paintHeight:i,tmpCanvas:null};if(o.length===1){const{newWidth:w,newHeight:x}=o[0],A=this.canvasFactory.create(w,x);return A.context.drawImage(t,0,0,s,i,0,0,w,x),{img:A.canvas,paintWidth:w,paintHeight:x,tmpCanvas:A}}let f=this.canvasFactory.create(1,1),g=this.canvasFactory.create(1,1),y=s,b=i,S=t;for(const{newWidth:w,newHeight:x}of o)this.canvasFactory.reset(g,w,x),g.context.drawImage(S,0,0,y,b,0,0,w,x),[f,g]=[g,f],S=f.canvas,y=w,b=x;return this.canvasFactory.destroy(g),{img:f.canvas,paintWidth:y,paintHeight:b,tmpCanvas:f}}_createMaskCanvas(t,e){var R,K;const s=this.ctx,{width:i,height:r}=e,a=this.current.fillColor,o=this.current.patternFill,l=Wt(s);let c,h,d,f;if((e.bitmap||e.data)&&e.count>1){const W=e.bitmap||e.data.buffer;h=JSON.stringify(o?l:[l.slice(0,4),a]),c=this._cachedBitmapsMap.getOrInsertComputed(W,Hm);const Q=c.get(h);if(Q&&!o){const ht=Math.round(Math.min(l[0],l[2])+l[4]),T=Math.round(Math.min(l[1],l[3])+l[5]);return(R=this.dependencyTracker)==null||R.recordDependencies(t,oi.transformAndFill),{canvas:Q,offsetX:ht,offsetY:T}}d=Q}d||(f=this.canvasFactory.create(i,r),Mv(f.context,e));let g=B.transform(l,[1/i,0,0,-1/r,0,0]);g=B.transform(g,[1,0,0,1,0,-r]);const y=ja.slice();B.axialAlignedBoundingBox([0,0,i,r],g,y);const[b,S,w,x]=y,A=Math.round(w-b)||1,C=Math.round(x-S)||1,_=this.canvasFactory.create(A,C),k=_.context,I=b,L=S;k.translate(-I,-L),k.transform(...g);let P=null;if(!d){const W=this._scaleImage(f.canvas,Xi(k));d=W.img,P=W.tmpCanvas,d!==f.canvas&&(this.canvasFactory.destroy(f),f=null),c&&o&&(c.set(h,d),P=null,f=null)}k.imageSmoothingEnabled=Iv(Wt(k),e.interpolate),Qu(k,d,0,0,d.width,d.height,0,0,i,r),P&&this.canvasFactory.destroy(P),f&&this.canvasFactory.destroy(f),k.globalCompositeOperation="source-in";const D=B.transform(Xi(k),[1,0,0,1,-I,-L]);return k.fillStyle=o?a.getPattern(s,this,D,We.FILL,t):a,k.fillRect(0,0,i,r),c&&!o&&c.set(h,_.canvas),(K=this.dependencyTracker)==null||K.recordDependencies(t,oi.transformAndFill),{canvas:_.canvas,canvasEntry:c&&!o?null:_,offsetX:Math.round(I),offsetY:Math.round(L)}}setLineWidth(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineCap",t),this.ctx.lineCap=_1[e]}setLineJoin(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineJoin",t),this.ctx.lineJoin=k1[e]}setMiterLimit(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,s){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("dash",t);const i=this.ctx;i.setLineDash!==void 0&&(i.setLineDash(e),i.lineDashOffset=s)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){var s,i,r,a,o;for(const[l,c]of e)switch(l){case"LW":this.setLineWidth(t,c);break;case"LC":this.setLineCap(t,c);break;case"LJ":this.setLineJoin(t,c);break;case"ML":this.setMiterLimit(t,c);break;case"D":this.setDash(t,c[0],c[1]);break;case"RI":this.setRenderingIntent(t,c);break;case"FL":this.setFlatness(t,c);break;case"Font":this.setFont(t,c[0],c[1]);break;case"CA":(s=this.dependencyTracker)==null||s.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=c;break;case"ca":(i=this.dependencyTracker)==null||i.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=c;break;case"BM":(r=this.dependencyTracker)==null||r.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=c;break;case"SMask":(a=this.dependencyTracker)==null||a.recordSimpleData("SMask",t),this.current.activeSMask=c?this.tempSMask:null,this.current.activeSMask&&(this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation),this.tempSMask=null,this.checkSMaskState(t);break;case"TR":(o=this.dependencyTracker)==null||o.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(c);break}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){this.smaskPreparedEntry&&(this.canvasFactory.destroy(this.smaskPreparedEntry),this.smaskPreparedEntry=null),this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null}_ensurePreparedSMask(t){t!==this.smaskPreparedFor&&(this._clearPreparedSMask(),this._prepareSMaskCanvas(t))}checkSMaskState(t){const e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode(t):!this.current.activeSMask&&e?this.endSMaskMode():this.current.activeSMask&&e&&this._ensurePreparedSMask(this.current.activeSMask)}_prepareSMaskCanvas(t){const{canvas:e,subtype:s,backdrop:i,transferMap:r}=t,a=s==="Luminosity"||s==="Alpha"&&r;if(!a&&!(s==="Luminosity"&&i)){this.smaskPreparedFor=t;return}let o;if(s==="Luminosity"&&i){const[x,A,C]=ju(i),_=Math.round(.3*x+.59*A+.11*C);o=(r==null?void 0:r[_])??_}else o=(r==null?void 0:r[0])??0;const l=4,{width:c,height:h}=this.ctx.canvas,d=e.width*e.height,f=c*h<l*d,g=a?{url:s==="Alpha"?this.filterFactory.addAlphaFilter(r):this.filterFactory.addLuminosityFilter(r),subtype:s,transferMap:r}:null,y=s==="Luminosity"?i:null;let b,S,w;f?(b=this._bakeSMaskCanvas(e,t.offsetX,t.offsetY,c,h,y,g),S=0,w=0):(b=this._bakeSMaskCanvas(e,0,0,e.width,e.height,y,g),S=t.offsetX,w=t.offsetY),this.smaskPreparedEntry=b,this.smaskPreparedFor=t,this.smaskPreparedOffsetX=S,this.smaskPreparedOffsetY=w,this.smaskPreparedOOBAlpha=!f&&o!==0?o:null}_bakeSMaskCanvas(t,e,s,i,r,a,o){!a&&!o&&Ct("_bakeSMaskCanvas with neither backdrop nor filter");const l=this.canvasFactory.create(i,r),c=l.context;if(c.drawImage(t,e,s),a&&(c.globalCompositeOperation="destination-atop",c.fillStyle=a,c.fillRect(0,0,i,r)),!o)return l;const h=this.canvasFactory.create(i,r),d=h.context;d.filter=o.url;const f=$t.isCanvasFilterSupported&&d.filter!=="none"&&d.filter!=="";if(d.drawImage(l.canvas,0,0),$t.isCanvasFilterSupported&&(d.filter="none"),!f){const g=d.getImageData(0,0,i,r),{data:y}=g,{transferMap:b}=o;if(o.subtype==="Luminosity")for(let S=0,w=y.length;S<w;S+=4){const x=.3*y[S]+.59*y[S+1]+.11*y[S+2]+.5|0;y[S]=y[S+1]=y[S+2]=0,y[S+3]=(b==null?void 0:b[x])??x}else for(let S=3,w=y.length;S<w;S+=4)y[S]=b[y[S]];d.putImageData(g,0,0)}return this.canvasFactory.destroy(l),h}beginSMaskMode(t){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const{width:e,height:s}=this.ctx.canvas,i=this.canvasFactory.create(e,s);this.smaskScratchCanvas=i,this.suspendedCtx=this.ctx;const r=this.ctx=i.context;r.setTransform(this.suspendedCtx.getTransform()),Oa(this.suspendedCtx,r),kv(r,this.suspendedCtx),this._ensurePreparedSMask(this.current.activeSMask),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Oa(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null,this.canvasFactory.destroy(this.smaskScratchCanvas),this.smaskScratchCanvas=null,this._clearPreparedSMask()}compose(t){if(!this.current.activeSMask)return;t=t?[Math.floor(t[0]),Math.floor(t[1]),Math.ceil(t[2]),Math.ceil(t[3])]:[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,s=this.suspendedCtx,i=n(this,Jr)>0&&s===this.ctx;this.composeSMask(i?null:s,e,this.ctx,t),!i&&(this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore())}composeSMask(t,e,s,i){const r=i[0],a=i[1],o=i[2]-r,l=i[3]-a;if(o===0||l===0)return;const c=this.smaskPreparedEntry;if(c){let h=r,d=a,f=o,g=l;const y=this.smaskPreparedOOBAlpha,b=y!==null;if(b){h=Math.max(r,e.offsetX),d=Math.max(a,e.offsetY);const S=Math.min(r+o,e.offsetX+e.canvas.width),w=Math.min(a+l,e.offsetY+e.canvas.height);f=S-h,g=w-d}if(f>0&&g>0){const S=h-this.smaskPreparedOffsetX,w=d-this.smaskPreparedOffsetY;s.save(),s.globalAlpha=1,s.setTransform(1,0,0,1,0,0);const x=new Path2D;x.rect(h,d,f,g),s.clip(x),s.globalCompositeOperation="destination-in",s.drawImage(c.canvas,S,w,f,g,h,d,f,g),s.restore()}b&&y<255&&this._applySMaskOOBAlpha(s,r,a,o,l,h,d,h+f,d+g,y)}else this.genericComposeSMask(e,s,o,l,r,a);t&&(t.save(),t.globalAlpha=1,t.globalCompositeOperation=e.blendMode||"source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,r,a,o,l,r,a,o,l),t.restore())}_applySMaskOOBAlpha(t,e,s,i,r,a,o,l,c,h){const d=a<l&&o<c;if(d&&a===e&&o===s&&l===e+i&&c===s+r)return;const f=new Path2D;f.rect(e,s,i,r),d&&f.rect(a,o,l-a,c-o),t.save(),t.globalAlpha=h/255,t.setTransform(1,0,0,1,0,0),t.clip(f,"evenodd"),t.globalCompositeOperation="destination-in",t.fillStyle="#000000",t.fillRect(e,s,i,r),t.restore()}genericComposeSMask(t,e,s,i,r,a){const{context:o,offsetX:l,offsetY:c}=t;e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const h=new Path2D;h.rect(r,a,s,i),e.clip(h),e.globalCompositeOperation="destination-in",e.drawImage(o.canvas,r-l,a-c,s,i,r,a,s,i),e.restore()}save(t){var s;this.inSMaskMode&&Oa(this.ctx,this.suspendedCtx),this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone(),(s=this.dependencyTracker)==null||s.save(t)}restore(t){var e;if((e=this.dependencyTracker)==null||e.restore(t),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&(Oa(this.suspendedCtx,this.ctx),this.ctx.setTransform(this.suspendedCtx.getTransform())),this.checkSMaskState(t),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,s,i,r,a,o){var l;(l=this.dependencyTracker)==null||l.recordIncrementalData("transform",t),this.ctx.transform(e,s,i,r,a,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s,i){let[r]=s;if(!i){r||(r=s[0]=new Path2D),e!==Ki.stroke&&e!==Ki.closeStroke&&(this.current.tilingPatternDims=null),this[e](t,r);return}if(this.dependencyTracker!==null){const o=e===Ki.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,i[0]-o,i[2]+o,i[1]-o,i[3]+o).recordDependencies(t,["transform"])}r instanceof Path2D||(r=s[0]=nb(r)),B.axialAlignedBoundingBox(i,Wt(this.ctx),this.current.minMax);const a=this.current.tilingPatternDims;if(a&&e!==Ki.stroke&&e!==Ki.closeStroke&&this.current.fillColor instanceof Xh){const o=B.intersect(this.current.clipBox,this.current.minMax);o?this.current.fillColor.updatePatternDims(o,a):this.current.tilingPatternDims=null}this[e](t,r),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,s=!0){var o;const i=s&&v(this,Z,ms).call(this,this.current.strokeAlpha),r=this.ctx,a=this.current.strokeColor;if(r.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof a=="object"&&(a!=null&&a.getPattern)){const l=a.isModifyingCurrentTransform()?r.getTransform():null;if(r.save(),r.strokeStyle=a.getPattern(r,this,Xi(r),We.STROKE,t),l){const c=new Path2D;c.addPath(e,r.getTransform().invertSelf().multiplySelf(l)),e=c}this.rescaleAndStroke(e,!1),r.restore()}else this.rescaleAndStroke(e,!0);(o=this.dependencyTracker)==null||o.recordDependencies(t,oi.stroke),s&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(We.STROKE,Wt(this.ctx))),r.globalAlpha=this.current.fillAlpha,v(this,Z,Ke).call(this,i)}closeStroke(t,e){this.stroke(t,e)}fill(t,e,s=!0){var h,d,f;const i=s&&v(this,Z,ms).call(this,this.current.fillAlpha),r=this.ctx,a=this.current.fillColor,o=this.current.patternFill;let l=!1;const c=this.current.getClippedPathBoundingBox();if((h=this.dependencyTracker)==null||h.recordDependencies(t,oi.fill),o){const g=this.current.tilingPatternDims,y=g&&a.canSkipPatternCanvas(g);if(y){a.drawPattern(this,e,this.pendingEOFill,y,t),this.pendingEOFill=!1,s&&this.consumePath(t,e,c),this.current.tilingPatternDims=null,v(this,Z,Ke).call(this,i);return}const b=a.isModifyingCurrentTransform()?r.getTransform():null;if((d=this.dependencyTracker)==null||d.save(t),r.save(),r.fillStyle=a.getPattern(r,this,Xi(r),We.FILL,t),b){const S=new Path2D;S.addPath(e,r.getTransform().invertSelf().multiplySelf(b)),e=S}l=!0}this.contentVisible&&c!==null&&(this.pendingEOFill?(r.fill(e,"evenodd"),this.pendingEOFill=!1):r.fill(e)),l&&(r.restore(),(f=this.dependencyTracker)==null||f.restore(t)),s&&this.consumePath(t,e,c),v(this,Z,Ke).call(this,i)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){const s=v(this,Z,ms).call(this,Math.min(this.current.fillAlpha,this.current.strokeAlpha));this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e),v(this,Z,Ke).call(this,s)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){var i;const s=v(this,Z,ms).call(this,this.current.fillAlpha);this.ctx.fill(e),(i=this.dependencyTracker)==null||i.recordDependencies(t,oi.rawFillPath).recordOperation(t),v(this,Z,Ke).call(this,s)}clip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=T1}eoClip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=Dv}beginText(t){var e;this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,(e=this.dependencyTracker)==null||e.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){const e=this.pendingTextPaths,s=this.ctx;if(this.dependencyTracker){const{dependencyTracker:i}=this;e!==void 0&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(e!==void 0){const i=new Path2D,r=s.getTransform().invertSelf();for(const{transform:a,x:o,y:l,fontSize:c,path:h}of e)h&&i.addPath(h,new DOMMatrix(a).preMultiplySelf(r).translate(o,l).scale(c,-c));s.clip(i)}delete this.pendingTextPaths}setCharSpacing(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,s){var d,f;(d=this.dependencyTracker)==null||d.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);const i=this.commonObjs.get(e),r=this.current;if(!i)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=i.fontMatrix||ng,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&lt("Invalid font matrix for font "+e),s<0?(s=-s,r.fontDirection=-1):r.fontDirection=1,this.current.font=i,this.current.fontSize=s,i.isType3Font)return;const a=i.loadedName||"sans-serif",o=((f=i.systemFontInfo)==null?void 0:f.css)||`"${a}", ${i.fallbackName}`;let l="normal";i.black?l="900":i.bold&&(l="bold");const c=i.italic?"italic":"normal",h=Qt(s,x1,E1);this.current.fontSizeScale=s/h,this.ctx.font=`${c} ${l} ${h}px ${o}`}setTextRenderingMode(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,s){var i;(i=this.dependencyTracker)==null||i.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=s}setLeadingMoveText(t,e,s){this.setLeading(t,-s),this.moveText(t,e,s)}setTextMatrix(t,e){var i;(i=this.dependencyTracker)==null||i.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);const{current:s}=this;s.textMatrix=e,s.textMatrixScale=Math.hypot(e[0],e[1]),s.x=s.lineX=0,s.y=s.lineY=0}nextLine(t){var e;this.moveText(t,0,this.current.leading),(e=this.dependencyTracker)==null||e.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}paintChar(t,e,s,i,r,a){var w,x,A,C;const o=this.ctx,l=this.current,c=l.font,h=l.textRenderingMode,d=l.fontSize/l.fontSizeScale,f=h&xe.FILL_STROKE_MASK,g=!!(h&xe.ADD_TO_PATH_FLAG),y=l.patternFill&&!c.missingFile,b=l.patternStroke&&!c.missingFile;let S;if((c.disableFontFace||g||y||b)&&!c.missingFile&&(S=c.getPathGenerator(this.commonObjs,e)),S&&(c.disableFontFace||y||b)){o.save(),o.translate(s,i),o.scale(d,-d),(w=this.dependencyTracker)==null||w.recordCharacterBBox(t,o,c);let _;if(f===xe.FILL||f===xe.FILL_STROKE)if(r){_=o.getTransform(),o.setTransform(...r);const k=v(this,Z,Hg).call(this,S,_,r);o.fill(k)}else o.fill(S);if(f===xe.STROKE||f===xe.FILL_STROKE)if(a){_||(_=o.getTransform()),o.setTransform(...a);const{a:k,b:I,c:L,d:P}=_,D=B.inverseTransform(a),R=B.transform([k,I,L,P,0,0],D);B.singularValueDecompose2dScale(R,si),o.lineWidth*=Math.max(si[0],si[1])/d,o.stroke(v(this,Z,Hg).call(this,S,_,a))}else o.lineWidth/=d,o.stroke(S);o.restore()}else(f===xe.FILL||f===xe.FILL_STROKE)&&(o.fillText(e,s,i),(x=this.dependencyTracker)==null||x.recordCharacterBBox(t,o,c,d,s,i,()=>o.measureText(e))),(f===xe.STROKE||f===xe.FILL_STROKE)&&(this.dependencyTracker&&((A=this.dependencyTracker)==null||A.recordCharacterBBox(t,o,c,d,s,i,()=>o.measureText(e)).recordDependencies(t,oi.stroke)),o.strokeText(e,s,i));g&&((this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Wt(o),x:s,y:i,fontSize:d,path:S}),(C=this.dependencyTracker)==null||C.recordCharacterBBox(t,o,c,d,s,i))}get isFontSubpixelAAEnabled(){const t=this.canvasFactory.create(10,10),e=t.context;e.scale(1.5,1),e.fillText("I",0,10);const s=e.getImageData(0,0,10,10).data;this.canvasFactory.destroy(t);let i=!1;for(let r=3;r<s.length;r+=4)if(s[r]>0&&s[r]<255){i=!0;break}return at(this,"isFontSubpixelAAEnabled",i)}showText(t,e){var K,W,Q,ht;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,oi.showText).resetBBox(t),this.current.textRenderingMode&xe.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const s=this.current,i=s.font;if(i.isType3Font){const T=v(this,Z,ms).call(this,s.fillAlpha);this.showType3Text(t,e),(K=this.dependencyTracker)==null||K.recordShowTextOperation(t),v(this,Z,Ke).call(this,T);return}const r=s.fontSize;if(r===0){(W=this.dependencyTracker)==null||W.recordOperation(t);return}const a=v(this,Z,ms).call(this,s.fillAlpha),o=this.ctx,l=s.fontSizeScale,c=s.charSpacing,h=s.wordSpacing,d=s.fontDirection,f=s.textHScale*d,g=e.length,y=i.vertical,b=y?1:-1,S=i.defaultVMetrics,w=r*s.fontMatrix[0],x=s.textRenderingMode===xe.FILL&&!i.disableFontFace&&!s.patternFill;o.save(),s.textMatrix&&o.transform(...s.textMatrix),o.translate(s.x,s.y+s.textRise),d>0?o.scale(f,-1):o.scale(f,1);let A,C;const _=s.textRenderingMode&xe.FILL_STROKE_MASK,k=_===xe.FILL||_===xe.FILL_STROKE,I=_===xe.STROKE||_===xe.FILL_STROKE;let L=s.lineWidth;const P=s.textMatrixScale;if(P===0||L===0?I&&(L=this.getSinglePixelWidth()):L/=P,l!==1&&(o.scale(l,l),L/=l),o.lineWidth=L,k&&s.patternFill){o.save();const T=s.fillColor.getPattern(o,this,Xi(o),We.FILL,t);A=Wt(o),o.restore(),o.fillStyle=T}if(I&&s.patternStroke){o.save();const T=s.strokeColor.getPattern(o,this,Xi(o),We.STROKE,t);C=Wt(o),o.restore(),o.strokeStyle=T}if(i.isInvalidPDFjsFont){const T=[];let q=0;for(const mt of e)T.push(mt.unicode),q+=mt.width;const Lt=T.join("");if(o.fillText(Lt,0,0),this.dependencyTracker!==null){const mt=o.measureText(Lt);this.dependencyTracker.recordBBox(t,this.ctx,-mt.actualBoundingBoxLeft,mt.actualBoundingBoxRight,-mt.actualBoundingBoxAscent,mt.actualBoundingBoxDescent).recordShowTextOperation(t)}s.x+=q*w*f,o.restore(),this.compose(),v(this,Z,Ke).call(this,a);return}let D=0,R;for(R=0;R<g;++R){const T=e[R];if(typeof T=="number"){D+=b*T*r/1e3;continue}let q=!1;const Lt=(T.isSpace?h:0)+c,mt=T.fontChar,_e=T.accent;let re,Gt,V=T.width;if(y){const ct=T.vmetric||S,J=-(T.vmetric?ct[1]:V*.5)*w,ae=ct[2]*w;V=ct?-ct[0]:V,re=J/l,Gt=(D+ae)/l}else re=D/l,Gt=0;let $;if(i.remeasure&&V>0){$=o.measureText(mt);const ct=$.width*1e3/r*l;if(V<ct&&this.isFontSubpixelAAEnabled){const J=V/ct;q=!0,o.save(),o.scale(J,1),re/=J}else V!==ct&&(re+=(V-ct)/2e3*r/l)}if(this.contentVisible&&(T.isInFont||i.missingFile)){if(x&&!_e)o.fillText(mt,re,Gt),(Q=this.dependencyTracker)==null||Q.recordCharacterBBox(t,o,$?{bbox:null}:i,r/l,re,Gt,()=>$??o.measureText(mt));else if(this.paintChar(t,mt,re,Gt,A,C),_e){const ct=re+r*_e.offset.x/l,J=Gt-r*_e.offset.y/l;this.paintChar(t,_e.fontChar,ct,J,A,C)}}const Et=y?V*w-Lt*d:V*w+Lt*d;D+=Et,q&&o.restore()}y?s.y-=D:s.x+=D*f,o.restore(),this.compose(),(ht=this.dependencyTracker)==null||ht.recordShowTextOperation(t),v(this,Z,Ke).call(this,a)}showType3Text(t,e){const s=this.ctx,i=this.current,r=i.font,a=i.fontSize,o=i.fontDirection,l=r.vertical?1:-1,c=i.charSpacing,h=i.wordSpacing,d=i.textHScale*o,f=i.fontMatrix||ng,g=e.length,y=i.textRenderingMode===xe.INVISIBLE;let b,S,w,x;if(y||a===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,s.save(),i.textMatrix&&s.transform(...i.textMatrix),s.translate(i.x,i.y+i.textRise),s.scale(d,o);const A=this.dependencyTracker;for(this.dependencyTracker=A?new Zh(A,t):null,b=0;b<g;++b){if(S=e[b],typeof S=="number"){x=l*S*a/1e3,this.ctx.translate(x,0),i.x+=x*d;continue}const C=(S.isSpace?h:0)+c,_=r.charProcOperatorList[S.operatorListId];_?this.contentVisible&&(this.save(),_.fnArray[0]===Ki.setCharWidth&&(i.fillAlpha=i.strokeAlpha=1,s.globalAlpha=1),s.scale(a,a),s.transform(...f),this.executeOperatorList(_),this.restore()):lt(`Type3 character "${S.operatorListId}" is not available.`);const k=[S.width,0];B.applyTransform(k,f),w=k[0]*a+C,s.translate(w,0),i.x+=w*d}s.restore(),A&&(this.dependencyTracker=A)}setCharWidth(t,e,s){}setCharWidthAndBounds(t,e,s,i,r,a,o){var c;const l=new Path2D;l.rect(i,r,a-i,o-r),this.ctx.clip(l),(c=this.dependencyTracker)==null||c.recordBBox(t,this.ctx,i,a,r,o).recordClipBox(t,this.ctx,i,a,r,o),this.endPath(t)}getColorN_Pattern(t,e){let s;if(e[0]==="TilingPattern"){const i=this.baseTransform||Wt(this.ctx),r={createCanvasGraphics:(a,o)=>new tv(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new Zh(this.dependencyTracker,o,!0):null)};s=new Xh(e,this.ctx,r,i)}else s=this._getPattern(t,e[1],e[2]);return s}setStrokeColorN(t,...e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("fillColor",t);const s=this.current.fillColor=this.getColorN_Pattern(t,e);this.current.patternFill=!0,this.current.tilingPatternDims=s instanceof Xh?[0,0,0,0]:null}setStrokeRGBColor(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}setStrokeTransparent(t){var e;(e=this.dependencyTracker)==null||e.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1,this.current.tilingPatternDims=null}setFillTransparent(t){var e;(e=this.dependencyTracker)==null||e.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1,this.current.tilingPatternDims=null}_getPattern(t,e,s=null){let i;return this.cachedPatterns.has(e)?i=this.cachedPatterns.get(e):(i=S1(this.getObject(t,e)),this.cachedPatterns.set(e,i)),s&&(i.matrix=s),i}shadingFill(t,e){var o;if(!this.contentVisible)return;const s=v(this,Z,ms).call(this,this.current.fillAlpha),i=this.ctx;this.save(t);const r=this._getPattern(t,e);i.fillStyle=r.getPattern(i,this,Xi(i),We.SHADING,t);const a=Xi(i);if(a){const{width:l,height:c}=i.canvas,h=ja.slice();B.axialAlignedBoundingBox([0,0,l,c],a,h);const[d,f,g,y]=h;this.ctx.fillRect(d,f,g-d,y-f)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);(o=this.dependencyTracker)==null||o.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,oi.transform).recordDependencies(t,oi.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t),v(this,Z,Ke).call(this,s)}beginInlineImage(){Ct("Should not call beginInlineImage")}beginImageData(){Ct("Should not call beginImageData")}paintFormXObjectBegin(t,e,s){var i;if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=Wt(this.ctx),s)){B.axialAlignedBoundingBox(s,this.baseTransform,this.current.minMax);const[r,a,o,l]=s,c=new Path2D;c.rect(r,a,o-r,l-a),this.ctx.clip(c),(i=this.dependencyTracker)==null||i.recordClipBox(t,this.ctx,r,o,a,l),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){var x;if(!this.contentVisible)return;this.save(t);const{inSMaskMode:s}=this;s&&(this.endSMaskMode(),this.current.activeSMask=null);const i=this.ctx;if((!e.needsIsolation||!e.isolated&&!e.hasSoftMask)&&!e.knockout&&!e.isGray&&n(this,Us)===0&&i.globalAlpha===1&&i.globalCompositeOperation==="source-over"&&!s){if(e.bbox){let A=new Path2D;const[C,_,k,I]=e.bbox;if(A.rect(C,_,k-C,I-_),e.matrix){const L=new Path2D;L.addPath(A,new DOMMatrix(e.matrix)),A=L}i.clip(A)}this.groupStack.push(null),n(this,cn).push(null),this.groupLevel++;return}!e.isolated&&!e.knockout&&n(this,Us)===0&&Fp("TODO: Fully support non-isolated non-knockout groups.");const r=Wt(i);e.matrix&&i.transform(...e.matrix);const a=[0,0,i.canvas.width,i.canvas.height];let o;e.bbox?(o=ja.slice(),B.axialAlignedBoundingBox(e.bbox,Wt(i),o),o=B.intersect(o,a)||[0,0,0,0]):o=a;const l=Math.floor(o[0]),c=Math.floor(o[1]),h=Math.max(Math.ceil(o[2])-l,1),d=Math.max(Math.ceil(o[3])-c,1);this.current.startNewPathAndClipBox([0,0,h,d]);const f=this.canvasFactory.create(h,d);e.smask&&this.smaskGroupCanvases.push(f);const g=f.context,y=e.knockout&&!e.isolated?i:null,b=!e.isolated&&!e.knockout&&!e.smask&&e.needsIsolation&&n(this,Us)>0,S=e.knockout?this.canvasFactory.create(h,d):null,w=n(this,Us);if(e.knockout?qt(this,Us)._++:p(this,Us,0),g.translate(-l,-c),g.transform(...r),!e.isolated&&!e.smask&&s&&e.needsIsolation&&(g.save(),g.setTransform(1,0,0,1,0,0),g.drawImage(i.canvas,-l,-c),g.restore()),e.bbox){let A=new Path2D;const[C,_,k,I]=e.bbox;if(A.rect(C,_,k-C,I-_),e.matrix){const L=new Path2D;L.addPath(A,new DOMMatrix(e.matrix)),A=L}g.clip(A)}e.smask&&this.smaskStack.push({canvas:f.canvas,context:g,offsetX:l,offsetY:c,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null}),(!e.smask||this.dependencyTracker)&&(i.setTransform(1,0,0,1,0,0),i.translate(l,c),i.save()),Oa(i,g),this.ctx=g,(x=this.dependencyTracker)==null||x.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(i),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(i),n(this,cn).push({backdropCtx:y,savedKnockoutLevel:w,offsetX:l,offsetY:c,hasInnerBackdrop:b,knockoutMaskEntry:S,knockoutTempEntry:null,knockoutBackdropEntry:null}),this.groupLevel++}endGroup(t,e){var a;if(!this.contentVisible)return;this.groupLevel--;const s=this.ctx,i=this.groupStack.pop(),r=n(this,cn).pop();if(r&&p(this,Us,r.savedKnockoutLevel),i===null){this.restore(t);return}if(e.isGray&&v(this,Z,ty).call(this,s),this.ctx=i,this.ctx.imageSmoothingEnabled=!1,(a=this.dependencyTracker)==null||a.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&(this.ctx.restore(),this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform())),v(this,Z,bf).call(this,r);else{this.ctx.restore();const o=Wt(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...o);const l=ja.slice();B.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],o,l);const c=n(this,cn).at(-1);if(n(this,Us)>0)if(r.hasInnerBackdrop){const{width:h,height:d}=s.canvas,f=this.canvasFactory.create(h,d),g=f.context;g.drawImage(i.canvas,r.offsetX,r.offsetY,h,d,0,0,h,d),g.globalCompositeOperation="source-over",g.drawImage(s.canvas,0,0);const y=v(this,Z,Bg).call(this,s.canvas);g.globalCompositeOperation="destination-in",g.drawImage(y.canvas,0,0);const b=this.ctx.globalCompositeOperation,S=this.ctx.globalAlpha,w=this.ctx.filter;this.ctx.save(),this.ctx.setTransform(...o),this.ctx.globalAlpha=1,$t.isCanvasFilterSupported&&(this.ctx.filter="none"),this.ctx.globalCompositeOperation="destination-out",this.ctx.drawImage(y.canvas,0,0),this.ctx.globalCompositeOperation=b,this.ctx.globalAlpha=S,$t.isCanvasFilterSupported&&(this.ctx.filter=w??"none"),this.ctx.drawImage(f.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(y),this.canvasFactory.destroy(f)}else{const h=(c==null?void 0:c.backdropCtx)??null;v(this,Z,Ug).call(this,this.ctx,s.canvas,{backdropCanvas:(h==null?void 0:h.canvas)??null,destTransform:o,backdropOffset:h?[c.offsetX+r.offsetX,c.offsetY+r.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}else this.ctx.drawImage(s.canvas,0,0);this.ctx.restore(),this.canvasFactory.destroy({canvas:s.canvas,context:s}),v(this,Z,bf).call(this,r),this.compose(l)}}beginAnnotation(t,e,s,i,r,a,o){if(v(this,Z,Rg).call(this),Ju(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),s){const l=s[2]-s[0],c=s[3]-s[1];if(a&&this.annotationCanvasMap){i=i.slice(),i[4]-=s[0],i[5]-=s[1],s=s.slice(),s[0]=s[1]=0,s[2]=l,s[3]=c,B.singularValueDecompose2dScale(Wt(this.ctx),si);const{viewportScale:h}=this,d=Math.ceil(l*this.outputScaleX*h),f=Math.ceil(c*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(d,f);const{canvas:g,context:y}=this.annotationCanvas;if(o){const b=this.annotationCanvasMap.getOrInsertComputed(e,Vu);g.setAttribute("data-canvas-name",o);const S=b.findIndex(w=>w.getAttribute("data-canvas-name")===o);S===-1?b.push(g):b[S]=g}else this.annotationCanvasMap.set(e,g);this.annotationCanvas.savedCtx=this.ctx,this.ctx=y,this.ctx.save(),this.ctx.setTransform(si[0],0,0,-si[1],0,c*si[1]),Ju(this.ctx)}else{Ju(this.ctx),this.endPath(t);const h=new Path2D;h.rect(s[0],s[1],l,c),this.ctx.clip(h)}}this.current=new Tv(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(t,...i),this.transform(t,...r),this.baseTransform=Wt(this.ctx)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),v(this,Z,Ng).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas),this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(t,e){var l;if(!this.contentVisible)return;const s=e.count;e=this.getObject(t,e.data,e),e.count=s;const i=v(this,Z,ms).call(this,this.current.fillAlpha),r=this.ctx,a=this._createMaskCanvas(t,e),o=a.canvas;r.save(),r.setTransform(1,0,0,1,0,0),r.drawImage(o,a.offsetX,a.offsetY),(l=this.dependencyTracker)==null||l.resetBBox(t).recordBBox(t,this.ctx,a.offsetX,a.offsetX+o.width,a.offsetY,a.offsetY+o.height).recordOperation(t),r.restore(),a.canvasEntry&&this.canvasFactory.destroy(a.canvasEntry),this.compose(),v(this,Z,Ke).call(this,i)}paintImageMaskXObjectRepeat(t,e,s,i=0,r=0,a,o){var f,g,y;if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const l=v(this,Z,ms).call(this,this.current.fillAlpha),c=this.ctx;c.save();const h=Wt(c);c.transform(s,i,r,a,0,0);const d=this._createMaskCanvas(t,e);c.setTransform(1,0,0,1,d.offsetX-h[4],d.offsetY-h[5]),(f=this.dependencyTracker)==null||f.resetBBox(t);for(let b=0,S=o.length;b<S;b+=2){const w=B.transform(h,[s,i,r,a,o[b],o[b+1]]);c.drawImage(d.canvas,w[4],w[5]),(g=this.dependencyTracker)==null||g.recordBBox(t,this.ctx,w[4],w[4]+d.canvas.width,w[5],w[5]+d.canvas.height)}c.restore(),d.canvasEntry&&this.canvasFactory.destroy(d.canvasEntry),this.compose(),(y=this.dependencyTracker)==null||y.recordOperation(t),v(this,Z,Ke).call(this,l)}paintImageMaskXObjectGroup(t,e){var o,l,c;if(!this.contentVisible)return;const s=v(this,Z,ms).call(this,this.current.fillAlpha),i=this.ctx,r=this.current.fillColor,a=this.current.patternFill;(o=this.dependencyTracker)==null||o.resetBBox(t).recordDependencies(t,oi.transformAndFill);for(const h of e){const{data:d,width:f,height:g,transform:y}=h,b=this.canvasFactory.create(f,g),S=b.context;S.save();const w=this.getObject(t,d,h);Mv(S,w),S.globalCompositeOperation="source-in",S.fillStyle=a?r.getPattern(S,this,Xi(i),We.FILL,t):r,S.fillRect(0,0,f,g),S.restore(),i.save(),i.transform(...y),i.scale(1,-1),Qu(i,b.canvas,0,0,f,g,0,-1,1,1),this.canvasFactory.destroy(b),(l=this.dependencyTracker)==null||l.recordBBox(t,i,0,f,0,g),i.restore()}this.compose(),(c=this.dependencyTracker)==null||c.recordOperation(t),v(this,Z,Ke).call(this,s)}paintImageXObject(t,e){if(!this.contentVisible)return;const s=this.getObject(t,e);if(!s){lt("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t,s)}paintImageXObjectRepeat(t,e,s,i,r){if(!this.contentVisible)return;const a=this.getObject(t,e);if(!a){lt("Dependent image isn't ready yet");return}const o=a.width,l=a.height,c=[];for(let h=0,d=r.length;h<d;h+=2)c.push({transform:[s,0,0,i,r[h],r[h+1]],x:0,y:0,w:o,h:l});this.paintInlineImageXObjectGroup(t,a,c)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return{img:t.bitmap,canvasEntry:null};const{bitmap:e,width:s,height:i}=t,r=this.canvasFactory.create(s,i),a=r.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",{img:r.canvas,canvasEntry:r}}paintInlineImageXObject(t,e){var d;if(!this.contentVisible)return;const s=e.width,i=e.height,r=v(this,Z,ms).call(this,this.current.fillAlpha),a=this.ctx;this.save(t);const{filter:o}=a;o!=="none"&&o!==""&&(a.filter="none"),a.scale(1/s,-1/i);let l,c=null;if(e.bitmap){const f=this.applyTransferMapsToBitmap(e);l=f.img,c=f.canvasEntry}else{const f=this.canvasFactory.create(s,i);Pv(f.context,e),l=this.applyTransferMapsToCanvas(f.context),c=f}const h=this._scaleImage(l,Xi(a));a.imageSmoothingEnabled=Iv(Wt(a),e.interpolate),this.dependencyTracker&&(this.dependencyTracker.resetBBox(t).recordBBox(t,a,0,s,-i,0).recordDependencies(t,oi.imageXObject).recordOperation(t),(d=this.imagesTracker)==null||d.record(a,s,i,this.dependencyTracker.clipBox)),Qu(a,h.img,0,0,h.paintWidth,h.paintHeight,0,-i,s,i),h.tmpCanvas&&this.canvasFactory.destroy(h.tmpCanvas),c&&this.canvasFactory.destroy(c),this.compose(),this.restore(t),v(this,Z,Ke).call(this,r)}paintInlineImageXObjectGroup(t,e,s){var l,c,h;if(!this.contentVisible)return;const i=v(this,Z,ms).call(this,this.current.fillAlpha),r=this.ctx;let a,o=null;if(e.bitmap)a=e.bitmap;else{const d=e.width,f=e.height,g=this.canvasFactory.create(d,f);Pv(g.context,e),a=this.applyTransferMapsToCanvas(g.context),o=g}(l=this.dependencyTracker)==null||l.resetBBox(t);for(const d of s)r.save(),r.transform(...d.transform),r.scale(1,-1),Qu(r,a,d.x,d.y,d.w,d.h,0,-1,1,1),(c=this.dependencyTracker)==null||c.recordBBox(t,r,0,1,-1,0),r.restore();o&&this.canvasFactory.destroy(o),(h=this.dependencyTracker)==null||h.recordOperation(t),this.compose(),v(this,Z,Ke).call(this,i)}paintSolidColorImageMask(t){var s;if(!this.contentVisible)return;const e=v(this,Z,ms).call(this,this.current.fillAlpha);(s=this.dependencyTracker)==null||s.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,oi.fill).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose(),v(this,Z,Ke).call(this,e)}markPoint(t,e){}markPointProps(t,e,s){}beginMarkedContent(t,e){var s;(s=this.dependencyTracker)==null||s.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,s){var i;(i=this.dependencyTracker)==null||i.beginMarkedContent(t),e==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(s)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){var e;(e=this.dependencyTracker)==null||e.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,s){var a,o;const i=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(s);const r=this.ctx;this.pendingClip?(i||(this.pendingClip===Dv?r.clip(e,"evenodd"):r.clip(e)),this.pendingClip=null,(a=this.dependencyTracker)==null||a.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):(o=this.dependencyTracker)==null||o.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Wt(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,i)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:s,c:i,d:r}=this.ctx.getTransform();let a,o;if(s===0&&i===0){const l=Math.abs(e),c=Math.abs(r);if(l===c)if(t===0)a=o=1/l;else{const h=l*t;a=o=h<1?1/h:1}else if(t===0)a=1/l,o=1/c;else{const h=l*t,d=c*t;a=h<1?1/h:1,o=d<1?1/d:1}}else{const l=Math.abs(e*r-s*i),c=Math.hypot(e,s),h=Math.hypot(i,r);if(t===0)a=h/l,o=c/l;else{const d=t*l;a=h>d?h/d:1,o=c>d?c/d:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:s,current:{lineWidth:i}}=this,[r,a]=this.getScaleForStroking();if(r===a){s.lineWidth=(i||1)*r,s.stroke(t);return}const o=s.getLineDash();e&&s.save(),s.scale(r,a),Zp.a=1/r,Zp.d=1/a;const l=new Path2D;if(l.addPath(t,Zp),o.length>0){const c=Math.max(r,a);s.setLineDash(o.map(h=>h/c)),s.lineDashOffset/=c}s.lineWidth=i||1,s.stroke(l),e&&s.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};Us=new WeakMap,Jr=new WeakMap,_o=new WeakMap,ko=new WeakMap,To=new WeakMap,Po=new WeakMap,Mo=new WeakMap,Io=new WeakMap,Do=new WeakMap,cn=new WeakMap,Z=new WeakSet,Rg=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(this.transparentCanvasEntry),this.transparentCanvas=null,this.transparentCanvasEntry=null)},Ng=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}},Bg=function(t,e=null,s=1){const{width:i,height:r}=t,a=e??this.canvasFactory.create(i,r),o=a.context;s=Math.round(s*255)/255;const l=s<1;l&&n(this,Io)===void 0&&p(this,Io,$t.isCanvasFilterSupported?new Map:"none");let c="none";if(l&&n(this,Io)instanceof Map&&(c=n(this,Io).getOrInsertComputed(s,()=>this.filterFactory.addKnockoutFilter(s))),!l||c!=="none")return e&&(o.save(),o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,i,r),o.restore()),o.filter=c,o.drawImage(t,0,0),o.filter="none",a;const h=t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,i,r),d=o.createImageData(i,r),f=h.data,g=d.data,y=s>0?1/s:1e6;for(let b=3,S=f.length;b<S;b+=4)g[b]=Math.min(Math.round(f[b]*y),255);return o.putImageData(d,0,0),a},$g=function(t,e,s,i){let r=(t==null?void 0:t[e])??null;if(r&&(r.canvas.width!==s||r.canvas.height!==i)&&(this.canvasFactory.destroy(r),r=null),!r)return r=this.canvasFactory.create(s,i),t&&(t[e]=r),r;const a=r.context;return a.save(),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,s,i),a.restore(),r},Ug=function(t,e,s={}){const{backdropCanvas:i=null,destTransform:r=[1,0,0,1,0,0],backdropOffset:a=[0,0],reuseMaskEntry:o=null,poolMeta:l=null,sourceAlpha:c=1,sourceFilter:h="none",knockoutAlpha:d=1}=s,{width:f,height:g}=e,y=v(this,Z,Bg).call(this,e,o,d),b=t.globalCompositeOperation;if(t.save(),t.setTransform(...r),t.globalAlpha=1,$t.isCanvasFilterSupported&&(t.filter="none"),t.globalCompositeOperation="destination-out",t.drawImage(y.canvas,0,0),i){const[S,w]=a,x=v(this,Z,$g).call(this,l,"knockoutBackdropEntry",f,g),A=x.context;A.drawImage(i,S,w,f,g,0,0,f,g),A.globalCompositeOperation="destination-in",A.drawImage(y.canvas,0,0),A.globalCompositeOperation="source-over",t.globalCompositeOperation="destination-over",t.drawImage(x.canvas,0,0),l||this.canvasFactory.destroy(x)}t.globalCompositeOperation=b,t.globalAlpha=c,$t.isCanvasFilterSupported&&(t.filter=h??"none"),t.drawImage(e,0,0),t.restore(),o||this.canvasFactory.destroy(y)},ms=function(t=1){if(n(this,Us)===0||n(this,Jr)>0||!this.contentVisible)return!1;qt(this,Jr)._++,p(this,Mo,t);const e=n(this,cn).at(-1),{canvas:s}=this.ctx,i=v(this,Z,$g).call(this,e,"knockoutTempEntry",s.width,s.height);p(this,_o,i);const r=i.context;return r.save(),r.setTransform(this.ctx.getTransform()),Oa(this.ctx,r),p(this,Po,r.globalCompositeOperation),r.globalCompositeOperation="source-over",kv(r,this.ctx),p(this,Do,e),p(this,ko,this.ctx),p(this,To,this.suspendedCtx),this.ctx=r,this.inSMaskMode&&(this.suspendedCtx=r),!0},Ke=function(t){var l;if(!t)return;const e=n(this,_o),s=n(this,ko),i=n(this,To),r=e.context;p(this,_o,null),p(this,ko,null),p(this,To,null),this.inSMaskMode&&this.suspendedCtx===r&&this.ctx!==r&&this.endSMaskMode(),this.inSMaskMode&&(this.suspendedCtx=i),this.ctx._removeMirroring(),this.ctx.globalCompositeOperation=n(this,Po),p(this,Po,null),Oa(this.ctx,s),this.ctx=s;const a=n(this,Do);p(this,Do,null);const o=n(this,Mo);p(this,Mo,1);try{v(this,Z,Ug).call(this,i??s,e.canvas,{backdropCanvas:((l=a==null?void 0:a.backdropCtx)==null?void 0:l.canvas)??null,backdropOffset:a!=null&&a.backdropCtx?[a.offsetX,a.offsetY]:[0,0],reuseMaskEntry:(a==null?void 0:a.knockoutMaskEntry)??null,poolMeta:a,knockoutAlpha:o})}finally{r.restore(),qt(this,Jr)._--,a||this.canvasFactory.destroy(e)}},Hg=function(t,e,s){const i=new Path2D;return i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),i},ty=function(t){const{canvas:e}=t,{width:s,height:i}=e;if($t.isCanvasFilterSupported){t.save(),t.setTransform(1,0,0,1,0,0),t.filter="grayscale(1)",t.globalAlpha=1,t.globalCompositeOperation="copy",t.drawImage(e,0,0),t.restore();return}const r=t.getImageData(0,0,s,i),{data:a}=r;for(let o=0,l=a.length;o<l;o+=4){const c=a[o]*.2126+a[o+1]*.7152+a[o+2]*.0722+.5|0;a[o]=a[o+1]=a[o+2]=c}t.putImageData(r,0,0)},bf=function(t){t&&(t.knockoutMaskEntry&&(this.canvasFactory.destroy(t.knockoutMaskEntry),t.knockoutMaskEntry=null),t.knockoutTempEntry&&(this.canvasFactory.destroy(t.knockoutTempEntry),t.knockoutTempEntry=null),t.knockoutBackdropEntry&&(this.canvasFactory.destroy(t.knockoutBackdropEntry),t.knockoutBackdropEntry=null))};let Hl=tv;for(const u in Ki)Hl.prototype[u]!==void 0&&(Hl.prototype[Ki[u]]=Hl.prototype[u]);var Ld,Fd;class Bp{constructor(t,e,s){m(this,Ld,null);m(this,Fd,null);M(this,"_fullReader",null);M(this,"_rangeReaders",new Set);M(this,"_source",null);this._source=t,p(this,Ld,e),p(this,Fd,s)}get _progressiveDataLength(){var t;return((t=this._fullReader)==null?void 0:t._loaded)??0}getFullReader(){return ne(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new(n(this,Ld))(this)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new(n(this,Fd))(this,t,e);return this._rangeReaders.add(s),s}cancelAllRequests(t){var e;(e=this._fullReader)==null||e.cancel(t);for(const s of new Set(this._rangeReaders))s.cancel(t)}}Ld=new WeakMap,Fd=new WeakMap;class $p{constructor(t){M(this,"onProgress",null);M(this,"_contentLength",0);M(this,"_filename",null);M(this,"_headersCapability",Promise.withResolvers());M(this,"_isRangeSupported",!1);M(this,"_isStreamingSupported",!1);M(this,"_loaded",0);M(this,"_stream",null);this._stream=t}_callOnProgress(){var t;(t=this.onProgress)==null||t.call(this,{loaded:this._loaded,total:this._contentLength})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){Ct("Abstract method `read` called")}cancel(t){Ct("Abstract method `cancel` called")}}class Up{constructor(t,e,s){M(this,"_stream",null);this._stream=t}async read(){Ct("Abstract method `read` called")}cancel(t){Ct("Abstract method `cancel` called")}}function P1(u){let t=!0,e=s("filename\\*","i").exec(u);if(e){e=e[1];let h=o(e);return h=unescape(h),h=l(h),h=c(h),r(h)}if(e=a(u),e){const h=c(e);return r(h)}if(e=s("filename","i").exec(u),e){e=e[1];let h=o(e);return h=c(h),r(h)}function s(h,d){return new RegExp("(?:^|;)\\s*"+h+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function i(h,d){if(h){if(!/^[\x00-\xFF]+$/.test(d))return d;try{const f=new TextDecoder(h,{fatal:!0}),g=Op(d);d=f.decode(g),t=!1}catch{}}return d}function r(h){return t&&/[\x80-\xff]/.test(h)&&(h=i("utf-8",h),t&&(h=i("iso-8859-1",h))),h}function a(h){const d=[];let f;const g=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(f=g.exec(h))!==null;){let[,b,S,w]=f;if(b=parseInt(b,10),b in d){if(b===0)break;continue}d[b]=[S,w]}const y=[];for(let b=0;b<d.length&&b in d;++b){let[S,w]=d[b];w=o(w),S&&(w=unescape(w),b===0&&(w=l(w))),y.push(w)}return y.join("")}function o(h){if(h.startsWith('"')){const d=h.slice(1).split('\\"');for(let f=0;f<d.length;++f){const g=d[f].indexOf('"');g!==-1&&(d[f]=d[f].slice(0,g),d.length=f+1),d[f]=d[f].replaceAll(/\\(.)/g,"$1")}h=d.join('"')}return h}function l(h){const d=h.indexOf("'");if(d===-1)return h;const f=h.slice(0,d),y=h.slice(d+1).replace(/^[^']*'/,"");return i(f,y)}function c(h){return!h.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(h)?h:h.replaceAll(/=\?([\w-]*)\?([QB])\?((?:[^?]|\?(?!=))*)\?=/gi,function(d,f,g,y){if(g==="q"||g==="Q")return y=y.replaceAll("_"," "),y=y.replaceAll(/=([0-9a-f]{2})/gi,function(b,S){return String.fromCharCode(parseInt(S,16))}),i(f,y);try{y=atob(y)}catch{}return i(f,y)})}return""}function ey(u,t){const e=new Headers;if(!u||!t||typeof t!="object")return e;for(const s in t){const i=t[s];i!==void 0&&e.append(s,i)}return e}function Hp(u){var t;return((t=URL.parse(u))==null?void 0:t.origin)??null}function sy({responseHeaders:u,isHttp:t,rangeChunkSize:e,disableRange:s}){const i={contentLength:0,isRangeSupported:!1},r=parseInt(u.get("Content-Length"),10);return!Number.isInteger(r)||(i.contentLength=r,r<=2*e)||s||!t||u.get("Accept-Ranges")!=="bytes"||(u.get("Content-Encoding")||"identity")==="identity"&&(i.isRangeSupported=!0),i}function iy(u){const t=u.get("Content-Disposition");if(t){let e=P1(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Gm(e))return e}return null}function zp(u,t){return new Xf(`Unexpected server response (${u}) while retrieving PDF "${t.href}".`,u,u===404||u===0&&t.protocol==="file:")}function ny(u,t){if(u!==t)throw new Error(`Expected range response-origin "${u}" to match "${t}".`)}function ry(u,t,e,s){return fetch(u,{method:"GET",headers:t,signal:s.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"})}function ay(u,t){if(u!==200&&u!==206)throw zp(u,t)}function Vp(u){if(u instanceof Uint8Array)return u.buffer;if(u instanceof ArrayBuffer)return u;throw new Error(`getArrayBuffer - unexpected data: ${u}`)}class M1 extends Bp{constructor(e){super(e,I1,D1);M(this,"_responseOrigin",null);const{httpHeaders:s,url:i}=e;ne(/https?:/.test(i.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=ey(!0,s)}}class I1 extends $p{constructor(e){super(e);M(this,"_abortController",new AbortController);M(this,"_reader",null);const{disableRange:s,disableStream:i,rangeChunkSize:r,url:a,withCredentials:o}=e._source;this._isStreamingSupported=!i;const l=new Headers(e.headers);ry(a,l,o,this._abortController).then(c=>{e._responseOrigin=Hp(c.url),ay(c.status,a),this._reader=c.body.getReader();const h=c.headers,{contentLength:d,isRangeSupported:f}=sy({responseHeaders:h,isHttp:!0,rangeChunkSize:r,disableRange:s});this._contentLength=d,this._isRangeSupported=f,this._filename=iy(h),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new _a("Streaming is disabled.")),this._headersCapability.resolve()}).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:(this._loaded+=e.byteLength,this._callOnProgress(),{value:Vp(e),done:!1})}cancel(e){var s;(s=this._reader)==null||s.cancel(e),this._abortController.abort()}}class D1 extends Up{constructor(e,s,i){super(e,s,i);M(this,"_abortController",new AbortController);M(this,"_readCapability",Promise.withResolvers());M(this,"_reader",null);const{url:r,withCredentials:a}=e._source,o=new Headers(e.headers);o.append("Range",`bytes=${s}-${i-1}`),ry(r,o,a,this._abortController).then(l=>{const c=Hp(l.url);ny(c,e._responseOrigin),ay(l.status,r),this._reader=l.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:{value:Vp(e),done:!1}}cancel(e){var s;(s=this._reader)==null||s.cancel(e),this._abortController.abort()}}function Lv(u){return u instanceof Uint8Array&&u.byteLength===u.buffer.byteLength?u.buffer:new Uint8Array(u).buffer}function Gp(){for(const u of this._requests)u.resolve({value:void 0,done:!0});this._requests.length=0}var vp,oy;class L1 extends Bp{constructor(e){super(e,F1,O1);m(this,vp);M(this,"_progressiveDone",!1);M(this,"_queuedChunks",[]);const{pdfDataRangeTransport:s}=e,{initialData:i,progressiveDone:r}=s;if((i==null?void 0:i.length)>0){const o=Lv(i);this._queuedChunks.push(o)}this._progressiveDone=r;const a=o=>{var l;switch(o.type){case"range":case"progressiveRead":v(this,vp,oy).call(this,o.begin,o.chunk);break;case"progressiveDone":(l=this._fullReader)==null||l.progressiveDone(),this._progressiveDone=!0;break}};s.transportReady(a)}getFullReader(){const e=super.getFullReader();return this._queuedChunks=null,e}getRangeReader(e,s){const i=super.getRangeReader(e,s);return i&&(i.onDone=()=>this._rangeReaders.delete(i),this._source.pdfDataRangeTransport.requestDataRange(e,s)),i}cancelAllRequests(e){super.cancelAllRequests(e),this._source.pdfDataRangeTransport.abort()}}vp=new WeakSet,oy=function(e,s){const i=Lv(s);if(e===void 0)this._fullReader?this._fullReader._enqueue(i):this._queuedChunks.push(i);else{const r=this._rangeReaders.keys().find(a=>a._begin===e);ne(r,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),r._enqueue(i)}};var Od;class F1 extends $p{constructor(e){super(e);m(this,Od,Gp.bind(this));M(this,"_done",!1);M(this,"_queuedChunks",null);M(this,"_requests",[]);const{pdfDataRangeTransport:s,disableRange:i,disableStream:r}=e._source,{length:a,contentDispositionFilename:o}=s;this._queuedChunks=e._queuedChunks||[];for(const c of this._queuedChunks)this._loaded+=c.byteLength;this._done=e._progressiveDone,this._contentLength=a,this._isStreamingSupported=!r,this._isRangeSupported=!i,Gm(o)&&(this._filename=o),this._headersCapability.resolve();const l=this._loaded;Promise.resolve().then(()=>{l>0&&this._loaded===l&&this._callOnProgress()})}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength,this._callOnProgress())}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,n(this,Od).call(this)}progressiveDone(){this._done||(this._done=!0),this._queuedChunks.length===0&&n(this,Od).call(this)}}Od=new WeakMap;var Rd;class O1 extends Up{constructor(e,s,i){super(e,s,i);m(this,Rd,Gp.bind(this));M(this,"onDone",null);M(this,"_begin",-1);M(this,"_done",!1);M(this,"_queuedChunk",null);M(this,"_requests",[]);this._begin=s}_enqueue(e){var s;this._done||(this._requests.length===0?this._queuedChunk=e:(this._requests.shift().resolve({value:e,done:!1}),n(this,Rd).call(this)),this._done=!0,(s=this.onDone)==null||s.call(this))}async read(){if(this._queuedChunk){const s=this._queuedChunk;return this._queuedChunk=null,{value:s,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){var s;this._done=!0,n(this,Rd).call(this),(s=this.onDone)==null||s.call(this)}}Rd=new WeakMap;const tg=200,Fv=206;function R1(u){return typeof u!="string"?u:Op(u).buffer}var hn,vh,ly,cy;class N1 extends Bp{constructor(e){super(e,B1,$1);m(this,vh);m(this,hn,new WeakMap);M(this,"_responseOrigin",null);const{httpHeaders:s,url:i}=e;this.url=i,this.isHttp=/https?:/.test(i.protocol),this.headers=ey(this.isHttp,s)}_request(e){const s=new XMLHttpRequest,i={validateStatus:null,onHeadersReceived:e.onHeadersReceived,onDone:e.onDone,onError:e.onError,onProgress:e.onProgress};n(this,hn).set(s,i),s.open("GET",this.url),s.withCredentials=this._source.withCredentials;for(const[r,a]of this.headers)s.setRequestHeader(r,a);return this.isHttp&&"begin"in e&&"end"in e?(s.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),i.validateStatus=r=>r===Fv||r===tg):i.validateStatus=r=>r===tg,s.responseType="arraybuffer",ne(e.onError,"Expected `onError` callback to be provided."),s.onerror=()=>e.onError(s.status),s.onreadystatechange=v(this,vh,cy).bind(this,s),s.onprogress=v(this,vh,ly).bind(this,s),s.send(null),s}_abortRequest(e){n(this,hn).has(e)&&(n(this,hn).delete(e),e.abort())}getRangeReader(e,s){const i=super.getRangeReader(e,s);return i&&(i.onClosed=()=>this._rangeReaders.delete(i)),i}}hn=new WeakMap,vh=new WeakSet,ly=function(e,s){var r;const i=n(this,hn).get(e);(r=i==null?void 0:i.onProgress)==null||r.call(i,s)},cy=function(e,s){const i=n(this,hn).get(e);if(!i||(e.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),e.readyState!==4)||!n(this,hn).has(e))return;if(n(this,hn).delete(e),e.status===0&&this.isHttp){i.onError(e.status);return}const r=e.status||tg;if(!i.validateStatus(r)){i.onError(e.status);return}const a=R1(e.response);if(r===Fv){const o=e.getResponseHeader("Content-Range");/bytes \d+-\d+\/\d+/.test(o)?i.onDone(a):(lt('Missing or invalid "Content-Range" header.'),i.onError(0))}else a?i.onDone(a):i.onError(e.status)};var Nd,Cn,hy,dy,uy,fy;class B1 extends $p{constructor(e){super(e);m(this,Cn);m(this,Nd,Gp.bind(this));M(this,"_cachedChunks",[]);M(this,"_done",!1);M(this,"_requests",[]);M(this,"_storedError",null);this._fullRequestXhr=e._request({onHeadersReceived:v(this,Cn,hy).bind(this),onDone:v(this,Cn,dy).bind(this),onError:v(this,Cn,uy).bind(this),onProgress:v(this,Cn,fy).bind(this)})}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._headersCapability.reject(e),n(this,Nd).call(this),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}Nd=new WeakMap,Cn=new WeakSet,hy=function(){const e=this._stream,{disableRange:s,rangeChunkSize:i}=e._source,r=this._fullRequestXhr;e._responseOrigin=Hp(r.responseURL);const a=r.getAllResponseHeaders(),o=new Headers(a?a.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(h=>{const[d,...f]=h.split(": ");return[d,f.join(": ")]}):[]),{contentLength:l,isRangeSupported:c}=sy({responseHeaders:o,isHttp:e.isHttp,rangeChunkSize:i,disableRange:s});this._contentLength=l,this._isRangeSupported=c,this._filename=iy(o),this._isRangeSupported&&e._abortRequest(r),this._headersCapability.resolve()},dy=function(e){this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._cachedChunks.push(e),this._done=!0,this._cachedChunks.length===0&&n(this,Nd).call(this)},uy=function(e){this._storedError=zp(e,this._stream.url),this._headersCapability.reject(this._storedError);for(const s of this._requests)s.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0},fy=function(e){var s;(s=this.onProgress)==null||s.call(this,{loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})};var Bd,wr,py,gy,zg;class $1 extends Up{constructor(e,s,i){super(e,s,i);m(this,wr);m(this,Bd,Gp.bind(this));M(this,"onClosed",null);M(this,"_done",!1);M(this,"_queuedChunk",null);M(this,"_requests",[]);M(this,"_storedError",null);this._requestXhr=e._request({begin:s,end:i,onHeadersReceived:v(this,wr,py).bind(this),onDone:v(this,wr,gy).bind(this),onError:v(this,wr,zg).bind(this),onProgress:null})}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const s=this._queuedChunk;return this._queuedChunk=null,{value:s,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){var s;this._done=!0,n(this,Bd).call(this),this._stream._abortRequest(this._requestXhr),(s=this.onClosed)==null||s.call(this)}}Bd=new WeakMap,wr=new WeakSet,py=function(){var s;const e=Hp((s=this._requestXhr)==null?void 0:s.responseURL);try{ny(e,this._stream._responseOrigin)}catch(i){this._storedError=i,v(this,wr,zg).call(this,0)}},gy=function(e){var s;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0,n(this,Bd).call(this),(s=this.onClosed)==null||s.call(this)},zg=function(e){this._storedError??(this._storedError=zp(e,this._stream.url));for(const s of this._requests)s.reject(this._storedError);this._requests.length=0,this._queuedChunk=null};function my(u,t=null){const e=process.getBuiltinModule("fs"),{Readable:s}=process.getBuiltinModule("stream"),i=e.createReadStream(u,t);return s.toWeb(i)}class U1 extends Bp{constructor(t){super(t,H1,z1);const{url:e}=t;ne(e.protocol==="file:","PDFNodeStream only supports file:// URLs.")}}class H1 extends $p{constructor(e){super(e);M(this,"_reader",null);const{disableRange:s,disableStream:i,rangeChunkSize:r,url:a}=e._source;this._isStreamingSupported=!i,process.getBuiltinModule("fs/promises").lstat(a).then(l=>{const c=my(a);this._reader=c.getReader();const{size:h}=l;this._contentLength=h,this._isRangeSupported=!s&&h>2*r,!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new _a("Streaming is disabled.")),this._headersCapability.resolve()}).catch(l=>{l.code==="ENOENT"&&(l=zp(0,a)),this._headersCapability.reject(l)})}async read(){await this._headersCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:(this._loaded+=e.byteLength,this._callOnProgress(),{value:Vp(e),done:!1})}cancel(e){var s;(s=this._reader)==null||s.cancel(e)}}class z1 extends Up{constructor(e,s,i){super(e,s,i);M(this,"_readCapability",Promise.withResolvers());M(this,"_reader",null);const{url:r}=e._source;try{const a=my(r,{start:s,end:i-1});this._reader=a.getReader(),this._readCapability.resolve()}catch(a){this._readCapability.reject(a)}}async read(){await this._readCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:{value:Vp(e),done:!1}}cancel(e){var s;(s=this._reader)==null||s.cancel(e)}}function V1(u){return Wh(u)?M1:ei?U1:N1}var $d,Ud;class Sn{static get workerPort(){return n(this,$d)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");p(this,$d,t)}static get workerSrc(){return n(this,Ud)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");p(this,Ud,t)}}$d=new WeakMap,Ud=new WeakMap,m(Sn,$d,null),m(Sn,Ud,"");var Ac,Hd;class G1{constructor({parsedData:t,rawData:e}){m(this,Ac);m(this,Hd);p(this,Ac,t),p(this,Hd,e)}getRaw(){return n(this,Hd)}get(t){return n(this,Ac).get(t)??null}[Symbol.iterator](){return n(this,Ac).entries()}}Ac=new WeakMap,Hd=new WeakMap;const Ba=Symbol("INTERNAL");var zd,Vd,Sc,Lo;class j1{constructor(t,{name:e,intent:s,usage:i,rbGroups:r}){m(this,zd,!1);m(this,Vd,!1);m(this,Sc,!1);m(this,Lo,!0);p(this,zd,!!(t&ti.DISPLAY)),p(this,Vd,!!(t&ti.PRINT)),this.name=e,this.intent=s,this.usage=i,this.rbGroups=r}get visible(){if(n(this,Sc))return n(this,Lo);if(!n(this,Lo))return!1;const{print:t,view:e}=this.usage;return n(this,zd)?(e==null?void 0:e.viewState)!=="OFF":n(this,Vd)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==Ba&&Ct("Internal method `_setVisible` called."),p(this,Sc,s),p(this,Lo,e)}get serializable(){return{userSet:n(this,Sc),visible:n(this,Lo)}}}zd=new WeakMap,Vd=new WeakMap,Sc=new WeakMap,Lo=new WeakMap;var Zr,kt,xc,Ec,Gd,jd,Gg;const ev=class ev{constructor(t,e=ti.DISPLAY,s=null){m(this,jd);m(this,Zr,null);m(this,kt,new Map);m(this,xc,null);m(this,Ec,null);m(this,Gd);M(this,"creator",null);M(this,"name",null);if(p(this,Gd,t),this.renderingIntent=e,t!==null){this.name=t.name,this.creator=t.creator,p(this,Ec,t.order);for(const i of t.groups)n(this,kt).set(i.id,new j1(e,i));if(s){s.size!==n(this,kt).size&&Ct("Incorrect serialized groupState.");for(const[i,r]of s)n(this,kt).get(i)._setVisible(Ba,r.visible,r.userSet)}else{if(t.baseState==="OFF")for(const i of n(this,kt).values())i._setVisible(Ba,!1);for(const i of t.on)n(this,kt).get(i)._setVisible(Ba,!0);for(const i of t.off)n(this,kt).get(i)._setVisible(Ba,!1)}p(this,xc,this.getHash())}}isVisible(t){if(n(this,kt).size===0)return!0;if(!t)return Fp("Optional content group not defined."),!0;if(t.type==="OCG")return n(this,kt).has(t.id)?n(this,kt).get(t.id).visible:(lt(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return v(this,jd,Gg).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!n(this,kt).has(e))return lt(`Optional content group not found: ${e}`),!0;if(n(this,kt).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!n(this,kt).has(e))return lt(`Optional content group not found: ${e}`),!0;if(!n(this,kt).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!n(this,kt).has(e))return lt(`Optional content group not found: ${e}`),!0;if(!n(this,kt).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!n(this,kt).has(e))return lt(`Optional content group not found: ${e}`),!0;if(n(this,kt).get(e).visible)return!1}return!0}return lt(`Unknown optional content policy ${t.policy}.`),!0}return lt(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){var r;const i=n(this,kt).get(t);if(!i){lt(`Optional content group not found: ${t}`);return}if(s&&e&&i.rbGroups.length)for(const a of i.rbGroups)for(const o of a)o!==t&&((r=n(this,kt).get(o))==null||r._setVisible(Ba,!1,!0));i._setVisible(Ba,!!e,!0),p(this,Zr,null)}setOCGState({state:t,preserveRB:e}){let s;for(const i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const r=n(this,kt).get(i);if(r)switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!r.visible,e);break}}p(this,Zr,null)}get hasInitialVisibility(){return n(this,xc)===null||this.getHash()===n(this,xc)}getOrder(){return n(this,kt).size?n(this,Ec)?n(this,Ec).slice():[...n(this,kt).keys()]:null}getGroup(t){return n(this,kt).get(t)||null}getHash(){if(n(this,Zr)!==null)return n(this,Zr);const t=new Tg;for(const[e,s]of n(this,kt))t.update(`${e}:${s.visible}`);return p(this,Zr,t.hexdigest())}[Symbol.iterator](){return n(this,kt).entries()}get serializable(){const t=new Map;for(const[e,s]of n(this,kt))t.set(e,s.serializable);return{data:n(this,Gd),renderingIntent:this.renderingIntent,groupState:t}}static fromSerializable({data:t,renderingIntent:e,groupState:s}){return new ev(t,e,s)}};Zr=new WeakMap,kt=new WeakMap,xc=new WeakMap,Ec=new WeakMap,Gd=new WeakMap,jd=new WeakSet,Gg=function(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const r=t[i];let a;if(Array.isArray(r))a=v(this,jd,Gg).call(this,r);else if(n(this,kt).has(r))a=n(this,kt).get(r).visible;else return lt(`Optional content group not found: ${r}`),!0;switch(s){case"And":if(!a)return!1;break;case"Or":if(a)return!0;break;case"Not":return!a;default:return!0}}return s==="And"};let Vg=ev;var ge,Ni,ze,Fo,dn,is,Rh,Nh,yf;class W1{constructor(){m(this,is);m(this,ge,null);m(this,Ni,null);m(this,ze,0);m(this,Fo,null);m(this,dn,null)}get pagesNumber(){return n(this,ze)}set pagesNumber(t){n(this,ze)!==t&&(p(this,ze,t),p(this,ge,null),p(this,Ni,null))}movePages(t,e,s){v(this,is,Rh).call(this);const i=n(this,ge),r=v(this,is,Nh).call(this),a=e.length,o=new Uint32Array(a);let l=0;for(let f=0;f<a;f++){const g=e[f]-1;o[f]=i[g],g<s&&l++}const c=n(this,ze),h=c-a,d=Qt(s-l,0,h);for(let f=0,g=0;f<c;f++)t.has(f+1)||(i[g++]=i[f]);i.copyWithin(d+a,d,h),i.set(o,d),v(this,is,yf).call(this,r),i.every((f,g)=>f===g+1)&&p(this,ge,null)}deletePages(t){v(this,is,Rh).call(this);const e=n(this,ge),s=v(this,is,Nh).call(this);p(this,dn,{pageNumberToId:e.slice(),pagesNumber:n(this,ze),prevPageNumbers:n(this,Ni).slice()});const i=n(this,ze)-t.length;p(this,ze,i);const r=p(this,ge,new Uint32Array(i));p(this,Ni,new Int32Array(i));let a=0,o=0;for(const l of t){const c=l-1;c!==a&&(r.set(e.subarray(a,c),o),o+=c-a),a=c+1}a<e.length&&r.set(e.subarray(a),o),v(this,is,yf).call(this,s,new Set(t))}cancelDelete(){n(this,dn)&&(p(this,ge,n(this,dn).pageNumberToId),p(this,ze,n(this,dn).pagesNumber),p(this,Ni,n(this,dn).prevPageNumbers),p(this,dn,null))}cleanSavedData(){p(this,dn,null)}copyPages(t){v(this,is,Rh).call(this),p(this,Fo,{pageNumbers:t,pageIds:t.map(e=>n(this,ge)[e-1])})}cancelCopy(){p(this,Fo,null)}pastePages(t){v(this,is,Rh).call(this);const e=n(this,ge),s=v(this,is,Nh).call(this),{pageNumbers:i,pageIds:r}=n(this,Fo),a=n(this,ze)+i.length;p(this,ze,a);const o=p(this,ge,new Uint32Array(a));p(this,Ni,new Int32Array(a)),o.set(e.subarray(0,t),0),o.set(r,t),o.set(e.subarray(t),t+i.length),v(this,is,yf).call(this,s,null,t,i),p(this,Fo,null)}hasBeenAltered(){return n(this,ge)!==null}getPageMappingForSaving(t=null){t??(t=v(this,is,Nh).call(this));let e=0;for(const i of t.values())e=Math.max(e,i.length);const s=new Array(e);for(let i=0;i<e;i++)s[i]={document:null,pageIndices:[],includePages:[]};for(const[i,r]of t)for(let a=0,o=r.length;a<o;a++)s[a].includePages.push([i-1,r[a]-1]);for(const{includePages:i,pageIndices:r}of s){i.sort((a,o)=>a[0]-o[0]);for(let a=0,o=i.length;a<o;a++)r.push(i[a][1]),i[a]=i[a][0]}return s}extractPages(t){t=Array.from(t).sort((s,i)=>s-i);const e=new Map;for(let s=0,i=t.length;s<i;s++){const r=this.getPageId(t[s]);e.getOrInsertComputed(r,Vu).push(s+1)}return this.getPageMappingForSaving(e)}getPrevPageNumber(t){var e;return((e=n(this,Ni))==null?void 0:e[t-1])??0}getPageNumber(t){if(!n(this,ge))return t;const e=n(this,ge);for(let s=0,i=n(this,ze);s<i;s++)if(e[s]===t)return s+1;return 0}getPageId(t){var e;return((e=n(this,ge))==null?void 0:e[t-1])??t}getMapping(){var t;return(t=n(this,ge))==null?void 0:t.subarray(0,this.pagesNumber)}}ge=new WeakMap,Ni=new WeakMap,ze=new WeakMap,Fo=new WeakMap,dn=new WeakMap,is=new WeakSet,Rh=function(){if(n(this,ge))return;const t=n(this,ze),e=p(this,ge,new Uint32Array(t));for(let s=0;s<t;s++)e[s]=s+1;p(this,Ni,new Int32Array(e))},Nh=function(){const t=new Map,e=n(this,ge);for(let s=0,i=n(this,ze);s<i;s++){const r=e[s],a=t.get(r);a?a.push(s+1):t.set(r,[s+1])}return t},yf=function(t,e=null,s=-1,i=null){const r=n(this,Ni),a=n(this,ge),o=s+((i==null?void 0:i.length)??0),l=new Map;for(let c=0,h=n(this,ze);c<h;c++){if(c>=s&&c<o){r[c]=-i[c-s];continue}const d=a[c],f=t.get(d);let g=l.get(d)||0;if(e&&f)for(;g<f.length&&e.has(f[g]);)g++;r[c]=f==null?void 0:f[g],l.set(d,g+1)}};const Ol=Symbol("INITIAL_DATA"),Ov=()=>({...Promise.withResolvers(),data:Ol});var vi;class vy{constructor(){m(this,vi,new Map)}get(t,e=null){if(e){const i=n(this,vi).getOrInsertComputed(t,Ov);return i.promise.then(()=>e(i.data)),null}const s=n(this,vi).get(t);if(!s||s.data===Ol)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=n(this,vi).get(t);return!!e&&e.data!==Ol}delete(t){const e=n(this,vi).get(t);return!e||e.data===Ol?!1:(n(this,vi).delete(t),!0)}resolve(t,e=null){const s=n(this,vi).getOrInsertComputed(t,Ov);if(s.data!==Ol)throw new Error(`Object already resolved ${t}.`);s.data=e,s.resolve()}clear(){var t;for(const{data:e}of n(this,vi).values())(t=e==null?void 0:e.bitmap)==null||t.close();n(this,vi).clear()}*[Symbol.iterator](){for(const[t,{data:e}]of n(this,vi))e!==Ol&&(yield[t,e])}}vi=new WeakMap;const X1=1e5,Rv=30;var Gv,ta,ls,Wd,Xd,Cc,Oo,qn,qd,Yd,Ro,Kd,_c,ea,kc,Qd,Tc,No,Jd,Zd,Pc,Bo,tu,Mc,Ic,Ar,by,yy,jg,ri,wf,Wg,wy,Ay;const Be=class Be{constructor({textContentSource:t,images:e,container:s,viewport:i}){m(this,Ar);m(this,ta,Promise.withResolvers());m(this,ls,null);m(this,Wd,!1);m(this,Xd,!!((Gv=globalThis.FontInspector)!=null&&Gv.enabled));m(this,Cc,null);m(this,Oo,null);m(this,qn,null);m(this,qd,0);m(this,Yd,0);m(this,Ro,null);m(this,Kd,null);m(this,_c,0);m(this,ea,0);m(this,kc,Object.create(null));m(this,Qd,[]);m(this,Tc,null);m(this,No,[]);m(this,Jd,new WeakMap);m(this,Zd,null);var c;if(t instanceof ReadableStream)p(this,Tc,t);else if(typeof t=="object")p(this,Tc,new ReadableStream({start(h){h.enqueue(t),h.close()}}));else throw new Error('No "textContentSource" parameter specified.');p(this,ls,p(this,Kd,s)),p(this,Cc,e),p(this,ea,i.scale*En.pixelRatio),p(this,_c,i.rotation),p(this,qn,{div:null,properties:null,ctx:null});const{pageWidth:r,pageHeight:a,pageX:o,pageY:l}=i.rawDims;p(this,Zd,[1,0,0,-1,-o,l+a]),p(this,Yd,r),p(this,qd,a),v(c=Be,ri,wy).call(c),s.style.setProperty("--min-font-size",n(Be,Mc)),xl(s,i),n(this,ta).promise.finally(()=>{n(Be,Ic).delete(this),p(this,qn,null),p(this,kc,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=$t.platform;return at(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){n(this,Cc)&&n(this,ls).append(n(this,Cc).render());const t=()=>{n(this,Ro).read().then(({value:e,done:s})=>{if(s){n(this,ta).resolve();return}n(this,Oo)??p(this,Oo,e.lang),Object.assign(n(this,kc),e.styles),v(this,Ar,by).call(this,e.items),t()},n(this,ta).reject)};return p(this,Ro,n(this,Tc).getReader()),n(Be,Ic).add(this),t(),n(this,ta).promise}update({viewport:t,onBefore:e=null}){var r;const s=t.scale*En.pixelRatio,i=t.rotation;if(i!==n(this,_c)&&(e==null||e(),p(this,_c,i),xl(n(this,Kd),{rotation:i})),s!==n(this,ea)){e==null||e(),p(this,ea,s);const a={div:null,properties:null,ctx:v(r=Be,ri,wf).call(r,n(this,Oo))};for(const o of n(this,No))a.properties=n(this,Jd).get(o),a.div=o,v(this,Ar,jg).call(this,a)}}cancel(){var e;const t=new _a("TextLayer task cancelled.");(e=n(this,Ro))==null||e.cancel(t).catch(()=>{}),p(this,Ro,null),n(this,ta).reject(t)}get textDivs(){return n(this,No)}get textContentItemsStr(){return n(this,Qd)}static cleanup(){if(!(n(this,Ic).size>0)){n(this,Pc).clear();for(const{canvas:t}of n(this,Bo).values())t.remove();n(this,Bo).clear()}}};ta=new WeakMap,ls=new WeakMap,Wd=new WeakMap,Xd=new WeakMap,Cc=new WeakMap,Oo=new WeakMap,qn=new WeakMap,qd=new WeakMap,Yd=new WeakMap,Ro=new WeakMap,Kd=new WeakMap,_c=new WeakMap,ea=new WeakMap,kc=new WeakMap,Qd=new WeakMap,Tc=new WeakMap,No=new WeakMap,Jd=new WeakMap,Zd=new WeakMap,Pc=new WeakMap,Bo=new WeakMap,tu=new WeakMap,Mc=new WeakMap,Ic=new WeakMap,Ar=new WeakSet,by=function(t){var i,r;if(n(this,Wd))return;(r=n(this,qn)).ctx??(r.ctx=v(i=Be,ri,wf).call(i,n(this,Oo)));const e=n(this,No),s=n(this,Qd);for(const a of t){if(e.length>X1){lt("Ignoring additional textDivs for performance reasons."),p(this,Wd,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=n(this,ls);p(this,ls,document.createElement("span")),n(this,ls).classList.add("markedContent"),a.id&&n(this,ls).setAttribute("id",`${a.id}`),a.tag==="Artifact"&&(n(this,ls).ariaHidden=!0),o.append(n(this,ls))}else a.type==="endMarkedContent"&&p(this,ls,n(this,ls).parentNode);continue}s.push(a.str),v(this,Ar,yy).call(this,a)}},yy=function(t){var y;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};n(this,No).push(e);const i=B.transform(n(this,Zd),t.transform);let r=Math.atan2(i[1],i[0]);const a=n(this,kc)[t.fontName];a.vertical&&(r+=Math.PI/2);let o=n(this,Xd)&&a.fontSubstitution||a.fontFamily;o=Be.fontFamilyMap.get(o)||o;const l=Math.hypot(i[2],i[3]),c=l*v(y=Be,ri,Ay).call(y,o,a,n(this,Oo));let h,d;r===0?(h=i[4],d=i[5]-c):(h=i[4]+c*Math.sin(r),d=i[5]-c*Math.cos(r));const f=e.style;f.left=`${(100*h/n(this,Yd)).toFixed(2)}%`,f.top=`${(100*d/n(this,qd)).toFixed(2)}%`,f.setProperty("--font-height",`${l.toFixed(2)}px`),f.fontFamily=o,s.fontSize=l,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,n(this,Xd)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),r!==0&&(s.angle=r*(180/Math.PI));let g=!1;if(t.str.length>1)g=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const b=Math.abs(t.transform[0]),S=Math.abs(t.transform[3]);b!==S&&Math.max(b,S)/Math.min(b,S)>1.5&&(g=!0)}if(g&&(s.canvasWidth=a.vertical?t.height:t.width),n(this,Jd).set(e,s),n(this,qn).div=e,n(this,qn).properties=s,v(this,Ar,jg).call(this,n(this,qn)),s.hasText&&n(this,ls).append(e),s.hasEOL){const b=document.createElement("br");b.setAttribute("role","presentation"),n(this,ls).append(b)}},jg=function(t){var a;const{div:e,properties:s,ctx:i}=t,{style:r}=e;if(s.canvasWidth!==0&&s.hasText){const{fontFamily:o}=r,{canvasWidth:l,fontSize:c}=s;v(a=Be,ri,Wg).call(a,i,c*n(this,ea),o);const{width:h}=i.measureText(e.textContent);h>0&&r.setProperty("--scale-x",l*n(this,ea)/h)}s.angle!==0&&r.setProperty("--rotate",`${s.angle}deg`)},ri=new WeakSet,wf=function(t=null){let e=n(this,Bo).get(t||(t=""));if(!e){const s=document.createElement("canvas");s.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none;letter-spacing:normal;word-spacing:normal",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),n(this,Bo).set(t,e),n(this,tu).set(e,{size:0,family:""})}return e},Wg=function(t,e,s){const i=n(this,tu).get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)},wy=function(){if(n(this,Mc)!==null)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),p(this,Mc,t.getBoundingClientRect().height),t.remove()},Ay=function(t,e,s){const i=n(this,Pc).get(t);if(i)return i;const r=v(this,ri,wf).call(this,s);r.canvas.width=r.canvas.height=Rv,v(this,ri,Wg).call(this,r,Rv,t);const a=r.measureText(""),o=a.fontBoundingBoxAscent,l=Math.abs(a.fontBoundingBoxDescent);r.canvas.width=r.canvas.height=0;let c=.8;return o?c=o/(o+l):($t.platform.isFirefox&&lt("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?c=e.ascent:e.descent&&(c=1+e.descent)),n(this,Pc).set(t,c),c},m(Be,ri),m(Be,Pc,new Map),m(Be,Bo,new Map),m(Be,tu,new WeakMap),m(Be,Mc,null),m(Be,Ic,new Set);let gh=Be;const q1=100;function Sy(u={}){const t=new Xg,{docId:e}=t,s=u.url?t1(u.url):null,i=u.data?e1(u.data):null,r=u.httpHeaders||null,a=u.withCredentials===!0,o=u.password??null,l=u.range instanceof xy?u.range:null,c=Number.isInteger(u.rangeChunkSize)&&u.rangeChunkSize>0?u.rangeChunkSize:2**16;let h=u.worker instanceof td?u.worker:null;const d=u.verbosity,f=typeof u.docBaseUrl=="string"&&!Rp(u.docBaseUrl)?u.docBaseUrl:null,g=Yu(u.cMapUrl),y=u.cMapPacked!==!1,b=Yu(u.iccUrl),S=Yu(u.standardFontDataUrl),w=Yu(u.wasmUrl),x=u.stopAtErrors!==!0,A=Number.isInteger(u.maxImageSize)&&u.maxImageSize>-1?u.maxImageSize:-1,C=typeof u.isOffscreenCanvasSupported=="boolean"?u.isOffscreenCanvasSupported:!ei,_=typeof u.isImageDecoderSupported=="boolean"?u.isImageDecoderSupported:!ei,k=Number.isInteger(u.canvasMaxAreaInBytes)?u.canvasMaxAreaInBytes:-1,I=typeof u.disableFontFace=="boolean"?u.disableFontFace:ei,L=u.fontExtraProperties===!0,P=u.enableXfa===!0,D=u.ownerDocument||globalThis.document,R=u.disableRange===!0,K=u.disableStream===!0,W=u.disableAutoFetch===!0,Q=u.pdfBug===!0,ht=u.CanvasFactory||(ei?c1:r1),T=u.FilterFactory||(ei?l1:a1),q=u.BinaryDataFactory||(ei?h1:Ev),Lt=u.enableHWA===!0,_e=u.enableWebGPU===!0?p1():Promise.resolve(!1),re=u.useWasm!==!1,Gt=u.pagesMapper||new W1,V=typeof u.useSystemFonts=="boolean"?u.useSystemFonts:!ei&&!I,$=typeof u.useWorkerFetch=="boolean"?u.useWorkerFetch:!!(q===Ev&&g&&y&&S&&w&&Wh(g,document.baseURI)&&Wh(S,document.baseURI)&&Wh(w,document.baseURI)),Et=null;xS(d);const ct={canvasFactory:new ht({ownerDocument:D,enableHWA:Lt}),filterFactory:new T({docId:e,ownerDocument:D}),binaryDataFactory:$?null:new q({cMapUrl:g,standardFontDataUrl:S,wasmUrl:w})};h||(h=td.create({verbosity:d,port:Sn.workerPort}),t._worker=h);const J={docId:e,apiVersion:"6.1.200",data:i,password:o,disableAutoFetch:W,rangeChunkSize:c,docBaseUrl:f,enableXfa:P,evaluatorOptions:{maxImageSize:A,disableFontFace:I,ignoreErrors:x,isOffscreenCanvasSupported:C,isImageDecoderSupported:_,canvasMaxAreaInBytes:k,fontExtraProperties:L,useSystemFonts:V,useWasm:re,useWorkerFetch:$,cMapUrl:g,cMapPacked:y,iccUrl:b,standardFontDataUrl:S,wasmUrl:w,hasGPU:!1}},ae={ownerDocument:D,pdfBug:Q,styleElement:Et,enableHWA:Lt,loadingParams:{disableAutoFetch:W,enableXfa:P}};return Promise.all([h.promise,_e]).then(function([,Ti]){if(h.destroyed)throw new Error("Worker was destroyed");J.evaluatorOptions.hasGPU=Ti;const ks=h.messageHandler.sendWithPromise("GetDocRequest",J,i?[i.buffer]:null);let Ts;if(!i)if(l)Ts=new L1({pdfDataRangeTransport:l,disableRange:R,disableStream:K});else if(s){const Se=V1(s);Ts=new Se({url:s,httpHeaders:r,withCredentials:a,rangeChunkSize:c,disableRange:R,disableStream:K})}else throw new Error("getDocument - expected either `data`, `range`, or `url` parameter.");return ks.then(Se=>{if(h.destroyed)throw new Error("Worker was destroyed");const Sr=new Ih(e,Se,h.port),Pa=new K1(Sr,t,Ts,ae,ct,Gt);if(t._transport=Pa,t.destroyed)throw new Error("Loading aborted");Sr.send("Ready",null)})}).catch(t._capability.reject).finally(t._setupCapability.resolve),t}var bp;const yp=class yp{constructor(){M(this,"_capability",Promise.withResolvers());M(this,"_setupCapability",Promise.withResolvers());M(this,"_transport",null);M(this,"_worker",null);M(this,"docId",`d${qt(yp,bp)._++}`);M(this,"destroyed",!1);M(this,"onPassword",null);M(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){var t,e,s,i;this.destroyed=!0,this._capability.promise.catch(()=>{});try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),await this._setupCapability.promise,await((e=this._transport)==null?void 0:e.destroy())}catch(r){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,r}this._transport=null,(i=this._worker)==null||i.destroy(),this._worker=null}async getData(){return this._transport.getData()}};bp=new WeakMap,m(yp,bp,0);let Xg=yp;var Dc,$o;class xy{constructor(t,e,s=!1,i=null){m(this,Dc,Promise.withResolvers());m(this,$o,null);this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i}onDataRange(t,e){n(this,$o).call(this,{type:"range",begin:t,chunk:e})}onDataProgressiveRead(t){n(this,Dc).promise.then(()=>{n(this,$o).call(this,{type:"progressiveRead",chunk:t})})}onDataProgressiveDone(){n(this,Dc).promise.then(()=>{n(this,$o).call(this,{type:"progressiveDone"})})}transportReady(t){p(this,$o,t),n(this,Dc).resolve()}requestDataRange(t,e){Ct("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}Dc=new WeakMap,$o=new WeakMap;class Y1{constructor(t,e){this._pdfInfo=t,this._transport=e}get pagesMapper(){return this._transport.pagesMapper}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return at(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getAttachmentContent(t){return this._transport.getAttachmentContent(t)}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}extractPages(t){return this._transport.extractPages(t)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}getRawData(t){return this._transport.getRawData(t)}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var Yn,Uo,Ho,Bh;const sv=class sv{constructor(t,e,s,i,r=!1){m(this,Ho);m(this,Yn,!1);m(this,Uo,null);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=r?new fv:null,this._pdfBug=r,this.commonObjs=s.commonObjs,this.objs=new vy,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,p(this,Uo,i),this.imageCoordinates=null}clone(t){const e=new sv(t,this._pageInfo,this._transport,n(this,Uo),this._pdfBug);return e.clonedFromIndex=this.clonedFromIndex??this._pageIndex,this._transport.updatePage(e),e}get pageNumber(){return this._pageIndex+1}set pageNumber(t){this._pageIndex=t-1,this._transport.updatePage(this)}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:r=!1}={}){return new Gu({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:r})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return at(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,canvas:e=t.canvas,viewport:s,intent:i="display",annotationMode:r=Cr.ENABLE,transform:a=null,background:o=null,optionalContentConfigPromise:l=null,annotationCanvasMap:c=null,pageColors:h=null,printAnnotationStorage:d=null,isEditing:f=!1,recordImages:g=!1,recordOperations:y=!1,operationsFilter:b=null}){var W,Q,ht;(W=this._stats)==null||W.time("Overall");const S=this._transport.getRenderingIntent(i,r,d,f),{renderingIntent:w,cacheKey:x}=S;p(this,Yn,!1),l||(l=this._transport.getOptionalContentConfig(w));const A=this._intentStates.getOrInsertComputed(x,cg);A.streamReaderCancelTimeout&&(clearTimeout(A.streamReaderCancelTimeout),A.streamReaderCancelTimeout=null);const C=!!(w&ti.PRINT);A.displayReadyCapability||(A.displayReadyCapability=Promise.withResolvers(),A.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(Q=this._stats)==null||Q.time("Page Request"),this._pumpOperatorList(S));const _=!!(this._pdfBug&&((ht=globalThis.StepperManager)!=null&&ht.enabled)),k=!!e&&!this.recordedBBoxes&&(y||_),I=!!e&&!this.imageCoordinates&&g,L=T=>{var q,Lt,mt,_e;if(A.renderTasks.delete(R),k){const re=(q=R.gfx)==null?void 0:q.dependencyTracker.take();re&&((Lt=R.stepper)==null||Lt.setOperatorBBoxes(re,R.gfx.dependencyTracker.takeDebugMetadata()),y&&(this.recordedBBoxes=re))}I&&!T&&(this.imageCoordinates=(mt=R.gfx)==null?void 0:mt.imagesTracker.take()),C&&p(this,Yn,!0),v(this,Ho,Bh).call(this),T?(R.capability.reject(T),this._abortOperatorList({intentState:A,reason:T instanceof Error?T:new Error(T)})):R.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(_e=globalThis.Stats)!=null&&_e.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))};let P=null,D=null;(k||I)&&(D=new jS(e,A.operatorList.length)),k&&(P=new WS(D,_));const R=new Yg({callback:L,params:{canvas:e,canvasContext:t,dependencyTracker:P??D,imagesTracker:I?new Ig(e):null,viewport:s,transform:a,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:c,operatorList:A.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!C,pdfBug:this._pdfBug,pageColors:h,enableHWA:this._transport.enableHWA,operationsFilter:b});(A.renderTasks||(A.renderTasks=new Set)).add(R);const K=R.task;return Promise.all([A.displayReadyCapability.promise,l]).then(([T,q])=>{var Lt;if(this.destroyed){L();return}if((Lt=this._stats)==null||Lt.time("Rendering"),!(q.renderingIntent&w))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");R.initializeGraphics({transparency:T,optionalContentConfig:q}),R.operatorListChanged()}).catch(L),K}getOperatorList({intent:t="display",annotationMode:e=Cr.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){var c;function r(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(l))}const a=this._transport.getRenderingIntent(t,e,s,i,!0),o=this._intentStates.getOrInsertComputed(a.cacheKey,cg);let l;return o.opListReadCapability||(l=Object.create(null),l.operatorListChanged=r,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(l),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(c=this._stats)==null||c.time("Page Request"),this._pumpOperatorList(a)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:n(this,Uo).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(i){return i.items.length}})}async getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(i=>Qh.textContent(i));const e=this.streamTextContent(t),s={items:[],styles:Object.create(null),lang:null};for await(const i of e)s.lang??(s.lang=i.lang),Object.assign(s.styles,i.styles),s.items.push(...i.items);return s}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),p(this,Yn,!1),Promise.all(t)}cleanup(t=!1){p(this,Yn,!0);const e=v(this,Ho,Bh).call(this);return t&&e&&this._stats&&(this._stats=new fv),e}_startRenderPage(t,e){var i,r;const s=this._intentStates.get(e);s&&((i=this._stats)==null||i.timeEnd("Page Request"),(r=s.displayReadyCapability)==null||r.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&v(this,Ho,Bh).call(this)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:i}){const{map:r,transfer:a}=s,l=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:n(this,Uo).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:r,modifiedIds:i},void 0,a).getReader(),c=this._intentStates.get(e);c.streamReader=l;const h=()=>{l.read().then(({value:d,done:f})=>{if(f){c.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(d,c),h())},d=>{if(c.streamReader=null,!this._transport.destroyed){if(c.operatorList){c.operatorList.lastChunk=!0;for(const f of c.renderTasks)f.operatorListChanged();v(this,Ho,Bh).call(this)}if(c.displayReadyCapability)c.displayReadyCapability.reject(d);else if(c.opListReadCapability)c.opListReadCapability.reject(d);else throw d}})};h()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof Vm){let i=q1;e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new _a(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,r]of this._intentStates)if(r===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}};Yn=new WeakMap,Uo=new WeakMap,Ho=new WeakSet,Bh=function(){if(!n(this,Yn)||this.destroyed)return!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),p(this,Yn,!1),!0};let qg=sv;var sa,Bi,Kn,zo,wp,Vo,Go,ps,Af,Ey,Cy,$h,Lc,Sf;const le=class le{constructor({name:t=null,port:e=null,verbosity:s=ES()}={}){m(this,ps);m(this,sa,Promise.withResolvers());m(this,Bi,null);m(this,Kn,null);m(this,zo,null);if(this.name=t,this.destroyed=!1,this.verbosity=s,e){if(n(le,Go).has(e))throw new Error("Cannot use more than one PDFWorker per port.");n(le,Go).set(e,this),v(this,ps,Ey).call(this,e)}else v(this,ps,Cy).call(this)}get promise(){return n(this,sa).promise}get port(){return n(this,Kn)}get messageHandler(){return n(this,Bi)}destroy(){var t,e;this.destroyed=!0,(t=n(this,zo))==null||t.terminate(),p(this,zo,null),n(le,Go).delete(n(this,Kn)),p(this,Kn,null),(e=n(this,Bi))==null||e.destroy(),p(this,Bi,null)}static create(t){const e=n(this,Go).get(t==null?void 0:t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new le(t)}static get workerSrc(){if(Sn.workerSrc)return Sn.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return at(this,"_setupFakeWorkerGlobal",(async()=>n(this,Lc,Sf)?n(this,Lc,Sf):(await import(this.workerSrc)).WorkerMessageHandler)())}};sa=new WeakMap,Bi=new WeakMap,Kn=new WeakMap,zo=new WeakMap,wp=new WeakMap,Vo=new WeakMap,Go=new WeakMap,ps=new WeakSet,Af=function(){n(this,sa).resolve(),n(this,Bi).send("configure",{verbosity:this.verbosity})},Ey=function(t){p(this,Kn,t),p(this,Bi,new Ih("main","worker",t)),n(this,Bi).on("ready",()=>{}),v(this,ps,Af).call(this)},Cy=function(){if(n(le,Vo)||n(le,Lc,Sf)){v(this,ps,$h).call(this);return}let{workerSrc:t}=le;try{le._isSameOrigin(window.location,t)||(t=le._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new Ih("main","worker",e),i=()=>{r.abort(),s.destroy(),e.terminate(),this.destroyed?n(this,sa).reject(new Error("Worker was destroyed")):v(this,ps,$h).call(this)},r=new AbortController;e.addEventListener("error",()=>{n(this,zo)||i()},{signal:r.signal}),s.on("test",o=>{if(r.abort(),this.destroyed||!o){i();return}p(this,Bi,s),p(this,Kn,e),p(this,zo,e),v(this,ps,Af).call(this)}),s.on("ready",o=>{if(r.abort(),this.destroyed){i();return}try{a()}catch{v(this,ps,$h).call(this)}});const a=()=>{const o=new Uint8Array;s.send("test",o,[o.buffer])};a();return}catch{Fp("The worker has been disabled.")}v(this,ps,$h).call(this)},$h=function(){n(le,Vo)||(lt("Setting up fake worker."),p(le,Vo,!0)),le._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){n(this,sa).reject(new Error("Worker was destroyed"));return}const e=new n1;p(this,Kn,e);const s=`fake${qt(le,wp)._++}`,i=new Ih(s+"_worker",s,e);t.setup(i,e),p(this,Bi,new Ih(s,s+"_worker",e)),v(this,ps,Af).call(this)}).catch(t=>{n(this,sa).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},Lc=new WeakSet,Sf=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},m(le,Lc),m(le,wp,0),m(le,Vo,!1),m(le,Go,new WeakMap),ei&&(p(le,Vo,!0),Sn.workerSrc||(Sn.workerSrc="./pdf.worker.mjs")),le._isSameOrigin=(t,e)=>{const s=URL.parse(t);if(!(s!=null&&s.origin)||s.origin==="null")return!1;const i=new URL(e,s);return s.origin===i.origin},le._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};let td=le;var Hs,jo,Qn,$i,Wo,Fc,Jn,Wi,Uh,xf;class K1{constructor(t,e,s,i,r,a){m(this,Wi);M(this,"downloadInfoCapability",Promise.withResolvers());m(this,Hs,null);m(this,jo,new Map);m(this,Qn,null);m(this,$i,new Map);m(this,Wo,new Map);m(this,Fc,new Map);m(this,Jn,null);this.messageHandler=t,this.loadingTask=e,p(this,Qn,s),this.commonObjs=new vy,this.fontLoader=new XS({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.enableHWA=i.enableHWA,this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.binaryDataFactory=r.binaryDataFactory,this.pagesMapper=a,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler()}updatePage(t){const{_pageIndex:e}=t;n(this,$i).set(e,t),n(this,Wo).set(e,Promise.resolve(t))}get annotationStorage(){return at(this,"annotationStorage",new jm)}getRenderingIntent(t,e=Cr.ENABLE,s=null,i=!1,r=!1){let a=ti.DISPLAY,o=Jh;switch(t){case"any":a=ti.ANY;break;case"display":break;case"print":a=ti.PRINT;break;default:lt(`getRenderingIntent - invalid intent: ${t}`)}const l=a&ti.PRINT&&s instanceof $b?s:this.annotationStorage;switch(e){case Cr.DISABLE:a+=ti.ANNOTATIONS_DISABLE;break;case Cr.ENABLE:break;case Cr.ENABLE_FORMS:a+=ti.ANNOTATIONS_FORMS;break;case Cr.ENABLE_STORAGE:a+=ti.ANNOTATIONS_STORAGE,o=l.serializable;break;default:lt(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(a+=ti.IS_EDITING),r&&(a+=ti.OPLIST);const{ids:c,hash:h}=l.modifiedIds,d=[a,o.hash,h];return{renderingIntent:a,cacheKey:d.join("_"),annotationStorageSerializable:o,modifiedIds:c}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=n(this,Jn))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of n(this,$i).values())t.push(i._destroy());n(this,$i).clear(),n(this,Wo).clear(),n(this,Fc).clear(),Object.hasOwn(this,"annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{var i,r;this.commonObjs.clear(),this.fontLoader.clear(),n(this,jo).clear(),this.filterFactory.destroy(),gh.cleanup(),(i=n(this,Qn))==null||i.cancelAllRequests(new _a("Worker was terminated.")),(r=this.messageHandler)==null||r.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,i)=>{ne(n(this,Qn),"GetReader - no `BasePDFStream` instance available."),p(this,Hs,n(this,Qn).getFullReader()),n(this,Hs).onProgress=r=>v(this,Wi,xf).call(this,r),i.onPull=()=>{n(this,Hs).read().then(function({value:r,done:a}){if(a){i.close();return}ne(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{i.error(r)})},i.onCancel=r=>{n(this,Hs).cancel(r),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("ReaderHeadersReady",async s=>{await n(this,Hs).headersReady;const{isStreamingSupported:i,isRangeSupported:r,contentLength:a}=n(this,Hs);return i&&r&&(n(this,Hs).onProgress=null),{isStreamingSupported:i,isRangeSupported:r,contentLength:a}}),t.on("GetRangeReader",(s,i)=>{ne(n(this,Qn),"GetRangeReader - no `BasePDFStream` instance available.");const r=n(this,Qn).getRangeReader(s.begin,s.end);if(!r){i.close();return}i.onPull=()=>{r.read().then(function({value:a,done:o}){if(o){i.close();return}ne(a instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{i.error(a)})},i.onCancel=a=>{r.cancel(a),i.ready.catch(o=>{if(!this.destroyed)throw o})}}),t.on("GetDoc",({pdfInfo:s})=>{this.pagesMapper.pagesNumber=s.numPages,this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new Y1(s,this))}),t.on("DocException",s=>{e._capability.reject(vs(s))}),t.on("PasswordRequest",s=>{p(this,Jn,Promise.withResolvers());try{if(!e.onPassword)throw vs(s);const i=r=>{r instanceof Error?n(this,Jn).reject(r):n(this,Jn).resolve({password:r})};e.onPassword(i,s.code)}catch(i){n(this,Jn).reject(i)}return n(this,Jn).promise}),t.on("DataLoaded",s=>{v(this,Wi,xf).call(this,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;n(this,$i).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,r])=>{var a;if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":if("error"in r){const f=r.error;lt(`Error during font loading: ${f}`),this.commonObjs.resolve(s,f);break}const o=new QS(r),l=this._params.pdfBug&&((a=globalThis.FontInspector)!=null&&a.enabled)?(f,g)=>globalThis.FontInspector.fontAdded(f,g):null,c=new qS(o,l,r.charProcOperatorList,r.extra);this.fontLoader.bind(c).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{c.fontExtraProperties||c.clearData(),this.commonObjs.resolve(s,c)});break;case"CopyLocalImage":const{imageRef:h}=r;ne(h,"The imageRef must be defined.");for(const f of n(this,$i).values())for(const[,g]of f.objs){if((g==null?void 0:g.ref)!==h)continue;if(!g.dataLen)return null;const y=structuredClone(g);return this.commonObjs.resolve(s,y),g.dataLen}break;case"FontPath":this.commonObjs.resolve(s,new ZS(r));break;case"Image":this.commonObjs.resolve(s,r);break;case"Pattern":const d=new JS(r);this.commonObjs.resolve(s,d.getIR());break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,r,a])=>{var l;if(this.destroyed)return;const o=n(this,$i).get(i);if(!o.objs.has(s)){if(o._intentStates.size===0){(l=a==null?void 0:a.bitmap)==null||l.close();return}switch(r){case"Image":case"Pattern":o.objs.resolve(s,a);break;default:throw new Error(`Got unknown object type ${r}`)}}}),t.on("DocProgress",s=>{this.destroyed||v(this,Wi,xf).call(this,s)}),t.on("FetchBinaryData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.binaryDataFactory)throw new Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var s;this.annotationStorage.size<=0&&lt("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:((s=n(this,Hs))==null?void 0:s.filename)??null},e).finally(()=>{this.annotationStorage.resetModified()})}extractPages(t){var r;const e={pageInfos:t};let s;const i=globalThis.ImageBitmap;if(typeof i=="function"){const a=Array.isArray(t)?t:[t];for(const o of a)(o==null?void 0:o.image)instanceof i&&(s||(s=[])).push(o.image)}if(this.annotationStorage.size>0){const a=this.annotationStorage.serializable;let{map:o}=a;(r=a.transfer)!=null&&r.length&&(s?s.push(...a.transfer):s=a.transfer);const l=this.pagesMapper.getMapping();if(l){const c=new Map;for(const[h,d]of o){if((d==null?void 0:d.pageIndex)!==void 0&&d.pageIndex>=0&&d.pageIndex<l.length){const f=l[d.pageIndex]-1;if(f!==d.pageIndex){c.set(h,{...d,pageIndex:f});continue}}c.set(h,d)}o=c}e.annotationStorage=o}return this.messageHandler.sendWithPromise("ExtractPages",e,s).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this.pagesMapper.pagesNumber)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=this.pagesMapper.getPageId(t)-1,i=n(this,Wo).get(e);if(i)return i;const r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:s}).then(a=>{if(this.destroyed)throw new Error("Transport destroyed");a.refStr&&n(this,Fc).set(a.refStr,s);const o=new qg(e,a,this,this.pagesMapper,this._params.pdfBug);return n(this,$i).set(e,o),o});return n(this,Wo).set(e,r),r}async getPageIndex(t){if(!Lg(t))throw new Error("Invalid pageIndex request.");const e=await this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}),s=this.pagesMapper.getPageNumber(e+1);if(s===0)throw new Error("GetPageIndex: page has been removed.");return s-1}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(t+1)-1,intent:e})}getFieldObjects(){return v(this,Wi,Uh).call(this,"GetFieldObjects")}hasJSActions(){return v(this,Wi,Uh).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAttachmentContent(t){return this.messageHandler.sendWithPromise("GetAttachmentContent",t)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return v(this,Wi,Uh).call(this,"GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return v(this,Wi,Uh).call(this,"GetOptionalContentConfig").then(e=>new Vg(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata";return n(this,jo).getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,null).then(e=>{var s,i;return{info:e[0],metadata:e[1]?new G1(e[1]):null,contentDispositionFilename:((s=n(this,Hs))==null?void 0:s.filename)??null,contentLength:((i=n(this,Hs))==null?void 0:i.contentLength)??null,hasStructTree:e[2]}}))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}getRawData(t){return this.messageHandler.sendWithPromise("GetRawData",t)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of n(this,$i).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),n(this,jo).clear(),this.filterFactory.destroy(!0),gh.cleanup()}}cachedPageNumber(t){if(!Lg(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`,s=n(this,Fc).get(e);if(s>=0){const i=this.pagesMapper.getPageNumber(s+1);if(i!==0)return i}return null}}Hs=new WeakMap,jo=new WeakMap,Qn=new WeakMap,$i=new WeakMap,Wo=new WeakMap,Fc=new WeakMap,Jn=new WeakMap,Wi=new WeakSet,Uh=function(t,e=null){return n(this,jo).getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,e))},xf=function({loaded:t,total:e}){var s,i;(i=(s=this.loadingTask).onProgress)==null||i.call(s,{loaded:t,total:e,percent:e?Qt(Math.round(t/e*100),0,100):NaN})};class Q1{constructor(t){M(this,"_internalRenderTask",null);M(this,"onContinue",null);M(this,"onError",null);this._internalRenderTask=t}get promise(){return this._internalRenderTask.capability.promise}cancel(t=0){this._internalRenderTask.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this._internalRenderTask.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this._internalRenderTask;return t.form||t.canvas&&(e==null?void 0:e.size)>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}}var ia,Xo;const Va=class Va{constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:r,operatorList:a,pageIndex:o,canvasFactory:l,filterFactory:c,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:f=null,enableHWA:g=!1,operationsFilter:y=null}){m(this,ia,null);this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=c,this._pdfBug=d,this.pageColors=f,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=h===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Q1(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=g,this._dependencyTracker=e.dependencyTracker,this._imagesTracker=e.imagesTracker,this._operationsFilter=y}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){var c,h;if(this.cancelled)return;if(this._canvas){if(n(Va,Xo).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");n(Va,Xo).add(this._canvas)}this._pdfBug&&((c=globalThis.StepperManager)!=null&&c.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:s,transform:i,background:r,dependencyTracker:a,imagesTracker:o}=this.params,l=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new Hl(l,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,a,o),this.gfx.beginDrawing({transform:i,viewport:s,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,(h=this.graphicsReadyCallback)==null||h.call(this)}cancel(t=null,e=0){var s,i,r;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),n(this,ia)&&(window.cancelAnimationFrame(n(this,ia)),p(this,ia,null)),n(Va,Xo).delete(this._canvas),t||(t=new Vm(`Rendering cancelled, page ${this._pageIndex+1}`,e)),this.callback(t),(r=(i=this.task).onError)==null||r.call(i,t)}operatorListChanged(){var t,e;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(t=this.gfx.dependencyTracker)==null||t.growOperationsCount(this.operatorList.fnArray.length),(e=this.stepper)==null||e.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?p(this,ia,window.requestAnimationFrame(()=>{p(this,ia,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),n(Va,Xo).delete(this._canvas),this.callback())))}};ia=new WeakMap,Xo=new WeakMap,m(Va,Xo,new WeakSet);let Yg=Va;const J1="6.1.200",Z1="6353acefe";var zs,qo,Oc,Ee,eu,Rc,Zn,su,na,Ui,iu,Ut,Kg,Qg,Jg,$a,_y,Er;const ys=class ys{constructor({editor:t=null,uiManager:e=null}){m(this,Ut);m(this,zs,null);m(this,qo,null);m(this,Oc);m(this,Ee,null);m(this,eu,!1);m(this,Rc,!1);m(this,Zn,null);m(this,su);m(this,na,null);m(this,Ui,null);var s,i;t?(p(this,Rc,!1),p(this,Zn,t)):p(this,Rc,!0),p(this,Ui,(t==null?void 0:t._uiManager)||e),p(this,su,n(this,Ui)._eventBus),p(this,Oc,((s=t==null?void 0:t.color)==null?void 0:s.toUpperCase())||((i=n(this,Ui))==null?void 0:i.highlightColors.values().next().value)||"#FFFF98"),n(ys,iu)||p(ys,iu,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return at(this,"_keyboardManager",new El([[["Escape"],ys.prototype._hideDropdownFromKeyboard],[["Space"],ys.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight"],ys.prototype._moveToNext],[["ArrowUp","ArrowLeft"],ys.prototype._moveToPrevious],[["Home"],ys.prototype._moveToBeginning],[["End"],ys.prototype._moveToEnd]]))}renderButton(){const t=p(this,zs,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",n(this,Zn)&&(t.ariaControls=`${n(this,Zn).id}_colorpicker_dropdown`);const e=n(this,Ui)._signal;t.addEventListener("click",v(this,Ut,$a).bind(this),{signal:e}),t.addEventListener("keydown",v(this,Ut,Jg).bind(this),{signal:e});const s=p(this,qo,document.createElement("span"));return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=n(this,Oc),t.append(s),t}renderMainDropdown(){const t=p(this,Ee,v(this,Ut,Kg).call(this));return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}_colorSelectFromKeyboard(t){if(t.target===n(this,zs)){v(this,Ut,$a).call(this,t);return}const e=t.target.getAttribute("data-color");e&&v(this,Ut,Qg).call(this,e,t)}_moveToNext(t){var e,s;if(!n(this,Ut,Er)){v(this,Ut,$a).call(this,t);return}if(t.target===n(this,zs)){(e=n(this,Ee).firstElementChild)==null||e.focus();return}(s=t.target.nextSibling)==null||s.focus()}_moveToPrevious(t){var e,s;if(t.target===((e=n(this,Ee))==null?void 0:e.firstElementChild)||t.target===n(this,zs)){n(this,Ut,Er)&&this._hideDropdownFromKeyboard();return}n(this,Ut,Er)||v(this,Ut,$a).call(this,t),(s=t.target.previousSibling)==null||s.focus()}_moveToBeginning(t){var e;if(!n(this,Ut,Er)){v(this,Ut,$a).call(this,t);return}(e=n(this,Ee).firstElementChild)==null||e.focus()}_moveToEnd(t){var e;if(!n(this,Ut,Er)){v(this,Ut,$a).call(this,t);return}(e=n(this,Ee).lastElementChild)==null||e.focus()}hideDropdown(){var t,e;(t=n(this,Ee))==null||t.classList.add("hidden"),n(this,zs).ariaExpanded="false",(e=n(this,na))==null||e.abort(),p(this,na,null)}_hideDropdownFromKeyboard(){var t;if(!n(this,Rc)){if(!n(this,Ut,Er)){(t=n(this,Zn))==null||t.unselect();return}this.hideDropdown(),n(this,zs).focus({preventScroll:!0,focusVisible:n(this,eu)})}}updateColor(t){if(n(this,qo)&&(n(this,qo).style.backgroundColor=t),!n(this,Ee))return;const e=n(this,Ui).highlightColors.values();for(const s of n(this,Ee).children)s.ariaSelected=e.next().value===t.toUpperCase()}destroy(){var t,e;(t=n(this,zs))==null||t.remove(),p(this,zs,null),p(this,qo,null),(e=n(this,Ee))==null||e.remove(),p(this,Ee,null)}};zs=new WeakMap,qo=new WeakMap,Oc=new WeakMap,Ee=new WeakMap,eu=new WeakMap,Rc=new WeakMap,Zn=new WeakMap,su=new WeakMap,na=new WeakMap,Ui=new WeakMap,iu=new WeakMap,Ut=new WeakSet,Kg=function(){const t=document.createElement("div"),e=n(this,Ui)._signal;t.addEventListener("contextmenu",Ci,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),n(this,Zn)&&(t.id=`${n(this,Zn).id}_colorpicker_dropdown`);for(const[s,i]of n(this,Ui).highlightColors){const r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",i),r.title=s,r.setAttribute("data-l10n-id",n(ys,iu)[s]);const a=document.createElement("span");r.append(a),a.className="swatch",a.style.backgroundColor=i,r.ariaSelected=i===n(this,Oc),r.addEventListener("click",v(this,Ut,Qg).bind(this,i),{signal:e}),t.append(r)}return t.addEventListener("keydown",v(this,Ut,Jg).bind(this),{signal:e}),t},Qg=function(t,e){e.stopPropagation(),n(this,su).dispatch("switchannotationeditorparams",{source:this,type:dt.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)},Jg=function(t){ys._keyboardManager.exec(this,t)},$a=function(t){if(n(this,Ut,Er)){this.hideDropdown();return}if(p(this,eu,t.detail===0),n(this,na)||(p(this,na,new AbortController),window.addEventListener("pointerdown",v(this,Ut,_y).bind(this),{signal:n(this,Ui).combinedSignal(n(this,na))})),n(this,zs).ariaExpanded="true",n(this,Ee)){n(this,Ee).classList.remove("hidden");return}const e=p(this,Ee,v(this,Ut,Kg).call(this));n(this,zs).append(e)},_y=function(t){var e;(e=n(this,Ee))!=null&&e.contains(t.target)||this.hideDropdown()},Er=function(){return n(this,Ee)&&!n(this,Ee).classList.contains("hidden")},m(ys,iu,null);let Qf=ys;var Vs,Nc,Yo,tr,nu;const Ga=class Ga{constructor(t){m(this,Vs,null);m(this,Nc,!1);m(this,Yo,null);m(this,tr,null);p(this,Yo,t),p(this,tr,t._uiManager),n(Ga,nu)||p(Ga,nu,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(n(this,Vs))return n(this,Vs);const{editorType:t,colorType:e,colorAndOpacityType:s,opacityType:i,color:r,opacity:a}=n(this,Yo),o=p(this,Nc,$t.isAlphaColorInputSupported&&i!==void 0),l=p(this,Vs,document.createElement("input"));if(l.type="color",o){l.setAttribute("alpha","");const c=B.hexNums[Math.round((a??1)*255)];l.value=(r||"#000000")+c}else l.value=r||"#000000";return l.className="basicColorPicker",l.tabIndex=0,l.setAttribute("data-l10n-id",n(Ga,nu)[t]),l.addEventListener("input",()=>{if(o){const c=ju(l.value);if(!c)return;const[h,d,f,g]=c,y=B.makeHexColor(h,d,f);s!==void 0?n(this,tr).updateParams(s,{color:y,opacity:g}):(n(this,tr).updateParams(e,y),n(this,tr).updateParams(i,g))}else n(this,tr).updateParams(e,l.value)},{signal:n(this,tr)._signal}),l}update(t){if(n(this,Vs))if(n(this,Nc)){const e=B.hexNums[Math.round(n(this,Yo).opacity*255)];n(this,Vs).value=t+e}else n(this,Vs).value=t}updateOpacity(t){if(!n(this,Vs)||!n(this,Nc))return;const e=B.hexNums[Math.round(t*255)];n(this,Vs).value=n(this,Yo).color+e}destroy(){var t;(t=n(this,Vs))==null||t.remove(),p(this,Vs,null)}hideDropdown(){}};Vs=new WeakMap,Nc=new WeakMap,Yo=new WeakMap,tr=new WeakMap,nu=new WeakMap,m(Ga,nu,null);let Jf=Ga;function Nv(u){return Math.floor(Qt(u,0,1)*255).toString(16).padStart(2,"0")}function Ah(u){return Qt(u,0,1)*255}class Bv{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=Ah(t),[t,t,t]}static G_HTML([t]){const e=Nv(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map(Ah)}static RGB_HTML(t){return`#${t.map(Nv).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[Ah(1-Math.min(1,t+i)),Ah(1-Math.min(1,s+i)),Ah(1-Math.min(1,e+i))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const i=1-t,r=1-e,a=1-s,o=Math.min(i,r,a);return["CMYK",i,r,a,o]}}class tx{create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){Ct("Abstract method `_createSVG` called.")}}class Zf extends tx{_createSVG(t){return document.createElementNS(Rs,t)}}const ex=9,_l=new WeakSet,sx=new Date().getTimezoneOffset()*60*1e3;class eg{static create(t){switch(t.data.annotationType){case oe.LINK:return new Xm(t);case oe.TEXT:return new nx(t);case oe.WIDGET:switch(t.data.fieldType){case"Tx":return new rx(t);case"Btn":return t.data.radioButton?new lx(t):t.data.checkBox?new ox(t):new cx(t);case"Ch":return new hx(t);case"Sig":return new ax(t)}return new Pl(t);case oe.POPUP:return new tm(t);case oe.FREETEXT:return new Ly(t);case oe.LINE:return new ux(t);case oe.SQUARE:return new fx(t);case oe.CIRCLE:return new px(t);case oe.POLYLINE:return new Fy(t);case oe.CARET:return new mx(t);case oe.INK:return new qm(t);case oe.POLYGON:return new gx(t);case oe.HIGHLIGHT:return new Oy(t);case oe.UNDERLINE:return new vx(t);case oe.SQUIGGLY:return new bx(t);case oe.STRIKEOUT:return new yx(t);case oe.STAMP:return new Ry(t);case oe.FILEATTACHMENT:return new wx(t);case oe.RICHMEDIA:case oe.SCREEN:return new Ny(t);default:return new te(t)}}}var Ko,Bc,bi,ru,Zg;const iv=class iv{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){m(this,ru);m(this,Ko,null);m(this,Bc,!1);m(this,bi,null);this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,this.hasOwnCommentButton=!1,e&&(this.contentElement=this.container=this._createContainer(s)),i&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t!=null&&t.str||e!=null&&e.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return iv._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){var s;const{data:t}=this,e=(s=this.annotationStorage)==null?void 0:s.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){var o;const t=(o=this.annotationStorage)==null?void 0:o.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;const{quadPoints:e,inkLists:s,rect:i}=this.data;let r=-1/0,a=-1/0;if((e==null?void 0:e.length)>=8){for(let l=0;l<e.length;l+=8)e[l+1]>a?(a=e[l+1],r=e[l+2]):e[l+1]===a&&(r=Math.max(r,e[l+2]));return[r,a]}if((s==null?void 0:s.length)>=1){for(const l of s)for(let c=0,h=l.length;c<h;c+=2)l[c+1]>a?(a=l[c+1],r=l[c]):l[c+1]===a&&(r=Math.max(r,l[c]));if(r!==1/0)return[r,a]}return i?[i[2],i[3]]:null}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:s,pageHeight:i,pageX:r,pageY:a}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-r)/s,t[1]=100*(t[1]-a)/i,t}get commentText(){var e,s,i;const{data:t}=this;return((s=(e=this.annotationStorage.getRawValue(`${Kh}${t.id}`))==null?void 0:e.popup)==null?void 0:s.contents)||((i=t.contentsObj)==null?void 0:i.str)||""}set commentText(t){const{data:e}=this,s={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:s})||this.annotationStorage.setValue(`${Kh}${e.id}`,{id:e.id,annotationType:e.annotationType,page:this.parent.page,popup:s,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){var t,e;(e=((t=n(this,bi))==null?void 0:t.popup)||this.popup)==null||e.remove(),p(this,bi,this.popup=null)}updateEdited(t){var r;if(!this.container)return;t.rect&&(n(this,Ko)||p(this,Ko,{rect:this.data.rect.slice(0)}));const{rect:e,popup:s}=t;e&&v(this,ru,Zg).call(this,e);let i=((r=n(this,bi))==null?void 0:r.popup)||this.popup;!i&&(s!=null&&s.text)&&(this._createPopup(s),i=n(this,bi).popup),i&&(i.updateEdited(t),s!=null&&s.deleted&&(i.remove(),p(this,bi,null),this.popup=null))}resetEdited(){var t;n(this,Ko)&&(v(this,ru,Zg).call(this,n(this,Ko).rect),(t=n(this,bi))==null||t.popup.resetEdited(),p(this,Ko,null))}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",e.id),!(this instanceof Pl)&&!(this instanceof Xm)&&!(this instanceof Ny)&&(r.tabIndex=0);const{style:a}=r;if(a.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(r.title=e.alternativeText),e.noRotate&&r.classList.add("norotate"),!e.rect||this instanceof tm){const{rotation:b}=e;return!e.hasOwnCanvas&&b!==0&&this.setRotation(b,r),r}const{width:o,height:l}=this;if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const b=e.borderStyle.horizontalCornerRadius,S=e.borderStyle.verticalCornerRadius;if(b>0||S>0){const x=`calc(${b}px * var(--total-scale-factor)) / calc(${S}px * var(--total-scale-factor))`;a.borderRadius=x}switch(e.borderStyle.style){case Ll.SOLID:a.borderStyle="solid";break;case Ll.DASHED:a.borderStyle="dashed";break;case Ll.BEVELED:lt("Unimplemented border style: beveled");break;case Ll.INSET:lt("Unimplemented border style: inset");break;case Ll.UNDERLINE:a.borderBottomStyle="solid";break}const w=e.borderColor||null;w?(p(this,Bc,!0),a.borderColor=B.makeHexColor(...w)):a.borderWidth=0}const c=B.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:h,pageHeight:d,pageX:f,pageY:g}=i.rawDims;a.left=`${100*(c[0]-f)/h}%`,a.top=`${100*(c[1]-g)/d}%`;const{rotation:y}=e;return e.hasOwnCanvas||y===0?(a.width=`${100*o/h}%`,a.height=`${100*l/d}%`):this.setRotation(y,r),r}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims;let{width:r,height:a}=this;t%180!==0&&([r,a]=[a,r]),e.style.width=`${100*r/s}%`,e.style.height=`${100*a/i}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const r=i.detail[e],a=r[0],o=r.slice(1);i.target.style[s]=Bv[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:Bv[`${a}_rgb`](o)})};return at(this,"_commonActions",{display:e=>{const{display:s}=e.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:e=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail)){const r=t[i]||s[i];r==null||r(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[i,r]of Object.entries(e)){const a=s[i];if(a){const o={detail:{[i]:r},target:t};a(o),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,r]=this.data.rect.map(b=>Math.fround(b));if(t.length===8){const[b,S,w,x]=t.subarray(2,6);if(i===b&&r===S&&e===w&&s===x)return}const{style:a}=this.container;let o;if(n(this,Bc)){const{borderColor:b,borderWidth:S}=a;a.borderWidth=0,o=["url('data:image/svg+xml;utf8,",`<svg xmlns="${Rs}" preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${b}" stroke-width="${S}">`],this.container.classList.add("hasBorder")}const l=i-e,c=r-s,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0),d.role="none";const f=h.createElement("defs");d.append(f);const g=h.createElement("clipPath"),y=`clippath_${this.data.id}`;g.setAttribute("id",y),g.setAttribute("clipPathUnits","objectBoundingBox"),f.append(g);for(let b=2,S=t.length;b<S;b+=8){const w=t[b],x=t[b+1],A=t[b+2],C=t[b+3],_=h.createElement("rect"),k=(A-e)/l,I=(r-x)/c,L=(w-A)/l,P=(x-C)/c;_.setAttribute("x",k),_.setAttribute("y",I),_.setAttribute("width",L),_.setAttribute("height",P),g.append(_),o==null||o.push(`<rect vector-effect="non-scaling-stroke" x="${k}" y="${I}" width="${L}" height="${P}"/>`)}n(this,Bc)&&(o.push("</g></svg>')"),a.backgroundImage=o.join("")),this.container.append(d),this.container.style.clipPath=`url(#${y})`}_createPopup(t=null){const{data:e}=this;let s,i;t?(s={str:t.text},i=t.date):(s=e.contentsObj,i=e.modificationDate),p(this,bi,new tm({data:{color:e.color,titleObj:e.titleObj,modificationDate:i,contentsObj:s,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}))}get hasPopupElement(){return!!(n(this,bi)||this.popup||this.data.popupRef)}get extraPopupElement(){return n(this,bi)}render(){Ct("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:r,id:a,exportValues:o}of i){if(r===-1||a===e)continue;const l=typeof o=="string"?o:null,c=document.querySelector(`[data-element-id="${a}"]`);if(c&&!_l.has(c)){lt(`_getElementsByName - element not allowed: ${a}`);continue}s.push({id:a,exportValue:l,domElement:c})}return s}for(const i of document.getElementsByName(t)){const{exportValue:r}=i,a=i.getAttribute("data-element-id");a!==e&&_l.has(i)&&s.push({id:a,exportValue:r,domElement:i})}return s}show(){var t;this.container&&(this.container.hidden=!1),(t=this.popup)==null||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),(t=this.popup)==null||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{var s;(s=this.linkService.eventBus)==null||s.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}updateOC(t){if(!this.data.oc||!t)return;t.isVisible(this.data.oc)?this.show():this.hide()}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":B.makeHexColor(...e)}};Ko=new WeakMap,Bc=new WeakMap,bi=new WeakMap,ru=new WeakSet,Zg=function(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}}}=this;s==null||s.splice(0,4,...t),e.left=`${100*(t[0]-o)/r}%`,e.top=`${100*(a-t[3]+l)/a}%`,i===0?(e.width=`${100*(t[2]-t[0])/r}%`,e.height=`${100*(t[3]-t[1])/a}%`):this.setRotation(i)};let te=iv;class ix extends te{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{editor:t}=this;t.hasComment&&this._createPopup(t.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}}var ii,Ua,ky,Ty;class Xm extends te{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});m(this,ii);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:s}=this,i=document.createElement("a");i.setAttribute("data-element-id",e.id);let r=!1;return e.url?(s.addLinkAttributes(i,e.url,e.newWindow),r=!0):e.action?(this._bindNamedAction(i,e.action,e.overlaidText),r=!0):e.attachment?(v(this,ii,ky).call(this,i,e.attachmentId,e.attachment,e.overlaidText,e.attachmentDest),r=!0):e.setOCGState?(v(this,ii,Ty).call(this,i,e.setOCGState,e.overlaidText),r=!0):e.dest?(this._bindLink(i,e.dest,e.overlaidText),r=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,e),r=!0),e.resetForm?(this._bindResetFormAction(i,e.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(i,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&(this.contentElement=i,this.container.append(i)),this.container}_bindLink(e,s,i=""){e.href=this.linkService.getDestinationHash(s),e.onclick=()=>(s&&this.linkService.goToDestination(s),!1),(s||s==="")&&v(this,ii,Ua).call(this),i&&(e.title=i)}_bindNamedAction(e,s,i=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(s),!1),i&&(e.title=i),v(this,ii,Ua).call(this)}_bindJSAction(e,s){e.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of Object.keys(s.actions)){const a=i.get(r);a&&(e[a]=()=>{var o;return(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:r}}),!1})}s.overlaidText&&(e.title=s.overlaidText),e.onclick||(e.onclick=()=>!1),v(this,ii,Ua).call(this)}_bindResetFormAction(e,s){const i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),v(this,ii,Ua).call(this),!this._fieldObjects){lt('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(e.onclick=()=>!1);return}e.onclick=()=>{var d;i==null||i();const{fields:r,refs:a,include:o}=s,l=[];if(r.length!==0||a.length!==0){const f=new Set(a);for(const g of r){const y=this._fieldObjects[g]||[];for(const{id:b}of y)f.add(b)}for(const g of Object.values(this._fieldObjects))for(const y of g)f.has(y.id)===o&&l.push(y)}else for(const f of Object.values(this._fieldObjects))l.push(...f);const c=this.annotationStorage,h=[];for(const f of l){const{id:g}=f;switch(h.push(g),f.type){case"text":{const b=f.defaultValue||"";c.setValue(g,{value:b});break}case"checkbox":case"radiobutton":{const b=f.defaultValue===f.exportValues;c.setValue(g,{value:b});break}case"combobox":case"listbox":{const b=f.defaultValue||"";c.setValue(g,{value:b});break}default:continue}const y=document.querySelector(`[data-element-id="${g}"]`);if(y){if(!_l.has(y)){lt(`_bindResetFormAction - element not allowed: ${g}`);continue}}else continue;y.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((d=this.linkService.eventBus)==null||d.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:h,name:"ResetForm"}})),!1}}}ii=new WeakSet,Ua=function(){this.container.setAttribute("data-internal-link","")},ky=function(e,s,i,r="",a=null){e.href=this.linkService.getAnchorUrl(""),i.description?e.title=i.description:r&&(e.title=r);const o=async()=>{var c;const l=await this.linkService.getAttachmentContent(s);l&&((c=this.downloadManager)==null||c.openOrDownloadData(l,i.filename,a))};e.onclick=()=>(o(),!1),v(this,ii,Ua).call(this)},Ty=function(e,s,i=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),i&&(e.title=i),v(this,ii,Ua).call(this)};class nx extends te{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(t),this.container}}class Pl extends te{render(){return this.container}_getKeyModifier(t){return $t.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,r){s.includes("mouse")?t.addEventListener(s,a=>{var o;(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(a),shift:a.shiftKey,modifier:this._getKeyModifier(a)}})}):t.addEventListener(s,a=>{var o;if(s==="blur"){if(!e.focused||!a.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}r&&((o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(a)}}))})}_setEventListeners(t,e,s,i){var r,a,o;for(const[l,c]of s)(c==="Action"||(r=this.data.actions)!=null&&r[c])&&((c==="Focus"||c==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,l,c,i),c==="Focus"&&!((a=this.data.actions)!=null&&a.Blur)?this._setEventListener(t,e,"blur","Blur",null):c==="Blur"&&!((o=this.data.actions)!=null&&o.Focus)&&this._setEventListener(t,e,"focus","Focus",null))}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||ex,r=t.style;let a;const o=2,l=c=>Math.round(10*c)/10;if(this.data.multiLine){const c=Math.abs(this.data.rect[3]-this.data.rect[1]-o),h=Math.round(c/(qp*i))||1,d=c/h;a=Math.min(i,l(d/qp))}else{const c=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(i,l(c/qp))}r.fontSize=`calc(${a}px * var(--total-scale-factor))`,r.color=B.makeHexColor(...s),this.data.textAlignment!==null&&!this.data.comb&&(r.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class rx extends Pl{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){const r=this.annotationStorage;for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=s),r.setValue(a.id,{[i]:s})}render(){var i,r;const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const a=t.getValue(e,{value:this.data.fieldValue});let o=a.value||"";const l=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;l&&o.length>l&&(o=o.slice(0,l));let c=a.formattedValue||((i=this.data.textContent)==null?void 0:i.join(`
`))||null;c&&this.data.comb&&(c=c.replaceAll(/\s+/g,""));const h={userValue:o,formattedValue:c,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=c??o,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type=this.data.password?"password":"text",s.setAttribute("value",c??o),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(this.container.classList.add("hasOwnCanvas"),t.has(e)&&this.container.classList.add("sandboxModified")),_l.add(s),this.contentElement=s,s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=0;const{datetimeFormat:d,datetimeType:f,timeStep:g}=this.data,y=!!f&&this.enableScripting;d&&(s.title=d),this._setRequired(s,this.data.required),l&&(s.maxLength=l),s.addEventListener("input",S=>{t.setValue(e,{value:S.target.value}),this.setPropertyOnSiblings(s,"value",S.target.value,"value"),h.formattedValue=null}),s.addEventListener("resetform",S=>{const w=this.data.defaultFieldValue??"";s.value=h.userValue=w,h.formattedValue=null});let b=S=>{const{formattedValue:w}=h;w!=null&&(S.target.value=w),S.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",w=>{var A;if(h.focused)return;const{target:x}=w;if(y&&(x.type=f,g&&(x.step=g)),h.userValue){const C=h.userValue;if(y)if(f==="time"){const _=new Date(C),k=[_.getHours(),_.getMinutes(),_.getSeconds()];x.value=k.map(I=>I.toString().padStart(2,"0")).join(":")}else x.value=new Date(C-sx).toISOString().split(f==="date"?"T":".",1)[0];else x.value=C}h.lastCommittedValue=x.value,h.commitKey=1,(A=this.data.actions)!=null&&A.Focus||(h.focused=!0)}),s.addEventListener("updatefromsandbox",w=>{this.container.classList.add("sandboxModified");const x={value(A){h.userValue=A.detail.value??"",y||t.setValue(e,{value:h.userValue.toString()}),A.target.value=h.userValue},formattedValue(A){const{formattedValue:C}=A.detail;h.formattedValue=C,C!=null&&A.target!==document.activeElement&&(A.target.value=C);const _={formattedValue:C};y&&(_.value=C),t.setValue(e,_)},selRange(A){A.target.setSelectionRange(...A.detail.selRange)},charLimit:A=>{var I;const{charLimit:C}=A.detail,{target:_}=A;if(C===0){_.removeAttribute("maxLength");return}_.setAttribute("maxLength",C);let k=h.userValue;!k||k.length<=C||(k=k.slice(0,C),_.value=h.userValue=k,t.setValue(e,{value:k}),(I=this.linkService.eventBus)==null||I.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:k,willCommit:!0,commitKey:1,selStart:_.selectionStart,selEnd:_.selectionEnd}}))}};this._dispatchEventFromSandbox(x,w)}),s.addEventListener("keydown",w=>{var C;h.commitKey=1;let x=-1;if(w.key==="Escape"?x=0:w.key==="Enter"&&!this.data.multiLine?x=2:w.key==="Tab"&&(h.commitKey=3),x===-1)return;const{value:A}=w.target;h.lastCommittedValue!==A&&(h.lastCommittedValue=A,h.userValue=A,(C=this.linkService.eventBus)==null||C.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:A,willCommit:!0,commitKey:x,selStart:w.target.selectionStart,selEnd:w.target.selectionEnd}}))});const S=b;b=null,s.addEventListener("blur",w=>{var C,_;if(!h.focused||!w.relatedTarget)return;(C=this.data.actions)!=null&&C.Blur||(h.focused=!1);const{target:x}=w;let{value:A}=x;if(y){if(A&&f==="time"){const k=A.split(":").map(I=>parseInt(I,10));A=new Date(2e3,0,1,k[0],k[1],k[2]||0).valueOf(),x.step=""}else A.includes("T")||(A=`${A}T00:00`),A=new Date(A).valueOf();x.type="text"}h.userValue=A,h.lastCommittedValue!==A&&((_=this.linkService.eventBus)==null||_.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:A,willCommit:!0,commitKey:h.commitKey,selStart:w.target.selectionStart,selEnd:w.target.selectionEnd}})),S(w)}),(r=this.data.actions)!=null&&r.Keystroke&&s.addEventListener("beforeinput",w=>{var P;h.lastCommittedValue=null;const{data:x,target:A}=w,{value:C,selectionStart:_,selectionEnd:k}=A;let I=_,L=k;switch(w.inputType){case"deleteWordBackward":{const D=C.substring(0,_).match(/\w*\W*$/);D&&(I-=D[0].length);break}case"deleteWordForward":{const D=C.substring(_).match(/^\W*\w*/);D&&(L+=D[0].length);break}case"deleteContentBackward":_===k&&(I-=1);break;case"deleteContentForward":_===k&&(L+=1);break}w.preventDefault(),(P=this.linkService.eventBus)==null||P.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:C,change:x||"",willCommit:!1,selStart:I,selEnd:L}})}),this._setEventListeners(s,h,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],w=>w.target.value)}if(b&&s.addEventListener("blur",b),this.data.comb){const w=(this.data.rect[2]-this.data.rect[0])/l;s.classList.add("comb"),s.style.setProperty("--comb-width",`calc(${w}px * var(--total-scale-factor))`);const x=this.data.textAlignment;if(x===1||x===2){const A=()=>{const C=l-s.value.length;s.style.setProperty("--comb-offset",`${x===1?C>>1:C}`)};A();for(const C of["input","blur","resetform","updatefromsandbox"])s.addEventListener(C,A)}}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class ax extends Pl{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class ox extends Pl{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;typeof i=="string"&&(i=i!=="Off",t.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const r=document.createElement("input");return _l.add(r),r.setAttribute("data-element-id",s),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=e.fieldName,i&&r.setAttribute("checked",!0),r.setAttribute("exportValue",e.exportValue),r.tabIndex=0,r.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const c of this._getElementsByName(o,s)){const h=l&&c.exportValue===e.exportValue;c.domElement&&(c.domElement.checked=h),t.setValue(c.id,{value:h})}t.setValue(s,{value:l})}),r.addEventListener("resetform",a=>{const o=e.defaultFieldValue||"Off";a.target.checked=o===e.exportValue}),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",a=>{const o={value(l){l.target.checked=l.detail.value!=="Off",t.setValue(s,{value:l.target.checked})}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class lx extends Pl{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.buttonValue!==null&&e.fieldValue===e.buttonValue}).value;if(typeof i=="string"&&(i=i!==e.buttonValue,t.setValue(s,{value:i})),i)for(const a of this._getElementsByName(e.fieldName,s))t.setValue(a.id,{value:!1});const r=document.createElement("input");if(_l.add(r),r.setAttribute("data-element-id",s),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=e.fieldName,i&&r.setAttribute("checked",!0),r.tabIndex=0,r.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const c of this._getElementsByName(o,s))t.setValue(c.id,{value:!1});t.setValue(s,{value:l})}),r.addEventListener("resetform",a=>{const o=e.defaultFieldValue;a.target.checked=o!=null&&o===e.buttonValue}),this.enableScripting&&this.hasJSActions){const a=e.buttonValue;r.addEventListener("updatefromsandbox",o=>{const l={value:c=>{const h=a===c.detail.value;for(const d of this._getElementsByName(c.target.name)){const f=h&&d.id===s;d.domElement&&(d.domElement.checked=f),t.setValue(d.id,{value:f})}}};this._dispatchEventFromSandbox(l,o)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)}return this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class cx extends Xm{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",s=>{this._dispatchEventFromSandbox({},s)})),t}}class hx extends Pl{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");_l.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=0;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",d=>{const f=this.data.defaultFieldValue;for(const g of i.options)g.selected=g.value===f});const a=(d,f)=>{const g=f.replaceAll(" "," ");d.textContent=g,g!==f&&d.setAttribute("display-value",f)};for(const d of this.data.options){const f=document.createElement("option");a(f,d.displayValue),f.value=d.exportValue,s.value.includes(d.exportValue)&&(f.setAttribute("selected",!0),r=!1),i.append(f)}let o=null;if(r){const d=document.createElement("option");d.value=" ",d.setAttribute("hidden",!0),d.setAttribute("selected",!0),i.prepend(d),o=()=>{d.remove(),i.removeEventListener("input",o),o=null},i.addEventListener("input",o)}const l=d=>{const f=d?"value":"textContent",{options:g,multiple:y}=i;return y?Array.prototype.filter.call(g,b=>b.selected).map(b=>b[f]):g.selectedIndex===-1?null:g[g.selectedIndex][f]};let c=l(!1);const h=d=>{const f=d.target.options;return Array.prototype.map.call(f,g=>({displayValue:g.getAttribute("display-value")||g.textContent,exportValue:g.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",d=>{const f={value(g){o==null||o();const y=g.detail.value,b=new Set(Array.isArray(y)?y:[y]);for(const S of i.options)S.selected=b.has(S.value);t.setValue(e,{value:l(!0)}),c=l(!1)},multipleSelection(g){i.multiple=!0},remove(g){const y=i.options,b=g.detail.remove;y[b].selected=!1,i.remove(b),y.length>0&&Array.prototype.findIndex.call(y,w=>w.selected)===-1&&(y[0].selected=!0),t.setValue(e,{value:l(!0),items:h(g)}),c=l(!1)},clear(g){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),c=l(!1)},insert(g){const{index:y,displayValue:b,exportValue:S}=g.detail.insert,w=i.children[y],x=document.createElement("option");a(x,b),x.value=S,w?w.before(x):i.append(x),t.setValue(e,{value:l(!0),items:h(g)}),c=l(!1)},items(g){const{items:y}=g.detail;for(;i.length!==0;)i.remove(0);for(const b of y){const{displayValue:S,exportValue:w}=b,x=document.createElement("option");a(x,S),x.value=w,i.append(x)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:l(!0),items:h(g)}),c=l(!1)},indices(g){const y=new Set(g.detail.indices);for(const b of g.target.options)b.selected=y.has(b.index);t.setValue(e,{value:l(!0)}),c=l(!1)},editable(g){g.target.disabled=!g.detail.editable}};this._dispatchEventFromSandbox(f,d)}),i.addEventListener("input",d=>{var y;const f=l(!0),g=l(!1);t.setValue(e,{value:f}),d.preventDefault(),(y=this.linkService.eventBus)==null||y.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:c,change:g,changeEx:f,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],d=>d.target.value)):i.addEventListener("input",function(d){t.setValue(e,{value:l(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}var au,em;class tm extends te{constructor(e){const{data:s,elements:i,parent:r}=e,a=!!r._commentManager;super(e,{isRenderable:!a&&te._hasPopupData(s)});m(this,au);if(this.elements=i,a&&te._hasPopupData(s)){const o=this.popup=v(this,au,em).call(this);for(const l of i)l.popup=o}else this.popup=null}render(){const{container:e}=this;e.classList.add("popupAnnotation"),e.role="comment";const s=this.popup=v(this,au,em).call(this),i=[];for(const r of this.elements)r.popup=s,r.container.ariaHasPopup="dialog",i.push(r.data.id),r.addHighlightArea();return this.container.setAttribute("aria-controls",i.map(r=>`${Bl}${r}`).join(",")),this.container}}au=new WeakSet,em=function(){return new dx({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open,commentManager:this.parent._commentManager})};var Gs,ra,Ap,Sp,$c,Uc,de,un,aa,Qo,Hc,zc,fn,js,er,sr,ue,ir,oa,ou,nr,Vc,Jo,la,De,ca,gt,Ef,sm,im,nm,Cf,rm,Py,My,Iy,Dy,_f,kf,am;class dx{constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:r,contentsObj:a,richText:o,parent:l,rect:c,parentRect:h,open:d,commentManager:f=null}){m(this,gt);m(this,Gs,null);m(this,ra,v(this,gt,Iy).bind(this));m(this,Ap,v(this,gt,am).bind(this));m(this,Sp,v(this,gt,kf).bind(this));m(this,$c,v(this,gt,_f).bind(this));m(this,Uc,null);m(this,de,null);m(this,un,null);m(this,aa,null);m(this,Qo,null);m(this,Hc,null);m(this,zc,null);m(this,fn,!1);m(this,js,null);m(this,er,null);m(this,sr,null);m(this,ue,null);m(this,ir,null);m(this,oa,null);m(this,ou,null);m(this,nr,null);m(this,Vc,null);m(this,Jo,null);m(this,la,!1);m(this,De,null);m(this,ca,null);p(this,de,t),p(this,Vc,i),p(this,un,a),p(this,nr,o),p(this,Hc,l),p(this,Uc,e),p(this,ou,c),p(this,zc,h),p(this,Qo,s),p(this,Gs,f),p(this,De,s[0]),p(this,aa,qf.toDateObject(r)),this.trigger=s.flatMap(g=>g.getElementsToTriggerPopup()),f||(v(this,gt,Ef).call(this),n(this,de).hidden=!0,d&&v(this,gt,_f).call(this))}renderCommentButton(){if(n(this,ue)){n(this,ue).parentNode||n(this,De).container.after(n(this,ue));return}if(n(this,ir)||v(this,gt,sm).call(this),!n(this,ir))return;const{signal:t}=p(this,er,new AbortController),e=n(this,De).hasOwnCommentButton,s=()=>{n(this,Gs).toggleCommentPopup(this,!0,void 0,!e)},i=()=>{n(this,Gs).toggleCommentPopup(this,!1,!0,!e)},r=()=>{n(this,Gs).toggleCommentPopup(this,!1,!1)};if(e){p(this,ue,n(this,De).container);for(const a of this.trigger)a.ariaHasPopup="dialog",a.ariaControls="commentPopup",a.addEventListener("keydown",n(this,ra),{signal:t}),a.addEventListener("click",s,{signal:t}),a.addEventListener("pointerenter",i,{signal:t}),a.addEventListener("pointerleave",r,{signal:t}),a.classList.add("popupTriggerArea")}else{const a=p(this,ue,document.createElement("button"));a.className="annotationCommentButton";const o=n(this,De).container;a.style.zIndex=parseInt(o.style.zIndex,10)+1,a.tabIndex=0,a.ariaHasPopup="dialog",a.ariaControls="commentPopup",a.setAttribute("data-l10n-id","pdfjs-show-comment-button"),v(this,gt,nm).call(this),v(this,gt,im).call(this),a.addEventListener("keydown",n(this,ra),{signal:t}),a.addEventListener("click",s,{signal:t}),a.addEventListener("pointerenter",i,{signal:t}),a.addEventListener("pointerleave",r,{signal:t}),o.after(a)}}get commentButtonColor(){const{color:t,opacity:e}=n(this,De).commentData;return t?n(this,Hc)._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{var t;(t=n(this,ue))==null||t.focus()},0)}getData(){const{richText:t,color:e,opacity:s,creationDate:i,modificationDate:r}=n(this,De).commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:s,creationDate:i,modificationDate:r}}get elementBeforePopup(){return n(this,ue)}get comment(){return n(this,ca)||p(this,ca,n(this,De).commentText),n(this,ca)}set comment(t){t!==this.comment&&(n(this,De).commentText=p(this,ca,t))}focus(){var t;(t=n(this,De).container)==null||t.focus()}get parentBoundingClientRect(){return n(this,De).layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){n(this,ue)&&(n(this,ue).classList.toggle("selected",t),n(this,ue).ariaExpanded=e)}setSelectedCommentButton(t){n(this,ue).classList.toggle("selected",t)}get commentPopupPosition(){if(n(this,oa))return n(this,oa);const{x:t,y:e,height:s}=n(this,ue).getBoundingClientRect(),{x:i,y:r,width:a,height:o}=n(this,De).layer.getBoundingClientRect();return[(t-i)/a,(e+s-r)/o]}set commentPopupPosition(t){p(this,oa,t)}hasDefaultPopupPosition(){return n(this,oa)===null}get commentButtonPosition(){return n(this,ir)}get commentButtonWidth(){return n(this,ue).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,s]=n(this,oa)||this.commentButtonPosition.map(c=>c/100),i=this.parentBoundingClientRect,{x:r,y:a,width:o,height:l}=i;n(this,Gs).showDialog(null,this,r+e*o,a+s*l,{...t,parentDimensions:i})}render(){var s,i;if(n(this,js))return;const t=p(this,js,document.createElement("div"));if(t.className="popup",n(this,Uc)){const r=t.style.outlineColor=B.makeHexColor(...n(this,Uc));t.style.backgroundColor=`color-mix(in srgb, ${r} 30%, white)`}const e=document.createElement("span");if(e.className="header",(s=n(this,Vc))!=null&&s.str){const r=document.createElement("span");r.className="title",e.append(r),{dir:r.dir,str:r.textContent}=n(this,Vc)}if(t.append(e),n(this,aa)){const r=document.createElement("time");r.className="popupDate",r.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),r.setAttribute("data-l10n-args",JSON.stringify({dateObj:n(this,aa).valueOf()})),r.dateTime=n(this,aa).toISOString(),e.append(r)}ib({html:n(this,gt,Cf)||n(this,un).str,dir:(i=n(this,un))==null?void 0:i.dir,className:"popupContent"},t),n(this,de).append(t)}updateEdited({rect:t,popup:e,deleted:s}){var i;if(n(this,Gs)){s?(this.remove(),p(this,ca,null)):e&&(e.deleted?this.remove():(v(this,gt,nm).call(this),p(this,ca,e.text))),t&&(p(this,ir,null),v(this,gt,sm).call(this),v(this,gt,im).call(this));return}if(s||e!=null&&e.deleted){this.remove();return}v(this,gt,Ef).call(this),n(this,Jo)||p(this,Jo,{contentsObj:n(this,un),richText:n(this,nr)}),t&&p(this,sr,null),e&&e.text&&(p(this,nr,v(this,gt,My).call(this,e.text)),p(this,aa,qf.toDateObject(e.date)),p(this,un,null)),(i=n(this,js))==null||i.remove(),p(this,js,null)}resetEdited(){var t;n(this,Jo)&&({contentsObj:qt(this,un)._,richText:qt(this,nr)._}=n(this,Jo),p(this,Jo,null),(t=n(this,js))==null||t.remove(),p(this,js,null),p(this,sr,null))}remove(){var t,e,s;if((t=n(this,er))==null||t.abort(),p(this,er,null),(e=n(this,js))==null||e.remove(),p(this,js,null),p(this,la,!1),p(this,fn,!1),(s=n(this,ue))==null||s.remove(),p(this,ue,null),this.trigger)for(const i of this.trigger)i.classList.remove("popupTriggerArea")}forceHide(){p(this,la,this.isVisible),n(this,la)&&(n(this,de).hidden=!0)}maybeShow(){n(this,Gs)||(v(this,gt,Ef).call(this),n(this,la)&&(n(this,js)||v(this,gt,kf).call(this),p(this,la,!1),n(this,de).hidden=!1))}get isVisible(){return n(this,Gs)?!1:n(this,de).hidden===!1}}Gs=new WeakMap,ra=new WeakMap,Ap=new WeakMap,Sp=new WeakMap,$c=new WeakMap,Uc=new WeakMap,de=new WeakMap,un=new WeakMap,aa=new WeakMap,Qo=new WeakMap,Hc=new WeakMap,zc=new WeakMap,fn=new WeakMap,js=new WeakMap,er=new WeakMap,sr=new WeakMap,ue=new WeakMap,ir=new WeakMap,oa=new WeakMap,ou=new WeakMap,nr=new WeakMap,Vc=new WeakMap,Jo=new WeakMap,la=new WeakMap,De=new WeakMap,ca=new WeakMap,gt=new WeakSet,Ef=function(){var e;if(n(this,er))return;p(this,er,new AbortController);const{signal:t}=n(this,er);for(const s of this.trigger)s.addEventListener("click",n(this,$c),{signal:t}),s.addEventListener("pointerenter",n(this,Sp),{signal:t}),s.addEventListener("pointerleave",n(this,Ap),{signal:t}),s.classList.add("popupTriggerArea");for(const s of n(this,Qo))(e=s.container)==null||e.addEventListener("keydown",n(this,ra),{signal:t})},sm=function(){const t=n(this,Qo).find(e=>e.hasCommentButton);t&&p(this,ir,t._normalizePoint(t.commentButtonPosition))},im=function(){if(n(this,De).extraPopupElement&&!n(this,De).editor)return;n(this,ue)||this.renderCommentButton();const[t,e]=n(this,ir),{style:s}=n(this,ue);s.left=`calc(${t}%)`,s.top=`calc(${e}% - var(--comment-button-dim))`},nm=function(){n(this,De).extraPopupElement||(n(this,ue)||this.renderCommentButton(),n(this,ue).style.backgroundColor=this.commentButtonColor||"")},Cf=function(){const t=n(this,nr),e=n(this,un);return t!=null&&t.str&&(!(e!=null&&e.str)||e.str===t.str)&&n(this,nr).html||null},rm=function(){var t,e,s;return((s=(e=(t=n(this,gt,Cf))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.fontSize)||0},Py=function(){var t,e,s;return((s=(e=(t=n(this,gt,Cf))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.color)||null},My=function(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:n(this,gt,Py),fontSize:n(this,gt,rm)?`calc(${n(this,gt,rm)}px * var(--total-scale-factor))`:""}};for(const r of t.split(`
`))e.push({name:"span",value:r,attributes:i});return s},Iy=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&n(this,fn))&&v(this,gt,_f).call(this)},Dy=function(){if(n(this,sr)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:r}}}=n(this,Hc);let a=!!n(this,zc),o=a?n(this,zc):n(this,ou);for(const y of n(this,Qo))if(!o||B.intersect(y.data.rect,o)!==null){o=y.data.rect,a=!0;break}const l=B.normalizeRect([o[0],t[3]-o[1]+t[1],o[2],t[3]-o[3]+t[1]]),h=a?o[2]-o[0]+5:0,d=l[0]+h,f=l[1];p(this,sr,[100*(d-i)/e,100*(f-r)/s]);const{style:g}=n(this,de);g.left=`${n(this,sr)[0]}%`,g.top=`${n(this,sr)[1]}%`},_f=function(){if(n(this,Gs)){n(this,Gs).toggleCommentPopup(this,!1);return}p(this,fn,!n(this,fn)),n(this,fn)?(v(this,gt,kf).call(this),n(this,de).addEventListener("click",n(this,$c)),n(this,de).addEventListener("keydown",n(this,ra))):(v(this,gt,am).call(this),n(this,de).removeEventListener("click",n(this,$c)),n(this,de).removeEventListener("keydown",n(this,ra)))},kf=function(){n(this,js)||this.render(),this.isVisible?n(this,fn)&&n(this,de).classList.add("focused"):(v(this,gt,Dy).call(this),n(this,de).hidden=!1,n(this,de).style.zIndex=parseInt(n(this,de).style.zIndex,10)+1e3)},am=function(){n(this,de).classList.remove("focused"),!(n(this,fn)||!this.isVisible)&&(n(this,de).hidden=!0,n(this,de).style.zIndex=parseInt(n(this,de).style.zIndex,10)-1e3)};class Ly extends te{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=ot.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=this.contentElement=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}var lu;class ux extends te{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,lu,null)}render(){this.container.classList.add("lineAnnotation");const{data:e,width:s,height:i}=this,r=this.svgFactory.create(s,i,!0),a=p(this,lu,this.svgFactory.createElement("svg:line"));return a.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),a.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),a.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),a.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),a.setAttribute("stroke-width",e.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),r.append(a),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return n(this,lu)}addHighlightArea(){this.container.classList.add("highlightArea")}}lu=new WeakMap;var cu;class fx extends te{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,cu,null)}render(){this.container.classList.add("squareAnnotation");const{data:e,width:s,height:i}=this,r=this.svgFactory.create(s,i,!0),a=e.borderStyle.width,o=p(this,cu,this.svgFactory.createElement("svg:rect"));return o.setAttribute("x",a/2),o.setAttribute("y",a/2),o.setAttribute("width",s-a),o.setAttribute("height",i-a),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),r.append(o),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return n(this,cu)}addHighlightArea(){this.container.classList.add("highlightArea")}}cu=new WeakMap;var hu;class px extends te{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,hu,null)}render(){this.container.classList.add("circleAnnotation");const{data:e,width:s,height:i}=this,r=this.svgFactory.create(s,i,!0),a=e.borderStyle.width,o=p(this,hu,this.svgFactory.createElement("svg:ellipse"));return o.setAttribute("cx",s/2),o.setAttribute("cy",i/2),o.setAttribute("rx",s/2-a/2),o.setAttribute("ry",i/2-a/2),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),r.append(o),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return n(this,hu)}addHighlightArea(){this.container.classList.add("highlightArea")}}hu=new WeakMap;var du;class Fy extends te{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,du,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:s,borderStyle:i,popupRef:r},width:a,height:o}=this;if(!s)return this.container;const l=this.svgFactory.create(a,o,!0);let c=[];for(let d=0,f=s.length;d<f;d+=2){const g=s[d]-e[0],y=e[3]-s[d+1];c.push(`${g},${y}`)}c=c.join(" ");const h=p(this,du,this.svgFactory.createElement(this.svgElementName));return h.setAttribute("points",c),h.setAttribute("stroke-width",i.width||1),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),l.append(h),this.container.append(l),!r&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return n(this,du)}addHighlightArea(){this.container.classList.add("highlightArea")}}du=new WeakMap;class gx extends Fy{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class mx extends te{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}}var uu,Zo,fu,om;class qm extends te{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,fu);m(this,uu,null);m(this,Zo,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?ot.HIGHLIGHT:ot.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,rotation:s,inkLists:i,borderStyle:r,popupRef:a}}=this,{transform:o,width:l,height:c}=v(this,fu,om).call(this,s,e),h=this.svgFactory.create(l,c,!0),d=p(this,uu,this.svgFactory.createElement("svg:g"));h.append(d),d.setAttribute("stroke-width",r.width||1),d.setAttribute("stroke-linecap","round"),d.setAttribute("stroke-linejoin","round"),d.setAttribute("stroke-miterlimit",10),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),d.setAttribute("transform",o);for(let f=0,g=i.length;f<g;f++){const y=this.svgFactory.createElement(this.svgElementName);n(this,Zo).push(y),y.setAttribute("points",i[f].join(",")),d.append(y)}return!a&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(h),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);const{thickness:s,points:i,rect:r}=e,a=n(this,uu);if(s>=0&&a.setAttribute("stroke-width",s||1),i)for(let o=0,l=n(this,Zo).length;o<l;o++)n(this,Zo)[o].setAttribute("points",i[o].join(","));if(r){const{transform:o,width:l,height:c}=v(this,fu,om).call(this,this.data.rotation,r);a.parentElement.setAttribute("viewBox",`0 0 ${l} ${c}`),a.setAttribute("transform",o)}}getElementsToTriggerPopup(){return n(this,Zo)}addHighlightArea(){this.container.classList.add("highlightArea")}}uu=new WeakMap,Zo=new WeakMap,fu=new WeakSet,om=function(e,s){switch(e){case 90:return{transform:`rotate(90) translate(${-s[0]},${s[1]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};case 180:return{transform:`rotate(180) translate(${-s[2]},${s[1]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]};case 270:return{transform:`rotate(270) translate(${-s[2]},${s[3]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};default:return{transform:`translate(${-s[0]},${s[3]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]}}};class Oy extends te{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=ot.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){const s=document.createElement("mark");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class vx extends te{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("underlineAnnotation"),t){const s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class bx extends te{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("squigglyAnnotation"),t){const s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class yx extends te{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("strikeoutAnnotation"),t){const s=document.createElement("s");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Ry extends te{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=ot.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}var pu,gu,lm;class wx extends te{constructor(e){var r;super(e,{isRenderable:!0});m(this,gu);m(this,pu,null);const{fileId:s,file:i}=this.data;this.filename=i.filename,this.content=i.content,this.fileId=s,(r=this.linkService.eventBus)==null||r.dispatch("fileattachmentannotation",{source:this,attachmentId:this.fileId,...i})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:s}=this;let i;s.hasAppearance||s.fillAlpha===0?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(s.name)?"paperclip":"pushpin"}.svg`,s.fillAlpha&&s.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(s.fillAlpha*100)}%);`)),i.addEventListener("dblclick",v(this,gu,lm).bind(this)),p(this,pu,i);const{isMac:r}=$t.platform;return e.addEventListener("keydown",a=>{a.key==="Enter"&&(r?a.metaKey:a.ctrlKey)&&v(this,gu,lm).call(this)}),!s.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):i.classList.add("popupTriggerArea"),e.append(i),e}getElementsToTriggerPopup(){return n(this,pu)}addHighlightArea(){this.container.classList.add("highlightArea")}}pu=new WeakMap,gu=new WeakSet,lm=async function(){var a;const{fileId:e,filename:s,content:i}=this,r=await this.linkService.getAttachmentContent(e)||i;r&&((a=this.downloadManager)==null||a.openOrDownloadData(r,s))};var Gc,tl,rr,kl,By,cm;class Ny extends te{constructor(e){super(e,{isRenderable:!!e.data.richMedia});m(this,kl);m(this,Gc,new AbortController);m(this,tl,null);m(this,rr,null)}render(){this.container.classList.add("mediaAnnotation");const{filename:e}=this.data.richMedia,s=document.createElement("button");return s.className="mediaPlayButton",s.type="button",s.title=s.ariaLabel=e,s.addEventListener("click",()=>v(this,kl,By).call(this,s),{signal:n(this,Gc).signal}),this.container.append(s),this.container}destroy(){n(this,Gc).abort(),n(this,rr)&&(n(this,rr).pause(),n(this,rr).removeAttribute("src"),n(this,rr).load(),p(this,rr,null)),v(this,kl,cm).call(this)}}Gc=new WeakMap,tl=new WeakMap,rr=new WeakMap,kl=new WeakSet,By=async function(e){const{fileId:s,filename:i,contentType:r}=this.data.richMedia;e.disabled=!0;let a;try{a=await this.linkService.getAttachmentContent(s)}catch{return}finally{e.disabled=!1}if(!a||!e.isConnected)return;const{signal:o}=n(this,Gc),l=URL.createObjectURL(new Blob([a],{type:r}));p(this,tl,l);const c=r.startsWith("audio/"),h=document.createElement(c?"audio":"video");if(p(this,rr,h),h.className="mediaContent",this._setBackgroundColor(h),h.src=l,h.title=i,h.controls=!0,h.autoplay=!0,h.tabIndex=0,c){let d=!1,f=!1;const g=()=>{h.controls=d||f};this.container.addEventListener("pointerenter",()=>{d=!0,g()},{signal:o}),this.container.addEventListener("pointerleave",()=>{d=!1,g()},{signal:o}),this.container.addEventListener("focusin",()=>{f=!0,g()},{signal:o}),this.container.addEventListener("focusout",()=>{f=!1,g()},{signal:o})}h.addEventListener("emptied",()=>v(this,kl,cm).call(this,l),{once:!0,signal:o}),e.replaceWith(h),h.play().catch(()=>{})},cm=function(e=n(this,tl)){e&&e===n(this,tl)&&(URL.revokeObjectURL(e),p(this,tl,null))};var ha,el,jc,ar,mu,sl,es,vu,xn,Tf,Pf;const nv=class nv{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:r,viewport:a,structTreeLayer:o,commentManager:l,linkService:c,annotationStorage:h}){m(this,xn);m(this,ha,null);m(this,el,null);m(this,jc,null);m(this,ar,new Map);m(this,mu,null);m(this,sl,null);m(this,es,[]);m(this,vu,!1);M(this,"zIndex",0);this.div=t,p(this,ha,e),p(this,el,s),p(this,mu,o||null),p(this,sl,c||null),p(this,jc,h||new jm),this.page=r,this.viewport=a,this._annotationEditorUIManager=i,this._commentManager=l||null}hasEditableAnnotations(){return n(this,ar).size>0}async render(t){var l;const{annotations:e,optionalContentConfig:s}=t,i=this.div;xl(i,this.viewport);const r=new Map,a=[],o={data:null,layer:i,linkService:n(this,sl),downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Zf,annotationStorage:n(this,jc),enableComment:t.enableComment===!0,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const c of e){if(c.noHTML)continue;const h=c.annotationType===oe.POPUP;if(h){const g=r.get(c.id);if(!g)continue;if(!this._commentManager){a.push(c);continue}o.elements=g}else if(c.rect[2]===c.rect[0]||c.rect[3]===c.rect[1])continue;o.data=c;const d=eg.create(o);if(!d.isRenderable)continue;h||(n(this,es).push(d),c.popupRef&&r.getOrInsertComputed(c.popupRef,Vu).push(d));const f=d.render();c.hidden&&(f.style.visibility="hidden"),d.updateOC(s),d._isEditable&&(n(this,ar).set(d.data.id,d),(l=this._annotationEditorUIManager)==null||l.renderAnnotationElement(d))}await v(this,xn,Tf).call(this);for(const c of a){const h=o.elements=r.get(c.id);o.data=c;const d=eg.create(o);if(!d.isRenderable)continue;const f=d.render();d.contentElement.id=`${Bl}${c.id}`,c.hidden&&(f.style.visibility="hidden"),h.at(-1).container.after(f)}v(this,xn,Pf).call(this)}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:n(this,sl),svgFactory:new Zf,parent:this};for(const s of t){s.borderStyle||(s.borderStyle=nv._defaultBorderStyle),e.data=s;const i=eg.create(e);i.isRenderable&&(i.render(),i.contentElement.id=`${Bl}${s.id}`,n(this,es).push(i))}await v(this,xn,Tf).call(this)}update({viewport:t,optionalContentConfig:e}){const s=this.div;this.viewport=t,xl(s,{rotation:t.rotation});for(const i of n(this,es))i.updateOC(e);v(this,xn,Pf).call(this),s.hidden=!1}destroy(){var t,e;for(const s of n(this,es))(t=s.destroy)==null||t.call(s),(e=n(this,ha))==null||e.removePointerInTextLayer(s.contentElement);n(this,es).length=0,n(this,ar).clear(),this.div.replaceChildren()}refreshCanvases(){v(this,xn,Pf).call(this)}getEditableAnnotations(){return n(this,ar).values()}getEditableAnnotation(t){return n(this,ar).get(t)}addFakeAnnotation(t){const{div:e}=this,{id:s,rotation:i}=t,r=new ix({data:{id:s,rect:t.getPDFRect(),rotation:i},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:n(this,sl),annotationStorage:n(this,jc)});return r.render(),r.contentElement.id=`${Bl}${s}`,r.createOrUpdatePopup(),n(this,es).push(r),r}removeAnnotation(t){var i;const e=n(this,es).findIndex(r=>r.data.id===t);if(e<0)return;const[s]=n(this,es).splice(e,1);(i=n(this,ha))==null||i.removePointerInTextLayer(s.contentElement)}updateFakeAnnotations(t){if(t.length!==0){for(const e of t)e.updateFakeAnnotationElement(this);v(this,xn,Tf).call(this)}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return at(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Ll.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};ha=new WeakMap,el=new WeakMap,jc=new WeakMap,ar=new WeakMap,mu=new WeakMap,sl=new WeakMap,es=new WeakMap,vu=new WeakMap,xn=new WeakSet,Tf=async function(){var s,i,r;if(n(this,es).length===0)return;this.div.replaceChildren();const t=[];if(!n(this,vu)){p(this,vu,!0);for(const{contentElement:a,data:{id:o}}of n(this,es)){const l=a.id=`${Bl}${o}`;t.push((s=n(this,mu))==null?void 0:s.getAriaAttributes(l).then(c=>{if(c)for(const[h,d]of c)a.setAttribute(h,d)}))}}n(this,es).sort(({data:{rect:[a,o,l,c]}},{data:{rect:[h,d,f,g]}})=>{if(a===l&&o===c)return 1;if(h===f&&d===g)return-1;const y=c,b=o,S=(o+c)/2,w=g,x=d,A=(d+g)/2;if(S>=w&&A<=b)return-1;if(A>=y&&S<=x)return 1;const C=(a+l)/2,_=(h+f)/2;return C-_});const e=document.createDocumentFragment();for(const a of n(this,es))e.append(a.container),this._commentManager?(r=((i=a.extraPopupElement)==null?void 0:i.popup)||a.popup)==null||r.renderCommentButton():a.extraPopupElement&&e.append(a.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),n(this,ha))for(const a of n(this,es))n(this,ha).addPointerInTextLayer(a.contentElement,!1)},Pf=function(){var e;if(!n(this,el))return;const t=this.div;for(const[s,i]of n(this,el)){const r=t.querySelector(`[data-annotation-id="${s}"]`);if(!r)continue;if(Array.isArray(i))for(const h of i)h.className="annotationContent",h.ariaHidden=!0;else i.className="annotationContent",i.ariaHidden=!0;const a=[];for(const h of r.children)h.nodeName==="CANVAS"&&a.push(h);for(const h of a)h.remove();const o=Array.isArray(i)?i[0]:i,{firstChild:l}=r;if(l?l.classList.contains("annotationContent")?l.after(o):l.before(o):r.append(o),Array.isArray(i)){let h=o;for(let d=1,f=i.length;d<f;d++)h.after(i[d]),h=i[d]}n(this,el).delete(s);const c=n(this,ar).get(s);c&&(c._hasNoCanvas?((e=this._annotationEditorUIManager)==null||e.setMissingCanvas(s,r.id,i),c._hasNoCanvas=!1):c.canvas=i)}};let hm=nv;const Zu=/\r\n?|\n/g;var Ws,bu,il,Xs,Ae,$y,Uy,Hy,Mf,br,If,Df,zy,um,Vy;const Yt=class Yt extends Pt{constructor(e){super({...e,name:"freeTextEditor"});m(this,Ae);m(this,Ws,"");m(this,bu,`${this.id}-editor`);m(this,il,null);m(this,Xs);M(this,"_colorPicker",null);this.color=e.color||Yt._defaultColor||Pt._defaultLineColor,p(this,Xs,e.fontSize||Yt._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert(Pt._l10nAlert.freetext),this.canAddComment=!1}static get _keyboardManager(){const e=Yt.prototype,s=a=>a.isEmpty(),i=Cl.TRANSLATE_SMALL,r=Cl.TRANSLATE_BIG;return at(this,"_keyboardManager",new El([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter"],e.commitOrRemove],[["Escape"],e.commitOrRemove],[["ArrowLeft"],e._translateEmpty,{args:[-i,0],checker:s}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-r,0],checker:s}],[["ArrowRight"],e._translateEmpty,{args:[i,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[r,0],checker:s}],[["ArrowUp"],e._translateEmpty,{args:[0,-i],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-r],checker:s}],[["ArrowDown"],e._translateEmpty,{args:[0,i],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,r],checker:s}]]))}static initialize(e,s){Pt.initialize(e,s);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,s){switch(e){case dt.FREETEXT_SIZE:Yt._defaultFontSize=s;break;case dt.FREETEXT_COLOR:Yt._defaultColor=s;break}}updateParams(e,s){switch(e){case dt.FREETEXT_SIZE:v(this,Ae,$y).call(this,s);break;case dt.FREETEXT_COLOR:v(this,Ae,Uy).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[dt.FREETEXT_SIZE,Yt._defaultFontSize],[dt.FREETEXT_COLOR,Yt._defaultColor||Pt._defaultLineColor]]}get propertiesToUpdate(){return[[dt.FREETEXT_SIZE,n(this,Xs)],[dt.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new Jf(this)),[["colorPicker",this._colorPicker]]}get colorType(){return dt.FREETEXT_COLOR}onUpdatedColor(){var e;this.editorDiv.style.color=this.color,(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}_translateEmpty(e,s){this._uiManager.translateSelectedEditors(e,s,!0)}getInitialTranslation(){const e=this.parentScale;return[-Yt._internalPadding*e,-(Yt._internalPadding+n(this,Xs))*e]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),p(this,il,new AbortController);const e=this._uiManager.combinedSignal(n(this,il));return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e}),!0}disableEditMode(){var e;return super.disableEditMode()?(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",n(this,bu)),this._isDraggable=!0,(e=n(this,il))==null||e.abort(),p(this,il,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){var s;this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),(s=this._initialOptions)!=null&&s.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=n(this,Ws),s=p(this,Ws,v(this,Ae,Hy).call(this).trimEnd());if(e===s)return;const i=r=>{if(p(this,Ws,r),!r){this.remove();return}v(this,Ae,Df).call(this),this._uiManager.rebuild(this),v(this,Ae,Mf).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(e)},mustExec:!1}),v(this,Ae,Mf).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(e){e.target===this.div&&e.key==="Enter"&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){Yt._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let e,s;(this._isCopy||this.annotationElementId)&&(e=this.x,s=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",n(this,bu)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${n(this,Xs)}px * var(--total-scale-factor))`,i.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[r,a]=this.parentDimensions;if(this.annotationElementId){const{position:o}=this._initialData;let[l,c]=this.getInitialTranslation();[l,c]=this.pageTranslationToScreen(l,c);const[h,d]=this.pageDimensions,[f,g]=this.pageTranslation;let y,b;switch(this.rotation){case 0:y=e+(o[0]-f)/h,b=s+this.height-(o[1]-g)/d;break;case 90:y=e+(o[0]-f)/h,b=s-(o[1]-g)/d,[l,c]=[c,-l];break;case 180:y=e-this.width+(o[0]-f)/h,b=s-(o[1]-g)/d,[l,c]=[-l,-c];break;case 270:y=e+(o[0]-f-this.height*d)/h,b=s+(o[1]-g-this.width*h)/d,[l,c]=[-c,l];break}this.setAt(y*r,b*a,l,c)}else this._moveAfterPaste(e,s);v(this,Ae,Df).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var y,b,S;const s=e.clipboardData||window.clipboardData,{types:i}=s;if(i.length===1&&i[0]==="text/plain")return;e.preventDefault();const r=v(y=Yt,br,um).call(y,s.getData("text")||"").replaceAll(Zu,`
`);if(!r)return;const a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();const o=a.getRangeAt(0);if(!r.includes(`
`)){o.insertNode(document.createTextNode(r)),this.editorDiv.normalize(),a.collapseToStart();return}const{startContainer:l,startOffset:c}=o,h=[],d=[];if(l.nodeType===Node.TEXT_NODE){const w=l.parentElement;if(d.push(l.nodeValue.slice(c).replaceAll(Zu,"")),w!==this.editorDiv){let x=h;for(const A of this.editorDiv.childNodes){if(A===w){x=d;continue}x.push(v(b=Yt,br,If).call(b,A))}}h.push(l.nodeValue.slice(0,c).replaceAll(Zu,""))}else if(l===this.editorDiv){let w=h,x=0;for(const A of this.editorDiv.childNodes)x++===c&&(w=d),w.push(v(S=Yt,br,If).call(S,A))}p(this,Ws,`${h.join(`
`)}${r}${d.join(`
`)}`),v(this,Ae,Df).call(this);const f=new Range;let g=Math.sumPrecise(h.map(w=>w.length));for(const{firstChild:w}of this.editorDiv.childNodes)if(w.nodeType===Node.TEXT_NODE){const x=w.nodeValue.length;if(g<=x){f.setStart(w,g),f.setEnd(w,g);break}g-=x}a.removeAllRanges(),a.addRange(f)}get contentDiv(){return this.editorDiv}getPDFRect(){const e=Yt._internalPadding*this.parentScale;return this.getRect(e,e)}static async deserialize(e,s,i){var o;let r=null;if(e instanceof Ly){const{data:{defaultAppearanceData:{fontSize:l,fontColor:c},rect:h,rotation:d,id:f,popupRef:g,richText:y,contentsObj:b,creationDate:S,modificationDate:w},textContent:x,textPosition:A,parent:{page:{pageNumber:C}}}=e;if(!(x!=null&&x.length))return null;r=e={annotationType:ot.FREETEXT,color:Array.from(c),fontSize:l,value:x.join(`
`),position:A,pageIndex:C-1,rect:h.slice(0),rotation:d,annotationElementId:f,id:f,deleted:!1,popupRef:g,comment:(b==null?void 0:b.str)||null,richText:y,creationDate:S,modificationDate:w}}const a=await super.deserialize(e,s,i);return p(a,Xs,e.fontSize),a.color=B.makeHexColor(...e.color),p(a,Ws,v(o=Yt,br,um).call(o,e.value)),a._initialData=r,e.comment&&a.setCommentData(e),a}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=Pt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(e),{color:s,fontSize:n(this,Xs),value:v(this,Ae,zy).call(this)});return this.addComment(i),e?(i.isCopy=!0,i):this.annotationElementId&&!v(this,Ae,Vy).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(e){const s=super.renderAnnotationElement(e);if(!s)return null;const{style:i}=s;i.fontSize=`calc(${n(this,Xs)}px * var(--total-scale-factor))`,i.color=this.color,s.replaceChildren();for(const r of n(this,Ws).split(`
`)){const a=document.createElement("div");a.append(r?document.createTextNode(r):document.createElement("br")),s.append(a)}return e.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:n(this,Ws)}}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};Ws=new WeakMap,bu=new WeakMap,il=new WeakMap,Xs=new WeakMap,Ae=new WeakSet,$y=function(e){const s=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--total-scale-factor))`,this.translate(0,-(r-n(this,Xs))*this.parentScale),p(this,Xs,r),v(this,Ae,Mf).call(this)},i=n(this,Xs);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:dt.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},Uy=function(e){const s=r=>{this.color=r,this.onUpdatedColor()},i=this.color;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:dt.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Hy=function(){var i;const e=[];this.editorDiv.normalize();let s=null;for(const r of this.editorDiv.childNodes)(s==null?void 0:s.nodeType)===Node.TEXT_NODE&&r.nodeName==="BR"||(e.push(v(i=Yt,br,If).call(i,r)),s=r);return e.join(`
`)},Mf=function(){const[e,s]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:r,div:a}=this,o=a.style.display,l=a.classList.contains("hidden");a.classList.remove("hidden"),a.style.display="hidden",r.div.append(this.div),i=a.getBoundingClientRect(),a.remove(),a.style.display=o,a.classList.toggle("hidden",l)}this.rotation%180===this.parentRotation%180?(this.width=i.width/e,this.height=i.height/s):(this.width=i.height/e,this.height=i.width/s),this.fixAndSetPosition()},br=new WeakSet,If=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(Zu,"")},Df=function(){if(this.editorDiv.replaceChildren(),!!n(this,Ws))for(const e of n(this,Ws).split(`
`)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},zy=function(){return n(this,Ws).replaceAll(" "," ")},um=function(e){return e.replaceAll(" "," ")},Vy=function(e){const{value:s,fontSize:i,color:r,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||e.value!==s||e.fontSize!==i||e.color.some((o,l)=>o!==r[l])||e.pageIndex!==a},m(Yt,br),M(Yt,"_freeTextDefaultContent",""),M(Yt,"_internalPadding",0),M(Yt,"_defaultColor",null),M(Yt,"_defaultFontSize",10),M(Yt,"_type","freetext"),M(Yt,"_editorType",ot.FREETEXT);let dm=Yt;class X{toSVGPath(){Ct("Abstract method `toSVGPath` must be implemented.")}get box(){Ct("Abstract getter `box` must be implemented.")}serialize(t,e){Ct("Abstract method `serialize` must be implemented.")}static _rescale(t,e,s,i,r,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o<l;o+=2)a[o]=e+t[o]*i,a[o+1]=s+t[o+1]*r;return a}static _rescaleAndSwap(t,e,s,i,r,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o<l;o+=2)a[o]=e+t[o+1]*i,a[o+1]=s+t[o]*r;return a}static _translate(t,e,s,i){i||(i=new Float32Array(t.length));for(let r=0,a=t.length;r<a;r+=2)i[r]=e+t[r],i[r+1]=s+t[r+1];return i}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,i,r){switch(r){case 90:return[1-e/s,t/i];case 180:return[1-t/s,1-e/i];case 270:return[e/s,1-t/i];default:return[t/s,e/i]}}static createBezierPoints(t,e,s,i,r,a){return[(t+5*s)/6,(e+5*i)/6,(5*s+r)/6,(5*i+a)/6,(s+r)/2,(i+a)/2]}}M(X,"PRECISION",1e-4);var qs,Hi,Wc,Xc,pn,bt,nl,rl,yu,wu,qc,Yc,da,Au,xp,Ep,Ce,Hh,Gy,jy,Wy,Xy,qy,Yy;const In=class In{constructor({x:t,y:e},s,i,r,a,o=0){m(this,Ce);m(this,qs);m(this,Hi,[]);m(this,Wc);m(this,Xc);m(this,pn,[]);m(this,bt,new Float32Array(18));m(this,nl);m(this,rl);m(this,yu);m(this,wu);m(this,qc);m(this,Yc);m(this,da,[]);p(this,qs,s),p(this,Yc,r*i),p(this,Xc,a),n(this,bt).set([NaN,NaN,NaN,NaN,t,e],6),p(this,Wc,o),p(this,wu,n(In,Au)*i),p(this,yu,n(In,Ep)*i),p(this,qc,i),n(this,da).push(t,e)}isEmpty(){return isNaN(n(this,bt)[8])}add({x:t,y:e}){var P;p(this,nl,t),p(this,rl,e);const[s,i,r,a]=n(this,qs);let[o,l,c,h]=n(this,bt).subarray(8,12);const d=t-c,f=e-h,g=Math.hypot(d,f);if(g<n(this,yu))return!1;const y=g-n(this,wu),b=y/g,S=b*d,w=b*f;let x=o,A=l;o=c,l=h,c+=S,h+=w,(P=n(this,da))==null||P.push(t,e);const C=-w/y,_=S/y,k=C*n(this,Yc),I=_*n(this,Yc);return n(this,bt).set(n(this,bt).subarray(2,8),0),n(this,bt).set([c+k,h+I],4),n(this,bt).set(n(this,bt).subarray(14,18),12),n(this,bt).set([c-k,h-I],16),isNaN(n(this,bt)[6])?(n(this,pn).length===0&&(n(this,bt).set([o+k,l+I],2),n(this,pn).push(NaN,NaN,NaN,NaN,(o+k-s)/r,(l+I-i)/a),n(this,bt).set([o-k,l-I],14),n(this,Hi).push(NaN,NaN,NaN,NaN,(o-k-s)/r,(l-I-i)/a)),n(this,bt).set([x,A,o,l,c,h],6),!this.isEmpty()):(n(this,bt).set([x,A,o,l,c,h],6),Math.abs(Math.atan2(A-l,x-o)-Math.atan2(w,S))<Math.PI/2?([o,l,c,h]=n(this,bt).subarray(2,6),n(this,pn).push(NaN,NaN,NaN,NaN,((o+c)/2-s)/r,((l+h)/2-i)/a),[o,l,x,A]=n(this,bt).subarray(14,18),n(this,Hi).push(NaN,NaN,NaN,NaN,((x+o)/2-s)/r,((A+l)/2-i)/a),!0):([x,A,o,l,c,h]=n(this,bt).subarray(0,6),n(this,pn).push(((x+5*o)/6-s)/r,((A+5*l)/6-i)/a,((5*o+c)/6-s)/r,((5*l+h)/6-i)/a,((o+c)/2-s)/r,((l+h)/2-i)/a),[c,h,o,l,x,A]=n(this,bt).subarray(12,18),n(this,Hi).push(((x+5*o)/6-s)/r,((A+5*l)/6-i)/a,((5*o+c)/6-s)/r,((5*l+h)/6-i)/a,((o+c)/2-s)/r,((l+h)/2-i)/a),!0))}toSVGPath(){if(this.isEmpty())return"";const t=n(this,pn),e=n(this,Hi);if(isNaN(n(this,bt)[6])&&!this.isEmpty())return v(this,Ce,Gy).call(this);const s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);v(this,Ce,Wy).call(this,s);for(let i=e.length-6;i>=6;i-=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return v(this,Ce,jy).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,r,a){return new Ky(t,e,s,i,r,a)}getOutlines(){var d;const t=n(this,pn),e=n(this,Hi),s=n(this,bt),[i,r,a,o]=n(this,qs),l=new Float32Array((((d=n(this,da))==null?void 0:d.length)??0)+2);for(let f=0,g=l.length-2;f<g;f+=2)l[f]=(n(this,da)[f]-i)/a,l[f+1]=(n(this,da)[f+1]-r)/o;if(l[l.length-2]=(n(this,nl)-i)/a,l[l.length-1]=(n(this,rl)-r)/o,isNaN(s[6])&&!this.isEmpty())return v(this,Ce,Xy).call(this,l);const c=new Float32Array(n(this,pn).length+24+n(this,Hi).length);let h=t.length;for(let f=0;f<h;f+=2){if(isNaN(t[f])){c[f]=c[f+1]=NaN;continue}c[f]=t[f],c[f+1]=t[f+1]}h=v(this,Ce,Yy).call(this,c,h);for(let f=e.length-6;f>=6;f-=6)for(let g=0;g<6;g+=2){if(isNaN(e[f+g])){c[h]=c[h+1]=NaN,h+=2;continue}c[h]=e[f+g],c[h+1]=e[f+g+1],h+=2}return v(this,Ce,qy).call(this,c,h),this.newFreeDrawOutline(c,l,n(this,qs),n(this,qc),n(this,Wc),n(this,Xc))}};qs=new WeakMap,Hi=new WeakMap,Wc=new WeakMap,Xc=new WeakMap,pn=new WeakMap,bt=new WeakMap,nl=new WeakMap,rl=new WeakMap,yu=new WeakMap,wu=new WeakMap,qc=new WeakMap,Yc=new WeakMap,da=new WeakMap,Au=new WeakMap,xp=new WeakMap,Ep=new WeakMap,Ce=new WeakSet,Hh=function(){const t=n(this,bt).subarray(4,6),e=n(this,bt).subarray(16,18),[s,i,r,a]=n(this,qs);return[(n(this,nl)+(t[0]-e[0])/2-s)/r,(n(this,rl)+(t[1]-e[1])/2-i)/a,(n(this,nl)+(e[0]-t[0])/2-s)/r,(n(this,rl)+(e[1]-t[1])/2-i)/a]},Gy=function(){const[t,e,s,i]=n(this,qs),[r,a,o,l]=v(this,Ce,Hh).call(this);return`M${(n(this,bt)[2]-t)/s} ${(n(this,bt)[3]-e)/i} L${(n(this,bt)[4]-t)/s} ${(n(this,bt)[5]-e)/i} L${r} ${a} L${o} ${l} L${(n(this,bt)[16]-t)/s} ${(n(this,bt)[17]-e)/i} L${(n(this,bt)[14]-t)/s} ${(n(this,bt)[15]-e)/i} Z`},jy=function(t){const e=n(this,Hi);t.push(`L${e[4]} ${e[5]} Z`)},Wy=function(t){const[e,s,i,r]=n(this,qs),a=n(this,bt).subarray(4,6),o=n(this,bt).subarray(16,18),[l,c,h,d]=v(this,Ce,Hh).call(this);t.push(`L${(a[0]-e)/i} ${(a[1]-s)/r} L${l} ${c} L${h} ${d} L${(o[0]-e)/i} ${(o[1]-s)/r}`)},Xy=function(t){const e=n(this,bt),[s,i,r,a]=n(this,qs),[o,l,c,h]=v(this,Ce,Hh).call(this),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-s)/r,(e[3]-i)/a,NaN,NaN,NaN,NaN,(e[4]-s)/r,(e[5]-i)/a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,(e[16]-s)/r,(e[17]-i)/a,NaN,NaN,NaN,NaN,(e[14]-s)/r,(e[15]-i)/a],0),this.newFreeDrawOutline(d,t,n(this,qs),n(this,qc),n(this,Wc),n(this,Xc))},qy=function(t,e){const s=n(this,Hi);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},Yy=function(t,e){const s=n(this,bt).subarray(4,6),i=n(this,bt).subarray(16,18),[r,a,o,l]=n(this,qs),[c,h,d,f]=v(this,Ce,Hh).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-r)/o,(s[1]-a)/l,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,d,f,NaN,NaN,NaN,NaN,(i[0]-r)/o,(i[1]-a)/l],e),e+=24},m(In,Au,8),m(In,xp,2),m(In,Ep,n(In,Au)+n(In,xp));let tp=In;var Kc,al,or,Su,Ys,xu,me,Cp,Qy;class Ky extends X{constructor(e,s,i,r,a,o){super();m(this,Cp);m(this,Kc);m(this,al,new Float32Array(4));m(this,or);m(this,Su);m(this,Ys);m(this,xu);m(this,me);p(this,me,e),p(this,Ys,s),p(this,Kc,i),p(this,xu,r),p(this,or,a),p(this,Su,o),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],v(this,Cp,Qy).call(this,o);const[l,c,h,d]=n(this,al);for(let f=0,g=e.length;f<g;f+=2)e[f]=(e[f]-l)/h,e[f+1]=(e[f+1]-c)/d;for(let f=0,g=s.length;f<g;f+=2)s[f]=(s[f]-l)/h,s[f+1]=(s[f+1]-c)/d}toSVGPath(){const e=[`M${n(this,me)[4]} ${n(this,me)[5]}`];for(let s=6,i=n(this,me).length;s<i;s+=6){if(isNaN(n(this,me)[s])){e.push(`L${n(this,me)[s+4]} ${n(this,me)[s+5]}`);continue}e.push(`C${n(this,me)[s]} ${n(this,me)[s+1]} ${n(this,me)[s+2]} ${n(this,me)[s+3]} ${n(this,me)[s+4]} ${n(this,me)[s+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,s,i,r],a){const o=i-e,l=r-s;let c,h;switch(a){case 0:c=X._rescale(n(this,me),e,r,o,-l),h=X._rescale(n(this,Ys),e,r,o,-l);break;case 90:c=X._rescaleAndSwap(n(this,me),e,s,o,l),h=X._rescaleAndSwap(n(this,Ys),e,s,o,l);break;case 180:c=X._rescale(n(this,me),i,s,-o,l),h=X._rescale(n(this,Ys),i,s,-o,l);break;case 270:c=X._rescaleAndSwap(n(this,me),i,r,-o,-l),h=X._rescaleAndSwap(n(this,Ys),i,r,-o,-l);break}return{outline:Array.from(c),points:[Array.from(h)]}}get box(){return n(this,al)}newOutliner(e,s,i,r,a,o=0){return new tp(e,s,i,r,a,o)}getNewOutline(e,s){const[i,r,a,o]=n(this,al),[l,c,h,d]=n(this,Kc),f=a*h,g=o*d,y=i*h+l,b=r*d+c,S=this.newOutliner({x:n(this,Ys)[0]*f+y,y:n(this,Ys)[1]*g+b},n(this,Kc),n(this,xu),e,n(this,Su),s??n(this,or));for(let w=2;w<n(this,Ys).length;w+=2)S.add({x:n(this,Ys)[w]*f+y,y:n(this,Ys)[w+1]*g+b});return S.getOutlines()}}Kc=new WeakMap,al=new WeakMap,or=new WeakMap,Su=new WeakMap,Ys=new WeakMap,xu=new WeakMap,me=new WeakMap,Cp=new WeakSet,Qy=function(e){const s=n(this,me);let i=s[4],r=s[5];const a=[i,r,i,r];let o=i,l=r,c=i,h=r;const d=e?Math.max:Math.min,f=new Float32Array(4);for(let y=6,b=s.length;y<b;y+=6){const S=s[y+4],w=s[y+5];isNaN(s[y])?(B.pointBoundingBox(S,w,a),l>w?(o=S,l=w):l===w&&(o=d(o,S)),h<w?(c=S,h=w):h===w&&(c=d(c,S))):(f.set(mr,0),B.bezierBoundingBox(i,r,...s.slice(y,y+6),f),B.rectBoundingBox(...f,a),l>f[1]?(o=f[0],l=f[1]):l===f[1]&&(o=d(o,f[0])),h<f[3]?(c=f[2],h=f[3]):h===f[3]&&(c=d(c,f[2]))),i=S,r=w}const g=n(this,al);g[0]=a[0]-n(this,or),g[1]=a[1]-n(this,or),g[2]=a[2]-a[0]+2*n(this,or),g[3]=a[3]-a[1]+2*n(this,or),this.firstPoint=[o,l],this.lastPoint=[c,h]};var Eu,Cu,_u,ua,zi,gs,Jy,Lf,Zy,t0,pm;class fm{constructor(t,e=0,s=0,i=!0){m(this,gs);m(this,Eu);m(this,Cu);m(this,_u);m(this,ua,[]);m(this,zi,[]);const r=mr.slice(),a=10**-4;for(const{x:b,y:S,width:w,height:x}of t){const A=Math.floor((b-e)/a)*a,C=Math.ceil((b+w+e)/a)*a,_=Math.floor((S-e)/a)*a,k=Math.ceil((S+x+e)/a)*a,I=[A,_,k,!0],L=[C,_,k,!1];n(this,ua).push(I,L),B.rectBoundingBox(A,_,C,k,r)}const o=r[2]-r[0]+2*s,l=r[3]-r[1]+2*s,c=r[0]-s,h=r[1]-s;let d=i?-1/0:1/0,f=1/0;const g=n(this,ua).at(i?-1:-2),y=[g[0],g[2]];for(const b of n(this,ua)){const[S,w,x,A]=b;!A&&i?w<f?(f=w,d=S):w===f&&(d=Math.max(d,S)):A&&!i&&(w<f?(f=w,d=S):w===f&&(d=Math.min(d,S))),b[0]=(S-c)/o,b[1]=(w-h)/l,b[2]=(x-h)/l}p(this,Eu,new Float32Array([c,h,o,l])),p(this,Cu,[d,f]),p(this,_u,y)}getOutlines(){n(this,ua).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of n(this,ua))e[3]?(t.push(...v(this,gs,pm).call(this,e)),v(this,gs,Zy).call(this,e)):(v(this,gs,t0).call(this,e),t.push(...v(this,gs,pm).call(this,e)));return v(this,gs,Jy).call(this,t)}}Eu=new WeakMap,Cu=new WeakMap,_u=new WeakMap,ua=new WeakMap,zi=new WeakMap,gs=new WeakSet,Jy=function(t){const e=[],s=new Set;for(const a of t){const[o,l,c]=a;e.push([o,l,a],[o,c,a])}e.sort((a,o)=>a[1]-o[1]||a[0]-o[0]);for(let a=0,o=e.length;a<o;a+=2){const l=e[a][2],c=e[a+1][2];l.push(c),c.push(l),s.add(l),s.add(c)}const i=[];let r;for(;s.size>0;){const a=s.values().next().value;let[o,l,c,h,d]=a;s.delete(a);let f=o,g=l;for(r=[o,c],i.push(r);;){let y;if(s.has(h))y=h;else if(s.has(d))y=d;else break;s.delete(y),[o,l,c,h,d]=y,f!==o&&(r.push(f,g,o,g===l?l:c),f=o),g=g===l?c:l}r.push(f,g)}return new Ax(i,n(this,Eu),n(this,Cu),n(this,_u))},Lf=function(t){const e=n(this,zi);let s=0,i=e.length-1;for(;s<=i;){const r=s+i>>1,a=e[r][0];if(a===t)return r;a<t?s=r+1:i=r-1}return i+1},Zy=function([,t,e]){const s=v(this,gs,Lf).call(this,t);n(this,zi).splice(s,0,[t,e])},t0=function([,t,e]){const s=v(this,gs,Lf).call(this,t);for(let i=s;i<n(this,zi).length;i++){const[r,a]=n(this,zi)[i];if(r!==t)break;if(r===t&&a===e){n(this,zi).splice(i,1);return}}for(let i=s-1;i>=0;i--){const[r,a]=n(this,zi)[i];if(r!==t)break;if(r===t&&a===e){n(this,zi).splice(i,1);return}}},pm=function(t){const[e,s,i]=t,r=[[e,s,i]],a=v(this,gs,Lf).call(this,i);for(let o=0;o<a;o++){const[l,c]=n(this,zi)[o];for(let h=0,d=r.length;h<d;h++){const[,f,g]=r[h];if(!(c<=f||g<=l)){if(f>=l){if(g>c)r[h][1]=c;else{if(d===1)return[];r.splice(h,1),h--,d--}continue}r[h][2]=l,g>c&&r.push([e,c,g])}}}return r};var ku,Qc;class Ax extends X{constructor(e,s,i,r){super();m(this,ku);m(this,Qc);p(this,Qc,e),p(this,ku,s),this.firstPoint=i,this.lastPoint=r}toSVGPath(){const e=[];for(const s of n(this,Qc)){let[i,r]=s;e.push(`M${i} ${r}`);for(let a=2;a<s.length;a+=2){const o=s[a],l=s[a+1];o===i?(e.push(`V${l}`),r=l):l===r&&(e.push(`H${o}`),i=o)}e.push("Z")}return e.join(" ")}serialize([e,s,i,r],a){const o=[],l=i-e,c=r-s;for(const h of n(this,Qc)){const d=new Array(h.length);for(let f=0;f<h.length;f+=2)d[f]=e+h[f]*l,d[f+1]=r-h[f+1]*c;o.push(d)}return o}get box(){return n(this,ku)}}ku=new WeakMap,Qc=new WeakMap;class gm extends tp{newFreeDrawOutline(t,e,s,i,r,a){return new Sx(t,e,s,i,r,a)}}class Sx extends Ky{newOutliner(t,e,s,i,r,a=0){return new gm(t,e,s,i,r,a)}}var Jc,Tu,lr,ol,Pu,xs,Mu,Iu,ll,Ks,Qs,Ve,Zc,th,ss,eh,yi,Du,pt,mm,Ff,e0,s0,i0,vm,Ha,Si,Rl,n0,Of,Rf,r0,a0,o0,l0,c0;const _t=class _t extends Pt{constructor(e){super({...e,name:"highlightEditor"});m(this,pt);m(this,Jc,null);m(this,Tu,0);m(this,lr);m(this,ol,null);m(this,Pu,null);m(this,xs,null);m(this,Mu,null);m(this,Iu,0);m(this,ll,null);m(this,Ks,null);m(this,Qs,null);m(this,Ve,!1);m(this,Zc,null);m(this,th,null);m(this,ss,null);m(this,eh,"");m(this,yi);m(this,Du,"");this.color=e.color||_t._defaultColor,p(this,yi,e.thickness||_t._defaultThickness),this.opacity=e.opacity||_t._defaultOpacity,p(this,lr,e.boxes||null),p(this,Du,e.methodOfCreation||""),p(this,eh,e.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",e.highlightId>-1?(p(this,Ve,!0),v(this,pt,Ff).call(this,e),v(this,pt,Ha).call(this)):n(this,lr)&&(p(this,Jc,e.anchorNode),p(this,Tu,e.anchorOffset),p(this,Mu,e.focusNode),p(this,Iu,e.focusOffset),v(this,pt,mm).call(this),v(this,pt,Ha).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert(Pt._l10nAlert.highlight)}static get _keyboardManager(){const e=_t.prototype;return at(this,"_keyboardManager",new El([[["ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown"],e._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:n(this,Ve)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:n(this,yi),methodOfCreation:n(this,Du)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}static initialize(e,s){var i;Pt.initialize(e,s),_t._defaultColor||(_t._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case dt.HIGHLIGHT_COLOR:_t._defaultColor=s;break;case dt.HIGHLIGHT_THICKNESS:_t._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return n(this,th)}get commentButtonPosition(){return n(this,Zc)}updateParams(e,s){switch(e){case dt.HIGHLIGHT_COLOR:v(this,pt,e0).call(this,s);break;case dt.HIGHLIGHT_THICKNESS:v(this,pt,s0).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[dt.HIGHLIGHT_COLOR,_t._defaultColor],[dt.HIGHLIGHT_THICKNESS,_t._defaultThickness]]}get propertiesToUpdate(){return[[dt.HIGHLIGHT_COLOR,this.color||_t._defaultColor],[dt.HIGHLIGHT_THICKNESS,n(this,yi)||_t._defaultThickness],[dt.HIGHLIGHT_FREE,n(this,Ve)]]}onUpdatedColor(){var e,s;(e=this.parent)==null||e.drawLayer.updateProperties(n(this,Qs),{root:{fill:this.color,"fill-opacity":this.opacity}}),(s=n(this,Pu))==null||s.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",p(this,Pu,new Qf({editor:this}))]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(v(this,pt,Rf).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,v(this,pt,Rf).call(this))}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){v(this,pt,vm).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(v(this,pt,Ha).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?v(this,pt,vm).call(this):e&&(v(this,pt,Ha).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),this.show(this._isVisible),s&&this.select()}rotate(e){var r,a,o;const{drawLayer:s}=this.parent;let i;n(this,Ve)?(e=(e-this.rotation+360)%360,i=v(r=_t,Si,Rl).call(r,n(this,Ks).box,e)):i=v(a=_t,Si,Rl).call(a,[this.x,this.y,this.width,this.height],e),s.updateProperties(n(this,Qs),{bbox:i,root:{"data-main-rotation":e}}),s.updateProperties(n(this,ss),{bbox:v(o=_t,Si,Rl).call(o,n(this,xs).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();n(this,eh)&&(e.setAttribute("aria-label",n(this,eh)),e.setAttribute("role","mark")),n(this,Ve)?e.classList.add("free"):this.div.addEventListener("keydown",v(this,pt,n0).bind(this),{signal:this._uiManager._signal});const s=p(this,ll,document.createElement("div"));return e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=n(this,ol),this.setDims(),hb(this,n(this,ll),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(n(this,ss),{rootClass:{hovered:!0}})}pointerleave(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(n(this,ss),{rootClass:{hovered:!1}})}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:v(this,pt,Of).call(this,!0);break;case 1:case 3:v(this,pt,Of).call(this,!1);break}}select(){var e;super.select(),n(this,ss)&&((e=this.parent)==null||e.drawLayer.updateProperties(n(this,ss),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var e;super.unselect(),n(this,ss)&&((e=this.parent)==null||e.drawLayer.updateProperties(n(this,ss),{rootClass:{selected:!1}}),n(this,Ve)||v(this,pt,Of).call(this,!1))}get _mustFixPosition(){return!n(this,Ve)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(n(this,Qs),{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(n(this,ss),{rootClass:{hidden:!e}}))}static startHighlighting(e,s,{target:i,x:r,y:a}){const{x:o,y:l,width:c,height:h}=i.getBoundingClientRect(),d=new AbortController,f=e.combinedSignal(d),g=y=>{d.abort(),v(this,Si,l0).call(this,e,y)};window.addEventListener("blur",g,{signal:f}),window.addEventListener("pointerup",g,{signal:f}),window.addEventListener("pointerdown",ie,{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",Ci,{signal:f}),i.addEventListener("pointermove",v(this,Si,o0).bind(this,e),{signal:f}),this._freeHighlight=new gm({x:r,y:a},[o,l,c,h],e.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static async deserialize(e,s,i){var S,w,x,A;let r=null;if(e instanceof Oy){const{data:{quadPoints:C,rect:_,rotation:k,id:I,color:L,opacity:P,popupRef:D,richText:R,contentsObj:K,creationDate:W,modificationDate:Q},parent:{page:{pageNumber:ht}}}=e;r=e={annotationType:ot.HIGHLIGHT,color:Array.from(L),opacity:P,quadPoints:C,boxes:null,pageIndex:ht-1,rect:_.slice(0),rotation:k,annotationElementId:I,id:I,deleted:!1,popupRef:D,richText:R,comment:(K==null?void 0:K.str)||null,creationDate:W,modificationDate:Q}}else if(e instanceof qm){const{data:{inkLists:C,rect:_,rotation:k,id:I,color:L,borderStyle:{rawWidth:P},popupRef:D,richText:R,contentsObj:K,creationDate:W,modificationDate:Q},parent:{page:{pageNumber:ht}}}=e;r=e={annotationType:ot.HIGHLIGHT,color:Array.from(L),thickness:P,inkLists:C,boxes:null,pageIndex:ht-1,rect:_.slice(0),rotation:k,annotationElementId:I,id:I,deleted:!1,popupRef:D,richText:R,comment:(K==null?void 0:K.str)||null,creationDate:W,modificationDate:Q}}const{color:a,quadPoints:o,inkLists:l,outlines:c,opacity:h}=e,d=await super.deserialize(e,s,i);d.color=B.makeHexColor(...a),d.opacity=h||1,l&&p(d,yi,e.thickness),d._initialData=r,e.comment&&d.setCommentData(e);const[f,g]=d.pageDimensions,[y,b]=d.pageTranslation;if(o){const C=p(d,lr,[]);for(let _=0;_<o.length;_+=8)C.push({x:(o[_]-y)/f,y:1-(o[_+1]-b)/g,width:(o[_+2]-o[_])/f,height:(o[_+1]-o[_+5])/g});v(S=d,pt,mm).call(S),v(w=d,pt,Ha).call(w),d.rotate(d.rotation)}else if(l||c){p(d,Ve,!0);const C=(l||c.points)[0],_={x:C[0]-y,y:g-(C[1]-b)},k=new gm(_,[0,0,f,g],1,n(d,yi)/2,!0,.001);for(let P=0,D=C.length;P<D;P+=2)_.x=C[P]-y,_.y=g-(C[P+1]-b),k.add(_);const{id:I,clipPathId:L}=s.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:d.color,"fill-opacity":d._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:k.toSVGPath()}},!0,!0);v(x=d,pt,Ff).call(x,{highlightOutlines:k.getOutlines(),highlightId:I,clipPathId:L}),v(A=d,pt,Ha).call(A),d.rotate(d.parentRotation)}return d}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const s=Pt._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),i=super.serialize(e);return Object.assign(i,{color:s,opacity:this.opacity,thickness:n(this,yi),quadPoints:v(this,pt,r0).call(this),outlines:v(this,pt,a0).call(this,i.rect)}),this.addComment(i),this.annotationElementId&&!v(this,pt,c0).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}};Jc=new WeakMap,Tu=new WeakMap,lr=new WeakMap,ol=new WeakMap,Pu=new WeakMap,xs=new WeakMap,Mu=new WeakMap,Iu=new WeakMap,ll=new WeakMap,Ks=new WeakMap,Qs=new WeakMap,Ve=new WeakMap,Zc=new WeakMap,th=new WeakMap,ss=new WeakMap,eh=new WeakMap,yi=new WeakMap,Du=new WeakMap,pt=new WeakSet,mm=function(){const e=new fm(n(this,lr),.001);p(this,Ks,e.getOutlines()),[this.x,this.y,this.width,this.height]=n(this,Ks).box;const s=new fm(n(this,lr),.0025,.001,this._uiManager.direction==="ltr");p(this,xs,s.getOutlines());const{firstPoint:i}=n(this,Ks);p(this,Zc,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]);const{lastPoint:r}=n(this,xs);p(this,th,[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height])},Ff=function({highlightOutlines:e,highlightId:s,clipPathId:i}){var f,g;if(p(this,Ks,e),p(this,xs,e.getNewOutline(n(this,yi)/2+1.5,.0025)),s>=0)p(this,Qs,s),p(this,ol,i),this.parent.drawLayer.finalizeDraw(s,{bbox:e.box,path:{d:e.toSVGPath()}}),p(this,ss,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:n(this,xs).box,path:{d:n(this,xs).toSVGPath()}},!0));else if(this.parent){const y=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(n(this,Qs),{bbox:v(f=_t,Si,Rl).call(f,n(this,Ks).box,(y-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(n(this,ss),{bbox:v(g=_t,Si,Rl).call(g,n(this,xs).box,y),path:{d:n(this,xs).toSVGPath()}})}const[a,o,l,c]=e.box;switch(this.rotation){case 0:this.x=a,this.y=o,this.width=l,this.height=c;break;case 90:{const[y,b]=this.parentDimensions;this.x=o,this.y=1-a,this.width=l*b/y,this.height=c*y/b;break}case 180:this.x=1-a,this.y=1-o,this.width=l,this.height=c;break;case 270:{const[y,b]=this.parentDimensions;this.x=1-o,this.y=a,this.width=l*b/y,this.height=c*y/b;break}}const{firstPoint:h}=e;p(this,Zc,[(h[0]-a)/l,(h[1]-o)/c]);const{lastPoint:d}=n(this,xs);p(this,th,[(d[0]-a)/l,(d[1]-o)/c])},e0=function(e){const s=(a,o)=>{this.color=a,this.opacity=o,this.onUpdatedColor()},i=this.color,r=this.opacity;this.addCommands({cmd:s.bind(this,e,_t._defaultOpacity),undo:s.bind(this,i,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:dt.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0)},s0=function(e){const s=n(this,yi),i=r=>{p(this,yi,r),v(this,pt,i0).call(this,r)};this.addCommands({cmd:i.bind(this,e),undo:i.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:dt.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},i0=function(e){n(this,Ve)&&(v(this,pt,Ff).call(this,{highlightOutlines:n(this,Ks).getNewOutline(e/2)}),this.fixAndSetPosition(),this.setDims())},vm=function(){n(this,Qs)===null||!this.parent||(this.parent.drawLayer.remove(n(this,Qs)),p(this,Qs,null),this.parent.drawLayer.remove(n(this,ss)),p(this,ss,null))},Ha=function(e=this.parent){n(this,Qs)===null&&({id:qt(this,Qs)._,clipPathId:qt(this,ol)._}=e.drawLayer.draw({bbox:n(this,Ks).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:n(this,Ve)},path:{d:n(this,Ks).toSVGPath()}},!1,!0),p(this,ss,e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:n(this,Ve)},bbox:n(this,xs).box,path:{d:n(this,xs).toSVGPath()}},n(this,Ve))),n(this,ll)&&(n(this,ll).style.clipPath=n(this,ol)))},Si=new WeakSet,Rl=function([e,s,i,r],a){switch(a){case 90:return[1-s-r,e,r,i];case 180:return[1-e-i,1-s-r,i,r];case 270:return[s,1-e-i,r,i]}return[e,s,i,r]},n0=function(e){_t._keyboardManager.exec(this,e)},Of=function(e){if(!n(this,Jc))return;const s=window.getSelection();e?s.setPosition(n(this,Jc),n(this,Tu)):s.setPosition(n(this,Mu),n(this,Iu))},Rf=function(){return n(this,Ve)?this.rotation:0},r0=function(){if(n(this,Ve))return null;const[e,s]=this.pageDimensions,[i,r]=this.pageTranslation,a=n(this,lr),o=new Float32Array(a.length*8);let l=0;for(const{x:c,y:h,width:d,height:f}of a){const g=c*e+i,y=(1-h)*s+r;o[l]=o[l+4]=g,o[l+1]=o[l+3]=y,o[l+2]=o[l+6]=g+d*e,o[l+5]=o[l+7]=y-f*s,l+=8}return o},a0=function(e){return n(this,Ks).serialize(e,v(this,pt,Rf).call(this))},o0=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},l0=function(e,s){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(s,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},c0=function(e){const{color:s}=this._initialData;return this.hasEditedComment||e.color.some((i,r)=>i!==s[r])},m(_t,Si),M(_t,"_defaultColor",null),M(_t,"_defaultOpacity",1),M(_t,"_defaultThickness",12),M(_t,"_type","highlight"),M(_t,"_editorType",ot.HIGHLIGHT),M(_t,"_freeHighlightId",-1),M(_t,"_freeHighlight",null),M(_t,"_freeHighlightClipId","");let ep=_t;var cl;class h0{constructor(){m(this,cl,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,s)}updateSVGProperty(t,e){n(this,cl)[t]=e}toSVGProperties(){const t=n(this,cl);return p(this,cl,Object.create(null)),{root:t}}reset(){p(this,cl,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){Ct("Not implemented")}}cl=new WeakMap;var cs,sh,Le,hl,dl,St,bm,ym,wm,zh,d0,Nf,Vh,Nl;const wt=class wt extends Pt{constructor(e){super(e);m(this,St);m(this,cs,null);m(this,sh);M(this,"_colorPicker",null);M(this,"_drawId",null);p(this,sh,e.mustBeCommitted||!1),this._addOutlines(e)}onUpdatedColor(){var e;(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){var e,s;(s=(e=this._colorPicker)==null?void 0:e.updateOpacity)==null||s.call(e,this.opacity)}_addOutlines(e){e.drawOutlines&&(v(this,St,bm).call(this,e),v(this,St,zh).call(this))}static _mergeSVGProperties(e,s){const i=new Set(Object.keys(e));for(const[r,a]of Object.entries(s))i.has(r)?Object.assign(e[r],a):e[r]=a;return e}static getDefaultDrawingOptions(e){Ct("Not implemented")}static get typesMap(){Ct("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,s){const i=this.typesMap.get(e);i&&this._defaultDrawingOptions.updateProperty(i,s),this._currentParent&&(n(wt,Le).updateProperty(i,s),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,s){const i=this.constructor.typesMap.get(e);i&&this._updateProperty(e,i,s)}static get defaultPropertiesToUpdate(){const e=[],s=this._defaultDrawingOptions;for(const[i,r]of this.typesMap)e.push([i,s[r]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:s}=this;for(const[i,r]of this.constructor.typesMap)e.push([i,s[r]]);return e}_updateProperty(e,s,i){const r=this._drawingOptions,a=r[s],o=l=>{var h;r.updateProperty(s,l);const c=n(this,cs).updateProperty(s,l);c&&v(this,St,Vh).call(this,c),(h=this.parent)==null||h.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),e===this.colorType?this.onUpdatedColor():e===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:o.bind(this,i),undo:o.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(e,s){const i=this.constructor.typesMap.get(this.colorType),r=this.constructor.typesMap.get(this.opacityType),a=this._drawingOptions,o=a[i],l=a[r],c=(h,d)=>{var f;a.updateProperty(i,h),a.updateProperty(r,d),n(this,cs).updateProperty(i,h),n(this,cs).updateProperty(r,d),(f=this.parent)==null||f.drawLayer.updateProperties(this._drawId,a.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:c.bind(this,e,s),undo:c.bind(this,o,l),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:dt.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,wt._mergeSVGProperties(n(this,cs).getPathResizingSVGProperties(v(this,St,Nf).call(this)),{bbox:v(this,St,Nl).call(this)}))}_onResized(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,wt._mergeSVGProperties(n(this,cs).getPathResizedSVGProperties(v(this,St,Nf).call(this)),{bbox:v(this,St,Nl).call(this)}))}_onTranslating(e,s){var i;(i=this.parent)==null||i.drawLayer.updateProperties(this._drawId,{bbox:v(this,St,Nl).call(this)})}_onTranslated(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,wt._mergeSVGProperties(n(this,cs).getPathTranslatedSVGProperties(v(this,St,Nf).call(this),this.parentDimensions),{bbox:v(this,St,Nl).call(this)}))}_onStartDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,n(this,sh)&&(p(this,sh,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){v(this,St,wm).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(v(this,St,zh).call(this),v(this,St,Vh).call(this,n(this,cs).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),v(this,St,wm).call(this)):e&&(this._uiManager.addShouldRescale(this),v(this,St,zh).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),s&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,wt._mergeSVGProperties({bbox:v(this,St,Nl).call(this)},n(this,cs).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&v(this,St,Vh).call(this,n(this,cs).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,s;this._isCopy&&(e=this.x,s=this.y);const i=super.render();i.classList.add("draw");const r=document.createElement("div");return i.append(r),r.setAttribute("aria-hidden","true"),r.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(e,s),i}static createDrawerInstance(e,s,i,r,a){Ct("Not implemented")}static startDrawing(e,s,i,r){var S;const{target:a,offsetX:o,offsetY:l,pointerId:c,pointerType:h}=r;if(Je.isInitializedAndDifferentPointerType(h))return;const{viewport:{rotation:d}}=e,{width:f,height:g}=a.getBoundingClientRect(),y=p(wt,hl,new AbortController),b=e.combinedSignal(y);if(Je.setPointer(h,c),window.addEventListener("pointerup",w=>{Je.isSamePointerIdOrRemove(w.pointerId)&&this._endDraw(w)},{signal:b}),window.addEventListener("pointercancel",w=>{Je.isSamePointerIdOrRemove(w.pointerId)&&this._currentParent.endDrawingSession()},{signal:b}),window.addEventListener("pointerdown",w=>{Je.isSamePointerType(w.pointerType)&&(Je.initializeAndAddPointerId(w.pointerId),n(wt,Le).isCancellable()&&(n(wt,Le).removeLastElement(),n(wt,Le).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:b}),window.addEventListener("contextmenu",Ci,{signal:b}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:b}),a.addEventListener("touchmove",w=>{Je.isSameTimeStamp(w.timeStamp)&&ie(w)},{signal:b}),e.toggleDrawing(),(S=s._editorUndoBar)==null||S.hide(),n(wt,Le)){e.drawLayer.updateProperties(this._currentDrawId,n(wt,Le).startNew(o,l,f,g,d));return}s.updateUIForDefaultProperties(this),p(wt,Le,this.createDrawerInstance(o,l,f,g,d)),p(wt,dl,this.getDefaultDrawingOptions()),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(n(wt,dl).toSVGProperties(),n(wt,Le).defaultSVGProperties),!0,!1)}static _drawMove(e){if(Je.isSameTimeStamp(e.timeStamp),!n(wt,Le))return;const{offsetX:s,offsetY:i,pointerId:r}=e;if(Je.isSamePointerId(r)){if(Je.isUsingMultiplePointers()){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,n(wt,Le).add(s,i)),Je.setTimeStamp(e.timeStamp),ie(e)}}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,p(wt,Le,null),p(wt,dl,null),Je.clearTimeStamp()),n(wt,hl)&&(n(wt,hl).abort(),p(wt,hl,null),Je.clearPointerIds())}static _endDraw(e){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),(e==null?void 0:e.target)===s.div&&s.drawLayer.updateProperties(this._currentDrawId,n(wt,Le).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const i=n(wt,Le),r=this._currentDrawId,a=i.getLastElement();s.addCommands({cmd:()=>{s.drawLayer.updateProperties(r,i.setLastElement(a))},undo:()=>{s.drawLayer.updateProperties(r,i.removeLastElement())},mustExec:!1,type:dt.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(dt.DRAW_STEP),!n(wt,Le).isEmpty()){const{pageDimensions:[i,r],scale:a}=s,o=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:n(wt,Le).getOutlines(i*a,r*a,a,this._INNER_MARGIN),drawingOptions:n(wt,dl),mustBeCommitted:!e});return this._cleanup(!0),o}return s.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,s,i,r,a,o){Ct("Not implemented")}static async deserialize(e,s,i){var d,f;const{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}=s.viewport,c=this.deserializeDraw(o,l,r,a,this._INNER_MARGIN,e),h=await super.deserialize(e,s,i);return h.createDrawingOptions(e),v(d=h,St,bm).call(d,{drawOutlines:c}),v(f=h,St,zh).call(f),h.onScaleChanging(),h.rotate(),h}serializeDraw(e){const[s,i]=this.pageTranslation,[r,a]=this.pageDimensions;return n(this,cs).serialize([s,i,r,a],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};cs=new WeakMap,sh=new WeakMap,Le=new WeakMap,hl=new WeakMap,dl=new WeakMap,St=new WeakSet,bm=function({drawOutlines:e,drawId:s,drawingOptions:i}){p(this,cs,e),this._drawingOptions||(this._drawingOptions=i),this.annotationElementId||this._uiManager.a11yAlert(Pt._l10nAlert[this.editorType]),s>=0?(this._drawId=s,this.parent.drawLayer.finalizeDraw(s,e.defaultProperties)):this._drawId=v(this,St,ym).call(this,e,this.parent),v(this,St,Vh).call(this,e.box)},ym=function(e,s){const{id:i}=s.drawLayer.draw(wt._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return i},wm=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},zh=function(e=this.parent){if(!(this._drawId!==null&&this.parent===e)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=v(this,St,ym).call(this,n(this,cs),e)}},d0=function([e,s,i,r]){const{parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[s,1-e,i*(o/a),r*(a/o)];case 180:return[1-e,1-s,i,r];case 270:return[1-s,e,i*(o/a),r*(a/o)];default:return[e,s,i,r]}},Nf=function(){const{x:e,y:s,width:i,height:r,parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[1-s,e,i*(a/o),r*(o/a)];case 180:return[1-e,1-s,i,r];case 270:return[s,1-e,i*(a/o),r*(o/a)];default:return[e,s,i,r]}},Vh=function(e){[this.x,this.y,this.width,this.height]=v(this,St,d0).call(this,e),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},Nl=function(){const{x:e,y:s,width:i,height:r,rotation:a,parentRotation:o,parentDimensions:[l,c]}=this;switch((a*4+o)/90){case 1:return[1-s-r,e,r,i];case 2:return[1-e-i,1-s-r,i,r];case 3:return[s,1-e-i,r,i];case 4:return[e,s-i*(l/c),r*(c/l),i*(l/c)];case 5:return[1-s,e,i*(l/c),r*(c/l)];case 6:return[1-e-r*(c/l),1-s,r*(c/l),i*(l/c)];case 7:return[s-i*(l/c),1-e-r*(c/l),i*(l/c),r*(c/l)];case 8:return[e-i,s-r,i,r];case 9:return[1-s,e-i,r,i];case 10:return[1-e,1-s,i,r];case 11:return[s-r,1-e,r,i];case 12:return[e-r*(c/l),s,r*(c/l),i*(l/c)];case 13:return[1-s-i*(l/c),e-r*(c/l),i*(l/c),r*(c/l)];case 14:return[1-e,1-s-i*(l/c),r*(c/l),i*(l/c)];case 15:return[s,1-e,i*(l/c),r*(c/l)];default:return[e,s,i,r]}},M(wt,"_currentDrawId",-1),M(wt,"_currentParent",null),m(wt,Le,null),m(wt,hl,null),m(wt,dl,null),M(wt,"_INNER_MARGIN",3);let sp=wt;var gn,Fe,Ge,ul,ih,hs,je,wi,fl,pl,gl,nh,Bf;class xx{constructor(t,e,s,i,r,a){m(this,nh);m(this,gn,new Float64Array(6));m(this,Fe);m(this,Ge);m(this,ul);m(this,ih);m(this,hs);m(this,je,"");m(this,wi,0);m(this,fl,new Xu);m(this,pl);m(this,gl);p(this,pl,s),p(this,gl,i),p(this,ul,r),p(this,ih,a),[t,e]=v(this,nh,Bf).call(this,t,e);const o=p(this,Fe,[NaN,NaN,NaN,NaN,t,e]);p(this,hs,[t,e]),p(this,Ge,[{line:o,points:n(this,hs)}]),n(this,gn).set(o,0)}updateProperty(t,e){t==="stroke-width"&&p(this,ih,e)}isEmpty(){var t;return!((t=n(this,Ge))!=null&&t.length)}isCancellable(){return n(this,hs).length<=10}add(t,e){[t,e]=v(this,nh,Bf).call(this,t,e);const[s,i,r,a]=n(this,gn).subarray(2,6),o=t-r,l=e-a;return Math.hypot(n(this,pl)*o,n(this,gl)*l)<=2?null:(n(this,hs).push(t,e),isNaN(s)?(n(this,gn).set([r,a,t,e],2),n(this,Fe).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(n(this,gn)[0])&&n(this,Fe).splice(6,6),n(this,gn).set([s,i,r,a,t,e],0),n(this,Fe).push(...X.createBezierPoints(s,i,r,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const s=this.add(t,e);return s||(n(this,hs).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,i,r){p(this,pl,s),p(this,gl,i),p(this,ul,r),[t,e]=v(this,nh,Bf).call(this,t,e);const a=p(this,Fe,[NaN,NaN,NaN,NaN,t,e]);p(this,hs,[t,e]);const o=n(this,Ge).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),n(this,Ge).push({line:a,points:n(this,hs)}),n(this,gn).set(a,0),p(this,wi,0),this.toSVGPath(),null}getLastElement(){return n(this,Ge).at(-1)}setLastElement(t){return n(this,Ge)?(n(this,Ge).push(t),p(this,Fe,t.line),p(this,hs,t.points),p(this,wi,0),{path:{d:this.toSVGPath()}}):n(this,fl).setLastElement(t)}removeLastElement(){if(!n(this,Ge))return n(this,fl).removeLastElement();n(this,Ge).pop(),p(this,je,"");for(let t=0,e=n(this,Ge).length;t<e;t++){const{line:s,points:i}=n(this,Ge)[t];p(this,Fe,s),p(this,hs,i),p(this,wi,0),this.toSVGPath()}return{path:{d:n(this,je)}}}toSVGPath(){const t=X.svgRound(n(this,Fe)[4]),e=X.svgRound(n(this,Fe)[5]);if(n(this,hs).length===2)return p(this,je,`${n(this,je)} M ${t} ${e} Z`),n(this,je);if(n(this,hs).length<=6){const i=n(this,je).lastIndexOf("M");p(this,je,`${n(this,je).slice(0,i)} M ${t} ${e}`),p(this,wi,6)}if(n(this,hs).length===4){const i=X.svgRound(n(this,Fe)[10]),r=X.svgRound(n(this,Fe)[11]);return p(this,je,`${n(this,je)} L ${i} ${r}`),p(this,wi,12),n(this,je)}const s=[];n(this,wi)===0&&(s.push(`M ${t} ${e}`),p(this,wi,6));for(let i=n(this,wi),r=n(this,Fe).length;i<r;i+=6){const[a,o,l,c,h,d]=n(this,Fe).slice(i,i+6).map(X.svgRound);s.push(`C${a} ${o} ${l} ${c} ${h} ${d}`)}return p(this,je,n(this,je)+s.join(" ")),p(this,wi,n(this,Fe).length),n(this,je)}getOutlines(t,e,s,i){const r=n(this,Ge).at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),n(this,fl).build(n(this,Ge),t,e,s,n(this,ul),n(this,ih),i),p(this,gn,null),p(this,Fe,null),p(this,Ge,null),p(this,je,null),n(this,fl)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}gn=new WeakMap,Fe=new WeakMap,Ge=new WeakMap,ul=new WeakMap,ih=new WeakMap,hs=new WeakMap,je=new WeakMap,wi=new WeakMap,fl=new WeakMap,pl=new WeakMap,gl=new WeakMap,nh=new WeakSet,Bf=function(t,e){return X._normalizePoint(t,e,n(this,pl),n(this,gl),n(this,ul))};var ds,Lu,Fu,Js,mn,vn,rh,ah,ml,Xe,Pn,u0,f0,p0;class Xu extends X{constructor(){super(...arguments);m(this,Xe);m(this,ds);m(this,Lu,0);m(this,Fu);m(this,Js);m(this,mn);m(this,vn);m(this,rh);m(this,ah);m(this,ml)}build(e,s,i,r,a,o,l){p(this,mn,s),p(this,vn,i),p(this,rh,r),p(this,ah,a),p(this,ml,o),p(this,Fu,l??0),p(this,Js,e),v(this,Xe,f0).call(this)}get thickness(){return n(this,ml)}setLastElement(e){return n(this,Js).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return n(this,Js).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:s}of n(this,Js)){if(e.push(`M${X.svgRound(s[4])} ${X.svgRound(s[5])}`),s.length===6){e.push("Z");continue}if(s.length===12&&isNaN(s[6])){e.push(`L${X.svgRound(s[10])} ${X.svgRound(s[11])}`);continue}for(let i=6,r=s.length;i<r;i+=6){const[a,o,l,c,h,d]=s.subarray(i,i+6).map(X.svgRound);e.push(`C${a} ${o} ${l} ${c} ${h} ${d}`)}}return e.join("")}serialize([e,s,i,r],a){const o=[],l=[],[c,h,d,f]=v(this,Xe,u0).call(this);let g,y,b,S,w,x,A,C,_;switch(n(this,ah)){case 0:_=X._rescale,g=e,y=s+r,b=i,S=-r,w=e+c*i,x=s+(1-h-f)*r,A=e+(c+d)*i,C=s+(1-h)*r;break;case 90:_=X._rescaleAndSwap,g=e,y=s,b=i,S=r,w=e+h*i,x=s+c*r,A=e+(h+f)*i,C=s+(c+d)*r;break;case 180:_=X._rescale,g=e+i,y=s,b=-i,S=r,w=e+(1-c-d)*i,x=s+h*r,A=e+(1-c)*i,C=s+(h+f)*r;break;case 270:_=X._rescaleAndSwap,g=e+i,y=s+r,b=-i,S=-r,w=e+(1-h-f)*i,x=s+(1-c-d)*r,A=e+(1-h)*i,C=s+(1-c)*r;break}for(const{line:k,points:I}of n(this,Js))o.push(_(k,g,y,b,S,a?new Array(k.length):null)),l.push(_(I,g,y,b,S,a?new Array(I.length):null));return{lines:o,points:l,rect:[w,x,A,C]}}static deserialize(e,s,i,r,a,{paths:{lines:o,points:l},rotation:c,thickness:h}){const d=[];let f,g,y,b,S;switch(c){case 0:S=X._rescale,f=-e/i,g=s/r+1,y=1/i,b=-1/r;break;case 90:S=X._rescaleAndSwap,f=-s/r,g=-e/i,y=1/r,b=1/i;break;case 180:S=X._rescale,f=e/i+1,g=-s/r,y=-1/i,b=1/r;break;case 270:S=X._rescaleAndSwap,f=s/r+1,g=e/i+1,y=-1/r,b=-1/i;break}if(!o){o=[];for(const x of l){const A=x.length;if(A===2){o.push(new Float32Array([NaN,NaN,NaN,NaN,x[0],x[1]]));continue}if(A===4){o.push(new Float32Array([NaN,NaN,NaN,NaN,x[0],x[1],NaN,NaN,NaN,NaN,x[2],x[3]]));continue}const C=new Float32Array(3*(A-2));o.push(C);let[_,k,I,L]=x.subarray(0,4);C.set([NaN,NaN,NaN,NaN,_,k],0);for(let P=4;P<A;P+=2){const D=x[P],R=x[P+1];C.set(X.createBezierPoints(_,k,I,L,D,R),(P-2)*3),[_,k,I,L]=[I,L,D,R]}}}for(let x=0,A=o.length;x<A;x++)d.push({line:S(o[x].map(C=>C??NaN),f,g,y,b),points:S(l[x].map(C=>C??NaN),f,g,y,b)});const w=new this.prototype.constructor;return w.build(d,i,r,1,c,h,a),w}get box(){return n(this,ds)}updateProperty(e,s){return e==="stroke-width"?v(this,Xe,p0).call(this,s):null}updateParentDimensions([e,s],i){const[r,a]=v(this,Xe,Pn).call(this);p(this,mn,e),p(this,vn,s),p(this,rh,i);const[o,l]=v(this,Xe,Pn).call(this),c=o-r,h=l-a,d=n(this,ds);return d[0]-=c,d[1]-=h,d[2]+=2*c,d[3]+=2*h,d}updateRotation(e){return p(this,Lu,e),{path:{transform:this.rotationTransform}}}get viewBox(){return n(this,ds).map(X.svgRound).join(" ")}get defaultProperties(){const[e,s]=n(this,ds);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(s)}`}}}get rotationTransform(){const[,,e,s]=n(this,ds);let i=0,r=0,a=0,o=0,l=0,c=0;switch(n(this,Lu)){case 90:r=s/e,a=-e/s,l=e;break;case 180:i=-1,o=-1,l=e,c=s;break;case 270:r=-s/e,a=e/s,c=s;break;default:return""}return`matrix(${i} ${r} ${a} ${o} ${X.svgRound(l)} ${X.svgRound(c)})`}getPathResizingSVGProperties([e,s,i,r]){const[a,o]=v(this,Xe,Pn).call(this),[l,c,h,d]=n(this,ds);if(Math.abs(h-a)<=X.PRECISION||Math.abs(d-o)<=X.PRECISION){const S=e+i/2-(l+h/2),w=s+r/2-(c+d/2);return{path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(s)}`,transform:`${this.rotationTransform} translate(${S} ${w})`}}}const f=(i-2*a)/(h-2*a),g=(r-2*o)/(d-2*o),y=h/i,b=d/r;return{path:{"transform-origin":`${X.svgRound(l)} ${X.svgRound(c)}`,transform:`${this.rotationTransform} scale(${y} ${b}) translate(${X.svgRound(a)} ${X.svgRound(o)}) scale(${f} ${g}) translate(${X.svgRound(-a)} ${X.svgRound(-o)})`}}}getPathResizedSVGProperties([e,s,i,r]){const[a,o]=v(this,Xe,Pn).call(this),l=n(this,ds),[c,h,d,f]=l;if(l[0]=e,l[1]=s,l[2]=i,l[3]=r,Math.abs(d-a)<=X.PRECISION||Math.abs(f-o)<=X.PRECISION){const w=e+i/2-(c+d/2),x=s+r/2-(h+f/2);for(const{line:A,points:C}of n(this,Js))X._translate(A,w,x,A),X._translate(C,w,x,C);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const g=(i-2*a)/(d-2*a),y=(r-2*o)/(f-2*o),b=-g*(c+a)+e+a,S=-y*(h+o)+s+o;if(g!==1||y!==1||b!==0||S!==0)for(const{line:w,points:x}of n(this,Js))X._rescale(w,b,S,g,y,w),X._rescale(x,b,S,g,y,x);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,s],i){const[r,a]=i,o=n(this,ds),l=e-o[0],c=s-o[1];if(n(this,mn)===r&&n(this,vn)===a)for(const{line:h,points:d}of n(this,Js))X._translate(h,l,c,h),X._translate(d,l,c,d);else{const h=n(this,mn)/r,d=n(this,vn)/a;p(this,mn,r),p(this,vn,a);for(const{line:f,points:g}of n(this,Js))X._rescale(f,l,c,h,d,f),X._rescale(g,l,c,h,d,g);o[2]*=h,o[3]*=d}return o[0]=e,o[1]=s,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${X.svgRound(e)} ${X.svgRound(s)}`}}}get defaultSVGProperties(){const e=n(this,ds);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${X.svgRound(e[0])} ${X.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}ds=new WeakMap,Lu=new WeakMap,Fu=new WeakMap,Js=new WeakMap,mn=new WeakMap,vn=new WeakMap,rh=new WeakMap,ah=new WeakMap,ml=new WeakMap,Xe=new WeakSet,Pn=function(e=n(this,ml)){const s=n(this,Fu)+e/2*n(this,rh);return n(this,ah)%180===0?[s/n(this,mn),s/n(this,vn)]:[s/n(this,vn),s/n(this,mn)]},u0=function(){const[e,s,i,r]=n(this,ds),[a,o]=v(this,Xe,Pn).call(this,0);return[e+a,s+o,i-2*a,r-2*o]},f0=function(){const e=p(this,ds,ja.slice());for(const{line:r}of n(this,Js)){if(r.length<=12){for(let l=4,c=r.length;l<c;l+=6)B.pointBoundingBox(r[l],r[l+1],e);continue}let a=r[4],o=r[5];for(let l=6,c=r.length;l<c;l+=6){const[h,d,f,g,y,b]=r.subarray(l,l+6);B.bezierBoundingBox(a,o,h,d,f,g,y,b,e),a=y,o=b}}const[s,i]=v(this,Xe,Pn).call(this);e[0]=Qt(e[0]-s,0,1),e[1]=Qt(e[1]-i,0,1),e[2]=Qt(e[2]+s,0,1),e[3]=Qt(e[3]+i,0,1),e[2]-=e[0],e[3]-=e[1]},p0=function(e){const[s,i]=v(this,Xe,Pn).call(this);p(this,ml,e);const[r,a]=v(this,Xe,Pn).call(this),[o,l]=[r-s,a-i],c=n(this,ds);return c[0]-=o,c[1]-=l,c[2]+=2*o,c[3]+=2*l,c};class jp extends h0{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:Pt._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??(e=this["stroke-width"]),e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new jp(this._viewParameters);return t.updateAll(this),t}}var _p,g0;const Ul=class Ul extends sp{constructor(e){super({...e,name:"inkEditor"});m(this,_p);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(e,s){Pt.initialize(e,s),this._defaultDrawingOptions=new jp(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!0}static get typesMap(){return at(this,"typesMap",new Map([[dt.INK_THICKNESS,"stroke-width"],[dt.INK_COLOR,"stroke"],[dt.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,s,i,r,a){return new xx(e,s,i,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,s,i,r,a,o){return Xu.deserialize(e,s,i,r,a,o)}static async deserialize(e,s,i){let r=null;if(e instanceof qm){const{data:{inkLists:o,rect:l,rotation:c,id:h,color:d,opacity:f,borderStyle:{rawWidth:g},popupRef:y,richText:b,contentsObj:S,creationDate:w,modificationDate:x},parent:{page:{pageNumber:A}}}=e;r=e={annotationType:ot.INK,color:Array.from(d),thickness:g,opacity:f,paths:{points:o},boxes:null,pageIndex:A-1,rect:l.slice(0),rotation:c,annotationElementId:h,id:h,deleted:!1,popupRef:y,richText:b,comment:(S==null?void 0:S.str)||null,creationDate:w,modificationDate:x}}const a=await super.deserialize(e,s,i);return a._initialData=r,e.comment&&a.setCommentData(e),a}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new Jf(this)),[["colorPicker",this._colorPicker]]}get colorType(){return dt.INK_COLOR}get colorAndOpacityType(){return dt.INK_COLOR_AND_OPACITY}get opacityType(){return dt.INK_OPACITY}updateParams(e,s){if(e===dt.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(s.color,s.opacity);return}super.updateParams(e,s)}static updateDefaultParams(e,s){if(e===dt.INK_COLOR_AND_OPACITY){super.updateDefaultParams(dt.INK_COLOR,s.color),super.updateDefaultParams(dt.INK_OPACITY,s.opacity);return}super.updateDefaultParams(e,s)}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:e,_drawingOptions:s,parent:i}=this;s.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(e,s.toSVGProperties())}static onScaleChangingWhenDrawing(){const e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:s,opacity:i}){this._drawingOptions=Ul.getDefaultDrawingOptions({stroke:B.makeHexColor(...e),"stroke-width":s,"stroke-opacity":i})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:s,points:i}=this.serializeDraw(e),{_drawingOptions:{stroke:r,"stroke-opacity":a,"stroke-width":o}}=this,l=Object.assign(super.serialize(e),{color:Pt._colorManager.convert(r),opacity:a,thickness:o,paths:{lines:s,points:i}});return this.addComment(l),e?(l.isCopy=!0,l):this.annotationElementId&&!v(this,_p,g0).call(this,l)?null:(l.id=this.annotationElementId,l)}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;const{points:s,rect:i}=this.serializeDraw(!1);return e.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:s,popup:this.comment}),null}};_p=new WeakSet,g0=function(e){const{color:s,thickness:i,opacity:r,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((o,l)=>o!==s[l])||e.thickness!==i||e.opacity!==r||e.pageIndex!==a},M(Ul,"_type","ink"),M(Ul,"_editorType",ot.INK),M(Ul,"_defaultDrawingOptions",null);let Am=Ul;class Sm extends Xu{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const tf=8,Sh=3;var vl,Mt,xm,Vi,m0,v0,Em,$f,b0,y0,w0,Cm,_m,A0;class gr{static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:i},r,a,o,l){let c=new OffscreenCanvas(1,1),h=c.getContext("2d",{alpha:!1});const d=200,f=h.font=`${s} ${i} ${d}px ${e}`,{actualBoundingBoxLeft:g,actualBoundingBoxRight:y,actualBoundingBoxAscent:b,actualBoundingBoxDescent:S,fontBoundingBoxAscent:w,fontBoundingBoxDescent:x,width:A}=h.measureText(t),C=1.5,_=Math.ceil(Math.max(Math.abs(g)+Math.abs(y)||0,A)*C),k=Math.ceil(Math.max(Math.abs(b)+Math.abs(S)||d,Math.abs(w)+Math.abs(x)||d)*C);c=new OffscreenCanvas(_,k),h=c.getContext("2d",{alpha:!0,willReadFrequently:!0}),h.font=f,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,_,k),h.fillStyle="black",h.fillText(t,_*(C-1)/2,k*(3-C)/2);const I=v(this,Mt,Cm).call(this,h.getImageData(0,0,_,k).data),L=v(this,Mt,w0).call(this,I),P=v(this,Mt,_m).call(this,L),D=v(this,Mt,Em).call(this,I,_,k,P);return this.processDrawnLines({lines:{curves:D,width:_,height:k},pageWidth:r,pageHeight:a,rotation:o,innerMargin:l,mustSmooth:!0,areContours:!0})}static process(t,e,s,i,r){const[a,o,l]=v(this,Mt,A0).call(this,t),[c,h]=v(this,Mt,y0).call(this,a,o,l,Math.hypot(o,l)*n(this,vl).sigmaSFactor,n(this,vl).sigmaR,n(this,vl).kernelSize),d=v(this,Mt,_m).call(this,h),f=v(this,Mt,Em).call(this,c,o,l,d);return this.processDrawnLines({lines:{curves:f,width:o,height:l},pageWidth:e,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:a,areContours:o}){i%180!==0&&([e,s]=[s,e]);const{curves:l,width:c,height:h}=t,d=t.thickness??0,f=[],g=Math.min(e/c,s/h),y=g/e,b=g/s,S=[];for(const{points:x}of l){const A=a?v(this,Mt,b0).call(this,x):x;if(!A)continue;S.push(A);const C=A.length,_=new Float32Array(C),k=new Float32Array(3*(C===2?2:C-2));if(f.push({line:k,points:_}),C===2){_[0]=A[0]*y,_[1]=A[1]*b,k.set([NaN,NaN,NaN,NaN,_[0],_[1]],0);continue}let[I,L,P,D]=A;I*=y,L*=b,P*=y,D*=b,_.set([I,L,P,D],0),k.set([NaN,NaN,NaN,NaN,I,L],0);for(let R=4;R<C;R+=2){const K=_[R]=A[R]*y,W=_[R+1]=A[R+1]*b;k.set(X.createBezierPoints(I,L,P,D,K,W),(R-2)*3),[I,L,P,D]=[P,D,K,W]}}if(f.length===0)return null;const w=o?new Sm:new Xu;return w.build(f,e,s,1,i,o?0:d,r),{outline:w,newCurves:S,areContours:o,thickness:d,width:c,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:i,height:r}){let a=1/0,o=-1/0,l=0;for(const x of t){l+=x.length;for(let A=2,C=x.length;A<C;A++){const _=x[A]-x[A-2];a=Math.min(a,_),o=Math.max(o,_)}}let c;a>=-128&&o<=127?c=Int8Array:a>=-32768&&o<=32767?c=Int16Array:c=Int32Array;const h=t.length,d=tf+Sh*h,f=new Uint32Array(d);let g=0;f[g++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*h)*c.BYTES_PER_ELEMENT,f[g++]=0,f[g++]=i,f[g++]=r,f[g++]=e?0:1,f[g++]=Math.max(0,Math.floor(s??0)),f[g++]=h,f[g++]=c.BYTES_PER_ELEMENT;for(const x of t)f[g++]=x.length-2,f[g++]=x[0],f[g++]=x[1];const y=new CompressionStream("deflate-raw"),b=y.writable.getWriter();await b.ready,b.write(f);const S=c.prototype.constructor;for(const x of t){const A=new S(x.length-2);for(let C=2,_=x.length;C<_;C++)A[C-2]=x[C]-x[C-2];b.write(A)}return b.close(),(await new Response(y.readable).bytes()).toBase64()}static async decompressSignature(t){try{const e=Uint8Array.fromBase64(t),{readable:s,writable:i}=new DecompressionStream("deflate-raw"),r=i.getWriter();await r.ready,r.write(e).then(async()=>{await r.ready,await r.close()}).catch(()=>{});let a=null,o=0;for await(const A of s)a||(a=new Uint8Array(new Uint32Array(A.buffer,0,4)[0])),a.set(A,o),o+=A.length;const l=new Uint32Array(a.buffer,0,a.length>>2),c=l[1];if(c!==0)throw new Error(`Invalid version: ${c}`);const h=l[2],d=l[3],f=l[4]===0,g=l[5],y=l[6],b=l[7],S=[],w=(tf+Sh*y)*Uint32Array.BYTES_PER_ELEMENT;let x;switch(b){case Int8Array.BYTES_PER_ELEMENT:x=new Int8Array(a.buffer,w);break;case Int16Array.BYTES_PER_ELEMENT:x=new Int16Array(a.buffer,w);break;case Int32Array.BYTES_PER_ELEMENT:x=new Int32Array(a.buffer,w);break}o=0;for(let A=0;A<y;A++){const C=l[Sh*A+tf],_=new Float32Array(C+2);S.push(_);for(let k=0;k<Sh-1;k++)_[k]=l[Sh*A+tf+k+1];for(let k=0;k<C;k++)_[k+2]=_[k]+x[o++]}return{areContours:f,thickness:g,outlines:S,width:h,height:d}}catch(e){return lt(`decompressSignature: ${e}`),null}}}vl=new WeakMap,Mt=new WeakSet,xm=function(t,e,s,i){return s-=t,i-=e,s===0?i>0?0:4:s===1?i+6:2-i},Vi=new WeakMap,m0=function(t,e,s,i,r,a,o){const l=v(this,Mt,xm).call(this,s,i,r,a);for(let c=0;c<8;c++){const h=(-c+l-o+16)%8,d=n(this,Vi)[2*h],f=n(this,Vi)[2*h+1];if(t[(s+d)*e+(i+f)]!==0)return h}return-1},v0=function(t,e,s,i,r,a,o){const l=v(this,Mt,xm).call(this,s,i,r,a);for(let c=0;c<8;c++){const h=(c+l+o+16)%8,d=n(this,Vi)[2*h],f=n(this,Vi)[2*h+1];if(t[(s+d)*e+(i+f)]!==0)return h}return-1},Em=function(t,e,s,i){const r=t.length,a=new Int32Array(r);for(let h=0;h<r;h++)a[h]=t[h]<=i?1:0;for(let h=1;h<s-1;h++)a[h*e]=a[h*e+e-1]=0;for(let h=0;h<e;h++)a[h]=a[e*s-1-h]=0;let o=1,l;const c=[];for(let h=1;h<s-1;h++){l=1;for(let d=1;d<e-1;d++){const f=h*e+d,g=a[f];if(g===0)continue;let y=h,b=d;if(g===1&&a[f-1]===0)o+=1,b-=1;else if(g>=1&&a[f+1]===0)o+=1,b+=1,g>1&&(l=g);else{g!==1&&(l=Math.abs(g));continue}const S=[d,h],w=b===d+1,x={isHole:w,points:S,id:o,parent:0};c.push(x);let A;for(const R of c)if(R.id===l){A=R;break}A?A.isHole?x.parent=w?A.parent:l:x.parent=w?l:A.parent:x.parent=w?l:0;const C=v(this,Mt,m0).call(this,a,e,h,d,y,b,0);if(C===-1){a[f]=-o,a[f]!==1&&(l=Math.abs(a[f]));continue}let _=n(this,Vi)[2*C],k=n(this,Vi)[2*C+1];const I=h+_,L=d+k;y=I,b=L;let P=h,D=d;for(;;){const R=v(this,Mt,v0).call(this,a,e,P,D,y,b,1);_=n(this,Vi)[2*R],k=n(this,Vi)[2*R+1];const K=P+_,W=D+k;S.push(W,K);const Q=P*e+D;if(a[Q+1]===0?a[Q]=-o:a[Q]===1&&(a[Q]=o),K===h&&W===d&&P===I&&D===L){a[f]!==1&&(l=Math.abs(a[f]));break}else y=P,b=D,P=K,D=W}}}return c},$f=function(t,e,s,i){if(s-e<=4){for(let I=e;I<s-2;I+=2)i.push(t[I],t[I+1]);return}const r=t[e],a=t[e+1],o=t[s-4]-r,l=t[s-3]-a,c=Math.hypot(o,l),h=o/c,d=l/c,f=h*a-d*r,g=l/o,y=1/c,b=Math.atan(g),S=Math.cos(b),w=Math.sin(b),x=y*(Math.abs(S)+Math.abs(w)),A=y*(1-x+x**2),C=Math.max(Math.atan(Math.abs(w+S)*A),Math.atan(Math.abs(w-S)*A));let _=0,k=e;for(let I=e+2;I<s-2;I+=2){const L=Math.abs(f-h*t[I+1]+d*t[I]);L>_&&(k=I,_=L)}_>(c*C)**2?(v(this,Mt,$f).call(this,t,e,k+2,i),v(this,Mt,$f).call(this,t,k,s,i)):i.push(r,a)},b0=function(t){const e=[],s=t.length;return v(this,Mt,$f).call(this,t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e},y0=function(t,e,s,i,r,a){const o=new Float32Array(a**2),l=-2*i**2,c=a>>1;for(let b=0;b<a;b++){const S=(b-c)**2;for(let w=0;w<a;w++)o[b*a+w]=Math.exp((S+(w-c)**2)/l)}const h=new Float32Array(256),d=-2*r**2;for(let b=0;b<256;b++)h[b]=Math.exp(b**2/d);const f=t.length,g=new Uint8Array(f),y=new Uint32Array(256);for(let b=0;b<s;b++)for(let S=0;S<e;S++){const w=b*e+S,x=t[w];let A=0,C=0;for(let k=0;k<a;k++){const I=b+k-c;if(!(I<0||I>=s))for(let L=0;L<a;L++){const P=S+L-c;if(P<0||P>=e)continue;const D=t[I*e+P],R=o[k*a+L]*h[Math.abs(D-x)];A+=D*R,C+=R}}const _=g[w]=Math.round(A/C);y[_]++}return[g,y]},w0=function(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e},Cm=function(t){const e=t.length,s=new Uint8ClampedArray(e>>2);let i=-1/0,r=1/0;for(let o=0,l=s.length;o<l;o++){const c=s[o]=t[o<<2];i=Math.max(i,c),r=Math.min(r,c)}const a=255/(i-r);for(let o=0,l=s.length;o<l;o++)s[o]=(s[o]-r)*a;return s},_m=function(t){let e,s=-1/0,i=-1/0;const r=t.findIndex(l=>l!==0);let a=r,o=r;for(e=r;e<256;e++){const l=t[e];l>s&&(e-a>i&&(i=e-a,o=e-1),s=l,a=e)}for(e=o-1;e>=0&&!(t[e]>t[e+1]);e--);return e},A0=function(t){const e=t,{width:s,height:i}=t,{maxDim:r}=n(this,vl);let a=s,o=i;if(s>r||i>r){let f=s,g=i,y=Math.log2(Math.max(s,i)/r);const b=Math.floor(y);y=y===b?b-1:b;for(let w=0;w<y;w++){a=Math.ceil(f/2),o=Math.ceil(g/2);const x=new OffscreenCanvas(a,o);x.getContext("2d").drawImage(t,0,0,f,g,0,0,a,o),f=a,g=o,t!==e&&t.close(),t=x.transferToImageBitmap()}const S=Math.min(r/a,r/o);a=Math.round(a*S),o=Math.round(o*S)}const c=new OffscreenCanvas(a,o).getContext("2d",{willReadFrequently:!0});c.fillStyle="white",c.fillRect(0,0,a,o),c.filter="grayscale(1)",c.drawImage(t,0,0,t.width,t.height,0,0,a,o);const h=c.getImageData(0,0,a,o).data;return[v(this,Mt,Cm).call(this,h),a,o]},m(gr,Mt),m(gr,vl,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),m(gr,Vi,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class Ym extends h0{constructor(){super(),super.updateProperties({fill:Pt._defaultLineColor,"stroke-width":0})}clone(){const t=new Ym;return t.updateAll(this),t}}class Km extends jp{constructor(t){super(t),super.updateProperties({stroke:Pt._defaultLineColor,"stroke-width":1})}clone(){const t=new Km(this._viewParameters);return t.updateAll(this),t}}var fa,bn,pa,bl;const Os=class Os extends sp{constructor(e){super({...e,mustBeCommitted:!0,name:"signatureEditor"});m(this,fa,!1);m(this,bn,null);m(this,pa,null);m(this,bl,null);this._willKeepAspectRatio=!0,p(this,pa,e.signatureData||null),p(this,bn,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(e,s){Pt.initialize(e,s),this._defaultDrawingOptions=new Ym,this._defaultDrawnSignatureOptions=new Km(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!1}static get typesMap(){return at(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!n(this,bn)}}static computeTelemetryFinalData(e){const s=e.get("hasDescription");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let e,s;const{_isCopy:i}=this;if(i&&(this._isCopy=!1,e=this.x,s=this.y),super.render(),this._drawId===null)if(n(this,pa)){const{lines:r,mustSmooth:a,areContours:o,description:l,uuid:c,heightInPage:h}=n(this,pa),{rawDims:{pageWidth:d,pageHeight:f},rotation:g}=this.parent.viewport,y=gr.processDrawnLines({lines:r,pageWidth:d,pageHeight:f,rotation:g,innerMargin:Os._INNER_MARGIN,mustSmooth:a,areContours:o});this.addSignature(y,h,l,c)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:n(this,bn)||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(e,s)),this.div}setUuid(e){p(this,bl,e),this.addEditToolbar()}getUuid(){return n(this,bl)}get description(){return n(this,bn)}set description(e){p(this,bn,e),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:e})),super.addEditToolbar().then(s=>{s==null||s.updateEditSignatureButton(e)}))}getSignaturePreview(){const{newCurves:e,areContours:s,thickness:i,width:r,height:a}=n(this,pa),o=Math.max(r,a),l=gr.processDrawnLines({lines:{curves:e.map(c=>({points:c})),thickness:i,width:r,height:a},pageWidth:o,pageHeight:o,rotation:0,innerMargin:0,mustSmooth:!1,areContours:s});return{areContours:s,outline:l.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,s,i,r){const{x:a,y:o}=this,{outline:l}=p(this,pa,e);p(this,fa,l instanceof Sm),this.description=i;let c;n(this,fa)?c=Os.getDefaultDrawingOptions():(c=Os._defaultDrawnSignatureOptions.clone(),c.updateProperties({"stroke-width":l.thickness})),this._addOutlines({drawOutlines:l,drawingOptions:c});const[,h]=this.pageDimensions;let d=s/h;d=d>=1?.5:d,this.width*=d/this.height,this.width>=1&&(d*=.9/this.width,this.width=.9),this.height=d,this.setDims(),this.x=a,this.y=o,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(r),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!r,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return gr.process(e,s,i,r,Os._INNER_MARGIN)}getFromText(e,s){const{rawDims:{pageWidth:i,pageHeight:r},rotation:a}=this.parent.viewport;return gr.extractContoursFromText(e,s,i,r,a,Os._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return gr.processDrawnLines({lines:e,pageWidth:s,pageHeight:i,rotation:r,innerMargin:Os._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:s}){e?this._drawingOptions=Os.getDefaultDrawingOptions():(this._drawingOptions=Os._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":s}))}serialize(e=!1){if(this.isEmpty())return null;const{lines:s,points:i}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":r}}=this,a=Object.assign(super.serialize(e),{isSignature:!0,areContours:n(this,fa),color:[0,0,0],thickness:n(this,fa)?0:r});return this.addComment(a),e?(a.paths={lines:s,points:i},a.uuid=n(this,bl),a.isCopy=!0):a.lines=s,n(this,bn)&&(a.accessibilityData={type:"Figure",alt:n(this,bn)}),a}static deserializeDraw(e,s,i,r,a,o){return o.areContours?Sm.deserialize(e,s,i,r,a,o):Xu.deserialize(e,s,i,r,a,o)}static async deserialize(e,s,i){var a;const r=await super.deserialize(e,s,i);return p(r,fa,e.areContours),r.description=((a=e.accessibilityData)==null?void 0:a.alt)||"",p(r,bl,e.uuid),r}};fa=new WeakMap,bn=new WeakMap,pa=new WeakMap,bl=new WeakMap,M(Os,"_type","signature"),M(Os,"_editorType",ot.SIGNATURE),M(Os,"_defaultDrawingOptions",null);let km=Os;var Zt,Oe,ga,cr,ma,oh,hr,yl,yn,Zs,lh,xt,Gh,jh,Uf,Hf,zf,Pm,Vf,S0;class Tm extends Pt{constructor(e){super({...e,name:"stampEditor"});m(this,xt);m(this,Zt,null);m(this,Oe,null);m(this,ga,null);m(this,cr,null);m(this,ma,null);m(this,oh,"");m(this,hr,null);m(this,yl,!1);m(this,yn,null);m(this,Zs,!1);m(this,lh,!1);p(this,cr,e.bitmapUrl),p(this,ma,e.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,s){Pt.initialize(e,s)}static isHandlingMimeForPasting(e){return hg.includes(e)}static paste(e,s){s.pasteEditor({mode:ot.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var e;return{type:"stamp",hasAltText:!!((e=this.altTextData)!=null&&e.altText)}}static computeTelemetryFinalData(e){const s=e.get("hasAltText");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}async mlGuessAltText(e=null,s=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:r,width:a,height:o}=e||this.copyCanvas(null,null,!0).imageData,l=await i.guess({name:"altText",request:{data:r,width:a,height:o,channels:r.length/(a*o)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");const c=l.output;return await this.setGuessedAltText(c),s&&!this.hasAltTextData()&&(this.altTextData={alt:c,decorative:!1}),c}remove(){var e;n(this,Oe)&&(p(this,Zt,null),this._uiManager.imageManager.deleteId(n(this,Oe)),(e=n(this,hr))==null||e.remove(),p(this,hr,null),n(this,yn)&&(clearTimeout(n(this,yn)),p(this,yn,null))),super.remove()}rebuild(){if(!this.parent){n(this,Oe)&&v(this,xt,Uf).call(this);return}super.rebuild(),this.div!==null&&(n(this,Oe)&&n(this,hr)===null&&v(this,xt,Uf).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(n(this,ga)||n(this,Zt)||n(this,cr)||n(this,ma)||n(this,Oe)||n(this,yl))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let e,s;return this._isCopy&&(e=this.x,s=this.y),super.render(),this.div.hidden=!0,this.createAltText(),n(this,yl)||(n(this,Zt)?v(this,xt,Hf).call(this):v(this,xt,Uf).call(this)),this._isCopy&&this._moveAfterPaste(e,s),this._uiManager.addShouldRescale(this),this.div}setCanvas(e,s){const{id:i,bitmap:r}=this._uiManager.imageManager.getFromCanvas(e,s);s.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(p(this,Oe,i),r&&p(this,Zt,r),p(this,yl,!1),v(this,xt,Hf).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;n(this,yn)!==null&&clearTimeout(n(this,yn)),p(this,yn,setTimeout(()=>{p(this,yn,null),v(this,xt,Pm).call(this)},200))}copyCanvas(e,s,i=!1){e||(e=224);const{width:r,height:a}=n(this,Zt),o=new En;let l=n(this,Zt),c=r,h=a,d=null;if(s){if(r>s||a>s){const I=Math.min(s/r,s/a);c=Math.floor(r*I),h=Math.floor(a*I)}d=document.createElement("canvas");const g=d.width=Math.ceil(c*o.sx),y=d.height=Math.ceil(h*o.sy);n(this,Zs)||(l=v(this,xt,zf).call(this,g,y));const b=d.getContext("2d");b.filter=this._uiManager.hcmFilter;let S="white",w="#cfcfd8";this._uiManager.hcmFilter!=="none"?w="black":FS.isDarkMode&&(S="#8f8f9d",w="#42414d");const x=15,A=x*o.sx,C=x*o.sy,_=new OffscreenCanvas(A*2,C*2),k=_.getContext("2d");k.fillStyle=S,k.fillRect(0,0,A*2,C*2),k.fillStyle=w,k.fillRect(0,0,A,C),k.fillRect(A,C,A,C),b.fillStyle=b.createPattern(_,"repeat"),b.fillRect(0,0,g,y),b.drawImage(l,0,0,l.width,l.height,0,0,g,y)}let f=null;if(i){let g,y;if(o.symmetric&&l.width<e&&l.height<e)g=l.width,y=l.height;else if(l=n(this,Zt),r>e||a>e){const w=Math.min(e/r,e/a);g=Math.floor(r*w),y=Math.floor(a*w),n(this,Zs)||(l=v(this,xt,zf).call(this,g,y))}const S=new OffscreenCanvas(g,y).getContext("2d",{willReadFrequently:!0});S.drawImage(l,0,0,l.width,l.height,0,0,g,y),f={width:g,height:y,data:S.getImageData(0,0,g,y).data}}return{canvas:d,width:c,height:h,imageData:f}}static async deserialize(e,s,i){var S;let r=null,a=!1;if(e instanceof Ry){const{data:{rect:w,rotation:x,id:A,structParent:C,popupRef:_,richText:k,contentsObj:I,creationDate:L,modificationDate:P},container:D,parent:{page:{pageNumber:R}},canvas:K}=e;let W,Q;K?(delete e.canvas,{id:W,bitmap:Q}=i.imageManager.getFromCanvas(D.id,K),K.remove()):(a=!0,e._hasNoCanvas=!0);const ht=((S=await s._structTree.getAriaAttributes(`${Bl}${A}`))==null?void 0:S.get("aria-label"))||"";r=e={annotationType:ot.STAMP,bitmapId:W,bitmap:Q,pageIndex:R-1,rect:w.slice(0),rotation:x,annotationElementId:A,id:A,deleted:!1,accessibilityData:{decorative:!1,altText:ht},isSvg:!1,structParent:C,popupRef:_,richText:k,comment:(I==null?void 0:I.str)||null,creationDate:L,modificationDate:P}}const o=await super.deserialize(e,s,i),{rect:l,bitmap:c,bitmapUrl:h,bitmapId:d,isSvg:f,accessibilityData:g}=e;a?(i.addMissingCanvas(e.id,o),p(o,yl,!0)):d&&i.imageManager.isValidId(d)?(p(o,Oe,d),c&&p(o,Zt,c)):p(o,cr,h),p(o,Zs,f);const[y,b]=o.pageDimensions;return o.width=(l[2]-l[0])/y,o.height=(l[3]-l[1])/b,g&&(o.altTextData=g),o._initialData=r,e.comment&&o.setCommentData(e),p(o,lh,!!r),o}serialize(e=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i=Object.assign(super.serialize(e),{bitmapId:n(this,Oe),isSvg:n(this,Zs)});if(this.addComment(i),e)return i.bitmapUrl=v(this,xt,Vf).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;const{decorative:r,altText:a}=this.serializeAltText(!1);if(!r&&a&&(i.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){const l=v(this,xt,S0).call(this,i);return l.isSame?null:(l.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1,i.id=this.annotationElementId,delete i.bitmapId,i)}if(s===null)return i;s.stamps||(s.stamps=new Map);const o=n(this,Zs)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(n(this,Oe)))s.stamps.set(n(this,Oe),{area:o,serialized:i}),i.bitmap=v(this,xt,Vf).call(this,!1);else if(n(this,Zs)){const l=s.stamps.get(n(this,Oe));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=v(this,xt,Vf).call(this,!1))}return i}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}Zt=new WeakMap,Oe=new WeakMap,ga=new WeakMap,cr=new WeakMap,ma=new WeakMap,oh=new WeakMap,hr=new WeakMap,yl=new WeakMap,yn=new WeakMap,Zs=new WeakMap,lh=new WeakMap,xt=new WeakSet,Gh=function(e,s=!1){if(!e){this.remove();return}p(this,Zt,e.bitmap),s||(p(this,Oe,e.id),p(this,Zs,e.isSvg)),e.file&&p(this,oh,e.file.name),v(this,xt,Hf).call(this)},jh=function(){if(p(this,ga,null),this._uiManager.enableWaiting(!1),!!n(this,hr)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,Zt)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,Zt)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},Uf=function(){if(n(this,Oe)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(n(this,Oe)).then(i=>v(this,xt,Gh).call(this,i,!0)).finally(()=>v(this,xt,jh).call(this));return}if(n(this,cr)){const i=n(this,cr);p(this,cr,null),this._uiManager.enableWaiting(!0),p(this,ga,this._uiManager.imageManager.getFromUrl(i).then(r=>v(this,xt,Gh).call(this,r)).finally(()=>v(this,xt,jh).call(this)));return}if(n(this,ma)){const i=n(this,ma);p(this,ma,null),this._uiManager.enableWaiting(!0),p(this,ga,this._uiManager.imageManager.getFromFile(i).then(r=>v(this,xt,Gh).call(this,r)).finally(()=>v(this,xt,jh).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=hg.join(",");const s=this._uiManager._signal;p(this,ga,new Promise(i=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const r=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),v(this,xt,Gh).call(this,r)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>v(this,xt,jh).call(this))),e.click()},Hf=function(){var c;const{div:e}=this;let{width:s,height:i}=n(this,Zt);const[r,a]=this.pageDimensions,o=.75;if(this.width)s=this.width*r,i=this.height*a;else if(s>o*r||i>o*a){const h=Math.min(o*r/s,o*a/i);s*=h,i*=h}this._uiManager.enableWaiting(!1);const l=p(this,hr,document.createElement("canvas"));l.setAttribute("role","img"),this.addContainer(l),this.width=s/r,this.height=i/a,this.setDims(),(c=this._initialOptions)!=null&&c.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),v(this,xt,Pm).call(this),n(this,lh)||(this.parent.addUndoableEditor(this),p(this,lh,!0)),this._reportTelemetry({action:"inserted_image"}),n(this,oh)&&this.div.setAttribute("aria-description",n(this,oh)),this.annotationElementId||this._uiManager.a11yAlert(Pt._l10nAlert.stamp)},zf=function(e,s){const{width:i,height:r}=n(this,Zt);let a=i,o=r,l=n(this,Zt);for(;a>2*e||o>2*s;){const c=a,h=o;a>2*e&&(a=Math.ceil(a/2)),o>2*s&&(o=Math.ceil(o/2));const d=new OffscreenCanvas(a,o);d.getContext("2d").drawImage(l,0,0,c,h,0,0,a,o),l=d.transferToImageBitmap()}return l},Pm=function(){const[e,s]=this.parentDimensions,{width:i,height:r}=this,a=new En,o=Math.ceil(i*e*a.sx),l=Math.ceil(r*s*a.sy),c=n(this,hr);if(!c||c.width===o&&c.height===l)return;c.width=o,c.height=l;const h=n(this,Zs)?n(this,Zt):v(this,xt,zf).call(this,o,l),d=c.getContext("2d");d.filter=this._uiManager.hcmFilter,d.drawImage(h,0,0,h.width,h.height,0,0,o,l)},Vf=function(e){if(e){if(n(this,Zs)){const r=this._uiManager.imageManager.getSvgUrl(n(this,Oe));if(r)return r}const s=document.createElement("canvas");return{width:s.width,height:s.height}=n(this,Zt),s.getContext("2d").drawImage(n(this,Zt),0,0),s.toDataURL()}if(n(this,Zs)){const[s,i]=this.pageDimensions,r=Math.round(this.width*s*ka.PDF_TO_CSS_UNITS),a=Math.round(this.height*i*ka.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(r,a);return o.getContext("2d").drawImage(n(this,Zt),0,0,n(this,Zt).width,n(this,Zt).height,0,0,r,a),o.transferToImageBitmap()}return structuredClone(n(this,Zt))},S0=function(e){var o;const{pageIndex:s,accessibilityData:{altText:i}}=this._initialData,r=e.pageIndex===s,a=(((o=e.accessibilityData)==null?void 0:o.alt)||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&r&&a,isSameAltText:a}},M(Tm,"_type","stamp"),M(Tm,"_editorType",ot.STAMP);var wl,ch,va,ba,dr,Es,ya,hh,dh,Gi,ur,Re,fr,wa,uh,Y,Aa,zt,Im,x0,Yi,Dm,Lm,Gf;const Mi=class Mi{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:c,l10n:h}){m(this,zt);m(this,wl);m(this,ch,!1);m(this,va,null);m(this,ba,null);m(this,dr,null);m(this,Es,new Map);m(this,ya,!1);m(this,hh,!1);m(this,dh,!1);m(this,Gi,null);m(this,ur,null);m(this,Re,null);m(this,fr,null);m(this,wa,null);m(this,uh,-1);m(this,Y);const d=[...n(Mi,Aa).values()];if(!Mi._initialized){Mi._initialized=!0;for(const f of d)f.initialize(h,t)}t.registerEditorTypes(d),p(this,Y,t),this.pageIndex=e,this.div=s,p(this,wl,r),p(this,va,a),this.viewport=c,p(this,Re,l),this.drawLayer=o,this._structTree=i,n(this,Y).addLayer(this)}get isEmpty(){return n(this,Es).size===0}get isInvisible(){return this.isEmpty&&n(this,Y).getMode()===ot.NONE}updateToolbar(t){n(this,Y).updateToolbar(t)}updateMode(t=n(this,Y).getMode()){switch(v(this,zt,Gf).call(this),t){case ot.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case ot.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case ot.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===ot.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const s of n(Mi,Aa).values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=n(this,Re))==null?void 0:e.div)}setEditingState(t){n(this,Y).setEditingState(t)}addCommands(t){n(this,Y).addCommands(t)}cleanUndoStack(t){n(this,Y).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;(e=n(this,va))==null||e.togglePointerEvents(t)}async enable(){var s;p(this,dh,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(s=n(this,wa))==null||s.abort(),p(this,wa,null);const t=new Set;for(const i of n(this,zt,Im))i.enableEditing(),i.show(!0),i.annotationElementId&&(n(this,Y).removeChangedExistingAnnotation(i),t.add(i.annotationElementId));const e=n(this,va);if(e)for(const i of e.getEditableAnnotations()){if(i.hide(),n(this,Y).isDeletedAnnotationElement(i.data.id)||t.has(i.data.id))continue;const r=await this.deserialize(i);r&&(this.addOrRebuild(r),r.enableEditing())}p(this,dh,!1),n(this,Y)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var i;if(p(this,hh,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),n(this,Re)&&!n(this,wa)){p(this,wa,new AbortController);const r=n(this,Y).combinedSignal(n(this,wa));n(this,Re).div.addEventListener("pointerdown",a=>{const{clientX:l,clientY:c,timeStamp:h}=a,d=n(this,uh);if(h-d>500){p(this,uh,h);return}p(this,uh,-1);const{classList:f}=this.div;f.toggle("getElements",!0);const g=document.elementsFromPoint(l,c);if(f.toggle("getElements",!1),!this.div.contains(g[0]))return;let y;const b=new RegExp(`^${Kh}[0-9]+$`);for(const w of g)if(b.test(w.id)){y=w.id;break}if(!y)return;const S=n(this,Es).get(y);(S==null?void 0:S.annotationElementId)===null&&(ie(a),S.dblclick(a))},{signal:r,capture:!0})}const t=n(this,va),e=[];if(t){const r=new Map,a=new Map;for(const o of n(this,zt,Im)){if(o.disableEditing(),!o.annotationElementId){e.push(o);continue}if(o.serialize()!==null){r.set(o.annotationElementId,o);continue}else a.set(o.annotationElementId,o);(i=this.getEditableAnnotation(o.annotationElementId))==null||i.show(),o.remove()}for(const o of t.getEditableAnnotations()){const{id:l}=o.data;if(n(this,Y).isDeletedAnnotationElement(l)){o.updateEdited({deleted:!0});continue}let c=a.get(l);if(c){c.resetAnnotationElement(o),c.show(!1),o.show();continue}c=r.get(l),c&&(n(this,Y).addChangedExistingAnnotation(c),c.renderAnnotationElement(o)&&c.show(!1)),o.show()}}v(this,zt,Gf).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const r of n(Mi,Aa).values())s.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t==null||t.updateFakeAnnotations(e),p(this,hh,!1)}getEditableAnnotation(t){var e;return((e=n(this,va))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){n(this,Y).getActive()!==t&&n(this,Y).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=n(this,Re))!=null&&t.div&&!n(this,fr)){p(this,fr,new AbortController);const e=n(this,Y).combinedSignal(n(this,fr));n(this,Re).div.addEventListener("pointerdown",v(this,zt,x0).bind(this),{signal:e}),n(this,Re).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=n(this,Re))!=null&&t.div&&n(this,fr)&&(n(this,fr).abort(),p(this,fr,null),n(this,Re).div.classList.remove("highlighting"))}enableClick(){if(n(this,ba))return;p(this,ba,new AbortController);const t=n(this,Y).combinedSignal(n(this,ba));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){var t;(t=n(this,ba))==null||t.abort(),p(this,ba,null)}attach(t){n(this,Es).set(t.id,t);const{annotationElementId:e}=t;e&&n(this,Y).isDeletedAnnotationElement(e)&&n(this,Y).removeDeletedAnnotationElement(t)}detach(t){var e;n(this,Es).delete(t.id),(e=n(this,wl))==null||e.removePointerInTextLayer(t.contentDiv),!n(this,hh)&&t.annotationElementId&&n(this,Y).addDeletedAnnotationElement(t)}remove(t){this.detach(t),n(this,Y).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(n(this,Y).addDeletedAnnotationElement(t),Pt.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),n(this,Y).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!n(this,dh)),n(this,Y).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!n(this,dr)&&(t._focusEventsAllowed=!1,p(this,dr,setTimeout(()=>{p(this,dr,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:n(this,Y)._signal}),e.focus())},0))),t._structTreeParentId=(s=n(this,wl))==null?void 0:s.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getEditorByUID(t){for(const e of n(this,Es).values())if(e.uid===t)return e;return null}combinedSignal(t){return n(this,Y).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=n(this,zt,Yi))==null?void 0:t.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await n(this,Y).updateMode(t.mode);const{offsetX:s,offsetY:i}=v(this,zt,Lm).call(this),r=n(this,Y).getId(),a=v(this,zt,Dm).call(this,{parent:this,id:r,x:s,y:i,uiManager:n(this,Y),isCentered:!0,...e});a&&this.add(a)}async deserialize(t){var e;return await((e=n(Mi,Aa).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,n(this,Y)))||null}createAndAddNewEditor(t,e,s={}){const i=n(this,Y).getId(),r=v(this,zt,Dm).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:n(this,Y),isCentered:e,...s});return r&&this.add(r),r}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(t={}){this.createAndAddNewEditor(v(this,zt,Lm).call(this),!0,t)}setSelected(t){n(this,Y).setSelected(t)}toggleSelected(t){n(this,Y).toggleSelected(t)}unselect(t){n(this,Y).unselect(t)}pointerup(t){var i;const{isMac:e}=$t.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!n(this,ya)||(p(this,ya,!1),(i=n(this,zt,Yi))!=null&&i.isDrawer&&n(this,zt,Yi).supportMultipleDrawings))return;if(!n(this,ch)){p(this,ch,!0);return}const s=n(this,Y).getMode();if(s===ot.STAMP||s===ot.POPUP||s===ot.SIGNATURE){n(this,Y).unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){var i;if(n(this,Y).getMode()===ot.HIGHLIGHT&&this.enableTextSelection(),n(this,ya)){p(this,ya,!1);return}const{isMac:e}=$t.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(p(this,ya,!0),(i=n(this,zt,Yi))!=null&&i.isDrawer){this.startDrawingSession(t);return}const s=n(this,Y).getActive();p(this,ch,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),n(this,Gi)){n(this,zt,Yi).startDrawing(this,n(this,Y),!1,t);return}n(this,Y).setCurrentDrawingSession(this),p(this,Gi,new AbortController);const e=n(this,Y).combinedSignal(n(this,Gi));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(p(this,ur,null),this.commitOrRemove())},{signal:e}),n(this,zt,Yi).startDrawing(this,n(this,Y),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&p(this,ur,e);return}n(this,ur)&&setTimeout(()=>{var e;(e=n(this,ur))==null||e.focus(),p(this,ur,null)},0)}endDrawingSession(t=!1){return n(this,Gi)?(n(this,Y).setCurrentDrawingSession(null),n(this,Gi).abort(),p(this,Gi,null),p(this,ur,null),n(this,zt,Yi).endDrawing(t)):null}findNewParent(t,e,s){const i=n(this,Y).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}commitOrRemove(){return n(this,Gi)?(this.endDrawingSession(),!0):!1}onScaleChanging(){n(this,Gi)&&n(this,zt,Yi).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),((t=n(this,Y).getActive())==null?void 0:t.parent)===this&&(n(this,Y).commitOrRemove(),n(this,Y).setActiveEditor(null)),n(this,dr)&&(clearTimeout(n(this,dr)),p(this,dr,null));for(const s of n(this,Es).values())(e=n(this,wl))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,n(this,Es).clear(),n(this,Y).removeLayer(this)}async render({viewport:t}){this.viewport=t,xl(this.div,t);for(const e of n(this,Y).getEditors(this.pageIndex))this.add(e),e.rebuild();await n(this,Y).findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){n(this,Y).commitOrRemove(),v(this,zt,Gf).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,xl(this.div,{rotation:s}),e!==s)for(const i of n(this,Es).values())i.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return n(this,Y).viewParameters.realScale}};wl=new WeakMap,ch=new WeakMap,va=new WeakMap,ba=new WeakMap,dr=new WeakMap,Es=new WeakMap,ya=new WeakMap,hh=new WeakMap,dh=new WeakMap,Gi=new WeakMap,ur=new WeakMap,Re=new WeakMap,fr=new WeakMap,wa=new WeakMap,uh=new WeakMap,Y=new WeakMap,Aa=new WeakMap,zt=new WeakSet,Im=function(){return n(this,Es).size!==0?n(this,Es).values():n(this,Y).getEditors(this.pageIndex)},x0=function(t){n(this,Y).unselectAll();const{target:e}=t;if(e===n(this,Re).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent")||e.classList.contains("textLayerImages")||e.classList.contains("textLayerImagePlaceholder"))&&n(this,Re).div.contains(e)){const{isMac:s}=$t.platform;if(t.button!==0||t.ctrlKey&&s)return;n(this,Y).showAllEditors("highlight",!0,!0),n(this,Re).div.classList.add("free"),this.toggleDrawing(),ep.startHighlighting(this,n(this,Y).direction==="ltr",{target:n(this,Re).div,x:t.x,y:t.y}),n(this,Re).div.addEventListener("pointerup",()=>{n(this,Re).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:n(this,Y)._signal}),t.preventDefault()}},Yi=function(){return n(Mi,Aa).get(n(this,Y).getMode())},Dm=function(t){const e=n(this,zt,Yi);return e?new e.prototype.constructor(t):null},Lm=function(){const{x:t,y:e,width:s,height:i}=this.boundingClientRect,r=Math.max(0,t),a=Math.max(0,e),o=Math.min(window.innerWidth,t+s),l=Math.min(window.innerHeight,e+i),c=(r+o)/2-t,h=(a+l)/2-e,[d,f]=this.viewport.rotation%180===0?[c,h]:[h,c];return{offsetX:d,offsetY:f}},Gf=function(){for(const t of n(this,Es).values())t.isEmpty()&&t.remove()},M(Mi,"_initialized",!1),m(Mi,Aa,new Map([dm,Am,Tm,ep,km].map(t=>[t._editorType,t])));let Mm=Mi;function Ex(u,t){return u===t?0:u.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function ef(u){var t;return u?u.nodeType===Node.ELEMENT_NODE?u.closest(".textLayer"):((t=u.parentElement)==null?void 0:t.closest(".textLayer"))||null:null}function Cx(u,t,e,s){if(u===e)return t<=s;const i=u.compareDocumentPosition(e);return i&Node.DOCUMENT_POSITION_FOLLOWING?!0:i&Node.DOCUMENT_POSITION_PRECEDING?!1:null}function $v(u,t,e){if(u.nodeType!==Node.ELEMENT_NODE||!u.classList.contains("textLayer")||t!==u.childNodes.length)return{container:u,offset:t};let s=u.lastChild;return(s==null?void 0:s.nodeType)===Node.ELEMENT_NODE&&s.classList.contains("endOfContent")&&(s=s.previousSibling),!s||!e.contains(s)?null:s.nodeType===Node.TEXT_NODE?{container:s,offset:s.textContent.length}:{container:s,offset:s.childNodes.length}}var Cs,us,Ai,Ou,Ru,Al,Sl,Nu,kp,Sa,xa,Ea,Ca,pr,ns,Om,Rm,E0,jf,C0,_n,Nm,_0,Bm;const tt=class tt{constructor({filterFactory:t=null,pageColors:e=null,pageIndex:s,textLayer:i=null}){m(this,_n);m(this,Cs,null);m(this,us,new Map);m(this,Ai,null);m(this,Ou,null);m(this,Ru,null);m(this,Al,null);m(this,Sl,new Map);if(this.pageIndex=s,p(this,Ou,t),p(this,Ru,e),i){const r=n(tt,pr).get(i);if(r!=null&&r.selectionDiv&&(r.selectionDiv.remove(),n(tt,xa).delete(r.selectionDiv)),n(tt,pr).set(i,{drawLayer:this}),n(tt,Ca).add(i),p(this,Ai,i),p(this,Al,new MutationObserver(a=>{var o,l,c;if(!(!n(this,Cs)||!((o=n(this,Ai))!=null&&o.isConnected)||!v(l=tt,ns,Rm).call(l))){for(const{addedNodes:h}of a)for(const d of h)if(d.nodeType===Node.ELEMENT_NODE&&d.classList.contains("endOfContent")){v(c=tt,ns,jf).call(c);return}}})),n(this,Al).observe(i,{childList:!0}),n(tt,Sa)===null){p(tt,Sa,new AbortController);const{signal:a}=n(tt,Sa);document.addEventListener("selectionchange",v(tt,ns,jf).bind(tt),{signal:a}),document.addEventListener("pointerdown",()=>{p(tt,Ea,!0)},{signal:a}),document.addEventListener("pointerup",()=>{p(tt,Ea,!1)},{signal:a}),window.addEventListener("blur",()=>{p(tt,Ea,!1)},{signal:a})}}}setParent(t){var e,s,i;if(!n(this,Cs)){p(this,Cs,t),(e=n(this,Ai))!=null&&e.isConnected&&v(s=tt,ns,Rm).call(s)&&v(i=tt,ns,jf).call(i);return}if(n(this,Cs)!==t){if(n(this,us).size>0)for(const r of n(this,us).values())r.remove(),t.append(r);p(this,Cs,t)}}static get _svgFactory(){return at(this,"_svgFactory",new Zf)}draw(t,e=!1,s=!1){const i=qt(tt,Nu)._++,r=v(this,_n,Nm).call(this),a=tt._svgFactory.createElement("defs");r.append(a);const o=tt._svgFactory.createElement("path");a.append(o);const l=`path_${i}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),e&&n(this,Sl).set(i,o);const c=s?v(this,_n,_0).call(this,a,l):null,h=tt._svgFactory.createElement("use");return r.append(h),h.setAttribute("href",`#${l}`),this.updateProperties(r,t),n(this,us).set(i,r),{id:i,clipPathId:`url(#${c})`}}drawOutline(t,e){const s=qt(tt,Nu)._++,i=v(this,_n,Nm).call(this),r=tt._svgFactory.createElement("defs");i.append(r);const a=tt._svgFactory.createElement("path");r.append(a);const o=`path_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke");let l;if(e){const d=tt._svgFactory.createElement("mask");r.append(d),l=`mask_${s}`,d.setAttribute("id",l),d.setAttribute("maskUnits","objectBoundingBox");const f=tt._svgFactory.createElement("rect");d.append(f),f.setAttribute("width","1"),f.setAttribute("height","1"),f.setAttribute("fill","white");const g=tt._svgFactory.createElement("use");d.append(g),g.setAttribute("href",`#${o}`),g.setAttribute("stroke","none"),g.setAttribute("fill","black"),g.setAttribute("fill-rule","nonzero"),g.classList.add("mask")}const c=tt._svgFactory.createElement("use");i.append(c),c.setAttribute("href",`#${o}`),l&&c.setAttribute("mask",`url(#${l})`);const h=c.cloneNode();return i.append(h),c.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(i,t),n(this,us).set(s,i),s}finalizeDraw(t,e){n(this,Sl).delete(t),this.updateProperties(t,e)}updateProperties(t,e){var l;if(!e)return;const{root:s,bbox:i,rootClass:r,path:a}=e,o=typeof t=="number"?n(this,us).get(t):t;if(o){if(s&&v(this,_n,Bm).call(this,o,s),i&&v(l=tt,ns,C0).call(l,o,i),r){const{classList:c}=o;for(const[h,d]of Object.entries(r))c.toggle(h,d)}if(a){const h=o.firstElementChild.firstElementChild;v(this,_n,Bm).call(this,h,a)}}}updateParent(t,e){if(e===this)return;const s=n(this,us).get(t);s&&(n(e,Cs).append(s),n(this,us).delete(t),n(e,us).set(t,s))}remove(t){n(this,Sl).delete(t),n(this,Cs)!==null&&(n(this,us).get(t).remove(),n(this,us).delete(t))}destroy(){var t,e,s;p(this,Cs,null);for(const i of n(this,us).values())i.remove();if(n(this,us).clear(),n(this,Sl).clear(),(t=n(this,Al))==null||t.disconnect(),p(this,Al,null),n(this,Ai)){const i=n(tt,pr).get(n(this,Ai));(i==null?void 0:i.drawLayer)===this&&(v(e=tt,ns,Om).call(e,n(this,Ai)),n(tt,pr).delete(n(this,Ai)),n(tt,Ca).delete(n(this,Ai)),n(tt,Ca).size===0&&((s=n(tt,Sa))==null||s.abort(),p(tt,Sa,null),p(tt,Ea,!1))),p(this,Ai,null)}}};Cs=new WeakMap,us=new WeakMap,Ai=new WeakMap,Ou=new WeakMap,Ru=new WeakMap,Al=new WeakMap,Sl=new WeakMap,Nu=new WeakMap,kp=new WeakMap,Sa=new WeakMap,xa=new WeakMap,Ea=new WeakMap,Ca=new WeakMap,pr=new WeakMap,ns=new WeakSet,Om=function(t){const e=n(this,pr).get(t);e!=null&&e.selectionDiv&&(e.selectionDiv.remove(),n(this,xa).delete(e.selectionDiv),e.selectionDiv=null,e.path=null)},Rm=function(){const t=document.getSelection();return!!t&&!t.isCollapsed},E0=function(){return[...n(this,Ca)].filter(t=>t.isConnected).sort(Ex)},jf=function(){var a;const t=document.getSelection();if(!t||t.isCollapsed){for(const o of n(this,xa))o.remove();n(this,xa).clear();return}const e=new WeakMap,s=v(this,ns,E0).call(this),i=[];for(let o=0,l=t.rangeCount;o<l;o++){const c=t.getRangeAt(o);if(c.collapsed)continue;let{startContainer:h,startOffset:d,endContainer:f,endOffset:g}=c,y=ef(h),b=ef(f);const S=y===null,w=b===null;if(n(this,Ea)&&S!==w)return;if(t.rangeCount===1){const{anchorNode:C,anchorOffset:_,focusNode:k,focusOffset:I}=t,L=ef(C),P=ef(k),D=Cx(C,_,k,I);L&&P&&D!==null&&(D?(h=C,d=_,y=L,f=k,g=I,b=P):(h=k,d=I,y=P,f=C,g=_,b=L))}const x=s.filter(C=>c.intersectsNode(C));if(x.length===0)continue;let A=!1;if(y||(y=x[0],h=y,d=0,A=!0),b||(b=x.at(-1),f=b,g=b.childNodes.length,A=!0),f.nodeType===Node.ELEMENT_NODE){if(f.classList.contains("endOfContent")){const C=f.previousSibling;if(!C)continue;f=C,g=C.nodeType===Node.TEXT_NODE?C.textContent.length:C.childNodes.length}else if(f.classList.contains("textLayer")&&f.childNodes.length===g){const C=$v(f,g,b);if(!C)continue;f=C.container,g=C.offset}}if(h.nodeType===Node.ELEMENT_NODE){const C=$v(h,d,y);if(!C)continue;h=C.container,d=C.offset}if(y===b&&!A&&x.includes(y)){i.push([c,y]);continue}for(const C of x){const _=C.firstChild;if(!_)continue;const k=document.createRange();if(C===y?k.setStart(h,d):k.setStartBefore(_),C===b)k.setEnd(f,g);else{const I=C.lastChild;if(!I)continue;if(I.nodeType===Node.ELEMENT_NODE&&I.classList.contains("endOfContent")){const L=I.previousSibling;if(!L)continue;k.setEndAfter(L)}else k.setEndAfter(I)}k.collapsed||i.push([k,C])}}const r=new Set(i.map(o=>o[1]));for(const o of n(this,Ca))r.has(o)||v(this,ns,Om).call(this,o);for(const[o,l]of i){const c=n(tt,pr).get(l);if(!c)continue;let h=e.get(l);if(!h){const b=l.getBoundingClientRect();h=(S,w,x,A)=>({x:(S-b.x)/b.width,y:(w-b.y)/b.height,width:x/b.width,height:A/b.height}),e.set(l,h)}const d=[];for(let{x:b,y:S,width:w,height:x}of o.getClientRects())w===0||x===0||({x:b,y:S,width:w,height:x}=h(b,S,w,x),!(w===1&&x===1)&&d.push(`M${b} ${S} h${w} v${x} h-${w} Z`));if(d.length===0)continue;const f=c.drawLayer;let g=c.selectionDiv,y=c.path;if(!g){const b=`clip_selection_${qt(tt,kp)._++}`;g=document.createElement("div"),g.className="selection",g.style.clipPath=`url(#${b})`;const S=(a=n(f,Ou))==null?void 0:a.createSelectionStyle(n(f,Ru));if(S)for(const[A,C]of Object.entries(S))g.style.setProperty(A,C);const w=tt._svgFactory.create(1,1,!0);w.setAttribute("aria-hidden","true"),w.setAttribute("width","100%"),w.setAttribute("height","100%");const x=tt._svgFactory.createElement("clipPath");x.setAttribute("id",b),x.setAttribute("clipPathUnits","objectBoundingBox"),y=tt._svgFactory.createElement("path"),x.append(y),w.append(x),g.append(w),c.path=y,c.selectionDiv=g}!g.parentNode&&n(f,Cs)&&(n(f,Cs).append(g),n(this,xa).add(g)),y.setAttribute("d",d.join(" "))}},C0=function(t,[e,s,i,r]){const{style:a}=t;a.top=`${100*s}%`,a.left=`${100*e}%`,a.width=`${100*i}%`,a.height=`${100*r}%`},_n=new WeakSet,Nm=function(){const t=tt._svgFactory.create(1,1,!0);return n(this,Cs).append(t),t.setAttribute("aria-hidden","true"),t},_0=function(t,e){const s=tt._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const r=tt._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),i},Bm=function(t,e){for(const[s,i]of Object.entries(e))i===null?t.removeAttribute(s):t.setAttribute(s,i)},m(tt,ns),m(tt,Nu,0),m(tt,kp,0),m(tt,Sa,null),m(tt,xa,new Set),m(tt,Ea,!1),m(tt,Ca,new Set),m(tt,pr,new WeakMap);let Fm=tt;function sf(u){return`${(u*100).toFixed(2)}%`}var fh,Bu,$u,ph,wn,An,Uu,Tp,k0;const Yh=class Yh{constructor(t,e,s,i){m(this,Tp);m(this,fh,[]);m(this,Bu,new Map);m(this,$u,null);m(this,ph,0);m(this,wn,0);m(this,An,0);p(this,ph,t),p(this,fh,e),p(this,wn,s.rawDims.pageWidth),p(this,An,s.rawDims.pageHeight),p(this,$u,i)}render(){const t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<n(this,fh).length;e+=6){const s=v(this,Tp,k0).call(this,n(this,fh).subarray(e,e+6));s&&t.append(s)}return t.addEventListener("contextmenu",e=>{var w;if(!(e.target instanceof HTMLCanvasElement))return;const s=e.target,i=n(this,Bu).get(s);if(!i)return;const r=(w=n(Yh,Uu))==null?void 0:w.deref();if(r===s)return;r&&(r.width=0,r.height=0),p(Yh,Uu,new WeakRef(s));const{inverseTransform:a,x1:o,y1:l,width:c,height:h}=i,d=n(this,$u).call(this),f=Math.ceil(o*d.width),g=Math.ceil(l*d.height),y=Math.floor((o+c/n(this,wn))*d.width),b=Math.floor((l+h/n(this,An))*d.height);s.width=y-f,s.height=b-g;const S=s.getContext("2d");S.setTransform(...a),S.translate(-f,-g),S.drawImage(d,0,0)}),t}};fh=new WeakMap,Bu=new WeakMap,$u=new WeakMap,ph=new WeakMap,wn=new WeakMap,An=new WeakMap,Uu=new WeakMap,Tp=new WeakSet,k0=function([t,e,s,i,r,a]){const o=Math.hypot((r-t)*n(this,wn),(a-e)*n(this,An)),l=Math.hypot((s-t)*n(this,wn),(i-e)*n(this,An));if(o<n(this,ph)||l<n(this,ph))return null;const c=[(r-t)*n(this,wn)/o,(a-e)*n(this,An)/o,(s-t)*n(this,wn)/l,(i-e)*n(this,An)/l,0,0],h=B.inverseTransform(c),d=document.createElement("canvas");return d.className="textLayerImagePlaceholder",d.width=0,d.height=0,Object.assign(d.style,{opacity:0,position:"absolute",left:sf(t),top:sf(e),width:sf(o/n(this,wn)),height:sf(l/n(this,An)),transformOrigin:"0% 0%",transform:`matrix(${c.join(",")})`}),n(this,Bu).set(d,{inverseTransform:h,width:o,height:l,x1:t,y1:e}),d},m(Yh,Uu,null);let $m=Yh;globalThis._pdfjsTestingUtils={HighlightOutliner:fm};globalThis.pdfjsLib={AbortException:_a,AnnotationEditorLayer:Mm,AnnotationEditorParamsType:dt,AnnotationEditorType:ot,AnnotationEditorUIManager:Cl,AnnotationLayer:hm,AnnotationMode:Cr,AnnotationType:oe,applyOpacity:RS,build:Z1,ColorPicker:Qf,createValidAbsoluteUrl:Zv,CSSConstants:OS,DOMSVGFactory:Zf,DrawLayer:Fm,FeatureTest:$t,fetchData:zm,findContrastColor:NS,getDocument:Sy,getFilenameFromUrl:IS,getPdfFilenameFromUrl:DS,getRGB:Wu,getRGBA:ju,getUuid:eb,GlobalWorkerOptions:Sn,ImageKind:rf,InvalidPDFException:og,isDataScheme:Rp,isPdfFile:Gm,isValidExplicitDest:i1,makeArr:Vu,makeMap:Hm,makeObj:cg,MathClamp:Qt,noContextMenu:Ci,normalizeUnicode:PS,OPS:Ki,OutputScale:En,PasswordException:ag,PasswordResponses:SS,PDFDataRangeTransport:xy,PDFDateString:qf,PDFWorker:td,PermissionFlag:AS,PixelsPerInch:ka,RenderingCancelledException:Vm,renderRichText:ib,ResponseException:Xf,setLayerDimensions:xl,shadow:at,SignatureExtractor:gr,stopEvent:ie,SupportedImageMimeTypes:hg,TextLayer:gh,TextLayerImages:$m,TouchManager:Kf,updateUrlHash:tb,Util:B,VerbosityLevel:Dp,version:J1,XfaLayer:sb};const _x="/assets/pdf.worker.min-DEtVeC4l.mjs",kx={class:"pdf-source-viewer","aria-label":"PDF 原文件预览"},Tx={key:0,class:"pdf-toolbar"},Px={class:"toolbar-group"},Mx=["disabled"],Ix={class:"page-indicator"},Dx=["disabled"],Lx={key:0,class:"fa fa-map-marker","aria-hidden":"true"},Fx={class:"toolbar-group"},Ox=["disabled"],Rx={class:"zoom-indicator"},Nx=["disabled"],Bx=["aria-label"],$x=["data-page-number"],Ux={key:0,class:"pdf-loading",role:"status"},Hx={key:1,class:"pdf-error",role:"alert"},zx=["href"],Vx={key:2,class:"pdf-unavailable",role:"status"},Gx=_i({__name:"PdfSourceViewer",props:{taskId:{},sourceFileId:{},fileName:{},selectedItem:{}},setup(u){Sn.workerSrc=_x;const t=u,e=rt(null),s=rt(null),i=rt(null),r=rt(null),a=nw(null),o=rt([]),l=rt(1),c=rt(0),h=rt(1),d=rt(1),f=rt(!1),g=rt(!1),y=rt(""),b=rt("idle");let S=null,w=null,x=null,A=0,C=0,_=0,k=0;const I=ut(()=>t.taskId!=null&&t.sourceFileId!=null?pw(t.taskId,t.sourceFileId):""),L=ut(()=>({"--total-scale-factor":String(d.value)})),P=ut(()=>b.value==="highlighted"?`切片原文已在第 ${l.value} 页高亮`:b.value==="unmatched"?`已定位第 ${l.value} 页,未匹配到可高亮文字`:b.value==="manual"?"手动新增切片没有原文位置":c.value?`${l.value} / ${c.value}`:"正在读取 PDF");function D(V){return!V||V.sourceStart==null||V.sourceEnd==null?null:o.value.find($=>V.sourceStart>=$.source_start&&V.sourceStart<$.source_end)??o.value.find($=>V.sourceStart<$.source_end&&V.sourceEnd>$.source_start)??null}function R(V){const $=t.selectedItem;if(!$||$.sourceStart==null||$.sourceEnd==null)return"";const Et=Math.max($.sourceStart,V.source_start),ct=Math.min($.sourceEnd,V.source_end);if(ct<=Et)return"";const J=Math.max(0,Et-$.sourceStart),ae=Math.max(J,ct-$.sourceStart);return $.originalContent.slice(J,ae)}function K(V){return V.normalize("NFKC").replace(/[^\p{L}\p{N}]+/gu,"").toLocaleLowerCase()}function W(V,$,Et){let ct=-1,J=Number.POSITIVE_INFINITY,ae=V.indexOf($);for(;ae>=0;){const Ti=Math.abs(ae-Et);Ti<J&&(ct=ae,J=Ti),ae=V.indexOf($,ae+1)}return ct}function Q(V,$,Et){var Pa;const ct=[];let J="";for(const Ps of V){const Ne=J.length;J+=K(Ps),ct.push({start:Ne,end:J.length})}const ae=K($);if(!J||!ae)return[];const Ti=((Pa=t.selectedItem)==null?void 0:Pa.sourceStart)??Et.source_start,ks=Math.max(1,Et.source_end-Et.source_start),Ts=Math.min(1,Math.max(0,(Ti-Et.source_start)/ks)),Se=Math.round(J.length*Ts),Sr=[ae.length,120,80,48,24,12,8].map(Ps=>Math.min(Ps,ae.length)).filter((Ps,Ne,Ms)=>Ps>=4&&Ms.indexOf(Ps)===Ne);for(const Ps of Sr){const Ne=ae.slice(0,Ps),Ms=W(J,Ne,Se);if(Ms<0)continue;const kn=Ms+Ne.length;return ct.reduce((Ma,Ml,Il)=>(Ml.end>Ms&&Ml.start<kn&&Ma.push(Il),Ma),[])}return[]}function ht(V){var ct;const $=t.selectedItem;for(const J of(x==null?void 0:x.textDivs)??[])J.classList.remove("is-slice-highlighted");if(!$||$.sourceStart==null||$.sourceEnd==null){b.value=$?"manual":"idle";return}if(!V||V.page_number!==l.value||!x){b.value="idle";return}const Et=Q(x.textContentItemsStr,R(V),V);for(const J of Et)(ct=x.textDivs[J])==null||ct.classList.add("is-slice-highlighted");b.value=Et.length?"highlighted":"unmatched"}async function T(V=!1){var Ts;const $=a.value,Et=s.value,ct=i.value,J=r.value,ae=e.value;if(!$||!Et||!ct||!J||!ae)return;const Ti=D(t.selectedItem);if(!V&&_===l.value&&x){ht(Ti);return}const ks=++C;w==null||w.cancel(),x==null||x.cancel(),w=null,x=null,g.value=!0,y.value="";try{const Se=await $.getPage(l.value);if(ks!==C)return;const Sr=Se.getViewport({scale:1}),Ps=Math.max(280,ae.clientWidth-36)/Sr.width*h.value,Ne=Se.getViewport({scale:Ps}),Ms=Math.max(1,window.devicePixelRatio||1);if(!ct.getContext("2d"))throw new Error("浏览器无法创建 PDF 画布");d.value=Ps,Et.style.width=`${Ne.width}px`,Et.style.height=`${Ne.height}px`,ct.width=Math.floor(Ne.width*Ms),ct.height=Math.floor(Ne.height*Ms),ct.style.width=`${Ne.width}px`,ct.style.height=`${Ne.height}px`,J.replaceChildren();const Ma=Se.render({canvas:ct,viewport:Ne,transform:Ms===1?void 0:[Ms,0,0,Ms,0,0]});w=Ma;const Ml=Ma.promise.catch(Ia=>{if(!(ks!==C||Ia instanceof Error&&Ia.name==="RenderingCancelledException"))throw Ia}),Il=await Se.getTextContent();if(ks!==C)return;const yh=new gh({textContentSource:Il,container:J,viewport:Ne});if(x=yh,await Promise.all([Ml,yh.render()]),ks!==C)return;_=l.value,ht(Ti),await Wf(),(Ts=Et.querySelector(".is-slice-highlighted"))==null||Ts.scrollIntoView({block:"center",inline:"center",behavior:"smooth"})}catch(Se){if(ks!==C)return;y.value=Se instanceof Error?Se.message:"PDF 页面渲染失败"}finally{ks===C&&(g.value=!1)}}async function q(){if(!a.value)return;const V=t.selectedItem;if(!V||V.sourceStart==null||V.sourceEnd==null){ht(null);return}const $=D(V);if(!$){b.value="unmatched";return}if(l.value!==$.page_number){l.value=$.page_number,await T(!0);return}await T(!1)}async function Lt(){const V=++A;if(++C,_=0,w==null||w.cancel(),x==null||x.cancel(),await(S==null?void 0:S.destroy()),S=null,a.value=null,o.value=[],c.value=0,l.value=1,y.value="",b.value="idle",!(!I.value||t.taskId==null||t.sourceFileId==null)){f.value=!0;try{const $=Sy({url:I.value});S=$;const[Et,ct]=await Promise.all([gw(t.taskId,t.sourceFileId),$.promise]);if(V!==A){await $.destroy();return}a.value=ct,o.value=Et.pages,c.value=ct.numPages,await Wf(),await q(),t.selectedItem||await T(!0)}catch($){if(V!==A)return;y.value=$ instanceof Error?$.message:"PDF 原文件加载失败"}finally{V===A&&(f.value=!1)}}}async function mt(V){const $=Math.min(c.value,Math.max(1,l.value+V));$!==l.value&&(l.value=$,await T(!0))}async function _e(V){const $=Math.min(2,Math.max(.6,Number((h.value+V).toFixed(1))));$!==h.value&&(h.value=$,await T(!0))}function re(){window.cancelAnimationFrame(k),k=window.requestAnimationFrame(()=>{a.value&&T(!0)})}const Gt=new ResizeObserver(re);return xi(e,(V,$)=>{$&&Gt.unobserve($),V&&Gt.observe(V)}),xi(I,()=>void Lt(),{immediate:!0}),xi(()=>{var V;return(V=t.selectedItem)==null?void 0:V.id},()=>void q()),jv(()=>{++A,++C,window.cancelAnimationFrame(k),Gt.disconnect(),w==null||w.cancel(),x==null||x.cancel(),S==null||S.destroy()}),(V,$)=>(N(),G("div",kx,[I.value?(N(),G("div",Tx,[E("div",Px,[E("button",{type:"button","aria-label":"上一页",disabled:l.value<=1||f.value,onClick:$[0]||($[0]=Et=>mt(-1))},[...$[4]||($[4]=[E("i",{class:"fa fa-chevron-left","aria-hidden":"true"},null,-1)])],8,Mx),E("span",Ix,j(l.value)+" / "+j(c.value||"—"),1),E("button",{type:"button","aria-label":"下一页",disabled:l.value>=c.value||f.value,onClick:$[1]||($[1]=Et=>mt(1))},[...$[5]||($[5]=[E("i",{class:"fa fa-chevron-right","aria-hidden":"true"},null,-1)])],8,Dx)]),E("span",{class:we(["location-state",`is-${b.value}`]),role:"status"},[b.value==="highlighted"?(N(),G("i",Lx)):vt("",!0),ft(" "+j(P.value),1)],2),E("div",Fx,[E("button",{type:"button","aria-label":"缩小",disabled:h.value<=.6||f.value,onClick:$[2]||($[2]=Et=>_e(-.1))},"",8,Ox),E("span",Rx,j(Math.round(h.value*100))+"%",1),E("button",{type:"button","aria-label":"放大",disabled:h.value>=2||f.value,onClick:$[3]||($[3]=Et=>_e(.1))},"+",8,Nx)])])):vt("",!0),I.value?(N(),G("div",{key:1,ref_key:"scrollRef",ref:e,class:"pdf-scroll",tabindex:"0","aria-label":`PDF 预览:${u.fileName}`},[E("div",{ref_key:"pageRef",ref:s,class:"pdf-page",style:iw(L.value),"data-page-number":l.value},[E("canvas",{ref_key:"canvasRef",ref:i,class:"pdf-canvas"},null,512),E("div",{ref_key:"textLayerRef",ref:r,class:"pdf-text-layer"},null,512)],12,$x),f.value||g.value?(N(),G("div",Ux,[$[6]||($[6]=E("i",{class:"fa fa-spinner fa-spin","aria-hidden":"true"},null,-1)),ft(" "+j(f.value?"正在加载 PDF…":"正在渲染页面…"),1)])):vt("",!0),y.value?(N(),G("div",Hx,[$[7]||($[7]=E("i",{class:"fa fa-exclamation-circle","aria-hidden":"true"},null,-1)),$[8]||($[8]=E("strong",null,"PDF 预览失败",-1)),E("span",null,j(y.value),1),E("a",{href:I.value,target:"_blank",rel:"noopener noreferrer"},"在新窗口打开原件",8,zx)])):vt("",!0)],8,Bx)):(N(),G("div",Vx,[...$[9]||($[9]=[E("i",{class:"fa fa-file-pdf-o","aria-hidden":"true"},null,-1),E("strong",null,"PDF 原文件暂不可预览",-1),E("span",null,"请重新上传该文件后再试。",-1)])]))]))}}),jx=ki(Gx,[["__scopeId","data-v-6e2d2dbc"]]),Wx=["问:如何看待当前的通货膨胀风险?","答:当前通胀水平总体可控,但仍需关注能源价格与供给扰动。","问:美联储下一次议息会议何时召开?","答:会议时间以美联储官方日历为准,市场会重点关注利率路径指引。","问:人民币汇率未来走势如何?","答:人民币汇率取决于中美利差、经济基本面与政策预期。","问:什么是复利?","答:复利是将上一期利息加入本金,再计算下一期利息。"].join(`
`);function Xx(u){const t=u.split(`
`);let e=0;return t.map((s,i)=>{const r=e,a=r+s.length;return e=a+(i<t.length-1?1:0),{number:i+1,content:s,start:r,end:a}})}function Uv(u){var t;return((t=u.match(/[\u3400-\u4dbf\u4e00-\u9fff]|[A-Za-z0-9_]+|[^\s]/gu))==null?void 0:t.length)??0}const qx={class:"preview-step"},Yx={class:"preview-file-switcher"},Kx={class:"file-switcher-control"},Qx={class:"file-option"},Jx=["title"],Zx={key:0},tE={class:"file-switcher-summary"},eE={class:"preview-workspace"},sE={class:"source-pane"},iE={class:"pane-header"},nE=["data-source-start"],rE={class:"line-number"},aE={class:"line-content"},oE={class:"preview-pane"},lE={class:"pane-header"},cE={class:"pane-header-actions"},hE={class:"preview-toolbar"},dE={class:"preview-list","aria-label":"预览条目列表"},uE=["data-preview-id","aria-selected","onClick","onKeydown"],fE={class:"item-name"},pE={class:"item-source"},gE={class:"item-actions"},mE={key:0,class:"empty-result"},vE={key:1,class:"preview-editor"},bE={class:"editor-heading"},yE={class:"editor-actions"},xh=6,wE=_i({__name:"PreviewCompareStep",props:{sourceText:{},items:{},selectedId:{},processType:{},fileName:{},taskId:{},sourceFileId:{},files:{},selectedFileId:{}},emits:["update:selectedId","update:selectedFileId","update:item-content","restore:item","add:item","remove:item"],setup(u,{emit:t}){const e=u,s=t,i=rt(null),r=rt(""),a=rt(1),o=rt(null),l=rt(""),c=ut(()=>Xx(e.sourceText)),h=ut(()=>e.items.find(P=>P.id===e.selectedId)??e.items[0]),d=ut(()=>e.items.find(P=>P.id===o.value)),f=ut(()=>/\.pdf$/i.test(e.fileName)),g=ut(()=>e.items.filter((P,D)=>!r.value.trim()||P.editedContent.toLowerCase().includes(r.value.trim().toLowerCase())||String(D+1).includes(r.value.trim()))),y=ut(()=>{const P=(a.value-1)*xh;return g.value.slice(P,P+xh)});function b(P,D){const R=h.value;return!R||R.sourceStart==null||R.sourceEnd==null?!1:D>=R.sourceStart&&P<=R.sourceEnd}function S(P){s("update:selectedId",P)}function w(P){S(P.id),o.value=P.id,l.value=P.editedContent}function x(){o.value=null,l.value=""}function A(){d.value&&(s("update:item-content",d.value.id,l.value),x())}function C(){d.value&&(s("restore:item",d.value.id),x())}function _(P){S(P.id),s("remove:item",P.id)}function k(){x()}xi(r,()=>{a.value=1,x()}),xi(()=>e.selectedFileId,x),xi(h,async P=>{var K,W;if(!P)return;const D=g.value.findIndex(Q=>Q.id===P.id);if(D>=0&&(a.value=Math.floor(D/xh)+1),f.value||P.sourceStart==null)return;await Wf();const R=((K=i.value)==null?void 0:K.querySelector(`[data-source-start="${P.sourceStart}"]`))??((W=i.value)==null?void 0:W.querySelector(".source-line.is-highlighted"));R==null||R.scrollIntoView({block:"center",behavior:"smooth"})},{immediate:!0});function I(P){return e.items.findIndex(D=>D.id===P.id)+1}function L(P){return P.sourceStartLine==null||P.sourceEndLine==null?"手动新增,无源文件定位":P.sourceStartLine===P.sourceEndLine?`来源:第 ${P.sourceStartLine}`:`来源:第 ${P.sourceStartLine}${P.sourceEndLine}`}return(P,D)=>{const R=Ip,K=Mp,W=Hu,Q=bh,ht=Yv;return N(),G("section",qx,[E("div",Yx,[E("div",Kx,[D[5]||(D[5]=E("span",null,"当前文件",-1)),U(K,{"model-value":u.selectedFileId,filterable:"",placeholder:"选择文件","aria-label":"选择当前预览文件","onUpdate:modelValue":D[0]||(D[0]=T=>s("update:selectedFileId",T))},{default:et(()=>[(N(!0),G(ye,null,ni(u.files,T=>(N(),Vt(R,{key:T.id,label:T.name,value:T.id},{default:et(()=>[E("div",Qx,[E("strong",{title:T.name},j(T.name),9,Jx),E("span",null,j(T.count.toLocaleString())+" "+j(u.processType==="unstructured"?"个切片":"条记录"),1),T.modifiedCount?(N(),G("em",Zx,j(T.modifiedCount)+" 处已修改",1)):vt("",!0)])]),_:2},1032,["label","value"]))),128))]),_:1},8,["model-value"])]),E("span",tE,j(u.files.length)+" 个文件 · 当前文件 "+j(u.items.length.toLocaleString())+" "+j(u.processType==="unstructured"?"个切片":"条记录"),1)]),E("div",eE,[E("div",sE,[E("div",iE,[E("div",null,[E("strong",null,"源文件 · "+j(u.fileName),1)])]),f.value?(N(),Vt(jx,{key:0,"task-id":u.taskId,"source-file-id":u.sourceFileId,"file-name":u.fileName,"selected-item":h.value??null},null,8,["task-id","source-file-id","file-name","selected-item"])):(N(),G("div",{key:1,ref_key:"sourceViewerRef",ref:i,class:"source-viewer",tabindex:"0","aria-label":"源文件内容"},[(N(!0),G(ye,null,ni(c.value,T=>(N(),G("div",{key:T.number,class:we(["source-line",{"is-highlighted":b(T.start,T.end)}]),"data-source-start":T.start},[E("span",rE,j(T.number),1),E("span",aE,j(T.content||" "),1)],10,nE))),128))],512))]),E("div",oE,[E("div",lE,[E("strong",null,j(u.processType==="unstructured"?"切片内容":"记录内容"),1),E("div",cE,[E("span",null,"共 "+j(u.items.length.toLocaleString())+" 条",1),U(W,{link:"",type:"primary",onClick:D[1]||(D[1]=T=>s("add:item"))},{default:et(()=>[...D[6]||(D[6]=[E("i",{class:"fa fa-plus"},null,-1),ft(" 手动新增 ",-1)])]),_:1})])]),d.value?(N(),G("div",vE,[E("div",bE,[E("div",null,[E("strong",null,j(u.processType==="unstructured"?"切片":"记录")+" #"+j(String(I(d.value)).padStart(3,"0"))+" 正文",1),E("small",null,j(L(d.value)),1)])]),U(Q,{modelValue:l.value,"onUpdate:modelValue":D[4]||(D[4]=T=>l.value=T),type:"textarea",rows:7,resize:"none"},null,8,["modelValue"]),E("div",yE,[d.value.sourceStart!=null?(N(),Vt(W,{key:0,link:"",onClick:C},{default:et(()=>[...D[10]||(D[10]=[E("i",{class:"fa fa-undo"},null,-1),ft(" 恢复原始内容 ",-1)])]),_:1})):vt("",!0),E("div",null,[U(W,{onClick:x},{default:et(()=>[...D[11]||(D[11]=[ft("取消",-1)])]),_:1}),U(W,{type:"primary",onClick:A},{default:et(()=>[...D[12]||(D[12]=[ft("保存修改",-1)])]),_:1})])])])):(N(),G(ye,{key:0},[E("div",hE,[U(Q,{modelValue:r.value,"onUpdate:modelValue":D[2]||(D[2]=T=>r.value=T),clearable:"",placeholder:"搜索编号或内容",size:"small"},{prefix:et(()=>[...D[7]||(D[7]=[E("i",{class:"fa fa-search"},null,-1)])]),_:1},8,["modelValue"])]),E("div",dE,[(N(!0),G(ye,null,ni(y.value,T=>{var q,Lt;return N(),G("div",{key:T.id,class:we(["preview-item",{"is-active":T.id===((q=h.value)==null?void 0:q.id)}]),"data-preview-id":T.id,"aria-selected":T.id===((Lt=h.value)==null?void 0:Lt.id),role:"button",tabindex:"0",onClick:mt=>S(T.id),onKeydown:[cv(mt=>S(T.id),["enter"]),cv(Xp(mt=>S(T.id),["prevent"]),["space"])]},[E("span",fE,j(u.processType==="unstructured"?"切片":"记录")+" #"+j(String(I(T)).padStart(3,"0")),1),E("span",pE,j(L(T)),1),E("span",gE,[U(W,{link:"","aria-label":"编辑切片",title:"编辑",onClick:Xp(mt=>w(T),["stop"])},{default:et(()=>[...D[8]||(D[8]=[E("i",{class:"fa fa-pencil"},null,-1)])]),_:1},8,["onClick"]),U(W,{link:"",type:"danger","aria-label":"删除切片",title:"删除",onClick:Xp(mt=>_(T),["stop"])},{default:et(()=>[...D[9]||(D[9]=[E("i",{class:"fa fa-trash-o"},null,-1)])]),_:1},8,["onClick"])])],42,uE)}),128)),g.value.length?vt("",!0):(N(),G("div",mE,"没有符合条件的内容"))]),g.value.length>xh?(N(),Vt(ht,{key:0,"current-page":a.value,"onUpdate:currentPage":D[3]||(D[3]=T=>a.value=T),"page-size":xh,total:g.value.length,"pager-count":5,small:"",background:"",layout:"prev, pager, next",class:"preview-pagination",onCurrentChange:k},null,8,["current-page","total"])):vt("",!0)],64))])])])}}}),AE=ki(wE,[["__scopeId","data-v-56f2a99f"]]),SE={class:"generation-step"},xE={class:"generation-layout"},EE={class:"summary-panel"},CE={class:"run-icon"},_E={key:0,class:"fa fa-check"},kE={key:1,class:"fa fa-exclamation"},TE={key:2,class:"fa fa-cog fa-spin"},PE={key:3,class:"fa fa-play"},ME=_i({__name:"GenerationStep",props:{taskName:{},processType:{},fileName:{},previewCount:{},modifiedCount:{},generation:{}},emits:["stop","retry"],setup(u,{emit:t}){const e=t;return(s,i)=>{const r=Kv,a=Hu;return N(),G("section",SE,[E("div",xE,[E("div",EE,[i[7]||(i[7]=E("div",{class:"panel-heading"},[E("strong",null,"任务摘要"),E("span",null,"已完成预览确认")],-1)),E("dl",null,[E("div",null,[i[2]||(i[2]=E("dt",null,"任务名称",-1)),E("dd",null,j(u.taskName),1)]),E("div",null,[i[3]||(i[3]=E("dt",null,"数据类型",-1)),E("dd",null,j(u.processType==="unstructured"?"非结构化数据":u.processType==="external"?"外来数据源拉取":"结构化数据"),1)]),E("div",null,[i[4]||(i[4]=E("dt",null,"源文件",-1)),E("dd",null,j(u.fileName),1)]),E("div",null,[i[5]||(i[5]=E("dt",null,"预览条目",-1)),E("dd",null,j(u.previewCount.toLocaleString())+" 条",1)]),E("div",null,[i[6]||(i[6]=E("dt",null,"已修改",-1)),E("dd",null,j(u.modifiedCount.toLocaleString())+" 条",1)])])]),E("div",{class:we(["run-panel",`is-${u.generation.status}`])},[E("div",CE,[u.generation.status==="success"?(N(),G("i",_E)):u.generation.status==="failed"?(N(),G("i",kE)):u.generation.status==="running"?(N(),G("i",TE)):(N(),G("i",PE))]),E("h3",null,j(u.generation.status==="idle"?"准备开始处理":u.generation.status==="running"?"正在生成数据":u.generation.status==="success"?"数据生成完成":"生成已停止"),1),E("p",null,j(u.generation.message),1),u.generation.status!=="idle"?(N(),Vt(r,{key:0,percentage:u.generation.progress,"stroke-width":10,status:u.generation.status==="success"?"success":void 0},null,8,["percentage","status"])):vt("",!0),i[10]||(i[10]=E("div",{class:"run-meta"},[E("span",null,"解析源数据"),E("span",null,"应用预览修改"),E("span",null,"生成标准结果")],-1)),u.generation.status==="running"?(N(),Vt(a,{key:1,plain:"",type:"warning",onClick:i[0]||(i[0]=o=>e("stop"))},{default:et(()=>[...i[8]||(i[8]=[ft(" 停止生成 ",-1)])]),_:1})):vt("",!0),u.generation.status==="failed"?(N(),Vt(a,{key:2,plain:"",type:"primary",onClick:i[1]||(i[1]=o=>e("retry"))},{default:et(()=>[...i[9]||(i[9]=[ft(" 重新生成 ",-1)])]),_:1})):vt("",!0)],2)])])}}}),IE=ki(ME,[["__scopeId","data-v-94e8b875"]]),DE={class:"result-step"},LE={class:"result-workspace"},FE={class:"result-list-pane"},OE={class:"pane-header"},RE={class:"result-toolbar"},NE={class:"result-list"},BE=["onClick"],$E={class:"result-index"},UE={class:"result-copy"},HE={key:0,class:"result-editor-pane"},zE={class:"pane-header"},VE={key:0,class:"modified-label"},GE={class:"field-editor"},jE={class:"field-editor"},WE={class:"field-editor"},XE={key:0,class:"validation-error"},qE={key:1,class:"validation-success"},YE={key:2,class:"quality-flags"},KE={class:"editor-pagination"},QE=_i({__name:"ResultEditorStep",props:{items:{},selectedId:{}},emits:["update:selectedId","update:field","restore:item"],setup(u,{emit:t}){const e=u,s=t,i=rt(""),r=rt(!1),a=ut(()=>e.items.find(h=>h.id===e.selectedId)??e.items[0]),o=ut(()=>e.items.findIndex(h=>{var d;return h.id===((d=a.value)==null?void 0:d.id)})),l=ut(()=>e.items.filter((h,d)=>{const f=i.value.trim().toLowerCase();return(!f||h.instruction.toLowerCase().includes(f)||h.output.toLowerCase().includes(f)||String(d+1).includes(f))&&(!r.value||h.status==="invalid")}));function c(h){if(!e.items.length)return;const d=Math.min(Math.max(o.value+h,0),e.items.length-1);s("update:selectedId",e.items[d].id)}return(h,d)=>{var S;const f=bh,g=Pp,y=Iw,b=Hu;return N(),G("section",DE,[E("div",LE,[E("aside",FE,[E("div",OE,[d[8]||(d[8]=E("strong",null,"生成结果",-1)),E("span",null,"共 "+j(u.items.length)+" 条",1)]),E("div",RE,[U(f,{modelValue:i.value,"onUpdate:modelValue":d[0]||(d[0]=w=>i.value=w),clearable:"",size:"small",placeholder:"搜索结果"},{prefix:et(()=>[...d[9]||(d[9]=[E("i",{class:"fa fa-search"},null,-1)])]),_:1},8,["modelValue"]),U(g,{modelValue:r.value,"onUpdate:modelValue":d[1]||(d[1]=w=>r.value=w)},{default:et(()=>[...d[10]||(d[10]=[ft("仅看错误",-1)])]),_:1},8,["modelValue"])]),E("div",NE,[(N(!0),G(ye,null,ni(l.value,w=>{var x;return N(),G("button",{key:w.id,type:"button",class:we(["result-item",{"is-active":w.id===((x=a.value)==null?void 0:x.id)}]),onClick:A=>s("update:selectedId",w.id)},[E("span",$E,"#"+j(String(u.items.findIndex(A=>A.id===w.id)+1).padStart(3,"0")),1),E("span",UE,[E("strong",null,j(w.instruction||"未填写指令"),1),E("small",null,j(w.output||"未填写输出"),1)]),E("i",{class:we(["fa",w.status==="invalid"?"fa-exclamation-circle is-error":"fa-check-circle is-valid"])},null,2)],10,BE)}),128))])]),a.value?(N(),G("div",HE,[E("div",zE,[E("div",null,[E("strong",null,"结果 #"+j(String(o.value+1).padStart(3,"0")),1),a.value.status==="modified"?(N(),G("span",VE,"已修改")):vt("",!0),a.value.split?(N(),Vt(y,{key:1,size:"small",effect:"plain"},{default:et(()=>[ft(j(a.value.split),1)]),_:1})):vt("",!0),a.value.qualityScore!=null?(N(),Vt(y,{key:2,size:"small",type:a.value.qualityScore>=80?"success":a.value.qualityScore>=60?"warning":"danger"},{default:et(()=>[ft("质量 "+j(a.value.qualityScore.toFixed(1)),1)]),_:1},8,["type"])):vt("",!0)]),U(b,{link:"",onClick:d[2]||(d[2]=w=>s("restore:item",a.value.id))},{default:et(()=>[...d[11]||(d[11]=[E("i",{class:"fa fa-undo"},null,-1),ft(" 恢复生成结果",-1)])]),_:1})]),E("div",GE,[d[12]||(d[12]=E("label",null,[ft("Instruction "),E("em",null,"必填")],-1)),U(f,{"model-value":a.value.instruction,type:"textarea",rows:3,"onUpdate:modelValue":d[3]||(d[3]=w=>s("update:field",a.value.id,"instruction",w))},null,8,["model-value"])]),E("div",jE,[d[13]||(d[13]=E("label",null,[ft("Input "),E("span",null,"选填")],-1)),U(f,{"model-value":a.value.input,type:"textarea",rows:2,"onUpdate:modelValue":d[4]||(d[4]=w=>s("update:field",a.value.id,"input",w))},null,8,["model-value"])]),E("div",WE,[d[14]||(d[14]=E("label",null,[ft("Output "),E("em",null,"必填")],-1)),U(f,{"model-value":a.value.output,type:"textarea",rows:7,"onUpdate:modelValue":d[5]||(d[5]=w=>s("update:field",a.value.id,"output",w))},null,8,["model-value"])]),a.value.error?(N(),G("div",XE,[d[15]||(d[15]=E("i",{class:"fa fa-exclamation-circle"},null,-1)),ft(" "+j(a.value.error),1)])):(N(),G("div",qE,[...d[16]||(d[16]=[E("i",{class:"fa fa-check-circle"},null,-1),ft(" 字段校验通过 ",-1)])])),(S=a.value.qualityFlags)!=null&&S.length?(N(),G("div",YE,[(N(!0),G(ye,null,ni(a.value.qualityFlags,w=>(N(),Vt(y,{key:w,size:"small",type:"warning",effect:"plain"},{default:et(()=>[ft(j(w),1)]),_:2},1024))),128))])):vt("",!0),E("div",KE,[U(b,{disabled:o.value<=0,onClick:d[6]||(d[6]=w=>c(-1))},{default:et(()=>[...d[17]||(d[17]=[ft("上一条",-1)])]),_:1},8,["disabled"]),E("span",null,j(o.value+1)+" / "+j(u.items.length),1),U(b,{disabled:o.value>=u.items.length-1,onClick:d[7]||(d[7]=w=>c(1))},{default:et(()=>[...d[18]||(d[18]=[ft("下一条",-1)])]),_:1},8,["disabled"])])])):vt("",!0)])])}}}),JE=ki(QE,[["__scopeId","data-v-37fecd0b"]]),T0="你是一名专业的数据生成助手。请根据输入内容生成准确、完整、可直接用于模型训练的问答数据。仅输出符合目标格式的内容,答案应事实清晰、语言自然,不要添加分析过程、说明或无关内容。";function ZE(){return{preprocessOptions:["clean_invalid","detect_structure","deduplicate","normalize_format"],semanticEnrichment:!1,qaPairsPerRow:1,datasetSplit:{train:80,validation:10,test:10},generationModelId:"",generationPrompt:T0,temperature:.7,maxTokens:1024,jsonMode:!1,qualityFilterEnabled:!1,filterLowQuality:!0,filterShortContent:!0,minOutputLength:20}}function tC(){return{preprocessOptions:["clean_invalid_content","detect_document_structure","merge_short_content","filter_low_quality","deduplicate_content","preserve_context"],chunkMethod:"structure",chunkSize:800,chunkOverlap:100,minChunkSize:100,customDelimiter:"",preserveTables:!0,preserveCodeBlocks:!0,preserveLists:!0,semanticEnrichment:!1,qaPairsPerChunk:1,datasetSplit:{train:80,validation:10,test:10},generationModelId:"",generationPrompt:T0,temperature:.7,maxTokens:1024,jsonMode:!1,qualityFilterEnabled:!1,filterLowQuality:!0,filterShortContent:!0,minOutputLength:20}}const Hv=500,nf=1500;function sg(u){var t,e;return{id:String(u.id),instruction:u.instruction,input:u.input||"",output:u.output,originalInstruction:u.original_instruction??u.instruction,originalInput:u.original_input??u.input??"",originalOutput:u.original_output??u.output,status:u.status,error:u.error||void 0,split:u.split||void 0,qualityScore:(t=u.quality_score)==null?void 0:t.overall,qualityFlags:((e=u.quality_score)==null?void 0:e.flags)||[],updatedAt:u.updated_at}}function eC(u){const t=rt([]),e=rt(null),s=ig({status:"idle",progress:0,message:"确认摘要后即可开始生成,过程中可查看实时进度。"});let i=null,r=0,a=0;function o(){r+=1,i&&clearTimeout(i),i=null}function l(){o(),s.status="idle",s.progress=0,s.message="确认摘要后即可开始生成,过程中可查看实时进度。",t.value=[],e.value=null}function c(A){s.progress=Math.max(0,Math.min(100,Number(A.progress)||0)),s.message=A.message||(A.status==="running"?"后端正在生成标准化结果并进行质量评分。":A.status==="completed"?"数据处理已完成。":A.failure_reason||"任务已停止。")}async function h(A){var I;const C=await hv(A,{page:1,page_size:Hv}),_=[...C.items],k=Math.ceil(C.total/C.page_size);for(let L=2;L<=k;L+=1){const P=await hv(A,{page:L,page_size:Hv});_.push(...P.items)}t.value=_.map(sg),e.value=((I=t.value[0])==null?void 0:I.id)??null}async function d(A){if(a=0,c(A),A.status==="completed"){const C=u.taskId.value;if(!C)return;await h(C),s.status="success",s.progress=100,s.message=`已完成 ${t.value.length.toLocaleString()} 条数据处理,可进入结果页检查。`,u.dirty.value=!0,yt.success("数据处理完成");return}(A.status==="failed"||A.status==="stopped")&&(s.status="failed",s.message=A.failure_reason||A.message||(A.status==="stopped"?"任务已停止,可以重新生成。":"数据处理失败,请检查配置后重试。"))}async function f(A){const C=u.taskId.value;if(!(!C||A!==r||s.status!=="running"))try{const _=await ww(C);if(A!==r)return;if(a=0,_.status==="running"||_.status==="pending"){c(_),i=setTimeout(()=>void f(A),nf);return}await d(_)}catch(_){if(A!==r)return;if(a+=1,a<=3){s.message=`进度查询暂时失败,正在重试(${a}/3`,i=setTimeout(()=>void f(A),nf);return}s.status="failed",s.message=_ instanceof Error?_.message:"查询任务进度失败,请重试。"}}async function g(){var _;const A=u.taskId.value;if(!A){yt.error("任务尚未创建,请返回上一步重试");return}o();const C=r;s.status="running",a=0,s.progress=0,s.message="正在同步预览修改并启动后端处理,请稍候。";try{await((_=u.beforeGenerate)==null?void 0:_.call(u));const k=await vw(A);if(C!==r)return;if(k.status==="completed"||k.status==="failed"||k.status==="stopped"){await d(k);return}c(k),i=setTimeout(()=>void f(C),nf)}catch(k){if(C!==r)return;s.status="failed",s.message=k instanceof Error?k.message:"启动数据处理失败,请重试。"}}async function y(){const A=u.taskId.value;if(A){o();try{const C=await mw(A);c(C)}catch{s.status="running",s.message="停止请求失败,继续查询后端任务状态。";const C=r;i=setTimeout(()=>void f(C),nf);return}s.status="failed",s.message="任务已停止,预览修改仍然保留,可以重新生成。"}}function b(A,C,_){const k=t.value.find(P=>P.id===A);if(!k)return;k[C]=_;const I=k.instruction.trim()&&k.output.trim();k.error=I?void 0:"Instruction 和 Output 不能为空";const L=k.instruction!==k.originalInstruction||k.input!==k.originalInput||k.output!==k.originalOutput;k.status=k.error?"invalid":L?"modified":"valid",u.dirty.value=!0}async function S(A){const C=u.taskId.value,_=t.value.find(L=>L.id===A);if(!C||!_)return;const k=await bw(C,A),I=t.value.indexOf(_);t.value[I]=sg(k),u.dirty.value=!0}async function w(){const A=u.taskId.value;if(!A)throw new Error("任务尚未创建");const C=t.value.filter(_=>_.instruction!==_.originalInstruction||_.input!==_.originalInput||_.output!==_.originalOutput);for(const _ of C){const k=await yw(A,_.id,{instruction:_.instruction,input:_.input,output:_.output,expected_updated_at:_.updatedAt}),I=t.value.findIndex(L=>L.id===_.id);I>=0&&(t.value[I]=sg(k))}}function x(){let A=null;for(const C of t.value)(!C.instruction.trim()||!C.output.trim()||C.status==="invalid")&&(C.error||(C.error="结果未通过后端质量校验,请修改后重新保存"),C.status="invalid",A??(A=C.id));return A&&(e.value=A),A==null}return{generation:s,results:t,selectedResultId:e,persistResultChanges:w,resetDownstream:l,restoreResult:S,startGeneration:g,stopGeneration:y,stopGenerationTimer:o,updateResultField:b,validateResults:x}}function sC(){async function u(t,e,s){var r,a;const i=[];for(const o of e){s({source_file_id:o,status:"processing",progress:0});let l;try{const c=await Aw(t,{replace_existing:!0,source_file_ids:[o]}),h=String(o),d=(r=c.files)==null?void 0:r.find(g=>String(g.source_file_id)===h),f=(d==null?void 0:d.preview_count)??((a=c.file_counts)==null?void 0:a[h])??c.items.filter(g=>String(g.source_file_id)===h).length;l=f>0?{source_file_id:o,status:"success",progress:100,preview_count:f}:{source_file_id:o,status:"failed",progress:0,preview_count:0,error:"该文件没有生成可用的预览条目,请检查内容或切分配置"}}catch(c){l={source_file_id:o,status:"failed",progress:0,error:c instanceof Error&&c.message?c.message:"切分失败,请重试"}}i.push(l),s(l)}return i}return{buildPreviewsByFile:u}}const zv=new Set(["xlsx","pdf","docx","pptx"]),iC=new Set(["json","jsonl","ndjson","csv","tsv","xlsx"]),nC=new Set(["txt","md","markdown","pdf","docx","pptx","json","jsonl","ndjson"]),rC=new Set(["doc","xls","ppt"]),aC=200*1024*1024,Vv=20,oC=500*1024*1024;function lC(u,t,e){var a;if(u.size>aC)return{valid:!1,severity:"warning",message:"单文件不能超过 200MB"};const s=((a=u.name.split(".").pop())==null?void 0:a.toLowerCase())??"";return rC.has(s)?{valid:!1,severity:"error",message:"旧版 DOC、XLS、PPT 文件暂不支持,请分别转换为 DOCX、XLSX、PPTX 后上传"}:(t==="unstructured"?nC:iC).has(s)?e.some(o=>o.name===u.name&&o.size===u.size)?{valid:!1,severity:"warning",message:"同名且同大小的文件已经选择"}:e.length>=Vv?{valid:!1,severity:"warning",message:`每个任务最多选择 ${Vv} 个文件`}:e.reduce((o,l)=>o+l.size,0)+u.size>oC?{valid:!1,severity:"warning",message:"当前任务选择的文件总大小不能超过 500MB"}:{valid:!0,extension:s}:{valid:!1,severity:"error",message:t==="unstructured"?"非结构化数据支持 TXT、MD、MARKDOWN、PDF、DOCX、PPTX、JSON、JSONL、NDJSON":"结构化数据支持 JSON、JSONL、NDJSON、CSV、TSV、XLSX"}}function P0(u,t=""){return{uid:String(u.id),sourceFileId:String(u.id),name:u.name,size:u.size_bytes,count:u.record_count,content:t,fileFormat:u.file_format,checksumSha256:u.checksum_sha256,status:"ready",uploadProgress:100,previewStatus:"waiting",previewProgress:0}}function cC(u){var s;const t=(s=u==null?void 0:u.response)==null?void 0:s.data,e=t==null?void 0:t.detail;return typeof e=="string"?e:e!=null&&e.message?e.message:t!=null&&t.message?t.message:u instanceof Error&&u.message?u.message:"上传失败,请删除该文件后重新选择"}function hC(u){const t=rt(!1),e=[];let s=null;async function i(o){const l=u.uploadedFiles.value.find(h=>String(h.uid)===o.uid);if(!l)return;const c=u.taskId.value;if(!c){l.status="failed",l.uploadError="任务尚未创建,请返回模型选择步骤后重试";return}l.status="uploading",l.uploadProgress=0,l.uploadError=void 0;try{let h="";if(!zv.has(o.extension)){try{h=new TextDecoder("utf-8",{fatal:!0}).decode(await o.file.arrayBuffer())}catch{throw new Error("文本文件不是有效的 UTF-8 编码,请转换编码后重试")}if(!h.trim())throw new Error("不能上传空文件")}const f=(await Sw(c,[o.file],g=>{l.uploadProgress=g})).files[0];if(!f)throw new Error("后端未返回源文件记录");if(Object.assign(l,P0(f),{rawFile:o.file,status:"uploading",uploadProgress:99}),zv.has(o.extension))try{const g=await Qv(c,f.id,{start_line:1,line_count:1e4});l.content=g.content}catch{}else l.content=h;l.status="ready",l.uploadProgress=100,u.onUploaded(l)}catch(h){l.status="failed",l.uploadError=cC(h)}}async function r(){t.value=!0;try{for(;e.length;){const o=e.shift();o&&await i(o)}}finally{t.value=!1}}function a(o){e.push(o),!s&&(s=r().finally(()=>{s=null}))}return{enqueueSourceUpload:a,sourceUploading:t}}const dC={class:"create-wizard-layout"},uC={class:"wizard-main"},fC={class:"wizard-main-inner"},pC={class:"wizard-steps-container"},gC={class:"custom-wizard-steps"},mC=["aria-current"],vC={class:"step-node"},bC={class:"step-icon"},yC={key:0,class:"fa fa-check"},wC={key:1},AC={class:"step-text"},SC={class:"step-title"},xC={class:"wizard-content"},EC={class:"wizard-footer"},CC={class:"footer-left"},_C={class:"footer-right"},kC="backend-pipeline-v2",TC=_i({__name:"DataProcessCreateView",setup(u){const t=cw(),e=Dw(),{list:s}=rw(e),i=ut(()=>s.value),r=rt(),a=rt(),o=rt(),l=[{id:"create",title:"创建任务",desc:"填写任务信息与处理配置"},{id:"model",title:"大模型选择",desc:"选择生成模型并设置输出要求"},{id:"upload",title:"上传文件",desc:"上传或接入待处理的源数据"},{id:"preview",title:"数据预览",desc:"核对源文件与预览内容"},{id:"generate",title:"开始生成",desc:"确认摘要并启动处理"},{id:"results",title:"结果编辑与保存",desc:"检查、修改并保存结果"}],c=rt(0),h=ut(()=>{var F;return((F=l[c.value])==null?void 0:F.id)??"create"}),d=ig({name:"",description:""}),f=rt(null),g=rt("structured"),y=rt(ZE()),b=rt(tC()),S=ut(()=>g.value==="unstructured"?b.value:y.value),w=rt([]),x=rt(!1),{buildPreviewsByFile:A}=sC(),C=ig({type:"postgresql",url:"",authMode:"none",username:"",password:"",limit:1e3,query:"",fileName:"external-data.jsonl"}),_=rt(!1),k=rt(!1),I=ut(()=>w.value.map(F=>F.name).join(", ")),L=rt(""),P=rt([]),D=rt(null),R=rt(null),K=rt({}),W=rt(!1);let Q=!1;const{generation:ht,results:T,selectedResultId:q,persistResultChanges:Lt,resetDownstream:mt,restoreResult:_e,startGeneration:re,stopGeneration:Gt,stopGenerationTimer:V,updateResultField:$,validateResults:Et}=eC({taskId:f,dirty:W,beforeGenerate:W0}),{enqueueSourceUpload:ct,sourceUploading:J}=hC({taskId:f,uploadedFiles:w,onUploaded(F){L.value="",mt(),W.value=!0,yt.success(`文件 ${F.name} 上传成功,等待切分`)}}),ae=ut(()=>w.value.some(F=>F.status!=="ready"||!F.sourceFileId)),Ti=ut(()=>P.value.filter(F=>F.status!=="original").length),ks=ut(()=>{const F=new Map;for(const O of P.value){const st=F.get(O.sourceFileId)||[];st.push(O),F.set(O.sourceFileId,st)}return F}),Ts=ut(()=>w.value.find(F=>String(F.uid)===D.value)),Se=ut(()=>ks.value.get(D.value||"")||[]),Sr=ut(()=>{var F;return((F=Ts.value)==null?void 0:F.content)??""}),Pa=ut(()=>w.value.map(F=>{const O=ks.value.get(String(F.uid))||[];return{id:String(F.uid),name:F.name,count:O.length,modifiedCount:O.filter(st=>st.status!=="original").length}})),Ps=ut(()=>h.value==="create"?"继续:选择大模型":h.value==="model"?"继续:上传文件":h.value==="upload"?J.value?"正在上传":x.value?"正在切分":"继续:数据预览":h.value==="preview"?"确认预览并继续":h.value==="results"?"保存任务":ht.status==="running"?"正在生成":ht.status==="success"?"查看生成结果":ht.status==="failed"?"重新生成":"开始生成"),Ne=ut(()=>h.value==="results"?"fa-check":h.value==="generate"&&ht.status!=="success"?"fa-play":"fa-arrow-right"),Ms=ut(()=>c.value>0?l[c.value-1].title:"");function kn(F){const O=l.findIndex(st=>st.id===F);O>=0&&(c.value=O)}function Ma(F){if(g.value==="unstructured"){b.value={...b.value,...F};return}y.value={...y.value,...F}}function Ml(){const F=g.value==="unstructured"?b.value:y.value,O={preprocess_options:[...F.preprocessOptions],semantic_enrichment:F.semanticEnrichment,dataset_split:{...F.datasetSplit},generation_model_id:F.generationModelId,generation_prompt:F.generationPrompt,temperature:F.temperature,max_tokens:F.maxTokens,json_mode:F.jsonMode,quality_filter_enabled:F.qualityFilterEnabled,filter_low_quality:F.filterLowQuality,filter_short_content:F.filterShortContent,min_output_length:F.minOutputLength};return g.value==="unstructured"?{...O,chunk_method:b.value.chunkMethod,chunk_size:b.value.chunkSize,chunk_overlap:b.value.chunkOverlap,min_chunk_size:b.value.minChunkSize,custom_delimiter:b.value.customDelimiter,preserve_tables:b.value.preserveTables,preserve_code_blocks:b.value.preserveCodeBlocks,preserve_lists:b.value.preserveLists,qa_pairs_per_chunk:b.value.qaPairsPerChunk}:{...O,qa_pairs_per_row:y.value.qaPairsPerRow}}function Il(){return{name:d.name.trim(),description:d.description.trim(),process_type:g.value,config:Ml()}}function yh(){var F;return{type:C.type,url:C.url.trim(),auth_mode:C.authMode,username:C.username||void 0,password:C.password||void 0,limit:C.limit,query:((F=C.query)==null?void 0:F.trim())||void 0,file_name:C.fileName||"external-data.jsonl"}}function Ia(F){return{id:String(F.id),sourceFileId:String(F.source_file_id),originalContent:F.original_content,editedContent:F.edited_content,sourceStart:F.source_start,sourceEnd:F.source_end,sourceStartLine:F.source_start_line,sourceEndLine:F.source_end_line,tokenCount:F.token_count,status:F.status,updatedAt:F.updated_at}}function M0(){if(g.value==="structured")return{preprocessOptions:y.value.preprocessOptions};if(g.value==="unstructured"){const{preprocessOptions:F,chunkMethod:O,chunkSize:st,chunkOverlap:Ht,minChunkSize:ke,customDelimiter:Is,preserveTables:At,preserveCodeBlocks:Ye,preserveLists:Xt}=b.value;return{preprocessOptions:F,chunkMethod:O,chunkSize:st,chunkOverlap:Ht,minChunkSize:ke,customDelimiter:O==="custom"?Is:"",preserveTables:At,preserveCodeBlocks:Ye,preserveLists:Xt}}return null}function I0(){if(g.value==="structured"){const{semanticEnrichment:F,qaPairsPerRow:O,datasetSplit:st,generationModelId:Ht,generationPrompt:ke,temperature:Is,maxTokens:At,jsonMode:Ye,qualityFilterEnabled:Xt,filterLowQuality:Ds,filterShortContent:Da,minOutputLength:La}=y.value;return{semanticEnrichment:F,qaPairsPerRow:O,datasetSplit:st,generationModelId:Ht,generationPrompt:ke,temperature:Is,maxTokens:At,jsonMode:Ye,qualityFilterEnabled:Xt,filterLowQuality:Ds,filterShortContent:Da,minOutputLength:La}}if(g.value==="unstructured"){const{semanticEnrichment:F,qaPairsPerChunk:O,datasetSplit:st,generationModelId:Ht,generationPrompt:ke,temperature:Is,maxTokens:At,jsonMode:Ye,qualityFilterEnabled:Xt,filterLowQuality:Ds,filterShortContent:Da,minOutputLength:La}=b.value;return{semanticEnrichment:F,qaPairsPerChunk:O,datasetSplit:st,generationModelId:Ht,generationPrompt:ke,temperature:Is,maxTokens:At,jsonMode:Ye,qualityFilterEnabled:Xt,filterLowQuality:Ds,filterShortContent:Da,minOutputLength:La}}return null}const D0=ut(()=>JSON.stringify(I0()));function rv(){return`${kC}:${g.value}:${JSON.stringify(M0())}`}function L0(){const F=w.value.map(O=>`${O.uid}:${O.name}:${O.size}:${O.checksumSha256||O.count}`).join("|");return`${rv()}:${F}`}xi([()=>d.name,()=>d.description,g,y,b,C],()=>{W.value=!0},{deep:!0}),xi(g,(F,O)=>{F===O||w.value.length===0||(U0(),yt.info("处理类型已变更,请重新上传或拉取匹配的源数据"))}),xi(D0,(F,O)=>{F!==O&&mt()});function F0(){var F;(F=document.querySelector(".layout-content"))==null||F.scrollTo({top:0,behavior:"smooth"})}xi(c,()=>Wf(F0));function av(F){const O=F.raw;if(!O)return;if(!f.value){yt.error("任务尚未创建,请返回模型选择步骤后重试");return}const st=lC(O,g.value,w.value);if(!st.valid){yt[st.severity](st.message);return}const Ht=`local-${F.uid}-${Date.now()}-${w.value.length}`;w.value.push({uid:Ht,rawFile:O,name:O.name,size:O.size,count:0,content:"",fileFormat:st.extension,status:"queued",uploadProgress:0,previewStatus:"waiting",previewProgress:0}),W.value=!0,ct({uid:Ht,file:O,extension:st.extension})}async function O0(){if(!f.value){yt.error("任务尚未创建,请返回模型选择步骤后重试");return}const F=new File([Wx],"finance_qa.jsonl",{type:"application/x-ndjson"});av({raw:F,uid:Date.now(),name:F.name})}function R0(F){Object.assign(C,F),k.value=!1}async function N0(){if(!f.value){yt.error("任务尚未创建,请返回模型选择步骤后重试");return}if(!C.url.trim()){yt.warning("请先填写数据源地址");return}_.value=!0;try{const F=await _w(f.value,yh());k.value=F.connected,F.connected?yt.success(F.message||"数据源连接测试成功"):yt.warning(F.message||"数据源连接失败")}catch{k.value=!1}finally{_.value=!1}}async function B0(){var F;if(!f.value){yt.error("任务尚未创建,请返回模型选择步骤后重试");return}if(!C.url.trim()){yt.warning("请先填写数据源地址");return}if(!((F=C.query)!=null&&F.trim())){yt.warning("请先填写只读 SELECT 查询语句");return}_.value=!0;try{const O=await kw(f.value,yh()),st=[];for(const Ht of O.files){const ke=await Qv(f.value,Ht.id,{start_line:1,line_count:5e3});st.push(P0(Ht,ke.content))}w.value.push(...st),k.value=!0,L.value="",mt(),W.value=!0,yt.success(`已成功登记 ${st.length} 个外部源文件`)}catch{k.value=!1}finally{_.value=!1}}async function $0(F){const O=w.value.findIndex(Ht=>Ht.uid===F);if(O<0||!f.value)return;const st=w.value[O];if(st){if(st.status==="uploading"){yt.warning("当前文件正在上传,请等待上传结束后再删除");return}if(st.sourceFileId)try{await Tw(f.value,st.sourceFileId)}catch{return}w.value.splice(O,1),L.value="",P.value=[],R.value=null,mt(),W.value=!0}}function U0(){w.value=[],L.value="",P.value=[],D.value=null,R.value=null,K.value={},k.value=!1,mt()}async function H0(){var O;await((O=r.value)==null?void 0:O.validate())&&kn("model")}async function z0(){var O;if(await((O=a.value)==null?void 0:O.validate()))try{const st=f.value?await Ew(f.value,Il()):await Cw(Il());f.value=String(st.id),W.value=!0,kn("upload")}catch{}}async function V0(){var ke,Is;if(x.value||J.value)return;if(!f.value){yt.error("任务尚未创建,请返回模型选择步骤后重试");return}if(w.value.length===0){yt.warning(g.value==="external"?"请先拉取至少一个数据源":"请上传至少一个源数据文件");return}const F=w.value.filter(At=>At.status==="failed");if(F.length){yt.warning(`${F.length} 个文件上传失败,请删除后重新选择`);return}if(ae.value){yt.warning("请等待所有文件上传完成后再开始切分");return}const O=L0(),st=rv(),Ht=()=>w.value.every(At=>At.previewStatus==="success"&&At.previewConfigSignature===st);if(O===L.value&&P.value.length&&Ht()){kn("preview");return}for(const At of w.value)At.previewConfigSignature!==st&&(At.previewStatus="waiting",At.previewProgress=0,At.previewError=void 0,At.previewCount=void 0);x.value=!0;try{const At=w.value.filter(Xt=>Xt.previewStatus!=="success"||Xt.previewConfigSignature!==st).map(Xt=>Xt.sourceFileId).filter(Xt=>!!Xt);await A(f.value,At,Xt=>{const Ds=w.value.find(Da=>String(Da.sourceFileId)===String(Xt.source_file_id));Ds&&(Ds.previewStatus=Xt.status,Ds.previewProgress=Xt.progress,Ds.previewCount=Xt.preview_count,Ds.previewError=Xt.error,Xt.status==="success"&&(Ds.previewConfigSignature=st))});const Ye=w.value.filter(Xt=>Xt.previewStatus==="failed").length;if(Ye||!Ht()){yt.warning(`${Ye||1} 个文件切分失败;修正问题后点击“继续:数据预览”即可重试`);return}try{const Xt=await dv(f.value,{page:1,page_size:500}),Ds=[...Xt.items],Da=Math.ceil(Xt.total/Xt.page_size);for(let La=2;La<=Da;La+=1){const tw=await dv(f.value,{page:La,page_size:500});Ds.push(...tw.items)}P.value=Ds.map(Ia)}catch{yt.warning("文件切分已经完成,但预览加载失败;请再次点击继续重试加载");return}if(!P.value.length){yt.warning("源文件没有生成可用的预览条目,请检查文件内容和预处理配置");return}D.value=String(((ke=w.value[0])==null?void 0:ke.uid)??"")||null,R.value=((Is=Se.value[0])==null?void 0:Is.id)??null,K.value=R.value&&D.value?{[D.value]:R.value}:{},L.value=O,mt(),kn("preview")}finally{x.value=!1}}function G0(F){var O;D.value&&R.value&&(K.value[D.value]=R.value),D.value=F,R.value=K.value[F]||((O=Se.value[0])==null?void 0:O.id)||null}function ov(F){R.value=F,D.value&&(K.value[D.value]=F)}function j0(F,O){const st=P.value.find(Ht=>Ht.id===F);st&&(st.editedContent=O,st.tokenCount=Uv(O),st.status=O===st.originalContent?"original":st.sourceStart==null?"manual":"modified",mt(),W.value=!0)}async function W0(){if(!f.value)throw new Error("任务尚未创建");const F=P.value.filter(O=>O.status==="modified"||O.status==="manual");for(const O of F){const st=await xw(f.value,O.id,{edited_content:O.editedContent,expected_updated_at:O.updatedAt}),Ht=P.value.findIndex(ke=>ke.id===O.id);Ht>=0&&(P.value[Ht]=Ia(st))}}function X0(F){const O=P.value.find(st=>st.id===F);!O||O.sourceStart==null||(O.editedContent=O.originalContent,O.tokenCount=Uv(O.originalContent),O.status="original",mt(),W.value=!0)}async function q0(){if(!(!D.value||!f.value))try{const F=await Pw(f.value,{source_file_id:D.value,edited_content:""}),O=Ia(F);P.value.push(O),ov(O.id),mt(),W.value=!0}catch{}}async function Y0(F){var Ht,ke;if(!await((Ht=o.value)==null?void 0:Ht.open({title:"删除预览内容?",message:"删除只影响本次处理,不会修改源文件。删除后可重新从源文件生成预览。",confirmText:"删除",cancelText:"取消",tone:"danger"})))return;const st=P.value.findIndex(Is=>Is.id===F);if(!(st<0)&&f.value){try{await Mw(f.value,F)}catch{return}P.value.splice(st,1),R.value=((ke=Se.value[Math.min(st,Se.value.length-1)])==null?void 0:ke.id)??null,D.value&&R.value&&(K.value[D.value]=R.value),mt(),W.value=!0}}async function K0(){if(h.value==="create"){await H0();return}if(h.value==="model"){await z0();return}if(h.value==="upload"){await V0();return}if(h.value==="preview"){if(!P.value.length){yt.warning("当前没有可生成的预览内容");return}kn("generate");return}if(h.value==="generate"){ht.status==="success"?kn("results"):ht.status!=="running"&&await re();return}await J0()}function Q0(){if(J.value){yt.warning("请等待当前文件上传完成");return}if(x.value){yt.warning("请等待当前文件切分完成");return}if(ht.status==="running"){yt.warning("请先停止当前生成任务");return}c.value>0&&(c.value-=1)}async function J0(){if(!Et()){yt.warning("请先修正校验失败的结果");return}try{await Lt()}catch{return}if(!Et()){yt.warning("仍有结果未通过后端质量校验,请继续修正");return}W.value=!1,Q=!0,yt.success("数据处理任务已保存"),await t.push("/data-process")}async function Z0(){var O;if(!W.value){Q=!0,t.back();return}await((O=o.value)==null?void 0:O.open({title:"确认离开当前页面?",message:"当前存在未保存修改,离开后这些修改将不会保留。",confirmText:"放弃修改",cancelText:"继续编辑",tone:"danger"}))&&(Q=!0,t.back())}return aw(async()=>{var O;if(J.value)return yt.warning("请等待当前文件上传完成后再离开页面"),!1;if(Q||!W.value)return!0;const F=await((O=o.value)==null?void 0:O.open({title:"确认离开当前页面?",message:"当前存在未保存修改,离开后这些修改将不会保留。",confirmText:"放弃修改",cancelText:"继续编辑",tone:"danger"}));return F&&(Q=!0),!!F}),jv(()=>{V()}),ow(()=>{localStorage.removeItem("yg-data-process-create-draft"),e.load(!0)}),(F,O)=>{var Ht,ke,Is;const st=Hu;return N(),G(ye,null,[E("div",dC,[E("main",uC,[E("div",fC,[E("div",pC,[E("div",gC,[(N(),G(ye,null,ni(l,(At,Ye)=>(N(),G(ye,{key:At.id},[Ye!==0?(N(),G("div",{key:0,class:we(["step-connector",{"is-active":c.value>=Ye}])},null,2)):vt("",!0),E("div",{class:we(["step-item",{"is-active":c.value===Ye,"is-completed":c.value>Ye}]),"aria-current":c.value===Ye?"step":void 0},[E("div",vC,[E("div",bC,[c.value>Ye?(N(),G("i",yC)):(N(),G("span",wC,j(Ye+1),1))]),E("div",AC,[E("div",SC,j(At.title),1)])])],10,mC)],64))),64))])]),E("div",xC,[h.value==="create"?(N(),Vt($A,{key:0,ref_key:"taskSetupRef",ref:r,name:d.name,"onUpdate:name":O[0]||(O[0]=At=>d.name=At),description:d.description,"onUpdate:description":O[1]||(O[1]=At=>d.description=At),"process-type":g.value,"onUpdate:processType":O[2]||(O[2]=At=>g.value=At),"structured-options":y.value,"onUpdate:structuredOptions":O[3]||(O[3]=At=>y.value=At),"unstructured-options":b.value,"onUpdate:unstructuredOptions":O[4]||(O[4]=At=>b.value=At)},null,8,["name","description","process-type","structured-options","unstructured-options"])):h.value==="model"?(N(),Vt(GA,{key:1,ref_key:"modelSelectionRef",ref:a,options:S.value,models:i.value,"onUpdate:options":Ma},null,8,["options","models"])):h.value==="upload"?(N(),Vt(wS,{key:2,"process-type":g.value,"uploaded-files":w.value,"external-source":C,"external-pulling":_.value,"external-connected":k.value,"preview-building":x.value,"source-uploading":Ls(J),"onUpdate:externalSource":R0,onFileChange:av,onRemoveFile:$0,onUseSample:O0,onTestConnection:N0,onPullData:B0},null,8,["process-type","uploaded-files","external-source","external-pulling","external-connected","preview-building","source-uploading"])):h.value==="preview"?(N(),Vt(AE,{key:3,"selected-id":R.value,"selected-file-id":D.value,"source-text":Sr.value,items:Se.value,"process-type":g.value,"file-name":((Ht=Ts.value)==null?void 0:Ht.name)??"","task-id":f.value,"source-file-id":((ke=Ts.value)==null?void 0:ke.sourceFileId)??((Is=Ts.value)==null?void 0:Is.uid)??null,files:Pa.value,"onUpdate:selectedId":ov,"onUpdate:selectedFileId":G0,"onUpdate:itemContent":j0,"onRestore:item":X0,"onAdd:item":q0,"onRemove:item":Y0},null,8,["selected-id","selected-file-id","source-text","items","process-type","file-name","task-id","source-file-id","files"])):h.value==="generate"?(N(),Vt(IE,{key:4,"task-name":d.name,"process-type":g.value,"file-name":I.value,"preview-count":P.value.length,"modified-count":Ti.value,generation:Ls(ht),onStop:Ls(Gt),onRetry:Ls(re)},null,8,["task-name","process-type","file-name","preview-count","modified-count","generation","onStop","onRetry"])):h.value==="results"?(N(),Vt(JE,{key:5,"selected-id":Ls(q),"onUpdate:selectedId":O[5]||(O[5]=At=>lw(q)?q.value=At:null),items:Ls(T),"onUpdate:field":Ls($),"onRestore:item":Ls(_e)},null,8,["selected-id","items","onUpdate:field","onRestore:item"])):vt("",!0)])])]),E("footer",EC,[E("div",CC,[c.value>0?(N(),Vt(st,{key:0,disabled:x.value||Ls(J),onClick:Q0},{default:et(()=>[O[6]||(O[6]=E("i",{class:"fa fa-arrow-left",style:{"margin-right":"6px"}},null,-1)),ft(" 返回:"+j(Ms.value),1)]),_:1},8,["disabled"])):(N(),Vt(st,{key:1,onClick:Z0},{default:et(()=>[...O[7]||(O[7]=[ft("取消",-1)])]),_:1}))]),O[8]||(O[8]=E("div",{class:"footer-center"},null,-1)),E("div",_C,[U(st,{class:"wizard-primary-action",type:"primary",loading:Ls(ht).status==="running"||h.value==="upload"&&(Ls(J)||x.value),disabled:h.value==="generate"&&Ls(ht).status==="running"||x.value||Ls(J)||h.value==="upload"&&ae.value,onClick:K0},{default:et(()=>[ft(j(Ps.value)+" ",1),E("i",{class:we(["fa",Ne.value]),style:{"margin-left":"6px"}},null,2)]),_:1},8,["loading","disabled"])])])]),U(hw,{ref_key:"confirmDialogRef",ref:o},null,512)],64)}}}),g_=ki(TC,[["__scopeId","data-v-63522af3"]]);export{g_ as default};