var Sw=Object.defineProperty;var kv=d=>{throw TypeError(d)};var xw=(d,t,e)=>t in d?Sw(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e;var M=(d,t,e)=>xw(d,typeof t!="symbol"?t+"":t,e),sg=(d,t,e)=>t.has(d)||kv("Cannot "+e);var n=(d,t,e)=>(sg(d,t,"read from private field"),e?e.call(d):t.get(d)),m=(d,t,e)=>t.has(d)?kv("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(d):t.set(d,e),p=(d,t,e,s)=>(sg(d,t,"write to private field"),s?s.call(d,e):t.set(d,e),e),b=(d,t,e)=>(sg(d,t,"access private method"),e);var Yt=(d,t,e,s)=>({set _(i){p(d,t,i,e)},get _(){return n(d,t,s)}});import{E as Ew}from"./el-alert-3zw4v2e7.js";import{E as zu}from"./index-DXP8yRbu.js";import{v as Cw}from"./directive-B3cCGCE3.js";import{d as Ci,o as O,c as $,q as C,s as H,n as Se,aa as X,g as ft,j as rt,x as ut,w as J,M as Ae,ad as ii,e as Ut,f as Jt,A as gt,y as et,D as Si,H as cb,al as _w,aQ as kw,P as Kh,t as Tv,aL as ig,z as pg,ac as Tw,ag as Pw,aR as Mw,G as Iw,K as Dw,aB as Lw,v as Fw}from"./index-Di_EOfGc.js";import{A as Ow}from"./AppConfirmDialog-DLErxki6.js";import{E as hb,a as db}from"./el-form-item-BA58sHM7.js";import{E as Vu}from"./index-BNuJTOPh.js";import{a as ub,E as Op}from"./el-checkbox-B1s63UdM.js";import{E as Gu}from"./el-input-number-Bug34JZW.js";/* empty css */import{_ as _i}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{E as Rp,a as Np}from"./el-select-CTMaVpjw.js";import{E as Rw}from"./el-slider-DViM1Irz.js";import{E as Nw}from"./el-switch-LPEdORwD.js";import"./el-popper-ijf4hJR9.js";import"./el-tooltip-l0sNRNKZ.js";import"./el-scrollbar-B3KhXaPF.js";import{E as Bw}from"./el-tag-7y8XfwGF.js";import{E as fb}from"./el-pagination-CfW-j38I.js";import{E as pb}from"./el-progress-DMG4au6m.js";import{E as $w}from"./el-upload-BidZtrXE.js";import{a as Uw,b as Hw,s as zw,c as Vw,r as Gw,u as jw,e as Ww,f as Pv,h as Xw,i as qw,j as Qm,k as ng,l as Yw,m as Jf,n as Kw,o as Qw,p as Jw,t as Zw,q as tA,v as eA,w as sA,x as iA}from"./dataProcess-CtPjv9ya.js";import{u as nA}from"./models-En12bx_d.js";import"./vnode-BJ_0wjgu.js";import"./castArray-BJO2UyU0.js";import"./_baseClone-9Jzhq_Q-.js";import"./raf-IGNBn_RA.js";import"./index-k8yHD6t1.js";import"./index-DfvEbper.js";import"./omit-DTOAvlk4.js";import"./index-C-Yxg-Fh.js";import"./index-B-Y9DN1b.js";import"./index-BwMV6MbE.js";import"./scroll-BFlUZz8k.js";import"./clamp-BE2VEtCh.js";import"./toNumber-CQib__o7.js";import"./_baseIteratee-DQCaw9G-.js";import"./debounce-DcBxaGXN.js";import"./validator-CGXjPPmc.js";import"./model-j6XB5QNI.js";const Sl={min:1,max:50};function Jm(d,t=1){const e=Number(d),s=Number.isFinite(e)?Math.trunc(e):t;return Math.min(Sl.max,Math.max(Sl.min,s))}const rA={class:"generation-option-row dataset-split-row"},aA={class:"dataset-split-config"},oA={class:"dataset-split-grid"},lA={class:"dataset-split-field"},cA={class:"dataset-split-input"},hA={class:"dataset-split-field"},dA={class:"dataset-split-input"},uA={class:"dataset-split-field"},fA={class:"dataset-split-input"},pA={key:0,role:"alert"},gA=Ci({__name:"DatasetSplitEditor",props:{modelValue:{},ariaLabelPrefix:{default:""}},emits:["update:modelValue"],setup(d,{emit:t}){const e=d,s=t,i=rt(()=>{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=Gu;return O(),$("div",rA,[l[9]||(l[9]=C("div",{class:"generation-option-copy"},[C("strong",null,"数据集划分"),C("small",null,"按比例将生成后的问答对随机划分为训练集、验证集和测试集")],-1)),C("div",aA,[C("div",oA,[C("label",lA,[l[4]||(l[4]=C("span",null,"训练集",-1)),C("span",cA,[H(c,{"model-value":d.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]=C("span",null,"%",-1))])]),C("label",hA,[l[6]||(l[6]=C("span",null,"验证集",-1)),C("span",dA,[H(c,{"model-value":d.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]=C("span",null,"%",-1))])]),C("label",uA,[l[8]||(l[8]=C("span",null,"测试集",-1)),C("span",fA,[H(c,{"model-value":d.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]=C("span",null,"%",-1))])])]),C("div",{class:Se(["dataset-split-summary",{"is-invalid":i.value!==100}])},[C("span",null,"总计 "+X(i.value)+"%",1),i.value!==100?(O(),$("span",pA," 训练集、验证集和测试集比例总和必须为 100% ")):ft("",!0)],2)])])}}}),gb=_i(gA,[["__scopeId","data-v-f479d5fe"]]),mA={key:0,class:"generation-config-group model-config-group"},vA={class:"model-field"},bA={class:"model-option"},yA={class:"model-field"},wA={class:"advanced-settings-grid"},AA={class:"config-field"},SA={class:"config-field"},xA={class:"unit-input"},EA={class:"json-mode-row"},CA={key:0,class:"generation-validation-message",role:"alert"},_A={key:1,class:"generation-config-group quality-config-group"},kA={class:"quality-switch-row"},TA={key:0,class:"quality-rule-panel"},PA={key:0,class:"minimum-length-field"},MA={class:"minimum-length-input"},IA={key:1,class:"quality-rule-warning",role:"alert"},DA={key:1,class:"generation-validation-message",role:"alert"},LA=Ci({__name:"GenerationOptionsPanel",props:{options:{},models:{},section:{},validationMessage:{}},emits:["update:options"],setup(d,{emit:t}){const e=d,s=t;function i(c,h){s("update:options",{...e.options,[c]:h})}function r(c){const h=c.filter(u=>typeof u=="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 u=Np,f=Rp,g=Vu,y=Rw,v=Gu,w=Nw,S=Op,x=ub;return d.section==="model"?(O(),$("div",mA,[C("div",vA,[h[8]||(h[8]=C("div",{class:"field-copy"},[C("strong",null,[ut("数据生成模型 "),C("em",null,"*")]),C("small",null,"选择负责生成问答、指令或结构化内容的大模型")],-1)),H(f,{class:"model-select","model-value":d.options.generationModelId,filterable:"",placeholder:"请选择用于生成数据的模型","aria-label":"数据生成模型","onUpdate:modelValue":h[0]||(h[0]=A=>i("generationModelId",A))},{empty:J(()=>[...h[7]||(h[7]=[C("div",{class:"model-empty"},"暂无模型,请先在模型管理中添加",-1)])]),default:J(()=>[(O(!0),$(Ae,null,ii(d.models||[],A=>(O(),Ut(u,{key:A.id,label:A.name,value:A.id},{default:J(()=>[C("div",bA,[C("span",null,X(A.name),1),C("small",null,X(l(A)),1)])]),_:2},1032,["label","value"]))),128))]),_:1},8,["model-value"])]),C("div",yA,[h[9]||(h[9]=C("div",{class:"field-copy"},[C("strong",null,"默认提示语"),C("small",null,"用于约束生成内容的格式、语气和完整性,可按任务需要修改")],-1)),H(g,{class:"prompt-input","model-value":d.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]=C("div",{class:"prompt-variables-hint"},[ut(" 提示:可在文本中通过 "),C("code",{textContent:"{{ content }}"}),ut(" 引用当前正在处理的数据内容。 ")],-1))]),C("div",wA,[C("label",AA,[h[11]||(h[11]=C("span",{class:"config-field-label"},"生成温度 (Temperature)",-1)),H(y,{"model-value":d.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]=C("small",null,"较低值输出更确定、保守,较高值输出更多样、有创造性",-1))]),C("label",SA,[h[14]||(h[14]=C("span",{class:"config-field-label"},"最大输出长度 (Max Tokens)",-1)),C("span",xA,[H(v,{"model-value":d.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]=C("span",null,"Token",-1))]),h[15]||(h[15]=C("small",null,"限制单次生成的最大内容长度,防止过度发散",-1))])]),C("div",EA,[h[16]||(h[16]=C("div",{class:"field-copy"},[C("strong",null,"强制 JSON 格式输出"),C("small",null,"要求大模型返回纯 JSON 对象,有助于提高下游结构化提取的稳定性")],-1)),H(w,{"model-value":d.options.jsonMode,"inline-prompt":"","active-text":"开","inactive-text":"关","onUpdate:modelValue":h[4]||(h[4]=A=>i("jsonMode",!!A))},null,8,["model-value"])]),o()?(O(),$("p",CA,X(o()),1)):ft("",!0)])):(O(),$("div",_A,[C("div",kA,[h[17]||(h[17]=C("div",{class:"config-group-heading"},[C("div",null,[C("h4",null,"质量筛选"),C("p",null,"生成后自动过滤不符合要求的内容,不影响源数据预处理")])],-1)),H(w,{"model-value":d.options.qualityFilterEnabled,"inline-prompt":"","active-text":"开","inactive-text":"关","aria-label":"质量筛选","onUpdate:modelValue":h[5]||(h[5]=A=>i("qualityFilterEnabled",!!A))},null,8,["model-value"])]),d.options.qualityFilterEnabled?(O(),$("div",TA,[H(x,{"model-value":a(),class:"quality-rule-list","onUpdate:modelValue":r},{default:J(()=>[H(S,{value:"low_quality"},{default:J(()=>[...h[18]||(h[18]=[C("span",{class:"rule-copy"},[C("strong",null,"过滤低质量内容"),C("small",null,"按相关性、完整性和可读性过滤明显不合格的生成结果")],-1)])]),_:1}),H(S,{value:"short_content"},{default:J(()=>[...h[19]||(h[19]=[C("span",{class:"rule-copy"},[C("strong",null,"过滤过短内容"),C("small",null,"过滤正文长度低于指定字数的生成结果")],-1)])]),_:1})]),_:1},8,["model-value"]),d.options.filterShortContent?(O(),$("label",PA,[h[21]||(h[21]=C("span",null,"最少字数",-1)),C("span",MA,[H(v,{"model-value":d.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]=C("span",null,"字",-1))]),h[22]||(h[22]=C("small",null,"少于该字数的生成结果将被过滤",-1))])):ft("",!0),!d.options.filterLowQuality&&!d.options.filterShortContent?(O(),$("p",IA," 请至少选择一项质量筛选规则 ")):ft("",!0)])):ft("",!0),o()?(O(),$("p",DA,X(o()),1)):ft("",!0)]))}}}),Zm=_i(LA,[["__scopeId","data-v-e6fd162c"]]),FA={class:"form-section structured-options-section"},OA={class:"preprocess-option-copy"},RA={class:"form-section generation-options-section"},NA={class:"generation-option-list"},BA={class:"generation-option-row"},$A=Ci({__name:"StructuredOptionsPanel",props:{options:{},validationAttempted:{type:Boolean},qualityValidationMessage:{}},emits:["update:options"],setup(d,{emit:t}){const e=d,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(c,h){s("update:options",{...e.options,[c]:h})}function a(c){s("update:options",{...e.options,...c})}function o(c){r("qaPairsPerRow",Jm(c))}function l(c){const h=new Set(i.map(f=>f.value)),u=Array.from(new Set(c.filter(f=>typeof f=="string"&&h.has(f))));r("preprocessOptions",u)}return(c,h)=>{const u=Op,f=ub,g=Gu;return O(),$(Ae,null,[C("div",FA,[h[1]||(h[1]=C("div",{class:"section-title-row"},[C("div",null,[C("h3",null,"预处理选项"),C("p",null,"选择在生成问答对之前需要执行的数据处理方式")])],-1)),H(f,{"model-value":d.options.preprocessOptions,class:"preprocess-option-grid","onUpdate:modelValue":l},{default:J(()=>[(O(),$(Ae,null,ii(i,y=>H(u,{key:y.value,value:y.value,class:"preprocess-option"},{default:J(()=>[C("span",OA,[C("strong",null,X(y.label),1),C("small",null,X(y.description),1)])]),_:2},1032,["value"])),64))]),_:1},8,["model-value"])]),C("div",RA,[h[3]||(h[3]=C("div",{class:"section-title-row"},[C("div",null,[C("h3",null,"生成选项"),C("p",null,"配置每条结构化记录生成问答对的方式和数量")])],-1)),C("div",NA,[H(Zm,{options:d.options,section:"quality","validation-message":d.validationAttempted?d.qualityValidationMessage:"","onUpdate:options":a},null,8,["options","validation-message"]),C("div",BA,[h[2]||(h[2]=C("div",{class:"generation-option-copy"},[C("strong",null,"每行生成数量"),C("small",null,"支持 1~50 条;数量越大,处理耗时和 Token 消耗越高")],-1)),H(g,{"model-value":d.options.qaPairsPerRow,min:Jt(Sl).min,max:Jt(Sl).max,step:1,precision:0,"controls-position":"right","onUpdate:modelValue":o},null,8,["model-value","min","max"])]),H(gb,{"model-value":d.options.datasetSplit,"onUpdate:modelValue":h[0]||(h[0]=y=>r("datasetSplit",y))},null,8,["model-value"])])])],64)}}}),UA=_i($A,[["__scopeId","data-v-e255bd71"]]),HA={class:"form-section unstructured-options-section"},zA={class:"preprocess-option-grid"},VA={class:"form-section chunk-options-section"},GA={class:"chunk-settings-grid is-basic"},jA={class:"config-field"},WA={key:0},XA={key:1},qA={key:2},YA={class:"config-field"},KA={class:"unit-input"},QA={class:"config-field"},JA={class:"unit-input"},ZA={class:"config-field"},tS={class:"unit-input"},eS={key:0,class:"config-field"},sS={class:"unit-input"},iS={key:0,class:"option-validation-message",role:"alert"},nS={class:"form-section generation-options-section"},rS={class:"generation-option-list"},aS={class:"generation-option-row"},oS=Ci({__name:"UnstructuredOptionsPanel",props:{options:{},validationAttempted:{type:Boolean},qualityValidationMessage:{},chunkValidationMessage:{}},emits:["update:options"],setup(d,{expose:t,emit:e}){const s=d,i=e,r=["clean_invalid_content","detect_document_structure","merge_short_content","filter_low_quality","deduplicate_content","preserve_context"],a=[{value:"layout_hybrid",label:"版面结构混合切分"},{value:"semantic",label:"语义切分"},{value:"fixed",label:"固定 Token 切分"}],o={chunkSize:{min:200,max:2e3},chunkOverlap:{min:0,max:500},minChunkSize:{min:20,max:500},semanticBreakpointPercentile:{min:1,max:99},qaPairsPerChunk:Sl},l=rt(()=>r.every(x=>s.options.preprocessOptions.includes(x))),c=rt(()=>s.options.preprocessOptions.includes("desensitize")),h=rt(()=>s.options.preserveTables&&s.options.preserveCodeBlocks&&s.options.preserveLists);function u(x,A){i("update:options",{...s.options,[x]:A})}function f(x){i("update:options",{...s.options,...x})}function g(x){const A=!!x,_=Array.from(new Set(s.options.preprocessOptions.filter(E=>!r.includes(E))));u("preprocessOptions",A?[...r,..._]:_)}function y(x){const A=Array.from(new Set(s.options.preprocessOptions.filter(_=>_!=="desensitize")));x&&A.push("desensitize"),u("preprocessOptions",A)}function v(x){const A=!!x;i("update:options",{...s.options,preserveTables:A,preserveCodeBlocks:A,preserveLists:A})}function w(x,A){const _=o[x],E=Number(A),k=Number.isFinite(E)?E:_.min;u(x,Math.min(_.max,Math.max(_.min,k)))}function S(){}return t({revealValidation:S}),(x,A)=>{const _=Op,E=Np,k=Rp,P=Gu;return O(),$(Ae,null,[C("div",HA,[A[10]||(A[10]=C("div",{class:"section-title-row"},[C("div",null,[C("h3",null,"预处理选项"),C("p",null,"默认启用结构感知的推荐策略,只需决定是否需要脱敏")])],-1)),C("div",zA,[C("label",{class:Se(["preprocess-option",{"is-checked":l.value}])},[H(_,{"model-value":l.value,"onUpdate:modelValue":g},null,8,["model-value"]),A[7]||(A[7]=C("span",{class:"preprocess-option-copy"},[C("strong",null,"智能预处理"),C("small",null,"清理页眉页脚、页码、目录和无效内容,感知文档结构、合并短块、预过滤低质量内容、近重复去重,并通过重叠保护上下文")],-1))],2),C("label",{class:Se(["preprocess-option",{"is-checked":c.value}])},[H(_,{"model-value":c.value,"onUpdate:modelValue":y},null,8,["model-value"]),A[8]||(A[8]=C("span",{class:"preprocess-option-copy"},[C("strong",null,"敏感信息脱敏"),C("small",null,"识别并脱敏姓名、手机号、邮箱和身份证号")],-1))],2),C("label",{class:Se(["preprocess-option",{"is-checked":h.value}])},[H(_,{"model-value":h.value,"onUpdate:modelValue":v},null,8,["model-value"]),A[9]||(A[9]=C("span",{class:"preprocess-option-copy"},[C("strong",null,"保护表格、代码和列表"),C("small",null,"避免切分点破坏特殊内容块的完整性")],-1))],2)])]),C("div",VA,[A[24]||(A[24]=C("div",{class:"section-title-row"},[C("div",null,[C("h3",null,"切分选项"),C("p",null,"优先保留文档版面结构,也可按主题变化或固定 Token 切分")])],-1)),C("div",GA,[C("label",jA,[A[11]||(A[11]=C("span",{class:"config-field-label"},"切分方式",-1)),H(k,{"model-value":d.options.chunkMethod,"aria-label":"切分方式","onUpdate:modelValue":A[0]||(A[0]=L=>u("chunkMethod",L))},{default:J(()=>[(O(),$(Ae,null,ii(a,L=>H(E,{key:L.value,label:L.label,value:L.value},null,8,["label","value"])),64))]),_:1},8,["model-value"]),d.options.chunkMethod==="layout_hybrid"?(O(),$("small",WA,"默认推荐,按标题、段落、列表和表格结构切分,并合并过短内容块")):d.options.chunkMethod==="semantic"?(O(),$("small",XA,"根据相邻内容的语义变化寻找主题边界,适合长文章和知识材料")):(O(),$("small",qA,"按句子边界控制固定 Token 长度,速度快且结果稳定"))]),C("label",YA,[A[13]||(A[13]=C("span",{class:"config-field-label"},"切片长度",-1)),C("span",KA,[H(P,{"model-value":d.options.chunkSize,min:200,max:2e3,step:50,precision:0,"controls-position":"right","aria-label":"切片长度","onUpdate:modelValue":A[1]||(A[1]=L=>w("chunkSize",L))},null,8,["model-value"]),A[12]||(A[12]=C("span",null,"Token",-1))]),A[14]||(A[14]=C("small",null,"单个切片的目标上限,默认 800 Token",-1))]),C("label",QA,[A[16]||(A[16]=C("span",{class:"config-field-label"},"重叠长度",-1)),C("span",JA,[H(P,{"model-value":d.options.chunkOverlap,min:0,max:500,step:10,precision:0,"controls-position":"right","aria-label":"重叠长度","onUpdate:modelValue":A[2]||(A[2]=L=>w("chunkOverlap",L))},null,8,["model-value"]),A[15]||(A[15]=C("span",null,"Token",-1))]),A[17]||(A[17]=C("small",null,"在相邻切片中最多重复保留的上下文,默认 100 Token",-1))]),C("label",ZA,[A[19]||(A[19]=C("span",{class:"config-field-label"},"最小切片长度",-1)),C("span",tS,[H(P,{"model-value":d.options.minChunkSize,min:20,max:500,step:10,precision:0,"controls-position":"right","aria-label":"最小切片长度","onUpdate:modelValue":A[3]||(A[3]=L=>w("minChunkSize",L))},null,8,["model-value"]),A[18]||(A[18]=C("span",null,"Token",-1))]),A[20]||(A[20]=C("small",null,"过短的尾部内容会尽量并入前一个切片",-1))]),d.options.chunkMethod==="semantic"?(O(),$("label",eS,[A[22]||(A[22]=C("span",{class:"config-field-label"},"语义断点百分位",-1)),C("span",sS,[H(P,{"model-value":d.options.semanticBreakpointPercentile,min:1,max:99,step:1,precision:0,"controls-position":"right","aria-label":"语义断点百分位","onUpdate:modelValue":A[4]||(A[4]=L=>w("semanticBreakpointPercentile",L))},null,8,["model-value"]),A[21]||(A[21]=C("span",null,"%",-1))]),A[23]||(A[23]=C("small",null,"百分位越低切片越多,推荐保持 95%",-1))])):ft("",!0)]),A[25]||(A[25]=C("p",{class:"chunk-estimation-note"}," Token 数为轻量估算值,实际长度以训练使用的模型分词器为准。 ",-1)),d.chunkValidationMessage?(O(),$("p",iS,X(d.chunkValidationMessage),1)):ft("",!0)]),C("div",nS,[A[27]||(A[27]=C("div",{class:"section-title-row"},[C("div",null,[C("h3",null,"生成选项"),C("p",null,"只保留会直接影响输出的核心设置")])],-1)),C("div",rS,[H(Zm,{options:d.options,section:"quality","validation-message":d.validationAttempted?d.qualityValidationMessage:"","onUpdate:options":f},null,8,["options","validation-message"]),C("div",aS,[A[26]||(A[26]=C("div",{class:"generation-option-copy"},[C("strong",null,"每个切片生成数量"),C("small",null,"支持 1~50 条;数量越大,处理耗时和 Token 消耗越高")],-1)),H(P,{"model-value":d.options.qaPairsPerChunk,min:Jt(Sl).min,max:Jt(Sl).max,step:1,precision:0,"controls-position":"right","aria-label":"每个切片生成数量","onUpdate:modelValue":A[5]||(A[5]=L=>w("qaPairsPerChunk",L))},null,8,["model-value","min","max"])]),H(gb,{"model-value":d.options.datasetSplit,"aria-label-prefix":"非结构化","onUpdate:modelValue":A[6]||(A[6]=L=>u("datasetSplit",L))},null,8,["model-value"])])])],64)}}}),lS=_i(oS,[["__scopeId","data-v-4ca60714"]]),cS={class:"task-setup-step"},hS={class:"form-section"},dS={class:"basic-grid"},uS={class:"form-section"},fS={class:"section-title-row"},pS={key:0},gS={key:1},mS={class:"type-options"},vS=["disabled"],bS=["disabled"],yS=["disabled"],wS=Ci({__name:"TaskSetupStep",props:{name:{},description:{},processType:{},structuredOptions:{},unstructuredOptions:{},processTypeLocked:{type:Boolean}},emits:["update:name","update:description","update:processType","update:structuredOptions","update:unstructuredOptions"],setup(d,{expose:t,emit:e}){const s=d,i=e,r=et(),a=et(),o=et(!1),l=rt(()=>({name:s.name,processType:s.processType})),c=rt(()=>{const{train:w,validation:S,test:x}=s.structuredOptions.datasetSplit;return w+S+x}),h=rt(()=>{const{train:w,validation:S,test:x}=s.unstructuredOptions.datasetSplit;return w+S+x}),u=rt(()=>s.processType==="structured"?s.structuredOptions:s.processType==="unstructured"?s.unstructuredOptions:null),f=rt(()=>{const w=u.value;return w?w.qualityFilterEnabled&&!w.filterLowQuality&&!w.filterShortContent?"开启质量筛选后,请至少选择一项筛选规则":w.qualityFilterEnabled&&w.filterShortContent&&w.minOutputLength<1?"最少字数必须大于 0":"":""}),g=rt(()=>s.unstructuredOptions.chunkOverlap>=s.unstructuredOptions.chunkSize?"重叠长度必须小于切片长度":s.unstructuredOptions.minChunkSize>s.unstructuredOptions.chunkSize?"最小切片长度不能大于切片长度":s.unstructuredOptions.chunkOverlap+s.unstructuredOptions.minChunkSize>s.unstructuredOptions.chunkSize?"重叠长度与最小切片长度之和不能大于切片长度":""),y={name:[{required:!0,message:"请输入任务名称",trigger:"blur"},{max:50,message:"任务名称不能超过 50 个字符",trigger:"blur"}],processType:[{required:!0,message:"请选择数据处理类型",trigger:"change"}]};async function v(){var w;if(o.value=!0,!r.value)return!1;try{if(await r.value.validate(),s.processType==="structured"&&c.value!==100)return gt.error("结构化数据处理:数据集划分比例总和必须为 100%"),!1;if(s.processType==="unstructured"){if(h.value!==100)return gt.error("非结构化数据处理:数据集划分比例总和必须为 100%"),!1;if(g.value)return(w=a.value)==null||w.revealValidation(),gt.error(g.value),!1}return f.value?(gt.error(f.value),!1):!0}catch{return gt.error("请完善标红的必填项"),!1}}return t({validate:v}),(w,S)=>{const x=Vu,A=db,_=hb;return O(),$("section",cS,[H(_,{ref_key:"formRef",ref:r,model:l.value,rules:y,"label-position":"top","scroll-to-error":""},{default:J(()=>[C("div",hS,[S[7]||(S[7]=C("h3",null,"基本信息",-1)),C("div",dS,[H(A,{label:"任务名称",prop:"name",required:""},{default:J(()=>[H(x,{"model-value":d.name,maxlength:"50","show-word-limit":"",placeholder:"例如:金融问答清洗任务","onUpdate:modelValue":S[0]||(S[0]=E=>i("update:name",E))},null,8,["model-value"])]),_:1}),H(A,{label:"任务描述(选填)"},{default:J(()=>[H(x,{"model-value":d.description,type:"textarea",rows:3,maxlength:"200","show-word-limit":"",placeholder:"简要说明本次数据处理目标","onUpdate:modelValue":S[1]||(S[1]=E=>i("update:description",E))},null,8,["model-value"])]),_:1})])]),C("div",uS,[C("div",fS,[C("div",null,[S[8]||(S[8]=C("h3",null,"处理类型",-1)),d.processTypeLocked?(O(),$("p",pS,"重新生成沿用原任务处理类型,不可修改")):(O(),$("p",gS,"类型会影响下一步支持的数据源格式和后续预览方式"))])]),H(A,{prop:"processType",class:"type-form-item"},{default:J(()=>[C("div",mS,[C("button",{type:"button",class:Se(["type-option",{"is-active":d.processType==="structured"}]),disabled:d.processTypeLocked,onClick:S[2]||(S[2]=E=>i("update:processType","structured"))},[...S[9]||(S[9]=[C("span",{class:"type-icon"},[C("i",{class:"fa fa-table"})],-1),C("span",null,[C("strong",null,"结构化数据"),C("small",null,"适用于 CSV、Excel、JSONL 等固定字段数据")],-1),C("i",{class:"fa fa-check-circle selection-mark"},null,-1)])],10,vS),C("button",{type:"button",class:Se(["type-option",{"is-active":d.processType==="unstructured"}]),disabled:d.processTypeLocked,onClick:S[3]||(S[3]=E=>i("update:processType","unstructured"))},[...S[10]||(S[10]=[C("span",{class:"type-icon"},[C("i",{class:"fa fa-file-text-o"})],-1),C("span",null,[C("strong",null,"非结构化数据"),C("small",null,"适用于文档、文本、问答等需要切分的数据")],-1),C("i",{class:"fa fa-check-circle selection-mark"},null,-1)])],10,bS),C("button",{type:"button",class:Se(["type-option",{"is-active":d.processType==="external"}]),disabled:d.processTypeLocked,onClick:S[4]||(S[4]=E=>i("update:processType","external"))},[...S[11]||(S[11]=[C("span",{class:"type-icon"},[C("i",{class:"fa fa-cloud-download"})],-1),C("span",null,[C("strong",null,"外来数据源拉取"),C("small",null,"适用于数据库、API 接口等需远程拉取的外部数据")],-1),C("i",{class:"fa fa-check-circle selection-mark"},null,-1)])],10,yS)])]),_:1})]),d.processType==="structured"?(O(),Ut(UA,{key:0,options:d.structuredOptions,"validation-attempted":o.value,"quality-validation-message":f.value,"onUpdate:options":S[5]||(S[5]=E=>i("update:structuredOptions",E))},null,8,["options","validation-attempted","quality-validation-message"])):ft("",!0),d.processType==="unstructured"?(O(),Ut(lS,{key:1,ref_key:"unstructuredOptionsPanelRef",ref:a,options:d.unstructuredOptions,"validation-attempted":o.value,"quality-validation-message":f.value,"chunk-validation-message":g.value,"onUpdate:options":S[6]||(S[6]=E=>i("update:unstructuredOptions",E))},null,8,["options","validation-attempted","quality-validation-message","chunk-validation-message"])):ft("",!0)]),_:1},8,["model"])])}}}),AS=_i(wS,[["__scopeId","data-v-d9b924a8"]]),SS={class:"model-selection-step","aria-labelledby":"model-selection-title"},xS={class:"form-section"},ES={class:"model-form-content"},CS=Ci({__name:"ModelSelectionStep",props:{options:{},models:{}},emits:["update:options"],setup(d,{expose:t,emit:e}){const s=d,i=e,r=et(!1),a=rt(()=>s.options.generationModelId===""?"请选择数据生成模型":"");function o(){return r.value=!0,a.value?(gt.error(a.value),!1):!0}return t({validate:o}),(l,c)=>(O(),$("section",SS,[C("div",xS,[c[1]||(c[1]=C("div",{class:"section-title-row"},[C("div",null,[C("h3",{id:"model-selection-title"},"大模型选择"),C("p",null,"选择本次数据生成使用的模型,并设置统一的输出要求")])],-1)),C("div",ES,[H(Zm,{options:d.options,models:d.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"])])])]))}}),_S=_i(CS,[["__scopeId","data-v-77825278"]]),kS={class:"source-upload-step","aria-labelledby":"source-upload-title"},TS={key:0,class:"form-section external-section"},PS={class:"external-form"},MS={class:"external-actions"},IS={key:0,class:"external-status is-connected",role:"status"},DS={key:0,class:"uploaded-file-list","aria-label":"已拉取数据列表"},LS={class:"uploaded-file-list-header"},FS={class:"uploaded-file-items"},OS={class:"file-main"},RS=["title"],NS=["title"],BS={class:"file-status",role:"status","aria-live":"polite"},$S={class:"file-progress-value"},US={key:0,class:"file-preview-error"},HS={key:1,class:"form-section upload-section"},zS={class:"section-title-row"},VS={class:"el-upload__tip"},GS={key:1,class:"uploaded-file-list","aria-label":"已上传文件列表"},jS={class:"uploaded-file-list-header"},WS={key:0,class:"upload-queue-status"},XS={class:"continue-upload"},qS={class:"uploaded-file-items"},YS={class:"file-main"},KS=["title"],QS=["title"],JS={class:"file-status",role:"status","aria-live":"polite"},ZS={class:"file-progress-value"},t1={key:0,class:"file-preview-error"},La=10,e1=Ci({__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(d,{emit:t}){const e=d,s=t,i=[{value:"postgresql",label:"PostgreSQL"}],r=[{value:"none",label:"免鉴权"},{value:"basic",label:"账号密码"}],a=et(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=rt(()=>e.processType==="external"),c=rt(()=>e.processType==="unstructured"?".txt,.md,.markdown,.pdf,.docx,.pptx,.json,.jsonl,.ndjson":".json,.jsonl,.ndjson,.csv,.tsv,.xlsx"),h=rt(()=>{const _=(a.value-1)*La;return e.uploadedFiles.slice(_,_+La)});Si(()=>e.uploadedFiles.length,(_,E)=>{const k=Math.max(1,Math.ceil(_/La));if(_>E){a.value=k;return}a.value=Math.min(a.value,k)}),Si(()=>e.processType,()=>{a.value=1});function u(_,E){s("update:externalSource",{...e.externalSource,[_]:E})}function f(_){return _?_>=1024*1024?`${(_/1024/1024).toFixed(1)} MB`:`${(_/1024).toFixed(1)} KB`:"0 KB"}function g(_){return _.status==="queued"||_.status==="uploading"?_.status:_.status==="failed"?"upload-failed":_.previewStatus==="processing"||_.previewStatus==="success"?_.previewStatus:_.previewStatus==="failed"?"preview-failed":"waiting"}function y(_){const E=g(_),k=E==="queued"||E==="uploading"||E==="upload-failed"?_.uploadProgress:E==="waiting"?100:_.previewProgress??0;return Math.min(100,Math.max(0,k))}function v(_){return g(_)==="processing"}function w(_){return v(_)?100:y(_)}function S(_){const E=g(_);if(E==="waiting"||E==="success")return"success";if(E==="upload-failed"||E==="preview-failed")return"exception"}function x(_){return v(_)?"处理中":g(_)==="waiting"?"已上传":`${y(_)}%`}function A(_){return _.uploadError||_.previewError}return(_,E)=>{const k=Np,P=Rp,L=db,I=Vu,D=Gu,R=hb,W=zu,Q=pb,Y=fb,yt=$w;return O(),$("section",kS,[l.value?(O(),$("div",TS,[E[18]||(E[18]=C("div",{class:"section-title-row"},[C("div",null,[C("h3",{id:"source-upload-title"},"数据源配置"),C("p",null,"配置并验证外部数据源,拉取成功后可在下一步预览数据内容")])],-1)),C("div",PS,[H(R,{"label-position":"top",class:"external-grid"},{default:J(()=>[H(L,{label:"数据源类型"},{default:J(()=>[H(P,{"model-value":d.externalSource.type,placeholder:"请选择数据源类型","aria-label":"数据源类型","onUpdate:modelValue":E[0]||(E[0]=T=>u("type",T))},{default:J(()=>[(O(),$(Ae,null,ii(i,T=>H(k,{key:T.value,label:T.label,value:T.value},null,8,["label","value"])),64))]),_:1},8,["model-value"])]),_:1}),H(L,{label:"地址 / URL"},{default:J(()=>[H(I,{"model-value":d.externalSource.url,placeholder:"例如:postgresql://db.example.com:5432/my_database","aria-label":"数据源地址或 URL","onUpdate:modelValue":E[1]||(E[1]=T=>u("url",T))},null,8,["model-value"])]),_:1}),H(L,{label:"鉴权方式"},{default:J(()=>[H(P,{"model-value":d.externalSource.authMode,"aria-label":"鉴权方式","onUpdate:modelValue":E[2]||(E[2]=T=>u("authMode",T))},{default:J(()=>[(O(),$(Ae,null,ii(r,T=>H(k,{key:T.value,label:T.label,value:T.value},null,8,["label","value"])),64))]),_:1},8,["model-value"])]),_:1}),d.externalSource.authMode==="basic"?(O(),Ut(L,{key:0,label:"账号"},{default:J(()=>[H(I,{"model-value":d.externalSource.username,autocomplete:"username",placeholder:"请输入账号","aria-label":"数据源账号","onUpdate:modelValue":E[3]||(E[3]=T=>u("username",T))},null,8,["model-value"])]),_:1})):ft("",!0),d.externalSource.authMode==="basic"?(O(),Ut(L,{key:1,label:"密码"},{default:J(()=>[H(I,{"model-value":d.externalSource.password,type:"password","show-password":"",autocomplete:"current-password",placeholder:"请输入密码","aria-label":"数据源密码","onUpdate:modelValue":E[4]||(E[4]=T=>u("password",T))},null,8,["model-value"])]),_:1})):ft("",!0),H(L,{label:"拉取条数"},{default:J(()=>[H(D,{"model-value":d.externalSource.limit,min:1,max:1e5,step:100,"controls-position":"right","aria-label":"数据拉取条数","onUpdate:modelValue":E[5]||(E[5]=T=>u("limit",Number(T)||0))},null,8,["model-value"])]),_:1}),H(L,{label:"只读查询语句",class:"external-query-field"},{default:J(()=>[H(I,{"model-value":d.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":E[6]||(E[6]=T=>u("query",T))},null,8,["model-value"]),E[12]||(E[12]=C("small",null,"只允许单条 SELECT 或 WITH 查询;后端会拒绝写入、DDL 和多语句。",-1))]),_:1})]),_:1}),C("div",MS,[H(W,{loading:d.externalPulling&&!d.externalConnected,disabled:d.externalPulling||d.previewBuilding,plain:"",onClick:E[7]||(E[7]=T=>s("test-connection"))},{default:J(()=>[...E[13]||(E[13]=[ut(" 测试连接 ",-1)])]),_:1},8,["loading","disabled"]),H(W,{type:"primary",loading:d.externalPulling,disabled:d.externalPulling||d.previewBuilding,onClick:E[8]||(E[8]=T=>s("pull-data"))},{default:J(()=>[...E[14]||(E[14]=[ut(" 拉取数据 ",-1)])]),_:1},8,["loading","disabled"]),d.externalConnected?(O(),$("span",IS,[...E[15]||(E[15]=[C("i",{class:"fa fa-check-circle","aria-hidden":"true"},null,-1),ut(" 连接正常 ",-1)])])):ft("",!0)]),d.uploadedFiles.length?(O(),$("section",DS,[C("div",LS,[C("span",null,"已拉取 "+X(d.uploadedFiles.length)+" 个数据集",1)]),C("div",FS,[(O(!0),$(Ae,null,ii(h.value,T=>(O(),$("div",{key:T.uid,class:"uploaded-file"},[E[17]||(E[17]=C("span",{class:"file-icon"},[C("i",{class:"fa fa-cloud-download","aria-hidden":"true"})],-1)),C("div",OS,[C("strong",{title:T.name},X(T.name),9,RS),C("span",null,[ut(X(f(T.size))+" ",1),T.count?(O(),$(Ae,{key:0},[ut(" · "+X(T.count.toLocaleString())+" 条",1)],64)):ft("",!0)])]),C("div",{class:Se(["file-preview-progress",`is-${g(T)}`]),title:A(T)},[C("div",BS,[C("span",null,[C("i",{class:Se(["fa",o[g(T)].icon]),"aria-hidden":"true"},null,2),ut(" "+X(o[g(T)].label),1)]),C("span",$S,X(x(T)),1)]),H(Q,{percentage:w(T),indeterminate:v(T),duration:1.5,"stroke-width":5,"show-text":!1,status:S(T),"aria-valuenow":v(T)?void 0:y(T),"aria-valuetext":v(T)?"正在切分,进度未知":x(T)},null,8,["percentage","indeterminate","status","aria-valuenow","aria-valuetext"]),A(T)?(O(),$("small",US,X(A(T)),1)):ft("",!0)],10,NS),H(W,{link:"",type:"danger",disabled:d.previewBuilding||T.status==="uploading","aria-label":`删除数据集 ${T.name}`,onClick:j=>s("remove-file",T.uid)},{default:J(()=>[...E[16]||(E[16]=[ut(" 删除 ",-1)])]),_:1},8,["disabled","aria-label","onClick"])]))),128))]),d.uploadedFiles.length>La?(O(),Ut(Y,{key:0,"current-page":a.value,"onUpdate:currentPage":E[9]||(E[9]=T=>a.value=T),"page-size":La,total:d.uploadedFiles.length,"pager-count":5,small:"",background:"",layout:"prev, pager, next",class:"uploaded-file-pagination","aria-label":"已拉取数据分页"},null,8,["current-page","total"])):ft("",!0)])):ft("",!0)])])):(O(),$("div",HS,[C("div",zS,[E[20]||(E[20]=C("div",null,[C("h3",{id:"source-upload-title"},"源数据上传"),C("p",null,"上传后可在下一步检查内容和切分效果,支持同时添加多个文件")],-1)),d.uploadedFiles.length===0?(O(),Ut(W,{key:0,link:"",type:"primary",disabled:d.previewBuilding,onClick:E[10]||(E[10]=T=>s("use-sample"))},{default:J(()=>[...E[19]||(E[19]=[ut(" 使用示例数据 ",-1)])]),_:1},8,["disabled"])):ft("",!0)]),d.uploadedFiles.length===0?(O(),Ut(yt,{key:0,drag:"",multiple:"",accept:c.value,disabled:d.previewBuilding,"auto-upload":!1,"show-file-list":!1,"on-change":T=>s("file-change",T),"aria-label":"选择或拖拽源数据文件"},{tip:J(()=>[C("div",VS,X(d.processType==="unstructured"?"支持 TXT、MD、MARKDOWN、PDF、DOCX、PPTX、JSON、JSONL、NDJSON;旧版 DOC/PPT 请先转换,单文件不超过 200MB":"支持 JSON、JSONL、NDJSON、CSV、TSV、XLSX;旧版 XLS 请先转换,单文件不超过 200MB"),1)]),default:J(()=>[E[21]||(E[21]=C("i",{class:"fa fa-cloud-upload upload-icon","aria-hidden":"true"},null,-1)),E[22]||(E[22]=C("div",{class:"el-upload__text"},[ut("拖拽文件到此处,或"),C("em",null,"点击选择文件")],-1))]),_:1},8,["accept","disabled","on-change"])):(O(),$("section",GS,[C("div",jS,[C("span",null,[ut(" 已选择 "+X(d.uploadedFiles.length)+" 个文件 ",1),d.sourceUploading?(O(),$("small",WS," · 正在逐个上传")):ft("",!0)]),C("div",XS,[H(yt,{multiple:"",accept:c.value,disabled:d.previewBuilding,"auto-upload":!1,"show-file-list":!1,"on-change":T=>s("file-change",T),"aria-label":"继续添加源数据文件"},{default:J(()=>[H(W,{size:"small",type:"primary",disabled:d.previewBuilding},{default:J(()=>[...E[23]||(E[23]=[ut("继续上传",-1)])]),_:1},8,["disabled"])]),_:1},8,["accept","disabled","on-change"])])]),C("div",qS,[(O(!0),$(Ae,null,ii(h.value,T=>(O(),$("div",{key:T.uid,class:"uploaded-file"},[E[25]||(E[25]=C("span",{class:"file-icon"},[C("i",{class:"fa fa-file-text-o","aria-hidden":"true"})],-1)),C("div",YS,[C("strong",{title:T.name},X(T.name),9,KS),C("span",null,[ut(X(f(T.size))+" ",1),T.count?(O(),$(Ae,{key:0},[ut(" · "+X(T.count.toLocaleString())+" 条",1)],64)):ft("",!0)])]),C("div",{class:Se(["file-preview-progress",`is-${g(T)}`]),title:A(T)},[C("div",JS,[C("span",null,[C("i",{class:Se(["fa",o[g(T)].icon]),"aria-hidden":"true"},null,2),ut(" "+X(o[g(T)].label),1)]),C("span",ZS,X(x(T)),1)]),H(Q,{percentage:w(T),indeterminate:v(T),duration:1.5,"stroke-width":5,"show-text":!1,status:S(T),"aria-valuenow":v(T)?void 0:y(T),"aria-valuetext":v(T)?"正在切分,进度未知":x(T)},null,8,["percentage","indeterminate","status","aria-valuenow","aria-valuetext"]),A(T)?(O(),$("small",t1,X(A(T)),1)):ft("",!0)],10,QS),H(W,{link:"",type:"danger",disabled:d.previewBuilding||T.status==="uploading","aria-label":`删除文件 ${T.name}`,onClick:j=>s("remove-file",T.uid)},{default:J(()=>[...E[24]||(E[24]=[ut(" 删除 ",-1)])]),_:1},8,["disabled","aria-label","onClick"])]))),128))]),d.uploadedFiles.length>La?(O(),Ut(Y,{key:0,"current-page":a.value,"onUpdate:currentPage":E[11]||(E[11]=T=>a.value=T),"page-size":La,total:d.uploadedFiles.length,"pager-count":5,small:"",background:"",layout:"prev, pager, next",class:"uploaded-file-pagination","aria-label":"已上传文件分页"},null,8,["current-page","total"])):ft("",!0)]))]))])}}}),s1=_i(e1,[["__scopeId","data-v-77d607a9"]]),ti=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),br=[1/0,1/0,-1/0,-1/0],Ga=new Float32Array(br),gg=[.001,0,0,.001,0,0],rg=1.35,Os="http://www.w3.org/2000/svg",Zs={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},_r={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Nl="pdfjs_internal_id_",Qh="pdfjs_internal_editor_",ct={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},pt={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},i1={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Ee={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},df={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},le={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},Dl={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Bp={ERRORS:0,WARNINGS:1,INFOS:5},Ji={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},n1={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let $p=Bp.WARNINGS;function r1(d){Number.isInteger(d)&&($p=d)}function a1(){return $p}function Up(d){$p>=Bp.INFOS&&console.info(`Info: ${d}`)}function ht(d){$p>=Bp.WARNINGS&&console.warn(`Warning: ${d}`)}function Ct(d){throw new Error(d)}function ae(d,t){d||Ct(t)}function o1(d){switch(d==null?void 0:d.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function mb(d,t=null,e=null){if(!d)return null;if(e&&typeof d=="string"){if(e.addDefaultProtocol&&d.startsWith("www.")){const i=d.match(/\./g);(i==null?void 0:i.length)>=2&&(d=`http://${d}`)}if(e.tryConvertEncoding)try{d=h1(d)}catch{}}const s=t?URL.parse(d,t):URL.parse(d);return o1(s)?s:null}function vb(d,t,e=!1){const s=URL.parse(d);return s?(s.hash=t,s.href):e&&mb(d,"http://example.com")?d.split("#",1)[0]+`${t?`#${t}`:""}`:""}function mg(d){return d.substring(d.lastIndexOf("/")+1)}function ot(d,t,e,s=!1){return Object.defineProperty(d,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 vg extends Tl{constructor(t,e){super(t,"PasswordException"),this.code=e}}class ag extends Tl{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class bg extends Tl{constructor(t){super(t,"InvalidPDFException")}}class Zf extends Tl{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class l1 extends Tl{constructor(t){super(t,"FormatError")}}class ka extends Tl{constructor(t){super(t,"AbortException")}}function c1(d){(typeof d!="object"||(d==null?void 0:d.length)===void 0)&&Ct("Invalid argument for bytesToString");const t=d.length,e=8192;if(t"u")return ot(this,"isAlphaColorInputSupported",!1);const t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",ot(this,"isAlphaColorInputSupported",t.value!=="#ff0000")}static get isBackdropFilterSupported(){return ot(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}}var yr,uf,yg;class B{static get hexNums(){return ot(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 u=t[s+h],f=t[s+h+1];t[s+h]=u*i+f*a+l,t[s+h+1]=u*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],u=t[1],f=t[2],g=t[3];let y=i*h+l,v=y,w=i*f+l,S=w,x=o*u+c,A=x,_=o*g+c,E=_;if(r!==0||a!==0){const k=r*h,P=r*f,L=a*u,I=a*g;y+=L,S+=L,w+=I,v+=I,x+=k,E+=k,_+=P,A+=P}s[0]=Math.min(s[0],y,w,v,S),s[1]=Math.min(s[1],x,_,A,E),s[2]=Math.max(s[2],y,w,v,S),s[3]=Math.max(s[3],x,_,A,E)}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,u=Math.sqrt(h**2-(o*c-l**2));e[0]=Math.sqrt(h+u||1),e[1]=Math.sqrt(h-u||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),b(this,yr,yg).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),b(this,yr,yg).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)}}yr=new WeakSet,uf=function(t,e,s,i,r,a,o,l,c,h){if(c<=0||c>=1)return;const u=1-c,f=c*c,g=f*c,y=u*(u*(u*t+3*c*e)+3*f*s)+g*i,v=u*(u*(u*r+3*c*a)+3*f*o)+g*l;h[0]=Math.min(h[0],y),h[1]=Math.min(h[1],v),h[2]=Math.max(h[2],y),h[3]=Math.max(h[3],v)},yg=function(t,e,s,i,r,a,o,l,c,h,u,f){if(Math.abs(c)<1e-12){Math.abs(h)>=1e-12&&b(this,yr,uf).call(this,t,e,s,i,r,a,o,l,-u/h,f);return}const g=h**2-4*u*c;if(g<0)return;const y=Math.sqrt(g),v=2*c;b(this,yr,uf).call(this,t,e,s,i,r,a,o,l,(-h+y)/v,f),b(this,yr,uf).call(this,t,e,s,i,r,a,o,l,(-h-y)/v,f)},m(B,yr);function h1(d){return decodeURIComponent(escape(d))}let og=null,Mv=null;function d1(d){return og||(og=/([\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,Mv=new Map([["ſt","ſt"]])),d.replaceAll(og,(t,e,s)=>e?e.normalize("NFKC"):Mv.get(s))}function bb(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const d=new Uint8Array(32);return crypto.getRandomValues(d),c1(d)}function u1(d,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,i,...r]=e;if(!d(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 ju=()=>[],tv=()=>new Map,wg=()=>Object.create(null);function Zt(d,t,e){return Math.min(Math.max(d,t),e)}class Wu{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,u,f,g;switch(i%=360,i<0&&(i+=360),i){case 180:h=-1,u=0,f=0,g=1;break;case 90:h=0,u=1,f=1,g=0;break;case 270:h=0,u=-1,f=-1,g=0;break;case 0:h=1,u=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,v,w,S;h===0?(y=Math.abs(c-t[1])*s+r,v=Math.abs(l-t[0])*s+a,w=(t[3]-t[1])*s,S=(t[2]-t[0])*s):(y=Math.abs(l-t[0])*s+r,v=Math.abs(c-t[1])*s+a,w=(t[2]-t[0])*s,S=(t[3]-t[1])*s),this.transform=[h*s,u*s,f*s,g*s,y-h*s*l-f*s*c,v-u*s*l-g*s*c],this.width=w,this.height=S}get rawDims(){const t=this.viewBox;return ot(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 Wu({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 Jh{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(Jh.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 yb{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 u,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&&Jh.shouldBuildText(i.name)&&c.push(g)}return{textDivs:c}}const h=[[i,-1,a]];for(;h.length>0;){const[g,y,v]=h.at(-1);if(y+1===g.children.length){h.pop();continue}const w=g.children[++h.at(-1)[1]];if(w===null)continue;const{name:S}=w;if(S==="#text"){const A=document.createTextNode(w.value);c.push(A),v.append(A);continue}const x=(u=w==null?void 0:w.attributes)!=null&&u.xmlns?document.createElementNS(w.attributes.xmlns,S):document.createElement(S);if(v.append(x),w.attributes&&this.setAttributes({html:x,element:w,storage:e,intent:r,linkService:s}),((f=w.children)==null?void 0:f.length)>0)h.push([w,-1,x]);else if(w.value){const A=document.createTextNode(w.value);o&&Jh.shouldBuildText(S)&&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 Wu({viewBox:[0,0,parseInt(i,10),parseInt(r,10)],userUnit:1,scale:e,rotation:s})}}const Ha=class Ha{};M(Ha,"CSS",96),M(Ha,"PDF",72),M(Ha,"PDF_TO_CSS_UNITS",Ha.CSS/Ha.PDF);let Ta=Ha;async function ev(d,t="text"){if(Wh(d,document.baseURI)){const e=await fetch(d);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",d,!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 sv extends Tl{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function zp(d){const t=d.length;let e=0;for(;e{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})(d);if(!s)return t;const i=o=>{try{let l=decodeURIComponent(o);return l.includes("/")&&(l=mg(l),l.length===4&&r.test(l))?o:l}catch{return o}},r=/\.pdf$/i,a=mg(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 kr;class Iv{constructor(){m(this,kr,new Map);M(this,"times",[])}time(t){n(this,kr).has(t)&&ht(`Timer is already running for ${t}`),n(this,kr).set(t,Date.now())}timeEnd(t){n(this,kr).has(t)||ht(`Timer has not been started for ${t}`),this.times.push({name:t,start:n(this,kr).get(t),end:Date.now()}),n(this,kr).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("")}}kr=new WeakMap;function Wh(d,t){const e=t?URL.parse(d,t):URL.parse(d);return/https?:/.test((e==null?void 0:e.protocol)??"")}function Ei(d){d.preventDefault()}function re(d){d.preventDefault(),d.stopPropagation()}var sd;class tp{static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;n(this,sd)||p(this,sd,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?"));const e=n(this,sd).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 u=parseInt(e[9],10)||0;return u=u>=0&&u<=59?u:0,c==="-"?(a+=h,o+=u):c==="+"&&(a-=h,o-=u),new Date(Date.UTC(s,i,r,a,o,l))}}sd=new WeakMap,m(tp,sd);function Xu(d){if(d.startsWith("#")){const e=d.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(d.startsWith("rgb(")){const[e,s,i]=d.slice(4,-1).split(",").map(r=>parseInt(r,10));return[e,s,i,1]}if(d.startsWith("rgba(")){const e=d.slice(5,-1).split(",");return[parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10),parseFloat(e[3])]}const t=d.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 qu(d){const t=Xu(d);return t?t.slice(0,3):(ht(`Not a valid color format: "${d}"`),[0,0,0])}function g1(d){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const e of d.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;d.set(e,qu(s))}t.remove()}function Xt(d){const{a:t,b:e,c:s,d:i,e:r,f:a}=d.getTransform();return[t,e,s,i,r,a]}function Yi(d){const{a:t,b:e,c:s,d:i,e:r,f:a}=d.getTransform().invertSelf();return[t,e,s,i,r,a]}function xl(d,t,e=!1,s=!0){if(t instanceof Wu){const{pageWidth:i,pageHeight:r}=t.rawDims,{style:a}=d,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&&d.setAttribute("data-main-rotation",t.rotation)}class _n{constructor(){const{pixelRatio:t}=_n;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=_n.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 Ag=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class m1{static get isDarkMode(){var t;return ot(this,"isDarkMode",!!((t=window==null?void 0:window.matchMedia)!=null&&t.call(window,"(prefers-color-scheme: dark)").matches))}}class v1{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(),ot(this,"commentForegroundColor",qu(s))}}function b1(d,t){t=Zt(t??1,0,1);const e=255*(1-t);return d.map(s=>Math.round(s*t+e))}function Dv(d,t){const e=d[0]/255,s=d[1]/255,i=d[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+(si?(s+.05)/(i+.05):(i+.05)/(s+.05)}const Ov=new Map;function y1(d,t){const e=d[0]+d[1]*256+d[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776;let s=Ov.get(e);if(s)return s;const i=new Float32Array(9),r=i.subarray(0,3),a=i.subarray(3,6);Dv(d,a);const o=i.subarray(6,9);Dv(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]),Fv(a,o,r)f;){const g=a[2]=(h+u)/2;l===Fv(a,o,r){e.delete()},{signal:e._signal}),n(this,li).append(s)}async addAltText(t){const e=await t.render();b(this,Ye,Ll).call(this,e),n(this,li).append(e,n(this,Ye,Eh)),p(this,id,t)}addComment(t,e=null){if(n(this,Mr))return;const s=t.renderForToolbar();if(!s)return;b(this,Ye,Ll).call(this,s);const i=p(this,Hl,n(this,Ye,Eh));e?(n(this,li).insertBefore(s,e),n(this,li).insertBefore(i,e)):n(this,li).append(s,i),p(this,Mr,t),t.toolbar=this}addColorPicker(t){if(n(this,Pr))return;p(this,Pr,t);const e=t.renderButton();b(this,Ye,Ll).call(this,e),n(this,li).append(e,n(this,Ye,Eh))}async addEditSignatureButton(t){const e=p(this,zl,await t.renderEditButton(n(this,oi)));b(this,Ye,Ll).call(this,e),n(this,li).append(e,n(this,Ye,Eh))}removeButton(t){var e,s;switch(t){case"comment":(e=n(this,Mr))==null||e.removeToolbarCommentButton(),p(this,Mr,null),(s=n(this,Hl))==null||s.remove(),p(this,Hl,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,li).querySelector(s);i&&t==="comment"&&this.addComment(e,i)}updateEditSignatureButton(t){n(this,zl)&&(n(this,zl).title=t)}remove(){var t;n(this,Tr).remove(),(t=n(this,Pr))==null||t.destroy(),p(this,Pr,null)}};Tr=new WeakMap,Pr=new WeakMap,oi=new WeakMap,li=new WeakMap,id=new WeakMap,Mr=new WeakMap,Hl=new WeakMap,zl=new WeakMap,nd=new WeakMap,cp=new WeakSet,Sb=function(t){t.stopPropagation()},Ye=new WeakSet,xb=function(t){n(this,oi)._focusEventsAllowed=!1,re(t)},Eb=function(t){n(this,oi)._focusEventsAllowed=!0,re(t)},Ll=function(t){const e=n(this,oi)._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",b(this,Ye,xb).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",b(this,Ye,Eb).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Ei,{signal:e}),!0)},Eh=function(){const t=document.createElement("div");return t.className="divider",t},m(In,cp),m(In,nd,null);let xg=In;var rd,ja,Ln,Ar,Cb,_b,Eg;class w1{constructor(t){m(this,Ar);m(this,rd,null);m(this,ja,null);m(this,Ln);p(this,Ln,t)}show(t,e,s){const[i,r]=b(this,Ar,_b).call(this,e,s),{style:a}=n(this,ja)||p(this,ja,b(this,Ar,Cb).call(this));t.append(n(this,ja)),a.insetInlineEnd=`${100*i}%`,a.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){n(this,ja).remove()}}rd=new WeakMap,ja=new WeakMap,Ln=new WeakMap,Ar=new WeakSet,Cb=function(){const t=p(this,ja,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar");const e=n(this,Ln)._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",Ei,{signal:e});const s=p(this,rd,document.createElement("div"));return s.className="buttons",t.append(s),n(this,Ln).hasCommentManager()&&b(this,Ar,Eg).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{n(this,Ln).commentSelection("floating_button")}),b(this,Ar,Eg).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{n(this,Ln).highlightSelection("floating_button")}),t},_b=function(t,e){let s=0,i=0;for(const r of t){const a=r.y+r.height;if(as){i=o,s=a;continue}e?o>i&&(i=o):o=1}static clearPointerType(){p(Ot,qa,null)}static clearPointerIds(){p(Ot,Wa,NaN),p(Ot,Xa,null)}static clearTimeStamp(){p(Ot,Vl,NaN)}};Wa=new WeakMap,Xa=new WeakMap,Vl=new WeakMap,qa=new WeakMap,m(Ot,Wa,NaN),m(Ot,Xa,null),m(Ot,Vl,NaN),m(Ot,qa,null);let Ze=Ot;var hp;class S1{constructor(){m(this,hp,0)}get id(){return`${Qh}${Yt(this,hp)._++}`}}hp=new WeakMap;var Gl,ad,ts,jl,ff;const dv=class dv{constructor(){m(this,jl);m(this,Gl,bb());m(this,ad,0);m(this,ts,null)}static get _isSVGFittingCanvas(){const t=`data:image/svg+xml;charset=UTF-8,`,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 ot(this,"_isSVGFittingCanvas",r)}async getFromFile(t){const{lastModified:e,name:s,size:i,type:r}=t;return b(this,jl,ff).call(this,`${e}_${s}_${i}_${r}`,t)}async getFromUrl(t){return b(this,jl,ff).call(this,t,t)}async getFromBlob(t,e){const s=await e;return b(this,jl,ff).call(this,t,s)}async getFromId(t){n(this,ts)||p(this,ts,new Map);const e=n(this,ts).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,ts)||p(this,ts,new Map);let s=n(this,ts).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,Gl)}_${Yt(this,ad)._++}`,refCounter:1,isSvg:!1},n(this,ts).set(t,s),n(this,ts).set(s.id,s),s}getSvgUrl(t){const e=n(this,ts).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var i;n(this,ts)||p(this,ts,new Map);const e=n(this,ts).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,Gl)}_`)}};Gl=new WeakMap,ad=new WeakMap,ts=new WeakMap,jl=new WeakSet,ff=async function(t,e){n(this,ts)||p(this,ts,new Map);let s=n(this,ts).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,Gl)}_${Yt(this,ad)._++}`,refCounter:0,isSvg:!1});let i;if(typeof e=="string"?(s.url=e,i=await ev(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const r=dv._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 u=s.svgUrl=a.result;o.src=await r?`${u}#svgView(preserveAspectRatio(none))`:u},o.onerror=a.onerror=h});a.readAsDataURL(i),await l}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){ht(i),s=null}return n(this,ts).set(t,s),s&&n(this,ts).set(s.id,s),s};let Cg=dv;var ge,Ir,od,ie;class x1{constructor(t=128){m(this,ge,[]);m(this,Ir,!1);m(this,od);m(this,ie,-1);p(this,od,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:r=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(i&&t(),n(this,Ir))return;const l={cmd:t,undo:e,post:s,type:r};if(n(this,ie)===-1){n(this,ge).length>0&&(n(this,ge).length=0),p(this,ie,0),n(this,ge).push(l);return}if(a&&n(this,ge)[n(this,ie)].type===r){o&&(l.undo=n(this,ge)[n(this,ie)].undo),n(this,ge)[n(this,ie)]=l;return}const c=n(this,ie)+1;c===n(this,od)?n(this,ge).splice(0,1):(p(this,ie,c),c=0;e--)if(n(this,ge)[e].type!==t){n(this,ge).splice(e+1,n(this,ie)-e),p(this,ie,e);return}n(this,ge).length=0,p(this,ie,-1)}}destroy(){p(this,ge,null)}}ge=new WeakMap,Ir=new WeakMap,od=new WeakMap,ie=new WeakMap;var gh,Tb,Pb;const As=class As{constructor(t){var s;this.callbacks=new Map;const{isMac:e}=Ht.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,u]=b(s=As,gh,Tb).call(s,c);h!==null&&this.callbacks.getOrInsertComputed(h,ju).push({callback:r,options:a,modifiers:u})}}}exec(t,e){var h;let s=this.callbacks.get(e.key);if(!s){if(/^[a-z]$/i.test(e.key))return;const u=b(h=As,gh,Pb).call(h,e.code);if(u===null||u===e.key||(s=this.callbacks.get(u),!s))return}const i=(e.altKey?As.ALT:0)|(e.ctrlKey?As.CTRL:0)|(e.metaKey?As.META:0)|(e.shiftKey?As.SHIFT:0),r=s.find(u=>u.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||re(e))}};gh=new WeakSet,Tb=function(t){let e=null,s=0;for(let i of t.split("+")){if(i=i.trim(),!i)continue;const r=i.toUpperCase(),a=As[r];if(a){s|=a;continue}if(e!==null){ht(`KeyboardManager: multiple keys in shortcut "${t}"`);break}e=r==="SPACE"?" ":i}return e===null&&ht(`KeyboardManager: no key found in shortcut "${t}"`),[e,s]},Pb=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(As,gh),M(As,"ALT",1),M(As,"CTRL",2),M(As,"META",4),M(As,"SHIFT",8);let El=As;const dp=class dp{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return g1(t),ot(this,"_colors",t)}convert(t){const e=qu(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 dp._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?B.makeHexColor(...e):t}};M(dp,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let _g=dp;var Wl,Rs,Xl,he,ne,ql,Yl,cs,Kl,ci,Pe,Dr,Lr,Fr,Or,Zi,hi,Ya,ld,cd,Ql,hd,tn,Rr,Jl,Nr,en,up,Fn,Zl,dd,Br,Ka,tc,$r,ud,we,Rt,On,Ur,Hr,fd,ec,pd,zr,sn,Rn,gd,md,di,G,pf,kg,Mb,Ib,Db,Ch,Lb,Fb,Ob,Tg,Rb,Nb,Bb,$b,os,Pn,Ub,Hb,Pg,zb,_h,Mg;const Bl=class Bl{constructor(t,e,s,i,r,a,o,l,c,h,u,f,g,y,v,w){m(this,G);m(this,Wl,new AbortController);m(this,Rs,null);m(this,Xl,null);m(this,he,new Map);m(this,ne,new Map);m(this,ql,null);m(this,Yl,null);m(this,cs,null);m(this,Kl,null);m(this,ci,new x1);m(this,Pe,null);m(this,Dr,null);m(this,Lr,null);m(this,Fr,0);m(this,Or,new Set);m(this,Zi,null);m(this,hi,null);m(this,Ya,new Set);M(this,"_editorUndoBar",null);m(this,ld,!1);m(this,cd,!1);m(this,Ql,!1);m(this,hd,null);m(this,tn,null);m(this,Rr,null);m(this,Jl,null);m(this,Nr,!1);m(this,en,null);m(this,up,new S1);m(this,Fn,!1);m(this,Zl,!1);m(this,dd,!1);m(this,Br,null);m(this,Ka,null);m(this,tc,null);m(this,$r,null);m(this,ud,null);m(this,we,ct.NONE);m(this,Rt,new Set);m(this,On,null);m(this,Ur,null);m(this,Hr,null);m(this,fd,null);m(this,ec,null);m(this,pd,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});m(this,zr,[0,0]);m(this,sn,null);m(this,Rn,null);m(this,gd,null);m(this,md,null);m(this,di,null);const S=this._signal=n(this,Wl).signal;p(this,Rn,t),p(this,gd,e),p(this,md,s),p(this,Yl,i),p(this,Pe,r),p(this,Ur,a),p(this,ec,l),this._eventBus=o;const x={signal:S,...lg};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,Zl,!0)},{capture:!0,signal:S}),window.addEventListener("pointerup",()=>{p(this,Zl,!1)},{capture:!0,signal:S}),window.addEventListener("beforeunload",b(this,G,Mb).bind(this),{capture:!0,signal:S}),b(this,G,Lb).call(this),b(this,G,$b).call(this),b(this,G,Tg).call(this),p(this,cs,l.annotationStorage),p(this,hd,l.filterFactory),p(this,Hr,c),p(this,Jl,h||null),p(this,ld,u),p(this,cd,f),p(this,Ql,g),p(this,ud,y||null),this.viewParameters={realScale:Ta.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=v||null,this._supportsPinchToZoom=w!==!1,r==null||r.setSidebarUiManager(this)}static get _keyboardManager(){const t=Bl.prototype,e=a=>n(a,Rn).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 ot(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,Rn).contains(o)&&!a.isEnterHandled}],[["Space"],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&n(a,Rn).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,di))==null||t.resolve(),p(this,di,null),(e=n(this,Wl))==null||e.abort(),p(this,Wl,null),this._signal=null;for(const h of n(this,ne).values())h.destroy();n(this,ne).clear(),n(this,he).clear(),n(this,Ya).clear(),(s=n(this,$r))==null||s.clear(),p(this,Rs,null),n(this,Rt).clear(),n(this,ci).destroy(),(i=n(this,Yl))==null||i.destroy(),(r=n(this,Pe))==null||r.destroy(),(a=n(this,Ur))==null||a.destroy(),(o=n(this,en))==null||o.hide(),p(this,en,null),(l=n(this,tc))==null||l.destroy(),p(this,tc,null),p(this,Xl,null),n(this,tn)&&(clearTimeout(n(this,tn)),p(this,tn,null)),n(this,sn)&&(clearTimeout(n(this,sn)),p(this,sn,null)),(c=this._editorUndoBar)==null||c.destroy(),p(this,ec,null)}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return n(this,ud)}get useNewAltTextFlow(){return n(this,cd)}get useNewAltTextWhenAddingImage(){return n(this,Ql)}get hcmFilter(){return ot(this,"hcmFilter",n(this,Hr)?n(this,hd).addHCMFilter(n(this,Hr).foreground,n(this,Hr).background):"none")}get direction(){return ot(this,"direction",getComputedStyle(n(this,Rn)).direction)}get _highlightColors(){return ot(this,"_highlightColors",n(this,Jl)?new Map(n(this,Jl).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 ot(this,"highlightColors",null);const e=new Map,s=!!n(this,Hr);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 ot(this,"highlightColors",e)}get highlightColorNames(){return ot(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,Lr,t)}setMainHighlightColorPicker(t){p(this,tc,t)}editAltText(t,e=!1){var s;(s=n(this,Yl))==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,ne).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,ne).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,lg),await s}getSignature(t){var e;(e=n(this,Ur))==null||e.getSignature({uiManager:this,editor:t})}get signatureManager(){return n(this,Ur)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal,...lg}),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,Ql,e);break}}onPageChanging({pageNumber:t}){p(this,Fr,t-1)}deletePage(t){for(const e of this.getEditors(t))e.remove();n(this,ne).delete(t),n(this,Fr)===t&&p(this,Fr,0)}focusMainContainer(){n(this,Rn).focus()}findParent(t,e){for(const s of n(this,ne).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,gd).classList.toggle("noUserSelect",t)}addShouldRescale(t){n(this,Ya).add(t)}removeShouldRescale(t){n(this,Ya).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*Ta.PDF_TO_CSS_UNITS;for(const s of n(this,Ya))s.onScaleChanging();(e=n(this,Lr))==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=b(this,G,pf).call(this,s).closest(".textLayer"),u=this.getSelectionBoxes(h);if(!u)return;s.empty();const f=b(this,G,kg).call(this,h),g=n(this,we)===ct.NONE,y=()=>{const v=f==null?void 0:f.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:u,anchorNode:i,anchorOffset:r,focusNode:a,focusOffset:o,text:l});g&&this.showAllEditors("highlight",!0,!0),e&&(v==null||v.editComment())};if(g){this.switchToMode(ct.HIGHLIGHT,y);return}y()}commentSelection(t=""){this.highlightSelection(t,!0)}getAndRemoveDataFromAnnotationStorage(t){if(!n(this,cs))return null;const e=`${Qh}${t}`,s=n(this,cs).getRawValue(e);return s&&n(this,cs).remove(e),s}addToAnnotationStorage(t){!t.isEmpty()&&n(this,cs)&&!n(this,cs).has(t.id)&&n(this,cs).setValue(t.id,t)}a11yAlert(t,e=null){const s=n(this,md);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,Nr)&&(p(this,Nr,!1),b(this,G,Ch).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of n(this,Rt))if(e.div.contains(t)){p(this,Ka,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!n(this,Ka))return;const[t,e]=n(this,Ka);p(this,Ka,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){b(this,G,Tg).call(this),this.setEditingState(!0)}removeEditListeners(){b(this,G,Rb).call(this),this.setEditingState(!1)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of n(this,hi))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,hi))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=n(this,Rs))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];for(const i of n(this,Rt)){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,hi))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){ht(`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)b(this,G,Pg).call(this,l);b(this,G,Mg).call(this,r)},o=()=>{for(const l of r)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(r){ht(`paste: "${r.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),n(this,we)!==ct.NONE&&!this.isEditorHandlingKeyboard&&Bl._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,n(this,Nr)&&(p(this,Nr,!1),b(this,G,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,ql).get(t);s&&(s.pageIndex=e,n(this,ne).set(e,s),n(this,Fn)?s.enable():s.disable())}startUpdatePages(){p(this,ql,new Map(n(this,ne))),n(this,ne).clear()}endUpdatePages(){p(this,ql,null)}clonePage(t,e){for(const s of this.getEditors(t)){const i=s.serialize(s.mode!==ct.HIGHLIGHT);i&&(i.pageIndex=e,i.id=this.getId(),i.isClone=!0,delete i.popupRef,n(this,cs).setValue(i.id,i))}}findClonesForPage(t){const e=[],{pageIndex:s}=t;for(const[i,r]of n(this,cs))r.pageIndex===s&&r.isClone&&(n(this,cs).remove(i),e.push(t.deserialize(r).then(a=>{a&&(a.isClone=!0,t.addOrRebuild(a))})));return Promise.all(e)}setEditingState(t){t?(b(this,G,Fb).call(this),b(this,G,Nb).call(this),b(this,G,os).call(this,{isEditing:n(this,we)!==ct.NONE,isEmpty:b(this,G,_h).call(this),hasSomethingToUndo:n(this,ci).hasSomethingToUndo(),hasSomethingToRedo:n(this,ci).hasSomethingToRedo(),hasSelectedEditor:!1})):(b(this,G,Ob).call(this),b(this,G,Bb).call(this),b(this,G,os).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!n(this,hi)){p(this,hi,t);for(const e of n(this,hi))b(this,G,Pn).call(this,e.defaultPropertiesToUpdate)}}getId(){return n(this,up).id}get currentLayer(){return n(this,ne).get(n(this,Fr))}getLayer(t){return n(this,ne).get(t)}get currentPageIndex(){return n(this,Fr)}addLayer(t){n(this,ne).set(t.pageIndex,t),n(this,Fn)?t.enable():t.disable()}removeLayer(t){n(this,ne).delete(t.pageIndex)}async updateMode(t,e=null,s=!1,i=!1,r=!1,a=!1){var o,l,c,h,u,f;if(n(this,we)!==t&&!(n(this,di)&&(await n(this,di).promise,!n(this,di)))){if(p(this,di,Promise.withResolvers()),(o=n(this,Lr))==null||o.commitOrRemove(),n(this,we)===ct.POPUP&&((l=n(this,Pe))==null||l.hideSidebar()),(c=n(this,Pe))==null||c.destroyPopup(),p(this,we,t),t===ct.NONE){this.setEditingState(!1),b(this,G,Hb).call(this);for(const g of n(this,he).values())g.hideStandaloneCommentButton();(h=this._editorUndoBar)==null||h.hide(),this.toggleComment(null),n(this,di).resolve();return}for(const g of n(this,he).values())g.addStandaloneCommentButton();t===ct.SIGNATURE&&await((u=n(this,Ur))==null?void 0:u.loadSignatures()),s&&Ze.clearPointerType(),this.setEditingState(!0),await b(this,G,Ub).call(this),this.unselectAll();for(const g of n(this,ne).values())g.updateMode(t);if(t===ct.POPUP){n(this,Xl)||p(this,Xl,await n(this,ec).getAnnotationsByType(new Set(n(this,hi).map(v=>v._editorType))));const g=new Set,y=[];for(const v of n(this,he).values()){const{annotationElementId:w,hasComment:S,deleted:x}=v;w&&g.add(w),S&&!x&&y.push(v.getData())}for(const v of n(this,Xl)){const{id:w,popupRef:S,contentsObj:x}=v;S&&(x!=null&&x.str)&&!g.has(w)&&!n(this,Or).has(w)&&y.push(v)}(f=n(this,Pe))==null||f.showSidebar(y)}if(!e){i&&this.addNewEditorFromKeyboard(),n(this,di).resolve();return}for(const g of n(this,he).values())g.uid===e?(this.setSelected(g),a?g.editComment():r?g.enterInEditMode():g.focus()):g.unselect();n(this,di).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==n(this,we)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(n(this,hi)){switch(t){case pt.CREATE:this.currentLayer.addNewEditor(e);return;case pt.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(n(this,fd)||p(this,fd,new Map)).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(const s of n(this,Rt))s.updateParams(t,e);else for(const s of n(this,hi))s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var r;for(const a of n(this,he).values())a.editorType===t&&a.show(e);(((r=n(this,fd))==null?void 0:r.get(pt.HIGHLIGHT_SHOW_ALL))??!0)!==e&&b(this,G,Pn).call(this,[[pt.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(n(this,dd)!==t){p(this,dd,t);for(const e of n(this,ne).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}*getEditors(t){for(const e of n(this,he).values())e.pageIndex===t&&(yield e)}getEditor(t){return n(this,he).get(t)}addEditor(t){n(this,he).set(t.id,t)}removeEditor(t){var e,s;t.div.contains(document.activeElement)&&(n(this,tn)&&clearTimeout(n(this,tn)),p(this,tn,setTimeout(()=>{this.focusMainContainer(),p(this,tn,null)},0))),n(this,he).delete(t.id),t.annotationElementId&&((e=n(this,$r))==null||e.delete(t.annotationElementId)),this.unselect(t),(!t.annotationElementId||!n(this,Or).has(t.annotationElementId))&&((s=n(this,cs))==null||s.remove(t.id))}addDeletedAnnotationElement(t){n(this,Or).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return n(this,Or).has(t)}removeDeletedAnnotationElement(t){n(this,Or).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){n(this,Rs)!==t&&(p(this,Rs,t),t&&b(this,G,Pn).call(this,t.propertiesToUpdate))}updateUI(t){n(this,G,zb)===t&&b(this,G,Pn).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){b(this,G,Pn).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(n(this,Rt).has(t)){n(this,Rt).delete(t),t.unselect(),b(this,G,os).call(this,{hasSelectedEditor:this.hasSelection});return}n(this,Rt).add(t),t.select(),b(this,G,Pn).call(this,t.propertiesToUpdate),b(this,G,os).call(this,{hasSelectedEditor:!0})}setSelected(t){var e,s;this.updateToolbar({mode:t.mode,editId:t.uid}),(e=n(this,Lr))==null||e.commitOrRemove();for(const i of n(this,Rt))i!==t&&i.unselect();(s=n(this,Pe))==null||s.destroyPopup(),n(this,Rt).clear(),n(this,Rt).add(t),t.select(),b(this,G,Pn).call(this,t.propertiesToUpdate),b(this,G,os).call(this,{hasSelectedEditor:!0})}get firstSelectedEditor(){return n(this,Rt).values().next().value}unselect(t){t.unselect(),n(this,Rt).delete(t),b(this,G,os).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return n(this,Rt).size!==0}get isEnterHandled(){return n(this,Rt).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var t;n(this,ci).undo(),b(this,G,os).call(this,{hasSomethingToUndo:n(this,ci).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:b(this,G,_h).call(this)}),(t=this._editorUndoBar)==null||t.hide()}redo(){n(this,ci).redo(),b(this,G,os).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:n(this,ci).hasSomethingToRedo(),isEmpty:b(this,G,_h).call(this)})}addCommands(t){n(this,ci).add(t),b(this,G,os).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:b(this,G,_h).call(this)})}cleanUndoStack(t){n(this,ci).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,Rt)],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)b(this,G,Pg).call(this,a)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){var t;(t=n(this,Rs))==null||t.commitOrRemove()}hasSomethingToControl(){return n(this,Rs)||this.hasSelection}selectAll(){for(const t of n(this,Rt))t.commit();b(this,G,Mg).call(this,n(this,he).values())}unselectAll(){var t,e;if(!(n(this,Rs)&&(n(this,Rs).commitOrRemove(),n(this,we)!==ct.NONE))&&!((t=n(this,Lr))!=null&&t.commitOrRemove())&&((e=n(this,Pe))==null||e.destroyPopup(),!!this.hasSelection)){for(const s of n(this,Rt))s.unselect();n(this,Rt).clear(),b(this,G,os).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;n(this,zr)[0]+=t,n(this,zr)[1]+=e;const[i,r]=n(this,zr),a=[...n(this,Rt)],o=1e3;n(this,sn)&&clearTimeout(n(this,sn)),p(this,sn,setTimeout(()=>{p(this,sn,null),n(this,zr)[0]=n(this,zr)[1]=0,this.addCommands({cmd:()=>{for(const l of a)n(this,he).has(l.id)&&(l.translateInPage(i,r),l.translationDone())},undo:()=>{for(const l of a)n(this,he).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,Zi,new Map);for(const t of n(this,Rt))n(this,Zi).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!n(this,Zi))return!1;this.disableUserSelect(!1);const t=n(this,Zi);p(this,Zi,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,he).has(i.id)){const l=n(this,ne).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,Zi))for(const s of n(this,Zi).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,Rt).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return n(this,Rs)===t}getActive(){return n(this,Rs)}getMode(){return n(this,we)}isEditingMode(){return n(this,we)!==ct.NONE}get imageManager(){return ot(this,"imageManager",new Cg)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let c=0,h=e.rangeCount;c({x:(h-i)/a,y:1-(c+u-s)/r,width:f/a,height:u/r});break;case"180":o=(c,h,u,f)=>({x:1-(c+u-s)/r,y:1-(h+f-i)/a,width:u/r,height:f/a});break;case"270":o=(c,h,u,f)=>({x:1-(h+f-i)/a,y:(c-s)/r,width:f/a,height:u/r});break;default:o=(c,h,u,f)=>({x:(c-s)/r,y:(h-i)/a,width:u/r,height:f/a});break}const l=[];for(let c=0,h=e.rangeCount;c{f.type==="pointerup"&&f.button!==0||(c.abort(),l==null||l.toggleDrawing(!0),f.type==="pointerup"&&b(this,G,Ch).call(this,"main_toolbar"))};window.addEventListener("pointerup",u,{signal:h}),window.addEventListener("blur",u,{signal:h})}else l==null||l.toggleDrawing(!0),b(this,G,Ch).call(this,"main_toolbar")}},Ch=function(t=""){n(this,we)===ct.HIGHLIGHT?this.highlightSelection(t):n(this,ld)&&b(this,G,Ib).call(this)},Lb=function(){document.addEventListener("selectionchange",b(this,G,Db).bind(this),{signal:this._signal})},Fb=function(){if(n(this,Rr))return;p(this,Rr,new AbortController);const t=this.combinedSignal(n(this,Rr));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},Ob=function(){var t;(t=n(this,Rr))==null||t.abort(),p(this,Rr,null)},Tg=function(){if(n(this,Br))return;p(this,Br,new AbortController);const t=this.combinedSignal(n(this,Br));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},Rb=function(){var t;(t=n(this,Br))==null||t.abort(),p(this,Br,null)},Nb=function(){if(n(this,Dr))return;p(this,Dr,new AbortController);const t=this.combinedSignal(n(this,Dr));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})},Bb=function(){var t;(t=n(this,Dr))==null||t.abort(),p(this,Dr,null)},$b=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},os=function(t){Object.entries(t).some(([s,i])=>n(this,pd)[s]!==i)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(n(this,pd),t)}),n(this,we)===ct.HIGHLIGHT&&t.hasSelectedEditor===!1&&b(this,G,Pn).call(this,[[pt.HIGHLIGHT_FREE,!0]]))},Pn=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},Ub=async function(){if(!n(this,Fn)){p(this,Fn,!0);const t=[];for(const e of n(this,ne).values())t.push(e.enable());await Promise.all(t);for(const e of n(this,he).values())e.enable()}},Hb=function(){if(this.unselectAll(),n(this,Fn)){p(this,Fn,!1);for(const t of n(this,ne).values())t.disable();for(const t of n(this,he).values())t.disable()}},Pg=function(t){const e=n(this,ne).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},zb=function(){let t=null;for(t of n(this,Rt));return t},_h=function(){if(n(this,he).size===0)return!0;if(n(this,he).size===1)for(const t of n(this,he).values())return t.isEmpty();return!1},Mg=function(t){for(const e of n(this,Rt))e.unselect();n(this,Rt).clear();for(const e of t)e.isEmpty()||(n(this,Rt).add(e),e.select());b(this,G,os).call(this,{hasSelectedEditor:this.hasSelection})},M(Bl,"TRANSLATE_SMALL",1),M(Bl,"TRANSLATE_BIG",10);let Cl=Bl;var Me,nn,Di,sc,rn,Ns,ic,an,xs,Nn,Qa,on,Vr,Wi,kh,gf;const ls=class ls{constructor(t){m(this,Wi);m(this,Me,null);m(this,nn,!1);m(this,Di,null);m(this,sc,null);m(this,rn,null);m(this,Ns,null);m(this,ic,!1);m(this,an,null);m(this,xs,null);m(this,Nn,null);m(this,Qa,null);m(this,on,!1);p(this,xs,t),p(this,on,t._uiManager.useNewAltTextFlow),n(ls,Vr)||p(ls,Vr,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){ls._l10n??(ls._l10n=t)}async render(){const t=p(this,Di,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=p(this,sc,document.createElement("span"));t.append(e),n(this,on)?(t.classList.add("new"),t.setAttribute("data-l10n-id",n(ls,Vr).missing),e.setAttribute("data-l10n-id",n(ls,Vr)["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,xs)._uiManager._signal;t.addEventListener("contextmenu",Ei,{signal:s}),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),n(this,xs)._uiManager.editAltText(n(this,xs)),n(this,on)&&n(this,xs)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:n(this,Wi,kh)}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(p(this,ic,!0),i(r))},{signal:s}),await b(this,Wi,gf).call(this),t}finish(){n(this,Di)&&(n(this,Di).focus({focusVisible:n(this,ic)}),p(this,ic,!1))}isEmpty(){return n(this,on)?n(this,Me)===null:!n(this,Me)&&!n(this,nn)}hasData(){return n(this,on)?n(this,Me)!==null||!!n(this,Nn):this.isEmpty()}get guessedText(){return n(this,Nn)}async setGuessedText(t){n(this,Me)===null&&(p(this,Nn,t),p(this,Qa,await ls._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),b(this,Wi,gf).call(this))}toggleAltTextBadge(t=!1){var e;if(!n(this,on)||n(this,Me)){(e=n(this,an))==null||e.remove(),p(this,an,null);return}if(!n(this,an)){const s=p(this,an,document.createElement("div"));s.className="noAltTextBadge",n(this,xs).div.append(s)}n(this,an).classList.toggle("hidden",!t)}serialize(t){let e=n(this,Me);return!t&&n(this,Nn)===e&&(e=n(this,Qa)),{altText:e,decorative:n(this,nn),guessedText:n(this,Nn),textWithDisclaimer:n(this,Qa)}}get data(){return{altText:n(this,Me),decorative:n(this,nn)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:r=!1}){s&&(p(this,Nn,s),p(this,Qa,i)),!(n(this,Me)===t&&n(this,nn)===e)&&(r||(p(this,Me,t),p(this,nn,e)),b(this,Wi,gf).call(this))}toggle(t=!1){n(this,Di)&&(!t&&n(this,Ns)&&(clearTimeout(n(this,Ns)),p(this,Ns,null)),n(this,Di).disabled=!t)}shown(){n(this,xs)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:n(this,Wi,kh)}})}destroy(){var t,e;(t=n(this,Di))==null||t.remove(),p(this,Di,null),p(this,sc,null),p(this,rn,null),(e=n(this,an))==null||e.remove(),p(this,an,null)}};Me=new WeakMap,nn=new WeakMap,Di=new WeakMap,sc=new WeakMap,rn=new WeakMap,Ns=new WeakMap,ic=new WeakMap,an=new WeakMap,xs=new WeakMap,Nn=new WeakMap,Qa=new WeakMap,on=new WeakMap,Vr=new WeakMap,Wi=new WeakSet,kh=function(){return n(this,Me)&&"added"||n(this,Me)===null&&this.guessedText&&"review"||"missing"},gf=async function(){var i,r,a;const t=n(this,Di);if(!t)return;if(n(this,on)){if(t.classList.toggle("done",!!n(this,Me)),t.setAttribute("data-l10n-id",n(ls,Vr)[n(this,Wi,kh)]),(i=n(this,sc))==null||i.setAttribute("data-l10n-id",n(ls,Vr)[`${n(this,Wi,kh)}-label`]),!n(this,Me)){(r=n(this,rn))==null||r.remove();return}}else{if(!n(this,Me)&&!n(this,nn)){t.classList.remove("done"),(a=n(this,rn))==null||a.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=n(this,rn);if(!e){p(this,rn,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${n(this,xs).id}`;const o=100,l=n(this,xs)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(n(this,Ns)),p(this,Ns,null)},{once:!0}),t.addEventListener("mouseenter",()=>{p(this,Ns,setTimeout(()=>{p(this,Ns,null),n(this,rn).classList.add("show"),n(this,xs)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),t.addEventListener("mouseleave",()=>{var c;n(this,Ns)&&(clearTimeout(n(this,Ns)),p(this,Ns,null)),(c=n(this,rn))==null||c.classList.remove("show")},{signal:l})}n(this,nn)?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,xs).getElementForAltText();s==null||s.setAttribute("aria-describedby",e.id)},m(ls,Vr,null),M(ls,"_l10n",null);let ep=ls;var Ue,ui,Ja,Wt,vd,Gr,fi,jr,Wr,Za,bd,Ig;class tf{constructor(t){m(this,bd);m(this,Ue,null);m(this,ui,null);m(this,Ja,!1);m(this,Wt,null);m(this,vd,null);m(this,Gr,null);m(this,fi,null);m(this,jr,null);m(this,Wr,!1);m(this,Za,null);p(this,Wt,t)}renderForToolbar(){const t=p(this,ui,document.createElement("button"));return t.className="comment",b(this,bd,Ig).call(this,t,!1)}renderForStandalone(){const t=p(this,Ue,document.createElement("button"));t.className="annotationCommentButton";const e=n(this,Wt).commentButtonPosition;if(e){const{style:s}=t;s.insetInlineEnd=`calc(${100*(n(this,Wt)._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,Wt).commentButtonColor;i&&(s.backgroundColor=i)}return b(this,bd,Ig).call(this,t,!0)}focusButton(){setTimeout(()=>{var t;(t=n(this,Ue)??n(this,ui))==null||t.focus()},0)}onUpdatedColor(){if(!n(this,Ue))return;const t=n(this,Wt).commentButtonColor;t&&(n(this,Ue).style.backgroundColor=t),n(this,Wt)._uiManager.updatePopupColor(n(this,Wt))}get commentButtonWidth(){var t;return(((t=n(this,Ue))==null?void 0:t.getBoundingClientRect().width)??0)/n(this,Wt).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(n(this,Za))return n(this,Za);if(!n(this,Ue))return null;const{x:t,y:e,height:s}=n(this,Ue).getBoundingClientRect(),{x:i,y:r,width:a,height:o}=n(this,Wt).parent.boundingClientRect;return[(t-i)/a,(e+s-r)/o]}set commentPopupPositionInLayer(t){p(this,Za,t)}hasDefaultPopupPosition(){return n(this,Za)===null}removeStandaloneCommentButton(){var t;(t=n(this,Ue))==null||t.remove(),p(this,Ue,null)}removeToolbarCommentButton(){var t;(t=n(this,ui))==null||t.remove(),p(this,ui,null)}setCommentButtonStates({selected:t,hasPopup:e}){n(this,Ue)&&(n(this,Ue).classList.toggle("selected",t),n(this,Ue).ariaExpanded=e)}edit(t){const e=this.commentPopupPositionInLayer;let s,i;if(e)[s,i]=e;else{[s,i]=n(this,Wt).commentButtonPosition;const{width:h,height:u,x:f,y:g}=n(this,Wt);s=f+s*h,i=g+i*u}const r=n(this,Wt).parent.boundingClientRect,{x:a,y:o,width:l,height:c}=r;n(this,Wt)._uiManager.editComment(n(this,Wt),a+s*l,o+i*c,{...t,parentDimensions:r})}finish(){n(this,ui)&&(n(this,ui).focus({focusVisible:n(this,Ja)}),p(this,Ja,!1))}isDeleted(){return n(this,Wr)||n(this,fi)===""}isEmpty(){return n(this,fi)===null}hasBeenEdited(){return this.isDeleted()||n(this,fi)!==n(this,vd)}serialize(){return this.data}get data(){return{text:n(this,fi),richText:n(this,Gr),date:n(this,jr),deleted:this.isDeleted()}}set data(t){if(t!==n(this,fi)&&p(this,Gr,null),t===null){p(this,fi,""),p(this,Wr,!0);return}p(this,fi,t),p(this,jr,new Date),p(this,Wr,!1)}restoreData({text:t,richText:e,date:s}){p(this,fi,t),p(this,Gr,e),p(this,jr,s),p(this,Wr,!1)}setInitialText(t,e=null){p(this,vd,t),this.data=t,p(this,jr,null),p(this,Gr,e)}shown(){}destroy(){var t,e;(t=n(this,ui))==null||t.remove(),p(this,ui,null),(e=n(this,Ue))==null||e.remove(),p(this,Ue,null),p(this,fi,""),p(this,Gr,null),p(this,jr,null),p(this,Wt,null),p(this,Ja,!1),p(this,Wr,!1)}}Ue=new WeakMap,ui=new WeakMap,Ja=new WeakMap,Wt=new WeakMap,vd=new WeakMap,Gr=new WeakMap,fi=new WeakMap,jr=new WeakMap,Wr=new WeakMap,Za=new WeakMap,bd=new WeakSet,Ig=function(t,e){if(!n(this,Wt)._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,Wt)._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const s=n(this,Wt)._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;t.addEventListener("contextmenu",Ei,{signal:s}),e&&(t.addEventListener("focusin",r=>{n(this,Wt)._focusEventsAllowed=!1,re(r)},{capture:!0,signal:s}),t.addEventListener("focusout",r=>{n(this,Wt)._focusEventsAllowed=!0,re(r)},{capture:!0,signal:s})),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),t===n(this,ui)?this.edit():n(this,Wt).toggleComment(!0)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(p(this,Ja,!0),i(r))},{signal:s}),t.addEventListener("pointerenter",()=>{n(this,Wt).toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{n(this,Wt).toggleComment(!1,!1)},{signal:s}),t};var nc,to,yd,wd,Ad,Sd,xd,Bn,eo,$n,so,Un,Pa,Vb,Gb,jb;const uv=class uv{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:r=null,onPinchEnd:a=null,signal:o}){m(this,Pa);m(this,nc);m(this,to,!1);m(this,yd,null);m(this,wd);m(this,Ad);m(this,Sd);m(this,xd);m(this,Bn,null);m(this,eo);m(this,$n,null);m(this,so);m(this,Un,null);p(this,nc,t),p(this,yd,s),p(this,wd,e),p(this,Ad,i),p(this,Sd,r),p(this,xd,a),p(this,so,new AbortController),p(this,eo,AbortSignal.any([o,n(this,so).signal])),t.addEventListener("touchstart",b(this,Pa,Vb).bind(this),{passive:!1,signal:n(this,eo)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/_n.pixelRatio}destroy(){var t,e;(t=n(this,so))==null||t.abort(),p(this,so,null),(e=n(this,Bn))==null||e.abort(),p(this,Bn,null)}};nc=new WeakMap,to=new WeakMap,yd=new WeakMap,wd=new WeakMap,Ad=new WeakMap,Sd=new WeakMap,xd=new WeakMap,Bn=new WeakMap,eo=new WeakMap,$n=new WeakMap,so=new WeakMap,Un=new WeakMap,Pa=new WeakSet,Vb=function(t){var i,r,a;if((i=n(this,wd))!=null&&i.call(this))return;if(t.touches.length===1){if(n(this,Bn))return;const o=p(this,Bn,new AbortController),l=AbortSignal.any([n(this,eo),o.signal]),c=n(this,nc),h={capture:!0,signal:l,passive:!1},u=f=>{var g;f.pointerType==="touch"&&((g=n(this,Bn))==null||g.abort(),p(this,Bn,null))};c.addEventListener("pointerdown",f=>{f.pointerType==="touch"&&(re(f),u(f))},h),c.addEventListener("pointerup",u,h),c.addEventListener("pointercancel",u,h);return}if(!n(this,Un)){p(this,Un,new AbortController);const o=AbortSignal.any([n(this,eo),n(this,Un).signal]),l=n(this,nc),c={signal:o,capture:!1,passive:!1};l.addEventListener("touchmove",b(this,Pa,Gb).bind(this),c);const h=b(this,Pa,jb).bind(this);l.addEventListener("touchend",h,c),l.addEventListener("touchcancel",h,c),c.capture=!0,l.addEventListener("pointerdown",re,c),l.addEventListener("pointermove",re,c),l.addEventListener("pointercancel",re,c),l.addEventListener("pointerup",re,c),(r=n(this,Ad))==null||r.call(this)}if(re(t),t.touches.length!==2||(a=n(this,yd))!=null&&a.call(this)){p(this,$n,null);return}let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]),p(this,$n,{touch0X:e.screenX,touch0Y:e.screenY,touch1X:s.screenX,touch1Y:s.screenY})},Gb=function(t){var _;if(!n(this,$n)||t.touches.length!==2)return;re(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,$n),{touch0X:c,touch0Y:h,touch1X:u,touch1Y:f}=l,g=u-c,y=f-h,v=a-i,w=o-r,S=Math.hypot(v,w)||1,x=Math.hypot(g,y)||1;if(!n(this,to)&&Math.abs(x-S)<=uv.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=i,l.touch0Y=r,l.touch1X=a,l.touch1Y=o,!n(this,to)){p(this,to,!0);return}const A=[(i+a)/2,(r+o)/2];(_=n(this,Sd))==null||_.call(this,A,x,S)},jb=function(t){var e;t.touches.length>=2||(n(this,Un)&&(n(this,Un).abort(),p(this,Un,null),(e=n(this,xd))==null||e.call(this)),n(this,$n)&&(re(t),p(this,$n,null),p(this,to,!1)))};let sp=uv;var io,Li,te,Dt,Hn,rc,Xr,Ed,He,no,zn,pi,qr,Cd,ro,Bs,_d,ao,Vn,ln,ac,oc,gi,oo,kd,fp,st,Dg,Td,Lg,mf,Wb,Xb,Fg,vf,Og,qb,Yb,Kb,Rg,Qb,Ng,Jb,Zb,ty,Bg,Th;const at=class at{constructor(t){m(this,st);m(this,io,null);m(this,Li,null);m(this,te,null);m(this,Dt,null);m(this,Hn,null);m(this,rc,!1);m(this,Xr,null);m(this,Ed,"");m(this,He,null);m(this,no,null);m(this,zn,null);m(this,pi,null);m(this,qr,null);m(this,Cd,"");m(this,ro,!1);m(this,Bs,null);m(this,_d,!1);m(this,ao,!1);m(this,Vn,!1);m(this,ln,null);m(this,ac,0);m(this,oc,0);m(this,gi,null);m(this,oo,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,kd,!1);m(this,fp,at._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=at.prototype._resizeWithKeyboard,e=Cl.TRANSLATE_SMALL,s=Cl.TRANSLATE_BIG;return ot(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"],at.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 ot(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new E1({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(at._l10n??(at._l10n=t),at._l10nAlert??(at._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"})),at._l10nResizer??(at._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"})),at._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);at._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,kd)}set _isDraggable(t){var e;p(this,kd,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,fp)}setParent(t){var e;t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(b(this,st,Th).call(this),(e=n(this,pi))==null||e.remove(),p(this,pi,null)),this.parent=t}focusin(t){this._focusEventsAllowed&&(n(this,ro)?p(this,ro,!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){b(this,st,Dg).call(this,this.parentDimensions,t,e)}translateInPage(t,e){n(this,Bs)||p(this,Bs,[this.x,this.y,this.width,this.height]),b(this,st,Dg).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){n(this,Bs)||p(this,Bs,[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:u,y:f}=this.div.getBoundingClientRect();this.parent.findNewParent(this,u,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,Bs)&&(n(this,Bs)[0]!==this.x||n(this,Bs)[1]!==this.y)}get _hasBeenResized(){return!!n(this,Bs)&&(n(this,Bs)[2]!==this.width||n(this,Bs)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=at,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=Zt(r,0,s-o),a=Zt(a,0,i-l);break;case 90:r=Zt(r,0,s-l),a=Zt(a,o,i);break;case 180:r=Zt(r,o,s),a=Zt(a,l,i);break;case 270:r=Zt(r,l,s),a=Zt(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 b(s=at,Td,Lg).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return b(s=at,Td,Lg).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,te))==null||t.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||n(this,ao))return this._editToolbar;this._editToolbar=new xg(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,te))==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,te)||(ep.initialize(at._l10n),p(this,te,new ep(this)),n(this,io)&&(n(this,te).data=n(this,io),p(this,io,null))),n(this,te)}get altTextData(){var t;return(t=n(this,te))==null?void 0:t.data}set altTextData(t){n(this,te)&&(n(this,te).data=t)}get guessedAltText(){var t;return(t=n(this,te))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=n(this,te))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=n(this,te))==null?void 0:e.serialize(t)}hasAltText(){return!!n(this,te)&&!n(this,te).isEmpty()}hasAltTextData(){var t;return((t=n(this,te))==null?void 0:t.hasData())??!1}focusCommentButton(){var t;(t=n(this,Dt))==null||t.focusButton()}addCommentButton(){return this.canAddComment?n(this,Dt)||p(this,Dt,new tf(this)):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(n(this,Hn)){this._uiManager.isEditingMode()&&n(this,Hn).classList.remove("hidden");return}this.hasComment&&(p(this,Hn,n(this,Dt).renderForStandalone()),this.div.append(n(this,Hn)))}}removeStandaloneCommentButton(){n(this,Dt).removeStandaloneCommentButton(),p(this,Hn,null)}hideStandaloneCommentButton(){var t;(t=n(this,Hn))==null||t.classList.add("hidden")}get comment(){if(!n(this,Dt))return null;const{data:{richText:t,text:e,date:s,deleted:i}}=n(this,Dt);return{text:e,richText:t,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){n(this,Dt)||p(this,Dt,new tf(this)),typeof t=="object"&&t!==null?n(this,Dt).restoreData(t):n(this,Dt).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,Dt)||p(this,Dt,new tf(this)),n(this,Dt).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,Dt))==null?void 0:t.hasBeenEdited()}get hasDeletedComment(){var t;return(t=n(this,Dt))==null?void 0:t.isDeleted()}get hasComment(){return!!n(this,Dt)&&!n(this,Dt).isEmpty()&&!n(this,Dt).isDeleted()}async editComment(t){n(this,Dt)||p(this,Dt,new tf(this)),n(this,Dt).edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){n(this,Dt).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,Dt).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,rc)?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),b(this,st,Ng).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),kb(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(n(this,oo)||p(this,oo,new sp({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:b(this,st,qb).bind(this),onPinching:b(this,st,Yb).bind(this),onPinchEnd:b(this,st,Kb).bind(this),signal:this._uiManager._signal}))),this.addStandaloneCommentButton(),(a=this._uiManager._editorUndoBar)==null||a.hide(),t}pointerdown(t){const{isMac:e}=Ht.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(p(this,ro,!0),this._isDraggable){b(this,st,Qb).call(this,t);return}b(this,st,Rg).call(this,t)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){n(this,ln)&&clearTimeout(n(this,ln)),p(this,ln,setTimeout(()=>{var t;p(this,ln,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,u=this.x*r,f=this.y*a,g=this.width*r,y=this.height*a;switch(s){case 0:return[u+c+o,a-f-h-y+l,u+c+g+o,a-f-h+l];case 90:return[u+h+o,a-f+c+l,u+h+y+o,a-f+c+g+l];case 180:return[u-c-g+o,a-f+h+l,u-c+o,a-f+h+y+l];case 270:return[u-h-y+o,a-f-c-g+l,u-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&&at._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){var t;(t=n(this,Dt))==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,ao,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),p(this,ao,!1),!0):!1}isInEditMode(){return n(this,ao)}shouldGetKeyboardEvents(){return n(this,Vn)}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 e0&&t0}rebuild(){b(this,st,Ng).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,io,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,qr))==null||t.abort(),p(this,qr,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),n(this,ln)&&(clearTimeout(n(this,ln)),p(this,ln,null)),b(this,st,Th).call(this),this.removeEditToolbar(),n(this,gi)){for(const i of n(this,gi).values())clearTimeout(i);p(this,gi,null)}this.parent=null,(e=n(this,oo))==null||e.destroy(),p(this,oo,null),(s=n(this,pi))==null||s.remove(),p(this,pi,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(b(this,st,Wb).call(this),n(this,He).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[at._round(s+(r-s)*t),at._round(i+(a-i)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return n(this,Dt).commentPopupPositionInLayer}set commentPopupPosition(t){n(this,Dt).commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return n(this,Dt).hasDefaultPopupPosition()}get commentButtonWidth(){return n(this,Dt).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){var e;(e=n(this,Dt))==null||e.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),p(this,zn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=n(this,He).children;if(!n(this,Li)){p(this,Li,Array.from(e));const a=b(this,st,Jb).bind(this),o=b(this,st,Zb).bind(this),l=this._uiManager._signal;for(const c of n(this,Li)){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",b(this,st,ty).bind(this,h),{signal:l}),c.setAttribute("data-l10n-id",at._l10nResizer[h])}}const s=n(this,Li)[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,Li).length/4);if(r!==i){if(ri)for(let o=0;o{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,te))==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,He))==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,te))==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,_d)}set isEditing(t){p(this,_d,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,gi)||p(this,gi,new Map);const{action:s}=t;let i=n(this,gi).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),n(this,gi).delete(s),n(this,gi).size===0&&p(this,gi,null)},at._telemetryTimeout),n(this,gi).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,rc,!1)}disable(){this.div&&(this.div.tabIndex=-1),p(this,rc,!0)}updateFakeAnnotationElement(t){if(!n(this,pi)&&!this.deleted){p(this,pi,t.addFakeAnnotation(this));return}if(this.deleted){n(this,pi).remove(),p(this,pi,null);return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&n(this,pi).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()}};io=new WeakMap,Li=new WeakMap,te=new WeakMap,Dt=new WeakMap,Hn=new WeakMap,rc=new WeakMap,Xr=new WeakMap,Ed=new WeakMap,He=new WeakMap,no=new WeakMap,zn=new WeakMap,pi=new WeakMap,qr=new WeakMap,Cd=new WeakMap,ro=new WeakMap,Bs=new WeakMap,_d=new WeakMap,ao=new WeakMap,Vn=new WeakMap,ln=new WeakMap,ac=new WeakMap,oc=new WeakMap,gi=new WeakMap,oo=new WeakMap,kd=new WeakMap,fp=new WeakMap,st=new WeakSet,Dg=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()},Td=new WeakSet,Lg=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]}},mf=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]}},Wb=function(){if(n(this,He))return;p(this,He,document.createElement("div")),n(this,He).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,He).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",b(this,st,Xb).bind(this,s),{signal:e}),i.addEventListener("contextmenu",Ei,{signal:e}),i.tabIndex=-1}this.div.prepend(n(this,He))},Xb=function(t,e){var h;e.preventDefault();const{isMac:s}=Ht.platform;if(e.button!==0||e.ctrlKey&&s)return;(h=n(this,te))==null||h.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,p(this,no,[e.screenX,e.screenY]);const r=new AbortController,a=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",b(this,st,Og).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",re,{passive:!1,signal:a}),window.addEventListener("contextmenu",Ei,{signal:a}),p(this,zn,{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 u;r.abort(),this.parent.togglePointerEvents(!0),(u=n(this,te))==null||u.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=o,this.div.style.cursor=l,b(this,st,vf).call(this)};window.addEventListener("pointerup",c,{signal:a}),window.addEventListener("blur",c,{signal:a})},Fg=function(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()},vf=function(){if(!n(this,zn))return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=n(this,zn);p(this,zn,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:b(this,st,Fg).bind(this,r,a,o,l),undo:b(this,st,Fg).bind(this,t,e,s,i),mustExec:!0})},Og=function(t,e){const[s,i]=this.parentDimensions,r=this.x,a=this.y,o=this.width,l=this.height,c=at.MIN_SIZE/s,h=at.MIN_SIZE/i,u=b(this,st,mf).call(this,this.rotation),f=(T,j)=>[u[0]*T+u[2]*j,u[1]*T+u[3]*j],g=b(this,st,mf).call(this,360-this.rotation),y=(T,j)=>[g[0]*T+g[2]*j,g[1]*T+g[3]*j];let v,w,S=!1,x=!1;switch(t){case"topLeft":S=!0,v=(T,j)=>[0,0],w=(T,j)=>[T,j];break;case"topMiddle":v=(T,j)=>[T/2,0],w=(T,j)=>[T/2,j];break;case"topRight":S=!0,v=(T,j)=>[T,0],w=(T,j)=>[0,j];break;case"middleRight":x=!0,v=(T,j)=>[T,j/2],w=(T,j)=>[0,j/2];break;case"bottomRight":S=!0,v=(T,j)=>[T,j],w=(T,j)=>[0,0];break;case"bottomMiddle":v=(T,j)=>[T/2,j],w=(T,j)=>[T/2,0];break;case"bottomLeft":S=!0,v=(T,j)=>[0,j],w=(T,j)=>[T,0];break;case"middleLeft":x=!0,v=(T,j)=>[0,j/2],w=(T,j)=>[T,j/2];break}const A=v(o,l),_=w(o,l);let E=f(..._);const k=at._round(r+E[0]),P=at._round(a+E[1]);let L=1,I=1,D,R;if(e.fromKeyboard)({deltaX:D,deltaY:R}=e);else{const{screenX:T,screenY:j}=e,[Ft,St]=n(this,no);[D,R]=this.screenToPageTranslation(T-Ft,j-St),n(this,no)[0]=T,n(this,no)[1]=j}if([D,R]=y(D/s,R/i),S){const T=Math.hypot(o,l);L=I=Math.max(Math.min(Math.hypot(_[0]-A[0]-D,_[1]-A[1]-R)/T,1/o,1/l),c/o,h/l)}else x?L=Zt(Math.abs(_[0]-A[0]-D),c,1)/o:I=Zt(Math.abs(_[1]-A[1]-R),h,1)/l;const W=at._round(o*L),Q=at._round(l*I);E=f(...w(W,Q));const Y=k-E[0],yt=P-E[1];n(this,Bs)||p(this,Bs,[this.x,this.y,this.width,this.height]),this.width=W,this.height=Q,this.x=Y,this.y=yt,this.setDims(),this.fixAndSetPosition(),this._onResizing()},qb=function(){var t;p(this,zn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(t=n(this,te))==null||t.toggle(!1),this.parent.togglePointerEvents(!1)},Yb=function(t,e,s){let r=.7*(s/e)+1-.7;if(r===1)return;const a=b(this,st,mf).call(this,this.rotation),o=(k,P)=>[a[0]*k+a[2]*P,a[1]*k+a[3]*P],[l,c]=this.parentDimensions,h=this.x,u=this.y,f=this.width,g=this.height,y=at.MIN_SIZE/l,v=at.MIN_SIZE/c;r=Math.max(Math.min(r,1/f,1/g),y/f,v/g);const w=at._round(f*r),S=at._round(g*r);if(w===f&&S===g)return;n(this,Bs)||p(this,Bs,[h,u,f,g]);const x=o(f/2,g/2),A=at._round(h+x[0]),_=at._round(u+x[1]),E=o(w/2,S/2);this.x=A-E[0],this.y=_-E[1],this.width=w,this.height=S,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Kb=function(){var t;(t=n(this,te))==null||t.toggle(!0),this.parent.togglePointerEvents(!0),b(this,st,vf).call(this)},Rg=function(t){const{isMac:e}=Ht.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Qb=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,Xr,null),p(this,ro,!1),this._uiManager.endDragSession()||b(this,st,Rg).call(this,c),s&&this._onStopDragging()};e&&(p(this,ac,t.clientX),p(this,oc,t.clientY),p(this,Xr,t.pointerId),p(this,Ed,t.pointerType),window.addEventListener("pointermove",c=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:h,clientY:u,pointerId:f}=c;if(f!==n(this,Xr)){re(c);return}const[g,y]=this.screenToPageTranslation(h-n(this,ac),u-n(this,oc));p(this,ac,h),p(this,oc,u),this._uiManager.dragSelectedEditors(g,y)},a),window.addEventListener("touchmove",re,a),window.addEventListener("pointerdown",c=>{c.pointerType===n(this,Ed)&&(n(this,oo)||c.isPrimary)&&o(c),re(c)},a));const l=c=>{if(!n(this,Xr)||n(this,Xr)===c.pointerId){o(c);return}re(c)};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})},Ng=function(){if(n(this,qr)||!this.div)return;p(this,qr,new AbortController);const t=this._uiManager.combinedSignal(n(this,qr));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},Jb=function(t){at._resizerKeyboardManager.exec(this,t)},Zb=function(t){var e;n(this,Vn)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==n(this,He)&&b(this,st,Th).call(this)},ty=function(t){p(this,Cd,n(this,Vn)?t:"")},Bg=function(t){if(n(this,Li))for(const e of n(this,Li))e.tabIndex=t},Th=function(){p(this,Vn,!1),b(this,st,Bg).call(this,-1),b(this,st,vf).call(this)},m(at,Td),M(at,"_l10n",null),M(at,"_l10nAlert",null),M(at,"_l10nResizer",null),M(at,"_borderLineWidth",-1),M(at,"_colorManager",new _g),M(at,"_zIndex",1),M(at,"_telemetryTimeout",1e3);let Mt=at;class E1 extends Mt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Rv=3285377520,ri=4294901760,Ki=65535;class $g{constructor(t){this.h1=t?t&4294967295:Rv,this.h2=t?t&4294967295:Rv}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let v=0,w=t.length;v>>8,e[s++]=S&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 u=3432918353,f=461845907,g=u&Ki,y=f&Ki;for(let v=0;v>>17,o=o*f&ri|o*y&Ki,c^=o,c=c<<13|c>>>19,c=c*5+3864292196):(l=a[v],l=l*u&ri|l*g&Ki,l=l<<15|l>>>17,l=l*f&ri|l*y&Ki,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*u&ri|o*g&Ki,o=o<<15|o>>>17,o=o*f&ri|o*y&Ki,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&ri|t*36045&Ki,e=e*4283543511&ri|((e<<16|t>>>16)*2950163797&ri)>>>16,t^=e>>>1,t=t*444984403&ri|t*60499&Ki,e=e*3301882366&ri|((e<<16|t>>>16)*3120437893&ri)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Zh=Object.freeze({map:null,hash:"",transfer:void 0});var lo,co,Gn,ze,pp,ey;class nv{constructor(){m(this,pp);m(this,lo,!1);m(this,co,null);m(this,Gn,null);m(this,ze,new Map);M(this,"onSetModified",null);M(this,"onResetModified",null);M(this,"onAnnotationEditor",null)}getValue(t,e){const s=n(this,ze).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return n(this,ze).get(t)}remove(t){var s;const e=n(this,ze).get(t);e!==void 0&&(e instanceof Mt&&n(this,Gn).delete(e.annotationElementId),n(this,ze).delete(t),n(this,ze).size===0&&this.resetModified(),!n(this,ze).values().some(i=>i instanceof Mt)&&((s=this.onAnnotationEditor)==null||s.call(this,null)))}setValue(t,e){var r;const s=n(this,ze).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,ze).set(t,e);i&&b(this,pp,ey).call(this),e instanceof Mt&&((n(this,Gn)||p(this,Gn,new Map)).set(e.annotationElementId,e),(r=this.onAnnotationEditor)==null||r.call(this,e.constructor._type))}has(t){return n(this,ze).has(t)}get size(){return n(this,ze).size}resetModified(){var t;n(this,lo)&&(p(this,lo,!1),(t=this.onResetModified)==null||t.call(this))}get print(){return new sy(this)}get serializable(){if(n(this,ze).size===0)return Zh;const t=new Map,e=new $g,s=[],i=Object.create(null);let r=!1;for(const[a,o]of n(this,ze)){const l=o instanceof Mt?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}:Zh}get editorStats(){let t=null;const e=new Map;let s=0,i=0;for(const r of n(this,ze).values()){if(!(r instanceof Mt)){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 u=l.getOrInsertComputed(c,tv);u.set(h,(u.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,co,null)}updateEditor(t,e){var i;const s=(i=n(this,Gn))==null?void 0:i.get(t);return s?(s.updateFromAnnotationLayer(e),!0):!1}getEditor(t){var e;return((e=n(this,Gn))==null?void 0:e.get(t))||null}get modifiedIds(){if(n(this,co))return n(this,co);const t=[];if(n(this,Gn))for(const s of n(this,Gn).values())s.serialize()&&t.push(s.annotationElementId);let e="";if(t.length){const s=new $g;s.update(t.join(",")),e=s.hexdigest()}return p(this,co,{ids:new Set(t),hash:e})}[Symbol.iterator](){return n(this,ze).entries()}}lo=new WeakMap,co=new WeakMap,Gn=new WeakMap,ze=new WeakMap,pp=new WeakSet,ey=function(){var t;n(this,lo)||(p(this,lo,!0),(t=this.onSetModified)==null||t.call(this))};var Pd;class sy extends nv{constructor(e){super();m(this,Pd,Zh);const{serializable:s}=e;if(s===Zh)return;const{map:i,hash:r,transfer:a}=s,o=structuredClone(i,a?{transfer:a}:null);p(this,Pd,{map:o,hash:r,transfer:[]})}get print(){Ct("Should not call PrintAnnotationStorage.print")}get serializable(){return n(this,Pd)}get modifiedIds(){return ot(this,"modifiedIds",{ids:new Set,hash:""})}}Pd=new WeakMap;const Il="__forcedDependency",{floor:Nv,ceil:Bv}=Math;function $v(d,t,e,s,i,r){d[t*4+0]=Math.min(d[t*4+0],e),d[t*4+1]=Math.min(d[t*4+1],s),d[t*4+2]=Math.max(d[t*4+2],i),d[t*4+3]=Math.max(d[t*4+3],r)}function C1(d,t,e,s,i){let r;d?(d<0&&(r=i[0],i[0]=i[2],i[2]=r),i[0]*=d,i[2]*=d,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 Ug=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];var lc,Yr;class _1{constructor(t,e){m(this,lc);m(this,Yr);p(this,lc,t),p(this,Yr,e)}get length(){return n(this,lc).length}isEmpty(t){return n(this,lc)[t]===Ug}minX(t){return n(this,Yr)[t*4+0]/256}minY(t){return n(this,Yr)[t*4+1]/256}maxX(t){return(n(this,Yr)[t*4+2]+1)/256}maxY(t){return(n(this,Yr)[t*4+3]+1)/256}}lc=new WeakMap,Yr=new WeakMap;const Uv=(d,t)=>d==null?void 0:d.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1}));var jn,Pt,Qt,ho,uo,fo,es,Md,Hg;class k1{constructor(t,e){m(this,Md);m(this,jn,[[1,0,0,1,0,0]]);m(this,Pt,[-1/0,-1/0,1/0,1/0]);m(this,Qt,new Float64Array(br));M(this,"_pendingBBoxIdx",-1);m(this,ho);m(this,uo);m(this,fo);m(this,es);M(this,"_savesStack",[]);M(this,"_markedContentStack",[]);p(this,ho,t.width),p(this,uo,t.height),b(this,Md,Hg).call(this,e)}growOperationsCount(t){t>=n(this,es).length&&b(this,Md,Hg).call(this,t,n(this,es))}get clipBox(){return n(this,Pt)}save(t){return p(this,Pt,{__proto__:n(this,Pt)}),this._savesStack.push(t),this}restore(t,e){const s=Object.getPrototypeOf(n(this,Pt));if(s===null)return this;p(this,Pt,s);const i=this._savesStack.pop();return i!==void 0&&(e==null||e(i,t),n(this,es)[t]=n(this,es)[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,es)[t]=n(this,es)[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,es)[t]=n(this,es)[s]),this}pushBaseTransform(t){return n(this,jn).push(B.multiplyByDOMMatrix(n(this,jn).at(-1),t.getTransform())),this}popBaseTransform(){return n(this,jn).length>1&&n(this,jn).pop(),this}resetBBox(t){return this._pendingBBoxIdx!==t&&(this._pendingBBoxIdx=t,n(this,Qt).set(br,0)),this}recordClipBox(t,e,s,i,r,a){const o=B.multiplyByDOMMatrix(n(this,jn).at(-1),e.getTransform()),l=br.slice();B.axialAlignedBoundingBox([s,r,i,a],o,l);const c=B.intersect(n(this,Pt),l);return c?(n(this,Pt)[0]=c[0],n(this,Pt)[1]=c[1],n(this,Pt)[2]=c[2],n(this,Pt)[3]=c[3]):(n(this,Pt)[0]=n(this,Pt)[1]=1/0,n(this,Pt)[2]=n(this,Pt)[3]=-1/0),this}recordBBox(t,e,s,i,r,a){const o=n(this,Pt);if(o[0]===1/0)return this;const l=B.multiplyByDOMMatrix(n(this,jn).at(-1),e.getTransform());if(o[0]===-1/0)return B.axialAlignedBoundingBox([s,r,i,a],l,n(this,Qt)),this;const c=br.slice();return B.axialAlignedBoundingBox([s,r,i,a],l,c),n(this,Qt)[0]=Zt(c[0],o[0],n(this,Qt)[0]),n(this,Qt)[1]=Zt(c[1],o[1],n(this,Qt)[1]),n(this,Qt)[2]=Zt(c[2],n(this,Qt)[2],o[2]),n(this,Qt)[3]=Zt(c[3],n(this,Qt)[3],o[3]),this}recordFullPageBBox(t){return n(this,Qt)[0]=Math.max(0,n(this,Pt)[0]),n(this,Qt)[1]=Math.max(0,n(this,Pt)[1]),n(this,Qt)[2]=Math.min(n(this,ho),n(this,Pt)[2]),n(this,Qt)[3]=Math.min(n(this,uo),n(this,Pt)[3]),this}recordOperation(t,e=!1,s){if(this._pendingBBoxIdx!==t)return this;const i=Nv(n(this,Qt)[0]*256/n(this,ho)),r=Nv(n(this,Qt)[1]*256/n(this,uo)),a=Bv(n(this,Qt)[2]*256/n(this,ho)),o=Bv(n(this,Qt)[3]*256/n(this,uo));if($v(n(this,fo),t,i,r,a,o),s)for(const l of s)for(const c of l)c!==t&&$v(n(this,fo),c,i,r,a,o);return e||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(t){return this._pendingBBoxIdx===t&&(this._pendingBBoxIdx=-1,n(this,Pt)[0]=Math.max(n(this,Pt)[0],n(this,Qt)[0]),n(this,Pt)[1]=Math.max(n(this,Pt)[1],n(this,Qt)[1]),n(this,Pt)[2]=Math.min(n(this,Pt)[2],n(this,Qt)[2]),n(this,Pt)[3]=Math.min(n(this,Pt)[3],n(this,Qt)[3])),this}take(){return new _1(n(this,es),n(this,fo))}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}}jn=new WeakMap,Pt=new WeakMap,Qt=new WeakMap,ho=new WeakMap,uo=new WeakMap,fo=new WeakMap,es=new WeakMap,Md=new WeakSet,Hg=function(t,e){const s=new ArrayBuffer(t*4);p(this,fo,new Uint8ClampedArray(s)),p(this,es,new Uint32Array(s)),e&&e.length>0?(n(this,es).set(e),n(this,es).fill(Ug,e.length)):n(this,es).fill(Ug)};var Es,Cs,po,Fi,cc,Kr,Qr,Nt;class T1{constructor(t,e=!1){m(this,Es,{__proto__:null});m(this,Cs,{__proto__:null,transform:[],moveText:[],sameLineText:[],[Il]:[]});m(this,po,new Map);m(this,Fi,new Set);m(this,cc,new Map);m(this,Kr);m(this,Qr);m(this,Nt);p(this,Nt,t),e&&(p(this,Kr,new Map),p(this,Qr,(s,i)=>{Uv(n(this,Kr),i).dependencies.add(s)}))}get clipBox(){return n(this,Nt).clipBox}growOperationsCount(t){n(this,Nt).growOperationsCount(t)}save(t){return p(this,Es,{__proto__:n(this,Es)}),p(this,Cs,{__proto__:n(this,Cs),transform:{__proto__:n(this,Cs).transform},moveText:{__proto__:n(this,Cs).moveText},sameLineText:{__proto__:n(this,Cs).sameLineText},[Il]:{__proto__:n(this,Cs)[Il]}}),n(this,Nt).save(t),this}restore(t){n(this,Nt).restore(t,n(this,Qr));const e=Object.getPrototypeOf(n(this,Es));return e===null?this:(p(this,Es,e),p(this,Cs,Object.getPrototypeOf(n(this,Cs))),this)}recordOpenMarker(t){return n(this,Nt).recordOpenMarker(t,n(this,Qr)),this}getOpenMarker(){return n(this,Nt).getOpenMarker()}recordCloseMarker(t){return n(this,Nt).recordCloseMarker(t,n(this,Qr)),this}beginMarkedContent(t){return n(this,Nt).beginMarkedContent(t),this}endMarkedContent(t){return n(this,Nt).endMarkedContent(t,n(this,Qr)),this}pushBaseTransform(t){return n(this,Nt).pushBaseTransform(t),this}popBaseTransform(){return n(this,Nt).popBaseTransform(),this}recordSimpleData(t,e){return n(this,Es)[t]=e,this}recordIncrementalData(t,e){return n(this,Cs)[t].push(e),this}resetIncrementalData(t,e){return n(this,Cs)[t].length=0,this}recordNamedData(t,e){return n(this,po).set(t,e),this}recordSimpleDataFromNamed(t,e,s){n(this,Es)[t]=n(this,po).get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(Il,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in n(this,Es)&&this.recordFutureForcedDependency(e,n(this,Es)[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of n(this,Fi))this.recordFutureForcedDependency(Il,t);return this}resetBBox(t){return n(this,Nt).resetBBox(t),this}recordClipBox(t,e,s,i,r,a){return n(this,Nt).recordClipBox(t,e,s,i,r,a),this}recordBBox(t,e,s,i,r,a){return n(this,Nt).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,cc).get(s),c!==!1&&(h=[0,0,0,0],B.axialAlignedBoundingBox(l,s.fontMatrix,h),(i!==1||r!==0||a!==0)&&C1(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 u=o();return l&&h&&c===void 0&&(c=h[0]<=r-u.actualBoundingBoxLeft&&h[2]>=r+u.actualBoundingBoxRight&&h[1]<=a-u.actualBoundingBoxAscent&&h[3]>=a+u.actualBoundingBoxDescent,n(this,cc).set(s,c),c)?this.recordBBox(t,e,h[0],h[2],h[1],h[3]):this.recordBBox(t,e,r-u.actualBoundingBoxLeft,r+u.actualBoundingBoxRight,a-u.actualBoundingBoxAscent,a+u.actualBoundingBoxDescent)}recordFullPageBBox(t){return n(this,Nt).recordFullPageBBox(t),this}getSimpleIndex(t){return n(this,Es)[t]}recordDependencies(t,e){const s=n(this,Fi),i=n(this,Es),r=n(this,Cs);for(const a of e)a in n(this,Es)?s.add(i[a]):a in r&&r[a].forEach(s.add,s);return this}recordNamedDependency(t,e){return n(this,po).has(e)&&n(this,Fi).add(n(this,po).get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[Il]),n(this,Kr)){const i=Uv(n(this,Kr),t),{dependencies:r}=i;n(this,Fi).forEach(r.add,r),n(this,Nt)._savesStack.forEach(r.add,r),n(this,Nt)._markedContentStack.forEach(r.add,r),r.delete(t),i.isRenderingOperation=!0}const s=!e&&t===n(this,Nt)._pendingBBoxIdx;return n(this,Nt).recordOperation(t,e,[n(this,Fi),n(this,Nt)._savesStack,n(this,Nt)._markedContentStack]),s&&n(this,Fi).clear(),this}recordShowTextOperation(t,e=!1){const s=Array.from(n(this,Fi));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,Nt)._pendingBBoxIdx;return n(this,Nt).bboxToClipBoxDropOperation(t),s&&n(this,Fi).clear(),this}take(){return n(this,cc).clear(),n(this,Nt).take()}takeDebugMetadata(){return n(this,Kr)}}Es=new WeakMap,Cs=new WeakMap,po=new WeakMap,Fi=new WeakMap,cc=new WeakMap,Kr=new WeakMap,Qr=new WeakMap,Nt=new WeakMap;var Bt,de,Oi,hc,dc;const fv=class fv{constructor(t,e,s){m(this,Bt);m(this,de);m(this,Oi);m(this,hc,0);m(this,dc,0);if(t instanceof fv&&n(t,Oi)===!!s)return t;p(this,Bt,t),p(this,de,e),p(this,Oi,!!s)}get clipBox(){return n(this,Bt).clipBox}growOperationsCount(){throw new Error("Unreachable")}save(t){return Yt(this,dc)._++,n(this,Bt).save(n(this,de)),this}restore(t){return n(this,dc)>0&&(n(this,Bt).restore(n(this,de)),Yt(this,dc)._--),this}recordOpenMarker(t){return Yt(this,hc)._++,this}getOpenMarker(){return n(this,hc)>0?n(this,de):n(this,Bt).getOpenMarker()}recordCloseMarker(t){return Yt(this,hc)._--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return n(this,Bt).pushBaseTransform(t),this}popBaseTransform(){return n(this,Bt).popBaseTransform(),this}recordSimpleData(t,e){return n(this,Bt).recordSimpleData(t,n(this,de)),this}recordIncrementalData(t,e){return n(this,Bt).recordIncrementalData(t,n(this,de)),this}resetIncrementalData(t,e){return n(this,Bt).resetIncrementalData(t,n(this,de)),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return n(this,Bt).recordSimpleDataFromNamed(t,e,n(this,de)),this}recordFutureForcedDependency(t,e){return n(this,Bt).recordFutureForcedDependency(t,n(this,de)),this}inheritSimpleDataAsFutureForcedDependencies(t){return n(this,Bt).inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return n(this,Bt).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return n(this,Oi)||n(this,Bt).resetBBox(n(this,de)),this}recordClipBox(t,e,s,i,r,a){return n(this,Oi)||n(this,Bt).recordClipBox(n(this,de),e,s,i,r,a),this}recordBBox(t,e,s,i,r,a){return n(this,Oi)||n(this,Bt).recordBBox(n(this,de),e,s,i,r,a),this}recordCharacterBBox(t,e,s,i,r,a,o){return n(this,Oi)||n(this,Bt).recordCharacterBBox(n(this,de),e,s,i,r,a,o),this}recordFullPageBBox(t){return n(this,Oi)||n(this,Bt).recordFullPageBBox(n(this,de)),this}getSimpleIndex(t){return n(this,Bt).getSimpleIndex(t)}recordDependencies(t,e){return n(this,Bt).recordDependencies(n(this,de),e),this}recordNamedDependency(t,e){return n(this,Bt).recordNamedDependency(n(this,de),e),this}recordOperation(t){return n(this,Bt).recordOperation(n(this,de),!0),this}recordShowTextOperation(t){return n(this,Bt).recordShowTextOperation(n(this,de),!0),this}bboxToClipBoxDropOperation(t){return n(this,Oi)||n(this,Bt).bboxToClipBoxDropOperation(n(this,de),!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}};Bt=new WeakMap,de=new WeakMap,Oi=new WeakMap,hc=new WeakMap,dc=new WeakMap;let td=fv;const ai={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 go,mo,vo,bo,yo,Id;const qh=class qh{constructor(t){m(this,go);m(this,mo);m(this,vo,4);m(this,bo,0);m(this,yo,new(n(qh,Id))(n(this,vo)*6));p(this,go,t.width),p(this,mo,t.height)}record(t,e,s,i){if(n(this,bo)===n(this,vo)){p(this,vo,n(this,vo)*2);const o=new(n(qh,Id))(n(this,vo)*6);o.set(n(this,yo)),p(this,yo,o)}const r=Xt(t);let a;if(i[0]!==1/0){const o=br.slice();B.axialAlignedBoundingBox([0,-s,e,0],r,o);const l=B.intersect(i,o);if(!l)return;const[c,h,u,f]=l;if(c!==o[0]||h!==o[1]||u!==o[2]||f!==o[3]){const g=Math.atan2(r[1],r[0]),y=Math.abs(Math.sin(g)),v=Math.abs(Math.cos(g));if(y<1e-6||v<1e-6||Math.abs(y-v)<1e-6)a=[c,h,c,f,u,h];else{const w=u-c,S=f-h,x=y*y,A=v*v,_=v*y,E=A-x,k=(S*A-w*_)/E,P=(S*_-w*x)/E;a=[c+P,h,c,h+k,u,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,go),a[1]/=n(this,mo),a[2]/=n(this,go),a[3]/=n(this,mo),a[4]/=n(this,go),a[5]/=n(this,mo),n(this,yo).set(a,n(this,bo)*6),Yt(this,bo)._++}take(){return n(this,yo).subarray(0,n(this,bo)*6)}};go=new WeakMap,mo=new WeakMap,vo=new WeakMap,bo=new WeakMap,yo=new WeakMap,Id=new WeakMap,m(qh,Id,Ht.isFloat16ArraySupported?Float16Array:Float32Array);let zg=qh;var uc,Ri,gp,iy;class P1{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){m(this,gp);m(this,uc,new Set);m(this,Ri,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=b(this,gp,iy).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,uc).clear(),n(this,Ri)){const{adoptedStyleSheets:t}=this._document;t!=null&&t.includes(n(this,Ri))&&(this._document.adoptedStyleSheets=t.filter(e=>e!==n(this,Ri))),p(this,Ri,null)}this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!(!t||n(this,uc).has(t.loadedName))){if(ae(!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,uc).add(i),s==null||s(t)}catch{ht(`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 ht(`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 ot(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return ot(this,"isSyncFontLoadingSupported",ti||Ht.platform.isFirefox)}_queueLoadingCallback(t){function e(){for(ae(!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 ot(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(E,k){return E.charCodeAt(k)<<24|E.charCodeAt(k+1)<<16|E.charCodeAt(k+2)<<8|E.charCodeAt(k+3)&255}function i(E){return String.fromCharCode(E>>24&255,E>>16&255,E>>8&255,E&255)}function r(E,k,P,L){const I=E.substring(0,k),D=E.substring(k+P);return I+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 u(E,k){if(++h>30){ht("Load test font never loaded."),k();return}if(c.font="30px "+E,c.fillText(".",0,20),c.getImageData(0,0,1,1).data[3]>0){k();return}setTimeout(u.bind(null,E,k))}const f=`lt${Date.now()}${this.loadTestFontId++}`;let g=this._loadTestFont;g=r(g,976,f.length,f);const v=16,w=1482184792;let S=s(g,v);for(a=0,o=f.length-3;a{_.remove(),e.complete()})}}uc=new WeakMap,Ri=new WeakMap,gp=new WeakSet,iy=function(){var e;if(n(this,Ri))return n(this,Ri);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,Ri,i)}}return this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement)),p(this,Ri,this.styleElement.sheet)};var $t;class M1{constructor(t,e=null,s,i){M(this,"compiledGlyphs",Object.create(null));m(this,$t);p(this,$t,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){ht(`getPathGenerator - ignoring character: "${a}".`)}const r=Ab(i==null?void 0:i.path);return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=r}get black(){return n(this,$t).black}get bold(){return n(this,$t).bold}get disableFontFace(){return n(this,$t).disableFontFace}set disableFontFace(t){ot(this,"disableFontFace",!!t)}get fontExtraProperties(){return n(this,$t).fontExtraProperties}get isInvalidPDFjsFont(){return n(this,$t).isInvalidPDFjsFont}get isType3Font(){return n(this,$t).isType3Font}get italic(){return n(this,$t).italic}get missingFile(){return n(this,$t).missingFile}get remeasure(){return n(this,$t).remeasure}get vertical(){return n(this,$t).vertical}get ascent(){return n(this,$t).ascent}get defaultWidth(){return n(this,$t).defaultWidth}get descent(){return n(this,$t).descent}get bbox(){return n(this,$t).bbox}get fontMatrix(){return n(this,$t).fontMatrix}get fallbackName(){return n(this,$t).fallbackName}get loadedName(){return n(this,$t).loadedName}get mimetype(){return n(this,$t).mimetype}get name(){return n(this,$t).name}get data(){return n(this,$t).data}clearData(){n(this,$t).clearData()}get cssFontInfo(){return n(this,$t).cssFontInfo}get systemFontInfo(){return n(this,$t).systemFontInfo}get defaultVMetrics(){return n(this,$t).defaultVMetrics}}$t=new WeakMap;class ny{}M(ny,"strings",["fontFamily","fontWeight","italicAngle"]);class ry{}M(ry,"strings",["css","loadedName","baseFontName","src"]);const Je=class Je{};M(Je,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]),M(Je,"numbers",["ascent","defaultWidth","descent"]),M(Je,"strings",["fallbackName","loadedName","mimetype","name"]),M(Je,"OFFSET_NUMBERS",Math.ceil(Je.bools.length*2/8)),M(Je,"OFFSET_BBOX",Je.OFFSET_NUMBERS+Je.numbers.length*8),M(Je,"OFFSET_FONT_MATRIX",Je.OFFSET_BBOX+1+8),M(Je,"OFFSET_DEFAULT_VMETRICS",Je.OFFSET_FONT_MATRIX+1+48),M(Je,"OFFSET_STRINGS",Je.OFFSET_DEFAULT_VMETRICS+1+6);let Ls=Je;class gs{}M(gs,"KIND",0),M(gs,"HAS_BBOX",1),M(gs,"HAS_BACKGROUND",2),M(gs,"SHADING_TYPE",3),M(gs,"N_COORD",4),M(gs,"N_COLOR",8),M(gs,"N_STOP",12),M(gs,"N_FIGURES",16);var Dd,mp,fc,pc,bf;class I1{constructor(t){m(this,pc);m(this,Dd);m(this,mp,new TextDecoder);m(this,fc);p(this,Dd,t),p(this,fc,new DataView(t))}get fontFamily(){return b(this,pc,bf).call(this,0)}get fontWeight(){return b(this,pc,bf).call(this,1)}get italicAngle(){return b(this,pc,bf).call(this,2)}}Dd=new WeakMap,mp=new WeakMap,fc=new WeakMap,pc=new WeakSet,bf=function(t){ae(t>s&3;return i===0?void 0:i===2},yf=function(t){return ae(t0){v=br.slice();for(let w=0,S=c.length;wtypeof d=="object"&&Number.isInteger(d==null?void 0:d.num)&&d.num>=0&&Number.isInteger(d==null?void 0:d.gen)&&d.gen>=0,B1=d=>typeof d=="object"&&typeof(d==null?void 0:d.name)=="string",$1=u1.bind(null,Gg,B1);var Wn,bp;class U1{constructor(){m(this,Wn,new Map);m(this,bp,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};n(this,bp).then(()=>{for(const[i]of n(this,Wn))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){ht("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(t,e);i=()=>r.removeEventListener("abort",a),r.addEventListener("abort",a)}n(this,Wn).set(e,i)}removeEventListener(t,e){const s=n(this,Wn).get(e);s==null||s(),n(this,Wn).delete(e)}terminate(){for(const[,t]of n(this,Wn))t==null||t();n(this,Wn).clear()}}Wn=new WeakMap,bp=new WeakMap;const sf={DATA:1,ERROR:2},ye={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Hv(){}function ws(d){if(d instanceof ka||d instanceof bg||d instanceof vg||d instanceof Zf||d instanceof ag)return d;switch(d instanceof Error||typeof d=="object"&&d!==null||Ct('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),d.name){case"AbortException":return new ka(d.message);case"InvalidPDFException":return new bg(d.message);case"PasswordException":return new vg(d.message,d.code);case"ResponseException":return new Zf(d.message,d.status,d.missing);case"UnknownErrorException":return new ag(d.message,d.details)}return new ag(d.message,d.toString())}var vc,xi,ay,oy,ly,Af;class Ih{constructor(t,e,s){m(this,xi);m(this,vc,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",b(this,xi,ay).bind(this),{signal:n(this,vc).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:ye.PULL,streamId:r,desiredSize:c.desiredSize}),h.promise},cancel:c=>{ae(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:ye.CANCEL,streamId:r,reason:ws(c)}),h.promise}},s)}destroy(){var t;(t=n(this,vc))==null||t.abort(),p(this,vc,null)}}vc=new WeakMap,xi=new WeakSet,ay=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){b(this,xi,ly).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===sf.DATA)i.resolve(t.data);else if(t.callback===sf.ERROR)i.reject(ws(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:sf.DATA,callbackId:t.callbackId,data:a})},function(a){r.postMessage({sourceName:s,targetName:i,callback:sf.ERROR,callbackId:t.callbackId,reason:ws(a)})});return}if(t.streamId){b(this,xi,oy).call(this,t);return}e(t.data)},oy=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,u){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:ye.ENQUEUE,streamId:e,chunk:c},u)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:ye.CLOSE,streamId:e}),delete a.streamSinks[e])},error(c){ae(c instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:ye.ERROR,streamId:e,reason:ws(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:ye.START_COMPLETE,streamId:e,success:!0})},function(c){r.postMessage({sourceName:s,targetName:i,stream:ye.START_COMPLETE,streamId:e,reason:ws(c)})})},ly=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 ye.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject(ws(t.reason));break;case ye.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject(ws(t.reason));break;case ye.PULL:if(!o){r.postMessage({sourceName:s,targetName:i,stream:ye.PULL_COMPLETE,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,Promise.try(o.onPull||Hv).then(function(){r.postMessage({sourceName:s,targetName:i,stream:ye.PULL_COMPLETE,streamId:e,success:!0})},function(c){r.postMessage({sourceName:s,targetName:i,stream:ye.PULL_COMPLETE,streamId:e,reason:ws(c)})});break;case ye.ENQUEUE:if(ae(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case ye.CLOSE:if(ae(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),b(this,xi,Af).call(this,a,e);break;case ye.ERROR:ae(a,"error should have stream controller"),a.controller.error(ws(t.reason)),b(this,xi,Af).call(this,a,e);break;case ye.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject(ws(t.reason)),b(this,xi,Af).call(this,a,e);break;case ye.CANCEL:if(!o)break;const l=ws(t.reason);Promise.try(o.onCancel||Hv,l).then(function(){r.postMessage({sourceName:s,targetName:i,stream:ye.CANCEL_COMPLETE,streamId:e,success:!0})},function(c){r.postMessage({sourceName:s,targetName:i,stream:ye.CANCEL_COMPLETE,streamId:e,reason:ws(c)})}),o.sinkCapability.reject(l),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},Af=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 yp;class cy{constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:s=null}){m(this,yp,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,yp)[t]} data at: ${i}`)})}async _fetch(t,e){Ct("Abstract method `_fetch` called.")}}yp=new WeakMap;class zv extends cy{async _fetch(t,e){const s=e==="cMapUrl"&&!t.endsWith(".bcmap")?"text":"bytes",i=await ev(t,s);return i instanceof Uint8Array?i:Hp(i)}}var Ld;class hy{constructor({enableHWA:t=!1}){m(this,Ld,!1);p(this,Ld,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,Ld)})}}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.")}}Ld=new WeakMap;class H1 extends hy{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 dy{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 So,bc,Xn,hn,Ie,xo,Jr,V,Te,Dh,Er,Sf,Oa,uy,jg,Ra,Lh,Fh,Wg,Oh,fy,py;class z1 extends dy{constructor({docId:e,ownerDocument:s=globalThis.document}){super();m(this,V);m(this,So);m(this,bc);m(this,Xn);m(this,hn);m(this,Ie);m(this,xo);m(this,Jr,0);p(this,hn,e),p(this,Ie,s)}addFilter(e){if(!e)return"none";let s=n(this,V,Te).get(e);if(s)return s;const[i,r,a]=b(this,V,Sf).call(this,e),o=e.length===1?i:`${i}${r}${a}`;if(s=n(this,V,Te).get(o),s)return n(this,V,Te).set(e,s),s;const l=`g_${n(this,hn)}_transfer_map_${Yt(this,Jr)._++}`,c=b(this,V,Oa).call(this,l);n(this,V,Te).set(e,c),n(this,V,Te).set(o,c);const h=b(this,V,Ra).call(this,l);return b(this,V,Fh).call(this,i,r,a,h),c}addHCMFilter(e,s){var y;const i=`${e}-${s}`,r="base";let a=n(this,V,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,V,Dh).set(r,a)),!e||!s))return a.url;const o=b(this,V,Oh).call(this,e);e=B.makeHexColor(...o);const l=b(this,V,Oh).call(this,s);if(s=B.makeHexColor(...l),n(this,V,Er).style.color="",e==="#000000"&&s==="#ffffff"||e===s)return a.url;const c=new Array(256);for(let v=0;v<=255;v++){const w=v/255;c[v]=w<=.03928?w/12.92:((w+.055)/1.055)**2.4}const h=c.join(","),u=`g_${n(this,hn)}_hcm_filter`,f=a.filter=b(this,V,Ra).call(this,u);b(this,V,Fh).call(this,h,h,h,f),b(this,V,jg).call(this,f);const g=(v,w)=>{const S=o[v]/255,x=l[v]/255,A=new Array(w+1);for(let _=0;_<=w;_++)A[_]=S+_/w*(x-S);return A.join(",")};return b(this,V,Fh).call(this,g(0,5),g(1,5),g(2,5),f),a.url=b(this,V,Oa).call(this,u),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"||!Ht.platform.isFirefox?null:{"backdrop-filter":s,"background-color":"transparent"}}addAlphaFilter(e){let s=n(this,V,Te).get(e);if(s)return s;const[i]=b(this,V,Sf).call(this,[e]),r=`alpha_${i}`;if(s=n(this,V,Te).get(r),s)return n(this,V,Te).set(e,s),s;const a=`g_${n(this,hn)}_alpha_map_${Yt(this,Jr)._++}`,o=b(this,V,Oa).call(this,a);n(this,V,Te).set(e,o),n(this,V,Te).set(r,o);const l=b(this,V,Ra).call(this,a);return b(this,V,Wg).call(this,i,l),o}addLuminosityFilter(e){let s=n(this,V,Te).get(e||"luminosity");if(s)return s;let i,r;if(e?([i]=b(this,V,Sf).call(this,[e]),r=`luminosity_${i}`):r="luminosity",s=n(this,V,Te).get(r),s)return n(this,V,Te).set(e,s),s;const a=`g_${n(this,hn)}_luminosity_map_${Yt(this,Jr)._++}`,o=b(this,V,Oa).call(this,a);n(this,V,Te).set(e,o),n(this,V,Te).set(r,o);const l=b(this,V,Ra).call(this,a);return b(this,V,uy).call(this,l),e&&b(this,V,Wg).call(this,i,l),o}addKnockoutFilter(e=0){const s=e>0?Math.min(1/e,1e6):1e6,i=`knockout_${s}`,r=n(this,V,Te).get(i);if(r)return r;const a=`g_${n(this,hn)}_knockout_filter_${Yt(this,Jr)._++}`,o=b(this,V,Oa).call(this,a);n(this,V,Te).set(i,o);const l=b(this,V,Ra).call(this,a),c=n(this,Ie).createElementNS(Os,"feComponentTransfer");l.append(c);const h=n(this,Ie).createElementNS(Os,"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,V,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,V,Dh).set(e,l)),!s||!i))return l.url;const[c,h]=[s,i].map(b(this,V,Oh).bind(this));let u=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(b(this,V,py).bind(this));f{const k=new Array(256),P=(f-u)/E,L=A/255,I=(_-A)/(255*E);let D=0;for(let R=0;R<=E;R++){const W=Math.round(u+R*P),Q=L+R*I;for(let Y=D;Y<=W;Y++)k[Y]=Q;D=W+1}for(let R=D;R<256;R++)k[R]=k[D-1];return k.join(",")},w=`g_${n(this,hn)}_hcm_${e}_filter`,S=l.filter=b(this,V,Ra).call(this,w);return b(this,V,jg).call(this,S),b(this,V,Fh).call(this,v(g[0],y[0],5),v(g[1],y[1],5),v(g[2],y[2],5),S),l.url=b(this,V,Oa).call(this,w),l.url}destroy(e=!1){var s,i,r,a;e&&((s=n(this,xo))!=null&&s.size)||((i=n(this,Xn))==null||i.parentNode.parentNode.remove(),p(this,Xn,null),(r=n(this,bc))==null||r.clear(),p(this,bc,null),(a=n(this,xo))==null||a.clear(),p(this,xo,null),p(this,Jr,0))}}So=new WeakMap,bc=new WeakMap,Xn=new WeakMap,hn=new WeakMap,Ie=new WeakMap,xo=new WeakMap,Jr=new WeakMap,V=new WeakSet,Te=function(){return n(this,bc)||p(this,bc,new Map)},Dh=function(){return n(this,xo)||p(this,xo,new Map)},Er=function(){if(!n(this,Xn)){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(Os,"svg");i.setAttribute("width",0),i.setAttribute("height",0),p(this,Xn,n(this,Ie).createElementNS(Os,"defs")),e.append(i),i.append(n(this,Xn)),n(this,Ie).body.append(e)}return n(this,Xn)},Sf=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 u=h.join(",");return[u,u,u]}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(",")]},Oa=function(e){if(n(this,So)===void 0){p(this,So,"");const s=n(this,Ie).URL;s!==n(this,Ie).baseURI&&(zp(s)?ht('#createUrl: ignore "data:"-URL for performance reasons.'):p(this,So,vb(s,"")))}return`url(${n(this,So)}#${e})`},uy=function(e){const s=n(this,Ie).createElementNS(Os,"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)},jg=function(e){const s=n(this,Ie).createElementNS(Os,"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)},Ra=function(e){const s=n(this,Ie).createElementNS(Os,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),n(this,V,Er).append(s),s},Lh=function(e,s,i){const r=n(this,Ie).createElementNS(Os,s);r.setAttribute("type","discrete"),r.setAttribute("tableValues",i),e.append(r)},Fh=function(e,s,i,r){const a=n(this,Ie).createElementNS(Os,"feComponentTransfer");r.append(a),b(this,V,Lh).call(this,a,"feFuncR",e),b(this,V,Lh).call(this,a,"feFuncG",s),b(this,V,Lh).call(this,a,"feFuncB",i)},Wg=function(e,s){const i=n(this,Ie).createElementNS(Os,"feComponentTransfer");s.append(i),b(this,V,Lh).call(this,i,"feFuncA",e)},Oh=function(e){return n(this,V,Er).style.color=e,qu(getComputedStyle(n(this,V,Er)).getPropertyValue("color"))},fy=function(e){return n(this,V,Er).style.color=e,Xu(getComputedStyle(n(this,V,Er)).getPropertyValue("color"))},py=function(e){const[s,i,r,a]=b(this,V,fy).call(this,e);if(a===1)return[s,i,r];const[o,l,c]=b(this,V,Oh).call(this,"Canvas");return[cg(s,o,a),cg(i,l,a),cg(r,c,a)]};function cg(d,t,e){return Math.round(e*d+(1-e)*t)}ti&&ht("Please use the `legacy` build in Node.js environments.");async function V1(d){const e=await process.getBuiltinModule("fs/promises").readFile(d);return new Uint8Array(e)}class G1 extends dy{}class j1 extends hy{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class W1 extends cy{async _fetch(t,e){return V1(t)}}function gy({src:d,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=Ht.isLittleEndian?4278190080:255,[l,c]=a?[r,o]:[o,r],h=s>>3,u=s&7,f=l^c,g=d.length;e=new Uint32Array(e.buffer);let y=0;for(let v=0;v>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(u===0)continue;const w=t>7-S&1)&f}return{srcPos:t,destPos:y}}function X1({src:d,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(d.buffer,t,l),h=Ht.isLittleEndian?4278190080:255;if(Ht.isLittleEndian){for(;a>>24|f<<8|h,e[s+2]=f>>>16|g<<16|h,e[s+3]=g>>>8|h}for(let u=a*4,f=t+o;u>>8|h,e[s+2]=f<<16|g>>>16|h,e[s+3]=g<<8|h}for(let u=a*4,f=t+o;u u : Uniforms; struct VertexInput { @location(0) position : vec2, @location(1) color : vec4, }; struct VertexOutput { @builtin(position) position : vec4, @location(0) color : vec3, }; @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( ((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 { return vec4(in.color, 1.0); } `;var wp,qn,Eo,yc,Ap,my;class Y1{constructor(){m(this,Ap);m(this,wp,null);m(this,qn,null);m(this,Eo,null);m(this,yc,null)}init(){return n(this,wp)||p(this,wp,b(this,Ap,my).call(this))}get isReady(){return n(this,qn)!==null}loadMeshShader(){if(!n(this,qn)||n(this,Eo))return;const t=n(this,qn).createShaderModule({code:q1});p(this,Eo,n(this,qn).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,yc)}]},primitive:{topology:"triangle-list"}}))}draw(t,e,s,i,r,a,o,l){this.loadMeshShader();const c=n(this,qn),{offsetX:h,offsetY:u,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 v=c.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});e.byteLength>0&&c.queue.writeBuffer(v,0,e);const w=c.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});c.queue.writeBuffer(w,0,new Float32Array([h,u,f,g,a,o,l,0]));const S=c.createBindGroup({layout:n(this,Eo).getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:w}}]}),x=new OffscreenCanvas(a,o),A=x.getContext("webgpu");A.configure({device:c,format:n(this,yc),alphaMode:r?"opaque":"premultiplied"});const _=r?{r:r[0]/255,g:r[1]/255,b:r[2]/255,a:1}:{r:0,g:0,b:0,a:0},E=c.createCommandEncoder(),k=E.beginRenderPass({colorAttachments:[{view:A.getCurrentTexture().createView(),clearValue:_,loadOp:"clear",storeOp:"store"}]});return s>0&&(k.setPipeline(n(this,Eo)),k.setBindGroup(0,S),k.setVertexBuffer(0,y),k.setVertexBuffer(1,v),k.draw(s)),k.end(),c.queue.submit([E.finish()]),y.destroy(),v.destroy(),w.destroy(),x.transferToImageBitmap()}}wp=new WeakMap,qn=new WeakMap,Eo=new WeakMap,yc=new WeakMap,Ap=new WeakSet,my=async function(){var t;if(!((t=globalThis.navigator)!=null&&t.gpu))return!1;try{const e=await navigator.gpu.requestAdapter();return e?(p(this,yc,navigator.gpu.getPreferredCanvasFormat()),p(this,qn,await e.requestDevice()),!0):!1}catch{return!1}};const Vp=new Y1;function K1(){return Vp.init()}function Q1(){return Vp.isReady}function J1(){Vp.loadMeshShader()}function Z1(d,t,e,s,i,r,a,o){return Vp.draw(d,t,e,s,i,r,a,o)}const Xe={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function xf(d,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),d.clip(i)}class rv{isModifyingCurrentTransform(){return!1}getPattern(){Ct("Abstract method `getPattern` called.")}}class tx extends rv{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===Xe.STROKE||i===Xe.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]),v=Math.hypot(f[2],f[3]),w=(f[0]*f[2]+f[1]*f[3])/(y*v);if(Math.abs(w)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,v=(l[s*2]+t.offsetX)*t.scaleX,w=(l[s*2+1]+t.offsetY)*t.scaleY,S=(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[r*4+1],E=c[r*4+2],k=c[a*4],P=c[a*4+1],L=c[a*4+2],I=c[o*4],D=c[o*4+1],R=c[o*4+2],W=Math.round(y),Q=Math.round(x);let Y,yt,T,j,Ft,St,ke,_t;for(let Gt=W;Gt<=Q;Gt++){if(Gtx?nt=1:w===x?nt=0:nt=(w-Gt)/(w-x),Y=v-(v-S)*nt,yt=k-(k-I)*nt,T=P-(P-D)*nt,j=L-(L-R)*nt}let z;Gtx?z=1:z=(y-Gt)/(y-x),Ft=g-(g-S)*z,St=A-(A-I)*z,ke=_-(_-D)*z,_t=E-(E-R)*z;const U=Math.round(Math.min(Y,Ft)),dt=Math.round(Math.max(Y,Ft));let lt=u*Gt+U*4;for(let nt=U;nt<=dt;nt++)z=(Y-nt)/(Y-Ft),z<0?z=0:z>1&&(z=1),h[lt++]=yt-(yt-St)*z|0,h[lt++]=T-(T-ke)*z|0,h[lt++]=j-(j-_t)*z|0,h[lt++]=255}}class sx extends rv{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,J1()}_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,u=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/u:1,y=h?h/f:1,v={coords:this._posData,colors:this._colData,offsetX:-o,offsetY:-l,scaleX:1/g,scaleY:1/y},w=u+4,S=f+4,x=s.create(w,S);if(Q1()&&this._vertexCount>48)x.context.drawImage(Z1(this._posData,this._colData,this._vertexCount,v,e,w,S,2),0,0);else{const A=x.context.createImageData(u,f);if(e){const _=A.data;for(let E=0,k=_.length;Ec+1e-6||e>h+1e-6)return null;const u=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<=u&&y<=g?[u,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,u=this.canvasGraphicsFactory.createCanvasGraphics(h,e);return u.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(u,this.paintType,this.color),h.translate(-s.scale*r,-i.scale*a),u.transform(0,s.scale,0,0,i.scale,0,0),h.save(),(f=u.dependencyTracker)==null||f.save(),this.clipBbox(u,r,a,o,l),u.baseTransform=Xt(u.ctx),u.executeOperatorList(this.operatorList),u.endDrawing(),(g=u.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,u=t.dependencyTracker;if(u&&(t.dependencyTracker=new td(u,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,v]=this._getCombinedScales(),w=this.getSizeAndScale(f,this.ctx.canvas.width,y),S=this.getSizeAndScale(g,this.ctx.canvas.height,v),x=this._renderTileCanvas(t,a,w,S);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=Xt(t.ctx),t.executeOperatorList(this.operatorList),t.baseTransform=t.baseTransformStack.pop();t.restore(),u&&(t.dependencyTracker=u)}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),Up("TilingType: "+this.tilingType);const[u,f]=this._getCombinedScales();let g=o,y=l,v=!1,w=!1;Math.ceil(c*u)>=Math.ceil(o*u)?g=c:v=!0,Math.ceil(h*f)>=Math.ceil(l*f)?y=h:w=!0;const S=this.getSizeAndScale(g,this.ctx.canvas.width,u),x=this.getSizeAndScale(y,this.ctx.canvas.height,f),A=this._renderTileCanvas(t,e,S,x);if(v||w){const _=A.canvas;v&&(g=c),w&&(y=h);const E=this.getSizeAndScale(g,this.ctx.canvas.width,u),k=this.getSizeAndScale(y,this.ctx.canvas.height,f),P=E.size,L=k.size,I=t.canvasFactory.create(P,L),D=I.context,R=v?Math.floor(o/c):0,W=w?Math.floor(l/h):0;for(let Q=0;Q<=R;Q++)for(let Y=0;Y<=W;Y++)D.drawImage(_,P*Q,L*Y,P,L,0,0,P,L);return t.canvasFactory.destroy(A),{canvas:I.canvas,canvasEntry:I,scaleX:E.scale,scaleY:k.scale,offsetX:s,offsetY:i}}return{canvas:A.canvas,canvasEntry:A,scaleX:S.scale,scaleY:x.scale,offsetX:s,offsetY:i}}getSizeAndScale(t,e,s){const i=Math.max(Sp.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],Xt(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 Vv.COLORED:const{fillStyle:a,strokeStyle:o}=this.ctx;i.fillStyle=r.fillColor=a,i.strokeStyle=r.strokeColor=o;break;case Vv.UNCOLORED:i.fillStyle=i.strokeStyle=s,r.fillColor=r.strokeColor=s;break;default:throw new l1(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,i,r){const a=i!==Xe.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(Sp,"MAX_PATTERN_SIZE",3e3);let Xh=Sp;const rx=16,ax=100,ox=15,Gv=10,Ps=16,hg=new DOMMatrix,ei=new Float32Array(2);function jv(d,t){if(d._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=d[s];typeof i!="function"||typeof t[s]!="function"||(e.set(s,i),d[s]=function(...r){return t[s](...r),i.apply(this,r)})}d._removeMirroring=()=>{for(const[s,i]of e)d[s]=i;delete d._removeMirroring}}function nf(d,t,e,s,i,r,a,o,l,c){const[h,u,f,g,y,v]=Xt(d);if(u===0&&f===0){const x=a*h+y,A=Math.round(x),_=o*g+v,E=Math.round(_),k=(a+l)*h+y,P=Math.abs(Math.round(k)-A)||1,L=(o+c)*g+v,I=Math.abs(Math.round(L)-E)||1;return d.setTransform(Math.sign(h),0,0,Math.sign(g),A,E),d.drawImage(t,e,s,i,r,0,0,P,I),d.setTransform(h,u,f,g,y,v),[P,I]}if(h===0&&g===0){const x=o*f+y,A=Math.round(x),_=a*u+v,E=Math.round(_),k=(o+c)*f+y,P=Math.abs(Math.round(k)-A)||1,L=(a+l)*u+v,I=Math.abs(Math.round(L)-E)||1;return d.setTransform(0,Math.sign(u),Math.sign(f),0,A,E),d.drawImage(t,e,s,i,r,0,0,I,P),d.setTransform(h,u,f,g,y,v),[I,P]}d.drawImage(t,e,s,i,r,a,o,l,c);const w=Math.hypot(h,u),S=Math.hypot(f,g);return[w*l,S*c]}class Wv{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",gg);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",Ee.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",Ga.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=Xe.FILL,e=null){const s=this.minMax.slice();if(t===Xe.STROKE){e||Ct("Stroke bounding box must include transform."),B.singularValueDecompose2dScale(e,ei);const i=ei[0]*this.lineWidth/2,r=ei[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(Ga,0)}getClippedPathBoundingBox(t=Xe.FILL,e=null){return B.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Xv(d,t){const{width:e,height:s,kind:i}=t,r=s%Ps,a=(s-r)/Ps,o=r===0?a:a+1,l=d.createImageData(e,Ps);let c=0;const h=t.data,u=l.data;let f;if(i===df.GRAYSCALE_1BPP)for(f=0;fGv&&typeof s=="function",u=h?Date.now()+ox:0;let f=0;const g=this.commonObjs,y=this.objs;let v,w;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(v=o[l],w=a[l]??null,v!==Ji.dependency)w===null?this[v](l):this[v](l,...w);else for(const x of w){(S=this.dependencyTracker)==null||S.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>Gv){if(Date.now()>u)return s(),l;f=0}}}endDrawing(){b(this,Z,Xg).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,dn))b(this,Z,Ef).call(this,t);n(this,dn).length=0,p(this,Co,null),p(this,_o,null),p(this,ko,null),p(this,To,null),p(this,Po,1),p(this,Io,null),p(this,Zr,0),p(this,$s,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(),b(this,Z,qg).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,u=i;for(;l>2&&h>1||c>2&&u>1;){let S=h,x=u;l>2&&h>1&&(S=Math.ceil(h/2),l/=h/S),c>2&&u>1&&(x=Math.ceil(u/2),c/=u/x),o.push({newWidth:S,newHeight:x}),h=S,u=x}if(o.length===0)return{img:t,paintWidth:s,paintHeight:i,tmpCanvas:null};if(o.length===1){const{newWidth:S,newHeight:x}=o[0],A=this.canvasFactory.create(S,x);return A.context.drawImage(t,0,0,s,i,0,0,S,x),{img:A.canvas,paintWidth:S,paintHeight:x,tmpCanvas:A}}let f=this.canvasFactory.create(1,1),g=this.canvasFactory.create(1,1),y=s,v=i,w=t;for(const{newWidth:S,newHeight:x}of o)this.canvasFactory.reset(g,S,x),g.context.drawImage(w,0,0,y,v,0,0,S,x),[f,g]=[g,f],w=f.canvas,y=S,v=x;return this.canvasFactory.destroy(g),{img:f.canvas,paintWidth:y,paintHeight:v,tmpCanvas:f}}_createMaskCanvas(t,e){var R,W;const s=this.ctx,{width:i,height:r}=e,a=this.current.fillColor,o=this.current.patternFill,l=Xt(s);let c,h,u,f;if((e.bitmap||e.data)&&e.count>1){const Q=e.bitmap||e.data.buffer;h=JSON.stringify(o?l:[l.slice(0,4),a]),c=this._cachedBitmapsMap.getOrInsertComputed(Q,tv);const Y=c.get(h);if(Y&&!o){const yt=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,ai.transformAndFill),{canvas:Y,offsetX:yt,offsetY:T}}u=Y}u||(f=this.canvasFactory.create(i,r),qv(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=Ga.slice();B.axialAlignedBoundingBox([0,0,i,r],g,y);const[v,w,S,x]=y,A=Math.round(S-v)||1,_=Math.round(x-w)||1,E=this.canvasFactory.create(A,_),k=E.context,P=v,L=w;k.translate(-P,-L),k.transform(...g);let I=null;if(!u){const Q=this._scaleImage(f.canvas,Yi(k));u=Q.img,I=Q.tmpCanvas,u!==f.canvas&&(this.canvasFactory.destroy(f),f=null),c&&o&&(c.set(h,u),I=null,f=null)}k.imageSmoothingEnabled=Yv(Xt(k),e.interpolate),nf(k,u,0,0,u.width,u.height,0,0,i,r),I&&this.canvasFactory.destroy(I),f&&this.canvasFactory.destroy(f),k.globalCompositeOperation="source-in";const D=B.transform(Yi(k),[1,0,0,1,-P,-L]);return k.fillStyle=o?a.getPattern(s,this,D,Xe.FILL,t):a,k.fillRect(0,0,i,r),c&&!o&&c.set(h,E.canvas),(W=this.dependencyTracker)==null||W.recordDependencies(t,ai.transformAndFill),{canvas:E.canvas,canvasEntry:c&&!o?null:E,offsetX:Math.round(P),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=lx[e]}setLineJoin(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineJoin",t),this.ctx.lineJoin=cx[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,_]=Xu(i),E=Math.round(.3*x+.59*A+.11*_);o=(r==null?void 0:r[E])??E}else o=(r==null?void 0:r[0])??0;const l=4,{width:c,height:h}=this.ctx.canvas,u=e.width*e.height,f=c*h0&&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,u=a,f=o,g=l;const y=this.smaskPreparedOOBAlpha,v=y!==null;if(v){h=Math.max(r,e.offsetX),u=Math.max(a,e.offsetY);const w=Math.min(r+o,e.offsetX+e.canvas.width),S=Math.min(a+l,e.offsetY+e.canvas.height);f=w-h,g=S-u}if(f>0&&g>0){const w=h-this.smaskPreparedOffsetX,S=u-this.smaskPreparedOffsetY;s.save(),s.globalAlpha=1,s.setTransform(1,0,0,1,0,0);const x=new Path2D;x.rect(h,u,f,g),s.clip(x),s.globalCompositeOperation="destination-in",s.drawImage(c.canvas,w,S,f,g,h,u,f,g),s.restore()}v&&y<255&&this._applySMaskOOBAlpha(s,r,a,o,l,h,u,h+f,u+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 u=ao.measureText(e))),(f===Ee.STROKE||f===Ee.FILL_STROKE)&&(this.dependencyTracker&&((A=this.dependencyTracker)==null||A.recordCharacterBBox(t,o,c,u,s,i,()=>o.measureText(e)).recordDependencies(t,ai.stroke)),o.strokeText(e,s,i));g&&((this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Xt(o),x:s,y:i,fontSize:u,path:w}),(_=this.dependencyTracker)==null||_.recordCharacterBBox(t,o,c,u,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;r0&&s[r]<255){i=!0;break}return ot(this,"isFontSubpixelAAEnabled",i)}showText(t,e){var W,Q,Y,yt;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,ai.showText).resetBBox(t),this.current.textRenderingMode&Ee.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const s=this.current,i=s.font;if(i.isType3Font){const T=b(this,Z,ys).call(this,s.fillAlpha);this.showType3Text(t,e),(W=this.dependencyTracker)==null||W.recordShowTextOperation(t),b(this,Z,Qe).call(this,T);return}const r=s.fontSize;if(r===0){(Q=this.dependencyTracker)==null||Q.recordOperation(t);return}const a=b(this,Z,ys).call(this,s.fillAlpha),o=this.ctx,l=s.fontSizeScale,c=s.charSpacing,h=s.wordSpacing,u=s.fontDirection,f=s.textHScale*u,g=e.length,y=i.vertical,v=y?1:-1,w=i.defaultVMetrics,S=r*s.fontMatrix[0],x=s.textRenderingMode===Ee.FILL&&!i.disableFontFace&&!s.patternFill;o.save(),s.textMatrix&&o.transform(...s.textMatrix),o.translate(s.x,s.y+s.textRise),u>0?o.scale(f,-1):o.scale(f,1);let A,_;const E=s.textRenderingMode&Ee.FILL_STROKE_MASK,k=E===Ee.FILL||E===Ee.FILL_STROKE,P=E===Ee.STROKE||E===Ee.FILL_STROKE;let L=s.lineWidth;const I=s.textMatrixScale;if(I===0||L===0?P&&(L=this.getSinglePixelWidth()):L/=I,l!==1&&(o.scale(l,l),L/=l),o.lineWidth=L,k&&s.patternFill){o.save();const T=s.fillColor.getPattern(o,this,Yi(o),Xe.FILL,t);A=Xt(o),o.restore(),o.fillStyle=T}if(P&&s.patternStroke){o.save();const T=s.strokeColor.getPattern(o,this,Yi(o),Xe.STROKE,t);_=Xt(o),o.restore(),o.strokeStyle=T}if(i.isInvalidPDFjsFont){const T=[];let j=0;for(const St of e)T.push(St.unicode),j+=St.width;const Ft=T.join("");if(o.fillText(Ft,0,0),this.dependencyTracker!==null){const St=o.measureText(Ft);this.dependencyTracker.recordBBox(t,this.ctx,-St.actualBoundingBoxLeft,St.actualBoundingBoxRight,-St.actualBoundingBoxAscent,St.actualBoundingBoxDescent).recordShowTextOperation(t)}s.x+=j*S*f,o.restore(),this.compose(),b(this,Z,Qe).call(this,a);return}let D=0,R;for(R=0;R0){U=o.measureText(St);const lt=U.width*1e3/r*l;if(zU??o.measureText(St));else if(this.paintChar(t,St,_t,Gt,A,_),ke){const lt=_t+r*ke.offset.x/l,nt=Gt-r*ke.offset.y/l;this.paintChar(t,ke.fontChar,lt,nt,A,_)}}const dt=y?z*S-Ft*u:z*S+Ft*u;D+=dt,j&&o.restore()}y?s.y-=D:s.x+=D*f,o.restore(),this.compose(),(yt=this.dependencyTracker)==null||yt.recordShowTextOperation(t),b(this,Z,Qe).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,u=i.textHScale*o,f=i.fontMatrix||gg,g=e.length,y=i.textRenderingMode===Ee.INVISIBLE;let v,w,S,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(u,o);const A=this.dependencyTracker;for(this.dependencyTracker=A?new td(A,t):null,v=0;vnew pv(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new td(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=nx(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=b(this,Z,ys).call(this,this.current.fillAlpha),i=this.ctx;this.save(t);const r=this._getPattern(t,e);i.fillStyle=r.getPattern(i,this,Yi(i),Xe.SHADING,t);const a=Yi(i);if(a){const{width:l,height:c}=i.canvas,h=Ga.slice();B.axialAlignedBoundingBox([0,0,l,c],a,h);const[u,f,g,y]=h;this.ctx.fillRect(u,f,g-u,y-f)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);(o=this.dependencyTracker)==null||o.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,ai.transform).recordDependencies(t,ai.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t),b(this,Z,Qe).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=Xt(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,$s)===0&&i.globalAlpha===1&&i.globalCompositeOperation==="source-over"&&!s){if(e.bbox){let A=new Path2D;const[_,E,k,P]=e.bbox;if(A.rect(_,E,k-_,P-E),e.matrix){const L=new Path2D;L.addPath(A,new DOMMatrix(e.matrix)),A=L}i.clip(A)}this.groupStack.push(null),n(this,dn).push(null),this.groupLevel++;return}!e.isolated&&!e.knockout&&n(this,$s)===0&&Up("TODO: Fully support non-isolated non-knockout groups.");const r=Xt(i);e.matrix&&i.transform(...e.matrix);const a=[0,0,i.canvas.width,i.canvas.height];let o;e.bbox?(o=Ga.slice(),B.axialAlignedBoundingBox(e.bbox,Xt(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),u=Math.max(Math.ceil(o[3])-c,1);this.current.startNewPathAndClipBox([0,0,h,u]);const f=this.canvasFactory.create(h,u);e.smask&&this.smaskGroupCanvases.push(f);const g=f.context,y=e.knockout&&!e.isolated?i:null,v=!e.isolated&&!e.knockout&&!e.smask&&e.needsIsolation&&n(this,$s)>0,w=e.knockout?this.canvasFactory.create(h,u):null,S=n(this,$s);if(e.knockout?Yt(this,$s)._++:p(this,$s,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[_,E,k,P]=e.bbox;if(A.rect(_,E,k-_,P-E),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()),Fa(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,dn).push({backdropCtx:y,savedKnockoutLevel:S,offsetX:l,offsetY:c,hasInnerBackdrop:v,knockoutMaskEntry:w,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,dn).pop();if(r&&p(this,$s,r.savedKnockoutLevel),i===null){this.restore(t);return}if(e.isGray&&b(this,Z,vy).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())),b(this,Z,Ef).call(this,r);else{this.ctx.restore();const o=Xt(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...o);const l=Ga.slice();B.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],o,l);const c=n(this,dn).at(-1);if(n(this,$s)>0)if(r.hasInnerBackdrop){const{width:h,height:u}=s.canvas,f=this.canvasFactory.create(h,u),g=f.context;g.drawImage(i.canvas,r.offsetX,r.offsetY,h,u,0,0,h,u),g.globalCompositeOperation="source-over",g.drawImage(s.canvas,0,0);const y=b(this,Z,Yg).call(this,s.canvas);g.globalCompositeOperation="destination-in",g.drawImage(y.canvas,0,0);const v=this.ctx.globalCompositeOperation,w=this.ctx.globalAlpha,S=this.ctx.filter;this.ctx.save(),this.ctx.setTransform(...o),this.ctx.globalAlpha=1,Ht.isCanvasFilterSupported&&(this.ctx.filter="none"),this.ctx.globalCompositeOperation="destination-out",this.ctx.drawImage(y.canvas,0,0),this.ctx.globalCompositeOperation=v,this.ctx.globalAlpha=w,Ht.isCanvasFilterSupported&&(this.ctx.filter=S??"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;b(this,Z,Qg).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}),b(this,Z,Ef).call(this,r),this.compose(l)}}beginAnnotation(t,e,s,i,r,a,o){if(b(this,Z,Xg).call(this),rf(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(Xt(this.ctx),ei);const{viewportScale:h}=this,u=Math.ceil(l*this.outputScaleX*h),f=Math.ceil(c*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(u,f);const{canvas:g,context:y}=this.annotationCanvas;if(o){const v=this.annotationCanvasMap.getOrInsertComputed(e,ju);g.setAttribute("data-canvas-name",o);const w=v.findIndex(S=>S.getAttribute("data-canvas-name")===o);w===-1?v.push(g):v[w]=g}else this.annotationCanvasMap.set(e,g);this.annotationCanvas.savedCtx=this.ctx,this.ctx=y,this.ctx.save(),this.ctx.setTransform(ei[0],0,0,-ei[1],0,c*ei[1]),rf(this.ctx)}else{rf(this.ctx),this.endPath(t);const h=new Path2D;h.rect(s[0],s[1],l,c),this.ctx.clip(h)}}this.current=new Wv(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(t,...i),this.transform(t,...r),this.baseTransform=Xt(this.ctx)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),b(this,Z,qg).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=b(this,Z,ys).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(),b(this,Z,Qe).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=b(this,Z,ys).call(this,this.current.fillAlpha),c=this.ctx;c.save();const h=Xt(c);c.transform(s,i,r,a,0,0);const u=this._createMaskCanvas(t,e);c.setTransform(1,0,0,1,u.offsetX-h[4],u.offsetY-h[5]),(f=this.dependencyTracker)==null||f.resetBBox(t);for(let v=0,w=o.length;vu?h/u:1,o=c>u?c/u: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),hg.a=1/r,hg.d=1/a;const l=new Path2D;if(l.addPath(t,hg),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}};$s=new WeakMap,Zr=new WeakMap,Co=new WeakMap,_o=new WeakMap,ko=new WeakMap,To=new WeakMap,Po=new WeakMap,Mo=new WeakMap,Io=new WeakMap,dn=new WeakMap,Z=new WeakSet,Xg=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)},qg=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}}},Yg=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,Mo)===void 0&&p(this,Mo,Ht.isCanvasFilterSupported?new Map:"none");let c="none";if(l&&n(this,Mo)instanceof Map&&(c=n(this,Mo).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),u=o.createImageData(i,r),f=h.data,g=u.data,y=s>0?1/s:1e6;for(let v=3,w=f.length;v0||!this.contentVisible)return!1;Yt(this,Zr)._++,p(this,Po,t);const e=n(this,dn).at(-1),{canvas:s}=this.ctx,i=b(this,Z,Kg).call(this,e,"knockoutTempEntry",s.width,s.height);p(this,Co,i);const r=i.context;return r.save(),r.setTransform(this.ctx.getTransform()),Fa(this.ctx,r),p(this,To,r.globalCompositeOperation),r.globalCompositeOperation="source-over",jv(r,this.ctx),p(this,Io,e),p(this,_o,this.ctx),p(this,ko,this.suspendedCtx),this.ctx=r,this.inSMaskMode&&(this.suspendedCtx=r),!0},Qe=function(t){var l;if(!t)return;const e=n(this,Co),s=n(this,_o),i=n(this,ko),r=e.context;p(this,Co,null),p(this,_o,null),p(this,ko,null),this.inSMaskMode&&this.suspendedCtx===r&&this.ctx!==r&&this.endSMaskMode(),this.inSMaskMode&&(this.suspendedCtx=i),this.ctx._removeMirroring(),this.ctx.globalCompositeOperation=n(this,To),p(this,To,null),Fa(this.ctx,s),this.ctx=s;const a=n(this,Io);p(this,Io,null);const o=n(this,Po);p(this,Po,1);try{b(this,Z,Qg).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(),Yt(this,Zr)._--,a||this.canvasFactory.destroy(e)}},Jg=function(t,e,s){const i=new Path2D;return i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),i},vy=function(t){const{canvas:e}=t,{width:s,height:i}=e;if(Ht.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{e._responseOrigin=Xp(c.url),xy(c.status,a),this._reader=c.body.getReader();const h=c.headers,{contentLength:u,isRangeSupported:f}=yy({responseHeaders:h,isHttp:!0,rangeChunkSize:r,disableRange:s});this._contentLength=u,this._isRangeSupported=f,this._filename=wy(h),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new ka("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:Yp(e),done:!1})}cancel(e){var s;(s=this._reader)==null||s.cancel(e),this._abortController.abort()}}class px extends Wp{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}`),Sy(r,o,a,this._abortController).then(l=>{const c=Xp(l.url);Ay(c,e._responseOrigin),xy(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:Yp(e),done:!1}}cancel(e){var s;(s=this._reader)==null||s.cancel(e),this._abortController.abort()}}function Qv(d){return d instanceof Uint8Array&&d.byteLength===d.buffer.byteLength?d.buffer:new Uint8Array(d).buffer}function Kp(){for(const d of this._requests)d.resolve({value:void 0,done:!0});this._requests.length=0}var xp,Ey;class gx extends Gp{constructor(e){super(e,mx,vx);m(this,xp);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=Qv(i);this._queuedChunks.push(o)}this._progressiveDone=r;const a=o=>{var l;switch(o.type){case"range":case"progressiveRead":b(this,xp,Ey).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()}}xp=new WeakSet,Ey=function(e,s){const i=Qv(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);ae(r,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),r._enqueue(i)}};var Rd;class mx extends jp{constructor(e){super(e);m(this,Rd,Kp.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,iv(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,Rd).call(this)}progressiveDone(){this._done||(this._done=!0),this._queuedChunks.length===0&&n(this,Rd).call(this)}}Rd=new WeakMap;var Nd;class vx extends Wp{constructor(e,s,i){super(e,s,i);m(this,Nd,Kp.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,Nd).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,Nd).call(this),(s=this.onDone)==null||s.call(this)}}Nd=new WeakMap;const dg=200,Jv=206;function bx(d){return typeof d!="string"?d:Hp(d).buffer}var un,mh,Cy,_y;class yx extends Gp{constructor(e){super(e,wx,Ax);m(this,mh);m(this,un,new WeakMap);M(this,"_responseOrigin",null);const{httpHeaders:s,url:i}=e;this.url=i,this.isHttp=/https?:/.test(i.protocol),this.headers=by(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,un).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===Jv||r===dg):i.validateStatus=r=>r===dg,s.responseType="arraybuffer",ae(e.onError,"Expected `onError` callback to be provided."),s.onerror=()=>e.onError(s.status),s.onreadystatechange=b(this,mh,_y).bind(this,s),s.onprogress=b(this,mh,Cy).bind(this,s),s.send(null),s}_abortRequest(e){n(this,un).has(e)&&(n(this,un).delete(e),e.abort())}getRangeReader(e,s){const i=super.getRangeReader(e,s);return i&&(i.onClosed=()=>this._rangeReaders.delete(i)),i}}un=new WeakMap,mh=new WeakSet,Cy=function(e,s){var r;const i=n(this,un).get(e);(r=i==null?void 0:i.onProgress)==null||r.call(i,s)},_y=function(e,s){const i=n(this,un).get(e);if(!i||(e.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),e.readyState!==4)||!n(this,un).has(e))return;if(n(this,un).delete(e),e.status===0&&this.isHttp){i.onError(e.status);return}const r=e.status||dg;if(!i.validateStatus(r)){i.onError(e.status);return}const a=bx(e.response);if(r===Jv){const o=e.getResponseHeader("Content-Range");/bytes \d+-\d+\/\d+/.test(o)?i.onDone(a):(ht('Missing or invalid "Content-Range" header.'),i.onError(0))}else a?i.onDone(a):i.onError(e.status)};var Bd,kn,ky,Ty,Py,My;class wx extends jp{constructor(e){super(e);m(this,kn);m(this,Bd,Kp.bind(this));M(this,"_cachedChunks",[]);M(this,"_done",!1);M(this,"_requests",[]);M(this,"_storedError",null);this._fullRequestXhr=e._request({onHeadersReceived:b(this,kn,ky).bind(this),onDone:b(this,kn,Ty).bind(this),onError:b(this,kn,Py).bind(this),onProgress:b(this,kn,My).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,Bd).call(this),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}Bd=new WeakMap,kn=new WeakSet,ky=function(){const e=this._stream,{disableRange:s,rangeChunkSize:i}=e._source,r=this._fullRequestXhr;e._responseOrigin=Xp(r.responseURL);const a=r.getAllResponseHeaders(),o=new Headers(a?a.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(h=>{const[u,...f]=h.split(": ");return[u,f.join(": ")]}):[]),{contentLength:l,isRangeSupported:c}=yy({responseHeaders:o,isHttp:e.isHttp,rangeChunkSize:i,disableRange:s});this._contentLength=l,this._isRangeSupported=c,this._filename=wy(o),this._isRangeSupported&&e._abortRequest(r),this._headersCapability.resolve()},Ty=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,Bd).call(this)},Py=function(e){this._storedError=qp(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},My=function(e){var s;(s=this.onProgress)==null||s.call(this,{loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})};var $d,Sr,Iy,Dy,Zg;class Ax extends Wp{constructor(e,s,i){super(e,s,i);m(this,Sr);m(this,$d,Kp.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:b(this,Sr,Iy).bind(this),onDone:b(this,Sr,Dy).bind(this),onError:b(this,Sr,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,$d).call(this),this._stream._abortRequest(this._requestXhr),(s=this.onClosed)==null||s.call(this)}}$d=new WeakMap,Sr=new WeakSet,Iy=function(){var s;const e=Xp((s=this._requestXhr)==null?void 0:s.responseURL);try{Ay(e,this._stream._responseOrigin)}catch(i){this._storedError=i,b(this,Sr,Zg).call(this,0)}},Dy=function(e){var s;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0,n(this,$d).call(this),(s=this.onClosed)==null||s.call(this)},Zg=function(e){this._storedError??(this._storedError=qp(e,this._stream.url));for(const s of this._requests)s.reject(this._storedError);this._requests.length=0,this._queuedChunk=null};function Ly(d,t=null){const e=process.getBuiltinModule("fs"),{Readable:s}=process.getBuiltinModule("stream"),i=e.createReadStream(d,t);return s.toWeb(i)}class Sx extends Gp{constructor(t){super(t,xx,Ex);const{url:e}=t;ae(e.protocol==="file:","PDFNodeStream only supports file:// URLs.")}}class xx extends jp{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=Ly(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 ka("Streaming is disabled.")),this._headersCapability.resolve()}).catch(l=>{l.code==="ENOENT"&&(l=qp(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:Yp(e),done:!1})}cancel(e){var s;(s=this._reader)==null||s.cancel(e)}}class Ex extends Wp{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=Ly(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:Yp(e),done:!1}}cancel(e){var s;(s=this._reader)==null||s.cancel(e)}}function Cx(d){return Wh(d)?ux:ti?Sx:yx}var Ud,Hd;class En{static get workerPort(){return n(this,Ud)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");p(this,Ud,t)}static get workerSrc(){return n(this,Hd)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");p(this,Hd,t)}}Ud=new WeakMap,Hd=new WeakMap,m(En,Ud,null),m(En,Hd,"");var wc,zd;class _x{constructor({parsedData:t,rawData:e}){m(this,wc);m(this,zd);p(this,wc,t),p(this,zd,e)}getRaw(){return n(this,zd)}get(t){return n(this,wc).get(t)??null}[Symbol.iterator](){return n(this,wc).entries()}}wc=new WeakMap,zd=new WeakMap;const Na=Symbol("INTERNAL");var Vd,Gd,Ac,Do;class kx{constructor(t,{name:e,intent:s,usage:i,rbGroups:r}){m(this,Vd,!1);m(this,Gd,!1);m(this,Ac,!1);m(this,Do,!0);p(this,Vd,!!(t&Zs.DISPLAY)),p(this,Gd,!!(t&Zs.PRINT)),this.name=e,this.intent=s,this.usage=i,this.rbGroups=r}get visible(){if(n(this,Ac))return n(this,Do);if(!n(this,Do))return!1;const{print:t,view:e}=this.usage;return n(this,Vd)?(e==null?void 0:e.viewState)!=="OFF":n(this,Gd)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==Na&&Ct("Internal method `_setVisible` called."),p(this,Ac,s),p(this,Do,e)}get serializable(){return{userSet:n(this,Ac),visible:n(this,Do)}}}Vd=new WeakMap,Gd=new WeakMap,Ac=new WeakMap,Do=new WeakMap;var ta,Tt,Sc,xc,jd,Wd,em;const gv=class gv{constructor(t,e=Zs.DISPLAY,s=null){m(this,Wd);m(this,ta,null);m(this,Tt,new Map);m(this,Sc,null);m(this,xc,null);m(this,jd);M(this,"creator",null);M(this,"name",null);if(p(this,jd,t),this.renderingIntent=e,t!==null){this.name=t.name,this.creator=t.creator,p(this,xc,t.order);for(const i of t.groups)n(this,Tt).set(i.id,new kx(e,i));if(s){s.size!==n(this,Tt).size&&Ct("Incorrect serialized groupState.");for(const[i,r]of s)n(this,Tt).get(i)._setVisible(Na,r.visible,r.userSet)}else{if(t.baseState==="OFF")for(const i of n(this,Tt).values())i._setVisible(Na,!1);for(const i of t.on)n(this,Tt).get(i)._setVisible(Na,!0);for(const i of t.off)n(this,Tt).get(i)._setVisible(Na,!1)}p(this,Sc,this.getHash())}}isVisible(t){if(n(this,Tt).size===0)return!0;if(!t)return Up("Optional content group not defined."),!0;if(t.type==="OCG")return n(this,Tt).has(t.id)?n(this,Tt).get(t.id).visible:(ht(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return b(this,Wd,em).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!n(this,Tt).has(e))return ht(`Optional content group not found: ${e}`),!0;if(n(this,Tt).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!n(this,Tt).has(e))return ht(`Optional content group not found: ${e}`),!0;if(!n(this,Tt).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!n(this,Tt).has(e))return ht(`Optional content group not found: ${e}`),!0;if(!n(this,Tt).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!n(this,Tt).has(e))return ht(`Optional content group not found: ${e}`),!0;if(n(this,Tt).get(e).visible)return!1}return!0}return ht(`Unknown optional content policy ${t.policy}.`),!0}return ht(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){var r;const i=n(this,Tt).get(t);if(!i){ht(`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,Tt).get(o))==null||r._setVisible(Na,!1,!0));i._setVisible(Na,!!e,!0),p(this,ta,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,Tt).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,ta,null)}get hasInitialVisibility(){return n(this,Sc)===null||this.getHash()===n(this,Sc)}getOrder(){return n(this,Tt).size?n(this,xc)?n(this,xc).slice():[...n(this,Tt).keys()]:null}getGroup(t){return n(this,Tt).get(t)||null}getHash(){if(n(this,ta)!==null)return n(this,ta);const t=new $g;for(const[e,s]of n(this,Tt))t.update(`${e}:${s.visible}`);return p(this,ta,t.hexdigest())}[Symbol.iterator](){return n(this,Tt).entries()}get serializable(){const t=new Map;for(const[e,s]of n(this,Tt))t.set(e,s.serializable);return{data:n(this,jd),renderingIntent:this.renderingIntent,groupState:t}}static fromSerializable({data:t,renderingIntent:e,groupState:s}){return new gv(t,e,s)}};ta=new WeakMap,Tt=new WeakMap,Sc=new WeakMap,xc=new WeakMap,jd=new WeakMap,Wd=new WeakSet,em=function(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;if===g+1)&&p(this,ve,null)}deletePages(t){b(this,ns,Rh).call(this);const e=n(this,ve),s=b(this,ns,Nh).call(this);p(this,fn,{pageNumberToId:e.slice(),pagesNumber:n(this,Ve),prevPageNumbers:n(this,Bi).slice()});const i=n(this,Ve)-t.length;p(this,Ve,i);const r=p(this,ve,new Uint32Array(i));p(this,Bi,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}an(this,ve)[e-1])})}cancelCopy(){p(this,Lo,null)}pastePages(t){b(this,ns,Rh).call(this);const e=n(this,ve),s=b(this,ns,Nh).call(this),{pageNumbers:i,pageIds:r}=n(this,Lo),a=n(this,Ve)+i.length;p(this,Ve,a);const o=p(this,ve,new Uint32Array(a));p(this,Bi,new Int32Array(a)),o.set(e.subarray(0,t),0),o.set(r,t),o.set(e.subarray(t),t+i.length),b(this,ns,Cf).call(this,s,null,t,i),p(this,Lo,null)}hasBeenAltered(){return n(this,ve)!==null}getPageMappingForSaving(t=null){t??(t=b(this,ns,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;ia[0]-o[0]);for(let a=0,o=i.length;as-i);const e=new Map;for(let s=0,i=t.length;s=s&&c({...Promise.withResolvers(),data:Fl});var mi;class Fy{constructor(){m(this,mi,new Map)}get(t,e=null){if(e){const i=n(this,mi).getOrInsertComputed(t,Zv);return i.promise.then(()=>e(i.data)),null}const s=n(this,mi).get(t);if(!s||s.data===Fl)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=n(this,mi).get(t);return!!e&&e.data!==Fl}delete(t){const e=n(this,mi).get(t);return!e||e.data===Fl?!1:(n(this,mi).delete(t),!0)}resolve(t,e=null){const s=n(this,mi).getOrInsertComputed(t,Zv);if(s.data!==Fl)throw new Error(`Object already resolved ${t}.`);s.data=e,s.resolve()}clear(){var t;for(const{data:e}of n(this,mi).values())(t=e==null?void 0:e.bitmap)==null||t.close();n(this,mi).clear()}*[Symbol.iterator](){for(const[t,{data:e}]of n(this,mi))e!==Fl&&(yield[t,e])}}mi=new WeakMap;const Px=1e5,tb=30;var lb,ea,hs,Xd,qd,Ec,Fo,Yn,Yd,Kd,Oo,Qd,Cc,sa,_c,Jd,kc,Ro,Zd,tu,Tc,No,eu,Pc,Mc,xr,Oy,Ry,sm,ni,_f,im,Ny,By;const $e=class $e{constructor({textContentSource:t,images:e,container:s,viewport:i}){m(this,xr);m(this,ea,Promise.withResolvers());m(this,hs,null);m(this,Xd,!1);m(this,qd,!!((lb=globalThis.FontInspector)!=null&&lb.enabled));m(this,Ec,null);m(this,Fo,null);m(this,Yn,null);m(this,Yd,0);m(this,Kd,0);m(this,Oo,null);m(this,Qd,null);m(this,Cc,0);m(this,sa,0);m(this,_c,Object.create(null));m(this,Jd,[]);m(this,kc,null);m(this,Ro,[]);m(this,Zd,new WeakMap);m(this,tu,null);var c;if(t instanceof ReadableStream)p(this,kc,t);else if(typeof t=="object")p(this,kc,new ReadableStream({start(h){h.enqueue(t),h.close()}}));else throw new Error('No "textContentSource" parameter specified.');p(this,hs,p(this,Qd,s)),p(this,Ec,e),p(this,sa,i.scale*_n.pixelRatio),p(this,Cc,i.rotation),p(this,Yn,{div:null,properties:null,ctx:null});const{pageWidth:r,pageHeight:a,pageX:o,pageY:l}=i.rawDims;p(this,tu,[1,0,0,-1,-o,l+a]),p(this,Kd,r),p(this,Yd,a),b(c=$e,ni,Ny).call(c),s.style.setProperty("--min-font-size",n($e,Pc)),xl(s,i),n(this,ea).promise.finally(()=>{n($e,Mc).delete(this),p(this,Yn,null),p(this,_c,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=Ht.platform;return ot(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){n(this,Ec)&&n(this,hs).append(n(this,Ec).render());const t=()=>{n(this,Oo).read().then(({value:e,done:s})=>{if(s){n(this,ea).resolve();return}n(this,Fo)??p(this,Fo,e.lang),Object.assign(n(this,_c),e.styles),b(this,xr,Oy).call(this,e.items),t()},n(this,ea).reject)};return p(this,Oo,n(this,kc).getReader()),n($e,Mc).add(this),t(),n(this,ea).promise}update({viewport:t,onBefore:e=null}){var r;const s=t.scale*_n.pixelRatio,i=t.rotation;if(i!==n(this,Cc)&&(e==null||e(),p(this,Cc,i),xl(n(this,Qd),{rotation:i})),s!==n(this,sa)){e==null||e(),p(this,sa,s);const a={div:null,properties:null,ctx:b(r=$e,ni,_f).call(r,n(this,Fo))};for(const o of n(this,Ro))a.properties=n(this,Zd).get(o),a.div=o,b(this,xr,sm).call(this,a)}}cancel(){var e;const t=new ka("TextLayer task cancelled.");(e=n(this,Oo))==null||e.cancel(t).catch(()=>{}),p(this,Oo,null),n(this,ea).reject(t)}get textDivs(){return n(this,Ro)}get textContentItemsStr(){return n(this,Jd)}static cleanup(){if(!(n(this,Mc).size>0)){n(this,Tc).clear();for(const{canvas:t}of n(this,No).values())t.remove();n(this,No).clear()}}};ea=new WeakMap,hs=new WeakMap,Xd=new WeakMap,qd=new WeakMap,Ec=new WeakMap,Fo=new WeakMap,Yn=new WeakMap,Yd=new WeakMap,Kd=new WeakMap,Oo=new WeakMap,Qd=new WeakMap,Cc=new WeakMap,sa=new WeakMap,_c=new WeakMap,Jd=new WeakMap,kc=new WeakMap,Ro=new WeakMap,Zd=new WeakMap,tu=new WeakMap,Tc=new WeakMap,No=new WeakMap,eu=new WeakMap,Pc=new WeakMap,Mc=new WeakMap,xr=new WeakSet,Oy=function(t){var i,r;if(n(this,Xd))return;(r=n(this,Yn)).ctx??(r.ctx=b(i=$e,ni,_f).call(i,n(this,Fo)));const e=n(this,Ro),s=n(this,Jd);for(const a of t){if(e.length>Px){ht("Ignoring additional textDivs for performance reasons."),p(this,Xd,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=n(this,hs);p(this,hs,document.createElement("span")),n(this,hs).classList.add("markedContent"),a.id&&n(this,hs).setAttribute("id",`${a.id}`),a.tag==="Artifact"&&(n(this,hs).ariaHidden=!0),o.append(n(this,hs))}else a.type==="endMarkedContent"&&p(this,hs,n(this,hs).parentNode);continue}s.push(a.str),b(this,xr,Ry).call(this,a)}},Ry=function(t){var y;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};n(this,Ro).push(e);const i=B.transform(n(this,tu),t.transform);let r=Math.atan2(i[1],i[0]);const a=n(this,_c)[t.fontName];a.vertical&&(r+=Math.PI/2);let o=n(this,qd)&&a.fontSubstitution||a.fontFamily;o=$e.fontFamilyMap.get(o)||o;const l=Math.hypot(i[2],i[3]),c=l*b(y=$e,ni,By).call(y,o,a,n(this,Fo));let h,u;r===0?(h=i[4],u=i[5]-c):(h=i[4]+c*Math.sin(r),u=i[5]-c*Math.cos(r));const f=e.style;f.left=`${(100*h/n(this,Kd)).toFixed(2)}%`,f.top=`${(100*u/n(this,Yd)).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,qd)&&(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 v=Math.abs(t.transform[0]),w=Math.abs(t.transform[3]);v!==w&&Math.max(v,w)/Math.min(v,w)>1.5&&(g=!0)}if(g&&(s.canvasWidth=a.vertical?t.height:t.width),n(this,Zd).set(e,s),n(this,Yn).div=e,n(this,Yn).properties=s,b(this,xr,sm).call(this,n(this,Yn)),s.hasText&&n(this,hs).append(e),s.hasEOL){const v=document.createElement("br");v.setAttribute("role","presentation"),n(this,hs).append(v)}},sm=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;b(a=$e,ni,im).call(a,i,c*n(this,sa),o);const{width:h}=i.measureText(e.textContent);h>0&&r.setProperty("--scale-x",l*n(this,sa)/h)}s.angle!==0&&r.setProperty("--rotate",`${s.angle}deg`)},ni=new WeakSet,_f=function(t=null){let e=n(this,No).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,No).set(t,e),n(this,eu).set(e,{size:0,family:""})}return e},im=function(t,e,s){const i=n(this,eu).get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)},Ny=function(){if(n(this,Pc)!==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,Pc,t.getBoundingClientRect().height),t.remove()},By=function(t,e,s){const i=n(this,Tc).get(t);if(i)return i;const r=b(this,ni,_f).call(this,s);r.canvas.width=r.canvas.height=tb,b(this,ni,im).call(this,r,tb,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):(Ht.platform.isFirefox&&ht("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,Tc).set(t,c),c},m($e,ni),m($e,Tc,new Map),m($e,No,new Map),m($e,eu,new WeakMap),m($e,Pc,null),m($e,Mc,new Set);let ph=$e;const Mx=100;function $y(d={}){const t=new nm,{docId:e}=t,s=d.url?R1(d.url):null,i=d.data?N1(d.data):null,r=d.httpHeaders||null,a=d.withCredentials===!0,o=d.password??null,l=d.range instanceof Uy?d.range:null,c=Number.isInteger(d.rangeChunkSize)&&d.rangeChunkSize>0?d.rangeChunkSize:2**16;let h=d.worker instanceof ed?d.worker:null;const u=d.verbosity,f=typeof d.docBaseUrl=="string"&&!zp(d.docBaseUrl)?d.docBaseUrl:null,g=ef(d.cMapUrl),y=d.cMapPacked!==!1,v=ef(d.iccUrl),w=ef(d.standardFontDataUrl),S=ef(d.wasmUrl),x=d.stopAtErrors!==!0,A=Number.isInteger(d.maxImageSize)&&d.maxImageSize>-1?d.maxImageSize:-1,_=typeof d.isOffscreenCanvasSupported=="boolean"?d.isOffscreenCanvasSupported:!ti,E=typeof d.isImageDecoderSupported=="boolean"?d.isImageDecoderSupported:!ti,k=Number.isInteger(d.canvasMaxAreaInBytes)?d.canvasMaxAreaInBytes:-1,P=typeof d.disableFontFace=="boolean"?d.disableFontFace:ti,L=d.fontExtraProperties===!0,I=d.enableXfa===!0,D=d.ownerDocument||globalThis.document,R=d.disableRange===!0,W=d.disableStream===!0,Q=d.disableAutoFetch===!0,Y=d.pdfBug===!0,yt=d.CanvasFactory||(ti?j1:H1),T=d.FilterFactory||(ti?G1:z1),j=d.BinaryDataFactory||(ti?W1:zv),Ft=d.enableHWA===!0,ke=d.enableWebGPU===!0?K1():Promise.resolve(!1),_t=d.useWasm!==!1,Gt=d.pagesMapper||new Tx,z=typeof d.useSystemFonts=="boolean"?d.useSystemFonts:!ti&&!P,U=typeof d.useWorkerFetch=="boolean"?d.useWorkerFetch:!!(j===zv&&g&&y&&w&&S&&Wh(g,document.baseURI)&&Wh(w,document.baseURI)&&Wh(S,document.baseURI)),dt=null;r1(u);const lt={canvasFactory:new yt({ownerDocument:D,enableHWA:Ft}),filterFactory:new T({docId:e,ownerDocument:D}),binaryDataFactory:U?null:new j({cMapUrl:g,standardFontDataUrl:w,wasmUrl:S})};h||(h=ed.create({verbosity:u,port:En.workerPort}),t._worker=h);const nt={docId:e,apiVersion:"6.1.200",data:i,password:o,disableAutoFetch:Q,rangeChunkSize:c,docBaseUrl:f,enableXfa:I,evaluatorOptions:{maxImageSize:A,disableFontFace:P,ignoreErrors:x,isOffscreenCanvasSupported:_,isImageDecoderSupported:E,canvasMaxAreaInBytes:k,fontExtraProperties:L,useSystemFonts:z,useWasm:_t,useWorkerFetch:U,cMapUrl:g,cMapPacked:y,iccUrl:v,standardFontDataUrl:w,wasmUrl:S,hasGPU:!1}},qt={ownerDocument:D,pdfBug:Y,styleElement:dt,enableHWA:Ft,loadingParams:{disableAutoFetch:Q,enableXfa:I}};return Promise.all([h.promise,ke]).then(function([,pe]){if(h.destroyed)throw new Error("Worker was destroyed");nt.evaluatorOptions.hasGPU=pe;const Ms=h.messageHandler.sendWithPromise("GetDocRequest",nt,i?[i.buffer]:null);let qi;if(!i)if(l)qi=new gx({pdfDataRangeTransport:l,disableRange:R,disableStream:W});else if(s){const Ke=Cx(s);qi=new Ke({url:s,httpHeaders:r,withCredentials:a,rangeChunkSize:c,disableRange:R,disableStream:W})}else throw new Error("getDocument - expected either `data`, `range`, or `url` parameter.");return Ms.then(Ke=>{if(h.destroyed)throw new Error("Worker was destroyed");const ki=new Ih(e,Ke,h.port),Ti=new Dx(ki,t,qi,qt,lt,Gt);if(t._transport=Ti,t.destroyed)throw new Error("Loading aborted");ki.send("Ready",null)})}).catch(t._capability.reject).finally(t._setupCapability.resolve),t}var Ep;const Cp=class Cp{constructor(){M(this,"_capability",Promise.withResolvers());M(this,"_setupCapability",Promise.withResolvers());M(this,"_transport",null);M(this,"_worker",null);M(this,"docId",`d${Yt(Cp,Ep)._++}`);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()}};Ep=new WeakMap,m(Cp,Ep,0);let nm=Cp;var Ic,Bo;class Uy{constructor(t,e,s=!1,i=null){m(this,Ic,Promise.withResolvers());m(this,Bo,null);this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i}onDataRange(t,e){n(this,Bo).call(this,{type:"range",begin:t,chunk:e})}onDataProgressiveRead(t){n(this,Ic).promise.then(()=>{n(this,Bo).call(this,{type:"progressiveRead",chunk:t})})}onDataProgressiveDone(){n(this,Ic).promise.then(()=>{n(this,Bo).call(this,{type:"progressiveDone"})})}transportReady(t){p(this,Bo,t),n(this,Ic).resolve()}requestDataRange(t,e){Ct("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}Ic=new WeakMap,Bo=new WeakMap;class Ix{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 ot(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 Kn,$o,Uo,Bh;const mv=class mv{constructor(t,e,s,i,r=!1){m(this,Uo);m(this,Kn,!1);m(this,$o,null);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=r?new Iv:null,this._pdfBug=r,this.commonObjs=s.commonObjs,this.objs=new Fy,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,p(this,$o,i),this.imageCoordinates=null}clone(t){const e=new mv(t,this._pageInfo,this._transport,n(this,$o),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 Wu({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 ot(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=_r.ENABLE,transform:a=null,background:o=null,optionalContentConfigPromise:l=null,annotationCanvasMap:c=null,pageColors:h=null,printAnnotationStorage:u=null,isEditing:f=!1,recordImages:g=!1,recordOperations:y=!1,operationsFilter:v=null}){var Q,Y,yt;(Q=this._stats)==null||Q.time("Overall");const w=this._transport.getRenderingIntent(i,r,u,f),{renderingIntent:S,cacheKey:x}=w;p(this,Kn,!1),l||(l=this._transport.getOptionalContentConfig(S));const A=this._intentStates.getOrInsertComputed(x,wg);A.streamReaderCancelTimeout&&(clearTimeout(A.streamReaderCancelTimeout),A.streamReaderCancelTimeout=null);const _=!!(S&Zs.PRINT);A.displayReadyCapability||(A.displayReadyCapability=Promise.withResolvers(),A.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(Y=this._stats)==null||Y.time("Page Request"),this._pumpOperatorList(w));const E=!!(this._pdfBug&&((yt=globalThis.StepperManager)!=null&&yt.enabled)),k=!!e&&!this.recordedBBoxes&&(y||E),P=!!e&&!this.imageCoordinates&&g,L=T=>{var j,Ft,St,ke;if(A.renderTasks.delete(R),k){const _t=(j=R.gfx)==null?void 0:j.dependencyTracker.take();_t&&((Ft=R.stepper)==null||Ft.setOperatorBBoxes(_t,R.gfx.dependencyTracker.takeDebugMetadata()),y&&(this.recordedBBoxes=_t))}P&&!T&&(this.imageCoordinates=(St=R.gfx)==null?void 0:St.imagesTracker.take()),_&&p(this,Kn,!0),b(this,Uo,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"),(ke=globalThis.Stats)!=null&&ke.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))};let I=null,D=null;(k||P)&&(D=new k1(e,A.operatorList.length)),k&&(I=new T1(D,E));const R=new am({callback:L,params:{canvas:e,canvasContext:t,dependencyTracker:I??D,imagesTracker:P?new zg(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:!_,pdfBug:this._pdfBug,pageColors:h,enableHWA:this._transport.enableHWA,operationsFilter:v});(A.renderTasks||(A.renderTasks=new Set)).add(R);const W=R.task;return Promise.all([A.displayReadyCapability.promise,l]).then(([T,j])=>{var Ft;if(this.destroyed){L();return}if((Ft=this._stats)==null||Ft.time("Rendering"),!(j.renderingIntent&S))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");R.initializeGraphics({transparency:T,optionalContentConfig:j}),R.operatorListChanged()}).catch(L),W}getOperatorList({intent:t="display",annotationMode:e=_r.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,wg);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,$o).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=>Jh.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,Kn,!1),Promise.all(t)}cleanup(t=!1){p(this,Kn,!0);const e=b(this,Uo,Bh).call(this);return t&&e&&this._stats&&(this._stats=new Iv),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{l.read().then(({value:u,done:f})=>{if(f){c.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(u,c),h())},u=>{if(c.streamReader=null,!this._transport.destroyed){if(c.operatorList){c.operatorList.lastChunk=!0;for(const f of c.renderTasks)f.operatorListChanged();b(this,Uo,Bh).call(this)}if(c.displayReadyCapability)c.displayReadyCapability.reject(u);else if(c.opListReadCapability)c.opListReadCapability.reject(u);else throw u}})};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 sv){let i=Mx;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 ka(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}};Kn=new WeakMap,$o=new WeakMap,Uo=new WeakSet,Bh=function(){if(!n(this,Kn)||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,Kn,!1),!0};let rm=mv;var ia,$i,Qn,Ho,_p,zo,Vo,vs,kf,Hy,zy,$h,Dc,Tf;const ce=class ce{constructor({name:t=null,port:e=null,verbosity:s=a1()}={}){m(this,vs);m(this,ia,Promise.withResolvers());m(this,$i,null);m(this,Qn,null);m(this,Ho,null);if(this.name=t,this.destroyed=!1,this.verbosity=s,e){if(n(ce,Vo).has(e))throw new Error("Cannot use more than one PDFWorker per port.");n(ce,Vo).set(e,this),b(this,vs,Hy).call(this,e)}else b(this,vs,zy).call(this)}get promise(){return n(this,ia).promise}get port(){return n(this,Qn)}get messageHandler(){return n(this,$i)}destroy(){var t,e;this.destroyed=!0,(t=n(this,Ho))==null||t.terminate(),p(this,Ho,null),n(ce,Vo).delete(n(this,Qn)),p(this,Qn,null),(e=n(this,$i))==null||e.destroy(),p(this,$i,null)}static create(t){const e=n(this,Vo).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 ce(t)}static get workerSrc(){if(En.workerSrc)return En.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return ot(this,"_setupFakeWorkerGlobal",(async()=>n(this,Dc,Tf)?n(this,Dc,Tf):(await import(this.workerSrc)).WorkerMessageHandler)())}};ia=new WeakMap,$i=new WeakMap,Qn=new WeakMap,Ho=new WeakMap,_p=new WeakMap,zo=new WeakMap,Vo=new WeakMap,vs=new WeakSet,kf=function(){n(this,ia).resolve(),n(this,$i).send("configure",{verbosity:this.verbosity})},Hy=function(t){p(this,Qn,t),p(this,$i,new Ih("main","worker",t)),n(this,$i).on("ready",()=>{}),b(this,vs,kf).call(this)},zy=function(){if(n(ce,zo)||n(ce,Dc,Tf)){b(this,vs,$h).call(this);return}let{workerSrc:t}=ce;try{ce._isSameOrigin(window.location,t)||(t=ce._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,ia).reject(new Error("Worker was destroyed")):b(this,vs,$h).call(this)},r=new AbortController;e.addEventListener("error",()=>{n(this,Ho)||i()},{signal:r.signal}),s.on("test",o=>{if(r.abort(),this.destroyed||!o){i();return}p(this,$i,s),p(this,Qn,e),p(this,Ho,e),b(this,vs,kf).call(this)}),s.on("ready",o=>{if(r.abort(),this.destroyed){i();return}try{a()}catch{b(this,vs,$h).call(this)}});const a=()=>{const o=new Uint8Array;s.send("test",o,[o.buffer])};a();return}catch{Up("The worker has been disabled.")}b(this,vs,$h).call(this)},$h=function(){n(ce,zo)||(ht("Setting up fake worker."),p(ce,zo,!0)),ce._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){n(this,ia).reject(new Error("Worker was destroyed"));return}const e=new U1;p(this,Qn,e);const s=`fake${Yt(ce,_p)._++}`,i=new Ih(s+"_worker",s,e);t.setup(i,e),p(this,$i,new Ih(s,s+"_worker",e)),b(this,vs,kf).call(this)}).catch(t=>{n(this,ia).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},Dc=new WeakSet,Tf=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},m(ce,Dc),m(ce,_p,0),m(ce,zo,!1),m(ce,Vo,new WeakMap),ti&&(p(ce,zo,!0),En.workerSrc||(En.workerSrc="./pdf.worker.mjs")),ce._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},ce._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};let ed=ce;var Us,Go,Jn,Ui,jo,Lc,Zn,Xi,Uh,Pf;class Dx{constructor(t,e,s,i,r,a){m(this,Xi);M(this,"downloadInfoCapability",Promise.withResolvers());m(this,Us,null);m(this,Go,new Map);m(this,Jn,null);m(this,Ui,new Map);m(this,jo,new Map);m(this,Lc,new Map);m(this,Zn,null);this.messageHandler=t,this.loadingTask=e,p(this,Jn,s),this.commonObjs=new Fy,this.fontLoader=new P1({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,Ui).set(e,t),n(this,jo).set(e,Promise.resolve(t))}get annotationStorage(){return ot(this,"annotationStorage",new nv)}getRenderingIntent(t,e=_r.ENABLE,s=null,i=!1,r=!1){let a=Zs.DISPLAY,o=Zh;switch(t){case"any":a=Zs.ANY;break;case"display":break;case"print":a=Zs.PRINT;break;default:ht(`getRenderingIntent - invalid intent: ${t}`)}const l=a&Zs.PRINT&&s instanceof sy?s:this.annotationStorage;switch(e){case _r.DISABLE:a+=Zs.ANNOTATIONS_DISABLE;break;case _r.ENABLE:break;case _r.ENABLE_FORMS:a+=Zs.ANNOTATIONS_FORMS;break;case _r.ENABLE_STORAGE:a+=Zs.ANNOTATIONS_STORAGE,o=l.serializable;break;default:ht(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(a+=Zs.IS_EDITING),r&&(a+=Zs.OPLIST);const{ids:c,hash:h}=l.modifiedIds,u=[a,o.hash,h];return{renderingIntent:a,cacheKey:u.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,Zn))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of n(this,Ui).values())t.push(i._destroy());n(this,Ui).clear(),n(this,jo).clear(),n(this,Lc).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,Go).clear(),this.filterFactory.destroy(),ph.cleanup(),(i=n(this,Jn))==null||i.cancelAllRequests(new ka("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)=>{ae(n(this,Jn),"GetReader - no `BasePDFStream` instance available."),p(this,Us,n(this,Jn).getFullReader()),n(this,Us).onProgress=r=>b(this,Xi,Pf).call(this,r),i.onPull=()=>{n(this,Us).read().then(function({value:r,done:a}){if(a){i.close();return}ae(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{i.error(r)})},i.onCancel=r=>{n(this,Us).cancel(r),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("ReaderHeadersReady",async s=>{await n(this,Us).headersReady;const{isStreamingSupported:i,isRangeSupported:r,contentLength:a}=n(this,Us);return i&&r&&(n(this,Us).onProgress=null),{isStreamingSupported:i,isRangeSupported:r,contentLength:a}}),t.on("GetRangeReader",(s,i)=>{ae(n(this,Jn),"GetRangeReader - no `BasePDFStream` instance available.");const r=n(this,Jn).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}ae(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 Ix(s,this))}),t.on("DocException",s=>{e._capability.reject(ws(s))}),t.on("PasswordRequest",s=>{p(this,Zn,Promise.withResolvers());try{if(!e.onPassword)throw ws(s);const i=r=>{r instanceof Error?n(this,Zn).reject(r):n(this,Zn).resolve({password:r})};e.onPassword(i,s.code)}catch(i){n(this,Zn).reject(i)}return n(this,Zn).promise}),t.on("DataLoaded",s=>{b(this,Xi,Pf).call(this,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;n(this,Ui).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;ht(`Error during font loading: ${f}`),this.commonObjs.resolve(s,f);break}const o=new L1(r),l=this._params.pdfBug&&((a=globalThis.FontInspector)!=null&&a.enabled)?(f,g)=>globalThis.FontInspector.fontAdded(f,g):null,c=new M1(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;ae(h,"The imageRef must be defined.");for(const f of n(this,Ui).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 O1(r));break;case"Image":this.commonObjs.resolve(s,r);break;case"Pattern":const u=new F1(r);this.commonObjs.resolve(s,u.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,Ui).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||b(this,Xi,Pf).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&&ht("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,Us))==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,u]of o){if((u==null?void 0:u.pageIndex)!==void 0&&u.pageIndex>=0&&u.pageIndex{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,jo).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,Lc).set(a.refStr,s);const o=new rm(e,a,this,this.pagesMapper,this._params.pdfBug);return n(this,Ui).set(e,o),o});return n(this,jo).set(e,r),r}async getPageIndex(t){if(!Gg(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 b(this,Xi,Uh).call(this,"GetFieldObjects")}hasJSActions(){return b(this,Xi,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 b(this,Xi,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 b(this,Xi,Uh).call(this,"GetOptionalContentConfig").then(e=>new tm(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata";return n(this,Go).getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,null).then(e=>{var s,i;return{info:e[0],metadata:e[1]?new _x(e[1]):null,contentDispositionFilename:((s=n(this,Us))==null?void 0:s.filename)??null,contentLength:((i=n(this,Us))==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,Ui).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),n(this,Go).clear(),this.filterFactory.destroy(!0),ph.cleanup()}}cachedPageNumber(t){if(!Gg(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`,s=n(this,Lc).get(e);if(s>=0){const i=this.pagesMapper.getPageNumber(s+1);if(i!==0)return i}return null}}Us=new WeakMap,Go=new WeakMap,Jn=new WeakMap,Ui=new WeakMap,jo=new WeakMap,Lc=new WeakMap,Zn=new WeakMap,Xi=new WeakSet,Uh=function(t,e=null){return n(this,Go).getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,e))},Pf=function({loaded:t,total:e}){var s,i;(i=(s=this.loadingTask).onProgress)==null||i.call(s,{loaded:t,total:e,percent:e?Zt(Math.round(t/e*100),0,100):NaN})};class Lx{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 na,Wo;const za=class za{constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:r,operatorList:a,pageIndex:o,canvasFactory:l,filterFactory:c,useRequestAnimationFrame:h=!1,pdfBug:u=!1,pageColors:f=null,enableHWA:g=!1,operationsFilter:y=null}){m(this,na,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=u,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 Lx(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(za,Wo).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(za,Wo).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 Ul(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,na)&&(window.cancelAnimationFrame(n(this,na)),p(this,na,null)),n(za,Wo).delete(this._canvas),t||(t=new sv(`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,na,window.requestAnimationFrame(()=>{p(this,na,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(za,Wo).delete(this._canvas),this.callback())))}};na=new WeakMap,Wo=new WeakMap,m(za,Wo,new WeakSet);let am=za;const Fx="6.1.200",Ox="6353acefe";var Hs,Xo,Fc,Ce,su,Oc,tr,iu,ra,Hi,nu,zt,om,lm,cm,Ba,Vy,Cr;const Ss=class Ss{constructor({editor:t=null,uiManager:e=null}){m(this,zt);m(this,Hs,null);m(this,Xo,null);m(this,Fc);m(this,Ce,null);m(this,su,!1);m(this,Oc,!1);m(this,tr,null);m(this,iu);m(this,ra,null);m(this,Hi,null);var s,i;t?(p(this,Oc,!1),p(this,tr,t)):p(this,Oc,!0),p(this,Hi,(t==null?void 0:t._uiManager)||e),p(this,iu,n(this,Hi)._eventBus),p(this,Fc,((s=t==null?void 0:t.color)==null?void 0:s.toUpperCase())||((i=n(this,Hi))==null?void 0:i.highlightColors.values().next().value)||"#FFFF98"),n(Ss,nu)||p(Ss,nu,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 ot(this,"_keyboardManager",new El([[["Escape"],Ss.prototype._hideDropdownFromKeyboard],[["Space"],Ss.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight"],Ss.prototype._moveToNext],[["ArrowUp","ArrowLeft"],Ss.prototype._moveToPrevious],[["Home"],Ss.prototype._moveToBeginning],[["End"],Ss.prototype._moveToEnd]]))}renderButton(){const t=p(this,Hs,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",n(this,tr)&&(t.ariaControls=`${n(this,tr).id}_colorpicker_dropdown`);const e=n(this,Hi)._signal;t.addEventListener("click",b(this,zt,Ba).bind(this),{signal:e}),t.addEventListener("keydown",b(this,zt,cm).bind(this),{signal:e});const s=p(this,Xo,document.createElement("span"));return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=n(this,Fc),t.append(s),t}renderMainDropdown(){const t=p(this,Ce,b(this,zt,om).call(this));return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}_colorSelectFromKeyboard(t){if(t.target===n(this,Hs)){b(this,zt,Ba).call(this,t);return}const e=t.target.getAttribute("data-color");e&&b(this,zt,lm).call(this,e,t)}_moveToNext(t){var e,s;if(!n(this,zt,Cr)){b(this,zt,Ba).call(this,t);return}if(t.target===n(this,Hs)){(e=n(this,Ce).firstElementChild)==null||e.focus();return}(s=t.target.nextSibling)==null||s.focus()}_moveToPrevious(t){var e,s;if(t.target===((e=n(this,Ce))==null?void 0:e.firstElementChild)||t.target===n(this,Hs)){n(this,zt,Cr)&&this._hideDropdownFromKeyboard();return}n(this,zt,Cr)||b(this,zt,Ba).call(this,t),(s=t.target.previousSibling)==null||s.focus()}_moveToBeginning(t){var e;if(!n(this,zt,Cr)){b(this,zt,Ba).call(this,t);return}(e=n(this,Ce).firstElementChild)==null||e.focus()}_moveToEnd(t){var e;if(!n(this,zt,Cr)){b(this,zt,Ba).call(this,t);return}(e=n(this,Ce).lastElementChild)==null||e.focus()}hideDropdown(){var t,e;(t=n(this,Ce))==null||t.classList.add("hidden"),n(this,Hs).ariaExpanded="false",(e=n(this,ra))==null||e.abort(),p(this,ra,null)}_hideDropdownFromKeyboard(){var t;if(!n(this,Oc)){if(!n(this,zt,Cr)){(t=n(this,tr))==null||t.unselect();return}this.hideDropdown(),n(this,Hs).focus({preventScroll:!0,focusVisible:n(this,su)})}}updateColor(t){if(n(this,Xo)&&(n(this,Xo).style.backgroundColor=t),!n(this,Ce))return;const e=n(this,Hi).highlightColors.values();for(const s of n(this,Ce).children)s.ariaSelected=e.next().value===t.toUpperCase()}destroy(){var t,e;(t=n(this,Hs))==null||t.remove(),p(this,Hs,null),p(this,Xo,null),(e=n(this,Ce))==null||e.remove(),p(this,Ce,null)}};Hs=new WeakMap,Xo=new WeakMap,Fc=new WeakMap,Ce=new WeakMap,su=new WeakMap,Oc=new WeakMap,tr=new WeakMap,iu=new WeakMap,ra=new WeakMap,Hi=new WeakMap,nu=new WeakMap,zt=new WeakSet,om=function(){const t=document.createElement("div"),e=n(this,Hi)._signal;t.addEventListener("contextmenu",Ei,{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,tr)&&(t.id=`${n(this,tr).id}_colorpicker_dropdown`);for(const[s,i]of n(this,Hi).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(Ss,nu)[s]);const a=document.createElement("span");r.append(a),a.className="swatch",a.style.backgroundColor=i,r.ariaSelected=i===n(this,Fc),r.addEventListener("click",b(this,zt,lm).bind(this,i),{signal:e}),t.append(r)}return t.addEventListener("keydown",b(this,zt,cm).bind(this),{signal:e}),t},lm=function(t,e){e.stopPropagation(),n(this,iu).dispatch("switchannotationeditorparams",{source:this,type:pt.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)},cm=function(t){Ss._keyboardManager.exec(this,t)},Ba=function(t){if(n(this,zt,Cr)){this.hideDropdown();return}if(p(this,su,t.detail===0),n(this,ra)||(p(this,ra,new AbortController),window.addEventListener("pointerdown",b(this,zt,Vy).bind(this),{signal:n(this,Hi).combinedSignal(n(this,ra))})),n(this,Hs).ariaExpanded="true",n(this,Ce)){n(this,Ce).classList.remove("hidden");return}const e=p(this,Ce,b(this,zt,om).call(this));n(this,Hs).append(e)},Vy=function(t){var e;(e=n(this,Ce))!=null&&e.contains(t.target)||this.hideDropdown()},Cr=function(){return n(this,Ce)&&!n(this,Ce).classList.contains("hidden")},m(Ss,nu,null);let ip=Ss;var zs,Rc,qo,er,ru;const Va=class Va{constructor(t){m(this,zs,null);m(this,Rc,!1);m(this,qo,null);m(this,er,null);p(this,qo,t),p(this,er,t._uiManager),n(Va,ru)||p(Va,ru,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(n(this,zs))return n(this,zs);const{editorType:t,colorType:e,colorAndOpacityType:s,opacityType:i,color:r,opacity:a}=n(this,qo),o=p(this,Rc,Ht.isAlphaColorInputSupported&&i!==void 0),l=p(this,zs,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(Va,ru)[t]),l.addEventListener("input",()=>{if(o){const c=Xu(l.value);if(!c)return;const[h,u,f,g]=c,y=B.makeHexColor(h,u,f);s!==void 0?n(this,er).updateParams(s,{color:y,opacity:g}):(n(this,er).updateParams(e,y),n(this,er).updateParams(i,g))}else n(this,er).updateParams(e,l.value)},{signal:n(this,er)._signal}),l}update(t){if(n(this,zs))if(n(this,Rc)){const e=B.hexNums[Math.round(n(this,qo).opacity*255)];n(this,zs).value=t+e}else n(this,zs).value=t}updateOpacity(t){if(!n(this,zs)||!n(this,Rc))return;const e=B.hexNums[Math.round(t*255)];n(this,zs).value=n(this,qo).color+e}destroy(){var t;(t=n(this,zs))==null||t.remove(),p(this,zs,null)}hideDropdown(){}};zs=new WeakMap,Rc=new WeakMap,qo=new WeakMap,er=new WeakMap,ru=new WeakMap,m(Va,ru,null);let np=Va;function eb(d){return Math.floor(Zt(d,0,1)*255).toString(16).padStart(2,"0")}function Ah(d){return Zt(d,0,1)*255}class sb{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=eb(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(eb).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 Rx{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 rp extends Rx{_createSVG(t){return document.createElementNS(Os,t)}}const Nx=9,_l=new WeakSet,Bx=new Date().getTimezoneOffset()*60*1e3;class ug{static create(t){switch(t.data.annotationType){case le.LINK:return new av(t);case le.TEXT:return new Ux(t);case le.WIDGET:switch(t.data.fieldType){case"Tx":return new Hx(t);case"Btn":return t.data.radioButton?new Gx(t):t.data.checkBox?new Vx(t):new jx(t);case"Ch":return new Wx(t);case"Sig":return new zx(t)}return new Pl(t);case le.POPUP:return new dm(t);case le.FREETEXT:return new Ky(t);case le.LINE:return new qx(t);case le.SQUARE:return new Yx(t);case le.CIRCLE:return new Kx(t);case le.POLYLINE:return new Qy(t);case le.CARET:return new Jx(t);case le.INK:return new ov(t);case le.POLYGON:return new Qx(t);case le.HIGHLIGHT:return new Jy(t);case le.UNDERLINE:return new Zx(t);case le.SQUIGGLY:return new tE(t);case le.STRIKEOUT:return new eE(t);case le.STAMP:return new Zy(t);case le.FILEATTACHMENT:return new sE(t);case le.RICHMEDIA:case le.SCREEN:return new t0(t);default:return new se(t)}}}var Yo,Nc,vi,au,hm;const vv=class vv{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){m(this,au);m(this,Yo,null);m(this,Nc,!1);m(this,vi,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 vv._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;la?(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;ca?(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(`${Qh}${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(`${Qh}${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,vi))==null?void 0:t.popup)||this.popup)==null||e.remove(),p(this,vi,this.popup=null)}updateEdited(t){var r;if(!this.container)return;t.rect&&(n(this,Yo)||p(this,Yo,{rect:this.data.rect.slice(0)}));const{rect:e,popup:s}=t;e&&b(this,au,hm).call(this,e);let i=((r=n(this,vi))==null?void 0:r.popup)||this.popup;!i&&(s!=null&&s.text)&&(this._createPopup(s),i=n(this,vi).popup),i&&(i.updateEdited(t),s!=null&&s.deleted&&(i.remove(),p(this,vi,null),this.popup=null))}resetEdited(){var t;n(this,Yo)&&(b(this,au,hm).call(this,n(this,Yo).rect),(t=n(this,vi))==null||t.popup.resetEdited(),p(this,Yo,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 av)&&!(this instanceof t0)&&(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 dm){const{rotation:v}=e;return!e.hasOwnCanvas&&v!==0&&this.setRotation(v,r),r}const{width:o,height:l}=this;if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const v=e.borderStyle.horizontalCornerRadius,w=e.borderStyle.verticalCornerRadius;if(v>0||w>0){const x=`calc(${v}px * var(--total-scale-factor)) / calc(${w}px * var(--total-scale-factor))`;a.borderRadius=x}switch(e.borderStyle.style){case Dl.SOLID:a.borderStyle="solid";break;case Dl.DASHED:a.borderStyle="dashed";break;case Dl.BEVELED:ht("Unimplemented border style: beveled");break;case Dl.INSET:ht("Unimplemented border style: inset");break;case Dl.UNDERLINE:a.borderBottomStyle="solid";break}const S=e.borderColor||null;S?(p(this,Nc,!0),a.borderColor=B.makeHexColor(...S)):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:u,pageX:f,pageY:g}=i.rawDims;a.left=`${100*(c[0]-f)/h}%`,a.top=`${100*(c[1]-g)/u}%`;const{rotation:y}=e;return e.hasOwnCanvas||y===0?(a.width=`${100*o/h}%`,a.height=`${100*l/u}%`):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]=sb[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:sb[`${a}_rgb`](o)})};return ot(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(v=>Math.fround(v));if(t.length===8){const[v,w,S,x]=t.subarray(2,6);if(i===v&&r===w&&e===S&&s===x)return}const{style:a}=this.container;let o;if(n(this,Nc)){const{borderColor:v,borderWidth:w}=a;a.borderWidth=0,o=["url('data:image/svg+xml;utf8,",``,``],this.container.classList.add("hasBorder")}const l=i-e,c=r-s,{svgFactory:h}=this,u=h.createElement("svg");u.classList.add("quadrilateralsContainer"),u.setAttribute("width",0),u.setAttribute("height",0),u.role="none";const f=h.createElement("defs");u.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 v=2,w=t.length;v`)}n(this,Nc)&&(o.push("')"),a.backgroundImage=o.join("")),this.container.append(u),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,vi,new dm({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,vi)||this.popup||this.data.popupRef)}get extraPopupElement(){return n(this,vi)}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)){ht(`_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)}};Yo=new WeakMap,Nc=new WeakMap,vi=new WeakMap,au=new WeakSet,hm=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 se=vv;class $x extends se{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 si,$a,Gy,jy;class av extends se{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});m(this,si);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?(b(this,si,Gy).call(this,i,e.attachmentId,e.attachment,e.overlaidText,e.attachmentDest),r=!0):e.setOCGState?(b(this,si,jy).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==="")&&b(this,si,$a).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),b(this,si,$a).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),b(this,si,$a).call(this)}_bindResetFormAction(e,s){const i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),b(this,si,$a).call(this),!this._fieldObjects){ht('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(e.onclick=()=>!1);return}e.onclick=()=>{var u;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:v}of y)f.add(v)}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 v=f.defaultValue||"";c.setValue(g,{value:v});break}case"checkbox":case"radiobutton":{const v=f.defaultValue===f.exportValues;c.setValue(g,{value:v});break}case"combobox":case"listbox":{const v=f.defaultValue||"";c.setValue(g,{value:v});break}default:continue}const y=document.querySelector(`[data-element-id="${g}"]`);if(y){if(!_l.has(y)){ht(`_bindResetFormAction - element not allowed: ${g}`);continue}}else continue;y.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((u=this.linkService.eventBus)==null||u.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:h,name:"ResetForm"}})),!1}}}si=new WeakSet,$a=function(){this.container.setAttribute("data-internal-link","")},Gy=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),b(this,si,$a).call(this)},jy=function(e,s,i=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),i&&(e.title=i),b(this,si,$a).call(this)};class Ux extends se{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 se{render(){return this.container}_getKeyModifier(t){return Ht.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||Nx,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/(rg*i))||1,u=c/h;a=Math.min(i,l(u/rg))}else{const c=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(i,l(c/rg))}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 Hx 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:u,datetimeType:f,timeStep:g}=this.data,y=!!f&&this.enableScripting;u&&(s.title=u),this._setRequired(s,this.data.required),l&&(s.maxLength=l),s.addEventListener("input",w=>{t.setValue(e,{value:w.target.value}),this.setPropertyOnSiblings(s,"value",w.target.value,"value"),h.formattedValue=null}),s.addEventListener("resetform",w=>{const S=this.data.defaultFieldValue??"";s.value=h.userValue=S,h.formattedValue=null});let v=w=>{const{formattedValue:S}=h;S!=null&&(w.target.value=S),w.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",S=>{var A;if(h.focused)return;const{target:x}=S;if(y&&(x.type=f,g&&(x.step=g)),h.userValue){const _=h.userValue;if(y)if(f==="time"){const E=new Date(_),k=[E.getHours(),E.getMinutes(),E.getSeconds()];x.value=k.map(P=>P.toString().padStart(2,"0")).join(":")}else x.value=new Date(_-Bx).toISOString().split(f==="date"?"T":".",1)[0];else x.value=_}h.lastCommittedValue=x.value,h.commitKey=1,(A=this.data.actions)!=null&&A.Focus||(h.focused=!0)}),s.addEventListener("updatefromsandbox",S=>{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:_}=A.detail;h.formattedValue=_,_!=null&&A.target!==document.activeElement&&(A.target.value=_);const E={formattedValue:_};y&&(E.value=_),t.setValue(e,E)},selRange(A){A.target.setSelectionRange(...A.detail.selRange)},charLimit:A=>{var P;const{charLimit:_}=A.detail,{target:E}=A;if(_===0){E.removeAttribute("maxLength");return}E.setAttribute("maxLength",_);let k=h.userValue;!k||k.length<=_||(k=k.slice(0,_),E.value=h.userValue=k,t.setValue(e,{value:k}),(P=this.linkService.eventBus)==null||P.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:k,willCommit:!0,commitKey:1,selStart:E.selectionStart,selEnd:E.selectionEnd}}))}};this._dispatchEventFromSandbox(x,S)}),s.addEventListener("keydown",S=>{var _;h.commitKey=1;let x=-1;if(S.key==="Escape"?x=0:S.key==="Enter"&&!this.data.multiLine?x=2:S.key==="Tab"&&(h.commitKey=3),x===-1)return;const{value:A}=S.target;h.lastCommittedValue!==A&&(h.lastCommittedValue=A,h.userValue=A,(_=this.linkService.eventBus)==null||_.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:A,willCommit:!0,commitKey:x,selStart:S.target.selectionStart,selEnd:S.target.selectionEnd}}))});const w=v;v=null,s.addEventListener("blur",S=>{var _,E;if(!h.focused||!S.relatedTarget)return;(_=this.data.actions)!=null&&_.Blur||(h.focused=!1);const{target:x}=S;let{value:A}=x;if(y){if(A&&f==="time"){const k=A.split(":").map(P=>parseInt(P,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&&((E=this.linkService.eventBus)==null||E.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:A,willCommit:!0,commitKey:h.commitKey,selStart:S.target.selectionStart,selEnd:S.target.selectionEnd}})),w(S)}),(r=this.data.actions)!=null&&r.Keystroke&&s.addEventListener("beforeinput",S=>{var I;h.lastCommittedValue=null;const{data:x,target:A}=S,{value:_,selectionStart:E,selectionEnd:k}=A;let P=E,L=k;switch(S.inputType){case"deleteWordBackward":{const D=_.substring(0,E).match(/\w*\W*$/);D&&(P-=D[0].length);break}case"deleteWordForward":{const D=_.substring(E).match(/^\W*\w*/);D&&(L+=D[0].length);break}case"deleteContentBackward":E===k&&(P-=1);break;case"deleteContentForward":E===k&&(L+=1);break}S.preventDefault(),(I=this.linkService.eventBus)==null||I.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:_,change:x||"",willCommit:!1,selStart:P,selEnd:L}})}),this._setEventListeners(s,h,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],S=>S.target.value)}if(v&&s.addEventListener("blur",v),this.data.comb){const S=(this.data.rect[2]-this.data.rect[0])/l;s.classList.add("comb"),s.style.setProperty("--comb-width",`calc(${S}px * var(--total-scale-factor))`);const x=this.data.textAlignment;if(x===1||x===2){const A=()=>{const _=l-s.value.length;s.style.setProperty("--comb-offset",`${x===1?_>>1:_}`)};A();for(const _ of["input","blur","resetform","updatefromsandbox"])s.addEventListener(_,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 zx extends Pl{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Vx 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 Gx 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 u of this._getElementsByName(c.target.name)){const f=h&&u.id===s;u.domElement&&(u.domElement.checked=f),t.setValue(u.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 jx extends av{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 Wx 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",u=>{const f=this.data.defaultFieldValue;for(const g of i.options)g.selected=g.value===f});const a=(u,f)=>{const g=f.replaceAll(" "," ");u.textContent=g,g!==f&&u.setAttribute("display-value",f)};for(const u of this.data.options){const f=document.createElement("option");a(f,u.displayValue),f.value=u.exportValue,s.value.includes(u.exportValue)&&(f.setAttribute("selected",!0),r=!1),i.append(f)}let o=null;if(r){const u=document.createElement("option");u.value=" ",u.setAttribute("hidden",!0),u.setAttribute("selected",!0),i.prepend(u),o=()=>{u.remove(),i.removeEventListener("input",o),o=null},i.addEventListener("input",o)}const l=u=>{const f=u?"value":"textContent",{options:g,multiple:y}=i;return y?Array.prototype.filter.call(g,v=>v.selected).map(v=>v[f]):g.selectedIndex===-1?null:g[g.selectedIndex][f]};let c=l(!1);const h=u=>{const f=u.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",u=>{const f={value(g){o==null||o();const y=g.detail.value,v=new Set(Array.isArray(y)?y:[y]);for(const w of i.options)w.selected=v.has(w.value);t.setValue(e,{value:l(!0)}),c=l(!1)},multipleSelection(g){i.multiple=!0},remove(g){const y=i.options,v=g.detail.remove;y[v].selected=!1,i.remove(v),y.length>0&&Array.prototype.findIndex.call(y,S=>S.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:v,exportValue:w}=g.detail.insert,S=i.children[y],x=document.createElement("option");a(x,v),x.value=w,S?S.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 v of y){const{displayValue:w,exportValue:S}=v,x=document.createElement("option");a(x,w),x.value=S,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 v of g.target.options)v.selected=y.has(v.index);t.setValue(e,{value:l(!0)}),c=l(!1)},editable(g){g.target.disabled=!g.detail.editable}};this._dispatchEventFromSandbox(f,u)}),i.addEventListener("input",u=>{var y;const f=l(!0),g=l(!1);t.setValue(e,{value:f}),u.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"]],u=>u.target.value)):i.addEventListener("input",function(u){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 ou,um;class dm extends se{constructor(e){const{data:s,elements:i,parent:r}=e,a=!!r._commentManager;super(e,{isRenderable:!a&&se._hasPopupData(s)});m(this,ou);if(this.elements=i,a&&se._hasPopupData(s)){const o=this.popup=b(this,ou,um).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=b(this,ou,um).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=>`${Nl}${r}`).join(",")),this.container}}ou=new WeakSet,um=function(){return new Xx({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 Vs,aa,kp,Tp,Bc,$c,ue,pn,oa,Ko,Uc,Hc,gn,Gs,sr,ir,fe,nr,la,lu,rr,zc,Qo,ca,De,ha,vt,Mf,fm,pm,gm,If,mm,Wy,Xy,qy,Yy,Df,Lf,vm;class Xx{constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:r,contentsObj:a,richText:o,parent:l,rect:c,parentRect:h,open:u,commentManager:f=null}){m(this,vt);m(this,Vs,null);m(this,aa,b(this,vt,qy).bind(this));m(this,kp,b(this,vt,vm).bind(this));m(this,Tp,b(this,vt,Lf).bind(this));m(this,Bc,b(this,vt,Df).bind(this));m(this,$c,null);m(this,ue,null);m(this,pn,null);m(this,oa,null);m(this,Ko,null);m(this,Uc,null);m(this,Hc,null);m(this,gn,!1);m(this,Gs,null);m(this,sr,null);m(this,ir,null);m(this,fe,null);m(this,nr,null);m(this,la,null);m(this,lu,null);m(this,rr,null);m(this,zc,null);m(this,Qo,null);m(this,ca,!1);m(this,De,null);m(this,ha,null);p(this,ue,t),p(this,zc,i),p(this,pn,a),p(this,rr,o),p(this,Uc,l),p(this,$c,e),p(this,lu,c),p(this,Hc,h),p(this,Ko,s),p(this,Vs,f),p(this,De,s[0]),p(this,oa,tp.toDateObject(r)),this.trigger=s.flatMap(g=>g.getElementsToTriggerPopup()),f||(b(this,vt,Mf).call(this),n(this,ue).hidden=!0,u&&b(this,vt,Df).call(this))}renderCommentButton(){if(n(this,fe)){n(this,fe).parentNode||n(this,De).container.after(n(this,fe));return}if(n(this,nr)||b(this,vt,fm).call(this),!n(this,nr))return;const{signal:t}=p(this,sr,new AbortController),e=n(this,De).hasOwnCommentButton,s=()=>{n(this,Vs).toggleCommentPopup(this,!0,void 0,!e)},i=()=>{n(this,Vs).toggleCommentPopup(this,!1,!0,!e)},r=()=>{n(this,Vs).toggleCommentPopup(this,!1,!1)};if(e){p(this,fe,n(this,De).container);for(const a of this.trigger)a.ariaHasPopup="dialog",a.ariaControls="commentPopup",a.addEventListener("keydown",n(this,aa),{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,fe,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"),b(this,vt,gm).call(this),b(this,vt,pm).call(this),a.addEventListener("keydown",n(this,aa),{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,Uc)._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{var t;(t=n(this,fe))==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,fe)}get comment(){return n(this,ha)||p(this,ha,n(this,De).commentText),n(this,ha)}set comment(t){t!==this.comment&&(n(this,De).commentText=p(this,ha,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,fe)&&(n(this,fe).classList.toggle("selected",t),n(this,fe).ariaExpanded=e)}setSelectedCommentButton(t){n(this,fe).classList.toggle("selected",t)}get commentPopupPosition(){if(n(this,la))return n(this,la);const{x:t,y:e,height:s}=n(this,fe).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,la,t)}hasDefaultPopupPosition(){return n(this,la)===null}get commentButtonPosition(){return n(this,nr)}get commentButtonWidth(){return n(this,fe).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,s]=n(this,la)||this.commentButtonPosition.map(c=>c/100),i=this.parentBoundingClientRect,{x:r,y:a,width:o,height:l}=i;n(this,Vs).showDialog(null,this,r+e*o,a+s*l,{...t,parentDimensions:i})}render(){var s,i;if(n(this,Gs))return;const t=p(this,Gs,document.createElement("div"));if(t.className="popup",n(this,$c)){const r=t.style.outlineColor=B.makeHexColor(...n(this,$c));t.style.backgroundColor=`color-mix(in srgb, ${r} 30%, white)`}const e=document.createElement("span");if(e.className="header",(s=n(this,zc))!=null&&s.str){const r=document.createElement("span");r.className="title",e.append(r),{dir:r.dir,str:r.textContent}=n(this,zc)}if(t.append(e),n(this,oa)){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,oa).valueOf()})),r.dateTime=n(this,oa).toISOString(),e.append(r)}wb({html:n(this,vt,If)||n(this,pn).str,dir:(i=n(this,pn))==null?void 0:i.dir,className:"popupContent"},t),n(this,ue).append(t)}updateEdited({rect:t,popup:e,deleted:s}){var i;if(n(this,Vs)){s?(this.remove(),p(this,ha,null)):e&&(e.deleted?this.remove():(b(this,vt,gm).call(this),p(this,ha,e.text))),t&&(p(this,nr,null),b(this,vt,fm).call(this),b(this,vt,pm).call(this));return}if(s||e!=null&&e.deleted){this.remove();return}b(this,vt,Mf).call(this),n(this,Qo)||p(this,Qo,{contentsObj:n(this,pn),richText:n(this,rr)}),t&&p(this,ir,null),e&&e.text&&(p(this,rr,b(this,vt,Xy).call(this,e.text)),p(this,oa,tp.toDateObject(e.date)),p(this,pn,null)),(i=n(this,Gs))==null||i.remove(),p(this,Gs,null)}resetEdited(){var t;n(this,Qo)&&({contentsObj:Yt(this,pn)._,richText:Yt(this,rr)._}=n(this,Qo),p(this,Qo,null),(t=n(this,Gs))==null||t.remove(),p(this,Gs,null),p(this,ir,null))}remove(){var t,e,s;if((t=n(this,sr))==null||t.abort(),p(this,sr,null),(e=n(this,Gs))==null||e.remove(),p(this,Gs,null),p(this,ca,!1),p(this,gn,!1),(s=n(this,fe))==null||s.remove(),p(this,fe,null),this.trigger)for(const i of this.trigger)i.classList.remove("popupTriggerArea")}forceHide(){p(this,ca,this.isVisible),n(this,ca)&&(n(this,ue).hidden=!0)}maybeShow(){n(this,Vs)||(b(this,vt,Mf).call(this),n(this,ca)&&(n(this,Gs)||b(this,vt,Lf).call(this),p(this,ca,!1),n(this,ue).hidden=!1))}get isVisible(){return n(this,Vs)?!1:n(this,ue).hidden===!1}}Vs=new WeakMap,aa=new WeakMap,kp=new WeakMap,Tp=new WeakMap,Bc=new WeakMap,$c=new WeakMap,ue=new WeakMap,pn=new WeakMap,oa=new WeakMap,Ko=new WeakMap,Uc=new WeakMap,Hc=new WeakMap,gn=new WeakMap,Gs=new WeakMap,sr=new WeakMap,ir=new WeakMap,fe=new WeakMap,nr=new WeakMap,la=new WeakMap,lu=new WeakMap,rr=new WeakMap,zc=new WeakMap,Qo=new WeakMap,ca=new WeakMap,De=new WeakMap,ha=new WeakMap,vt=new WeakSet,Mf=function(){var e;if(n(this,sr))return;p(this,sr,new AbortController);const{signal:t}=n(this,sr);for(const s of this.trigger)s.addEventListener("click",n(this,Bc),{signal:t}),s.addEventListener("pointerenter",n(this,Tp),{signal:t}),s.addEventListener("pointerleave",n(this,kp),{signal:t}),s.classList.add("popupTriggerArea");for(const s of n(this,Ko))(e=s.container)==null||e.addEventListener("keydown",n(this,aa),{signal:t})},fm=function(){const t=n(this,Ko).find(e=>e.hasCommentButton);t&&p(this,nr,t._normalizePoint(t.commentButtonPosition))},pm=function(){if(n(this,De).extraPopupElement&&!n(this,De).editor)return;n(this,fe)||this.renderCommentButton();const[t,e]=n(this,nr),{style:s}=n(this,fe);s.left=`calc(${t}%)`,s.top=`calc(${e}% - var(--comment-button-dim))`},gm=function(){n(this,De).extraPopupElement||(n(this,fe)||this.renderCommentButton(),n(this,fe).style.backgroundColor=this.commentButtonColor||"")},If=function(){const t=n(this,rr),e=n(this,pn);return t!=null&&t.str&&(!(e!=null&&e.str)||e.str===t.str)&&n(this,rr).html||null},mm=function(){var t,e,s;return((s=(e=(t=n(this,vt,If))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.fontSize)||0},Wy=function(){var t,e,s;return((s=(e=(t=n(this,vt,If))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.color)||null},Xy=function(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:n(this,vt,Wy),fontSize:n(this,vt,mm)?`calc(${n(this,vt,mm)}px * var(--total-scale-factor))`:""}};for(const r of t.split(` `))e.push({name:"span",value:r,attributes:i});return s},qy=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&n(this,gn))&&b(this,vt,Df).call(this)},Yy=function(){if(n(this,ir)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:r}}}=n(this,Uc);let a=!!n(this,Hc),o=a?n(this,Hc):n(this,lu);for(const y of n(this,Ko))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,u=l[0]+h,f=l[1];p(this,ir,[100*(u-i)/e,100*(f-r)/s]);const{style:g}=n(this,ue);g.left=`${n(this,ir)[0]}%`,g.top=`${n(this,ir)[1]}%`},Df=function(){if(n(this,Vs)){n(this,Vs).toggleCommentPopup(this,!1);return}p(this,gn,!n(this,gn)),n(this,gn)?(b(this,vt,Lf).call(this),n(this,ue).addEventListener("click",n(this,Bc)),n(this,ue).addEventListener("keydown",n(this,aa))):(b(this,vt,vm).call(this),n(this,ue).removeEventListener("click",n(this,Bc)),n(this,ue).removeEventListener("keydown",n(this,aa)))},Lf=function(){n(this,Gs)||this.render(),this.isVisible?n(this,gn)&&n(this,ue).classList.add("focused"):(b(this,vt,Yy).call(this),n(this,ue).hidden=!1,n(this,ue).style.zIndex=parseInt(n(this,ue).style.zIndex,10)+1e3)},vm=function(){n(this,ue).classList.remove("focused"),!(n(this,gn)||!this.isVisible)&&(n(this,ue).hidden=!0,n(this,ue).style.zIndex=parseInt(n(this,ue).style.zIndex,10)-1e3)};class Ky extends se{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=ct.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 cu;class qx extends se{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,cu,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,cu,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,cu)}addHighlightArea(){this.container.classList.add("highlightArea")}}cu=new WeakMap;var hu;class Yx extends se{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,hu,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,hu,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,hu)}addHighlightArea(){this.container.classList.add("highlightArea")}}hu=new WeakMap;var du;class Kx extends se{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,du,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,du,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,du)}addHighlightArea(){this.container.classList.add("highlightArea")}}du=new WeakMap;var uu;class Qy extends se{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,uu,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 u=0,f=s.length;u=0&&a.setAttribute("stroke-width",s||1),i)for(let o=0,l=n(this,Jo).length;o{a.key==="Enter"&&(r?a.metaKey:a.ctrlKey)&&b(this,mu,ym).call(this)}),!s.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):i.classList.add("popupTriggerArea"),e.append(i),e}getElementsToTriggerPopup(){return n(this,gu)}addHighlightArea(){this.container.classList.add("highlightArea")}}gu=new WeakMap,mu=new WeakSet,ym=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 Vc,Zo,ar,kl,e0,wm;class t0 extends se{constructor(e){super(e,{isRenderable:!!e.data.richMedia});m(this,kl);m(this,Vc,new AbortController);m(this,Zo,null);m(this,ar,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",()=>b(this,kl,e0).call(this,s),{signal:n(this,Vc).signal}),this.container.append(s),this.container}destroy(){n(this,Vc).abort(),n(this,ar)&&(n(this,ar).pause(),n(this,ar).removeAttribute("src"),n(this,ar).load(),p(this,ar,null)),b(this,kl,wm).call(this)}}Vc=new WeakMap,Zo=new WeakMap,ar=new WeakMap,kl=new WeakSet,e0=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,Vc),l=URL.createObjectURL(new Blob([a],{type:r}));p(this,Zo,l);const c=r.startsWith("audio/"),h=document.createElement(c?"audio":"video");if(p(this,ar,h),h.className="mediaContent",this._setBackgroundColor(h),h.src=l,h.title=i,h.controls=!0,h.autoplay=!0,h.tabIndex=0,c){let u=!1,f=!1;const g=()=>{h.controls=u||f};this.container.addEventListener("pointerenter",()=>{u=!0,g()},{signal:o}),this.container.addEventListener("pointerleave",()=>{u=!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",()=>b(this,kl,wm).call(this,l),{once:!0,signal:o}),e.replaceWith(h),h.play().catch(()=>{})},wm=function(e=n(this,Zo)){e&&e===n(this,Zo)&&(URL.revokeObjectURL(e),p(this,Zo,null))};var da,tl,Gc,or,vu,el,ss,bu,Cn,Ff,Of;const bv=class bv{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:r,viewport:a,structTreeLayer:o,commentManager:l,linkService:c,annotationStorage:h}){m(this,Cn);m(this,da,null);m(this,tl,null);m(this,Gc,null);m(this,or,new Map);m(this,vu,null);m(this,el,null);m(this,ss,[]);m(this,bu,!1);M(this,"zIndex",0);this.div=t,p(this,da,e),p(this,tl,s),p(this,vu,o||null),p(this,el,c||null),p(this,Gc,h||new nv),this.page=r,this.viewport=a,this._annotationEditorUIManager=i,this._commentManager=l||null}hasEditableAnnotations(){return n(this,or).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,el),downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new rp,annotationStorage:n(this,Gc),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===le.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 u=ug.create(o);if(!u.isRenderable)continue;h||(n(this,ss).push(u),c.popupRef&&r.getOrInsertComputed(c.popupRef,ju).push(u));const f=u.render();c.hidden&&(f.style.visibility="hidden"),u.updateOC(s),u._isEditable&&(n(this,or).set(u.data.id,u),(l=this._annotationEditorUIManager)==null||l.renderAnnotationElement(u))}await b(this,Cn,Ff).call(this);for(const c of a){const h=o.elements=r.get(c.id);o.data=c;const u=ug.create(o);if(!u.isRenderable)continue;const f=u.render();u.contentElement.id=`${Nl}${c.id}`,c.hidden&&(f.style.visibility="hidden"),h.at(-1).container.after(f)}b(this,Cn,Of).call(this)}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:n(this,el),svgFactory:new rp,parent:this};for(const s of t){s.borderStyle||(s.borderStyle=bv._defaultBorderStyle),e.data=s;const i=ug.create(e);i.isRenderable&&(i.render(),i.contentElement.id=`${Nl}${s.id}`,n(this,ss).push(i))}await b(this,Cn,Ff).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,ss))i.updateOC(e);b(this,Cn,Of).call(this),s.hidden=!1}destroy(){var t,e;for(const s of n(this,ss))(t=s.destroy)==null||t.call(s),(e=n(this,da))==null||e.removePointerInTextLayer(s.contentElement);n(this,ss).length=0,n(this,or).clear(),this.div.replaceChildren()}refreshCanvases(){b(this,Cn,Of).call(this)}getEditableAnnotations(){return n(this,or).values()}getEditableAnnotation(t){return n(this,or).get(t)}addFakeAnnotation(t){const{div:e}=this,{id:s,rotation:i}=t,r=new $x({data:{id:s,rect:t.getPDFRect(),rotation:i},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:n(this,el),annotationStorage:n(this,Gc)});return r.render(),r.contentElement.id=`${Nl}${s}`,r.createOrUpdatePopup(),n(this,ss).push(r),r}removeAnnotation(t){var i;const e=n(this,ss).findIndex(r=>r.data.id===t);if(e<0)return;const[s]=n(this,ss).splice(e,1);(i=n(this,da))==null||i.removePointerInTextLayer(s.contentElement)}updateFakeAnnotations(t){if(t.length!==0){for(const e of t)e.updateFakeAnnotationElement(this);b(this,Cn,Ff).call(this)}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return ot(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Dl.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};da=new WeakMap,tl=new WeakMap,Gc=new WeakMap,or=new WeakMap,vu=new WeakMap,el=new WeakMap,ss=new WeakMap,bu=new WeakMap,Cn=new WeakSet,Ff=async function(){var s,i,r;if(n(this,ss).length===0)return;this.div.replaceChildren();const t=[];if(!n(this,bu)){p(this,bu,!0);for(const{contentElement:a,data:{id:o}}of n(this,ss)){const l=a.id=`${Nl}${o}`;t.push((s=n(this,vu))==null?void 0:s.getAriaAttributes(l).then(c=>{if(c)for(const[h,u]of c)a.setAttribute(h,u)}))}}n(this,ss).sort(({data:{rect:[a,o,l,c]}},{data:{rect:[h,u,f,g]}})=>{if(a===l&&o===c)return 1;if(h===f&&u===g)return-1;const y=c,v=o,w=(o+c)/2,S=g,x=u,A=(u+g)/2;if(w>=S&&A<=v)return-1;if(A>=y&&w<=x)return 1;const _=(a+l)/2,E=(h+f)/2;return _-E});const e=document.createDocumentFragment();for(const a of n(this,ss))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,da))for(const a of n(this,ss))n(this,da).addPointerInTextLayer(a.contentElement,!1)},Of=function(){var e;if(!n(this,tl))return;const t=this.div;for(const[s,i]of n(this,tl)){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 u=1,f=i.length;ua.isEmpty(),i=Cl.TRANSLATE_SMALL,r=Cl.TRANSLATE_BIG;return ot(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){Mt.initialize(e,s);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,s){switch(e){case pt.FREETEXT_SIZE:Kt._defaultFontSize=s;break;case pt.FREETEXT_COLOR:Kt._defaultColor=s;break}}updateParams(e,s){switch(e){case pt.FREETEXT_SIZE:b(this,xe,s0).call(this,s);break;case pt.FREETEXT_COLOR:b(this,xe,i0).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[pt.FREETEXT_SIZE,Kt._defaultFontSize],[pt.FREETEXT_COLOR,Kt._defaultColor||Mt._defaultLineColor]]}get propertiesToUpdate(){return[[pt.FREETEXT_SIZE,n(this,Ws)],[pt.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new np(this)),[["colorPicker",this._colorPicker]]}get colorType(){return pt.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[-Kt._internalPadding*e,-(Kt._internalPadding+n(this,Ws))*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,sl,new AbortController);const e=this._uiManager.combinedSignal(n(this,sl));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,yu)),this._isDraggable=!0,(e=n(this,sl))==null||e.abort(),p(this,sl,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,js),s=p(this,js,b(this,xe,n0).call(this).trimEnd());if(e===s)return;const i=r=>{if(p(this,js,r),!r){this.remove();return}b(this,xe,Bf).call(this),this._uiManager.rebuild(this),b(this,xe,Rf).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(e)},mustExec:!1}),b(this,xe,Rf).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){Kt._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,yu)),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,Ws)}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,u]=this.pageDimensions,[f,g]=this.pageTranslation;let y,v;switch(this.rotation){case 0:y=e+(o[0]-f)/h,v=s+this.height-(o[1]-g)/u;break;case 90:y=e+(o[0]-f)/h,v=s-(o[1]-g)/u,[l,c]=[c,-l];break;case 180:y=e-this.width+(o[0]-f)/h,v=s-(o[1]-g)/u,[l,c]=[-l,-c];break;case 270:y=e+(o[0]-f-this.height*u)/h,v=s+(o[1]-g-this.width*h)/u,[l,c]=[-c,l];break}this.setAt(y*r,v*a,l,c)}else this._moveAfterPaste(e,s);b(this,xe,Bf).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var y,v,w;const s=e.clipboardData||window.clipboardData,{types:i}=s;if(i.length===1&&i[0]==="text/plain")return;e.preventDefault();const r=b(y=Kt,wr,xm).call(y,s.getData("text")||"").replaceAll(af,` `);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=[],u=[];if(l.nodeType===Node.TEXT_NODE){const S=l.parentElement;if(u.push(l.nodeValue.slice(c).replaceAll(af,"")),S!==this.editorDiv){let x=h;for(const A of this.editorDiv.childNodes){if(A===S){x=u;continue}x.push(b(v=Kt,wr,Nf).call(v,A))}}h.push(l.nodeValue.slice(0,c).replaceAll(af,""))}else if(l===this.editorDiv){let S=h,x=0;for(const A of this.editorDiv.childNodes)x++===c&&(S=u),S.push(b(w=Kt,wr,Nf).call(w,A))}p(this,js,`${h.join(` `)}${r}${u.join(` `)}`),b(this,xe,Bf).call(this);const f=new Range;let g=Math.sumPrecise(h.map(S=>S.length));for(const{firstChild:S}of this.editorDiv.childNodes)if(S.nodeType===Node.TEXT_NODE){const x=S.nodeValue.length;if(g<=x){f.setStart(S,g),f.setEnd(S,g);break}g-=x}a.removeAllRanges(),a.addRange(f)}get contentDiv(){return this.editorDiv}getPDFRect(){const e=Kt._internalPadding*this.parentScale;return this.getRect(e,e)}static async deserialize(e,s,i){var o;let r=null;if(e instanceof Ky){const{data:{defaultAppearanceData:{fontSize:l,fontColor:c},rect:h,rotation:u,id:f,popupRef:g,richText:y,contentsObj:v,creationDate:w,modificationDate:S},textContent:x,textPosition:A,parent:{page:{pageNumber:_}}}=e;if(!(x!=null&&x.length))return null;r=e={annotationType:ct.FREETEXT,color:Array.from(c),fontSize:l,value:x.join(` `),position:A,pageIndex:_-1,rect:h.slice(0),rotation:u,annotationElementId:f,id:f,deleted:!1,popupRef:g,comment:(v==null?void 0:v.str)||null,richText:y,creationDate:w,modificationDate:S}}const a=await super.deserialize(e,s,i);return p(a,Ws,e.fontSize),a.color=B.makeHexColor(...e.color),p(a,js,b(o=Kt,wr,xm).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=Mt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(e),{color:s,fontSize:n(this,Ws),value:b(this,xe,r0).call(this)});return this.addComment(i),e?(i.isCopy=!0,i):this.annotationElementId&&!b(this,xe,a0).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,Ws)}px * var(--total-scale-factor))`,i.color=this.color,s.replaceChildren();for(const r of n(this,js).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,js)}}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};js=new WeakMap,yu=new WeakMap,sl=new WeakMap,Ws=new WeakMap,xe=new WeakSet,s0=function(e){const s=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--total-scale-factor))`,this.translate(0,-(r-n(this,Ws))*this.parentScale),p(this,Ws,r),b(this,xe,Rf).call(this)},i=n(this,Ws);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:pt.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},i0=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:pt.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},n0=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(b(i=Kt,wr,Nf).call(i,r)),s=r);return e.join(` `)},Rf=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()},wr=new WeakSet,Nf=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(af,"")},Bf=function(){if(this.editorDiv.replaceChildren(),!!n(this,js))for(const e of n(this,js).split(` `)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},r0=function(){return n(this,js).replaceAll(" "," ")},xm=function(e){return e.replaceAll(" "," ")},a0=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(Kt,wr),M(Kt,"_freeTextDefaultContent",""),M(Kt,"_internalPadding",0),M(Kt,"_defaultColor",null),M(Kt,"_defaultFontSize",10),M(Kt,"_type","freetext"),M(Kt,"_editorType",ct.FREETEXT);let Sm=Kt;class q{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=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 b(this,_e,l0).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,r,a){return new f0(t,e,s,i,r,a)}getOutlines(){var u;const t=n(this,mn),e=n(this,zi),s=n(this,bt),[i,r,a,o]=n(this,Xs),l=new Float32Array((((u=n(this,ua))==null?void 0:u.length)??0)+2);for(let f=0,g=l.length-2;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 b(this,_e,d0).call(this,c,h),this.newFreeDrawOutline(c,l,n(this,Xs),n(this,Xc),n(this,jc),n(this,Wc))}};Xs=new WeakMap,zi=new WeakMap,jc=new WeakMap,Wc=new WeakMap,mn=new WeakMap,bt=new WeakMap,il=new WeakMap,nl=new WeakMap,wu=new WeakMap,Au=new WeakMap,Xc=new WeakMap,qc=new WeakMap,ua=new WeakMap,Su=new WeakMap,Pp=new WeakMap,Mp=new WeakMap,_e=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,Xs);return[(n(this,il)+(t[0]-e[0])/2-s)/r,(n(this,nl)+(t[1]-e[1])/2-i)/a,(n(this,il)+(e[0]-t[0])/2-s)/r,(n(this,nl)+(e[1]-t[1])/2-i)/a]},o0=function(){const[t,e,s,i]=n(this,Xs),[r,a,o,l]=b(this,_e,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`},l0=function(t){const e=n(this,zi);t.push(`L${e[4]} ${e[5]} Z`)},c0=function(t){const[e,s,i,r]=n(this,Xs),a=n(this,bt).subarray(4,6),o=n(this,bt).subarray(16,18),[l,c,h,u]=b(this,_e,Hh).call(this);t.push(`L${(a[0]-e)/i} ${(a[1]-s)/r} L${l} ${c} L${h} ${u} L${(o[0]-e)/i} ${(o[1]-s)/r}`)},h0=function(t){const e=n(this,bt),[s,i,r,a]=n(this,Xs),[o,l,c,h]=b(this,_e,Hh).call(this),u=new Float32Array(36);return u.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(u,t,n(this,Xs),n(this,Xc),n(this,jc),n(this,Wc))},d0=function(t,e){const s=n(this,zi);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},u0=function(t,e){const s=n(this,bt).subarray(4,6),i=n(this,bt).subarray(16,18),[r,a,o,l]=n(this,Xs),[c,h,u,f]=b(this,_e,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,u,f,NaN,NaN,NaN,NaN,(i[0]-r)/o,(i[1]-a)/l],e),e+=24},m(Dn,Su,8),m(Dn,Pp,2),m(Dn,Mp,n(Dn,Su)+n(Dn,Pp));let ap=Dn;var Yc,rl,lr,xu,qs,Eu,be,Ip,p0;class f0 extends q{constructor(e,s,i,r,a,o){super();m(this,Ip);m(this,Yc);m(this,rl,new Float32Array(4));m(this,lr);m(this,xu);m(this,qs);m(this,Eu);m(this,be);p(this,be,e),p(this,qs,s),p(this,Yc,i),p(this,Eu,r),p(this,lr,a),p(this,xu,o),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],b(this,Ip,p0).call(this,o);const[l,c,h,u]=n(this,rl);for(let f=0,g=e.length;fS?(o=w,l=S):l===S&&(o=u(o,w)),hf[1]?(o=f[0],l=f[1]):l===f[1]&&(o=u(o,f[0])),he[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of n(this,fa))e[3]?(t.push(...b(this,bs,Cm).call(this,e)),b(this,bs,m0).call(this,e)):(b(this,bs,v0).call(this,e),t.push(...b(this,bs,Cm).call(this,e)));return b(this,bs,g0).call(this,t)}}Cu=new WeakMap,_u=new WeakMap,ku=new WeakMap,fa=new WeakMap,Vi=new WeakMap,bs=new WeakSet,g0=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;a0;){const a=s.values().next().value;let[o,l,c,h,u]=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(u))y=u;else break;s.delete(y),[o,l,c,h,u]=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 iE(i,n(this,Cu),n(this,_u),n(this,ku))},$f=function(t){const e=n(this,Vi);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=0;i--){const[r,a]=n(this,Vi)[i];if(r!==t)break;if(r===t&&a===e){n(this,Vi).splice(i,1);return}}},Cm=function(t){const[e,s,i]=t,r=[[e,s,i]],a=b(this,bs,$f).call(this,i);for(let o=0;o=l){if(g>c)r[h][1]=c;else{if(u===1)return[];r.splice(h,1),h--,u--}continue}r[h][2]=l,g>c&&r.push([e,c,g])}}}return r};var Tu,Kc;class iE extends q{constructor(e,s,i,r){super();m(this,Tu);m(this,Kc);p(this,Kc,e),p(this,Tu,s),this.firstPoint=i,this.lastPoint=r}toSVGPath(){const e=[];for(const s of n(this,Kc)){let[i,r]=s;e.push(`M${i} ${r}`);for(let a=2;a-1?(p(this,Ge,!0),b(this,mt,Uf).call(this,e),b(this,mt,Ua).call(this)):n(this,cr)&&(p(this,Qc,e.anchorNode),p(this,Pu,e.anchorOffset),p(this,Iu,e.focusNode),p(this,Du,e.focusOffset),b(this,mt,km).call(this),b(this,mt,Ua).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert(Mt._l10nAlert.highlight)}static get _keyboardManager(){const e=kt.prototype;return ot(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,Ge)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:n(this,bi),methodOfCreation:n(this,Lu)}}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;Mt.initialize(e,s),kt._defaultColor||(kt._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case pt.HIGHLIGHT_COLOR:kt._defaultColor=s;break;case pt.HIGHLIGHT_THICKNESS:kt._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return n(this,Zc)}get commentButtonPosition(){return n(this,Jc)}updateParams(e,s){switch(e){case pt.HIGHLIGHT_COLOR:b(this,mt,b0).call(this,s);break;case pt.HIGHLIGHT_THICKNESS:b(this,mt,y0).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[pt.HIGHLIGHT_COLOR,kt._defaultColor],[pt.HIGHLIGHT_THICKNESS,kt._defaultThickness]]}get propertiesToUpdate(){return[[pt.HIGHLIGHT_COLOR,this.color||kt._defaultColor],[pt.HIGHLIGHT_THICKNESS,n(this,bi)||kt._defaultThickness],[pt.HIGHLIGHT_FREE,n(this,Ge)]]}onUpdatedColor(){var e,s;(e=this.parent)==null||e.drawLayer.updateProperties(n(this,Ks),{root:{fill:this.color,"fill-opacity":this.opacity}}),(s=n(this,Mu))==null||s.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",p(this,Mu,new ip({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(b(this,mt,zf).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,b(this,mt,zf).call(this))}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){b(this,mt,Tm).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,mt,Ua).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?b(this,mt,Tm).call(this):e&&(b(this,mt,Ua).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,Ge)?(e=(e-this.rotation+360)%360,i=b(r=kt,Ai,Ol).call(r,n(this,Ys).box,e)):i=b(a=kt,Ai,Ol).call(a,[this.x,this.y,this.width,this.height],e),s.updateProperties(n(this,Ks),{bbox:i,root:{"data-main-rotation":e}}),s.updateProperties(n(this,is),{bbox:b(o=kt,Ai,Ol).call(o,n(this,_s).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();n(this,th)&&(e.setAttribute("aria-label",n(this,th)),e.setAttribute("role","mark")),n(this,Ge)?e.classList.add("free"):this.div.addEventListener("keydown",b(this,mt,A0).bind(this),{signal:this._uiManager._signal});const s=p(this,ol,document.createElement("div"));return e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=n(this,al),this.setDims(),kb(this,n(this,ol),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(n(this,is),{rootClass:{hovered:!0}})}pointerleave(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(n(this,is),{rootClass:{hovered:!1}})}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:b(this,mt,Hf).call(this,!0);break;case 1:case 3:b(this,mt,Hf).call(this,!1);break}}select(){var e;super.select(),n(this,is)&&((e=this.parent)==null||e.drawLayer.updateProperties(n(this,is),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var e;super.unselect(),n(this,is)&&((e=this.parent)==null||e.drawLayer.updateProperties(n(this,is),{rootClass:{selected:!1}}),n(this,Ge)||b(this,mt,Hf).call(this,!1))}get _mustFixPosition(){return!n(this,Ge)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(n(this,Ks),{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(n(this,is),{rootClass:{hidden:!e}}))}static startHighlighting(e,s,{target:i,x:r,y:a}){const{x:o,y:l,width:c,height:h}=i.getBoundingClientRect(),u=new AbortController,f=e.combinedSignal(u),g=y=>{u.abort(),b(this,Ai,C0).call(this,e,y)};window.addEventListener("blur",g,{signal:f}),window.addEventListener("pointerup",g,{signal:f}),window.addEventListener("pointerdown",re,{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",Ei,{signal:f}),i.addEventListener("pointermove",b(this,Ai,E0).bind(this,e),{signal:f}),this._freeHighlight=new _m({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 w,S,x,A;let r=null;if(e instanceof Jy){const{data:{quadPoints:_,rect:E,rotation:k,id:P,color:L,opacity:I,popupRef:D,richText:R,contentsObj:W,creationDate:Q,modificationDate:Y},parent:{page:{pageNumber:yt}}}=e;r=e={annotationType:ct.HIGHLIGHT,color:Array.from(L),opacity:I,quadPoints:_,boxes:null,pageIndex:yt-1,rect:E.slice(0),rotation:k,annotationElementId:P,id:P,deleted:!1,popupRef:D,richText:R,comment:(W==null?void 0:W.str)||null,creationDate:Q,modificationDate:Y}}else if(e instanceof ov){const{data:{inkLists:_,rect:E,rotation:k,id:P,color:L,borderStyle:{rawWidth:I},popupRef:D,richText:R,contentsObj:W,creationDate:Q,modificationDate:Y},parent:{page:{pageNumber:yt}}}=e;r=e={annotationType:ct.HIGHLIGHT,color:Array.from(L),thickness:I,inkLists:_,boxes:null,pageIndex:yt-1,rect:E.slice(0),rotation:k,annotationElementId:P,id:P,deleted:!1,popupRef:D,richText:R,comment:(W==null?void 0:W.str)||null,creationDate:Q,modificationDate:Y}}const{color:a,quadPoints:o,inkLists:l,outlines:c,opacity:h}=e,u=await super.deserialize(e,s,i);u.color=B.makeHexColor(...a),u.opacity=h||1,l&&p(u,bi,e.thickness),u._initialData=r,e.comment&&u.setCommentData(e);const[f,g]=u.pageDimensions,[y,v]=u.pageTranslation;if(o){const _=p(u,cr,[]);for(let E=0;E=0)p(this,Ks,s),p(this,al,i),this.parent.drawLayer.finalizeDraw(s,{bbox:e.box,path:{d:e.toSVGPath()}}),p(this,is,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:n(this,_s).box,path:{d:n(this,_s).toSVGPath()}},!0));else if(this.parent){const y=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(n(this,Ks),{bbox:b(f=kt,Ai,Ol).call(f,n(this,Ys).box,(y-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(n(this,is),{bbox:b(g=kt,Ai,Ol).call(g,n(this,_s).box,y),path:{d:n(this,_s).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,v]=this.parentDimensions;this.x=o,this.y=1-a,this.width=l*v/y,this.height=c*y/v;break}case 180:this.x=1-a,this.y=1-o,this.width=l,this.height=c;break;case 270:{const[y,v]=this.parentDimensions;this.x=1-o,this.y=a,this.width=l*v/y,this.height=c*y/v;break}}const{firstPoint:h}=e;p(this,Jc,[(h[0]-a)/l,(h[1]-o)/c]);const{lastPoint:u}=n(this,_s);p(this,Zc,[(u[0]-a)/l,(u[1]-o)/c])},b0=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,kt._defaultOpacity),undo:s.bind(this,i,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:pt.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0)},y0=function(e){const s=n(this,bi),i=r=>{p(this,bi,r),b(this,mt,w0).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:pt.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},w0=function(e){n(this,Ge)&&(b(this,mt,Uf).call(this,{highlightOutlines:n(this,Ys).getNewOutline(e/2)}),this.fixAndSetPosition(),this.setDims())},Tm=function(){n(this,Ks)===null||!this.parent||(this.parent.drawLayer.remove(n(this,Ks)),p(this,Ks,null),this.parent.drawLayer.remove(n(this,is)),p(this,is,null))},Ua=function(e=this.parent){n(this,Ks)===null&&({id:Yt(this,Ks)._,clipPathId:Yt(this,al)._}=e.drawLayer.draw({bbox:n(this,Ys).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:n(this,Ge)},path:{d:n(this,Ys).toSVGPath()}},!1,!0),p(this,is,e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:n(this,Ge)},bbox:n(this,_s).box,path:{d:n(this,_s).toSVGPath()}},n(this,Ge))),n(this,ol)&&(n(this,ol).style.clipPath=n(this,al)))},Ai=new WeakSet,Ol=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]},A0=function(e){kt._keyboardManager.exec(this,e)},Hf=function(e){if(!n(this,Qc))return;const s=window.getSelection();e?s.setPosition(n(this,Qc),n(this,Pu)):s.setPosition(n(this,Iu),n(this,Du))},zf=function(){return n(this,Ge)?this.rotation:0},S0=function(){if(n(this,Ge))return null;const[e,s]=this.pageDimensions,[i,r]=this.pageTranslation,a=n(this,cr),o=new Float32Array(a.length*8);let l=0;for(const{x:c,y:h,width:u,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+u*e,o[l+5]=o[l+7]=y-f*s,l+=8}return o},x0=function(e){return n(this,Ys).serialize(e,b(this,mt,zf).call(this))},E0=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},C0=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=""},_0=function(e){const{color:s}=this._initialData;return this.hasEditedComment||e.color.some((i,r)=>i!==s[r])},m(kt,Ai),M(kt,"_defaultColor",null),M(kt,"_defaultOpacity",1),M(kt,"_defaultThickness",12),M(kt,"_type","highlight"),M(kt,"_editorType",ct.HIGHLIGHT),M(kt,"_freeHighlightId",-1),M(kt,"_freeHighlight",null),M(kt,"_freeHighlightClipId","");let op=kt;var ll;class k0{constructor(){m(this,ll,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,ll)[t]=e}toSVGProperties(){const t=n(this,ll);return p(this,ll,Object.create(null)),{root:t}}reset(){p(this,ll,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){Ct("Not implemented")}}ll=new WeakMap;var ds,eh,Le,cl,hl,xt,Pm,Mm,Im,zh,T0,Vf,Vh,Rl;const wt=class wt extends Mt{constructor(e){super(e);m(this,xt);m(this,ds,null);m(this,eh);M(this,"_colorPicker",null);M(this,"_drawId",null);p(this,eh,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&&(b(this,xt,Pm).call(this,e),b(this,xt,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,ds).updateProperty(s,l);c&&b(this,xt,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,u)=>{var f;a.updateProperty(i,h),a.updateProperty(r,u),n(this,ds).updateProperty(i,h),n(this,ds).updateProperty(r,u),(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:pt.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,wt._mergeSVGProperties(n(this,ds).getPathResizingSVGProperties(b(this,xt,Vf).call(this)),{bbox:b(this,xt,Rl).call(this)}))}_onResized(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,wt._mergeSVGProperties(n(this,ds).getPathResizedSVGProperties(b(this,xt,Vf).call(this)),{bbox:b(this,xt,Rl).call(this)}))}_onTranslating(e,s){var i;(i=this.parent)==null||i.drawLayer.updateProperties(this._drawId,{bbox:b(this,xt,Rl).call(this)})}_onTranslated(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,wt._mergeSVGProperties(n(this,ds).getPathTranslatedSVGProperties(b(this,xt,Vf).call(this),this.parentDimensions),{bbox:b(this,xt,Rl).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,eh)&&(p(this,eh,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){b(this,xt,Im).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,xt,zh).call(this),b(this,xt,Vh).call(this,n(this,ds).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),b(this,xt,Im).call(this)):e&&(this._uiManager.addShouldRescale(this),b(this,xt,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:b(this,xt,Rl).call(this)},n(this,ds).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&b(this,xt,Vh).call(this,n(this,ds).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 w;const{target:a,offsetX:o,offsetY:l,pointerId:c,pointerType:h}=r;if(Ze.isInitializedAndDifferentPointerType(h))return;const{viewport:{rotation:u}}=e,{width:f,height:g}=a.getBoundingClientRect(),y=p(wt,cl,new AbortController),v=e.combinedSignal(y);if(Ze.setPointer(h,c),window.addEventListener("pointerup",S=>{Ze.isSamePointerIdOrRemove(S.pointerId)&&this._endDraw(S)},{signal:v}),window.addEventListener("pointercancel",S=>{Ze.isSamePointerIdOrRemove(S.pointerId)&&this._currentParent.endDrawingSession()},{signal:v}),window.addEventListener("pointerdown",S=>{Ze.isSamePointerType(S.pointerType)&&(Ze.initializeAndAddPointerId(S.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:v}),window.addEventListener("contextmenu",Ei,{signal:v}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:v}),a.addEventListener("touchmove",S=>{Ze.isSameTimeStamp(S.timeStamp)&&re(S)},{signal:v}),e.toggleDrawing(),(w=s._editorUndoBar)==null||w.hide(),n(wt,Le)){e.drawLayer.updateProperties(this._currentDrawId,n(wt,Le).startNew(o,l,f,g,u));return}s.updateUIForDefaultProperties(this),p(wt,Le,this.createDrawerInstance(o,l,f,g,u)),p(wt,hl,this.getDefaultDrawingOptions()),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(n(wt,hl).toSVGProperties(),n(wt,Le).defaultSVGProperties),!0,!1)}static _drawMove(e){if(Ze.isSameTimeStamp(e.timeStamp),!n(wt,Le))return;const{offsetX:s,offsetY:i,pointerId:r}=e;if(Ze.isSamePointerId(r)){if(Ze.isUsingMultiplePointers()){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,n(wt,Le).add(s,i)),Ze.setTimeStamp(e.timeStamp),re(e)}}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,p(wt,Le,null),p(wt,hl,null),Ze.clearTimeStamp()),n(wt,cl)&&(n(wt,cl).abort(),p(wt,cl,null),Ze.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:pt.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(pt.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,hl),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 u,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),b(u=h,xt,Pm).call(u,{drawOutlines:c}),b(f=h,xt,zh).call(f),h.onScaleChanging(),h.rotate(),h}serializeDraw(e){const[s,i]=this.pageTranslation,[r,a]=this.pageDimensions;return n(this,ds).serialize([s,i,r,a],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};ds=new WeakMap,eh=new WeakMap,Le=new WeakMap,cl=new WeakMap,hl=new WeakMap,xt=new WeakSet,Pm=function({drawOutlines:e,drawId:s,drawingOptions:i}){p(this,ds,e),this._drawingOptions||(this._drawingOptions=i),this.annotationElementId||this._uiManager.a11yAlert(Mt._l10nAlert[this.editorType]),s>=0?(this._drawId=s,this.parent.drawLayer.finalizeDraw(s,e.defaultProperties)):this._drawId=b(this,xt,Mm).call(this,e,this.parent),b(this,xt,Vh).call(this,e.box)},Mm=function(e,s){const{id:i}=s.drawLayer.draw(wt._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return i},Im=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=b(this,xt,Mm).call(this,n(this,ds),e)}},T0=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]}},Vf=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]=b(this,xt,T0).call(this,e),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},Rl=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,cl,null),m(wt,hl,null),M(wt,"_INNER_MARGIN",3);let lp=wt;var vn,Fe,je,dl,sh,us,We,yi,ul,fl,pl,ih,Gf;class rE{constructor(t,e,s,i,r,a){m(this,ih);m(this,vn,new Float64Array(6));m(this,Fe);m(this,je);m(this,dl);m(this,sh);m(this,us);m(this,We,"");m(this,yi,0);m(this,ul,new Yu);m(this,fl);m(this,pl);p(this,fl,s),p(this,pl,i),p(this,dl,r),p(this,sh,a),[t,e]=b(this,ih,Gf).call(this,t,e);const o=p(this,Fe,[NaN,NaN,NaN,NaN,t,e]);p(this,us,[t,e]),p(this,je,[{line:o,points:n(this,us)}]),n(this,vn).set(o,0)}updateProperty(t,e){t==="stroke-width"&&p(this,sh,e)}isEmpty(){var t;return!((t=n(this,je))!=null&&t.length)}isCancellable(){return n(this,us).length<=10}add(t,e){[t,e]=b(this,ih,Gf).call(this,t,e);const[s,i,r,a]=n(this,vn).subarray(2,6),o=t-r,l=e-a;return Math.hypot(n(this,fl)*o,n(this,pl)*l)<=2?null:(n(this,us).push(t,e),isNaN(s)?(n(this,vn).set([r,a,t,e],2),n(this,Fe).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(n(this,vn)[0])&&n(this,Fe).splice(6,6),n(this,vn).set([s,i,r,a,t,e],0),n(this,Fe).push(...q.createBezierPoints(s,i,r,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const s=this.add(t,e);return s||(n(this,us).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,i,r){p(this,fl,s),p(this,pl,i),p(this,dl,r),[t,e]=b(this,ih,Gf).call(this,t,e);const a=p(this,Fe,[NaN,NaN,NaN,NaN,t,e]);p(this,us,[t,e]);const o=n(this,je).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),n(this,je).push({line:a,points:n(this,us)}),n(this,vn).set(a,0),p(this,yi,0),this.toSVGPath(),null}getLastElement(){return n(this,je).at(-1)}setLastElement(t){return n(this,je)?(n(this,je).push(t),p(this,Fe,t.line),p(this,us,t.points),p(this,yi,0),{path:{d:this.toSVGPath()}}):n(this,ul).setLastElement(t)}removeLastElement(){if(!n(this,je))return n(this,ul).removeLastElement();n(this,je).pop(),p(this,We,"");for(let t=0,e=n(this,je).length;t_??NaN),f,g,y,v),points:w(l[x].map(_=>_??NaN),f,g,y,v)});const S=new this.prototype.constructor;return S.build(u,i,r,1,c,h,a),S}get box(){return n(this,fs)}updateProperty(e,s){return e==="stroke-width"?b(this,qe,I0).call(this,s):null}updateParentDimensions([e,s],i){const[r,a]=b(this,qe,Mn).call(this);p(this,bn,e),p(this,yn,s),p(this,nh,i);const[o,l]=b(this,qe,Mn).call(this),c=o-r,h=l-a,u=n(this,fs);return u[0]-=c,u[1]-=h,u[2]+=2*c,u[3]+=2*h,u}updateRotation(e){return p(this,Fu,e),{path:{transform:this.rotationTransform}}}get viewBox(){return n(this,fs).map(q.svgRound).join(" ")}get defaultProperties(){const[e,s]=n(this,fs);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${q.svgRound(e)} ${q.svgRound(s)}`}}}get rotationTransform(){const[,,e,s]=n(this,fs);let i=0,r=0,a=0,o=0,l=0,c=0;switch(n(this,Fu)){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} ${q.svgRound(l)} ${q.svgRound(c)})`}getPathResizingSVGProperties([e,s,i,r]){const[a,o]=b(this,qe,Mn).call(this),[l,c,h,u]=n(this,fs);if(Math.abs(h-a)<=q.PRECISION||Math.abs(u-o)<=q.PRECISION){const w=e+i/2-(l+h/2),S=s+r/2-(c+u/2);return{path:{"transform-origin":`${q.svgRound(e)} ${q.svgRound(s)}`,transform:`${this.rotationTransform} translate(${w} ${S})`}}}const f=(i-2*a)/(h-2*a),g=(r-2*o)/(u-2*o),y=h/i,v=u/r;return{path:{"transform-origin":`${q.svgRound(l)} ${q.svgRound(c)}`,transform:`${this.rotationTransform} scale(${y} ${v}) translate(${q.svgRound(a)} ${q.svgRound(o)}) scale(${f} ${g}) translate(${q.svgRound(-a)} ${q.svgRound(-o)})`}}}getPathResizedSVGProperties([e,s,i,r]){const[a,o]=b(this,qe,Mn).call(this),l=n(this,fs),[c,h,u,f]=l;if(l[0]=e,l[1]=s,l[2]=i,l[3]=r,Math.abs(u-a)<=q.PRECISION||Math.abs(f-o)<=q.PRECISION){const S=e+i/2-(c+u/2),x=s+r/2-(h+f/2);for(const{line:A,points:_}of n(this,Qs))q._translate(A,S,x,A),q._translate(_,S,x,_);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${q.svgRound(e)} ${q.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const g=(i-2*a)/(u-2*a),y=(r-2*o)/(f-2*o),v=-g*(c+a)+e+a,w=-y*(h+o)+s+o;if(g!==1||y!==1||v!==0||w!==0)for(const{line:S,points:x}of n(this,Qs))q._rescale(S,v,w,g,y,S),q._rescale(x,v,w,g,y,x);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${q.svgRound(e)} ${q.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,s],i){const[r,a]=i,o=n(this,fs),l=e-o[0],c=s-o[1];if(n(this,bn)===r&&n(this,yn)===a)for(const{line:h,points:u}of n(this,Qs))q._translate(h,l,c,h),q._translate(u,l,c,u);else{const h=n(this,bn)/r,u=n(this,yn)/a;p(this,bn,r),p(this,yn,a);for(const{line:f,points:g}of n(this,Qs))q._rescale(f,l,c,h,u,f),q._rescale(g,l,c,h,u,g);o[2]*=h,o[3]*=u}return o[0]=e,o[1]=s,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${q.svgRound(e)} ${q.svgRound(s)}`}}}get defaultSVGProperties(){const e=n(this,fs);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${q.svgRound(e[0])} ${q.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}fs=new WeakMap,Fu=new WeakMap,Ou=new WeakMap,Qs=new WeakMap,bn=new WeakMap,yn=new WeakMap,nh=new WeakMap,rh=new WeakMap,gl=new WeakMap,qe=new WeakSet,Mn=function(e=n(this,gl)){const s=n(this,Ou)+e/2*n(this,nh);return n(this,rh)%180===0?[s/n(this,bn),s/n(this,yn)]:[s/n(this,yn),s/n(this,bn)]},P0=function(){const[e,s,i,r]=n(this,fs),[a,o]=b(this,qe,Mn).call(this,0);return[e+a,s+o,i-2*a,r-2*o]},M0=function(){const e=p(this,fs,Ga.slice());for(const{line:r}of n(this,Qs)){if(r.length<=12){for(let l=4,c=r.length;lo!==s[l])||e.thickness!==i||e.opacity!==r||e.pageIndex!==a},M($l,"_type","ink"),M($l,"_editorType",ct.INK),M($l,"_defaultDrawingOptions",null);let Dm=$l;class Lm extends Yu{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const of=8,Sh=3;var ml,It,Fm,Gi,L0,F0,Om,jf,O0,R0,N0,Rm,Nm,B0;class mr{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 u=200,f=h.font=`${s} ${i} ${u}px ${e}`,{actualBoundingBoxLeft:g,actualBoundingBoxRight:y,actualBoundingBoxAscent:v,actualBoundingBoxDescent:w,fontBoundingBoxAscent:S,fontBoundingBoxDescent:x,width:A}=h.measureText(t),_=1.5,E=Math.ceil(Math.max(Math.abs(g)+Math.abs(y)||0,A)*_),k=Math.ceil(Math.max(Math.abs(v)+Math.abs(w)||u,Math.abs(S)+Math.abs(x)||u)*_);c=new OffscreenCanvas(E,k),h=c.getContext("2d",{alpha:!0,willReadFrequently:!0}),h.font=f,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,E,k),h.fillStyle="black",h.fillText(t,E*(_-1)/2,k*(3-_)/2);const P=b(this,It,Rm).call(this,h.getImageData(0,0,E,k).data),L=b(this,It,N0).call(this,P),I=b(this,It,Nm).call(this,L),D=b(this,It,Om).call(this,P,E,k,I);return this.processDrawnLines({lines:{curves:D,width:E,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]=b(this,It,B0).call(this,t),[c,h]=b(this,It,R0).call(this,a,o,l,Math.hypot(o,l)*n(this,ml).sigmaSFactor,n(this,ml).sigmaR,n(this,ml).kernelSize),u=b(this,It,Nm).call(this,h),f=b(this,It,Om).call(this,c,o,l,u);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,u=t.thickness??0,f=[],g=Math.min(e/c,s/h),y=g/e,v=g/s,w=[];for(const{points:x}of l){const A=a?b(this,It,O0).call(this,x):x;if(!A)continue;w.push(A);const _=A.length,E=new Float32Array(_),k=new Float32Array(3*(_===2?2:_-2));if(f.push({line:k,points:E}),_===2){E[0]=A[0]*y,E[1]=A[1]*v,k.set([NaN,NaN,NaN,NaN,E[0],E[1]],0);continue}let[P,L,I,D]=A;P*=y,L*=v,I*=y,D*=v,E.set([P,L,I,D],0),k.set([NaN,NaN,NaN,NaN,P,L],0);for(let R=4;R<_;R+=2){const W=E[R]=A[R]*y,Q=E[R+1]=A[R+1]*v;k.set(q.createBezierPoints(P,L,I,D,W,Q),(R-2)*3),[P,L,I,D]=[I,D,W,Q]}}if(f.length===0)return null;const S=o?new Lm:new Yu;return S.build(f,e,s,1,i,o?0:u,r),{outline:S,newCurves:w,areContours:o,thickness:u,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,_=x.length;A<_;A++){const E=x[A]-x[A-2];a=Math.min(a,E),o=Math.max(o,E)}}let c;a>=-128&&o<=127?c=Int8Array:a>=-32768&&o<=32767?c=Int16Array:c=Int32Array;const h=t.length,u=of+Sh*h,f=new Uint32Array(u);let g=0;f[g++]=u*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"),v=y.writable.getWriter();await v.ready,v.write(f);const w=c.prototype.constructor;for(const x of t){const A=new w(x.length-2);for(let _=2,E=x.length;_{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],u=l[3],f=l[4]===0,g=l[5],y=l[6],v=l[7],w=[],S=(of+Sh*y)*Uint32Array.BYTES_PER_ELEMENT;let x;switch(v){case Int8Array.BYTES_PER_ELEMENT:x=new Int8Array(a.buffer,S);break;case Int16Array.BYTES_PER_ELEMENT:x=new Int16Array(a.buffer,S);break;case Int32Array.BYTES_PER_ELEMENT:x=new Int32Array(a.buffer,S);break}o=0;for(let A=0;A0?0:4:s===1?i+6:2-i},Gi=new WeakMap,L0=function(t,e,s,i,r,a,o){const l=b(this,It,Fm).call(this,s,i,r,a);for(let c=0;c<8;c++){const h=(-c+l-o+16)%8,u=n(this,Gi)[2*h],f=n(this,Gi)[2*h+1];if(t[(s+u)*e+(i+f)]!==0)return h}return-1},F0=function(t,e,s,i,r,a,o){const l=b(this,It,Fm).call(this,s,i,r,a);for(let c=0;c<8;c++){const h=(c+l+o+16)%8,u=n(this,Gi)[2*h],f=n(this,Gi)[2*h+1];if(t[(s+u)*e+(i+f)]!==0)return h}return-1},Om=function(t,e,s,i){const r=t.length,a=new Int32Array(r);for(let h=0;h=1&&a[f+1]===0)o+=1,v+=1,g>1&&(l=g);else{g!==1&&(l=Math.abs(g));continue}const w=[u,h],S=v===u+1,x={isHole:S,points:w,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=S?A.parent:l:x.parent=S?l:A.parent:x.parent=S?l:0;const _=b(this,It,L0).call(this,a,e,h,u,y,v,0);if(_===-1){a[f]=-o,a[f]!==1&&(l=Math.abs(a[f]));continue}let E=n(this,Gi)[2*_],k=n(this,Gi)[2*_+1];const P=h+E,L=u+k;y=P,v=L;let I=h,D=u;for(;;){const R=b(this,It,F0).call(this,a,e,I,D,y,v,1);E=n(this,Gi)[2*R],k=n(this,Gi)[2*R+1];const W=I+E,Q=D+k;w.push(Q,W);const Y=I*e+D;if(a[Y+1]===0?a[Y]=-o:a[Y]===1&&(a[Y]=o),W===h&&Q===u&&I===P&&D===L){a[f]!==1&&(l=Math.abs(a[f]));break}else y=I,v=D,I=W,D=Q}}}return c},jf=function(t,e,s,i){if(s-e<=4){for(let P=e;PE&&(k=P,E=L)}E>(c*_)**2?(b(this,It,jf).call(this,t,e,k+2,i),b(this,It,jf).call(this,t,k,s,i)):i.push(r,a)},O0=function(t){const e=[],s=t.length;return b(this,It,jf).call(this,t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e},R0=function(t,e,s,i,r,a){const o=new Float32Array(a**2),l=-2*i**2,c=a>>1;for(let v=0;v=s))for(let L=0;L=e)continue;const D=t[P*e+I],R=o[k*a+L]*h[Math.abs(D-x)];A+=D*R,_+=R}}const E=g[S]=Math.round(A/_);y[E]++}return[g,y]},N0=function(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e},Rm=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;ol!==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},B0=function(t){const e=t,{width:s,height:i}=t,{maxDim:r}=n(this,ml);let a=s,o=i;if(s>r||i>r){let f=s,g=i,y=Math.log2(Math.max(s,i)/r);const v=Math.floor(y);y=y===v?v-1:v;for(let S=0;S{s==null||s.updateEditSignatureButton(e)}))}getSignaturePreview(){const{newCurves:e,areContours:s,thickness:i,width:r,height:a}=n(this,ga),o=Math.max(r,a),l=mr.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,ga,e);p(this,pa,l instanceof Lm),this.description=i;let c;n(this,pa)?c=Fs.getDefaultDrawingOptions():(c=Fs._defaultDrawnSignatureOptions.clone(),c.updateProperties({"stroke-width":l.thickness})),this._addOutlines({drawOutlines:l,drawingOptions:c});const[,h]=this.pageDimensions;let u=s/h;u=u>=1?.5:u,this.width*=u/this.height,this.width>=1&&(u*=.9/this.width,this.width=.9),this.height=u,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 mr.process(e,s,i,r,Fs._INNER_MARGIN)}getFromText(e,s){const{rawDims:{pageWidth:i,pageHeight:r},rotation:a}=this.parent.viewport;return mr.extractContoursFromText(e,s,i,r,a,Fs._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return mr.processDrawnLines({lines:e,pageWidth:s,pageHeight:i,rotation:r,innerMargin:Fs._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:s}){e?this._drawingOptions=Fs.getDefaultDrawingOptions():(this._drawingOptions=Fs._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,pa),color:[0,0,0],thickness:n(this,pa)?0:r});return this.addComment(a),e?(a.paths={lines:s,points:i},a.uuid=n(this,vl),a.isCopy=!0):a.lines=s,n(this,wn)&&(a.accessibilityData={type:"Figure",alt:n(this,wn)}),a}static deserializeDraw(e,s,i,r,a,o){return o.areContours?Lm.deserialize(e,s,i,r,a,o):Yu.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,pa,e.areContours),r.description=((a=e.accessibilityData)==null?void 0:a.alt)||"",p(r,vl,e.uuid),r}};pa=new WeakMap,wn=new WeakMap,ga=new WeakMap,vl=new WeakMap,M(Fs,"_type","signature"),M(Fs,"_editorType",ct.SIGNATURE),M(Fs,"_defaultDrawingOptions",null);let Bm=Fs;var ee,Oe,ma,hr,va,ah,dr,bl,An,Js,oh,Et,Gh,jh,Wf,Xf,qf,Um,Yf,$0;class $m extends Mt{constructor(e){super({...e,name:"stampEditor"});m(this,Et);m(this,ee,null);m(this,Oe,null);m(this,ma,null);m(this,hr,null);m(this,va,null);m(this,ah,"");m(this,dr,null);m(this,bl,!1);m(this,An,null);m(this,Js,!1);m(this,oh,!1);p(this,hr,e.bitmapUrl),p(this,va,e.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,s){Mt.initialize(e,s)}static isHandlingMimeForPasting(e){return Ag.includes(e)}static paste(e,s){s.pasteEditor({mode:ct.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,ee,null),this._uiManager.imageManager.deleteId(n(this,Oe)),(e=n(this,dr))==null||e.remove(),p(this,dr,null),n(this,An)&&(clearTimeout(n(this,An)),p(this,An,null))),super.remove()}rebuild(){if(!this.parent){n(this,Oe)&&b(this,Et,Wf).call(this);return}super.rebuild(),this.div!==null&&(n(this,Oe)&&n(this,dr)===null&&b(this,Et,Wf).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(n(this,ma)||n(this,ee)||n(this,hr)||n(this,va)||n(this,Oe)||n(this,bl))}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,bl)||(n(this,ee)?b(this,Et,Xf).call(this):b(this,Et,Wf).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,ee,r),p(this,bl,!1),b(this,Et,Xf).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;n(this,An)!==null&&clearTimeout(n(this,An)),p(this,An,setTimeout(()=>{p(this,An,null),b(this,Et,Um).call(this)},200))}copyCanvas(e,s,i=!1){e||(e=224);const{width:r,height:a}=n(this,ee),o=new _n;let l=n(this,ee),c=r,h=a,u=null;if(s){if(r>s||a>s){const P=Math.min(s/r,s/a);c=Math.floor(r*P),h=Math.floor(a*P)}u=document.createElement("canvas");const g=u.width=Math.ceil(c*o.sx),y=u.height=Math.ceil(h*o.sy);n(this,Js)||(l=b(this,Et,qf).call(this,g,y));const v=u.getContext("2d");v.filter=this._uiManager.hcmFilter;let w="white",S="#cfcfd8";this._uiManager.hcmFilter!=="none"?S="black":m1.isDarkMode&&(w="#8f8f9d",S="#42414d");const x=15,A=x*o.sx,_=x*o.sy,E=new OffscreenCanvas(A*2,_*2),k=E.getContext("2d");k.fillStyle=w,k.fillRect(0,0,A*2,_*2),k.fillStyle=S,k.fillRect(0,0,A,_),k.fillRect(A,_,A,_),v.fillStyle=v.createPattern(E,"repeat"),v.fillRect(0,0,g,y),v.drawImage(l,0,0,l.width,l.height,0,0,g,y)}let f=null;if(i){let g,y;if(o.symmetric&&l.widthe||a>e){const S=Math.min(e/r,e/a);g=Math.floor(r*S),y=Math.floor(a*S),n(this,Js)||(l=b(this,Et,qf).call(this,g,y))}const w=new OffscreenCanvas(g,y).getContext("2d",{willReadFrequently:!0});w.drawImage(l,0,0,l.width,l.height,0,0,g,y),f={width:g,height:y,data:w.getImageData(0,0,g,y).data}}return{canvas:u,width:c,height:h,imageData:f}}static async deserialize(e,s,i){var w;let r=null,a=!1;if(e instanceof Zy){const{data:{rect:S,rotation:x,id:A,structParent:_,popupRef:E,richText:k,contentsObj:P,creationDate:L,modificationDate:I},container:D,parent:{page:{pageNumber:R}},canvas:W}=e;let Q,Y;W?(delete e.canvas,{id:Q,bitmap:Y}=i.imageManager.getFromCanvas(D.id,W),W.remove()):(a=!0,e._hasNoCanvas=!0);const yt=((w=await s._structTree.getAriaAttributes(`${Nl}${A}`))==null?void 0:w.get("aria-label"))||"";r=e={annotationType:ct.STAMP,bitmapId:Q,bitmap:Y,pageIndex:R-1,rect:S.slice(0),rotation:x,annotationElementId:A,id:A,deleted:!1,accessibilityData:{decorative:!1,altText:yt},isSvg:!1,structParent:_,popupRef:E,richText:k,comment:(P==null?void 0:P.str)||null,creationDate:L,modificationDate:I}}const o=await super.deserialize(e,s,i),{rect:l,bitmap:c,bitmapUrl:h,bitmapId:u,isSvg:f,accessibilityData:g}=e;a?(i.addMissingCanvas(e.id,o),p(o,bl,!0)):u&&i.imageManager.isValidId(u)?(p(o,Oe,u),c&&p(o,ee,c)):p(o,hr,h),p(o,Js,f);const[y,v]=o.pageDimensions;return o.width=(l[2]-l[0])/y,o.height=(l[3]-l[1])/v,g&&(o.altTextData=g),o._initialData=r,e.comment&&o.setCommentData(e),p(o,oh,!!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,Js)});if(this.addComment(i),e)return i.bitmapUrl=b(this,Et,Yf).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=b(this,Et,$0).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,Js)?(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=b(this,Et,Yf).call(this,!1);else if(n(this,Js)){const l=s.stamps.get(n(this,Oe));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=b(this,Et,Yf).call(this,!1))}return i}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}ee=new WeakMap,Oe=new WeakMap,ma=new WeakMap,hr=new WeakMap,va=new WeakMap,ah=new WeakMap,dr=new WeakMap,bl=new WeakMap,An=new WeakMap,Js=new WeakMap,oh=new WeakMap,Et=new WeakSet,Gh=function(e,s=!1){if(!e){this.remove();return}p(this,ee,e.bitmap),s||(p(this,Oe,e.id),p(this,Js,e.isSvg)),e.file&&p(this,ah,e.file.name),b(this,Et,Xf).call(this)},jh=function(){if(p(this,ma,null),this._uiManager.enableWaiting(!1),!!n(this,dr)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,ee)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,ee)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},Wf=function(){if(n(this,Oe)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(n(this,Oe)).then(i=>b(this,Et,Gh).call(this,i,!0)).finally(()=>b(this,Et,jh).call(this));return}if(n(this,hr)){const i=n(this,hr);p(this,hr,null),this._uiManager.enableWaiting(!0),p(this,ma,this._uiManager.imageManager.getFromUrl(i).then(r=>b(this,Et,Gh).call(this,r)).finally(()=>b(this,Et,jh).call(this)));return}if(n(this,va)){const i=n(this,va);p(this,va,null),this._uiManager.enableWaiting(!0),p(this,ma,this._uiManager.imageManager.getFromFile(i).then(r=>b(this,Et,Gh).call(this,r)).finally(()=>b(this,Et,jh).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=Ag.join(",");const s=this._uiManager._signal;p(this,ma,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}}),b(this,Et,Gh).call(this,r)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>b(this,Et,jh).call(this))),e.click()},Xf=function(){var c;const{div:e}=this;let{width:s,height:i}=n(this,ee);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,dr,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),b(this,Et,Um).call(this),n(this,oh)||(this.parent.addUndoableEditor(this),p(this,oh,!0)),this._reportTelemetry({action:"inserted_image"}),n(this,ah)&&this.div.setAttribute("aria-description",n(this,ah)),this.annotationElementId||this._uiManager.a11yAlert(Mt._l10nAlert.stamp)},qf=function(e,s){const{width:i,height:r}=n(this,ee);let a=i,o=r,l=n(this,ee);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 u=new OffscreenCanvas(a,o);u.getContext("2d").drawImage(l,0,0,c,h,0,0,a,o),l=u.transferToImageBitmap()}return l},Um=function(){const[e,s]=this.parentDimensions,{width:i,height:r}=this,a=new _n,o=Math.ceil(i*e*a.sx),l=Math.ceil(r*s*a.sy),c=n(this,dr);if(!c||c.width===o&&c.height===l)return;c.width=o,c.height=l;const h=n(this,Js)?n(this,ee):b(this,Et,qf).call(this,o,l),u=c.getContext("2d");u.filter=this._uiManager.hcmFilter,u.drawImage(h,0,0,h.width,h.height,0,0,o,l)},Yf=function(e){if(e){if(n(this,Js)){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,ee),s.getContext("2d").drawImage(n(this,ee),0,0),s.toDataURL()}if(n(this,Js)){const[s,i]=this.pageDimensions,r=Math.round(this.width*s*Ta.PDF_TO_CSS_UNITS),a=Math.round(this.height*i*Ta.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(r,a);return o.getContext("2d").drawImage(n(this,ee),0,0,n(this,ee).width,n(this,ee).height,0,0,r,a),o.transferToImageBitmap()}return structuredClone(n(this,ee))},$0=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($m,"_type","stamp"),M($m,"_editorType",ct.STAMP);var yl,lh,ba,ya,ur,ks,wa,ch,hh,ji,fr,Re,pr,Aa,dh,K,Sa,Vt,zm,U0,Qi,Vm,Gm,Kf;const Ii=class Ii{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:c,l10n:h}){m(this,Vt);m(this,yl);m(this,lh,!1);m(this,ba,null);m(this,ya,null);m(this,ur,null);m(this,ks,new Map);m(this,wa,!1);m(this,ch,!1);m(this,hh,!1);m(this,ji,null);m(this,fr,null);m(this,Re,null);m(this,pr,null);m(this,Aa,null);m(this,dh,-1);m(this,K);const u=[...n(Ii,Sa).values()];if(!Ii._initialized){Ii._initialized=!0;for(const f of u)f.initialize(h,t)}t.registerEditorTypes(u),p(this,K,t),this.pageIndex=e,this.div=s,p(this,yl,r),p(this,ba,a),this.viewport=c,p(this,Re,l),this.drawLayer=o,this._structTree=i,n(this,K).addLayer(this)}get isEmpty(){return n(this,ks).size===0}get isInvisible(){return this.isEmpty&&n(this,K).getMode()===ct.NONE}updateToolbar(t){n(this,K).updateToolbar(t)}updateMode(t=n(this,K).getMode()){switch(b(this,Vt,Kf).call(this),t){case ct.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case ct.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case ct.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===ct.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const s of n(Ii,Sa).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,K).setEditingState(t)}addCommands(t){n(this,K).addCommands(t)}cleanUndoStack(t){n(this,K).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,ba))==null||e.togglePointerEvents(t)}async enable(){var s;p(this,hh,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(s=n(this,Aa))==null||s.abort(),p(this,Aa,null);const t=new Set;for(const i of n(this,Vt,zm))i.enableEditing(),i.show(!0),i.annotationElementId&&(n(this,K).removeChangedExistingAnnotation(i),t.add(i.annotationElementId));const e=n(this,ba);if(e)for(const i of e.getEditableAnnotations()){if(i.hide(),n(this,K).isDeletedAnnotationElement(i.data.id)||t.has(i.data.id))continue;const r=await this.deserialize(i);r&&(this.addOrRebuild(r),r.enableEditing())}p(this,hh,!1),n(this,K)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var i;if(p(this,ch,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),n(this,Re)&&!n(this,Aa)){p(this,Aa,new AbortController);const r=n(this,K).combinedSignal(n(this,Aa));n(this,Re).div.addEventListener("pointerdown",a=>{const{clientX:l,clientY:c,timeStamp:h}=a,u=n(this,dh);if(h-u>500){p(this,dh,h);return}p(this,dh,-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 v=new RegExp(`^${Qh}[0-9]+$`);for(const S of g)if(v.test(S.id)){y=S.id;break}if(!y)return;const w=n(this,ks).get(y);(w==null?void 0:w.annotationElementId)===null&&(re(a),w.dblclick(a))},{signal:r,capture:!0})}const t=n(this,ba),e=[];if(t){const r=new Map,a=new Map;for(const o of n(this,Vt,zm)){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,K).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,K).addChangedExistingAnnotation(c),c.renderAnnotationElement(o)&&c.show(!1)),o.show()}}b(this,Vt,Kf).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const r of n(Ii,Sa).values())s.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t==null||t.updateFakeAnnotations(e),p(this,ch,!1)}getEditableAnnotation(t){var e;return((e=n(this,ba))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){n(this,K).getActive()!==t&&n(this,K).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=n(this,Re))!=null&&t.div&&!n(this,pr)){p(this,pr,new AbortController);const e=n(this,K).combinedSignal(n(this,pr));n(this,Re).div.addEventListener("pointerdown",b(this,Vt,U0).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,pr)&&(n(this,pr).abort(),p(this,pr,null),n(this,Re).div.classList.remove("highlighting"))}enableClick(){if(n(this,ya))return;p(this,ya,new AbortController);const t=n(this,K).combinedSignal(n(this,ya));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,ya))==null||t.abort(),p(this,ya,null)}attach(t){n(this,ks).set(t.id,t);const{annotationElementId:e}=t;e&&n(this,K).isDeletedAnnotationElement(e)&&n(this,K).removeDeletedAnnotationElement(t)}detach(t){var e;n(this,ks).delete(t.id),(e=n(this,yl))==null||e.removePointerInTextLayer(t.contentDiv),!n(this,ch)&&t.annotationElementId&&n(this,K).addDeletedAnnotationElement(t)}remove(t){this.detach(t),n(this,K).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(n(this,K).addDeletedAnnotationElement(t),Mt.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,K).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!n(this,hh)),n(this,K).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!n(this,ur)&&(t._focusEventsAllowed=!1,p(this,ur,setTimeout(()=>{p(this,ur,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:n(this,K)._signal}),e.focus())},0))),t._structTreeParentId=(s=n(this,yl))==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,ks).values())if(e.uid===t)return e;return null}combinedSignal(t){return n(this,K).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=n(this,Vt,Qi))==null?void 0:t.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await n(this,K).updateMode(t.mode);const{offsetX:s,offsetY:i}=b(this,Vt,Gm).call(this),r=n(this,K).getId(),a=b(this,Vt,Vm).call(this,{parent:this,id:r,x:s,y:i,uiManager:n(this,K),isCentered:!0,...e});a&&this.add(a)}async deserialize(t){var e;return await((e=n(Ii,Sa).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,n(this,K)))||null}createAndAddNewEditor(t,e,s={}){const i=n(this,K).getId(),r=b(this,Vt,Vm).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:n(this,K),isCentered:e,...s});return r&&this.add(r),r}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(t={}){this.createAndAddNewEditor(b(this,Vt,Gm).call(this),!0,t)}setSelected(t){n(this,K).setSelected(t)}toggleSelected(t){n(this,K).toggleSelected(t)}unselect(t){n(this,K).unselect(t)}pointerup(t){var i;const{isMac:e}=Ht.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!n(this,wa)||(p(this,wa,!1),(i=n(this,Vt,Qi))!=null&&i.isDrawer&&n(this,Vt,Qi).supportMultipleDrawings))return;if(!n(this,lh)){p(this,lh,!0);return}const s=n(this,K).getMode();if(s===ct.STAMP||s===ct.POPUP||s===ct.SIGNATURE){n(this,K).unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){var i;if(n(this,K).getMode()===ct.HIGHLIGHT&&this.enableTextSelection(),n(this,wa)){p(this,wa,!1);return}const{isMac:e}=Ht.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(p(this,wa,!0),(i=n(this,Vt,Qi))!=null&&i.isDrawer){this.startDrawingSession(t);return}const s=n(this,K).getActive();p(this,lh,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),n(this,ji)){n(this,Vt,Qi).startDrawing(this,n(this,K),!1,t);return}n(this,K).setCurrentDrawingSession(this),p(this,ji,new AbortController);const e=n(this,K).combinedSignal(n(this,ji));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(p(this,fr,null),this.commitOrRemove())},{signal:e}),n(this,Vt,Qi).startDrawing(this,n(this,K),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&p(this,fr,e);return}n(this,fr)&&setTimeout(()=>{var e;(e=n(this,fr))==null||e.focus(),p(this,fr,null)},0)}endDrawingSession(t=!1){return n(this,ji)?(n(this,K).setCurrentDrawingSession(null),n(this,ji).abort(),p(this,ji,null),p(this,fr,null),n(this,Vt,Qi).endDrawing(t)):null}findNewParent(t,e,s){const i=n(this,K).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}commitOrRemove(){return n(this,ji)?(this.endDrawingSession(),!0):!1}onScaleChanging(){n(this,ji)&&n(this,Vt,Qi).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),((t=n(this,K).getActive())==null?void 0:t.parent)===this&&(n(this,K).commitOrRemove(),n(this,K).setActiveEditor(null)),n(this,ur)&&(clearTimeout(n(this,ur)),p(this,ur,null));for(const s of n(this,ks).values())(e=n(this,yl))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,n(this,ks).clear(),n(this,K).removeLayer(this)}async render({viewport:t}){this.viewport=t,xl(this.div,t);for(const e of n(this,K).getEditors(this.pageIndex))this.add(e),e.rebuild();await n(this,K).findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){n(this,K).commitOrRemove(),b(this,Vt,Kf).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,ks).values())i.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return n(this,K).viewParameters.realScale}};yl=new WeakMap,lh=new WeakMap,ba=new WeakMap,ya=new WeakMap,ur=new WeakMap,ks=new WeakMap,wa=new WeakMap,ch=new WeakMap,hh=new WeakMap,ji=new WeakMap,fr=new WeakMap,Re=new WeakMap,pr=new WeakMap,Aa=new WeakMap,dh=new WeakMap,K=new WeakMap,Sa=new WeakMap,Vt=new WeakSet,zm=function(){return n(this,ks).size!==0?n(this,ks).values():n(this,K).getEditors(this.pageIndex)},U0=function(t){n(this,K).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}=Ht.platform;if(t.button!==0||t.ctrlKey&&s)return;n(this,K).showAllEditors("highlight",!0,!0),n(this,Re).div.classList.add("free"),this.toggleDrawing(),op.startHighlighting(this,n(this,K).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,K)._signal}),t.preventDefault()}},Qi=function(){return n(Ii,Sa).get(n(this,K).getMode())},Vm=function(t){const e=n(this,Vt,Qi);return e?new e.prototype.constructor(t):null},Gm=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,[u,f]=this.viewport.rotation%180===0?[c,h]:[h,c];return{offsetX:u,offsetY:f}},Kf=function(){for(const t of n(this,ks).values())t.isEmpty()&&t.remove()},M(Ii,"_initialized",!1),m(Ii,Sa,new Map([Sm,Dm,$m,op,Bm].map(t=>[t._editorType,t])));let Hm=Ii;function aE(d,t){return d===t?0:d.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function lf(d){var t;return d?d.nodeType===Node.ELEMENT_NODE?d.closest(".textLayer"):((t=d.parentElement)==null?void 0:t.closest(".textLayer"))||null:null}function oE(d,t,e,s){if(d===e)return t<=s;const i=d.compareDocumentPosition(e);return i&Node.DOCUMENT_POSITION_FOLLOWING?!0:i&Node.DOCUMENT_POSITION_PRECEDING?!1:null}function ib(d,t,e){if(d.nodeType!==Node.ELEMENT_NODE||!d.classList.contains("textLayer")||t!==d.childNodes.length)return{container:d,offset:t};let s=d.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 Ts,ps,wi,Ru,Nu,wl,Al,Bu,Lp,xa,Ea,Ca,_a,gr,rs,Wm,Xm,H0,Qf,z0,Tn,qm,V0,Ym;const tt=class tt{constructor({filterFactory:t=null,pageColors:e=null,pageIndex:s,textLayer:i=null}){m(this,Tn);m(this,Ts,null);m(this,ps,new Map);m(this,wi,null);m(this,Ru,null);m(this,Nu,null);m(this,wl,null);m(this,Al,new Map);if(this.pageIndex=s,p(this,Ru,t),p(this,Nu,e),i){const r=n(tt,gr).get(i);if(r!=null&&r.selectionDiv&&(r.selectionDiv.remove(),n(tt,Ea).delete(r.selectionDiv)),n(tt,gr).set(i,{drawLayer:this}),n(tt,_a).add(i),p(this,wi,i),p(this,wl,new MutationObserver(a=>{var o,l,c;if(!(!n(this,Ts)||!((o=n(this,wi))!=null&&o.isConnected)||!b(l=tt,rs,Xm).call(l))){for(const{addedNodes:h}of a)for(const u of h)if(u.nodeType===Node.ELEMENT_NODE&&u.classList.contains("endOfContent")){b(c=tt,rs,Qf).call(c);return}}})),n(this,wl).observe(i,{childList:!0}),n(tt,xa)===null){p(tt,xa,new AbortController);const{signal:a}=n(tt,xa);document.addEventListener("selectionchange",b(tt,rs,Qf).bind(tt),{signal:a}),document.addEventListener("pointerdown",()=>{p(tt,Ca,!0)},{signal:a}),document.addEventListener("pointerup",()=>{p(tt,Ca,!1)},{signal:a}),window.addEventListener("blur",()=>{p(tt,Ca,!1)},{signal:a})}}}setParent(t){var e,s,i;if(!n(this,Ts)){p(this,Ts,t),(e=n(this,wi))!=null&&e.isConnected&&b(s=tt,rs,Xm).call(s)&&b(i=tt,rs,Qf).call(i);return}if(n(this,Ts)!==t){if(n(this,ps).size>0)for(const r of n(this,ps).values())r.remove(),t.append(r);p(this,Ts,t)}}static get _svgFactory(){return ot(this,"_svgFactory",new rp)}draw(t,e=!1,s=!1){const i=Yt(tt,Bu)._++,r=b(this,Tn,qm).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,Al).set(i,o);const c=s?b(this,Tn,V0).call(this,a,l):null,h=tt._svgFactory.createElement("use");return r.append(h),h.setAttribute("href",`#${l}`),this.updateProperties(r,t),n(this,ps).set(i,r),{id:i,clipPathId:`url(#${c})`}}drawOutline(t,e){const s=Yt(tt,Bu)._++,i=b(this,Tn,qm).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 u=tt._svgFactory.createElement("mask");r.append(u),l=`mask_${s}`,u.setAttribute("id",l),u.setAttribute("maskUnits","objectBoundingBox");const f=tt._svgFactory.createElement("rect");u.append(f),f.setAttribute("width","1"),f.setAttribute("height","1"),f.setAttribute("fill","white");const g=tt._svgFactory.createElement("use");u.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,ps).set(s,i),s}finalizeDraw(t,e){n(this,Al).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,ps).get(t):t;if(o){if(s&&b(this,Tn,Ym).call(this,o,s),i&&b(l=tt,rs,z0).call(l,o,i),r){const{classList:c}=o;for(const[h,u]of Object.entries(r))c.toggle(h,u)}if(a){const h=o.firstElementChild.firstElementChild;b(this,Tn,Ym).call(this,h,a)}}}updateParent(t,e){if(e===this)return;const s=n(this,ps).get(t);s&&(n(e,Ts).append(s),n(this,ps).delete(t),n(e,ps).set(t,s))}remove(t){n(this,Al).delete(t),n(this,Ts)!==null&&(n(this,ps).get(t).remove(),n(this,ps).delete(t))}destroy(){var t,e,s;p(this,Ts,null);for(const i of n(this,ps).values())i.remove();if(n(this,ps).clear(),n(this,Al).clear(),(t=n(this,wl))==null||t.disconnect(),p(this,wl,null),n(this,wi)){const i=n(tt,gr).get(n(this,wi));(i==null?void 0:i.drawLayer)===this&&(b(e=tt,rs,Wm).call(e,n(this,wi)),n(tt,gr).delete(n(this,wi)),n(tt,_a).delete(n(this,wi)),n(tt,_a).size===0&&((s=n(tt,xa))==null||s.abort(),p(tt,xa,null),p(tt,Ca,!1))),p(this,wi,null)}}};Ts=new WeakMap,ps=new WeakMap,wi=new WeakMap,Ru=new WeakMap,Nu=new WeakMap,wl=new WeakMap,Al=new WeakMap,Bu=new WeakMap,Lp=new WeakMap,xa=new WeakMap,Ea=new WeakMap,Ca=new WeakMap,_a=new WeakMap,gr=new WeakMap,rs=new WeakSet,Wm=function(t){const e=n(this,gr).get(t);e!=null&&e.selectionDiv&&(e.selectionDiv.remove(),n(this,Ea).delete(e.selectionDiv),e.selectionDiv=null,e.path=null)},Xm=function(){const t=document.getSelection();return!!t&&!t.isCollapsed},H0=function(){return[...n(this,_a)].filter(t=>t.isConnected).sort(aE)},Qf=function(){var a;const t=document.getSelection();if(!t||t.isCollapsed){for(const o of n(this,Ea))o.remove();n(this,Ea).clear();return}const e=new WeakMap,s=b(this,rs,H0).call(this),i=[];for(let o=0,l=t.rangeCount;oc.intersectsNode(_));if(x.length===0)continue;let A=!1;if(y||(y=x[0],h=y,u=0,A=!0),v||(v=x.at(-1),f=v,g=v.childNodes.length,A=!0),f.nodeType===Node.ELEMENT_NODE){if(f.classList.contains("endOfContent")){const _=f.previousSibling;if(!_)continue;f=_,g=_.nodeType===Node.TEXT_NODE?_.textContent.length:_.childNodes.length}else if(f.classList.contains("textLayer")&&f.childNodes.length===g){const _=ib(f,g,v);if(!_)continue;f=_.container,g=_.offset}}if(h.nodeType===Node.ELEMENT_NODE){const _=ib(h,u,y);if(!_)continue;h=_.container,u=_.offset}if(y===v&&!A&&x.includes(y)){i.push([c,y]);continue}for(const _ of x){const E=_.firstChild;if(!E)continue;const k=document.createRange();if(_===y?k.setStart(h,u):k.setStartBefore(E),_===v)k.setEnd(f,g);else{const P=_.lastChild;if(!P)continue;if(P.nodeType===Node.ELEMENT_NODE&&P.classList.contains("endOfContent")){const L=P.previousSibling;if(!L)continue;k.setEndAfter(L)}else k.setEndAfter(P)}k.collapsed||i.push([k,_])}}const r=new Set(i.map(o=>o[1]));for(const o of n(this,_a))r.has(o)||b(this,rs,Wm).call(this,o);for(const[o,l]of i){const c=n(tt,gr).get(l);if(!c)continue;let h=e.get(l);if(!h){const v=l.getBoundingClientRect();h=(w,S,x,A)=>({x:(w-v.x)/v.width,y:(S-v.y)/v.height,width:x/v.width,height:A/v.height}),e.set(l,h)}const u=[];for(let{x:v,y:w,width:S,height:x}of o.getClientRects())S===0||x===0||({x:v,y:w,width:S,height:x}=h(v,w,S,x),!(S===1&&x===1)&&u.push(`M${v} ${w} h${S} v${x} h-${S} Z`));if(u.length===0)continue;const f=c.drawLayer;let g=c.selectionDiv,y=c.path;if(!g){const v=`clip_selection_${Yt(tt,Lp)._++}`;g=document.createElement("div"),g.className="selection",g.style.clipPath=`url(#${v})`;const w=(a=n(f,Ru))==null?void 0:a.createSelectionStyle(n(f,Nu));if(w)for(const[A,_]of Object.entries(w))g.style.setProperty(A,_);const S=tt._svgFactory.create(1,1,!0);S.setAttribute("aria-hidden","true"),S.setAttribute("width","100%"),S.setAttribute("height","100%");const x=tt._svgFactory.createElement("clipPath");x.setAttribute("id",v),x.setAttribute("clipPathUnits","objectBoundingBox"),y=tt._svgFactory.createElement("path"),x.append(y),S.append(x),g.append(S),c.path=y,c.selectionDiv=g}!g.parentNode&&n(f,Ts)&&(n(f,Ts).append(g),n(this,Ea).add(g)),y.setAttribute("d",u.join(" "))}},z0=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}%`},Tn=new WeakSet,qm=function(){const t=tt._svgFactory.create(1,1,!0);return n(this,Ts).append(t),t.setAttribute("aria-hidden","true"),t},V0=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},Ym=function(t,e){for(const[s,i]of Object.entries(e))i===null?t.removeAttribute(s):t.setAttribute(s,i)},m(tt,rs),m(tt,Bu,0),m(tt,Lp,0),m(tt,xa,null),m(tt,Ea,new Set),m(tt,Ca,!1),m(tt,_a,new Set),m(tt,gr,new WeakMap);let jm=tt;function cf(d){return`${(d*100).toFixed(2)}%`}var uh,$u,Uu,fh,Sn,xn,Hu,Fp,G0;const Yh=class Yh{constructor(t,e,s,i){m(this,Fp);m(this,uh,[]);m(this,$u,new Map);m(this,Uu,null);m(this,fh,0);m(this,Sn,0);m(this,xn,0);p(this,fh,t),p(this,uh,e),p(this,Sn,s.rawDims.pageWidth),p(this,xn,s.rawDims.pageHeight),p(this,Uu,i)}render(){const t=document.createElement("div");t.className="textLayerImages";for(let e=0;e{var S;if(!(e.target instanceof HTMLCanvasElement))return;const s=e.target,i=n(this,$u).get(s);if(!i)return;const r=(S=n(Yh,Hu))==null?void 0:S.deref();if(r===s)return;r&&(r.width=0,r.height=0),p(Yh,Hu,new WeakRef(s));const{inverseTransform:a,x1:o,y1:l,width:c,height:h}=i,u=n(this,Uu).call(this),f=Math.ceil(o*u.width),g=Math.ceil(l*u.height),y=Math.floor((o+c/n(this,Sn))*u.width),v=Math.floor((l+h/n(this,xn))*u.height);s.width=y-f,s.height=v-g;const w=s.getContext("2d");w.setTransform(...a),w.translate(-f,-g),w.drawImage(u,0,0)}),t}};uh=new WeakMap,$u=new WeakMap,Uu=new WeakMap,fh=new WeakMap,Sn=new WeakMap,xn=new WeakMap,Hu=new WeakMap,Fp=new WeakSet,G0=function([t,e,s,i,r,a]){const o=Math.hypot((r-t)*n(this,Sn),(a-e)*n(this,xn)),l=Math.hypot((s-t)*n(this,Sn),(i-e)*n(this,xn));if(ot.taskId!=null&&t.sourceFileId!=null?Uw(t.taskId,t.sourceFileId):""),L=rt(()=>({"--total-scale-factor":String(u.value)})),I=rt(()=>v.value==="highlighted"?`切片原文已在第 ${l.value} 页高亮`:v.value==="unmatched"?`已定位第 ${l.value} 页,未匹配到可高亮文字`:v.value==="manual"?"手动新增切片没有原文位置":c.value?`第 ${l.value} / ${c.value} 页`:"正在读取 PDF");function D(z){var U;if(!z)return null;if(z.sourceStart==null||z.sourceEnd==null){const dt=(U=z.sourcePages)==null?void 0:U[0];return dt==null?null:o.value.find(lt=>lt.page_number===dt)??null}return o.value.find(dt=>z.sourceStart>=dt.source_start&&z.sourceStartz.sourceStartdt.source_start)??null}function R(z){var pe;const U=t.selectedItem;if(!U)return"";if(U.sourceStart==null||U.sourceEnd==null)return(pe=U.sourcePages)!=null&&pe.includes(z.page_number)?U.originalContent:"";const dt=Math.max(U.sourceStart,z.source_start),lt=Math.min(U.sourceEnd,z.source_end);if(lt<=dt)return"";const nt=Math.max(0,dt-U.sourceStart),qt=Math.max(nt,lt-U.sourceStart);return U.originalContent.slice(nt,qt)}function W(z){return z.normalize("NFKC").replace(/[^\p{L}\p{N}]+/gu,"").toLocaleLowerCase()}function Q(z,U,dt){let lt=-1,nt=Number.POSITIVE_INFINITY,qt=z.indexOf(U);for(;qt>=0;){const pe=Math.abs(qt-dt);peMath.min(Is,qt.length)).filter((Is,Ne,Ds)=>Is>=4&&Ds.indexOf(Is)===Ne);for(const Is of ki){const Ne=qt.slice(0,Is),Ds=Q(nt,Ne,Ke);if(Ds<0)continue;const Ku=Ds+Ne.length;return lt.reduce((Ma,Pi,vh)=>(Pi.end>Ds&&Pi.start{if(!(Ms!==_||Ia instanceof Error&&Ia.name==="RenderingCancelledException"))throw Ia}),vh=Ke.streamTextContent();if(Ms!==_)return;const Qu=new ph({textContentSource:vh,container:nt,viewport:Ne});if(x=Qu,await Promise.all([Pi,Qu.render()]),Ms!==_)return;E=l.value,yt(pe),await Kh(),(qi=dt.querySelector(".is-slice-highlighted"))==null||qi.scrollIntoView({block:"center",inline:"center",behavior:"smooth"})}catch(Ke){if(Ms!==_)return;y.value=Ke instanceof Error?Ke.message:"PDF 页面渲染失败"}finally{Ms===_&&(g.value=!1)}}async function j(){var dt;if(!a.value)return;const z=t.selectedItem;if(!z||(z.sourceStart==null||z.sourceEnd==null)&&!((dt=z.sourcePages)!=null&&dt.length)){yt(null);return}const U=D(z);if(!U){v.value="unmatched";return}if(l.value!==U.page_number){l.value=U.page_number,await T(!0);return}await T(!1)}async function Ft(){const z=++A;if(++_,E=0,S==null||S.cancel(),x==null||x.cancel(),await(w==null?void 0:w.destroy()),w=null,a.value=null,o.value=[],c.value=0,l.value=1,y.value="",v.value="idle",!(!P.value||t.taskId==null||t.sourceFileId==null)){f.value=!0;try{const U=$y({url:P.value});w=U;const[dt,lt]=await Promise.all([Hw(t.taskId,t.sourceFileId),U.promise]);if(z!==A){await U.destroy();return}a.value=lt,o.value=dt.pages,c.value=lt.numPages,await Kh(),await j(),t.selectedItem||await T(!0)}catch(U){if(z!==A)return;y.value=U instanceof Error?U.message:"PDF 原文件加载失败"}finally{z===A&&(f.value=!1)}}}async function St(z){const U=Math.min(c.value,Math.max(1,l.value+z));U!==l.value&&(l.value=U,await T(!0))}async function ke(z){const U=Math.min(2,Math.max(.6,Number((h.value+z).toFixed(1))));U!==h.value&&(h.value=U,await T(!0))}function _t(){window.cancelAnimationFrame(k),k=window.requestAnimationFrame(()=>{a.value&&T(!0)})}const Gt=new ResizeObserver(_t);return Si(e,(z,U)=>{U&&Gt.unobserve(U),z&&Gt.observe(z)}),Si(P,()=>void Ft(),{immediate:!0}),Si(()=>{var z;return(z=t.selectedItem)==null?void 0:z.id},()=>void j()),cb(()=>{++A,++_,window.cancelAnimationFrame(k),Gt.disconnect(),S==null||S.cancel(),x==null||x.cancel(),w==null||w.destroy()}),(z,U)=>(O(),$("div",cE,[P.value?(O(),$("div",hE,[C("div",dE,[C("button",{type:"button","aria-label":"上一页",disabled:l.value<=1||f.value,onClick:U[0]||(U[0]=dt=>St(-1))},[...U[4]||(U[4]=[C("i",{class:"fa fa-chevron-left","aria-hidden":"true"},null,-1)])],8,uE),C("span",fE,X(l.value)+" / "+X(c.value||"—"),1),C("button",{type:"button","aria-label":"下一页",disabled:l.value>=c.value||f.value,onClick:U[1]||(U[1]=dt=>St(1))},[...U[5]||(U[5]=[C("i",{class:"fa fa-chevron-right","aria-hidden":"true"},null,-1)])],8,pE)]),C("span",{class:Se(["location-state",`is-${v.value}`]),role:"status"},[v.value==="highlighted"?(O(),$("i",gE)):ft("",!0),ut(" "+X(I.value),1)],2),C("div",mE,[C("button",{type:"button","aria-label":"缩小",disabled:h.value<=.6||f.value,onClick:U[2]||(U[2]=dt=>ke(-.1))},"−",8,vE),C("span",bE,X(Math.round(h.value*100))+"%",1),C("button",{type:"button","aria-label":"放大",disabled:h.value>=2||f.value,onClick:U[3]||(U[3]=dt=>ke(.1))},"+",8,yE)])])):ft("",!0),P.value?(O(),$("div",{key:1,ref_key:"scrollRef",ref:e,class:"pdf-scroll",tabindex:"0","aria-label":`PDF 预览:${d.fileName}`},[C("div",{ref_key:"pageRef",ref:s,class:"pdf-page",style:_w(L.value),"data-page-number":l.value},[C("canvas",{ref_key:"canvasRef",ref:i,class:"pdf-canvas"},null,512),C("div",{ref_key:"textLayerRef",ref:r,class:"pdf-text-layer"},null,512)],12,AE),f.value||g.value?(O(),$("div",SE,[U[6]||(U[6]=C("i",{class:"fa fa-spinner fa-spin","aria-hidden":"true"},null,-1)),ut(" "+X(f.value?"正在加载 PDF…":"正在渲染页面…"),1)])):ft("",!0),y.value?(O(),$("div",xE,[U[7]||(U[7]=C("i",{class:"fa fa-exclamation-circle","aria-hidden":"true"},null,-1)),U[8]||(U[8]=C("strong",null,"PDF 预览失败",-1)),C("span",null,X(y.value),1),C("a",{href:P.value,target:"_blank",rel:"noopener noreferrer"},"在新窗口打开原件",8,EE)])):ft("",!0)],8,wE)):(O(),$("div",CE,[...U[9]||(U[9]=[C("i",{class:"fa fa-file-pdf-o","aria-hidden":"true"},null,-1),C("strong",null,"PDF 原文件暂不可预览",-1),C("span",null,"请重新上传该文件后再试。",-1)])]))]))}}),kE=_i(_E,[["__scopeId","data-v-b5c8430d"]]),TE=["问:如何看待当前的通货膨胀风险?","答:当前通胀水平总体可控,但仍需关注能源价格与供给扰动。","问:美联储下一次议息会议何时召开?","答:会议时间以美联储官方日历为准,市场会重点关注利率路径指引。","问:人民币汇率未来走势如何?","答:人民币汇率取决于中美利差、经济基本面与政策预期。","问:什么是复利?","答:复利是将上一期利息加入本金,再计算下一期利息。"].join(` `);function PE(d){const t=d.split(` `);let e=0;return t.map((s,i)=>{const r=e,a=r+s.length;return e=a+(iPE(e.sourceText)),h=rt(()=>e.items.find(I=>I.id===e.selectedId)??e.items[0]),u=rt(()=>e.items.find(I=>I.id===o.value)),f=rt(()=>/\.pdf$/i.test(e.fileName)),g=rt(()=>e.items.filter((I,D)=>!r.value.trim()||I.editedContent.toLowerCase().includes(r.value.trim().toLowerCase())||String(D+1).includes(r.value.trim()))),y=rt(()=>{const I=(a.value-1)*xh;return g.value.slice(I,I+xh)});function v(I,D){const R=h.value;return!R||R.sourceStart==null||R.sourceEnd==null?!1:D>=R.sourceStart&&I<=R.sourceEnd}function w(I){s("update:selectedId",I)}function S(I){w(I.id),o.value=I.id,l.value=I.editedContent}function x(){o.value=null,l.value=""}function A(){u.value&&(s("update:item-content",u.value.id,l.value),x())}function _(){u.value&&(s("restore:item",u.value.id),x())}function E(I){w(I.id),s("remove:item",I.id)}function k(){x()}Si(r,()=>{a.value=1,x()}),Si(()=>e.selectedFileId,x),Si(h,async I=>{var W,Q;if(!I)return;const D=g.value.findIndex(Y=>Y.id===I.id);if(D>=0&&(a.value=Math.floor(D/xh)+1),f.value||I.sourceStart==null)return;await Kh();const R=((W=i.value)==null?void 0:W.querySelector(`[data-source-start="${I.sourceStart}"]`))??((Q=i.value)==null?void 0:Q.querySelector(".source-line.is-highlighted"));R==null||R.scrollIntoView({block:"center",behavior:"smooth"})},{immediate:!0});function P(I){return e.items.findIndex(D=>D.id===I.id)+1}function L(I){var D;if((D=I.sourcePages)!=null&&D.length){const R=I.sourcePages[0],W=I.sourcePages[I.sourcePages.length-1];return R===W?`来源:第 ${R} 页`:`来源:第 ${R}–${W} 页`}return I.sourceStartLine==null||I.sourceEndLine==null?"手动新增,无源文件定位":I.sourceStartLine===I.sourceEndLine?`来源:第 ${I.sourceStartLine} 行`:`来源:第 ${I.sourceStartLine}–${I.sourceEndLine} 行`}return(I,D)=>{const R=Np,W=Rp,Q=zu,Y=Vu,yt=fb;return O(),$("section",ME,[C("div",IE,[C("div",DE,[D[5]||(D[5]=C("span",null,"当前文件",-1)),H(W,{"model-value":d.selectedFileId,filterable:"",placeholder:"选择文件","aria-label":"选择当前预览文件","onUpdate:modelValue":D[0]||(D[0]=T=>s("update:selectedFileId",T))},{default:J(()=>[(O(!0),$(Ae,null,ii(d.files,T=>(O(),Ut(R,{key:T.id,label:T.name,value:T.id},{default:J(()=>[C("div",LE,[C("strong",{title:T.name},X(T.name),9,FE),C("span",null,X(T.count.toLocaleString())+" "+X(d.processType==="unstructured"?"个切片":"条记录"),1),T.modifiedCount?(O(),$("em",OE,X(T.modifiedCount)+" 处已修改",1)):ft("",!0)])]),_:2},1032,["label","value"]))),128))]),_:1},8,["model-value"])]),C("span",RE,X(d.files.length)+" 个文件 · 当前文件 "+X(d.items.length.toLocaleString())+" "+X(d.processType==="unstructured"?"个切片":"条记录"),1)]),C("div",NE,[C("div",BE,[C("div",$E,[C("div",null,[C("strong",null,"源文件 · "+X(d.fileName),1)])]),f.value?(O(),Ut(kE,{key:0,"task-id":d.taskId,"source-file-id":d.sourceFileId,"file-name":d.fileName,"selected-item":h.value??null},null,8,["task-id","source-file-id","file-name","selected-item"])):(O(),$("div",{key:1,ref_key:"sourceViewerRef",ref:i,class:"source-viewer",tabindex:"0","aria-label":"源文件内容"},[(O(!0),$(Ae,null,ii(c.value,T=>(O(),$("div",{key:T.number,class:Se(["source-line",{"is-highlighted":v(T.start,T.end)}]),"data-source-start":T.start},[C("span",HE,X(T.number),1),C("span",zE,X(T.content||" "),1)],10,UE))),128))],512))]),C("div",VE,[C("div",GE,[C("strong",null,X(d.processType==="unstructured"?"切片内容":"记录内容"),1),C("div",jE,[C("span",null,"共 "+X(d.items.length.toLocaleString())+" 条",1),H(Q,{link:"",type:"primary",onClick:D[1]||(D[1]=T=>s("add:item"))},{default:J(()=>[...D[6]||(D[6]=[C("i",{class:"fa fa-plus"},null,-1),ut(" 手动新增 ",-1)])]),_:1})])]),u.value?(O(),$("div",ZE,[C("div",tC,[C("div",null,[C("strong",null,X(d.processType==="unstructured"?"切片":"记录")+" #"+X(String(P(u.value)).padStart(3,"0"))+" 正文",1),C("small",null,X(L(u.value)),1)])]),H(Y,{modelValue:l.value,"onUpdate:modelValue":D[4]||(D[4]=T=>l.value=T),type:"textarea",rows:7,resize:"none"},null,8,["modelValue"]),C("div",eC,[u.value.sourceStart!=null?(O(),Ut(Q,{key:0,link:"",onClick:_},{default:J(()=>[...D[10]||(D[10]=[C("i",{class:"fa fa-undo"},null,-1),ut(" 恢复原始内容 ",-1)])]),_:1})):ft("",!0),C("div",null,[H(Q,{onClick:x},{default:J(()=>[...D[11]||(D[11]=[ut("取消",-1)])]),_:1}),H(Q,{type:"primary",onClick:A},{default:J(()=>[...D[12]||(D[12]=[ut("保存修改",-1)])]),_:1})])])])):(O(),$(Ae,{key:0},[C("div",WE,[H(Y,{modelValue:r.value,"onUpdate:modelValue":D[2]||(D[2]=T=>r.value=T),clearable:"",placeholder:"搜索编号或内容",size:"small"},{prefix:J(()=>[...D[7]||(D[7]=[C("i",{class:"fa fa-search"},null,-1)])]),_:1},8,["modelValue"])]),C("div",XE,[(O(!0),$(Ae,null,ii(y.value,T=>{var j,Ft;return O(),$("div",{key:T.id,class:Se(["preview-item",{"is-active":T.id===((j=h.value)==null?void 0:j.id)}]),"data-preview-id":T.id,"aria-selected":T.id===((Ft=h.value)==null?void 0:Ft.id),role:"button",tabindex:"0",onClick:St=>w(T.id),onKeydown:[Tv(St=>w(T.id),["enter"]),Tv(ig(St=>w(T.id),["prevent"]),["space"])]},[C("span",YE,X(d.processType==="unstructured"?"切片":"记录")+" #"+X(String(P(T)).padStart(3,"0")),1),C("span",KE,X(L(T)),1),C("span",QE,[H(Q,{link:"","aria-label":"编辑切片",title:"编辑",onClick:ig(St=>S(T),["stop"])},{default:J(()=>[...D[8]||(D[8]=[C("i",{class:"fa fa-pencil"},null,-1)])]),_:1},8,["onClick"]),H(Q,{link:"",type:"danger","aria-label":"删除切片",title:"删除",onClick:ig(St=>E(T),["stop"])},{default:J(()=>[...D[9]||(D[9]=[C("i",{class:"fa fa-trash-o"},null,-1)])]),_:1},8,["onClick"])])],42,qE)}),128)),g.value.length?ft("",!0):(O(),$("div",JE,"没有符合条件的内容"))]),g.value.length>xh?(O(),Ut(yt,{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"])):ft("",!0)],64))])])])}}}),iC=_i(sC,[["__scopeId","data-v-13041697"]]),nC={class:"generation-step"},rC={class:"generation-layout"},aC={class:"summary-panel"},oC={class:"run-icon"},lC={key:0,class:"fa fa-check"},cC={key:1,class:"fa fa-exclamation"},hC={key:2,class:"fa fa-cog fa-spin"},dC={key:3,class:"fa fa-play"},uC=Ci({__name:"GenerationStep",props:{taskName:{},processType:{},fileName:{},previewCount:{},modifiedCount:{},generation:{}},emits:["stop","retry"],setup(d,{emit:t}){const e=t;return(s,i)=>{const r=pb,a=zu;return O(),$("section",nC,[C("div",rC,[C("div",aC,[i[7]||(i[7]=C("div",{class:"panel-heading"},[C("strong",null,"任务摘要"),C("span",null,"已完成预览确认")],-1)),C("dl",null,[C("div",null,[i[2]||(i[2]=C("dt",null,"任务名称",-1)),C("dd",null,X(d.taskName),1)]),C("div",null,[i[3]||(i[3]=C("dt",null,"数据类型",-1)),C("dd",null,X(d.processType==="unstructured"?"非结构化数据":d.processType==="external"?"外来数据源拉取":"结构化数据"),1)]),C("div",null,[i[4]||(i[4]=C("dt",null,"源文件",-1)),C("dd",null,X(d.fileName),1)]),C("div",null,[i[5]||(i[5]=C("dt",null,"预览条目",-1)),C("dd",null,X(d.previewCount.toLocaleString())+" 条",1)]),C("div",null,[i[6]||(i[6]=C("dt",null,"已修改",-1)),C("dd",null,X(d.modifiedCount.toLocaleString())+" 条",1)])])]),C("div",{class:Se(["run-panel",`is-${d.generation.status}`])},[C("div",oC,[d.generation.status==="success"?(O(),$("i",lC)):d.generation.status==="failed"?(O(),$("i",cC)):d.generation.status==="running"?(O(),$("i",hC)):(O(),$("i",dC))]),C("h3",null,X(d.generation.status==="idle"?"准备开始处理":d.generation.status==="running"?"正在生成数据":d.generation.status==="success"?"数据生成完成":"生成已停止"),1),C("p",null,X(d.generation.message),1),d.generation.status!=="idle"?(O(),Ut(r,{key:0,percentage:d.generation.progress,"stroke-width":10,status:d.generation.status==="success"?"success":void 0},null,8,["percentage","status"])):ft("",!0),i[10]||(i[10]=C("div",{class:"run-meta"},[C("span",null,"解析源数据"),C("span",null,"应用预览修改"),C("span",null,"生成标准结果")],-1)),d.generation.status==="running"?(O(),Ut(a,{key:1,plain:"",type:"warning",onClick:i[0]||(i[0]=o=>e("stop"))},{default:J(()=>[...i[8]||(i[8]=[ut(" 停止生成 ",-1)])]),_:1})):ft("",!0),d.generation.status==="failed"?(O(),Ut(a,{key:2,plain:"",type:"primary",onClick:i[1]||(i[1]=o=>e("retry"))},{default:J(()=>[...i[9]||(i[9]=[ut(" 重新生成 ",-1)])]),_:1})):ft("",!0)],2)])])}}}),fC=_i(uC,[["__scopeId","data-v-94e8b875"]]),pC={class:"result-step"},gC={class:"result-workspace"},mC={class:"result-list-pane"},vC={class:"pane-header"},bC={class:"result-toolbar"},yC={class:"result-list"},wC=["onClick"],AC={class:"result-index"},SC={class:"result-copy"},xC={key:0,class:"result-editor-pane"},EC={class:"pane-header"},CC={key:0,class:"modified-label"},_C={class:"source-reference","aria-labelledby":"source-reference-title"},kC={class:"source-reference-heading"},TC={key:0},PC={key:0},MC={key:1},IC={key:2},DC={class:"field-editor"},LC={class:"field-editor"},FC={class:"field-editor"},OC={key:0,class:"validation-error"},RC={key:1,class:"validation-success"},NC={key:2,class:"quality-flags"},BC={class:"editor-pagination"},$C=Ci({__name:"ResultEditorStep",props:{items:{},previewItems:{},selectedId:{}},emits:["update:selectedId","update:field","restore:item"],setup(d,{emit:t}){const e=d,s=t,i=et(""),r=et(!1),a=rt(()=>e.items.find(y=>y.id===e.selectedId)??e.items[0]),o=rt(()=>e.items.findIndex(y=>{var v;return y.id===((v=a.value)==null?void 0:v.id)})),l=rt(()=>{var v;const y=(v=a.value)==null?void 0:v.previewItemId;return y?e.previewItems.find(w=>w.id===y)??null:null}),c=rt(()=>{var y,v;return((y=l.value)==null?void 0:y.editedContent.trim())||((v=l.value)==null?void 0:v.originalContent.trim())||""}),h=rt(()=>!!(l.value&&l.value.editedContent.trim()&&l.value.editedContent!==l.value.originalContent)),u=rt(()=>{const y=l.value;if(!y)return"";const v=[];return y.sourceStartLine!=null&&v.push(y.sourceEndLine!=null&&y.sourceEndLine!==y.sourceStartLine?`第 ${y.sourceStartLine}–${y.sourceEndLine} 行`:`第 ${y.sourceStartLine} 行`),y.tokenCount>0&&v.push(`${y.tokenCount} Token`),v.join(" · ")}),f=rt(()=>e.items.filter((y,v)=>{const w=i.value.trim().toLowerCase();return(!w||y.instruction.toLowerCase().includes(w)||y.output.toLowerCase().includes(w)||String(v+1).includes(w))&&(!r.value||y.status==="invalid")}));function g(y){if(!e.items.length)return;const v=Math.min(Math.max(o.value+y,0),e.items.length-1);s("update:selectedId",e.items[v].id)}return(y,v)=>{var _;const w=Vu,S=Op,x=Bw,A=zu;return O(),$("section",pC,[C("div",gC,[C("aside",mC,[C("div",vC,[v[8]||(v[8]=C("strong",null,"生成结果",-1)),C("span",null,"共 "+X(d.items.length)+" 条",1)]),C("div",bC,[H(w,{modelValue:i.value,"onUpdate:modelValue":v[0]||(v[0]=E=>i.value=E),clearable:"",size:"small",placeholder:"搜索结果"},{prefix:J(()=>[...v[9]||(v[9]=[C("i",{class:"fa fa-search"},null,-1)])]),_:1},8,["modelValue"]),H(S,{modelValue:r.value,"onUpdate:modelValue":v[1]||(v[1]=E=>r.value=E)},{default:J(()=>[...v[10]||(v[10]=[ut("仅看错误",-1)])]),_:1},8,["modelValue"])]),C("div",yC,[(O(!0),$(Ae,null,ii(f.value,E=>{var k;return O(),$("button",{key:E.id,type:"button",class:Se(["result-item",{"is-active":E.id===((k=a.value)==null?void 0:k.id)}]),onClick:P=>s("update:selectedId",E.id)},[C("span",AC,"#"+X(String(d.items.findIndex(P=>P.id===E.id)+1).padStart(3,"0")),1),C("span",SC,[C("strong",null,X(E.instruction||"未填写指令"),1),C("small",null,X(E.output||"未填写输出"),1)]),C("i",{class:Se(["fa",E.status==="invalid"?"fa-exclamation-circle is-error":"fa-check-circle is-valid"])},null,2)],10,wC)}),128))])]),a.value?(O(),$("div",xC,[C("div",EC,[C("div",null,[C("strong",null,"结果 #"+X(String(o.value+1).padStart(3,"0")),1),a.value.status==="modified"?(O(),$("span",CC,"已修改")):ft("",!0),a.value.split?(O(),Ut(x,{key:1,size:"small",effect:"plain"},{default:J(()=>[ut(X(a.value.split),1)]),_:1})):ft("",!0),a.value.qualityScore!=null?(O(),Ut(x,{key:2,size:"small",type:a.value.qualityScore>=80?"success":a.value.qualityScore>=60?"warning":"danger"},{default:J(()=>[ut("质量 "+X(a.value.qualityScore.toFixed(1)),1)]),_:1},8,["type"])):ft("",!0)]),H(A,{link:"",onClick:v[2]||(v[2]=E=>s("restore:item",a.value.id))},{default:J(()=>[...v[11]||(v[11]=[C("i",{class:"fa fa-undo"},null,-1),ut(" 恢复生成结果",-1)])]),_:1})]),C("article",_C,[C("div",kC,[C("div",null,[v[12]||(v[12]=C("strong",{id:"source-reference-title"},"原文参照",-1)),u.value?(O(),$("span",TC,X(u.value),1)):ft("",!0)]),h.value?(O(),Ut(x,{key:0,size:"small",effect:"plain"},{default:J(()=>[...v[13]||(v[13]=[ut("已智能预处理",-1)])]),_:1})):ft("",!0)]),c.value?(O(),$("pre",PC,X(c.value),1)):(O(),$("p",MC,"当前结果没有关联到可用的原文切片。")),h.value?(O(),$("small",IC,"这里展示的是实际送入模型的预处理后原文,便于核对问题和答案是否有依据。")):ft("",!0)]),C("div",DC,[v[14]||(v[14]=C("label",null,[ut("Instruction "),C("em",null,"必填")],-1)),H(w,{"model-value":a.value.instruction,type:"textarea",rows:3,"onUpdate:modelValue":v[3]||(v[3]=E=>s("update:field",a.value.id,"instruction",E))},null,8,["model-value"])]),C("div",LC,[v[15]||(v[15]=C("label",null,[ut("Input "),C("span",null,"选填")],-1)),H(w,{"model-value":a.value.input,type:"textarea",rows:2,"onUpdate:modelValue":v[4]||(v[4]=E=>s("update:field",a.value.id,"input",E))},null,8,["model-value"])]),C("div",FC,[v[16]||(v[16]=C("label",null,[ut("Output "),C("em",null,"必填")],-1)),H(w,{"model-value":a.value.output,type:"textarea",rows:7,"onUpdate:modelValue":v[5]||(v[5]=E=>s("update:field",a.value.id,"output",E))},null,8,["model-value"])]),a.value.error?(O(),$("div",OC,[v[17]||(v[17]=C("i",{class:"fa fa-exclamation-circle"},null,-1)),ut(" "+X(a.value.error),1)])):(O(),$("div",RC,[...v[18]||(v[18]=[C("i",{class:"fa fa-check-circle"},null,-1),ut(" 字段校验通过 ",-1)])])),(_=a.value.qualityFlags)!=null&&_.length?(O(),$("div",NC,[(O(!0),$(Ae,null,ii(a.value.qualityFlags,E=>(O(),Ut(x,{key:E,size:"small",type:"warning",effect:"plain"},{default:J(()=>[ut(X(E),1)]),_:2},1024))),128))])):ft("",!0),C("div",BC,[H(A,{disabled:o.value<=0,onClick:v[6]||(v[6]=E=>g(-1))},{default:J(()=>[...v[19]||(v[19]=[ut("上一条",-1)])]),_:1},8,["disabled"]),C("span",null,X(o.value+1)+" / "+X(d.items.length),1),H(A,{disabled:o.value>=d.items.length-1,onClick:v[7]||(v[7]=E=>g(1))},{default:J(()=>[...v[20]||(v[20]=[ut("下一条",-1)])]),_:1},8,["disabled"])])])):ft("",!0)])])}}}),UC=_i($C,[["__scopeId","data-v-56aaf4d5"]]),j0="你是一名专业的数据生成助手。请根据输入内容生成准确、完整、可直接用于模型训练的问答数据。仅输出符合目标格式的内容,答案应事实清晰、语言自然,不要添加分析过程、说明或无关内容。";function W0(){return{preprocessOptions:["clean_invalid","detect_structure","deduplicate","normalize_format"],semanticEnrichment:!1,qaPairsPerRow:1,datasetSplit:{train:80,validation:10,test:10},generationModelId:"",generationPrompt:j0,temperature:.7,maxTokens:1024,jsonMode:!1,qualityFilterEnabled:!1,filterLowQuality:!0,filterShortContent:!0,minOutputLength:20}}function X0(){return{preprocessOptions:["clean_invalid_content","detect_document_structure","merge_short_content","filter_low_quality","deduplicate_content","preserve_context"],chunkMethod:"layout_hybrid",chunkSize:800,chunkOverlap:100,minChunkSize:100,semanticBreakpointPercentile:95,preserveTables:!0,preserveCodeBlocks:!0,preserveLists:!0,semanticEnrichment:!1,qaPairsPerChunk:1,datasetSplit:{train:80,validation:10,test:10},generationModelId:"",generationPrompt:j0,temperature:.7,maxTokens:1024,jsonMode:!1,qualityFilterEnabled:!1,filterLowQuality:!0,filterShortContent:!0,minOutputLength:20}}function ms(d,t,e){return Object.prototype.hasOwnProperty.call(d,t)?d[t]:e}function vr(d,t,e){const s=Number(ms(d,t,e));return Number.isFinite(s)?s:e}function q0(d,t){const e=d.dataset_split;if(!e||typeof e!="object")return{...t};const s=e,i=r=>{const a=Number(s[r]);return Number.isFinite(a)?a:t[r]};return{train:i("train"),validation:i("validation"),test:i("test")}}function Y0(d,t){return{generationModelId:ms(d,"generation_model_id",t.generationModelId),generationPrompt:String(ms(d,"generation_prompt",t.generationPrompt)),temperature:vr(d,"temperature",t.temperature),maxTokens:vr(d,"max_tokens",t.maxTokens),jsonMode:!!ms(d,"json_mode",t.jsonMode),qualityFilterEnabled:!!ms(d,"quality_filter_enabled",t.qualityFilterEnabled),filterLowQuality:!!ms(d,"filter_low_quality",t.filterLowQuality),filterShortContent:!!ms(d,"filter_short_content",t.filterShortContent),minOutputLength:vr(d,"min_output_length",t.minOutputLength)}}function HC(d){const t=W0(),e=ms(d,"preprocess_options",[]);return{...t,...Y0(d,t),preprocessOptions:Array.isArray(e)?e.map(String):t.preprocessOptions,semanticEnrichment:!!ms(d,"semantic_enrichment",t.semanticEnrichment),qaPairsPerRow:Jm(vr(d,"qa_pairs_per_row",t.qaPairsPerRow),t.qaPairsPerRow),datasetSplit:q0(d,t.datasetSplit)}}function zC(d){const t=X0(),e=ms(d,"preprocess_options",[]);return{...t,...Y0(d,t),preprocessOptions:Array.isArray(e)?e.map(String):t.preprocessOptions,chunkMethod:ms(d,"chunk_method",t.chunkMethod),chunkSize:vr(d,"chunk_size",t.chunkSize),chunkOverlap:vr(d,"chunk_overlap",t.chunkOverlap),minChunkSize:vr(d,"min_chunk_size",t.minChunkSize),semanticBreakpointPercentile:vr(d,"semantic_breakpoint_percentile",t.semanticBreakpointPercentile),preserveTables:!!ms(d,"preserve_tables",t.preserveTables),preserveCodeBlocks:!!ms(d,"preserve_code_blocks",t.preserveCodeBlocks),preserveLists:!!ms(d,"preserve_lists",t.preserveLists),semanticEnrichment:!!ms(d,"semantic_enrichment",t.semanticEnrichment),qaPairsPerChunk:Jm(vr(d,"qa_pairs_per_chunk",t.qaPairsPerChunk),t.qaPairsPerChunk),datasetSplit:q0(d,t.datasetSplit)}}function VC(d,t,e){if(d==="structured")return{preprocessOptions:t.preprocessOptions};if(d!=="unstructured")return null;const{preprocessOptions:s,chunkMethod:i,chunkSize:r,chunkOverlap:a,minChunkSize:o,semanticBreakpointPercentile:l,preserveTables:c,preserveCodeBlocks:h,preserveLists:u}=e;return{preprocessOptions:s,chunkMethod:i,chunkSize:r,chunkOverlap:a,minChunkSize:o,semanticBreakpointPercentile:l,preserveTables:c,preserveCodeBlocks:h,preserveLists:u}}function GC(d,t,e){const s=d==="unstructured"?e:t;if(d==="external")return null;const i={semanticEnrichment:s.semanticEnrichment,datasetSplit:s.datasetSplit,generationModelId:s.generationModelId,generationPrompt:s.generationPrompt,temperature:s.temperature,maxTokens:s.maxTokens,jsonMode:s.jsonMode,qualityFilterEnabled:s.qualityFilterEnabled,filterLowQuality:s.filterLowQuality,filterShortContent:s.filterShortContent,minOutputLength:s.minOutputLength};return d==="unstructured"?{...i,qaPairsPerChunk:e.qaPairsPerChunk}:{...i,qaPairsPerRow:t.qaPairsPerRow}}const rb=500,hf=1500;function fg(d){var t,e;return{id:String(d.id),previewItemId:d.preview_item_id==null?null:String(d.preview_item_id),instruction:d.instruction,input:d.input||"",output:d.output,originalInstruction:d.original_instruction??d.instruction,originalInput:d.original_input??d.input??"",originalOutput:d.original_output??d.output,status:d.status,error:d.error||void 0,split:d.split||void 0,qualityScore:(t=d.quality_score)==null?void 0:t.overall,qualityFlags:((e=d.quality_score)==null?void 0:e.flags)||[],updatedAt:d.updated_at}}function jC(d){const t=et([]),e=et(null),s=pg({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 P;const _=await Pv(A,{page:1,page_size:rb}),E=[..._.items],k=Math.ceil(_.total/_.page_size);for(let L=2;L<=k;L+=1){const I=await Pv(A,{page:L,page_size:rb});E.push(...I.items)}t.value=E.map(fg),e.value=((P=t.value[0])==null?void 0:P.id)??null}async function u(A){if(a=0,c(A),A.status==="completed"){const _=d.taskId.value;if(!_)return;await h(_),s.status="success",s.progress=100,s.message=`已完成 ${t.value.length.toLocaleString()} 条数据处理,可进入结果页检查。`,d.dirty.value=!0,gt.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 _=d.taskId.value;if(!(!_||A!==r||s.status!=="running"))try{const E=await Ww(_);if(A!==r)return;if(a=0,E.status==="running"||E.status==="pending"){c(E),i=setTimeout(()=>void f(A),hf);return}await u(E)}catch(E){if(A!==r)return;if(a+=1,a<=3){s.message=`进度查询暂时失败,正在重试(${a}/3)…`,i=setTimeout(()=>void f(A),hf);return}s.status="failed",s.message=E instanceof Error?E.message:"查询任务进度失败,请重试。"}}async function g(){var E;const A=d.taskId.value;if(!A){gt.error("任务尚未创建,请返回上一步重试");return}o();const _=r;s.status="running",a=0,s.progress=0,s.message="正在同步预览修改并启动后端处理,请稍候。";try{await((E=d.beforeGenerate)==null?void 0:E.call(d));const k=await Vw(A);if(_!==r)return;if(k.status==="completed"||k.status==="failed"||k.status==="stopped"){await u(k);return}c(k),i=setTimeout(()=>void f(_),hf)}catch(k){if(_!==r)return;s.status="failed",s.message=k instanceof Error?k.message:"启动数据处理失败,请重试。"}}async function y(){const A=d.taskId.value;if(A){o();try{const _=await zw(A);c(_)}catch{s.status="running",s.message="停止请求失败,继续查询后端任务状态。";const _=r;i=setTimeout(()=>void f(_),hf);return}s.status="failed",s.message="任务已停止,预览修改仍然保留,可以重新生成。"}}function v(A,_,E){const k=t.value.find(I=>I.id===A);if(!k)return;k[_]=E;const P=k.instruction.trim()&&k.output.trim();k.error=P?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",d.dirty.value=!0}async function w(A){const _=d.taskId.value,E=t.value.find(L=>L.id===A);if(!_||!E)return;const k=await Gw(_,A),P=t.value.indexOf(E);t.value[P]=fg(k),d.dirty.value=!0}async function S(){const A=d.taskId.value;if(!A)throw new Error("任务尚未创建");const _=t.value.filter(E=>E.instruction!==E.originalInstruction||E.input!==E.originalInput||E.output!==E.originalOutput);for(const E of _){const k=await jw(A,E.id,{instruction:E.instruction,input:E.input,output:E.output,expected_updated_at:E.updatedAt}),P=t.value.findIndex(L=>L.id===E.id);P>=0&&(t.value[P]=fg(k))}}function x(){let A=null;for(const _ of t.value)(!_.instruction.trim()||!_.output.trim()||_.status==="invalid")&&(_.error||(_.error="结果未通过后端质量校验,请修改后重新保存"),_.status="invalid",A??(A=_.id));return A&&(e.value=A),A==null}return{generation:s,results:t,selectedResultId:e,persistResultChanges:S,resetDownstream:l,restoreResult:w,startGeneration:g,stopGeneration:y,stopGenerationTimer:o,updateResultField:v,validateResults:x}}function WC(){async function d(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 Xw(t,{replace_existing:!0,source_file_ids:[o]}),h=String(o),u=(r=c.files)==null?void 0:r.find(g=>String(g.source_file_id)===h),f=(u==null?void 0:u.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:d}}const ab=new Set(["xlsx","pdf","docx","pptx"]),XC=new Set(["json","jsonl","ndjson","csv","tsv","xlsx"]),qC=new Set(["txt","md","markdown","pdf","docx","pptx","json","jsonl","ndjson"]),YC=new Set(["doc","xls","ppt"]),KC=200*1024*1024,ob=20,QC=500*1024*1024;function JC(d,t,e){var a;if(d.size>KC)return{valid:!1,severity:"warning",message:"单文件不能超过 200MB"};const s=((a=d.name.split(".").pop())==null?void 0:a.toLowerCase())??"";return YC.has(s)?{valid:!1,severity:"error",message:"旧版 DOC、XLS、PPT 文件暂不支持,请分别转换为 DOCX、XLSX、PPTX 后上传"}:(t==="unstructured"?qC:XC).has(s)?e.some(o=>o.name===d.name&&o.size===d.size)?{valid:!1,severity:"warning",message:"同名且同大小的文件已经选择"}:e.length>=ob?{valid:!1,severity:"warning",message:`每个任务最多选择 ${ob} 个文件`}:e.reduce((o,l)=>o+l.size,0)+d.size>QC?{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 hv(d,t=""){return{uid:String(d.id),sourceFileId:String(d.id),name:d.name,size:d.size_bytes,count:d.record_count,content:t,fileFormat:d.file_format,checksumSha256:d.checksum_sha256,status:"ready",uploadProgress:100,previewStatus:"waiting",previewProgress:0}}function ZC(d){var s;const t=(s=d==null?void 0:d.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:d instanceof Error&&d.message?d.message:"上传失败,请删除该文件后重新选择"}function t_(d){const t=et(!1),e=[];let s=null;async function i(o){const l=d.uploadedFiles.value.find(h=>String(h.uid)===o.uid);if(!l)return;const c=d.taskId.value;if(!c){l.status="failed",l.uploadError="任务尚未创建,请返回模型选择步骤后重试";return}l.status="uploading",l.uploadProgress=0,l.uploadError=void 0;try{let h="";if(!ab.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 qw(c,[o.file],g=>{l.uploadProgress=g})).files[0];if(!f)throw new Error("后端未返回源文件记录");if(Object.assign(l,hv(f),{rawFile:o.file,status:"uploading",uploadProgress:99}),ab.has(o.extension))try{const g=await Qm(c,f.id,{start_line:1,line_count:1e4});l.content=g.content}catch{}else l.content=h;l.status="ready",l.uploadProgress=100,d.onUploaded(l)}catch(h){l.status="failed",l.uploadError=ZC(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}}async function e_(d,t){const e=[];let s=1;for(;;){const i=await Qm(d,t,{start_line:s,line_count:1e4});if(e.push(i.content||""),!i.has_more)break;const r=Number(i.end_line||s)+1;if(r<=s)break;s=r}return e.join("")}async function s_(d,t){const e=await Jf(d,{page:1,page_size:500}),s=[...e.items],i=Math.ceil(e.total/e.page_size);for(let r=2;r<=i;r+=1){const a=await Jf(d,{page:r,page_size:500});s.push(...a.items)}return s.map(t)}function i_(d){const t=Tw(),e=rt(()=>t.name==="data-process-regenerate"?String(t.params.id||""):""),s=rt(()=>!!e.value),i=et(null),r=et(""),a=et(!1),o=et(""),l=et(""),c=et(!1),h=et("");async function u(v,w){var _,E;const S=String(v.id);d.uploadedFiles.value=await Promise.all((v.source_files||[]).map(async k=>hv(k,await e_(S,k.id)))),d.previewItems.value=w?await s_(S,d.mapPreviewItem):[];const x=d.buildPreviewConfigSignature(),A=new Map;for(const k of d.previewItems.value)A.set(k.sourceFileId,(A.get(k.sourceFileId)||0)+1);for(const k of d.uploadedFiles.value){const P=A.get(String(k.sourceFileId))||0;k.previewCount=P,k.previewStatus=w&&P>0?"success":"waiting",k.previewProgress=w&&P>0?100:0,k.previewConfigSignature=w&&P>0?x:void 0}d.selectedPreviewFileId.value=String(((_=d.uploadedFiles.value[0])==null?void 0:_.uid)??"")||null,d.selectedPreviewId.value=d.selectedPreviewFileId.value?((E=d.previewItems.value.find(k=>k.sourceFileId===d.selectedPreviewFileId.value))==null?void 0:E.id)??null:null,d.selectedPreviewIdsByFile.value=d.selectedPreviewFileId.value&&d.selectedPreviewId.value?{[d.selectedPreviewFileId.value]:d.selectedPreviewId.value}:{},d.previewSignature.value=w&&d.previewItems.value.length?d.buildPreviewSignature():"",d.resetDownstream()}async function f(){if(e.value){c.value=!0,h.value="";try{const v=await ng(e.value),w=v.process_type;i.value=w,r.value=v.updated_at,d.task.name=v.name,d.task.description=v.description||"",d.processType.value=w;const S=v.config||{};d.structuredOptions.value=HC(S),d.unstructuredOptions.value=zC(S),o.value=d.buildPreviewConfigSignature(),l.value="",await u(v,!0),await Kh(),d.dirty.value=!1}catch(v){h.value=v instanceof Error?v.message:"原数据处理任务加载失败,请返回详情页后重试"}finally{c.value=!1}}}async function g(v){if(!s.value||!d.previewItems.value.length)return!0;const w=d.buildPreviewConfigSignature();if(!(w!==o.value)||w===l.value)return!0;const x=await v({title:"确认修改切分配置?",message:"修改预处理或切分配置将删除现有切片和生成结果;已发布三数据集暂时保留,直到重新发布后才会更新。",confirmText:"确认并继续",cancelText:"返回检查",tone:"warning"});return x&&(l.value=w),!!x}async function y(v){if(a.value){const S=await ng(e.value);r.value=S.updated_at||r.value}const w=await Yw(e.value,{...v,expected_updated_at:r.value});r.value=w.task.updated_at||r.value,o.value=d.buildPreviewConfigSignature(),l.value="",a.value=!0,d.dirty.value=!0;try{const S=w.task.source_files?w.task:await ng(w.task.id);r.value=S.updated_at||r.value,c.value=!0;try{await u(S,!w.preview_invalidated)}finally{c.value=!1}}catch(S){throw h.value=S instanceof Error?`任务已进入重新生成状态,但工作区恢复失败:${S.message}`:"任务已进入重新生成状态,但工作区恢复失败,请重试加载原任务",S}return w}return{sourceTaskId:e,isRegeneration:s,originalProcessType:i,originalTaskUpdatedAt:r,regenerationPrepared:a,hydrating:c,initializationError:h,hydrateWorkspace:u,loadSource:f,confirmPreviewConfigChange:g,prepareRegeneration:y}}const n_={class:"create-wizard-layout"},r_={class:"wizard-main"},a_={class:"wizard-main-inner"},o_={class:"wizard-steps-container"},l_={class:"custom-wizard-steps"},c_=["aria-current"],h_={class:"step-node"},d_={class:"step-icon"},u_={key:0,class:"fa fa-check"},f_={key:1},p_={class:"step-text"},g_={class:"step-title"},m_={class:"wizard-content"},v_={key:0,class:"initialization-error",role:"alert"},b_={class:"wizard-footer"},y_={class:"footer-left"},w_={class:"footer-right"},A_="backend-pipeline-v4",S_=Ci({__name:"DataProcessCreateView",setup(d){const t=Fw(),e=nA(),{list:s,loaded:i}=Pw(e),r=rt(()=>s.value),a=et(),o=et(),l=et(),c=[{id:"create",title:"创建任务",desc:"填写任务信息与处理配置"},{id:"model",title:"大模型选择",desc:"选择生成模型并设置输出要求"},{id:"upload",title:"上传文件",desc:"上传或接入待处理的源数据"},{id:"preview",title:"数据预览",desc:"核对源文件与预览内容"},{id:"generate",title:"开始生成",desc:"确认摘要并启动处理"},{id:"results",title:"结果编辑与保存",desc:"检查、修改并保存结果"}],h=et(0),u=rt(()=>{var F;return((F=c[h.value])==null?void 0:F.id)??"create"}),f=pg({name:"",description:""}),g=et(null),y=et("structured"),v=et(W0()),w=et(X0()),S=rt(()=>y.value==="unstructured"?w.value:v.value),x=et([]),A=et(!1),{buildPreviewsByFile:_}=WC(),E=pg({type:"postgresql",url:"",authMode:"none",username:"",password:"",limit:1e3,query:"",fileName:"external-data.jsonl"}),k=et(!1),P=et(!1),L=rt(()=>x.value.map(F=>F.name).join(", ")),I=et(""),D=et([]),R=et(null),W=et(null),Q=et({}),Y=et(!1),yt=et(!1);let T=!1;const{generation:j,results:Ft,selectedResultId:St,persistResultChanges:ke,resetDownstream:_t,restoreResult:Gt,startGeneration:z,stopGeneration:U,stopGenerationTimer:dt,updateResultField:lt,validateResults:nt}=jC({taskId:g,dirty:Y,beforeGenerate:fw}),{enqueueSourceUpload:qt,sourceUploading:pe}=t_({taskId:g,uploadedFiles:x,onUploaded(F){I.value="",_t(),Y.value=!0,gt.success(`文件 ${F.name} 上传成功,等待切分`)}}),Ms=rt(()=>x.value.some(F=>F.status!=="ready"||!F.sourceFileId)),qi=rt(()=>D.value.filter(F=>F.status!=="original").length),Ke=rt(()=>{const F=new Map;for(const N of D.value){const it=F.get(N.sourceFileId)||[];it.push(N),F.set(N.sourceFileId,it)}return F}),ki=rt(()=>x.value.find(F=>String(F.uid)===R.value)),Ti=rt(()=>Ke.value.get(R.value||"")||[]),Is=rt(()=>{var F;return((F=ki.value)==null?void 0:F.content)??""}),Ne=rt(()=>x.value.map(F=>{const N=Ke.value.get(String(F.uid))||[];return{id:String(F.uid),name:F.name,count:N.length,modifiedCount:N.filter(it=>it.status!=="original").length}})),Ds=rt(()=>u.value==="create"?"继续:选择大模型":u.value==="model"?"继续:上传文件":u.value==="upload"?pe.value?"正在上传":A.value?"正在切分":"继续:数据预览":u.value==="preview"?"确认预览并继续":u.value==="results"?"保存任务":j.status==="running"?"正在生成":j.status==="success"?"查看生成结果":j.status==="failed"?"重新生成":"开始生成"),Ku=rt(()=>u.value==="results"?"fa-check":u.value==="generate"&&j.status!=="success"?"fa-play":"fa-arrow-right"),Ma=rt(()=>h.value>0?c[h.value-1].title:"");function Pi(F){const N=c.findIndex(it=>it.id===F);N>=0&&(h.value=N)}function vh(F){if(y.value==="unstructured"){w.value={...w.value,...F};return}v.value={...v.value,...F}}function Qu(){const F=y.value==="unstructured"?w.value:v.value,N={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 y.value==="unstructured"?{...N,chunk_method:w.value.chunkMethod,chunk_size:w.value.chunkSize,chunk_overlap:w.value.chunkOverlap,min_chunk_size:w.value.minChunkSize,semantic_breakpoint_percentile:w.value.semanticBreakpointPercentile,preserve_tables:w.value.preserveTables,preserve_code_blocks:w.value.preserveCodeBlocks,preserve_lists:w.value.preserveLists,qa_pairs_per_chunk:w.value.qaPairsPerChunk}:{...N,qa_pairs_per_row:v.value.qaPairsPerRow}}function Ia(){return{name:f.name.trim(),description:f.description.trim(),process_type:Zu.value||y.value,config:Qu()}}function yv(){var F;return{type:"postgresql",url:E.url.trim(),auth_mode:E.authMode,username:E.username||void 0,password:E.password||void 0,limit:E.limit,query:((F=E.query)==null?void 0:F.trim())||void 0,file_name:E.fileName||"external-data.jsonl"}}function Ju(F){var N;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,sourcePages:Array.isArray((N=F.quality_score)==null?void 0:N.source_pages)?F.quality_score.source_pages.filter(it=>typeof it=="number"):[],updatedAt:F.updated_at}}function K0(){return VC(y.value,v.value,w.value)}function Q0(){return GC(y.value,v.value,w.value)}const J0=rt(()=>JSON.stringify(Q0()));function Jp(){return`${A_}:${y.value}:${JSON.stringify(K0())}`}function wv(){const F=x.value.map(N=>`${N.uid}:${N.name}:${N.size}:${N.checksumSha256||N.count}`).join("|");return`${Jp()}:${F}`}const{isRegeneration:bh,originalProcessType:Zu,regenerationPrepared:Av,hydrating:Ml,initializationError:Zp,loadSource:Sv,confirmPreviewConfigChange:Z0,prepareRegeneration:tw}=i_({task:f,processType:y,structuredOptions:v,unstructuredOptions:w,uploadedFiles:x,previewItems:D,selectedPreviewFileId:R,selectedPreviewId:W,selectedPreviewIdsByFile:Q,previewSignature:I,dirty:Y,buildPreviewConfigSignature:Jp,buildPreviewSignature:wv,mapPreviewItem:Ju,resetDownstream:_t}),xv=rt(()=>Av.value?"仍有尚未完成的本地操作;已提交到服务端的修改不会因离开页面而撤销。":"当前存在未保存修改,离开后这些修改将不会保留。"),Ev=rt(()=>Av.value?"离开页面":"放弃修改");Si([()=>f.name,()=>f.description,y,v,w,E],()=>{Ml.value||(Y.value=!0)},{deep:!0}),Si(y,(F,N)=>{if(!Ml.value){if(bh.value&&Zu.value&&F!==Zu.value){y.value=Zu.value;return}F===N||x.value.length===0||(ow(),gt.info("处理类型已变更,请重新上传或拉取匹配的源数据"))}}),Si(J0,(F,N)=>{Ml.value||F!==N&&_t()});function ew(){var F;(F=document.querySelector(".layout-content"))==null||F.scrollTo({top:0,behavior:"smooth"})}Si(h,()=>Kh(ew));function Cv(F){const N=F.raw;if(!N)return;if(!g.value){gt.error("任务尚未创建,请返回模型选择步骤后重试");return}const it=JC(N,y.value,x.value);if(!it.valid){gt[it.severity](it.message);return}const jt=`local-${F.uid}-${Date.now()}-${x.value.length}`;x.value.push({uid:jt,rawFile:N,name:N.name,size:N.size,count:0,content:"",fileFormat:it.extension,status:"queued",uploadProgress:0,previewStatus:"waiting",previewProgress:0}),Y.value=!0,qt({uid:jt,file:N,extension:it.extension})}async function sw(){if(!g.value){gt.error("任务尚未创建,请返回模型选择步骤后重试");return}const F=new File([TE],"finance_qa.jsonl",{type:"application/x-ndjson"});Cv({raw:F,uid:Date.now(),name:F.name})}function iw(F){Object.assign(E,F),P.value=!1}async function nw(){if(!g.value){gt.error("任务尚未创建,请返回模型选择步骤后重试");return}if(!E.url.trim()){gt.warning("请先填写数据源地址");return}k.value=!0;try{const F=await Zw(g.value,yv());P.value=F.connected,F.connected?gt.success(F.message||"数据源连接测试成功"):gt.warning(F.message||"数据源连接失败")}catch{P.value=!1}finally{k.value=!1}}async function rw(){var F;if(!g.value){gt.error("任务尚未创建,请返回模型选择步骤后重试");return}if(!E.url.trim()){gt.warning("请先填写数据源地址");return}if(!((F=E.query)!=null&&F.trim())){gt.warning("请先填写只读 SELECT 查询语句");return}k.value=!0;try{const N=await tA(g.value,yv()),it=[];for(const jt of N.files){const oe=await Qm(g.value,jt.id,{start_line:1,line_count:5e3});it.push(hv(jt,oe.content))}x.value.push(...it),P.value=!0,I.value="",_t(),Y.value=!0,gt.success(`已成功登记 ${it.length} 个外部源文件`)}catch{P.value=!1}finally{k.value=!1}}async function aw(F){const N=x.value.findIndex(jt=>jt.uid===F);if(N<0||!g.value)return;const it=x.value[N];if(it){if(it.status==="uploading"){gt.warning("当前文件正在上传,请等待上传结束后再删除");return}if(it.sourceFileId)try{await eA(g.value,it.sourceFileId)}catch{return}x.value.splice(N,1),I.value="",D.value=[],W.value=null,_t(),Y.value=!0}}function ow(){x.value=[],I.value="",D.value=[],R.value=null,W.value=null,Q.value={},P.value=!1,_t()}async function lw(){var it;!await((it=a.value)==null?void 0:it.validate())||!await Z0(jt=>{var oe;return((oe=l.value)==null?void 0:oe.open(jt))??Promise.resolve(!1)})||Pi("model")}async function cw(){var F;if(!yt.value){yt.value=!0;try{if(await e.load(!0),!i.value){gt.error("模型列表加载失败,未提交任何修改,请稍后重试");return}const N=S.value.generationModelId,it=r.value.some(oe=>String(oe.id)===String(N));if(N!==""&&!it){gt.error(bh.value?"原任务使用的模型已删除,请重新选择模型":"所选模型已删除,请重新选择");return}if(!await((F=o.value)==null?void 0:F.validate()))return;if(bh.value){const oe=await tw(Ia());g.value=String(oe.task.id),oe.preview_invalidated?gt.info("切分配置已变化,现有源文件将在下一步按新配置重新切分"):oe.published_outputs_preserved&>.info("已保留原切片;已发布的三个数据集将在重新发布前保持不变")}else{const oe=g.value?await Qw(g.value,Ia()):await Jw(Ia());g.value=String(oe.id)}Y.value=!0,Pi("upload")}catch{}finally{yt.value=!1}}}async function hw(){var oe,Da;if(A.value||pe.value)return;if(!g.value){gt.error("任务尚未创建,请返回模型选择步骤后重试");return}if(x.value.length===0){gt.warning(y.value==="external"?"请先拉取至少一个数据源":"请上传至少一个源数据文件");return}const F=x.value.filter(as=>as.status==="failed");if(F.length){gt.warning(`${F.length} 个文件上传失败,请删除后重新选择`);return}if(Ms.value){gt.warning("请等待所有文件上传完成后再开始切分");return}const N=wv(),it=Jp(),jt=()=>x.value.every(as=>as.previewStatus==="success"&&as.previewConfigSignature===it);if(N===I.value&&D.value.length&&jt()){Pi("preview");return}for(const as of x.value)as.previewConfigSignature!==it&&(as.previewStatus="waiting",as.previewProgress=0,as.previewError=void 0,as.previewCount=void 0);A.value=!0;try{const as=x.value.filter(At=>At.previewStatus!=="success"||At.previewConfigSignature!==it).map(At=>At.sourceFileId).filter(At=>!!At);await _(g.value,as,At=>{const Be=x.value.find(tg=>String(tg.sourceFileId)===String(At.source_file_id));Be&&(Be.previewStatus=At.status,Be.previewProgress=At.progress,Be.previewCount=At.preview_count,Be.previewError=At.error,At.status==="success"&&(Be.previewConfigSignature=it))});const yh=x.value.filter(At=>At.previewStatus==="failed").length;if(yh||!jt()){gt.warning(`${yh||1} 个文件切分失败;修正问题后点击“继续:数据预览”即可重试`);return}try{const At=await Jf(g.value,{page:1,page_size:500}),Be=[...At.items],tg=Math.ceil(At.total/At.page_size);for(let eg=2;eg<=tg;eg+=1){const Aw=await Jf(g.value,{page:eg,page_size:500});Be.push(...Aw.items)}D.value=Be.map(Ju)}catch{gt.warning("文件切分已经完成,但预览加载失败;请再次点击继续重试加载");return}if(!D.value.length){gt.warning("源文件没有生成可用的预览条目,请检查文件内容和预处理配置");return}R.value=String(((oe=x.value[0])==null?void 0:oe.uid)??"")||null,W.value=((Da=Ti.value[0])==null?void 0:Da.id)??null,Q.value=W.value&&R.value?{[R.value]:W.value}:{},I.value=N,_t(),Pi("preview")}finally{A.value=!1}}function dw(F){var N;R.value&&W.value&&(Q.value[R.value]=W.value),R.value=F,W.value=Q.value[F]||((N=Ti.value[0])==null?void 0:N.id)||null}function _v(F){W.value=F,R.value&&(Q.value[R.value]=F)}function uw(F,N){const it=D.value.find(jt=>jt.id===F);it&&(it.editedContent=N,it.tokenCount=nb(N),it.status=N===it.originalContent?"original":it.sourceStart==null?"manual":"modified",_t(),Y.value=!0)}async function fw(){if(!g.value)throw new Error("任务尚未创建");const F=D.value.filter(N=>N.status==="modified"||N.status==="manual");for(const N of F){const it=await Kw(g.value,N.id,{edited_content:N.editedContent,expected_updated_at:N.updatedAt}),jt=D.value.findIndex(oe=>oe.id===N.id);jt>=0&&(D.value[jt]=Ju(it))}}function pw(F){const N=D.value.find(it=>it.id===F);!N||N.sourceStart==null||(N.editedContent=N.originalContent,N.tokenCount=nb(N.originalContent),N.status="original",_t(),Y.value=!0)}async function gw(){if(!(!R.value||!g.value))try{const F=await sA(g.value,{source_file_id:R.value,edited_content:""}),N=Ju(F);D.value.push(N),_v(N.id),_t(),Y.value=!0}catch{}}async function mw(F){var jt,oe;if(!await((jt=l.value)==null?void 0:jt.open({title:"删除预览内容?",message:"删除只影响本次处理,不会修改源文件。删除后可重新从源文件生成预览。",confirmText:"删除",cancelText:"取消",tone:"danger"})))return;const it=D.value.findIndex(Da=>Da.id===F);if(!(it<0)&&g.value){try{await iA(g.value,F)}catch{return}D.value.splice(it,1),W.value=((oe=Ti.value[Math.min(it,Ti.value.length-1)])==null?void 0:oe.id)??null,R.value&&W.value&&(Q.value[R.value]=W.value),_t(),Y.value=!0}}async function vw(){if(u.value==="create"){await lw();return}if(u.value==="model"){await cw();return}if(u.value==="upload"){await hw();return}if(u.value==="preview"){if(!D.value.length){gt.warning("当前没有可生成的预览内容");return}Pi("generate");return}if(u.value==="generate"){j.status==="success"?Pi("results"):j.status!=="running"&&await z();return}await yw()}function bw(){if(pe.value){gt.warning("请等待当前文件上传完成");return}if(A.value){gt.warning("请等待当前文件切分完成");return}if(j.status==="running"){gt.warning("请先停止当前生成任务");return}h.value>0&&(h.value-=1)}async function yw(){if(!nt()){gt.warning("请先修正校验失败的结果");return}try{await ke()}catch{return}if(!nt()){gt.warning("仍有结果未通过后端质量校验,请继续修正");return}Y.value=!1,T=!0,gt.success("数据处理任务已保存"),await t.push("/data-process")}async function ww(){var N;if(!Y.value){T=!0,t.back();return}await((N=l.value)==null?void 0:N.open({title:"确认离开当前页面?",message:xv.value,confirmText:Ev.value,cancelText:"继续编辑",tone:"danger"}))&&(T=!0,t.back())}return Mw(async()=>{var N;if(pe.value)return gt.warning("请等待当前文件上传完成后再离开页面"),!1;if(T||!Y.value)return!0;const F=await((N=l.value)==null?void 0:N.open({title:"确认离开当前页面?",message:xv.value,confirmText:Ev.value,cancelText:"继续编辑",tone:"danger"}));return F&&(T=!0),!!F}),cb(()=>{dt()}),Iw(()=>{localStorage.removeItem("yg-data-process-create-draft"),e.load(!0),bh.value&&Sv()}),(F,N)=>{var Da,as,yh;const it=Ew,jt=zu,oe=Cw;return O(),$(Ae,null,[C("div",n_,[C("main",r_,[C("div",a_,[C("div",o_,[C("div",l_,[(O(),$(Ae,null,ii(c,(At,Be)=>(O(),$(Ae,{key:At.id},[Be!==0?(O(),$("div",{key:0,class:Se(["step-connector",{"is-active":h.value>=Be}])},null,2)):ft("",!0),C("div",{class:Se(["step-item",{"is-active":h.value===Be,"is-completed":h.value>Be}]),"aria-current":h.value===Be?"step":void 0},[C("div",h_,[C("div",d_,[h.value>Be?(O(),$("i",u_)):(O(),$("span",f_,X(Be+1),1))]),C("div",p_,[C("div",g_,X(At.title),1)])])],10,c_)],64))),64))])]),Dw((O(),$("div",m_,[Jt(Zp)?(O(),$("div",v_,[H(it,{type:"error",closable:!1,title:Jt(Zp),"show-icon":""},null,8,["title"]),H(jt,{type:"primary",loading:Jt(Ml),onClick:Jt(Sv)},{default:J(()=>[...N[6]||(N[6]=[ut("重试加载原任务",-1)])]),_:1},8,["loading","onClick"])])):u.value==="create"?(O(),Ut(AS,{key:1,ref_key:"taskSetupRef",ref:a,name:f.name,"onUpdate:name":N[0]||(N[0]=At=>f.name=At),description:f.description,"onUpdate:description":N[1]||(N[1]=At=>f.description=At),"process-type":y.value,"onUpdate:processType":N[2]||(N[2]=At=>y.value=At),"structured-options":v.value,"onUpdate:structuredOptions":N[3]||(N[3]=At=>v.value=At),"unstructured-options":w.value,"onUpdate:unstructuredOptions":N[4]||(N[4]=At=>w.value=At),"process-type-locked":Jt(bh)},null,8,["name","description","process-type","structured-options","unstructured-options","process-type-locked"])):u.value==="model"?(O(),Ut(_S,{key:2,ref_key:"modelSelectionRef",ref:o,options:S.value,models:r.value,"onUpdate:options":vh},null,8,["options","models"])):u.value==="upload"?(O(),Ut(s1,{key:3,"process-type":y.value,"uploaded-files":x.value,"external-source":E,"external-pulling":k.value,"external-connected":P.value,"preview-building":A.value,"source-uploading":Jt(pe),"onUpdate:externalSource":iw,onFileChange:Cv,onRemoveFile:aw,onUseSample:sw,onTestConnection:nw,onPullData:rw},null,8,["process-type","uploaded-files","external-source","external-pulling","external-connected","preview-building","source-uploading"])):u.value==="preview"?(O(),Ut(iC,{key:4,"selected-id":W.value,"selected-file-id":R.value,"source-text":Is.value,items:Ti.value,"process-type":y.value,"file-name":((Da=ki.value)==null?void 0:Da.name)??"","task-id":g.value,"source-file-id":((as=ki.value)==null?void 0:as.sourceFileId)??((yh=ki.value)==null?void 0:yh.uid)??null,files:Ne.value,"onUpdate:selectedId":_v,"onUpdate:selectedFileId":dw,"onUpdate:itemContent":uw,"onRestore:item":pw,"onAdd:item":gw,"onRemove:item":mw},null,8,["selected-id","selected-file-id","source-text","items","process-type","file-name","task-id","source-file-id","files"])):u.value==="generate"?(O(),Ut(fC,{key:5,"task-name":f.name,"process-type":y.value,"file-name":L.value,"preview-count":D.value.length,"modified-count":qi.value,generation:Jt(j),onStop:Jt(U),onRetry:Jt(z)},null,8,["task-name","process-type","file-name","preview-count","modified-count","generation","onStop","onRetry"])):u.value==="results"?(O(),Ut(UC,{key:6,"selected-id":Jt(St),"onUpdate:selectedId":N[5]||(N[5]=At=>Lw(St)?St.value=At:null),items:Jt(Ft),"preview-items":D.value,"onUpdate:field":Jt(lt),"onRestore:item":Jt(Gt)},null,8,["selected-id","items","preview-items","onUpdate:field","onRestore:item"])):ft("",!0)])),[[oe,Jt(Ml)]])])]),C("footer",b_,[C("div",y_,[h.value>0?(O(),Ut(jt,{key:0,disabled:A.value||Jt(pe),onClick:bw},{default:J(()=>[N[7]||(N[7]=C("i",{class:"fa fa-arrow-left",style:{"margin-right":"6px"}},null,-1)),ut(" 返回:"+X(Ma.value),1)]),_:1},8,["disabled"])):(O(),Ut(jt,{key:1,onClick:ww},{default:J(()=>[...N[8]||(N[8]=[ut("取消",-1)])]),_:1}))]),N[9]||(N[9]=C("div",{class:"footer-center"},null,-1)),C("div",w_,[H(jt,{class:"wizard-primary-action",type:"primary",loading:yt.value||Jt(j).status==="running"||u.value==="upload"&&(Jt(pe)||A.value),disabled:Jt(Ml)||yt.value||!!Jt(Zp)||u.value==="generate"&&Jt(j).status==="running"||A.value||Jt(pe)||u.value==="upload"&&Ms.value,onClick:vw},{default:J(()=>[ut(X(Ds.value)+" ",1),C("i",{class:Se(["fa",Ku.value]),style:{"margin-left":"6px"}},null,2)]),_:1},8,["loading","disabled"])])])]),H(Ow,{ref_key:"confirmDialogRef",ref:l},null,512)],64)}}}),hk=_i(S_,[["__scopeId","data-v-1b6a4890"]]);export{hk as default};