var ew=Object.defineProperty;var lv=u=>{throw TypeError(u)};var sw=(u,t,e)=>t in u?ew(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e;var P=(u,t,e)=>sw(u,typeof t!="symbol"?t+"":t,e),Wp=(u,t,e)=>t.has(u)||lv("Cannot "+e);var n=(u,t,e)=>(Wp(u,t,"read from private field"),e?e.call(u):t.get(u)),m=(u,t,e)=>t.has(u)?lv("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(u):t.set(u,e),p=(u,t,e,s)=>(Wp(u,t,"write to private field"),s?s.call(u,e):t.set(u,e),e),v=(u,t,e)=>(Wp(u,t,"access private method"),e);var Yt=(u,t,e,s)=>({set _(i){p(u,t,i,e)},get _(){return n(u,t,s)}});import{E as Uu}from"./index-CX3tRQGA.js";import{d as ki,o as R,c as U,q as C,s as z,n as we,aa as j,g as ut,j as ct,x as pt,w as et,M as ye,ad as ri,e as $t,A as wt,y as rt,D as Ei,H as jv,al as iw,aQ as nw,P as Wf,t as cv,aL as Xp,z as ig,ag as rw,aR as aw,G as ow,f as Fs,aB as lw,v as cw}from"./index-DlMMG01R.js";import{A as hw}from"./AppConfirmDialog-Ag_JS7dx.js";import{E as Wv,a as Xv}from"./el-form-item-CVKPsKks.js";import{E as Hu}from"./index-BXTVgd_U.js";import{a as qv,E as Pp}from"./el-checkbox-DqqwEdQC.js";import{E as zu}from"./el-input-number-fKfc92sH.js";/* empty css */import{_ as Ti}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{E as Mp,a as Ip}from"./el-select-6-rWjby5.js";import{E as dw}from"./el-slider-leM7mLgE.js";import{E as uw}from"./el-switch-Bel7xDMu.js";import"./el-popper-IyKEajFX.js";import"./el-tooltip-l0sNRNKZ.js";import"./el-scrollbar-Dy4DbV8r.js";import{E as fw}from"./el-tag-cURousI6.js";import{E as Yv}from"./el-pagination-B6r319__.js";import{E as Kv}from"./el-progress-B4MdLj_6.js";import{E as pw}from"./el-upload-CEarUIfs.js";import{a as gw,b as mw,s as vw,c as bw,r as yw,u as ww,e as Aw,f as hv,h as Sw,i as xw,j as Qv,k as Ew,l as Cw,m as _w,n as dv,t as kw,p as Tw,o as Pw,q as Mw,v as Iw}from"./dataProcess-q-9-DTcz.js";import{u as Dw}from"./models-DEAVH-M_.js";import"./castArray-7zADuvev.js";import"./_baseClone-ByfTJ6fR.js";import"./raf-BkRpj8vQ.js";import"./index-bqLfwDNC.js";import"./index-BF7OFqWH.js";import"./omit-czPmuCG1.js";import"./index-CicPf2dR.js";import"./index-4_3fwCBX.js";import"./vnode-FlZU1NdB.js";import"./index-5whHmOUP.js";import"./scroll-DrJeZ2h7.js";import"./clamp-BOWtGcsb.js";import"./toNumber-EgQ2Nr-7.js";import"./_baseIteratee-BeRmRUkG.js";import"./debounce-Bbj-pL2w.js";import"./validator-DiWsXPEi.js";import"./model-h5x6LplB.js";const Lw={class:"generation-option-row dataset-split-row"},Fw={class:"dataset-split-config"},Rw={class:"dataset-split-grid"},Ow={class:"dataset-split-field"},Nw={class:"dataset-split-input"},Bw={class:"dataset-split-field"},$w={class:"dataset-split-input"},Uw={class:"dataset-split-field"},Hw={class:"dataset-split-input"},zw={key:0,role:"alert"},Vw=ki({__name:"DatasetSplitEditor",props:{modelValue:{},ariaLabelPrefix:{default:""}},emits:["update:modelValue"],setup(u,{emit:t}){const e=u,s=t,i=ct(()=>{const{train:o,validation:l,test:c}=e.modelValue;return o+l+c});function r(o,l){s("update:modelValue",{...e.modelValue,[o]:Math.min(100,Math.max(0,Number(l)||0))})}function a(o){return`${e.ariaLabelPrefix}${o}比例`}return(o,l)=>{const c=zu;return R(),U("div",Lw,[l[9]||(l[9]=C("div",{class:"generation-option-copy"},[C("strong",null,"数据集划分"),C("small",null,"按比例将生成后的问答对随机划分为训练集、验证集和测试集")],-1)),C("div",Fw,[C("div",Rw,[C("label",Ow,[l[4]||(l[4]=C("span",null,"训练集",-1)),C("span",Nw,[z(c,{"model-value":u.modelValue.train,min:0,max:100,step:1,precision:0,"controls-position":"right","aria-label":a("训练集"),"onUpdate:modelValue":l[0]||(l[0]=h=>r("train",h))},null,8,["model-value","aria-label"]),l[3]||(l[3]=C("span",null,"%",-1))])]),C("label",Bw,[l[6]||(l[6]=C("span",null,"验证集",-1)),C("span",$w,[z(c,{"model-value":u.modelValue.validation,min:0,max:100,step:1,precision:0,"controls-position":"right","aria-label":a("验证集"),"onUpdate:modelValue":l[1]||(l[1]=h=>r("validation",h))},null,8,["model-value","aria-label"]),l[5]||(l[5]=C("span",null,"%",-1))])]),C("label",Uw,[l[8]||(l[8]=C("span",null,"测试集",-1)),C("span",Hw,[z(c,{"model-value":u.modelValue.test,min:0,max:100,step:1,precision:0,"controls-position":"right","aria-label":a("测试集"),"onUpdate:modelValue":l[2]||(l[2]=h=>r("test",h))},null,8,["model-value","aria-label"]),l[7]||(l[7]=C("span",null,"%",-1))])])]),C("div",{class:we(["dataset-split-summary",{"is-invalid":i.value!==100}])},[C("span",null,"总计 "+j(i.value)+"%",1),i.value!==100?(R(),U("span",zw," 训练集、验证集和测试集比例总和必须为 100% ")):ut("",!0)],2)])])}}}),Jv=Ti(Vw,[["__scopeId","data-v-f479d5fe"]]),Gw={key:0,class:"generation-config-group model-config-group"},jw={class:"model-field"},Ww={class:"model-option"},Xw={class:"model-field"},qw={class:"advanced-settings-grid"},Yw={class:"config-field"},Kw={class:"config-field"},Qw={class:"unit-input"},Jw={class:"json-mode-row"},Zw={key:0,class:"generation-validation-message",role:"alert"},tA={key:1,class:"generation-config-group quality-config-group"},eA={class:"quality-switch-row"},sA={key:0,class:"quality-rule-panel"},iA={key:0,class:"minimum-length-field"},nA={class:"minimum-length-input"},rA={key:1,class:"quality-rule-warning",role:"alert"},aA={key:1,class:"generation-validation-message",role:"alert"},oA=ki({__name:"GenerationOptionsPanel",props:{options:{},models:{},section:{},validationMessage:{}},emits:["update:options"],setup(u,{emit:t}){const e=u,s=t;function i(c,h){s("update:options",{...e.options,[c]:h})}function r(c){const h=c.filter(d=>typeof d=="string");s("update:options",{...e.options,filterLowQuality:h.includes("low_quality"),filterShortContent:h.includes("short_content")})}const a=()=>[e.options.filterLowQuality?"low_quality":"",e.options.filterShortContent?"short_content":""].filter(Boolean);function o(){if(!e.validationMessage)return"";const c=e.validationMessage.includes("数据生成模型");return e.section==="model"?c?e.validationMessage:"":c?"":e.validationMessage}function l(c){const h=c.model_source==="api"||c.model_source==="online"?"在线模型":c.model_source==="local"?"本地模型":c.model_source||"模型管理";return c.type?`${h} · ${c.type}`:h}return(c,h)=>{const d=Ip,f=Mp,g=Hu,y=dw,b=zu,S=uw,w=Pp,E=qv;return u.section==="model"?(R(),U("div",Gw,[C("div",jw,[h[8]||(h[8]=C("div",{class:"field-copy"},[C("strong",null,[pt("数据生成模型 "),C("em",null,"*")]),C("small",null,"选择负责生成问答、指令或结构化内容的大模型")],-1)),z(f,{class:"model-select","model-value":u.options.generationModelId,filterable:"",placeholder:"请选择用于生成数据的模型","aria-label":"数据生成模型","onUpdate:modelValue":h[0]||(h[0]=A=>i("generationModelId",A))},{empty:et(()=>[...h[7]||(h[7]=[C("div",{class:"model-empty"},"暂无模型,请先在模型管理中添加",-1)])]),default:et(()=>[(R(!0),U(ye,null,ri(u.models||[],A=>(R(),$t(d,{key:A.id,label:A.name,value:A.id},{default:et(()=>[C("div",Ww,[C("span",null,j(A.name),1),C("small",null,j(l(A)),1)])]),_:2},1032,["label","value"]))),128))]),_:1},8,["model-value"])]),C("div",Xw,[h[9]||(h[9]=C("div",{class:"field-copy"},[C("strong",null,"默认提示语"),C("small",null,"用于约束生成内容的格式、语气和完整性,可按任务需要修改")],-1)),z(g,{class:"prompt-input","model-value":u.options.generationPrompt,type:"textarea",rows:4,maxlength:"500","show-word-limit":"",resize:"vertical",placeholder:"请输入模型生成内容时需要遵循的要求","aria-label":"模型默认提示语","onUpdate:modelValue":h[1]||(h[1]=A=>i("generationPrompt",A))},null,8,["model-value"]),h[10]||(h[10]=C("div",{class:"prompt-variables-hint"},[pt(" 提示:可在文本中通过 "),C("code",{textContent:"{{ content }}"}),pt(" 引用当前正在处理的数据内容。 ")],-1))]),C("div",qw,[C("label",Yw,[h[11]||(h[11]=C("span",{class:"config-field-label"},"生成温度 (Temperature)",-1)),z(y,{"model-value":u.options.temperature,min:0,max:1,step:.1,"show-input":"","onUpdate:modelValue":h[2]||(h[2]=A=>i("temperature",Number(A)||0))},null,8,["model-value"]),h[12]||(h[12]=C("small",null,"较低值输出更确定、保守,较高值输出更多样、有创造性",-1))]),C("label",Kw,[h[14]||(h[14]=C("span",{class:"config-field-label"},"最大输出长度 (Max Tokens)",-1)),C("span",Qw,[z(b,{"model-value":u.options.maxTokens,min:100,max:8192,step:256,"controls-position":"right","onUpdate:modelValue":h[3]||(h[3]=A=>i("maxTokens",Number(A)||1024))},null,8,["model-value"]),h[13]||(h[13]=C("span",null,"Token",-1))]),h[15]||(h[15]=C("small",null,"限制单次生成的最大内容长度,防止过度发散",-1))])]),C("div",Jw,[h[16]||(h[16]=C("div",{class:"field-copy"},[C("strong",null,"强制 JSON 格式输出"),C("small",null,"要求大模型返回纯 JSON 对象,有助于提高下游结构化提取的稳定性")],-1)),z(S,{"model-value":u.options.jsonMode,"inline-prompt":"","active-text":"开","inactive-text":"关","onUpdate:modelValue":h[4]||(h[4]=A=>i("jsonMode",!!A))},null,8,["model-value"])]),o()?(R(),U("p",Zw,j(o()),1)):ut("",!0)])):(R(),U("div",tA,[C("div",eA,[h[17]||(h[17]=C("div",{class:"config-group-heading"},[C("div",null,[C("h4",null,"质量筛选"),C("p",null,"生成后自动过滤不符合要求的内容,不影响源数据预处理")])],-1)),z(S,{"model-value":u.options.qualityFilterEnabled,"inline-prompt":"","active-text":"开","inactive-text":"关","aria-label":"质量筛选","onUpdate:modelValue":h[5]||(h[5]=A=>i("qualityFilterEnabled",!!A))},null,8,["model-value"])]),u.options.qualityFilterEnabled?(R(),U("div",sA,[z(E,{"model-value":a(),class:"quality-rule-list","onUpdate:modelValue":r},{default:et(()=>[z(w,{value:"low_quality"},{default:et(()=>[...h[18]||(h[18]=[C("span",{class:"rule-copy"},[C("strong",null,"过滤低质量内容"),C("small",null,"按相关性、完整性和可读性过滤明显不合格的生成结果")],-1)])]),_:1}),z(w,{value:"short_content"},{default:et(()=>[...h[19]||(h[19]=[C("span",{class:"rule-copy"},[C("strong",null,"过滤过短内容"),C("small",null,"过滤正文长度低于指定字数的生成结果")],-1)])]),_:1})]),_:1},8,["model-value"]),u.options.filterShortContent?(R(),U("label",iA,[h[21]||(h[21]=C("span",null,"最少字数",-1)),C("span",nA,[z(b,{"model-value":u.options.minOutputLength,min:1,max:1e3,step:5,precision:0,"controls-position":"right","aria-label":"生成内容最少字数","onUpdate:modelValue":h[6]||(h[6]=A=>i("minOutputLength",Number(A)||1))},null,8,["model-value"]),h[20]||(h[20]=C("span",null,"字",-1))]),h[22]||(h[22]=C("small",null,"少于该字数的生成结果将被过滤",-1))])):ut("",!0),!u.options.filterLowQuality&&!u.options.filterShortContent?(R(),U("p",rA," 请至少选择一项质量筛选规则 ")):ut("",!0)])):ut("",!0),o()?(R(),U("p",aA,j(o()),1)):ut("",!0)]))}}}),Um=Ti(oA,[["__scopeId","data-v-e6fd162c"]]),lA={class:"form-section structured-options-section"},cA={class:"preprocess-option-copy"},hA={class:"form-section generation-options-section"},dA={class:"generation-option-list"},uA={class:"generation-option-row"},fA=ki({__name:"StructuredOptionsPanel",props:{options:{},validationAttempted:{type:Boolean},qualityValidationMessage:{}},emits:["update:options"],setup(u,{emit:t}){const e=u,s=t,i=[{value:"clean_invalid",label:"清理无效数据",description:"清理全空列,并剔除关键字段残缺的数据行"},{value:"detect_structure",label:"识别表格结构",description:"识别多级表头与合并单元格,并将嵌套字段展平"},{value:"deduplicate",label:"重复数据去重",description:"基于整行精确匹配和关键字段组合删除重复记录"},{value:"normalize_format",label:"数据格式标准化",description:"按所选规则统一编码、空白、字段名及 JSON 序列化格式"},{value:"filter_anomaly",label:"异常数据过滤",description:"使用 IQR 识别数值离群值,并过滤乱码等异常记录"},{value:"desensitize",label:"敏感信息脱敏",description:"识别并脱敏姓名、手机号、邮箱和身份证号"}];function r(l,c){s("update:options",{...e.options,[l]:c})}function a(l){s("update:options",{...e.options,...l})}function o(l){const c=new Set(i.map(d=>d.value)),h=Array.from(new Set(l.filter(d=>typeof d=="string"&&c.has(d))));r("preprocessOptions",h)}return(l,c)=>{const h=Pp,d=qv,f=zu;return R(),U(ye,null,[C("div",lA,[c[2]||(c[2]=C("div",{class:"section-title-row"},[C("div",null,[C("h3",null,"预处理选项"),C("p",null,"选择在生成问答对之前需要执行的数据处理方式")])],-1)),z(d,{"model-value":u.options.preprocessOptions,class:"preprocess-option-grid","onUpdate:modelValue":o},{default:et(()=>[(R(),U(ye,null,ri(i,g=>z(h,{key:g.value,value:g.value,class:"preprocess-option"},{default:et(()=>[C("span",cA,[C("strong",null,j(g.label),1),C("small",null,j(g.description),1)])]),_:2},1032,["value"])),64))]),_:1},8,["model-value"])]),C("div",hA,[c[4]||(c[4]=C("div",{class:"section-title-row"},[C("div",null,[C("h3",null,"生成选项"),C("p",null,"配置每条结构化记录生成问答对的方式和数量")])],-1)),C("div",dA,[z(Um,{options:u.options,section:"quality","validation-message":u.validationAttempted?u.qualityValidationMessage:"","onUpdate:options":a},null,8,["options","validation-message"]),C("div",uA,[c[3]||(c[3]=C("div",{class:"generation-option-copy"},[C("strong",null,"每行生成数量"),C("small",null,"每行结构化数据生成的问答对数量")],-1)),z(f,{"model-value":u.options.qaPairsPerRow,min:1,max:5,step:1,"controls-position":"right","onUpdate:modelValue":c[0]||(c[0]=g=>r("qaPairsPerRow",Number(g)||1))},null,8,["model-value"])]),z(Jv,{"model-value":u.options.datasetSplit,"onUpdate:modelValue":c[1]||(c[1]=g=>r("datasetSplit",g))},null,8,["model-value"])])])],64)}}}),pA=Ti(fA,[["__scopeId","data-v-c48db990"]]),gA={class:"form-section unstructured-options-section"},mA={class:"preprocess-option-grid"},vA={class:"form-section chunk-options-section"},bA={class:"chunk-settings-grid is-basic"},yA={class:"config-field"},wA={key:0},AA={key:1},SA={key:2},xA={class:"config-field"},EA={class:"unit-input"},CA={class:"config-field"},_A={class:"unit-input"},kA={class:"config-field"},TA={class:"unit-input"},PA={key:0,class:"config-field"},MA={class:"unit-input"},IA={key:0,class:"option-validation-message",role:"alert"},DA={class:"form-section generation-options-section"},LA={class:"generation-option-list"},FA={class:"generation-option-row"},RA=ki({__name:"UnstructuredOptionsPanel",props:{options:{},validationAttempted:{type:Boolean},qualityValidationMessage:{},chunkValidationMessage:{}},emits:["update:options"],setup(u,{expose:t,emit:e}){const s=u,i=e,r=["clean_invalid_content","detect_document_structure","merge_short_content","filter_low_quality","deduplicate_content","preserve_context"],a=[{value:"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:{min:1,max:3}},l=ct(()=>r.every(E=>s.options.preprocessOptions.includes(E))),c=ct(()=>s.options.preprocessOptions.includes("desensitize")),h=ct(()=>s.options.preserveTables&&s.options.preserveCodeBlocks&&s.options.preserveLists);function d(E,A){i("update:options",{...s.options,[E]:A})}function f(E){i("update:options",{...s.options,...E})}function g(E){const A=!!E,_=Array.from(new Set(s.options.preprocessOptions.filter(x=>!r.includes(x))));d("preprocessOptions",A?[...r,..._]:_)}function y(E){const A=Array.from(new Set(s.options.preprocessOptions.filter(_=>_!=="desensitize")));E&&A.push("desensitize"),d("preprocessOptions",A)}function b(E){const A=!!E;i("update:options",{...s.options,preserveTables:A,preserveCodeBlocks:A,preserveLists:A})}function S(E,A){const _=o[E],x=Number(A),k=Number.isFinite(x)?x:_.min;d(E,Math.min(_.max,Math.max(_.min,k)))}function w(){}return t({revealValidation:w}),(E,A)=>{const _=Pp,x=Ip,k=Mp,M=zu;return R(),U(ye,null,[C("div",gA,[A[10]||(A[10]=C("div",{class:"section-title-row"},[C("div",null,[C("h3",null,"预处理选项"),C("p",null,"默认启用结构感知的推荐策略,只需决定是否需要脱敏")])],-1)),C("div",mA,[C("label",{class:we(["preprocess-option",{"is-checked":l.value}])},[z(_,{"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:we(["preprocess-option",{"is-checked":c.value}])},[z(_,{"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:we(["preprocess-option",{"is-checked":h.value}])},[z(_,{"model-value":h.value,"onUpdate:modelValue":b},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",bA,[C("label",yA,[A[11]||(A[11]=C("span",{class:"config-field-label"},"切分方式",-1)),z(k,{"model-value":u.options.chunkMethod,"aria-label":"切分方式","onUpdate:modelValue":A[0]||(A[0]=D=>d("chunkMethod",D))},{default:et(()=>[(R(),U(ye,null,ri(a,D=>z(x,{key:D.value,label:D.label,value:D.value},null,8,["label","value"])),64))]),_:1},8,["model-value"]),u.options.chunkMethod==="layout_hybrid"?(R(),U("small",wA,"默认推荐,按标题、段落、列表和表格结构切分,并合并过短内容块")):u.options.chunkMethod==="semantic"?(R(),U("small",AA,"根据相邻内容的语义变化寻找主题边界,适合长文章和知识材料")):(R(),U("small",SA,"按句子边界控制固定 Token 长度,速度快且结果稳定"))]),C("label",xA,[A[13]||(A[13]=C("span",{class:"config-field-label"},"切片长度",-1)),C("span",EA,[z(M,{"model-value":u.options.chunkSize,min:200,max:2e3,step:50,precision:0,"controls-position":"right","aria-label":"切片长度","onUpdate:modelValue":A[1]||(A[1]=D=>S("chunkSize",D))},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",CA,[A[16]||(A[16]=C("span",{class:"config-field-label"},"重叠长度",-1)),C("span",_A,[z(M,{"model-value":u.options.chunkOverlap,min:0,max:500,step:10,precision:0,"controls-position":"right","aria-label":"重叠长度","onUpdate:modelValue":A[2]||(A[2]=D=>S("chunkOverlap",D))},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",kA,[A[19]||(A[19]=C("span",{class:"config-field-label"},"最小切片长度",-1)),C("span",TA,[z(M,{"model-value":u.options.minChunkSize,min:20,max:500,step:10,precision:0,"controls-position":"right","aria-label":"最小切片长度","onUpdate:modelValue":A[3]||(A[3]=D=>S("minChunkSize",D))},null,8,["model-value"]),A[18]||(A[18]=C("span",null,"Token",-1))]),A[20]||(A[20]=C("small",null,"过短的尾部内容会尽量并入前一个切片",-1))]),u.options.chunkMethod==="semantic"?(R(),U("label",PA,[A[22]||(A[22]=C("span",{class:"config-field-label"},"语义断点百分位",-1)),C("span",MA,[z(M,{"model-value":u.options.semanticBreakpointPercentile,min:1,max:99,step:1,precision:0,"controls-position":"right","aria-label":"语义断点百分位","onUpdate:modelValue":A[4]||(A[4]=D=>S("semanticBreakpointPercentile",D))},null,8,["model-value"]),A[21]||(A[21]=C("span",null,"%",-1))]),A[23]||(A[23]=C("small",null,"百分位越低切片越多,推荐保持 95%",-1))])):ut("",!0)]),A[25]||(A[25]=C("p",{class:"chunk-estimation-note"}," Token 数为轻量估算值,实际长度以训练使用的模型分词器为准。 ",-1)),u.chunkValidationMessage?(R(),U("p",IA,j(u.chunkValidationMessage),1)):ut("",!0)]),C("div",DA,[A[27]||(A[27]=C("div",{class:"section-title-row"},[C("div",null,[C("h3",null,"生成选项"),C("p",null,"只保留会直接影响输出的核心设置")])],-1)),C("div",LA,[z(Um,{options:u.options,section:"quality","validation-message":u.validationAttempted?u.qualityValidationMessage:"","onUpdate:options":f},null,8,["options","validation-message"]),C("div",FA,[A[26]||(A[26]=C("div",{class:"generation-option-copy"},[C("strong",null,"每个切片生成数量"),C("small",null,"每个内容切片最多生成 3 个不同角度的问答对")],-1)),z(M,{"model-value":u.options.qaPairsPerChunk,min:1,max:3,step:1,precision:0,"controls-position":"right","aria-label":"每个切片生成数量","onUpdate:modelValue":A[5]||(A[5]=D=>S("qaPairsPerChunk",D))},null,8,["model-value"])]),z(Jv,{"model-value":u.options.datasetSplit,"aria-label-prefix":"非结构化","onUpdate:modelValue":A[6]||(A[6]=D=>d("datasetSplit",D))},null,8,["model-value"])])])],64)}}}),OA=Ti(RA,[["__scopeId","data-v-0d5209a3"]]),NA={class:"task-setup-step"},BA={class:"form-section"},$A={class:"basic-grid"},UA={class:"form-section"},HA={class:"type-options"},zA=ki({__name:"TaskSetupStep",props:{name:{},description:{},processType:{},structuredOptions:{},unstructuredOptions:{}},emits:["update:name","update:description","update:processType","update:structuredOptions","update:unstructuredOptions"],setup(u,{expose:t,emit:e}){const s=u,i=e,r=rt(),a=rt(),o=rt(!1),l=ct(()=>({name:s.name,processType:s.processType})),c=ct(()=>{const{train:S,validation:w,test:E}=s.structuredOptions.datasetSplit;return S+w+E}),h=ct(()=>{const{train:S,validation:w,test:E}=s.unstructuredOptions.datasetSplit;return S+w+E}),d=ct(()=>s.processType==="structured"?s.structuredOptions:s.processType==="unstructured"?s.unstructuredOptions:null),f=ct(()=>{const S=d.value;return S?S.qualityFilterEnabled&&!S.filterLowQuality&&!S.filterShortContent?"开启质量筛选后,请至少选择一项筛选规则":S.qualityFilterEnabled&&S.filterShortContent&&S.minOutputLength<1?"最少字数必须大于 0":"":""}),g=ct(()=>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 b(){var S;if(o.value=!0,!r.value)return!1;try{if(await r.value.validate(),s.processType==="structured"&&c.value!==100)return wt.error("结构化数据处理:数据集划分比例总和必须为 100%"),!1;if(s.processType==="unstructured"){if(h.value!==100)return wt.error("非结构化数据处理:数据集划分比例总和必须为 100%"),!1;if(g.value)return(S=a.value)==null||S.revealValidation(),wt.error(g.value),!1}return f.value?(wt.error(f.value),!1):!0}catch{return wt.error("请完善标红的必填项"),!1}}return t({validate:b}),(S,w)=>{const E=Hu,A=Xv,_=Wv;return R(),U("section",NA,[z(_,{ref_key:"formRef",ref:r,model:l.value,rules:y,"label-position":"top","scroll-to-error":""},{default:et(()=>[C("div",BA,[w[7]||(w[7]=C("h3",null,"基本信息",-1)),C("div",$A,[z(A,{label:"任务名称",prop:"name",required:""},{default:et(()=>[z(E,{"model-value":u.name,maxlength:"50","show-word-limit":"",placeholder:"例如:金融问答清洗任务","onUpdate:modelValue":w[0]||(w[0]=x=>i("update:name",x))},null,8,["model-value"])]),_:1}),z(A,{label:"任务描述(选填)"},{default:et(()=>[z(E,{"model-value":u.description,type:"textarea",rows:3,maxlength:"200","show-word-limit":"",placeholder:"简要说明本次数据处理目标","onUpdate:modelValue":w[1]||(w[1]=x=>i("update:description",x))},null,8,["model-value"])]),_:1})])]),C("div",UA,[w[11]||(w[11]=C("div",{class:"section-title-row"},[C("div",null,[C("h3",null,"处理类型"),C("p",null,"类型会影响下一步支持的数据源格式和后续预览方式")])],-1)),z(A,{prop:"processType",class:"type-form-item"},{default:et(()=>[C("div",HA,[C("button",{type:"button",class:we(["type-option",{"is-active":u.processType==="structured"}]),onClick:w[2]||(w[2]=x=>i("update:processType","structured"))},[...w[8]||(w[8]=[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)])],2),C("button",{type:"button",class:we(["type-option",{"is-active":u.processType==="unstructured"}]),onClick:w[3]||(w[3]=x=>i("update:processType","unstructured"))},[...w[9]||(w[9]=[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)])],2),C("button",{type:"button",class:we(["type-option",{"is-active":u.processType==="external"}]),onClick:w[4]||(w[4]=x=>i("update:processType","external"))},[...w[10]||(w[10]=[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)])],2)])]),_:1})]),u.processType==="structured"?(R(),$t(pA,{key:0,options:u.structuredOptions,"validation-attempted":o.value,"quality-validation-message":f.value,"onUpdate:options":w[5]||(w[5]=x=>i("update:structuredOptions",x))},null,8,["options","validation-attempted","quality-validation-message"])):ut("",!0),u.processType==="unstructured"?(R(),$t(OA,{key:1,ref_key:"unstructuredOptionsPanelRef",ref:a,options:u.unstructuredOptions,"validation-attempted":o.value,"quality-validation-message":f.value,"chunk-validation-message":g.value,"onUpdate:options":w[6]||(w[6]=x=>i("update:unstructuredOptions",x))},null,8,["options","validation-attempted","quality-validation-message","chunk-validation-message"])):ut("",!0)]),_:1},8,["model"])])}}}),VA=Ti(zA,[["__scopeId","data-v-47155dac"]]),GA={class:"model-selection-step","aria-labelledby":"model-selection-title"},jA={class:"form-section"},WA={class:"model-form-content"},XA=ki({__name:"ModelSelectionStep",props:{options:{},models:{}},emits:["update:options"],setup(u,{expose:t,emit:e}){const s=u,i=e,r=rt(!1),a=ct(()=>s.options.generationModelId===""?"请选择数据生成模型":"");function o(){return r.value=!0,a.value?(wt.error(a.value),!1):!0}return t({validate:o}),(l,c)=>(R(),U("section",GA,[C("div",jA,[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",WA,[z(Um,{options:u.options,models:u.models,section:"model","validation-message":r.value?a.value:"","onUpdate:options":c[0]||(c[0]=h=>i("update:options",h))},null,8,["options","models","validation-message"])])])]))}}),qA=Ti(XA,[["__scopeId","data-v-77825278"]]),YA={class:"source-upload-step","aria-labelledby":"source-upload-title"},KA={key:0,class:"form-section external-section"},QA={class:"external-form"},JA={class:"external-actions"},ZA={key:0,class:"external-status is-connected",role:"status"},tS={key:0,class:"uploaded-file-list","aria-label":"已拉取数据列表"},eS={class:"uploaded-file-list-header"},sS={class:"uploaded-file-items"},iS={class:"file-main"},nS=["title"],rS=["title"],aS={class:"file-status",role:"status","aria-live":"polite"},oS={class:"file-progress-value"},lS={key:0,class:"file-preview-error"},cS={key:1,class:"form-section upload-section"},hS={class:"section-title-row"},dS={class:"el-upload__tip"},uS={key:1,class:"uploaded-file-list","aria-label":"已上传文件列表"},fS={class:"uploaded-file-list-header"},pS={key:0,class:"upload-queue-status"},gS={class:"continue-upload"},mS={class:"uploaded-file-items"},vS={class:"file-main"},bS=["title"],yS=["title"],wS={class:"file-status",role:"status","aria-live":"polite"},AS={class:"file-progress-value"},SS={key:0,class:"file-preview-error"},Fa=10,xS=ki({__name:"SourceUploadStep",props:{processType:{},uploadedFiles:{},externalSource:{},externalPulling:{type:Boolean},externalConnected:{type:Boolean},previewBuilding:{type:Boolean},sourceUploading:{type:Boolean}},emits:["update:externalSource","file-change","remove-file","use-sample","test-connection","pull-data"],setup(u,{emit:t}){const e=u,s=t,i=[{value:"postgresql",label:"PostgreSQL"}],r=[{value:"none",label:"免鉴权"},{value:"basic",label:"账号密码"}],a=rt(1),o={queued:{label:"等待上传",icon:"fa-clock-o"},uploading:{label:"正在上传",icon:"fa-cloud-upload"},waiting:{label:"等待切分",icon:"fa-clock-o"},processing:{label:"正在切分",icon:"fa-spinner fa-spin"},success:{label:"切分完成",icon:"fa-check-circle"},"upload-failed":{label:"上传失败",icon:"fa-exclamation-circle"},"preview-failed":{label:"切分失败",icon:"fa-exclamation-circle"}},l=ct(()=>e.processType==="external"),c=ct(()=>e.processType==="unstructured"?".txt,.md,.markdown,.pdf,.docx,.pptx,.json,.jsonl,.ndjson":".json,.jsonl,.ndjson,.csv,.tsv,.xlsx"),h=ct(()=>{const _=(a.value-1)*Fa;return e.uploadedFiles.slice(_,_+Fa)});Ei(()=>e.uploadedFiles.length,(_,x)=>{const k=Math.max(1,Math.ceil(_/Fa));if(_>x){a.value=k;return}a.value=Math.min(a.value,k)}),Ei(()=>e.processType,()=>{a.value=1});function d(_,x){s("update:externalSource",{...e.externalSource,[_]:x})}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 x=g(_),k=x==="queued"||x==="uploading"||x==="upload-failed"?_.uploadProgress:x==="waiting"?100:_.previewProgress??0;return Math.min(100,Math.max(0,k))}function b(_){return g(_)==="processing"}function S(_){return b(_)?100:y(_)}function w(_){const x=g(_);if(x==="waiting"||x==="success")return"success";if(x==="upload-failed"||x==="preview-failed")return"exception"}function E(_){return b(_)?"处理中":g(_)==="waiting"?"已上传":`${y(_)}%`}function A(_){return _.uploadError||_.previewError}return(_,x)=>{const k=Ip,M=Mp,D=Xv,I=Hu,L=zu,O=Wv,Y=Uu,W=Kv,Q=Yv,ft=pw;return R(),U("section",YA,[l.value?(R(),U("div",KA,[x[18]||(x[18]=C("div",{class:"section-title-row"},[C("div",null,[C("h3",{id:"source-upload-title"},"数据源配置"),C("p",null,"配置并验证外部数据源,拉取成功后可在下一步预览数据内容")])],-1)),C("div",QA,[z(O,{"label-position":"top",class:"external-grid"},{default:et(()=>[z(D,{label:"数据源类型"},{default:et(()=>[z(M,{"model-value":u.externalSource.type,placeholder:"请选择数据源类型","aria-label":"数据源类型","onUpdate:modelValue":x[0]||(x[0]=T=>d("type",T))},{default:et(()=>[(R(),U(ye,null,ri(i,T=>z(k,{key:T.value,label:T.label,value:T.value},null,8,["label","value"])),64))]),_:1},8,["model-value"])]),_:1}),z(D,{label:"地址 / URL"},{default:et(()=>[z(I,{"model-value":u.externalSource.url,placeholder:"例如:postgresql://db.example.com:5432/my_database","aria-label":"数据源地址或 URL","onUpdate:modelValue":x[1]||(x[1]=T=>d("url",T))},null,8,["model-value"])]),_:1}),z(D,{label:"鉴权方式"},{default:et(()=>[z(M,{"model-value":u.externalSource.authMode,"aria-label":"鉴权方式","onUpdate:modelValue":x[2]||(x[2]=T=>d("authMode",T))},{default:et(()=>[(R(),U(ye,null,ri(r,T=>z(k,{key:T.value,label:T.label,value:T.value},null,8,["label","value"])),64))]),_:1},8,["model-value"])]),_:1}),u.externalSource.authMode==="basic"?(R(),$t(D,{key:0,label:"账号"},{default:et(()=>[z(I,{"model-value":u.externalSource.username,autocomplete:"username",placeholder:"请输入账号","aria-label":"数据源账号","onUpdate:modelValue":x[3]||(x[3]=T=>d("username",T))},null,8,["model-value"])]),_:1})):ut("",!0),u.externalSource.authMode==="basic"?(R(),$t(D,{key:1,label:"密码"},{default:et(()=>[z(I,{"model-value":u.externalSource.password,type:"password","show-password":"",autocomplete:"current-password",placeholder:"请输入密码","aria-label":"数据源密码","onUpdate:modelValue":x[4]||(x[4]=T=>d("password",T))},null,8,["model-value"])]),_:1})):ut("",!0),z(D,{label:"拉取条数"},{default:et(()=>[z(L,{"model-value":u.externalSource.limit,min:1,max:1e5,step:100,"controls-position":"right","aria-label":"数据拉取条数","onUpdate:modelValue":x[5]||(x[5]=T=>d("limit",Number(T)||0))},null,8,["model-value"])]),_:1}),z(D,{label:"只读查询语句",class:"external-query-field"},{default:et(()=>[z(I,{"model-value":u.externalSource.query,type:"textarea",rows:4,maxlength:"20000","show-word-limit":"",placeholder:"例如:SELECT question, answer FROM qa_data ORDER BY id","aria-label":"外部数据源只读查询语句","onUpdate:modelValue":x[6]||(x[6]=T=>d("query",T))},null,8,["model-value"]),x[12]||(x[12]=C("small",null,"只允许单条 SELECT 或 WITH 查询;后端会拒绝写入、DDL 和多语句。",-1))]),_:1})]),_:1}),C("div",JA,[z(Y,{loading:u.externalPulling&&!u.externalConnected,disabled:u.externalPulling||u.previewBuilding,plain:"",onClick:x[7]||(x[7]=T=>s("test-connection"))},{default:et(()=>[...x[13]||(x[13]=[pt(" 测试连接 ",-1)])]),_:1},8,["loading","disabled"]),z(Y,{type:"primary",loading:u.externalPulling,disabled:u.externalPulling||u.previewBuilding,onClick:x[8]||(x[8]=T=>s("pull-data"))},{default:et(()=>[...x[14]||(x[14]=[pt(" 拉取数据 ",-1)])]),_:1},8,["loading","disabled"]),u.externalConnected?(R(),U("span",ZA,[...x[15]||(x[15]=[C("i",{class:"fa fa-check-circle","aria-hidden":"true"},null,-1),pt(" 连接正常 ",-1)])])):ut("",!0)]),u.uploadedFiles.length?(R(),U("section",tS,[C("div",eS,[C("span",null,"已拉取 "+j(u.uploadedFiles.length)+" 个数据集",1)]),C("div",sS,[(R(!0),U(ye,null,ri(h.value,T=>(R(),U("div",{key:T.uid,class:"uploaded-file"},[x[17]||(x[17]=C("span",{class:"file-icon"},[C("i",{class:"fa fa-cloud-download","aria-hidden":"true"})],-1)),C("div",iS,[C("strong",{title:T.name},j(T.name),9,nS),C("span",null,[pt(j(f(T.size))+" ",1),T.count?(R(),U(ye,{key:0},[pt(" · "+j(T.count.toLocaleString())+" 条",1)],64)):ut("",!0)])]),C("div",{class:we(["file-preview-progress",`is-${g(T)}`]),title:A(T)},[C("div",aS,[C("span",null,[C("i",{class:we(["fa",o[g(T)].icon]),"aria-hidden":"true"},null,2),pt(" "+j(o[g(T)].label),1)]),C("span",oS,j(E(T)),1)]),z(W,{percentage:S(T),indeterminate:b(T),duration:1.5,"stroke-width":5,"show-text":!1,status:w(T),"aria-valuenow":b(T)?void 0:y(T),"aria-valuetext":b(T)?"正在切分,进度未知":E(T)},null,8,["percentage","indeterminate","status","aria-valuenow","aria-valuetext"]),A(T)?(R(),U("small",lS,j(A(T)),1)):ut("",!0)],10,rS),z(Y,{link:"",type:"danger",disabled:u.previewBuilding||T.status==="uploading","aria-label":`删除数据集 ${T.name}`,onClick:q=>s("remove-file",T.uid)},{default:et(()=>[...x[16]||(x[16]=[pt(" 删除 ",-1)])]),_:1},8,["disabled","aria-label","onClick"])]))),128))]),u.uploadedFiles.length>Fa?(R(),$t(Q,{key:0,"current-page":a.value,"onUpdate:currentPage":x[9]||(x[9]=T=>a.value=T),"page-size":Fa,total:u.uploadedFiles.length,"pager-count":5,small:"",background:"",layout:"prev, pager, next",class:"uploaded-file-pagination","aria-label":"已拉取数据分页"},null,8,["current-page","total"])):ut("",!0)])):ut("",!0)])])):(R(),U("div",cS,[C("div",hS,[x[20]||(x[20]=C("div",null,[C("h3",{id:"source-upload-title"},"源数据上传"),C("p",null,"上传后可在下一步检查内容和切分效果,支持同时添加多个文件")],-1)),u.uploadedFiles.length===0?(R(),$t(Y,{key:0,link:"",type:"primary",disabled:u.previewBuilding,onClick:x[10]||(x[10]=T=>s("use-sample"))},{default:et(()=>[...x[19]||(x[19]=[pt(" 使用示例数据 ",-1)])]),_:1},8,["disabled"])):ut("",!0)]),u.uploadedFiles.length===0?(R(),$t(ft,{key:0,drag:"",multiple:"",accept:c.value,disabled:u.previewBuilding,"auto-upload":!1,"show-file-list":!1,"on-change":T=>s("file-change",T),"aria-label":"选择或拖拽源数据文件"},{tip:et(()=>[C("div",dS,j(u.processType==="unstructured"?"支持 TXT、MD、MARKDOWN、PDF、DOCX、PPTX、JSON、JSONL、NDJSON;旧版 DOC/PPT 请先转换,单文件不超过 200MB":"支持 JSON、JSONL、NDJSON、CSV、TSV、XLSX;旧版 XLS 请先转换,单文件不超过 200MB"),1)]),default:et(()=>[x[21]||(x[21]=C("i",{class:"fa fa-cloud-upload upload-icon","aria-hidden":"true"},null,-1)),x[22]||(x[22]=C("div",{class:"el-upload__text"},[pt("拖拽文件到此处,或"),C("em",null,"点击选择文件")],-1))]),_:1},8,["accept","disabled","on-change"])):(R(),U("section",uS,[C("div",fS,[C("span",null,[pt(" 已选择 "+j(u.uploadedFiles.length)+" 个文件 ",1),u.sourceUploading?(R(),U("small",pS," · 正在逐个上传")):ut("",!0)]),C("div",gS,[z(ft,{multiple:"",accept:c.value,disabled:u.previewBuilding,"auto-upload":!1,"show-file-list":!1,"on-change":T=>s("file-change",T),"aria-label":"继续添加源数据文件"},{default:et(()=>[z(Y,{size:"small",type:"primary",disabled:u.previewBuilding},{default:et(()=>[...x[23]||(x[23]=[pt("继续上传",-1)])]),_:1},8,["disabled"])]),_:1},8,["accept","disabled","on-change"])])]),C("div",mS,[(R(!0),U(ye,null,ri(h.value,T=>(R(),U("div",{key:T.uid,class:"uploaded-file"},[x[25]||(x[25]=C("span",{class:"file-icon"},[C("i",{class:"fa fa-file-text-o","aria-hidden":"true"})],-1)),C("div",vS,[C("strong",{title:T.name},j(T.name),9,bS),C("span",null,[pt(j(f(T.size))+" ",1),T.count?(R(),U(ye,{key:0},[pt(" · "+j(T.count.toLocaleString())+" 条",1)],64)):ut("",!0)])]),C("div",{class:we(["file-preview-progress",`is-${g(T)}`]),title:A(T)},[C("div",wS,[C("span",null,[C("i",{class:we(["fa",o[g(T)].icon]),"aria-hidden":"true"},null,2),pt(" "+j(o[g(T)].label),1)]),C("span",AS,j(E(T)),1)]),z(W,{percentage:S(T),indeterminate:b(T),duration:1.5,"stroke-width":5,"show-text":!1,status:w(T),"aria-valuenow":b(T)?void 0:y(T),"aria-valuetext":b(T)?"正在切分,进度未知":E(T)},null,8,["percentage","indeterminate","status","aria-valuenow","aria-valuetext"]),A(T)?(R(),U("small",SS,j(A(T)),1)):ut("",!0)],10,yS),z(Y,{link:"",type:"danger",disabled:u.previewBuilding||T.status==="uploading","aria-label":`删除文件 ${T.name}`,onClick:q=>s("remove-file",T.uid)},{default:et(()=>[...x[24]||(x[24]=[pt(" 删除 ",-1)])]),_:1},8,["disabled","aria-label","onClick"])]))),128))]),u.uploadedFiles.length>Fa?(R(),$t(Q,{key:0,"current-page":a.value,"onUpdate:currentPage":x[11]||(x[11]=T=>a.value=T),"page-size":Fa,total:u.uploadedFiles.length,"pager-count":5,small:"",background:"",layout:"prev, pager, next",class:"uploaded-file-pagination","aria-label":"已上传文件分页"},null,8,["current-page","total"])):ut("",!0)]))]))])}}}),ES=Ti(xS,[["__scopeId","data-v-77d607a9"]]),si=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),mr=[1/0,1/0,-1/0,-1/0],ja=new Float32Array(mr),ng=[.001,0,0,.001,0,0],qp=1.35,Ns="http://www.w3.org/2000/svg",ei={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Cr={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Bl="pdfjs_internal_id_",Yh="pdfjs_internal_editor_",lt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},gt={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},CS={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},xe={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},rf={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},oe={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26,RICHMEDIA:27},Ll={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Dp={ERRORS:0,WARNINGS:1,INFOS:5},Ki={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},yh={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},_S={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Lp=Dp.WARNINGS;function kS(u){Number.isInteger(u)&&(Lp=u)}function TS(){return Lp}function Fp(u){Lp>=Dp.INFOS&&console.info(`Info: ${u}`)}function dt(u){Lp>=Dp.WARNINGS&&console.warn(`Warning: ${u}`)}function Ct(u){throw new Error(u)}function re(u,t){u||Ct(t)}function PS(u){switch(u==null?void 0:u.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Zv(u,t=null,e=null){if(!u)return null;if(e&&typeof u=="string"){if(e.addDefaultProtocol&&u.startsWith("www.")){const i=u.match(/\./g);(i==null?void 0:i.length)>=2&&(u=`http://${u}`)}if(e.tryConvertEncoding)try{u=DS(u)}catch{}}const s=t?URL.parse(u,t):URL.parse(u);return PS(s)?s:null}function tb(u,t,e=!1){const s=URL.parse(u);return s?(s.hash=t,s.href):e&&Zv(u,"http://example.com")?u.split("#",1)[0]+`${t?`#${t}`:""}`:""}function rg(u){return u.substring(u.lastIndexOf("/")+1)}function at(u,t,e,s=!1){return Object.defineProperty(u,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Tl=(function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})();class ag extends Tl{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Yp extends Tl{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class og extends Tl{constructor(t){super(t,"InvalidPDFException")}}class Xf extends Tl{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class MS extends Tl{constructor(t){super(t,"FormatError")}}class _a extends Tl{constructor(t){super(t,"AbortException")}}function IS(u){(typeof u!="object"||(u==null?void 0:u.length)===void 0)&&Ct("Invalid argument for bytesToString");const t=u.length,e=8192;if(t"u")return at(this,"isAlphaColorInputSupported",!1);const t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",at(this,"isAlphaColorInputSupported",t.value!=="#ff0000")}static get isBackdropFilterSupported(){return at(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}}var vr,af,lg;class B{static get hexNums(){return at(this,"hexNums",Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0")))}static makeHexColor(t,e,s){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[s]}`}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,s=0){const i=t[s],r=t[s+1];t[s]=i*e[0]+r*e[2]+e[4],t[s+1]=i*e[1]+r*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){const i=e[0],r=e[1],a=e[2],o=e[3],l=e[4],c=e[5];for(let h=0;h<6;h+=2){const d=t[s+h],f=t[s+h+1];t[s+h]=d*i+f*a+l,t[s+h+1]=d*r+f*o+c}}static applyInverseTransform(t,e){const s=t[0],i=t[1],r=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/r,t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/r}static axialAlignedBoundingBox(t,e,s){const i=e[0],r=e[1],a=e[2],o=e[3],l=e[4],c=e[5],h=t[0],d=t[1],f=t[2],g=t[3];let y=i*h+l,b=y,S=i*f+l,w=S,E=o*d+c,A=E,_=o*g+c,x=_;if(r!==0||a!==0){const k=r*h,M=r*f,D=a*d,I=a*g;y+=D,w+=D,S+=I,b+=I,E+=k,x+=k,_+=M,A+=M}s[0]=Math.min(s[0],y,S,b,w),s[1]=Math.min(s[1],E,_,A,x),s[2]=Math.max(s[2],y,S,b,w),s[3]=Math.max(s[3],E,_,A,x)}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){const s=t[0],i=t[1],r=t[2],a=t[3],o=s**2+i**2,l=s*r+i*a,c=r**2+a**2,h=(o+c)/2,d=Math.sqrt(h**2-(o*c-l**2));e[0]=Math.sqrt(h+d||1),e[1]=Math.sqrt(h-d||1)}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;const r=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return r>a?null:[s,r,i,a]}static pointBoundingBox(t,e,s){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}static rectBoundingBox(t,e,s,i,r){r[0]=Math.min(r[0],t,s),r[1]=Math.min(r[1],e,i),r[2]=Math.max(r[2],t,s),r[3]=Math.max(r[3],e,i)}static bezierBoundingBox(t,e,s,i,r,a,o,l,c){c[0]=Math.min(c[0],t,o),c[1]=Math.min(c[1],e,l),c[2]=Math.max(c[2],t,o),c[3]=Math.max(c[3],e,l),v(this,vr,lg).call(this,t,s,r,o,e,i,a,l,3*(-t+3*(s-r)+o),6*(t-2*s+r),3*(s-t),c),v(this,vr,lg).call(this,t,s,r,o,e,i,a,l,3*(-e+3*(i-a)+l),6*(e-2*i+a),3*(i-e),c)}}vr=new WeakSet,af=function(t,e,s,i,r,a,o,l,c,h){if(c<=0||c>=1)return;const d=1-c,f=c*c,g=f*c,y=d*(d*(d*t+3*c*e)+3*f*s)+g*i,b=d*(d*(d*r+3*c*a)+3*f*o)+g*l;h[0]=Math.min(h[0],y),h[1]=Math.min(h[1],b),h[2]=Math.max(h[2],y),h[3]=Math.max(h[3],b)},lg=function(t,e,s,i,r,a,o,l,c,h,d,f){if(Math.abs(c)<1e-12){Math.abs(h)>=1e-12&&v(this,vr,af).call(this,t,e,s,i,r,a,o,l,-d/h,f);return}const g=h**2-4*d*c;if(g<0)return;const y=Math.sqrt(g),b=2*c;v(this,vr,af).call(this,t,e,s,i,r,a,o,l,(-h+y)/b,f),v(this,vr,af).call(this,t,e,s,i,r,a,o,l,(-h-y)/b,f)},m(B,vr);function DS(u){return decodeURIComponent(escape(u))}let Kp=null,uv=null;function LS(u){return Kp||(Kp=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,uv=new Map([["ſt","ſt"]])),u.replaceAll(Kp,(t,e,s)=>e?e.normalize("NFKC"):uv.get(s))}function eb(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const u=new Uint8Array(32);return crypto.getRandomValues(u),IS(u)}function FS(u,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,i,...r]=e;if(!u(s)&&!Number.isInteger(s)||!t(i))return!1;const a=r.length;let o=!0;switch(i.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return a===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(a!==4)return!1;o=!1;break;default:return!1}for(const l of r)if(!(typeof l=="number"||o&&l===null))return!1;return!0}const Vu=()=>[],Hm=()=>new Map,cg=()=>Object.create(null);function Jt(u,t,e){return Math.min(Math.max(u,t),e)}class Gu{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:r=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=r,this.offsetY=a,s*=e;const l=(t[2]+t[0])/2,c=(t[3]+t[1])/2;let h,d,f,g;switch(i%=360,i<0&&(i+=360),i){case 180:h=-1,d=0,f=0,g=1;break;case 90:h=0,d=1,f=1,g=0;break;case 270:h=0,d=-1,f=-1,g=0;break;case 0:h=1,d=0,f=0,g=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(f=-f,g=-g);let y,b,S,w;h===0?(y=Math.abs(c-t[1])*s+r,b=Math.abs(l-t[0])*s+a,S=(t[3]-t[1])*s,w=(t[2]-t[0])*s):(y=Math.abs(l-t[0])*s+r,b=Math.abs(c-t[1])*s+a,S=(t[2]-t[0])*s,w=(t[3]-t[1])*s),this.transform=[h*s,d*s,f*s,g*s,y-h*s*l-f*s*c,b-d*s*l-g*s*c],this.width=S,this.height=w}get rawDims(){const t=this.viewBox;return at(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:r=!1}={}){return new Gu({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:r})}convertToViewportPoint(t,e){const s=[t,e];return B.applyTransform(s,this.transform),s}convertToPdfPoint(t,e){const s=[t,e];return B.applyInverseTransform(s,this.transform),s}}class Kh{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(Kh.shouldBuildText(o))(l=r==null?void 0:r.attributes)!=null&&l.textContent?a=r.attributes.textContent:r.value&&(a=r.value);else return;if(a!==null&&e.push({str:a}),!!r.children)for(const c of r.children)i(c)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}class sb{static setupStorage(t,e,s,i,r){const a=i.getValue(e,{value:null});switch(s.name){case"textarea":if(a.value!==null&&(t.textContent=a.value),r==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(a.value===s.attributes.xfaOn?t.setAttribute("checked",!0):a.value===s.attributes.xfaOff&&t.removeAttribute("checked"),r==="print")break;t.addEventListener("change",o=>{i.setValue(e,{value:o.target.checked?o.target.getAttribute("xfaOn"):o.target.getAttribute("xfaOff")})})}else{if(a.value!==null&&t.setAttribute("value",a.value),r==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})})}break;case"select":if(a.value!==null){t.setAttribute("value",a.value);for(const o of s.children)o.attributes.value===a.value?o.attributes.selected=!0:Object.hasOwn(o.attributes,"selected")&&delete o.attributes.selected}t.addEventListener("input",o=>{const l=o.target.options,c=l.selectedIndex===-1?"":l[l.selectedIndex].value;i.setValue(e,{value:c})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:r}){const{attributes:a}=e,o=t instanceof HTMLAnchorElement;a.type==="radio"&&(a.name=`${a.name}-${i}`);for(const[l,c]of Object.entries(a))if(c!=null)switch(l){case"class":c.length&&t.setAttribute(l,c.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",c);break;case"style":Object.assign(t.style,c);break;case"textContent":t.textContent=c;break;default:(!o||l!=="href"&&l!=="newWindow")&&t.setAttribute(l,c)}o&&r.addLinkAttributes(t,a.href,a.newWindow),s&&a.dataId&&this.setupStorage(t,a.dataId,e,s)}static render(t){var d,f;const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,r=t.intent||"display",a=document.createElement(i.name);i.attributes&&this.setAttributes({html:a,element:i,intent:r,linkService:s});const o=r!=="richText",l=t.div;if(l.append(a),t.viewport){const g=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=g}o&&l.setAttribute("class","xfaLayer xfaFont");const c=[];if(i.children.length===0){if(i.value){const g=document.createTextNode(i.value);a.append(g),o&&Kh.shouldBuildText(i.name)&&c.push(g)}return{textDivs:c}}const h=[[i,-1,a]];for(;h.length>0;){const[g,y,b]=h.at(-1);if(y+1===g.children.length){h.pop();continue}const S=g.children[++h.at(-1)[1]];if(S===null)continue;const{name:w}=S;if(w==="#text"){const A=document.createTextNode(S.value);c.push(A),b.append(A);continue}const E=(d=S==null?void 0:S.attributes)!=null&&d.xmlns?document.createElementNS(S.attributes.xmlns,w):document.createElement(w);if(b.append(E),S.attributes&&this.setAttributes({html:E,element:S,storage:e,intent:r,linkService:s}),((f=S.children)==null?void 0:f.length)>0)h.push([S,-1,E]);else if(S.value){const A=document.createTextNode(S.value);o&&Kh.shouldBuildText(w)&&c.push(A),E.append(A)}}for(const g of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))g.setAttribute("readOnly",!0);return{textDivs:c}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}static getPageViewport(t,{scale:e=1,rotation:s=0}){const{width:i,height:r}=t.attributes.style;return new Gu({viewBox:[0,0,parseInt(i,10),parseInt(r,10)],userUnit:1,scale:e,rotation:s})}}const za=class za{};P(za,"CSS",96),P(za,"PDF",72),P(za,"PDF_TO_CSS_UNITS",za.CSS/za.PDF);let ka=za;async function zm(u,t="text"){if(jh(u,document.baseURI)){const e=await fetch(u);if(!e.ok)throw new Error(e.statusText);switch(t){case"blob":return e.blob();case"bytes":return e.bytes();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const i=new XMLHttpRequest;i.open("GET",u,!0),i.responseType=t==="bytes"?"arraybuffer":t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"bytes":e(new Uint8Array(i.response));return;case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class Vm extends Tl{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Op(u){const t=u.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})(u);if(!s)return t;const i=o=>{try{let l=decodeURIComponent(o);return l.includes("/")&&(l=rg(l),l.length===4&&r.test(l))?o:l}catch{return o}},r=/\.pdf$/i,a=rg(s.pathname);if(r.test(a))return i(a);if(s.searchParams.size>0){const o=c=>[...c].findLast(h=>r.test(h)),l=o(s.searchParams.values())??o(s.searchParams.keys());if(l)return i(l)}if(s.hash){const l=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(s.hash);if(l)return i(l[0])}return t}var _r;class fv{constructor(){m(this,_r,new Map);P(this,"times",[])}time(t){n(this,_r).has(t)&&dt(`Timer is already running for ${t}`),n(this,_r).set(t,Date.now())}timeEnd(t){n(this,_r).has(t)||dt(`Timer has not been started for ${t}`),this.times.push({name:t,start:n(this,_r).get(t),end:Date.now()}),n(this,_r).delete(t)}toString(){const t=Math.max(...this.times.map(e=>e.name.length));return this.times.map(e=>`${e.name.padEnd(t)} ${e.end-e.start}ms `).join("")}}_r=new WeakMap;function jh(u,t){const e=t?URL.parse(u,t):URL.parse(u);return/https?:/.test((e==null?void 0:e.protocol)??"")}function _i(u){u.preventDefault()}function ne(u){u.preventDefault(),u.stopPropagation()}var td;class qf{static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;n(this,td)||p(this,td,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?"));const e=n(this,td).exec(t);if(!e)return null;const s=parseInt(e[1],10);let i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(e[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(e[6],10);l=l>=0&&l<=59?l:0;const c=e[7]||"Z";let h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,c==="-"?(a+=h,o+=d):c==="+"&&(a-=h,o-=d),new Date(Date.UTC(s,i,r,a,o,l))}}td=new WeakMap,m(qf,td);function ju(u){if(u.startsWith("#")){const e=u.slice(1);return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16),e.length>=8?parseInt(e.slice(6,8),16)/255:1]}if(u.startsWith("rgb(")){const[e,s,i]=u.slice(4,-1).split(",").map(r=>parseInt(r,10));return[e,s,i,1]}if(u.startsWith("rgba(")){const e=u.slice(5,-1).split(",");return[parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10),parseFloat(e[3])]}const t=u.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return t?[Math.round(parseFloat(t[1])*255),Math.round(parseFloat(t[2])*255),Math.round(parseFloat(t[3])*255),t[4]!==void 0&&t[4]!=="none"?parseFloat(t[4]):1]:null}function Wu(u){const t=ju(u);return t?t.slice(0,3):(dt(`Not a valid color format: "${u}"`),[0,0,0])}function NS(u){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const e of u.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;u.set(e,Wu(s))}t.remove()}function Xt(u){const{a:t,b:e,c:s,d:i,e:r,f:a}=u.getTransform();return[t,e,s,i,r,a]}function Xi(u){const{a:t,b:e,c:s,d:i,e:r,f:a}=u.getTransform().invertSelf();return[t,e,s,i,r,a]}function xl(u,t,e=!1,s=!0){if(t instanceof Gu){const{pageWidth:i,pageHeight:r}=t.rawDims,{style:a}=u,o=`round(down, var(--total-scale-factor) * ${i}px, var(--scale-round-x))`,l=`round(down, var(--total-scale-factor) * ${r}px, var(--scale-round-y))`;!e||t.rotation%180===0?(a.width=o,a.height=l):(a.width=l,a.height=o)}s&&u.setAttribute("data-main-rotation",t.rotation)}class En{constructor(){const{pixelRatio:t}=En;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,s,i,r=-1){let a=1/0,o=1/0,l=1/0;s=En.capPixels(s,r),s>0&&(a=Math.sqrt(s/(t*e))),i!==-1&&(o=i/t,l=i/e);const c=Math.min(a,o,l);return this.sx>c||this.sy>c?(this.sx=c,this.sy=c,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,s):s}return t}}const hg=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class BS{static get isDarkMode(){var t;return at(this,"isDarkMode",!!((t=window==null?void 0:window.matchMedia)!=null&&t.call(window,"(prefers-color-scheme: dark)").matches))}}class $S{static get commentForegroundColor(){const t=document.createElement("span");t.classList.add("comment","sidebar");const{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);const{color:s}=window.getComputedStyle(t);return t.remove(),at(this,"commentForegroundColor",Wu(s))}}function US(u,t){t=Jt(t??1,0,1);const e=255*(1-t);return u.map(s=>Math.round(s*t+e))}function pv(u,t){const e=u[0]/255,s=u[1]/255,i=u[2]/255,r=Math.max(e,s,i),a=Math.min(e,s,i),o=(r+a)/2;if(r===a)t[0]=t[1]=0;else{const l=r-a;switch(t[1]=o<.5?l/(r+a):l/(2-r-a),r){case e:t[0]=((s-i)/l+(si?(s+.05)/(i+.05):(i+.05)/(s+.05)}const vv=new Map;function HS(u,t){const e=u[0]+u[1]*256+u[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776;let s=vv.get(e);if(s)return s;const i=new Float32Array(9),r=i.subarray(0,3),a=i.subarray(3,6);pv(u,a);const o=i.subarray(6,9);pv(t,o);const l=o[2]<.5,c=l?12:4.5;if(a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]),mv(a,o,r)f;){const g=a[2]=(h+d)/2;l===mv(a,o,r){e.delete()},{signal:e._signal}),n(this,hi).append(s)}async addAltText(t){const e=await t.render();v(this,qe,Fl).call(this,e),n(this,hi).append(e,n(this,qe,xh)),p(this,ed,t)}addComment(t,e=null){if(n(this,Pr))return;const s=t.renderForToolbar();if(!s)return;v(this,qe,Fl).call(this,s);const i=p(this,zl,n(this,qe,xh));e?(n(this,hi).insertBefore(s,e),n(this,hi).insertBefore(i,e)):n(this,hi).append(s,i),p(this,Pr,t),t.toolbar=this}addColorPicker(t){if(n(this,Tr))return;p(this,Tr,t);const e=t.renderButton();v(this,qe,Fl).call(this,e),n(this,hi).append(e,n(this,qe,xh))}async addEditSignatureButton(t){const e=p(this,Vl,await t.renderEditButton(n(this,ci)));v(this,qe,Fl).call(this,e),n(this,hi).append(e,n(this,qe,xh))}removeButton(t){var e,s;switch(t){case"comment":(e=n(this,Pr))==null||e.removeToolbarCommentButton(),p(this,Pr,null),(s=n(this,zl))==null||s.remove(),p(this,zl,null);break}}async addButton(t,e){switch(t){case"colorPicker":e&&this.addColorPicker(e);break;case"altText":e&&await this.addAltText(e);break;case"editSignature":e&&await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":e&&this.addComment(e);break}}async addButtonBefore(t,e,s){if(!e&&t==="comment")return;const i=n(this,hi).querySelector(s);i&&t==="comment"&&this.addComment(e,i)}updateEditSignatureButton(t){n(this,Vl)&&(n(this,Vl).title=t)}remove(){var t;n(this,kr).remove(),(t=n(this,Tr))==null||t.destroy(),p(this,Tr,null)}};kr=new WeakMap,Tr=new WeakMap,ci=new WeakMap,hi=new WeakMap,ed=new WeakMap,Pr=new WeakMap,zl=new WeakMap,Vl=new WeakMap,sd=new WeakMap,ip=new WeakSet,rb=function(t){t.stopPropagation()},qe=new WeakSet,ab=function(t){n(this,ci)._focusEventsAllowed=!1,ne(t)},ob=function(t){n(this,ci)._focusEventsAllowed=!0,ne(t)},Fl=function(t){const e=n(this,ci)._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",v(this,qe,ab).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",v(this,qe,ob).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",_i,{signal:e}),!0)},xh=function(){const t=document.createElement("div");return t.className="divider",t},m(Mn,ip),m(Mn,sd,null);let ug=Mn;var id,Wa,Dn,yr,lb,cb,fg;class zS{constructor(t){m(this,yr);m(this,id,null);m(this,Wa,null);m(this,Dn);p(this,Dn,t)}show(t,e,s){const[i,r]=v(this,yr,cb).call(this,e,s),{style:a}=n(this,Wa)||p(this,Wa,v(this,yr,lb).call(this));t.append(n(this,Wa)),a.insetInlineEnd=`${100*i}%`,a.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){n(this,Wa).remove()}}id=new WeakMap,Wa=new WeakMap,Dn=new WeakMap,yr=new WeakSet,lb=function(){const t=p(this,Wa,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar");const e=n(this,Dn)._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",_i,{signal:e});const s=p(this,id,document.createElement("div"));return s.className="buttons",t.append(s),n(this,Dn).hasCommentManager()&&v(this,yr,fg).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{n(this,Dn).commentSelection("floating_button")}),v(this,yr,fg).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{n(this,Dn).highlightSelection("floating_button")}),t},cb=function(t,e){let s=0,i=0;for(const r of t){const a=r.y+r.height;if(as){i=o,s=a;continue}e?o>i&&(i=o):o=1}static clearPointerType(){p(Ft,Ya,null)}static clearPointerIds(){p(Ft,Xa,NaN),p(Ft,qa,null)}static clearTimeStamp(){p(Ft,Gl,NaN)}};Xa=new WeakMap,qa=new WeakMap,Gl=new WeakMap,Ya=new WeakMap,m(Ft,Xa,NaN),m(Ft,qa,null),m(Ft,Gl,NaN),m(Ft,Ya,null);let Je=Ft;var np;class GS{constructor(){m(this,np,0)}get id(){return`${Yh}${Yt(this,np)._++}`}}np=new WeakMap;var jl,nd,Ze,Wl,of;const Qm=class Qm{constructor(){m(this,Wl);m(this,jl,eb());m(this,nd,0);m(this,Ze,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 at(this,"_isSVGFittingCanvas",r)}async getFromFile(t){const{lastModified:e,name:s,size:i,type:r}=t;return v(this,Wl,of).call(this,`${e}_${s}_${i}_${r}`,t)}async getFromUrl(t){return v(this,Wl,of).call(this,t,t)}async getFromBlob(t,e){const s=await e;return v(this,Wl,of).call(this,t,s)}async getFromId(t){n(this,Ze)||p(this,Ze,new Map);const e=n(this,Ze).get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){n(this,Ze)||p(this,Ze,new Map);let s=n(this,Ze).get(t);if(s!=null&&s.bitmap)return s.refCounter+=1,s;const i=new OffscreenCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${n(this,jl)}_${Yt(this,nd)._++}`,refCounter:1,isSvg:!1},n(this,Ze).set(t,s),n(this,Ze).set(s.id,s),s}getSvgUrl(t){const e=n(this,Ze).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var i;n(this,Ze)||p(this,Ze,new Map);const e=n(this,Ze).get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const r=new OffscreenCanvas(s.width,s.height);r.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=r.convertToBlob()}(i=s.close)==null||i.call(s),e.bitmap=null}isValidId(t){return t.startsWith(`image_${n(this,jl)}_`)}};jl=new WeakMap,nd=new WeakMap,Ze=new WeakMap,Wl=new WeakSet,of=async function(t,e){n(this,Ze)||p(this,Ze,new Map);let s=n(this,Ze).get(t);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${n(this,jl)}_${Yt(this,nd)._++}`,refCounter:0,isSvg:!1});let i;if(typeof e=="string"?(s.url=e,i=await zm(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const r=Qm._isSVGFittingCanvas,a=new FileReader,o=new Image,l=new Promise((c,h)=>{o.onload=()=>{s.bitmap=o,s.isSvg=!0,c()},a.onload=async()=>{const d=s.svgUrl=a.result;o.src=await r?`${d}#svgView(preserveAspectRatio(none))`:d},o.onerror=a.onerror=h});a.readAsDataURL(i),await l}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){dt(i),s=null}return n(this,Ze).set(t,s),s&&n(this,Ze).set(s.id,s),s};let pg=Qm;var fe,Mr,rd,se;class jS{constructor(t=128){m(this,fe,[]);m(this,Mr,!1);m(this,rd);m(this,se,-1);p(this,rd,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:r=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(i&&t(),n(this,Mr))return;const l={cmd:t,undo:e,post:s,type:r};if(n(this,se)===-1){n(this,fe).length>0&&(n(this,fe).length=0),p(this,se,0),n(this,fe).push(l);return}if(a&&n(this,fe)[n(this,se)].type===r){o&&(l.undo=n(this,fe)[n(this,se)].undo),n(this,fe)[n(this,se)]=l;return}const c=n(this,se)+1;c===n(this,rd)?n(this,fe).splice(0,1):(p(this,se,c),c=0;e--)if(n(this,fe)[e].type!==t){n(this,fe).splice(e+1,n(this,se)-e),p(this,se,e);return}n(this,fe).length=0,p(this,se,-1)}}destroy(){p(this,fe,null)}}fe=new WeakMap,Mr=new WeakMap,rd=new WeakMap,se=new WeakMap;var mh,db,ub;const ys=class ys{constructor(t){var s;this.callbacks=new Map;const{isMac:e}=Ut.platform;for(const[i,r,a={}]of t){const o=i.some(l=>l.startsWith("mac+"));for(const l of i){let c=l;if(o){const f=l.startsWith("mac+");if(e!==f)continue;f&&(c=l.slice(4))}const[h,d]=v(s=ys,mh,db).call(s,c);h!==null&&this.callbacks.getOrInsertComputed(h,Vu).push({callback:r,options:a,modifiers:d})}}}exec(t,e){var h;let s=this.callbacks.get(e.key);if(!s){if(/^[a-z]$/i.test(e.key))return;const d=v(h=ys,mh,ub).call(h,e.code);if(d===null||d===e.key||(s=this.callbacks.get(d),!s))return}const i=(e.altKey?ys.ALT:0)|(e.ctrlKey?ys.CTRL:0)|(e.metaKey?ys.META:0)|(e.shiftKey?ys.SHIFT:0),r=s.find(d=>d.modifiers===i);if(!r)return;const{callback:a,options:{bubbles:o=!1,args:l=[],checker:c=null}}=r;c&&!c(t,e)||(a.bind(t,...l,e)(),o||ne(e))}};mh=new WeakSet,db=function(t){let e=null,s=0;for(let i of t.split("+")){if(i=i.trim(),!i)continue;const r=i.toUpperCase(),a=ys[r];if(a){s|=a;continue}if(e!==null){dt(`KeyboardManager: multiple keys in shortcut "${t}"`);break}e=r==="SPACE"?" ":i}return e===null&&dt(`KeyboardManager: no key found in shortcut "${t}"`),[e,s]},ub=function(t){var s;const e=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(t);return e?((s=e[1])==null?void 0:s.toLowerCase())??e[2]:null},m(ys,mh),P(ys,"ALT",1),P(ys,"CTRL",2),P(ys,"META",4),P(ys,"SHIFT",8);let El=ys;const rp=class rp{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return NS(t),at(this,"_colors",t)}convert(t){const e=Wu(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((r,a)=>r===e[a]))return rp._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?B.makeHexColor(...e):t}};P(rp,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let gg=rp;var Xl,Bs,ql,ce,ie,Yl,Kl,os,Ql,di,Pe,Ir,Dr,Lr,Fr,Qi,ui,Ka,ad,od,Jl,ld,Ji,Rr,Zl,Or,Zi,ap,Ln,tc,cd,Nr,Qa,ec,Br,hd,be,Rt,Fn,$r,Ur,dd,sc,ud,Hr,tn,Rn,fd,pd,fi,G,lf,mg,fb,pb,gb,Eh,mb,vb,bb,vg,yb,wb,Ab,Sb,rs,Tn,xb,Eb,bg,Cb,Ch,yg;const $l=class $l{constructor(t,e,s,i,r,a,o,l,c,h,d,f,g,y,b,S){m(this,G);m(this,Xl,new AbortController);m(this,Bs,null);m(this,ql,null);m(this,ce,new Map);m(this,ie,new Map);m(this,Yl,null);m(this,Kl,null);m(this,os,null);m(this,Ql,null);m(this,di,new jS);m(this,Pe,null);m(this,Ir,null);m(this,Dr,null);m(this,Lr,0);m(this,Fr,new Set);m(this,Qi,null);m(this,ui,null);m(this,Ka,new Set);P(this,"_editorUndoBar",null);m(this,ad,!1);m(this,od,!1);m(this,Jl,!1);m(this,ld,null);m(this,Ji,null);m(this,Rr,null);m(this,Zl,null);m(this,Or,!1);m(this,Zi,null);m(this,ap,new GS);m(this,Ln,!1);m(this,tc,!1);m(this,cd,!1);m(this,Nr,null);m(this,Qa,null);m(this,ec,null);m(this,Br,null);m(this,hd,null);m(this,be,lt.NONE);m(this,Rt,new Set);m(this,Fn,null);m(this,$r,null);m(this,Ur,null);m(this,dd,null);m(this,sc,null);m(this,ud,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});m(this,Hr,[0,0]);m(this,tn,null);m(this,Rn,null);m(this,fd,null);m(this,pd,null);m(this,fi,null);const w=this._signal=n(this,Xl).signal;p(this,Rn,t),p(this,fd,e),p(this,pd,s),p(this,Kl,i),p(this,Pe,r),p(this,$r,a),p(this,sc,l),this._eventBus=o;const E={signal:w,...Qp};o.on("editingaction",this.onEditingAction.bind(this),E),o.on("pagechanging",this.onPageChanging.bind(this),E),o.on("scalechanging",this.onScaleChanging.bind(this),E),o.on("rotationchanging",this.onRotationChanging.bind(this),E),o.on("setpreference",this.onSetPreference.bind(this),E),o.on("switchannotationeditorparams",A=>this.updateParams(A.type,A.value),E),window.addEventListener("pointerdown",()=>{p(this,tc,!0)},{capture:!0,signal:w}),window.addEventListener("pointerup",()=>{p(this,tc,!1)},{capture:!0,signal:w}),window.addEventListener("beforeunload",v(this,G,fb).bind(this),{capture:!0,signal:w}),v(this,G,mb).call(this),v(this,G,Sb).call(this),v(this,G,vg).call(this),p(this,os,l.annotationStorage),p(this,ld,l.filterFactory),p(this,Ur,c),p(this,Zl,h||null),p(this,ad,d),p(this,od,f),p(this,Jl,g),p(this,hd,y||null),this.viewParameters={realScale:ka.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=b||null,this._supportsPinchToZoom=S!==!1,r==null||r.setSidebarUiManager(this)}static get _keyboardManager(){const t=$l.prototype,e=a=>n(a,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 at(this,"_keyboardManager",new El([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:s}],[["Enter"],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&n(a,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,fi))==null||t.resolve(),p(this,fi,null),(e=n(this,Xl))==null||e.abort(),p(this,Xl,null),this._signal=null;for(const h of n(this,ie).values())h.destroy();n(this,ie).clear(),n(this,ce).clear(),n(this,Ka).clear(),(s=n(this,Br))==null||s.clear(),p(this,Bs,null),n(this,Rt).clear(),n(this,di).destroy(),(i=n(this,Kl))==null||i.destroy(),(r=n(this,Pe))==null||r.destroy(),(a=n(this,$r))==null||a.destroy(),(o=n(this,Zi))==null||o.hide(),p(this,Zi,null),(l=n(this,ec))==null||l.destroy(),p(this,ec,null),p(this,ql,null),n(this,Ji)&&(clearTimeout(n(this,Ji)),p(this,Ji,null)),n(this,tn)&&(clearTimeout(n(this,tn)),p(this,tn,null)),(c=this._editorUndoBar)==null||c.destroy(),p(this,sc,null)}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return n(this,hd)}get useNewAltTextFlow(){return n(this,od)}get useNewAltTextWhenAddingImage(){return n(this,Jl)}get hcmFilter(){return at(this,"hcmFilter",n(this,Ur)?n(this,ld).addHCMFilter(n(this,Ur).foreground,n(this,Ur).background):"none")}get direction(){return at(this,"direction",getComputedStyle(n(this,Rn)).direction)}get _highlightColors(){return at(this,"_highlightColors",n(this,Zl)?new Map(n(this,Zl).split(",").map(t=>(t=t.split("=").map(e=>e.trim()),t[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return at(this,"highlightColors",null);const e=new Map,s=!!n(this,Ur);for(const[i,r]of t){const a=i.endsWith("_HCM");if(s&&a){e.set(i.replace("_HCM",""),r);continue}!s&&!a&&e.set(i,r)}return at(this,"highlightColors",e)}get highlightColorNames(){return at(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),p(this,Dr,t)}setMainHighlightColorPicker(t){p(this,ec,t)}editAltText(t,e=!1){var s;(s=n(this,Kl))==null||s.editAltText(this,t,e)}hasCommentManager(){return!!n(this,Pe)}editComment(t,e,s,i){var r;(r=n(this,Pe))==null||r.showDialog(this,t,e,s,i)}selectComment(t,e){const s=n(this,ie).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,ie).has(t-1))return;const{resolve:e,promise:s}=Promise.withResolvers(),i=r=>{r.pageNumber===t&&(this._eventBus.off("editorsrendered",i),e())};this._eventBus.on("editorsrendered",i,Qp),await s}getSignature(t){var e;(e=n(this,$r))==null||e.getSignature({uiManager:this,editor:t})}get signatureManager(){return n(this,$r)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal,...Qp}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){switch(t){case"enableNewAltTextWhenAddingImage":p(this,Jl,e);break}}onPageChanging({pageNumber:t}){p(this,Lr,t-1)}deletePage(t){for(const e of this.getEditors(t))e.remove();n(this,ie).delete(t),n(this,Lr)===t&&p(this,Lr,0)}focusMainContainer(){n(this,Rn).focus()}findParent(t,e){for(const s of n(this,ie).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,fd).classList.toggle("noUserSelect",t)}addShouldRescale(t){n(this,Ka).add(t)}removeShouldRescale(t){n(this,Ka).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*ka.PDF_TO_CSS_UNITS;for(const s of n(this,Ka))s.onScaleChanging();(e=n(this,Dr))==null||e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t="",e=!1){const s=document.getSelection();if(!s||s.isCollapsed)return;const{anchorNode:i,anchorOffset:r,focusNode:a,focusOffset:o}=s,l=s.toString(),h=v(this,G,lf).call(this,s).closest(".textLayer"),d=this.getSelectionBoxes(h);if(!d)return;s.empty();const f=v(this,G,mg).call(this,h),g=n(this,be)===lt.NONE,y=()=>{const b=f==null?void 0:f.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:d,anchorNode:i,anchorOffset:r,focusNode:a,focusOffset:o,text:l});g&&this.showAllEditors("highlight",!0,!0),e&&(b==null||b.editComment())};if(g){this.switchToMode(lt.HIGHLIGHT,y);return}y()}commentSelection(t=""){this.highlightSelection(t,!0)}getAndRemoveDataFromAnnotationStorage(t){if(!n(this,os))return null;const e=`${Yh}${t}`,s=n(this,os).getRawValue(e);return s&&n(this,os).remove(e),s}addToAnnotationStorage(t){!t.isEmpty()&&n(this,os)&&!n(this,os).has(t.id)&&n(this,os).setValue(t.id,t)}a11yAlert(t,e=null){const s=n(this,pd);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,Or)&&(p(this,Or,!1),v(this,G,Eh).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,Qa,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!n(this,Qa))return;const[t,e]=n(this,Qa);p(this,Qa,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){v(this,G,vg).call(this),this.setEditingState(!0)}removeEditListeners(){v(this,G,yb).call(this),this.setEditingState(!1)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of n(this,ui))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,ui))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=n(this,Bs))==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,ui))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){dt(`paste: "${r.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const r=[];for(const l of s){const c=await i.deserialize(l);if(!c)return;r.push(c)}const a=()=>{for(const l of r)v(this,G,bg).call(this,l);v(this,G,yg).call(this,r)},o=()=>{for(const l of r)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(r){dt(`paste: "${r.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),n(this,be)!==lt.NONE&&!this.isEditorHandlingKeyboard&&$l._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,n(this,Or)&&(p(this,Or,!1),v(this,G,Eh).call(this,"main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}updatePageIndex(t,e){for(const i of this.getEditors(t))i.pageIndex=e;const s=n(this,Yl).get(t);s&&(s.pageIndex=e,n(this,ie).set(e,s),n(this,Ln)?s.enable():s.disable())}startUpdatePages(){p(this,Yl,new Map(n(this,ie))),n(this,ie).clear()}endUpdatePages(){p(this,Yl,null)}clonePage(t,e){for(const s of this.getEditors(t)){const i=s.serialize(s.mode!==lt.HIGHLIGHT);i&&(i.pageIndex=e,i.id=this.getId(),i.isClone=!0,delete i.popupRef,n(this,os).setValue(i.id,i))}}findClonesForPage(t){const e=[],{pageIndex:s}=t;for(const[i,r]of n(this,os))r.pageIndex===s&&r.isClone&&(n(this,os).remove(i),e.push(t.deserialize(r).then(a=>{a&&(a.isClone=!0,t.addOrRebuild(a))})));return Promise.all(e)}setEditingState(t){t?(v(this,G,vb).call(this),v(this,G,wb).call(this),v(this,G,rs).call(this,{isEditing:n(this,be)!==lt.NONE,isEmpty:v(this,G,Ch).call(this),hasSomethingToUndo:n(this,di).hasSomethingToUndo(),hasSomethingToRedo:n(this,di).hasSomethingToRedo(),hasSelectedEditor:!1})):(v(this,G,bb).call(this),v(this,G,Ab).call(this),v(this,G,rs).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!n(this,ui)){p(this,ui,t);for(const e of n(this,ui))v(this,G,Tn).call(this,e.defaultPropertiesToUpdate)}}getId(){return n(this,ap).id}get currentLayer(){return n(this,ie).get(n(this,Lr))}getLayer(t){return n(this,ie).get(t)}get currentPageIndex(){return n(this,Lr)}addLayer(t){n(this,ie).set(t.pageIndex,t),n(this,Ln)?t.enable():t.disable()}removeLayer(t){n(this,ie).delete(t.pageIndex)}async updateMode(t,e=null,s=!1,i=!1,r=!1,a=!1){var o,l,c,h,d,f;if(n(this,be)!==t&&!(n(this,fi)&&(await n(this,fi).promise,!n(this,fi)))){if(p(this,fi,Promise.withResolvers()),(o=n(this,Dr))==null||o.commitOrRemove(),n(this,be)===lt.POPUP&&((l=n(this,Pe))==null||l.hideSidebar()),(c=n(this,Pe))==null||c.destroyPopup(),p(this,be,t),t===lt.NONE){this.setEditingState(!1),v(this,G,Eb).call(this);for(const g of n(this,ce).values())g.hideStandaloneCommentButton();(h=this._editorUndoBar)==null||h.hide(),this.toggleComment(null),n(this,fi).resolve();return}for(const g of n(this,ce).values())g.addStandaloneCommentButton();t===lt.SIGNATURE&&await((d=n(this,$r))==null?void 0:d.loadSignatures()),s&&Je.clearPointerType(),this.setEditingState(!0),await v(this,G,xb).call(this),this.unselectAll();for(const g of n(this,ie).values())g.updateMode(t);if(t===lt.POPUP){n(this,ql)||p(this,ql,await n(this,sc).getAnnotationsByType(new Set(n(this,ui).map(b=>b._editorType))));const g=new Set,y=[];for(const b of n(this,ce).values()){const{annotationElementId:S,hasComment:w,deleted:E}=b;S&&g.add(S),w&&!E&&y.push(b.getData())}for(const b of n(this,ql)){const{id:S,popupRef:w,contentsObj:E}=b;w&&(E!=null&&E.str)&&!g.has(S)&&!n(this,Fr).has(S)&&y.push(b)}(f=n(this,Pe))==null||f.showSidebar(y)}if(!e){i&&this.addNewEditorFromKeyboard(),n(this,fi).resolve();return}for(const g of n(this,ce).values())g.uid===e?(this.setSelected(g),a?g.editComment():r?g.enterInEditMode():g.focus()):g.unselect();n(this,fi).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==n(this,be)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(n(this,ui)){switch(t){case gt.CREATE:this.currentLayer.addNewEditor(e);return;case gt.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(n(this,dd)||p(this,dd,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,ui))s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var r;for(const a of n(this,ce).values())a.editorType===t&&a.show(e);(((r=n(this,dd))==null?void 0:r.get(gt.HIGHLIGHT_SHOW_ALL))??!0)!==e&&v(this,G,Tn).call(this,[[gt.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(n(this,cd)!==t){p(this,cd,t);for(const e of n(this,ie).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}*getEditors(t){for(const e of n(this,ce).values())e.pageIndex===t&&(yield e)}getEditor(t){return n(this,ce).get(t)}addEditor(t){n(this,ce).set(t.id,t)}removeEditor(t){var e,s;t.div.contains(document.activeElement)&&(n(this,Ji)&&clearTimeout(n(this,Ji)),p(this,Ji,setTimeout(()=>{this.focusMainContainer(),p(this,Ji,null)},0))),n(this,ce).delete(t.id),t.annotationElementId&&((e=n(this,Br))==null||e.delete(t.annotationElementId)),this.unselect(t),(!t.annotationElementId||!n(this,Fr).has(t.annotationElementId))&&((s=n(this,os))==null||s.remove(t.id))}addDeletedAnnotationElement(t){n(this,Fr).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return n(this,Fr).has(t)}removeDeletedAnnotationElement(t){n(this,Fr).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){n(this,Bs)!==t&&(p(this,Bs,t),t&&v(this,G,Tn).call(this,t.propertiesToUpdate))}updateUI(t){n(this,G,Cb)===t&&v(this,G,Tn).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){v(this,G,Tn).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(n(this,Rt).has(t)){n(this,Rt).delete(t),t.unselect(),v(this,G,rs).call(this,{hasSelectedEditor:this.hasSelection});return}n(this,Rt).add(t),t.select(),v(this,G,Tn).call(this,t.propertiesToUpdate),v(this,G,rs).call(this,{hasSelectedEditor:!0})}setSelected(t){var e,s;this.updateToolbar({mode:t.mode,editId:t.uid}),(e=n(this,Dr))==null||e.commitOrRemove();for(const i of n(this,Rt))i!==t&&i.unselect();(s=n(this,Pe))==null||s.destroyPopup(),n(this,Rt).clear(),n(this,Rt).add(t),t.select(),v(this,G,Tn).call(this,t.propertiesToUpdate),v(this,G,rs).call(this,{hasSelectedEditor:!0})}get firstSelectedEditor(){return n(this,Rt).values().next().value}unselect(t){t.unselect(),n(this,Rt).delete(t),v(this,G,rs).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,di).undo(),v(this,G,rs).call(this,{hasSomethingToUndo:n(this,di).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:v(this,G,Ch).call(this)}),(t=this._editorUndoBar)==null||t.hide()}redo(){n(this,di).redo(),v(this,G,rs).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:n(this,di).hasSomethingToRedo(),isEmpty:v(this,G,Ch).call(this)})}addCommands(t){n(this,di).add(t),v(this,G,rs).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:v(this,G,Ch).call(this)})}cleanUndoStack(t){n(this,di).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)v(this,G,bg).call(this,a)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){var t;(t=n(this,Bs))==null||t.commitOrRemove()}hasSomethingToControl(){return n(this,Bs)||this.hasSelection}selectAll(){for(const t of n(this,Rt))t.commit();v(this,G,yg).call(this,n(this,ce).values())}unselectAll(){var t,e;if(!(n(this,Bs)&&(n(this,Bs).commitOrRemove(),n(this,be)!==lt.NONE))&&!((t=n(this,Dr))!=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(),v(this,G,rs).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;n(this,Hr)[0]+=t,n(this,Hr)[1]+=e;const[i,r]=n(this,Hr),a=[...n(this,Rt)],o=1e3;n(this,tn)&&clearTimeout(n(this,tn)),p(this,tn,setTimeout(()=>{p(this,tn,null),n(this,Hr)[0]=n(this,Hr)[1]=0,this.addCommands({cmd:()=>{for(const l of a)n(this,ce).has(l.id)&&(l.translateInPage(i,r),l.translationDone())},undo:()=>{for(const l of a)n(this,ce).has(l.id)&&(l.translateInPage(-i,-r),l.translationDone())},mustExec:!1})},o));for(const l of a)l.translateInPage(t,e),l.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),p(this,Qi,new Map);for(const t of n(this,Rt))n(this,Qi).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!n(this,Qi))return!1;this.disableUserSelect(!1);const t=n(this,Qi);p(this,Qi,null);let e=!1;for(const[{x:i,y:r,pageIndex:a},o]of t)o.newX=i,o.newY=r,o.newPageIndex=a,e||(e=i!==o.savedX||r!==o.savedY||a!==o.savedPageIndex);if(!e)return!1;const s=(i,r,a,o)=>{if(n(this,ce).has(i.id)){const l=n(this,ie).get(o);l?i._setParentAndPosition(l,r,a):(i.pageIndex=o,i.x=r,i.y=a)}};return this.addCommands({cmd:()=>{for(const[i,{newX:r,newY:a,newPageIndex:o}]of t)s(i,r,a,o)},undo:()=>{for(const[i,{savedX:r,savedY:a,savedPageIndex:o}]of t)s(i,r,a,o)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(n(this,Qi))for(const s of n(this,Qi).keys())s.drag(t,e)}rebuild(t){if(t.parent===null){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return((t=this.getActive())==null?void 0:t.shouldGetKeyboardEvents())||n(this,Rt).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return n(this,Bs)===t}getActive(){return n(this,Bs)}getMode(){return n(this,be)}isEditingMode(){return n(this,be)!==lt.NONE}get imageManager(){return at(this,"imageManager",new pg)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let c=0,h=e.rangeCount;c({x:(h-i)/a,y:1-(c+d-s)/r,width:f/a,height:d/r});break;case"180":o=(c,h,d,f)=>({x:1-(c+d-s)/r,y:1-(h+f-i)/a,width:d/r,height:f/a});break;case"270":o=(c,h,d,f)=>({x:1-(h+f-i)/a,y:(c-s)/r,width:f/a,height:d/r});break;default:o=(c,h,d,f)=>({x:(c-s)/r,y:(h-i)/a,width:d/r,height:f/a});break}const l=[];for(let c=0,h=e.rangeCount;c{f.type==="pointerup"&&f.button!==0||(c.abort(),l==null||l.toggleDrawing(!0),f.type==="pointerup"&&v(this,G,Eh).call(this,"main_toolbar"))};window.addEventListener("pointerup",d,{signal:h}),window.addEventListener("blur",d,{signal:h})}else l==null||l.toggleDrawing(!0),v(this,G,Eh).call(this,"main_toolbar")}},Eh=function(t=""){n(this,be)===lt.HIGHLIGHT?this.highlightSelection(t):n(this,ad)&&v(this,G,pb).call(this)},mb=function(){document.addEventListener("selectionchange",v(this,G,gb).bind(this),{signal:this._signal})},vb=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})},bb=function(){var t;(t=n(this,Rr))==null||t.abort(),p(this,Rr,null)},vg=function(){if(n(this,Nr))return;p(this,Nr,new AbortController);const t=this.combinedSignal(n(this,Nr));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},yb=function(){var t;(t=n(this,Nr))==null||t.abort(),p(this,Nr,null)},wb=function(){if(n(this,Ir))return;p(this,Ir,new AbortController);const t=this.combinedSignal(n(this,Ir));document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})},Ab=function(){var t;(t=n(this,Ir))==null||t.abort(),p(this,Ir,null)},Sb=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},rs=function(t){Object.entries(t).some(([s,i])=>n(this,ud)[s]!==i)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(n(this,ud),t)}),n(this,be)===lt.HIGHLIGHT&&t.hasSelectedEditor===!1&&v(this,G,Tn).call(this,[[gt.HIGHLIGHT_FREE,!0]]))},Tn=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},xb=async function(){if(!n(this,Ln)){p(this,Ln,!0);const t=[];for(const e of n(this,ie).values())t.push(e.enable());await Promise.all(t);for(const e of n(this,ce).values())e.enable()}},Eb=function(){if(this.unselectAll(),n(this,Ln)){p(this,Ln,!1);for(const t of n(this,ie).values())t.disable();for(const t of n(this,ce).values())t.disable()}},bg=function(t){const e=n(this,ie).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},Cb=function(){let t=null;for(t of n(this,Rt));return t},Ch=function(){if(n(this,ce).size===0)return!0;if(n(this,ce).size===1)for(const t of n(this,ce).values())return t.isEmpty();return!1},yg=function(t){for(const e of n(this,Rt))e.unselect();n(this,Rt).clear();for(const e of t)e.isEmpty()||(n(this,Rt).add(e),e.select());v(this,G,rs).call(this,{hasSelectedEditor:this.hasSelection})},P($l,"TRANSLATE_SMALL",1),P($l,"TRANSLATE_BIG",10);let Cl=$l;var Me,en,Ii,ic,sn,$s,nc,nn,As,On,Ja,rn,zr,ji,_h,cf;const as=class as{constructor(t){m(this,ji);m(this,Me,null);m(this,en,!1);m(this,Ii,null);m(this,ic,null);m(this,sn,null);m(this,$s,null);m(this,nc,!1);m(this,nn,null);m(this,As,null);m(this,On,null);m(this,Ja,null);m(this,rn,!1);p(this,As,t),p(this,rn,t._uiManager.useNewAltTextFlow),n(as,zr)||p(as,zr,Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(t){as._l10n??(as._l10n=t)}async render(){const t=p(this,Ii,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=p(this,ic,document.createElement("span"));t.append(e),n(this,rn)?(t.classList.add("new"),t.setAttribute("data-l10n-id",n(as,zr).missing),e.setAttribute("data-l10n-id",n(as,zr)["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=n(this,As)._uiManager._signal;t.addEventListener("contextmenu",_i,{signal:s}),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),n(this,As)._uiManager.editAltText(n(this,As)),n(this,rn)&&n(this,As)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:n(this,ji,_h)}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(p(this,nc,!0),i(r))},{signal:s}),await v(this,ji,cf).call(this),t}finish(){n(this,Ii)&&(n(this,Ii).focus({focusVisible:n(this,nc)}),p(this,nc,!1))}isEmpty(){return n(this,rn)?n(this,Me)===null:!n(this,Me)&&!n(this,en)}hasData(){return n(this,rn)?n(this,Me)!==null||!!n(this,On):this.isEmpty()}get guessedText(){return n(this,On)}async setGuessedText(t){n(this,Me)===null&&(p(this,On,t),p(this,Ja,await as._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),v(this,ji,cf).call(this))}toggleAltTextBadge(t=!1){var e;if(!n(this,rn)||n(this,Me)){(e=n(this,nn))==null||e.remove(),p(this,nn,null);return}if(!n(this,nn)){const s=p(this,nn,document.createElement("div"));s.className="noAltTextBadge",n(this,As).div.append(s)}n(this,nn).classList.toggle("hidden",!t)}serialize(t){let e=n(this,Me);return!t&&n(this,On)===e&&(e=n(this,Ja)),{altText:e,decorative:n(this,en),guessedText:n(this,On),textWithDisclaimer:n(this,Ja)}}get data(){return{altText:n(this,Me),decorative:n(this,en)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:r=!1}){s&&(p(this,On,s),p(this,Ja,i)),!(n(this,Me)===t&&n(this,en)===e)&&(r||(p(this,Me,t),p(this,en,e)),v(this,ji,cf).call(this))}toggle(t=!1){n(this,Ii)&&(!t&&n(this,$s)&&(clearTimeout(n(this,$s)),p(this,$s,null)),n(this,Ii).disabled=!t)}shown(){n(this,As)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:n(this,ji,_h)}})}destroy(){var t,e;(t=n(this,Ii))==null||t.remove(),p(this,Ii,null),p(this,ic,null),p(this,sn,null),(e=n(this,nn))==null||e.remove(),p(this,nn,null)}};Me=new WeakMap,en=new WeakMap,Ii=new WeakMap,ic=new WeakMap,sn=new WeakMap,$s=new WeakMap,nc=new WeakMap,nn=new WeakMap,As=new WeakMap,On=new WeakMap,Ja=new WeakMap,rn=new WeakMap,zr=new WeakMap,ji=new WeakSet,_h=function(){return n(this,Me)&&"added"||n(this,Me)===null&&this.guessedText&&"review"||"missing"},cf=async function(){var i,r,a;const t=n(this,Ii);if(!t)return;if(n(this,rn)){if(t.classList.toggle("done",!!n(this,Me)),t.setAttribute("data-l10n-id",n(as,zr)[n(this,ji,_h)]),(i=n(this,ic))==null||i.setAttribute("data-l10n-id",n(as,zr)[`${n(this,ji,_h)}-label`]),!n(this,Me)){(r=n(this,sn))==null||r.remove();return}}else{if(!n(this,Me)&&!n(this,en)){t.classList.remove("done"),(a=n(this,sn))==null||a.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=n(this,sn);if(!e){p(this,sn,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${n(this,As).id}`;const o=100,l=n(this,As)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(n(this,$s)),p(this,$s,null)},{once:!0}),t.addEventListener("mouseenter",()=>{p(this,$s,setTimeout(()=>{p(this,$s,null),n(this,sn).classList.add("show"),n(this,As)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),t.addEventListener("mouseleave",()=>{var c;n(this,$s)&&(clearTimeout(n(this,$s)),p(this,$s,null)),(c=n(this,sn))==null||c.classList.remove("show")},{signal:l})}n(this,en)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=n(this,Me)),e.parentNode||t.append(e);const s=n(this,As).getElementForAltText();s==null||s.setAttribute("aria-describedby",e.id)},m(as,zr,null),P(as,"_l10n",null);let Yf=as;var $e,pi,Za,Wt,gd,Vr,gi,Gr,jr,to,md,wg;class qu{constructor(t){m(this,md);m(this,$e,null);m(this,pi,null);m(this,Za,!1);m(this,Wt,null);m(this,gd,null);m(this,Vr,null);m(this,gi,null);m(this,Gr,null);m(this,jr,!1);m(this,to,null);p(this,Wt,t)}renderForToolbar(){const t=p(this,pi,document.createElement("button"));return t.className="comment",v(this,md,wg).call(this,t,!1)}renderForStandalone(){const t=p(this,$e,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 v(this,md,wg).call(this,t,!0)}focusButton(){setTimeout(()=>{var t;(t=n(this,$e)??n(this,pi))==null||t.focus()},0)}onUpdatedColor(){if(!n(this,$e))return;const t=n(this,Wt).commentButtonColor;t&&(n(this,$e).style.backgroundColor=t),n(this,Wt)._uiManager.updatePopupColor(n(this,Wt))}get commentButtonWidth(){var t;return(((t=n(this,$e))==null?void 0:t.getBoundingClientRect().width)??0)/n(this,Wt).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(n(this,to))return n(this,to);if(!n(this,$e))return null;const{x:t,y:e,height:s}=n(this,$e).getBoundingClientRect(),{x:i,y:r,width:a,height:o}=n(this,Wt).parent.boundingClientRect;return[(t-i)/a,(e+s-r)/o]}set commentPopupPositionInLayer(t){p(this,to,t)}hasDefaultPopupPosition(){return n(this,to)===null}removeStandaloneCommentButton(){var t;(t=n(this,$e))==null||t.remove(),p(this,$e,null)}removeToolbarCommentButton(){var t;(t=n(this,pi))==null||t.remove(),p(this,pi,null)}setCommentButtonStates({selected:t,hasPopup:e}){n(this,$e)&&(n(this,$e).classList.toggle("selected",t),n(this,$e).ariaExpanded=e)}edit(t){const e=this.commentPopupPositionInLayer;let s,i;if(e)[s,i]=e;else{[s,i]=n(this,Wt).commentButtonPosition;const{width:h,height:d,x:f,y:g}=n(this,Wt);s=f+s*h,i=g+i*d}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,pi)&&(n(this,pi).focus({focusVisible:n(this,Za)}),p(this,Za,!1))}isDeleted(){return n(this,jr)||n(this,gi)===""}isEmpty(){return n(this,gi)===null}hasBeenEdited(){return this.isDeleted()||n(this,gi)!==n(this,gd)}serialize(){return this.data}get data(){return{text:n(this,gi),richText:n(this,Vr),date:n(this,Gr),deleted:this.isDeleted()}}set data(t){if(t!==n(this,gi)&&p(this,Vr,null),t===null){p(this,gi,""),p(this,jr,!0);return}p(this,gi,t),p(this,Gr,new Date),p(this,jr,!1)}restoreData({text:t,richText:e,date:s}){p(this,gi,t),p(this,Vr,e),p(this,Gr,s),p(this,jr,!1)}setInitialText(t,e=null){p(this,gd,t),this.data=t,p(this,Gr,null),p(this,Vr,e)}shown(){}destroy(){var t,e;(t=n(this,pi))==null||t.remove(),p(this,pi,null),(e=n(this,$e))==null||e.remove(),p(this,$e,null),p(this,gi,""),p(this,Vr,null),p(this,Gr,null),p(this,Wt,null),p(this,Za,!1),p(this,jr,!1)}}$e=new WeakMap,pi=new WeakMap,Za=new WeakMap,Wt=new WeakMap,gd=new WeakMap,Vr=new WeakMap,gi=new WeakMap,Gr=new WeakMap,jr=new WeakMap,to=new WeakMap,md=new WeakSet,wg=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",_i,{signal:s}),e&&(t.addEventListener("focusin",r=>{n(this,Wt)._focusEventsAllowed=!1,ne(r)},{capture:!0,signal:s}),t.addEventListener("focusout",r=>{n(this,Wt)._focusEventsAllowed=!0,ne(r)},{capture:!0,signal:s})),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),t===n(this,pi)?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,Za,!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 rc,eo,vd,bd,yd,wd,Ad,Nn,so,Bn,io,$n,Ta,_b,kb,Tb;const Jm=class Jm{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:r=null,onPinchEnd:a=null,signal:o}){m(this,Ta);m(this,rc);m(this,eo,!1);m(this,vd,null);m(this,bd);m(this,yd);m(this,wd);m(this,Ad);m(this,Nn,null);m(this,so);m(this,Bn,null);m(this,io);m(this,$n,null);p(this,rc,t),p(this,vd,s),p(this,bd,e),p(this,yd,i),p(this,wd,r),p(this,Ad,a),p(this,io,new AbortController),p(this,so,AbortSignal.any([o,n(this,io).signal])),t.addEventListener("touchstart",v(this,Ta,_b).bind(this),{passive:!1,signal:n(this,so)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/En.pixelRatio}destroy(){var t,e;(t=n(this,io))==null||t.abort(),p(this,io,null),(e=n(this,Nn))==null||e.abort(),p(this,Nn,null)}};rc=new WeakMap,eo=new WeakMap,vd=new WeakMap,bd=new WeakMap,yd=new WeakMap,wd=new WeakMap,Ad=new WeakMap,Nn=new WeakMap,so=new WeakMap,Bn=new WeakMap,io=new WeakMap,$n=new WeakMap,Ta=new WeakSet,_b=function(t){var i,r,a;if((i=n(this,bd))!=null&&i.call(this))return;if(t.touches.length===1){if(n(this,Nn))return;const o=p(this,Nn,new AbortController),l=AbortSignal.any([n(this,so),o.signal]),c=n(this,rc),h={capture:!0,signal:l,passive:!1},d=f=>{var g;f.pointerType==="touch"&&((g=n(this,Nn))==null||g.abort(),p(this,Nn,null))};c.addEventListener("pointerdown",f=>{f.pointerType==="touch"&&(ne(f),d(f))},h),c.addEventListener("pointerup",d,h),c.addEventListener("pointercancel",d,h);return}if(!n(this,$n)){p(this,$n,new AbortController);const o=AbortSignal.any([n(this,so),n(this,$n).signal]),l=n(this,rc),c={signal:o,capture:!1,passive:!1};l.addEventListener("touchmove",v(this,Ta,kb).bind(this),c);const h=v(this,Ta,Tb).bind(this);l.addEventListener("touchend",h,c),l.addEventListener("touchcancel",h,c),c.capture=!0,l.addEventListener("pointerdown",ne,c),l.addEventListener("pointermove",ne,c),l.addEventListener("pointercancel",ne,c),l.addEventListener("pointerup",ne,c),(r=n(this,yd))==null||r.call(this)}if(ne(t),t.touches.length!==2||(a=n(this,vd))!=null&&a.call(this)){p(this,Bn,null);return}let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]),p(this,Bn,{touch0X:e.screenX,touch0Y:e.screenY,touch1X:s.screenX,touch1Y:s.screenY})},kb=function(t){var _;if(!n(this,Bn)||t.touches.length!==2)return;ne(t);let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]);const{screenX:i,screenY:r}=e,{screenX:a,screenY:o}=s,l=n(this,Bn),{touch0X:c,touch0Y:h,touch1X:d,touch1Y:f}=l,g=d-c,y=f-h,b=a-i,S=o-r,w=Math.hypot(b,S)||1,E=Math.hypot(g,y)||1;if(!n(this,eo)&&Math.abs(E-w)<=Jm.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=i,l.touch0Y=r,l.touch1X=a,l.touch1Y=o,!n(this,eo)){p(this,eo,!0);return}const A=[(i+a)/2,(r+o)/2];(_=n(this,wd))==null||_.call(this,A,E,w)},Tb=function(t){var e;t.touches.length>=2||(n(this,$n)&&(n(this,$n).abort(),p(this,$n,null),(e=n(this,Ad))==null||e.call(this)),n(this,Bn)&&(ne(t),p(this,Bn,null),p(this,eo,!1)))};let Kf=Jm;var no,Di,Zt,It,Un,ac,Wr,Sd,Ue,ro,Hn,mi,Xr,xd,ao,Us,Ed,oo,zn,an,oc,lc,vi,lo,Cd,op,it,Ag,_d,Sg,hf,Pb,Mb,xg,df,Eg,Ib,Db,Lb,Cg,Fb,_g,Rb,Ob,Nb,kg,kh;const nt=class nt{constructor(t){m(this,it);m(this,no,null);m(this,Di,null);m(this,Zt,null);m(this,It,null);m(this,Un,null);m(this,ac,!1);m(this,Wr,null);m(this,Sd,"");m(this,Ue,null);m(this,ro,null);m(this,Hn,null);m(this,mi,null);m(this,Xr,null);m(this,xd,"");m(this,ao,!1);m(this,Us,null);m(this,Ed,!1);m(this,oo,!1);m(this,zn,!1);m(this,an,null);m(this,oc,0);m(this,lc,0);m(this,vi,null);m(this,lo,null);P(this,"isSelected",!1);P(this,"_isCopy",!1);P(this,"_editToolbar",null);P(this,"_initialOptions",Object.create(null));P(this,"_initialData",null);P(this,"_isVisible",!0);P(this,"_uiManager",null);P(this,"_focusEventsAllowed",!0);m(this,Cd,!1);m(this,op,nt._zIndex++);this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;const{rotation:e,rawDims:{pageWidth:s,pageHeight:i,pageX:r,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[r,a];const[o,l]=this.parentDimensions;this.x=t.x/o,this.y=t.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const t=nt.prototype._resizeWithKeyboard,e=Cl.TRANSLATE_SMALL,s=Cl.TRANSLATE_BIG;return at(this,"_resizerKeyboardManager",new El([[["ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape"],nt.prototype._stopResizingWithKeyboard]]))}updatePageIndex(t){this.pageIndex=t}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return at(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new WS({id:t._uiManager.getId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(nt._l10n??(nt._l10n=t),nt._l10nAlert??(nt._l10nAlert=Object.freeze({highlight:"pdfjs-editor-highlight-added-alert",freetext:"pdfjs-editor-freetext-added-alert",ink:"pdfjs-editor-ink-added-alert",stamp:"pdfjs-editor-stamp-added-alert",signature:"pdfjs-editor-signature-added-alert"})),nt._l10nResizer??(nt._l10nResizer=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"})),nt._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);nt._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){Ct("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return n(this,Cd)}set _isDraggable(t){var e;p(this,Cd,t),(e=this.div)==null||e.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=n(this,op)}setParent(t){var e;t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(v(this,it,kh).call(this),(e=n(this,mi))==null||e.remove(),p(this,mi,null)),this.parent=t}focusin(t){this._focusEventsAllowed&&(n(this,ao)?p(this,ao,!1):this.parent.setSelected(this))}focusout(t){var s;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const e=t.relatedTarget;e!=null&&e.closest(`#${this.id}`)||(t.preventDefault(),(s=this.parent)!=null&&s.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){const[r,a]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/r,this.y=(e+i)/a,this.fixAndSetPosition()}_moveAfterPaste(t,e){if(this.isClone){delete this.isClone;return}const[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i),this._onTranslated()}translate(t,e){v(this,it,Ag).call(this,this.parentDimensions,t,e)}translateInPage(t,e){n(this,Us)||p(this,Us,[this.x,this.y,this.width,this.height]),v(this,it,Ag).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){n(this,Us)||p(this,Us,[this.x,this.y,this.width,this.height]);const{div:s,parentDimensions:[i,r]}=this;if(this.x+=t/i,this.y+=e/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:d,y:f}=this.div.getBoundingClientRect();this.parent.findNewParent(this,d,f)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this;const[l,c]=this.getBaseTranslation();a+=l,o+=c;const{style:h}=s;h.left=`${(100*a).toFixed(2)}%`,h.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o),s.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!n(this,Us)&&(n(this,Us)[0]!==this.x||n(this,Us)[1]!==this.y)}get _hasBeenResized(){return!!n(this,Us)&&(n(this,Us)[2]!==this.width||n(this,Us)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=nt,i=s/t,r=s/e;switch(this.rotation){case 90:return[-i,r];case 180:return[i,r];case 270:return[i,-r];default:return[-i,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[s,i]}=this;let{x:r,y:a,width:o,height:l}=this;if(o*=s,l*=i,r*=s,a*=i,this._mustFixPosition)switch(t){case 0:r=Jt(r,0,s-o),a=Jt(a,0,i-l);break;case 90:r=Jt(r,0,s-l),a=Jt(a,o,i);break;case 180:r=Jt(r,o,s),a=Jt(a,l,i);break;case 270:r=Jt(r,l,s),a=Jt(a,0,i-o);break}this.x=r/=s,this.y=a/=i;const[c,h]=this.getBaseTranslation();r+=c,a+=h,e.left=`${(100*r).toFixed(2)}%`,e.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){var s;return v(s=nt,_d,Sg).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return v(s=nt,_d,Sg).call(s,t,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(){const{div:{style:t},width:e,height:s}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*s).toFixed(2)}%`}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(t*1e4)/1e4}_onResizing(){}altTextFinish(){var t;(t=n(this,Zt))==null||t.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||n(this,oo))return this._editToolbar;this._editToolbar=new ug(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[e,s]of t)await this._editToolbar.addButton(e,s);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){var t;(t=this._editToolbar)==null||t.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){var t;(t=this._editToolbar)==null||t.removeButton("comment")}removeEditToolbar(){var t,e;(t=this._editToolbar)==null||t.remove(),this._editToolbar=null,(e=n(this,Zt))==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,Zt)||(Yf.initialize(nt._l10n),p(this,Zt,new Yf(this)),n(this,no)&&(n(this,Zt).data=n(this,no),p(this,no,null))),n(this,Zt)}get altTextData(){var t;return(t=n(this,Zt))==null?void 0:t.data}set altTextData(t){n(this,Zt)&&(n(this,Zt).data=t)}get guessedAltText(){var t;return(t=n(this,Zt))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=n(this,Zt))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=n(this,Zt))==null?void 0:e.serialize(t)}hasAltText(){return!!n(this,Zt)&&!n(this,Zt).isEmpty()}hasAltTextData(){var t;return((t=n(this,Zt))==null?void 0:t.hasData())??!1}focusCommentButton(){var t;(t=n(this,It))==null||t.focusButton()}addCommentButton(){return this.canAddComment?n(this,It)||p(this,It,new qu(this)):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(n(this,Un)){this._uiManager.isEditingMode()&&n(this,Un).classList.remove("hidden");return}this.hasComment&&(p(this,Un,n(this,It).renderForStandalone()),this.div.append(n(this,Un)))}}removeStandaloneCommentButton(){n(this,It).removeStandaloneCommentButton(),p(this,Un,null)}hideStandaloneCommentButton(){var t;(t=n(this,Un))==null||t.classList.add("hidden")}get comment(){if(!n(this,It))return null;const{data:{richText:t,text:e,date:s,deleted:i}}=n(this,It);return{text:e,richText:t,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){n(this,It)||p(this,It,new qu(this)),typeof t=="object"&&t!==null?n(this,It).restoreData(t):n(this,It).data=t,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:t,popupRef:e,richText:s}){if(!e||(n(this,It)||p(this,It,new qu(this)),n(this,It).setInitialText(t,s),!this.annotationElementId))return;const i=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);i&&this.updateFromAnnotationLayer(i)}get hasEditedComment(){var t;return(t=n(this,It))==null?void 0:t.hasBeenEdited()}get hasDeletedComment(){var t;return(t=n(this,It))==null?void 0:t.isDeleted()}get hasComment(){return!!n(this,It)&&!n(this,It).isEmpty()&&!n(this,It).isDeleted()}async editComment(t){n(this,It)||p(this,It,new qu(this)),n(this,It).edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){n(this,It).setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const[,,,i]=t.rect,[r]=this.pageDimensions,[a]=this.pageTranslation,o=a+r+1,l=i-100,c=o+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[o,l,c,i]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){n(this,It).data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){var a;const t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=n(this,ac)?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),v(this,it,_g).call(this);const[e,s]=this.parentDimensions;this.parentRotation%180!==0&&(t.style.maxWidth=`${(100*s/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[i,r]=this.getInitialTranslation();return this.translate(i,r),hb(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(n(this,lo)||p(this,lo,new Kf({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:v(this,it,Ib).bind(this),onPinching:v(this,it,Db).bind(this),onPinchEnd:v(this,it,Lb).bind(this),signal:this._uiManager._signal}))),this.addStandaloneCommentButton(),(a=this._uiManager._editorUndoBar)==null||a.hide(),t}pointerdown(t){const{isMac:e}=Ut.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(p(this,ao,!0),this._isDraggable){v(this,it,Fb).call(this,t);return}v(this,it,Cg).call(this,t)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){n(this,an)&&clearTimeout(n(this,an)),p(this,an,setTimeout(()=>{var t;p(this,an,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){const i=this.parentScale,[r,a]=this.pageDimensions,[o,l]=this.pageTranslation,c=t/i,h=e/i,d=this.x*r,f=this.y*a,g=this.width*r,y=this.height*a;switch(s){case 0:return[d+c+o,a-f-h-y+l,d+c+g+o,a-f-h+l];case 90:return[d+h+o,a-f+c+l,d+h+y+o,a-f+c+g+l];case 180:return[d-c-g+o,a-f+h+l,d-c+o,a-f+h+y+l];case 270:return[d-h-y+o,a-f-c-g+l,d-h+o,a-f-c+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,r,a]=t,o=r-s,l=a-i;switch(this.rotation){case 0:return[s,e-a,o,l];case 90:return[s,e-i,l,o];case 180:return[r,e-i,o,l];case 270:return[r,e-a,l,o];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&nt._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){var t;(t=n(this,It))==null||t.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:s,opacity:i,deleted:r,richText:a},uid:o,pageIndex:l,creationDate:c,modificationDate:h}=this;return{id:o,pageIndex:l,rect:this.getPDFRect(),richText:a,contentsObj:{str:t},creationDate:c,modificationDate:s||h,popupRef:!r,color:e,opacity:i}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),p(this,oo,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),p(this,oo,!1),!0):!1}isInEditMode(){return n(this,oo)}shouldGetKeyboardEvents(){return n(this,zn)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:r,innerWidth:a}=window;return e0&&t0}rebuild(){v(this,it,_g).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((t=this._initialData)==null?void 0:t.popupRef)||""}}serialize(t=!1,e=null){var s;return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:((s=this._initialData)==null?void 0:s.popupRef)||""}}static async deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:s.getId(),uiManager:s,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});i.rotation=t.rotation,p(i,no,t.accessibilityData),i._isCopy=t.isCopy||!1;const[r,a]=i.pageDimensions,[o,l,c,h]=i.getRectInCurrentCoords(t.rect,a);return i.x=o/r,i.y=l/a,i.width=c/r,i.height=h/a,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t,e,s;if((t=n(this,Xr))==null||t.abort(),p(this,Xr,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),n(this,an)&&(clearTimeout(n(this,an)),p(this,an,null)),v(this,it,kh).call(this),this.removeEditToolbar(),n(this,vi)){for(const i of n(this,vi).values())clearTimeout(i);p(this,vi,null)}this.parent=null,(e=n(this,lo))==null||e.destroy(),p(this,lo,null),(s=n(this,mi))==null||s.remove(),p(this,mi,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(v(this,it,Pb).call(this),n(this,Ue).classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[t,e]}=this,[s,i,r,a]=this.getPDFRect();return[nt._round(s+(r-s)*t),nt._round(i+(a-i)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return n(this,It).commentPopupPositionInLayer}set commentPopupPosition(t){n(this,It).commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return n(this,It).hasDefaultPopupPosition()}get commentButtonWidth(){return n(this,It).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){var e;(e=n(this,It))==null||e.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),p(this,Hn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=n(this,Ue).children;if(!n(this,Di)){p(this,Di,Array.from(e));const a=v(this,it,Rb).bind(this),o=v(this,it,Ob).bind(this),l=this._uiManager._signal;for(const c of n(this,Di)){const h=c.getAttribute("data-resizer-name");c.setAttribute("role","spinbutton"),c.addEventListener("keydown",a,{signal:l}),c.addEventListener("blur",o,{signal:l}),c.addEventListener("focus",v(this,it,Nb).bind(this,h),{signal:l}),c.setAttribute("data-l10n-id",nt._l10nResizer[h])}}const s=n(this,Di)[0];let i=0;for(const a of e){if(a===s)break;i++}const r=(360-this.rotation+this.parentRotation)%360/90*(n(this,Di).length/4);if(r!==i){if(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,Zt))==null||s.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>{var t;return(t=this.div)==null?void 0:t.focus({preventScroll:!0})},0)}unselect(){var t,e,s,i,r;this.isSelected&&(this.isSelected=!1,(t=n(this,Ue))==null||t.classList.add("hidden"),(e=this.div)==null||e.classList.remove("selectedEditor"),(s=this.div)!=null&&s.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(i=this._editToolbar)==null||i.hide(),(r=n(this,Zt))==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,Ed)}set isEditing(t){p(this,Ed,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,vi)||p(this,vi,new Map);const{action:s}=t;let i=n(this,vi).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),n(this,vi).delete(s),n(this,vi).size===0&&p(this,vi,null)},nt._telemetryTimeout),n(this,vi).set(s,i);return}t.type||(t.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),p(this,ac,!1)}disable(){this.div&&(this.div.tabIndex=-1),p(this,ac,!0)}updateFakeAnnotationElement(t){if(!n(this,mi)&&!this.deleted){p(this,mi,t.addFakeAnnotation(this));return}if(this.deleted){n(this,mi).remove(),p(this,mi,null);return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&n(this,mi).updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){const{firstElementChild:e}=t.container;(e==null?void 0:e.nodeName)==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}};no=new WeakMap,Di=new WeakMap,Zt=new WeakMap,It=new WeakMap,Un=new WeakMap,ac=new WeakMap,Wr=new WeakMap,Sd=new WeakMap,Ue=new WeakMap,ro=new WeakMap,Hn=new WeakMap,mi=new WeakMap,Xr=new WeakMap,xd=new WeakMap,ao=new WeakMap,Us=new WeakMap,Ed=new WeakMap,oo=new WeakMap,zn=new WeakMap,an=new WeakMap,oc=new WeakMap,lc=new WeakMap,vi=new WeakMap,lo=new WeakMap,Cd=new WeakMap,op=new WeakMap,it=new WeakSet,Ag=function([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},_d=new WeakSet,Sg=function(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}},hf=function(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}},Pb=function(){if(n(this,Ue))return;p(this,Ue,document.createElement("div")),n(this,Ue).classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const s of t){const i=document.createElement("div");n(this,Ue).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",v(this,it,Mb).bind(this,s),{signal:e}),i.addEventListener("contextmenu",_i,{signal:e}),i.tabIndex=-1}this.div.prepend(n(this,Ue))},Mb=function(t,e){var h;e.preventDefault();const{isMac:s}=Ut.platform;if(e.button!==0||e.ctrlKey&&s)return;(h=n(this,Zt))==null||h.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,p(this,ro,[e.screenX,e.screenY]);const r=new AbortController,a=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",v(this,it,Eg).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",ne,{passive:!1,signal:a}),window.addEventListener("contextmenu",_i,{signal:a}),p(this,Hn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const c=()=>{var d;r.abort(),this.parent.togglePointerEvents(!0),(d=n(this,Zt))==null||d.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=o,this.div.style.cursor=l,v(this,it,df).call(this)};window.addEventListener("pointerup",c,{signal:a}),window.addEventListener("blur",c,{signal:a})},xg=function(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()},df=function(){if(!n(this,Hn))return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=n(this,Hn);p(this,Hn,null);const r=this.x,a=this.y,o=this.width,l=this.height;r===t&&a===e&&o===s&&l===i||this.addCommands({cmd:v(this,it,xg).bind(this,r,a,o,l),undo:v(this,it,xg).bind(this,t,e,s,i),mustExec:!0})},Eg=function(t,e){const[s,i]=this.parentDimensions,r=this.x,a=this.y,o=this.width,l=this.height,c=nt.MIN_SIZE/s,h=nt.MIN_SIZE/i,d=v(this,it,hf).call(this,this.rotation),f=(T,q)=>[d[0]*T+d[2]*q,d[1]*T+d[3]*q],g=v(this,it,hf).call(this,360-this.rotation),y=(T,q)=>[g[0]*T+g[2]*q,g[1]*T+g[3]*q];let b,S,w=!1,E=!1;switch(t){case"topLeft":w=!0,b=(T,q)=>[0,0],S=(T,q)=>[T,q];break;case"topMiddle":b=(T,q)=>[T/2,0],S=(T,q)=>[T/2,q];break;case"topRight":w=!0,b=(T,q)=>[T,0],S=(T,q)=>[0,q];break;case"middleRight":E=!0,b=(T,q)=>[T,q/2],S=(T,q)=>[0,q/2];break;case"bottomRight":w=!0,b=(T,q)=>[T,q],S=(T,q)=>[0,0];break;case"bottomMiddle":b=(T,q)=>[T/2,q],S=(T,q)=>[T/2,0];break;case"bottomLeft":w=!0,b=(T,q)=>[0,q],S=(T,q)=>[T,0];break;case"middleLeft":E=!0,b=(T,q)=>[0,q/2],S=(T,q)=>[T,q/2];break}const A=b(o,l),_=S(o,l);let x=f(..._);const k=nt._round(r+x[0]),M=nt._round(a+x[1]);let D=1,I=1,L,O;if(e.fromKeyboard)({deltaX:L,deltaY:O}=e);else{const{screenX:T,screenY:q}=e,[Lt,bt]=n(this,ro);[L,O]=this.screenToPageTranslation(T-Lt,q-bt),n(this,ro)[0]=T,n(this,ro)[1]=q}if([L,O]=y(L/s,O/i),w){const T=Math.hypot(o,l);D=I=Math.max(Math.min(Math.hypot(_[0]-A[0]-L,_[1]-A[1]-O)/T,1/o,1/l),c/o,h/l)}else E?D=Jt(Math.abs(_[0]-A[0]-L),c,1)/o:I=Jt(Math.abs(_[1]-A[1]-O),h,1)/l;const Y=nt._round(o*D),W=nt._round(l*I);x=f(...S(Y,W));const Q=k-x[0],ft=M-x[1];n(this,Us)||p(this,Us,[this.x,this.y,this.width,this.height]),this.width=Y,this.height=W,this.x=Q,this.y=ft,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Ib=function(){var t;p(this,Hn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(t=n(this,Zt))==null||t.toggle(!1),this.parent.togglePointerEvents(!1)},Db=function(t,e,s){let r=.7*(s/e)+1-.7;if(r===1)return;const a=v(this,it,hf).call(this,this.rotation),o=(k,M)=>[a[0]*k+a[2]*M,a[1]*k+a[3]*M],[l,c]=this.parentDimensions,h=this.x,d=this.y,f=this.width,g=this.height,y=nt.MIN_SIZE/l,b=nt.MIN_SIZE/c;r=Math.max(Math.min(r,1/f,1/g),y/f,b/g);const S=nt._round(f*r),w=nt._round(g*r);if(S===f&&w===g)return;n(this,Us)||p(this,Us,[h,d,f,g]);const E=o(f/2,g/2),A=nt._round(h+E[0]),_=nt._round(d+E[1]),x=o(S/2,w/2);this.x=A-x[0],this.y=_-x[1],this.width=S,this.height=w,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Lb=function(){var t;(t=n(this,Zt))==null||t.toggle(!0),this.parent.togglePointerEvents(!0),v(this,it,df).call(this)},Cg=function(t){const{isMac:e}=Ut.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Fb=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1;const i=new AbortController,r=this._uiManager.combinedSignal(i),a={capture:!0,passive:!1,signal:r},o=c=>{i.abort(),p(this,Wr,null),p(this,ao,!1),this._uiManager.endDragSession()||v(this,it,Cg).call(this,c),s&&this._onStopDragging()};e&&(p(this,oc,t.clientX),p(this,lc,t.clientY),p(this,Wr,t.pointerId),p(this,Sd,t.pointerType),window.addEventListener("pointermove",c=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:h,clientY:d,pointerId:f}=c;if(f!==n(this,Wr)){ne(c);return}const[g,y]=this.screenToPageTranslation(h-n(this,oc),d-n(this,lc));p(this,oc,h),p(this,lc,d),this._uiManager.dragSelectedEditors(g,y)},a),window.addEventListener("touchmove",ne,a),window.addEventListener("pointerdown",c=>{c.pointerType===n(this,Sd)&&(n(this,lo)||c.isPrimary)&&o(c),ne(c)},a));const l=c=>{if(!n(this,Wr)||n(this,Wr)===c.pointerId){o(c);return}ne(c)};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})},_g=function(){if(n(this,Xr)||!this.div)return;p(this,Xr,new AbortController);const t=this._uiManager.combinedSignal(n(this,Xr));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},Rb=function(t){nt._resizerKeyboardManager.exec(this,t)},Ob=function(t){var e;n(this,zn)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==n(this,Ue)&&v(this,it,kh).call(this)},Nb=function(t){p(this,xd,n(this,zn)?t:"")},kg=function(t){if(n(this,Di))for(const e of n(this,Di))e.tabIndex=t},kh=function(){p(this,zn,!1),v(this,it,kg).call(this,-1),v(this,it,df).call(this)},m(nt,_d),P(nt,"_l10n",null),P(nt,"_l10nAlert",null),P(nt,"_l10nResizer",null),P(nt,"_borderLineWidth",-1),P(nt,"_colorManager",new gg),P(nt,"_zIndex",1),P(nt,"_telemetryTimeout",1e3);let Pt=nt;class WS extends Pt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const bv=3285377520,oi=4294901760,qi=65535;class Tg{constructor(t){this.h1=t?t&4294967295:bv,this.h2=t?t&4294967295:bv}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let b=0,S=t.length;b>>8,e[s++]=w&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,r=s-i*4,a=new Uint32Array(e.buffer,0,i);let o=0,l=0,c=this.h1,h=this.h2;const d=3432918353,f=461845907,g=d&qi,y=f&qi;for(let b=0;b>>17,o=o*f&oi|o*y&qi,c^=o,c=c<<13|c>>>19,c=c*5+3864292196):(l=a[b],l=l*d&oi|l*g&qi,l=l<<15|l>>>17,l=l*f&oi|l*y&qi,h^=l,h=h<<13|h>>>19,h=h*5+3864292196);switch(o=0,r){case 3:o^=e[i*4+2]<<16;case 2:o^=e[i*4+1]<<8;case 1:o^=e[i*4],o=o*d&oi|o*g&qi,o=o<<15|o>>>17,o=o*f&oi|o*y&qi,i&1?c^=o:h^=o}this.h1=c,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&oi|t*36045&qi,e=e*4283543511&oi|((e<<16|t>>>16)*2950163797&oi)>>>16,t^=e>>>1,t=t*444984403&oi|t*60499&qi,e=e*3301882366&oi|((e<<16|t>>>16)*3120437893&oi)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Qh=Object.freeze({map:null,hash:"",transfer:void 0});var co,ho,Vn,He,lp,Bb;class jm{constructor(){m(this,lp);m(this,co,!1);m(this,ho,null);m(this,Vn,null);m(this,He,new Map);P(this,"onSetModified",null);P(this,"onResetModified",null);P(this,"onAnnotationEditor",null)}getValue(t,e){const s=n(this,He).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return n(this,He).get(t)}remove(t){var s;const e=n(this,He).get(t);e!==void 0&&(e instanceof Pt&&n(this,Vn).delete(e.annotationElementId),n(this,He).delete(t),n(this,He).size===0&&this.resetModified(),!n(this,He).values().some(i=>i instanceof Pt)&&((s=this.onAnnotationEditor)==null||s.call(this,null)))}setValue(t,e){var r;const s=n(this,He).get(t);let i=!1;if(s!==void 0)for(const[a,o]of Object.entries(e))s[a]!==o&&(i=!0,s[a]=o);else i=!0,n(this,He).set(t,e);i&&v(this,lp,Bb).call(this),e instanceof Pt&&((n(this,Vn)||p(this,Vn,new Map)).set(e.annotationElementId,e),(r=this.onAnnotationEditor)==null||r.call(this,e.constructor._type))}has(t){return n(this,He).has(t)}get size(){return n(this,He).size}resetModified(){var t;n(this,co)&&(p(this,co,!1),(t=this.onResetModified)==null||t.call(this))}get print(){return new $b(this)}get serializable(){if(n(this,He).size===0)return Qh;const t=new Map,e=new Tg,s=[],i=Object.create(null);let r=!1;for(const[a,o]of n(this,He)){const l=o instanceof Pt?o.serialize(!1,i):o;o.page&&(o.pageIndex=o.page._pageIndex,delete o.page),l&&(t.set(a,l),e.update(`${a}:${JSON.stringify(l)}`),r||(r=!!l.bitmap))}if(r)for(const a of t.values())a.bitmap&&s.push(a.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:Qh}get editorStats(){let t=null;const e=new Map;let s=0,i=0;for(const r of n(this,He).values()){if(!(r instanceof Pt)){r.popup&&(r.popup.deleted?i+=1:s+=1);continue}r.isCommentDeleted?i+=1:r.hasEditedComment&&(s+=1);const a=r.telemetryFinalData;if(!a)continue;const{type:o}=a;e.getOrInsertComputed(o,()=>Object.getPrototypeOf(r).constructor),t||(t=Object.create(null));const l=t[o]||(t[o]=new Map);for(const[c,h]of Object.entries(a)){if(c==="type")continue;const d=l.getOrInsertComputed(c,Hm);d.set(h,(d.get(h)??0)+1)}}if((i>0||s>0)&&(t||(t=Object.create(null)),t.comments={deleted:i,edited:s}),!t)return null;for(const[r,a]of e)t[r]=a.computeTelemetryFinalData(t[r]);return t}resetModifiedIds(){p(this,ho,null)}updateEditor(t,e){var i;const s=(i=n(this,Vn))==null?void 0:i.get(t);return s?(s.updateFromAnnotationLayer(e),!0):!1}getEditor(t){var e;return((e=n(this,Vn))==null?void 0:e.get(t))||null}get modifiedIds(){if(n(this,ho))return n(this,ho);const t=[];if(n(this,Vn))for(const s of n(this,Vn).values())s.serialize()&&t.push(s.annotationElementId);let e="";if(t.length){const s=new Tg;s.update(t.join(",")),e=s.hexdigest()}return p(this,ho,{ids:new Set(t),hash:e})}[Symbol.iterator](){return n(this,He).entries()}}co=new WeakMap,ho=new WeakMap,Vn=new WeakMap,He=new WeakMap,lp=new WeakSet,Bb=function(){var t;n(this,co)||(p(this,co,!0),(t=this.onSetModified)==null||t.call(this))};var kd;class $b extends jm{constructor(e){super();m(this,kd,Qh);const{serializable:s}=e;if(s===Qh)return;const{map:i,hash:r,transfer:a}=s,o=structuredClone(i,a?{transfer:a}:null);p(this,kd,{map:o,hash:r,transfer:[]})}get print(){Ct("Should not call PrintAnnotationStorage.print")}get serializable(){return n(this,kd)}get modifiedIds(){return at(this,"modifiedIds",{ids:new Set,hash:""})}}kd=new WeakMap;const Dl="__forcedDependency",{floor:yv,ceil:wv}=Math;function Av(u,t,e,s,i,r){u[t*4+0]=Math.min(u[t*4+0],e),u[t*4+1]=Math.min(u[t*4+1],s),u[t*4+2]=Math.max(u[t*4+2],i),u[t*4+3]=Math.max(u[t*4+3],r)}function XS(u,t,e,s,i){let r;u?(u<0&&(r=i[0],i[0]=i[2],i[2]=r),i[0]*=u,i[2]*=u,t<0&&(r=i[1],i[1]=i[3],i[3]=r),i[1]*=t,i[3]*=t):i.fill(0),i[0]+=e,i[1]+=s,i[2]+=e,i[3]+=s}const Pg=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];var cc,qr;class qS{constructor(t,e){m(this,cc);m(this,qr);p(this,cc,t),p(this,qr,e)}get length(){return n(this,cc).length}isEmpty(t){return n(this,cc)[t]===Pg}minX(t){return n(this,qr)[t*4+0]/256}minY(t){return n(this,qr)[t*4+1]/256}maxX(t){return(n(this,qr)[t*4+2]+1)/256}maxY(t){return(n(this,qr)[t*4+3]+1)/256}}cc=new WeakMap,qr=new WeakMap;const Sv=(u,t)=>u==null?void 0:u.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1}));var Gn,Tt,Qt,uo,fo,po,ts,Td,Mg;class YS{constructor(t,e){m(this,Td);m(this,Gn,[[1,0,0,1,0,0]]);m(this,Tt,[-1/0,-1/0,1/0,1/0]);m(this,Qt,new Float64Array(mr));P(this,"_pendingBBoxIdx",-1);m(this,uo);m(this,fo);m(this,po);m(this,ts);P(this,"_savesStack",[]);P(this,"_markedContentStack",[]);p(this,uo,t.width),p(this,fo,t.height),v(this,Td,Mg).call(this,e)}growOperationsCount(t){t>=n(this,ts).length&&v(this,Td,Mg).call(this,t,n(this,ts))}get clipBox(){return n(this,Tt)}save(t){return p(this,Tt,{__proto__:n(this,Tt)}),this._savesStack.push(t),this}restore(t,e){const s=Object.getPrototypeOf(n(this,Tt));if(s===null)return this;p(this,Tt,s);const i=this._savesStack.pop();return i!==void 0&&(e==null||e(i,t),n(this,ts)[t]=n(this,ts)[i]),this}recordOpenMarker(t){return this._savesStack.push(t),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(t,e){const s=this._savesStack.pop();return s!==void 0&&(e==null||e(s,t),n(this,ts)[t]=n(this,ts)[s]),this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,e){const s=this._markedContentStack.pop();return s!==void 0&&(e==null||e(s,t),n(this,ts)[t]=n(this,ts)[s]),this}pushBaseTransform(t){return n(this,Gn).push(B.multiplyByDOMMatrix(n(this,Gn).at(-1),t.getTransform())),this}popBaseTransform(){return n(this,Gn).length>1&&n(this,Gn).pop(),this}resetBBox(t){return this._pendingBBoxIdx!==t&&(this._pendingBBoxIdx=t,n(this,Qt).set(mr,0)),this}recordClipBox(t,e,s,i,r,a){const o=B.multiplyByDOMMatrix(n(this,Gn).at(-1),e.getTransform()),l=mr.slice();B.axialAlignedBoundingBox([s,r,i,a],o,l);const c=B.intersect(n(this,Tt),l);return c?(n(this,Tt)[0]=c[0],n(this,Tt)[1]=c[1],n(this,Tt)[2]=c[2],n(this,Tt)[3]=c[3]):(n(this,Tt)[0]=n(this,Tt)[1]=1/0,n(this,Tt)[2]=n(this,Tt)[3]=-1/0),this}recordBBox(t,e,s,i,r,a){const o=n(this,Tt);if(o[0]===1/0)return this;const l=B.multiplyByDOMMatrix(n(this,Gn).at(-1),e.getTransform());if(o[0]===-1/0)return B.axialAlignedBoundingBox([s,r,i,a],l,n(this,Qt)),this;const c=mr.slice();return B.axialAlignedBoundingBox([s,r,i,a],l,c),n(this,Qt)[0]=Jt(c[0],o[0],n(this,Qt)[0]),n(this,Qt)[1]=Jt(c[1],o[1],n(this,Qt)[1]),n(this,Qt)[2]=Jt(c[2],n(this,Qt)[2],o[2]),n(this,Qt)[3]=Jt(c[3],n(this,Qt)[3],o[3]),this}recordFullPageBBox(t){return n(this,Qt)[0]=Math.max(0,n(this,Tt)[0]),n(this,Qt)[1]=Math.max(0,n(this,Tt)[1]),n(this,Qt)[2]=Math.min(n(this,uo),n(this,Tt)[2]),n(this,Qt)[3]=Math.min(n(this,fo),n(this,Tt)[3]),this}recordOperation(t,e=!1,s){if(this._pendingBBoxIdx!==t)return this;const i=yv(n(this,Qt)[0]*256/n(this,uo)),r=yv(n(this,Qt)[1]*256/n(this,fo)),a=wv(n(this,Qt)[2]*256/n(this,uo)),o=wv(n(this,Qt)[3]*256/n(this,fo));if(Av(n(this,po),t,i,r,a,o),s)for(const l of s)for(const c of l)c!==t&&Av(n(this,po),c,i,r,a,o);return e||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(t){return this._pendingBBoxIdx===t&&(this._pendingBBoxIdx=-1,n(this,Tt)[0]=Math.max(n(this,Tt)[0],n(this,Qt)[0]),n(this,Tt)[1]=Math.max(n(this,Tt)[1],n(this,Qt)[1]),n(this,Tt)[2]=Math.min(n(this,Tt)[2],n(this,Qt)[2]),n(this,Tt)[3]=Math.min(n(this,Tt)[3],n(this,Qt)[3])),this}take(){return new qS(n(this,ts),n(this,po))}takeDebugMetadata(){throw new Error("Unreachable")}recordSimpleData(t,e){return this}recordIncrementalData(t,e){return this}resetIncrementalData(t,e){return this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this}recordFutureForcedDependency(t,e){return this}inheritSimpleDataAsFutureForcedDependencies(t){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(t,e,s,i=1,r=0,a=0,o){return this}getSimpleIndex(t){}recordDependencies(t,e){return this}recordNamedDependency(t,e){return this}recordShowTextOperation(t,e=!1){return this}}Gn=new WeakMap,Tt=new WeakMap,Qt=new WeakMap,uo=new WeakMap,fo=new WeakMap,po=new WeakMap,ts=new WeakMap,Td=new WeakSet,Mg=function(t,e){const s=new ArrayBuffer(t*4);p(this,po,new Uint8ClampedArray(s)),p(this,ts,new Uint32Array(s)),e&&e.length>0?(n(this,ts).set(e),n(this,ts).fill(Pg,e.length)):n(this,ts).fill(Pg)};var Ss,xs,go,Li,hc,Yr,Kr,Ot;class KS{constructor(t,e=!1){m(this,Ss,{__proto__:null});m(this,xs,{__proto__:null,transform:[],moveText:[],sameLineText:[],[Dl]:[]});m(this,go,new Map);m(this,Li,new Set);m(this,hc,new Map);m(this,Yr);m(this,Kr);m(this,Ot);p(this,Ot,t),e&&(p(this,Yr,new Map),p(this,Kr,(s,i)=>{Sv(n(this,Yr),i).dependencies.add(s)}))}get clipBox(){return n(this,Ot).clipBox}growOperationsCount(t){n(this,Ot).growOperationsCount(t)}save(t){return p(this,Ss,{__proto__:n(this,Ss)}),p(this,xs,{__proto__:n(this,xs),transform:{__proto__:n(this,xs).transform},moveText:{__proto__:n(this,xs).moveText},sameLineText:{__proto__:n(this,xs).sameLineText},[Dl]:{__proto__:n(this,xs)[Dl]}}),n(this,Ot).save(t),this}restore(t){n(this,Ot).restore(t,n(this,Kr));const e=Object.getPrototypeOf(n(this,Ss));return e===null?this:(p(this,Ss,e),p(this,xs,Object.getPrototypeOf(n(this,xs))),this)}recordOpenMarker(t){return n(this,Ot).recordOpenMarker(t,n(this,Kr)),this}getOpenMarker(){return n(this,Ot).getOpenMarker()}recordCloseMarker(t){return n(this,Ot).recordCloseMarker(t,n(this,Kr)),this}beginMarkedContent(t){return n(this,Ot).beginMarkedContent(t),this}endMarkedContent(t){return n(this,Ot).endMarkedContent(t,n(this,Kr)),this}pushBaseTransform(t){return n(this,Ot).pushBaseTransform(t),this}popBaseTransform(){return n(this,Ot).popBaseTransform(),this}recordSimpleData(t,e){return n(this,Ss)[t]=e,this}recordIncrementalData(t,e){return n(this,xs)[t].push(e),this}resetIncrementalData(t,e){return n(this,xs)[t].length=0,this}recordNamedData(t,e){return n(this,go).set(t,e),this}recordSimpleDataFromNamed(t,e,s){n(this,Ss)[t]=n(this,go).get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(Dl,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in n(this,Ss)&&this.recordFutureForcedDependency(e,n(this,Ss)[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of n(this,Li))this.recordFutureForcedDependency(Dl,t);return this}resetBBox(t){return n(this,Ot).resetBBox(t),this}recordClipBox(t,e,s,i,r,a){return n(this,Ot).recordClipBox(t,e,s,i,r,a),this}recordBBox(t,e,s,i,r,a){return n(this,Ot).recordBBox(t,e,s,i,r,a),this}recordCharacterBBox(t,e,s,i=1,r=0,a=0,o){const l=s.bbox;let c,h;if(l&&(c=l[2]!==l[0]&&l[3]!==l[1]&&n(this,hc).get(s),c!==!1&&(h=[0,0,0,0],B.axialAlignedBoundingBox(l,s.fontMatrix,h),(i!==1||r!==0||a!==0)&&XS(i,-i,r,a,h),c)))return this.recordBBox(t,e,h[0],h[2],h[1],h[3]);if(!o)return this.recordFullPageBBox(t);const d=o();return l&&h&&c===void 0&&(c=h[0]<=r-d.actualBoundingBoxLeft&&h[2]>=r+d.actualBoundingBoxRight&&h[1]<=a-d.actualBoundingBoxAscent&&h[3]>=a+d.actualBoundingBoxDescent,n(this,hc).set(s,c),c)?this.recordBBox(t,e,h[0],h[2],h[1],h[3]):this.recordBBox(t,e,r-d.actualBoundingBoxLeft,r+d.actualBoundingBoxRight,a-d.actualBoundingBoxAscent,a+d.actualBoundingBoxDescent)}recordFullPageBBox(t){return n(this,Ot).recordFullPageBBox(t),this}getSimpleIndex(t){return n(this,Ss)[t]}recordDependencies(t,e){const s=n(this,Li),i=n(this,Ss),r=n(this,xs);for(const a of e)a in n(this,Ss)?s.add(i[a]):a in r&&r[a].forEach(s.add,s);return this}recordNamedDependency(t,e){return n(this,go).has(e)&&n(this,Li).add(n(this,go).get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[Dl]),n(this,Yr)){const i=Sv(n(this,Yr),t),{dependencies:r}=i;n(this,Li).forEach(r.add,r),n(this,Ot)._savesStack.forEach(r.add,r),n(this,Ot)._markedContentStack.forEach(r.add,r),r.delete(t),i.isRenderingOperation=!0}const s=!e&&t===n(this,Ot)._pendingBBoxIdx;return n(this,Ot).recordOperation(t,e,[n(this,Li),n(this,Ot)._savesStack,n(this,Ot)._markedContentStack]),s&&n(this,Li).clear(),this}recordShowTextOperation(t,e=!1){const s=Array.from(n(this,Li));this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const i of s)this.recordIncrementalData("sameLineText",i);return this}bboxToClipBoxDropOperation(t,e=!1){const s=!e&&t===n(this,Ot)._pendingBBoxIdx;return n(this,Ot).bboxToClipBoxDropOperation(t),s&&n(this,Li).clear(),this}take(){return n(this,hc).clear(),n(this,Ot).take()}takeDebugMetadata(){return n(this,Yr)}}Ss=new WeakMap,xs=new WeakMap,go=new WeakMap,Li=new WeakMap,hc=new WeakMap,Yr=new WeakMap,Kr=new WeakMap,Ot=new WeakMap;var Nt,he,Fi,dc,uc;const Zm=class Zm{constructor(t,e,s){m(this,Nt);m(this,he);m(this,Fi);m(this,dc,0);m(this,uc,0);if(t instanceof Zm&&n(t,Fi)===!!s)return t;p(this,Nt,t),p(this,he,e),p(this,Fi,!!s)}get clipBox(){return n(this,Nt).clipBox}growOperationsCount(){throw new Error("Unreachable")}save(t){return Yt(this,uc)._++,n(this,Nt).save(n(this,he)),this}restore(t){return n(this,uc)>0&&(n(this,Nt).restore(n(this,he)),Yt(this,uc)._--),this}recordOpenMarker(t){return Yt(this,dc)._++,this}getOpenMarker(){return n(this,dc)>0?n(this,he):n(this,Nt).getOpenMarker()}recordCloseMarker(t){return Yt(this,dc)._--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return n(this,Nt).pushBaseTransform(t),this}popBaseTransform(){return n(this,Nt).popBaseTransform(),this}recordSimpleData(t,e){return n(this,Nt).recordSimpleData(t,n(this,he)),this}recordIncrementalData(t,e){return n(this,Nt).recordIncrementalData(t,n(this,he)),this}resetIncrementalData(t,e){return n(this,Nt).resetIncrementalData(t,n(this,he)),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return n(this,Nt).recordSimpleDataFromNamed(t,e,n(this,he)),this}recordFutureForcedDependency(t,e){return n(this,Nt).recordFutureForcedDependency(t,n(this,he)),this}inheritSimpleDataAsFutureForcedDependencies(t){return n(this,Nt).inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return n(this,Nt).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return n(this,Fi)||n(this,Nt).resetBBox(n(this,he)),this}recordClipBox(t,e,s,i,r,a){return n(this,Fi)||n(this,Nt).recordClipBox(n(this,he),e,s,i,r,a),this}recordBBox(t,e,s,i,r,a){return n(this,Fi)||n(this,Nt).recordBBox(n(this,he),e,s,i,r,a),this}recordCharacterBBox(t,e,s,i,r,a,o){return n(this,Fi)||n(this,Nt).recordCharacterBBox(n(this,he),e,s,i,r,a,o),this}recordFullPageBBox(t){return n(this,Fi)||n(this,Nt).recordFullPageBBox(n(this,he)),this}getSimpleIndex(t){return n(this,Nt).getSimpleIndex(t)}recordDependencies(t,e){return n(this,Nt).recordDependencies(n(this,he),e),this}recordNamedDependency(t,e){return n(this,Nt).recordNamedDependency(n(this,he),e),this}recordOperation(t){return n(this,Nt).recordOperation(n(this,he),!0),this}recordShowTextOperation(t){return n(this,Nt).recordShowTextOperation(n(this,he),!0),this}bboxToClipBoxDropOperation(t){return n(this,Fi)||n(this,Nt).bboxToClipBoxDropOperation(n(this,he),!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}};Nt=new WeakMap,he=new WeakMap,Fi=new WeakMap,dc=new WeakMap,uc=new WeakMap;let Jh=Zm;const li={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]};var mo,vo,bo,yo,wo,Pd;const Xh=class Xh{constructor(t){m(this,mo);m(this,vo);m(this,bo,4);m(this,yo,0);m(this,wo,new(n(Xh,Pd))(n(this,bo)*6));p(this,mo,t.width),p(this,vo,t.height)}record(t,e,s,i){if(n(this,yo)===n(this,bo)){p(this,bo,n(this,bo)*2);const o=new(n(Xh,Pd))(n(this,bo)*6);o.set(n(this,wo)),p(this,wo,o)}const r=Xt(t);let a;if(i[0]!==1/0){const o=mr.slice();B.axialAlignedBoundingBox([0,-s,e,0],r,o);const l=B.intersect(i,o);if(!l)return;const[c,h,d,f]=l;if(c!==o[0]||h!==o[1]||d!==o[2]||f!==o[3]){const g=Math.atan2(r[1],r[0]),y=Math.abs(Math.sin(g)),b=Math.abs(Math.cos(g));if(y<1e-6||b<1e-6||Math.abs(y-b)<1e-6)a=[c,h,c,f,d,h];else{const S=d-c,w=f-h,E=y*y,A=b*b,_=b*y,x=A-E,k=(w*A-S*_)/x,M=(w*_-S*E)/x;a=[c+M,h,c,h+k,d,f-k]}}}a||(a=[0,-s,0,0,e,-s],B.applyTransform(a,r,0),B.applyTransform(a,r,2),B.applyTransform(a,r,4)),a[0]/=n(this,mo),a[1]/=n(this,vo),a[2]/=n(this,mo),a[3]/=n(this,vo),a[4]/=n(this,mo),a[5]/=n(this,vo),n(this,wo).set(a,n(this,yo)*6),Yt(this,yo)._++}take(){return n(this,wo).subarray(0,n(this,yo)*6)}};mo=new WeakMap,vo=new WeakMap,bo=new WeakMap,yo=new WeakMap,wo=new WeakMap,Pd=new WeakMap,m(Xh,Pd,Ut.isFloat16ArraySupported?Float16Array:Float32Array);let Ig=Xh;var fc,Ri,cp,Ub;class QS{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){m(this,cp);m(this,fc,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=v(this,cp,Ub).call(this);e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);if(this.nativeFontFaces.clear(),n(this,fc).clear(),n(this,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,fc).has(t.loadedName))){if(re(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:r,style:a}=t,o=new FontFace(i,r,a);this.addNativeFontFace(o);try{await o.load(),n(this,fc).add(i),s==null||s(t)}catch{dt(`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 dt(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){var e;const t=!!((e=this._document)!=null&&e.fonts);return at(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return at(this,"isSyncFontLoadingSupported",si||Ut.platform.isFirefox)}_queueLoadingCallback(t){function e(){for(re(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const r=s.shift();setTimeout(r.callback,0)}}const{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return at(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(x,k){return x.charCodeAt(k)<<24|x.charCodeAt(k+1)<<16|x.charCodeAt(k+2)<<8|x.charCodeAt(k+3)&255}function i(x){return String.fromCharCode(x>>24&255,x>>16&255,x>>8&255,x&255)}function r(x,k,M,D){const I=x.substring(0,k),L=x.substring(k+M);return I+D+L}let a,o;const l=this._document.createElement("canvas");l.width=1,l.height=1;const c=l.getContext("2d");let h=0;function d(x,k){if(++h>30){dt("Load test font never loaded."),k();return}if(c.font="30px "+x,c.fillText(".",0,20),c.getImageData(0,0,1,1).data[3]>0){k();return}setTimeout(d.bind(null,x,k))}const f=`lt${Date.now()}${this.loadTestFontId++}`;let g=this._loadTestFont;g=r(g,976,f.length,f);const b=16,S=1482184792;let w=s(g,b);for(a=0,o=f.length-3;a{_.remove(),e.complete()})}}fc=new WeakMap,Ri=new WeakMap,cp=new WeakSet,Ub=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 Bt;class JS{constructor(t,e=null,s,i){P(this,"compiledGlyphs",Object.create(null));m(this,Bt);p(this,Bt,t),this._inspectFont=e,s&&(this.charProcOperatorList=s),i&&Object.assign(this,i)}createNativeFontFace(){var e;if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const s={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(s.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,s)}return(e=this._inspectFont)==null||e.call(this,this),t}createFontFaceRule(){var s;if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${this.data.toBase64()});`;let e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${t}}`}return(s=this._inspectFont)==null||s.call(this,this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];const s=this.loadedName+"_path_"+e;let i;try{i=t.get(s)}catch(a){dt(`getPathGenerator - ignoring character: "${a}".`)}const r=nb(i==null?void 0:i.path);return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=r}get black(){return n(this,Bt).black}get bold(){return n(this,Bt).bold}get disableFontFace(){return n(this,Bt).disableFontFace}set disableFontFace(t){at(this,"disableFontFace",!!t)}get fontExtraProperties(){return n(this,Bt).fontExtraProperties}get isInvalidPDFjsFont(){return n(this,Bt).isInvalidPDFjsFont}get isType3Font(){return n(this,Bt).isType3Font}get italic(){return n(this,Bt).italic}get missingFile(){return n(this,Bt).missingFile}get remeasure(){return n(this,Bt).remeasure}get vertical(){return n(this,Bt).vertical}get ascent(){return n(this,Bt).ascent}get defaultWidth(){return n(this,Bt).defaultWidth}get descent(){return n(this,Bt).descent}get bbox(){return n(this,Bt).bbox}get fontMatrix(){return n(this,Bt).fontMatrix}get fallbackName(){return n(this,Bt).fallbackName}get loadedName(){return n(this,Bt).loadedName}get mimetype(){return n(this,Bt).mimetype}get name(){return n(this,Bt).name}get data(){return n(this,Bt).data}clearData(){n(this,Bt).clearData()}get cssFontInfo(){return n(this,Bt).cssFontInfo}get systemFontInfo(){return n(this,Bt).systemFontInfo}get defaultVMetrics(){return n(this,Bt).defaultVMetrics}}Bt=new WeakMap;class Hb{}P(Hb,"strings",["fontFamily","fontWeight","italicAngle"]);class zb{}P(zb,"strings",["css","loadedName","baseFontName","src"]);const Qe=class Qe{};P(Qe,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]),P(Qe,"numbers",["ascent","defaultWidth","descent"]),P(Qe,"strings",["fallbackName","loadedName","mimetype","name"]),P(Qe,"OFFSET_NUMBERS",Math.ceil(Qe.bools.length*2/8)),P(Qe,"OFFSET_BBOX",Qe.OFFSET_NUMBERS+Qe.numbers.length*8),P(Qe,"OFFSET_FONT_MATRIX",Qe.OFFSET_BBOX+1+8),P(Qe,"OFFSET_DEFAULT_VMETRICS",Qe.OFFSET_FONT_MATRIX+1+48),P(Qe,"OFFSET_STRINGS",Qe.OFFSET_DEFAULT_VMETRICS+1+6);let Rs=Qe;class fs{}P(fs,"KIND",0),P(fs,"HAS_BBOX",1),P(fs,"HAS_BACKGROUND",2),P(fs,"SHADING_TYPE",3),P(fs,"N_COORD",4),P(fs,"N_COLOR",8),P(fs,"N_STOP",12),P(fs,"N_FIGURES",16);var Md,hp,pc,gc,uf;class ZS{constructor(t){m(this,gc);m(this,Md);m(this,hp,new TextDecoder);m(this,pc);p(this,Md,t),p(this,pc,new DataView(t))}get fontFamily(){return v(this,gc,uf).call(this,0)}get fontWeight(){return v(this,gc,uf).call(this,1)}get italicAngle(){return v(this,gc,uf).call(this,2)}}Md=new WeakMap,hp=new WeakMap,pc=new WeakMap,gc=new WeakSet,uf=function(t){re(t>s&3;return i===0?void 0:i===2},ff=function(t){return re(t0){b=mr.slice();for(let S=0,w=c.length;Stypeof u=="object"&&Number.isInteger(u==null?void 0:u.num)&&u.num>=0&&Number.isInteger(u==null?void 0:u.gen)&&u.gen>=0,a1=u=>typeof u=="object"&&typeof(u==null?void 0:u.name)=="string",o1=FS.bind(null,Lg,a1);var jn,up;class l1{constructor(){m(this,jn,new Map);m(this,up,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};n(this,up).then(()=>{for(const[i]of n(this,jn))i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:r}=s;if(r.aborted){dt("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(t,e);i=()=>r.removeEventListener("abort",a),r.addEventListener("abort",a)}n(this,jn).set(e,i)}removeEventListener(t,e){const s=n(this,jn).get(e);s==null||s(),n(this,jn).delete(e)}terminate(){for(const[,t]of n(this,jn))t==null||t();n(this,jn).clear()}}jn=new WeakMap,up=new WeakMap;const Ku={DATA:1,ERROR:2},ve={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function xv(){}function bs(u){if(u instanceof _a||u instanceof og||u instanceof ag||u instanceof Xf||u instanceof Yp)return u;switch(u instanceof Error||typeof u=="object"&&u!==null||Ct('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),u.name){case"AbortException":return new _a(u.message);case"InvalidPDFException":return new og(u.message);case"PasswordException":return new ag(u.message,u.code);case"ResponseException":return new Xf(u.message,u.status,u.missing);case"UnknownErrorException":return new Yp(u.message,u.details)}return new Yp(u.message,u.toString())}var bc,Ci,Vb,Gb,jb,gf;class Mh{constructor(t,e,s){m(this,Ci);m(this,bc,new AbortController);this.sourceName=t,this.targetName=e,this.comObj=s,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),s.addEventListener("message",v(this,Ci,Vb).bind(this),{signal:n(this,bc).signal})}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const i=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[i]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(a){r.reject(a)}return r.promise}sendWithStream(t,e,s,i){const r=this.streamId++,a=this.sourceName,o=this.targetName,l=this.comObj;return new ReadableStream({start:c=>{const h=Promise.withResolvers();return this.streamControllers[r]={controller:c,startCall:h,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:a,targetName:o,action:t,streamId:r,data:e,desiredSize:c.desiredSize},i),h.promise},pull:c=>{const h=Promise.withResolvers();return this.streamControllers[r].pullCall=h,l.postMessage({sourceName:a,targetName:o,stream:ve.PULL,streamId:r,desiredSize:c.desiredSize}),h.promise},cancel:c=>{re(c instanceof Error,"cancel must have a valid reason");const h=Promise.withResolvers();return this.streamControllers[r].cancelCall=h,this.streamControllers[r].isClosed=!0,l.postMessage({sourceName:a,targetName:o,stream:ve.CANCEL,streamId:r,reason:bs(c)}),h.promise}},s)}destroy(){var t;(t=n(this,bc))==null||t.abort(),p(this,bc,null)}}bc=new WeakMap,Ci=new WeakSet,Vb=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){v(this,Ci,jb).call(this,t);return}if(t.callback){const s=t.callbackId,i=this.callbackCapabilities[s];if(!i)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===Ku.DATA)i.resolve(t.data);else if(t.callback===Ku.ERROR)i.reject(bs(t.reason));else throw new Error("Unexpected callback case");return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=this.sourceName,i=t.sourceName,r=this.comObj;Promise.try(e,t.data).then(function(a){r.postMessage({sourceName:s,targetName:i,callback:Ku.DATA,callbackId:t.callbackId,data:a})},function(a){r.postMessage({sourceName:s,targetName:i,callback:Ku.ERROR,callbackId:t.callbackId,reason:bs(a)})});return}if(t.streamId){v(this,Ci,Gb).call(this,t);return}e(t.data)},Gb=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,r=this.comObj,a=this,o=this.actionHandler[t.action],l={enqueue(c,h=1,d){if(this.isCancelled)return;const f=this.desiredSize;this.desiredSize-=h,f>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:s,targetName:i,stream:ve.ENQUEUE,streamId:e,chunk:c},d)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:ve.CLOSE,streamId:e}),delete a.streamSinks[e])},error(c){re(c instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:ve.ERROR,streamId:e,reason:bs(c)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[e]=l,Promise.try(o,t.data,l).then(function(){r.postMessage({sourceName:s,targetName:i,stream:ve.START_COMPLETE,streamId:e,success:!0})},function(c){r.postMessage({sourceName:s,targetName:i,stream:ve.START_COMPLETE,streamId:e,reason:bs(c)})})},jb=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,r=this.comObj,a=this.streamControllers[e],o=this.streamSinks[e];switch(t.stream){case ve.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject(bs(t.reason));break;case ve.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject(bs(t.reason));break;case ve.PULL:if(!o){r.postMessage({sourceName:s,targetName:i,stream:ve.PULL_COMPLETE,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,Promise.try(o.onPull||xv).then(function(){r.postMessage({sourceName:s,targetName:i,stream:ve.PULL_COMPLETE,streamId:e,success:!0})},function(c){r.postMessage({sourceName:s,targetName:i,stream:ve.PULL_COMPLETE,streamId:e,reason:bs(c)})});break;case ve.ENQUEUE:if(re(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case ve.CLOSE:if(re(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),v(this,Ci,gf).call(this,a,e);break;case ve.ERROR:re(a,"error should have stream controller"),a.controller.error(bs(t.reason)),v(this,Ci,gf).call(this,a,e);break;case ve.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject(bs(t.reason)),v(this,Ci,gf).call(this,a,e);break;case ve.CANCEL:if(!o)break;const l=bs(t.reason);Promise.try(o.onCancel||xv,l).then(function(){r.postMessage({sourceName:s,targetName:i,stream:ve.CANCEL_COMPLETE,streamId:e,success:!0})},function(c){r.postMessage({sourceName:s,targetName:i,stream:ve.CANCEL_COMPLETE,streamId:e,reason:bs(c)})}),o.sinkCapability.reject(l),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},gf=async function(t,e){var s,i,r;await Promise.allSettled([(s=t.startCall)==null?void 0:s.promise,(i=t.pullCall)==null?void 0:i.promise,(r=t.cancelCall)==null?void 0:r.promise]),delete this.streamControllers[e]};var fp;class Wb{constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:s=null}){m(this,fp,Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"}));this.cMapUrl=t,this.standardFontDataUrl=e,this.wasmUrl=s}async fetch({kind:t,filename:e}){switch(t){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:Ct(`Not implemented: ${t}`)}const s=this[t];if(!s)throw new Error(`Ensure that the \`${t}\` API parameter is provided.`);const i=`${s}${e}`;return this._fetch(i,t).catch(r=>{throw new Error(`Unable to load ${n(this,fp)[t]} data at: ${i}`)})}async _fetch(t,e){Ct("Abstract method `_fetch` called.")}}fp=new WeakMap;class Ev extends Wb{async _fetch(t,e){const s=e==="cMapUrl"&&!t.endsWith(".bcmap")?"text":"bytes",i=await zm(t,s);return i instanceof Uint8Array?i:Rp(i)}}var Id;class Xb{constructor({enableHWA:t=!1}){m(this,Id,!1);p(this,Id,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,Id)})}}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.")}}Id=new WeakMap;class c1 extends Xb{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}class qb{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addKnockoutFilter(t=0){return"none"}addHighlightHCMFilter(t,e,s,i,r){return"none"}addSelectionHCMFilter(t,e){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(t=null){return null}destroy(t=!1){}}var xo,yc,Wn,ln,Ie,Eo,Qr,V,Te,Ih,xr,mf,Oa,Yb,Fg,Na,Dh,Lh,Rg,Fh,Kb,Qb;class h1 extends qb{constructor({docId:e,ownerDocument:s=globalThis.document}){super();m(this,V);m(this,xo);m(this,yc);m(this,Wn);m(this,ln);m(this,Ie);m(this,Eo);m(this,Qr,0);p(this,ln,e),p(this,Ie,s)}addFilter(e){if(!e)return"none";let s=n(this,V,Te).get(e);if(s)return s;const[i,r,a]=v(this,V,mf).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,ln)}_transfer_map_${Yt(this,Qr)._++}`,c=v(this,V,Oa).call(this,l);n(this,V,Te).set(e,c),n(this,V,Te).set(o,c);const h=v(this,V,Na).call(this,l);return v(this,V,Lh).call(this,i,r,a,h),c}addHCMFilter(e,s){var y;const i=`${e}-${s}`,r="base";let a=n(this,V,Ih).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,Ih).set(r,a)),!e||!s))return a.url;const o=v(this,V,Fh).call(this,e);e=B.makeHexColor(...o);const l=v(this,V,Fh).call(this,s);if(s=B.makeHexColor(...l),n(this,V,xr).style.color="",e==="#000000"&&s==="#ffffff"||e===s)return a.url;const c=new Array(256);for(let b=0;b<=255;b++){const S=b/255;c[b]=S<=.03928?S/12.92:((S+.055)/1.055)**2.4}const h=c.join(","),d=`g_${n(this,ln)}_hcm_filter`,f=a.filter=v(this,V,Na).call(this,d);v(this,V,Lh).call(this,h,h,h,f),v(this,V,Fg).call(this,f);const g=(b,S)=>{const w=o[b]/255,E=l[b]/255,A=new Array(S+1);for(let _=0;_<=S;_++)A[_]=w+_/S*(E-w);return A.join(",")};return v(this,V,Lh).call(this,g(0,5),g(1,5),g(2,5),f),a.url=v(this,V,Oa).call(this,d),a.url}addSelectionHCMFilter(e,s){return this.addHighlightHCMFilter("selection",e,s,"HighlightText","Highlight")}addSelectionFilter(){return this.addHighlightHCMFilter("selection_default","black","white","HighlightText","Highlight")}createSelectionStyle(e=null){const s=e?this.addSelectionHCMFilter(e.foreground,e.background):this.addSelectionFilter();return s==="none"||!Ut.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]=v(this,V,mf).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,ln)}_alpha_map_${Yt(this,Qr)._++}`,o=v(this,V,Oa).call(this,a);n(this,V,Te).set(e,o),n(this,V,Te).set(r,o);const l=v(this,V,Na).call(this,a);return v(this,V,Rg).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]=v(this,V,mf).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,ln)}_luminosity_map_${Yt(this,Qr)._++}`,o=v(this,V,Oa).call(this,a);n(this,V,Te).set(e,o),n(this,V,Te).set(r,o);const l=v(this,V,Na).call(this,a);return v(this,V,Yb).call(this,l),e&&v(this,V,Rg).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,ln)}_knockout_filter_${Yt(this,Qr)._++}`,o=v(this,V,Oa).call(this,a);n(this,V,Te).set(i,o);const l=v(this,V,Na).call(this,a),c=n(this,Ie).createElementNS(Ns,"feComponentTransfer");l.append(c);const h=n(this,Ie).createElementNS(Ns,"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 E;const o=`${s}-${i}-${r}-${a}`;let l=n(this,V,Ih).get(e);if((l==null?void 0:l.key)===o||(l?((E=l.filter)==null||E.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},n(this,V,Ih).set(e,l)),!s||!i))return l.url;const[c,h]=[s,i].map(v(this,V,Fh).bind(this));let d=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),f=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),[g,y]=[r,a].map(v(this,V,Qb).bind(this));f{const k=new Array(256),M=(f-d)/x,D=A/255,I=(_-A)/(255*x);let L=0;for(let O=0;O<=x;O++){const Y=Math.round(d+O*M),W=D+O*I;for(let Q=L;Q<=Y;Q++)k[Q]=W;L=Y+1}for(let O=L;O<256;O++)k[O]=k[L-1];return k.join(",")},S=`g_${n(this,ln)}_hcm_${e}_filter`,w=l.filter=v(this,V,Na).call(this,S);return v(this,V,Fg).call(this,w),v(this,V,Lh).call(this,b(g[0],y[0],5),b(g[1],y[1],5),b(g[2],y[2],5),w),l.url=v(this,V,Oa).call(this,S),l.url}destroy(e=!1){var s,i,r,a;e&&((s=n(this,Eo))!=null&&s.size)||((i=n(this,Wn))==null||i.parentNode.parentNode.remove(),p(this,Wn,null),(r=n(this,yc))==null||r.clear(),p(this,yc,null),(a=n(this,Eo))==null||a.clear(),p(this,Eo,null),p(this,Qr,0))}}xo=new WeakMap,yc=new WeakMap,Wn=new WeakMap,ln=new WeakMap,Ie=new WeakMap,Eo=new WeakMap,Qr=new WeakMap,V=new WeakSet,Te=function(){return n(this,yc)||p(this,yc,new Map)},Ih=function(){return n(this,Eo)||p(this,Eo,new Map)},xr=function(){if(!n(this,Wn)){const e=n(this,Ie).createElement("div"),{style:s}=e;s.colorScheme="only light",s.visibility="hidden",s.contain="strict",s.width=s.height=0,s.position="absolute",s.top=s.left=0,s.zIndex=-1;const i=n(this,Ie).createElementNS(Ns,"svg");i.setAttribute("width",0),i.setAttribute("height",0),p(this,Wn,n(this,Ie).createElementNS(Ns,"defs")),e.append(i),i.append(n(this,Wn)),n(this,Ie).body.append(e)}return n(this,Wn)},mf=function(e){if(e.length===1){const c=e[0],h=new Array(256);for(let f=0;f<256;f++)h[f]=c[f]/255;const d=h.join(",");return[d,d,d]}const[s,i,r]=e,a=new Array(256),o=new Array(256),l=new Array(256);for(let c=0;c<256;c++)a[c]=s[c]/255,o[c]=i[c]/255,l[c]=r[c]/255;return[a.join(","),o.join(","),l.join(",")]},Oa=function(e){if(n(this,xo)===void 0){p(this,xo,"");const s=n(this,Ie).URL;s!==n(this,Ie).baseURI&&(Op(s)?dt('#createUrl: ignore "data:"-URL for performance reasons.'):p(this,xo,tb(s,"")))}return`url(${n(this,xo)}#${e})`},Yb=function(e){const s=n(this,Ie).createElementNS(Ns,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),e.append(s)},Fg=function(e){const s=n(this,Ie).createElementNS(Ns,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(s)},Na=function(e){const s=n(this,Ie).createElementNS(Ns,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),n(this,V,xr).append(s),s},Dh=function(e,s,i){const r=n(this,Ie).createElementNS(Ns,s);r.setAttribute("type","discrete"),r.setAttribute("tableValues",i),e.append(r)},Lh=function(e,s,i,r){const a=n(this,Ie).createElementNS(Ns,"feComponentTransfer");r.append(a),v(this,V,Dh).call(this,a,"feFuncR",e),v(this,V,Dh).call(this,a,"feFuncG",s),v(this,V,Dh).call(this,a,"feFuncB",i)},Rg=function(e,s){const i=n(this,Ie).createElementNS(Ns,"feComponentTransfer");s.append(i),v(this,V,Dh).call(this,i,"feFuncA",e)},Fh=function(e){return n(this,V,xr).style.color=e,Wu(getComputedStyle(n(this,V,xr)).getPropertyValue("color"))},Kb=function(e){return n(this,V,xr).style.color=e,ju(getComputedStyle(n(this,V,xr)).getPropertyValue("color"))},Qb=function(e){const[s,i,r,a]=v(this,V,Kb).call(this,e);if(a===1)return[s,i,r];const[o,l,c]=v(this,V,Fh).call(this,"Canvas");return[Jp(s,o,a),Jp(i,l,a),Jp(r,c,a)]};function Jp(u,t,e){return Math.round(e*u+(1-e)*t)}si&&dt("Please use the `legacy` build in Node.js environments.");async function d1(u){const e=await process.getBuiltinModule("fs/promises").readFile(u);return new Uint8Array(e)}class u1 extends qb{}class f1 extends Xb{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class p1 extends Wb{async _fetch(t,e){return d1(t)}}function Jb({src:u,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=Ut.isLittleEndian?4278190080:255,[l,c]=a?[r,o]:[o,r],h=s>>3,d=s&7,f=l^c,g=u.length;e=new Uint32Array(e.buffer);let y=0;for(let b=0;b>7&1)&f,e[y+1]=l^-(E>>6&1)&f,e[y+2]=l^-(E>>5&1)&f,e[y+3]=l^-(E>>4&1)&f,e[y+4]=l^-(E>>3&1)&f,e[y+5]=l^-(E>>2&1)&f,e[y+6]=l^-(E>>1&1)&f,e[y+7]=l^-(E&1)&f}if(d===0)continue;const S=t>7-w&1)&f}return{srcPos:t,destPos:y}}function g1({src:u,srcPos:t=0,dest:e,destPos:s=0,width:i,height:r}){let a=0;const o=i*r*3,l=o>>2,c=new Uint32Array(u.buffer,t,l),h=Ut.isLittleEndian?4278190080:255;if(Ut.isLittleEndian){for(;a>>24|f<<8|h,e[s+2]=f>>>16|g<<16|h,e[s+3]=g>>>8|h}for(let d=a*4,f=t+o;d>>8|h,e[s+2]=f<<16|g>>>16|h,e[s+3]=g<<8|h}for(let d=a*4,f=t+o;d 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 pp,Xn,Co,wc,gp,Zb;class v1{constructor(){m(this,gp);m(this,pp,null);m(this,Xn,null);m(this,Co,null);m(this,wc,null)}init(){return n(this,pp)||p(this,pp,v(this,gp,Zb).call(this))}get isReady(){return n(this,Xn)!==null}loadMeshShader(){if(!n(this,Xn)||n(this,Co))return;const t=n(this,Xn).createShaderModule({code:m1});p(this,Co,n(this,Xn).createRenderPipeline({layout:"auto",vertex:{module:t,entryPoint:"vs_main",buffers:[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:t,entryPoint:"fs_main",targets:[{format:n(this,wc)}]},primitive:{topology:"triangle-list"}}))}draw(t,e,s,i,r,a,o,l){this.loadMeshShader();const c=n(this,Xn),{offsetX:h,offsetY:d,scaleX:f,scaleY:g}=i,y=c.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});t.byteLength>0&&c.queue.writeBuffer(y,0,t);const b=c.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});e.byteLength>0&&c.queue.writeBuffer(b,0,e);const S=c.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});c.queue.writeBuffer(S,0,new Float32Array([h,d,f,g,a,o,l,0]));const w=c.createBindGroup({layout:n(this,Co).getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:S}}]}),E=new OffscreenCanvas(a,o),A=E.getContext("webgpu");A.configure({device:c,format:n(this,wc),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},x=c.createCommandEncoder(),k=x.beginRenderPass({colorAttachments:[{view:A.getCurrentTexture().createView(),clearValue:_,loadOp:"clear",storeOp:"store"}]});return s>0&&(k.setPipeline(n(this,Co)),k.setBindGroup(0,w),k.setVertexBuffer(0,y),k.setVertexBuffer(1,b),k.draw(s)),k.end(),c.queue.submit([x.finish()]),y.destroy(),b.destroy(),S.destroy(),E.transferToImageBitmap()}}pp=new WeakMap,Xn=new WeakMap,Co=new WeakMap,wc=new WeakMap,gp=new WeakSet,Zb=async function(){var t;if(!((t=globalThis.navigator)!=null&&t.gpu))return!1;try{const e=await navigator.gpu.requestAdapter();return e?(p(this,wc,navigator.gpu.getPreferredCanvasFormat()),p(this,Xn,await e.requestDevice()),!0):!1}catch{return!1}};const Np=new v1;function b1(){return Np.init()}function y1(){return Np.isReady}function w1(){Np.loadMeshShader()}function A1(u,t,e,s,i,r,a,o){return Np.draw(u,t,e,s,i,r,a,o)}const We={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function vf(u,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],e,s),u.clip(i)}class Wm{isModifyingCurrentTransform(){return!1}getPattern(){Ct("Abstract method `getPattern` called.")}}class S1 extends Wm{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}isOriginBased(){return this._p0[0]===0&&this._p0[1]===0&&(!this.isRadial()||this._p1[0]===0&&this._p1[1]===0)}isRadial(){return this._type==="radial"}areConic(){if(!this.isRadial())return!1;const t=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return t+this._r1>this._r0&&t+this._r0>this._r1}_createGradient(t,e=null){let s,i=this._p0,r=this._p1;if(e&&(i=i.slice(),r=r.slice(),B.applyTransform(i,e),B.applyTransform(r,e)),this._type==="axial")s=t.createLinearGradient(i[0],i[1],r[0],r[1]);else if(this._type==="radial"){let a=this._r0,o=this._r1;if(e){const l=new Float32Array(2);B.singularValueDecompose2dScale(e,l),a*=l[0],o*=l[0]}s=t.createRadialGradient(i[0],i[1],a,r[0],r[1],o)}for(const a of this._colorStops)s.addColorStop(a[0],a[1]);return s}_createReversedGradient(t,e=null){let s=this._p1,i=this._p0;e&&(s=s.slice(),i=i.slice(),B.applyTransform(s,e),B.applyTransform(i,e));let r=this._r1,a=this._r0;if(e){const c=new Float32Array(2);B.singularValueDecompose2dScale(e,c),r*=c[0],a*=c[0]}const o=t.createRadialGradient(s[0],s[1],r,i[0],i[1],a),l=this._colorStops.map(([c,h])=>[1-c,h]).reverse();for(const[c,h]of l)o.addColorStop(c,h);return o}getPattern(t,e,s,i){let r;if(i===We.STROKE||i===We.FILL){if(this.isOriginBased()){let f=B.transform(s,e.baseTransform);this.matrix&&(f=B.transform(f,this.matrix));const g=.001,y=Math.hypot(f[0],f[1]),b=Math.hypot(f[2],f[3]),S=(f[0]*f[2]+f[1]*f[3])/(y*b);if(Math.abs(S)l[s*2+1]&&(f=e,e=s,s=f,f=r,r=a,a=f),l[s*2+1]>l[i*2+1]&&(f=s,s=i,i=f,f=a,a=o,o=f),l[e*2+1]>l[s*2+1]&&(f=e,e=s,s=f,f=r,r=a,a=f);const g=(l[e*2]+t.offsetX)*t.scaleX,y=(l[e*2+1]+t.offsetY)*t.scaleY,b=(l[s*2]+t.offsetX)*t.scaleX,S=(l[s*2+1]+t.offsetY)*t.scaleY,w=(l[i*2]+t.offsetX)*t.scaleX,E=(l[i*2+1]+t.offsetY)*t.scaleY;if(y>=E)return;const A=c[r*4],_=c[r*4+1],x=c[r*4+2],k=c[a*4],M=c[a*4+1],D=c[a*4+2],I=c[o*4],L=c[o*4+1],O=c[o*4+2],Y=Math.round(y),W=Math.round(E);let Q,ft,T,q,Lt,bt,_e,ae;for(let Gt=Y;Gt<=W;Gt++){if(GtE?Z=1:S===E?Z=0:Z=(S-Gt)/(S-E),Q=b-(b-w)*Z,ft=k-(k-I)*Z,T=M-(M-L)*Z,q=D-(D-O)*Z}let H;GtE?H=1:H=(y-Gt)/(y-E),Lt=g-(g-w)*H,bt=A-(A-I)*H,_e=_-(_-L)*H,ae=x-(x-O)*H;const $=Math.round(Math.min(Q,Lt)),ht=Math.round(Math.max(Q,Lt));let ot=d*Gt+$*4;for(let Z=$;Z<=ht;Z++)H=(Q-Z)/(Q-Lt),H<0?H=0:H>1&&(H=1),h[ot++]=ft-(ft-bt)*H|0,h[ot++]=T-(T-_e)*H|0,h[ot++]=q-(q-ae)*H|0,h[ot++]=255}}class E1 extends Wm{constructor(t){super(),this._posData=t[2],this._colData=t[3],this._vertexCount=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null,w1()}_createMeshCanvas(t,e,s){const o=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),c=Math.ceil(this._bounds[2])-o,h=Math.ceil(this._bounds[3])-l,d=Math.min(Math.ceil(Math.abs(c*t[0]*1.1)),3e3)||1,f=Math.min(Math.ceil(Math.abs(h*t[1]*1.1)),3e3)||1,g=c?c/d:1,y=h?h/f:1,b={coords:this._posData,colors:this._colData,offsetX:-o,offsetY:-l,scaleX:1/g,scaleY:1/y},S=d+4,w=f+4,E=s.create(S,w);if(y1()&&this._vertexCount>48)E.context.drawImage(A1(this._posData,this._colData,this._vertexCount,b,e,S,w,2),0,0);else{const A=E.context.createImageData(d,f);if(e){const _=A.data;for(let x=0,k=_.length;xc+1e-6||e>h+1e-6)return null;const d=Math.floor((s-o)/c)+1,f=Math.ceil((s+t-r)/c)-1,g=Math.floor((i-l)/h)+1,y=Math.ceil((i+e-a)/h)-1;return f<=d&&y<=g?[d,g]:null}updatePatternDims(t,e){const s=B.inverseTransform(this.patternBaseMatrix),i=[t[0],t[1]],r=[t[2],t[3]];B.applyTransform(i,s),B.applyTransform(r,s),e[0]=Math.abs(r[0]-i[0]),e[1]=Math.abs(r[1]-i[1]),e[2]=Math.min(i[0],r[0]),e[3]=Math.min(i[1],r[1])}_renderTileCanvas(t,e,s,i){var f,g;const[r,a,o,l]=this.bbox,c=t.canvasFactory.create(s.size,i.size),h=c.context,d=this.canvasGraphicsFactory.createCanvasGraphics(h,e);return d.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(d,this.paintType,this.color),h.translate(-s.scale*r,-i.scale*a),d.transform(0,s.scale,0,0,i.scale,0,0),h.save(),(f=d.dependencyTracker)==null||f.save(),this.clipBbox(d,r,a,o,l),d.baseTransform=Xt(d.ctx),d.executeOperatorList(this.operatorList),d.endDrawing(),(g=d.dependencyTracker)==null||g.restore(),h.restore(),c}_getCombinedScales(){const t=new Float32Array(2);B.singularValueDecompose2dScale(this.matrix,t);const[e,s]=t;return B.singularValueDecompose2dScale(this.baseTransform,t),[e*t[0],s*t[1]]}drawPattern(t,e,s=!1,[i,r],a){const[o,l,c,h]=this.bbox,d=t.dependencyTracker;if(d&&(t.dependencyTracker=new Jh(d,a)),t.save(),s?t.ctx.clip(e,"evenodd"):t.ctx.clip(e),t.ctx.setTransform(...this.patternBaseMatrix),t.ctx.translate(i*this.xstep,r*this.ystep),this.needsIsolation||t.ctx.globalAlpha!==1||t.ctx.globalCompositeOperation!=="source-over"||t.inSMaskMode){const f=c-o,g=h-l,[y,b]=this._getCombinedScales(),S=this.getSizeAndScale(f,this.ctx.canvas.width,y),w=this.getSizeAndScale(g,this.ctx.canvas.height,b),E=this._renderTileCanvas(t,a,S,w);t.ctx.drawImage(E.canvas,o,l,f,g),t.canvasFactory.destroy(E)}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(),d&&(t.dependencyTracker=d)}createPatternCanvas(t,e){const[s,i,r,a]=this.bbox,o=r-s,l=a-i;let{xstep:c,ystep:h}=this;c=Math.abs(c),h=Math.abs(h),Fp("TilingType: "+this.tilingType);const[d,f]=this._getCombinedScales();let g=o,y=l,b=!1,S=!1;Math.ceil(c*d)>=Math.ceil(o*d)?g=c:b=!0,Math.ceil(h*f)>=Math.ceil(l*f)?y=h:S=!0;const w=this.getSizeAndScale(g,this.ctx.canvas.width,d),E=this.getSizeAndScale(y,this.ctx.canvas.height,f),A=this._renderTileCanvas(t,e,w,E);if(b||S){const _=A.canvas;b&&(g=c),S&&(y=h);const x=this.getSizeAndScale(g,this.ctx.canvas.width,d),k=this.getSizeAndScale(y,this.ctx.canvas.height,f),M=x.size,D=k.size,I=t.canvasFactory.create(M,D),L=I.context,O=b?Math.floor(o/c):0,Y=S?Math.floor(l/h):0;for(let W=0;W<=O;W++)for(let Q=0;Q<=Y;Q++)L.drawImage(_,M*W,D*Q,M,D,0,0,M,D);return t.canvasFactory.destroy(A),{canvas:I.canvas,canvasEntry:I,scaleX:x.scale,scaleY:k.scale,offsetX:s,offsetY:i}}return{canvas:A.canvas,canvasEntry:A,scaleX:w.scale,scaleY:E.scale,offsetX:s,offsetY:i}}getSizeAndScale(t,e,s){const i=Math.max(mp.MAX_PATTERN_SIZE,e);let r=Math.ceil(t*s);return r>=i?r=i:s=r/t,{scale:s,size:r}}clipBbox(t,e,s,i,r){const a=i-e,o=r-s,l=new Path2D;l.rect(e,s,a,o),B.axialAlignedBoundingBox([e,s,i,r],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 Cv.COLORED:const{fillStyle:a,strokeStyle:o}=this.ctx;i.fillStyle=r.fillColor=a,i.strokeStyle=r.strokeColor=o;break;case Cv.UNCOLORED:i.fillStyle=i.strokeStyle=s,r.fillColor=r.strokeColor=s;break;default:throw new MS(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,i,r){const a=i!==We.SHADING?B.transform(s,this.patternBaseMatrix):s,o=this.createPatternCanvas(e,r);let l=new DOMMatrix(a);l=l.translate(o.offsetX,o.offsetY),l=l.scale(1/o.scaleX,1/o.scaleY);const c=t.createPattern(o.canvas,"repeat");return e.canvasFactory.destroy(o.canvasEntry),c.setTransform(l),c}};P(mp,"MAX_PATTERN_SIZE",3e3);let Wh=mp;const k1=16,T1=100,P1=15,_v=10,ks=16,Zp=new DOMMatrix,ii=new Float32Array(2);function kv(u,t){if(u._removeMirroring)throw new Error("Context is already forwarding operations.");const e=new Map;for(const s of["save","restore","rotate","scale","translate","transform","setTransform","resetTransform","clip","moveTo","lineTo","bezierCurveTo","quadraticCurveTo","arc","arcTo","ellipse","rect","roundRect","closePath","beginPath"]){const i=u[s];typeof i!="function"||typeof t[s]!="function"||(e.set(s,i),u[s]=function(...r){return t[s](...r),i.apply(this,r)})}u._removeMirroring=()=>{for(const[s,i]of e)u[s]=i;delete u._removeMirroring}}function Qu(u,t,e,s,i,r,a,o,l,c){const[h,d,f,g,y,b]=Xt(u);if(d===0&&f===0){const E=a*h+y,A=Math.round(E),_=o*g+b,x=Math.round(_),k=(a+l)*h+y,M=Math.abs(Math.round(k)-A)||1,D=(o+c)*g+b,I=Math.abs(Math.round(D)-x)||1;return u.setTransform(Math.sign(h),0,0,Math.sign(g),A,x),u.drawImage(t,e,s,i,r,0,0,M,I),u.setTransform(h,d,f,g,y,b),[M,I]}if(h===0&&g===0){const E=o*f+y,A=Math.round(E),_=a*d+b,x=Math.round(_),k=(o+c)*f+y,M=Math.abs(Math.round(k)-A)||1,D=(a+l)*d+b,I=Math.abs(Math.round(D)-x)||1;return u.setTransform(0,Math.sign(d),Math.sign(f),0,A,x),u.drawImage(t,e,s,i,r,0,0,I,M),u.setTransform(h,d,f,g,y,b),[I,M]}u.drawImage(t,e,s,i,r,a,o,l,c);const S=Math.hypot(h,d),w=Math.hypot(f,g);return[S*l,w*c]}class Tv{constructor(t,e){P(this,"alphaIsShape",!1);P(this,"fontSize",0);P(this,"fontSizeScale",1);P(this,"textMatrix",null);P(this,"textMatrixScale",1);P(this,"fontMatrix",ng);P(this,"leading",0);P(this,"x",0);P(this,"y",0);P(this,"lineX",0);P(this,"lineY",0);P(this,"charSpacing",0);P(this,"wordSpacing",0);P(this,"textHScale",1);P(this,"textRenderingMode",xe.FILL);P(this,"textRise",0);P(this,"fillColor","#000000");P(this,"strokeColor","#000000");P(this,"tilingPatternDims",null);P(this,"patternFill",!1);P(this,"patternStroke",!1);P(this,"fillAlpha",1);P(this,"strokeAlpha",1);P(this,"lineWidth",1);P(this,"activeSMask",null);P(this,"transferMaps","none");P(this,"minMax",ja.slice());this.clipBox=new Float32Array([0,0,t,e])}clone(){var e;const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t.tilingPatternDims=(e=this.tilingPatternDims)==null?void 0:e.slice(),t}getPathBoundingBox(t=We.FILL,e=null){const s=this.minMax.slice();if(t===We.STROKE){e||Ct("Stroke bounding box must include transform."),B.singularValueDecompose2dScale(e,ii);const i=ii[0]*this.lineWidth/2,r=ii[1]*this.lineWidth/2;s[0]-=i,s[1]-=r,s[2]+=i,s[3]+=r}return s}updateClipFromPath(){const t=B.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(ja,0)}getClippedPathBoundingBox(t=We.FILL,e=null){return B.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Pv(u,t){const{width:e,height:s,kind:i}=t,r=s%ks,a=(s-r)/ks,o=r===0?a:a+1,l=u.createImageData(e,ks);let c=0;const h=t.data,d=l.data;let f;if(i===rf.GRAYSCALE_1BPP)for(f=0;f_v&&typeof s=="function",d=h?Date.now()+P1:0;let f=0;const g=this.commonObjs,y=this.objs;let b,S;for(;;){if(i!==void 0){if(l===i.nextBreakPoint)return i.breakIt(l,s),l;if(i.shouldSkip(l)){if(++l===c)return l;continue}}if(!r||r(l))if(b=o[l],S=a[l]??null,b!==Ki.dependency)S===null?this[b](l):this[b](l,...S);else for(const E of S){(w=this.dependencyTracker)==null||w.recordNamedData(E,l);const A=E.startsWith("g_")?g:y;if(!A.has(E))return A.get(E,s),l}if(l++,l===c)return l;if(h&&++f>_v){if(Date.now()>d)return s(),l;f=0}}}endDrawing(){v(this,J,Og).call(this);for(const t of this.smaskGroupCanvases)this.canvasFactory.destroy(t);this.smaskGroupCanvases.length=0,this._clearPreparedSMask(),this.tempSMask=null,this.smaskStack.length=0;for(const t of n(this,cn))v(this,J,bf).call(this,t);n(this,cn).length=0,p(this,_o,null),p(this,ko,null),p(this,To,null),p(this,Po,null),p(this,Mo,1),p(this,Do,null),p(this,Jr,0),p(this,Hs,0),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),v(this,J,Ng).call(this)}_scaleImage(t,e){const s=t.width??t.displayWidth,i=t.height??t.displayHeight,r=Math.max(Math.hypot(e[0],e[1]),1),a=Math.max(Math.hypot(e[2],e[3]),1),o=[];let l=r,c=a,h=s,d=i;for(;l>2&&h>1||c>2&&d>1;){let w=h,E=d;l>2&&h>1&&(w=Math.ceil(h/2),l/=h/w),c>2&&d>1&&(E=Math.ceil(d/2),c/=d/E),o.push({newWidth:w,newHeight:E}),h=w,d=E}if(o.length===0)return{img:t,paintWidth:s,paintHeight:i,tmpCanvas:null};if(o.length===1){const{newWidth:w,newHeight:E}=o[0],A=this.canvasFactory.create(w,E);return A.context.drawImage(t,0,0,s,i,0,0,w,E),{img:A.canvas,paintWidth:w,paintHeight:E,tmpCanvas:A}}let f=this.canvasFactory.create(1,1),g=this.canvasFactory.create(1,1),y=s,b=i,S=t;for(const{newWidth:w,newHeight:E}of o)this.canvasFactory.reset(g,w,E),g.context.drawImage(S,0,0,y,b,0,0,w,E),[f,g]=[g,f],S=f.canvas,y=w,b=E;return this.canvasFactory.destroy(g),{img:f.canvas,paintWidth:y,paintHeight:b,tmpCanvas:f}}_createMaskCanvas(t,e){var O,Y;const s=this.ctx,{width:i,height:r}=e,a=this.current.fillColor,o=this.current.patternFill,l=Xt(s);let c,h,d,f;if((e.bitmap||e.data)&&e.count>1){const W=e.bitmap||e.data.buffer;h=JSON.stringify(o?l:[l.slice(0,4),a]),c=this._cachedBitmapsMap.getOrInsertComputed(W,Hm);const Q=c.get(h);if(Q&&!o){const ft=Math.round(Math.min(l[0],l[2])+l[4]),T=Math.round(Math.min(l[1],l[3])+l[5]);return(O=this.dependencyTracker)==null||O.recordDependencies(t,li.transformAndFill),{canvas:Q,offsetX:ft,offsetY:T}}d=Q}d||(f=this.canvasFactory.create(i,r),Mv(f.context,e));let g=B.transform(l,[1/i,0,0,-1/r,0,0]);g=B.transform(g,[1,0,0,1,0,-r]);const y=ja.slice();B.axialAlignedBoundingBox([0,0,i,r],g,y);const[b,S,w,E]=y,A=Math.round(w-b)||1,_=Math.round(E-S)||1,x=this.canvasFactory.create(A,_),k=x.context,M=b,D=S;k.translate(-M,-D),k.transform(...g);let I=null;if(!d){const W=this._scaleImage(f.canvas,Xi(k));d=W.img,I=W.tmpCanvas,d!==f.canvas&&(this.canvasFactory.destroy(f),f=null),c&&o&&(c.set(h,d),I=null,f=null)}k.imageSmoothingEnabled=Iv(Xt(k),e.interpolate),Qu(k,d,0,0,d.width,d.height,0,0,i,r),I&&this.canvasFactory.destroy(I),f&&this.canvasFactory.destroy(f),k.globalCompositeOperation="source-in";const L=B.transform(Xi(k),[1,0,0,1,-M,-D]);return k.fillStyle=o?a.getPattern(s,this,L,We.FILL,t):a,k.fillRect(0,0,i,r),c&&!o&&c.set(h,x.canvas),(Y=this.dependencyTracker)==null||Y.recordDependencies(t,li.transformAndFill),{canvas:x.canvas,canvasEntry:c&&!o?null:x,offsetX:Math.round(M),offsetY:Math.round(D)}}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=M1[e]}setLineJoin(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineJoin",t),this.ctx.lineJoin=I1[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[E,A,_]=ju(i),x=Math.round(.3*E+.59*A+.11*_);o=(r==null?void 0:r[x])??x}else o=(r==null?void 0:r[0])??0;const l=4,{width:c,height:h}=this.ctx.canvas,d=e.width*e.height,f=c*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,d=a,f=o,g=l;const y=this.smaskPreparedOOBAlpha,b=y!==null;if(b){h=Math.max(r,e.offsetX),d=Math.max(a,e.offsetY);const S=Math.min(r+o,e.offsetX+e.canvas.width),w=Math.min(a+l,e.offsetY+e.canvas.height);f=S-h,g=w-d}if(f>0&&g>0){const S=h-this.smaskPreparedOffsetX,w=d-this.smaskPreparedOffsetY;s.save(),s.globalAlpha=1,s.setTransform(1,0,0,1,0,0);const E=new Path2D;E.rect(h,d,f,g),s.clip(E),s.globalCompositeOperation="destination-in",s.drawImage(c.canvas,S,w,f,g,h,d,f,g),s.restore()}b&&y<255&&this._applySMaskOOBAlpha(s,r,a,o,l,h,d,h+f,d+g,y)}else this.genericComposeSMask(e,s,o,l,r,a);t&&(t.save(),t.globalAlpha=1,t.globalCompositeOperation=e.blendMode||"source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,r,a,o,l,r,a,o,l),t.restore())}_applySMaskOOBAlpha(t,e,s,i,r,a,o,l,c,h){const d=ao.measureText(e))),(f===xe.STROKE||f===xe.FILL_STROKE)&&(this.dependencyTracker&&((A=this.dependencyTracker)==null||A.recordCharacterBBox(t,o,c,d,s,i,()=>o.measureText(e)).recordDependencies(t,li.stroke)),o.strokeText(e,s,i));g&&((this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Xt(o),x:s,y:i,fontSize:d,path:S}),(_=this.dependencyTracker)==null||_.recordCharacterBBox(t,o,c,d,s,i))}get isFontSubpixelAAEnabled(){const t=this.canvasFactory.create(10,10),e=t.context;e.scale(1.5,1),e.fillText("I",0,10);const s=e.getImageData(0,0,10,10).data;this.canvasFactory.destroy(t);let i=!1;for(let r=3;r0&&s[r]<255){i=!0;break}return at(this,"isFontSubpixelAAEnabled",i)}showText(t,e){var Y,W,Q,ft;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,li.showText).resetBBox(t),this.current.textRenderingMode&xe.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const s=this.current,i=s.font;if(i.isType3Font){const T=v(this,J,vs).call(this,s.fillAlpha);this.showType3Text(t,e),(Y=this.dependencyTracker)==null||Y.recordShowTextOperation(t),v(this,J,Ke).call(this,T);return}const r=s.fontSize;if(r===0){(W=this.dependencyTracker)==null||W.recordOperation(t);return}const a=v(this,J,vs).call(this,s.fillAlpha),o=this.ctx,l=s.fontSizeScale,c=s.charSpacing,h=s.wordSpacing,d=s.fontDirection,f=s.textHScale*d,g=e.length,y=i.vertical,b=y?1:-1,S=i.defaultVMetrics,w=r*s.fontMatrix[0],E=s.textRenderingMode===xe.FILL&&!i.disableFontFace&&!s.patternFill;o.save(),s.textMatrix&&o.transform(...s.textMatrix),o.translate(s.x,s.y+s.textRise),d>0?o.scale(f,-1):o.scale(f,1);let A,_;const x=s.textRenderingMode&xe.FILL_STROKE_MASK,k=x===xe.FILL||x===xe.FILL_STROKE,M=x===xe.STROKE||x===xe.FILL_STROKE;let D=s.lineWidth;const I=s.textMatrixScale;if(I===0||D===0?M&&(D=this.getSinglePixelWidth()):D/=I,l!==1&&(o.scale(l,l),D/=l),o.lineWidth=D,k&&s.patternFill){o.save();const T=s.fillColor.getPattern(o,this,Xi(o),We.FILL,t);A=Xt(o),o.restore(),o.fillStyle=T}if(M&&s.patternStroke){o.save();const T=s.strokeColor.getPattern(o,this,Xi(o),We.STROKE,t);_=Xt(o),o.restore(),o.strokeStyle=T}if(i.isInvalidPDFjsFont){const T=[];let q=0;for(const bt of e)T.push(bt.unicode),q+=bt.width;const Lt=T.join("");if(o.fillText(Lt,0,0),this.dependencyTracker!==null){const bt=o.measureText(Lt);this.dependencyTracker.recordBBox(t,this.ctx,-bt.actualBoundingBoxLeft,bt.actualBoundingBoxRight,-bt.actualBoundingBoxAscent,bt.actualBoundingBoxDescent).recordShowTextOperation(t)}s.x+=q*w*f,o.restore(),this.compose(),v(this,J,Ke).call(this,a);return}let L=0,O;for(O=0;O0){$=o.measureText(bt);const ot=$.width*1e3/r*l;if(H$??o.measureText(bt));else if(this.paintChar(t,bt,ae,Gt,A,_),_e){const ot=ae+r*_e.offset.x/l,Z=Gt-r*_e.offset.y/l;this.paintChar(t,_e.fontChar,ot,Z,A,_)}}const ht=y?H*w-Lt*d:H*w+Lt*d;L+=ht,q&&o.restore()}y?s.y-=L:s.x+=L*f,o.restore(),this.compose(),(ft=this.dependencyTracker)==null||ft.recordShowTextOperation(t),v(this,J,Ke).call(this,a)}showType3Text(t,e){const s=this.ctx,i=this.current,r=i.font,a=i.fontSize,o=i.fontDirection,l=r.vertical?1:-1,c=i.charSpacing,h=i.wordSpacing,d=i.textHScale*o,f=i.fontMatrix||ng,g=e.length,y=i.textRenderingMode===xe.INVISIBLE;let b,S,w,E;if(y||a===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,s.save(),i.textMatrix&&s.transform(...i.textMatrix),s.translate(i.x,i.y+i.textRise),s.scale(d,o);const A=this.dependencyTracker;for(this.dependencyTracker=A?new Jh(A,t):null,b=0;bnew tv(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new Jh(this.dependencyTracker,o,!0):null)};s=new Wh(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 Wh?[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=_1(this.getObject(t,e)),this.cachedPatterns.set(e,i)),s&&(i.matrix=s),i}shadingFill(t,e){var o;if(!this.contentVisible)return;const s=v(this,J,vs).call(this,this.current.fillAlpha),i=this.ctx;this.save(t);const r=this._getPattern(t,e);i.fillStyle=r.getPattern(i,this,Xi(i),We.SHADING,t);const a=Xi(i);if(a){const{width:l,height:c}=i.canvas,h=ja.slice();B.axialAlignedBoundingBox([0,0,l,c],a,h);const[d,f,g,y]=h;this.ctx.fillRect(d,f,g-d,y-f)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);(o=this.dependencyTracker)==null||o.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,li.transform).recordDependencies(t,li.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t),v(this,J,Ke).call(this,s)}beginInlineImage(){Ct("Should not call beginInlineImage")}beginImageData(){Ct("Should not call beginImageData")}paintFormXObjectBegin(t,e,s){var i;if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=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 E;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,Hs)===0&&i.globalAlpha===1&&i.globalCompositeOperation==="source-over"&&!s){if(e.bbox){let A=new Path2D;const[_,x,k,M]=e.bbox;if(A.rect(_,x,k-_,M-x),e.matrix){const D=new Path2D;D.addPath(A,new DOMMatrix(e.matrix)),A=D}i.clip(A)}this.groupStack.push(null),n(this,cn).push(null),this.groupLevel++;return}!e.isolated&&!e.knockout&&n(this,Hs)===0&&Fp("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=ja.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),d=Math.max(Math.ceil(o[3])-c,1);this.current.startNewPathAndClipBox([0,0,h,d]);const f=this.canvasFactory.create(h,d);e.smask&&this.smaskGroupCanvases.push(f);const g=f.context,y=e.knockout&&!e.isolated?i:null,b=!e.isolated&&!e.knockout&&!e.smask&&e.needsIsolation&&n(this,Hs)>0,S=e.knockout?this.canvasFactory.create(h,d):null,w=n(this,Hs);if(e.knockout?Yt(this,Hs)._++:p(this,Hs,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[_,x,k,M]=e.bbox;if(A.rect(_,x,k-_,M-x),e.matrix){const D=new Path2D;D.addPath(A,new DOMMatrix(e.matrix)),A=D}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()),Ra(i,g),this.ctx=g,(E=this.dependencyTracker)==null||E.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(i),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(i),n(this,cn).push({backdropCtx:y,savedKnockoutLevel:w,offsetX:l,offsetY:c,hasInnerBackdrop:b,knockoutMaskEntry:S,knockoutTempEntry:null,knockoutBackdropEntry:null}),this.groupLevel++}endGroup(t,e){var a;if(!this.contentVisible)return;this.groupLevel--;const s=this.ctx,i=this.groupStack.pop(),r=n(this,cn).pop();if(r&&p(this,Hs,r.savedKnockoutLevel),i===null){this.restore(t);return}if(e.isGray&&v(this,J,ty).call(this,s),this.ctx=i,this.ctx.imageSmoothingEnabled=!1,(a=this.dependencyTracker)==null||a.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&(this.ctx.restore(),this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform())),v(this,J,bf).call(this,r);else{this.ctx.restore();const o=Xt(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...o);const l=ja.slice();B.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],o,l);const c=n(this,cn).at(-1);if(n(this,Hs)>0)if(r.hasInnerBackdrop){const{width:h,height:d}=s.canvas,f=this.canvasFactory.create(h,d),g=f.context;g.drawImage(i.canvas,r.offsetX,r.offsetY,h,d,0,0,h,d),g.globalCompositeOperation="source-over",g.drawImage(s.canvas,0,0);const y=v(this,J,Bg).call(this,s.canvas);g.globalCompositeOperation="destination-in",g.drawImage(y.canvas,0,0);const b=this.ctx.globalCompositeOperation,S=this.ctx.globalAlpha,w=this.ctx.filter;this.ctx.save(),this.ctx.setTransform(...o),this.ctx.globalAlpha=1,Ut.isCanvasFilterSupported&&(this.ctx.filter="none"),this.ctx.globalCompositeOperation="destination-out",this.ctx.drawImage(y.canvas,0,0),this.ctx.globalCompositeOperation=b,this.ctx.globalAlpha=S,Ut.isCanvasFilterSupported&&(this.ctx.filter=w??"none"),this.ctx.drawImage(f.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(y),this.canvasFactory.destroy(f)}else{const h=(c==null?void 0:c.backdropCtx)??null;v(this,J,Ug).call(this,this.ctx,s.canvas,{backdropCanvas:(h==null?void 0:h.canvas)??null,destTransform:o,backdropOffset:h?[c.offsetX+r.offsetX,c.offsetY+r.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}else this.ctx.drawImage(s.canvas,0,0);this.ctx.restore(),this.canvasFactory.destroy({canvas:s.canvas,context:s}),v(this,J,bf).call(this,r),this.compose(l)}}beginAnnotation(t,e,s,i,r,a,o){if(v(this,J,Og).call(this),Ju(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),s){const l=s[2]-s[0],c=s[3]-s[1];if(a&&this.annotationCanvasMap){i=i.slice(),i[4]-=s[0],i[5]-=s[1],s=s.slice(),s[0]=s[1]=0,s[2]=l,s[3]=c,B.singularValueDecompose2dScale(Xt(this.ctx),ii);const{viewportScale:h}=this,d=Math.ceil(l*this.outputScaleX*h),f=Math.ceil(c*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(d,f);const{canvas:g,context:y}=this.annotationCanvas;if(o){const b=this.annotationCanvasMap.getOrInsertComputed(e,Vu);g.setAttribute("data-canvas-name",o);const S=b.findIndex(w=>w.getAttribute("data-canvas-name")===o);S===-1?b.push(g):b[S]=g}else this.annotationCanvasMap.set(e,g);this.annotationCanvas.savedCtx=this.ctx,this.ctx=y,this.ctx.save(),this.ctx.setTransform(ii[0],0,0,-ii[1],0,c*ii[1]),Ju(this.ctx)}else{Ju(this.ctx),this.endPath(t);const h=new Path2D;h.rect(s[0],s[1],l,c),this.ctx.clip(h)}}this.current=new Tv(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(t,...i),this.transform(t,...r),this.baseTransform=Xt(this.ctx)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),v(this,J,Ng).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas),this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(t,e){var l;if(!this.contentVisible)return;const s=e.count;e=this.getObject(t,e.data,e),e.count=s;const i=v(this,J,vs).call(this,this.current.fillAlpha),r=this.ctx,a=this._createMaskCanvas(t,e),o=a.canvas;r.save(),r.setTransform(1,0,0,1,0,0),r.drawImage(o,a.offsetX,a.offsetY),(l=this.dependencyTracker)==null||l.resetBBox(t).recordBBox(t,this.ctx,a.offsetX,a.offsetX+o.width,a.offsetY,a.offsetY+o.height).recordOperation(t),r.restore(),a.canvasEntry&&this.canvasFactory.destroy(a.canvasEntry),this.compose(),v(this,J,Ke).call(this,i)}paintImageMaskXObjectRepeat(t,e,s,i=0,r=0,a,o){var f,g,y;if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const l=v(this,J,vs).call(this,this.current.fillAlpha),c=this.ctx;c.save();const h=Xt(c);c.transform(s,i,r,a,0,0);const d=this._createMaskCanvas(t,e);c.setTransform(1,0,0,1,d.offsetX-h[4],d.offsetY-h[5]),(f=this.dependencyTracker)==null||f.resetBBox(t);for(let b=0,S=o.length;bd?h/d:1,o=c>d?c/d:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:s,current:{lineWidth:i}}=this,[r,a]=this.getScaleForStroking();if(r===a){s.lineWidth=(i||1)*r,s.stroke(t);return}const o=s.getLineDash();e&&s.save(),s.scale(r,a),Zp.a=1/r,Zp.d=1/a;const l=new Path2D;if(l.addPath(t,Zp),o.length>0){const c=Math.max(r,a);s.setLineDash(o.map(h=>h/c)),s.lineDashOffset/=c}s.lineWidth=i||1,s.stroke(l),e&&s.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};Hs=new WeakMap,Jr=new WeakMap,_o=new WeakMap,ko=new WeakMap,To=new WeakMap,Po=new WeakMap,Mo=new WeakMap,Io=new WeakMap,Do=new WeakMap,cn=new WeakMap,J=new WeakSet,Og=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(this.transparentCanvasEntry),this.transparentCanvas=null,this.transparentCanvasEntry=null)},Ng=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}},Bg=function(t,e=null,s=1){const{width:i,height:r}=t,a=e??this.canvasFactory.create(i,r),o=a.context;s=Math.round(s*255)/255;const l=s<1;l&&n(this,Io)===void 0&&p(this,Io,Ut.isCanvasFilterSupported?new Map:"none");let c="none";if(l&&n(this,Io)instanceof Map&&(c=n(this,Io).getOrInsertComputed(s,()=>this.filterFactory.addKnockoutFilter(s))),!l||c!=="none")return e&&(o.save(),o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,i,r),o.restore()),o.filter=c,o.drawImage(t,0,0),o.filter="none",a;const h=t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,i,r),d=o.createImageData(i,r),f=h.data,g=d.data,y=s>0?1/s:1e6;for(let b=3,S=f.length;b0||!this.contentVisible)return!1;Yt(this,Jr)._++,p(this,Mo,t);const e=n(this,cn).at(-1),{canvas:s}=this.ctx,i=v(this,J,$g).call(this,e,"knockoutTempEntry",s.width,s.height);p(this,_o,i);const r=i.context;return r.save(),r.setTransform(this.ctx.getTransform()),Ra(this.ctx,r),p(this,Po,r.globalCompositeOperation),r.globalCompositeOperation="source-over",kv(r,this.ctx),p(this,Do,e),p(this,ko,this.ctx),p(this,To,this.suspendedCtx),this.ctx=r,this.inSMaskMode&&(this.suspendedCtx=r),!0},Ke=function(t){var l;if(!t)return;const e=n(this,_o),s=n(this,ko),i=n(this,To),r=e.context;p(this,_o,null),p(this,ko,null),p(this,To,null),this.inSMaskMode&&this.suspendedCtx===r&&this.ctx!==r&&this.endSMaskMode(),this.inSMaskMode&&(this.suspendedCtx=i),this.ctx._removeMirroring(),this.ctx.globalCompositeOperation=n(this,Po),p(this,Po,null),Ra(this.ctx,s),this.ctx=s;const a=n(this,Do);p(this,Do,null);const o=n(this,Mo);p(this,Mo,1);try{v(this,J,Ug).call(this,i??s,e.canvas,{backdropCanvas:((l=a==null?void 0:a.backdropCtx)==null?void 0:l.canvas)??null,backdropOffset:a!=null&&a.backdropCtx?[a.offsetX,a.offsetY]:[0,0],reuseMaskEntry:(a==null?void 0:a.knockoutMaskEntry)??null,poolMeta:a,knockoutAlpha:o})}finally{r.restore(),Yt(this,Jr)._--,a||this.canvasFactory.destroy(e)}},Hg=function(t,e,s){const i=new Path2D;return i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),i},ty=function(t){const{canvas:e}=t,{width:s,height:i}=e;if(Ut.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=Hp(c.url),ay(c.status,a),this._reader=c.body.getReader();const h=c.headers,{contentLength:d,isRangeSupported:f}=sy({responseHeaders:h,isHttp:!0,rangeChunkSize:r,disableRange:s});this._contentLength=d,this._isRangeSupported=f,this._filename=iy(h),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new _a("Streaming is disabled.")),this._headersCapability.resolve()}).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:(this._loaded+=e.byteLength,this._callOnProgress(),{value:Vp(e),done:!1})}cancel(e){var s;(s=this._reader)==null||s.cancel(e),this._abortController.abort()}}class O1 extends Up{constructor(e,s,i){super(e,s,i);P(this,"_abortController",new AbortController);P(this,"_readCapability",Promise.withResolvers());P(this,"_reader",null);const{url:r,withCredentials:a}=e._source,o=new Headers(e.headers);o.append("Range",`bytes=${s}-${i-1}`),ry(r,o,a,this._abortController).then(l=>{const c=Hp(l.url);ny(c,e._responseOrigin),ay(l.status,r),this._reader=l.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:{value:Vp(e),done:!1}}cancel(e){var s;(s=this._reader)==null||s.cancel(e),this._abortController.abort()}}function Lv(u){return u instanceof Uint8Array&&u.byteLength===u.buffer.byteLength?u.buffer:new Uint8Array(u).buffer}function Gp(){for(const u of this._requests)u.resolve({value:void 0,done:!0});this._requests.length=0}var vp,oy;class N1 extends Bp{constructor(e){super(e,B1,$1);m(this,vp);P(this,"_progressiveDone",!1);P(this,"_queuedChunks",[]);const{pdfDataRangeTransport:s}=e,{initialData:i,progressiveDone:r}=s;if((i==null?void 0:i.length)>0){const o=Lv(i);this._queuedChunks.push(o)}this._progressiveDone=r;const a=o=>{var l;switch(o.type){case"range":case"progressiveRead":v(this,vp,oy).call(this,o.begin,o.chunk);break;case"progressiveDone":(l=this._fullReader)==null||l.progressiveDone(),this._progressiveDone=!0;break}};s.transportReady(a)}getFullReader(){const e=super.getFullReader();return this._queuedChunks=null,e}getRangeReader(e,s){const i=super.getRangeReader(e,s);return i&&(i.onDone=()=>this._rangeReaders.delete(i),this._source.pdfDataRangeTransport.requestDataRange(e,s)),i}cancelAllRequests(e){super.cancelAllRequests(e),this._source.pdfDataRangeTransport.abort()}}vp=new WeakSet,oy=function(e,s){const i=Lv(s);if(e===void 0)this._fullReader?this._fullReader._enqueue(i):this._queuedChunks.push(i);else{const r=this._rangeReaders.keys().find(a=>a._begin===e);re(r,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),r._enqueue(i)}};var Fd;class B1 extends $p{constructor(e){super(e);m(this,Fd,Gp.bind(this));P(this,"_done",!1);P(this,"_queuedChunks",null);P(this,"_requests",[]);const{pdfDataRangeTransport:s,disableRange:i,disableStream:r}=e._source,{length:a,contentDispositionFilename:o}=s;this._queuedChunks=e._queuedChunks||[];for(const c of this._queuedChunks)this._loaded+=c.byteLength;this._done=e._progressiveDone,this._contentLength=a,this._isStreamingSupported=!r,this._isRangeSupported=!i,Gm(o)&&(this._filename=o),this._headersCapability.resolve();const l=this._loaded;Promise.resolve().then(()=>{l>0&&this._loaded===l&&this._callOnProgress()})}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength,this._callOnProgress())}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,n(this,Fd).call(this)}progressiveDone(){this._done||(this._done=!0),this._queuedChunks.length===0&&n(this,Fd).call(this)}}Fd=new WeakMap;var Rd;class $1 extends Up{constructor(e,s,i){super(e,s,i);m(this,Rd,Gp.bind(this));P(this,"onDone",null);P(this,"_begin",-1);P(this,"_done",!1);P(this,"_queuedChunk",null);P(this,"_requests",[]);this._begin=s}_enqueue(e){var s;this._done||(this._requests.length===0?this._queuedChunk=e:(this._requests.shift().resolve({value:e,done:!1}),n(this,Rd).call(this)),this._done=!0,(s=this.onDone)==null||s.call(this))}async read(){if(this._queuedChunk){const s=this._queuedChunk;return this._queuedChunk=null,{value:s,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){var s;this._done=!0,n(this,Rd).call(this),(s=this.onDone)==null||s.call(this)}}Rd=new WeakMap;const tg=200,Fv=206;function U1(u){return typeof u!="string"?u:Rp(u).buffer}var hn,vh,ly,cy;class H1 extends Bp{constructor(e){super(e,z1,V1);m(this,vh);m(this,hn,new WeakMap);P(this,"_responseOrigin",null);const{httpHeaders:s,url:i}=e;this.url=i,this.isHttp=/https?:/.test(i.protocol),this.headers=ey(this.isHttp,s)}_request(e){const s=new XMLHttpRequest,i={validateStatus:null,onHeadersReceived:e.onHeadersReceived,onDone:e.onDone,onError:e.onError,onProgress:e.onProgress};n(this,hn).set(s,i),s.open("GET",this.url),s.withCredentials=this._source.withCredentials;for(const[r,a]of this.headers)s.setRequestHeader(r,a);return this.isHttp&&"begin"in e&&"end"in e?(s.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),i.validateStatus=r=>r===Fv||r===tg):i.validateStatus=r=>r===tg,s.responseType="arraybuffer",re(e.onError,"Expected `onError` callback to be provided."),s.onerror=()=>e.onError(s.status),s.onreadystatechange=v(this,vh,cy).bind(this,s),s.onprogress=v(this,vh,ly).bind(this,s),s.send(null),s}_abortRequest(e){n(this,hn).has(e)&&(n(this,hn).delete(e),e.abort())}getRangeReader(e,s){const i=super.getRangeReader(e,s);return i&&(i.onClosed=()=>this._rangeReaders.delete(i)),i}}hn=new WeakMap,vh=new WeakSet,ly=function(e,s){var r;const i=n(this,hn).get(e);(r=i==null?void 0:i.onProgress)==null||r.call(i,s)},cy=function(e,s){const i=n(this,hn).get(e);if(!i||(e.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),e.readyState!==4)||!n(this,hn).has(e))return;if(n(this,hn).delete(e),e.status===0&&this.isHttp){i.onError(e.status);return}const r=e.status||tg;if(!i.validateStatus(r)){i.onError(e.status);return}const a=U1(e.response);if(r===Fv){const o=e.getResponseHeader("Content-Range");/bytes \d+-\d+\/\d+/.test(o)?i.onDone(a):(dt('Missing or invalid "Content-Range" header.'),i.onError(0))}else a?i.onDone(a):i.onError(e.status)};var Od,Cn,hy,dy,uy,fy;class z1 extends $p{constructor(e){super(e);m(this,Cn);m(this,Od,Gp.bind(this));P(this,"_cachedChunks",[]);P(this,"_done",!1);P(this,"_requests",[]);P(this,"_storedError",null);this._fullRequestXhr=e._request({onHeadersReceived:v(this,Cn,hy).bind(this),onDone:v(this,Cn,dy).bind(this),onError:v(this,Cn,uy).bind(this),onProgress:v(this,Cn,fy).bind(this)})}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._headersCapability.reject(e),n(this,Od).call(this),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}Od=new WeakMap,Cn=new WeakSet,hy=function(){const e=this._stream,{disableRange:s,rangeChunkSize:i}=e._source,r=this._fullRequestXhr;e._responseOrigin=Hp(r.responseURL);const a=r.getAllResponseHeaders(),o=new Headers(a?a.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(h=>{const[d,...f]=h.split(": ");return[d,f.join(": ")]}):[]),{contentLength:l,isRangeSupported:c}=sy({responseHeaders:o,isHttp:e.isHttp,rangeChunkSize:i,disableRange:s});this._contentLength=l,this._isRangeSupported=c,this._filename=iy(o),this._isRangeSupported&&e._abortRequest(r),this._headersCapability.resolve()},dy=function(e){this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._cachedChunks.push(e),this._done=!0,this._cachedChunks.length===0&&n(this,Od).call(this)},uy=function(e){this._storedError=zp(e,this._stream.url),this._headersCapability.reject(this._storedError);for(const s of this._requests)s.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0},fy=function(e){var s;(s=this.onProgress)==null||s.call(this,{loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})};var Nd,wr,py,gy,zg;class V1 extends Up{constructor(e,s,i){super(e,s,i);m(this,wr);m(this,Nd,Gp.bind(this));P(this,"onClosed",null);P(this,"_done",!1);P(this,"_queuedChunk",null);P(this,"_requests",[]);P(this,"_storedError",null);this._requestXhr=e._request({begin:s,end:i,onHeadersReceived:v(this,wr,py).bind(this),onDone:v(this,wr,gy).bind(this),onError:v(this,wr,zg).bind(this),onProgress:null})}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const s=this._queuedChunk;return this._queuedChunk=null,{value:s,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){var s;this._done=!0,n(this,Nd).call(this),this._stream._abortRequest(this._requestXhr),(s=this.onClosed)==null||s.call(this)}}Nd=new WeakMap,wr=new WeakSet,py=function(){var s;const e=Hp((s=this._requestXhr)==null?void 0:s.responseURL);try{ny(e,this._stream._responseOrigin)}catch(i){this._storedError=i,v(this,wr,zg).call(this,0)}},gy=function(e){var s;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0,n(this,Nd).call(this),(s=this.onClosed)==null||s.call(this)},zg=function(e){this._storedError??(this._storedError=zp(e,this._stream.url));for(const s of this._requests)s.reject(this._storedError);this._requests.length=0,this._queuedChunk=null};function my(u,t=null){const e=process.getBuiltinModule("fs"),{Readable:s}=process.getBuiltinModule("stream"),i=e.createReadStream(u,t);return s.toWeb(i)}class G1 extends Bp{constructor(t){super(t,j1,W1);const{url:e}=t;re(e.protocol==="file:","PDFNodeStream only supports file:// URLs.")}}class j1 extends $p{constructor(e){super(e);P(this,"_reader",null);const{disableRange:s,disableStream:i,rangeChunkSize:r,url:a}=e._source;this._isStreamingSupported=!i,process.getBuiltinModule("fs/promises").lstat(a).then(l=>{const c=my(a);this._reader=c.getReader();const{size:h}=l;this._contentLength=h,this._isRangeSupported=!s&&h>2*r,!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new _a("Streaming is disabled.")),this._headersCapability.resolve()}).catch(l=>{l.code==="ENOENT"&&(l=zp(0,a)),this._headersCapability.reject(l)})}async read(){await this._headersCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:(this._loaded+=e.byteLength,this._callOnProgress(),{value:Vp(e),done:!1})}cancel(e){var s;(s=this._reader)==null||s.cancel(e)}}class W1 extends Up{constructor(e,s,i){super(e,s,i);P(this,"_readCapability",Promise.withResolvers());P(this,"_reader",null);const{url:r}=e._source;try{const a=my(r,{start:s,end:i-1});this._reader=a.getReader(),this._readCapability.resolve()}catch(a){this._readCapability.reject(a)}}async read(){await this._readCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:{value:Vp(e),done:!1}}cancel(e){var s;(s=this._reader)==null||s.cancel(e)}}function X1(u){return jh(u)?F1:si?G1:H1}var Bd,$d;class Sn{static get workerPort(){return n(this,Bd)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");p(this,Bd,t)}static get workerSrc(){return n(this,$d)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");p(this,$d,t)}}Bd=new WeakMap,$d=new WeakMap,m(Sn,Bd,null),m(Sn,$d,"");var Ac,Ud;class q1{constructor({parsedData:t,rawData:e}){m(this,Ac);m(this,Ud);p(this,Ac,t),p(this,Ud,e)}getRaw(){return n(this,Ud)}get(t){return n(this,Ac).get(t)??null}[Symbol.iterator](){return n(this,Ac).entries()}}Ac=new WeakMap,Ud=new WeakMap;const Ba=Symbol("INTERNAL");var Hd,zd,Sc,Lo;class Y1{constructor(t,{name:e,intent:s,usage:i,rbGroups:r}){m(this,Hd,!1);m(this,zd,!1);m(this,Sc,!1);m(this,Lo,!0);p(this,Hd,!!(t&ei.DISPLAY)),p(this,zd,!!(t&ei.PRINT)),this.name=e,this.intent=s,this.usage=i,this.rbGroups=r}get visible(){if(n(this,Sc))return n(this,Lo);if(!n(this,Lo))return!1;const{print:t,view:e}=this.usage;return n(this,Hd)?(e==null?void 0:e.viewState)!=="OFF":n(this,zd)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==Ba&&Ct("Internal method `_setVisible` called."),p(this,Sc,s),p(this,Lo,e)}get serializable(){return{userSet:n(this,Sc),visible:n(this,Lo)}}}Hd=new WeakMap,zd=new WeakMap,Sc=new WeakMap,Lo=new WeakMap;var Zr,kt,xc,Ec,Vd,Gd,Gg;const ev=class ev{constructor(t,e=ei.DISPLAY,s=null){m(this,Gd);m(this,Zr,null);m(this,kt,new Map);m(this,xc,null);m(this,Ec,null);m(this,Vd);P(this,"creator",null);P(this,"name",null);if(p(this,Vd,t),this.renderingIntent=e,t!==null){this.name=t.name,this.creator=t.creator,p(this,Ec,t.order);for(const i of t.groups)n(this,kt).set(i.id,new Y1(e,i));if(s){s.size!==n(this,kt).size&&Ct("Incorrect serialized groupState.");for(const[i,r]of s)n(this,kt).get(i)._setVisible(Ba,r.visible,r.userSet)}else{if(t.baseState==="OFF")for(const i of n(this,kt).values())i._setVisible(Ba,!1);for(const i of t.on)n(this,kt).get(i)._setVisible(Ba,!0);for(const i of t.off)n(this,kt).get(i)._setVisible(Ba,!1)}p(this,xc,this.getHash())}}isVisible(t){if(n(this,kt).size===0)return!0;if(!t)return Fp("Optional content group not defined."),!0;if(t.type==="OCG")return n(this,kt).has(t.id)?n(this,kt).get(t.id).visible:(dt(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return v(this,Gd,Gg).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!n(this,kt).has(e))return dt(`Optional content group not found: ${e}`),!0;if(n(this,kt).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!n(this,kt).has(e))return dt(`Optional content group not found: ${e}`),!0;if(!n(this,kt).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!n(this,kt).has(e))return dt(`Optional content group not found: ${e}`),!0;if(!n(this,kt).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!n(this,kt).has(e))return dt(`Optional content group not found: ${e}`),!0;if(n(this,kt).get(e).visible)return!1}return!0}return dt(`Unknown optional content policy ${t.policy}.`),!0}return dt(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){var r;const i=n(this,kt).get(t);if(!i){dt(`Optional content group not found: ${t}`);return}if(s&&e&&i.rbGroups.length)for(const a of i.rbGroups)for(const o of a)o!==t&&((r=n(this,kt).get(o))==null||r._setVisible(Ba,!1,!0));i._setVisible(Ba,!!e,!0),p(this,Zr,null)}setOCGState({state:t,preserveRB:e}){let s;for(const i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const r=n(this,kt).get(i);if(r)switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!r.visible,e);break}}p(this,Zr,null)}get hasInitialVisibility(){return n(this,xc)===null||this.getHash()===n(this,xc)}getOrder(){return n(this,kt).size?n(this,Ec)?n(this,Ec).slice():[...n(this,kt).keys()]:null}getGroup(t){return n(this,kt).get(t)||null}getHash(){if(n(this,Zr)!==null)return n(this,Zr);const t=new Tg;for(const[e,s]of n(this,kt))t.update(`${e}:${s.visible}`);return p(this,Zr,t.hexdigest())}[Symbol.iterator](){return n(this,kt).entries()}get serializable(){const t=new Map;for(const[e,s]of n(this,kt))t.set(e,s.serializable);return{data:n(this,Vd),renderingIntent:this.renderingIntent,groupState:t}}static fromSerializable({data:t,renderingIntent:e,groupState:s}){return new ev(t,e,s)}};Zr=new WeakMap,kt=new WeakMap,xc=new WeakMap,Ec=new WeakMap,Vd=new WeakMap,Gd=new WeakSet,Gg=function(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;if===g+1)&&p(this,ge,null)}deletePages(t){v(this,is,Rh).call(this);const e=n(this,ge),s=v(this,is,Oh).call(this);p(this,dn,{pageNumberToId:e.slice(),pagesNumber:n(this,ze),prevPageNumbers:n(this,Ni).slice()});const i=n(this,ze)-t.length;p(this,ze,i);const r=p(this,ge,new Uint32Array(i));p(this,Ni,new Int32Array(i));let a=0,o=0;for(const l of t){const c=l-1;c!==a&&(r.set(e.subarray(a,c),o),o+=c-a),a=c+1}an(this,ge)[e-1])})}cancelCopy(){p(this,Fo,null)}pastePages(t){v(this,is,Rh).call(this);const e=n(this,ge),s=v(this,is,Oh).call(this),{pageNumbers:i,pageIds:r}=n(this,Fo),a=n(this,ze)+i.length;p(this,ze,a);const o=p(this,ge,new Uint32Array(a));p(this,Ni,new Int32Array(a)),o.set(e.subarray(0,t),0),o.set(r,t),o.set(e.subarray(t),t+i.length),v(this,is,yf).call(this,s,null,t,i),p(this,Fo,null)}hasBeenAltered(){return n(this,ge)!==null}getPageMappingForSaving(t=null){t??(t=v(this,is,Oh).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:Rl});var bi;class vy{constructor(){m(this,bi,new Map)}get(t,e=null){if(e){const i=n(this,bi).getOrInsertComputed(t,Rv);return i.promise.then(()=>e(i.data)),null}const s=n(this,bi).get(t);if(!s||s.data===Rl)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=n(this,bi).get(t);return!!e&&e.data!==Rl}delete(t){const e=n(this,bi).get(t);return!e||e.data===Rl?!1:(n(this,bi).delete(t),!0)}resolve(t,e=null){const s=n(this,bi).getOrInsertComputed(t,Rv);if(s.data!==Rl)throw new Error(`Object already resolved ${t}.`);s.data=e,s.resolve()}clear(){var t;for(const{data:e}of n(this,bi).values())(t=e==null?void 0:e.bitmap)==null||t.close();n(this,bi).clear()}*[Symbol.iterator](){for(const[t,{data:e}]of n(this,bi))e!==Rl&&(yield[t,e])}}bi=new WeakMap;const Q1=1e5,Ov=30;var Gv,ta,ls,jd,Wd,Cc,Ro,qn,Xd,qd,Oo,Yd,_c,ea,kc,Kd,Tc,No,Qd,Jd,Pc,Bo,Zd,Mc,Ic,Ar,by,yy,jg,ai,wf,Wg,wy,Ay;const Be=class Be{constructor({textContentSource:t,images:e,container:s,viewport:i}){m(this,Ar);m(this,ta,Promise.withResolvers());m(this,ls,null);m(this,jd,!1);m(this,Wd,!!((Gv=globalThis.FontInspector)!=null&&Gv.enabled));m(this,Cc,null);m(this,Ro,null);m(this,qn,null);m(this,Xd,0);m(this,qd,0);m(this,Oo,null);m(this,Yd,null);m(this,_c,0);m(this,ea,0);m(this,kc,Object.create(null));m(this,Kd,[]);m(this,Tc,null);m(this,No,[]);m(this,Qd,new WeakMap);m(this,Jd,null);var c;if(t instanceof ReadableStream)p(this,Tc,t);else if(typeof t=="object")p(this,Tc,new ReadableStream({start(h){h.enqueue(t),h.close()}}));else throw new Error('No "textContentSource" parameter specified.');p(this,ls,p(this,Yd,s)),p(this,Cc,e),p(this,ea,i.scale*En.pixelRatio),p(this,_c,i.rotation),p(this,qn,{div:null,properties:null,ctx:null});const{pageWidth:r,pageHeight:a,pageX:o,pageY:l}=i.rawDims;p(this,Jd,[1,0,0,-1,-o,l+a]),p(this,qd,r),p(this,Xd,a),v(c=Be,ai,wy).call(c),s.style.setProperty("--min-font-size",n(Be,Mc)),xl(s,i),n(this,ta).promise.finally(()=>{n(Be,Ic).delete(this),p(this,qn,null),p(this,kc,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=Ut.platform;return at(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){n(this,Cc)&&n(this,ls).append(n(this,Cc).render());const t=()=>{n(this,Oo).read().then(({value:e,done:s})=>{if(s){n(this,ta).resolve();return}n(this,Ro)??p(this,Ro,e.lang),Object.assign(n(this,kc),e.styles),v(this,Ar,by).call(this,e.items),t()},n(this,ta).reject)};return p(this,Oo,n(this,Tc).getReader()),n(Be,Ic).add(this),t(),n(this,ta).promise}update({viewport:t,onBefore:e=null}){var r;const s=t.scale*En.pixelRatio,i=t.rotation;if(i!==n(this,_c)&&(e==null||e(),p(this,_c,i),xl(n(this,Yd),{rotation:i})),s!==n(this,ea)){e==null||e(),p(this,ea,s);const a={div:null,properties:null,ctx:v(r=Be,ai,wf).call(r,n(this,Ro))};for(const o of n(this,No))a.properties=n(this,Qd).get(o),a.div=o,v(this,Ar,jg).call(this,a)}}cancel(){var e;const t=new _a("TextLayer task cancelled.");(e=n(this,Oo))==null||e.cancel(t).catch(()=>{}),p(this,Oo,null),n(this,ta).reject(t)}get textDivs(){return n(this,No)}get textContentItemsStr(){return n(this,Kd)}static cleanup(){if(!(n(this,Ic).size>0)){n(this,Pc).clear();for(const{canvas:t}of n(this,Bo).values())t.remove();n(this,Bo).clear()}}};ta=new WeakMap,ls=new WeakMap,jd=new WeakMap,Wd=new WeakMap,Cc=new WeakMap,Ro=new WeakMap,qn=new WeakMap,Xd=new WeakMap,qd=new WeakMap,Oo=new WeakMap,Yd=new WeakMap,_c=new WeakMap,ea=new WeakMap,kc=new WeakMap,Kd=new WeakMap,Tc=new WeakMap,No=new WeakMap,Qd=new WeakMap,Jd=new WeakMap,Pc=new WeakMap,Bo=new WeakMap,Zd=new WeakMap,Mc=new WeakMap,Ic=new WeakMap,Ar=new WeakSet,by=function(t){var i,r;if(n(this,jd))return;(r=n(this,qn)).ctx??(r.ctx=v(i=Be,ai,wf).call(i,n(this,Ro)));const e=n(this,No),s=n(this,Kd);for(const a of t){if(e.length>Q1){dt("Ignoring additional textDivs for performance reasons."),p(this,jd,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=n(this,ls);p(this,ls,document.createElement("span")),n(this,ls).classList.add("markedContent"),a.id&&n(this,ls).setAttribute("id",`${a.id}`),a.tag==="Artifact"&&(n(this,ls).ariaHidden=!0),o.append(n(this,ls))}else a.type==="endMarkedContent"&&p(this,ls,n(this,ls).parentNode);continue}s.push(a.str),v(this,Ar,yy).call(this,a)}},yy=function(t){var y;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};n(this,No).push(e);const i=B.transform(n(this,Jd),t.transform);let r=Math.atan2(i[1],i[0]);const a=n(this,kc)[t.fontName];a.vertical&&(r+=Math.PI/2);let o=n(this,Wd)&&a.fontSubstitution||a.fontFamily;o=Be.fontFamilyMap.get(o)||o;const l=Math.hypot(i[2],i[3]),c=l*v(y=Be,ai,Ay).call(y,o,a,n(this,Ro));let h,d;r===0?(h=i[4],d=i[5]-c):(h=i[4]+c*Math.sin(r),d=i[5]-c*Math.cos(r));const f=e.style;f.left=`${(100*h/n(this,qd)).toFixed(2)}%`,f.top=`${(100*d/n(this,Xd)).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,Wd)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),r!==0&&(s.angle=r*(180/Math.PI));let g=!1;if(t.str.length>1)g=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const b=Math.abs(t.transform[0]),S=Math.abs(t.transform[3]);b!==S&&Math.max(b,S)/Math.min(b,S)>1.5&&(g=!0)}if(g&&(s.canvasWidth=a.vertical?t.height:t.width),n(this,Qd).set(e,s),n(this,qn).div=e,n(this,qn).properties=s,v(this,Ar,jg).call(this,n(this,qn)),s.hasText&&n(this,ls).append(e),s.hasEOL){const b=document.createElement("br");b.setAttribute("role","presentation"),n(this,ls).append(b)}},jg=function(t){var a;const{div:e,properties:s,ctx:i}=t,{style:r}=e;if(s.canvasWidth!==0&&s.hasText){const{fontFamily:o}=r,{canvasWidth:l,fontSize:c}=s;v(a=Be,ai,Wg).call(a,i,c*n(this,ea),o);const{width:h}=i.measureText(e.textContent);h>0&&r.setProperty("--scale-x",l*n(this,ea)/h)}s.angle!==0&&r.setProperty("--rotate",`${s.angle}deg`)},ai=new WeakSet,wf=function(t=null){let e=n(this,Bo).get(t||(t=""));if(!e){const s=document.createElement("canvas");s.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none;letter-spacing:normal;word-spacing:normal",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),n(this,Bo).set(t,e),n(this,Zd).set(e,{size:0,family:""})}return e},Wg=function(t,e,s){const i=n(this,Zd).get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)},wy=function(){if(n(this,Mc)!==null)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),p(this,Mc,t.getBoundingClientRect().height),t.remove()},Ay=function(t,e,s){const i=n(this,Pc).get(t);if(i)return i;const r=v(this,ai,wf).call(this,s);r.canvas.width=r.canvas.height=Ov,v(this,ai,Wg).call(this,r,Ov,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):(Ut.platform.isFirefox&&dt("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?c=e.ascent:e.descent&&(c=1+e.descent)),n(this,Pc).set(t,c),c},m(Be,ai),m(Be,Pc,new Map),m(Be,Bo,new Map),m(Be,Zd,new WeakMap),m(Be,Mc,null),m(Be,Ic,new Set);let gh=Be;const J1=100;function Sy(u={}){const t=new Xg,{docId:e}=t,s=u.url?n1(u.url):null,i=u.data?r1(u.data):null,r=u.httpHeaders||null,a=u.withCredentials===!0,o=u.password??null,l=u.range instanceof xy?u.range:null,c=Number.isInteger(u.rangeChunkSize)&&u.rangeChunkSize>0?u.rangeChunkSize:2**16;let h=u.worker instanceof Zh?u.worker:null;const d=u.verbosity,f=typeof u.docBaseUrl=="string"&&!Op(u.docBaseUrl)?u.docBaseUrl:null,g=Yu(u.cMapUrl),y=u.cMapPacked!==!1,b=Yu(u.iccUrl),S=Yu(u.standardFontDataUrl),w=Yu(u.wasmUrl),E=u.stopAtErrors!==!0,A=Number.isInteger(u.maxImageSize)&&u.maxImageSize>-1?u.maxImageSize:-1,_=typeof u.isOffscreenCanvasSupported=="boolean"?u.isOffscreenCanvasSupported:!si,x=typeof u.isImageDecoderSupported=="boolean"?u.isImageDecoderSupported:!si,k=Number.isInteger(u.canvasMaxAreaInBytes)?u.canvasMaxAreaInBytes:-1,M=typeof u.disableFontFace=="boolean"?u.disableFontFace:si,D=u.fontExtraProperties===!0,I=u.enableXfa===!0,L=u.ownerDocument||globalThis.document,O=u.disableRange===!0,Y=u.disableStream===!0,W=u.disableAutoFetch===!0,Q=u.pdfBug===!0,ft=u.CanvasFactory||(si?f1:c1),T=u.FilterFactory||(si?u1:h1),q=u.BinaryDataFactory||(si?p1:Ev),Lt=u.enableHWA===!0,_e=u.enableWebGPU===!0?b1():Promise.resolve(!1),ae=u.useWasm!==!1,Gt=u.pagesMapper||new K1,H=typeof u.useSystemFonts=="boolean"?u.useSystemFonts:!si&&!M,$=typeof u.useWorkerFetch=="boolean"?u.useWorkerFetch:!!(q===Ev&&g&&y&&S&&w&&jh(g,document.baseURI)&&jh(S,document.baseURI)&&jh(w,document.baseURI)),ht=null;kS(d);const ot={canvasFactory:new ft({ownerDocument:L,enableHWA:Lt}),filterFactory:new T({docId:e,ownerDocument:L}),binaryDataFactory:$?null:new q({cMapUrl:g,standardFontDataUrl:S,wasmUrl:w})};h||(h=Zh.create({verbosity:d,port:Sn.workerPort}),t._worker=h);const Z={docId:e,apiVersion:"6.1.200",data:i,password:o,disableAutoFetch:W,rangeChunkSize:c,docBaseUrl:f,enableXfa:I,evaluatorOptions:{maxImageSize:A,disableFontFace:M,ignoreErrors:E,isOffscreenCanvasSupported:_,isImageDecoderSupported:x,canvasMaxAreaInBytes:k,fontExtraProperties:D,useSystemFonts:H,useWasm:ae,useWorkerFetch:$,cMapUrl:g,cMapPacked:y,iccUrl:b,standardFontDataUrl:S,wasmUrl:w,hasGPU:!1}},jt={ownerDocument:L,pdfBug:Q,styleElement:ht,enableHWA:Lt,loadingParams:{disableAutoFetch:W,enableXfa:I}};return Promise.all([h.promise,_e]).then(function([,ms]){if(h.destroyed)throw new Error("Worker was destroyed");Z.evaluatorOptions.hasGPU=ms;const Ts=h.messageHandler.sendWithPromise("GetDocRequest",Z,i?[i.buffer]:null);let Ps;if(!i)if(l)Ps=new N1({pdfDataRangeTransport:l,disableRange:O,disableStream:Y});else if(s){const Se=X1(s);Ps=new Se({url:s,httpHeaders:r,withCredentials:a,rangeChunkSize:c,disableRange:O,disableStream:Y})}else throw new Error("getDocument - expected either `data`, `range`, or `url` parameter.");return Ts.then(Se=>{if(h.destroyed)throw new Error("Worker was destroyed");const Sr=new Mh(e,Se,h.port),Pa=new tx(Sr,t,Ps,jt,ot,Gt);if(t._transport=Pa,t.destroyed)throw new Error("Loading aborted");Sr.send("Ready",null)})}).catch(t._capability.reject).finally(t._setupCapability.resolve),t}var bp;const yp=class yp{constructor(){P(this,"_capability",Promise.withResolvers());P(this,"_setupCapability",Promise.withResolvers());P(this,"_transport",null);P(this,"_worker",null);P(this,"docId",`d${Yt(yp,bp)._++}`);P(this,"destroyed",!1);P(this,"onPassword",null);P(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){var t,e,s,i;this.destroyed=!0,this._capability.promise.catch(()=>{});try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),await this._setupCapability.promise,await((e=this._transport)==null?void 0:e.destroy())}catch(r){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,r}this._transport=null,(i=this._worker)==null||i.destroy(),this._worker=null}async getData(){return this._transport.getData()}};bp=new WeakMap,m(yp,bp,0);let Xg=yp;var Dc,$o;class xy{constructor(t,e,s=!1,i=null){m(this,Dc,Promise.withResolvers());m(this,$o,null);this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i}onDataRange(t,e){n(this,$o).call(this,{type:"range",begin:t,chunk:e})}onDataProgressiveRead(t){n(this,Dc).promise.then(()=>{n(this,$o).call(this,{type:"progressiveRead",chunk:t})})}onDataProgressiveDone(){n(this,Dc).promise.then(()=>{n(this,$o).call(this,{type:"progressiveDone"})})}transportReady(t){p(this,$o,t),n(this,Dc).resolve()}requestDataRange(t,e){Ct("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}Dc=new WeakMap,$o=new WeakMap;class Z1{constructor(t,e){this._pdfInfo=t,this._transport=e}get pagesMapper(){return this._transport.pagesMapper}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return at(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getAttachmentContent(t){return this._transport.getAttachmentContent(t)}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}extractPages(t){return this._transport.extractPages(t)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}getRawData(t){return this._transport.getRawData(t)}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var Yn,Uo,Ho,Nh;const sv=class sv{constructor(t,e,s,i,r=!1){m(this,Ho);m(this,Yn,!1);m(this,Uo,null);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=r?new fv:null,this._pdfBug=r,this.commonObjs=s.commonObjs,this.objs=new vy,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,p(this,Uo,i),this.imageCoordinates=null}clone(t){const e=new sv(t,this._pageInfo,this._transport,n(this,Uo),this._pdfBug);return e.clonedFromIndex=this.clonedFromIndex??this._pageIndex,this._transport.updatePage(e),e}get pageNumber(){return this._pageIndex+1}set pageNumber(t){this._pageIndex=t-1,this._transport.updatePage(this)}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:r=!1}={}){return new Gu({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:r})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return at(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,canvas:e=t.canvas,viewport:s,intent:i="display",annotationMode:r=Cr.ENABLE,transform:a=null,background:o=null,optionalContentConfigPromise:l=null,annotationCanvasMap:c=null,pageColors:h=null,printAnnotationStorage:d=null,isEditing:f=!1,recordImages:g=!1,recordOperations:y=!1,operationsFilter:b=null}){var W,Q,ft;(W=this._stats)==null||W.time("Overall");const S=this._transport.getRenderingIntent(i,r,d,f),{renderingIntent:w,cacheKey:E}=S;p(this,Yn,!1),l||(l=this._transport.getOptionalContentConfig(w));const A=this._intentStates.getOrInsertComputed(E,cg);A.streamReaderCancelTimeout&&(clearTimeout(A.streamReaderCancelTimeout),A.streamReaderCancelTimeout=null);const _=!!(w&ei.PRINT);A.displayReadyCapability||(A.displayReadyCapability=Promise.withResolvers(),A.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(Q=this._stats)==null||Q.time("Page Request"),this._pumpOperatorList(S));const x=!!(this._pdfBug&&((ft=globalThis.StepperManager)!=null&&ft.enabled)),k=!!e&&!this.recordedBBoxes&&(y||x),M=!!e&&!this.imageCoordinates&&g,D=T=>{var q,Lt,bt,_e;if(A.renderTasks.delete(O),k){const ae=(q=O.gfx)==null?void 0:q.dependencyTracker.take();ae&&((Lt=O.stepper)==null||Lt.setOperatorBBoxes(ae,O.gfx.dependencyTracker.takeDebugMetadata()),y&&(this.recordedBBoxes=ae))}M&&!T&&(this.imageCoordinates=(bt=O.gfx)==null?void 0:bt.imagesTracker.take()),_&&p(this,Yn,!0),v(this,Ho,Nh).call(this),T?(O.capability.reject(T),this._abortOperatorList({intentState:A,reason:T instanceof Error?T:new Error(T)})):O.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(_e=globalThis.Stats)!=null&&_e.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))};let I=null,L=null;(k||M)&&(L=new YS(e,A.operatorList.length)),k&&(I=new KS(L,x));const O=new Yg({callback:D,params:{canvas:e,canvasContext:t,dependencyTracker:I??L,imagesTracker:M?new Ig(e):null,viewport:s,transform:a,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:c,operatorList:A.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!_,pdfBug:this._pdfBug,pageColors:h,enableHWA:this._transport.enableHWA,operationsFilter:b});(A.renderTasks||(A.renderTasks=new Set)).add(O);const Y=O.task;return Promise.all([A.displayReadyCapability.promise,l]).then(([T,q])=>{var Lt;if(this.destroyed){D();return}if((Lt=this._stats)==null||Lt.time("Rendering"),!(q.renderingIntent&w))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");O.initializeGraphics({transparency:T,optionalContentConfig:q}),O.operatorListChanged()}).catch(D),Y}getOperatorList({intent:t="display",annotationMode:e=Cr.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){var c;function r(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(l))}const a=this._transport.getRenderingIntent(t,e,s,i,!0),o=this._intentStates.getOrInsertComputed(a.cacheKey,cg);let l;return o.opListReadCapability||(l=Object.create(null),l.operatorListChanged=r,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(l),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(c=this._stats)==null||c.time("Page Request"),this._pumpOperatorList(a)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:n(this,Uo).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(i){return i.items.length}})}async getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(i=>Kh.textContent(i));const e=this.streamTextContent(t),s={items:[],styles:Object.create(null),lang:null};for await(const i of e)s.lang??(s.lang=i.lang),Object.assign(s.styles,i.styles),s.items.push(...i.items);return s}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),p(this,Yn,!1),Promise.all(t)}cleanup(t=!1){p(this,Yn,!0);const e=v(this,Ho,Nh).call(this);return t&&e&&this._stats&&(this._stats=new fv),e}_startRenderPage(t,e){var i,r;const s=this._intentStates.get(e);s&&((i=this._stats)==null||i.timeEnd("Page Request"),(r=s.displayReadyCapability)==null||r.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s{l.read().then(({value:d,done:f})=>{if(f){c.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(d,c),h())},d=>{if(c.streamReader=null,!this._transport.destroyed){if(c.operatorList){c.operatorList.lastChunk=!0;for(const f of c.renderTasks)f.operatorListChanged();v(this,Ho,Nh).call(this)}if(c.displayReadyCapability)c.displayReadyCapability.reject(d);else if(c.opListReadCapability)c.opListReadCapability.reject(d);else throw d}})};h()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof Vm){let i=J1;e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new _a(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,r]of this._intentStates)if(r===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}};Yn=new WeakMap,Uo=new WeakMap,Ho=new WeakSet,Nh=function(){if(!n(this,Yn)||this.destroyed)return!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),p(this,Yn,!1),!0};let qg=sv;var sa,Bi,Kn,zo,wp,Vo,Go,ps,Af,Ey,Cy,Bh,Lc,Sf;const le=class le{constructor({name:t=null,port:e=null,verbosity:s=TS()}={}){m(this,ps);m(this,sa,Promise.withResolvers());m(this,Bi,null);m(this,Kn,null);m(this,zo,null);if(this.name=t,this.destroyed=!1,this.verbosity=s,e){if(n(le,Go).has(e))throw new Error("Cannot use more than one PDFWorker per port.");n(le,Go).set(e,this),v(this,ps,Ey).call(this,e)}else v(this,ps,Cy).call(this)}get promise(){return n(this,sa).promise}get port(){return n(this,Kn)}get messageHandler(){return n(this,Bi)}destroy(){var t,e;this.destroyed=!0,(t=n(this,zo))==null||t.terminate(),p(this,zo,null),n(le,Go).delete(n(this,Kn)),p(this,Kn,null),(e=n(this,Bi))==null||e.destroy(),p(this,Bi,null)}static create(t){const e=n(this,Go).get(t==null?void 0:t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new le(t)}static get workerSrc(){if(Sn.workerSrc)return Sn.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return at(this,"_setupFakeWorkerGlobal",(async()=>n(this,Lc,Sf)?n(this,Lc,Sf):(await import(this.workerSrc)).WorkerMessageHandler)())}};sa=new WeakMap,Bi=new WeakMap,Kn=new WeakMap,zo=new WeakMap,wp=new WeakMap,Vo=new WeakMap,Go=new WeakMap,ps=new WeakSet,Af=function(){n(this,sa).resolve(),n(this,Bi).send("configure",{verbosity:this.verbosity})},Ey=function(t){p(this,Kn,t),p(this,Bi,new Mh("main","worker",t)),n(this,Bi).on("ready",()=>{}),v(this,ps,Af).call(this)},Cy=function(){if(n(le,Vo)||n(le,Lc,Sf)){v(this,ps,Bh).call(this);return}let{workerSrc:t}=le;try{le._isSameOrigin(window.location,t)||(t=le._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new Mh("main","worker",e),i=()=>{r.abort(),s.destroy(),e.terminate(),this.destroyed?n(this,sa).reject(new Error("Worker was destroyed")):v(this,ps,Bh).call(this)},r=new AbortController;e.addEventListener("error",()=>{n(this,zo)||i()},{signal:r.signal}),s.on("test",o=>{if(r.abort(),this.destroyed||!o){i();return}p(this,Bi,s),p(this,Kn,e),p(this,zo,e),v(this,ps,Af).call(this)}),s.on("ready",o=>{if(r.abort(),this.destroyed){i();return}try{a()}catch{v(this,ps,Bh).call(this)}});const a=()=>{const o=new Uint8Array;s.send("test",o,[o.buffer])};a();return}catch{Fp("The worker has been disabled.")}v(this,ps,Bh).call(this)},Bh=function(){n(le,Vo)||(dt("Setting up fake worker."),p(le,Vo,!0)),le._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){n(this,sa).reject(new Error("Worker was destroyed"));return}const e=new l1;p(this,Kn,e);const s=`fake${Yt(le,wp)._++}`,i=new Mh(s+"_worker",s,e);t.setup(i,e),p(this,Bi,new Mh(s,s+"_worker",e)),v(this,ps,Af).call(this)}).catch(t=>{n(this,sa).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},Lc=new WeakSet,Sf=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},m(le,Lc),m(le,wp,0),m(le,Vo,!1),m(le,Go,new WeakMap),si&&(p(le,Vo,!0),Sn.workerSrc||(Sn.workerSrc="./pdf.worker.mjs")),le._isSameOrigin=(t,e)=>{const s=URL.parse(t);if(!(s!=null&&s.origin)||s.origin==="null")return!1;const i=new URL(e,s);return s.origin===i.origin},le._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};let Zh=le;var zs,jo,Qn,$i,Wo,Fc,Jn,Wi,$h,xf;class tx{constructor(t,e,s,i,r,a){m(this,Wi);P(this,"downloadInfoCapability",Promise.withResolvers());m(this,zs,null);m(this,jo,new Map);m(this,Qn,null);m(this,$i,new Map);m(this,Wo,new Map);m(this,Fc,new Map);m(this,Jn,null);this.messageHandler=t,this.loadingTask=e,p(this,Qn,s),this.commonObjs=new vy,this.fontLoader=new QS({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.enableHWA=i.enableHWA,this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.binaryDataFactory=r.binaryDataFactory,this.pagesMapper=a,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler()}updatePage(t){const{_pageIndex:e}=t;n(this,$i).set(e,t),n(this,Wo).set(e,Promise.resolve(t))}get annotationStorage(){return at(this,"annotationStorage",new jm)}getRenderingIntent(t,e=Cr.ENABLE,s=null,i=!1,r=!1){let a=ei.DISPLAY,o=Qh;switch(t){case"any":a=ei.ANY;break;case"display":break;case"print":a=ei.PRINT;break;default:dt(`getRenderingIntent - invalid intent: ${t}`)}const l=a&ei.PRINT&&s instanceof $b?s:this.annotationStorage;switch(e){case Cr.DISABLE:a+=ei.ANNOTATIONS_DISABLE;break;case Cr.ENABLE:break;case Cr.ENABLE_FORMS:a+=ei.ANNOTATIONS_FORMS;break;case Cr.ENABLE_STORAGE:a+=ei.ANNOTATIONS_STORAGE,o=l.serializable;break;default:dt(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(a+=ei.IS_EDITING),r&&(a+=ei.OPLIST);const{ids:c,hash:h}=l.modifiedIds,d=[a,o.hash,h];return{renderingIntent:a,cacheKey:d.join("_"),annotationStorageSerializable:o,modifiedIds:c}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=n(this,Jn))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of n(this,$i).values())t.push(i._destroy());n(this,$i).clear(),n(this,Wo).clear(),n(this,Fc).clear(),Object.hasOwn(this,"annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{var i,r;this.commonObjs.clear(),this.fontLoader.clear(),n(this,jo).clear(),this.filterFactory.destroy(),gh.cleanup(),(i=n(this,Qn))==null||i.cancelAllRequests(new _a("Worker was terminated.")),(r=this.messageHandler)==null||r.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,i)=>{re(n(this,Qn),"GetReader - no `BasePDFStream` instance available."),p(this,zs,n(this,Qn).getFullReader()),n(this,zs).onProgress=r=>v(this,Wi,xf).call(this,r),i.onPull=()=>{n(this,zs).read().then(function({value:r,done:a}){if(a){i.close();return}re(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{i.error(r)})},i.onCancel=r=>{n(this,zs).cancel(r),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("ReaderHeadersReady",async s=>{await n(this,zs).headersReady;const{isStreamingSupported:i,isRangeSupported:r,contentLength:a}=n(this,zs);return i&&r&&(n(this,zs).onProgress=null),{isStreamingSupported:i,isRangeSupported:r,contentLength:a}}),t.on("GetRangeReader",(s,i)=>{re(n(this,Qn),"GetRangeReader - no `BasePDFStream` instance available.");const r=n(this,Qn).getRangeReader(s.begin,s.end);if(!r){i.close();return}i.onPull=()=>{r.read().then(function({value:a,done:o}){if(o){i.close();return}re(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 Z1(s,this))}),t.on("DocException",s=>{e._capability.reject(bs(s))}),t.on("PasswordRequest",s=>{p(this,Jn,Promise.withResolvers());try{if(!e.onPassword)throw bs(s);const i=r=>{r instanceof Error?n(this,Jn).reject(r):n(this,Jn).resolve({password:r})};e.onPassword(i,s.code)}catch(i){n(this,Jn).reject(i)}return n(this,Jn).promise}),t.on("DataLoaded",s=>{v(this,Wi,xf).call(this,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;n(this,$i).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,r])=>{var a;if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":if("error"in r){const f=r.error;dt(`Error during font loading: ${f}`),this.commonObjs.resolve(s,f);break}const o=new e1(r),l=this._params.pdfBug&&((a=globalThis.FontInspector)!=null&&a.enabled)?(f,g)=>globalThis.FontInspector.fontAdded(f,g):null,c=new JS(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;re(h,"The imageRef must be defined.");for(const f of n(this,$i).values())for(const[,g]of f.objs){if((g==null?void 0:g.ref)!==h)continue;if(!g.dataLen)return null;const y=structuredClone(g);return this.commonObjs.resolve(s,y),g.dataLen}break;case"FontPath":this.commonObjs.resolve(s,new i1(r));break;case"Image":this.commonObjs.resolve(s,r);break;case"Pattern":const d=new s1(r);this.commonObjs.resolve(s,d.getIR());break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,r,a])=>{var l;if(this.destroyed)return;const o=n(this,$i).get(i);if(!o.objs.has(s)){if(o._intentStates.size===0){(l=a==null?void 0:a.bitmap)==null||l.close();return}switch(r){case"Image":case"Pattern":o.objs.resolve(s,a);break;default:throw new Error(`Got unknown object type ${r}`)}}}),t.on("DocProgress",s=>{this.destroyed||v(this,Wi,xf).call(this,s)}),t.on("FetchBinaryData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.binaryDataFactory)throw new Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var s;this.annotationStorage.size<=0&&dt("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,zs))==null?void 0:s.filename)??null},e).finally(()=>{this.annotationStorage.resetModified()})}extractPages(t){var r;const e={pageInfos:t};let s;const i=globalThis.ImageBitmap;if(typeof i=="function"){const a=Array.isArray(t)?t:[t];for(const o of a)(o==null?void 0:o.image)instanceof i&&(s||(s=[])).push(o.image)}if(this.annotationStorage.size>0){const a=this.annotationStorage.serializable;let{map:o}=a;(r=a.transfer)!=null&&r.length&&(s?s.push(...a.transfer):s=a.transfer);const l=this.pagesMapper.getMapping();if(l){const c=new Map;for(const[h,d]of o){if((d==null?void 0:d.pageIndex)!==void 0&&d.pageIndex>=0&&d.pageIndex{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this.pagesMapper.pagesNumber)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=this.pagesMapper.getPageId(t)-1,i=n(this,Wo).get(e);if(i)return i;const r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:s}).then(a=>{if(this.destroyed)throw new Error("Transport destroyed");a.refStr&&n(this,Fc).set(a.refStr,s);const o=new qg(e,a,this,this.pagesMapper,this._params.pdfBug);return n(this,$i).set(e,o),o});return n(this,Wo).set(e,r),r}async getPageIndex(t){if(!Lg(t))throw new Error("Invalid pageIndex request.");const e=await this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}),s=this.pagesMapper.getPageNumber(e+1);if(s===0)throw new Error("GetPageIndex: page has been removed.");return s-1}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(t+1)-1,intent:e})}getFieldObjects(){return v(this,Wi,$h).call(this,"GetFieldObjects")}hasJSActions(){return v(this,Wi,$h).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAttachmentContent(t){return this.messageHandler.sendWithPromise("GetAttachmentContent",t)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return v(this,Wi,$h).call(this,"GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return v(this,Wi,$h).call(this,"GetOptionalContentConfig").then(e=>new Vg(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata";return n(this,jo).getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,null).then(e=>{var s,i;return{info:e[0],metadata:e[1]?new q1(e[1]):null,contentDispositionFilename:((s=n(this,zs))==null?void 0:s.filename)??null,contentLength:((i=n(this,zs))==null?void 0:i.contentLength)??null,hasStructTree:e[2]}}))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}getRawData(t){return this.messageHandler.sendWithPromise("GetRawData",t)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of n(this,$i).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),n(this,jo).clear(),this.filterFactory.destroy(!0),gh.cleanup()}}cachedPageNumber(t){if(!Lg(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`,s=n(this,Fc).get(e);if(s>=0){const i=this.pagesMapper.getPageNumber(s+1);if(i!==0)return i}return null}}zs=new WeakMap,jo=new WeakMap,Qn=new WeakMap,$i=new WeakMap,Wo=new WeakMap,Fc=new WeakMap,Jn=new WeakMap,Wi=new WeakSet,$h=function(t,e=null){return n(this,jo).getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,e))},xf=function({loaded:t,total:e}){var s,i;(i=(s=this.loadingTask).onProgress)==null||i.call(s,{loaded:t,total:e,percent:e?Jt(Math.round(t/e*100),0,100):NaN})};class ex{constructor(t){P(this,"_internalRenderTask",null);P(this,"onContinue",null);P(this,"onError",null);this._internalRenderTask=t}get promise(){return this._internalRenderTask.capability.promise}cancel(t=0){this._internalRenderTask.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this._internalRenderTask.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this._internalRenderTask;return t.form||t.canvas&&(e==null?void 0:e.size)>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}}var ia,Xo;const Va=class Va{constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:r,operatorList:a,pageIndex:o,canvasFactory:l,filterFactory:c,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:f=null,enableHWA:g=!1,operationsFilter:y=null}){m(this,ia,null);this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=c,this._pdfBug=d,this.pageColors=f,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=h===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new ex(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=g,this._dependencyTracker=e.dependencyTracker,this._imagesTracker=e.imagesTracker,this._operationsFilter=y}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){var c,h;if(this.cancelled)return;if(this._canvas){if(n(Va,Xo).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");n(Va,Xo).add(this._canvas)}this._pdfBug&&((c=globalThis.StepperManager)!=null&&c.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:s,transform:i,background:r,dependencyTracker:a,imagesTracker:o}=this.params,l=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new Hl(l,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,a,o),this.gfx.beginDrawing({transform:i,viewport:s,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,(h=this.graphicsReadyCallback)==null||h.call(this)}cancel(t=null,e=0){var s,i,r;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),n(this,ia)&&(window.cancelAnimationFrame(n(this,ia)),p(this,ia,null)),n(Va,Xo).delete(this._canvas),t||(t=new Vm(`Rendering cancelled, page ${this._pageIndex+1}`,e)),this.callback(t),(r=(i=this.task).onError)==null||r.call(i,t)}operatorListChanged(){var t,e;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(t=this.gfx.dependencyTracker)==null||t.growOperationsCount(this.operatorList.fnArray.length),(e=this.stepper)==null||e.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?p(this,ia,window.requestAnimationFrame(()=>{p(this,ia,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),n(Va,Xo).delete(this._canvas),this.callback())))}};ia=new WeakMap,Xo=new WeakMap,m(Va,Xo,new WeakSet);let Yg=Va;const sx="6.1.200",ix="6353acefe";var Vs,qo,Rc,Ee,tu,Oc,Zn,eu,na,Ui,su,Ht,Kg,Qg,Jg,$a,_y,Er;const ws=class ws{constructor({editor:t=null,uiManager:e=null}){m(this,Ht);m(this,Vs,null);m(this,qo,null);m(this,Rc);m(this,Ee,null);m(this,tu,!1);m(this,Oc,!1);m(this,Zn,null);m(this,eu);m(this,na,null);m(this,Ui,null);var s,i;t?(p(this,Oc,!1),p(this,Zn,t)):p(this,Oc,!0),p(this,Ui,(t==null?void 0:t._uiManager)||e),p(this,eu,n(this,Ui)._eventBus),p(this,Rc,((s=t==null?void 0:t.color)==null?void 0:s.toUpperCase())||((i=n(this,Ui))==null?void 0:i.highlightColors.values().next().value)||"#FFFF98"),n(ws,su)||p(ws,su,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return at(this,"_keyboardManager",new El([[["Escape"],ws.prototype._hideDropdownFromKeyboard],[["Space"],ws.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight"],ws.prototype._moveToNext],[["ArrowUp","ArrowLeft"],ws.prototype._moveToPrevious],[["Home"],ws.prototype._moveToBeginning],[["End"],ws.prototype._moveToEnd]]))}renderButton(){const t=p(this,Vs,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",n(this,Zn)&&(t.ariaControls=`${n(this,Zn).id}_colorpicker_dropdown`);const e=n(this,Ui)._signal;t.addEventListener("click",v(this,Ht,$a).bind(this),{signal:e}),t.addEventListener("keydown",v(this,Ht,Jg).bind(this),{signal:e});const s=p(this,qo,document.createElement("span"));return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=n(this,Rc),t.append(s),t}renderMainDropdown(){const t=p(this,Ee,v(this,Ht,Kg).call(this));return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}_colorSelectFromKeyboard(t){if(t.target===n(this,Vs)){v(this,Ht,$a).call(this,t);return}const e=t.target.getAttribute("data-color");e&&v(this,Ht,Qg).call(this,e,t)}_moveToNext(t){var e,s;if(!n(this,Ht,Er)){v(this,Ht,$a).call(this,t);return}if(t.target===n(this,Vs)){(e=n(this,Ee).firstElementChild)==null||e.focus();return}(s=t.target.nextSibling)==null||s.focus()}_moveToPrevious(t){var e,s;if(t.target===((e=n(this,Ee))==null?void 0:e.firstElementChild)||t.target===n(this,Vs)){n(this,Ht,Er)&&this._hideDropdownFromKeyboard();return}n(this,Ht,Er)||v(this,Ht,$a).call(this,t),(s=t.target.previousSibling)==null||s.focus()}_moveToBeginning(t){var e;if(!n(this,Ht,Er)){v(this,Ht,$a).call(this,t);return}(e=n(this,Ee).firstElementChild)==null||e.focus()}_moveToEnd(t){var e;if(!n(this,Ht,Er)){v(this,Ht,$a).call(this,t);return}(e=n(this,Ee).lastElementChild)==null||e.focus()}hideDropdown(){var t,e;(t=n(this,Ee))==null||t.classList.add("hidden"),n(this,Vs).ariaExpanded="false",(e=n(this,na))==null||e.abort(),p(this,na,null)}_hideDropdownFromKeyboard(){var t;if(!n(this,Oc)){if(!n(this,Ht,Er)){(t=n(this,Zn))==null||t.unselect();return}this.hideDropdown(),n(this,Vs).focus({preventScroll:!0,focusVisible:n(this,tu)})}}updateColor(t){if(n(this,qo)&&(n(this,qo).style.backgroundColor=t),!n(this,Ee))return;const e=n(this,Ui).highlightColors.values();for(const s of n(this,Ee).children)s.ariaSelected=e.next().value===t.toUpperCase()}destroy(){var t,e;(t=n(this,Vs))==null||t.remove(),p(this,Vs,null),p(this,qo,null),(e=n(this,Ee))==null||e.remove(),p(this,Ee,null)}};Vs=new WeakMap,qo=new WeakMap,Rc=new WeakMap,Ee=new WeakMap,tu=new WeakMap,Oc=new WeakMap,Zn=new WeakMap,eu=new WeakMap,na=new WeakMap,Ui=new WeakMap,su=new WeakMap,Ht=new WeakSet,Kg=function(){const t=document.createElement("div"),e=n(this,Ui)._signal;t.addEventListener("contextmenu",_i,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),n(this,Zn)&&(t.id=`${n(this,Zn).id}_colorpicker_dropdown`);for(const[s,i]of n(this,Ui).highlightColors){const r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",i),r.title=s,r.setAttribute("data-l10n-id",n(ws,su)[s]);const a=document.createElement("span");r.append(a),a.className="swatch",a.style.backgroundColor=i,r.ariaSelected=i===n(this,Rc),r.addEventListener("click",v(this,Ht,Qg).bind(this,i),{signal:e}),t.append(r)}return t.addEventListener("keydown",v(this,Ht,Jg).bind(this),{signal:e}),t},Qg=function(t,e){e.stopPropagation(),n(this,eu).dispatch("switchannotationeditorparams",{source:this,type:gt.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)},Jg=function(t){ws._keyboardManager.exec(this,t)},$a=function(t){if(n(this,Ht,Er)){this.hideDropdown();return}if(p(this,tu,t.detail===0),n(this,na)||(p(this,na,new AbortController),window.addEventListener("pointerdown",v(this,Ht,_y).bind(this),{signal:n(this,Ui).combinedSignal(n(this,na))})),n(this,Vs).ariaExpanded="true",n(this,Ee)){n(this,Ee).classList.remove("hidden");return}const e=p(this,Ee,v(this,Ht,Kg).call(this));n(this,Vs).append(e)},_y=function(t){var e;(e=n(this,Ee))!=null&&e.contains(t.target)||this.hideDropdown()},Er=function(){return n(this,Ee)&&!n(this,Ee).classList.contains("hidden")},m(ws,su,null);let Qf=ws;var Gs,Nc,Yo,tr,iu;const Ga=class Ga{constructor(t){m(this,Gs,null);m(this,Nc,!1);m(this,Yo,null);m(this,tr,null);p(this,Yo,t),p(this,tr,t._uiManager),n(Ga,iu)||p(Ga,iu,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(n(this,Gs))return n(this,Gs);const{editorType:t,colorType:e,colorAndOpacityType:s,opacityType:i,color:r,opacity:a}=n(this,Yo),o=p(this,Nc,Ut.isAlphaColorInputSupported&&i!==void 0),l=p(this,Gs,document.createElement("input"));if(l.type="color",o){l.setAttribute("alpha","");const c=B.hexNums[Math.round((a??1)*255)];l.value=(r||"#000000")+c}else l.value=r||"#000000";return l.className="basicColorPicker",l.tabIndex=0,l.setAttribute("data-l10n-id",n(Ga,iu)[t]),l.addEventListener("input",()=>{if(o){const c=ju(l.value);if(!c)return;const[h,d,f,g]=c,y=B.makeHexColor(h,d,f);s!==void 0?n(this,tr).updateParams(s,{color:y,opacity:g}):(n(this,tr).updateParams(e,y),n(this,tr).updateParams(i,g))}else n(this,tr).updateParams(e,l.value)},{signal:n(this,tr)._signal}),l}update(t){if(n(this,Gs))if(n(this,Nc)){const e=B.hexNums[Math.round(n(this,Yo).opacity*255)];n(this,Gs).value=t+e}else n(this,Gs).value=t}updateOpacity(t){if(!n(this,Gs)||!n(this,Nc))return;const e=B.hexNums[Math.round(t*255)];n(this,Gs).value=n(this,Yo).color+e}destroy(){var t;(t=n(this,Gs))==null||t.remove(),p(this,Gs,null)}hideDropdown(){}};Gs=new WeakMap,Nc=new WeakMap,Yo=new WeakMap,tr=new WeakMap,iu=new WeakMap,m(Ga,iu,null);let Jf=Ga;function Nv(u){return Math.floor(Jt(u,0,1)*255).toString(16).padStart(2,"0")}function wh(u){return Jt(u,0,1)*255}class Bv{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=wh(t),[t,t,t]}static G_HTML([t]){const e=Nv(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map(wh)}static RGB_HTML(t){return`#${t.map(Nv).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[wh(1-Math.min(1,t+i)),wh(1-Math.min(1,s+i)),wh(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 nx{create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){Ct("Abstract method `_createSVG` called.")}}class Zf extends nx{_createSVG(t){return document.createElementNS(Ns,t)}}const rx=9,_l=new WeakSet,ax=new Date().getTimezoneOffset()*60*1e3;class eg{static create(t){switch(t.data.annotationType){case oe.LINK:return new Xm(t);case oe.TEXT:return new lx(t);case oe.WIDGET:switch(t.data.fieldType){case"Tx":return new cx(t);case"Btn":return t.data.radioButton?new ux(t):t.data.checkBox?new dx(t):new fx(t);case"Ch":return new px(t);case"Sig":return new hx(t)}return new Pl(t);case oe.POPUP:return new tm(t);case oe.FREETEXT:return new Ly(t);case oe.LINE:return new mx(t);case oe.SQUARE:return new vx(t);case oe.CIRCLE:return new bx(t);case oe.POLYLINE:return new Fy(t);case oe.CARET:return new wx(t);case oe.INK:return new qm(t);case oe.POLYGON:return new yx(t);case oe.HIGHLIGHT:return new Ry(t);case oe.UNDERLINE:return new Ax(t);case oe.SQUIGGLY:return new Sx(t);case oe.STRIKEOUT:return new xx(t);case oe.STAMP:return new Oy(t);case oe.FILEATTACHMENT:return new Ex(t);case oe.RICHMEDIA:case oe.SCREEN:return new Ny(t);default:return new ee(t)}}}var Ko,Bc,yi,nu,Zg;const iv=class iv{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){m(this,nu);m(this,Ko,null);m(this,Bc,!1);m(this,yi,null);this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,this.hasOwnCommentButton=!1,e&&(this.contentElement=this.container=this._createContainer(s)),i&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t!=null&&t.str||e!=null&&e.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return iv._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){var s;const{data:t}=this,e=(s=this.annotationStorage)==null?void 0:s.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){var o;const t=(o=this.annotationStorage)==null?void 0:o.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;const{quadPoints:e,inkLists:s,rect:i}=this.data;let r=-1/0,a=-1/0;if((e==null?void 0:e.length)>=8){for(let l=0;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(`${Yh}${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(`${Yh}${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,yi))==null?void 0:t.popup)||this.popup)==null||e.remove(),p(this,yi,this.popup=null)}updateEdited(t){var r;if(!this.container)return;t.rect&&(n(this,Ko)||p(this,Ko,{rect:this.data.rect.slice(0)}));const{rect:e,popup:s}=t;e&&v(this,nu,Zg).call(this,e);let i=((r=n(this,yi))==null?void 0:r.popup)||this.popup;!i&&(s!=null&&s.text)&&(this._createPopup(s),i=n(this,yi).popup),i&&(i.updateEdited(t),s!=null&&s.deleted&&(i.remove(),p(this,yi,null),this.popup=null))}resetEdited(){var t;n(this,Ko)&&(v(this,nu,Zg).call(this,n(this,Ko).rect),(t=n(this,yi))==null||t.popup.resetEdited(),p(this,Ko,null))}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",e.id),!(this instanceof Pl)&&!(this instanceof Xm)&&!(this instanceof Ny)&&(r.tabIndex=0);const{style:a}=r;if(a.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(r.title=e.alternativeText),e.noRotate&&r.classList.add("norotate"),!e.rect||this instanceof tm){const{rotation:b}=e;return!e.hasOwnCanvas&&b!==0&&this.setRotation(b,r),r}const{width:o,height:l}=this;if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const b=e.borderStyle.horizontalCornerRadius,S=e.borderStyle.verticalCornerRadius;if(b>0||S>0){const E=`calc(${b}px * var(--total-scale-factor)) / calc(${S}px * var(--total-scale-factor))`;a.borderRadius=E}switch(e.borderStyle.style){case Ll.SOLID:a.borderStyle="solid";break;case Ll.DASHED:a.borderStyle="dashed";break;case Ll.BEVELED:dt("Unimplemented border style: beveled");break;case Ll.INSET:dt("Unimplemented border style: inset");break;case Ll.UNDERLINE:a.borderBottomStyle="solid";break}const w=e.borderColor||null;w?(p(this,Bc,!0),a.borderColor=B.makeHexColor(...w)):a.borderWidth=0}const c=B.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:h,pageHeight:d,pageX:f,pageY:g}=i.rawDims;a.left=`${100*(c[0]-f)/h}%`,a.top=`${100*(c[1]-g)/d}%`;const{rotation:y}=e;return e.hasOwnCanvas||y===0?(a.width=`${100*o/h}%`,a.height=`${100*l/d}%`):this.setRotation(y,r),r}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims;let{width:r,height:a}=this;t%180!==0&&([r,a]=[a,r]),e.style.width=`${100*r/s}%`,e.style.height=`${100*a/i}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const r=i.detail[e],a=r[0],o=r.slice(1);i.target.style[s]=Bv[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:Bv[`${a}_rgb`](o)})};return at(this,"_commonActions",{display:e=>{const{display:s}=e.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:e=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail)){const r=t[i]||s[i];r==null||r(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[i,r]of Object.entries(e)){const a=s[i];if(a){const o={detail:{[i]:r},target:t};a(o),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,r]=this.data.rect.map(b=>Math.fround(b));if(t.length===8){const[b,S,w,E]=t.subarray(2,6);if(i===b&&r===S&&e===w&&s===E)return}const{style:a}=this.container;let o;if(n(this,Bc)){const{borderColor:b,borderWidth:S}=a;a.borderWidth=0,o=["url('data:image/svg+xml;utf8,",``,``],this.container.classList.add("hasBorder")}const l=i-e,c=r-s,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0),d.role="none";const f=h.createElement("defs");d.append(f);const g=h.createElement("clipPath"),y=`clippath_${this.data.id}`;g.setAttribute("id",y),g.setAttribute("clipPathUnits","objectBoundingBox"),f.append(g);for(let b=2,S=t.length;b`)}n(this,Bc)&&(o.push("')"),a.backgroundImage=o.join("")),this.container.append(d),this.container.style.clipPath=`url(#${y})`}_createPopup(t=null){const{data:e}=this;let s,i;t?(s={str:t.text},i=t.date):(s=e.contentsObj,i=e.modificationDate),p(this,yi,new tm({data:{color:e.color,titleObj:e.titleObj,modificationDate:i,contentsObj:s,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}))}get hasPopupElement(){return!!(n(this,yi)||this.popup||this.data.popupRef)}get extraPopupElement(){return n(this,yi)}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)){dt(`_getElementsByName - element not allowed: ${a}`);continue}s.push({id:a,exportValue:l,domElement:c})}return s}for(const i of document.getElementsByName(t)){const{exportValue:r}=i,a=i.getAttribute("data-element-id");a!==e&&_l.has(i)&&s.push({id:a,exportValue:r,domElement:i})}return s}show(){var t;this.container&&(this.container.hidden=!1),(t=this.popup)==null||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),(t=this.popup)==null||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{var s;(s=this.linkService.eventBus)==null||s.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}updateOC(t){if(!this.data.oc||!t)return;t.isVisible(this.data.oc)?this.show():this.hide()}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":B.makeHexColor(...e)}};Ko=new WeakMap,Bc=new WeakMap,yi=new WeakMap,nu=new WeakSet,Zg=function(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}}}=this;s==null||s.splice(0,4,...t),e.left=`${100*(t[0]-o)/r}%`,e.top=`${100*(a-t[3]+l)/a}%`,i===0?(e.width=`${100*(t[2]-t[0])/r}%`,e.height=`${100*(t[3]-t[1])/a}%`):this.setRotation(i)};let ee=iv;class ox extends ee{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 ni,Ua,ky,Ty;class Xm extends ee{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});m(this,ni);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:s}=this,i=document.createElement("a");i.setAttribute("data-element-id",e.id);let r=!1;return e.url?(s.addLinkAttributes(i,e.url,e.newWindow),r=!0):e.action?(this._bindNamedAction(i,e.action,e.overlaidText),r=!0):e.attachment?(v(this,ni,ky).call(this,i,e.attachmentId,e.attachment,e.overlaidText,e.attachmentDest),r=!0):e.setOCGState?(v(this,ni,Ty).call(this,i,e.setOCGState,e.overlaidText),r=!0):e.dest?(this._bindLink(i,e.dest,e.overlaidText),r=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,e),r=!0),e.resetForm?(this._bindResetFormAction(i,e.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(i,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&(this.contentElement=i,this.container.append(i)),this.container}_bindLink(e,s,i=""){e.href=this.linkService.getDestinationHash(s),e.onclick=()=>(s&&this.linkService.goToDestination(s),!1),(s||s==="")&&v(this,ni,Ua).call(this),i&&(e.title=i)}_bindNamedAction(e,s,i=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(s),!1),i&&(e.title=i),v(this,ni,Ua).call(this)}_bindJSAction(e,s){e.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of Object.keys(s.actions)){const a=i.get(r);a&&(e[a]=()=>{var o;return(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:r}}),!1})}s.overlaidText&&(e.title=s.overlaidText),e.onclick||(e.onclick=()=>!1),v(this,ni,Ua).call(this)}_bindResetFormAction(e,s){const i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),v(this,ni,Ua).call(this),!this._fieldObjects){dt('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(e.onclick=()=>!1);return}e.onclick=()=>{var d;i==null||i();const{fields:r,refs:a,include:o}=s,l=[];if(r.length!==0||a.length!==0){const f=new Set(a);for(const g of r){const y=this._fieldObjects[g]||[];for(const{id:b}of y)f.add(b)}for(const g of Object.values(this._fieldObjects))for(const y of g)f.has(y.id)===o&&l.push(y)}else for(const f of Object.values(this._fieldObjects))l.push(...f);const c=this.annotationStorage,h=[];for(const f of l){const{id:g}=f;switch(h.push(g),f.type){case"text":{const b=f.defaultValue||"";c.setValue(g,{value:b});break}case"checkbox":case"radiobutton":{const b=f.defaultValue===f.exportValues;c.setValue(g,{value:b});break}case"combobox":case"listbox":{const b=f.defaultValue||"";c.setValue(g,{value:b});break}default:continue}const y=document.querySelector(`[data-element-id="${g}"]`);if(y){if(!_l.has(y)){dt(`_bindResetFormAction - element not allowed: ${g}`);continue}}else continue;y.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((d=this.linkService.eventBus)==null||d.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:h,name:"ResetForm"}})),!1}}}ni=new WeakSet,Ua=function(){this.container.setAttribute("data-internal-link","")},ky=function(e,s,i,r="",a=null){e.href=this.linkService.getAnchorUrl(""),i.description?e.title=i.description:r&&(e.title=r);const o=async()=>{var c;const l=await this.linkService.getAttachmentContent(s);l&&((c=this.downloadManager)==null||c.openOrDownloadData(l,i.filename,a))};e.onclick=()=>(o(),!1),v(this,ni,Ua).call(this)},Ty=function(e,s,i=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),i&&(e.title=i),v(this,ni,Ua).call(this)};class lx extends ee{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 ee{render(){return this.container}_getKeyModifier(t){return Ut.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||rx,r=t.style;let a;const o=2,l=c=>Math.round(10*c)/10;if(this.data.multiLine){const c=Math.abs(this.data.rect[3]-this.data.rect[1]-o),h=Math.round(c/(qp*i))||1,d=c/h;a=Math.min(i,l(d/qp))}else{const c=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(i,l(c/qp))}r.fontSize=`calc(${a}px * var(--total-scale-factor))`,r.color=B.makeHexColor(...s),this.data.textAlignment!==null&&!this.data.comb&&(r.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class cx extends Pl{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){const r=this.annotationStorage;for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=s),r.setValue(a.id,{[i]:s})}render(){var i,r;const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const a=t.getValue(e,{value:this.data.fieldValue});let o=a.value||"";const l=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;l&&o.length>l&&(o=o.slice(0,l));let c=a.formattedValue||((i=this.data.textContent)==null?void 0:i.join(` `))||null;c&&this.data.comb&&(c=c.replaceAll(/\s+/g,""));const h={userValue:o,formattedValue:c,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=c??o,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type=this.data.password?"password":"text",s.setAttribute("value",c??o),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(this.container.classList.add("hasOwnCanvas"),t.has(e)&&this.container.classList.add("sandboxModified")),_l.add(s),this.contentElement=s,s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=0;const{datetimeFormat:d,datetimeType:f,timeStep:g}=this.data,y=!!f&&this.enableScripting;d&&(s.title=d),this._setRequired(s,this.data.required),l&&(s.maxLength=l),s.addEventListener("input",S=>{t.setValue(e,{value:S.target.value}),this.setPropertyOnSiblings(s,"value",S.target.value,"value"),h.formattedValue=null}),s.addEventListener("resetform",S=>{const w=this.data.defaultFieldValue??"";s.value=h.userValue=w,h.formattedValue=null});let b=S=>{const{formattedValue:w}=h;w!=null&&(S.target.value=w),S.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",w=>{var A;if(h.focused)return;const{target:E}=w;if(y&&(E.type=f,g&&(E.step=g)),h.userValue){const _=h.userValue;if(y)if(f==="time"){const x=new Date(_),k=[x.getHours(),x.getMinutes(),x.getSeconds()];E.value=k.map(M=>M.toString().padStart(2,"0")).join(":")}else E.value=new Date(_-ax).toISOString().split(f==="date"?"T":".",1)[0];else E.value=_}h.lastCommittedValue=E.value,h.commitKey=1,(A=this.data.actions)!=null&&A.Focus||(h.focused=!0)}),s.addEventListener("updatefromsandbox",w=>{this.container.classList.add("sandboxModified");const E={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 x={formattedValue:_};y&&(x.value=_),t.setValue(e,x)},selRange(A){A.target.setSelectionRange(...A.detail.selRange)},charLimit:A=>{var M;const{charLimit:_}=A.detail,{target:x}=A;if(_===0){x.removeAttribute("maxLength");return}x.setAttribute("maxLength",_);let k=h.userValue;!k||k.length<=_||(k=k.slice(0,_),x.value=h.userValue=k,t.setValue(e,{value:k}),(M=this.linkService.eventBus)==null||M.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:k,willCommit:!0,commitKey:1,selStart:x.selectionStart,selEnd:x.selectionEnd}}))}};this._dispatchEventFromSandbox(E,w)}),s.addEventListener("keydown",w=>{var _;h.commitKey=1;let E=-1;if(w.key==="Escape"?E=0:w.key==="Enter"&&!this.data.multiLine?E=2:w.key==="Tab"&&(h.commitKey=3),E===-1)return;const{value:A}=w.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:E,selStart:w.target.selectionStart,selEnd:w.target.selectionEnd}}))});const S=b;b=null,s.addEventListener("blur",w=>{var _,x;if(!h.focused||!w.relatedTarget)return;(_=this.data.actions)!=null&&_.Blur||(h.focused=!1);const{target:E}=w;let{value:A}=E;if(y){if(A&&f==="time"){const k=A.split(":").map(M=>parseInt(M,10));A=new Date(2e3,0,1,k[0],k[1],k[2]||0).valueOf(),E.step=""}else A.includes("T")||(A=`${A}T00:00`),A=new Date(A).valueOf();E.type="text"}h.userValue=A,h.lastCommittedValue!==A&&((x=this.linkService.eventBus)==null||x.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:A,willCommit:!0,commitKey:h.commitKey,selStart:w.target.selectionStart,selEnd:w.target.selectionEnd}})),S(w)}),(r=this.data.actions)!=null&&r.Keystroke&&s.addEventListener("beforeinput",w=>{var I;h.lastCommittedValue=null;const{data:E,target:A}=w,{value:_,selectionStart:x,selectionEnd:k}=A;let M=x,D=k;switch(w.inputType){case"deleteWordBackward":{const L=_.substring(0,x).match(/\w*\W*$/);L&&(M-=L[0].length);break}case"deleteWordForward":{const L=_.substring(x).match(/^\W*\w*/);L&&(D+=L[0].length);break}case"deleteContentBackward":x===k&&(M-=1);break;case"deleteContentForward":x===k&&(D+=1);break}w.preventDefault(),(I=this.linkService.eventBus)==null||I.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:_,change:E||"",willCommit:!1,selStart:M,selEnd:D}})}),this._setEventListeners(s,h,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],w=>w.target.value)}if(b&&s.addEventListener("blur",b),this.data.comb){const w=(this.data.rect[2]-this.data.rect[0])/l;s.classList.add("comb"),s.style.setProperty("--comb-width",`calc(${w}px * var(--total-scale-factor))`);const E=this.data.textAlignment;if(E===1||E===2){const A=()=>{const _=l-s.value.length;s.style.setProperty("--comb-offset",`${E===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 hx extends Pl{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class dx 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 ux extends Pl{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.buttonValue!==null&&e.fieldValue===e.buttonValue}).value;if(typeof i=="string"&&(i=i!==e.buttonValue,t.setValue(s,{value:i})),i)for(const a of this._getElementsByName(e.fieldName,s))t.setValue(a.id,{value:!1});const r=document.createElement("input");if(_l.add(r),r.setAttribute("data-element-id",s),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=e.fieldName,i&&r.setAttribute("checked",!0),r.tabIndex=0,r.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const c of this._getElementsByName(o,s))t.setValue(c.id,{value:!1});t.setValue(s,{value:l})}),r.addEventListener("resetform",a=>{const o=e.defaultFieldValue;a.target.checked=o!=null&&o===e.buttonValue}),this.enableScripting&&this.hasJSActions){const a=e.buttonValue;r.addEventListener("updatefromsandbox",o=>{const l={value:c=>{const h=a===c.detail.value;for(const d of this._getElementsByName(c.target.name)){const f=h&&d.id===s;d.domElement&&(d.domElement.checked=f),t.setValue(d.id,{value:f})}}};this._dispatchEventFromSandbox(l,o)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)}return this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class fx extends Xm{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",s=>{this._dispatchEventFromSandbox({},s)})),t}}class px extends Pl{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");_l.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=0;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",d=>{const f=this.data.defaultFieldValue;for(const g of i.options)g.selected=g.value===f});const a=(d,f)=>{const g=f.replaceAll(" "," ");d.textContent=g,g!==f&&d.setAttribute("display-value",f)};for(const d of this.data.options){const f=document.createElement("option");a(f,d.displayValue),f.value=d.exportValue,s.value.includes(d.exportValue)&&(f.setAttribute("selected",!0),r=!1),i.append(f)}let o=null;if(r){const d=document.createElement("option");d.value=" ",d.setAttribute("hidden",!0),d.setAttribute("selected",!0),i.prepend(d),o=()=>{d.remove(),i.removeEventListener("input",o),o=null},i.addEventListener("input",o)}const l=d=>{const f=d?"value":"textContent",{options:g,multiple:y}=i;return y?Array.prototype.filter.call(g,b=>b.selected).map(b=>b[f]):g.selectedIndex===-1?null:g[g.selectedIndex][f]};let c=l(!1);const h=d=>{const f=d.target.options;return Array.prototype.map.call(f,g=>({displayValue:g.getAttribute("display-value")||g.textContent,exportValue:g.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",d=>{const f={value(g){o==null||o();const y=g.detail.value,b=new Set(Array.isArray(y)?y:[y]);for(const S of i.options)S.selected=b.has(S.value);t.setValue(e,{value:l(!0)}),c=l(!1)},multipleSelection(g){i.multiple=!0},remove(g){const y=i.options,b=g.detail.remove;y[b].selected=!1,i.remove(b),y.length>0&&Array.prototype.findIndex.call(y,w=>w.selected)===-1&&(y[0].selected=!0),t.setValue(e,{value:l(!0),items:h(g)}),c=l(!1)},clear(g){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),c=l(!1)},insert(g){const{index:y,displayValue:b,exportValue:S}=g.detail.insert,w=i.children[y],E=document.createElement("option");a(E,b),E.value=S,w?w.before(E):i.append(E),t.setValue(e,{value:l(!0),items:h(g)}),c=l(!1)},items(g){const{items:y}=g.detail;for(;i.length!==0;)i.remove(0);for(const b of y){const{displayValue:S,exportValue:w}=b,E=document.createElement("option");a(E,S),E.value=w,i.append(E)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:l(!0),items:h(g)}),c=l(!1)},indices(g){const y=new Set(g.detail.indices);for(const b of g.target.options)b.selected=y.has(b.index);t.setValue(e,{value:l(!0)}),c=l(!1)},editable(g){g.target.disabled=!g.detail.editable}};this._dispatchEventFromSandbox(f,d)}),i.addEventListener("input",d=>{var y;const f=l(!0),g=l(!1);t.setValue(e,{value:f}),d.preventDefault(),(y=this.linkService.eventBus)==null||y.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:c,change:g,changeEx:f,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],d=>d.target.value)):i.addEventListener("input",function(d){t.setValue(e,{value:l(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}var ru,em;class tm extends ee{constructor(e){const{data:s,elements:i,parent:r}=e,a=!!r._commentManager;super(e,{isRenderable:!a&&ee._hasPopupData(s)});m(this,ru);if(this.elements=i,a&&ee._hasPopupData(s)){const o=this.popup=v(this,ru,em).call(this);for(const l of i)l.popup=o}else this.popup=null}render(){const{container:e}=this;e.classList.add("popupAnnotation"),e.role="comment";const s=this.popup=v(this,ru,em).call(this),i=[];for(const r of this.elements)r.popup=s,r.container.ariaHasPopup="dialog",i.push(r.data.id),r.addHighlightArea();return this.container.setAttribute("aria-controls",i.map(r=>`${Bl}${r}`).join(",")),this.container}}ru=new WeakSet,em=function(){return new gx({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 js,ra,Ap,Sp,$c,Uc,de,un,aa,Qo,Hc,zc,fn,Ws,er,sr,ue,ir,oa,au,nr,Vc,Jo,la,De,ca,vt,Ef,sm,im,nm,Cf,rm,Py,My,Iy,Dy,_f,kf,am;class gx{constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:r,contentsObj:a,richText:o,parent:l,rect:c,parentRect:h,open:d,commentManager:f=null}){m(this,vt);m(this,js,null);m(this,ra,v(this,vt,Iy).bind(this));m(this,Ap,v(this,vt,am).bind(this));m(this,Sp,v(this,vt,kf).bind(this));m(this,$c,v(this,vt,_f).bind(this));m(this,Uc,null);m(this,de,null);m(this,un,null);m(this,aa,null);m(this,Qo,null);m(this,Hc,null);m(this,zc,null);m(this,fn,!1);m(this,Ws,null);m(this,er,null);m(this,sr,null);m(this,ue,null);m(this,ir,null);m(this,oa,null);m(this,au,null);m(this,nr,null);m(this,Vc,null);m(this,Jo,null);m(this,la,!1);m(this,De,null);m(this,ca,null);p(this,de,t),p(this,Vc,i),p(this,un,a),p(this,nr,o),p(this,Hc,l),p(this,Uc,e),p(this,au,c),p(this,zc,h),p(this,Qo,s),p(this,js,f),p(this,De,s[0]),p(this,aa,qf.toDateObject(r)),this.trigger=s.flatMap(g=>g.getElementsToTriggerPopup()),f||(v(this,vt,Ef).call(this),n(this,de).hidden=!0,d&&v(this,vt,_f).call(this))}renderCommentButton(){if(n(this,ue)){n(this,ue).parentNode||n(this,De).container.after(n(this,ue));return}if(n(this,ir)||v(this,vt,sm).call(this),!n(this,ir))return;const{signal:t}=p(this,er,new AbortController),e=n(this,De).hasOwnCommentButton,s=()=>{n(this,js).toggleCommentPopup(this,!0,void 0,!e)},i=()=>{n(this,js).toggleCommentPopup(this,!1,!0,!e)},r=()=>{n(this,js).toggleCommentPopup(this,!1,!1)};if(e){p(this,ue,n(this,De).container);for(const a of this.trigger)a.ariaHasPopup="dialog",a.ariaControls="commentPopup",a.addEventListener("keydown",n(this,ra),{signal:t}),a.addEventListener("click",s,{signal:t}),a.addEventListener("pointerenter",i,{signal:t}),a.addEventListener("pointerleave",r,{signal:t}),a.classList.add("popupTriggerArea")}else{const a=p(this,ue,document.createElement("button"));a.className="annotationCommentButton";const o=n(this,De).container;a.style.zIndex=parseInt(o.style.zIndex,10)+1,a.tabIndex=0,a.ariaHasPopup="dialog",a.ariaControls="commentPopup",a.setAttribute("data-l10n-id","pdfjs-show-comment-button"),v(this,vt,nm).call(this),v(this,vt,im).call(this),a.addEventListener("keydown",n(this,ra),{signal:t}),a.addEventListener("click",s,{signal:t}),a.addEventListener("pointerenter",i,{signal:t}),a.addEventListener("pointerleave",r,{signal:t}),o.after(a)}}get commentButtonColor(){const{color:t,opacity:e}=n(this,De).commentData;return t?n(this,Hc)._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{var t;(t=n(this,ue))==null||t.focus()},0)}getData(){const{richText:t,color:e,opacity:s,creationDate:i,modificationDate:r}=n(this,De).commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:s,creationDate:i,modificationDate:r}}get elementBeforePopup(){return n(this,ue)}get comment(){return n(this,ca)||p(this,ca,n(this,De).commentText),n(this,ca)}set comment(t){t!==this.comment&&(n(this,De).commentText=p(this,ca,t))}focus(){var t;(t=n(this,De).container)==null||t.focus()}get parentBoundingClientRect(){return n(this,De).layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){n(this,ue)&&(n(this,ue).classList.toggle("selected",t),n(this,ue).ariaExpanded=e)}setSelectedCommentButton(t){n(this,ue).classList.toggle("selected",t)}get commentPopupPosition(){if(n(this,oa))return n(this,oa);const{x:t,y:e,height:s}=n(this,ue).getBoundingClientRect(),{x:i,y:r,width:a,height:o}=n(this,De).layer.getBoundingClientRect();return[(t-i)/a,(e+s-r)/o]}set commentPopupPosition(t){p(this,oa,t)}hasDefaultPopupPosition(){return n(this,oa)===null}get commentButtonPosition(){return n(this,ir)}get commentButtonWidth(){return n(this,ue).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,s]=n(this,oa)||this.commentButtonPosition.map(c=>c/100),i=this.parentBoundingClientRect,{x:r,y:a,width:o,height:l}=i;n(this,js).showDialog(null,this,r+e*o,a+s*l,{...t,parentDimensions:i})}render(){var s,i;if(n(this,Ws))return;const t=p(this,Ws,document.createElement("div"));if(t.className="popup",n(this,Uc)){const r=t.style.outlineColor=B.makeHexColor(...n(this,Uc));t.style.backgroundColor=`color-mix(in srgb, ${r} 30%, white)`}const e=document.createElement("span");if(e.className="header",(s=n(this,Vc))!=null&&s.str){const r=document.createElement("span");r.className="title",e.append(r),{dir:r.dir,str:r.textContent}=n(this,Vc)}if(t.append(e),n(this,aa)){const r=document.createElement("time");r.className="popupDate",r.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),r.setAttribute("data-l10n-args",JSON.stringify({dateObj:n(this,aa).valueOf()})),r.dateTime=n(this,aa).toISOString(),e.append(r)}ib({html:n(this,vt,Cf)||n(this,un).str,dir:(i=n(this,un))==null?void 0:i.dir,className:"popupContent"},t),n(this,de).append(t)}updateEdited({rect:t,popup:e,deleted:s}){var i;if(n(this,js)){s?(this.remove(),p(this,ca,null)):e&&(e.deleted?this.remove():(v(this,vt,nm).call(this),p(this,ca,e.text))),t&&(p(this,ir,null),v(this,vt,sm).call(this),v(this,vt,im).call(this));return}if(s||e!=null&&e.deleted){this.remove();return}v(this,vt,Ef).call(this),n(this,Jo)||p(this,Jo,{contentsObj:n(this,un),richText:n(this,nr)}),t&&p(this,sr,null),e&&e.text&&(p(this,nr,v(this,vt,My).call(this,e.text)),p(this,aa,qf.toDateObject(e.date)),p(this,un,null)),(i=n(this,Ws))==null||i.remove(),p(this,Ws,null)}resetEdited(){var t;n(this,Jo)&&({contentsObj:Yt(this,un)._,richText:Yt(this,nr)._}=n(this,Jo),p(this,Jo,null),(t=n(this,Ws))==null||t.remove(),p(this,Ws,null),p(this,sr,null))}remove(){var t,e,s;if((t=n(this,er))==null||t.abort(),p(this,er,null),(e=n(this,Ws))==null||e.remove(),p(this,Ws,null),p(this,la,!1),p(this,fn,!1),(s=n(this,ue))==null||s.remove(),p(this,ue,null),this.trigger)for(const i of this.trigger)i.classList.remove("popupTriggerArea")}forceHide(){p(this,la,this.isVisible),n(this,la)&&(n(this,de).hidden=!0)}maybeShow(){n(this,js)||(v(this,vt,Ef).call(this),n(this,la)&&(n(this,Ws)||v(this,vt,kf).call(this),p(this,la,!1),n(this,de).hidden=!1))}get isVisible(){return n(this,js)?!1:n(this,de).hidden===!1}}js=new WeakMap,ra=new WeakMap,Ap=new WeakMap,Sp=new WeakMap,$c=new WeakMap,Uc=new WeakMap,de=new WeakMap,un=new WeakMap,aa=new WeakMap,Qo=new WeakMap,Hc=new WeakMap,zc=new WeakMap,fn=new WeakMap,Ws=new WeakMap,er=new WeakMap,sr=new WeakMap,ue=new WeakMap,ir=new WeakMap,oa=new WeakMap,au=new WeakMap,nr=new WeakMap,Vc=new WeakMap,Jo=new WeakMap,la=new WeakMap,De=new WeakMap,ca=new WeakMap,vt=new WeakSet,Ef=function(){var e;if(n(this,er))return;p(this,er,new AbortController);const{signal:t}=n(this,er);for(const s of this.trigger)s.addEventListener("click",n(this,$c),{signal:t}),s.addEventListener("pointerenter",n(this,Sp),{signal:t}),s.addEventListener("pointerleave",n(this,Ap),{signal:t}),s.classList.add("popupTriggerArea");for(const s of n(this,Qo))(e=s.container)==null||e.addEventListener("keydown",n(this,ra),{signal:t})},sm=function(){const t=n(this,Qo).find(e=>e.hasCommentButton);t&&p(this,ir,t._normalizePoint(t.commentButtonPosition))},im=function(){if(n(this,De).extraPopupElement&&!n(this,De).editor)return;n(this,ue)||this.renderCommentButton();const[t,e]=n(this,ir),{style:s}=n(this,ue);s.left=`calc(${t}%)`,s.top=`calc(${e}% - var(--comment-button-dim))`},nm=function(){n(this,De).extraPopupElement||(n(this,ue)||this.renderCommentButton(),n(this,ue).style.backgroundColor=this.commentButtonColor||"")},Cf=function(){const t=n(this,nr),e=n(this,un);return t!=null&&t.str&&(!(e!=null&&e.str)||e.str===t.str)&&n(this,nr).html||null},rm=function(){var t,e,s;return((s=(e=(t=n(this,vt,Cf))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.fontSize)||0},Py=function(){var t,e,s;return((s=(e=(t=n(this,vt,Cf))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.color)||null},My=function(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:n(this,vt,Py),fontSize:n(this,vt,rm)?`calc(${n(this,vt,rm)}px * var(--total-scale-factor))`:""}};for(const r of t.split(` `))e.push({name:"span",value:r,attributes:i});return s},Iy=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&n(this,fn))&&v(this,vt,_f).call(this)},Dy=function(){if(n(this,sr)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:r}}}=n(this,Hc);let a=!!n(this,zc),o=a?n(this,zc):n(this,au);for(const y of n(this,Qo))if(!o||B.intersect(y.data.rect,o)!==null){o=y.data.rect,a=!0;break}const l=B.normalizeRect([o[0],t[3]-o[1]+t[1],o[2],t[3]-o[3]+t[1]]),h=a?o[2]-o[0]+5:0,d=l[0]+h,f=l[1];p(this,sr,[100*(d-i)/e,100*(f-r)/s]);const{style:g}=n(this,de);g.left=`${n(this,sr)[0]}%`,g.top=`${n(this,sr)[1]}%`},_f=function(){if(n(this,js)){n(this,js).toggleCommentPopup(this,!1);return}p(this,fn,!n(this,fn)),n(this,fn)?(v(this,vt,kf).call(this),n(this,de).addEventListener("click",n(this,$c)),n(this,de).addEventListener("keydown",n(this,ra))):(v(this,vt,am).call(this),n(this,de).removeEventListener("click",n(this,$c)),n(this,de).removeEventListener("keydown",n(this,ra)))},kf=function(){n(this,Ws)||this.render(),this.isVisible?n(this,fn)&&n(this,de).classList.add("focused"):(v(this,vt,Dy).call(this),n(this,de).hidden=!1,n(this,de).style.zIndex=parseInt(n(this,de).style.zIndex,10)+1e3)},am=function(){n(this,de).classList.remove("focused"),!(n(this,fn)||!this.isVisible)&&(n(this,de).hidden=!0,n(this,de).style.zIndex=parseInt(n(this,de).style.zIndex,10)-1e3)};class Ly extends ee{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=lt.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 ou;class mx extends ee{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,ou,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,ou,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,ou)}addHighlightArea(){this.container.classList.add("highlightArea")}}ou=new WeakMap;var lu;class vx extends ee{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,lu,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,lu,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,lu)}addHighlightArea(){this.container.classList.add("highlightArea")}}lu=new WeakMap;var cu;class bx extends ee{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,cu,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,cu,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,cu)}addHighlightArea(){this.container.classList.add("highlightArea")}}cu=new WeakMap;var hu;class Fy extends ee{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});m(this,hu,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:s,borderStyle:i,popupRef:r},width:a,height:o}=this;if(!s)return this.container;const l=this.svgFactory.create(a,o,!0);let c=[];for(let d=0,f=s.length;d=0&&a.setAttribute("stroke-width",s||1),i)for(let o=0,l=n(this,Zo).length;o{a.key==="Enter"&&(r?a.metaKey:a.ctrlKey)&&v(this,pu,lm).call(this)}),!s.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):i.classList.add("popupTriggerArea"),e.append(i),e}getElementsToTriggerPopup(){return n(this,fu)}addHighlightArea(){this.container.classList.add("highlightArea")}}fu=new WeakMap,pu=new WeakSet,lm=async function(){var a;const{fileId:e,filename:s,content:i}=this,r=await this.linkService.getAttachmentContent(e)||i;r&&((a=this.downloadManager)==null||a.openOrDownloadData(r,s))};var Gc,tl,rr,kl,By,cm;class Ny extends ee{constructor(e){super(e,{isRenderable:!!e.data.richMedia});m(this,kl);m(this,Gc,new AbortController);m(this,tl,null);m(this,rr,null)}render(){this.container.classList.add("mediaAnnotation");const{filename:e}=this.data.richMedia,s=document.createElement("button");return s.className="mediaPlayButton",s.type="button",s.title=s.ariaLabel=e,s.addEventListener("click",()=>v(this,kl,By).call(this,s),{signal:n(this,Gc).signal}),this.container.append(s),this.container}destroy(){n(this,Gc).abort(),n(this,rr)&&(n(this,rr).pause(),n(this,rr).removeAttribute("src"),n(this,rr).load(),p(this,rr,null)),v(this,kl,cm).call(this)}}Gc=new WeakMap,tl=new WeakMap,rr=new WeakMap,kl=new WeakSet,By=async function(e){const{fileId:s,filename:i,contentType:r}=this.data.richMedia;e.disabled=!0;let a;try{a=await this.linkService.getAttachmentContent(s)}catch{return}finally{e.disabled=!1}if(!a||!e.isConnected)return;const{signal:o}=n(this,Gc),l=URL.createObjectURL(new Blob([a],{type:r}));p(this,tl,l);const c=r.startsWith("audio/"),h=document.createElement(c?"audio":"video");if(p(this,rr,h),h.className="mediaContent",this._setBackgroundColor(h),h.src=l,h.title=i,h.controls=!0,h.autoplay=!0,h.tabIndex=0,c){let d=!1,f=!1;const g=()=>{h.controls=d||f};this.container.addEventListener("pointerenter",()=>{d=!0,g()},{signal:o}),this.container.addEventListener("pointerleave",()=>{d=!1,g()},{signal:o}),this.container.addEventListener("focusin",()=>{f=!0,g()},{signal:o}),this.container.addEventListener("focusout",()=>{f=!1,g()},{signal:o})}h.addEventListener("emptied",()=>v(this,kl,cm).call(this,l),{once:!0,signal:o}),e.replaceWith(h),h.play().catch(()=>{})},cm=function(e=n(this,tl)){e&&e===n(this,tl)&&(URL.revokeObjectURL(e),p(this,tl,null))};var ha,el,jc,ar,gu,sl,es,mu,xn,Tf,Pf;const nv=class nv{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:r,viewport:a,structTreeLayer:o,commentManager:l,linkService:c,annotationStorage:h}){m(this,xn);m(this,ha,null);m(this,el,null);m(this,jc,null);m(this,ar,new Map);m(this,gu,null);m(this,sl,null);m(this,es,[]);m(this,mu,!1);P(this,"zIndex",0);this.div=t,p(this,ha,e),p(this,el,s),p(this,gu,o||null),p(this,sl,c||null),p(this,jc,h||new jm),this.page=r,this.viewport=a,this._annotationEditorUIManager=i,this._commentManager=l||null}hasEditableAnnotations(){return n(this,ar).size>0}async render(t){var l;const{annotations:e,optionalContentConfig:s}=t,i=this.div;xl(i,this.viewport);const r=new Map,a=[],o={data:null,layer:i,linkService:n(this,sl),downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Zf,annotationStorage:n(this,jc),enableComment:t.enableComment===!0,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const c of e){if(c.noHTML)continue;const h=c.annotationType===oe.POPUP;if(h){const g=r.get(c.id);if(!g)continue;if(!this._commentManager){a.push(c);continue}o.elements=g}else if(c.rect[2]===c.rect[0]||c.rect[3]===c.rect[1])continue;o.data=c;const d=eg.create(o);if(!d.isRenderable)continue;h||(n(this,es).push(d),c.popupRef&&r.getOrInsertComputed(c.popupRef,Vu).push(d));const f=d.render();c.hidden&&(f.style.visibility="hidden"),d.updateOC(s),d._isEditable&&(n(this,ar).set(d.data.id,d),(l=this._annotationEditorUIManager)==null||l.renderAnnotationElement(d))}await v(this,xn,Tf).call(this);for(const c of a){const h=o.elements=r.get(c.id);o.data=c;const d=eg.create(o);if(!d.isRenderable)continue;const f=d.render();d.contentElement.id=`${Bl}${c.id}`,c.hidden&&(f.style.visibility="hidden"),h.at(-1).container.after(f)}v(this,xn,Pf).call(this)}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:n(this,sl),svgFactory:new Zf,parent:this};for(const s of t){s.borderStyle||(s.borderStyle=nv._defaultBorderStyle),e.data=s;const i=eg.create(e);i.isRenderable&&(i.render(),i.contentElement.id=`${Bl}${s.id}`,n(this,es).push(i))}await v(this,xn,Tf).call(this)}update({viewport:t,optionalContentConfig:e}){const s=this.div;this.viewport=t,xl(s,{rotation:t.rotation});for(const i of n(this,es))i.updateOC(e);v(this,xn,Pf).call(this),s.hidden=!1}destroy(){var t,e;for(const s of n(this,es))(t=s.destroy)==null||t.call(s),(e=n(this,ha))==null||e.removePointerInTextLayer(s.contentElement);n(this,es).length=0,n(this,ar).clear(),this.div.replaceChildren()}refreshCanvases(){v(this,xn,Pf).call(this)}getEditableAnnotations(){return n(this,ar).values()}getEditableAnnotation(t){return n(this,ar).get(t)}addFakeAnnotation(t){const{div:e}=this,{id:s,rotation:i}=t,r=new ox({data:{id:s,rect:t.getPDFRect(),rotation:i},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:n(this,sl),annotationStorage:n(this,jc)});return r.render(),r.contentElement.id=`${Bl}${s}`,r.createOrUpdatePopup(),n(this,es).push(r),r}removeAnnotation(t){var i;const e=n(this,es).findIndex(r=>r.data.id===t);if(e<0)return;const[s]=n(this,es).splice(e,1);(i=n(this,ha))==null||i.removePointerInTextLayer(s.contentElement)}updateFakeAnnotations(t){if(t.length!==0){for(const e of t)e.updateFakeAnnotationElement(this);v(this,xn,Tf).call(this)}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return at(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Ll.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};ha=new WeakMap,el=new WeakMap,jc=new WeakMap,ar=new WeakMap,gu=new WeakMap,sl=new WeakMap,es=new WeakMap,mu=new WeakMap,xn=new WeakSet,Tf=async function(){var s,i,r;if(n(this,es).length===0)return;this.div.replaceChildren();const t=[];if(!n(this,mu)){p(this,mu,!0);for(const{contentElement:a,data:{id:o}}of n(this,es)){const l=a.id=`${Bl}${o}`;t.push((s=n(this,gu))==null?void 0:s.getAriaAttributes(l).then(c=>{if(c)for(const[h,d]of c)a.setAttribute(h,d)}))}}n(this,es).sort(({data:{rect:[a,o,l,c]}},{data:{rect:[h,d,f,g]}})=>{if(a===l&&o===c)return 1;if(h===f&&d===g)return-1;const y=c,b=o,S=(o+c)/2,w=g,E=d,A=(d+g)/2;if(S>=w&&A<=b)return-1;if(A>=y&&S<=E)return 1;const _=(a+l)/2,x=(h+f)/2;return _-x});const e=document.createDocumentFragment();for(const a of n(this,es))e.append(a.container),this._commentManager?(r=((i=a.extraPopupElement)==null?void 0:i.popup)||a.popup)==null||r.renderCommentButton():a.extraPopupElement&&e.append(a.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),n(this,ha))for(const a of n(this,es))n(this,ha).addPointerInTextLayer(a.contentElement,!1)},Pf=function(){var e;if(!n(this,el))return;const t=this.div;for(const[s,i]of n(this,el)){const r=t.querySelector(`[data-annotation-id="${s}"]`);if(!r)continue;if(Array.isArray(i))for(const h of i)h.className="annotationContent",h.ariaHidden=!0;else i.className="annotationContent",i.ariaHidden=!0;const a=[];for(const h of r.children)h.nodeName==="CANVAS"&&a.push(h);for(const h of a)h.remove();const o=Array.isArray(i)?i[0]:i,{firstChild:l}=r;if(l?l.classList.contains("annotationContent")?l.after(o):l.before(o):r.append(o),Array.isArray(i)){let h=o;for(let d=1,f=i.length;da.isEmpty(),i=Cl.TRANSLATE_SMALL,r=Cl.TRANSLATE_BIG;return at(this,"_keyboardManager",new El([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter"],e.commitOrRemove],[["Escape"],e.commitOrRemove],[["ArrowLeft"],e._translateEmpty,{args:[-i,0],checker:s}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-r,0],checker:s}],[["ArrowRight"],e._translateEmpty,{args:[i,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[r,0],checker:s}],[["ArrowUp"],e._translateEmpty,{args:[0,-i],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-r],checker:s}],[["ArrowDown"],e._translateEmpty,{args:[0,i],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,r],checker:s}]]))}static initialize(e,s){Pt.initialize(e,s);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,s){switch(e){case gt.FREETEXT_SIZE:Kt._defaultFontSize=s;break;case gt.FREETEXT_COLOR:Kt._defaultColor=s;break}}updateParams(e,s){switch(e){case gt.FREETEXT_SIZE:v(this,Ae,$y).call(this,s);break;case gt.FREETEXT_COLOR:v(this,Ae,Uy).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[gt.FREETEXT_SIZE,Kt._defaultFontSize],[gt.FREETEXT_COLOR,Kt._defaultColor||Pt._defaultLineColor]]}get propertiesToUpdate(){return[[gt.FREETEXT_SIZE,n(this,qs)],[gt.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new Jf(this)),[["colorPicker",this._colorPicker]]}get colorType(){return gt.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,qs))*e]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),p(this,il,new AbortController);const e=this._uiManager.combinedSignal(n(this,il));return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e}),!0}disableEditMode(){var e;return super.disableEditMode()?(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",n(this,vu)),this._isDraggable=!0,(e=n(this,il))==null||e.abort(),p(this,il,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){var s;this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),(s=this._initialOptions)!=null&&s.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=n(this,Xs),s=p(this,Xs,v(this,Ae,Hy).call(this).trimEnd());if(e===s)return;const i=r=>{if(p(this,Xs,r),!r){this.remove();return}v(this,Ae,Df).call(this),this._uiManager.rebuild(this),v(this,Ae,Mf).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(e)},mustExec:!1}),v(this,Ae,Mf).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(e){e.target===this.div&&e.key==="Enter"&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){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,vu)),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,qs)}px * var(--total-scale-factor))`,i.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[r,a]=this.parentDimensions;if(this.annotationElementId){const{position:o}=this._initialData;let[l,c]=this.getInitialTranslation();[l,c]=this.pageTranslationToScreen(l,c);const[h,d]=this.pageDimensions,[f,g]=this.pageTranslation;let y,b;switch(this.rotation){case 0:y=e+(o[0]-f)/h,b=s+this.height-(o[1]-g)/d;break;case 90:y=e+(o[0]-f)/h,b=s-(o[1]-g)/d,[l,c]=[c,-l];break;case 180:y=e-this.width+(o[0]-f)/h,b=s-(o[1]-g)/d,[l,c]=[-l,-c];break;case 270:y=e+(o[0]-f-this.height*d)/h,b=s+(o[1]-g-this.width*h)/d,[l,c]=[-c,l];break}this.setAt(y*r,b*a,l,c)}else this._moveAfterPaste(e,s);v(this,Ae,Df).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var y,b,S;const s=e.clipboardData||window.clipboardData,{types:i}=s;if(i.length===1&&i[0]==="text/plain")return;e.preventDefault();const r=v(y=Kt,br,um).call(y,s.getData("text")||"").replaceAll(Zu,` `);if(!r)return;const a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();const o=a.getRangeAt(0);if(!r.includes(` `)){o.insertNode(document.createTextNode(r)),this.editorDiv.normalize(),a.collapseToStart();return}const{startContainer:l,startOffset:c}=o,h=[],d=[];if(l.nodeType===Node.TEXT_NODE){const w=l.parentElement;if(d.push(l.nodeValue.slice(c).replaceAll(Zu,"")),w!==this.editorDiv){let E=h;for(const A of this.editorDiv.childNodes){if(A===w){E=d;continue}E.push(v(b=Kt,br,If).call(b,A))}}h.push(l.nodeValue.slice(0,c).replaceAll(Zu,""))}else if(l===this.editorDiv){let w=h,E=0;for(const A of this.editorDiv.childNodes)E++===c&&(w=d),w.push(v(S=Kt,br,If).call(S,A))}p(this,Xs,`${h.join(` `)}${r}${d.join(` `)}`),v(this,Ae,Df).call(this);const f=new Range;let g=Math.sumPrecise(h.map(w=>w.length));for(const{firstChild:w}of this.editorDiv.childNodes)if(w.nodeType===Node.TEXT_NODE){const E=w.nodeValue.length;if(g<=E){f.setStart(w,g),f.setEnd(w,g);break}g-=E}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 Ly){const{data:{defaultAppearanceData:{fontSize:l,fontColor:c},rect:h,rotation:d,id:f,popupRef:g,richText:y,contentsObj:b,creationDate:S,modificationDate:w},textContent:E,textPosition:A,parent:{page:{pageNumber:_}}}=e;if(!(E!=null&&E.length))return null;r=e={annotationType:lt.FREETEXT,color:Array.from(c),fontSize:l,value:E.join(` `),position:A,pageIndex:_-1,rect:h.slice(0),rotation:d,annotationElementId:f,id:f,deleted:!1,popupRef:g,comment:(b==null?void 0:b.str)||null,richText:y,creationDate:S,modificationDate:w}}const a=await super.deserialize(e,s,i);return p(a,qs,e.fontSize),a.color=B.makeHexColor(...e.color),p(a,Xs,v(o=Kt,br,um).call(o,e.value)),a._initialData=r,e.comment&&a.setCommentData(e),a}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=Pt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(e),{color:s,fontSize:n(this,qs),value:v(this,Ae,zy).call(this)});return this.addComment(i),e?(i.isCopy=!0,i):this.annotationElementId&&!v(this,Ae,Vy).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(e){const s=super.renderAnnotationElement(e);if(!s)return null;const{style:i}=s;i.fontSize=`calc(${n(this,qs)}px * var(--total-scale-factor))`,i.color=this.color,s.replaceChildren();for(const r of n(this,Xs).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,Xs)}}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};Xs=new WeakMap,vu=new WeakMap,il=new WeakMap,qs=new WeakMap,Ae=new WeakSet,$y=function(e){const s=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--total-scale-factor))`,this.translate(0,-(r-n(this,qs))*this.parentScale),p(this,qs,r),v(this,Ae,Mf).call(this)},i=n(this,qs);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:gt.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},Uy=function(e){const s=r=>{this.color=r,this.onUpdatedColor()},i=this.color;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:gt.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Hy=function(){var i;const e=[];this.editorDiv.normalize();let s=null;for(const r of this.editorDiv.childNodes)(s==null?void 0:s.nodeType)===Node.TEXT_NODE&&r.nodeName==="BR"||(e.push(v(i=Kt,br,If).call(i,r)),s=r);return e.join(` `)},Mf=function(){const[e,s]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:r,div:a}=this,o=a.style.display,l=a.classList.contains("hidden");a.classList.remove("hidden"),a.style.display="hidden",r.div.append(this.div),i=a.getBoundingClientRect(),a.remove(),a.style.display=o,a.classList.toggle("hidden",l)}this.rotation%180===this.parentRotation%180?(this.width=i.width/e,this.height=i.height/s):(this.width=i.height/e,this.height=i.width/s),this.fixAndSetPosition()},br=new WeakSet,If=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(Zu,"")},Df=function(){if(this.editorDiv.replaceChildren(),!!n(this,Xs))for(const e of n(this,Xs).split(` `)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},zy=function(){return n(this,Xs).replaceAll(" "," ")},um=function(e){return e.replaceAll(" "," ")},Vy=function(e){const{value:s,fontSize:i,color:r,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||e.value!==s||e.fontSize!==i||e.color.some((o,l)=>o!==r[l])||e.pageIndex!==a},m(Kt,br),P(Kt,"_freeTextDefaultContent",""),P(Kt,"_internalPadding",0),P(Kt,"_defaultColor",null),P(Kt,"_defaultFontSize",10),P(Kt,"_type","freetext"),P(Kt,"_editorType",lt.FREETEXT);let dm=Kt;class X{toSVGPath(){Ct("Abstract method `toSVGPath` must be implemented.")}get box(){Ct("Abstract getter `box` must be implemented.")}serialize(t,e){Ct("Abstract method `serialize` must be implemented.")}static _rescale(t,e,s,i,r,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o=6;i-=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return v(this,Ce,jy).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,r,a){return new Ky(t,e,s,i,r,a)}getOutlines(){var d;const t=n(this,pn),e=n(this,Hi),s=n(this,yt),[i,r,a,o]=n(this,Ys),l=new Float32Array((((d=n(this,da))==null?void 0:d.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 v(this,Ce,qy).call(this,c,h),this.newFreeDrawOutline(c,l,n(this,Ys),n(this,qc),n(this,Wc),n(this,Xc))}};Ys=new WeakMap,Hi=new WeakMap,Wc=new WeakMap,Xc=new WeakMap,pn=new WeakMap,yt=new WeakMap,nl=new WeakMap,rl=new WeakMap,bu=new WeakMap,yu=new WeakMap,qc=new WeakMap,Yc=new WeakMap,da=new WeakMap,wu=new WeakMap,xp=new WeakMap,Ep=new WeakMap,Ce=new WeakSet,Uh=function(){const t=n(this,yt).subarray(4,6),e=n(this,yt).subarray(16,18),[s,i,r,a]=n(this,Ys);return[(n(this,nl)+(t[0]-e[0])/2-s)/r,(n(this,rl)+(t[1]-e[1])/2-i)/a,(n(this,nl)+(e[0]-t[0])/2-s)/r,(n(this,rl)+(e[1]-t[1])/2-i)/a]},Gy=function(){const[t,e,s,i]=n(this,Ys),[r,a,o,l]=v(this,Ce,Uh).call(this);return`M${(n(this,yt)[2]-t)/s} ${(n(this,yt)[3]-e)/i} L${(n(this,yt)[4]-t)/s} ${(n(this,yt)[5]-e)/i} L${r} ${a} L${o} ${l} L${(n(this,yt)[16]-t)/s} ${(n(this,yt)[17]-e)/i} L${(n(this,yt)[14]-t)/s} ${(n(this,yt)[15]-e)/i} Z`},jy=function(t){const e=n(this,Hi);t.push(`L${e[4]} ${e[5]} Z`)},Wy=function(t){const[e,s,i,r]=n(this,Ys),a=n(this,yt).subarray(4,6),o=n(this,yt).subarray(16,18),[l,c,h,d]=v(this,Ce,Uh).call(this);t.push(`L${(a[0]-e)/i} ${(a[1]-s)/r} L${l} ${c} L${h} ${d} L${(o[0]-e)/i} ${(o[1]-s)/r}`)},Xy=function(t){const e=n(this,yt),[s,i,r,a]=n(this,Ys),[o,l,c,h]=v(this,Ce,Uh).call(this),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-s)/r,(e[3]-i)/a,NaN,NaN,NaN,NaN,(e[4]-s)/r,(e[5]-i)/a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,(e[16]-s)/r,(e[17]-i)/a,NaN,NaN,NaN,NaN,(e[14]-s)/r,(e[15]-i)/a],0),this.newFreeDrawOutline(d,t,n(this,Ys),n(this,qc),n(this,Wc),n(this,Xc))},qy=function(t,e){const s=n(this,Hi);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},Yy=function(t,e){const s=n(this,yt).subarray(4,6),i=n(this,yt).subarray(16,18),[r,a,o,l]=n(this,Ys),[c,h,d,f]=v(this,Ce,Uh).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-r)/o,(s[1]-a)/l,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,d,f,NaN,NaN,NaN,NaN,(i[0]-r)/o,(i[1]-a)/l],e),e+=24},m(In,wu,8),m(In,xp,2),m(In,Ep,n(In,wu)+n(In,xp));let tp=In;var Kc,al,or,Au,Ks,Su,me,Cp,Qy;class Ky extends X{constructor(e,s,i,r,a,o){super();m(this,Cp);m(this,Kc);m(this,al,new Float32Array(4));m(this,or);m(this,Au);m(this,Ks);m(this,Su);m(this,me);p(this,me,e),p(this,Ks,s),p(this,Kc,i),p(this,Su,r),p(this,or,a),p(this,Au,o),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],v(this,Cp,Qy).call(this,o);const[l,c,h,d]=n(this,al);for(let f=0,g=e.length;fw?(o=S,l=w):l===w&&(o=d(o,S)),hf[1]?(o=f[0],l=f[1]):l===f[1]&&(o=d(o,f[0])),he[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of n(this,ua))e[3]?(t.push(...v(this,gs,pm).call(this,e)),v(this,gs,Zy).call(this,e)):(v(this,gs,t0).call(this,e),t.push(...v(this,gs,pm).call(this,e)));return v(this,gs,Jy).call(this,t)}}xu=new WeakMap,Eu=new WeakMap,Cu=new WeakMap,ua=new WeakMap,zi=new WeakMap,gs=new WeakSet,Jy=function(t){const e=[],s=new Set;for(const a of t){const[o,l,c]=a;e.push([o,l,a],[o,c,a])}e.sort((a,o)=>a[1]-o[1]||a[0]-o[0]);for(let a=0,o=e.length;a0;){const a=s.values().next().value;let[o,l,c,h,d]=a;s.delete(a);let f=o,g=l;for(r=[o,c],i.push(r);;){let y;if(s.has(h))y=h;else if(s.has(d))y=d;else break;s.delete(y),[o,l,c,h,d]=y,f!==o&&(r.push(f,g,o,g===l?l:c),f=o),g=g===l?c:l}r.push(f,g)}return new Cx(i,n(this,xu),n(this,Eu),n(this,Cu))},Lf=function(t){const e=n(this,zi);let s=0,i=e.length-1;for(;s<=i;){const r=s+i>>1,a=e[r][0];if(a===t)return r;a=0;i--){const[r,a]=n(this,zi)[i];if(r!==t)break;if(r===t&&a===e){n(this,zi).splice(i,1);return}}},pm=function(t){const[e,s,i]=t,r=[[e,s,i]],a=v(this,gs,Lf).call(this,i);for(let o=0;o=l){if(g>c)r[h][1]=c;else{if(d===1)return[];r.splice(h,1),h--,d--}continue}r[h][2]=l,g>c&&r.push([e,c,g])}}}return r};var _u,Qc;class Cx extends X{constructor(e,s,i,r){super();m(this,_u);m(this,Qc);p(this,Qc,e),p(this,_u,s),this.firstPoint=i,this.lastPoint=r}toSVGPath(){const e=[];for(const s of n(this,Qc)){let[i,r]=s;e.push(`M${i} ${r}`);for(let a=2;a-1?(p(this,Ve,!0),v(this,mt,Ff).call(this,e),v(this,mt,Ha).call(this)):n(this,lr)&&(p(this,Jc,e.anchorNode),p(this,ku,e.anchorOffset),p(this,Pu,e.focusNode),p(this,Mu,e.focusOffset),v(this,mt,mm).call(this),v(this,mt,Ha).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert(Pt._l10nAlert.highlight)}static get _keyboardManager(){const e=_t.prototype;return at(this,"_keyboardManager",new El([[["ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown"],e._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:n(this,Ve)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:n(this,wi),methodOfCreation:n(this,Iu)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}static initialize(e,s){var i;Pt.initialize(e,s),_t._defaultColor||(_t._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case gt.HIGHLIGHT_COLOR:_t._defaultColor=s;break;case gt.HIGHLIGHT_THICKNESS:_t._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return n(this,th)}get commentButtonPosition(){return n(this,Zc)}updateParams(e,s){switch(e){case gt.HIGHLIGHT_COLOR:v(this,mt,e0).call(this,s);break;case gt.HIGHLIGHT_THICKNESS:v(this,mt,s0).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[gt.HIGHLIGHT_COLOR,_t._defaultColor],[gt.HIGHLIGHT_THICKNESS,_t._defaultThickness]]}get propertiesToUpdate(){return[[gt.HIGHLIGHT_COLOR,this.color||_t._defaultColor],[gt.HIGHLIGHT_THICKNESS,n(this,wi)||_t._defaultThickness],[gt.HIGHLIGHT_FREE,n(this,Ve)]]}onUpdatedColor(){var e,s;(e=this.parent)==null||e.drawLayer.updateProperties(n(this,Js),{root:{fill:this.color,"fill-opacity":this.opacity}}),(s=n(this,Tu))==null||s.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",p(this,Tu,new Qf({editor:this}))]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(v(this,mt,Of).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,v(this,mt,Of).call(this))}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){v(this,mt,vm).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(v(this,mt,Ha).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?v(this,mt,vm).call(this):e&&(v(this,mt,Ha).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),this.show(this._isVisible),s&&this.select()}rotate(e){var r,a,o;const{drawLayer:s}=this.parent;let i;n(this,Ve)?(e=(e-this.rotation+360)%360,i=v(r=_t,xi,Ol).call(r,n(this,Qs).box,e)):i=v(a=_t,xi,Ol).call(a,[this.x,this.y,this.width,this.height],e),s.updateProperties(n(this,Js),{bbox:i,root:{"data-main-rotation":e}}),s.updateProperties(n(this,ss),{bbox:v(o=_t,xi,Ol).call(o,n(this,Es).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();n(this,eh)&&(e.setAttribute("aria-label",n(this,eh)),e.setAttribute("role","mark")),n(this,Ve)?e.classList.add("free"):this.div.addEventListener("keydown",v(this,mt,n0).bind(this),{signal:this._uiManager._signal});const s=p(this,ll,document.createElement("div"));return e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=n(this,ol),this.setDims(),hb(this,n(this,ll),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(n(this,ss),{rootClass:{hovered:!0}})}pointerleave(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(n(this,ss),{rootClass:{hovered:!1}})}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:v(this,mt,Rf).call(this,!0);break;case 1:case 3:v(this,mt,Rf).call(this,!1);break}}select(){var e;super.select(),n(this,ss)&&((e=this.parent)==null||e.drawLayer.updateProperties(n(this,ss),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var e;super.unselect(),n(this,ss)&&((e=this.parent)==null||e.drawLayer.updateProperties(n(this,ss),{rootClass:{selected:!1}}),n(this,Ve)||v(this,mt,Rf).call(this,!1))}get _mustFixPosition(){return!n(this,Ve)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(n(this,Js),{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(n(this,ss),{rootClass:{hidden:!e}}))}static startHighlighting(e,s,{target:i,x:r,y:a}){const{x:o,y:l,width:c,height:h}=i.getBoundingClientRect(),d=new AbortController,f=e.combinedSignal(d),g=y=>{d.abort(),v(this,xi,l0).call(this,e,y)};window.addEventListener("blur",g,{signal:f}),window.addEventListener("pointerup",g,{signal:f}),window.addEventListener("pointerdown",ne,{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",_i,{signal:f}),i.addEventListener("pointermove",v(this,xi,o0).bind(this,e),{signal:f}),this._freeHighlight=new gm({x:r,y:a},[o,l,c,h],e.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static async deserialize(e,s,i){var S,w,E,A;let r=null;if(e instanceof Ry){const{data:{quadPoints:_,rect:x,rotation:k,id:M,color:D,opacity:I,popupRef:L,richText:O,contentsObj:Y,creationDate:W,modificationDate:Q},parent:{page:{pageNumber:ft}}}=e;r=e={annotationType:lt.HIGHLIGHT,color:Array.from(D),opacity:I,quadPoints:_,boxes:null,pageIndex:ft-1,rect:x.slice(0),rotation:k,annotationElementId:M,id:M,deleted:!1,popupRef:L,richText:O,comment:(Y==null?void 0:Y.str)||null,creationDate:W,modificationDate:Q}}else if(e instanceof qm){const{data:{inkLists:_,rect:x,rotation:k,id:M,color:D,borderStyle:{rawWidth:I},popupRef:L,richText:O,contentsObj:Y,creationDate:W,modificationDate:Q},parent:{page:{pageNumber:ft}}}=e;r=e={annotationType:lt.HIGHLIGHT,color:Array.from(D),thickness:I,inkLists:_,boxes:null,pageIndex:ft-1,rect:x.slice(0),rotation:k,annotationElementId:M,id:M,deleted:!1,popupRef:L,richText:O,comment:(Y==null?void 0:Y.str)||null,creationDate:W,modificationDate:Q}}const{color:a,quadPoints:o,inkLists:l,outlines:c,opacity:h}=e,d=await super.deserialize(e,s,i);d.color=B.makeHexColor(...a),d.opacity=h||1,l&&p(d,wi,e.thickness),d._initialData=r,e.comment&&d.setCommentData(e);const[f,g]=d.pageDimensions,[y,b]=d.pageTranslation;if(o){const _=p(d,lr,[]);for(let x=0;x=0)p(this,Js,s),p(this,ol,i),this.parent.drawLayer.finalizeDraw(s,{bbox:e.box,path:{d:e.toSVGPath()}}),p(this,ss,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:n(this,Es).box,path:{d:n(this,Es).toSVGPath()}},!0));else if(this.parent){const y=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(n(this,Js),{bbox:v(f=_t,xi,Ol).call(f,n(this,Qs).box,(y-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(n(this,ss),{bbox:v(g=_t,xi,Ol).call(g,n(this,Es).box,y),path:{d:n(this,Es).toSVGPath()}})}const[a,o,l,c]=e.box;switch(this.rotation){case 0:this.x=a,this.y=o,this.width=l,this.height=c;break;case 90:{const[y,b]=this.parentDimensions;this.x=o,this.y=1-a,this.width=l*b/y,this.height=c*y/b;break}case 180:this.x=1-a,this.y=1-o,this.width=l,this.height=c;break;case 270:{const[y,b]=this.parentDimensions;this.x=1-o,this.y=a,this.width=l*b/y,this.height=c*y/b;break}}const{firstPoint:h}=e;p(this,Zc,[(h[0]-a)/l,(h[1]-o)/c]);const{lastPoint:d}=n(this,Es);p(this,th,[(d[0]-a)/l,(d[1]-o)/c])},e0=function(e){const s=(a,o)=>{this.color=a,this.opacity=o,this.onUpdatedColor()},i=this.color,r=this.opacity;this.addCommands({cmd:s.bind(this,e,_t._defaultOpacity),undo:s.bind(this,i,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:gt.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0)},s0=function(e){const s=n(this,wi),i=r=>{p(this,wi,r),v(this,mt,i0).call(this,r)};this.addCommands({cmd:i.bind(this,e),undo:i.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:gt.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},i0=function(e){n(this,Ve)&&(v(this,mt,Ff).call(this,{highlightOutlines:n(this,Qs).getNewOutline(e/2)}),this.fixAndSetPosition(),this.setDims())},vm=function(){n(this,Js)===null||!this.parent||(this.parent.drawLayer.remove(n(this,Js)),p(this,Js,null),this.parent.drawLayer.remove(n(this,ss)),p(this,ss,null))},Ha=function(e=this.parent){n(this,Js)===null&&({id:Yt(this,Js)._,clipPathId:Yt(this,ol)._}=e.drawLayer.draw({bbox:n(this,Qs).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:n(this,Ve)},path:{d:n(this,Qs).toSVGPath()}},!1,!0),p(this,ss,e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:n(this,Ve)},bbox:n(this,Es).box,path:{d:n(this,Es).toSVGPath()}},n(this,Ve))),n(this,ll)&&(n(this,ll).style.clipPath=n(this,ol)))},xi=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]},n0=function(e){_t._keyboardManager.exec(this,e)},Rf=function(e){if(!n(this,Jc))return;const s=window.getSelection();e?s.setPosition(n(this,Jc),n(this,ku)):s.setPosition(n(this,Pu),n(this,Mu))},Of=function(){return n(this,Ve)?this.rotation:0},r0=function(){if(n(this,Ve))return null;const[e,s]=this.pageDimensions,[i,r]=this.pageTranslation,a=n(this,lr),o=new Float32Array(a.length*8);let l=0;for(const{x:c,y:h,width:d,height:f}of a){const g=c*e+i,y=(1-h)*s+r;o[l]=o[l+4]=g,o[l+1]=o[l+3]=y,o[l+2]=o[l+6]=g+d*e,o[l+5]=o[l+7]=y-f*s,l+=8}return o},a0=function(e){return n(this,Qs).serialize(e,v(this,mt,Of).call(this))},o0=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},l0=function(e,s){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(s,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},c0=function(e){const{color:s}=this._initialData;return this.hasEditedComment||e.color.some((i,r)=>i!==s[r])},m(_t,xi),P(_t,"_defaultColor",null),P(_t,"_defaultOpacity",1),P(_t,"_defaultThickness",12),P(_t,"_type","highlight"),P(_t,"_editorType",lt.HIGHLIGHT),P(_t,"_freeHighlightId",-1),P(_t,"_freeHighlight",null),P(_t,"_freeHighlightClipId","");let ep=_t;var cl;class h0{constructor(){m(this,cl,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,s)}updateSVGProperty(t,e){n(this,cl)[t]=e}toSVGProperties(){const t=n(this,cl);return p(this,cl,Object.create(null)),{root:t}}reset(){p(this,cl,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){Ct("Not implemented")}}cl=new WeakMap;var cs,sh,Le,hl,dl,xt,bm,ym,wm,Hh,d0,Nf,zh,Nl;const At=class At extends Pt{constructor(e){super(e);m(this,xt);m(this,cs,null);m(this,sh);P(this,"_colorPicker",null);P(this,"_drawId",null);p(this,sh,e.mustBeCommitted||!1),this._addOutlines(e)}onUpdatedColor(){var e;(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){var e,s;(s=(e=this._colorPicker)==null?void 0:e.updateOpacity)==null||s.call(e,this.opacity)}_addOutlines(e){e.drawOutlines&&(v(this,xt,bm).call(this,e),v(this,xt,Hh).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(At,Le).updateProperty(i,s),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,s){const i=this.constructor.typesMap.get(e);i&&this._updateProperty(e,i,s)}static get defaultPropertiesToUpdate(){const e=[],s=this._defaultDrawingOptions;for(const[i,r]of this.typesMap)e.push([i,s[r]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:s}=this;for(const[i,r]of this.constructor.typesMap)e.push([i,s[r]]);return e}_updateProperty(e,s,i){const r=this._drawingOptions,a=r[s],o=l=>{var h;r.updateProperty(s,l);const c=n(this,cs).updateProperty(s,l);c&&v(this,xt,zh).call(this,c),(h=this.parent)==null||h.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),e===this.colorType?this.onUpdatedColor():e===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:o.bind(this,i),undo:o.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(e,s){const i=this.constructor.typesMap.get(this.colorType),r=this.constructor.typesMap.get(this.opacityType),a=this._drawingOptions,o=a[i],l=a[r],c=(h,d)=>{var f;a.updateProperty(i,h),a.updateProperty(r,d),n(this,cs).updateProperty(i,h),n(this,cs).updateProperty(r,d),(f=this.parent)==null||f.drawLayer.updateProperties(this._drawId,a.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:c.bind(this,e,s),undo:c.bind(this,o,l),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:gt.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,At._mergeSVGProperties(n(this,cs).getPathResizingSVGProperties(v(this,xt,Nf).call(this)),{bbox:v(this,xt,Nl).call(this)}))}_onResized(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,At._mergeSVGProperties(n(this,cs).getPathResizedSVGProperties(v(this,xt,Nf).call(this)),{bbox:v(this,xt,Nl).call(this)}))}_onTranslating(e,s){var i;(i=this.parent)==null||i.drawLayer.updateProperties(this._drawId,{bbox:v(this,xt,Nl).call(this)})}_onTranslated(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,At._mergeSVGProperties(n(this,cs).getPathTranslatedSVGProperties(v(this,xt,Nf).call(this),this.parentDimensions),{bbox:v(this,xt,Nl).call(this)}))}_onStartDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,n(this,sh)&&(p(this,sh,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){v(this,xt,wm).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(v(this,xt,Hh).call(this),v(this,xt,zh).call(this,n(this,cs).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),v(this,xt,wm).call(this)):e&&(this._uiManager.addShouldRescale(this),v(this,xt,Hh).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,At._mergeSVGProperties({bbox:v(this,xt,Nl).call(this)},n(this,cs).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&v(this,xt,zh).call(this,n(this,cs).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,s;this._isCopy&&(e=this.x,s=this.y);const i=super.render();i.classList.add("draw");const r=document.createElement("div");return i.append(r),r.setAttribute("aria-hidden","true"),r.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(e,s),i}static createDrawerInstance(e,s,i,r,a){Ct("Not implemented")}static startDrawing(e,s,i,r){var S;const{target:a,offsetX:o,offsetY:l,pointerId:c,pointerType:h}=r;if(Je.isInitializedAndDifferentPointerType(h))return;const{viewport:{rotation:d}}=e,{width:f,height:g}=a.getBoundingClientRect(),y=p(At,hl,new AbortController),b=e.combinedSignal(y);if(Je.setPointer(h,c),window.addEventListener("pointerup",w=>{Je.isSamePointerIdOrRemove(w.pointerId)&&this._endDraw(w)},{signal:b}),window.addEventListener("pointercancel",w=>{Je.isSamePointerIdOrRemove(w.pointerId)&&this._currentParent.endDrawingSession()},{signal:b}),window.addEventListener("pointerdown",w=>{Je.isSamePointerType(w.pointerType)&&(Je.initializeAndAddPointerId(w.pointerId),n(At,Le).isCancellable()&&(n(At,Le).removeLastElement(),n(At,Le).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:b}),window.addEventListener("contextmenu",_i,{signal:b}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:b}),a.addEventListener("touchmove",w=>{Je.isSameTimeStamp(w.timeStamp)&&ne(w)},{signal:b}),e.toggleDrawing(),(S=s._editorUndoBar)==null||S.hide(),n(At,Le)){e.drawLayer.updateProperties(this._currentDrawId,n(At,Le).startNew(o,l,f,g,d));return}s.updateUIForDefaultProperties(this),p(At,Le,this.createDrawerInstance(o,l,f,g,d)),p(At,dl,this.getDefaultDrawingOptions()),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(n(At,dl).toSVGProperties(),n(At,Le).defaultSVGProperties),!0,!1)}static _drawMove(e){if(Je.isSameTimeStamp(e.timeStamp),!n(At,Le))return;const{offsetX:s,offsetY:i,pointerId:r}=e;if(Je.isSamePointerId(r)){if(Je.isUsingMultiplePointers()){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,n(At,Le).add(s,i)),Je.setTimeStamp(e.timeStamp),ne(e)}}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,p(At,Le,null),p(At,dl,null),Je.clearTimeStamp()),n(At,hl)&&(n(At,hl).abort(),p(At,hl,null),Je.clearPointerIds())}static _endDraw(e){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),(e==null?void 0:e.target)===s.div&&s.drawLayer.updateProperties(this._currentDrawId,n(At,Le).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const i=n(At,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:gt.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(gt.DRAW_STEP),!n(At,Le).isEmpty()){const{pageDimensions:[i,r],scale:a}=s,o=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:n(At,Le).getOutlines(i*a,r*a,a,this._INNER_MARGIN),drawingOptions:n(At,dl),mustBeCommitted:!e});return this._cleanup(!0),o}return s.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,s,i,r,a,o){Ct("Not implemented")}static async deserialize(e,s,i){var d,f;const{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}=s.viewport,c=this.deserializeDraw(o,l,r,a,this._INNER_MARGIN,e),h=await super.deserialize(e,s,i);return h.createDrawingOptions(e),v(d=h,xt,bm).call(d,{drawOutlines:c}),v(f=h,xt,Hh).call(f),h.onScaleChanging(),h.rotate(),h}serializeDraw(e){const[s,i]=this.pageTranslation,[r,a]=this.pageDimensions;return n(this,cs).serialize([s,i,r,a],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};cs=new WeakMap,sh=new WeakMap,Le=new WeakMap,hl=new WeakMap,dl=new WeakMap,xt=new WeakSet,bm=function({drawOutlines:e,drawId:s,drawingOptions:i}){p(this,cs,e),this._drawingOptions||(this._drawingOptions=i),this.annotationElementId||this._uiManager.a11yAlert(Pt._l10nAlert[this.editorType]),s>=0?(this._drawId=s,this.parent.drawLayer.finalizeDraw(s,e.defaultProperties)):this._drawId=v(this,xt,ym).call(this,e,this.parent),v(this,xt,zh).call(this,e.box)},ym=function(e,s){const{id:i}=s.drawLayer.draw(At._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return i},wm=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},Hh=function(e=this.parent){if(!(this._drawId!==null&&this.parent===e)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=v(this,xt,ym).call(this,n(this,cs),e)}},d0=function([e,s,i,r]){const{parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[s,1-e,i*(o/a),r*(a/o)];case 180:return[1-e,1-s,i,r];case 270:return[1-s,e,i*(o/a),r*(a/o)];default:return[e,s,i,r]}},Nf=function(){const{x:e,y:s,width:i,height:r,parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[1-s,e,i*(a/o),r*(o/a)];case 180:return[1-e,1-s,i,r];case 270:return[s,1-e,i*(a/o),r*(o/a)];default:return[e,s,i,r]}},zh=function(e){[this.x,this.y,this.width,this.height]=v(this,xt,d0).call(this,e),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},Nl=function(){const{x:e,y:s,width:i,height:r,rotation:a,parentRotation:o,parentDimensions:[l,c]}=this;switch((a*4+o)/90){case 1:return[1-s-r,e,r,i];case 2:return[1-e-i,1-s-r,i,r];case 3:return[s,1-e-i,r,i];case 4:return[e,s-i*(l/c),r*(c/l),i*(l/c)];case 5:return[1-s,e,i*(l/c),r*(c/l)];case 6:return[1-e-r*(c/l),1-s,r*(c/l),i*(l/c)];case 7:return[s-i*(l/c),1-e-r*(c/l),i*(l/c),r*(c/l)];case 8:return[e-i,s-r,i,r];case 9:return[1-s,e-i,r,i];case 10:return[1-e,1-s,i,r];case 11:return[s-r,1-e,r,i];case 12:return[e-r*(c/l),s,r*(c/l),i*(l/c)];case 13:return[1-s-i*(l/c),e-r*(c/l),i*(l/c),r*(c/l)];case 14:return[1-e,1-s-i*(l/c),r*(c/l),i*(l/c)];case 15:return[s,1-e,i*(l/c),r*(c/l)];default:return[e,s,i,r]}},P(At,"_currentDrawId",-1),P(At,"_currentParent",null),m(At,Le,null),m(At,hl,null),m(At,dl,null),P(At,"_INNER_MARGIN",3);let sp=At;var gn,Fe,Ge,ul,ih,hs,je,Ai,fl,pl,gl,nh,Bf;class kx{constructor(t,e,s,i,r,a){m(this,nh);m(this,gn,new Float64Array(6));m(this,Fe);m(this,Ge);m(this,ul);m(this,ih);m(this,hs);m(this,je,"");m(this,Ai,0);m(this,fl,new Xu);m(this,pl);m(this,gl);p(this,pl,s),p(this,gl,i),p(this,ul,r),p(this,ih,a),[t,e]=v(this,nh,Bf).call(this,t,e);const o=p(this,Fe,[NaN,NaN,NaN,NaN,t,e]);p(this,hs,[t,e]),p(this,Ge,[{line:o,points:n(this,hs)}]),n(this,gn).set(o,0)}updateProperty(t,e){t==="stroke-width"&&p(this,ih,e)}isEmpty(){var t;return!((t=n(this,Ge))!=null&&t.length)}isCancellable(){return n(this,hs).length<=10}add(t,e){[t,e]=v(this,nh,Bf).call(this,t,e);const[s,i,r,a]=n(this,gn).subarray(2,6),o=t-r,l=e-a;return Math.hypot(n(this,pl)*o,n(this,gl)*l)<=2?null:(n(this,hs).push(t,e),isNaN(s)?(n(this,gn).set([r,a,t,e],2),n(this,Fe).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(n(this,gn)[0])&&n(this,Fe).splice(6,6),n(this,gn).set([s,i,r,a,t,e],0),n(this,Fe).push(...X.createBezierPoints(s,i,r,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const s=this.add(t,e);return s||(n(this,hs).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,i,r){p(this,pl,s),p(this,gl,i),p(this,ul,r),[t,e]=v(this,nh,Bf).call(this,t,e);const a=p(this,Fe,[NaN,NaN,NaN,NaN,t,e]);p(this,hs,[t,e]);const o=n(this,Ge).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),n(this,Ge).push({line:a,points:n(this,hs)}),n(this,gn).set(a,0),p(this,Ai,0),this.toSVGPath(),null}getLastElement(){return n(this,Ge).at(-1)}setLastElement(t){return n(this,Ge)?(n(this,Ge).push(t),p(this,Fe,t.line),p(this,hs,t.points),p(this,Ai,0),{path:{d:this.toSVGPath()}}):n(this,fl).setLastElement(t)}removeLastElement(){if(!n(this,Ge))return n(this,fl).removeLastElement();n(this,Ge).pop(),p(this,je,"");for(let t=0,e=n(this,Ge).length;t_??NaN),f,g,y,b),points:S(l[E].map(_=>_??NaN),f,g,y,b)});const w=new this.prototype.constructor;return w.build(d,i,r,1,c,h,a),w}get box(){return n(this,ds)}updateProperty(e,s){return e==="stroke-width"?v(this,Xe,p0).call(this,s):null}updateParentDimensions([e,s],i){const[r,a]=v(this,Xe,Pn).call(this);p(this,mn,e),p(this,vn,s),p(this,rh,i);const[o,l]=v(this,Xe,Pn).call(this),c=o-r,h=l-a,d=n(this,ds);return d[0]-=c,d[1]-=h,d[2]+=2*c,d[3]+=2*h,d}updateRotation(e){return p(this,Du,e),{path:{transform:this.rotationTransform}}}get viewBox(){return n(this,ds).map(X.svgRound).join(" ")}get defaultProperties(){const[e,s]=n(this,ds);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(s)}`}}}get rotationTransform(){const[,,e,s]=n(this,ds);let i=0,r=0,a=0,o=0,l=0,c=0;switch(n(this,Du)){case 90:r=s/e,a=-e/s,l=e;break;case 180:i=-1,o=-1,l=e,c=s;break;case 270:r=-s/e,a=e/s,c=s;break;default:return""}return`matrix(${i} ${r} ${a} ${o} ${X.svgRound(l)} ${X.svgRound(c)})`}getPathResizingSVGProperties([e,s,i,r]){const[a,o]=v(this,Xe,Pn).call(this),[l,c,h,d]=n(this,ds);if(Math.abs(h-a)<=X.PRECISION||Math.abs(d-o)<=X.PRECISION){const S=e+i/2-(l+h/2),w=s+r/2-(c+d/2);return{path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(s)}`,transform:`${this.rotationTransform} translate(${S} ${w})`}}}const f=(i-2*a)/(h-2*a),g=(r-2*o)/(d-2*o),y=h/i,b=d/r;return{path:{"transform-origin":`${X.svgRound(l)} ${X.svgRound(c)}`,transform:`${this.rotationTransform} scale(${y} ${b}) translate(${X.svgRound(a)} ${X.svgRound(o)}) scale(${f} ${g}) translate(${X.svgRound(-a)} ${X.svgRound(-o)})`}}}getPathResizedSVGProperties([e,s,i,r]){const[a,o]=v(this,Xe,Pn).call(this),l=n(this,ds),[c,h,d,f]=l;if(l[0]=e,l[1]=s,l[2]=i,l[3]=r,Math.abs(d-a)<=X.PRECISION||Math.abs(f-o)<=X.PRECISION){const w=e+i/2-(c+d/2),E=s+r/2-(h+f/2);for(const{line:A,points:_}of n(this,Zs))X._translate(A,w,E,A),X._translate(_,w,E,_);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const g=(i-2*a)/(d-2*a),y=(r-2*o)/(f-2*o),b=-g*(c+a)+e+a,S=-y*(h+o)+s+o;if(g!==1||y!==1||b!==0||S!==0)for(const{line:w,points:E}of n(this,Zs))X._rescale(w,b,S,g,y,w),X._rescale(E,b,S,g,y,E);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${X.svgRound(e)} ${X.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,s],i){const[r,a]=i,o=n(this,ds),l=e-o[0],c=s-o[1];if(n(this,mn)===r&&n(this,vn)===a)for(const{line:h,points:d}of n(this,Zs))X._translate(h,l,c,h),X._translate(d,l,c,d);else{const h=n(this,mn)/r,d=n(this,vn)/a;p(this,mn,r),p(this,vn,a);for(const{line:f,points:g}of n(this,Zs))X._rescale(f,l,c,h,d,f),X._rescale(g,l,c,h,d,g);o[2]*=h,o[3]*=d}return o[0]=e,o[1]=s,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${X.svgRound(e)} ${X.svgRound(s)}`}}}get defaultSVGProperties(){const e=n(this,ds);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${X.svgRound(e[0])} ${X.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}ds=new WeakMap,Du=new WeakMap,Lu=new WeakMap,Zs=new WeakMap,mn=new WeakMap,vn=new WeakMap,rh=new WeakMap,ah=new WeakMap,ml=new WeakMap,Xe=new WeakSet,Pn=function(e=n(this,ml)){const s=n(this,Lu)+e/2*n(this,rh);return n(this,ah)%180===0?[s/n(this,mn),s/n(this,vn)]:[s/n(this,vn),s/n(this,mn)]},u0=function(){const[e,s,i,r]=n(this,ds),[a,o]=v(this,Xe,Pn).call(this,0);return[e+a,s+o,i-2*a,r-2*o]},f0=function(){const e=p(this,ds,ja.slice());for(const{line:r}of n(this,Zs)){if(r.length<=12){for(let l=4,c=r.length;lo!==s[l])||e.thickness!==i||e.opacity!==r||e.pageIndex!==a},P(Ul,"_type","ink"),P(Ul,"_editorType",lt.INK),P(Ul,"_defaultDrawingOptions",null);let Am=Ul;class Sm extends Xu{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const tf=8,Ah=3;var vl,Mt,xm,Vi,m0,v0,Em,$f,b0,y0,w0,Cm,_m,A0;class gr{static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:i},r,a,o,l){let c=new OffscreenCanvas(1,1),h=c.getContext("2d",{alpha:!1});const d=200,f=h.font=`${s} ${i} ${d}px ${e}`,{actualBoundingBoxLeft:g,actualBoundingBoxRight:y,actualBoundingBoxAscent:b,actualBoundingBoxDescent:S,fontBoundingBoxAscent:w,fontBoundingBoxDescent:E,width:A}=h.measureText(t),_=1.5,x=Math.ceil(Math.max(Math.abs(g)+Math.abs(y)||0,A)*_),k=Math.ceil(Math.max(Math.abs(b)+Math.abs(S)||d,Math.abs(w)+Math.abs(E)||d)*_);c=new OffscreenCanvas(x,k),h=c.getContext("2d",{alpha:!0,willReadFrequently:!0}),h.font=f,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,x,k),h.fillStyle="black",h.fillText(t,x*(_-1)/2,k*(3-_)/2);const M=v(this,Mt,Cm).call(this,h.getImageData(0,0,x,k).data),D=v(this,Mt,w0).call(this,M),I=v(this,Mt,_m).call(this,D),L=v(this,Mt,Em).call(this,M,x,k,I);return this.processDrawnLines({lines:{curves:L,width:x,height:k},pageWidth:r,pageHeight:a,rotation:o,innerMargin:l,mustSmooth:!0,areContours:!0})}static process(t,e,s,i,r){const[a,o,l]=v(this,Mt,A0).call(this,t),[c,h]=v(this,Mt,y0).call(this,a,o,l,Math.hypot(o,l)*n(this,vl).sigmaSFactor,n(this,vl).sigmaR,n(this,vl).kernelSize),d=v(this,Mt,_m).call(this,h),f=v(this,Mt,Em).call(this,c,o,l,d);return this.processDrawnLines({lines:{curves:f,width:o,height:l},pageWidth:e,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:a,areContours:o}){i%180!==0&&([e,s]=[s,e]);const{curves:l,width:c,height:h}=t,d=t.thickness??0,f=[],g=Math.min(e/c,s/h),y=g/e,b=g/s,S=[];for(const{points:E}of l){const A=a?v(this,Mt,b0).call(this,E):E;if(!A)continue;S.push(A);const _=A.length,x=new Float32Array(_),k=new Float32Array(3*(_===2?2:_-2));if(f.push({line:k,points:x}),_===2){x[0]=A[0]*y,x[1]=A[1]*b,k.set([NaN,NaN,NaN,NaN,x[0],x[1]],0);continue}let[M,D,I,L]=A;M*=y,D*=b,I*=y,L*=b,x.set([M,D,I,L],0),k.set([NaN,NaN,NaN,NaN,M,D],0);for(let O=4;O<_;O+=2){const Y=x[O]=A[O]*y,W=x[O+1]=A[O+1]*b;k.set(X.createBezierPoints(M,D,I,L,Y,W),(O-2)*3),[M,D,I,L]=[I,L,Y,W]}}if(f.length===0)return null;const w=o?new Sm:new Xu;return w.build(f,e,s,1,i,o?0:d,r),{outline:w,newCurves:S,areContours:o,thickness:d,width:c,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:i,height:r}){let a=1/0,o=-1/0,l=0;for(const E of t){l+=E.length;for(let A=2,_=E.length;A<_;A++){const x=E[A]-E[A-2];a=Math.min(a,x),o=Math.max(o,x)}}let c;a>=-128&&o<=127?c=Int8Array:a>=-32768&&o<=32767?c=Int16Array:c=Int32Array;const h=t.length,d=tf+Ah*h,f=new Uint32Array(d);let g=0;f[g++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*h)*c.BYTES_PER_ELEMENT,f[g++]=0,f[g++]=i,f[g++]=r,f[g++]=e?0:1,f[g++]=Math.max(0,Math.floor(s??0)),f[g++]=h,f[g++]=c.BYTES_PER_ELEMENT;for(const E of t)f[g++]=E.length-2,f[g++]=E[0],f[g++]=E[1];const y=new CompressionStream("deflate-raw"),b=y.writable.getWriter();await b.ready,b.write(f);const S=c.prototype.constructor;for(const E of t){const A=new S(E.length-2);for(let _=2,x=E.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],d=l[3],f=l[4]===0,g=l[5],y=l[6],b=l[7],S=[],w=(tf+Ah*y)*Uint32Array.BYTES_PER_ELEMENT;let E;switch(b){case Int8Array.BYTES_PER_ELEMENT:E=new Int8Array(a.buffer,w);break;case Int16Array.BYTES_PER_ELEMENT:E=new Int16Array(a.buffer,w);break;case Int32Array.BYTES_PER_ELEMENT:E=new Int32Array(a.buffer,w);break}o=0;for(let A=0;A0?0:4:s===1?i+6:2-i},Vi=new WeakMap,m0=function(t,e,s,i,r,a,o){const l=v(this,Mt,xm).call(this,s,i,r,a);for(let c=0;c<8;c++){const h=(-c+l-o+16)%8,d=n(this,Vi)[2*h],f=n(this,Vi)[2*h+1];if(t[(s+d)*e+(i+f)]!==0)return h}return-1},v0=function(t,e,s,i,r,a,o){const l=v(this,Mt,xm).call(this,s,i,r,a);for(let c=0;c<8;c++){const h=(c+l+o+16)%8,d=n(this,Vi)[2*h],f=n(this,Vi)[2*h+1];if(t[(s+d)*e+(i+f)]!==0)return h}return-1},Em=function(t,e,s,i){const r=t.length,a=new Int32Array(r);for(let h=0;h=1&&a[f+1]===0)o+=1,b+=1,g>1&&(l=g);else{g!==1&&(l=Math.abs(g));continue}const S=[d,h],w=b===d+1,E={isHole:w,points:S,id:o,parent:0};c.push(E);let A;for(const O of c)if(O.id===l){A=O;break}A?A.isHole?E.parent=w?A.parent:l:E.parent=w?l:A.parent:E.parent=w?l:0;const _=v(this,Mt,m0).call(this,a,e,h,d,y,b,0);if(_===-1){a[f]=-o,a[f]!==1&&(l=Math.abs(a[f]));continue}let x=n(this,Vi)[2*_],k=n(this,Vi)[2*_+1];const M=h+x,D=d+k;y=M,b=D;let I=h,L=d;for(;;){const O=v(this,Mt,v0).call(this,a,e,I,L,y,b,1);x=n(this,Vi)[2*O],k=n(this,Vi)[2*O+1];const Y=I+x,W=L+k;S.push(W,Y);const Q=I*e+L;if(a[Q+1]===0?a[Q]=-o:a[Q]===1&&(a[Q]=o),Y===h&&W===d&&I===M&&L===D){a[f]!==1&&(l=Math.abs(a[f]));break}else y=I,b=L,I=Y,L=W}}}return c},$f=function(t,e,s,i){if(s-e<=4){for(let M=e;Mx&&(k=M,x=D)}x>(c*_)**2?(v(this,Mt,$f).call(this,t,e,k+2,i),v(this,Mt,$f).call(this,t,k,s,i)):i.push(r,a)},b0=function(t){const e=[],s=t.length;return v(this,Mt,$f).call(this,t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e},y0=function(t,e,s,i,r,a){const o=new Float32Array(a**2),l=-2*i**2,c=a>>1;for(let b=0;b=s))for(let D=0;D=e)continue;const L=t[M*e+I],O=o[k*a+D]*h[Math.abs(L-E)];A+=L*O,_+=O}}const x=g[w]=Math.round(A/_);y[x]++}return[g,y]},w0=function(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e},Cm=function(t){const e=t.length,s=new Uint8ClampedArray(e>>2);let i=-1/0,r=1/0;for(let o=0,l=s.length;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},A0=function(t){const e=t,{width:s,height:i}=t,{maxDim:r}=n(this,vl);let a=s,o=i;if(s>r||i>r){let f=s,g=i,y=Math.log2(Math.max(s,i)/r);const b=Math.floor(y);y=y===b?b-1:b;for(let w=0;w{s==null||s.updateEditSignatureButton(e)}))}getSignaturePreview(){const{newCurves:e,areContours:s,thickness:i,width:r,height:a}=n(this,pa),o=Math.max(r,a),l=gr.processDrawnLines({lines:{curves:e.map(c=>({points:c})),thickness:i,width:r,height:a},pageWidth:o,pageHeight:o,rotation:0,innerMargin:0,mustSmooth:!1,areContours:s});return{areContours:s,outline:l.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,s,i,r){const{x:a,y:o}=this,{outline:l}=p(this,pa,e);p(this,fa,l instanceof Sm),this.description=i;let c;n(this,fa)?c=Os.getDefaultDrawingOptions():(c=Os._defaultDrawnSignatureOptions.clone(),c.updateProperties({"stroke-width":l.thickness})),this._addOutlines({drawOutlines:l,drawingOptions:c});const[,h]=this.pageDimensions;let d=s/h;d=d>=1?.5:d,this.width*=d/this.height,this.width>=1&&(d*=.9/this.width,this.width=.9),this.height=d,this.setDims(),this.x=a,this.y=o,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(r),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!r,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return gr.process(e,s,i,r,Os._INNER_MARGIN)}getFromText(e,s){const{rawDims:{pageWidth:i,pageHeight:r},rotation:a}=this.parent.viewport;return gr.extractContoursFromText(e,s,i,r,a,Os._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return gr.processDrawnLines({lines:e,pageWidth:s,pageHeight:i,rotation:r,innerMargin:Os._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:s}){e?this._drawingOptions=Os.getDefaultDrawingOptions():(this._drawingOptions=Os._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":s}))}serialize(e=!1){if(this.isEmpty())return null;const{lines:s,points:i}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":r}}=this,a=Object.assign(super.serialize(e),{isSignature:!0,areContours:n(this,fa),color:[0,0,0],thickness:n(this,fa)?0:r});return this.addComment(a),e?(a.paths={lines:s,points:i},a.uuid=n(this,bl),a.isCopy=!0):a.lines=s,n(this,bn)&&(a.accessibilityData={type:"Figure",alt:n(this,bn)}),a}static deserializeDraw(e,s,i,r,a,o){return o.areContours?Sm.deserialize(e,s,i,r,a,o):Xu.deserialize(e,s,i,r,a,o)}static async deserialize(e,s,i){var a;const r=await super.deserialize(e,s,i);return p(r,fa,e.areContours),r.description=((a=e.accessibilityData)==null?void 0:a.alt)||"",p(r,bl,e.uuid),r}};fa=new WeakMap,bn=new WeakMap,pa=new WeakMap,bl=new WeakMap,P(Os,"_type","signature"),P(Os,"_editorType",lt.SIGNATURE),P(Os,"_defaultDrawingOptions",null);let km=Os;var te,Re,ga,cr,ma,oh,hr,yl,yn,ti,lh,Et,Vh,Gh,Uf,Hf,zf,Pm,Vf,S0;class Tm extends Pt{constructor(e){super({...e,name:"stampEditor"});m(this,Et);m(this,te,null);m(this,Re,null);m(this,ga,null);m(this,cr,null);m(this,ma,null);m(this,oh,"");m(this,hr,null);m(this,yl,!1);m(this,yn,null);m(this,ti,!1);m(this,lh,!1);p(this,cr,e.bitmapUrl),p(this,ma,e.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,s){Pt.initialize(e,s)}static isHandlingMimeForPasting(e){return hg.includes(e)}static paste(e,s){s.pasteEditor({mode:lt.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,Re)&&(p(this,te,null),this._uiManager.imageManager.deleteId(n(this,Re)),(e=n(this,hr))==null||e.remove(),p(this,hr,null),n(this,yn)&&(clearTimeout(n(this,yn)),p(this,yn,null))),super.remove()}rebuild(){if(!this.parent){n(this,Re)&&v(this,Et,Uf).call(this);return}super.rebuild(),this.div!==null&&(n(this,Re)&&n(this,hr)===null&&v(this,Et,Uf).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(n(this,ga)||n(this,te)||n(this,cr)||n(this,ma)||n(this,Re)||n(this,yl))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let e,s;return this._isCopy&&(e=this.x,s=this.y),super.render(),this.div.hidden=!0,this.createAltText(),n(this,yl)||(n(this,te)?v(this,Et,Hf).call(this):v(this,Et,Uf).call(this)),this._isCopy&&this._moveAfterPaste(e,s),this._uiManager.addShouldRescale(this),this.div}setCanvas(e,s){const{id:i,bitmap:r}=this._uiManager.imageManager.getFromCanvas(e,s);s.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(p(this,Re,i),r&&p(this,te,r),p(this,yl,!1),v(this,Et,Hf).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;n(this,yn)!==null&&clearTimeout(n(this,yn)),p(this,yn,setTimeout(()=>{p(this,yn,null),v(this,Et,Pm).call(this)},200))}copyCanvas(e,s,i=!1){e||(e=224);const{width:r,height:a}=n(this,te),o=new En;let l=n(this,te),c=r,h=a,d=null;if(s){if(r>s||a>s){const M=Math.min(s/r,s/a);c=Math.floor(r*M),h=Math.floor(a*M)}d=document.createElement("canvas");const g=d.width=Math.ceil(c*o.sx),y=d.height=Math.ceil(h*o.sy);n(this,ti)||(l=v(this,Et,zf).call(this,g,y));const b=d.getContext("2d");b.filter=this._uiManager.hcmFilter;let S="white",w="#cfcfd8";this._uiManager.hcmFilter!=="none"?w="black":BS.isDarkMode&&(S="#8f8f9d",w="#42414d");const E=15,A=E*o.sx,_=E*o.sy,x=new OffscreenCanvas(A*2,_*2),k=x.getContext("2d");k.fillStyle=S,k.fillRect(0,0,A*2,_*2),k.fillStyle=w,k.fillRect(0,0,A,_),k.fillRect(A,_,A,_),b.fillStyle=b.createPattern(x,"repeat"),b.fillRect(0,0,g,y),b.drawImage(l,0,0,l.width,l.height,0,0,g,y)}let f=null;if(i){let g,y;if(o.symmetric&&l.widthe||a>e){const w=Math.min(e/r,e/a);g=Math.floor(r*w),y=Math.floor(a*w),n(this,ti)||(l=v(this,Et,zf).call(this,g,y))}const S=new OffscreenCanvas(g,y).getContext("2d",{willReadFrequently:!0});S.drawImage(l,0,0,l.width,l.height,0,0,g,y),f={width:g,height:y,data:S.getImageData(0,0,g,y).data}}return{canvas:d,width:c,height:h,imageData:f}}static async deserialize(e,s,i){var S;let r=null,a=!1;if(e instanceof Oy){const{data:{rect:w,rotation:E,id:A,structParent:_,popupRef:x,richText:k,contentsObj:M,creationDate:D,modificationDate:I},container:L,parent:{page:{pageNumber:O}},canvas:Y}=e;let W,Q;Y?(delete e.canvas,{id:W,bitmap:Q}=i.imageManager.getFromCanvas(L.id,Y),Y.remove()):(a=!0,e._hasNoCanvas=!0);const ft=((S=await s._structTree.getAriaAttributes(`${Bl}${A}`))==null?void 0:S.get("aria-label"))||"";r=e={annotationType:lt.STAMP,bitmapId:W,bitmap:Q,pageIndex:O-1,rect:w.slice(0),rotation:E,annotationElementId:A,id:A,deleted:!1,accessibilityData:{decorative:!1,altText:ft},isSvg:!1,structParent:_,popupRef:x,richText:k,comment:(M==null?void 0:M.str)||null,creationDate:D,modificationDate:I}}const o=await super.deserialize(e,s,i),{rect:l,bitmap:c,bitmapUrl:h,bitmapId:d,isSvg:f,accessibilityData:g}=e;a?(i.addMissingCanvas(e.id,o),p(o,yl,!0)):d&&i.imageManager.isValidId(d)?(p(o,Re,d),c&&p(o,te,c)):p(o,cr,h),p(o,ti,f);const[y,b]=o.pageDimensions;return o.width=(l[2]-l[0])/y,o.height=(l[3]-l[1])/b,g&&(o.altTextData=g),o._initialData=r,e.comment&&o.setCommentData(e),p(o,lh,!!r),o}serialize(e=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i=Object.assign(super.serialize(e),{bitmapId:n(this,Re),isSvg:n(this,ti)});if(this.addComment(i),e)return i.bitmapUrl=v(this,Et,Vf).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;const{decorative:r,altText:a}=this.serializeAltText(!1);if(!r&&a&&(i.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){const l=v(this,Et,S0).call(this,i);return l.isSame?null:(l.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1,i.id=this.annotationElementId,delete i.bitmapId,i)}if(s===null)return i;s.stamps||(s.stamps=new Map);const o=n(this,ti)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(n(this,Re)))s.stamps.set(n(this,Re),{area:o,serialized:i}),i.bitmap=v(this,Et,Vf).call(this,!1);else if(n(this,ti)){const l=s.stamps.get(n(this,Re));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=v(this,Et,Vf).call(this,!1))}return i}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}te=new WeakMap,Re=new WeakMap,ga=new WeakMap,cr=new WeakMap,ma=new WeakMap,oh=new WeakMap,hr=new WeakMap,yl=new WeakMap,yn=new WeakMap,ti=new WeakMap,lh=new WeakMap,Et=new WeakSet,Vh=function(e,s=!1){if(!e){this.remove();return}p(this,te,e.bitmap),s||(p(this,Re,e.id),p(this,ti,e.isSvg)),e.file&&p(this,oh,e.file.name),v(this,Et,Hf).call(this)},Gh=function(){if(p(this,ga,null),this._uiManager.enableWaiting(!1),!!n(this,hr)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,te)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,te)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},Uf=function(){if(n(this,Re)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(n(this,Re)).then(i=>v(this,Et,Vh).call(this,i,!0)).finally(()=>v(this,Et,Gh).call(this));return}if(n(this,cr)){const i=n(this,cr);p(this,cr,null),this._uiManager.enableWaiting(!0),p(this,ga,this._uiManager.imageManager.getFromUrl(i).then(r=>v(this,Et,Vh).call(this,r)).finally(()=>v(this,Et,Gh).call(this)));return}if(n(this,ma)){const i=n(this,ma);p(this,ma,null),this._uiManager.enableWaiting(!0),p(this,ga,this._uiManager.imageManager.getFromFile(i).then(r=>v(this,Et,Vh).call(this,r)).finally(()=>v(this,Et,Gh).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=hg.join(",");const s=this._uiManager._signal;p(this,ga,new Promise(i=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const r=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),v(this,Et,Vh).call(this,r)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>v(this,Et,Gh).call(this))),e.click()},Hf=function(){var c;const{div:e}=this;let{width:s,height:i}=n(this,te);const[r,a]=this.pageDimensions,o=.75;if(this.width)s=this.width*r,i=this.height*a;else if(s>o*r||i>o*a){const h=Math.min(o*r/s,o*a/i);s*=h,i*=h}this._uiManager.enableWaiting(!1);const l=p(this,hr,document.createElement("canvas"));l.setAttribute("role","img"),this.addContainer(l),this.width=s/r,this.height=i/a,this.setDims(),(c=this._initialOptions)!=null&&c.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),v(this,Et,Pm).call(this),n(this,lh)||(this.parent.addUndoableEditor(this),p(this,lh,!0)),this._reportTelemetry({action:"inserted_image"}),n(this,oh)&&this.div.setAttribute("aria-description",n(this,oh)),this.annotationElementId||this._uiManager.a11yAlert(Pt._l10nAlert.stamp)},zf=function(e,s){const{width:i,height:r}=n(this,te);let a=i,o=r,l=n(this,te);for(;a>2*e||o>2*s;){const c=a,h=o;a>2*e&&(a=Math.ceil(a/2)),o>2*s&&(o=Math.ceil(o/2));const d=new OffscreenCanvas(a,o);d.getContext("2d").drawImage(l,0,0,c,h,0,0,a,o),l=d.transferToImageBitmap()}return l},Pm=function(){const[e,s]=this.parentDimensions,{width:i,height:r}=this,a=new En,o=Math.ceil(i*e*a.sx),l=Math.ceil(r*s*a.sy),c=n(this,hr);if(!c||c.width===o&&c.height===l)return;c.width=o,c.height=l;const h=n(this,ti)?n(this,te):v(this,Et,zf).call(this,o,l),d=c.getContext("2d");d.filter=this._uiManager.hcmFilter,d.drawImage(h,0,0,h.width,h.height,0,0,o,l)},Vf=function(e){if(e){if(n(this,ti)){const r=this._uiManager.imageManager.getSvgUrl(n(this,Re));if(r)return r}const s=document.createElement("canvas");return{width:s.width,height:s.height}=n(this,te),s.getContext("2d").drawImage(n(this,te),0,0),s.toDataURL()}if(n(this,ti)){const[s,i]=this.pageDimensions,r=Math.round(this.width*s*ka.PDF_TO_CSS_UNITS),a=Math.round(this.height*i*ka.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(r,a);return o.getContext("2d").drawImage(n(this,te),0,0,n(this,te).width,n(this,te).height,0,0,r,a),o.transferToImageBitmap()}return structuredClone(n(this,te))},S0=function(e){var o;const{pageIndex:s,accessibilityData:{altText:i}}=this._initialData,r=e.pageIndex===s,a=(((o=e.accessibilityData)==null?void 0:o.alt)||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&r&&a,isSameAltText:a}},P(Tm,"_type","stamp"),P(Tm,"_editorType",lt.STAMP);var wl,ch,va,ba,dr,Cs,ya,hh,dh,Gi,ur,Oe,fr,wa,uh,K,Aa,Vt,Im,x0,Yi,Dm,Lm,Gf;const Mi=class Mi{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:c,l10n:h}){m(this,Vt);m(this,wl);m(this,ch,!1);m(this,va,null);m(this,ba,null);m(this,dr,null);m(this,Cs,new Map);m(this,ya,!1);m(this,hh,!1);m(this,dh,!1);m(this,Gi,null);m(this,ur,null);m(this,Oe,null);m(this,fr,null);m(this,wa,null);m(this,uh,-1);m(this,K);const d=[...n(Mi,Aa).values()];if(!Mi._initialized){Mi._initialized=!0;for(const f of d)f.initialize(h,t)}t.registerEditorTypes(d),p(this,K,t),this.pageIndex=e,this.div=s,p(this,wl,r),p(this,va,a),this.viewport=c,p(this,Oe,l),this.drawLayer=o,this._structTree=i,n(this,K).addLayer(this)}get isEmpty(){return n(this,Cs).size===0}get isInvisible(){return this.isEmpty&&n(this,K).getMode()===lt.NONE}updateToolbar(t){n(this,K).updateToolbar(t)}updateMode(t=n(this,K).getMode()){switch(v(this,Vt,Gf).call(this),t){case lt.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case lt.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case lt.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===lt.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const s of n(Mi,Aa).values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=n(this,Oe))==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,va))==null||e.togglePointerEvents(t)}async enable(){var s;p(this,dh,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(s=n(this,wa))==null||s.abort(),p(this,wa,null);const t=new Set;for(const i of n(this,Vt,Im))i.enableEditing(),i.show(!0),i.annotationElementId&&(n(this,K).removeChangedExistingAnnotation(i),t.add(i.annotationElementId));const e=n(this,va);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,dh,!1),n(this,K)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var i;if(p(this,hh,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),n(this,Oe)&&!n(this,wa)){p(this,wa,new AbortController);const r=n(this,K).combinedSignal(n(this,wa));n(this,Oe).div.addEventListener("pointerdown",a=>{const{clientX:l,clientY:c,timeStamp:h}=a,d=n(this,uh);if(h-d>500){p(this,uh,h);return}p(this,uh,-1);const{classList:f}=this.div;f.toggle("getElements",!0);const g=document.elementsFromPoint(l,c);if(f.toggle("getElements",!1),!this.div.contains(g[0]))return;let y;const b=new RegExp(`^${Yh}[0-9]+$`);for(const w of g)if(b.test(w.id)){y=w.id;break}if(!y)return;const S=n(this,Cs).get(y);(S==null?void 0:S.annotationElementId)===null&&(ne(a),S.dblclick(a))},{signal:r,capture:!0})}const t=n(this,va),e=[];if(t){const r=new Map,a=new Map;for(const o of n(this,Vt,Im)){if(o.disableEditing(),!o.annotationElementId){e.push(o);continue}if(o.serialize()!==null){r.set(o.annotationElementId,o);continue}else a.set(o.annotationElementId,o);(i=this.getEditableAnnotation(o.annotationElementId))==null||i.show(),o.remove()}for(const o of t.getEditableAnnotations()){const{id:l}=o.data;if(n(this,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()}}v(this,Vt,Gf).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const r of n(Mi,Aa).values())s.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t==null||t.updateFakeAnnotations(e),p(this,hh,!1)}getEditableAnnotation(t){var e;return((e=n(this,va))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){n(this,K).getActive()!==t&&n(this,K).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=n(this,Oe))!=null&&t.div&&!n(this,fr)){p(this,fr,new AbortController);const e=n(this,K).combinedSignal(n(this,fr));n(this,Oe).div.addEventListener("pointerdown",v(this,Vt,x0).bind(this),{signal:e}),n(this,Oe).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=n(this,Oe))!=null&&t.div&&n(this,fr)&&(n(this,fr).abort(),p(this,fr,null),n(this,Oe).div.classList.remove("highlighting"))}enableClick(){if(n(this,ba))return;p(this,ba,new AbortController);const t=n(this,K).combinedSignal(n(this,ba));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){var t;(t=n(this,ba))==null||t.abort(),p(this,ba,null)}attach(t){n(this,Cs).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,Cs).delete(t.id),(e=n(this,wl))==null||e.removePointerInTextLayer(t.contentDiv),!n(this,hh)&&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),Pt.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),n(this,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,dh)),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,dr)&&(t._focusEventsAllowed=!1,p(this,dr,setTimeout(()=>{p(this,dr,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:n(this,K)._signal}),e.focus())},0))),t._structTreeParentId=(s=n(this,wl))==null?void 0:s.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getEditorByUID(t){for(const e of n(this,Cs).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,Yi))==null?void 0:t.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await n(this,K).updateMode(t.mode);const{offsetX:s,offsetY:i}=v(this,Vt,Lm).call(this),r=n(this,K).getId(),a=v(this,Vt,Dm).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(Mi,Aa).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=v(this,Vt,Dm).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(v(this,Vt,Lm).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}=Ut.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!n(this,ya)||(p(this,ya,!1),(i=n(this,Vt,Yi))!=null&&i.isDrawer&&n(this,Vt,Yi).supportMultipleDrawings))return;if(!n(this,ch)){p(this,ch,!0);return}const s=n(this,K).getMode();if(s===lt.STAMP||s===lt.POPUP||s===lt.SIGNATURE){n(this,K).unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){var i;if(n(this,K).getMode()===lt.HIGHLIGHT&&this.enableTextSelection(),n(this,ya)){p(this,ya,!1);return}const{isMac:e}=Ut.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(p(this,ya,!0),(i=n(this,Vt,Yi))!=null&&i.isDrawer){this.startDrawingSession(t);return}const s=n(this,K).getActive();p(this,ch,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),n(this,Gi)){n(this,Vt,Yi).startDrawing(this,n(this,K),!1,t);return}n(this,K).setCurrentDrawingSession(this),p(this,Gi,new AbortController);const e=n(this,K).combinedSignal(n(this,Gi));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(p(this,ur,null),this.commitOrRemove())},{signal:e}),n(this,Vt,Yi).startDrawing(this,n(this,K),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&p(this,ur,e);return}n(this,ur)&&setTimeout(()=>{var e;(e=n(this,ur))==null||e.focus(),p(this,ur,null)},0)}endDrawingSession(t=!1){return n(this,Gi)?(n(this,K).setCurrentDrawingSession(null),n(this,Gi).abort(),p(this,Gi,null),p(this,ur,null),n(this,Vt,Yi).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,Gi)?(this.endDrawingSession(),!0):!1}onScaleChanging(){n(this,Gi)&&n(this,Vt,Yi).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,dr)&&(clearTimeout(n(this,dr)),p(this,dr,null));for(const s of n(this,Cs).values())(e=n(this,wl))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,n(this,Cs).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(),v(this,Vt,Gf).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,xl(this.div,{rotation:s}),e!==s)for(const i of n(this,Cs).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}};wl=new WeakMap,ch=new WeakMap,va=new WeakMap,ba=new WeakMap,dr=new WeakMap,Cs=new WeakMap,ya=new WeakMap,hh=new WeakMap,dh=new WeakMap,Gi=new WeakMap,ur=new WeakMap,Oe=new WeakMap,fr=new WeakMap,wa=new WeakMap,uh=new WeakMap,K=new WeakMap,Aa=new WeakMap,Vt=new WeakSet,Im=function(){return n(this,Cs).size!==0?n(this,Cs).values():n(this,K).getEditors(this.pageIndex)},x0=function(t){n(this,K).unselectAll();const{target:e}=t;if(e===n(this,Oe).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent")||e.classList.contains("textLayerImages")||e.classList.contains("textLayerImagePlaceholder"))&&n(this,Oe).div.contains(e)){const{isMac:s}=Ut.platform;if(t.button!==0||t.ctrlKey&&s)return;n(this,K).showAllEditors("highlight",!0,!0),n(this,Oe).div.classList.add("free"),this.toggleDrawing(),ep.startHighlighting(this,n(this,K).direction==="ltr",{target:n(this,Oe).div,x:t.x,y:t.y}),n(this,Oe).div.addEventListener("pointerup",()=>{n(this,Oe).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:n(this,K)._signal}),t.preventDefault()}},Yi=function(){return n(Mi,Aa).get(n(this,K).getMode())},Dm=function(t){const e=n(this,Vt,Yi);return e?new e.prototype.constructor(t):null},Lm=function(){const{x:t,y:e,width:s,height:i}=this.boundingClientRect,r=Math.max(0,t),a=Math.max(0,e),o=Math.min(window.innerWidth,t+s),l=Math.min(window.innerHeight,e+i),c=(r+o)/2-t,h=(a+l)/2-e,[d,f]=this.viewport.rotation%180===0?[c,h]:[h,c];return{offsetX:d,offsetY:f}},Gf=function(){for(const t of n(this,Cs).values())t.isEmpty()&&t.remove()},P(Mi,"_initialized",!1),m(Mi,Aa,new Map([dm,Am,Tm,ep,km].map(t=>[t._editorType,t])));let Mm=Mi;function Tx(u,t){return u===t?0:u.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function ef(u){var t;return u?u.nodeType===Node.ELEMENT_NODE?u.closest(".textLayer"):((t=u.parentElement)==null?void 0:t.closest(".textLayer"))||null:null}function Px(u,t,e,s){if(u===e)return t<=s;const i=u.compareDocumentPosition(e);return i&Node.DOCUMENT_POSITION_FOLLOWING?!0:i&Node.DOCUMENT_POSITION_PRECEDING?!1:null}function $v(u,t,e){if(u.nodeType!==Node.ELEMENT_NODE||!u.classList.contains("textLayer")||t!==u.childNodes.length)return{container:u,offset:t};let s=u.lastChild;return(s==null?void 0:s.nodeType)===Node.ELEMENT_NODE&&s.classList.contains("endOfContent")&&(s=s.previousSibling),!s||!e.contains(s)?null:s.nodeType===Node.TEXT_NODE?{container:s,offset:s.textContent.length}:{container:s,offset:s.childNodes.length}}var _s,us,Si,Fu,Ru,Al,Sl,Ou,kp,Sa,xa,Ea,Ca,pr,ns,Rm,Om,E0,jf,C0,_n,Nm,_0,Bm;const st=class st{constructor({filterFactory:t=null,pageColors:e=null,pageIndex:s,textLayer:i=null}){m(this,_n);m(this,_s,null);m(this,us,new Map);m(this,Si,null);m(this,Fu,null);m(this,Ru,null);m(this,Al,null);m(this,Sl,new Map);if(this.pageIndex=s,p(this,Fu,t),p(this,Ru,e),i){const r=n(st,pr).get(i);if(r!=null&&r.selectionDiv&&(r.selectionDiv.remove(),n(st,xa).delete(r.selectionDiv)),n(st,pr).set(i,{drawLayer:this}),n(st,Ca).add(i),p(this,Si,i),p(this,Al,new MutationObserver(a=>{var o,l,c;if(!(!n(this,_s)||!((o=n(this,Si))!=null&&o.isConnected)||!v(l=st,ns,Om).call(l))){for(const{addedNodes:h}of a)for(const d of h)if(d.nodeType===Node.ELEMENT_NODE&&d.classList.contains("endOfContent")){v(c=st,ns,jf).call(c);return}}})),n(this,Al).observe(i,{childList:!0}),n(st,Sa)===null){p(st,Sa,new AbortController);const{signal:a}=n(st,Sa);document.addEventListener("selectionchange",v(st,ns,jf).bind(st),{signal:a}),document.addEventListener("pointerdown",()=>{p(st,Ea,!0)},{signal:a}),document.addEventListener("pointerup",()=>{p(st,Ea,!1)},{signal:a}),window.addEventListener("blur",()=>{p(st,Ea,!1)},{signal:a})}}}setParent(t){var e,s,i;if(!n(this,_s)){p(this,_s,t),(e=n(this,Si))!=null&&e.isConnected&&v(s=st,ns,Om).call(s)&&v(i=st,ns,jf).call(i);return}if(n(this,_s)!==t){if(n(this,us).size>0)for(const r of n(this,us).values())r.remove(),t.append(r);p(this,_s,t)}}static get _svgFactory(){return at(this,"_svgFactory",new Zf)}draw(t,e=!1,s=!1){const i=Yt(st,Ou)._++,r=v(this,_n,Nm).call(this),a=st._svgFactory.createElement("defs");r.append(a);const o=st._svgFactory.createElement("path");a.append(o);const l=`path_${i}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),e&&n(this,Sl).set(i,o);const c=s?v(this,_n,_0).call(this,a,l):null,h=st._svgFactory.createElement("use");return r.append(h),h.setAttribute("href",`#${l}`),this.updateProperties(r,t),n(this,us).set(i,r),{id:i,clipPathId:`url(#${c})`}}drawOutline(t,e){const s=Yt(st,Ou)._++,i=v(this,_n,Nm).call(this),r=st._svgFactory.createElement("defs");i.append(r);const a=st._svgFactory.createElement("path");r.append(a);const o=`path_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke");let l;if(e){const d=st._svgFactory.createElement("mask");r.append(d),l=`mask_${s}`,d.setAttribute("id",l),d.setAttribute("maskUnits","objectBoundingBox");const f=st._svgFactory.createElement("rect");d.append(f),f.setAttribute("width","1"),f.setAttribute("height","1"),f.setAttribute("fill","white");const g=st._svgFactory.createElement("use");d.append(g),g.setAttribute("href",`#${o}`),g.setAttribute("stroke","none"),g.setAttribute("fill","black"),g.setAttribute("fill-rule","nonzero"),g.classList.add("mask")}const c=st._svgFactory.createElement("use");i.append(c),c.setAttribute("href",`#${o}`),l&&c.setAttribute("mask",`url(#${l})`);const h=c.cloneNode();return i.append(h),c.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(i,t),n(this,us).set(s,i),s}finalizeDraw(t,e){n(this,Sl).delete(t),this.updateProperties(t,e)}updateProperties(t,e){var l;if(!e)return;const{root:s,bbox:i,rootClass:r,path:a}=e,o=typeof t=="number"?n(this,us).get(t):t;if(o){if(s&&v(this,_n,Bm).call(this,o,s),i&&v(l=st,ns,C0).call(l,o,i),r){const{classList:c}=o;for(const[h,d]of Object.entries(r))c.toggle(h,d)}if(a){const h=o.firstElementChild.firstElementChild;v(this,_n,Bm).call(this,h,a)}}}updateParent(t,e){if(e===this)return;const s=n(this,us).get(t);s&&(n(e,_s).append(s),n(this,us).delete(t),n(e,us).set(t,s))}remove(t){n(this,Sl).delete(t),n(this,_s)!==null&&(n(this,us).get(t).remove(),n(this,us).delete(t))}destroy(){var t,e,s;p(this,_s,null);for(const i of n(this,us).values())i.remove();if(n(this,us).clear(),n(this,Sl).clear(),(t=n(this,Al))==null||t.disconnect(),p(this,Al,null),n(this,Si)){const i=n(st,pr).get(n(this,Si));(i==null?void 0:i.drawLayer)===this&&(v(e=st,ns,Rm).call(e,n(this,Si)),n(st,pr).delete(n(this,Si)),n(st,Ca).delete(n(this,Si)),n(st,Ca).size===0&&((s=n(st,Sa))==null||s.abort(),p(st,Sa,null),p(st,Ea,!1))),p(this,Si,null)}}};_s=new WeakMap,us=new WeakMap,Si=new WeakMap,Fu=new WeakMap,Ru=new WeakMap,Al=new WeakMap,Sl=new WeakMap,Ou=new WeakMap,kp=new WeakMap,Sa=new WeakMap,xa=new WeakMap,Ea=new WeakMap,Ca=new WeakMap,pr=new WeakMap,ns=new WeakSet,Rm=function(t){const e=n(this,pr).get(t);e!=null&&e.selectionDiv&&(e.selectionDiv.remove(),n(this,xa).delete(e.selectionDiv),e.selectionDiv=null,e.path=null)},Om=function(){const t=document.getSelection();return!!t&&!t.isCollapsed},E0=function(){return[...n(this,Ca)].filter(t=>t.isConnected).sort(Tx)},jf=function(){var a;const t=document.getSelection();if(!t||t.isCollapsed){for(const o of n(this,xa))o.remove();n(this,xa).clear();return}const e=new WeakMap,s=v(this,ns,E0).call(this),i=[];for(let o=0,l=t.rangeCount;oc.intersectsNode(_));if(E.length===0)continue;let A=!1;if(y||(y=E[0],h=y,d=0,A=!0),b||(b=E.at(-1),f=b,g=b.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 _=$v(f,g,b);if(!_)continue;f=_.container,g=_.offset}}if(h.nodeType===Node.ELEMENT_NODE){const _=$v(h,d,y);if(!_)continue;h=_.container,d=_.offset}if(y===b&&!A&&E.includes(y)){i.push([c,y]);continue}for(const _ of E){const x=_.firstChild;if(!x)continue;const k=document.createRange();if(_===y?k.setStart(h,d):k.setStartBefore(x),_===b)k.setEnd(f,g);else{const M=_.lastChild;if(!M)continue;if(M.nodeType===Node.ELEMENT_NODE&&M.classList.contains("endOfContent")){const D=M.previousSibling;if(!D)continue;k.setEndAfter(D)}else k.setEndAfter(M)}k.collapsed||i.push([k,_])}}const r=new Set(i.map(o=>o[1]));for(const o of n(this,Ca))r.has(o)||v(this,ns,Rm).call(this,o);for(const[o,l]of i){const c=n(st,pr).get(l);if(!c)continue;let h=e.get(l);if(!h){const b=l.getBoundingClientRect();h=(S,w,E,A)=>({x:(S-b.x)/b.width,y:(w-b.y)/b.height,width:E/b.width,height:A/b.height}),e.set(l,h)}const d=[];for(let{x:b,y:S,width:w,height:E}of o.getClientRects())w===0||E===0||({x:b,y:S,width:w,height:E}=h(b,S,w,E),!(w===1&&E===1)&&d.push(`M${b} ${S} h${w} v${E} h-${w} Z`));if(d.length===0)continue;const f=c.drawLayer;let g=c.selectionDiv,y=c.path;if(!g){const b=`clip_selection_${Yt(st,kp)._++}`;g=document.createElement("div"),g.className="selection",g.style.clipPath=`url(#${b})`;const S=(a=n(f,Fu))==null?void 0:a.createSelectionStyle(n(f,Ru));if(S)for(const[A,_]of Object.entries(S))g.style.setProperty(A,_);const w=st._svgFactory.create(1,1,!0);w.setAttribute("aria-hidden","true"),w.setAttribute("width","100%"),w.setAttribute("height","100%");const E=st._svgFactory.createElement("clipPath");E.setAttribute("id",b),E.setAttribute("clipPathUnits","objectBoundingBox"),y=st._svgFactory.createElement("path"),E.append(y),w.append(E),g.append(w),c.path=y,c.selectionDiv=g}!g.parentNode&&n(f,_s)&&(n(f,_s).append(g),n(this,xa).add(g)),y.setAttribute("d",d.join(" "))}},C0=function(t,[e,s,i,r]){const{style:a}=t;a.top=`${100*s}%`,a.left=`${100*e}%`,a.width=`${100*i}%`,a.height=`${100*r}%`},_n=new WeakSet,Nm=function(){const t=st._svgFactory.create(1,1,!0);return n(this,_s).append(t),t.setAttribute("aria-hidden","true"),t},_0=function(t,e){const s=st._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const r=st._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),i},Bm=function(t,e){for(const[s,i]of Object.entries(e))i===null?t.removeAttribute(s):t.setAttribute(s,i)},m(st,ns),m(st,Ou,0),m(st,kp,0),m(st,Sa,null),m(st,xa,new Set),m(st,Ea,!1),m(st,Ca,new Set),m(st,pr,new WeakMap);let Fm=st;function sf(u){return`${(u*100).toFixed(2)}%`}var fh,Nu,Bu,ph,wn,An,$u,Tp,k0;const qh=class qh{constructor(t,e,s,i){m(this,Tp);m(this,fh,[]);m(this,Nu,new Map);m(this,Bu,null);m(this,ph,0);m(this,wn,0);m(this,An,0);p(this,ph,t),p(this,fh,e),p(this,wn,s.rawDims.pageWidth),p(this,An,s.rawDims.pageHeight),p(this,Bu,i)}render(){const t=document.createElement("div");t.className="textLayerImages";for(let e=0;e{var w;if(!(e.target instanceof HTMLCanvasElement))return;const s=e.target,i=n(this,Nu).get(s);if(!i)return;const r=(w=n(qh,$u))==null?void 0:w.deref();if(r===s)return;r&&(r.width=0,r.height=0),p(qh,$u,new WeakRef(s));const{inverseTransform:a,x1:o,y1:l,width:c,height:h}=i,d=n(this,Bu).call(this),f=Math.ceil(o*d.width),g=Math.ceil(l*d.height),y=Math.floor((o+c/n(this,wn))*d.width),b=Math.floor((l+h/n(this,An))*d.height);s.width=y-f,s.height=b-g;const S=s.getContext("2d");S.setTransform(...a),S.translate(-f,-g),S.drawImage(d,0,0)}),t}};fh=new WeakMap,Nu=new WeakMap,Bu=new WeakMap,ph=new WeakMap,wn=new WeakMap,An=new WeakMap,$u=new WeakMap,Tp=new WeakSet,k0=function([t,e,s,i,r,a]){const o=Math.hypot((r-t)*n(this,wn),(a-e)*n(this,An)),l=Math.hypot((s-t)*n(this,wn),(i-e)*n(this,An));if(ot.taskId!=null&&t.sourceFileId!=null?gw(t.taskId,t.sourceFileId):""),D=ct(()=>({"--total-scale-factor":String(d.value)})),I=ct(()=>b.value==="highlighted"?`切片原文已在第 ${l.value} 页高亮`:b.value==="unmatched"?`已定位第 ${l.value} 页,未匹配到可高亮文字`:b.value==="manual"?"手动新增切片没有原文位置":c.value?`第 ${l.value} / ${c.value} 页`:"正在读取 PDF");function L(H){var $;if(!H)return null;if(H.sourceStart==null||H.sourceEnd==null){const ht=($=H.sourcePages)==null?void 0:$[0];return ht==null?null:o.value.find(ot=>ot.page_number===ht)??null}return o.value.find(ht=>H.sourceStart>=ht.source_start&&H.sourceStartH.sourceStartht.source_start)??null}function O(H){var ms;const $=t.selectedItem;if(!$)return"";if($.sourceStart==null||$.sourceEnd==null)return(ms=$.sourcePages)!=null&&ms.includes(H.page_number)?$.originalContent:"";const ht=Math.max($.sourceStart,H.source_start),ot=Math.min($.sourceEnd,H.source_end);if(ot<=ht)return"";const Z=Math.max(0,ht-$.sourceStart),jt=Math.max(Z,ot-$.sourceStart);return $.originalContent.slice(Z,jt)}function Y(H){return H.normalize("NFKC").replace(/[^\p{L}\p{N}]+/gu,"").toLocaleLowerCase()}function W(H,$,ht){let ot=-1,Z=Number.POSITIVE_INFINITY,jt=H.indexOf($);for(;jt>=0;){const ms=Math.abs(jt-ht);msMath.min(Ms,jt.length)).filter((Ms,Ne,Is)=>Ms>=4&&Is.indexOf(Ms)===Ne);for(const Ms of Sr){const Ne=jt.slice(0,Ms),Is=W(Z,Ne,Se);if(Is<0)continue;const kn=Is+Ne.length;return ot.reduce((Ma,Ml,Il)=>(Ml.end>Is&&Ml.start{if(!(Ts!==_||Ia instanceof Error&&Ia.name==="RenderingCancelledException"))throw Ia}),Il=Se.streamTextContent();if(Ts!==_)return;const bh=new gh({textContentSource:Il,container:Z,viewport:Ne});if(E=bh,await Promise.all([Ml,bh.render()]),Ts!==_)return;x=l.value,ft(ms),await Wf(),(Ps=ht.querySelector(".is-slice-highlighted"))==null||Ps.scrollIntoView({block:"center",inline:"center",behavior:"smooth"})}catch(Se){if(Ts!==_)return;y.value=Se instanceof Error?Se.message:"PDF 页面渲染失败"}finally{Ts===_&&(g.value=!1)}}async function q(){var ht;if(!a.value)return;const H=t.selectedItem;if(!H||(H.sourceStart==null||H.sourceEnd==null)&&!((ht=H.sourcePages)!=null&&ht.length)){ft(null);return}const $=L(H);if(!$){b.value="unmatched";return}if(l.value!==$.page_number){l.value=$.page_number,await T(!0);return}await T(!1)}async function Lt(){const H=++A;if(++_,x=0,w==null||w.cancel(),E==null||E.cancel(),await(S==null?void 0:S.destroy()),S=null,a.value=null,o.value=[],c.value=0,l.value=1,y.value="",b.value="idle",!(!M.value||t.taskId==null||t.sourceFileId==null)){f.value=!0;try{const $=Sy({url:M.value});S=$;const[ht,ot]=await Promise.all([mw(t.taskId,t.sourceFileId),$.promise]);if(H!==A){await $.destroy();return}a.value=ot,o.value=ht.pages,c.value=ot.numPages,await Wf(),await q(),t.selectedItem||await T(!0)}catch($){if(H!==A)return;y.value=$ instanceof Error?$.message:"PDF 原文件加载失败"}finally{H===A&&(f.value=!1)}}}async function bt(H){const $=Math.min(c.value,Math.max(1,l.value+H));$!==l.value&&(l.value=$,await T(!0))}async function _e(H){const $=Math.min(2,Math.max(.6,Number((h.value+H).toFixed(1))));$!==h.value&&(h.value=$,await T(!0))}function ae(){window.cancelAnimationFrame(k),k=window.requestAnimationFrame(()=>{a.value&&T(!0)})}const Gt=new ResizeObserver(ae);return Ei(e,(H,$)=>{$&&Gt.unobserve($),H&&Gt.observe(H)}),Ei(M,()=>void Lt(),{immediate:!0}),Ei(()=>{var H;return(H=t.selectedItem)==null?void 0:H.id},()=>void q()),jv(()=>{++A,++_,window.cancelAnimationFrame(k),Gt.disconnect(),w==null||w.cancel(),E==null||E.cancel(),S==null||S.destroy()}),(H,$)=>(R(),U("div",Ix,[M.value?(R(),U("div",Dx,[C("div",Lx,[C("button",{type:"button","aria-label":"上一页",disabled:l.value<=1||f.value,onClick:$[0]||($[0]=ht=>bt(-1))},[...$[4]||($[4]=[C("i",{class:"fa fa-chevron-left","aria-hidden":"true"},null,-1)])],8,Fx),C("span",Rx,j(l.value)+" / "+j(c.value||"—"),1),C("button",{type:"button","aria-label":"下一页",disabled:l.value>=c.value||f.value,onClick:$[1]||($[1]=ht=>bt(1))},[...$[5]||($[5]=[C("i",{class:"fa fa-chevron-right","aria-hidden":"true"},null,-1)])],8,Ox)]),C("span",{class:we(["location-state",`is-${b.value}`]),role:"status"},[b.value==="highlighted"?(R(),U("i",Nx)):ut("",!0),pt(" "+j(I.value),1)],2),C("div",Bx,[C("button",{type:"button","aria-label":"缩小",disabled:h.value<=.6||f.value,onClick:$[2]||($[2]=ht=>_e(-.1))},"−",8,$x),C("span",Ux,j(Math.round(h.value*100))+"%",1),C("button",{type:"button","aria-label":"放大",disabled:h.value>=2||f.value,onClick:$[3]||($[3]=ht=>_e(.1))},"+",8,Hx)])])):ut("",!0),M.value?(R(),U("div",{key:1,ref_key:"scrollRef",ref:e,class:"pdf-scroll",tabindex:"0","aria-label":`PDF 预览:${u.fileName}`},[C("div",{ref_key:"pageRef",ref:s,class:"pdf-page",style:iw(D.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,Vx),f.value||g.value?(R(),U("div",Gx,[$[6]||($[6]=C("i",{class:"fa fa-spinner fa-spin","aria-hidden":"true"},null,-1)),pt(" "+j(f.value?"正在加载 PDF…":"正在渲染页面…"),1)])):ut("",!0),y.value?(R(),U("div",jx,[$[7]||($[7]=C("i",{class:"fa fa-exclamation-circle","aria-hidden":"true"},null,-1)),$[8]||($[8]=C("strong",null,"PDF 预览失败",-1)),C("span",null,j(y.value),1),C("a",{href:M.value,target:"_blank",rel:"noopener noreferrer"},"在新窗口打开原件",8,Wx)])):ut("",!0)],8,zx)):(R(),U("div",Xx,[...$[9]||($[9]=[C("i",{class:"fa fa-file-pdf-o","aria-hidden":"true"},null,-1),C("strong",null,"PDF 原文件暂不可预览",-1),C("span",null,"请重新上传该文件后再试。",-1)])]))]))}}),Yx=Ti(qx,[["__scopeId","data-v-b5c8430d"]]),Kx=["问:如何看待当前的通货膨胀风险?","答:当前通胀水平总体可控,但仍需关注能源价格与供给扰动。","问:美联储下一次议息会议何时召开?","答:会议时间以美联储官方日历为准,市场会重点关注利率路径指引。","问:人民币汇率未来走势如何?","答:人民币汇率取决于中美利差、经济基本面与政策预期。","问:什么是复利?","答:复利是将上一期利息加入本金,再计算下一期利息。"].join(` `);function Qx(u){const t=u.split(` `);let e=0;return t.map((s,i)=>{const r=e,a=r+s.length;return e=a+(iQx(e.sourceText)),h=ct(()=>e.items.find(I=>I.id===e.selectedId)??e.items[0]),d=ct(()=>e.items.find(I=>I.id===o.value)),f=ct(()=>/\.pdf$/i.test(e.fileName)),g=ct(()=>e.items.filter((I,L)=>!r.value.trim()||I.editedContent.toLowerCase().includes(r.value.trim().toLowerCase())||String(L+1).includes(r.value.trim()))),y=ct(()=>{const I=(a.value-1)*Sh;return g.value.slice(I,I+Sh)});function b(I,L){const O=h.value;return!O||O.sourceStart==null||O.sourceEnd==null?!1:L>=O.sourceStart&&I<=O.sourceEnd}function S(I){s("update:selectedId",I)}function w(I){S(I.id),o.value=I.id,l.value=I.editedContent}function E(){o.value=null,l.value=""}function A(){d.value&&(s("update:item-content",d.value.id,l.value),E())}function _(){d.value&&(s("restore:item",d.value.id),E())}function x(I){S(I.id),s("remove:item",I.id)}function k(){E()}Ei(r,()=>{a.value=1,E()}),Ei(()=>e.selectedFileId,E),Ei(h,async I=>{var Y,W;if(!I)return;const L=g.value.findIndex(Q=>Q.id===I.id);if(L>=0&&(a.value=Math.floor(L/Sh)+1),f.value||I.sourceStart==null)return;await Wf();const O=((Y=i.value)==null?void 0:Y.querySelector(`[data-source-start="${I.sourceStart}"]`))??((W=i.value)==null?void 0:W.querySelector(".source-line.is-highlighted"));O==null||O.scrollIntoView({block:"center",behavior:"smooth"})},{immediate:!0});function M(I){return e.items.findIndex(L=>L.id===I.id)+1}function D(I){var L;if((L=I.sourcePages)!=null&&L.length){const O=I.sourcePages[0],Y=I.sourcePages[I.sourcePages.length-1];return O===Y?`来源:第 ${O} 页`:`来源:第 ${O}–${Y} 页`}return I.sourceStartLine==null||I.sourceEndLine==null?"手动新增,无源文件定位":I.sourceStartLine===I.sourceEndLine?`来源:第 ${I.sourceStartLine} 行`:`来源:第 ${I.sourceStartLine}–${I.sourceEndLine} 行`}return(I,L)=>{const O=Ip,Y=Mp,W=Uu,Q=Hu,ft=Yv;return R(),U("section",Jx,[C("div",Zx,[C("div",tE,[L[5]||(L[5]=C("span",null,"当前文件",-1)),z(Y,{"model-value":u.selectedFileId,filterable:"",placeholder:"选择文件","aria-label":"选择当前预览文件","onUpdate:modelValue":L[0]||(L[0]=T=>s("update:selectedFileId",T))},{default:et(()=>[(R(!0),U(ye,null,ri(u.files,T=>(R(),$t(O,{key:T.id,label:T.name,value:T.id},{default:et(()=>[C("div",eE,[C("strong",{title:T.name},j(T.name),9,sE),C("span",null,j(T.count.toLocaleString())+" "+j(u.processType==="unstructured"?"个切片":"条记录"),1),T.modifiedCount?(R(),U("em",iE,j(T.modifiedCount)+" 处已修改",1)):ut("",!0)])]),_:2},1032,["label","value"]))),128))]),_:1},8,["model-value"])]),C("span",nE,j(u.files.length)+" 个文件 · 当前文件 "+j(u.items.length.toLocaleString())+" "+j(u.processType==="unstructured"?"个切片":"条记录"),1)]),C("div",rE,[C("div",aE,[C("div",oE,[C("div",null,[C("strong",null,"源文件 · "+j(u.fileName),1)])]),f.value?(R(),$t(Yx,{key:0,"task-id":u.taskId,"source-file-id":u.sourceFileId,"file-name":u.fileName,"selected-item":h.value??null},null,8,["task-id","source-file-id","file-name","selected-item"])):(R(),U("div",{key:1,ref_key:"sourceViewerRef",ref:i,class:"source-viewer",tabindex:"0","aria-label":"源文件内容"},[(R(!0),U(ye,null,ri(c.value,T=>(R(),U("div",{key:T.number,class:we(["source-line",{"is-highlighted":b(T.start,T.end)}]),"data-source-start":T.start},[C("span",cE,j(T.number),1),C("span",hE,j(T.content||" "),1)],10,lE))),128))],512))]),C("div",dE,[C("div",uE,[C("strong",null,j(u.processType==="unstructured"?"切片内容":"记录内容"),1),C("div",fE,[C("span",null,"共 "+j(u.items.length.toLocaleString())+" 条",1),z(W,{link:"",type:"primary",onClick:L[1]||(L[1]=T=>s("add:item"))},{default:et(()=>[...L[6]||(L[6]=[C("i",{class:"fa fa-plus"},null,-1),pt(" 手动新增 ",-1)])]),_:1})])]),d.value?(R(),U("div",AE,[C("div",SE,[C("div",null,[C("strong",null,j(u.processType==="unstructured"?"切片":"记录")+" #"+j(String(M(d.value)).padStart(3,"0"))+" 正文",1),C("small",null,j(D(d.value)),1)])]),z(Q,{modelValue:l.value,"onUpdate:modelValue":L[4]||(L[4]=T=>l.value=T),type:"textarea",rows:7,resize:"none"},null,8,["modelValue"]),C("div",xE,[d.value.sourceStart!=null?(R(),$t(W,{key:0,link:"",onClick:_},{default:et(()=>[...L[10]||(L[10]=[C("i",{class:"fa fa-undo"},null,-1),pt(" 恢复原始内容 ",-1)])]),_:1})):ut("",!0),C("div",null,[z(W,{onClick:E},{default:et(()=>[...L[11]||(L[11]=[pt("取消",-1)])]),_:1}),z(W,{type:"primary",onClick:A},{default:et(()=>[...L[12]||(L[12]=[pt("保存修改",-1)])]),_:1})])])])):(R(),U(ye,{key:0},[C("div",pE,[z(Q,{modelValue:r.value,"onUpdate:modelValue":L[2]||(L[2]=T=>r.value=T),clearable:"",placeholder:"搜索编号或内容",size:"small"},{prefix:et(()=>[...L[7]||(L[7]=[C("i",{class:"fa fa-search"},null,-1)])]),_:1},8,["modelValue"])]),C("div",gE,[(R(!0),U(ye,null,ri(y.value,T=>{var q,Lt;return R(),U("div",{key:T.id,class:we(["preview-item",{"is-active":T.id===((q=h.value)==null?void 0:q.id)}]),"data-preview-id":T.id,"aria-selected":T.id===((Lt=h.value)==null?void 0:Lt.id),role:"button",tabindex:"0",onClick:bt=>S(T.id),onKeydown:[cv(bt=>S(T.id),["enter"]),cv(Xp(bt=>S(T.id),["prevent"]),["space"])]},[C("span",vE,j(u.processType==="unstructured"?"切片":"记录")+" #"+j(String(M(T)).padStart(3,"0")),1),C("span",bE,j(D(T)),1),C("span",yE,[z(W,{link:"","aria-label":"编辑切片",title:"编辑",onClick:Xp(bt=>w(T),["stop"])},{default:et(()=>[...L[8]||(L[8]=[C("i",{class:"fa fa-pencil"},null,-1)])]),_:1},8,["onClick"]),z(W,{link:"",type:"danger","aria-label":"删除切片",title:"删除",onClick:Xp(bt=>x(T),["stop"])},{default:et(()=>[...L[9]||(L[9]=[C("i",{class:"fa fa-trash-o"},null,-1)])]),_:1},8,["onClick"])])],42,mE)}),128)),g.value.length?ut("",!0):(R(),U("div",wE,"没有符合条件的内容"))]),g.value.length>Sh?(R(),$t(ft,{key:0,"current-page":a.value,"onUpdate:currentPage":L[3]||(L[3]=T=>a.value=T),"page-size":Sh,total:g.value.length,"pager-count":5,small:"",background:"",layout:"prev, pager, next",class:"preview-pagination",onCurrentChange:k},null,8,["current-page","total"])):ut("",!0)],64))])])])}}}),CE=Ti(EE,[["__scopeId","data-v-13041697"]]),_E={class:"generation-step"},kE={class:"generation-layout"},TE={class:"summary-panel"},PE={class:"run-icon"},ME={key:0,class:"fa fa-check"},IE={key:1,class:"fa fa-exclamation"},DE={key:2,class:"fa fa-cog fa-spin"},LE={key:3,class:"fa fa-play"},FE=ki({__name:"GenerationStep",props:{taskName:{},processType:{},fileName:{},previewCount:{},modifiedCount:{},generation:{}},emits:["stop","retry"],setup(u,{emit:t}){const e=t;return(s,i)=>{const r=Kv,a=Uu;return R(),U("section",_E,[C("div",kE,[C("div",TE,[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,j(u.taskName),1)]),C("div",null,[i[3]||(i[3]=C("dt",null,"数据类型",-1)),C("dd",null,j(u.processType==="unstructured"?"非结构化数据":u.processType==="external"?"外来数据源拉取":"结构化数据"),1)]),C("div",null,[i[4]||(i[4]=C("dt",null,"源文件",-1)),C("dd",null,j(u.fileName),1)]),C("div",null,[i[5]||(i[5]=C("dt",null,"预览条目",-1)),C("dd",null,j(u.previewCount.toLocaleString())+" 条",1)]),C("div",null,[i[6]||(i[6]=C("dt",null,"已修改",-1)),C("dd",null,j(u.modifiedCount.toLocaleString())+" 条",1)])])]),C("div",{class:we(["run-panel",`is-${u.generation.status}`])},[C("div",PE,[u.generation.status==="success"?(R(),U("i",ME)):u.generation.status==="failed"?(R(),U("i",IE)):u.generation.status==="running"?(R(),U("i",DE)):(R(),U("i",LE))]),C("h3",null,j(u.generation.status==="idle"?"准备开始处理":u.generation.status==="running"?"正在生成数据":u.generation.status==="success"?"数据生成完成":"生成已停止"),1),C("p",null,j(u.generation.message),1),u.generation.status!=="idle"?(R(),$t(r,{key:0,percentage:u.generation.progress,"stroke-width":10,status:u.generation.status==="success"?"success":void 0},null,8,["percentage","status"])):ut("",!0),i[10]||(i[10]=C("div",{class:"run-meta"},[C("span",null,"解析源数据"),C("span",null,"应用预览修改"),C("span",null,"生成标准结果")],-1)),u.generation.status==="running"?(R(),$t(a,{key:1,plain:"",type:"warning",onClick:i[0]||(i[0]=o=>e("stop"))},{default:et(()=>[...i[8]||(i[8]=[pt(" 停止生成 ",-1)])]),_:1})):ut("",!0),u.generation.status==="failed"?(R(),$t(a,{key:2,plain:"",type:"primary",onClick:i[1]||(i[1]=o=>e("retry"))},{default:et(()=>[...i[9]||(i[9]=[pt(" 重新生成 ",-1)])]),_:1})):ut("",!0)],2)])])}}}),RE=Ti(FE,[["__scopeId","data-v-94e8b875"]]),OE={class:"result-step"},NE={class:"result-workspace"},BE={class:"result-list-pane"},$E={class:"pane-header"},UE={class:"result-toolbar"},HE={class:"result-list"},zE=["onClick"],VE={class:"result-index"},GE={class:"result-copy"},jE={key:0,class:"result-editor-pane"},WE={class:"pane-header"},XE={key:0,class:"modified-label"},qE={class:"source-reference","aria-labelledby":"source-reference-title"},YE={class:"source-reference-heading"},KE={key:0},QE={key:0},JE={key:1},ZE={key:2},tC={class:"field-editor"},eC={class:"field-editor"},sC={class:"field-editor"},iC={key:0,class:"validation-error"},nC={key:1,class:"validation-success"},rC={key:2,class:"quality-flags"},aC={class:"editor-pagination"},oC=ki({__name:"ResultEditorStep",props:{items:{},previewItems:{},selectedId:{}},emits:["update:selectedId","update:field","restore:item"],setup(u,{emit:t}){const e=u,s=t,i=rt(""),r=rt(!1),a=ct(()=>e.items.find(y=>y.id===e.selectedId)??e.items[0]),o=ct(()=>e.items.findIndex(y=>{var b;return y.id===((b=a.value)==null?void 0:b.id)})),l=ct(()=>{var b;const y=(b=a.value)==null?void 0:b.previewItemId;return y?e.previewItems.find(S=>S.id===y)??null:null}),c=ct(()=>{var y,b;return((y=l.value)==null?void 0:y.editedContent.trim())||((b=l.value)==null?void 0:b.originalContent.trim())||""}),h=ct(()=>!!(l.value&&l.value.editedContent.trim()&&l.value.editedContent!==l.value.originalContent)),d=ct(()=>{const y=l.value;if(!y)return"";const b=[];return y.sourceStartLine!=null&&b.push(y.sourceEndLine!=null&&y.sourceEndLine!==y.sourceStartLine?`第 ${y.sourceStartLine}–${y.sourceEndLine} 行`:`第 ${y.sourceStartLine} 行`),y.tokenCount>0&&b.push(`${y.tokenCount} Token`),b.join(" · ")}),f=ct(()=>e.items.filter((y,b)=>{const S=i.value.trim().toLowerCase();return(!S||y.instruction.toLowerCase().includes(S)||y.output.toLowerCase().includes(S)||String(b+1).includes(S))&&(!r.value||y.status==="invalid")}));function g(y){if(!e.items.length)return;const b=Math.min(Math.max(o.value+y,0),e.items.length-1);s("update:selectedId",e.items[b].id)}return(y,b)=>{var _;const S=Hu,w=Pp,E=fw,A=Uu;return R(),U("section",OE,[C("div",NE,[C("aside",BE,[C("div",$E,[b[8]||(b[8]=C("strong",null,"生成结果",-1)),C("span",null,"共 "+j(u.items.length)+" 条",1)]),C("div",UE,[z(S,{modelValue:i.value,"onUpdate:modelValue":b[0]||(b[0]=x=>i.value=x),clearable:"",size:"small",placeholder:"搜索结果"},{prefix:et(()=>[...b[9]||(b[9]=[C("i",{class:"fa fa-search"},null,-1)])]),_:1},8,["modelValue"]),z(w,{modelValue:r.value,"onUpdate:modelValue":b[1]||(b[1]=x=>r.value=x)},{default:et(()=>[...b[10]||(b[10]=[pt("仅看错误",-1)])]),_:1},8,["modelValue"])]),C("div",HE,[(R(!0),U(ye,null,ri(f.value,x=>{var k;return R(),U("button",{key:x.id,type:"button",class:we(["result-item",{"is-active":x.id===((k=a.value)==null?void 0:k.id)}]),onClick:M=>s("update:selectedId",x.id)},[C("span",VE,"#"+j(String(u.items.findIndex(M=>M.id===x.id)+1).padStart(3,"0")),1),C("span",GE,[C("strong",null,j(x.instruction||"未填写指令"),1),C("small",null,j(x.output||"未填写输出"),1)]),C("i",{class:we(["fa",x.status==="invalid"?"fa-exclamation-circle is-error":"fa-check-circle is-valid"])},null,2)],10,zE)}),128))])]),a.value?(R(),U("div",jE,[C("div",WE,[C("div",null,[C("strong",null,"结果 #"+j(String(o.value+1).padStart(3,"0")),1),a.value.status==="modified"?(R(),U("span",XE,"已修改")):ut("",!0),a.value.split?(R(),$t(E,{key:1,size:"small",effect:"plain"},{default:et(()=>[pt(j(a.value.split),1)]),_:1})):ut("",!0),a.value.qualityScore!=null?(R(),$t(E,{key:2,size:"small",type:a.value.qualityScore>=80?"success":a.value.qualityScore>=60?"warning":"danger"},{default:et(()=>[pt("质量 "+j(a.value.qualityScore.toFixed(1)),1)]),_:1},8,["type"])):ut("",!0)]),z(A,{link:"",onClick:b[2]||(b[2]=x=>s("restore:item",a.value.id))},{default:et(()=>[...b[11]||(b[11]=[C("i",{class:"fa fa-undo"},null,-1),pt(" 恢复生成结果",-1)])]),_:1})]),C("article",qE,[C("div",YE,[C("div",null,[b[12]||(b[12]=C("strong",{id:"source-reference-title"},"原文参照",-1)),d.value?(R(),U("span",KE,j(d.value),1)):ut("",!0)]),h.value?(R(),$t(E,{key:0,size:"small",effect:"plain"},{default:et(()=>[...b[13]||(b[13]=[pt("已智能预处理",-1)])]),_:1})):ut("",!0)]),c.value?(R(),U("pre",QE,j(c.value),1)):(R(),U("p",JE,"当前结果没有关联到可用的原文切片。")),h.value?(R(),U("small",ZE,"这里展示的是实际送入模型的预处理后原文,便于核对问题和答案是否有依据。")):ut("",!0)]),C("div",tC,[b[14]||(b[14]=C("label",null,[pt("Instruction "),C("em",null,"必填")],-1)),z(S,{"model-value":a.value.instruction,type:"textarea",rows:3,"onUpdate:modelValue":b[3]||(b[3]=x=>s("update:field",a.value.id,"instruction",x))},null,8,["model-value"])]),C("div",eC,[b[15]||(b[15]=C("label",null,[pt("Input "),C("span",null,"选填")],-1)),z(S,{"model-value":a.value.input,type:"textarea",rows:2,"onUpdate:modelValue":b[4]||(b[4]=x=>s("update:field",a.value.id,"input",x))},null,8,["model-value"])]),C("div",sC,[b[16]||(b[16]=C("label",null,[pt("Output "),C("em",null,"必填")],-1)),z(S,{"model-value":a.value.output,type:"textarea",rows:7,"onUpdate:modelValue":b[5]||(b[5]=x=>s("update:field",a.value.id,"output",x))},null,8,["model-value"])]),a.value.error?(R(),U("div",iC,[b[17]||(b[17]=C("i",{class:"fa fa-exclamation-circle"},null,-1)),pt(" "+j(a.value.error),1)])):(R(),U("div",nC,[...b[18]||(b[18]=[C("i",{class:"fa fa-check-circle"},null,-1),pt(" 字段校验通过 ",-1)])])),(_=a.value.qualityFlags)!=null&&_.length?(R(),U("div",rC,[(R(!0),U(ye,null,ri(a.value.qualityFlags,x=>(R(),$t(E,{key:x,size:"small",type:"warning",effect:"plain"},{default:et(()=>[pt(j(x),1)]),_:2},1024))),128))])):ut("",!0),C("div",aC,[z(A,{disabled:o.value<=0,onClick:b[6]||(b[6]=x=>g(-1))},{default:et(()=>[...b[19]||(b[19]=[pt("上一条",-1)])]),_:1},8,["disabled"]),C("span",null,j(o.value+1)+" / "+j(u.items.length),1),z(A,{disabled:o.value>=u.items.length-1,onClick:b[7]||(b[7]=x=>g(1))},{default:et(()=>[...b[20]||(b[20]=[pt("下一条",-1)])]),_:1},8,["disabled"])])])):ut("",!0)])])}}}),lC=Ti(oC,[["__scopeId","data-v-56aaf4d5"]]),T0="你是一名专业的数据生成助手。请根据输入内容生成准确、完整、可直接用于模型训练的问答数据。仅输出符合目标格式的内容,答案应事实清晰、语言自然,不要添加分析过程、说明或无关内容。";function cC(){return{preprocessOptions:["clean_invalid","detect_structure","deduplicate","normalize_format"],semanticEnrichment:!1,qaPairsPerRow:1,datasetSplit:{train:80,validation:10,test:10},generationModelId:"",generationPrompt:T0,temperature:.7,maxTokens:1024,jsonMode:!1,qualityFilterEnabled:!1,filterLowQuality:!0,filterShortContent:!0,minOutputLength:20}}function hC(){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:T0,temperature:.7,maxTokens:1024,jsonMode:!1,qualityFilterEnabled:!1,filterLowQuality:!0,filterShortContent:!0,minOutputLength:20}}const Hv=500,nf=1500;function sg(u){var t,e;return{id:String(u.id),previewItemId:u.preview_item_id==null?null:String(u.preview_item_id),instruction:u.instruction,input:u.input||"",output:u.output,originalInstruction:u.original_instruction??u.instruction,originalInput:u.original_input??u.input??"",originalOutput:u.original_output??u.output,status:u.status,error:u.error||void 0,split:u.split||void 0,qualityScore:(t=u.quality_score)==null?void 0:t.overall,qualityFlags:((e=u.quality_score)==null?void 0:e.flags)||[],updatedAt:u.updated_at}}function dC(u){const t=rt([]),e=rt(null),s=ig({status:"idle",progress:0,message:"确认摘要后即可开始生成,过程中可查看实时进度。"});let i=null,r=0,a=0;function o(){r+=1,i&&clearTimeout(i),i=null}function l(){o(),s.status="idle",s.progress=0,s.message="确认摘要后即可开始生成,过程中可查看实时进度。",t.value=[],e.value=null}function c(A){s.progress=Math.max(0,Math.min(100,Number(A.progress)||0)),s.message=A.message||(A.status==="running"?"后端正在生成标准化结果并进行质量评分。":A.status==="completed"?"数据处理已完成。":A.failure_reason||"任务已停止。")}async function h(A){var M;const _=await hv(A,{page:1,page_size:Hv}),x=[..._.items],k=Math.ceil(_.total/_.page_size);for(let D=2;D<=k;D+=1){const I=await hv(A,{page:D,page_size:Hv});x.push(...I.items)}t.value=x.map(sg),e.value=((M=t.value[0])==null?void 0:M.id)??null}async function d(A){if(a=0,c(A),A.status==="completed"){const _=u.taskId.value;if(!_)return;await h(_),s.status="success",s.progress=100,s.message=`已完成 ${t.value.length.toLocaleString()} 条数据处理,可进入结果页检查。`,u.dirty.value=!0,wt.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 _=u.taskId.value;if(!(!_||A!==r||s.status!=="running"))try{const x=await Aw(_);if(A!==r)return;if(a=0,x.status==="running"||x.status==="pending"){c(x),i=setTimeout(()=>void f(A),nf);return}await d(x)}catch(x){if(A!==r)return;if(a+=1,a<=3){s.message=`进度查询暂时失败,正在重试(${a}/3)…`,i=setTimeout(()=>void f(A),nf);return}s.status="failed",s.message=x instanceof Error?x.message:"查询任务进度失败,请重试。"}}async function g(){var x;const A=u.taskId.value;if(!A){wt.error("任务尚未创建,请返回上一步重试");return}o();const _=r;s.status="running",a=0,s.progress=0,s.message="正在同步预览修改并启动后端处理,请稍候。";try{await((x=u.beforeGenerate)==null?void 0:x.call(u));const k=await bw(A);if(_!==r)return;if(k.status==="completed"||k.status==="failed"||k.status==="stopped"){await d(k);return}c(k),i=setTimeout(()=>void f(_),nf)}catch(k){if(_!==r)return;s.status="failed",s.message=k instanceof Error?k.message:"启动数据处理失败,请重试。"}}async function y(){const A=u.taskId.value;if(A){o();try{const _=await vw(A);c(_)}catch{s.status="running",s.message="停止请求失败,继续查询后端任务状态。";const _=r;i=setTimeout(()=>void f(_),nf);return}s.status="failed",s.message="任务已停止,预览修改仍然保留,可以重新生成。"}}function b(A,_,x){const k=t.value.find(I=>I.id===A);if(!k)return;k[_]=x;const M=k.instruction.trim()&&k.output.trim();k.error=M?void 0:"Instruction 和 Output 不能为空";const D=k.instruction!==k.originalInstruction||k.input!==k.originalInput||k.output!==k.originalOutput;k.status=k.error?"invalid":D?"modified":"valid",u.dirty.value=!0}async function S(A){const _=u.taskId.value,x=t.value.find(D=>D.id===A);if(!_||!x)return;const k=await yw(_,A),M=t.value.indexOf(x);t.value[M]=sg(k),u.dirty.value=!0}async function w(){const A=u.taskId.value;if(!A)throw new Error("任务尚未创建");const _=t.value.filter(x=>x.instruction!==x.originalInstruction||x.input!==x.originalInput||x.output!==x.originalOutput);for(const x of _){const k=await ww(A,x.id,{instruction:x.instruction,input:x.input,output:x.output,expected_updated_at:x.updatedAt}),M=t.value.findIndex(D=>D.id===x.id);M>=0&&(t.value[M]=sg(k))}}function E(){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:w,resetDownstream:l,restoreResult:S,startGeneration:g,stopGeneration:y,stopGenerationTimer:o,updateResultField:b,validateResults:E}}function uC(){async function u(t,e,s){var r,a;const i=[];for(const o of e){s({source_file_id:o,status:"processing",progress:0});let l;try{const c=await Sw(t,{replace_existing:!0,source_file_ids:[o]}),h=String(o),d=(r=c.files)==null?void 0:r.find(g=>String(g.source_file_id)===h),f=(d==null?void 0:d.preview_count)??((a=c.file_counts)==null?void 0:a[h])??c.items.filter(g=>String(g.source_file_id)===h).length;l=f>0?{source_file_id:o,status:"success",progress:100,preview_count:f}:{source_file_id:o,status:"failed",progress:0,preview_count:0,error:"该文件没有生成可用的预览条目,请检查内容或切分配置"}}catch(c){l={source_file_id:o,status:"failed",progress:0,error:c instanceof Error&&c.message?c.message:"切分失败,请重试"}}i.push(l),s(l)}return i}return{buildPreviewsByFile:u}}const zv=new Set(["xlsx","pdf","docx","pptx"]),fC=new Set(["json","jsonl","ndjson","csv","tsv","xlsx"]),pC=new Set(["txt","md","markdown","pdf","docx","pptx","json","jsonl","ndjson"]),gC=new Set(["doc","xls","ppt"]),mC=200*1024*1024,Vv=20,vC=500*1024*1024;function bC(u,t,e){var a;if(u.size>mC)return{valid:!1,severity:"warning",message:"单文件不能超过 200MB"};const s=((a=u.name.split(".").pop())==null?void 0:a.toLowerCase())??"";return gC.has(s)?{valid:!1,severity:"error",message:"旧版 DOC、XLS、PPT 文件暂不支持,请分别转换为 DOCX、XLSX、PPTX 后上传"}:(t==="unstructured"?pC:fC).has(s)?e.some(o=>o.name===u.name&&o.size===u.size)?{valid:!1,severity:"warning",message:"同名且同大小的文件已经选择"}:e.length>=Vv?{valid:!1,severity:"warning",message:`每个任务最多选择 ${Vv} 个文件`}:e.reduce((o,l)=>o+l.size,0)+u.size>vC?{valid:!1,severity:"warning",message:"当前任务选择的文件总大小不能超过 500MB"}:{valid:!0,extension:s}:{valid:!1,severity:"error",message:t==="unstructured"?"非结构化数据支持 TXT、MD、MARKDOWN、PDF、DOCX、PPTX、JSON、JSONL、NDJSON":"结构化数据支持 JSON、JSONL、NDJSON、CSV、TSV、XLSX"}}function P0(u,t=""){return{uid:String(u.id),sourceFileId:String(u.id),name:u.name,size:u.size_bytes,count:u.record_count,content:t,fileFormat:u.file_format,checksumSha256:u.checksum_sha256,status:"ready",uploadProgress:100,previewStatus:"waiting",previewProgress:0}}function yC(u){var s;const t=(s=u==null?void 0:u.response)==null?void 0:s.data,e=t==null?void 0:t.detail;return typeof e=="string"?e:e!=null&&e.message?e.message:t!=null&&t.message?t.message:u instanceof Error&&u.message?u.message:"上传失败,请删除该文件后重新选择"}function wC(u){const t=rt(!1),e=[];let s=null;async function i(o){const l=u.uploadedFiles.value.find(h=>String(h.uid)===o.uid);if(!l)return;const c=u.taskId.value;if(!c){l.status="failed",l.uploadError="任务尚未创建,请返回模型选择步骤后重试";return}l.status="uploading",l.uploadProgress=0,l.uploadError=void 0;try{let h="";if(!zv.has(o.extension)){try{h=new TextDecoder("utf-8",{fatal:!0}).decode(await o.file.arrayBuffer())}catch{throw new Error("文本文件不是有效的 UTF-8 编码,请转换编码后重试")}if(!h.trim())throw new Error("不能上传空文件")}const f=(await xw(c,[o.file],g=>{l.uploadProgress=g})).files[0];if(!f)throw new Error("后端未返回源文件记录");if(Object.assign(l,P0(f),{rawFile:o.file,status:"uploading",uploadProgress:99}),zv.has(o.extension))try{const g=await Qv(c,f.id,{start_line:1,line_count:1e4});l.content=g.content}catch{}else l.content=h;l.status="ready",l.uploadProgress=100,u.onUploaded(l)}catch(h){l.status="failed",l.uploadError=yC(h)}}async function r(){t.value=!0;try{for(;e.length;){const o=e.shift();o&&await i(o)}}finally{t.value=!1}}function a(o){e.push(o),!s&&(s=r().finally(()=>{s=null}))}return{enqueueSourceUpload:a,sourceUploading:t}}const AC={class:"create-wizard-layout"},SC={class:"wizard-main"},xC={class:"wizard-main-inner"},EC={class:"wizard-steps-container"},CC={class:"custom-wizard-steps"},_C=["aria-current"],kC={class:"step-node"},TC={class:"step-icon"},PC={key:0,class:"fa fa-check"},MC={key:1},IC={class:"step-text"},DC={class:"step-title"},LC={class:"wizard-content"},FC={class:"wizard-footer"},RC={class:"footer-left"},OC={class:"footer-right"},NC="backend-pipeline-v4",BC=ki({__name:"DataProcessCreateView",setup(u){const t=cw(),e=Dw(),{list:s}=rw(e),i=ct(()=>s.value),r=rt(),a=rt(),o=rt(),l=[{id:"create",title:"创建任务",desc:"填写任务信息与处理配置"},{id:"model",title:"大模型选择",desc:"选择生成模型并设置输出要求"},{id:"upload",title:"上传文件",desc:"上传或接入待处理的源数据"},{id:"preview",title:"数据预览",desc:"核对源文件与预览内容"},{id:"generate",title:"开始生成",desc:"确认摘要并启动处理"},{id:"results",title:"结果编辑与保存",desc:"检查、修改并保存结果"}],c=rt(0),h=ct(()=>{var F;return((F=l[c.value])==null?void 0:F.id)??"create"}),d=ig({name:"",description:""}),f=rt(null),g=rt("structured"),y=rt(cC()),b=rt(hC()),S=ct(()=>g.value==="unstructured"?b.value:y.value),w=rt([]),E=rt(!1),{buildPreviewsByFile:A}=uC(),_=ig({type:"postgresql",url:"",authMode:"none",username:"",password:"",limit:1e3,query:"",fileName:"external-data.jsonl"}),x=rt(!1),k=rt(!1),M=ct(()=>w.value.map(F=>F.name).join(", ")),D=rt(""),I=rt([]),L=rt(null),O=rt(null),Y=rt({}),W=rt(!1);let Q=!1;const{generation:ft,results:T,selectedResultId:q,persistResultChanges:Lt,resetDownstream:bt,restoreResult:_e,startGeneration:ae,stopGeneration:Gt,stopGenerationTimer:H,updateResultField:$,validateResults:ht}=dC({taskId:f,dirty:W,beforeGenerate:W0}),{enqueueSourceUpload:ot,sourceUploading:Z}=wC({taskId:f,uploadedFiles:w,onUploaded(F){D.value="",bt(),W.value=!0,wt.success(`文件 ${F.name} 上传成功,等待切分`)}}),jt=ct(()=>w.value.some(F=>F.status!=="ready"||!F.sourceFileId)),ms=ct(()=>I.value.filter(F=>F.status!=="original").length),Ts=ct(()=>{const F=new Map;for(const N of I.value){const tt=F.get(N.sourceFileId)||[];tt.push(N),F.set(N.sourceFileId,tt)}return F}),Ps=ct(()=>w.value.find(F=>String(F.uid)===L.value)),Se=ct(()=>Ts.value.get(L.value||"")||[]),Sr=ct(()=>{var F;return((F=Ps.value)==null?void 0:F.content)??""}),Pa=ct(()=>w.value.map(F=>{const N=Ts.value.get(String(F.uid))||[];return{id:String(F.uid),name:F.name,count:N.length,modifiedCount:N.filter(tt=>tt.status!=="original").length}})),Ms=ct(()=>h.value==="create"?"继续:选择大模型":h.value==="model"?"继续:上传文件":h.value==="upload"?Z.value?"正在上传":E.value?"正在切分":"继续:数据预览":h.value==="preview"?"确认预览并继续":h.value==="results"?"保存任务":ft.status==="running"?"正在生成":ft.status==="success"?"查看生成结果":ft.status==="failed"?"重新生成":"开始生成"),Ne=ct(()=>h.value==="results"?"fa-check":h.value==="generate"&&ft.status!=="success"?"fa-play":"fa-arrow-right"),Is=ct(()=>c.value>0?l[c.value-1].title:"");function kn(F){const N=l.findIndex(tt=>tt.id===F);N>=0&&(c.value=N)}function Ma(F){if(g.value==="unstructured"){b.value={...b.value,...F};return}y.value={...y.value,...F}}function Ml(){const F=g.value==="unstructured"?b.value:y.value,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 g.value==="unstructured"?{...N,chunk_method:b.value.chunkMethod,chunk_size:b.value.chunkSize,chunk_overlap:b.value.chunkOverlap,min_chunk_size:b.value.minChunkSize,semantic_breakpoint_percentile:b.value.semanticBreakpointPercentile,preserve_tables:b.value.preserveTables,preserve_code_blocks:b.value.preserveCodeBlocks,preserve_lists:b.value.preserveLists,qa_pairs_per_chunk:b.value.qaPairsPerChunk}:{...N,qa_pairs_per_row:y.value.qaPairsPerRow}}function Il(){return{name:d.name.trim(),description:d.description.trim(),process_type:g.value,config:Ml()}}function bh(){var F;return{type:"postgresql",url:_.url.trim(),auth_mode:_.authMode,username:_.username||void 0,password:_.password||void 0,limit:_.limit,query:((F=_.query)==null?void 0:F.trim())||void 0,file_name:_.fileName||"external-data.jsonl"}}function Ia(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(tt=>typeof tt=="number"):[],updatedAt:F.updated_at}}function M0(){if(g.value==="structured")return{preprocessOptions:y.value.preprocessOptions};if(g.value==="unstructured"){const{preprocessOptions:F,chunkMethod:N,chunkSize:tt,chunkOverlap:zt,minChunkSize:ke,semanticBreakpointPercentile:Ds,preserveTables:St,preserveCodeBlocks:Ye,preserveLists:qt}=b.value;return{preprocessOptions:F,chunkMethod:N,chunkSize:tt,chunkOverlap:zt,minChunkSize:ke,semanticBreakpointPercentile:Ds,preserveTables:St,preserveCodeBlocks:Ye,preserveLists:qt}}return null}function I0(){if(g.value==="structured"){const{semanticEnrichment:F,qaPairsPerRow:N,datasetSplit:tt,generationModelId:zt,generationPrompt:ke,temperature:Ds,maxTokens:St,jsonMode:Ye,qualityFilterEnabled:qt,filterLowQuality:Ls,filterShortContent:Da,minOutputLength:La}=y.value;return{semanticEnrichment:F,qaPairsPerRow:N,datasetSplit:tt,generationModelId:zt,generationPrompt:ke,temperature:Ds,maxTokens:St,jsonMode:Ye,qualityFilterEnabled:qt,filterLowQuality:Ls,filterShortContent:Da,minOutputLength:La}}if(g.value==="unstructured"){const{semanticEnrichment:F,qaPairsPerChunk:N,datasetSplit:tt,generationModelId:zt,generationPrompt:ke,temperature:Ds,maxTokens:St,jsonMode:Ye,qualityFilterEnabled:qt,filterLowQuality:Ls,filterShortContent:Da,minOutputLength:La}=b.value;return{semanticEnrichment:F,qaPairsPerChunk:N,datasetSplit:tt,generationModelId:zt,generationPrompt:ke,temperature:Ds,maxTokens:St,jsonMode:Ye,qualityFilterEnabled:qt,filterLowQuality:Ls,filterShortContent:Da,minOutputLength:La}}return null}const D0=ct(()=>JSON.stringify(I0()));function rv(){return`${NC}:${g.value}:${JSON.stringify(M0())}`}function L0(){const F=w.value.map(N=>`${N.uid}:${N.name}:${N.size}:${N.checksumSha256||N.count}`).join("|");return`${rv()}:${F}`}Ei([()=>d.name,()=>d.description,g,y,b,_],()=>{W.value=!0},{deep:!0}),Ei(g,(F,N)=>{F===N||w.value.length===0||(U0(),wt.info("处理类型已变更,请重新上传或拉取匹配的源数据"))}),Ei(D0,(F,N)=>{F!==N&&bt()});function F0(){var F;(F=document.querySelector(".layout-content"))==null||F.scrollTo({top:0,behavior:"smooth"})}Ei(c,()=>Wf(F0));function av(F){const N=F.raw;if(!N)return;if(!f.value){wt.error("任务尚未创建,请返回模型选择步骤后重试");return}const tt=bC(N,g.value,w.value);if(!tt.valid){wt[tt.severity](tt.message);return}const zt=`local-${F.uid}-${Date.now()}-${w.value.length}`;w.value.push({uid:zt,rawFile:N,name:N.name,size:N.size,count:0,content:"",fileFormat:tt.extension,status:"queued",uploadProgress:0,previewStatus:"waiting",previewProgress:0}),W.value=!0,ot({uid:zt,file:N,extension:tt.extension})}async function R0(){if(!f.value){wt.error("任务尚未创建,请返回模型选择步骤后重试");return}const F=new File([Kx],"finance_qa.jsonl",{type:"application/x-ndjson"});av({raw:F,uid:Date.now(),name:F.name})}function O0(F){Object.assign(_,F),k.value=!1}async function N0(){if(!f.value){wt.error("任务尚未创建,请返回模型选择步骤后重试");return}if(!_.url.trim()){wt.warning("请先填写数据源地址");return}x.value=!0;try{const F=await kw(f.value,bh());k.value=F.connected,F.connected?wt.success(F.message||"数据源连接测试成功"):wt.warning(F.message||"数据源连接失败")}catch{k.value=!1}finally{x.value=!1}}async function B0(){var F;if(!f.value){wt.error("任务尚未创建,请返回模型选择步骤后重试");return}if(!_.url.trim()){wt.warning("请先填写数据源地址");return}if(!((F=_.query)!=null&&F.trim())){wt.warning("请先填写只读 SELECT 查询语句");return}x.value=!0;try{const N=await Tw(f.value,bh()),tt=[];for(const zt of N.files){const ke=await Qv(f.value,zt.id,{start_line:1,line_count:5e3});tt.push(P0(zt,ke.content))}w.value.push(...tt),k.value=!0,D.value="",bt(),W.value=!0,wt.success(`已成功登记 ${tt.length} 个外部源文件`)}catch{k.value=!1}finally{x.value=!1}}async function $0(F){const N=w.value.findIndex(zt=>zt.uid===F);if(N<0||!f.value)return;const tt=w.value[N];if(tt){if(tt.status==="uploading"){wt.warning("当前文件正在上传,请等待上传结束后再删除");return}if(tt.sourceFileId)try{await Pw(f.value,tt.sourceFileId)}catch{return}w.value.splice(N,1),D.value="",I.value=[],O.value=null,bt(),W.value=!0}}function U0(){w.value=[],D.value="",I.value=[],L.value=null,O.value=null,Y.value={},k.value=!1,bt()}async function H0(){var N;await((N=r.value)==null?void 0:N.validate())&&kn("model")}async function z0(){var N;if(await((N=a.value)==null?void 0:N.validate()))try{const tt=f.value?await Cw(f.value,Il()):await _w(Il());f.value=String(tt.id),W.value=!0,kn("upload")}catch{}}async function V0(){var ke,Ds;if(E.value||Z.value)return;if(!f.value){wt.error("任务尚未创建,请返回模型选择步骤后重试");return}if(w.value.length===0){wt.warning(g.value==="external"?"请先拉取至少一个数据源":"请上传至少一个源数据文件");return}const F=w.value.filter(St=>St.status==="failed");if(F.length){wt.warning(`${F.length} 个文件上传失败,请删除后重新选择`);return}if(jt.value){wt.warning("请等待所有文件上传完成后再开始切分");return}const N=L0(),tt=rv(),zt=()=>w.value.every(St=>St.previewStatus==="success"&&St.previewConfigSignature===tt);if(N===D.value&&I.value.length&&zt()){kn("preview");return}for(const St of w.value)St.previewConfigSignature!==tt&&(St.previewStatus="waiting",St.previewProgress=0,St.previewError=void 0,St.previewCount=void 0);E.value=!0;try{const St=w.value.filter(qt=>qt.previewStatus!=="success"||qt.previewConfigSignature!==tt).map(qt=>qt.sourceFileId).filter(qt=>!!qt);await A(f.value,St,qt=>{const Ls=w.value.find(Da=>String(Da.sourceFileId)===String(qt.source_file_id));Ls&&(Ls.previewStatus=qt.status,Ls.previewProgress=qt.progress,Ls.previewCount=qt.preview_count,Ls.previewError=qt.error,qt.status==="success"&&(Ls.previewConfigSignature=tt))});const Ye=w.value.filter(qt=>qt.previewStatus==="failed").length;if(Ye||!zt()){wt.warning(`${Ye||1} 个文件切分失败;修正问题后点击“继续:数据预览”即可重试`);return}try{const qt=await dv(f.value,{page:1,page_size:500}),Ls=[...qt.items],Da=Math.ceil(qt.total/qt.page_size);for(let La=2;La<=Da;La+=1){const tw=await dv(f.value,{page:La,page_size:500});Ls.push(...tw.items)}I.value=Ls.map(Ia)}catch{wt.warning("文件切分已经完成,但预览加载失败;请再次点击继续重试加载");return}if(!I.value.length){wt.warning("源文件没有生成可用的预览条目,请检查文件内容和预处理配置");return}L.value=String(((ke=w.value[0])==null?void 0:ke.uid)??"")||null,O.value=((Ds=Se.value[0])==null?void 0:Ds.id)??null,Y.value=O.value&&L.value?{[L.value]:O.value}:{},D.value=N,bt(),kn("preview")}finally{E.value=!1}}function G0(F){var N;L.value&&O.value&&(Y.value[L.value]=O.value),L.value=F,O.value=Y.value[F]||((N=Se.value[0])==null?void 0:N.id)||null}function ov(F){O.value=F,L.value&&(Y.value[L.value]=F)}function j0(F,N){const tt=I.value.find(zt=>zt.id===F);tt&&(tt.editedContent=N,tt.tokenCount=Uv(N),tt.status=N===tt.originalContent?"original":tt.sourceStart==null?"manual":"modified",bt(),W.value=!0)}async function W0(){if(!f.value)throw new Error("任务尚未创建");const F=I.value.filter(N=>N.status==="modified"||N.status==="manual");for(const N of F){const tt=await Ew(f.value,N.id,{edited_content:N.editedContent,expected_updated_at:N.updatedAt}),zt=I.value.findIndex(ke=>ke.id===N.id);zt>=0&&(I.value[zt]=Ia(tt))}}function X0(F){const N=I.value.find(tt=>tt.id===F);!N||N.sourceStart==null||(N.editedContent=N.originalContent,N.tokenCount=Uv(N.originalContent),N.status="original",bt(),W.value=!0)}async function q0(){if(!(!L.value||!f.value))try{const F=await Mw(f.value,{source_file_id:L.value,edited_content:""}),N=Ia(F);I.value.push(N),ov(N.id),bt(),W.value=!0}catch{}}async function Y0(F){var zt,ke;if(!await((zt=o.value)==null?void 0:zt.open({title:"删除预览内容?",message:"删除只影响本次处理,不会修改源文件。删除后可重新从源文件生成预览。",confirmText:"删除",cancelText:"取消",tone:"danger"})))return;const tt=I.value.findIndex(Ds=>Ds.id===F);if(!(tt<0)&&f.value){try{await Iw(f.value,F)}catch{return}I.value.splice(tt,1),O.value=((ke=Se.value[Math.min(tt,Se.value.length-1)])==null?void 0:ke.id)??null,L.value&&O.value&&(Y.value[L.value]=O.value),bt(),W.value=!0}}async function K0(){if(h.value==="create"){await H0();return}if(h.value==="model"){await z0();return}if(h.value==="upload"){await V0();return}if(h.value==="preview"){if(!I.value.length){wt.warning("当前没有可生成的预览内容");return}kn("generate");return}if(h.value==="generate"){ft.status==="success"?kn("results"):ft.status!=="running"&&await ae();return}await J0()}function Q0(){if(Z.value){wt.warning("请等待当前文件上传完成");return}if(E.value){wt.warning("请等待当前文件切分完成");return}if(ft.status==="running"){wt.warning("请先停止当前生成任务");return}c.value>0&&(c.value-=1)}async function J0(){if(!ht()){wt.warning("请先修正校验失败的结果");return}try{await Lt()}catch{return}if(!ht()){wt.warning("仍有结果未通过后端质量校验,请继续修正");return}W.value=!1,Q=!0,wt.success("数据处理任务已保存"),await t.push("/data-process")}async function Z0(){var N;if(!W.value){Q=!0,t.back();return}await((N=o.value)==null?void 0:N.open({title:"确认离开当前页面?",message:"当前存在未保存修改,离开后这些修改将不会保留。",confirmText:"放弃修改",cancelText:"继续编辑",tone:"danger"}))&&(Q=!0,t.back())}return aw(async()=>{var N;if(Z.value)return wt.warning("请等待当前文件上传完成后再离开页面"),!1;if(Q||!W.value)return!0;const F=await((N=o.value)==null?void 0:N.open({title:"确认离开当前页面?",message:"当前存在未保存修改,离开后这些修改将不会保留。",confirmText:"放弃修改",cancelText:"继续编辑",tone:"danger"}));return F&&(Q=!0),!!F}),jv(()=>{H()}),ow(()=>{localStorage.removeItem("yg-data-process-create-draft"),e.load(!0)}),(F,N)=>{var zt,ke,Ds;const tt=Uu;return R(),U(ye,null,[C("div",AC,[C("main",SC,[C("div",xC,[C("div",EC,[C("div",CC,[(R(),U(ye,null,ri(l,(St,Ye)=>(R(),U(ye,{key:St.id},[Ye!==0?(R(),U("div",{key:0,class:we(["step-connector",{"is-active":c.value>=Ye}])},null,2)):ut("",!0),C("div",{class:we(["step-item",{"is-active":c.value===Ye,"is-completed":c.value>Ye}]),"aria-current":c.value===Ye?"step":void 0},[C("div",kC,[C("div",TC,[c.value>Ye?(R(),U("i",PC)):(R(),U("span",MC,j(Ye+1),1))]),C("div",IC,[C("div",DC,j(St.title),1)])])],10,_C)],64))),64))])]),C("div",LC,[h.value==="create"?(R(),$t(VA,{key:0,ref_key:"taskSetupRef",ref:r,name:d.name,"onUpdate:name":N[0]||(N[0]=St=>d.name=St),description:d.description,"onUpdate:description":N[1]||(N[1]=St=>d.description=St),"process-type":g.value,"onUpdate:processType":N[2]||(N[2]=St=>g.value=St),"structured-options":y.value,"onUpdate:structuredOptions":N[3]||(N[3]=St=>y.value=St),"unstructured-options":b.value,"onUpdate:unstructuredOptions":N[4]||(N[4]=St=>b.value=St)},null,8,["name","description","process-type","structured-options","unstructured-options"])):h.value==="model"?(R(),$t(qA,{key:1,ref_key:"modelSelectionRef",ref:a,options:S.value,models:i.value,"onUpdate:options":Ma},null,8,["options","models"])):h.value==="upload"?(R(),$t(ES,{key:2,"process-type":g.value,"uploaded-files":w.value,"external-source":_,"external-pulling":x.value,"external-connected":k.value,"preview-building":E.value,"source-uploading":Fs(Z),"onUpdate:externalSource":O0,onFileChange:av,onRemoveFile:$0,onUseSample:R0,onTestConnection:N0,onPullData:B0},null,8,["process-type","uploaded-files","external-source","external-pulling","external-connected","preview-building","source-uploading"])):h.value==="preview"?(R(),$t(CE,{key:3,"selected-id":O.value,"selected-file-id":L.value,"source-text":Sr.value,items:Se.value,"process-type":g.value,"file-name":((zt=Ps.value)==null?void 0:zt.name)??"","task-id":f.value,"source-file-id":((ke=Ps.value)==null?void 0:ke.sourceFileId)??((Ds=Ps.value)==null?void 0:Ds.uid)??null,files:Pa.value,"onUpdate:selectedId":ov,"onUpdate:selectedFileId":G0,"onUpdate:itemContent":j0,"onRestore:item":X0,"onAdd:item":q0,"onRemove:item":Y0},null,8,["selected-id","selected-file-id","source-text","items","process-type","file-name","task-id","source-file-id","files"])):h.value==="generate"?(R(),$t(RE,{key:4,"task-name":d.name,"process-type":g.value,"file-name":M.value,"preview-count":I.value.length,"modified-count":ms.value,generation:Fs(ft),onStop:Fs(Gt),onRetry:Fs(ae)},null,8,["task-name","process-type","file-name","preview-count","modified-count","generation","onStop","onRetry"])):h.value==="results"?(R(),$t(lC,{key:5,"selected-id":Fs(q),"onUpdate:selectedId":N[5]||(N[5]=St=>lw(q)?q.value=St:null),items:Fs(T),"preview-items":I.value,"onUpdate:field":Fs($),"onRestore:item":Fs(_e)},null,8,["selected-id","items","preview-items","onUpdate:field","onRestore:item"])):ut("",!0)])])]),C("footer",FC,[C("div",RC,[c.value>0?(R(),$t(tt,{key:0,disabled:E.value||Fs(Z),onClick:Q0},{default:et(()=>[N[6]||(N[6]=C("i",{class:"fa fa-arrow-left",style:{"margin-right":"6px"}},null,-1)),pt(" 返回:"+j(Is.value),1)]),_:1},8,["disabled"])):(R(),$t(tt,{key:1,onClick:Z0},{default:et(()=>[...N[7]||(N[7]=[pt("取消",-1)])]),_:1}))]),N[8]||(N[8]=C("div",{class:"footer-center"},null,-1)),C("div",OC,[z(tt,{class:"wizard-primary-action",type:"primary",loading:Fs(ft).status==="running"||h.value==="upload"&&(Fs(Z)||E.value),disabled:h.value==="generate"&&Fs(ft).status==="running"||E.value||Fs(Z)||h.value==="upload"&&jt.value,onClick:K0},{default:et(()=>[pt(j(Ms.value)+" ",1),C("i",{class:we(["fa",Ne.value]),style:{"margin-left":"6px"}},null,2)]),_:1},8,["loading","disabled"])])])]),z(hw,{ref_key:"confirmDialogRef",ref:o},null,512)],64)}}}),E_=Ti(BC,[["__scopeId","data-v-f64e21b6"]]);export{E_ as default};