/*!
 * Nutrient Web SDK 1.16.0 (https://www.nutrient.io/sdk/web)
 *
 * Copyright (c) 2016-2026 PSPDFKit GmbH. All rights reserved.
 *
 * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
 * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT.
 * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
 * This notice may not be removed from this file.
 *
 * PSPDFKit uses several open source third-party components: https://www.nutrient.io/legal/acknowledgements/web-acknowledgements/
 */
"use strict";(globalThis.webpackChunkNutrientViewer=globalThis.webpackChunkNutrientViewer||[]).push([[567],{23948(t,e,n){n.d(e,{prepareUpload:()=>p});var l=n(44008),c=n(56741);const u=(0,c.wU)("Cgxjb21tb24ucHJvdG8SEG51dHJpZW50Lm1ldHJpY3Mi8gEKCEFueVZhbHVlEhYKDHN0cmluZ192YWx1ZRgBIAEoCUgAEhQKCmJvb2xfdmFsdWUYAiABKAhIABITCglpbnRfdmFsdWUYAyABKANIABIWCgxkb3VibGVfdmFsdWUYBCABKAFIABIzCgthcnJheV92YWx1ZRgFIAEoCzIcLm51dHJpZW50Lm1ldHJpY3MuQXJyYXlWYWx1ZUgAEjYKDGt2bGlzdF92YWx1ZRgGIAEoCzIeLm51dHJpZW50Lm1ldHJpY3MuS2V5VmFsdWVMaXN0SAASFQoLYnl0ZXNfdmFsdWUYByABKAxIAEIHCgV2YWx1ZSI4CgpBcnJheVZhbHVlEioKBnZhbHVlcxgBIAMoCzIaLm51dHJpZW50Lm1ldHJpY3MuQW55VmFsdWUiQgoIS2V5VmFsdWUSCwoDa2V5GAEgASgJEikKBXZhbHVlGAIgASgLMhoubnV0cmllbnQubWV0cmljcy5BbnlWYWx1ZSI6CgxLZXlWYWx1ZUxpc3QSKgoGdmFsdWVzGAEgAygLMhoubnV0cmllb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2VBc3luY1Jlc3BvbnNlEhAKCGFjY2VwdGVkGAEgASgIEhoKDWVycm9yX21lc3NhZ2UYAiABKAlIAIgBAUIQCg5fZXJyb3JfbWVzc2FnZUIYWhZpby5udXRyaWVudC5tZXRyaWNzL3BiYgZwcm90bzM",[A,i]),m=(0,c.Zk)(b,0);async function p(t,e){if(0===e.length)return null;const n=function(t){const e=t.map(t=>({metric:t,sortedAttributes:I(t.attributes)})),n=new Map;for(const{metric:t,sortedAttributes:l}of e){const e=l.map(t=>{let[e,n]=t;return`${e}=${n}`}).join(";"),c=`${t.name}|${e}|${t.timestamp}`;if(y(t)){const e=n.get(c);e&&"counter"===e.type?e.count+=1:n.set(c,{type:"counter",metric:t,count:1,sortedAttributes:l})}else if(V(t)){const e=n.get(c);e&&"unique"===e.type?e.values.add(t.value):n.set(c,{type:"unique",metric:t,values:new Set([t.value]),sortedAttributes:l})}}const l=[];for(const t of n.values())"counter"===t.type?l.push({...t.metric,count:t.count,sortedAttributes:t.sortedAttributes}):"unique"===t.type&&l.push({...t.metric,values:Array.from(t.values),sortedAttributes:t.sortedAttributes});return l}(e),c=[...n].sort((t,e)=>t.timestamp-e.timestamp),u=`${c[0].timestamp}-${function(){const t=new Uint8Array(4);return crypto.getRandomValues(t),Array.from(t).map(t=>t.toString(16).padStart(2,"0")).join("")}()}`,i=(0,l.vt)(m,{client:Z(t.clientInfo),dataPoints:c.map(t=>function(t){let e;if(y(t))e={case:"counterValue",value:(0,l.vt)(s,{count:BigInt(t.count??1)})};else if(V(t)){const n=t.values??[t.value];e={case:"setValues",value:(0,l.vt)(g,{values:n})}}else e={case:void 0};const n=t.sortedAttributes??I(t.attributes),c=n.length>0?(0,l.vt)(d,{values:n.map(t=>{let[e,n]=t;return(0,l.vt)(a,{key:e,value:(0,l.vt)(o,{value:{case:"stringValue",value:n}})})})}):void 0;return(0,l.vt)(W,{timeUnixMs:BigInt(t.timestamp),name:t.name,value:e,attributes:c})}(t))}),r=(0,l.Rm)(m,i),A=await async function(t,e){if("undefined"==typeof crypto||!crypto.subtle)throw new Error("Web Crypto API is not available.");try{const l=await crypto.subtle.importKey("raw",t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),c=await crypto.subtle.sign("HMAC",l,e);return n=c,Array.from(new Uint8Array(n)).map(t=>t.toString(16).padStart(2,"0")).join("")}catch(t){throw new Error(`Failed to sign request with Web Crypto API: ${t}`)}var n}(t.hmacSecret,r);return{bucketId:u,headers:{"Content-Type":"application/protobuf","Nutrient-Metrics-Signature":`sha256=${A}`},body:r,requestId:`bucketId=${u}|signature=${A}`}}function Z(t){const e={};return void 0!==t.tenantId?e.tenantId=t.tenantId:void 0!==t.licenseId?e.licenseId=BigInt(t.licenseId):void 0!==t.demoKeyId?e.demoKeyId=BigInt(t.demoKeyId):e.tag=t.tag??Math.random().toString(36).substring(2,15),(0,l.vt)(r,{environment:t.environment,productId:BigInt(t.productId),productVersion:t.productVersion,...e})}function I(t){return Object.keys(t).sort().map(e=>[e,t[e]])}function y(t){return"counter"===t.type}function V(t){return"unique"===t.type}}}]);