@opentiny/next-remoter 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,89 +1,89 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("vue"),Gt=require("@opentiny/tiny-robot"),Y1=require("@opentiny/genui-sdk-vue"),dr=require("@opentiny/tiny-robot-kit"),$i=require("@opentiny/tiny-robot-svgs"),Ki=require("@opentiny/next-sdk"),q1=require("@opentiny/vue-icon");function K1(t,n){for(var o=0;o<n.length;o++){const l=n[o];if(typeof l!="string"&&!Array.isArray(l)){for(const u in l)if(u!=="default"&&!(u in t)){const f=Object.getOwnPropertyDescriptor(l,u);f&&Object.defineProperty(t,u,f.get?f:{enumerable:!0,get:()=>l[u]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var Ll="vercel.ai.error",J1=Symbol.for(Ll),Fl,Q1=class $l extends Error{constructor({name:n,message:o,cause:l}){super(o),this[Fl]=!0,this.name=n,this.cause=l}static isInstance(n){return $l.hasMarker(n,Ll)}static hasMarker(n,o){const l=Symbol.for(o);return n!=null&&typeof n=="object"&&l in n&&typeof n[l]=="boolean"&&n[l]===!0}};Fl=J1;var Et=Q1,Ul="AI_APICallError",zl=`vercel.ai.error.${Ul}`,e0=Symbol.for(zl),Zl,zn=class extends Et{constructor({message:n,url:o,requestBodyValues:l,statusCode:u,responseHeaders:f,responseBody:g,cause:m,isRetryable:y=u!=null&&(u===408||u===409||u===429||u>=500),data:x}){super({name:Ul,message:n,cause:m}),this[Zl]=!0,this.url=o,this.requestBodyValues=l,this.statusCode=u,this.responseHeaders=f,this.responseBody=g,this.isRetryable=y,this.data=x}static isInstance(n){return Et.hasMarker(n,zl)}};Zl=e0;var Vl="AI_EmptyResponseBodyError",jl=`vercel.ai.error.${Vl}`,t0=Symbol.for(jl),Hl,n0=class extends Et{constructor({message:n="Empty response body"}={}){super({name:Vl,message:n}),this[Hl]=!0}static isInstance(n){return Et.hasMarker(n,jl)}};Hl=t0;function Wl(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var Gl="AI_InvalidArgumentError",Xl=`vercel.ai.error.${Gl}`,r0=Symbol.for(Xl),Yl,ql=class extends Et{constructor({message:n,cause:o,argument:l}){super({name:Gl,message:n,cause:o}),this[Yl]=!0,this.argument=l}static isInstance(n){return Et.hasMarker(n,Xl)}};Yl=r0;var Kl="AI_InvalidResponseDataError",Jl=`vercel.ai.error.${Kl}`,i0=Symbol.for(Jl),Ql,Vs=class extends Et{constructor({data:n,message:o=`Invalid response data: ${JSON.stringify(n)}.`}){super({name:Kl,message:o}),this[Ql]=!0,this.data=n}static isInstance(n){return Et.hasMarker(n,Jl)}};Ql=i0;var ec="AI_JSONParseError",tc=`vercel.ai.error.${ec}`,o0=Symbol.for(tc),nc,Ui=class extends Et{constructor({text:n,cause:o}){super({name:ec,message:`JSON parsing failed: Text: ${n}.
2
- Error message: ${Wl(o)}`,cause:o}),this[nc]=!0,this.text=n}static isInstance(n){return Et.hasMarker(n,tc)}};nc=o0;var rc="AI_LoadAPIKeyError",ic=`vercel.ai.error.${rc}`,s0=Symbol.for(ic),oc,Ci=class extends Et{constructor({message:n}){super({name:rc,message:n}),this[oc]=!0}static isInstance(n){return Et.hasMarker(n,ic)}};oc=s0;var sc="AI_NoSuchModelError",ac=`vercel.ai.error.${sc}`,a0=Symbol.for(ac),lc,js=class extends Et{constructor({errorName:t=sc,modelId:n,modelType:o,message:l=`No such ${o}: ${n}`}){super({name:t,message:l}),this[lc]=!0,this.modelId=n,this.modelType=o}static isInstance(t){return Et.hasMarker(t,ac)}};lc=a0;var cc="AI_TypeValidationError",uc=`vercel.ai.error.${cc}`,l0=Symbol.for(uc),dc,c0=class zo extends Et{constructor({value:n,cause:o}){super({name:cc,message:`Type validation failed: Value: ${JSON.stringify(n)}.
3
- Error message: ${Wl(o)}`,cause:o}),this[dc]=!0,this.value=n}static isInstance(n){return Et.hasMarker(n,uc)}static wrap({value:n,cause:o}){return zo.isInstance(o)&&o.value===n?o:new zo({value:n,cause:o})}};dc=l0;var qr=c0,fc="AI_UnsupportedFunctionalityError",hc=`vercel.ai.error.${fc}`,u0=Symbol.for(hc),pc,gc=class extends Et{constructor({functionality:n,message:o=`'${n}' functionality not supported.`}){super({name:fc,message:o}),this[pc]=!0,this.functionality=n}static isInstance(n){return Et.hasMarker(n,hc)}};pc=u0;class Hs extends Error{constructor(n,o){super(n),this.name="ParseError",this.type=o.type,this.field=o.field,this.value=o.value,this.line=o.line}}function Ao(t){}function d0(t){if(typeof t=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:n=Ao,onError:o=Ao,onRetry:l=Ao,onComment:u}=t;let f="",g=!0,m,y="",x="";function A(D){const M=g?D.replace(/^\xEF\xBB\xBF/,""):D,[z,U]=f0(`${f}${M}`);for(const k of z)b(k);f=U,g=!1}function b(D){if(D===""){N();return}if(D.startsWith(":")){u&&u(D.slice(D.startsWith(": ")?2:1));return}const M=D.indexOf(":");if(M!==-1){const z=D.slice(0,M),U=D[M+1]===" "?2:1,k=D.slice(M+U);P(z,k,D);return}P(D,"",D)}function P(D,M,z){switch(D){case"event":x=M;break;case"data":y=`${y}${M}
4
- `;break;case"id":m=M.includes("\0")?void 0:M;break;case"retry":/^\d+$/.test(M)?l(parseInt(M,10)):o(new Hs(`Invalid \`retry\` value: "${M}"`,{type:"invalid-retry",value:M,line:z}));break;default:o(new Hs(`Unknown field "${D.length>20?`${D.slice(0,20)}…`:D}"`,{type:"unknown-field",field:D,value:M,line:z}));break}}function N(){y.length>0&&n({id:m,event:x||void 0,data:y.endsWith(`
5
- `)?y.slice(0,-1):y}),m=void 0,y="",x=""}function R(D={}){f&&D.consume&&b(f),g=!0,m=void 0,y="",x="",f=""}return{feed:A,reset:R}}function f0(t){const n=[];let o="",l=0;for(;l<t.length;){const u=t.indexOf("\r",l),f=t.indexOf(`
6
- `,l);let g=-1;if(u!==-1&&f!==-1?g=Math.min(u,f):u!==-1?u===t.length-1?g=-1:g=u:f!==-1&&(g=f),g===-1){o=t.slice(l);break}else{const m=t.slice(l,g);n.push(m),l=g+1,t[l-1]==="\r"&&t[l]===`
7
- `&&l++}}return[n,o]}class mc extends TransformStream{constructor({onError:n,onRetry:o,onComment:l}={}){let u;super({start(f){u=d0({onEvent:g=>{f.enqueue(g)},onError(g){n==="terminate"?f.error(g):typeof n=="function"&&n(g)},onRetry:o,onComment:l})},transform(f){u.feed(f)}})}}function q(t,n,o){function l(m,y){var x;Object.defineProperty(m,"_zod",{value:m._zod??{},enumerable:!1}),(x=m._zod).traits??(x.traits=new Set),m._zod.traits.add(t),n(m,y);for(const A in g.prototype)A in m||Object.defineProperty(m,A,{value:g.prototype[A].bind(m)});m._zod.constr=g,m._zod.def=y}const u=o?.Parent??Object;class f extends u{}Object.defineProperty(f,"name",{value:t});function g(m){var y;const x=o?.Parent?new f:this;l(x,m),(y=x._zod).deferred??(y.deferred=[]);for(const A of x._zod.deferred)A();return x}return Object.defineProperty(g,"init",{value:l}),Object.defineProperty(g,Symbol.hasInstance,{value:m=>o?.Parent&&m instanceof o.Parent?!0:m?._zod?.traits?.has(t)}),Object.defineProperty(g,"name",{value:t}),g}class Kr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const xc={};function er(t){return xc}function wc(t){const n=Object.values(t).filter(l=>typeof l=="number");return Object.entries(t).filter(([l,u])=>n.indexOf(+l)===-1).map(([l,u])=>u)}function h0(t,n){return typeof n=="bigint"?n.toString():n}function ns(t){return{get value(){{const n=t();return Object.defineProperty(this,"value",{value:n}),n}}}}function rs(t){return t==null}function is(t){const n=t.startsWith("^")?1:0,o=t.endsWith("$")?t.length-1:t.length;return t.slice(n,o)}function p0(t,n){const o=(t.toString().split(".")[1]||"").length,l=(n.toString().split(".")[1]||"").length,u=o>l?o:l,f=Number.parseInt(t.toFixed(u).replace(".","")),g=Number.parseInt(n.toFixed(u).replace(".",""));return f%g/10**u}function Qe(t,n,o){Object.defineProperty(t,n,{get(){{const l=o();return t[n]=l,l}},set(l){Object.defineProperty(t,n,{value:l})},configurable:!0})}function os(t,n,o){Object.defineProperty(t,n,{value:o,writable:!0,enumerable:!0,configurable:!0})}function Ur(t){return JSON.stringify(t)}const yc=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function zi(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const g0=ns(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Zi(t){if(zi(t)===!1)return!1;const n=t.constructor;if(n===void 0)return!0;const o=n.prototype;return!(zi(o)===!1||Object.prototype.hasOwnProperty.call(o,"isPrototypeOf")===!1)}const m0=new Set(["string","number","symbol"]);function oi(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function hr(t,n,o){const l=new t._zod.constr(n??t._zod.def);return(!n||o?.parent)&&(l._zod.parent=t),l}function Te(t){const n=t;if(!n)return{};if(typeof n=="string")return{error:()=>n};if(n?.message!==void 0){if(n?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");n.error=n.message}return delete n.message,typeof n.error=="string"?{...n,error:()=>n.error}:n}function x0(t){return Object.keys(t).filter(n=>t[n]._zod.optin==="optional"&&t[n]._zod.optout==="optional")}const w0={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function y0(t,n){const o={},l=t._zod.def;for(const u in n){if(!(u in l.shape))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(o[u]=l.shape[u])}return hr(t,{...t._zod.def,shape:o,checks:[]})}function _0(t,n){const o={...t._zod.def.shape},l=t._zod.def;for(const u in n){if(!(u in l.shape))throw new Error(`Unrecognized key: "${u}"`);n[u]&&delete o[u]}return hr(t,{...t._zod.def,shape:o,checks:[]})}function v0(t,n){if(!Zi(n))throw new Error("Invalid input to extend: expected a plain object");const o={...t._zod.def,get shape(){const l={...t._zod.def.shape,...n};return os(this,"shape",l),l},checks:[]};return hr(t,o)}function C0(t,n){return hr(t,{...t._zod.def,get shape(){const o={...t._zod.def.shape,...n._zod.def.shape};return os(this,"shape",o),o},catchall:n._zod.def.catchall,checks:[]})}function b0(t,n,o){const l=n._zod.def.shape,u={...l};if(o)for(const f in o){if(!(f in l))throw new Error(`Unrecognized key: "${f}"`);o[f]&&(u[f]=t?new t({type:"optional",innerType:l[f]}):l[f])}else for(const f in l)u[f]=t?new t({type:"optional",innerType:l[f]}):l[f];return hr(n,{...n._zod.def,shape:u,checks:[]})}function E0(t,n,o){const l=n._zod.def.shape,u={...l};if(o)for(const f in o){if(!(f in u))throw new Error(`Unrecognized key: "${f}"`);o[f]&&(u[f]=new t({type:"nonoptional",innerType:l[f]}))}else for(const f in l)u[f]=new t({type:"nonoptional",innerType:l[f]});return hr(n,{...n._zod.def,shape:u,checks:[]})}function Xr(t,n=0){for(let o=n;o<t.issues.length;o++)if(t.issues[o]?.continue!==!0)return!0;return!1}function fr(t,n){return n.map(o=>{var l;return(l=o).path??(l.path=[]),o.path.unshift(t),o})}function bi(t){return typeof t=="string"?t:t?.message}function tr(t,n,o){const l={...t,path:t.path??[]};if(!t.message){const u=bi(t.inst?._zod.def?.error?.(t))??bi(n?.error?.(t))??bi(o.customError?.(t))??bi(o.localeError?.(t))??"Invalid input";l.message=u}return delete l.inst,delete l.continue,n?.reportInput||delete l.input,l}function ss(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Jr(...t){const[n,o,l]=t;return typeof n=="string"?{message:n,code:"custom",input:o,inst:l}:{...n}}const _c=(t,n)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:n,enumerable:!1}),Object.defineProperty(t,"message",{get(){return JSON.stringify(n,h0,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},vc=q("$ZodError",_c),Cc=q("$ZodError",_c,{Parent:Error});function A0(t,n=o=>o.message){const o={},l=[];for(const u of t.issues)u.path.length>0?(o[u.path[0]]=o[u.path[0]]||[],o[u.path[0]].push(n(u))):l.push(n(u));return{formErrors:l,fieldErrors:o}}function I0(t,n){const o=n||function(f){return f.message},l={_errors:[]},u=f=>{for(const g of f.issues)if(g.code==="invalid_union"&&g.errors.length)g.errors.map(m=>u({issues:m}));else if(g.code==="invalid_key")u({issues:g.issues});else if(g.code==="invalid_element")u({issues:g.issues});else if(g.path.length===0)l._errors.push(o(g));else{let m=l,y=0;for(;y<g.path.length;){const x=g.path[y];y===g.path.length-1?(m[x]=m[x]||{_errors:[]},m[x]._errors.push(o(g))):m[x]=m[x]||{_errors:[]},m=m[x],y++}}};return u(t),l}const S0=t=>(n,o,l,u)=>{const f=l?Object.assign(l,{async:!1}):{async:!1},g=n._zod.run({value:o,issues:[]},f);if(g instanceof Promise)throw new Kr;if(g.issues.length){const m=new(u?.Err??t)(g.issues.map(y=>tr(y,f,er())));throw yc(m,u?.callee),m}return g.value},T0=t=>async(n,o,l,u)=>{const f=l?Object.assign(l,{async:!0}):{async:!0};let g=n._zod.run({value:o,issues:[]},f);if(g instanceof Promise&&(g=await g),g.issues.length){const m=new(u?.Err??t)(g.issues.map(y=>tr(y,f,er())));throw yc(m,u?.callee),m}return g.value},bc=t=>(n,o,l)=>{const u=l?{...l,async:!1}:{async:!1},f=n._zod.run({value:o,issues:[]},u);if(f instanceof Promise)throw new Kr;return f.issues.length?{success:!1,error:new(t??vc)(f.issues.map(g=>tr(g,u,er())))}:{success:!0,data:f.value}},O0=bc(Cc),Ec=t=>async(n,o,l)=>{const u=l?Object.assign(l,{async:!0}):{async:!0};let f=n._zod.run({value:o,issues:[]},u);return f instanceof Promise&&(f=await f),f.issues.length?{success:!1,error:new t(f.issues.map(g=>tr(g,u,er())))}:{success:!0,data:f.value}},N0=Ec(Cc),k0=/^[cC][^\s-]{8,}$/,R0=/^[0-9a-z]+$/,D0=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,M0=/^[0-9a-vA-V]{20}$/,P0=/^[A-Za-z0-9]{27}$/,B0=/^[a-zA-Z0-9_-]{21}$/,L0=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,F0=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ws=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,$0=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,U0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function z0(){return new RegExp(U0,"u")}const Z0=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,V0=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,j0=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,H0=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,W0=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ac=/^[A-Za-z0-9_-]*$/,G0=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,X0=/^\+(?:[0-9]){6,14}[0-9]$/,Ic="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Y0=new RegExp(`^${Ic}$`);function Sc(t){const n="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${n}`:t.precision===0?`${n}:[0-5]\\d`:`${n}:[0-5]\\d\\.\\d{${t.precision}}`:`${n}(?::[0-5]\\d(?:\\.\\d+)?)?`}function q0(t){return new RegExp(`^${Sc(t)}$`)}function K0(t){const n=Sc({precision:t.precision}),o=["Z"];t.local&&o.push(""),t.offset&&o.push("([+-]\\d{2}:\\d{2})");const l=`${n}(?:${o.join("|")})`;return new RegExp(`^${Ic}T(?:${l})$`)}const J0=t=>{const n=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${n}$`)},Q0=/^\d+$/,ed=/^-?\d+(?:\.\d+)?/i,td=/true|false/i,nd=/null/i,rd=/^[^A-Z]*$/,id=/^[^a-z]*$/,rn=q("$ZodCheck",(t,n)=>{var o;t._zod??(t._zod={}),t._zod.def=n,(o=t._zod).onattach??(o.onattach=[])}),Tc={number:"number",bigint:"bigint",object:"date"},Oc=q("$ZodCheckLessThan",(t,n)=>{rn.init(t,n);const o=Tc[typeof n.value];t._zod.onattach.push(l=>{const u=l._zod.bag,f=(n.inclusive?u.maximum:u.exclusiveMaximum)??Number.POSITIVE_INFINITY;n.value<f&&(n.inclusive?u.maximum=n.value:u.exclusiveMaximum=n.value)}),t._zod.check=l=>{(n.inclusive?l.value<=n.value:l.value<n.value)||l.issues.push({origin:o,code:"too_big",maximum:n.value,input:l.value,inclusive:n.inclusive,inst:t,continue:!n.abort})}}),Nc=q("$ZodCheckGreaterThan",(t,n)=>{rn.init(t,n);const o=Tc[typeof n.value];t._zod.onattach.push(l=>{const u=l._zod.bag,f=(n.inclusive?u.minimum:u.exclusiveMinimum)??Number.NEGATIVE_INFINITY;n.value>f&&(n.inclusive?u.minimum=n.value:u.exclusiveMinimum=n.value)}),t._zod.check=l=>{(n.inclusive?l.value>=n.value:l.value>n.value)||l.issues.push({origin:o,code:"too_small",minimum:n.value,input:l.value,inclusive:n.inclusive,inst:t,continue:!n.abort})}}),od=q("$ZodCheckMultipleOf",(t,n)=>{rn.init(t,n),t._zod.onattach.push(o=>{var l;(l=o._zod.bag).multipleOf??(l.multipleOf=n.value)}),t._zod.check=o=>{if(typeof o.value!=typeof n.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof o.value=="bigint"?o.value%n.value===BigInt(0):p0(o.value,n.value)===0)||o.issues.push({origin:typeof o.value,code:"not_multiple_of",divisor:n.value,input:o.value,inst:t,continue:!n.abort})}}),sd=q("$ZodCheckNumberFormat",(t,n)=>{rn.init(t,n),n.format=n.format||"float64";const o=n.format?.includes("int"),l=o?"int":"number",[u,f]=w0[n.format];t._zod.onattach.push(g=>{const m=g._zod.bag;m.format=n.format,m.minimum=u,m.maximum=f,o&&(m.pattern=Q0)}),t._zod.check=g=>{const m=g.value;if(o){if(!Number.isInteger(m)){g.issues.push({expected:l,format:n.format,code:"invalid_type",input:m,inst:t});return}if(!Number.isSafeInteger(m)){m>0?g.issues.push({input:m,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:l,continue:!n.abort}):g.issues.push({input:m,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:l,continue:!n.abort});return}}m<u&&g.issues.push({origin:"number",input:m,code:"too_small",minimum:u,inclusive:!0,inst:t,continue:!n.abort}),m>f&&g.issues.push({origin:"number",input:m,code:"too_big",maximum:f,inst:t})}}),ad=q("$ZodCheckMaxLength",(t,n)=>{var o;rn.init(t,n),(o=t._zod.def).when??(o.when=l=>{const u=l.value;return!rs(u)&&u.length!==void 0}),t._zod.onattach.push(l=>{const u=l._zod.bag.maximum??Number.POSITIVE_INFINITY;n.maximum<u&&(l._zod.bag.maximum=n.maximum)}),t._zod.check=l=>{const u=l.value;if(u.length<=n.maximum)return;const g=ss(u);l.issues.push({origin:g,code:"too_big",maximum:n.maximum,inclusive:!0,input:u,inst:t,continue:!n.abort})}}),ld=q("$ZodCheckMinLength",(t,n)=>{var o;rn.init(t,n),(o=t._zod.def).when??(o.when=l=>{const u=l.value;return!rs(u)&&u.length!==void 0}),t._zod.onattach.push(l=>{const u=l._zod.bag.minimum??Number.NEGATIVE_INFINITY;n.minimum>u&&(l._zod.bag.minimum=n.minimum)}),t._zod.check=l=>{const u=l.value;if(u.length>=n.minimum)return;const g=ss(u);l.issues.push({origin:g,code:"too_small",minimum:n.minimum,inclusive:!0,input:u,inst:t,continue:!n.abort})}}),cd=q("$ZodCheckLengthEquals",(t,n)=>{var o;rn.init(t,n),(o=t._zod.def).when??(o.when=l=>{const u=l.value;return!rs(u)&&u.length!==void 0}),t._zod.onattach.push(l=>{const u=l._zod.bag;u.minimum=n.length,u.maximum=n.length,u.length=n.length}),t._zod.check=l=>{const u=l.value,f=u.length;if(f===n.length)return;const g=ss(u),m=f>n.length;l.issues.push({origin:g,...m?{code:"too_big",maximum:n.length}:{code:"too_small",minimum:n.length},inclusive:!0,exact:!0,input:l.value,inst:t,continue:!n.abort})}}),Ji=q("$ZodCheckStringFormat",(t,n)=>{var o,l;rn.init(t,n),t._zod.onattach.push(u=>{const f=u._zod.bag;f.format=n.format,n.pattern&&(f.patterns??(f.patterns=new Set),f.patterns.add(n.pattern))}),n.pattern?(o=t._zod).check??(o.check=u=>{n.pattern.lastIndex=0,!n.pattern.test(u.value)&&u.issues.push({origin:"string",code:"invalid_format",format:n.format,input:u.value,...n.pattern?{pattern:n.pattern.toString()}:{},inst:t,continue:!n.abort})}):(l=t._zod).check??(l.check=()=>{})}),ud=q("$ZodCheckRegex",(t,n)=>{Ji.init(t,n),t._zod.check=o=>{n.pattern.lastIndex=0,!n.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:"regex",input:o.value,pattern:n.pattern.toString(),inst:t,continue:!n.abort})}}),dd=q("$ZodCheckLowerCase",(t,n)=>{n.pattern??(n.pattern=rd),Ji.init(t,n)}),fd=q("$ZodCheckUpperCase",(t,n)=>{n.pattern??(n.pattern=id),Ji.init(t,n)}),hd=q("$ZodCheckIncludes",(t,n)=>{rn.init(t,n);const o=oi(n.includes),l=new RegExp(typeof n.position=="number"?`^.{${n.position}}${o}`:o);n.pattern=l,t._zod.onattach.push(u=>{const f=u._zod.bag;f.patterns??(f.patterns=new Set),f.patterns.add(l)}),t._zod.check=u=>{u.value.includes(n.includes,n.position)||u.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:n.includes,input:u.value,inst:t,continue:!n.abort})}}),pd=q("$ZodCheckStartsWith",(t,n)=>{rn.init(t,n);const o=new RegExp(`^${oi(n.prefix)}.*`);n.pattern??(n.pattern=o),t._zod.onattach.push(l=>{const u=l._zod.bag;u.patterns??(u.patterns=new Set),u.patterns.add(o)}),t._zod.check=l=>{l.value.startsWith(n.prefix)||l.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:n.prefix,input:l.value,inst:t,continue:!n.abort})}}),gd=q("$ZodCheckEndsWith",(t,n)=>{rn.init(t,n);const o=new RegExp(`.*${oi(n.suffix)}$`);n.pattern??(n.pattern=o),t._zod.onattach.push(l=>{const u=l._zod.bag;u.patterns??(u.patterns=new Set),u.patterns.add(o)}),t._zod.check=l=>{l.value.endsWith(n.suffix)||l.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:n.suffix,input:l.value,inst:t,continue:!n.abort})}}),md=q("$ZodCheckOverwrite",(t,n)=>{rn.init(t,n),t._zod.check=o=>{o.value=n.tx(o.value)}});class xd{constructor(n=[]){this.content=[],this.indent=0,this&&(this.args=n)}indented(n){this.indent+=1,n(this),this.indent-=1}write(n){if(typeof n=="function"){n(this,{execution:"sync"}),n(this,{execution:"async"});return}const l=n.split(`
8
- `).filter(g=>g),u=Math.min(...l.map(g=>g.length-g.trimStart().length)),f=l.map(g=>g.slice(u)).map(g=>" ".repeat(this.indent*2)+g);for(const g of f)this.content.push(g)}compile(){const n=Function,o=this?.args,u=[...(this?.content??[""]).map(f=>` ${f}`)];return new n(...o,u.join(`
9
- `))}}const wd={major:4,minor:0,patch:0},st=q("$ZodType",(t,n)=>{var o;t??(t={}),t._zod.def=n,t._zod.bag=t._zod.bag||{},t._zod.version=wd;const l=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&l.unshift(t);for(const u of l)for(const f of u._zod.onattach)f(t);if(l.length===0)(o=t._zod).deferred??(o.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{const u=(f,g,m)=>{let y=Xr(f),x;for(const A of g){if(A._zod.def.when){if(!A._zod.def.when(f))continue}else if(y)continue;const b=f.issues.length,P=A._zod.check(f);if(P instanceof Promise&&m?.async===!1)throw new Kr;if(x||P instanceof Promise)x=(x??Promise.resolve()).then(async()=>{await P,f.issues.length!==b&&(y||(y=Xr(f,b)))});else{if(f.issues.length===b)continue;y||(y=Xr(f,b))}}return x?x.then(()=>f):f};t._zod.run=(f,g)=>{const m=t._zod.parse(f,g);if(m instanceof Promise){if(g.async===!1)throw new Kr;return m.then(y=>u(y,l,g))}return u(m,l,g)}}t["~standard"]={validate:u=>{try{const f=O0(t,u);return f.success?{value:f.data}:{issues:f.error?.issues}}catch{return N0(t,u).then(g=>g.success?{value:g.data}:{issues:g.error?.issues})}},vendor:"zod",version:1}}),as=q("$ZodString",(t,n)=>{st.init(t,n),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??J0(t._zod.bag),t._zod.parse=(o,l)=>{if(n.coerce)try{o.value=String(o.value)}catch{}return typeof o.value=="string"||o.issues.push({expected:"string",code:"invalid_type",input:o.value,inst:t}),o}}),gt=q("$ZodStringFormat",(t,n)=>{Ji.init(t,n),as.init(t,n)}),yd=q("$ZodGUID",(t,n)=>{n.pattern??(n.pattern=F0),gt.init(t,n)}),_d=q("$ZodUUID",(t,n)=>{if(n.version){const l={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[n.version];if(l===void 0)throw new Error(`Invalid UUID version: "${n.version}"`);n.pattern??(n.pattern=Ws(l))}else n.pattern??(n.pattern=Ws());gt.init(t,n)}),vd=q("$ZodEmail",(t,n)=>{n.pattern??(n.pattern=$0),gt.init(t,n)}),Cd=q("$ZodURL",(t,n)=>{gt.init(t,n),t._zod.check=o=>{try{const l=o.value,u=new URL(l),f=u.href;n.hostname&&(n.hostname.lastIndex=0,n.hostname.test(u.hostname)||o.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:G0.source,input:o.value,inst:t,continue:!n.abort})),n.protocol&&(n.protocol.lastIndex=0,n.protocol.test(u.protocol.endsWith(":")?u.protocol.slice(0,-1):u.protocol)||o.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:n.protocol.source,input:o.value,inst:t,continue:!n.abort})),!l.endsWith("/")&&f.endsWith("/")?o.value=f.slice(0,-1):o.value=f;return}catch{o.issues.push({code:"invalid_format",format:"url",input:o.value,inst:t,continue:!n.abort})}}}),bd=q("$ZodEmoji",(t,n)=>{n.pattern??(n.pattern=z0()),gt.init(t,n)}),Ed=q("$ZodNanoID",(t,n)=>{n.pattern??(n.pattern=B0),gt.init(t,n)}),Ad=q("$ZodCUID",(t,n)=>{n.pattern??(n.pattern=k0),gt.init(t,n)}),Id=q("$ZodCUID2",(t,n)=>{n.pattern??(n.pattern=R0),gt.init(t,n)}),Sd=q("$ZodULID",(t,n)=>{n.pattern??(n.pattern=D0),gt.init(t,n)}),Td=q("$ZodXID",(t,n)=>{n.pattern??(n.pattern=M0),gt.init(t,n)}),Od=q("$ZodKSUID",(t,n)=>{n.pattern??(n.pattern=P0),gt.init(t,n)}),Nd=q("$ZodISODateTime",(t,n)=>{n.pattern??(n.pattern=K0(n)),gt.init(t,n)}),kd=q("$ZodISODate",(t,n)=>{n.pattern??(n.pattern=Y0),gt.init(t,n)}),Rd=q("$ZodISOTime",(t,n)=>{n.pattern??(n.pattern=q0(n)),gt.init(t,n)}),Dd=q("$ZodISODuration",(t,n)=>{n.pattern??(n.pattern=L0),gt.init(t,n)}),Md=q("$ZodIPv4",(t,n)=>{n.pattern??(n.pattern=Z0),gt.init(t,n),t._zod.onattach.push(o=>{const l=o._zod.bag;l.format="ipv4"})}),Pd=q("$ZodIPv6",(t,n)=>{n.pattern??(n.pattern=V0),gt.init(t,n),t._zod.onattach.push(o=>{const l=o._zod.bag;l.format="ipv6"}),t._zod.check=o=>{try{new URL(`http://[${o.value}]`)}catch{o.issues.push({code:"invalid_format",format:"ipv6",input:o.value,inst:t,continue:!n.abort})}}}),Bd=q("$ZodCIDRv4",(t,n)=>{n.pattern??(n.pattern=j0),gt.init(t,n)}),Ld=q("$ZodCIDRv6",(t,n)=>{n.pattern??(n.pattern=H0),gt.init(t,n),t._zod.check=o=>{const[l,u]=o.value.split("/");try{if(!u)throw new Error;const f=Number(u);if(`${f}`!==u)throw new Error;if(f<0||f>128)throw new Error;new URL(`http://[${l}]`)}catch{o.issues.push({code:"invalid_format",format:"cidrv6",input:o.value,inst:t,continue:!n.abort})}}});function kc(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const Fd=q("$ZodBase64",(t,n)=>{n.pattern??(n.pattern=W0),gt.init(t,n),t._zod.onattach.push(o=>{o._zod.bag.contentEncoding="base64"}),t._zod.check=o=>{kc(o.value)||o.issues.push({code:"invalid_format",format:"base64",input:o.value,inst:t,continue:!n.abort})}});function $d(t){if(!Ac.test(t))return!1;const n=t.replace(/[-_]/g,l=>l==="-"?"+":"/"),o=n.padEnd(Math.ceil(n.length/4)*4,"=");return kc(o)}const Ud=q("$ZodBase64URL",(t,n)=>{n.pattern??(n.pattern=Ac),gt.init(t,n),t._zod.onattach.push(o=>{o._zod.bag.contentEncoding="base64url"}),t._zod.check=o=>{$d(o.value)||o.issues.push({code:"invalid_format",format:"base64url",input:o.value,inst:t,continue:!n.abort})}}),zd=q("$ZodE164",(t,n)=>{n.pattern??(n.pattern=X0),gt.init(t,n)});function Zd(t,n=null){try{const o=t.split(".");if(o.length!==3)return!1;const[l]=o;if(!l)return!1;const u=JSON.parse(atob(l));return!("typ"in u&&u?.typ!=="JWT"||!u.alg||n&&(!("alg"in u)||u.alg!==n))}catch{return!1}}const Vd=q("$ZodJWT",(t,n)=>{gt.init(t,n),t._zod.check=o=>{Zd(o.value,n.alg)||o.issues.push({code:"invalid_format",format:"jwt",input:o.value,inst:t,continue:!n.abort})}}),Rc=q("$ZodNumber",(t,n)=>{st.init(t,n),t._zod.pattern=t._zod.bag.pattern??ed,t._zod.parse=(o,l)=>{if(n.coerce)try{o.value=Number(o.value)}catch{}const u=o.value;if(typeof u=="number"&&!Number.isNaN(u)&&Number.isFinite(u))return o;const f=typeof u=="number"?Number.isNaN(u)?"NaN":Number.isFinite(u)?void 0:"Infinity":void 0;return o.issues.push({expected:"number",code:"invalid_type",input:u,inst:t,...f?{received:f}:{}}),o}}),jd=q("$ZodNumber",(t,n)=>{sd.init(t,n),Rc.init(t,n)}),Hd=q("$ZodBoolean",(t,n)=>{st.init(t,n),t._zod.pattern=td,t._zod.parse=(o,l)=>{if(n.coerce)try{o.value=!!o.value}catch{}const u=o.value;return typeof u=="boolean"||o.issues.push({expected:"boolean",code:"invalid_type",input:u,inst:t}),o}}),Wd=q("$ZodNull",(t,n)=>{st.init(t,n),t._zod.pattern=nd,t._zod.values=new Set([null]),t._zod.parse=(o,l)=>{const u=o.value;return u===null||o.issues.push({expected:"null",code:"invalid_type",input:u,inst:t}),o}}),Gd=q("$ZodAny",(t,n)=>{st.init(t,n),t._zod.parse=o=>o}),Xd=q("$ZodUnknown",(t,n)=>{st.init(t,n),t._zod.parse=o=>o}),Yd=q("$ZodNever",(t,n)=>{st.init(t,n),t._zod.parse=(o,l)=>(o.issues.push({expected:"never",code:"invalid_type",input:o.value,inst:t}),o)});function Gs(t,n,o){t.issues.length&&n.issues.push(...fr(o,t.issues)),n.value[o]=t.value}const qd=q("$ZodArray",(t,n)=>{st.init(t,n),t._zod.parse=(o,l)=>{const u=o.value;if(!Array.isArray(u))return o.issues.push({expected:"array",code:"invalid_type",input:u,inst:t}),o;o.value=Array(u.length);const f=[];for(let g=0;g<u.length;g++){const m=u[g],y=n.element._zod.run({value:m,issues:[]},l);y instanceof Promise?f.push(y.then(x=>Gs(x,o,g))):Gs(y,o,g)}return f.length?Promise.all(f).then(()=>o):o}});function Ei(t,n,o){t.issues.length&&n.issues.push(...fr(o,t.issues)),n.value[o]=t.value}function Xs(t,n,o,l){t.issues.length?l[o]===void 0?o in l?n.value[o]=void 0:n.value[o]=t.value:n.issues.push(...fr(o,t.issues)):t.value===void 0?o in l&&(n.value[o]=void 0):n.value[o]=t.value}const Kd=q("$ZodObject",(t,n)=>{st.init(t,n);const o=ns(()=>{const b=Object.keys(n.shape);for(const N of b)if(!(n.shape[N]instanceof st))throw new Error(`Invalid element at key "${N}": expected a Zod schema`);const P=x0(n.shape);return{shape:n.shape,keys:b,keySet:new Set(b),numKeys:b.length,optionalKeys:new Set(P)}});Qe(t._zod,"propValues",()=>{const b=n.shape,P={};for(const N in b){const R=b[N]._zod;if(R.values){P[N]??(P[N]=new Set);for(const D of R.values)P[N].add(D)}}return P});const l=b=>{const P=new xd(["shape","payload","ctx"]),N=o.value,R=U=>{const k=Ur(U);return`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`};P.write("const input = payload.value;");const D=Object.create(null);let M=0;for(const U of N.keys)D[U]=`key_${M++}`;P.write("const newResult = {}");for(const U of N.keys)if(N.optionalKeys.has(U)){const k=D[U];P.write(`const ${k} = ${R(U)};`);const K=Ur(U);P.write(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("vue"),Gt=require("@opentiny/tiny-robot"),U1=require("@opentiny/genui-sdk-vue"),or=require("@opentiny/tiny-robot-kit"),Di=require("@opentiny/tiny-robot-svgs"),Hi=require("@opentiny/next-sdk"),z1=require("@opentiny/vue-icon");function V1(t,r){for(var o=0;o<r.length;o++){const l=r[o];if(typeof l!="string"&&!Array.isArray(l)){for(const u in l)if(u!=="default"&&!(u in t)){const f=Object.getOwnPropertyDescriptor(l,u);f&&Object.defineProperty(t,u,f.get?f:{enumerable:!0,get:()=>l[u]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var Nl="vercel.ai.error",Z1=Symbol.for(Nl),Ol,j1=class kl extends Error{constructor({name:r,message:o,cause:l}){super(o),this[Ol]=!0,this.name=r,this.cause=l}static isInstance(r){return kl.hasMarker(r,Nl)}static hasMarker(r,o){const l=Symbol.for(o);return r!=null&&typeof r=="object"&&l in r&&typeof r[l]=="boolean"&&r[l]===!0}};Ol=Z1;var Ct=j1,Rl="AI_APICallError",Dl=`vercel.ai.error.${Rl}`,H1=Symbol.for(Dl),Ml,Bn=class extends Ct{constructor({message:r,url:o,requestBodyValues:l,statusCode:u,responseHeaders:f,responseBody:g,cause:x,isRetryable:y=u!=null&&(u===408||u===409||u===429||u>=500),data:m}){super({name:Rl,message:r,cause:x}),this[Ml]=!0,this.url=o,this.requestBodyValues=l,this.statusCode=u,this.responseHeaders=f,this.responseBody=g,this.isRetryable=y,this.data=m}static isInstance(r){return Ct.hasMarker(r,Dl)}};Ml=H1;var Pl="AI_EmptyResponseBodyError",Bl=`vercel.ai.error.${Pl}`,W1=Symbol.for(Bl),Ll,G1=class extends Ct{constructor({message:r="Empty response body"}={}){super({name:Pl,message:r}),this[Ll]=!0}static isInstance(r){return Ct.hasMarker(r,Bl)}};Ll=W1;function Fl(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var $l="AI_InvalidArgumentError",Ul=`vercel.ai.error.${$l}`,X1=Symbol.for(Ul),zl,Vl=class extends Ct{constructor({message:r,cause:o,argument:l}){super({name:$l,message:r,cause:o}),this[zl]=!0,this.argument=l}static isInstance(r){return Ct.hasMarker(r,Ul)}};zl=X1;var Zl="AI_InvalidResponseDataError",jl=`vercel.ai.error.${Zl}`,q1=Symbol.for(jl),Hl,Bs=class extends Ct{constructor({data:r,message:o=`Invalid response data: ${JSON.stringify(r)}.`}){super({name:Zl,message:o}),this[Hl]=!0,this.data=r}static isInstance(r){return Ct.hasMarker(r,jl)}};Hl=q1;var Wl="AI_JSONParseError",Gl=`vercel.ai.error.${Wl}`,Y1=Symbol.for(Gl),Xl,Mi=class extends Ct{constructor({text:r,cause:o}){super({name:Wl,message:`JSON parsing failed: Text: ${r}.
2
+ Error message: ${Fl(o)}`,cause:o}),this[Xl]=!0,this.text=r}static isInstance(r){return Ct.hasMarker(r,Gl)}};Xl=Y1;var ql="AI_LoadAPIKeyError",Yl=`vercel.ai.error.${ql}`,K1=Symbol.for(Yl),Kl,xi=class extends Ct{constructor({message:r}){super({name:ql,message:r}),this[Kl]=!0}static isInstance(r){return Ct.hasMarker(r,Yl)}};Kl=K1;var Jl="AI_NoSuchModelError",Ql=`vercel.ai.error.${Jl}`,J1=Symbol.for(Ql),ec,Ls=class extends Ct{constructor({errorName:t=Jl,modelId:r,modelType:o,message:l=`No such ${o}: ${r}`}){super({name:t,message:l}),this[ec]=!0,this.modelId=r,this.modelType=o}static isInstance(t){return Ct.hasMarker(t,Ql)}};ec=J1;var tc="AI_TypeValidationError",nc=`vercel.ai.error.${tc}`,Q1=Symbol.for(nc),rc,ed=class Mo extends Ct{constructor({value:r,cause:o}){super({name:tc,message:`Type validation failed: Value: ${JSON.stringify(r)}.
3
+ Error message: ${Fl(o)}`,cause:o}),this[rc]=!0,this.value=r}static isInstance(r){return Ct.hasMarker(r,nc)}static wrap({value:r,cause:o}){return Mo.isInstance(o)&&o.value===r?o:new Mo({value:r,cause:o})}};rc=Q1;var Wr=ed,ic="AI_UnsupportedFunctionalityError",oc=`vercel.ai.error.${ic}`,td=Symbol.for(oc),sc,ac=class extends Ct{constructor({functionality:r,message:o=`'${r}' functionality not supported.`}){super({name:ic,message:o}),this[sc]=!0,this.functionality=r}static isInstance(r){return Ct.hasMarker(r,oc)}};sc=td;class Fs extends Error{constructor(r,o){super(r),this.name="ParseError",this.type=o.type,this.field=o.field,this.value=o.value,this.line=o.line}}function yo(t){}function nd(t){if(typeof t=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:r=yo,onError:o=yo,onRetry:l=yo,onComment:u}=t;let f="",g=!0,x,y="",m="";function E(R){const M=g?R.replace(/^\xEF\xBB\xBF/,""):R,[V,U]=rd(`${f}${M}`);for(const k of V)C(k);f=U,g=!1}function C(R){if(R===""){O();return}if(R.startsWith(":")){u&&u(R.slice(R.startsWith(": ")?2:1));return}const M=R.indexOf(":");if(M!==-1){const V=R.slice(0,M),U=R[M+1]===" "?2:1,k=R.slice(M+U);P(V,k,R);return}P(R,"",R)}function P(R,M,V){switch(R){case"event":m=M;break;case"data":y=`${y}${M}
4
+ `;break;case"id":x=M.includes("\0")?void 0:M;break;case"retry":/^\d+$/.test(M)?l(parseInt(M,10)):o(new Fs(`Invalid \`retry\` value: "${M}"`,{type:"invalid-retry",value:M,line:V}));break;default:o(new Fs(`Unknown field "${R.length>20?`${R.slice(0,20)}…`:R}"`,{type:"unknown-field",field:R,value:M,line:V}));break}}function O(){y.length>0&&r({id:x,event:m||void 0,data:y.endsWith(`
5
+ `)?y.slice(0,-1):y}),x=void 0,y="",m=""}function D(R={}){f&&R.consume&&C(f),g=!0,x=void 0,y="",m="",f=""}return{feed:E,reset:D}}function rd(t){const r=[];let o="",l=0;for(;l<t.length;){const u=t.indexOf("\r",l),f=t.indexOf(`
6
+ `,l);let g=-1;if(u!==-1&&f!==-1?g=Math.min(u,f):u!==-1?u===t.length-1?g=-1:g=u:f!==-1&&(g=f),g===-1){o=t.slice(l);break}else{const x=t.slice(l,g);r.push(x),l=g+1,t[l-1]==="\r"&&t[l]===`
7
+ `&&l++}}return[r,o]}class lc extends TransformStream{constructor({onError:r,onRetry:o,onComment:l}={}){let u;super({start(f){u=nd({onEvent:g=>{f.enqueue(g)},onError(g){r==="terminate"?f.error(g):typeof r=="function"&&r(g)},onRetry:o,onComment:l})},transform(f){u.feed(f)}})}}function Q(t,r,o){function l(x,y){var m;Object.defineProperty(x,"_zod",{value:x._zod??{},enumerable:!1}),(m=x._zod).traits??(m.traits=new Set),x._zod.traits.add(t),r(x,y);for(const E in g.prototype)E in x||Object.defineProperty(x,E,{value:g.prototype[E].bind(x)});x._zod.constr=g,x._zod.def=y}const u=o?.Parent??Object;class f extends u{}Object.defineProperty(f,"name",{value:t});function g(x){var y;const m=o?.Parent?new f:this;l(m,x),(y=m._zod).deferred??(y.deferred=[]);for(const E of m._zod.deferred)E();return m}return Object.defineProperty(g,"init",{value:l}),Object.defineProperty(g,Symbol.hasInstance,{value:x=>o?.Parent&&x instanceof o.Parent?!0:x?._zod?.traits?.has(t)}),Object.defineProperty(g,"name",{value:t}),g}class Gr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const cc={};function qn(t){return cc}function uc(t){const r=Object.values(t).filter(l=>typeof l=="number");return Object.entries(t).filter(([l,u])=>r.indexOf(+l)===-1).map(([l,u])=>u)}function id(t,r){return typeof r=="bigint"?r.toString():r}function qo(t){return{get value(){{const r=t();return Object.defineProperty(this,"value",{value:r}),r}}}}function Yo(t){return t==null}function Ko(t){const r=t.startsWith("^")?1:0,o=t.endsWith("$")?t.length-1:t.length;return t.slice(r,o)}function od(t,r){const o=(t.toString().split(".")[1]||"").length,l=(r.toString().split(".")[1]||"").length,u=o>l?o:l,f=Number.parseInt(t.toFixed(u).replace(".","")),g=Number.parseInt(r.toFixed(u).replace(".",""));return f%g/10**u}function Xe(t,r,o){Object.defineProperty(t,r,{get(){{const l=o();return t[r]=l,l}},set(l){Object.defineProperty(t,r,{value:l})},configurable:!0})}function Jo(t,r,o){Object.defineProperty(t,r,{value:o,writable:!0,enumerable:!0,configurable:!0})}function Br(t){return JSON.stringify(t)}const dc=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function Pi(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const sd=qo(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Bi(t){if(Pi(t)===!1)return!1;const r=t.constructor;if(r===void 0)return!0;const o=r.prototype;return!(Pi(o)===!1||Object.prototype.hasOwnProperty.call(o,"isPrototypeOf")===!1)}const ad=new Set(["string","number","symbol"]);function ti(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ar(t,r,o){const l=new t._zod.constr(r??t._zod.def);return(!r||o?.parent)&&(l._zod.parent=t),l}function Te(t){const r=t;if(!r)return{};if(typeof r=="string")return{error:()=>r};if(r?.message!==void 0){if(r?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");r.error=r.message}return delete r.message,typeof r.error=="string"?{...r,error:()=>r.error}:r}function ld(t){return Object.keys(t).filter(r=>t[r]._zod.optin==="optional"&&t[r]._zod.optout==="optional")}const cd={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ud(t,r){const o={},l=t._zod.def;for(const u in r){if(!(u in l.shape))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(o[u]=l.shape[u])}return ar(t,{...t._zod.def,shape:o,checks:[]})}function dd(t,r){const o={...t._zod.def.shape},l=t._zod.def;for(const u in r){if(!(u in l.shape))throw new Error(`Unrecognized key: "${u}"`);r[u]&&delete o[u]}return ar(t,{...t._zod.def,shape:o,checks:[]})}function fd(t,r){if(!Bi(r))throw new Error("Invalid input to extend: expected a plain object");const o={...t._zod.def,get shape(){const l={...t._zod.def.shape,...r};return Jo(this,"shape",l),l},checks:[]};return ar(t,o)}function hd(t,r){return ar(t,{...t._zod.def,get shape(){const o={...t._zod.def.shape,...r._zod.def.shape};return Jo(this,"shape",o),o},catchall:r._zod.def.catchall,checks:[]})}function pd(t,r,o){const l=r._zod.def.shape,u={...l};if(o)for(const f in o){if(!(f in l))throw new Error(`Unrecognized key: "${f}"`);o[f]&&(u[f]=t?new t({type:"optional",innerType:l[f]}):l[f])}else for(const f in l)u[f]=t?new t({type:"optional",innerType:l[f]}):l[f];return ar(r,{...r._zod.def,shape:u,checks:[]})}function gd(t,r,o){const l=r._zod.def.shape,u={...l};if(o)for(const f in o){if(!(f in u))throw new Error(`Unrecognized key: "${f}"`);o[f]&&(u[f]=new t({type:"nonoptional",innerType:l[f]}))}else for(const f in l)u[f]=new t({type:"nonoptional",innerType:l[f]});return ar(r,{...r._zod.def,shape:u,checks:[]})}function jr(t,r=0){for(let o=r;o<t.issues.length;o++)if(t.issues[o]?.continue!==!0)return!0;return!1}function sr(t,r){return r.map(o=>{var l;return(l=o).path??(l.path=[]),o.path.unshift(t),o})}function wi(t){return typeof t=="string"?t:t?.message}function Yn(t,r,o){const l={...t,path:t.path??[]};if(!t.message){const u=wi(t.inst?._zod.def?.error?.(t))??wi(r?.error?.(t))??wi(o.customError?.(t))??wi(o.localeError?.(t))??"Invalid input";l.message=u}return delete l.inst,delete l.continue,r?.reportInput||delete l.input,l}function Qo(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Xr(...t){const[r,o,l]=t;return typeof r=="string"?{message:r,code:"custom",input:o,inst:l}:{...r}}const fc=(t,r)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:r,enumerable:!1}),Object.defineProperty(t,"message",{get(){return JSON.stringify(r,id,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},hc=Q("$ZodError",fc),pc=Q("$ZodError",fc,{Parent:Error});function md(t,r=o=>o.message){const o={},l=[];for(const u of t.issues)u.path.length>0?(o[u.path[0]]=o[u.path[0]]||[],o[u.path[0]].push(r(u))):l.push(r(u));return{formErrors:l,fieldErrors:o}}function xd(t,r){const o=r||function(f){return f.message},l={_errors:[]},u=f=>{for(const g of f.issues)if(g.code==="invalid_union"&&g.errors.length)g.errors.map(x=>u({issues:x}));else if(g.code==="invalid_key")u({issues:g.issues});else if(g.code==="invalid_element")u({issues:g.issues});else if(g.path.length===0)l._errors.push(o(g));else{let x=l,y=0;for(;y<g.path.length;){const m=g.path[y];y===g.path.length-1?(x[m]=x[m]||{_errors:[]},x[m]._errors.push(o(g))):x[m]=x[m]||{_errors:[]},x=x[m],y++}}};return u(t),l}const wd=t=>(r,o,l,u)=>{const f=l?Object.assign(l,{async:!1}):{async:!1},g=r._zod.run({value:o,issues:[]},f);if(g instanceof Promise)throw new Gr;if(g.issues.length){const x=new(u?.Err??t)(g.issues.map(y=>Yn(y,f,qn())));throw dc(x,u?.callee),x}return g.value},yd=t=>async(r,o,l,u)=>{const f=l?Object.assign(l,{async:!0}):{async:!0};let g=r._zod.run({value:o,issues:[]},f);if(g instanceof Promise&&(g=await g),g.issues.length){const x=new(u?.Err??t)(g.issues.map(y=>Yn(y,f,qn())));throw dc(x,u?.callee),x}return g.value},gc=t=>(r,o,l)=>{const u=l?{...l,async:!1}:{async:!1},f=r._zod.run({value:o,issues:[]},u);if(f instanceof Promise)throw new Gr;return f.issues.length?{success:!1,error:new(t??hc)(f.issues.map(g=>Yn(g,u,qn())))}:{success:!0,data:f.value}},_d=gc(pc),mc=t=>async(r,o,l)=>{const u=l?Object.assign(l,{async:!0}):{async:!0};let f=r._zod.run({value:o,issues:[]},u);return f instanceof Promise&&(f=await f),f.issues.length?{success:!1,error:new t(f.issues.map(g=>Yn(g,u,qn())))}:{success:!0,data:f.value}},vd=mc(pc),bd=/^[cC][^\s-]{8,}$/,Cd=/^[0-9a-z]+$/,Ed=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ad=/^[0-9a-vA-V]{20}$/,Id=/^[A-Za-z0-9]{27}$/,Sd=/^[a-zA-Z0-9_-]{21}$/,Td=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Nd=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,$s=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,Od=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,kd="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Rd(){return new RegExp(kd,"u")}const Dd=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Md=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,Pd=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Bd=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ld=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,xc=/^[A-Za-z0-9_-]*$/,Fd=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,$d=/^\+(?:[0-9]){6,14}[0-9]$/,wc="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Ud=new RegExp(`^${wc}$`);function yc(t){const r="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${r}`:t.precision===0?`${r}:[0-5]\\d`:`${r}:[0-5]\\d\\.\\d{${t.precision}}`:`${r}(?::[0-5]\\d(?:\\.\\d+)?)?`}function zd(t){return new RegExp(`^${yc(t)}$`)}function Vd(t){const r=yc({precision:t.precision}),o=["Z"];t.local&&o.push(""),t.offset&&o.push("([+-]\\d{2}:\\d{2})");const l=`${r}(?:${o.join("|")})`;return new RegExp(`^${wc}T(?:${l})$`)}const Zd=t=>{const r=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${r}$`)},jd=/^\d+$/,Hd=/^-?\d+(?:\.\d+)?/i,Wd=/true|false/i,Gd=/null/i,Xd=/^[^A-Z]*$/,qd=/^[^a-z]*$/,tn=Q("$ZodCheck",(t,r)=>{var o;t._zod??(t._zod={}),t._zod.def=r,(o=t._zod).onattach??(o.onattach=[])}),_c={number:"number",bigint:"bigint",object:"date"},vc=Q("$ZodCheckLessThan",(t,r)=>{tn.init(t,r);const o=_c[typeof r.value];t._zod.onattach.push(l=>{const u=l._zod.bag,f=(r.inclusive?u.maximum:u.exclusiveMaximum)??Number.POSITIVE_INFINITY;r.value<f&&(r.inclusive?u.maximum=r.value:u.exclusiveMaximum=r.value)}),t._zod.check=l=>{(r.inclusive?l.value<=r.value:l.value<r.value)||l.issues.push({origin:o,code:"too_big",maximum:r.value,input:l.value,inclusive:r.inclusive,inst:t,continue:!r.abort})}}),bc=Q("$ZodCheckGreaterThan",(t,r)=>{tn.init(t,r);const o=_c[typeof r.value];t._zod.onattach.push(l=>{const u=l._zod.bag,f=(r.inclusive?u.minimum:u.exclusiveMinimum)??Number.NEGATIVE_INFINITY;r.value>f&&(r.inclusive?u.minimum=r.value:u.exclusiveMinimum=r.value)}),t._zod.check=l=>{(r.inclusive?l.value>=r.value:l.value>r.value)||l.issues.push({origin:o,code:"too_small",minimum:r.value,input:l.value,inclusive:r.inclusive,inst:t,continue:!r.abort})}}),Yd=Q("$ZodCheckMultipleOf",(t,r)=>{tn.init(t,r),t._zod.onattach.push(o=>{var l;(l=o._zod.bag).multipleOf??(l.multipleOf=r.value)}),t._zod.check=o=>{if(typeof o.value!=typeof r.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof o.value=="bigint"?o.value%r.value===BigInt(0):od(o.value,r.value)===0)||o.issues.push({origin:typeof o.value,code:"not_multiple_of",divisor:r.value,input:o.value,inst:t,continue:!r.abort})}}),Kd=Q("$ZodCheckNumberFormat",(t,r)=>{tn.init(t,r),r.format=r.format||"float64";const o=r.format?.includes("int"),l=o?"int":"number",[u,f]=cd[r.format];t._zod.onattach.push(g=>{const x=g._zod.bag;x.format=r.format,x.minimum=u,x.maximum=f,o&&(x.pattern=jd)}),t._zod.check=g=>{const x=g.value;if(o){if(!Number.isInteger(x)){g.issues.push({expected:l,format:r.format,code:"invalid_type",input:x,inst:t});return}if(!Number.isSafeInteger(x)){x>0?g.issues.push({input:x,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:l,continue:!r.abort}):g.issues.push({input:x,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:l,continue:!r.abort});return}}x<u&&g.issues.push({origin:"number",input:x,code:"too_small",minimum:u,inclusive:!0,inst:t,continue:!r.abort}),x>f&&g.issues.push({origin:"number",input:x,code:"too_big",maximum:f,inst:t})}}),Jd=Q("$ZodCheckMaxLength",(t,r)=>{var o;tn.init(t,r),(o=t._zod.def).when??(o.when=l=>{const u=l.value;return!Yo(u)&&u.length!==void 0}),t._zod.onattach.push(l=>{const u=l._zod.bag.maximum??Number.POSITIVE_INFINITY;r.maximum<u&&(l._zod.bag.maximum=r.maximum)}),t._zod.check=l=>{const u=l.value;if(u.length<=r.maximum)return;const g=Qo(u);l.issues.push({origin:g,code:"too_big",maximum:r.maximum,inclusive:!0,input:u,inst:t,continue:!r.abort})}}),Qd=Q("$ZodCheckMinLength",(t,r)=>{var o;tn.init(t,r),(o=t._zod.def).when??(o.when=l=>{const u=l.value;return!Yo(u)&&u.length!==void 0}),t._zod.onattach.push(l=>{const u=l._zod.bag.minimum??Number.NEGATIVE_INFINITY;r.minimum>u&&(l._zod.bag.minimum=r.minimum)}),t._zod.check=l=>{const u=l.value;if(u.length>=r.minimum)return;const g=Qo(u);l.issues.push({origin:g,code:"too_small",minimum:r.minimum,inclusive:!0,input:u,inst:t,continue:!r.abort})}}),e0=Q("$ZodCheckLengthEquals",(t,r)=>{var o;tn.init(t,r),(o=t._zod.def).when??(o.when=l=>{const u=l.value;return!Yo(u)&&u.length!==void 0}),t._zod.onattach.push(l=>{const u=l._zod.bag;u.minimum=r.length,u.maximum=r.length,u.length=r.length}),t._zod.check=l=>{const u=l.value,f=u.length;if(f===r.length)return;const g=Qo(u),x=f>r.length;l.issues.push({origin:g,...x?{code:"too_big",maximum:r.length}:{code:"too_small",minimum:r.length},inclusive:!0,exact:!0,input:l.value,inst:t,continue:!r.abort})}}),Wi=Q("$ZodCheckStringFormat",(t,r)=>{var o,l;tn.init(t,r),t._zod.onattach.push(u=>{const f=u._zod.bag;f.format=r.format,r.pattern&&(f.patterns??(f.patterns=new Set),f.patterns.add(r.pattern))}),r.pattern?(o=t._zod).check??(o.check=u=>{r.pattern.lastIndex=0,!r.pattern.test(u.value)&&u.issues.push({origin:"string",code:"invalid_format",format:r.format,input:u.value,...r.pattern?{pattern:r.pattern.toString()}:{},inst:t,continue:!r.abort})}):(l=t._zod).check??(l.check=()=>{})}),t0=Q("$ZodCheckRegex",(t,r)=>{Wi.init(t,r),t._zod.check=o=>{r.pattern.lastIndex=0,!r.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:"regex",input:o.value,pattern:r.pattern.toString(),inst:t,continue:!r.abort})}}),n0=Q("$ZodCheckLowerCase",(t,r)=>{r.pattern??(r.pattern=Xd),Wi.init(t,r)}),r0=Q("$ZodCheckUpperCase",(t,r)=>{r.pattern??(r.pattern=qd),Wi.init(t,r)}),i0=Q("$ZodCheckIncludes",(t,r)=>{tn.init(t,r);const o=ti(r.includes),l=new RegExp(typeof r.position=="number"?`^.{${r.position}}${o}`:o);r.pattern=l,t._zod.onattach.push(u=>{const f=u._zod.bag;f.patterns??(f.patterns=new Set),f.patterns.add(l)}),t._zod.check=u=>{u.value.includes(r.includes,r.position)||u.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:r.includes,input:u.value,inst:t,continue:!r.abort})}}),o0=Q("$ZodCheckStartsWith",(t,r)=>{tn.init(t,r);const o=new RegExp(`^${ti(r.prefix)}.*`);r.pattern??(r.pattern=o),t._zod.onattach.push(l=>{const u=l._zod.bag;u.patterns??(u.patterns=new Set),u.patterns.add(o)}),t._zod.check=l=>{l.value.startsWith(r.prefix)||l.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:r.prefix,input:l.value,inst:t,continue:!r.abort})}}),s0=Q("$ZodCheckEndsWith",(t,r)=>{tn.init(t,r);const o=new RegExp(`.*${ti(r.suffix)}$`);r.pattern??(r.pattern=o),t._zod.onattach.push(l=>{const u=l._zod.bag;u.patterns??(u.patterns=new Set),u.patterns.add(o)}),t._zod.check=l=>{l.value.endsWith(r.suffix)||l.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:r.suffix,input:l.value,inst:t,continue:!r.abort})}}),a0=Q("$ZodCheckOverwrite",(t,r)=>{tn.init(t,r),t._zod.check=o=>{o.value=r.tx(o.value)}});class l0{constructor(r=[]){this.content=[],this.indent=0,this&&(this.args=r)}indented(r){this.indent+=1,r(this),this.indent-=1}write(r){if(typeof r=="function"){r(this,{execution:"sync"}),r(this,{execution:"async"});return}const l=r.split(`
8
+ `).filter(g=>g),u=Math.min(...l.map(g=>g.length-g.trimStart().length)),f=l.map(g=>g.slice(u)).map(g=>" ".repeat(this.indent*2)+g);for(const g of f)this.content.push(g)}compile(){const r=Function,o=this?.args,u=[...(this?.content??[""]).map(f=>` ${f}`)];return new r(...o,u.join(`
9
+ `))}}const c0={major:4,minor:0,patch:0},rt=Q("$ZodType",(t,r)=>{var o;t??(t={}),t._zod.def=r,t._zod.bag=t._zod.bag||{},t._zod.version=c0;const l=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&l.unshift(t);for(const u of l)for(const f of u._zod.onattach)f(t);if(l.length===0)(o=t._zod).deferred??(o.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{const u=(f,g,x)=>{let y=jr(f),m;for(const E of g){if(E._zod.def.when){if(!E._zod.def.when(f))continue}else if(y)continue;const C=f.issues.length,P=E._zod.check(f);if(P instanceof Promise&&x?.async===!1)throw new Gr;if(m||P instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await P,f.issues.length!==C&&(y||(y=jr(f,C)))});else{if(f.issues.length===C)continue;y||(y=jr(f,C))}}return m?m.then(()=>f):f};t._zod.run=(f,g)=>{const x=t._zod.parse(f,g);if(x instanceof Promise){if(g.async===!1)throw new Gr;return x.then(y=>u(y,l,g))}return u(x,l,g)}}t["~standard"]={validate:u=>{try{const f=_d(t,u);return f.success?{value:f.data}:{issues:f.error?.issues}}catch{return vd(t,u).then(g=>g.success?{value:g.data}:{issues:g.error?.issues})}},vendor:"zod",version:1}}),es=Q("$ZodString",(t,r)=>{rt.init(t,r),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??Zd(t._zod.bag),t._zod.parse=(o,l)=>{if(r.coerce)try{o.value=String(o.value)}catch{}return typeof o.value=="string"||o.issues.push({expected:"string",code:"invalid_type",input:o.value,inst:t}),o}}),ht=Q("$ZodStringFormat",(t,r)=>{Wi.init(t,r),es.init(t,r)}),u0=Q("$ZodGUID",(t,r)=>{r.pattern??(r.pattern=Nd),ht.init(t,r)}),d0=Q("$ZodUUID",(t,r)=>{if(r.version){const l={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[r.version];if(l===void 0)throw new Error(`Invalid UUID version: "${r.version}"`);r.pattern??(r.pattern=$s(l))}else r.pattern??(r.pattern=$s());ht.init(t,r)}),f0=Q("$ZodEmail",(t,r)=>{r.pattern??(r.pattern=Od),ht.init(t,r)}),h0=Q("$ZodURL",(t,r)=>{ht.init(t,r),t._zod.check=o=>{try{const l=o.value,u=new URL(l),f=u.href;r.hostname&&(r.hostname.lastIndex=0,r.hostname.test(u.hostname)||o.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Fd.source,input:o.value,inst:t,continue:!r.abort})),r.protocol&&(r.protocol.lastIndex=0,r.protocol.test(u.protocol.endsWith(":")?u.protocol.slice(0,-1):u.protocol)||o.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:r.protocol.source,input:o.value,inst:t,continue:!r.abort})),!l.endsWith("/")&&f.endsWith("/")?o.value=f.slice(0,-1):o.value=f;return}catch{o.issues.push({code:"invalid_format",format:"url",input:o.value,inst:t,continue:!r.abort})}}}),p0=Q("$ZodEmoji",(t,r)=>{r.pattern??(r.pattern=Rd()),ht.init(t,r)}),g0=Q("$ZodNanoID",(t,r)=>{r.pattern??(r.pattern=Sd),ht.init(t,r)}),m0=Q("$ZodCUID",(t,r)=>{r.pattern??(r.pattern=bd),ht.init(t,r)}),x0=Q("$ZodCUID2",(t,r)=>{r.pattern??(r.pattern=Cd),ht.init(t,r)}),w0=Q("$ZodULID",(t,r)=>{r.pattern??(r.pattern=Ed),ht.init(t,r)}),y0=Q("$ZodXID",(t,r)=>{r.pattern??(r.pattern=Ad),ht.init(t,r)}),_0=Q("$ZodKSUID",(t,r)=>{r.pattern??(r.pattern=Id),ht.init(t,r)}),v0=Q("$ZodISODateTime",(t,r)=>{r.pattern??(r.pattern=Vd(r)),ht.init(t,r)}),b0=Q("$ZodISODate",(t,r)=>{r.pattern??(r.pattern=Ud),ht.init(t,r)}),C0=Q("$ZodISOTime",(t,r)=>{r.pattern??(r.pattern=zd(r)),ht.init(t,r)}),E0=Q("$ZodISODuration",(t,r)=>{r.pattern??(r.pattern=Td),ht.init(t,r)}),A0=Q("$ZodIPv4",(t,r)=>{r.pattern??(r.pattern=Dd),ht.init(t,r),t._zod.onattach.push(o=>{const l=o._zod.bag;l.format="ipv4"})}),I0=Q("$ZodIPv6",(t,r)=>{r.pattern??(r.pattern=Md),ht.init(t,r),t._zod.onattach.push(o=>{const l=o._zod.bag;l.format="ipv6"}),t._zod.check=o=>{try{new URL(`http://[${o.value}]`)}catch{o.issues.push({code:"invalid_format",format:"ipv6",input:o.value,inst:t,continue:!r.abort})}}}),S0=Q("$ZodCIDRv4",(t,r)=>{r.pattern??(r.pattern=Pd),ht.init(t,r)}),T0=Q("$ZodCIDRv6",(t,r)=>{r.pattern??(r.pattern=Bd),ht.init(t,r),t._zod.check=o=>{const[l,u]=o.value.split("/");try{if(!u)throw new Error;const f=Number(u);if(`${f}`!==u)throw new Error;if(f<0||f>128)throw new Error;new URL(`http://[${l}]`)}catch{o.issues.push({code:"invalid_format",format:"cidrv6",input:o.value,inst:t,continue:!r.abort})}}});function Cc(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const N0=Q("$ZodBase64",(t,r)=>{r.pattern??(r.pattern=Ld),ht.init(t,r),t._zod.onattach.push(o=>{o._zod.bag.contentEncoding="base64"}),t._zod.check=o=>{Cc(o.value)||o.issues.push({code:"invalid_format",format:"base64",input:o.value,inst:t,continue:!r.abort})}});function O0(t){if(!xc.test(t))return!1;const r=t.replace(/[-_]/g,l=>l==="-"?"+":"/"),o=r.padEnd(Math.ceil(r.length/4)*4,"=");return Cc(o)}const k0=Q("$ZodBase64URL",(t,r)=>{r.pattern??(r.pattern=xc),ht.init(t,r),t._zod.onattach.push(o=>{o._zod.bag.contentEncoding="base64url"}),t._zod.check=o=>{O0(o.value)||o.issues.push({code:"invalid_format",format:"base64url",input:o.value,inst:t,continue:!r.abort})}}),R0=Q("$ZodE164",(t,r)=>{r.pattern??(r.pattern=$d),ht.init(t,r)});function D0(t,r=null){try{const o=t.split(".");if(o.length!==3)return!1;const[l]=o;if(!l)return!1;const u=JSON.parse(atob(l));return!("typ"in u&&u?.typ!=="JWT"||!u.alg||r&&(!("alg"in u)||u.alg!==r))}catch{return!1}}const M0=Q("$ZodJWT",(t,r)=>{ht.init(t,r),t._zod.check=o=>{D0(o.value,r.alg)||o.issues.push({code:"invalid_format",format:"jwt",input:o.value,inst:t,continue:!r.abort})}}),Ec=Q("$ZodNumber",(t,r)=>{rt.init(t,r),t._zod.pattern=t._zod.bag.pattern??Hd,t._zod.parse=(o,l)=>{if(r.coerce)try{o.value=Number(o.value)}catch{}const u=o.value;if(typeof u=="number"&&!Number.isNaN(u)&&Number.isFinite(u))return o;const f=typeof u=="number"?Number.isNaN(u)?"NaN":Number.isFinite(u)?void 0:"Infinity":void 0;return o.issues.push({expected:"number",code:"invalid_type",input:u,inst:t,...f?{received:f}:{}}),o}}),P0=Q("$ZodNumber",(t,r)=>{Kd.init(t,r),Ec.init(t,r)}),B0=Q("$ZodBoolean",(t,r)=>{rt.init(t,r),t._zod.pattern=Wd,t._zod.parse=(o,l)=>{if(r.coerce)try{o.value=!!o.value}catch{}const u=o.value;return typeof u=="boolean"||o.issues.push({expected:"boolean",code:"invalid_type",input:u,inst:t}),o}}),L0=Q("$ZodNull",(t,r)=>{rt.init(t,r),t._zod.pattern=Gd,t._zod.values=new Set([null]),t._zod.parse=(o,l)=>{const u=o.value;return u===null||o.issues.push({expected:"null",code:"invalid_type",input:u,inst:t}),o}}),F0=Q("$ZodAny",(t,r)=>{rt.init(t,r),t._zod.parse=o=>o}),$0=Q("$ZodUnknown",(t,r)=>{rt.init(t,r),t._zod.parse=o=>o}),U0=Q("$ZodNever",(t,r)=>{rt.init(t,r),t._zod.parse=(o,l)=>(o.issues.push({expected:"never",code:"invalid_type",input:o.value,inst:t}),o)});function Us(t,r,o){t.issues.length&&r.issues.push(...sr(o,t.issues)),r.value[o]=t.value}const z0=Q("$ZodArray",(t,r)=>{rt.init(t,r),t._zod.parse=(o,l)=>{const u=o.value;if(!Array.isArray(u))return o.issues.push({expected:"array",code:"invalid_type",input:u,inst:t}),o;o.value=Array(u.length);const f=[];for(let g=0;g<u.length;g++){const x=u[g],y=r.element._zod.run({value:x,issues:[]},l);y instanceof Promise?f.push(y.then(m=>Us(m,o,g))):Us(y,o,g)}return f.length?Promise.all(f).then(()=>o):o}});function yi(t,r,o){t.issues.length&&r.issues.push(...sr(o,t.issues)),r.value[o]=t.value}function zs(t,r,o,l){t.issues.length?l[o]===void 0?o in l?r.value[o]=void 0:r.value[o]=t.value:r.issues.push(...sr(o,t.issues)):t.value===void 0?o in l&&(r.value[o]=void 0):r.value[o]=t.value}const V0=Q("$ZodObject",(t,r)=>{rt.init(t,r);const o=qo(()=>{const C=Object.keys(r.shape);for(const O of C)if(!(r.shape[O]instanceof rt))throw new Error(`Invalid element at key "${O}": expected a Zod schema`);const P=ld(r.shape);return{shape:r.shape,keys:C,keySet:new Set(C),numKeys:C.length,optionalKeys:new Set(P)}});Xe(t._zod,"propValues",()=>{const C=r.shape,P={};for(const O in C){const D=C[O]._zod;if(D.values){P[O]??(P[O]=new Set);for(const R of D.values)P[O].add(R)}}return P});const l=C=>{const P=new l0(["shape","payload","ctx"]),O=o.value,D=U=>{const k=Br(U);return`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`};P.write("const input = payload.value;");const R=Object.create(null);let M=0;for(const U of O.keys)R[U]=`key_${M++}`;P.write("const newResult = {}");for(const U of O.keys)if(O.optionalKeys.has(U)){const k=R[U];P.write(`const ${k} = ${D(U)};`);const J=Br(U);P.write(`
10
10
  if (${k}.issues.length) {
11
- if (input[${K}] === undefined) {
12
- if (${K} in input) {
13
- newResult[${K}] = undefined;
11
+ if (input[${J}] === undefined) {
12
+ if (${J} in input) {
13
+ newResult[${J}] = undefined;
14
14
  }
15
15
  } else {
16
16
  payload.issues = payload.issues.concat(
17
17
  ${k}.issues.map((iss) => ({
18
18
  ...iss,
19
- path: iss.path ? [${K}, ...iss.path] : [${K}],
19
+ path: iss.path ? [${J}, ...iss.path] : [${J}],
20
20
  }))
21
21
  );
22
22
  }
23
23
  } else if (${k}.value === undefined) {
24
- if (${K} in input) newResult[${K}] = undefined;
24
+ if (${J} in input) newResult[${J}] = undefined;
25
25
  } else {
26
- newResult[${K}] = ${k}.value;
26
+ newResult[${J}] = ${k}.value;
27
27
  }
28
- `)}else{const k=D[U];P.write(`const ${k} = ${R(U)};`),P.write(`
28
+ `)}else{const k=R[U];P.write(`const ${k} = ${D(U)};`),P.write(`
29
29
  if (${k}.issues.length) payload.issues = payload.issues.concat(${k}.issues.map(iss => ({
30
30
  ...iss,
31
- path: iss.path ? [${Ur(U)}, ...iss.path] : [${Ur(U)}]
32
- })));`),P.write(`newResult[${Ur(U)}] = ${k}.value`)}P.write("payload.value = newResult;"),P.write("return payload;");const z=P.compile();return(U,k)=>z(b,U,k)};let u;const f=zi,g=!xc.jitless,y=g&&g0.value,x=n.catchall;let A;t._zod.parse=(b,P)=>{A??(A=o.value);const N=b.value;if(!f(N))return b.issues.push({expected:"object",code:"invalid_type",input:N,inst:t}),b;const R=[];if(g&&y&&P?.async===!1&&P.jitless!==!0)u||(u=l(n.shape)),b=u(b,P);else{b.value={};const k=A.shape;for(const K of A.keys){const ve=k[K],Q=ve._zod.run({value:N[K],issues:[]},P),j=ve._zod.optin==="optional"&&ve._zod.optout==="optional";Q instanceof Promise?R.push(Q.then(ie=>j?Xs(ie,b,K,N):Ei(ie,b,K))):j?Xs(Q,b,K,N):Ei(Q,b,K)}}if(!x)return R.length?Promise.all(R).then(()=>b):b;const D=[],M=A.keySet,z=x._zod,U=z.def.type;for(const k of Object.keys(N)){if(M.has(k))continue;if(U==="never"){D.push(k);continue}const K=z.run({value:N[k],issues:[]},P);K instanceof Promise?R.push(K.then(ve=>Ei(ve,b,k))):Ei(K,b,k)}return D.length&&b.issues.push({code:"unrecognized_keys",keys:D,input:N,inst:t}),R.length?Promise.all(R).then(()=>b):b}});function Ys(t,n,o,l){for(const u of t)if(u.issues.length===0)return n.value=u.value,n;return n.issues.push({code:"invalid_union",input:n.value,inst:o,errors:t.map(u=>u.issues.map(f=>tr(f,l,er())))}),n}const Dc=q("$ZodUnion",(t,n)=>{st.init(t,n),Qe(t._zod,"optin",()=>n.options.some(o=>o._zod.optin==="optional")?"optional":void 0),Qe(t._zod,"optout",()=>n.options.some(o=>o._zod.optout==="optional")?"optional":void 0),Qe(t._zod,"values",()=>{if(n.options.every(o=>o._zod.values))return new Set(n.options.flatMap(o=>Array.from(o._zod.values)))}),Qe(t._zod,"pattern",()=>{if(n.options.every(o=>o._zod.pattern)){const o=n.options.map(l=>l._zod.pattern);return new RegExp(`^(${o.map(l=>is(l.source)).join("|")})$`)}}),t._zod.parse=(o,l)=>{let u=!1;const f=[];for(const g of n.options){const m=g._zod.run({value:o.value,issues:[]},l);if(m instanceof Promise)f.push(m),u=!0;else{if(m.issues.length===0)return m;f.push(m)}}return u?Promise.all(f).then(g=>Ys(g,o,t,l)):Ys(f,o,t,l)}}),Jd=q("$ZodDiscriminatedUnion",(t,n)=>{Dc.init(t,n);const o=t._zod.parse;Qe(t._zod,"propValues",()=>{const u={};for(const f of n.options){const g=f._zod.propValues;if(!g||Object.keys(g).length===0)throw new Error(`Invalid discriminated union option at index "${n.options.indexOf(f)}"`);for(const[m,y]of Object.entries(g)){u[m]||(u[m]=new Set);for(const x of y)u[m].add(x)}}return u});const l=ns(()=>{const u=n.options,f=new Map;for(const g of u){const m=g._zod.propValues[n.discriminator];if(!m||m.size===0)throw new Error(`Invalid discriminated union option at index "${n.options.indexOf(g)}"`);for(const y of m){if(f.has(y))throw new Error(`Duplicate discriminator value "${String(y)}"`);f.set(y,g)}}return f});t._zod.parse=(u,f)=>{const g=u.value;if(!zi(g))return u.issues.push({code:"invalid_type",expected:"object",input:g,inst:t}),u;const m=l.value.get(g?.[n.discriminator]);return m?m._zod.run(u,f):n.unionFallback?o(u,f):(u.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:g,path:[n.discriminator],inst:t}),u)}}),Qd=q("$ZodIntersection",(t,n)=>{st.init(t,n),t._zod.parse=(o,l)=>{const u=o.value,f=n.left._zod.run({value:u,issues:[]},l),g=n.right._zod.run({value:u,issues:[]},l);return f instanceof Promise||g instanceof Promise?Promise.all([f,g]).then(([y,x])=>qs(o,y,x)):qs(o,f,g)}});function Zo(t,n){if(t===n)return{valid:!0,data:t};if(t instanceof Date&&n instanceof Date&&+t==+n)return{valid:!0,data:t};if(Zi(t)&&Zi(n)){const o=Object.keys(n),l=Object.keys(t).filter(f=>o.indexOf(f)!==-1),u={...t,...n};for(const f of l){const g=Zo(t[f],n[f]);if(!g.valid)return{valid:!1,mergeErrorPath:[f,...g.mergeErrorPath]};u[f]=g.data}return{valid:!0,data:u}}if(Array.isArray(t)&&Array.isArray(n)){if(t.length!==n.length)return{valid:!1,mergeErrorPath:[]};const o=[];for(let l=0;l<t.length;l++){const u=t[l],f=n[l],g=Zo(u,f);if(!g.valid)return{valid:!1,mergeErrorPath:[l,...g.mergeErrorPath]};o.push(g.data)}return{valid:!0,data:o}}return{valid:!1,mergeErrorPath:[]}}function qs(t,n,o){if(n.issues.length&&t.issues.push(...n.issues),o.issues.length&&t.issues.push(...o.issues),Xr(t))return t;const l=Zo(n.value,o.value);if(!l.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(l.mergeErrorPath)}`);return t.value=l.data,t}const ef=q("$ZodRecord",(t,n)=>{st.init(t,n),t._zod.parse=(o,l)=>{const u=o.value;if(!Zi(u))return o.issues.push({expected:"record",code:"invalid_type",input:u,inst:t}),o;const f=[];if(n.keyType._zod.values){const g=n.keyType._zod.values;o.value={};for(const y of g)if(typeof y=="string"||typeof y=="number"||typeof y=="symbol"){const x=n.valueType._zod.run({value:u[y],issues:[]},l);x instanceof Promise?f.push(x.then(A=>{A.issues.length&&o.issues.push(...fr(y,A.issues)),o.value[y]=A.value})):(x.issues.length&&o.issues.push(...fr(y,x.issues)),o.value[y]=x.value)}let m;for(const y in u)g.has(y)||(m=m??[],m.push(y));m&&m.length>0&&o.issues.push({code:"unrecognized_keys",input:u,inst:t,keys:m})}else{o.value={};for(const g of Reflect.ownKeys(u)){if(g==="__proto__")continue;const m=n.keyType._zod.run({value:g,issues:[]},l);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(m.issues.length){o.issues.push({origin:"record",code:"invalid_key",issues:m.issues.map(x=>tr(x,l,er())),input:g,path:[g],inst:t}),o.value[m.value]=m.value;continue}const y=n.valueType._zod.run({value:u[g],issues:[]},l);y instanceof Promise?f.push(y.then(x=>{x.issues.length&&o.issues.push(...fr(g,x.issues)),o.value[m.value]=x.value})):(y.issues.length&&o.issues.push(...fr(g,y.issues)),o.value[m.value]=y.value)}}return f.length?Promise.all(f).then(()=>o):o}}),tf=q("$ZodEnum",(t,n)=>{st.init(t,n);const o=wc(n.entries);t._zod.values=new Set(o),t._zod.pattern=new RegExp(`^(${o.filter(l=>m0.has(typeof l)).map(l=>typeof l=="string"?oi(l):l.toString()).join("|")})$`),t._zod.parse=(l,u)=>{const f=l.value;return t._zod.values.has(f)||l.issues.push({code:"invalid_value",values:o,input:f,inst:t}),l}}),nf=q("$ZodLiteral",(t,n)=>{st.init(t,n),t._zod.values=new Set(n.values),t._zod.pattern=new RegExp(`^(${n.values.map(o=>typeof o=="string"?oi(o):o?o.toString():String(o)).join("|")})$`),t._zod.parse=(o,l)=>{const u=o.value;return t._zod.values.has(u)||o.issues.push({code:"invalid_value",values:n.values,input:u,inst:t}),o}}),rf=q("$ZodTransform",(t,n)=>{st.init(t,n),t._zod.parse=(o,l)=>{const u=n.transform(o.value,o);if(l.async)return(u instanceof Promise?u:Promise.resolve(u)).then(g=>(o.value=g,o));if(u instanceof Promise)throw new Kr;return o.value=u,o}}),of=q("$ZodOptional",(t,n)=>{st.init(t,n),t._zod.optin="optional",t._zod.optout="optional",Qe(t._zod,"values",()=>n.innerType._zod.values?new Set([...n.innerType._zod.values,void 0]):void 0),Qe(t._zod,"pattern",()=>{const o=n.innerType._zod.pattern;return o?new RegExp(`^(${is(o.source)})?$`):void 0}),t._zod.parse=(o,l)=>n.innerType._zod.optin==="optional"?n.innerType._zod.run(o,l):o.value===void 0?o:n.innerType._zod.run(o,l)}),sf=q("$ZodNullable",(t,n)=>{st.init(t,n),Qe(t._zod,"optin",()=>n.innerType._zod.optin),Qe(t._zod,"optout",()=>n.innerType._zod.optout),Qe(t._zod,"pattern",()=>{const o=n.innerType._zod.pattern;return o?new RegExp(`^(${is(o.source)}|null)$`):void 0}),Qe(t._zod,"values",()=>n.innerType._zod.values?new Set([...n.innerType._zod.values,null]):void 0),t._zod.parse=(o,l)=>o.value===null?o:n.innerType._zod.run(o,l)}),af=q("$ZodDefault",(t,n)=>{st.init(t,n),t._zod.optin="optional",Qe(t._zod,"values",()=>n.innerType._zod.values),t._zod.parse=(o,l)=>{if(o.value===void 0)return o.value=n.defaultValue,o;const u=n.innerType._zod.run(o,l);return u instanceof Promise?u.then(f=>Ks(f,n)):Ks(u,n)}});function Ks(t,n){return t.value===void 0&&(t.value=n.defaultValue),t}const lf=q("$ZodPrefault",(t,n)=>{st.init(t,n),t._zod.optin="optional",Qe(t._zod,"values",()=>n.innerType._zod.values),t._zod.parse=(o,l)=>(o.value===void 0&&(o.value=n.defaultValue),n.innerType._zod.run(o,l))}),cf=q("$ZodNonOptional",(t,n)=>{st.init(t,n),Qe(t._zod,"values",()=>{const o=n.innerType._zod.values;return o?new Set([...o].filter(l=>l!==void 0)):void 0}),t._zod.parse=(o,l)=>{const u=n.innerType._zod.run(o,l);return u instanceof Promise?u.then(f=>Js(f,t)):Js(u,t)}});function Js(t,n){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:n}),t}const uf=q("$ZodCatch",(t,n)=>{st.init(t,n),t._zod.optin="optional",Qe(t._zod,"optout",()=>n.innerType._zod.optout),Qe(t._zod,"values",()=>n.innerType._zod.values),t._zod.parse=(o,l)=>{const u=n.innerType._zod.run(o,l);return u instanceof Promise?u.then(f=>(o.value=f.value,f.issues.length&&(o.value=n.catchValue({...o,error:{issues:f.issues.map(g=>tr(g,l,er()))},input:o.value}),o.issues=[]),o)):(o.value=u.value,u.issues.length&&(o.value=n.catchValue({...o,error:{issues:u.issues.map(f=>tr(f,l,er()))},input:o.value}),o.issues=[]),o)}}),df=q("$ZodPipe",(t,n)=>{st.init(t,n),Qe(t._zod,"values",()=>n.in._zod.values),Qe(t._zod,"optin",()=>n.in._zod.optin),Qe(t._zod,"optout",()=>n.out._zod.optout),t._zod.parse=(o,l)=>{const u=n.in._zod.run(o,l);return u instanceof Promise?u.then(f=>Qs(f,n,l)):Qs(u,n,l)}});function Qs(t,n,o){return Xr(t)?t:n.out._zod.run({value:t.value,issues:t.issues},o)}const ff=q("$ZodReadonly",(t,n)=>{st.init(t,n),Qe(t._zod,"propValues",()=>n.innerType._zod.propValues),Qe(t._zod,"values",()=>n.innerType._zod.values),Qe(t._zod,"optin",()=>n.innerType._zod.optin),Qe(t._zod,"optout",()=>n.innerType._zod.optout),t._zod.parse=(o,l)=>{const u=n.innerType._zod.run(o,l);return u instanceof Promise?u.then(ea):ea(u)}});function ea(t){return t.value=Object.freeze(t.value),t}const hf=q("$ZodLazy",(t,n)=>{st.init(t,n),Qe(t._zod,"innerType",()=>n.getter()),Qe(t._zod,"pattern",()=>t._zod.innerType._zod.pattern),Qe(t._zod,"propValues",()=>t._zod.innerType._zod.propValues),Qe(t._zod,"optin",()=>t._zod.innerType._zod.optin),Qe(t._zod,"optout",()=>t._zod.innerType._zod.optout),t._zod.parse=(o,l)=>t._zod.innerType._zod.run(o,l)}),pf=q("$ZodCustom",(t,n)=>{rn.init(t,n),st.init(t,n),t._zod.parse=(o,l)=>o,t._zod.check=o=>{const l=o.value,u=n.fn(l);if(u instanceof Promise)return u.then(f=>ta(f,o,l,t));ta(u,o,l,t)}});function ta(t,n,o,l){if(!t){const u={code:"custom",input:o,inst:l,path:[...l._zod.def.path??[]],continue:!l._zod.def.abort};l._zod.def.params&&(u.params=l._zod.def.params),n.issues.push(Jr(u))}}class Mc{constructor(){this._map=new Map,this._idmap=new Map}add(n,...o){const l=o[0];if(this._map.set(n,l),l&&typeof l=="object"&&"id"in l){if(this._idmap.has(l.id))throw new Error(`ID ${l.id} already exists in the registry`);this._idmap.set(l.id,n)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(n){const o=this._map.get(n);return o&&typeof o=="object"&&"id"in o&&this._idmap.delete(o.id),this._map.delete(n),this}get(n){const o=n._zod.parent;if(o){const l={...this.get(o)??{}};return delete l.id,{...l,...this._map.get(n)}}return this._map.get(n)}has(n){return this._map.has(n)}}function gf(){return new Mc}const Hr=gf();function mf(t,n){return new t({type:"string",...Te(n)})}function xf(t,n){return new t({type:"string",format:"email",check:"string_format",abort:!1,...Te(n)})}function na(t,n){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...Te(n)})}function wf(t,n){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...Te(n)})}function yf(t,n){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Te(n)})}function _f(t,n){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Te(n)})}function vf(t,n){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Te(n)})}function Cf(t,n){return new t({type:"string",format:"url",check:"string_format",abort:!1,...Te(n)})}function bf(t,n){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...Te(n)})}function Ef(t,n){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...Te(n)})}function Af(t,n){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...Te(n)})}function If(t,n){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...Te(n)})}function Sf(t,n){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...Te(n)})}function Tf(t,n){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...Te(n)})}function Of(t,n){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...Te(n)})}function Nf(t,n){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...Te(n)})}function kf(t,n){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...Te(n)})}function Rf(t,n){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Te(n)})}function Df(t,n){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Te(n)})}function Mf(t,n){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...Te(n)})}function Pf(t,n){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...Te(n)})}function Bf(t,n){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...Te(n)})}function Lf(t,n){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...Te(n)})}function Ff(t,n){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Te(n)})}function $f(t,n){return new t({type:"string",format:"date",check:"string_format",...Te(n)})}function Uf(t,n){return new t({type:"string",format:"time",check:"string_format",precision:null,...Te(n)})}function zf(t,n){return new t({type:"string",format:"duration",check:"string_format",...Te(n)})}function Zf(t,n){return new t({type:"number",checks:[],...Te(n)})}function Vf(t,n){return new t({type:"number",coerce:!0,checks:[],...Te(n)})}function jf(t,n){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...Te(n)})}function Hf(t,n){return new t({type:"boolean",...Te(n)})}function Wf(t,n){return new t({type:"null",...Te(n)})}function Gf(t){return new t({type:"any"})}function Xf(t){return new t({type:"unknown"})}function Yf(t,n){return new t({type:"never",...Te(n)})}function ra(t,n){return new Oc({check:"less_than",...Te(n),value:t,inclusive:!1})}function Io(t,n){return new Oc({check:"less_than",...Te(n),value:t,inclusive:!0})}function ia(t,n){return new Nc({check:"greater_than",...Te(n),value:t,inclusive:!1})}function So(t,n){return new Nc({check:"greater_than",...Te(n),value:t,inclusive:!0})}function oa(t,n){return new od({check:"multiple_of",...Te(n),value:t})}function Pc(t,n){return new ad({check:"max_length",...Te(n),maximum:t})}function Vi(t,n){return new ld({check:"min_length",...Te(n),minimum:t})}function Bc(t,n){return new cd({check:"length_equals",...Te(n),length:t})}function qf(t,n){return new ud({check:"string_format",format:"regex",...Te(n),pattern:t})}function Kf(t){return new dd({check:"string_format",format:"lowercase",...Te(t)})}function Jf(t){return new fd({check:"string_format",format:"uppercase",...Te(t)})}function Qf(t,n){return new hd({check:"string_format",format:"includes",...Te(n),includes:t})}function eh(t,n){return new pd({check:"string_format",format:"starts_with",...Te(n),prefix:t})}function th(t,n){return new gd({check:"string_format",format:"ends_with",...Te(n),suffix:t})}function si(t){return new md({check:"overwrite",tx:t})}function nh(t){return si(n=>n.normalize(t))}function rh(){return si(t=>t.trim())}function ih(){return si(t=>t.toLowerCase())}function oh(){return si(t=>t.toUpperCase())}function sh(t,n,o){return new t({type:"array",element:n,...Te(o)})}function ah(t,n,o){const l=Te(o);return l.abort??(l.abort=!0),new t({type:"custom",check:"custom",fn:n,...l})}function lh(t,n,o){return new t({type:"custom",check:"custom",fn:n,...Te(o)})}class sa{constructor(n){this.counter=0,this.metadataRegistry=n?.metadata??Hr,this.target=n?.target??"draft-2020-12",this.unrepresentable=n?.unrepresentable??"throw",this.override=n?.override??(()=>{}),this.io=n?.io??"output",this.seen=new Map}process(n,o={path:[],schemaPath:[]}){var l;const u=n._zod.def,f={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},g=this.seen.get(n);if(g)return g.count++,o.schemaPath.includes(n)&&(g.cycle=o.path),g.schema;const m={schema:{},count:1,cycle:void 0,path:o.path};this.seen.set(n,m);const y=n._zod.toJSONSchema?.();if(y)m.schema=y;else{const b={...o,schemaPath:[...o.schemaPath,n],path:o.path},P=n._zod.parent;if(P)m.ref=P,this.process(P,b),this.seen.get(P).isParent=!0;else{const N=m.schema;switch(u.type){case"string":{const R=N;R.type="string";const{minimum:D,maximum:M,format:z,patterns:U,contentEncoding:k}=n._zod.bag;if(typeof D=="number"&&(R.minLength=D),typeof M=="number"&&(R.maxLength=M),z&&(R.format=f[z]??z,R.format===""&&delete R.format),k&&(R.contentEncoding=k),U&&U.size>0){const K=[...U];K.length===1?R.pattern=K[0].source:K.length>1&&(m.schema.allOf=[...K.map(ve=>({...this.target==="draft-7"?{type:"string"}:{},pattern:ve.source}))])}break}case"number":{const R=N,{minimum:D,maximum:M,format:z,multipleOf:U,exclusiveMaximum:k,exclusiveMinimum:K}=n._zod.bag;typeof z=="string"&&z.includes("int")?R.type="integer":R.type="number",typeof K=="number"&&(R.exclusiveMinimum=K),typeof D=="number"&&(R.minimum=D,typeof K=="number"&&(K>=D?delete R.minimum:delete R.exclusiveMinimum)),typeof k=="number"&&(R.exclusiveMaximum=k),typeof M=="number"&&(R.maximum=M,typeof k=="number"&&(k<=M?delete R.maximum:delete R.exclusiveMaximum)),typeof U=="number"&&(R.multipleOf=U);break}case"boolean":{const R=N;R.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{N.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{N.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{const R=N,{minimum:D,maximum:M}=n._zod.bag;typeof D=="number"&&(R.minItems=D),typeof M=="number"&&(R.maxItems=M),R.type="array",R.items=this.process(u.element,{...b,path:[...b.path,"items"]});break}case"object":{const R=N;R.type="object",R.properties={};const D=u.shape;for(const U in D)R.properties[U]=this.process(D[U],{...b,path:[...b.path,"properties",U]});const M=new Set(Object.keys(D)),z=new Set([...M].filter(U=>{const k=u.shape[U]._zod;return this.io==="input"?k.optin===void 0:k.optout===void 0}));z.size>0&&(R.required=Array.from(z)),u.catchall?._zod.def.type==="never"?R.additionalProperties=!1:u.catchall?u.catchall&&(R.additionalProperties=this.process(u.catchall,{...b,path:[...b.path,"additionalProperties"]})):this.io==="output"&&(R.additionalProperties=!1);break}case"union":{const R=N;R.anyOf=u.options.map((D,M)=>this.process(D,{...b,path:[...b.path,"anyOf",M]}));break}case"intersection":{const R=N,D=this.process(u.left,{...b,path:[...b.path,"allOf",0]}),M=this.process(u.right,{...b,path:[...b.path,"allOf",1]}),z=k=>"allOf"in k&&Object.keys(k).length===1,U=[...z(D)?D.allOf:[D],...z(M)?M.allOf:[M]];R.allOf=U;break}case"tuple":{const R=N;R.type="array";const D=u.items.map((U,k)=>this.process(U,{...b,path:[...b.path,"prefixItems",k]}));if(this.target==="draft-2020-12"?R.prefixItems=D:R.items=D,u.rest){const U=this.process(u.rest,{...b,path:[...b.path,"items"]});this.target==="draft-2020-12"?R.items=U:R.additionalItems=U}u.rest&&(R.items=this.process(u.rest,{...b,path:[...b.path,"items"]}));const{minimum:M,maximum:z}=n._zod.bag;typeof M=="number"&&(R.minItems=M),typeof z=="number"&&(R.maxItems=z);break}case"record":{const R=N;R.type="object",R.propertyNames=this.process(u.keyType,{...b,path:[...b.path,"propertyNames"]}),R.additionalProperties=this.process(u.valueType,{...b,path:[...b.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{const R=N,D=wc(u.entries);D.every(M=>typeof M=="number")&&(R.type="number"),D.every(M=>typeof M=="string")&&(R.type="string"),R.enum=D;break}case"literal":{const R=N,D=[];for(const M of u.values)if(M===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof M=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");D.push(Number(M))}else D.push(M);if(D.length!==0)if(D.length===1){const M=D[0];R.type=M===null?"null":typeof M,R.const=M}else D.every(M=>typeof M=="number")&&(R.type="number"),D.every(M=>typeof M=="string")&&(R.type="string"),D.every(M=>typeof M=="boolean")&&(R.type="string"),D.every(M=>M===null)&&(R.type="null"),R.enum=D;break}case"file":{const R=N,D={type:"string",format:"binary",contentEncoding:"binary"},{minimum:M,maximum:z,mime:U}=n._zod.bag;M!==void 0&&(D.minLength=M),z!==void 0&&(D.maxLength=z),U?U.length===1?(D.contentMediaType=U[0],Object.assign(R,D)):R.anyOf=U.map(k=>({...D,contentMediaType:k})):Object.assign(R,D);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{const R=this.process(u.innerType,b);N.anyOf=[R,{type:"null"}];break}case"nonoptional":{this.process(u.innerType,b),m.ref=u.innerType;break}case"success":{const R=N;R.type="boolean";break}case"default":{this.process(u.innerType,b),m.ref=u.innerType,N.default=JSON.parse(JSON.stringify(u.defaultValue));break}case"prefault":{this.process(u.innerType,b),m.ref=u.innerType,this.io==="input"&&(N._prefault=JSON.parse(JSON.stringify(u.defaultValue)));break}case"catch":{this.process(u.innerType,b),m.ref=u.innerType;let R;try{R=u.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}N.default=R;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{const R=N,D=n._zod.pattern;if(!D)throw new Error("Pattern not found in template literal");R.type="string",R.pattern=D.source;break}case"pipe":{const R=this.io==="input"?u.in._zod.def.type==="transform"?u.out:u.in:u.out;this.process(R,b),m.ref=R;break}case"readonly":{this.process(u.innerType,b),m.ref=u.innerType,N.readOnly=!0;break}case"promise":{this.process(u.innerType,b),m.ref=u.innerType;break}case"optional":{this.process(u.innerType,b),m.ref=u.innerType;break}case"lazy":{const R=n._zod.innerType;this.process(R,b),m.ref=R;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}}}}const x=this.metadataRegistry.get(n);return x&&Object.assign(m.schema,x),this.io==="input"&&Ot(n)&&(delete m.schema.examples,delete m.schema.default),this.io==="input"&&m.schema._prefault&&((l=m.schema).default??(l.default=m.schema._prefault)),delete m.schema._prefault,this.seen.get(n).schema}emit(n,o){const l={cycles:o?.cycles??"ref",reused:o?.reused??"inline",external:o?.external??void 0},u=this.seen.get(n);if(!u)throw new Error("Unprocessed schema. This is a bug in Zod.");const f=A=>{const b=this.target==="draft-2020-12"?"$defs":"definitions";if(l.external){const D=l.external.registry.get(A[0])?.id,M=l.external.uri??(U=>U);if(D)return{ref:M(D)};const z=A[1].defId??A[1].schema.id??`schema${this.counter++}`;return A[1].defId=z,{defId:z,ref:`${M("__shared")}#/${b}/${z}`}}if(A[1]===u)return{ref:"#"};const N=`#/${b}/`,R=A[1].schema.id??`__schema${this.counter++}`;return{defId:R,ref:N+R}},g=A=>{if(A[1].schema.$ref)return;const b=A[1],{ref:P,defId:N}=f(A);b.def={...b.schema},N&&(b.defId=N);const R=b.schema;for(const D in R)delete R[D];R.$ref=P};if(l.cycles==="throw")for(const A of this.seen.entries()){const b=A[1];if(b.cycle)throw new Error(`Cycle detected: #/${b.cycle?.join("/")}/<root>
31
+ path: iss.path ? [${Br(U)}, ...iss.path] : [${Br(U)}]
32
+ })));`),P.write(`newResult[${Br(U)}] = ${k}.value`)}P.write("payload.value = newResult;"),P.write("return payload;");const V=P.compile();return(U,k)=>V(C,U,k)};let u;const f=Pi,g=!cc.jitless,y=g&&sd.value,m=r.catchall;let E;t._zod.parse=(C,P)=>{E??(E=o.value);const O=C.value;if(!f(O))return C.issues.push({expected:"object",code:"invalid_type",input:O,inst:t}),C;const D=[];if(g&&y&&P?.async===!1&&P.jitless!==!0)u||(u=l(r.shape)),C=u(C,P);else{C.value={};const k=E.shape;for(const J of E.keys){const be=k[J],Z=be._zod.run({value:O[J],issues:[]},P),z=be._zod.optin==="optional"&&be._zod.optout==="optional";Z instanceof Promise?D.push(Z.then(Y=>z?zs(Y,C,J,O):yi(Y,C,J))):z?zs(Z,C,J,O):yi(Z,C,J)}}if(!m)return D.length?Promise.all(D).then(()=>C):C;const R=[],M=E.keySet,V=m._zod,U=V.def.type;for(const k of Object.keys(O)){if(M.has(k))continue;if(U==="never"){R.push(k);continue}const J=V.run({value:O[k],issues:[]},P);J instanceof Promise?D.push(J.then(be=>yi(be,C,k))):yi(J,C,k)}return R.length&&C.issues.push({code:"unrecognized_keys",keys:R,input:O,inst:t}),D.length?Promise.all(D).then(()=>C):C}});function Vs(t,r,o,l){for(const u of t)if(u.issues.length===0)return r.value=u.value,r;return r.issues.push({code:"invalid_union",input:r.value,inst:o,errors:t.map(u=>u.issues.map(f=>Yn(f,l,qn())))}),r}const Ac=Q("$ZodUnion",(t,r)=>{rt.init(t,r),Xe(t._zod,"optin",()=>r.options.some(o=>o._zod.optin==="optional")?"optional":void 0),Xe(t._zod,"optout",()=>r.options.some(o=>o._zod.optout==="optional")?"optional":void 0),Xe(t._zod,"values",()=>{if(r.options.every(o=>o._zod.values))return new Set(r.options.flatMap(o=>Array.from(o._zod.values)))}),Xe(t._zod,"pattern",()=>{if(r.options.every(o=>o._zod.pattern)){const o=r.options.map(l=>l._zod.pattern);return new RegExp(`^(${o.map(l=>Ko(l.source)).join("|")})$`)}}),t._zod.parse=(o,l)=>{let u=!1;const f=[];for(const g of r.options){const x=g._zod.run({value:o.value,issues:[]},l);if(x instanceof Promise)f.push(x),u=!0;else{if(x.issues.length===0)return x;f.push(x)}}return u?Promise.all(f).then(g=>Vs(g,o,t,l)):Vs(f,o,t,l)}}),Z0=Q("$ZodDiscriminatedUnion",(t,r)=>{Ac.init(t,r);const o=t._zod.parse;Xe(t._zod,"propValues",()=>{const u={};for(const f of r.options){const g=f._zod.propValues;if(!g||Object.keys(g).length===0)throw new Error(`Invalid discriminated union option at index "${r.options.indexOf(f)}"`);for(const[x,y]of Object.entries(g)){u[x]||(u[x]=new Set);for(const m of y)u[x].add(m)}}return u});const l=qo(()=>{const u=r.options,f=new Map;for(const g of u){const x=g._zod.propValues[r.discriminator];if(!x||x.size===0)throw new Error(`Invalid discriminated union option at index "${r.options.indexOf(g)}"`);for(const y of x){if(f.has(y))throw new Error(`Duplicate discriminator value "${String(y)}"`);f.set(y,g)}}return f});t._zod.parse=(u,f)=>{const g=u.value;if(!Pi(g))return u.issues.push({code:"invalid_type",expected:"object",input:g,inst:t}),u;const x=l.value.get(g?.[r.discriminator]);return x?x._zod.run(u,f):r.unionFallback?o(u,f):(u.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:g,path:[r.discriminator],inst:t}),u)}}),j0=Q("$ZodIntersection",(t,r)=>{rt.init(t,r),t._zod.parse=(o,l)=>{const u=o.value,f=r.left._zod.run({value:u,issues:[]},l),g=r.right._zod.run({value:u,issues:[]},l);return f instanceof Promise||g instanceof Promise?Promise.all([f,g]).then(([y,m])=>Zs(o,y,m)):Zs(o,f,g)}});function Po(t,r){if(t===r)return{valid:!0,data:t};if(t instanceof Date&&r instanceof Date&&+t==+r)return{valid:!0,data:t};if(Bi(t)&&Bi(r)){const o=Object.keys(r),l=Object.keys(t).filter(f=>o.indexOf(f)!==-1),u={...t,...r};for(const f of l){const g=Po(t[f],r[f]);if(!g.valid)return{valid:!1,mergeErrorPath:[f,...g.mergeErrorPath]};u[f]=g.data}return{valid:!0,data:u}}if(Array.isArray(t)&&Array.isArray(r)){if(t.length!==r.length)return{valid:!1,mergeErrorPath:[]};const o=[];for(let l=0;l<t.length;l++){const u=t[l],f=r[l],g=Po(u,f);if(!g.valid)return{valid:!1,mergeErrorPath:[l,...g.mergeErrorPath]};o.push(g.data)}return{valid:!0,data:o}}return{valid:!1,mergeErrorPath:[]}}function Zs(t,r,o){if(r.issues.length&&t.issues.push(...r.issues),o.issues.length&&t.issues.push(...o.issues),jr(t))return t;const l=Po(r.value,o.value);if(!l.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(l.mergeErrorPath)}`);return t.value=l.data,t}const H0=Q("$ZodRecord",(t,r)=>{rt.init(t,r),t._zod.parse=(o,l)=>{const u=o.value;if(!Bi(u))return o.issues.push({expected:"record",code:"invalid_type",input:u,inst:t}),o;const f=[];if(r.keyType._zod.values){const g=r.keyType._zod.values;o.value={};for(const y of g)if(typeof y=="string"||typeof y=="number"||typeof y=="symbol"){const m=r.valueType._zod.run({value:u[y],issues:[]},l);m instanceof Promise?f.push(m.then(E=>{E.issues.length&&o.issues.push(...sr(y,E.issues)),o.value[y]=E.value})):(m.issues.length&&o.issues.push(...sr(y,m.issues)),o.value[y]=m.value)}let x;for(const y in u)g.has(y)||(x=x??[],x.push(y));x&&x.length>0&&o.issues.push({code:"unrecognized_keys",input:u,inst:t,keys:x})}else{o.value={};for(const g of Reflect.ownKeys(u)){if(g==="__proto__")continue;const x=r.keyType._zod.run({value:g,issues:[]},l);if(x instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(x.issues.length){o.issues.push({origin:"record",code:"invalid_key",issues:x.issues.map(m=>Yn(m,l,qn())),input:g,path:[g],inst:t}),o.value[x.value]=x.value;continue}const y=r.valueType._zod.run({value:u[g],issues:[]},l);y instanceof Promise?f.push(y.then(m=>{m.issues.length&&o.issues.push(...sr(g,m.issues)),o.value[x.value]=m.value})):(y.issues.length&&o.issues.push(...sr(g,y.issues)),o.value[x.value]=y.value)}}return f.length?Promise.all(f).then(()=>o):o}}),W0=Q("$ZodEnum",(t,r)=>{rt.init(t,r);const o=uc(r.entries);t._zod.values=new Set(o),t._zod.pattern=new RegExp(`^(${o.filter(l=>ad.has(typeof l)).map(l=>typeof l=="string"?ti(l):l.toString()).join("|")})$`),t._zod.parse=(l,u)=>{const f=l.value;return t._zod.values.has(f)||l.issues.push({code:"invalid_value",values:o,input:f,inst:t}),l}}),G0=Q("$ZodLiteral",(t,r)=>{rt.init(t,r),t._zod.values=new Set(r.values),t._zod.pattern=new RegExp(`^(${r.values.map(o=>typeof o=="string"?ti(o):o?o.toString():String(o)).join("|")})$`),t._zod.parse=(o,l)=>{const u=o.value;return t._zod.values.has(u)||o.issues.push({code:"invalid_value",values:r.values,input:u,inst:t}),o}}),X0=Q("$ZodTransform",(t,r)=>{rt.init(t,r),t._zod.parse=(o,l)=>{const u=r.transform(o.value,o);if(l.async)return(u instanceof Promise?u:Promise.resolve(u)).then(g=>(o.value=g,o));if(u instanceof Promise)throw new Gr;return o.value=u,o}}),q0=Q("$ZodOptional",(t,r)=>{rt.init(t,r),t._zod.optin="optional",t._zod.optout="optional",Xe(t._zod,"values",()=>r.innerType._zod.values?new Set([...r.innerType._zod.values,void 0]):void 0),Xe(t._zod,"pattern",()=>{const o=r.innerType._zod.pattern;return o?new RegExp(`^(${Ko(o.source)})?$`):void 0}),t._zod.parse=(o,l)=>r.innerType._zod.optin==="optional"?r.innerType._zod.run(o,l):o.value===void 0?o:r.innerType._zod.run(o,l)}),Y0=Q("$ZodNullable",(t,r)=>{rt.init(t,r),Xe(t._zod,"optin",()=>r.innerType._zod.optin),Xe(t._zod,"optout",()=>r.innerType._zod.optout),Xe(t._zod,"pattern",()=>{const o=r.innerType._zod.pattern;return o?new RegExp(`^(${Ko(o.source)}|null)$`):void 0}),Xe(t._zod,"values",()=>r.innerType._zod.values?new Set([...r.innerType._zod.values,null]):void 0),t._zod.parse=(o,l)=>o.value===null?o:r.innerType._zod.run(o,l)}),K0=Q("$ZodDefault",(t,r)=>{rt.init(t,r),t._zod.optin="optional",Xe(t._zod,"values",()=>r.innerType._zod.values),t._zod.parse=(o,l)=>{if(o.value===void 0)return o.value=r.defaultValue,o;const u=r.innerType._zod.run(o,l);return u instanceof Promise?u.then(f=>js(f,r)):js(u,r)}});function js(t,r){return t.value===void 0&&(t.value=r.defaultValue),t}const J0=Q("$ZodPrefault",(t,r)=>{rt.init(t,r),t._zod.optin="optional",Xe(t._zod,"values",()=>r.innerType._zod.values),t._zod.parse=(o,l)=>(o.value===void 0&&(o.value=r.defaultValue),r.innerType._zod.run(o,l))}),Q0=Q("$ZodNonOptional",(t,r)=>{rt.init(t,r),Xe(t._zod,"values",()=>{const o=r.innerType._zod.values;return o?new Set([...o].filter(l=>l!==void 0)):void 0}),t._zod.parse=(o,l)=>{const u=r.innerType._zod.run(o,l);return u instanceof Promise?u.then(f=>Hs(f,t)):Hs(u,t)}});function Hs(t,r){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:r}),t}const ef=Q("$ZodCatch",(t,r)=>{rt.init(t,r),t._zod.optin="optional",Xe(t._zod,"optout",()=>r.innerType._zod.optout),Xe(t._zod,"values",()=>r.innerType._zod.values),t._zod.parse=(o,l)=>{const u=r.innerType._zod.run(o,l);return u instanceof Promise?u.then(f=>(o.value=f.value,f.issues.length&&(o.value=r.catchValue({...o,error:{issues:f.issues.map(g=>Yn(g,l,qn()))},input:o.value}),o.issues=[]),o)):(o.value=u.value,u.issues.length&&(o.value=r.catchValue({...o,error:{issues:u.issues.map(f=>Yn(f,l,qn()))},input:o.value}),o.issues=[]),o)}}),tf=Q("$ZodPipe",(t,r)=>{rt.init(t,r),Xe(t._zod,"values",()=>r.in._zod.values),Xe(t._zod,"optin",()=>r.in._zod.optin),Xe(t._zod,"optout",()=>r.out._zod.optout),t._zod.parse=(o,l)=>{const u=r.in._zod.run(o,l);return u instanceof Promise?u.then(f=>Ws(f,r,l)):Ws(u,r,l)}});function Ws(t,r,o){return jr(t)?t:r.out._zod.run({value:t.value,issues:t.issues},o)}const nf=Q("$ZodReadonly",(t,r)=>{rt.init(t,r),Xe(t._zod,"propValues",()=>r.innerType._zod.propValues),Xe(t._zod,"values",()=>r.innerType._zod.values),Xe(t._zod,"optin",()=>r.innerType._zod.optin),Xe(t._zod,"optout",()=>r.innerType._zod.optout),t._zod.parse=(o,l)=>{const u=r.innerType._zod.run(o,l);return u instanceof Promise?u.then(Gs):Gs(u)}});function Gs(t){return t.value=Object.freeze(t.value),t}const rf=Q("$ZodLazy",(t,r)=>{rt.init(t,r),Xe(t._zod,"innerType",()=>r.getter()),Xe(t._zod,"pattern",()=>t._zod.innerType._zod.pattern),Xe(t._zod,"propValues",()=>t._zod.innerType._zod.propValues),Xe(t._zod,"optin",()=>t._zod.innerType._zod.optin),Xe(t._zod,"optout",()=>t._zod.innerType._zod.optout),t._zod.parse=(o,l)=>t._zod.innerType._zod.run(o,l)}),of=Q("$ZodCustom",(t,r)=>{tn.init(t,r),rt.init(t,r),t._zod.parse=(o,l)=>o,t._zod.check=o=>{const l=o.value,u=r.fn(l);if(u instanceof Promise)return u.then(f=>Xs(f,o,l,t));Xs(u,o,l,t)}});function Xs(t,r,o,l){if(!t){const u={code:"custom",input:o,inst:l,path:[...l._zod.def.path??[]],continue:!l._zod.def.abort};l._zod.def.params&&(u.params=l._zod.def.params),r.issues.push(Xr(u))}}class Ic{constructor(){this._map=new Map,this._idmap=new Map}add(r,...o){const l=o[0];if(this._map.set(r,l),l&&typeof l=="object"&&"id"in l){if(this._idmap.has(l.id))throw new Error(`ID ${l.id} already exists in the registry`);this._idmap.set(l.id,r)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(r){const o=this._map.get(r);return o&&typeof o=="object"&&"id"in o&&this._idmap.delete(o.id),this._map.delete(r),this}get(r){const o=r._zod.parent;if(o){const l={...this.get(o)??{}};return delete l.id,{...l,...this._map.get(r)}}return this._map.get(r)}has(r){return this._map.has(r)}}function sf(){return new Ic}const zr=sf();function af(t,r){return new t({type:"string",...Te(r)})}function lf(t,r){return new t({type:"string",format:"email",check:"string_format",abort:!1,...Te(r)})}function qs(t,r){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...Te(r)})}function cf(t,r){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...Te(r)})}function uf(t,r){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Te(r)})}function df(t,r){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Te(r)})}function ff(t,r){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Te(r)})}function hf(t,r){return new t({type:"string",format:"url",check:"string_format",abort:!1,...Te(r)})}function pf(t,r){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...Te(r)})}function gf(t,r){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...Te(r)})}function mf(t,r){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...Te(r)})}function xf(t,r){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...Te(r)})}function wf(t,r){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...Te(r)})}function yf(t,r){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...Te(r)})}function _f(t,r){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...Te(r)})}function vf(t,r){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...Te(r)})}function bf(t,r){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...Te(r)})}function Cf(t,r){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Te(r)})}function Ef(t,r){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Te(r)})}function Af(t,r){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...Te(r)})}function If(t,r){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...Te(r)})}function Sf(t,r){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...Te(r)})}function Tf(t,r){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...Te(r)})}function Nf(t,r){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Te(r)})}function Of(t,r){return new t({type:"string",format:"date",check:"string_format",...Te(r)})}function kf(t,r){return new t({type:"string",format:"time",check:"string_format",precision:null,...Te(r)})}function Rf(t,r){return new t({type:"string",format:"duration",check:"string_format",...Te(r)})}function Df(t,r){return new t({type:"number",checks:[],...Te(r)})}function Mf(t,r){return new t({type:"number",coerce:!0,checks:[],...Te(r)})}function Pf(t,r){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...Te(r)})}function Bf(t,r){return new t({type:"boolean",...Te(r)})}function Lf(t,r){return new t({type:"null",...Te(r)})}function Ff(t){return new t({type:"any"})}function $f(t){return new t({type:"unknown"})}function Uf(t,r){return new t({type:"never",...Te(r)})}function Ys(t,r){return new vc({check:"less_than",...Te(r),value:t,inclusive:!1})}function _o(t,r){return new vc({check:"less_than",...Te(r),value:t,inclusive:!0})}function Ks(t,r){return new bc({check:"greater_than",...Te(r),value:t,inclusive:!1})}function vo(t,r){return new bc({check:"greater_than",...Te(r),value:t,inclusive:!0})}function Js(t,r){return new Yd({check:"multiple_of",...Te(r),value:t})}function Sc(t,r){return new Jd({check:"max_length",...Te(r),maximum:t})}function Li(t,r){return new Qd({check:"min_length",...Te(r),minimum:t})}function Tc(t,r){return new e0({check:"length_equals",...Te(r),length:t})}function zf(t,r){return new t0({check:"string_format",format:"regex",...Te(r),pattern:t})}function Vf(t){return new n0({check:"string_format",format:"lowercase",...Te(t)})}function Zf(t){return new r0({check:"string_format",format:"uppercase",...Te(t)})}function jf(t,r){return new i0({check:"string_format",format:"includes",...Te(r),includes:t})}function Hf(t,r){return new o0({check:"string_format",format:"starts_with",...Te(r),prefix:t})}function Wf(t,r){return new s0({check:"string_format",format:"ends_with",...Te(r),suffix:t})}function ni(t){return new a0({check:"overwrite",tx:t})}function Gf(t){return ni(r=>r.normalize(t))}function Xf(){return ni(t=>t.trim())}function qf(){return ni(t=>t.toLowerCase())}function Yf(){return ni(t=>t.toUpperCase())}function Kf(t,r,o){return new t({type:"array",element:r,...Te(o)})}function Jf(t,r,o){const l=Te(o);return l.abort??(l.abort=!0),new t({type:"custom",check:"custom",fn:r,...l})}function Qf(t,r,o){return new t({type:"custom",check:"custom",fn:r,...Te(o)})}class Qs{constructor(r){this.counter=0,this.metadataRegistry=r?.metadata??zr,this.target=r?.target??"draft-2020-12",this.unrepresentable=r?.unrepresentable??"throw",this.override=r?.override??(()=>{}),this.io=r?.io??"output",this.seen=new Map}process(r,o={path:[],schemaPath:[]}){var l;const u=r._zod.def,f={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},g=this.seen.get(r);if(g)return g.count++,o.schemaPath.includes(r)&&(g.cycle=o.path),g.schema;const x={schema:{},count:1,cycle:void 0,path:o.path};this.seen.set(r,x);const y=r._zod.toJSONSchema?.();if(y)x.schema=y;else{const C={...o,schemaPath:[...o.schemaPath,r],path:o.path},P=r._zod.parent;if(P)x.ref=P,this.process(P,C),this.seen.get(P).isParent=!0;else{const O=x.schema;switch(u.type){case"string":{const D=O;D.type="string";const{minimum:R,maximum:M,format:V,patterns:U,contentEncoding:k}=r._zod.bag;if(typeof R=="number"&&(D.minLength=R),typeof M=="number"&&(D.maxLength=M),V&&(D.format=f[V]??V,D.format===""&&delete D.format),k&&(D.contentEncoding=k),U&&U.size>0){const J=[...U];J.length===1?D.pattern=J[0].source:J.length>1&&(x.schema.allOf=[...J.map(be=>({...this.target==="draft-7"?{type:"string"}:{},pattern:be.source}))])}break}case"number":{const D=O,{minimum:R,maximum:M,format:V,multipleOf:U,exclusiveMaximum:k,exclusiveMinimum:J}=r._zod.bag;typeof V=="string"&&V.includes("int")?D.type="integer":D.type="number",typeof J=="number"&&(D.exclusiveMinimum=J),typeof R=="number"&&(D.minimum=R,typeof J=="number"&&(J>=R?delete D.minimum:delete D.exclusiveMinimum)),typeof k=="number"&&(D.exclusiveMaximum=k),typeof M=="number"&&(D.maximum=M,typeof k=="number"&&(k<=M?delete D.maximum:delete D.exclusiveMaximum)),typeof U=="number"&&(D.multipleOf=U);break}case"boolean":{const D=O;D.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{O.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{O.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{const D=O,{minimum:R,maximum:M}=r._zod.bag;typeof R=="number"&&(D.minItems=R),typeof M=="number"&&(D.maxItems=M),D.type="array",D.items=this.process(u.element,{...C,path:[...C.path,"items"]});break}case"object":{const D=O;D.type="object",D.properties={};const R=u.shape;for(const U in R)D.properties[U]=this.process(R[U],{...C,path:[...C.path,"properties",U]});const M=new Set(Object.keys(R)),V=new Set([...M].filter(U=>{const k=u.shape[U]._zod;return this.io==="input"?k.optin===void 0:k.optout===void 0}));V.size>0&&(D.required=Array.from(V)),u.catchall?._zod.def.type==="never"?D.additionalProperties=!1:u.catchall?u.catchall&&(D.additionalProperties=this.process(u.catchall,{...C,path:[...C.path,"additionalProperties"]})):this.io==="output"&&(D.additionalProperties=!1);break}case"union":{const D=O;D.anyOf=u.options.map((R,M)=>this.process(R,{...C,path:[...C.path,"anyOf",M]}));break}case"intersection":{const D=O,R=this.process(u.left,{...C,path:[...C.path,"allOf",0]}),M=this.process(u.right,{...C,path:[...C.path,"allOf",1]}),V=k=>"allOf"in k&&Object.keys(k).length===1,U=[...V(R)?R.allOf:[R],...V(M)?M.allOf:[M]];D.allOf=U;break}case"tuple":{const D=O;D.type="array";const R=u.items.map((U,k)=>this.process(U,{...C,path:[...C.path,"prefixItems",k]}));if(this.target==="draft-2020-12"?D.prefixItems=R:D.items=R,u.rest){const U=this.process(u.rest,{...C,path:[...C.path,"items"]});this.target==="draft-2020-12"?D.items=U:D.additionalItems=U}u.rest&&(D.items=this.process(u.rest,{...C,path:[...C.path,"items"]}));const{minimum:M,maximum:V}=r._zod.bag;typeof M=="number"&&(D.minItems=M),typeof V=="number"&&(D.maxItems=V);break}case"record":{const D=O;D.type="object",D.propertyNames=this.process(u.keyType,{...C,path:[...C.path,"propertyNames"]}),D.additionalProperties=this.process(u.valueType,{...C,path:[...C.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{const D=O,R=uc(u.entries);R.every(M=>typeof M=="number")&&(D.type="number"),R.every(M=>typeof M=="string")&&(D.type="string"),D.enum=R;break}case"literal":{const D=O,R=[];for(const M of u.values)if(M===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof M=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");R.push(Number(M))}else R.push(M);if(R.length!==0)if(R.length===1){const M=R[0];D.type=M===null?"null":typeof M,D.const=M}else R.every(M=>typeof M=="number")&&(D.type="number"),R.every(M=>typeof M=="string")&&(D.type="string"),R.every(M=>typeof M=="boolean")&&(D.type="string"),R.every(M=>M===null)&&(D.type="null"),D.enum=R;break}case"file":{const D=O,R={type:"string",format:"binary",contentEncoding:"binary"},{minimum:M,maximum:V,mime:U}=r._zod.bag;M!==void 0&&(R.minLength=M),V!==void 0&&(R.maxLength=V),U?U.length===1?(R.contentMediaType=U[0],Object.assign(D,R)):D.anyOf=U.map(k=>({...R,contentMediaType:k})):Object.assign(D,R);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{const D=this.process(u.innerType,C);O.anyOf=[D,{type:"null"}];break}case"nonoptional":{this.process(u.innerType,C),x.ref=u.innerType;break}case"success":{const D=O;D.type="boolean";break}case"default":{this.process(u.innerType,C),x.ref=u.innerType,O.default=JSON.parse(JSON.stringify(u.defaultValue));break}case"prefault":{this.process(u.innerType,C),x.ref=u.innerType,this.io==="input"&&(O._prefault=JSON.parse(JSON.stringify(u.defaultValue)));break}case"catch":{this.process(u.innerType,C),x.ref=u.innerType;let D;try{D=u.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}O.default=D;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{const D=O,R=r._zod.pattern;if(!R)throw new Error("Pattern not found in template literal");D.type="string",D.pattern=R.source;break}case"pipe":{const D=this.io==="input"?u.in._zod.def.type==="transform"?u.out:u.in:u.out;this.process(D,C),x.ref=D;break}case"readonly":{this.process(u.innerType,C),x.ref=u.innerType,O.readOnly=!0;break}case"promise":{this.process(u.innerType,C),x.ref=u.innerType;break}case"optional":{this.process(u.innerType,C),x.ref=u.innerType;break}case"lazy":{const D=r._zod.innerType;this.process(D,C),x.ref=D;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}}}}const m=this.metadataRegistry.get(r);return m&&Object.assign(x.schema,m),this.io==="input"&&Nt(r)&&(delete x.schema.examples,delete x.schema.default),this.io==="input"&&x.schema._prefault&&((l=x.schema).default??(l.default=x.schema._prefault)),delete x.schema._prefault,this.seen.get(r).schema}emit(r,o){const l={cycles:o?.cycles??"ref",reused:o?.reused??"inline",external:o?.external??void 0},u=this.seen.get(r);if(!u)throw new Error("Unprocessed schema. This is a bug in Zod.");const f=E=>{const C=this.target==="draft-2020-12"?"$defs":"definitions";if(l.external){const R=l.external.registry.get(E[0])?.id,M=l.external.uri??(U=>U);if(R)return{ref:M(R)};const V=E[1].defId??E[1].schema.id??`schema${this.counter++}`;return E[1].defId=V,{defId:V,ref:`${M("__shared")}#/${C}/${V}`}}if(E[1]===u)return{ref:"#"};const O=`#/${C}/`,D=E[1].schema.id??`__schema${this.counter++}`;return{defId:D,ref:O+D}},g=E=>{if(E[1].schema.$ref)return;const C=E[1],{ref:P,defId:O}=f(E);C.def={...C.schema},O&&(C.defId=O);const D=C.schema;for(const R in D)delete D[R];D.$ref=P};if(l.cycles==="throw")for(const E of this.seen.entries()){const C=E[1];if(C.cycle)throw new Error(`Cycle detected: #/${C.cycle?.join("/")}/<root>
33
33
 
34
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const A of this.seen.entries()){const b=A[1];if(n===A[0]){g(A);continue}if(l.external){const N=l.external.registry.get(A[0])?.id;if(n!==A[0]&&N){g(A);continue}}if(this.metadataRegistry.get(A[0])?.id){g(A);continue}if(b.cycle){g(A);continue}if(b.count>1&&l.reused==="ref"){g(A);continue}}const m=(A,b)=>{const P=this.seen.get(A),N=P.def??P.schema,R={...N};if(P.ref===null)return;const D=P.ref;if(P.ref=null,D){m(D,b);const M=this.seen.get(D).schema;M.$ref&&b.target==="draft-7"?(N.allOf=N.allOf??[],N.allOf.push(M)):(Object.assign(N,M),Object.assign(N,R))}P.isParent||this.override({zodSchema:A,jsonSchema:N,path:P.path??[]})};for(const A of[...this.seen.entries()].reverse())m(A[0],{target:this.target});const y={};if(this.target==="draft-2020-12"?y.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?y.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),l.external?.uri){const A=l.external.registry.get(n)?.id;if(!A)throw new Error("Schema is missing an `id` property");y.$id=l.external.uri(A)}Object.assign(y,u.def);const x=l.external?.defs??{};for(const A of this.seen.entries()){const b=A[1];b.def&&b.defId&&(x[b.defId]=b.def)}l.external||Object.keys(x).length>0&&(this.target==="draft-2020-12"?y.$defs=x:y.definitions=x);try{return JSON.parse(JSON.stringify(y))}catch{throw new Error("Error converting schema to JSON.")}}}function Lc(t,n){if(t instanceof Mc){const l=new sa(n),u={};for(const m of t._idmap.entries()){const[y,x]=m;l.process(x)}const f={},g={registry:t,uri:n?.uri,defs:u};for(const m of t._idmap.entries()){const[y,x]=m;f[y]=l.emit(x,{...n,external:g})}if(Object.keys(u).length>0){const m=l.target==="draft-2020-12"?"$defs":"definitions";f.__shared={[m]:u}}return{schemas:f}}const o=new sa(n);return o.process(t),o.emit(t,n)}function Ot(t,n){const o=n??{seen:new Set};if(o.seen.has(t))return!1;o.seen.add(t);const u=t._zod.def;switch(u.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return Ot(u.element,o);case"object":{for(const f in u.shape)if(Ot(u.shape[f],o))return!0;return!1}case"union":{for(const f of u.options)if(Ot(f,o))return!0;return!1}case"intersection":return Ot(u.left,o)||Ot(u.right,o);case"tuple":{for(const f of u.items)if(Ot(f,o))return!0;return!!(u.rest&&Ot(u.rest,o))}case"record":return Ot(u.keyType,o)||Ot(u.valueType,o);case"map":return Ot(u.keyType,o)||Ot(u.valueType,o);case"set":return Ot(u.valueType,o);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return Ot(u.innerType,o);case"lazy":return Ot(u.getter(),o);case"default":return Ot(u.innerType,o);case"prefault":return Ot(u.innerType,o);case"custom":return!1;case"transform":return!0;case"pipe":return Ot(u.in,o)||Ot(u.out,o);case"success":return!1;case"catch":return!1}throw new Error(`Unknown schema type: ${u.type}`)}const ch=q("ZodISODateTime",(t,n)=>{Nd.init(t,n),xt.init(t,n)});function uh(t){return Ff(ch,t)}const dh=q("ZodISODate",(t,n)=>{kd.init(t,n),xt.init(t,n)});function fh(t){return $f(dh,t)}const hh=q("ZodISOTime",(t,n)=>{Rd.init(t,n),xt.init(t,n)});function ph(t){return Uf(hh,t)}const gh=q("ZodISODuration",(t,n)=>{Dd.init(t,n),xt.init(t,n)});function mh(t){return zf(gh,t)}const xh=(t,n)=>{vc.init(t,n),t.name="ZodError",Object.defineProperties(t,{format:{value:o=>I0(t,o)},flatten:{value:o=>A0(t,o)},addIssue:{value:o=>t.issues.push(o)},addIssues:{value:o=>t.issues.push(...o)},isEmpty:{get(){return t.issues.length===0}}})},Qi=q("ZodError",xh,{Parent:Error}),wh=S0(Qi),yh=T0(Qi),_h=bc(Qi),ls=Ec(Qi),dt=q("ZodType",(t,n)=>(st.init(t,n),t.def=n,Object.defineProperty(t,"_def",{value:n}),t.check=(...o)=>t.clone({...n,checks:[...n.checks??[],...o.map(l=>typeof l=="function"?{_zod:{check:l,def:{check:"custom"},onattach:[]}}:l)]}),t.clone=(o,l)=>hr(t,o,l),t.brand=()=>t,t.register=((o,l)=>(o.add(t,l),t)),t.parse=(o,l)=>wh(t,o,l,{callee:t.parse}),t.safeParse=(o,l)=>_h(t,o,l),t.parseAsync=async(o,l)=>yh(t,o,l,{callee:t.parseAsync}),t.safeParseAsync=async(o,l)=>ls(t,o,l),t.spa=t.safeParseAsync,t.refine=(o,l)=>t.check(mp(o,l)),t.superRefine=o=>t.check(xp(o)),t.overwrite=o=>t.check(si(o)),t.optional=()=>ca(t),t.nullable=()=>ua(t),t.nullish=()=>ca(ua(t)),t.nonoptional=o=>ap(t,o),t.array=()=>_e(t),t.or=o=>ut([t,o]),t.and=o=>Kh(t,o),t.transform=o=>da(t,tp(o)),t.default=o=>ip(t,o),t.prefault=o=>sp(t,o),t.catch=o=>cp(t,o),t.pipe=o=>da(t,o),t.readonly=()=>fp(t),t.describe=o=>{const l=t.clone();return Hr.add(l,{description:o}),l},Object.defineProperty(t,"description",{get(){return Hr.get(t)?.description},configurable:!0}),t.meta=(...o)=>{if(o.length===0)return Hr.get(t);const l=t.clone();return Hr.add(l,o[0]),l},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),Fc=q("_ZodString",(t,n)=>{as.init(t,n),dt.init(t,n);const o=t._zod.bag;t.format=o.format??null,t.minLength=o.minimum??null,t.maxLength=o.maximum??null,t.regex=(...l)=>t.check(qf(...l)),t.includes=(...l)=>t.check(Qf(...l)),t.startsWith=(...l)=>t.check(eh(...l)),t.endsWith=(...l)=>t.check(th(...l)),t.min=(...l)=>t.check(Vi(...l)),t.max=(...l)=>t.check(Pc(...l)),t.length=(...l)=>t.check(Bc(...l)),t.nonempty=(...l)=>t.check(Vi(1,...l)),t.lowercase=l=>t.check(Kf(l)),t.uppercase=l=>t.check(Jf(l)),t.trim=()=>t.check(rh()),t.normalize=(...l)=>t.check(nh(...l)),t.toLowerCase=()=>t.check(ih()),t.toUpperCase=()=>t.check(oh())}),vh=q("ZodString",(t,n)=>{as.init(t,n),Fc.init(t,n),t.email=o=>t.check(xf(Ch,o)),t.url=o=>t.check(Cf(bh,o)),t.jwt=o=>t.check(Lf(Fh,o)),t.emoji=o=>t.check(bf(Eh,o)),t.guid=o=>t.check(na(aa,o)),t.uuid=o=>t.check(wf(Ai,o)),t.uuidv4=o=>t.check(yf(Ai,o)),t.uuidv6=o=>t.check(_f(Ai,o)),t.uuidv7=o=>t.check(vf(Ai,o)),t.nanoid=o=>t.check(Ef(Ah,o)),t.guid=o=>t.check(na(aa,o)),t.cuid=o=>t.check(Af(Ih,o)),t.cuid2=o=>t.check(If(Sh,o)),t.ulid=o=>t.check(Sf(Th,o)),t.base64=o=>t.check(Mf(Ph,o)),t.base64url=o=>t.check(Pf(Bh,o)),t.xid=o=>t.check(Tf(Oh,o)),t.ksuid=o=>t.check(Of(Nh,o)),t.ipv4=o=>t.check(Nf(kh,o)),t.ipv6=o=>t.check(kf(Rh,o)),t.cidrv4=o=>t.check(Rf(Dh,o)),t.cidrv6=o=>t.check(Df(Mh,o)),t.e164=o=>t.check(Bf(Lh,o)),t.datetime=o=>t.check(uh(o)),t.date=o=>t.check(fh(o)),t.time=o=>t.check(ph(o)),t.duration=o=>t.check(mh(o))});function I(t){return mf(vh,t)}const xt=q("ZodStringFormat",(t,n)=>{gt.init(t,n),Fc.init(t,n)}),Ch=q("ZodEmail",(t,n)=>{vd.init(t,n),xt.init(t,n)}),aa=q("ZodGUID",(t,n)=>{yd.init(t,n),xt.init(t,n)}),Ai=q("ZodUUID",(t,n)=>{_d.init(t,n),xt.init(t,n)}),bh=q("ZodURL",(t,n)=>{Cd.init(t,n),xt.init(t,n)}),Eh=q("ZodEmoji",(t,n)=>{bd.init(t,n),xt.init(t,n)}),Ah=q("ZodNanoID",(t,n)=>{Ed.init(t,n),xt.init(t,n)}),Ih=q("ZodCUID",(t,n)=>{Ad.init(t,n),xt.init(t,n)}),Sh=q("ZodCUID2",(t,n)=>{Id.init(t,n),xt.init(t,n)}),Th=q("ZodULID",(t,n)=>{Sd.init(t,n),xt.init(t,n)}),Oh=q("ZodXID",(t,n)=>{Td.init(t,n),xt.init(t,n)}),Nh=q("ZodKSUID",(t,n)=>{Od.init(t,n),xt.init(t,n)}),kh=q("ZodIPv4",(t,n)=>{Md.init(t,n),xt.init(t,n)}),Rh=q("ZodIPv6",(t,n)=>{Pd.init(t,n),xt.init(t,n)}),Dh=q("ZodCIDRv4",(t,n)=>{Bd.init(t,n),xt.init(t,n)}),Mh=q("ZodCIDRv6",(t,n)=>{Ld.init(t,n),xt.init(t,n)}),Ph=q("ZodBase64",(t,n)=>{Fd.init(t,n),xt.init(t,n)}),Bh=q("ZodBase64URL",(t,n)=>{Ud.init(t,n),xt.init(t,n)}),Lh=q("ZodE164",(t,n)=>{zd.init(t,n),xt.init(t,n)}),Fh=q("ZodJWT",(t,n)=>{Vd.init(t,n),xt.init(t,n)}),cs=q("ZodNumber",(t,n)=>{Rc.init(t,n),dt.init(t,n),t.gt=(l,u)=>t.check(ia(l,u)),t.gte=(l,u)=>t.check(So(l,u)),t.min=(l,u)=>t.check(So(l,u)),t.lt=(l,u)=>t.check(ra(l,u)),t.lte=(l,u)=>t.check(Io(l,u)),t.max=(l,u)=>t.check(Io(l,u)),t.int=l=>t.check(la(l)),t.safe=l=>t.check(la(l)),t.positive=l=>t.check(ia(0,l)),t.nonnegative=l=>t.check(So(0,l)),t.negative=l=>t.check(ra(0,l)),t.nonpositive=l=>t.check(Io(0,l)),t.multipleOf=(l,u)=>t.check(oa(l,u)),t.step=(l,u)=>t.check(oa(l,u)),t.finite=()=>t;const o=t._zod.bag;t.minValue=Math.max(o.minimum??Number.NEGATIVE_INFINITY,o.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(o.maximum??Number.POSITIVE_INFINITY,o.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(o.format??"").includes("int")||Number.isSafeInteger(o.multipleOf??.5),t.isFinite=!0,t.format=o.format??null});function W(t){return Zf(cs,t)}const $h=q("ZodNumberFormat",(t,n)=>{jd.init(t,n),cs.init(t,n)});function la(t){return jf($h,t)}const Uh=q("ZodBoolean",(t,n)=>{Hd.init(t,n),dt.init(t,n)});function Ft(t){return Hf(Uh,t)}const zh=q("ZodNull",(t,n)=>{Wd.init(t,n),dt.init(t,n)});function Zh(t){return Wf(zh,t)}const Vh=q("ZodAny",(t,n)=>{Gd.init(t,n),dt.init(t,n)});function ai(){return Gf(Vh)}const jh=q("ZodUnknown",(t,n)=>{Xd.init(t,n),dt.init(t,n)});function Qr(){return Xf(jh)}const Hh=q("ZodNever",(t,n)=>{Yd.init(t,n),dt.init(t,n)});function Wh(t){return Yf(Hh,t)}const Gh=q("ZodArray",(t,n)=>{qd.init(t,n),dt.init(t,n),t.element=n.element,t.min=(o,l)=>t.check(Vi(o,l)),t.nonempty=o=>t.check(Vi(1,o)),t.max=(o,l)=>t.check(Pc(o,l)),t.length=(o,l)=>t.check(Bc(o,l)),t.unwrap=()=>t.element});function _e(t,n){return sh(Gh,t,n)}const Xh=q("ZodObject",(t,n)=>{Kd.init(t,n),dt.init(t,n),Qe(t,"shape",()=>n.shape),t.keyof=()=>pt(Object.keys(t._zod.def.shape)),t.catchall=o=>t.clone({...t._zod.def,catchall:o}),t.passthrough=()=>t.clone({...t._zod.def,catchall:Qr()}),t.loose=()=>t.clone({...t._zod.def,catchall:Qr()}),t.strict=()=>t.clone({...t._zod.def,catchall:Wh()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=o=>v0(t,o),t.merge=o=>C0(t,o),t.pick=o=>y0(t,o),t.omit=o=>_0(t,o),t.partial=(...o)=>b0(Uc,t,o[0]),t.required=(...o)=>E0(zc,t,o[0])});function B(t,n){const o={type:"object",get shape(){return os(this,"shape",{...t}),this.shape},...Te(n)};return new Xh(o)}const $c=q("ZodUnion",(t,n)=>{Dc.init(t,n),dt.init(t,n),t.options=n.options});function ut(t,n){return new $c({type:"union",options:t,...Te(n)})}const Yh=q("ZodDiscriminatedUnion",(t,n)=>{$c.init(t,n),Jd.init(t,n)});function Lt(t,n,o){return new Yh({type:"union",options:n,discriminator:t,...Te(o)})}const qh=q("ZodIntersection",(t,n)=>{Qd.init(t,n),dt.init(t,n)});function Kh(t,n){return new qh({type:"intersection",left:t,right:n})}const Jh=q("ZodRecord",(t,n)=>{ef.init(t,n),dt.init(t,n),t.keyType=n.keyType,t.valueType=n.valueType});function Dt(t,n,o){return new Jh({type:"record",keyType:t,valueType:n,...Te(o)})}const Vo=q("ZodEnum",(t,n)=>{tf.init(t,n),dt.init(t,n),t.enum=n.entries,t.options=Object.values(n.entries);const o=new Set(Object.keys(n.entries));t.extract=(l,u)=>{const f={};for(const g of l)if(o.has(g))f[g]=n.entries[g];else throw new Error(`Key ${g} not found in enum`);return new Vo({...n,checks:[],...Te(u),entries:f})},t.exclude=(l,u)=>{const f={...n.entries};for(const g of l)if(o.has(g))delete f[g];else throw new Error(`Key ${g} not found in enum`);return new Vo({...n,checks:[],...Te(u),entries:f})}});function pt(t,n){const o=Array.isArray(t)?Object.fromEntries(t.map(l=>[l,l])):t;return new Vo({type:"enum",entries:o,...Te(n)})}const Qh=q("ZodLiteral",(t,n)=>{nf.init(t,n),dt.init(t,n),t.values=new Set(n.values),Object.defineProperty(t,"value",{get(){if(n.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return n.values[0]}})});function re(t,n){return new Qh({type:"literal",values:Array.isArray(t)?t:[t],...Te(n)})}const ep=q("ZodTransform",(t,n)=>{rf.init(t,n),dt.init(t,n),t._zod.parse=(o,l)=>{o.addIssue=f=>{if(typeof f=="string")o.issues.push(Jr(f,o.value,n));else{const g=f;g.fatal&&(g.continue=!1),g.code??(g.code="custom"),g.input??(g.input=o.value),g.inst??(g.inst=t),g.continue??(g.continue=!0),o.issues.push(Jr(g))}};const u=n.transform(o.value,o);return u instanceof Promise?u.then(f=>(o.value=f,o)):(o.value=u,o)}});function tp(t){return new ep({type:"transform",transform:t})}const Uc=q("ZodOptional",(t,n)=>{of.init(t,n),dt.init(t,n),t.unwrap=()=>t._zod.def.innerType});function ca(t){return new Uc({type:"optional",innerType:t})}const np=q("ZodNullable",(t,n)=>{sf.init(t,n),dt.init(t,n),t.unwrap=()=>t._zod.def.innerType});function ua(t){return new np({type:"nullable",innerType:t})}const rp=q("ZodDefault",(t,n)=>{af.init(t,n),dt.init(t,n),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function ip(t,n){return new rp({type:"default",innerType:t,get defaultValue(){return typeof n=="function"?n():n}})}const op=q("ZodPrefault",(t,n)=>{lf.init(t,n),dt.init(t,n),t.unwrap=()=>t._zod.def.innerType});function sp(t,n){return new op({type:"prefault",innerType:t,get defaultValue(){return typeof n=="function"?n():n}})}const zc=q("ZodNonOptional",(t,n)=>{cf.init(t,n),dt.init(t,n),t.unwrap=()=>t._zod.def.innerType});function ap(t,n){return new zc({type:"nonoptional",innerType:t,...Te(n)})}const lp=q("ZodCatch",(t,n)=>{uf.init(t,n),dt.init(t,n),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function cp(t,n){return new lp({type:"catch",innerType:t,catchValue:typeof n=="function"?n:()=>n})}const up=q("ZodPipe",(t,n)=>{df.init(t,n),dt.init(t,n),t.in=n.in,t.out=n.out});function da(t,n){return new up({type:"pipe",in:t,out:n})}const dp=q("ZodReadonly",(t,n)=>{ff.init(t,n),dt.init(t,n)});function fp(t){return new dp({type:"readonly",innerType:t})}const hp=q("ZodLazy",(t,n)=>{hf.init(t,n),dt.init(t,n),t.unwrap=()=>t._zod.def.getter()});function Zc(t){return new hp({type:"lazy",getter:t})}const us=q("ZodCustom",(t,n)=>{pf.init(t,n),dt.init(t,n)});function pp(t){const n=new rn({check:"custom"});return n._zod.check=t,n}function gp(t,n){return ah(us,t??(()=>!0),n)}function mp(t,n={}){return lh(us,t,n)}function xp(t){const n=pp(o=>(o.addIssue=l=>{if(typeof l=="string")o.issues.push(Jr(l,o.value,n._zod.def));else{const u=l;u.fatal&&(u.continue=!1),u.code??(u.code="custom"),u.input??(u.input=o.value),u.inst??(u.inst=n),u.continue??(u.continue=!n._zod.def.abort),o.issues.push(Jr(u))}},t(o.value,o)));return n}function ji(t,n={error:`Input not instance of ${t.name}`}){const o=new us({type:"custom",check:"custom",fn:l=>l instanceof t,abort:!0,...Te(n)});return o._zod.bag.Class=t,o}function wp(t){return Vf(cs,t)}var de;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(de||(de={}));function fa(...t){return t.reduce((n,o)=>({...n,...o??{}}),{})}function eo(t){return Object.fromEntries([...t.headers])}var li=({prefix:t,size:n=16,alphabet:o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:l="-"}={})=>{const u=()=>{const f=o.length,g=new Array(n);for(let m=0;m<n;m++)g[m]=o[Math.random()*f|0];return g.join("")};if(t==null)return u;if(o.includes(l))throw new ql({argument:"separator",message:`The separator "${l}" must not be part of the alphabet "${o}".`});return()=>`${t}${l}${u()}`},Ii=li();function jo(t){return(t instanceof Error||t instanceof DOMException)&&(t.name==="AbortError"||t.name==="ResponseAborted"||t.name==="TimeoutError")}var yp=["fetch failed","failed to fetch"];function _p({error:t,url:n,requestBodyValues:o}){if(jo(t))return t;if(t instanceof TypeError&&yp.includes(t.message.toLowerCase())){const l=t.cause;if(l!=null)return new zn({message:`Cannot connect to API: ${l.message}`,cause:l,url:n,requestBodyValues:o,isRetryable:!0})}return t}function vp(t=globalThis){var n,o,l;return t.window?"runtime/browser":(n=t.navigator)!=null&&n.userAgent?`runtime/${t.navigator.userAgent.toLowerCase()}`:(l=(o=t.process)==null?void 0:o.versions)!=null&&l.node?`runtime/node.js/${t.process.version.substring(0)}`:t.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function Cp(t){if(t==null)return{};const n={};if(t instanceof Headers)t.forEach((o,l)=>{n[l.toLowerCase()]=o});else{Array.isArray(t)||(t=Object.entries(t));for(const[o,l]of t)l!=null&&(n[o.toLowerCase()]=l)}return n}function Vc(t,...n){const o=new Headers(Cp(t)),l=o.get("user-agent")||"";return o.set("user-agent",[l,...n].filter(Boolean).join(" ")),Object.fromEntries(o.entries())}var bp="3.0.18";function Ep({apiKey:t,environmentVariableName:n,apiKeyParameterName:o="apiKey",description:l}){if(typeof t=="string")return t;if(t!=null)throw new Ci({message:`${l} API key must be a string.`});if(typeof process>"u")throw new Ci({message:`${l} API key is missing. Pass it using the '${o}' parameter. Environment variables is not supported in this environment.`});if(t=process.env[n],t==null)throw new Ci({message:`${l} API key is missing. Pass it using the '${o}' parameter or the ${n} environment variable.`});if(typeof t!="string")throw new Ci({message:`${l} API key must be a string. The value of the ${n} environment variable is not a string.`});return t}var Ap=/"__proto__"\s*:/,Ip=/"constructor"\s*:/;function ha(t){const n=JSON.parse(t);return n===null||typeof n!="object"||Ap.test(t)===!1&&Ip.test(t)===!1?n:Sp(n)}function Sp(t){let n=[t];for(;n.length;){const o=n;n=[];for(const l of o){if(Object.prototype.hasOwnProperty.call(l,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(l,"constructor")&&Object.prototype.hasOwnProperty.call(l.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const u in l){const f=l[u];f&&typeof f=="object"&&n.push(f)}}}return t}function ds(t){const{stackTraceLimit:n}=Error;try{Error.stackTraceLimit=0}catch{return ha(t)}try{return ha(t)}finally{Error.stackTraceLimit=n}}var Hi=Symbol.for("vercel.ai.validator");function Tp(t){return{[Hi]:!0,validate:t}}function Op(t){return typeof t=="object"&&t!==null&&Hi in t&&t[Hi]===!0&&"validate"in t}function Np(t){return Op(t)?t:typeof t=="function"?t():kp(t)}function kp(t){return Tp(async n=>{const o=await t["~standard"].validate(n);return o.issues==null?{success:!0,value:o.value}:{success:!1,error:new qr({value:n,cause:o.issues})}})}async function Rp({value:t,schema:n}){const o=await Tr({value:t,schema:n});if(!o.success)throw qr.wrap({value:t,cause:o.error});return o.value}async function Tr({value:t,schema:n}){const o=Np(n);try{if(o.validate==null)return{success:!0,value:t,rawValue:t};const l=await o.validate(t);return l.success?{success:!0,value:l.value,rawValue:t}:{success:!1,error:qr.wrap({value:t,cause:l.error}),rawValue:t}}catch(l){return{success:!1,error:qr.wrap({value:t,cause:l}),rawValue:t}}}async function Dp({text:t,schema:n}){try{const o=ds(t);return n==null?o:Rp({value:o,schema:n})}catch(o){throw Ui.isInstance(o)||qr.isInstance(o)?o:new Ui({text:t,cause:o})}}async function ei({text:t,schema:n}){try{const o=ds(t);return n==null?{success:!0,value:o,rawValue:o}:await Tr({value:o,schema:n})}catch(o){return{success:!1,error:Ui.isInstance(o)?o:new Ui({text:t,cause:o}),rawValue:void 0}}}function pa(t){try{return ds(t),!0}catch{return!1}}function Mp({stream:t,schema:n}){return t.pipeThrough(new TextDecoderStream).pipeThrough(new mc).pipeThrough(new TransformStream({async transform({data:o},l){o!=="[DONE]"&&l.enqueue(await ei({text:o,schema:n}))}}))}async function ga({provider:t,providerOptions:n,schema:o}){if(n?.[t]==null)return;const l=await Tr({value:n[t],schema:o});if(!l.success)throw new ql({argument:"providerOptions",message:`invalid ${t} provider options`,cause:l.error});return l.value}var Pp=()=>globalThis.fetch,ma=async({url:t,headers:n,body:o,failedResponseHandler:l,successfulResponseHandler:u,abortSignal:f,fetch:g})=>Bp({url:t,headers:{"Content-Type":"application/json",...n},body:{content:JSON.stringify(o),values:o},failedResponseHandler:l,successfulResponseHandler:u,abortSignal:f,fetch:g}),Bp=async({url:t,headers:n={},body:o,successfulResponseHandler:l,failedResponseHandler:u,abortSignal:f,fetch:g=Pp()})=>{try{const m=await g(t,{method:"POST",headers:Vc(n,`ai-sdk/provider-utils/${bp}`,vp()),body:o.content,signal:f}),y=eo(m);if(!m.ok){let x;try{x=await u({response:m,url:t,requestBodyValues:o.values})}catch(A){throw jo(A)||zn.isInstance(A)?A:new zn({message:"Failed to process error response",cause:A,statusCode:m.status,url:t,responseHeaders:y,requestBodyValues:o.values})}throw x.value}try{return await l({response:m,url:t,requestBodyValues:o.values})}catch(x){throw x instanceof Error&&(jo(x)||zn.isInstance(x))?x:new zn({message:"Failed to process successful response",cause:x,statusCode:m.status,url:t,responseHeaders:y,requestBodyValues:o.values})}}catch(m){throw _p({error:m,url:t,requestBodyValues:o.values})}};var Lp=({errorSchema:t,errorToMessage:n,isRetryable:o})=>async({response:l,url:u,requestBodyValues:f})=>{const g=await l.text(),m=eo(l);if(g.trim()==="")return{responseHeaders:m,value:new zn({message:l.statusText,url:u,requestBodyValues:f,statusCode:l.status,responseHeaders:m,responseBody:g,isRetryable:o?.(l)})};try{const y=await Dp({text:g,schema:t});return{responseHeaders:m,value:new zn({message:n(y),url:u,requestBodyValues:f,statusCode:l.status,responseHeaders:m,responseBody:g,data:y,isRetryable:o?.(l,y)})}}catch{return{responseHeaders:m,value:new zn({message:l.statusText,url:u,requestBodyValues:f,statusCode:l.status,responseHeaders:m,responseBody:g,isRetryable:o?.(l)})}}},Fp=t=>async({response:n})=>{const o=eo(n);if(n.body==null)throw new n0({});return{responseHeaders:o,value:Mp({stream:n.body,schema:t})}},$p=t=>async({response:n,url:o,requestBodyValues:l})=>{const u=await n.text(),f=await ei({text:u,schema:t}),g=eo(n);if(!f.success)throw new zn({message:"Invalid JSON response",cause:f.error,statusCode:n.status,responseHeaders:g,responseBody:u,url:o,requestBodyValues:l});return{responseHeaders:g,value:f.value,rawValue:f.rawValue}},Up=(t,n)=>{let o=0;for(;o<t.length&&o<n.length&&t[o]===n[o];o++);return[(t.length-o).toString(),...n.slice(o)].join("/")},zp=Symbol("Let zodToJsonSchema decide on which parser to use"),xa={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},Zp=t=>typeof t=="string"?{...xa,name:t}:{...xa,...t};function an(){return{}}function Vp(t,n){var o,l,u;const f={type:"array"};return(o=t.type)!=null&&o._def&&((u=(l=t.type)==null?void 0:l._def)==null?void 0:u.typeName)!==de.ZodAny&&(f.items=et(t.type._def,{...n,currentPath:[...n.currentPath,"items"]})),t.minLength&&(f.minItems=t.minLength.value),t.maxLength&&(f.maxItems=t.maxLength.value),t.exactLength&&(f.minItems=t.exactLength.value,f.maxItems=t.exactLength.value),f}function jp(t){const n={type:"integer",format:"int64"};if(!t.checks)return n;for(const o of t.checks)switch(o.kind){case"min":o.inclusive?n.minimum=o.value:n.exclusiveMinimum=o.value;break;case"max":o.inclusive?n.maximum=o.value:n.exclusiveMaximum=o.value;break;case"multipleOf":n.multipleOf=o.value;break}return n}function Hp(){return{type:"boolean"}}function jc(t,n){return et(t.type._def,n)}var Wp=(t,n)=>et(t.innerType._def,n);function Hc(t,n,o){const l=o??n.dateStrategy;if(Array.isArray(l))return{anyOf:l.map((u,f)=>Hc(t,n,u))};switch(l){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Gp(t)}}var Gp=t=>{const n={type:"integer",format:"unix-time"};for(const o of t.checks)switch(o.kind){case"min":n.minimum=o.value;break;case"max":n.maximum=o.value;break}return n};function Xp(t,n){return{...et(t.innerType._def,n),default:t.defaultValue()}}function Yp(t,n){return n.effectStrategy==="input"?et(t.schema._def,n):an()}function qp(t){return{type:"string",enum:Array.from(t.values)}}var Kp=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function Jp(t,n){const o=[et(t.left._def,{...n,currentPath:[...n.currentPath,"allOf","0"]}),et(t.right._def,{...n,currentPath:[...n.currentPath,"allOf","1"]})].filter(u=>!!u),l=[];return o.forEach(u=>{if(Kp(u))l.push(...u.allOf);else{let f=u;if("additionalProperties"in u&&u.additionalProperties===!1){const{additionalProperties:g,...m}=u;f=m}l.push(f)}}),l.length?{allOf:l}:void 0}function Qp(t){const n=typeof t.value;return n!=="bigint"&&n!=="number"&&n!=="boolean"&&n!=="string"?{type:Array.isArray(t.value)?"array":"object"}:{type:n==="bigint"?"integer":n,const:t.value}}var To=void 0,Cn={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(To===void 0&&(To=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),To),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Wc(t,n){const o={type:"string"};if(t.checks)for(const l of t.checks)switch(l.kind){case"min":o.minLength=typeof o.minLength=="number"?Math.max(o.minLength,l.value):l.value;break;case"max":o.maxLength=typeof o.maxLength=="number"?Math.min(o.maxLength,l.value):l.value;break;case"email":switch(n.emailStrategy){case"format:email":bn(o,"email",l.message,n);break;case"format:idn-email":bn(o,"idn-email",l.message,n);break;case"pattern:zod":Ht(o,Cn.email,l.message,n);break}break;case"url":bn(o,"uri",l.message,n);break;case"uuid":bn(o,"uuid",l.message,n);break;case"regex":Ht(o,l.regex,l.message,n);break;case"cuid":Ht(o,Cn.cuid,l.message,n);break;case"cuid2":Ht(o,Cn.cuid2,l.message,n);break;case"startsWith":Ht(o,RegExp(`^${Oo(l.value,n)}`),l.message,n);break;case"endsWith":Ht(o,RegExp(`${Oo(l.value,n)}$`),l.message,n);break;case"datetime":bn(o,"date-time",l.message,n);break;case"date":bn(o,"date",l.message,n);break;case"time":bn(o,"time",l.message,n);break;case"duration":bn(o,"duration",l.message,n);break;case"length":o.minLength=typeof o.minLength=="number"?Math.max(o.minLength,l.value):l.value,o.maxLength=typeof o.maxLength=="number"?Math.min(o.maxLength,l.value):l.value;break;case"includes":{Ht(o,RegExp(Oo(l.value,n)),l.message,n);break}case"ip":{l.version!=="v6"&&bn(o,"ipv4",l.message,n),l.version!=="v4"&&bn(o,"ipv6",l.message,n);break}case"base64url":Ht(o,Cn.base64url,l.message,n);break;case"jwt":Ht(o,Cn.jwt,l.message,n);break;case"cidr":{l.version!=="v6"&&Ht(o,Cn.ipv4Cidr,l.message,n),l.version!=="v4"&&Ht(o,Cn.ipv6Cidr,l.message,n);break}case"emoji":Ht(o,Cn.emoji(),l.message,n);break;case"ulid":{Ht(o,Cn.ulid,l.message,n);break}case"base64":{switch(n.base64Strategy){case"format:binary":{bn(o,"binary",l.message,n);break}case"contentEncoding:base64":{o.contentEncoding="base64";break}case"pattern:zod":{Ht(o,Cn.base64,l.message,n);break}}break}case"nanoid":Ht(o,Cn.nanoid,l.message,n)}return o}function Oo(t,n){return n.patternStrategy==="escape"?tg(t):t}var eg=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function tg(t){let n="";for(let o=0;o<t.length;o++)eg.has(t[o])||(n+="\\"),n+=t[o];return n}function bn(t,n,o,l){var u;t.format||(u=t.anyOf)!=null&&u.some(f=>f.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format}),delete t.format),t.anyOf.push({format:n,...o&&l.errorMessages&&{errorMessage:{format:o}}})):t.format=n}function Ht(t,n,o,l){var u;t.pattern||(u=t.allOf)!=null&&u.some(f=>f.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern}),delete t.pattern),t.allOf.push({pattern:wa(n,l),...o&&l.errorMessages&&{errorMessage:{pattern:o}}})):t.pattern=wa(n,l)}function wa(t,n){var o;if(!n.applyRegexFlags||!t.flags)return t.source;const l={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},u=l.i?t.source.toLowerCase():t.source;let f="",g=!1,m=!1,y=!1;for(let x=0;x<u.length;x++){if(g){f+=u[x],g=!1;continue}if(l.i){if(m){if(u[x].match(/[a-z]/)){y?(f+=u[x],f+=`${u[x-2]}-${u[x]}`.toUpperCase(),y=!1):u[x+1]==="-"&&((o=u[x+2])!=null&&o.match(/[a-z]/))?(f+=u[x],y=!0):f+=`${u[x]}${u[x].toUpperCase()}`;continue}}else if(u[x].match(/[a-z]/)){f+=`[${u[x]}${u[x].toUpperCase()}]`;continue}}if(l.m){if(u[x]==="^"){f+=`(^|(?<=[\r
35
- ]))`;continue}else if(u[x]==="$"){f+=`($|(?=[\r
36
- ]))`;continue}}if(l.s&&u[x]==="."){f+=m?`${u[x]}\r
37
- `:`[${u[x]}\r
38
- ]`;continue}f+=u[x],u[x]==="\\"?g=!0:m&&u[x]==="]"?m=!1:!m&&u[x]==="["&&(m=!0)}try{new RegExp(f)}catch{return console.warn(`Could not convert regex pattern at ${n.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return f}function Gc(t,n){var o,l,u,f,g,m;const y={type:"object",additionalProperties:(o=et(t.valueType._def,{...n,currentPath:[...n.currentPath,"additionalProperties"]}))!=null?o:n.allowedAdditionalProperties};if(((l=t.keyType)==null?void 0:l._def.typeName)===de.ZodString&&((u=t.keyType._def.checks)!=null&&u.length)){const{type:x,...A}=Wc(t.keyType._def,n);return{...y,propertyNames:A}}else{if(((f=t.keyType)==null?void 0:f._def.typeName)===de.ZodEnum)return{...y,propertyNames:{enum:t.keyType._def.values}};if(((g=t.keyType)==null?void 0:g._def.typeName)===de.ZodBranded&&t.keyType._def.type._def.typeName===de.ZodString&&((m=t.keyType._def.type._def.checks)!=null&&m.length)){const{type:x,...A}=jc(t.keyType._def,n);return{...y,propertyNames:A}}}return y}function ng(t,n){if(n.mapStrategy==="record")return Gc(t,n);const o=et(t.keyType._def,{...n,currentPath:[...n.currentPath,"items","items","0"]})||an(),l=et(t.valueType._def,{...n,currentPath:[...n.currentPath,"items","items","1"]})||an();return{type:"array",maxItems:125,items:{type:"array",items:[o,l],minItems:2,maxItems:2}}}function rg(t){const n=t.values,l=Object.keys(t.values).filter(f=>typeof n[n[f]]!="number").map(f=>n[f]),u=Array.from(new Set(l.map(f=>typeof f)));return{type:u.length===1?u[0]==="string"?"string":"number":["string","number"],enum:l}}function ig(){return{not:an()}}function og(){return{type:"null"}}var Ho={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function sg(t,n){const o=t.options instanceof Map?Array.from(t.options.values()):t.options;if(o.every(l=>l._def.typeName in Ho&&(!l._def.checks||!l._def.checks.length))){const l=o.reduce((u,f)=>{const g=Ho[f._def.typeName];return g&&!u.includes(g)?[...u,g]:u},[]);return{type:l.length>1?l:l[0]}}else if(o.every(l=>l._def.typeName==="ZodLiteral"&&!l.description)){const l=o.reduce((u,f)=>{const g=typeof f._def.value;switch(g){case"string":case"number":case"boolean":return[...u,g];case"bigint":return[...u,"integer"];case"object":if(f._def.value===null)return[...u,"null"];case"symbol":case"undefined":case"function":default:return u}},[]);if(l.length===o.length){const u=l.filter((f,g,m)=>m.indexOf(f)===g);return{type:u.length>1?u:u[0],enum:o.reduce((f,g)=>f.includes(g._def.value)?f:[...f,g._def.value],[])}}}else if(o.every(l=>l._def.typeName==="ZodEnum"))return{type:"string",enum:o.reduce((l,u)=>[...l,...u._def.values.filter(f=>!l.includes(f))],[])};return ag(t,n)}var ag=(t,n)=>{const o=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((l,u)=>et(l._def,{...n,currentPath:[...n.currentPath,"anyOf",`${u}`]})).filter(l=>!!l&&(!n.strictUnions||typeof l=="object"&&Object.keys(l).length>0));return o.length?{anyOf:o}:void 0};function lg(t,n){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return{type:[Ho[t.innerType._def.typeName],"null"]};const o=et(t.innerType._def,{...n,currentPath:[...n.currentPath,"anyOf","0"]});return o&&{anyOf:[o,{type:"null"}]}}function cg(t){const n={type:"number"};if(!t.checks)return n;for(const o of t.checks)switch(o.kind){case"int":n.type="integer";break;case"min":o.inclusive?n.minimum=o.value:n.exclusiveMinimum=o.value;break;case"max":o.inclusive?n.maximum=o.value:n.exclusiveMaximum=o.value;break;case"multipleOf":n.multipleOf=o.value;break}return n}function ug(t,n){const o={type:"object",properties:{}},l=[],u=t.shape();for(const g in u){let m=u[g];if(m===void 0||m._def===void 0)continue;const y=fg(m),x=et(m._def,{...n,currentPath:[...n.currentPath,"properties",g],propertyPath:[...n.currentPath,"properties",g]});x!==void 0&&(o.properties[g]=x,y||l.push(g))}l.length&&(o.required=l);const f=dg(t,n);return f!==void 0&&(o.additionalProperties=f),o}function dg(t,n){if(t.catchall._def.typeName!=="ZodNever")return et(t.catchall._def,{...n,currentPath:[...n.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return n.allowedAdditionalProperties;case"strict":return n.rejectedAdditionalProperties;case"strip":return n.removeAdditionalStrategy==="strict"?n.allowedAdditionalProperties:n.rejectedAdditionalProperties}}function fg(t){try{return t.isOptional()}catch{return!0}}var hg=(t,n)=>{var o;if(n.currentPath.toString()===((o=n.propertyPath)==null?void 0:o.toString()))return et(t.innerType._def,n);const l=et(t.innerType._def,{...n,currentPath:[...n.currentPath,"anyOf","1"]});return l?{anyOf:[{not:an()},l]}:an()},pg=(t,n)=>{if(n.pipeStrategy==="input")return et(t.in._def,n);if(n.pipeStrategy==="output")return et(t.out._def,n);const o=et(t.in._def,{...n,currentPath:[...n.currentPath,"allOf","0"]}),l=et(t.out._def,{...n,currentPath:[...n.currentPath,"allOf",o?"1":"0"]});return{allOf:[o,l].filter(u=>u!==void 0)}};function gg(t,n){return et(t.type._def,n)}function mg(t,n){const l={type:"array",uniqueItems:!0,items:et(t.valueType._def,{...n,currentPath:[...n.currentPath,"items"]})};return t.minSize&&(l.minItems=t.minSize.value),t.maxSize&&(l.maxItems=t.maxSize.value),l}function xg(t,n){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((o,l)=>et(o._def,{...n,currentPath:[...n.currentPath,"items",`${l}`]})).reduce((o,l)=>l===void 0?o:[...o,l],[]),additionalItems:et(t.rest._def,{...n,currentPath:[...n.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((o,l)=>et(o._def,{...n,currentPath:[...n.currentPath,"items",`${l}`]})).reduce((o,l)=>l===void 0?o:[...o,l],[])}}function wg(){return{not:an()}}function yg(){return an()}var _g=(t,n)=>et(t.innerType._def,n),vg=(t,n,o)=>{switch(n){case de.ZodString:return Wc(t,o);case de.ZodNumber:return cg(t);case de.ZodObject:return ug(t,o);case de.ZodBigInt:return jp(t);case de.ZodBoolean:return Hp();case de.ZodDate:return Hc(t,o);case de.ZodUndefined:return wg();case de.ZodNull:return og();case de.ZodArray:return Vp(t,o);case de.ZodUnion:case de.ZodDiscriminatedUnion:return sg(t,o);case de.ZodIntersection:return Jp(t,o);case de.ZodTuple:return xg(t,o);case de.ZodRecord:return Gc(t,o);case de.ZodLiteral:return Qp(t);case de.ZodEnum:return qp(t);case de.ZodNativeEnum:return rg(t);case de.ZodNullable:return lg(t,o);case de.ZodOptional:return hg(t,o);case de.ZodMap:return ng(t,o);case de.ZodSet:return mg(t,o);case de.ZodLazy:return()=>t.getter()._def;case de.ZodPromise:return gg(t,o);case de.ZodNaN:case de.ZodNever:return ig();case de.ZodEffects:return Yp(t,o);case de.ZodAny:return an();case de.ZodUnknown:return yg();case de.ZodDefault:return Xp(t,o);case de.ZodBranded:return jc(t,o);case de.ZodReadonly:return _g(t,o);case de.ZodCatch:return Wp(t,o);case de.ZodPipeline:return pg(t,o);case de.ZodFunction:case de.ZodVoid:case de.ZodSymbol:return;default:return(l=>{})()}};function et(t,n,o=!1){var l;const u=n.seen.get(t);if(n.override){const y=(l=n.override)==null?void 0:l.call(n,t,n,u,o);if(y!==zp)return y}if(u&&!o){const y=Cg(u,n);if(y!==void 0)return y}const f={def:t,path:n.currentPath,jsonSchema:void 0};n.seen.set(t,f);const g=vg(t,t.typeName,n),m=typeof g=="function"?et(g(),n):g;if(m&&bg(t,n,m),n.postProcess){const y=n.postProcess(m,t,n);return f.jsonSchema=m,y}return f.jsonSchema=m,m}var Cg=(t,n)=>{switch(n.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Up(n.currentPath,t.path)};case"none":case"seen":return t.path.length<n.currentPath.length&&t.path.every((o,l)=>n.currentPath[l]===o)?(console.warn(`Recursive reference detected at ${n.currentPath.join("/")}! Defaulting to any`),an()):n.$refStrategy==="seen"?an():void 0}},bg=(t,n,o)=>(t.description&&(o.description=t.description),o),Eg=t=>{const n=Zp(t),o=n.name!==void 0?[...n.basePath,n.definitionPath,n.name]:n.basePath;return{...n,currentPath:o,propertyPath:void 0,seen:new Map(Object.entries(n.definitions).map(([l,u])=>[u._def,{def:u._def,path:[...n.basePath,n.definitionPath,l],jsonSchema:void 0}]))}},Ag=(t,n)=>{var o;const l=Eg(n);let u=typeof n=="object"&&n.definitions?Object.entries(n.definitions).reduce((x,[A,b])=>{var P;return{...x,[A]:(P=et(b._def,{...l,currentPath:[...l.basePath,l.definitionPath,A]},!0))!=null?P:an()}},{}):void 0;const f=typeof n=="string"?n:n?.nameStrategy==="title"?void 0:n?.name,g=(o=et(t._def,f===void 0?l:{...l,currentPath:[...l.basePath,l.definitionPath,f]},!1))!=null?o:an(),m=typeof n=="object"&&n.name!==void 0&&n.nameStrategy==="title"?n.name:void 0;m!==void 0&&(g.title=m);const y=f===void 0?u?{...g,[l.definitionPath]:u}:g:{$ref:[...l.$refStrategy==="relative"?[]:l.basePath,l.definitionPath,f].join("/"),[l.definitionPath]:{...u,[f]:g}};return y.$schema="http://json-schema.org/draft-07/schema#",y},Ig=Ag;function Sg(t,n){var o;const l=(o=void 0)!=null?o:!1;return fs(()=>Ig(t,{$refStrategy:l?"root":"none"}),{validate:async u=>{const f=await t.safeParseAsync(u);return f.success?{success:!0,value:f.data}:{success:!1,error:f.error}}})}function Tg(t,n){var o;const l=(o=void 0)!=null?o:!1;return fs(()=>Lc(t,{target:"draft-7",io:"output",reused:l?"ref":"inline"}),{validate:async u=>{const f=await ls(t,u);return f.success?{success:!0,value:f.data}:{success:!1,error:f.error}}})}function Og(t){return"_zod"in t}function Ng(t,n){return Og(t)?Tg(t):Sg(t)}var Wo=Symbol.for("vercel.ai.schema");function fs(t,{validate:n}={}){return{[Wo]:!0,_type:void 0,[Hi]:!0,get jsonSchema(){return typeof t=="function"&&(t=t()),t},validate:n}}function kg(t){return typeof t=="object"&&t!==null&&Wo in t&&t[Wo]===!0&&"jsonSchema"in t&&"validate"in t}function Rg(t){return t==null?fs({properties:{},additionalProperties:!1}):kg(t)?t:typeof t=="function"?t():Ng(t)}var{btoa:Dg}=globalThis;function Mg(t){let n="";for(let o=0;o<t.length;o++)n+=String.fromCodePoint(t[o]);return Dg(n)}function Pg(t){return t instanceof Uint8Array?Mg(t):t}function Bg(t){return t?.replace(/\/$/,"")}var Si=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Xc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Lg=Object.defineProperty,Fg=(t,n)=>{for(var o in n)Lg(t,o,{get:n[o],enumerable:!0})},Yc="AI_NoObjectGeneratedError",qc=`vercel.ai.error.${Yc}`,$g=Symbol.for(qc),Kc,ya=class extends Et{constructor({message:t="No object generated.",cause:n,text:o,response:l,usage:u,finishReason:f}){super({name:Yc,message:t,cause:n}),this[Kc]=!0,this.text=o,this.response=l,this.usage=u,this.finishReason=f}static isInstance(t){return Et.hasMarker(t,qc)}};Kc=$g;var Jc=ut([I(),ji(Uint8Array),ji(ArrayBuffer),gp(t=>{var n,o;return(o=(n=globalThis.Buffer)==null?void 0:n.isBuffer(t))!=null?o:!1},{message:"Must be a Buffer"})]),ti=Zc(()=>ut([Zh(),I(),W(),Ft(),Dt(I(),ti),_e(ti)])),Fn=Dt(I(),Dt(I(),ti)),Qc=B({type:re("text"),text:I(),providerOptions:Fn.optional()}),Ug=B({type:re("image"),image:ut([Jc,ji(URL)]),mediaType:I().optional(),providerOptions:Fn.optional()}),eu=B({type:re("file"),data:ut([Jc,ji(URL)]),filename:I().optional(),mediaType:I(),providerOptions:Fn.optional()}),zg=B({type:re("reasoning"),text:I(),providerOptions:Fn.optional()}),Zg=B({type:re("tool-call"),toolCallId:I(),toolName:I(),input:Qr(),providerOptions:Fn.optional(),providerExecuted:Ft().optional()}),Vg=Lt("type",[B({type:re("text"),value:I()}),B({type:re("json"),value:ti}),B({type:re("error-text"),value:I()}),B({type:re("error-json"),value:ti}),B({type:re("content"),value:_e(ut([B({type:re("text"),text:I()}),B({type:re("media"),data:I(),mediaType:I()})]))})]),tu=B({type:re("tool-result"),toolCallId:I(),toolName:I(),output:Vg,providerOptions:Fn.optional()}),jg=B({role:re("system"),content:I(),providerOptions:Fn.optional()}),Hg=B({role:re("user"),content:ut([I(),_e(ut([Qc,Ug,eu]))]),providerOptions:Fn.optional()}),Wg=B({role:re("assistant"),content:ut([I(),_e(ut([Qc,eu,zg,Zg,tu]))]),providerOptions:Fn.optional()}),Gg=B({role:re("tool"),content:_e(tu),providerOptions:Fn.optional()});ut([jg,Hg,Wg,Gg]);li({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(t,n){n.enqueue(`data: ${JSON.stringify(t)}
34
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const E of this.seen.entries()){const C=E[1];if(r===E[0]){g(E);continue}if(l.external){const O=l.external.registry.get(E[0])?.id;if(r!==E[0]&&O){g(E);continue}}if(this.metadataRegistry.get(E[0])?.id){g(E);continue}if(C.cycle){g(E);continue}if(C.count>1&&l.reused==="ref"){g(E);continue}}const x=(E,C)=>{const P=this.seen.get(E),O=P.def??P.schema,D={...O};if(P.ref===null)return;const R=P.ref;if(P.ref=null,R){x(R,C);const M=this.seen.get(R).schema;M.$ref&&C.target==="draft-7"?(O.allOf=O.allOf??[],O.allOf.push(M)):(Object.assign(O,M),Object.assign(O,D))}P.isParent||this.override({zodSchema:E,jsonSchema:O,path:P.path??[]})};for(const E of[...this.seen.entries()].reverse())x(E[0],{target:this.target});const y={};if(this.target==="draft-2020-12"?y.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?y.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),l.external?.uri){const E=l.external.registry.get(r)?.id;if(!E)throw new Error("Schema is missing an `id` property");y.$id=l.external.uri(E)}Object.assign(y,u.def);const m=l.external?.defs??{};for(const E of this.seen.entries()){const C=E[1];C.def&&C.defId&&(m[C.defId]=C.def)}l.external||Object.keys(m).length>0&&(this.target==="draft-2020-12"?y.$defs=m:y.definitions=m);try{return JSON.parse(JSON.stringify(y))}catch{throw new Error("Error converting schema to JSON.")}}}function Nc(t,r){if(t instanceof Ic){const l=new Qs(r),u={};for(const x of t._idmap.entries()){const[y,m]=x;l.process(m)}const f={},g={registry:t,uri:r?.uri,defs:u};for(const x of t._idmap.entries()){const[y,m]=x;f[y]=l.emit(m,{...r,external:g})}if(Object.keys(u).length>0){const x=l.target==="draft-2020-12"?"$defs":"definitions";f.__shared={[x]:u}}return{schemas:f}}const o=new Qs(r);return o.process(t),o.emit(t,r)}function Nt(t,r){const o=r??{seen:new Set};if(o.seen.has(t))return!1;o.seen.add(t);const u=t._zod.def;switch(u.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return Nt(u.element,o);case"object":{for(const f in u.shape)if(Nt(u.shape[f],o))return!0;return!1}case"union":{for(const f of u.options)if(Nt(f,o))return!0;return!1}case"intersection":return Nt(u.left,o)||Nt(u.right,o);case"tuple":{for(const f of u.items)if(Nt(f,o))return!0;return!!(u.rest&&Nt(u.rest,o))}case"record":return Nt(u.keyType,o)||Nt(u.valueType,o);case"map":return Nt(u.keyType,o)||Nt(u.valueType,o);case"set":return Nt(u.valueType,o);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return Nt(u.innerType,o);case"lazy":return Nt(u.getter(),o);case"default":return Nt(u.innerType,o);case"prefault":return Nt(u.innerType,o);case"custom":return!1;case"transform":return!0;case"pipe":return Nt(u.in,o)||Nt(u.out,o);case"success":return!1;case"catch":return!1}throw new Error(`Unknown schema type: ${u.type}`)}const eh=Q("ZodISODateTime",(t,r)=>{v0.init(t,r),gt.init(t,r)});function th(t){return Nf(eh,t)}const nh=Q("ZodISODate",(t,r)=>{b0.init(t,r),gt.init(t,r)});function rh(t){return Of(nh,t)}const ih=Q("ZodISOTime",(t,r)=>{C0.init(t,r),gt.init(t,r)});function oh(t){return kf(ih,t)}const sh=Q("ZodISODuration",(t,r)=>{E0.init(t,r),gt.init(t,r)});function ah(t){return Rf(sh,t)}const lh=(t,r)=>{hc.init(t,r),t.name="ZodError",Object.defineProperties(t,{format:{value:o=>xd(t,o)},flatten:{value:o=>md(t,o)},addIssue:{value:o=>t.issues.push(o)},addIssues:{value:o=>t.issues.push(...o)},isEmpty:{get(){return t.issues.length===0}}})},Gi=Q("ZodError",lh,{Parent:Error}),ch=wd(Gi),uh=yd(Gi),dh=gc(Gi),ts=mc(Gi),ct=Q("ZodType",(t,r)=>(rt.init(t,r),t.def=r,Object.defineProperty(t,"_def",{value:r}),t.check=(...o)=>t.clone({...r,checks:[...r.checks??[],...o.map(l=>typeof l=="function"?{_zod:{check:l,def:{check:"custom"},onattach:[]}}:l)]}),t.clone=(o,l)=>ar(t,o,l),t.brand=()=>t,t.register=((o,l)=>(o.add(t,l),t)),t.parse=(o,l)=>ch(t,o,l,{callee:t.parse}),t.safeParse=(o,l)=>dh(t,o,l),t.parseAsync=async(o,l)=>uh(t,o,l,{callee:t.parseAsync}),t.safeParseAsync=async(o,l)=>ts(t,o,l),t.spa=t.safeParseAsync,t.refine=(o,l)=>t.check(ap(o,l)),t.superRefine=o=>t.check(lp(o)),t.overwrite=o=>t.check(ni(o)),t.optional=()=>na(t),t.nullable=()=>ra(t),t.nullish=()=>na(ra(t)),t.nonoptional=o=>Jh(t,o),t.array=()=>ve(t),t.or=o=>lt([t,o]),t.and=o=>Vh(t,o),t.transform=o=>ia(t,Wh(o)),t.default=o=>qh(t,o),t.prefault=o=>Kh(t,o),t.catch=o=>ep(t,o),t.pipe=o=>ia(t,o),t.readonly=()=>rp(t),t.describe=o=>{const l=t.clone();return zr.add(l,{description:o}),l},Object.defineProperty(t,"description",{get(){return zr.get(t)?.description},configurable:!0}),t.meta=(...o)=>{if(o.length===0)return zr.get(t);const l=t.clone();return zr.add(l,o[0]),l},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),Oc=Q("_ZodString",(t,r)=>{es.init(t,r),ct.init(t,r);const o=t._zod.bag;t.format=o.format??null,t.minLength=o.minimum??null,t.maxLength=o.maximum??null,t.regex=(...l)=>t.check(zf(...l)),t.includes=(...l)=>t.check(jf(...l)),t.startsWith=(...l)=>t.check(Hf(...l)),t.endsWith=(...l)=>t.check(Wf(...l)),t.min=(...l)=>t.check(Li(...l)),t.max=(...l)=>t.check(Sc(...l)),t.length=(...l)=>t.check(Tc(...l)),t.nonempty=(...l)=>t.check(Li(1,...l)),t.lowercase=l=>t.check(Vf(l)),t.uppercase=l=>t.check(Zf(l)),t.trim=()=>t.check(Xf()),t.normalize=(...l)=>t.check(Gf(...l)),t.toLowerCase=()=>t.check(qf()),t.toUpperCase=()=>t.check(Yf())}),fh=Q("ZodString",(t,r)=>{es.init(t,r),Oc.init(t,r),t.email=o=>t.check(lf(hh,o)),t.url=o=>t.check(hf(ph,o)),t.jwt=o=>t.check(Tf(Nh,o)),t.emoji=o=>t.check(pf(gh,o)),t.guid=o=>t.check(qs(ea,o)),t.uuid=o=>t.check(cf(_i,o)),t.uuidv4=o=>t.check(uf(_i,o)),t.uuidv6=o=>t.check(df(_i,o)),t.uuidv7=o=>t.check(ff(_i,o)),t.nanoid=o=>t.check(gf(mh,o)),t.guid=o=>t.check(qs(ea,o)),t.cuid=o=>t.check(mf(xh,o)),t.cuid2=o=>t.check(xf(wh,o)),t.ulid=o=>t.check(wf(yh,o)),t.base64=o=>t.check(Af(Ih,o)),t.base64url=o=>t.check(If(Sh,o)),t.xid=o=>t.check(yf(_h,o)),t.ksuid=o=>t.check(_f(vh,o)),t.ipv4=o=>t.check(vf(bh,o)),t.ipv6=o=>t.check(bf(Ch,o)),t.cidrv4=o=>t.check(Cf(Eh,o)),t.cidrv6=o=>t.check(Ef(Ah,o)),t.e164=o=>t.check(Sf(Th,o)),t.datetime=o=>t.check(th(o)),t.date=o=>t.check(rh(o)),t.time=o=>t.check(oh(o)),t.duration=o=>t.check(ah(o))});function I(t){return af(fh,t)}const gt=Q("ZodStringFormat",(t,r)=>{ht.init(t,r),Oc.init(t,r)}),hh=Q("ZodEmail",(t,r)=>{f0.init(t,r),gt.init(t,r)}),ea=Q("ZodGUID",(t,r)=>{u0.init(t,r),gt.init(t,r)}),_i=Q("ZodUUID",(t,r)=>{d0.init(t,r),gt.init(t,r)}),ph=Q("ZodURL",(t,r)=>{h0.init(t,r),gt.init(t,r)}),gh=Q("ZodEmoji",(t,r)=>{p0.init(t,r),gt.init(t,r)}),mh=Q("ZodNanoID",(t,r)=>{g0.init(t,r),gt.init(t,r)}),xh=Q("ZodCUID",(t,r)=>{m0.init(t,r),gt.init(t,r)}),wh=Q("ZodCUID2",(t,r)=>{x0.init(t,r),gt.init(t,r)}),yh=Q("ZodULID",(t,r)=>{w0.init(t,r),gt.init(t,r)}),_h=Q("ZodXID",(t,r)=>{y0.init(t,r),gt.init(t,r)}),vh=Q("ZodKSUID",(t,r)=>{_0.init(t,r),gt.init(t,r)}),bh=Q("ZodIPv4",(t,r)=>{A0.init(t,r),gt.init(t,r)}),Ch=Q("ZodIPv6",(t,r)=>{I0.init(t,r),gt.init(t,r)}),Eh=Q("ZodCIDRv4",(t,r)=>{S0.init(t,r),gt.init(t,r)}),Ah=Q("ZodCIDRv6",(t,r)=>{T0.init(t,r),gt.init(t,r)}),Ih=Q("ZodBase64",(t,r)=>{N0.init(t,r),gt.init(t,r)}),Sh=Q("ZodBase64URL",(t,r)=>{k0.init(t,r),gt.init(t,r)}),Th=Q("ZodE164",(t,r)=>{R0.init(t,r),gt.init(t,r)}),Nh=Q("ZodJWT",(t,r)=>{M0.init(t,r),gt.init(t,r)}),ns=Q("ZodNumber",(t,r)=>{Ec.init(t,r),ct.init(t,r),t.gt=(l,u)=>t.check(Ks(l,u)),t.gte=(l,u)=>t.check(vo(l,u)),t.min=(l,u)=>t.check(vo(l,u)),t.lt=(l,u)=>t.check(Ys(l,u)),t.lte=(l,u)=>t.check(_o(l,u)),t.max=(l,u)=>t.check(_o(l,u)),t.int=l=>t.check(ta(l)),t.safe=l=>t.check(ta(l)),t.positive=l=>t.check(Ks(0,l)),t.nonnegative=l=>t.check(vo(0,l)),t.negative=l=>t.check(Ys(0,l)),t.nonpositive=l=>t.check(_o(0,l)),t.multipleOf=(l,u)=>t.check(Js(l,u)),t.step=(l,u)=>t.check(Js(l,u)),t.finite=()=>t;const o=t._zod.bag;t.minValue=Math.max(o.minimum??Number.NEGATIVE_INFINITY,o.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(o.maximum??Number.POSITIVE_INFINITY,o.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(o.format??"").includes("int")||Number.isSafeInteger(o.multipleOf??.5),t.isFinite=!0,t.format=o.format??null});function X(t){return Df(ns,t)}const Oh=Q("ZodNumberFormat",(t,r)=>{P0.init(t,r),ns.init(t,r)});function ta(t){return Pf(Oh,t)}const kh=Q("ZodBoolean",(t,r)=>{B0.init(t,r),ct.init(t,r)});function $t(t){return Bf(kh,t)}const Rh=Q("ZodNull",(t,r)=>{L0.init(t,r),ct.init(t,r)});function Dh(t){return Lf(Rh,t)}const Mh=Q("ZodAny",(t,r)=>{F0.init(t,r),ct.init(t,r)});function ri(){return Ff(Mh)}const Ph=Q("ZodUnknown",(t,r)=>{$0.init(t,r),ct.init(t,r)});function qr(){return $f(Ph)}const Bh=Q("ZodNever",(t,r)=>{U0.init(t,r),ct.init(t,r)});function Lh(t){return Uf(Bh,t)}const Fh=Q("ZodArray",(t,r)=>{z0.init(t,r),ct.init(t,r),t.element=r.element,t.min=(o,l)=>t.check(Li(o,l)),t.nonempty=o=>t.check(Li(1,o)),t.max=(o,l)=>t.check(Sc(o,l)),t.length=(o,l)=>t.check(Tc(o,l)),t.unwrap=()=>t.element});function ve(t,r){return Kf(Fh,t,r)}const $h=Q("ZodObject",(t,r)=>{V0.init(t,r),ct.init(t,r),Xe(t,"shape",()=>r.shape),t.keyof=()=>ft(Object.keys(t._zod.def.shape)),t.catchall=o=>t.clone({...t._zod.def,catchall:o}),t.passthrough=()=>t.clone({...t._zod.def,catchall:qr()}),t.loose=()=>t.clone({...t._zod.def,catchall:qr()}),t.strict=()=>t.clone({...t._zod.def,catchall:Lh()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=o=>fd(t,o),t.merge=o=>hd(t,o),t.pick=o=>ud(t,o),t.omit=o=>dd(t,o),t.partial=(...o)=>pd(Rc,t,o[0]),t.required=(...o)=>gd(Dc,t,o[0])});function B(t,r){const o={type:"object",get shape(){return Jo(this,"shape",{...t}),this.shape},...Te(r)};return new $h(o)}const kc=Q("ZodUnion",(t,r)=>{Ac.init(t,r),ct.init(t,r),t.options=r.options});function lt(t,r){return new kc({type:"union",options:t,...Te(r)})}const Uh=Q("ZodDiscriminatedUnion",(t,r)=>{kc.init(t,r),Z0.init(t,r)});function Ft(t,r,o){return new Uh({type:"union",options:r,discriminator:t,...Te(o)})}const zh=Q("ZodIntersection",(t,r)=>{j0.init(t,r),ct.init(t,r)});function Vh(t,r){return new zh({type:"intersection",left:t,right:r})}const Zh=Q("ZodRecord",(t,r)=>{H0.init(t,r),ct.init(t,r),t.keyType=r.keyType,t.valueType=r.valueType});function Dt(t,r,o){return new Zh({type:"record",keyType:t,valueType:r,...Te(o)})}const Bo=Q("ZodEnum",(t,r)=>{W0.init(t,r),ct.init(t,r),t.enum=r.entries,t.options=Object.values(r.entries);const o=new Set(Object.keys(r.entries));t.extract=(l,u)=>{const f={};for(const g of l)if(o.has(g))f[g]=r.entries[g];else throw new Error(`Key ${g} not found in enum`);return new Bo({...r,checks:[],...Te(u),entries:f})},t.exclude=(l,u)=>{const f={...r.entries};for(const g of l)if(o.has(g))delete f[g];else throw new Error(`Key ${g} not found in enum`);return new Bo({...r,checks:[],...Te(u),entries:f})}});function ft(t,r){const o=Array.isArray(t)?Object.fromEntries(t.map(l=>[l,l])):t;return new Bo({type:"enum",entries:o,...Te(r)})}const jh=Q("ZodLiteral",(t,r)=>{G0.init(t,r),ct.init(t,r),t.values=new Set(r.values),Object.defineProperty(t,"value",{get(){if(r.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return r.values[0]}})});function ie(t,r){return new jh({type:"literal",values:Array.isArray(t)?t:[t],...Te(r)})}const Hh=Q("ZodTransform",(t,r)=>{X0.init(t,r),ct.init(t,r),t._zod.parse=(o,l)=>{o.addIssue=f=>{if(typeof f=="string")o.issues.push(Xr(f,o.value,r));else{const g=f;g.fatal&&(g.continue=!1),g.code??(g.code="custom"),g.input??(g.input=o.value),g.inst??(g.inst=t),g.continue??(g.continue=!0),o.issues.push(Xr(g))}};const u=r.transform(o.value,o);return u instanceof Promise?u.then(f=>(o.value=f,o)):(o.value=u,o)}});function Wh(t){return new Hh({type:"transform",transform:t})}const Rc=Q("ZodOptional",(t,r)=>{q0.init(t,r),ct.init(t,r),t.unwrap=()=>t._zod.def.innerType});function na(t){return new Rc({type:"optional",innerType:t})}const Gh=Q("ZodNullable",(t,r)=>{Y0.init(t,r),ct.init(t,r),t.unwrap=()=>t._zod.def.innerType});function ra(t){return new Gh({type:"nullable",innerType:t})}const Xh=Q("ZodDefault",(t,r)=>{K0.init(t,r),ct.init(t,r),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function qh(t,r){return new Xh({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():r}})}const Yh=Q("ZodPrefault",(t,r)=>{J0.init(t,r),ct.init(t,r),t.unwrap=()=>t._zod.def.innerType});function Kh(t,r){return new Yh({type:"prefault",innerType:t,get defaultValue(){return typeof r=="function"?r():r}})}const Dc=Q("ZodNonOptional",(t,r)=>{Q0.init(t,r),ct.init(t,r),t.unwrap=()=>t._zod.def.innerType});function Jh(t,r){return new Dc({type:"nonoptional",innerType:t,...Te(r)})}const Qh=Q("ZodCatch",(t,r)=>{ef.init(t,r),ct.init(t,r),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function ep(t,r){return new Qh({type:"catch",innerType:t,catchValue:typeof r=="function"?r:()=>r})}const tp=Q("ZodPipe",(t,r)=>{tf.init(t,r),ct.init(t,r),t.in=r.in,t.out=r.out});function ia(t,r){return new tp({type:"pipe",in:t,out:r})}const np=Q("ZodReadonly",(t,r)=>{nf.init(t,r),ct.init(t,r)});function rp(t){return new np({type:"readonly",innerType:t})}const ip=Q("ZodLazy",(t,r)=>{rf.init(t,r),ct.init(t,r),t.unwrap=()=>t._zod.def.getter()});function Mc(t){return new ip({type:"lazy",getter:t})}const rs=Q("ZodCustom",(t,r)=>{of.init(t,r),ct.init(t,r)});function op(t){const r=new tn({check:"custom"});return r._zod.check=t,r}function sp(t,r){return Jf(rs,t??(()=>!0),r)}function ap(t,r={}){return Qf(rs,t,r)}function lp(t){const r=op(o=>(o.addIssue=l=>{if(typeof l=="string")o.issues.push(Xr(l,o.value,r._zod.def));else{const u=l;u.fatal&&(u.continue=!1),u.code??(u.code="custom"),u.input??(u.input=o.value),u.inst??(u.inst=r),u.continue??(u.continue=!r._zod.def.abort),o.issues.push(Xr(u))}},t(o.value,o)));return r}function Fi(t,r={error:`Input not instance of ${t.name}`}){const o=new rs({type:"custom",check:"custom",fn:l=>l instanceof t,abort:!0,...Te(r)});return o._zod.bag.Class=t,o}function cp(t){return Mf(ns,t)}var ue;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(ue||(ue={}));function oa(...t){return t.reduce((r,o)=>({...r,...o??{}}),{})}function Xi(t){return Object.fromEntries([...t.headers])}var ii=({prefix:t,size:r=16,alphabet:o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:l="-"}={})=>{const u=()=>{const f=o.length,g=new Array(r);for(let x=0;x<r;x++)g[x]=o[Math.random()*f|0];return g.join("")};if(t==null)return u;if(o.includes(l))throw new Vl({argument:"separator",message:`The separator "${l}" must not be part of the alphabet "${o}".`});return()=>`${t}${l}${u()}`},vi=ii();function Lo(t){return(t instanceof Error||t instanceof DOMException)&&(t.name==="AbortError"||t.name==="ResponseAborted"||t.name==="TimeoutError")}var up=["fetch failed","failed to fetch"];function dp({error:t,url:r,requestBodyValues:o}){if(Lo(t))return t;if(t instanceof TypeError&&up.includes(t.message.toLowerCase())){const l=t.cause;if(l!=null)return new Bn({message:`Cannot connect to API: ${l.message}`,cause:l,url:r,requestBodyValues:o,isRetryable:!0})}return t}function fp(t=globalThis){var r,o,l;return t.window?"runtime/browser":(r=t.navigator)!=null&&r.userAgent?`runtime/${t.navigator.userAgent.toLowerCase()}`:(l=(o=t.process)==null?void 0:o.versions)!=null&&l.node?`runtime/node.js/${t.process.version.substring(0)}`:t.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function hp(t){if(t==null)return{};const r={};if(t instanceof Headers)t.forEach((o,l)=>{r[l.toLowerCase()]=o});else{Array.isArray(t)||(t=Object.entries(t));for(const[o,l]of t)l!=null&&(r[o.toLowerCase()]=l)}return r}function Pc(t,...r){const o=new Headers(hp(t)),l=o.get("user-agent")||"";return o.set("user-agent",[l,...r].filter(Boolean).join(" ")),Object.fromEntries(o.entries())}var pp="3.0.18";function gp({apiKey:t,environmentVariableName:r,apiKeyParameterName:o="apiKey",description:l}){if(typeof t=="string")return t;if(t!=null)throw new xi({message:`${l} API key must be a string.`});if(typeof process>"u")throw new xi({message:`${l} API key is missing. Pass it using the '${o}' parameter. Environment variables is not supported in this environment.`});if(t=process.env[r],t==null)throw new xi({message:`${l} API key is missing. Pass it using the '${o}' parameter or the ${r} environment variable.`});if(typeof t!="string")throw new xi({message:`${l} API key must be a string. The value of the ${r} environment variable is not a string.`});return t}var mp=/"__proto__"\s*:/,xp=/"constructor"\s*:/;function sa(t){const r=JSON.parse(t);return r===null||typeof r!="object"||mp.test(t)===!1&&xp.test(t)===!1?r:wp(r)}function wp(t){let r=[t];for(;r.length;){const o=r;r=[];for(const l of o){if(Object.prototype.hasOwnProperty.call(l,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(l,"constructor")&&Object.prototype.hasOwnProperty.call(l.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const u in l){const f=l[u];f&&typeof f=="object"&&r.push(f)}}}return t}function is(t){const{stackTraceLimit:r}=Error;try{Error.stackTraceLimit=0}catch{return sa(t)}try{return sa(t)}finally{Error.stackTraceLimit=r}}var $i=Symbol.for("vercel.ai.validator");function yp(t){return{[$i]:!0,validate:t}}function _p(t){return typeof t=="object"&&t!==null&&$i in t&&t[$i]===!0&&"validate"in t}function vp(t){return _p(t)?t:typeof t=="function"?t():bp(t)}function bp(t){return yp(async r=>{const o=await t["~standard"].validate(r);return o.issues==null?{success:!0,value:o.value}:{success:!1,error:new Wr({value:r,cause:o.issues})}})}async function Cp({value:t,schema:r}){const o=await Cr({value:t,schema:r});if(!o.success)throw Wr.wrap({value:t,cause:o.error});return o.value}async function Cr({value:t,schema:r}){const o=vp(r);try{if(o.validate==null)return{success:!0,value:t,rawValue:t};const l=await o.validate(t);return l.success?{success:!0,value:l.value,rawValue:t}:{success:!1,error:Wr.wrap({value:t,cause:l.error}),rawValue:t}}catch(l){return{success:!1,error:Wr.wrap({value:t,cause:l}),rawValue:t}}}async function Ep({text:t,schema:r}){try{const o=is(t);return r==null?o:Cp({value:o,schema:r})}catch(o){throw Mi.isInstance(o)||Wr.isInstance(o)?o:new Mi({text:t,cause:o})}}async function Yr({text:t,schema:r}){try{const o=is(t);return r==null?{success:!0,value:o,rawValue:o}:await Cr({value:o,schema:r})}catch(o){return{success:!1,error:Mi.isInstance(o)?o:new Mi({text:t,cause:o}),rawValue:void 0}}}function aa(t){try{return is(t),!0}catch{return!1}}function Ap({stream:t,schema:r}){return t.pipeThrough(new TextDecoderStream).pipeThrough(new lc).pipeThrough(new TransformStream({async transform({data:o},l){o!=="[DONE]"&&l.enqueue(await Yr({text:o,schema:r}))}}))}async function la({provider:t,providerOptions:r,schema:o}){if(r?.[t]==null)return;const l=await Cr({value:r[t],schema:o});if(!l.success)throw new Vl({argument:"providerOptions",message:`invalid ${t} provider options`,cause:l.error});return l.value}var Ip=()=>globalThis.fetch,ca=async({url:t,headers:r,body:o,failedResponseHandler:l,successfulResponseHandler:u,abortSignal:f,fetch:g})=>Sp({url:t,headers:{"Content-Type":"application/json",...r},body:{content:JSON.stringify(o),values:o},failedResponseHandler:l,successfulResponseHandler:u,abortSignal:f,fetch:g}),Sp=async({url:t,headers:r={},body:o,successfulResponseHandler:l,failedResponseHandler:u,abortSignal:f,fetch:g=Ip()})=>{try{const x=await g(t,{method:"POST",headers:Pc(r,`ai-sdk/provider-utils/${pp}`,fp()),body:o.content,signal:f}),y=Xi(x);if(!x.ok){let m;try{m=await u({response:x,url:t,requestBodyValues:o.values})}catch(E){throw Lo(E)||Bn.isInstance(E)?E:new Bn({message:"Failed to process error response",cause:E,statusCode:x.status,url:t,responseHeaders:y,requestBodyValues:o.values})}throw m.value}try{return await l({response:x,url:t,requestBodyValues:o.values})}catch(m){throw m instanceof Error&&(Lo(m)||Bn.isInstance(m))?m:new Bn({message:"Failed to process successful response",cause:m,statusCode:x.status,url:t,responseHeaders:y,requestBodyValues:o.values})}}catch(x){throw dp({error:x,url:t,requestBodyValues:o.values})}};var Tp=({errorSchema:t,errorToMessage:r,isRetryable:o})=>async({response:l,url:u,requestBodyValues:f})=>{const g=await l.text(),x=Xi(l);if(g.trim()==="")return{responseHeaders:x,value:new Bn({message:l.statusText,url:u,requestBodyValues:f,statusCode:l.status,responseHeaders:x,responseBody:g,isRetryable:o?.(l)})};try{const y=await Ep({text:g,schema:t});return{responseHeaders:x,value:new Bn({message:r(y),url:u,requestBodyValues:f,statusCode:l.status,responseHeaders:x,responseBody:g,data:y,isRetryable:o?.(l,y)})}}catch{return{responseHeaders:x,value:new Bn({message:l.statusText,url:u,requestBodyValues:f,statusCode:l.status,responseHeaders:x,responseBody:g,isRetryable:o?.(l)})}}},Np=t=>async({response:r})=>{const o=Xi(r);if(r.body==null)throw new G1({});return{responseHeaders:o,value:Ap({stream:r.body,schema:t})}},Op=t=>async({response:r,url:o,requestBodyValues:l})=>{const u=await r.text(),f=await Yr({text:u,schema:t}),g=Xi(r);if(!f.success)throw new Bn({message:"Invalid JSON response",cause:f.error,statusCode:r.status,responseHeaders:g,responseBody:u,url:o,requestBodyValues:l});return{responseHeaders:g,value:f.value,rawValue:f.rawValue}},kp=(t,r)=>{let o=0;for(;o<t.length&&o<r.length&&t[o]===r[o];o++);return[(t.length-o).toString(),...r.slice(o)].join("/")},Rp=Symbol("Let zodToJsonSchema decide on which parser to use"),ua={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},Dp=t=>typeof t=="string"?{...ua,name:t}:{...ua,...t};function on(){return{}}function Mp(t,r){var o,l,u;const f={type:"array"};return(o=t.type)!=null&&o._def&&((u=(l=t.type)==null?void 0:l._def)==null?void 0:u.typeName)!==ue.ZodAny&&(f.items=qe(t.type._def,{...r,currentPath:[...r.currentPath,"items"]})),t.minLength&&(f.minItems=t.minLength.value),t.maxLength&&(f.maxItems=t.maxLength.value),t.exactLength&&(f.minItems=t.exactLength.value,f.maxItems=t.exactLength.value),f}function Pp(t){const r={type:"integer",format:"int64"};if(!t.checks)return r;for(const o of t.checks)switch(o.kind){case"min":o.inclusive?r.minimum=o.value:r.exclusiveMinimum=o.value;break;case"max":o.inclusive?r.maximum=o.value:r.exclusiveMaximum=o.value;break;case"multipleOf":r.multipleOf=o.value;break}return r}function Bp(){return{type:"boolean"}}function Bc(t,r){return qe(t.type._def,r)}var Lp=(t,r)=>qe(t.innerType._def,r);function Lc(t,r,o){const l=o??r.dateStrategy;if(Array.isArray(l))return{anyOf:l.map((u,f)=>Lc(t,r,u))};switch(l){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Fp(t)}}var Fp=t=>{const r={type:"integer",format:"unix-time"};for(const o of t.checks)switch(o.kind){case"min":r.minimum=o.value;break;case"max":r.maximum=o.value;break}return r};function $p(t,r){return{...qe(t.innerType._def,r),default:t.defaultValue()}}function Up(t,r){return r.effectStrategy==="input"?qe(t.schema._def,r):on()}function zp(t){return{type:"string",enum:Array.from(t.values)}}var Vp=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function Zp(t,r){const o=[qe(t.left._def,{...r,currentPath:[...r.currentPath,"allOf","0"]}),qe(t.right._def,{...r,currentPath:[...r.currentPath,"allOf","1"]})].filter(u=>!!u),l=[];return o.forEach(u=>{if(Vp(u))l.push(...u.allOf);else{let f=u;if("additionalProperties"in u&&u.additionalProperties===!1){const{additionalProperties:g,...x}=u;f=x}l.push(f)}}),l.length?{allOf:l}:void 0}function jp(t){const r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:{type:r==="bigint"?"integer":r,const:t.value}}var bo=void 0,wn={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(bo===void 0&&(bo=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),bo),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Fc(t,r){const o={type:"string"};if(t.checks)for(const l of t.checks)switch(l.kind){case"min":o.minLength=typeof o.minLength=="number"?Math.max(o.minLength,l.value):l.value;break;case"max":o.maxLength=typeof o.maxLength=="number"?Math.min(o.maxLength,l.value):l.value;break;case"email":switch(r.emailStrategy){case"format:email":yn(o,"email",l.message,r);break;case"format:idn-email":yn(o,"idn-email",l.message,r);break;case"pattern:zod":Ht(o,wn.email,l.message,r);break}break;case"url":yn(o,"uri",l.message,r);break;case"uuid":yn(o,"uuid",l.message,r);break;case"regex":Ht(o,l.regex,l.message,r);break;case"cuid":Ht(o,wn.cuid,l.message,r);break;case"cuid2":Ht(o,wn.cuid2,l.message,r);break;case"startsWith":Ht(o,RegExp(`^${Co(l.value,r)}`),l.message,r);break;case"endsWith":Ht(o,RegExp(`${Co(l.value,r)}$`),l.message,r);break;case"datetime":yn(o,"date-time",l.message,r);break;case"date":yn(o,"date",l.message,r);break;case"time":yn(o,"time",l.message,r);break;case"duration":yn(o,"duration",l.message,r);break;case"length":o.minLength=typeof o.minLength=="number"?Math.max(o.minLength,l.value):l.value,o.maxLength=typeof o.maxLength=="number"?Math.min(o.maxLength,l.value):l.value;break;case"includes":{Ht(o,RegExp(Co(l.value,r)),l.message,r);break}case"ip":{l.version!=="v6"&&yn(o,"ipv4",l.message,r),l.version!=="v4"&&yn(o,"ipv6",l.message,r);break}case"base64url":Ht(o,wn.base64url,l.message,r);break;case"jwt":Ht(o,wn.jwt,l.message,r);break;case"cidr":{l.version!=="v6"&&Ht(o,wn.ipv4Cidr,l.message,r),l.version!=="v4"&&Ht(o,wn.ipv6Cidr,l.message,r);break}case"emoji":Ht(o,wn.emoji(),l.message,r);break;case"ulid":{Ht(o,wn.ulid,l.message,r);break}case"base64":{switch(r.base64Strategy){case"format:binary":{yn(o,"binary",l.message,r);break}case"contentEncoding:base64":{o.contentEncoding="base64";break}case"pattern:zod":{Ht(o,wn.base64,l.message,r);break}}break}case"nanoid":Ht(o,wn.nanoid,l.message,r)}return o}function Co(t,r){return r.patternStrategy==="escape"?Wp(t):t}var Hp=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Wp(t){let r="";for(let o=0;o<t.length;o++)Hp.has(t[o])||(r+="\\"),r+=t[o];return r}function yn(t,r,o,l){var u;t.format||(u=t.anyOf)!=null&&u.some(f=>f.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format}),delete t.format),t.anyOf.push({format:r,...o&&l.errorMessages&&{errorMessage:{format:o}}})):t.format=r}function Ht(t,r,o,l){var u;t.pattern||(u=t.allOf)!=null&&u.some(f=>f.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern}),delete t.pattern),t.allOf.push({pattern:da(r,l),...o&&l.errorMessages&&{errorMessage:{pattern:o}}})):t.pattern=da(r,l)}function da(t,r){var o;if(!r.applyRegexFlags||!t.flags)return t.source;const l={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},u=l.i?t.source.toLowerCase():t.source;let f="",g=!1,x=!1,y=!1;for(let m=0;m<u.length;m++){if(g){f+=u[m],g=!1;continue}if(l.i){if(x){if(u[m].match(/[a-z]/)){y?(f+=u[m],f+=`${u[m-2]}-${u[m]}`.toUpperCase(),y=!1):u[m+1]==="-"&&((o=u[m+2])!=null&&o.match(/[a-z]/))?(f+=u[m],y=!0):f+=`${u[m]}${u[m].toUpperCase()}`;continue}}else if(u[m].match(/[a-z]/)){f+=`[${u[m]}${u[m].toUpperCase()}]`;continue}}if(l.m){if(u[m]==="^"){f+=`(^|(?<=[\r
35
+ ]))`;continue}else if(u[m]==="$"){f+=`($|(?=[\r
36
+ ]))`;continue}}if(l.s&&u[m]==="."){f+=x?`${u[m]}\r
37
+ `:`[${u[m]}\r
38
+ ]`;continue}f+=u[m],u[m]==="\\"?g=!0:x&&u[m]==="]"?x=!1:!x&&u[m]==="["&&(x=!0)}try{new RegExp(f)}catch{return console.warn(`Could not convert regex pattern at ${r.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return f}function $c(t,r){var o,l,u,f,g,x;const y={type:"object",additionalProperties:(o=qe(t.valueType._def,{...r,currentPath:[...r.currentPath,"additionalProperties"]}))!=null?o:r.allowedAdditionalProperties};if(((l=t.keyType)==null?void 0:l._def.typeName)===ue.ZodString&&((u=t.keyType._def.checks)!=null&&u.length)){const{type:m,...E}=Fc(t.keyType._def,r);return{...y,propertyNames:E}}else{if(((f=t.keyType)==null?void 0:f._def.typeName)===ue.ZodEnum)return{...y,propertyNames:{enum:t.keyType._def.values}};if(((g=t.keyType)==null?void 0:g._def.typeName)===ue.ZodBranded&&t.keyType._def.type._def.typeName===ue.ZodString&&((x=t.keyType._def.type._def.checks)!=null&&x.length)){const{type:m,...E}=Bc(t.keyType._def,r);return{...y,propertyNames:E}}}return y}function Gp(t,r){if(r.mapStrategy==="record")return $c(t,r);const o=qe(t.keyType._def,{...r,currentPath:[...r.currentPath,"items","items","0"]})||on(),l=qe(t.valueType._def,{...r,currentPath:[...r.currentPath,"items","items","1"]})||on();return{type:"array",maxItems:125,items:{type:"array",items:[o,l],minItems:2,maxItems:2}}}function Xp(t){const r=t.values,l=Object.keys(t.values).filter(f=>typeof r[r[f]]!="number").map(f=>r[f]),u=Array.from(new Set(l.map(f=>typeof f)));return{type:u.length===1?u[0]==="string"?"string":"number":["string","number"],enum:l}}function qp(){return{not:on()}}function Yp(){return{type:"null"}}var Fo={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Kp(t,r){const o=t.options instanceof Map?Array.from(t.options.values()):t.options;if(o.every(l=>l._def.typeName in Fo&&(!l._def.checks||!l._def.checks.length))){const l=o.reduce((u,f)=>{const g=Fo[f._def.typeName];return g&&!u.includes(g)?[...u,g]:u},[]);return{type:l.length>1?l:l[0]}}else if(o.every(l=>l._def.typeName==="ZodLiteral"&&!l.description)){const l=o.reduce((u,f)=>{const g=typeof f._def.value;switch(g){case"string":case"number":case"boolean":return[...u,g];case"bigint":return[...u,"integer"];case"object":if(f._def.value===null)return[...u,"null"];case"symbol":case"undefined":case"function":default:return u}},[]);if(l.length===o.length){const u=l.filter((f,g,x)=>x.indexOf(f)===g);return{type:u.length>1?u:u[0],enum:o.reduce((f,g)=>f.includes(g._def.value)?f:[...f,g._def.value],[])}}}else if(o.every(l=>l._def.typeName==="ZodEnum"))return{type:"string",enum:o.reduce((l,u)=>[...l,...u._def.values.filter(f=>!l.includes(f))],[])};return Jp(t,r)}var Jp=(t,r)=>{const o=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((l,u)=>qe(l._def,{...r,currentPath:[...r.currentPath,"anyOf",`${u}`]})).filter(l=>!!l&&(!r.strictUnions||typeof l=="object"&&Object.keys(l).length>0));return o.length?{anyOf:o}:void 0};function Qp(t,r){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return{type:[Fo[t.innerType._def.typeName],"null"]};const o=qe(t.innerType._def,{...r,currentPath:[...r.currentPath,"anyOf","0"]});return o&&{anyOf:[o,{type:"null"}]}}function eg(t){const r={type:"number"};if(!t.checks)return r;for(const o of t.checks)switch(o.kind){case"int":r.type="integer";break;case"min":o.inclusive?r.minimum=o.value:r.exclusiveMinimum=o.value;break;case"max":o.inclusive?r.maximum=o.value:r.exclusiveMaximum=o.value;break;case"multipleOf":r.multipleOf=o.value;break}return r}function tg(t,r){const o={type:"object",properties:{}},l=[],u=t.shape();for(const g in u){let x=u[g];if(x===void 0||x._def===void 0)continue;const y=rg(x),m=qe(x._def,{...r,currentPath:[...r.currentPath,"properties",g],propertyPath:[...r.currentPath,"properties",g]});m!==void 0&&(o.properties[g]=m,y||l.push(g))}l.length&&(o.required=l);const f=ng(t,r);return f!==void 0&&(o.additionalProperties=f),o}function ng(t,r){if(t.catchall._def.typeName!=="ZodNever")return qe(t.catchall._def,{...r,currentPath:[...r.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return r.allowedAdditionalProperties;case"strict":return r.rejectedAdditionalProperties;case"strip":return r.removeAdditionalStrategy==="strict"?r.allowedAdditionalProperties:r.rejectedAdditionalProperties}}function rg(t){try{return t.isOptional()}catch{return!0}}var ig=(t,r)=>{var o;if(r.currentPath.toString()===((o=r.propertyPath)==null?void 0:o.toString()))return qe(t.innerType._def,r);const l=qe(t.innerType._def,{...r,currentPath:[...r.currentPath,"anyOf","1"]});return l?{anyOf:[{not:on()},l]}:on()},og=(t,r)=>{if(r.pipeStrategy==="input")return qe(t.in._def,r);if(r.pipeStrategy==="output")return qe(t.out._def,r);const o=qe(t.in._def,{...r,currentPath:[...r.currentPath,"allOf","0"]}),l=qe(t.out._def,{...r,currentPath:[...r.currentPath,"allOf",o?"1":"0"]});return{allOf:[o,l].filter(u=>u!==void 0)}};function sg(t,r){return qe(t.type._def,r)}function ag(t,r){const l={type:"array",uniqueItems:!0,items:qe(t.valueType._def,{...r,currentPath:[...r.currentPath,"items"]})};return t.minSize&&(l.minItems=t.minSize.value),t.maxSize&&(l.maxItems=t.maxSize.value),l}function lg(t,r){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((o,l)=>qe(o._def,{...r,currentPath:[...r.currentPath,"items",`${l}`]})).reduce((o,l)=>l===void 0?o:[...o,l],[]),additionalItems:qe(t.rest._def,{...r,currentPath:[...r.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((o,l)=>qe(o._def,{...r,currentPath:[...r.currentPath,"items",`${l}`]})).reduce((o,l)=>l===void 0?o:[...o,l],[])}}function cg(){return{not:on()}}function ug(){return on()}var dg=(t,r)=>qe(t.innerType._def,r),fg=(t,r,o)=>{switch(r){case ue.ZodString:return Fc(t,o);case ue.ZodNumber:return eg(t);case ue.ZodObject:return tg(t,o);case ue.ZodBigInt:return Pp(t);case ue.ZodBoolean:return Bp();case ue.ZodDate:return Lc(t,o);case ue.ZodUndefined:return cg();case ue.ZodNull:return Yp();case ue.ZodArray:return Mp(t,o);case ue.ZodUnion:case ue.ZodDiscriminatedUnion:return Kp(t,o);case ue.ZodIntersection:return Zp(t,o);case ue.ZodTuple:return lg(t,o);case ue.ZodRecord:return $c(t,o);case ue.ZodLiteral:return jp(t);case ue.ZodEnum:return zp(t);case ue.ZodNativeEnum:return Xp(t);case ue.ZodNullable:return Qp(t,o);case ue.ZodOptional:return ig(t,o);case ue.ZodMap:return Gp(t,o);case ue.ZodSet:return ag(t,o);case ue.ZodLazy:return()=>t.getter()._def;case ue.ZodPromise:return sg(t,o);case ue.ZodNaN:case ue.ZodNever:return qp();case ue.ZodEffects:return Up(t,o);case ue.ZodAny:return on();case ue.ZodUnknown:return ug();case ue.ZodDefault:return $p(t,o);case ue.ZodBranded:return Bc(t,o);case ue.ZodReadonly:return dg(t,o);case ue.ZodCatch:return Lp(t,o);case ue.ZodPipeline:return og(t,o);case ue.ZodFunction:case ue.ZodVoid:case ue.ZodSymbol:return;default:return(l=>{})()}};function qe(t,r,o=!1){var l;const u=r.seen.get(t);if(r.override){const y=(l=r.override)==null?void 0:l.call(r,t,r,u,o);if(y!==Rp)return y}if(u&&!o){const y=hg(u,r);if(y!==void 0)return y}const f={def:t,path:r.currentPath,jsonSchema:void 0};r.seen.set(t,f);const g=fg(t,t.typeName,r),x=typeof g=="function"?qe(g(),r):g;if(x&&pg(t,r,x),r.postProcess){const y=r.postProcess(x,t,r);return f.jsonSchema=x,y}return f.jsonSchema=x,x}var hg=(t,r)=>{switch(r.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:kp(r.currentPath,t.path)};case"none":case"seen":return t.path.length<r.currentPath.length&&t.path.every((o,l)=>r.currentPath[l]===o)?(console.warn(`Recursive reference detected at ${r.currentPath.join("/")}! Defaulting to any`),on()):r.$refStrategy==="seen"?on():void 0}},pg=(t,r,o)=>(t.description&&(o.description=t.description),o),gg=t=>{const r=Dp(t),o=r.name!==void 0?[...r.basePath,r.definitionPath,r.name]:r.basePath;return{...r,currentPath:o,propertyPath:void 0,seen:new Map(Object.entries(r.definitions).map(([l,u])=>[u._def,{def:u._def,path:[...r.basePath,r.definitionPath,l],jsonSchema:void 0}]))}},mg=(t,r)=>{var o;const l=gg(r);let u=typeof r=="object"&&r.definitions?Object.entries(r.definitions).reduce((m,[E,C])=>{var P;return{...m,[E]:(P=qe(C._def,{...l,currentPath:[...l.basePath,l.definitionPath,E]},!0))!=null?P:on()}},{}):void 0;const f=typeof r=="string"?r:r?.nameStrategy==="title"?void 0:r?.name,g=(o=qe(t._def,f===void 0?l:{...l,currentPath:[...l.basePath,l.definitionPath,f]},!1))!=null?o:on(),x=typeof r=="object"&&r.name!==void 0&&r.nameStrategy==="title"?r.name:void 0;x!==void 0&&(g.title=x);const y=f===void 0?u?{...g,[l.definitionPath]:u}:g:{$ref:[...l.$refStrategy==="relative"?[]:l.basePath,l.definitionPath,f].join("/"),[l.definitionPath]:{...u,[f]:g}};return y.$schema="http://json-schema.org/draft-07/schema#",y},xg=mg;function wg(t,r){var o;const l=(o=void 0)!=null?o:!1;return os(()=>xg(t,{$refStrategy:l?"root":"none"}),{validate:async u=>{const f=await t.safeParseAsync(u);return f.success?{success:!0,value:f.data}:{success:!1,error:f.error}}})}function yg(t,r){var o;const l=(o=void 0)!=null?o:!1;return os(()=>Nc(t,{target:"draft-7",io:"output",reused:l?"ref":"inline"}),{validate:async u=>{const f=await ts(t,u);return f.success?{success:!0,value:f.data}:{success:!1,error:f.error}}})}function _g(t){return"_zod"in t}function vg(t,r){return _g(t)?yg(t):wg(t)}var $o=Symbol.for("vercel.ai.schema");function os(t,{validate:r}={}){return{[$o]:!0,_type:void 0,[$i]:!0,get jsonSchema(){return typeof t=="function"&&(t=t()),t},validate:r}}function bg(t){return typeof t=="object"&&t!==null&&$o in t&&t[$o]===!0&&"jsonSchema"in t&&"validate"in t}function Cg(t){return t==null?os({properties:{},additionalProperties:!1}):bg(t)?t:typeof t=="function"?t():vg(t)}var{btoa:Eg}=globalThis;function Ag(t){let r="";for(let o=0;o<t.length;o++)r+=String.fromCodePoint(t[o]);return Eg(r)}function Ig(t){return t instanceof Uint8Array?Ag(t):t}function Sg(t){return t?.replace(/\/$/,"")}var bi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Uc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Tg=Object.defineProperty,Ng=(t,r)=>{for(var o in r)Tg(t,o,{get:r[o],enumerable:!0})},zc="AI_NoObjectGeneratedError",Vc=`vercel.ai.error.${zc}`,Og=Symbol.for(Vc),Zc,fa=class extends Ct{constructor({message:t="No object generated.",cause:r,text:o,response:l,usage:u,finishReason:f}){super({name:zc,message:t,cause:r}),this[Zc]=!0,this.text=o,this.response=l,this.usage=u,this.finishReason=f}static isInstance(t){return Ct.hasMarker(t,Vc)}};Zc=Og;var jc=lt([I(),Fi(Uint8Array),Fi(ArrayBuffer),sp(t=>{var r,o;return(o=(r=globalThis.Buffer)==null?void 0:r.isBuffer(t))!=null?o:!1},{message:"Must be a Buffer"})]),Kr=Mc(()=>lt([Dh(),I(),X(),$t(),Dt(I(),Kr),ve(Kr)])),Mn=Dt(I(),Dt(I(),Kr)),Hc=B({type:ie("text"),text:I(),providerOptions:Mn.optional()}),kg=B({type:ie("image"),image:lt([jc,Fi(URL)]),mediaType:I().optional(),providerOptions:Mn.optional()}),Wc=B({type:ie("file"),data:lt([jc,Fi(URL)]),filename:I().optional(),mediaType:I(),providerOptions:Mn.optional()}),Rg=B({type:ie("reasoning"),text:I(),providerOptions:Mn.optional()}),Dg=B({type:ie("tool-call"),toolCallId:I(),toolName:I(),input:qr(),providerOptions:Mn.optional(),providerExecuted:$t().optional()}),Mg=Ft("type",[B({type:ie("text"),value:I()}),B({type:ie("json"),value:Kr}),B({type:ie("error-text"),value:I()}),B({type:ie("error-json"),value:Kr}),B({type:ie("content"),value:ve(lt([B({type:ie("text"),text:I()}),B({type:ie("media"),data:I(),mediaType:I()})]))})]),Gc=B({type:ie("tool-result"),toolCallId:I(),toolName:I(),output:Mg,providerOptions:Mn.optional()}),Pg=B({role:ie("system"),content:I(),providerOptions:Mn.optional()}),Bg=B({role:ie("user"),content:lt([I(),ve(lt([Hc,kg,Wc]))]),providerOptions:Mn.optional()}),Lg=B({role:ie("assistant"),content:lt([I(),ve(lt([Hc,Wc,Rg,Dg,Gc]))]),providerOptions:Mn.optional()}),Fg=B({role:ie("tool"),content:ve(Gc),providerOptions:Mn.optional()});lt([Pg,Bg,Lg,Fg]);ii({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(t,r){r.enqueue(`data: ${JSON.stringify(t)}
39
39
 
40
40
  `)},flush(t){t.enqueue(`data: [DONE]
41
41
 
42
- `)}})}});function Xg(t){const n=["ROOT"];let o=-1,l=null;function u(y,x,A){switch(y){case'"':{o=x,n.pop(),n.push(A),n.push("INSIDE_STRING");break}case"f":case"t":case"n":{o=x,l=x,n.pop(),n.push(A),n.push("INSIDE_LITERAL");break}case"-":{n.pop(),n.push(A),n.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{o=x,n.pop(),n.push(A),n.push("INSIDE_NUMBER");break}case"{":{o=x,n.pop(),n.push(A),n.push("INSIDE_OBJECT_START");break}case"[":{o=x,n.pop(),n.push(A),n.push("INSIDE_ARRAY_START");break}}}function f(y,x){switch(y){case",":{n.pop(),n.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{o=x,n.pop();break}}}function g(y,x){switch(y){case",":{n.pop(),n.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{o=x,n.pop();break}}}for(let y=0;y<t.length;y++){const x=t[y];switch(n[n.length-1]){case"ROOT":u(x,y,"FINISH");break;case"INSIDE_OBJECT_START":{switch(x){case'"':{n.pop(),n.push("INSIDE_OBJECT_KEY");break}case"}":{o=y,n.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(x){case'"':{n.pop(),n.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(x){case'"':{n.pop(),n.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(x){case":":{n.pop(),n.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{u(x,y,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{f(x,y);break}case"INSIDE_STRING":{switch(x){case'"':{n.pop(),o=y;break}case"\\":{n.push("INSIDE_STRING_ESCAPE");break}default:o=y}break}case"INSIDE_ARRAY_START":{switch(x){case"]":{o=y,n.pop();break}default:{o=y,u(x,y,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(x){case",":{n.pop(),n.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{o=y,n.pop();break}default:{o=y;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{u(x,y,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{n.pop(),o=y;break}case"INSIDE_NUMBER":{switch(x){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{o=y;break}case"e":case"E":case"-":case".":break;case",":{n.pop(),n[n.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&g(x,y),n[n.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&f(x,y);break}case"}":{n.pop(),n[n.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&f(x,y);break}case"]":{n.pop(),n[n.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&g(x,y);break}default:{n.pop();break}}break}case"INSIDE_LITERAL":{const b=t.substring(l,y+1);!"false".startsWith(b)&&!"true".startsWith(b)&&!"null".startsWith(b)?(n.pop(),n[n.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?f(x,y):n[n.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&g(x,y)):o=y;break}}}let m=t.slice(0,o+1);for(let y=n.length-1;y>=0;y--)switch(n[y]){case"INSIDE_STRING":{m+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{m+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{m+="]";break}case"INSIDE_LITERAL":{const A=t.substring(l,t.length);"true".startsWith(A)?m+="true".slice(A.length):"false".startsWith(A)?m+="false".slice(A.length):"null".startsWith(A)&&(m+="null".slice(A.length))}}return m}async function Yg(t){if(t===void 0)return{value:void 0,state:"undefined-input"};let n=await ei({text:t});return n.success?{value:n.value,state:"successful-parse"}:(n=await ei({text:Xg(t)}),n.success?{value:n.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}li({prefix:"aitxt",size:24});li({prefix:"aiobj",size:24});li({prefix:"aiobj",size:24});var qg={};Fg(qg,{object:()=>Jg,text:()=>Kg});var Kg=()=>({type:"text",responseFormat:{type:"text"},async parsePartial({text:t}){return{partial:t}},async parseOutput({text:t}){return t}}),Jg=({schema:t})=>{const n=Rg(t);return{type:"object",responseFormat:{type:"json",schema:n.jsonSchema},async parsePartial({text:o}){const l=await Yg(o);switch(l.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:l.value};default:{const u=l.state;throw new Error(`Unsupported parse state: ${u}`)}}},async parseOutput({text:o},l){const u=await ei({text:o});if(!u.success)throw new ya({message:"No object generated: could not parse the response.",cause:u.error,text:o,response:l.response,usage:l.usage,finishReason:l.finishReason});const f=await Tr({value:u.value,schema:n});if(!f.success)throw new ya({message:"No object generated: response did not match schema.",cause:f.error,text:o,response:l.response,usage:l.usage,finishReason:l.finishReason});return f.value}}},Bi={exports:{}},Qg=Bi.exports,_a;function e2(){return _a||(_a=1,(function(t,n){(function(o,l){t.exports=l()})(Qg,(function(){var o=1e3,l=6e4,u=36e5,f="millisecond",g="second",m="minute",y="hour",x="day",A="week",b="month",P="quarter",N="year",R="date",D="Invalid Date",M=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,z=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,U={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(le){var F=["th","st","nd","rd"],J=le%100;return"["+le+(F[(J-20)%10]||F[J]||F[0])+"]"}},k=function(le,F,J){var X=String(le);return!X||X.length>=F?le:""+Array(F+1-X.length).join(J)+le},K={s:k,z:function(le){var F=-le.utcOffset(),J=Math.abs(F),X=Math.floor(J/60),te=J%60;return(F<=0?"+":"-")+k(X,2,"0")+":"+k(te,2,"0")},m:function le(F,J){if(F.date()<J.date())return-le(J,F);var X=12*(J.year()-F.year())+(J.month()-F.month()),te=F.clone().add(X,b),pe=J-te<0,ge=F.clone().add(X+(pe?-1:1),b);return+(-(X+(J-te)/(pe?te-ge:ge-te))||0)},a:function(le){return le<0?Math.ceil(le)||0:Math.floor(le)},p:function(le){return{M:b,y:N,w:A,d:x,D:R,h:y,m,s:g,ms:f,Q:P}[le]||String(le||"").toLowerCase().replace(/s$/,"")},u:function(le){return le===void 0}},ve="en",Q={};Q[ve]=U;var j="$isDayjsObject",ie=function(le){return le instanceof he||!(!le||!le[j])},Y=function le(F,J,X){var te;if(!F)return ve;if(typeof F=="string"){var pe=F.toLowerCase();Q[pe]&&(te=pe),J&&(Q[pe]=J,te=pe);var ge=F.split("-");if(!te&&ge.length>1)return le(ge[0])}else{var ye=F.name;Q[ye]=F,te=ye}return!X&&te&&(ve=te),te||!X&&ve},Ie=function(le,F){if(ie(le))return le.clone();var J=typeof F=="object"?F:{};return J.date=le,J.args=arguments,new he(J)},Ce=K;Ce.l=Y,Ce.i=ie,Ce.w=function(le,F){return Ie(le,{locale:F.$L,utc:F.$u,x:F.$x,$offset:F.$offset})};var he=(function(){function le(J){this.$L=Y(J.locale,null,!0),this.parse(J),this.$x=this.$x||J.x||{},this[j]=!0}var F=le.prototype;return F.parse=function(J){this.$d=(function(X){var te=X.date,pe=X.utc;if(te===null)return new Date(NaN);if(Ce.u(te))return new Date;if(te instanceof Date)return new Date(te);if(typeof te=="string"&&!/Z$/i.test(te)){var ge=te.match(M);if(ge){var ye=ge[2]-1||0,we=(ge[7]||"0").substring(0,3);return pe?new Date(Date.UTC(ge[1],ye,ge[3]||1,ge[4]||0,ge[5]||0,ge[6]||0,we)):new Date(ge[1],ye,ge[3]||1,ge[4]||0,ge[5]||0,ge[6]||0,we)}}return new Date(te)})(J),this.init()},F.init=function(){var J=this.$d;this.$y=J.getFullYear(),this.$M=J.getMonth(),this.$D=J.getDate(),this.$W=J.getDay(),this.$H=J.getHours(),this.$m=J.getMinutes(),this.$s=J.getSeconds(),this.$ms=J.getMilliseconds()},F.$utils=function(){return Ce},F.isValid=function(){return this.$d.toString()!==D},F.isSame=function(J,X){var te=Ie(J);return this.startOf(X)<=te&&te<=this.endOf(X)},F.isAfter=function(J,X){return Ie(J)<this.startOf(X)},F.isBefore=function(J,X){return this.endOf(X)<Ie(J)},F.$g=function(J,X,te){return Ce.u(J)?this[X]:this.set(te,J)},F.unix=function(){return Math.floor(this.valueOf()/1e3)},F.valueOf=function(){return this.$d.getTime()},F.startOf=function(J,X){var te=this,pe=!!Ce.u(X)||X,ge=Ce.p(J),ye=function(Le,$e){var Xe=Ce.w(te.$u?Date.UTC(te.$y,$e,Le):new Date(te.$y,$e,Le),te);return pe?Xe:Xe.endOf(x)},we=function(Le,$e){return Ce.w(te.toDate()[Le].apply(te.toDate("s"),(pe?[0,0,0,0]:[23,59,59,999]).slice($e)),te)},Fe=this.$W,Pe=this.$M,ne=this.$D,S="set"+(this.$u?"UTC":"");switch(ge){case N:return pe?ye(1,0):ye(31,11);case b:return pe?ye(1,Pe):ye(0,Pe+1);case A:var fe=this.$locale().weekStart||0,se=(Fe<fe?Fe+7:Fe)-fe;return ye(pe?ne-se:ne+(6-se),Pe);case x:case R:return we(S+"Hours",0);case y:return we(S+"Minutes",1);case m:return we(S+"Seconds",2);case g:return we(S+"Milliseconds",3);default:return this.clone()}},F.endOf=function(J){return this.startOf(J,!1)},F.$set=function(J,X){var te,pe=Ce.p(J),ge="set"+(this.$u?"UTC":""),ye=(te={},te[x]=ge+"Date",te[R]=ge+"Date",te[b]=ge+"Month",te[N]=ge+"FullYear",te[y]=ge+"Hours",te[m]=ge+"Minutes",te[g]=ge+"Seconds",te[f]=ge+"Milliseconds",te)[pe],we=pe===x?this.$D+(X-this.$W):X;if(pe===b||pe===N){var Fe=this.clone().set(R,1);Fe.$d[ye](we),Fe.init(),this.$d=Fe.set(R,Math.min(this.$D,Fe.daysInMonth())).$d}else ye&&this.$d[ye](we);return this.init(),this},F.set=function(J,X){return this.clone().$set(J,X)},F.get=function(J){return this[Ce.p(J)]()},F.add=function(J,X){var te,pe=this;J=Number(J);var ge=Ce.p(X),ye=function(Pe){var ne=Ie(pe);return Ce.w(ne.date(ne.date()+Math.round(Pe*J)),pe)};if(ge===b)return this.set(b,this.$M+J);if(ge===N)return this.set(N,this.$y+J);if(ge===x)return ye(1);if(ge===A)return ye(7);var we=(te={},te[m]=l,te[y]=u,te[g]=o,te)[ge]||1,Fe=this.$d.getTime()+J*we;return Ce.w(Fe,this)},F.subtract=function(J,X){return this.add(-1*J,X)},F.format=function(J){var X=this,te=this.$locale();if(!this.isValid())return te.invalidDate||D;var pe=J||"YYYY-MM-DDTHH:mm:ssZ",ge=Ce.z(this),ye=this.$H,we=this.$m,Fe=this.$M,Pe=te.weekdays,ne=te.months,S=te.meridiem,fe=function($e,Xe,qt,je){return $e&&($e[Xe]||$e(X,pe))||qt[Xe].slice(0,je)},se=function($e){return Ce.s(ye%12||12,$e,"0")},Le=S||function($e,Xe,qt){var je=$e<12?"AM":"PM";return qt?je.toLowerCase():je};return pe.replace(z,(function($e,Xe){return Xe||(function(qt){switch(qt){case"YY":return String(X.$y).slice(-2);case"YYYY":return Ce.s(X.$y,4,"0");case"M":return Fe+1;case"MM":return Ce.s(Fe+1,2,"0");case"MMM":return fe(te.monthsShort,Fe,ne,3);case"MMMM":return fe(ne,Fe);case"D":return X.$D;case"DD":return Ce.s(X.$D,2,"0");case"d":return String(X.$W);case"dd":return fe(te.weekdaysMin,X.$W,Pe,2);case"ddd":return fe(te.weekdaysShort,X.$W,Pe,3);case"dddd":return Pe[X.$W];case"H":return String(ye);case"HH":return Ce.s(ye,2,"0");case"h":return se(1);case"hh":return se(2);case"a":return Le(ye,we,!0);case"A":return Le(ye,we,!1);case"m":return String(we);case"mm":return Ce.s(we,2,"0");case"s":return String(X.$s);case"ss":return Ce.s(X.$s,2,"0");case"SSS":return Ce.s(X.$ms,3,"0");case"Z":return ge}return null})($e)||ge.replace(":","")}))},F.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},F.diff=function(J,X,te){var pe,ge=this,ye=Ce.p(X),we=Ie(J),Fe=(we.utcOffset()-this.utcOffset())*l,Pe=this-we,ne=function(){return Ce.m(ge,we)};switch(ye){case N:pe=ne()/12;break;case b:pe=ne();break;case P:pe=ne()/3;break;case A:pe=(Pe-Fe)/6048e5;break;case x:pe=(Pe-Fe)/864e5;break;case y:pe=Pe/u;break;case m:pe=Pe/l;break;case g:pe=Pe/o;break;default:pe=Pe}return te?pe:Ce.a(pe)},F.daysInMonth=function(){return this.endOf(b).$D},F.$locale=function(){return Q[this.$L]},F.locale=function(J,X){if(!J)return this.$L;var te=this.clone(),pe=Y(J,X,!0);return pe&&(te.$L=pe),te},F.clone=function(){return Ce.w(this.$d,this)},F.toDate=function(){return new Date(this.valueOf())},F.toJSON=function(){return this.isValid()?this.toISOString():null},F.toISOString=function(){return this.$d.toISOString()},F.toString=function(){return this.$d.toUTCString()},le})(),xe=he.prototype;return Ie.prototype=xe,[["$ms",f],["$s",g],["$m",m],["$H",y],["$W",x],["$M",b],["$y",N],["$D",R]].forEach((function(le){xe[le[1]]=function(F){return this.$g(F,le[0],le[1])}})),Ie.extend=function(le,F){return le.$i||(le(F,he,Ie),le.$i=!0),Ie},Ie.locale=Y,Ie.isDayjs=ie,Ie.unix=function(le){return Ie(1e3*le)},Ie.en=Q[ve],Ie.Ls=Q,Ie.p={},Ie}))})(Bi)),Bi.exports}var t2=e2();const n2=Xc(t2),r2={description:"获取今天的日期",inputSchema:Ki.z.object({}),execute:()=>({date:`当前日期: ${n2().format("YYYY-M-D")}`})};function zr(t){var n,o;return(o=(n=t?.providerOptions)==null?void 0:n.openaiCompatible)!=null?o:{}}function i2(t){const n=[];for(const{role:o,content:l,...u}of t){const f=zr({...u});switch(o){case"system":{n.push({role:"system",content:l,...f});break}case"user":{if(l.length===1&&l[0].type==="text"){n.push({role:"user",content:l[0].text,...zr(l[0])});break}n.push({role:"user",content:l.map(g=>{const m=zr(g);switch(g.type){case"text":return{type:"text",text:g.text,...m};case"file":if(g.mediaType.startsWith("image/")){const y=g.mediaType==="image/*"?"image/jpeg":g.mediaType;return{type:"image_url",image_url:{url:g.data instanceof URL?g.data.toString():`data:${y};base64,${Pg(g.data)}`},...m}}else throw new gc({functionality:`file part media type ${g.mediaType}`})}}),...f});break}case"assistant":{let g="";const m=[];for(const y of l){const x=zr(y);switch(y.type){case"text":{g+=y.text;break}case"tool-call":{m.push({id:y.toolCallId,type:"function",function:{name:y.toolName,arguments:JSON.stringify(y.input)},...x});break}}}n.push({role:"assistant",content:g,tool_calls:m.length>0?m:void 0,...f});break}case"tool":{for(const g of l){const m=g.output;let y;switch(m.type){case"text":case"error-text":y=m.value;break;case"content":case"json":case"error-json":y=JSON.stringify(m.value);break}const x=zr(g);n.push({role:"tool",tool_call_id:g.toolCallId,content:y,...x})}break}default:{const g=o;throw new Error(`Unsupported role: ${g}`)}}}return n}function va({id:t,model:n,created:o}){return{id:t??void 0,modelId:n??void 0,timestamp:o!=null?new Date(o*1e3):void 0}}function Ca(t){switch(t){case"stop":return"stop";case"length":return"length";case"content_filter":return"content-filter";case"function_call":case"tool_calls":return"tool-calls";default:return"unknown"}}var No=B({user:I().optional(),reasoningEffort:I().optional(),textVerbosity:I().optional()}),o2=B({error:B({message:I(),type:I().nullish(),param:ai().nullish(),code:ut([I(),W()]).nullish()})}),s2={errorSchema:o2,errorToMessage:t=>t.error.message};function a2({tools:t,toolChoice:n}){t=t?.length?t:void 0;const o=[];if(t==null)return{tools:void 0,toolChoice:void 0,toolWarnings:o};const l=[];for(const f of t)f.type==="provider-defined"?o.push({type:"unsupported-tool",tool:f}):l.push({type:"function",function:{name:f.name,description:f.description,parameters:f.inputSchema}});if(n==null)return{tools:l,toolChoice:void 0,toolWarnings:o};const u=n.type;switch(u){case"auto":case"none":case"required":return{tools:l,toolChoice:u,toolWarnings:o};case"tool":return{tools:l,toolChoice:{type:"function",function:{name:n.toolName}},toolWarnings:o};default:{const f=u;throw new gc({functionality:`tool choice type: ${f}`})}}}var l2=class{constructor(t,n){this.specificationVersion="v2";var o,l;this.modelId=t,this.config=n;const u=(o=n.errorStructure)!=null?o:s2;this.chunkSchema=u2(u.errorSchema),this.failedResponseHandler=Lp(u),this.supportsStructuredOutputs=(l=n.supportsStructuredOutputs)!=null?l:!1}get provider(){return this.config.provider}get providerOptionsName(){return this.config.provider.split(".")[0].trim()}get supportedUrls(){var t,n,o;return(o=(n=(t=this.config).supportedUrls)==null?void 0:n.call(t))!=null?o:{}}async getArgs({prompt:t,maxOutputTokens:n,temperature:o,topP:l,topK:u,frequencyPenalty:f,presencePenalty:g,providerOptions:m,stopSequences:y,responseFormat:x,seed:A,toolChoice:b,tools:P}){var N,R,D,M;const z=[],U=Object.assign((N=await ga({provider:"openai-compatible",providerOptions:m,schema:No}))!=null?N:{},(R=await ga({provider:this.providerOptionsName,providerOptions:m,schema:No}))!=null?R:{});u!=null&&z.push({type:"unsupported-setting",setting:"topK"}),x?.type==="json"&&x.schema!=null&&!this.supportsStructuredOutputs&&z.push({type:"unsupported-setting",setting:"responseFormat",details:"JSON response format schema is only supported with structuredOutputs"});const{tools:k,toolChoice:K,toolWarnings:ve}=a2({tools:P,toolChoice:b});return{args:{model:this.modelId,user:U.user,max_tokens:n,temperature:o,top_p:l,frequency_penalty:f,presence_penalty:g,response_format:x?.type==="json"?this.supportsStructuredOutputs===!0&&x.schema!=null?{type:"json_schema",json_schema:{schema:x.schema,name:(D=x.name)!=null?D:"response",description:x.description}}:{type:"json_object"}:void 0,stop:y,seed:A,...Object.fromEntries(Object.entries((M=m?.[this.providerOptionsName])!=null?M:{}).filter(([Q])=>!Object.keys(No.shape).includes(Q))),reasoning_effort:U.reasoningEffort,verbosity:U.textVerbosity,messages:i2(t),tools:k,tool_choice:K},warnings:[...z,...ve]}}async doGenerate(t){var n,o,l,u,f,g,m,y,x,A,b,P,N,R,D,M,z;const{args:U,warnings:k}=await this.getArgs({...t}),K=JSON.stringify(U),{responseHeaders:ve,value:Q,rawValue:j}=await ma({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:fa(this.config.headers(),t.headers),body:U,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:$p(c2),abortSignal:t.abortSignal,fetch:this.config.fetch}),ie=Q.choices[0],Y=[],Ie=ie.message.content;Ie!=null&&Ie.length>0&&Y.push({type:"text",text:Ie});const Ce=(n=ie.message.reasoning_content)!=null?n:ie.message.reasoning;if(Ce!=null&&Ce.length>0&&Y.push({type:"reasoning",text:Ce}),ie.message.tool_calls!=null)for(const le of ie.message.tool_calls)Y.push({type:"tool-call",toolCallId:(o=le.id)!=null?o:Ii(),toolName:le.function.name,input:le.function.arguments});const he={[this.providerOptionsName]:{},...await((u=(l=this.config.metadataExtractor)==null?void 0:l.extractMetadata)==null?void 0:u.call(l,{parsedBody:j}))},xe=(f=Q.usage)==null?void 0:f.completion_tokens_details;return xe?.accepted_prediction_tokens!=null&&(he[this.providerOptionsName].acceptedPredictionTokens=xe?.accepted_prediction_tokens),xe?.rejected_prediction_tokens!=null&&(he[this.providerOptionsName].rejectedPredictionTokens=xe?.rejected_prediction_tokens),{content:Y,finishReason:Ca(ie.finish_reason),usage:{inputTokens:(m=(g=Q.usage)==null?void 0:g.prompt_tokens)!=null?m:void 0,outputTokens:(x=(y=Q.usage)==null?void 0:y.completion_tokens)!=null?x:void 0,totalTokens:(b=(A=Q.usage)==null?void 0:A.total_tokens)!=null?b:void 0,reasoningTokens:(R=(N=(P=Q.usage)==null?void 0:P.completion_tokens_details)==null?void 0:N.reasoning_tokens)!=null?R:void 0,cachedInputTokens:(z=(M=(D=Q.usage)==null?void 0:D.prompt_tokens_details)==null?void 0:M.cached_tokens)!=null?z:void 0},providerMetadata:he,request:{body:K},response:{...va(Q),headers:ve,body:j},warnings:k}}async doStream(t){var n;const{args:o,warnings:l}=await this.getArgs({...t}),u={...o,stream:!0,stream_options:this.config.includeUsage?{include_usage:!0}:void 0},f=(n=this.config.metadataExtractor)==null?void 0:n.createStreamExtractor(),{responseHeaders:g,value:m}=await ma({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:fa(this.config.headers(),t.headers),body:u,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:Fp(this.chunkSchema),abortSignal:t.abortSignal,fetch:this.config.fetch}),y=[];let x="unknown";const A={completionTokens:void 0,completionTokensDetails:{reasoningTokens:void 0,acceptedPredictionTokens:void 0,rejectedPredictionTokens:void 0},promptTokens:void 0,promptTokensDetails:{cachedTokens:void 0},totalTokens:void 0};let b=!0;const P=this.providerOptionsName;let N=!1,R=!1;return{stream:m.pipeThrough(new TransformStream({start(D){D.enqueue({type:"stream-start",warnings:l})},transform(D,M){var z,U,k,K,ve,Q,j,ie,Y,Ie,Ce,he,xe;if(t.includeRawChunks&&M.enqueue({type:"raw",rawValue:D.rawValue}),!D.success){x="error",M.enqueue({type:"error",error:D.error});return}const le=D.value;if(f?.processChunk(D.rawValue),"error"in le){x="error",M.enqueue({type:"error",error:le.error.message});return}if(b&&(b=!1,M.enqueue({type:"response-metadata",...va(le)})),le.usage!=null){const{prompt_tokens:te,completion_tokens:pe,total_tokens:ge,prompt_tokens_details:ye,completion_tokens_details:we}=le.usage;A.promptTokens=te??void 0,A.completionTokens=pe??void 0,A.totalTokens=ge??void 0,we?.reasoning_tokens!=null&&(A.completionTokensDetails.reasoningTokens=we?.reasoning_tokens),we?.accepted_prediction_tokens!=null&&(A.completionTokensDetails.acceptedPredictionTokens=we?.accepted_prediction_tokens),we?.rejected_prediction_tokens!=null&&(A.completionTokensDetails.rejectedPredictionTokens=we?.rejected_prediction_tokens),ye?.cached_tokens!=null&&(A.promptTokensDetails.cachedTokens=ye?.cached_tokens)}const F=le.choices[0];if(F?.finish_reason!=null&&(x=Ca(F.finish_reason)),F?.delta==null)return;const J=F.delta,X=(z=J.reasoning_content)!=null?z:J.reasoning;if(X&&(N||(M.enqueue({type:"reasoning-start",id:"reasoning-0"}),N=!0),M.enqueue({type:"reasoning-delta",id:"reasoning-0",delta:X})),J.content&&(R||(M.enqueue({type:"text-start",id:"txt-0"}),R=!0),M.enqueue({type:"text-delta",id:"txt-0",delta:J.content})),J.tool_calls!=null)for(const te of J.tool_calls){const pe=te.index;if(y[pe]==null){if(te.id==null)throw new Vs({data:te,message:"Expected 'id' to be a string."});if(((U=te.function)==null?void 0:U.name)==null)throw new Vs({data:te,message:"Expected 'function.name' to be a string."});M.enqueue({type:"tool-input-start",id:te.id,toolName:te.function.name}),y[pe]={id:te.id,type:"function",function:{name:te.function.name,arguments:(k=te.function.arguments)!=null?k:""},hasFinished:!1};const ye=y[pe];((K=ye.function)==null?void 0:K.name)!=null&&((ve=ye.function)==null?void 0:ve.arguments)!=null&&(ye.function.arguments.length>0&&M.enqueue({type:"tool-input-delta",id:ye.id,delta:ye.function.arguments}),pa(ye.function.arguments)&&(M.enqueue({type:"tool-input-end",id:ye.id}),M.enqueue({type:"tool-call",toolCallId:(Q=ye.id)!=null?Q:Ii(),toolName:ye.function.name,input:ye.function.arguments}),ye.hasFinished=!0));continue}const ge=y[pe];ge.hasFinished||(((j=te.function)==null?void 0:j.arguments)!=null&&(ge.function.arguments+=(Y=(ie=te.function)==null?void 0:ie.arguments)!=null?Y:""),M.enqueue({type:"tool-input-delta",id:ge.id,delta:(Ie=te.function.arguments)!=null?Ie:""}),((Ce=ge.function)==null?void 0:Ce.name)!=null&&((he=ge.function)==null?void 0:he.arguments)!=null&&pa(ge.function.arguments)&&(M.enqueue({type:"tool-input-end",id:ge.id}),M.enqueue({type:"tool-call",toolCallId:(xe=ge.id)!=null?xe:Ii(),toolName:ge.function.name,input:ge.function.arguments}),ge.hasFinished=!0))}},flush(D){var M,z,U,k,K,ve;N&&D.enqueue({type:"reasoning-end",id:"reasoning-0"}),R&&D.enqueue({type:"text-end",id:"txt-0"});for(const j of y.filter(ie=>!ie.hasFinished))D.enqueue({type:"tool-input-end",id:j.id}),D.enqueue({type:"tool-call",toolCallId:(M=j.id)!=null?M:Ii(),toolName:j.function.name,input:j.function.arguments});const Q={[P]:{},...f?.buildMetadata()};A.completionTokensDetails.acceptedPredictionTokens!=null&&(Q[P].acceptedPredictionTokens=A.completionTokensDetails.acceptedPredictionTokens),A.completionTokensDetails.rejectedPredictionTokens!=null&&(Q[P].rejectedPredictionTokens=A.completionTokensDetails.rejectedPredictionTokens),D.enqueue({type:"finish",finishReason:x,usage:{inputTokens:(z=A.promptTokens)!=null?z:void 0,outputTokens:(U=A.completionTokens)!=null?U:void 0,totalTokens:(k=A.totalTokens)!=null?k:void 0,reasoningTokens:(K=A.completionTokensDetails.reasoningTokens)!=null?K:void 0,cachedInputTokens:(ve=A.promptTokensDetails.cachedTokens)!=null?ve:void 0},providerMetadata:Q})}})),request:{body:u},response:{headers:g}}}},nu=B({prompt_tokens:W().nullish(),completion_tokens:W().nullish(),total_tokens:W().nullish(),prompt_tokens_details:B({cached_tokens:W().nullish()}).nullish(),completion_tokens_details:B({reasoning_tokens:W().nullish(),accepted_prediction_tokens:W().nullish(),rejected_prediction_tokens:W().nullish()}).nullish()}).nullish(),c2=B({id:I().nullish(),created:W().nullish(),model:I().nullish(),choices:_e(B({message:B({role:re("assistant").nullish(),content:I().nullish(),reasoning_content:I().nullish(),reasoning:I().nullish(),tool_calls:_e(B({id:I().nullish(),function:B({name:I(),arguments:I()})})).nullish()}),finish_reason:I().nullish()})),usage:nu}),u2=t=>ut([B({id:I().nullish(),created:W().nullish(),model:I().nullish(),choices:_e(B({delta:B({role:pt(["assistant"]).nullish(),content:I().nullish(),reasoning_content:I().nullish(),reasoning:I().nullish(),tool_calls:_e(B({index:W(),id:I().nullish(),function:B({name:I().nullish(),arguments:I().nullish()})})).nullish()}).nullish(),finish_reason:I().nullish()})),usage:nu}),t]);B({echo:Ft().optional(),logitBias:Dt(I(),W()).optional(),suffix:I().optional(),user:I().optional()});var d2=B({prompt_tokens:W(),completion_tokens:W(),total_tokens:W()});B({id:I().nullish(),created:W().nullish(),model:I().nullish(),choices:_e(B({text:I(),finish_reason:I()})),usage:d2.nullish()});B({dimensions:W().optional(),user:I().optional()});B({data:_e(B({embedding:_e(W())})),usage:B({prompt_tokens:W()}).nullish(),providerMetadata:Dt(I(),Dt(I(),ai())).optional()});B({data:_e(B({b64_json:I()}))});var ba=t=>{var n,o;return t==null?void 0:{deepseek:{promptCacheHitTokens:(n=t.prompt_cache_hit_tokens)!=null?n:NaN,promptCacheMissTokens:(o=t.prompt_cache_miss_tokens)!=null?o:NaN}}},f2={extractMetadata:async({parsedBody:t})=>{const n=await Tr({value:t,schema:h2});return!n.success||n.value.usage==null?void 0:ba(n.value.usage)},createStreamExtractor:()=>{let t;return{processChunk:async n=>{var o,l;const u=await Tr({value:n,schema:p2});u.success&&((l=(o=u.value.choices)==null?void 0:o[0])==null?void 0:l.finish_reason)==="stop"&&u.value.usage&&(t=u.value.usage)},buildMetadata:()=>ba(t)}}},ru=B({prompt_cache_hit_tokens:W().nullish(),prompt_cache_miss_tokens:W().nullish()}),h2=B({usage:ru.nullish()}),p2=B({choices:_e(B({finish_reason:I().nullish()})).nullish(),usage:ru.nullish()}),g2="1.0.30";function iu(t={}){var n;const o=Bg((n=t.baseURL)!=null?n:"https://api.deepseek.com/v1"),l=()=>Vc({Authorization:`Bearer ${Ep({apiKey:t.apiKey,environmentVariableName:"DEEPSEEK_API_KEY",description:"DeepSeek API key"})}`,...t.headers},`ai-sdk/deepseek/${g2}`);class u extends l2{addJsonInstruction(y){var x;if(((x=y.responseFormat)==null?void 0:x.type)!=="json")return y;const P=[...Array.isArray(y.prompt)?y.prompt:[],{role:"user",content:[{type:"text",text:"Return ONLY a valid JSON object."}]}];return{...y,prompt:P}}async doGenerate(y){return super.doGenerate(this.addJsonInstruction(y))}async doStream(y){return super.doStream(this.addJsonInstruction(y))}}const f=m=>new u(m,{provider:"deepseek.chat",url:({path:y})=>`${o}${y}`,headers:l,fetch:t.fetch,metadataExtractor:f2}),g=m=>f(m);return g.languageModel=f,g.chat=f,g.textEmbeddingModel=m=>{throw new js({modelId:m,modelType:"textEmbeddingModel"})},g.imageModel=m=>{throw new js({modelId:m,modelType:"imageModel"})},g}iu();var ou="vercel.ai.error",m2=Symbol.for(ou),Ea,Aa,At=class su extends(Aa=Error,Ea=m2,Aa){constructor({name:n,message:o,cause:l}){super(o),this[Ea]=!0,this.name=n,this.cause=l}static isInstance(n){return su.hasMarker(n,ou)}static hasMarker(n,o){const l=Symbol.for(o);return n!=null&&typeof n=="object"&&l in n&&typeof n[l]=="boolean"&&n[l]===!0}},au="AI_APICallError",lu=`vercel.ai.error.${au}`,x2=Symbol.for(lu),Ia,Sa,wn=class extends(Sa=At,Ia=x2,Sa){constructor({message:t,url:n,requestBodyValues:o,statusCode:l,responseHeaders:u,responseBody:f,cause:g,isRetryable:m=l!=null&&(l===408||l===409||l===429||l>=500),data:y}){super({name:au,message:t,cause:g}),this[Ia]=!0,this.url=n,this.requestBodyValues=o,this.statusCode=l,this.responseHeaders=u,this.responseBody=f,this.isRetryable=m,this.data=y}static isInstance(t){return At.hasMarker(t,lu)}},cu="AI_EmptyResponseBodyError",uu=`vercel.ai.error.${cu}`,w2=Symbol.for(uu),Ta,Oa,y2=class extends(Oa=At,Ta=w2,Oa){constructor({message:t="Empty response body"}={}){super({name:cu,message:t}),this[Ta]=!0}static isInstance(t){return At.hasMarker(t,uu)}};function du(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var fu="AI_InvalidArgumentError",hu=`vercel.ai.error.${fu}`,_2=Symbol.for(hu),Na,ka,pu=class extends(ka=At,Na=_2,ka){constructor({message:t,cause:n,argument:o}){super({name:fu,message:t,cause:n}),this[Na]=!0,this.argument=o}static isInstance(t){return At.hasMarker(t,hu)}},gu="AI_InvalidPromptError",mu=`vercel.ai.error.${gu}`,v2=Symbol.for(mu),Ra,Da,C2=class extends(Da=At,Ra=v2,Da){constructor({prompt:t,message:n,cause:o}){super({name:gu,message:`Invalid prompt: ${n}`,cause:o}),this[Ra]=!0,this.prompt=t}static isInstance(t){return At.hasMarker(t,mu)}},xu="AI_InvalidResponseDataError",wu=`vercel.ai.error.${xu}`,b2=Symbol.for(wu),Ma,Pa,ko=class extends(Pa=At,Ma=b2,Pa){constructor({data:t,message:n=`Invalid response data: ${JSON.stringify(t)}.`}){super({name:xu,message:n}),this[Ma]=!0,this.data=t}static isInstance(t){return At.hasMarker(t,wu)}},yu="AI_JSONParseError",_u=`vercel.ai.error.${yu}`,E2=Symbol.for(_u),Ba,La,Wi=class extends(La=At,Ba=E2,La){constructor({text:t,cause:n}){super({name:yu,message:`JSON parsing failed: Text: ${t}.
43
- Error message: ${du(n)}`,cause:n}),this[Ba]=!0,this.text=t}static isInstance(t){return At.hasMarker(t,_u)}},vu="AI_LoadAPIKeyError",Cu=`vercel.ai.error.${vu}`,A2=Symbol.for(Cu),Fa,$a,Ti=class extends($a=At,Fa=A2,$a){constructor({message:t}){super({name:vu,message:t}),this[Fa]=!0}static isInstance(t){return At.hasMarker(t,Cu)}},bu="AI_TooManyEmbeddingValuesForCallError",Eu=`vercel.ai.error.${bu}`,I2=Symbol.for(Eu),Ua,za,S2=class extends(za=At,Ua=I2,za){constructor(t){super({name:bu,message:`Too many values for a single embedding call. The ${t.provider} model "${t.modelId}" can only embed up to ${t.maxEmbeddingsPerCall} values per call, but ${t.values.length} values were provided.`}),this[Ua]=!0,this.provider=t.provider,this.modelId=t.modelId,this.maxEmbeddingsPerCall=t.maxEmbeddingsPerCall,this.values=t.values}static isInstance(t){return At.hasMarker(t,Eu)}},Au="AI_TypeValidationError",Iu=`vercel.ai.error.${Au}`,T2=Symbol.for(Iu),Za,Va,ni=class Go extends(Va=At,Za=T2,Va){constructor({value:n,cause:o}){super({name:Au,message:`Type validation failed: Value: ${JSON.stringify(n)}.
44
- Error message: ${du(o)}`,cause:o}),this[Za]=!0,this.value=n}static isInstance(n){return At.hasMarker(n,Iu)}static wrap({value:n,cause:o}){return Go.isInstance(o)&&o.value===n?o:new Go({value:n,cause:o})}},Su="AI_UnsupportedFunctionalityError",Tu=`vercel.ai.error.${Su}`,O2=Symbol.for(Tu),ja,Ha,Zn=class extends(Ha=At,ja=O2,Ha){constructor({functionality:t,message:n=`'${t}' functionality not supported.`}){super({name:Su,message:n}),this[ja]=!0,this.functionality=t}static isInstance(t){return At.hasMarker(t,Tu)}};function Bn(...t){return t.reduce((n,o)=>({...n,...o??{}}),{})}function ci(t){return Object.fromEntries([...t.headers])}var N2=({prefix:t,size:n=16,alphabet:o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:l="-"}={})=>{const u=()=>{const f=o.length,g=new Array(n);for(let m=0;m<n;m++)g[m]=o[Math.random()*f|0];return g.join("")};if(t==null)return u;if(o.includes(l))throw new pu({argument:"separator",message:`The separator "${l}" must not be part of the alphabet "${o}".`});return()=>`${t}${l}${u()}`},Sn=N2();function Xo(t){return(t instanceof Error||t instanceof DOMException)&&(t.name==="AbortError"||t.name==="ResponseAborted"||t.name==="TimeoutError")}var k2=["fetch failed","failed to fetch"];function R2({error:t,url:n,requestBodyValues:o}){if(Xo(t))return t;if(t instanceof TypeError&&k2.includes(t.message.toLowerCase())){const l=t.cause;if(l!=null)return new wn({message:`Cannot connect to API: ${l.message}`,cause:l,url:n,requestBodyValues:o,isRetryable:!0})}return t}function D2(t=globalThis){var n,o,l;return t.window?"runtime/browser":(n=t.navigator)!=null&&n.userAgent?`runtime/${t.navigator.userAgent.toLowerCase()}`:(l=(o=t.process)==null?void 0:o.versions)!=null&&l.node?`runtime/node.js/${t.process.version.substring(0)}`:t.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function M2(t){if(t==null)return{};const n={};if(t instanceof Headers)t.forEach((o,l)=>{n[l.toLowerCase()]=o});else{Array.isArray(t)||(t=Object.entries(t));for(const[o,l]of t)l!=null&&(n[o.toLowerCase()]=l)}return n}function Ou(t,...n){const o=new Headers(M2(t)),l=o.get("user-agent")||"";return o.set("user-agent",[l,...n].filter(Boolean).join(" ")),Object.fromEntries(o.entries())}var P2="3.0.20";function B2({apiKey:t,environmentVariableName:n,apiKeyParameterName:o="apiKey",description:l}){if(typeof t=="string")return t;if(t!=null)throw new Ti({message:`${l} API key must be a string.`});if(typeof process>"u")throw new Ti({message:`${l} API key is missing. Pass it using the '${o}' parameter. Environment variables is not supported in this environment.`});if(t=process.env[n],t==null)throw new Ti({message:`${l} API key is missing. Pass it using the '${o}' parameter or the ${n} environment variable.`});if(typeof t!="string")throw new Ti({message:`${l} API key must be a string. The value of the ${n} environment variable is not a string.`});return t}function L2({settingValue:t,environmentVariableName:n}){if(typeof t=="string")return t;if(!(t!=null||typeof process>"u")&&(t=process.env[n],!(t==null||typeof t!="string")))return t}function F2(t){var n;const[o,l=""]=t.toLowerCase().split("/");return(n={mpeg:"mp3","x-wav":"wav",opus:"ogg",mp4:"m4a","x-m4a":"m4a"}[l])!=null?n:l}var $2=/"__proto__"\s*:/,U2=/"constructor"\s*:/;function Wa(t){const n=JSON.parse(t);return n===null||typeof n!="object"||$2.test(t)===!1&&U2.test(t)===!1?n:z2(n)}function z2(t){let n=[t];for(;n.length;){const o=n;n=[];for(const l of o){if(Object.prototype.hasOwnProperty.call(l,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(l,"constructor")&&Object.prototype.hasOwnProperty.call(l.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const u in l){const f=l[u];f&&typeof f=="object"&&n.push(f)}}}return t}function hs(t){const{stackTraceLimit:n}=Error;try{Error.stackTraceLimit=0}catch{return Wa(t)}try{return Wa(t)}finally{Error.stackTraceLimit=n}}var Gi=Symbol.for("vercel.ai.validator");function Z2(t){return{[Gi]:!0,validate:t}}function V2(t){return typeof t=="object"&&t!==null&&Gi in t&&t[Gi]===!0&&"validate"in t}function Yt(t){let n;return()=>(n==null&&(n=t()),n)}function j2(t){return V2(t)?t:typeof t=="function"?t():H2(t)}function H2(t){return Z2(async n=>{const o=await t["~standard"].validate(n);return o.issues==null?{success:!0,value:o.value}:{success:!1,error:new ni({value:n,cause:o.issues})}})}async function Jn({value:t,schema:n}){const o=await ps({value:t,schema:n});if(!o.success)throw ni.wrap({value:t,cause:o.error});return o.value}async function ps({value:t,schema:n}){const o=j2(n);try{if(o.validate==null)return{success:!0,value:t,rawValue:t};const l=await o.validate(t);return l.success?{success:!0,value:l.value,rawValue:t}:{success:!1,error:ni.wrap({value:t,cause:l.error}),rawValue:t}}catch(l){return{success:!1,error:ni.wrap({value:t,cause:l}),rawValue:t}}}async function W2({text:t,schema:n}){try{const o=hs(t);return n==null?o:Jn({value:o,schema:n})}catch(o){throw Wi.isInstance(o)||ni.isInstance(o)?o:new Wi({text:t,cause:o})}}async function Nu({text:t,schema:n}){try{const o=hs(t);return n==null?{success:!0,value:o,rawValue:o}:await ps({value:o,schema:n})}catch(o){return{success:!1,error:Wi.isInstance(o)?o:new Wi({text:t,cause:o}),rawValue:void 0}}}function Ga(t){try{return hs(t),!0}catch{return!1}}function G2({stream:t,schema:n}){return t.pipeThrough(new TextDecoderStream).pipeThrough(new mc).pipeThrough(new TransformStream({async transform({data:o},l){o!=="[DONE]"&&l.enqueue(await Nu({text:o,schema:n}))}}))}async function nr({provider:t,providerOptions:n,schema:o}){if(n?.[t]==null)return;const l=await ps({value:n[t],schema:o});if(!l.success)throw new pu({argument:"providerOptions",message:`invalid ${t} provider options`,cause:l.error});return l.value}var X2=()=>globalThis.fetch,Vn=async({url:t,headers:n,body:o,failedResponseHandler:l,successfulResponseHandler:u,abortSignal:f,fetch:g})=>ku({url:t,headers:{"Content-Type":"application/json",...n},body:{content:JSON.stringify(o),values:o},failedResponseHandler:l,successfulResponseHandler:u,abortSignal:f,fetch:g}),Y2=async({url:t,headers:n,formData:o,failedResponseHandler:l,successfulResponseHandler:u,abortSignal:f,fetch:g})=>ku({url:t,headers:n,body:{content:o,values:Object.fromEntries(o.entries())},failedResponseHandler:l,successfulResponseHandler:u,abortSignal:f,fetch:g}),ku=async({url:t,headers:n={},body:o,successfulResponseHandler:l,failedResponseHandler:u,abortSignal:f,fetch:g=X2()})=>{try{const m=await g(t,{method:"POST",headers:Ou(n,`ai-sdk/provider-utils/${P2}`,D2()),body:o.content,signal:f}),y=ci(m);if(!m.ok){let x;try{x=await u({response:m,url:t,requestBodyValues:o.values})}catch(A){throw Xo(A)||wn.isInstance(A)?A:new wn({message:"Failed to process error response",cause:A,statusCode:m.status,url:t,responseHeaders:y,requestBodyValues:o.values})}throw x.value}try{return await l({response:m,url:t,requestBodyValues:o.values})}catch(x){throw x instanceof Error&&(Xo(x)||wn.isInstance(x))?x:new wn({message:"Failed to process successful response",cause:x,statusCode:m.status,url:t,responseHeaders:y,requestBodyValues:o.values})}}catch(m){throw R2({error:m,url:t,requestBodyValues:o.values})}};function Or({id:t,name:n,inputSchema:o,outputSchema:l}){return({execute:u,toModelOutput:f,onInputStart:g,onInputDelta:m,onInputAvailable:y,...x})=>({type:"provider-defined",id:t,name:n,args:x,inputSchema:o,outputSchema:l,execute:u,toModelOutput:f,onInputStart:g,onInputDelta:m,onInputAvailable:y})}var q2=({errorSchema:t,errorToMessage:n,isRetryable:o})=>async({response:l,url:u,requestBodyValues:f})=>{const g=await l.text(),m=ci(l);if(g.trim()==="")return{responseHeaders:m,value:new wn({message:l.statusText,url:u,requestBodyValues:f,statusCode:l.status,responseHeaders:m,responseBody:g,isRetryable:o?.(l)})};try{const y=await W2({text:g,schema:t});return{responseHeaders:m,value:new wn({message:n(y),url:u,requestBodyValues:f,statusCode:l.status,responseHeaders:m,responseBody:g,data:y,isRetryable:o?.(l,y)})}}catch{return{responseHeaders:m,value:new wn({message:l.statusText,url:u,requestBodyValues:f,statusCode:l.status,responseHeaders:m,responseBody:g,isRetryable:o?.(l)})}}},gs=t=>async({response:n})=>{const o=ci(n);if(n.body==null)throw new y2({});return{responseHeaders:o,value:G2({stream:n.body,schema:t})}},Nr=t=>async({response:n,url:o,requestBodyValues:l})=>{const u=await n.text(),f=await Nu({text:u,schema:t}),g=ci(n);if(!f.success)throw new wn({message:"Invalid JSON response",cause:f.error,statusCode:n.status,responseHeaders:g,responseBody:u,url:o,requestBodyValues:l});return{responseHeaders:g,value:f.value,rawValue:f.rawValue}},K2=()=>async({response:t,url:n,requestBodyValues:o})=>{const l=ci(t);if(!t.body)throw new wn({message:"Response body is empty",url:n,requestBodyValues:o,statusCode:t.status,responseHeaders:l,responseBody:void 0});try{const u=await t.arrayBuffer();return{responseHeaders:l,value:new Uint8Array(u)}}catch(u){throw new wn({message:"Failed to read response as array buffer",url:n,requestBodyValues:o,statusCode:t.status,responseHeaders:l,responseBody:void 0,cause:u})}};function Li(t){if(t.type==="object"){t.additionalProperties=!1;const n=t.properties;if(n!=null)for(const o in n)n[o]=Li(n[o])}return t.type==="array"&&t.items!=null&&(Array.isArray(t.items)?t.items=t.items.map(n=>Li(n)):t.items=Li(t.items)),t}var J2=(t,n)=>{let o=0;for(;o<t.length&&o<n.length&&t[o]===n[o];o++);return[(t.length-o).toString(),...n.slice(o)].join("/")},Q2=Symbol("Let zodToJsonSchema decide on which parser to use"),Xa={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},em=t=>typeof t=="string"?{...Xa,name:t}:{...Xa,...t};function ln(){return{}}function tm(t,n){var o,l,u;const f={type:"array"};return(o=t.type)!=null&&o._def&&((u=(l=t.type)==null?void 0:l._def)==null?void 0:u.typeName)!==de.ZodAny&&(f.items=tt(t.type._def,{...n,currentPath:[...n.currentPath,"items"]})),t.minLength&&(f.minItems=t.minLength.value),t.maxLength&&(f.maxItems=t.maxLength.value),t.exactLength&&(f.minItems=t.exactLength.value,f.maxItems=t.exactLength.value),f}function nm(t){const n={type:"integer",format:"int64"};if(!t.checks)return n;for(const o of t.checks)switch(o.kind){case"min":o.inclusive?n.minimum=o.value:n.exclusiveMinimum=o.value;break;case"max":o.inclusive?n.maximum=o.value:n.exclusiveMaximum=o.value;break;case"multipleOf":n.multipleOf=o.value;break}return n}function rm(){return{type:"boolean"}}function Ru(t,n){return tt(t.type._def,n)}var im=(t,n)=>tt(t.innerType._def,n);function Du(t,n,o){const l=o??n.dateStrategy;if(Array.isArray(l))return{anyOf:l.map((u,f)=>Du(t,n,u))};switch(l){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return om(t)}}var om=t=>{const n={type:"integer",format:"unix-time"};for(const o of t.checks)switch(o.kind){case"min":n.minimum=o.value;break;case"max":n.maximum=o.value;break}return n};function sm(t,n){return{...tt(t.innerType._def,n),default:t.defaultValue()}}function am(t,n){return n.effectStrategy==="input"?tt(t.schema._def,n):ln()}function lm(t){return{type:"string",enum:Array.from(t.values)}}var cm=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function um(t,n){const o=[tt(t.left._def,{...n,currentPath:[...n.currentPath,"allOf","0"]}),tt(t.right._def,{...n,currentPath:[...n.currentPath,"allOf","1"]})].filter(u=>!!u),l=[];return o.forEach(u=>{if(cm(u))l.push(...u.allOf);else{let f=u;if("additionalProperties"in u&&u.additionalProperties===!1){const{additionalProperties:g,...m}=u;f=m}l.push(f)}}),l.length?{allOf:l}:void 0}function dm(t){const n=typeof t.value;return n!=="bigint"&&n!=="number"&&n!=="boolean"&&n!=="string"?{type:Array.isArray(t.value)?"array":"object"}:{type:n==="bigint"?"integer":n,const:t.value}}var Ro=void 0,En={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(Ro===void 0&&(Ro=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Ro),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Mu(t,n){const o={type:"string"};if(t.checks)for(const l of t.checks)switch(l.kind){case"min":o.minLength=typeof o.minLength=="number"?Math.max(o.minLength,l.value):l.value;break;case"max":o.maxLength=typeof o.maxLength=="number"?Math.min(o.maxLength,l.value):l.value;break;case"email":switch(n.emailStrategy){case"format:email":An(o,"email",l.message,n);break;case"format:idn-email":An(o,"idn-email",l.message,n);break;case"pattern:zod":Wt(o,En.email,l.message,n);break}break;case"url":An(o,"uri",l.message,n);break;case"uuid":An(o,"uuid",l.message,n);break;case"regex":Wt(o,l.regex,l.message,n);break;case"cuid":Wt(o,En.cuid,l.message,n);break;case"cuid2":Wt(o,En.cuid2,l.message,n);break;case"startsWith":Wt(o,RegExp(`^${Do(l.value,n)}`),l.message,n);break;case"endsWith":Wt(o,RegExp(`${Do(l.value,n)}$`),l.message,n);break;case"datetime":An(o,"date-time",l.message,n);break;case"date":An(o,"date",l.message,n);break;case"time":An(o,"time",l.message,n);break;case"duration":An(o,"duration",l.message,n);break;case"length":o.minLength=typeof o.minLength=="number"?Math.max(o.minLength,l.value):l.value,o.maxLength=typeof o.maxLength=="number"?Math.min(o.maxLength,l.value):l.value;break;case"includes":{Wt(o,RegExp(Do(l.value,n)),l.message,n);break}case"ip":{l.version!=="v6"&&An(o,"ipv4",l.message,n),l.version!=="v4"&&An(o,"ipv6",l.message,n);break}case"base64url":Wt(o,En.base64url,l.message,n);break;case"jwt":Wt(o,En.jwt,l.message,n);break;case"cidr":{l.version!=="v6"&&Wt(o,En.ipv4Cidr,l.message,n),l.version!=="v4"&&Wt(o,En.ipv6Cidr,l.message,n);break}case"emoji":Wt(o,En.emoji(),l.message,n);break;case"ulid":{Wt(o,En.ulid,l.message,n);break}case"base64":{switch(n.base64Strategy){case"format:binary":{An(o,"binary",l.message,n);break}case"contentEncoding:base64":{o.contentEncoding="base64";break}case"pattern:zod":{Wt(o,En.base64,l.message,n);break}}break}case"nanoid":Wt(o,En.nanoid,l.message,n)}return o}function Do(t,n){return n.patternStrategy==="escape"?hm(t):t}var fm=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function hm(t){let n="";for(let o=0;o<t.length;o++)fm.has(t[o])||(n+="\\"),n+=t[o];return n}function An(t,n,o,l){var u;t.format||(u=t.anyOf)!=null&&u.some(f=>f.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format}),delete t.format),t.anyOf.push({format:n,...o&&l.errorMessages&&{errorMessage:{format:o}}})):t.format=n}function Wt(t,n,o,l){var u;t.pattern||(u=t.allOf)!=null&&u.some(f=>f.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern}),delete t.pattern),t.allOf.push({pattern:Ya(n,l),...o&&l.errorMessages&&{errorMessage:{pattern:o}}})):t.pattern=Ya(n,l)}function Ya(t,n){var o;if(!n.applyRegexFlags||!t.flags)return t.source;const l={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},u=l.i?t.source.toLowerCase():t.source;let f="",g=!1,m=!1,y=!1;for(let x=0;x<u.length;x++){if(g){f+=u[x],g=!1;continue}if(l.i){if(m){if(u[x].match(/[a-z]/)){y?(f+=u[x],f+=`${u[x-2]}-${u[x]}`.toUpperCase(),y=!1):u[x+1]==="-"&&((o=u[x+2])!=null&&o.match(/[a-z]/))?(f+=u[x],y=!0):f+=`${u[x]}${u[x].toUpperCase()}`;continue}}else if(u[x].match(/[a-z]/)){f+=`[${u[x]}${u[x].toUpperCase()}]`;continue}}if(l.m){if(u[x]==="^"){f+=`(^|(?<=[\r
45
- ]))`;continue}else if(u[x]==="$"){f+=`($|(?=[\r
46
- ]))`;continue}}if(l.s&&u[x]==="."){f+=m?`${u[x]}\r
47
- `:`[${u[x]}\r
48
- ]`;continue}f+=u[x],u[x]==="\\"?g=!0:m&&u[x]==="]"?m=!1:!m&&u[x]==="["&&(m=!0)}try{new RegExp(f)}catch{return console.warn(`Could not convert regex pattern at ${n.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return f}function Pu(t,n){var o,l,u,f,g,m;const y={type:"object",additionalProperties:(o=tt(t.valueType._def,{...n,currentPath:[...n.currentPath,"additionalProperties"]}))!=null?o:n.allowedAdditionalProperties};if(((l=t.keyType)==null?void 0:l._def.typeName)===de.ZodString&&((u=t.keyType._def.checks)!=null&&u.length)){const{type:x,...A}=Mu(t.keyType._def,n);return{...y,propertyNames:A}}else{if(((f=t.keyType)==null?void 0:f._def.typeName)===de.ZodEnum)return{...y,propertyNames:{enum:t.keyType._def.values}};if(((g=t.keyType)==null?void 0:g._def.typeName)===de.ZodBranded&&t.keyType._def.type._def.typeName===de.ZodString&&((m=t.keyType._def.type._def.checks)!=null&&m.length)){const{type:x,...A}=Ru(t.keyType._def,n);return{...y,propertyNames:A}}}return y}function pm(t,n){if(n.mapStrategy==="record")return Pu(t,n);const o=tt(t.keyType._def,{...n,currentPath:[...n.currentPath,"items","items","0"]})||ln(),l=tt(t.valueType._def,{...n,currentPath:[...n.currentPath,"items","items","1"]})||ln();return{type:"array",maxItems:125,items:{type:"array",items:[o,l],minItems:2,maxItems:2}}}function gm(t){const n=t.values,l=Object.keys(t.values).filter(f=>typeof n[n[f]]!="number").map(f=>n[f]),u=Array.from(new Set(l.map(f=>typeof f)));return{type:u.length===1?u[0]==="string"?"string":"number":["string","number"],enum:l}}function mm(){return{not:ln()}}function xm(){return{type:"null"}}var Yo={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function wm(t,n){const o=t.options instanceof Map?Array.from(t.options.values()):t.options;if(o.every(l=>l._def.typeName in Yo&&(!l._def.checks||!l._def.checks.length))){const l=o.reduce((u,f)=>{const g=Yo[f._def.typeName];return g&&!u.includes(g)?[...u,g]:u},[]);return{type:l.length>1?l:l[0]}}else if(o.every(l=>l._def.typeName==="ZodLiteral"&&!l.description)){const l=o.reduce((u,f)=>{const g=typeof f._def.value;switch(g){case"string":case"number":case"boolean":return[...u,g];case"bigint":return[...u,"integer"];case"object":if(f._def.value===null)return[...u,"null"];case"symbol":case"undefined":case"function":default:return u}},[]);if(l.length===o.length){const u=l.filter((f,g,m)=>m.indexOf(f)===g);return{type:u.length>1?u:u[0],enum:o.reduce((f,g)=>f.includes(g._def.value)?f:[...f,g._def.value],[])}}}else if(o.every(l=>l._def.typeName==="ZodEnum"))return{type:"string",enum:o.reduce((l,u)=>[...l,...u._def.values.filter(f=>!l.includes(f))],[])};return ym(t,n)}var ym=(t,n)=>{const o=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((l,u)=>tt(l._def,{...n,currentPath:[...n.currentPath,"anyOf",`${u}`]})).filter(l=>!!l&&(!n.strictUnions||typeof l=="object"&&Object.keys(l).length>0));return o.length?{anyOf:o}:void 0};function _m(t,n){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return{type:[Yo[t.innerType._def.typeName],"null"]};const o=tt(t.innerType._def,{...n,currentPath:[...n.currentPath,"anyOf","0"]});return o&&{anyOf:[o,{type:"null"}]}}function vm(t){const n={type:"number"};if(!t.checks)return n;for(const o of t.checks)switch(o.kind){case"int":n.type="integer";break;case"min":o.inclusive?n.minimum=o.value:n.exclusiveMinimum=o.value;break;case"max":o.inclusive?n.maximum=o.value:n.exclusiveMaximum=o.value;break;case"multipleOf":n.multipleOf=o.value;break}return n}function Cm(t,n){const o={type:"object",properties:{}},l=[],u=t.shape();for(const g in u){let m=u[g];if(m===void 0||m._def===void 0)continue;const y=Em(m),x=tt(m._def,{...n,currentPath:[...n.currentPath,"properties",g],propertyPath:[...n.currentPath,"properties",g]});x!==void 0&&(o.properties[g]=x,y||l.push(g))}l.length&&(o.required=l);const f=bm(t,n);return f!==void 0&&(o.additionalProperties=f),o}function bm(t,n){if(t.catchall._def.typeName!=="ZodNever")return tt(t.catchall._def,{...n,currentPath:[...n.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return n.allowedAdditionalProperties;case"strict":return n.rejectedAdditionalProperties;case"strip":return n.removeAdditionalStrategy==="strict"?n.allowedAdditionalProperties:n.rejectedAdditionalProperties}}function Em(t){try{return t.isOptional()}catch{return!0}}var Am=(t,n)=>{var o;if(n.currentPath.toString()===((o=n.propertyPath)==null?void 0:o.toString()))return tt(t.innerType._def,n);const l=tt(t.innerType._def,{...n,currentPath:[...n.currentPath,"anyOf","1"]});return l?{anyOf:[{not:ln()},l]}:ln()},Im=(t,n)=>{if(n.pipeStrategy==="input")return tt(t.in._def,n);if(n.pipeStrategy==="output")return tt(t.out._def,n);const o=tt(t.in._def,{...n,currentPath:[...n.currentPath,"allOf","0"]}),l=tt(t.out._def,{...n,currentPath:[...n.currentPath,"allOf",o?"1":"0"]});return{allOf:[o,l].filter(u=>u!==void 0)}};function Sm(t,n){return tt(t.type._def,n)}function Tm(t,n){const l={type:"array",uniqueItems:!0,items:tt(t.valueType._def,{...n,currentPath:[...n.currentPath,"items"]})};return t.minSize&&(l.minItems=t.minSize.value),t.maxSize&&(l.maxItems=t.maxSize.value),l}function Om(t,n){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((o,l)=>tt(o._def,{...n,currentPath:[...n.currentPath,"items",`${l}`]})).reduce((o,l)=>l===void 0?o:[...o,l],[]),additionalItems:tt(t.rest._def,{...n,currentPath:[...n.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((o,l)=>tt(o._def,{...n,currentPath:[...n.currentPath,"items",`${l}`]})).reduce((o,l)=>l===void 0?o:[...o,l],[])}}function Nm(){return{not:ln()}}function km(){return ln()}var Rm=(t,n)=>tt(t.innerType._def,n),Dm=(t,n,o)=>{switch(n){case de.ZodString:return Mu(t,o);case de.ZodNumber:return vm(t);case de.ZodObject:return Cm(t,o);case de.ZodBigInt:return nm(t);case de.ZodBoolean:return rm();case de.ZodDate:return Du(t,o);case de.ZodUndefined:return Nm();case de.ZodNull:return xm();case de.ZodArray:return tm(t,o);case de.ZodUnion:case de.ZodDiscriminatedUnion:return wm(t,o);case de.ZodIntersection:return um(t,o);case de.ZodTuple:return Om(t,o);case de.ZodRecord:return Pu(t,o);case de.ZodLiteral:return dm(t);case de.ZodEnum:return lm(t);case de.ZodNativeEnum:return gm(t);case de.ZodNullable:return _m(t,o);case de.ZodOptional:return Am(t,o);case de.ZodMap:return pm(t,o);case de.ZodSet:return Tm(t,o);case de.ZodLazy:return()=>t.getter()._def;case de.ZodPromise:return Sm(t,o);case de.ZodNaN:case de.ZodNever:return mm();case de.ZodEffects:return am(t,o);case de.ZodAny:return ln();case de.ZodUnknown:return km();case de.ZodDefault:return sm(t,o);case de.ZodBranded:return Ru(t,o);case de.ZodReadonly:return Rm(t,o);case de.ZodCatch:return im(t,o);case de.ZodPipeline:return Im(t,o);case de.ZodFunction:case de.ZodVoid:case de.ZodSymbol:return;default:return(l=>{})()}};function tt(t,n,o=!1){var l;const u=n.seen.get(t);if(n.override){const y=(l=n.override)==null?void 0:l.call(n,t,n,u,o);if(y!==Q2)return y}if(u&&!o){const y=Mm(u,n);if(y!==void 0)return y}const f={def:t,path:n.currentPath,jsonSchema:void 0};n.seen.set(t,f);const g=Dm(t,t.typeName,n),m=typeof g=="function"?tt(g(),n):g;if(m&&Pm(t,n,m),n.postProcess){const y=n.postProcess(m,t,n);return f.jsonSchema=m,y}return f.jsonSchema=m,m}var Mm=(t,n)=>{switch(n.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:J2(n.currentPath,t.path)};case"none":case"seen":return t.path.length<n.currentPath.length&&t.path.every((o,l)=>n.currentPath[l]===o)?(console.warn(`Recursive reference detected at ${n.currentPath.join("/")}! Defaulting to any`),ln()):n.$refStrategy==="seen"?ln():void 0}},Pm=(t,n,o)=>(t.description&&(o.description=t.description),o),Bm=t=>{const n=em(t),o=n.name!==void 0?[...n.basePath,n.definitionPath,n.name]:n.basePath;return{...n,currentPath:o,propertyPath:void 0,seen:new Map(Object.entries(n.definitions).map(([l,u])=>[u._def,{def:u._def,path:[...n.basePath,n.definitionPath,l],jsonSchema:void 0}]))}},Lm=(t,n)=>{var o;const l=Bm(n);let u=typeof n=="object"&&n.definitions?Object.entries(n.definitions).reduce((x,[A,b])=>{var P;return{...x,[A]:(P=tt(b._def,{...l,currentPath:[...l.basePath,l.definitionPath,A]},!0))!=null?P:ln()}},{}):void 0;const f=typeof n=="string"?n:n?.nameStrategy==="title"?void 0:n?.name,g=(o=tt(t._def,f===void 0?l:{...l,currentPath:[...l.basePath,l.definitionPath,f]},!1))!=null?o:ln(),m=typeof n=="object"&&n.name!==void 0&&n.nameStrategy==="title"?n.name:void 0;m!==void 0&&(g.title=m);const y=f===void 0?u?{...g,[l.definitionPath]:u}:g:{$ref:[...l.$refStrategy==="relative"?[]:l.basePath,l.definitionPath,f].join("/"),[l.definitionPath]:{...u,[f]:g}};return y.$schema="http://json-schema.org/draft-07/schema#",y},Fm=Lm;function $m(t,n){var o;const l=(o=void 0)!=null?o:!1;return Bu(()=>Fm(t,{$refStrategy:l?"root":"none"}),{validate:async u=>{const f=await t.safeParseAsync(u);return f.success?{success:!0,value:f.data}:{success:!1,error:f.error}}})}function Um(t,n){var o;const l=(o=void 0)!=null?o:!1;return Bu(()=>Li(Lc(t,{target:"draft-7",io:"input",reused:l?"ref":"inline"})),{validate:async u=>{const f=await ls(t,u);return f.success?{success:!0,value:f.data}:{success:!1,error:f.error}}})}function zm(t){return"_zod"in t}function Ke(t,n){return zm(t)?Um(t):$m(t)}var Zm=Symbol.for("vercel.ai.schema");function zt(t){let n;return()=>(n==null&&(n=t()),n)}function Bu(t,{validate:n}={}){return{[Zm]:!0,_type:void 0,[Gi]:!0,get jsonSchema(){return typeof t=="function"&&(t=t()),t},validate:n}}var{btoa:Vm,atob:jm}=globalThis;function Hm(t){const n=t.replace(/-/g,"+").replace(/_/g,"/"),o=jm(n);return Uint8Array.from(o,l=>l.codePointAt(0))}function Wm(t){let n="";for(let o=0;o<t.length;o++)n+=String.fromCodePoint(t[o]);return Vm(n)}function Ir(t){return t instanceof Uint8Array?Wm(t):t}function Gm(t){return t?.replace(/\/$/,"")}var ms=B({error:B({message:I(),type:I().nullish(),param:ai().nullish(),code:ut([I(),W()]).nullish()})}),Ln=q2({errorSchema:ms,errorToMessage:t=>t.error.message});function Lu(t){const n=t.startsWith("o3")||t.startsWith("o4-mini")||t.startsWith("gpt-5")&&!t.startsWith("gpt-5-chat"),o=t.startsWith("gpt-4")||t.startsWith("gpt-5-mini")||t.startsWith("gpt-5")&&!t.startsWith("gpt-5-nano")&&!t.startsWith("gpt-5-chat")||t.startsWith("o3")||t.startsWith("o4-mini"),l=!(t.startsWith("gpt-3")||t.startsWith("gpt-4")||t.startsWith("chatgpt-4o")||t.startsWith("gpt-5-chat")),u=t.startsWith("gpt-5.1")||t.startsWith("gpt-5.2");return{supportsFlexProcessing:n,supportsPriorityProcessing:o,isReasoningModel:l,systemMessageMode:l?"developer":"system",supportsNonReasoningParameters:u}}function Xm({prompt:t,systemMessageMode:n="system"}){const o=[],l=[];for(const{role:u,content:f}of t)switch(u){case"system":{switch(n){case"system":{o.push({role:"system",content:f});break}case"developer":{o.push({role:"developer",content:f});break}case"remove":{l.push({type:"other",message:"system messages are removed for this model"});break}default:{const g=n;throw new Error(`Unsupported system message mode: ${g}`)}}break}case"user":{if(f.length===1&&f[0].type==="text"){o.push({role:"user",content:f[0].text});break}o.push({role:"user",content:f.map((g,m)=>{var y,x,A;switch(g.type){case"text":return{type:"text",text:g.text};case"file":if(g.mediaType.startsWith("image/")){const b=g.mediaType==="image/*"?"image/jpeg":g.mediaType;return{type:"image_url",image_url:{url:g.data instanceof URL?g.data.toString():`data:${b};base64,${Ir(g.data)}`,detail:(x=(y=g.providerOptions)==null?void 0:y.openai)==null?void 0:x.imageDetail}}}else if(g.mediaType.startsWith("audio/")){if(g.data instanceof URL)throw new Zn({functionality:"audio file parts with URLs"});switch(g.mediaType){case"audio/wav":return{type:"input_audio",input_audio:{data:Ir(g.data),format:"wav"}};case"audio/mp3":case"audio/mpeg":return{type:"input_audio",input_audio:{data:Ir(g.data),format:"mp3"}};default:throw new Zn({functionality:`audio content parts with media type ${g.mediaType}`})}}else if(g.mediaType==="application/pdf"){if(g.data instanceof URL)throw new Zn({functionality:"PDF file parts with URLs"});return{type:"file",file:typeof g.data=="string"&&g.data.startsWith("file-")?{file_id:g.data}:{filename:(A=g.filename)!=null?A:`part-${m}.pdf`,file_data:`data:application/pdf;base64,${Ir(g.data)}`}}}else throw new Zn({functionality:`file part media type ${g.mediaType}`})}})});break}case"assistant":{let g="";const m=[];for(const y of f)switch(y.type){case"text":{g+=y.text;break}case"tool-call":{m.push({id:y.toolCallId,type:"function",function:{name:y.toolName,arguments:JSON.stringify(y.input)}});break}}o.push({role:"assistant",content:g,tool_calls:m.length>0?m:void 0});break}case"tool":{for(const g of f){const m=g.output;let y;switch(m.type){case"text":case"error-text":y=m.value;break;case"content":case"json":case"error-json":y=JSON.stringify(m.value);break}o.push({role:"tool",tool_call_id:g.toolCallId,content:y})}break}default:{const g=u;throw new Error(`Unsupported role: ${g}`)}}return{messages:o,warnings:l}}function Mo({id:t,model:n,created:o}){return{id:t??void 0,modelId:n??void 0,timestamp:o?new Date(o*1e3):void 0}}function qa(t){switch(t){case"stop":return"stop";case"length":return"length";case"content_filter":return"content-filter";case"function_call":case"tool_calls":return"tool-calls";default:return"unknown"}}var Ym=Yt(()=>Ke(B({id:I().nullish(),created:W().nullish(),model:I().nullish(),choices:_e(B({message:B({role:re("assistant").nullish(),content:I().nullish(),tool_calls:_e(B({id:I().nullish(),type:re("function"),function:B({name:I(),arguments:I()})})).nullish(),annotations:_e(B({type:re("url_citation"),url_citation:B({start_index:W(),end_index:W(),url:I(),title:I()})})).nullish()}),index:W(),logprobs:B({content:_e(B({token:I(),logprob:W(),top_logprobs:_e(B({token:I(),logprob:W()}))})).nullish()}).nullish(),finish_reason:I().nullish()})),usage:B({prompt_tokens:W().nullish(),completion_tokens:W().nullish(),total_tokens:W().nullish(),prompt_tokens_details:B({cached_tokens:W().nullish()}).nullish(),completion_tokens_details:B({reasoning_tokens:W().nullish(),accepted_prediction_tokens:W().nullish(),rejected_prediction_tokens:W().nullish()}).nullish()}).nullish()}))),qm=Yt(()=>Ke(ut([B({id:I().nullish(),created:W().nullish(),model:I().nullish(),choices:_e(B({delta:B({role:pt(["assistant"]).nullish(),content:I().nullish(),tool_calls:_e(B({index:W(),id:I().nullish(),type:re("function").nullish(),function:B({name:I().nullish(),arguments:I().nullish()})})).nullish(),annotations:_e(B({type:re("url_citation"),url_citation:B({start_index:W(),end_index:W(),url:I(),title:I()})})).nullish()}).nullish(),logprobs:B({content:_e(B({token:I(),logprob:W(),top_logprobs:_e(B({token:I(),logprob:W()}))})).nullish()}).nullish(),finish_reason:I().nullish(),index:W()})),usage:B({prompt_tokens:W().nullish(),completion_tokens:W().nullish(),total_tokens:W().nullish(),prompt_tokens_details:B({cached_tokens:W().nullish()}).nullish(),completion_tokens_details:B({reasoning_tokens:W().nullish(),accepted_prediction_tokens:W().nullish(),rejected_prediction_tokens:W().nullish()}).nullish()}).nullish()}),ms]))),Km=Yt(()=>Ke(B({logitBias:Dt(wp(),W()).optional(),logprobs:ut([Ft(),W()]).optional(),parallelToolCalls:Ft().optional(),user:I().optional(),reasoningEffort:pt(["none","minimal","low","medium","high","xhigh"]).optional(),maxCompletionTokens:W().optional(),store:Ft().optional(),metadata:Dt(I().max(64),I().max(512)).optional(),prediction:Dt(I(),ai()).optional(),structuredOutputs:Ft().optional(),serviceTier:pt(["auto","flex","priority","default"]).optional(),strictJsonSchema:Ft().optional(),textVerbosity:pt(["low","medium","high"]).optional(),promptCacheKey:I().optional(),promptCacheRetention:pt(["in_memory","24h"]).optional(),safetyIdentifier:I().optional()})));function Jm({tools:t,toolChoice:n,structuredOutputs:o,strictJsonSchema:l}){t=t?.length?t:void 0;const u=[];if(t==null)return{tools:void 0,toolChoice:void 0,toolWarnings:u};const f=[];for(const m of t)switch(m.type){case"function":f.push({type:"function",function:{name:m.name,description:m.description,parameters:m.inputSchema,strict:o?l:void 0}});break;default:u.push({type:"unsupported-tool",tool:m});break}if(n==null)return{tools:f,toolChoice:void 0,toolWarnings:u};const g=n.type;switch(g){case"auto":case"none":case"required":return{tools:f,toolChoice:g,toolWarnings:u};case"tool":return{tools:f,toolChoice:{type:"function",function:{name:n.toolName}},toolWarnings:u};default:{const m=g;throw new Zn({functionality:`tool choice type: ${m}`})}}}var Qm=class{constructor(t,n){this.specificationVersion="v2",this.supportedUrls={"image/*":[/^https?:\/\/.*$/]},this.modelId=t,this.config=n}get provider(){return this.config.provider}async getArgs({prompt:t,maxOutputTokens:n,temperature:o,topP:l,topK:u,frequencyPenalty:f,presencePenalty:g,stopSequences:m,responseFormat:y,seed:x,tools:A,toolChoice:b,providerOptions:P}){var N,R,D,M;const z=[],U=(N=await nr({provider:"openai",providerOptions:P,schema:Km}))!=null?N:{},k=(R=U.structuredOutputs)!=null?R:!0,K=Lu(this.modelId);u!=null&&z.push({type:"unsupported-setting",setting:"topK"}),y?.type==="json"&&y.schema!=null&&!k&&z.push({type:"unsupported-setting",setting:"responseFormat",details:"JSON response format schema is only supported with structuredOutputs"});const{messages:ve,warnings:Q}=Xm({prompt:t,systemMessageMode:K.systemMessageMode});z.push(...Q);const j=(D=U.strictJsonSchema)!=null?D:!1,ie={model:this.modelId,logit_bias:U.logitBias,logprobs:U.logprobs===!0||typeof U.logprobs=="number"?!0:void 0,top_logprobs:typeof U.logprobs=="number"?U.logprobs:typeof U.logprobs=="boolean"&&U.logprobs?0:void 0,user:U.user,parallel_tool_calls:U.parallelToolCalls,max_tokens:n,temperature:o,top_p:l,frequency_penalty:f,presence_penalty:g,response_format:y?.type==="json"?k&&y.schema!=null?{type:"json_schema",json_schema:{schema:y.schema,strict:j,name:(M=y.name)!=null?M:"response",description:y.description}}:{type:"json_object"}:void 0,stop:m,seed:x,verbosity:U.textVerbosity,max_completion_tokens:U.maxCompletionTokens,store:U.store,metadata:U.metadata,prediction:U.prediction,reasoning_effort:U.reasoningEffort,service_tier:U.serviceTier,prompt_cache_key:U.promptCacheKey,prompt_cache_retention:U.promptCacheRetention,safety_identifier:U.safetyIdentifier,messages:ve};K.isReasoningModel?((U.reasoningEffort!=="none"||!K.supportsNonReasoningParameters)&&(ie.temperature!=null&&(ie.temperature=void 0,z.push({type:"unsupported-setting",setting:"temperature",details:"temperature is not supported for reasoning models"})),ie.top_p!=null&&(ie.top_p=void 0,z.push({type:"unsupported-setting",setting:"topP",details:"topP is not supported for reasoning models"})),ie.logprobs!=null&&(ie.logprobs=void 0,z.push({type:"other",message:"logprobs is not supported for reasoning models"}))),ie.frequency_penalty!=null&&(ie.frequency_penalty=void 0,z.push({type:"unsupported-setting",setting:"frequencyPenalty",details:"frequencyPenalty is not supported for reasoning models"})),ie.presence_penalty!=null&&(ie.presence_penalty=void 0,z.push({type:"unsupported-setting",setting:"presencePenalty",details:"presencePenalty is not supported for reasoning models"})),ie.logit_bias!=null&&(ie.logit_bias=void 0,z.push({type:"other",message:"logitBias is not supported for reasoning models"})),ie.top_logprobs!=null&&(ie.top_logprobs=void 0,z.push({type:"other",message:"topLogprobs is not supported for reasoning models"})),ie.max_tokens!=null&&(ie.max_completion_tokens==null&&(ie.max_completion_tokens=ie.max_tokens),ie.max_tokens=void 0)):(this.modelId.startsWith("gpt-4o-search-preview")||this.modelId.startsWith("gpt-4o-mini-search-preview"))&&ie.temperature!=null&&(ie.temperature=void 0,z.push({type:"unsupported-setting",setting:"temperature",details:"temperature is not supported for the search preview models and has been removed."})),U.serviceTier==="flex"&&!K.supportsFlexProcessing&&(z.push({type:"unsupported-setting",setting:"serviceTier",details:"flex processing is only available for o3, o4-mini, and gpt-5 models"}),ie.service_tier=void 0),U.serviceTier==="priority"&&!K.supportsPriorityProcessing&&(z.push({type:"unsupported-setting",setting:"serviceTier",details:"priority processing is only available for supported models (gpt-4, gpt-5, gpt-5-mini, o3, o4-mini) and requires Enterprise access. gpt-5-nano is not supported"}),ie.service_tier=void 0);const{tools:Y,toolChoice:Ie,toolWarnings:Ce}=Jm({tools:A,toolChoice:b,structuredOutputs:k,strictJsonSchema:j});return{args:{...ie,tools:Y,tool_choice:Ie},warnings:[...z,...Ce]}}async doGenerate(t){var n,o,l,u,f,g,m,y,x,A,b,P,N,R;const{args:D,warnings:M}=await this.getArgs(t),{responseHeaders:z,value:U,rawValue:k}=await Vn({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:Bn(this.config.headers(),t.headers),body:D,failedResponseHandler:Ln,successfulResponseHandler:Nr(Ym),abortSignal:t.abortSignal,fetch:this.config.fetch}),K=U.choices[0],ve=[],Q=K.message.content;Q!=null&&Q.length>0&&ve.push({type:"text",text:Q});for(const Ie of(n=K.message.tool_calls)!=null?n:[])ve.push({type:"tool-call",toolCallId:(o=Ie.id)!=null?o:Sn(),toolName:Ie.function.name,input:Ie.function.arguments});for(const Ie of(l=K.message.annotations)!=null?l:[])ve.push({type:"source",sourceType:"url",id:Sn(),url:Ie.url_citation.url,title:Ie.url_citation.title});const j=(u=U.usage)==null?void 0:u.completion_tokens_details,ie=(f=U.usage)==null?void 0:f.prompt_tokens_details,Y={openai:{}};return j?.accepted_prediction_tokens!=null&&(Y.openai.acceptedPredictionTokens=j?.accepted_prediction_tokens),j?.rejected_prediction_tokens!=null&&(Y.openai.rejectedPredictionTokens=j?.rejected_prediction_tokens),((g=K.logprobs)==null?void 0:g.content)!=null&&(Y.openai.logprobs=K.logprobs.content),{content:ve,finishReason:qa(K.finish_reason),usage:{inputTokens:(y=(m=U.usage)==null?void 0:m.prompt_tokens)!=null?y:void 0,outputTokens:(A=(x=U.usage)==null?void 0:x.completion_tokens)!=null?A:void 0,totalTokens:(P=(b=U.usage)==null?void 0:b.total_tokens)!=null?P:void 0,reasoningTokens:(N=j?.reasoning_tokens)!=null?N:void 0,cachedInputTokens:(R=ie?.cached_tokens)!=null?R:void 0},request:{body:D},response:{...Mo(U),headers:z,body:k},warnings:M,providerMetadata:Y}}async doStream(t){const{args:n,warnings:o}=await this.getArgs(t),l={...n,stream:!0,stream_options:{include_usage:!0}},{responseHeaders:u,value:f}=await Vn({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:Bn(this.config.headers(),t.headers),body:l,failedResponseHandler:Ln,successfulResponseHandler:gs(qm),abortSignal:t.abortSignal,fetch:this.config.fetch}),g=[];let m="unknown";const y={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0};let x=!1,A=!1;const b={openai:{}};return{stream:f.pipeThrough(new TransformStream({start(P){P.enqueue({type:"stream-start",warnings:o})},transform(P,N){var R,D,M,z,U,k,K,ve,Q,j,ie,Y,Ie,Ce,he,xe,le,F,J,X,te,pe,ge,ye;if(t.includeRawChunks&&N.enqueue({type:"raw",rawValue:P.rawValue}),!P.success){m="error",N.enqueue({type:"error",error:P.error});return}const we=P.value;if("error"in we){m="error",N.enqueue({type:"error",error:we.error});return}if(!x){const ne=Mo(we);Object.values(ne).some(Boolean)&&(x=!0,N.enqueue({type:"response-metadata",...Mo(we)}))}we.usage!=null&&(y.inputTokens=(R=we.usage.prompt_tokens)!=null?R:void 0,y.outputTokens=(D=we.usage.completion_tokens)!=null?D:void 0,y.totalTokens=(M=we.usage.total_tokens)!=null?M:void 0,y.reasoningTokens=(U=(z=we.usage.completion_tokens_details)==null?void 0:z.reasoning_tokens)!=null?U:void 0,y.cachedInputTokens=(K=(k=we.usage.prompt_tokens_details)==null?void 0:k.cached_tokens)!=null?K:void 0,((ve=we.usage.completion_tokens_details)==null?void 0:ve.accepted_prediction_tokens)!=null&&(b.openai.acceptedPredictionTokens=(Q=we.usage.completion_tokens_details)==null?void 0:Q.accepted_prediction_tokens),((j=we.usage.completion_tokens_details)==null?void 0:j.rejected_prediction_tokens)!=null&&(b.openai.rejectedPredictionTokens=(ie=we.usage.completion_tokens_details)==null?void 0:ie.rejected_prediction_tokens));const Fe=we.choices[0];if(Fe?.finish_reason!=null&&(m=qa(Fe.finish_reason)),((Y=Fe?.logprobs)==null?void 0:Y.content)!=null&&(b.openai.logprobs=Fe.logprobs.content),Fe?.delta==null)return;const Pe=Fe.delta;if(Pe.content!=null&&(A||(N.enqueue({type:"text-start",id:"0"}),A=!0),N.enqueue({type:"text-delta",id:"0",delta:Pe.content})),Pe.tool_calls!=null)for(const ne of Pe.tool_calls){const S=ne.index;if(g[S]==null){if(ne.type!=="function")throw new ko({data:ne,message:"Expected 'function' type."});if(ne.id==null)throw new ko({data:ne,message:"Expected 'id' to be a string."});if(((Ie=ne.function)==null?void 0:Ie.name)==null)throw new ko({data:ne,message:"Expected 'function.name' to be a string."});N.enqueue({type:"tool-input-start",id:ne.id,toolName:ne.function.name}),g[S]={id:ne.id,type:"function",function:{name:ne.function.name,arguments:(Ce=ne.function.arguments)!=null?Ce:""},hasFinished:!1};const se=g[S];((he=se.function)==null?void 0:he.name)!=null&&((xe=se.function)==null?void 0:xe.arguments)!=null&&(se.function.arguments.length>0&&N.enqueue({type:"tool-input-delta",id:se.id,delta:se.function.arguments}),Ga(se.function.arguments)&&(N.enqueue({type:"tool-input-end",id:se.id}),N.enqueue({type:"tool-call",toolCallId:(le=se.id)!=null?le:Sn(),toolName:se.function.name,input:se.function.arguments}),se.hasFinished=!0));continue}const fe=g[S];fe.hasFinished||(((F=ne.function)==null?void 0:F.arguments)!=null&&(fe.function.arguments+=(X=(J=ne.function)==null?void 0:J.arguments)!=null?X:""),N.enqueue({type:"tool-input-delta",id:fe.id,delta:(te=ne.function.arguments)!=null?te:""}),((pe=fe.function)==null?void 0:pe.name)!=null&&((ge=fe.function)==null?void 0:ge.arguments)!=null&&Ga(fe.function.arguments)&&(N.enqueue({type:"tool-input-end",id:fe.id}),N.enqueue({type:"tool-call",toolCallId:(ye=fe.id)!=null?ye:Sn(),toolName:fe.function.name,input:fe.function.arguments}),fe.hasFinished=!0))}if(Pe.annotations!=null)for(const ne of Pe.annotations)N.enqueue({type:"source",sourceType:"url",id:Sn(),url:ne.url_citation.url,title:ne.url_citation.title})},flush(P){A&&P.enqueue({type:"text-end",id:"0"}),P.enqueue({type:"finish",finishReason:m,usage:y,...b!=null?{providerMetadata:b}:{}})}})),request:{body:l},response:{headers:u}}}};function ex({prompt:t,user:n="user",assistant:o="assistant"}){let l="";t[0].role==="system"&&(l+=`${t[0].content}
42
+ `)}})}});function $g(t){const r=["ROOT"];let o=-1,l=null;function u(y,m,E){switch(y){case'"':{o=m,r.pop(),r.push(E),r.push("INSIDE_STRING");break}case"f":case"t":case"n":{o=m,l=m,r.pop(),r.push(E),r.push("INSIDE_LITERAL");break}case"-":{r.pop(),r.push(E),r.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{o=m,r.pop(),r.push(E),r.push("INSIDE_NUMBER");break}case"{":{o=m,r.pop(),r.push(E),r.push("INSIDE_OBJECT_START");break}case"[":{o=m,r.pop(),r.push(E),r.push("INSIDE_ARRAY_START");break}}}function f(y,m){switch(y){case",":{r.pop(),r.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{o=m,r.pop();break}}}function g(y,m){switch(y){case",":{r.pop(),r.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{o=m,r.pop();break}}}for(let y=0;y<t.length;y++){const m=t[y];switch(r[r.length-1]){case"ROOT":u(m,y,"FINISH");break;case"INSIDE_OBJECT_START":{switch(m){case'"':{r.pop(),r.push("INSIDE_OBJECT_KEY");break}case"}":{o=y,r.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(m){case'"':{r.pop(),r.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(m){case'"':{r.pop(),r.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(m){case":":{r.pop(),r.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{u(m,y,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{f(m,y);break}case"INSIDE_STRING":{switch(m){case'"':{r.pop(),o=y;break}case"\\":{r.push("INSIDE_STRING_ESCAPE");break}default:o=y}break}case"INSIDE_ARRAY_START":{switch(m){case"]":{o=y,r.pop();break}default:{o=y,u(m,y,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(m){case",":{r.pop(),r.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{o=y,r.pop();break}default:{o=y;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{u(m,y,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{r.pop(),o=y;break}case"INSIDE_NUMBER":{switch(m){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{o=y;break}case"e":case"E":case"-":case".":break;case",":{r.pop(),r[r.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&g(m,y),r[r.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&f(m,y);break}case"}":{r.pop(),r[r.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&f(m,y);break}case"]":{r.pop(),r[r.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&g(m,y);break}default:{r.pop();break}}break}case"INSIDE_LITERAL":{const C=t.substring(l,y+1);!"false".startsWith(C)&&!"true".startsWith(C)&&!"null".startsWith(C)?(r.pop(),r[r.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?f(m,y):r[r.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&g(m,y)):o=y;break}}}let x=t.slice(0,o+1);for(let y=r.length-1;y>=0;y--)switch(r[y]){case"INSIDE_STRING":{x+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{x+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{x+="]";break}case"INSIDE_LITERAL":{const E=t.substring(l,t.length);"true".startsWith(E)?x+="true".slice(E.length):"false".startsWith(E)?x+="false".slice(E.length):"null".startsWith(E)&&(x+="null".slice(E.length))}}return x}async function Ug(t){if(t===void 0)return{value:void 0,state:"undefined-input"};let r=await Yr({text:t});return r.success?{value:r.value,state:"successful-parse"}:(r=await Yr({text:$g(t)}),r.success?{value:r.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}ii({prefix:"aitxt",size:24});ii({prefix:"aiobj",size:24});ii({prefix:"aiobj",size:24});var zg={};Ng(zg,{object:()=>Zg,text:()=>Vg});var Vg=()=>({type:"text",responseFormat:{type:"text"},async parsePartial({text:t}){return{partial:t}},async parseOutput({text:t}){return t}}),Zg=({schema:t})=>{const r=Cg(t);return{type:"object",responseFormat:{type:"json",schema:r.jsonSchema},async parsePartial({text:o}){const l=await Ug(o);switch(l.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:l.value};default:{const u=l.state;throw new Error(`Unsupported parse state: ${u}`)}}},async parseOutput({text:o},l){const u=await Yr({text:o});if(!u.success)throw new fa({message:"No object generated: could not parse the response.",cause:u.error,text:o,response:l.response,usage:l.usage,finishReason:l.finishReason});const f=await Cr({value:u.value,schema:r});if(!f.success)throw new fa({message:"No object generated: response did not match schema.",cause:f.error,text:o,response:l.response,usage:l.usage,finishReason:l.finishReason});return f.value}}},ki={exports:{}},jg=ki.exports,ha;function Hg(){return ha||(ha=1,(function(t,r){(function(o,l){t.exports=l()})(jg,(function(){var o=1e3,l=6e4,u=36e5,f="millisecond",g="second",x="minute",y="hour",m="day",E="week",C="month",P="quarter",O="year",D="date",R="Invalid Date",M=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,V=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,U={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(le){var L=["th","st","nd","rd"],te=le%100;return"["+le+(L[(te-20)%10]||L[te]||L[0])+"]"}},k=function(le,L,te){var K=String(le);return!K||K.length>=L?le:""+Array(L+1-K.length).join(te)+le},J={s:k,z:function(le){var L=-le.utcOffset(),te=Math.abs(L),K=Math.floor(te/60),ne=te%60;return(L<=0?"+":"-")+k(K,2,"0")+":"+k(ne,2,"0")},m:function le(L,te){if(L.date()<te.date())return-le(te,L);var K=12*(te.year()-L.year())+(te.month()-L.month()),ne=L.clone().add(K,C),fe=te-ne<0,xe=L.clone().add(K+(fe?-1:1),C);return+(-(K+(te-ne)/(fe?ne-xe:xe-ne))||0)},a:function(le){return le<0?Math.ceil(le)||0:Math.floor(le)},p:function(le){return{M:C,y:O,w:E,d:m,D,h:y,m:x,s:g,ms:f,Q:P}[le]||String(le||"").toLowerCase().replace(/s$/,"")},u:function(le){return le===void 0}},be="en",Z={};Z[be]=U;var z="$isDayjsObject",Y=function(le){return le instanceof pe||!(!le||!le[z])},W=function le(L,te,K){var ne;if(!L)return be;if(typeof L=="string"){var fe=L.toLowerCase();Z[fe]&&(ne=fe),te&&(Z[fe]=te,ne=fe);var xe=L.split("-");if(!ne&&xe.length>1)return le(xe[0])}else{var ye=L.name;Z[ye]=L,ne=ye}return!K&&ne&&(be=ne),ne||!K&&be},de=function(le,L){if(Y(le))return le.clone();var te=typeof L=="object"?L:{};return te.date=le,te.args=arguments,new pe(te)},me=J;me.l=W,me.i=Y,me.w=function(le,L){return de(le,{locale:L.$L,utc:L.$u,x:L.$x,$offset:L.$offset})};var pe=(function(){function le(te){this.$L=W(te.locale,null,!0),this.parse(te),this.$x=this.$x||te.x||{},this[z]=!0}var L=le.prototype;return L.parse=function(te){this.$d=(function(K){var ne=K.date,fe=K.utc;if(ne===null)return new Date(NaN);if(me.u(ne))return new Date;if(ne instanceof Date)return new Date(ne);if(typeof ne=="string"&&!/Z$/i.test(ne)){var xe=ne.match(M);if(xe){var ye=xe[2]-1||0,ee=(xe[7]||"0").substring(0,3);return fe?new Date(Date.UTC(xe[1],ye,xe[3]||1,xe[4]||0,xe[5]||0,xe[6]||0,ee)):new Date(xe[1],ye,xe[3]||1,xe[4]||0,xe[5]||0,xe[6]||0,ee)}}return new Date(ne)})(te),this.init()},L.init=function(){var te=this.$d;this.$y=te.getFullYear(),this.$M=te.getMonth(),this.$D=te.getDate(),this.$W=te.getDay(),this.$H=te.getHours(),this.$m=te.getMinutes(),this.$s=te.getSeconds(),this.$ms=te.getMilliseconds()},L.$utils=function(){return me},L.isValid=function(){return this.$d.toString()!==R},L.isSame=function(te,K){var ne=de(te);return this.startOf(K)<=ne&&ne<=this.endOf(K)},L.isAfter=function(te,K){return de(te)<this.startOf(K)},L.isBefore=function(te,K){return this.endOf(K)<de(te)},L.$g=function(te,K,ne){return me.u(te)?this[K]:this.set(ne,te)},L.unix=function(){return Math.floor(this.valueOf()/1e3)},L.valueOf=function(){return this.$d.getTime()},L.startOf=function(te,K){var ne=this,fe=!!me.u(K)||K,xe=me.p(te),ye=function(mt,ot){var Qe=me.w(ne.$u?Date.UTC(ne.$y,ot,mt):new Date(ne.$y,ot,mt),ne);return fe?Qe:Qe.endOf(m)},ee=function(mt,ot){return me.w(ne.toDate()[mt].apply(ne.toDate("s"),(fe?[0,0,0,0]:[23,59,59,999]).slice(ot)),ne)},he=this.$W,Ee=this.$M,_e=this.$D,T="set"+(this.$u?"UTC":"");switch(xe){case O:return fe?ye(1,0):ye(31,11);case C:return fe?ye(1,Ee):ye(0,Ee+1);case E:var ce=this.$locale().weekStart||0,we=(he<ce?he+7:he)-ce;return ye(fe?_e-we:_e+(6-we),Ee);case m:case D:return ee(T+"Hours",0);case y:return ee(T+"Minutes",1);case x:return ee(T+"Seconds",2);case g:return ee(T+"Milliseconds",3);default:return this.clone()}},L.endOf=function(te){return this.startOf(te,!1)},L.$set=function(te,K){var ne,fe=me.p(te),xe="set"+(this.$u?"UTC":""),ye=(ne={},ne[m]=xe+"Date",ne[D]=xe+"Date",ne[C]=xe+"Month",ne[O]=xe+"FullYear",ne[y]=xe+"Hours",ne[x]=xe+"Minutes",ne[g]=xe+"Seconds",ne[f]=xe+"Milliseconds",ne)[fe],ee=fe===m?this.$D+(K-this.$W):K;if(fe===C||fe===O){var he=this.clone().set(D,1);he.$d[ye](ee),he.init(),this.$d=he.set(D,Math.min(this.$D,he.daysInMonth())).$d}else ye&&this.$d[ye](ee);return this.init(),this},L.set=function(te,K){return this.clone().$set(te,K)},L.get=function(te){return this[me.p(te)]()},L.add=function(te,K){var ne,fe=this;te=Number(te);var xe=me.p(K),ye=function(Ee){var _e=de(fe);return me.w(_e.date(_e.date()+Math.round(Ee*te)),fe)};if(xe===C)return this.set(C,this.$M+te);if(xe===O)return this.set(O,this.$y+te);if(xe===m)return ye(1);if(xe===E)return ye(7);var ee=(ne={},ne[x]=l,ne[y]=u,ne[g]=o,ne)[xe]||1,he=this.$d.getTime()+te*ee;return me.w(he,this)},L.subtract=function(te,K){return this.add(-1*te,K)},L.format=function(te){var K=this,ne=this.$locale();if(!this.isValid())return ne.invalidDate||R;var fe=te||"YYYY-MM-DDTHH:mm:ssZ",xe=me.z(this),ye=this.$H,ee=this.$m,he=this.$M,Ee=ne.weekdays,_e=ne.months,T=ne.meridiem,ce=function(ot,Qe,an,Fe){return ot&&(ot[Qe]||ot(K,fe))||an[Qe].slice(0,Fe)},we=function(ot){return me.s(ye%12||12,ot,"0")},mt=T||function(ot,Qe,an){var Fe=ot<12?"AM":"PM";return an?Fe.toLowerCase():Fe};return fe.replace(V,(function(ot,Qe){return Qe||(function(an){switch(an){case"YY":return String(K.$y).slice(-2);case"YYYY":return me.s(K.$y,4,"0");case"M":return he+1;case"MM":return me.s(he+1,2,"0");case"MMM":return ce(ne.monthsShort,he,_e,3);case"MMMM":return ce(_e,he);case"D":return K.$D;case"DD":return me.s(K.$D,2,"0");case"d":return String(K.$W);case"dd":return ce(ne.weekdaysMin,K.$W,Ee,2);case"ddd":return ce(ne.weekdaysShort,K.$W,Ee,3);case"dddd":return Ee[K.$W];case"H":return String(ye);case"HH":return me.s(ye,2,"0");case"h":return we(1);case"hh":return we(2);case"a":return mt(ye,ee,!0);case"A":return mt(ye,ee,!1);case"m":return String(ee);case"mm":return me.s(ee,2,"0");case"s":return String(K.$s);case"ss":return me.s(K.$s,2,"0");case"SSS":return me.s(K.$ms,3,"0");case"Z":return xe}return null})(ot)||xe.replace(":","")}))},L.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},L.diff=function(te,K,ne){var fe,xe=this,ye=me.p(K),ee=de(te),he=(ee.utcOffset()-this.utcOffset())*l,Ee=this-ee,_e=function(){return me.m(xe,ee)};switch(ye){case O:fe=_e()/12;break;case C:fe=_e();break;case P:fe=_e()/3;break;case E:fe=(Ee-he)/6048e5;break;case m:fe=(Ee-he)/864e5;break;case y:fe=Ee/u;break;case x:fe=Ee/l;break;case g:fe=Ee/o;break;default:fe=Ee}return ne?fe:me.a(fe)},L.daysInMonth=function(){return this.endOf(C).$D},L.$locale=function(){return Z[this.$L]},L.locale=function(te,K){if(!te)return this.$L;var ne=this.clone(),fe=W(te,K,!0);return fe&&(ne.$L=fe),ne},L.clone=function(){return me.w(this.$d,this)},L.toDate=function(){return new Date(this.valueOf())},L.toJSON=function(){return this.isValid()?this.toISOString():null},L.toISOString=function(){return this.$d.toISOString()},L.toString=function(){return this.$d.toUTCString()},le})(),Ce=pe.prototype;return de.prototype=Ce,[["$ms",f],["$s",g],["$m",x],["$H",y],["$W",m],["$M",C],["$y",O],["$D",D]].forEach((function(le){Ce[le[1]]=function(L){return this.$g(L,le[0],le[1])}})),de.extend=function(le,L){return le.$i||(le(L,pe,de),le.$i=!0),de},de.locale=W,de.isDayjs=Y,de.unix=function(le){return de(1e3*le)},de.en=Z[be],de.Ls=Z,de.p={},de}))})(ki)),ki.exports}var Wg=Hg();const Gg=Uc(Wg),Xg={description:"获取今天的日期",inputSchema:Hi.z.object({}),execute:()=>({date:`当前日期: ${Gg().format("YYYY-M-D")}`})};function Lr(t){var r,o;return(o=(r=t?.providerOptions)==null?void 0:r.openaiCompatible)!=null?o:{}}function qg(t){const r=[];for(const{role:o,content:l,...u}of t){const f=Lr({...u});switch(o){case"system":{r.push({role:"system",content:l,...f});break}case"user":{if(l.length===1&&l[0].type==="text"){r.push({role:"user",content:l[0].text,...Lr(l[0])});break}r.push({role:"user",content:l.map(g=>{const x=Lr(g);switch(g.type){case"text":return{type:"text",text:g.text,...x};case"file":if(g.mediaType.startsWith("image/")){const y=g.mediaType==="image/*"?"image/jpeg":g.mediaType;return{type:"image_url",image_url:{url:g.data instanceof URL?g.data.toString():`data:${y};base64,${Ig(g.data)}`},...x}}else throw new ac({functionality:`file part media type ${g.mediaType}`})}}),...f});break}case"assistant":{let g="";const x=[];for(const y of l){const m=Lr(y);switch(y.type){case"text":{g+=y.text;break}case"tool-call":{x.push({id:y.toolCallId,type:"function",function:{name:y.toolName,arguments:JSON.stringify(y.input)},...m});break}}}r.push({role:"assistant",content:g,tool_calls:x.length>0?x:void 0,...f});break}case"tool":{for(const g of l){const x=g.output;let y;switch(x.type){case"text":case"error-text":y=x.value;break;case"content":case"json":case"error-json":y=JSON.stringify(x.value);break}const m=Lr(g);r.push({role:"tool",tool_call_id:g.toolCallId,content:y,...m})}break}default:{const g=o;throw new Error(`Unsupported role: ${g}`)}}}return r}function pa({id:t,model:r,created:o}){return{id:t??void 0,modelId:r??void 0,timestamp:o!=null?new Date(o*1e3):void 0}}function ga(t){switch(t){case"stop":return"stop";case"length":return"length";case"content_filter":return"content-filter";case"function_call":case"tool_calls":return"tool-calls";default:return"unknown"}}var Eo=B({user:I().optional(),reasoningEffort:I().optional(),textVerbosity:I().optional()}),Yg=B({error:B({message:I(),type:I().nullish(),param:ri().nullish(),code:lt([I(),X()]).nullish()})}),Kg={errorSchema:Yg,errorToMessage:t=>t.error.message};function Jg({tools:t,toolChoice:r}){t=t?.length?t:void 0;const o=[];if(t==null)return{tools:void 0,toolChoice:void 0,toolWarnings:o};const l=[];for(const f of t)f.type==="provider-defined"?o.push({type:"unsupported-tool",tool:f}):l.push({type:"function",function:{name:f.name,description:f.description,parameters:f.inputSchema}});if(r==null)return{tools:l,toolChoice:void 0,toolWarnings:o};const u=r.type;switch(u){case"auto":case"none":case"required":return{tools:l,toolChoice:u,toolWarnings:o};case"tool":return{tools:l,toolChoice:{type:"function",function:{name:r.toolName}},toolWarnings:o};default:{const f=u;throw new ac({functionality:`tool choice type: ${f}`})}}}var Qg=class{constructor(t,r){this.specificationVersion="v2";var o,l;this.modelId=t,this.config=r;const u=(o=r.errorStructure)!=null?o:Kg;this.chunkSchema=tm(u.errorSchema),this.failedResponseHandler=Tp(u),this.supportsStructuredOutputs=(l=r.supportsStructuredOutputs)!=null?l:!1}get provider(){return this.config.provider}get providerOptionsName(){return this.config.provider.split(".")[0].trim()}get supportedUrls(){var t,r,o;return(o=(r=(t=this.config).supportedUrls)==null?void 0:r.call(t))!=null?o:{}}async getArgs({prompt:t,maxOutputTokens:r,temperature:o,topP:l,topK:u,frequencyPenalty:f,presencePenalty:g,providerOptions:x,stopSequences:y,responseFormat:m,seed:E,toolChoice:C,tools:P}){var O,D,R,M;const V=[],U=Object.assign((O=await la({provider:"openai-compatible",providerOptions:x,schema:Eo}))!=null?O:{},(D=await la({provider:this.providerOptionsName,providerOptions:x,schema:Eo}))!=null?D:{});u!=null&&V.push({type:"unsupported-setting",setting:"topK"}),m?.type==="json"&&m.schema!=null&&!this.supportsStructuredOutputs&&V.push({type:"unsupported-setting",setting:"responseFormat",details:"JSON response format schema is only supported with structuredOutputs"});const{tools:k,toolChoice:J,toolWarnings:be}=Jg({tools:P,toolChoice:C});return{args:{model:this.modelId,user:U.user,max_tokens:r,temperature:o,top_p:l,frequency_penalty:f,presence_penalty:g,response_format:m?.type==="json"?this.supportsStructuredOutputs===!0&&m.schema!=null?{type:"json_schema",json_schema:{schema:m.schema,name:(R=m.name)!=null?R:"response",description:m.description}}:{type:"json_object"}:void 0,stop:y,seed:E,...Object.fromEntries(Object.entries((M=x?.[this.providerOptionsName])!=null?M:{}).filter(([Z])=>!Object.keys(Eo.shape).includes(Z))),reasoning_effort:U.reasoningEffort,verbosity:U.textVerbosity,messages:qg(t),tools:k,tool_choice:J},warnings:[...V,...be]}}async doGenerate(t){var r,o,l,u,f,g,x,y,m,E,C,P,O,D,R,M,V;const{args:U,warnings:k}=await this.getArgs({...t}),J=JSON.stringify(U),{responseHeaders:be,value:Z,rawValue:z}=await ca({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:oa(this.config.headers(),t.headers),body:U,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:Op(em),abortSignal:t.abortSignal,fetch:this.config.fetch}),Y=Z.choices[0],W=[],de=Y.message.content;de!=null&&de.length>0&&W.push({type:"text",text:de});const me=(r=Y.message.reasoning_content)!=null?r:Y.message.reasoning;if(me!=null&&me.length>0&&W.push({type:"reasoning",text:me}),Y.message.tool_calls!=null)for(const le of Y.message.tool_calls)W.push({type:"tool-call",toolCallId:(o=le.id)!=null?o:vi(),toolName:le.function.name,input:le.function.arguments});const pe={[this.providerOptionsName]:{},...await((u=(l=this.config.metadataExtractor)==null?void 0:l.extractMetadata)==null?void 0:u.call(l,{parsedBody:z}))},Ce=(f=Z.usage)==null?void 0:f.completion_tokens_details;return Ce?.accepted_prediction_tokens!=null&&(pe[this.providerOptionsName].acceptedPredictionTokens=Ce?.accepted_prediction_tokens),Ce?.rejected_prediction_tokens!=null&&(pe[this.providerOptionsName].rejectedPredictionTokens=Ce?.rejected_prediction_tokens),{content:W,finishReason:ga(Y.finish_reason),usage:{inputTokens:(x=(g=Z.usage)==null?void 0:g.prompt_tokens)!=null?x:void 0,outputTokens:(m=(y=Z.usage)==null?void 0:y.completion_tokens)!=null?m:void 0,totalTokens:(C=(E=Z.usage)==null?void 0:E.total_tokens)!=null?C:void 0,reasoningTokens:(D=(O=(P=Z.usage)==null?void 0:P.completion_tokens_details)==null?void 0:O.reasoning_tokens)!=null?D:void 0,cachedInputTokens:(V=(M=(R=Z.usage)==null?void 0:R.prompt_tokens_details)==null?void 0:M.cached_tokens)!=null?V:void 0},providerMetadata:pe,request:{body:J},response:{...pa(Z),headers:be,body:z},warnings:k}}async doStream(t){var r;const{args:o,warnings:l}=await this.getArgs({...t}),u={...o,stream:!0,stream_options:this.config.includeUsage?{include_usage:!0}:void 0},f=(r=this.config.metadataExtractor)==null?void 0:r.createStreamExtractor(),{responseHeaders:g,value:x}=await ca({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:oa(this.config.headers(),t.headers),body:u,failedResponseHandler:this.failedResponseHandler,successfulResponseHandler:Np(this.chunkSchema),abortSignal:t.abortSignal,fetch:this.config.fetch}),y=[];let m="unknown";const E={completionTokens:void 0,completionTokensDetails:{reasoningTokens:void 0,acceptedPredictionTokens:void 0,rejectedPredictionTokens:void 0},promptTokens:void 0,promptTokensDetails:{cachedTokens:void 0},totalTokens:void 0};let C=!0;const P=this.providerOptionsName;let O=!1,D=!1;return{stream:x.pipeThrough(new TransformStream({start(R){R.enqueue({type:"stream-start",warnings:l})},transform(R,M){var V,U,k,J,be,Z,z,Y,W,de,me,pe,Ce;if(t.includeRawChunks&&M.enqueue({type:"raw",rawValue:R.rawValue}),!R.success){m="error",M.enqueue({type:"error",error:R.error});return}const le=R.value;if(f?.processChunk(R.rawValue),"error"in le){m="error",M.enqueue({type:"error",error:le.error.message});return}if(C&&(C=!1,M.enqueue({type:"response-metadata",...pa(le)})),le.usage!=null){const{prompt_tokens:ne,completion_tokens:fe,total_tokens:xe,prompt_tokens_details:ye,completion_tokens_details:ee}=le.usage;E.promptTokens=ne??void 0,E.completionTokens=fe??void 0,E.totalTokens=xe??void 0,ee?.reasoning_tokens!=null&&(E.completionTokensDetails.reasoningTokens=ee?.reasoning_tokens),ee?.accepted_prediction_tokens!=null&&(E.completionTokensDetails.acceptedPredictionTokens=ee?.accepted_prediction_tokens),ee?.rejected_prediction_tokens!=null&&(E.completionTokensDetails.rejectedPredictionTokens=ee?.rejected_prediction_tokens),ye?.cached_tokens!=null&&(E.promptTokensDetails.cachedTokens=ye?.cached_tokens)}const L=le.choices[0];if(L?.finish_reason!=null&&(m=ga(L.finish_reason)),L?.delta==null)return;const te=L.delta,K=(V=te.reasoning_content)!=null?V:te.reasoning;if(K&&(O||(M.enqueue({type:"reasoning-start",id:"reasoning-0"}),O=!0),M.enqueue({type:"reasoning-delta",id:"reasoning-0",delta:K})),te.content&&(D||(M.enqueue({type:"text-start",id:"txt-0"}),D=!0),M.enqueue({type:"text-delta",id:"txt-0",delta:te.content})),te.tool_calls!=null)for(const ne of te.tool_calls){const fe=ne.index;if(y[fe]==null){if(ne.id==null)throw new Bs({data:ne,message:"Expected 'id' to be a string."});if(((U=ne.function)==null?void 0:U.name)==null)throw new Bs({data:ne,message:"Expected 'function.name' to be a string."});M.enqueue({type:"tool-input-start",id:ne.id,toolName:ne.function.name}),y[fe]={id:ne.id,type:"function",function:{name:ne.function.name,arguments:(k=ne.function.arguments)!=null?k:""},hasFinished:!1};const ye=y[fe];((J=ye.function)==null?void 0:J.name)!=null&&((be=ye.function)==null?void 0:be.arguments)!=null&&(ye.function.arguments.length>0&&M.enqueue({type:"tool-input-delta",id:ye.id,delta:ye.function.arguments}),aa(ye.function.arguments)&&(M.enqueue({type:"tool-input-end",id:ye.id}),M.enqueue({type:"tool-call",toolCallId:(Z=ye.id)!=null?Z:vi(),toolName:ye.function.name,input:ye.function.arguments}),ye.hasFinished=!0));continue}const xe=y[fe];xe.hasFinished||(((z=ne.function)==null?void 0:z.arguments)!=null&&(xe.function.arguments+=(W=(Y=ne.function)==null?void 0:Y.arguments)!=null?W:""),M.enqueue({type:"tool-input-delta",id:xe.id,delta:(de=ne.function.arguments)!=null?de:""}),((me=xe.function)==null?void 0:me.name)!=null&&((pe=xe.function)==null?void 0:pe.arguments)!=null&&aa(xe.function.arguments)&&(M.enqueue({type:"tool-input-end",id:xe.id}),M.enqueue({type:"tool-call",toolCallId:(Ce=xe.id)!=null?Ce:vi(),toolName:xe.function.name,input:xe.function.arguments}),xe.hasFinished=!0))}},flush(R){var M,V,U,k,J,be;O&&R.enqueue({type:"reasoning-end",id:"reasoning-0"}),D&&R.enqueue({type:"text-end",id:"txt-0"});for(const z of y.filter(Y=>!Y.hasFinished))R.enqueue({type:"tool-input-end",id:z.id}),R.enqueue({type:"tool-call",toolCallId:(M=z.id)!=null?M:vi(),toolName:z.function.name,input:z.function.arguments});const Z={[P]:{},...f?.buildMetadata()};E.completionTokensDetails.acceptedPredictionTokens!=null&&(Z[P].acceptedPredictionTokens=E.completionTokensDetails.acceptedPredictionTokens),E.completionTokensDetails.rejectedPredictionTokens!=null&&(Z[P].rejectedPredictionTokens=E.completionTokensDetails.rejectedPredictionTokens),R.enqueue({type:"finish",finishReason:m,usage:{inputTokens:(V=E.promptTokens)!=null?V:void 0,outputTokens:(U=E.completionTokens)!=null?U:void 0,totalTokens:(k=E.totalTokens)!=null?k:void 0,reasoningTokens:(J=E.completionTokensDetails.reasoningTokens)!=null?J:void 0,cachedInputTokens:(be=E.promptTokensDetails.cachedTokens)!=null?be:void 0},providerMetadata:Z})}})),request:{body:u},response:{headers:g}}}},Xc=B({prompt_tokens:X().nullish(),completion_tokens:X().nullish(),total_tokens:X().nullish(),prompt_tokens_details:B({cached_tokens:X().nullish()}).nullish(),completion_tokens_details:B({reasoning_tokens:X().nullish(),accepted_prediction_tokens:X().nullish(),rejected_prediction_tokens:X().nullish()}).nullish()}).nullish(),em=B({id:I().nullish(),created:X().nullish(),model:I().nullish(),choices:ve(B({message:B({role:ie("assistant").nullish(),content:I().nullish(),reasoning_content:I().nullish(),reasoning:I().nullish(),tool_calls:ve(B({id:I().nullish(),function:B({name:I(),arguments:I()})})).nullish()}),finish_reason:I().nullish()})),usage:Xc}),tm=t=>lt([B({id:I().nullish(),created:X().nullish(),model:I().nullish(),choices:ve(B({delta:B({role:ft(["assistant"]).nullish(),content:I().nullish(),reasoning_content:I().nullish(),reasoning:I().nullish(),tool_calls:ve(B({index:X(),id:I().nullish(),function:B({name:I().nullish(),arguments:I().nullish()})})).nullish()}).nullish(),finish_reason:I().nullish()})),usage:Xc}),t]);B({echo:$t().optional(),logitBias:Dt(I(),X()).optional(),suffix:I().optional(),user:I().optional()});var nm=B({prompt_tokens:X(),completion_tokens:X(),total_tokens:X()});B({id:I().nullish(),created:X().nullish(),model:I().nullish(),choices:ve(B({text:I(),finish_reason:I()})),usage:nm.nullish()});B({dimensions:X().optional(),user:I().optional()});B({data:ve(B({embedding:ve(X())})),usage:B({prompt_tokens:X()}).nullish(),providerMetadata:Dt(I(),Dt(I(),ri())).optional()});B({data:ve(B({b64_json:I()}))});var ma=t=>{var r,o;return t==null?void 0:{deepseek:{promptCacheHitTokens:(r=t.prompt_cache_hit_tokens)!=null?r:NaN,promptCacheMissTokens:(o=t.prompt_cache_miss_tokens)!=null?o:NaN}}},rm={extractMetadata:async({parsedBody:t})=>{const r=await Cr({value:t,schema:im});return!r.success||r.value.usage==null?void 0:ma(r.value.usage)},createStreamExtractor:()=>{let t;return{processChunk:async r=>{var o,l;const u=await Cr({value:r,schema:om});u.success&&((l=(o=u.value.choices)==null?void 0:o[0])==null?void 0:l.finish_reason)==="stop"&&u.value.usage&&(t=u.value.usage)},buildMetadata:()=>ma(t)}}},qc=B({prompt_cache_hit_tokens:X().nullish(),prompt_cache_miss_tokens:X().nullish()}),im=B({usage:qc.nullish()}),om=B({choices:ve(B({finish_reason:I().nullish()})).nullish(),usage:qc.nullish()}),sm="1.0.30";function Yc(t={}){var r;const o=Sg((r=t.baseURL)!=null?r:"https://api.deepseek.com/v1"),l=()=>Pc({Authorization:`Bearer ${gp({apiKey:t.apiKey,environmentVariableName:"DEEPSEEK_API_KEY",description:"DeepSeek API key"})}`,...t.headers},`ai-sdk/deepseek/${sm}`);class u extends Qg{addJsonInstruction(y){var m;if(((m=y.responseFormat)==null?void 0:m.type)!=="json")return y;const P=[...Array.isArray(y.prompt)?y.prompt:[],{role:"user",content:[{type:"text",text:"Return ONLY a valid JSON object."}]}];return{...y,prompt:P}}async doGenerate(y){return super.doGenerate(this.addJsonInstruction(y))}async doStream(y){return super.doStream(this.addJsonInstruction(y))}}const f=x=>new u(x,{provider:"deepseek.chat",url:({path:y})=>`${o}${y}`,headers:l,fetch:t.fetch,metadataExtractor:rm}),g=x=>f(x);return g.languageModel=f,g.chat=f,g.textEmbeddingModel=x=>{throw new Ls({modelId:x,modelType:"textEmbeddingModel"})},g.imageModel=x=>{throw new Ls({modelId:x,modelType:"imageModel"})},g}Yc();var Kc="vercel.ai.error",am=Symbol.for(Kc),xa,wa,Et=class Jc extends(wa=Error,xa=am,wa){constructor({name:r,message:o,cause:l}){super(o),this[xa]=!0,this.name=r,this.cause=l}static isInstance(r){return Jc.hasMarker(r,Kc)}static hasMarker(r,o){const l=Symbol.for(o);return r!=null&&typeof r=="object"&&l in r&&typeof r[l]=="boolean"&&r[l]===!0}},Qc="AI_APICallError",eu=`vercel.ai.error.${Qc}`,lm=Symbol.for(eu),ya,_a,pn=class extends(_a=Et,ya=lm,_a){constructor({message:t,url:r,requestBodyValues:o,statusCode:l,responseHeaders:u,responseBody:f,cause:g,isRetryable:x=l!=null&&(l===408||l===409||l===429||l>=500),data:y}){super({name:Qc,message:t,cause:g}),this[ya]=!0,this.url=r,this.requestBodyValues=o,this.statusCode=l,this.responseHeaders=u,this.responseBody=f,this.isRetryable=x,this.data=y}static isInstance(t){return Et.hasMarker(t,eu)}},tu="AI_EmptyResponseBodyError",nu=`vercel.ai.error.${tu}`,cm=Symbol.for(nu),va,ba,um=class extends(ba=Et,va=cm,ba){constructor({message:t="Empty response body"}={}){super({name:tu,message:t}),this[va]=!0}static isInstance(t){return Et.hasMarker(t,nu)}};function ru(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var iu="AI_InvalidArgumentError",ou=`vercel.ai.error.${iu}`,dm=Symbol.for(ou),Ca,Ea,su=class extends(Ea=Et,Ca=dm,Ea){constructor({message:t,cause:r,argument:o}){super({name:iu,message:t,cause:r}),this[Ca]=!0,this.argument=o}static isInstance(t){return Et.hasMarker(t,ou)}},au="AI_InvalidPromptError",lu=`vercel.ai.error.${au}`,fm=Symbol.for(lu),Aa,Ia,hm=class extends(Ia=Et,Aa=fm,Ia){constructor({prompt:t,message:r,cause:o}){super({name:au,message:`Invalid prompt: ${r}`,cause:o}),this[Aa]=!0,this.prompt=t}static isInstance(t){return Et.hasMarker(t,lu)}},cu="AI_InvalidResponseDataError",uu=`vercel.ai.error.${cu}`,pm=Symbol.for(uu),Sa,Ta,Ao=class extends(Ta=Et,Sa=pm,Ta){constructor({data:t,message:r=`Invalid response data: ${JSON.stringify(t)}.`}){super({name:cu,message:r}),this[Sa]=!0,this.data=t}static isInstance(t){return Et.hasMarker(t,uu)}},du="AI_JSONParseError",fu=`vercel.ai.error.${du}`,gm=Symbol.for(fu),Na,Oa,Ui=class extends(Oa=Et,Na=gm,Oa){constructor({text:t,cause:r}){super({name:du,message:`JSON parsing failed: Text: ${t}.
43
+ Error message: ${ru(r)}`,cause:r}),this[Na]=!0,this.text=t}static isInstance(t){return Et.hasMarker(t,fu)}},hu="AI_LoadAPIKeyError",pu=`vercel.ai.error.${hu}`,mm=Symbol.for(pu),ka,Ra,Ci=class extends(Ra=Et,ka=mm,Ra){constructor({message:t}){super({name:hu,message:t}),this[ka]=!0}static isInstance(t){return Et.hasMarker(t,pu)}},gu="AI_TooManyEmbeddingValuesForCallError",mu=`vercel.ai.error.${gu}`,xm=Symbol.for(mu),Da,Ma,wm=class extends(Ma=Et,Da=xm,Ma){constructor(t){super({name:gu,message:`Too many values for a single embedding call. The ${t.provider} model "${t.modelId}" can only embed up to ${t.maxEmbeddingsPerCall} values per call, but ${t.values.length} values were provided.`}),this[Da]=!0,this.provider=t.provider,this.modelId=t.modelId,this.maxEmbeddingsPerCall=t.maxEmbeddingsPerCall,this.values=t.values}static isInstance(t){return Et.hasMarker(t,mu)}},xu="AI_TypeValidationError",wu=`vercel.ai.error.${xu}`,ym=Symbol.for(wu),Pa,Ba,Jr=class Uo extends(Ba=Et,Pa=ym,Ba){constructor({value:r,cause:o}){super({name:xu,message:`Type validation failed: Value: ${JSON.stringify(r)}.
44
+ Error message: ${ru(o)}`,cause:o}),this[Pa]=!0,this.value=r}static isInstance(r){return Et.hasMarker(r,wu)}static wrap({value:r,cause:o}){return Uo.isInstance(o)&&o.value===r?o:new Uo({value:r,cause:o})}},yu="AI_UnsupportedFunctionalityError",_u=`vercel.ai.error.${yu}`,_m=Symbol.for(_u),La,Fa,Ln=class extends(Fa=Et,La=_m,Fa){constructor({functionality:t,message:r=`'${t}' functionality not supported.`}){super({name:yu,message:r}),this[La]=!0,this.functionality=t}static isInstance(t){return Et.hasMarker(t,_u)}};function Rn(...t){return t.reduce((r,o)=>({...r,...o??{}}),{})}function oi(t){return Object.fromEntries([...t.headers])}var vm=({prefix:t,size:r=16,alphabet:o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:l="-"}={})=>{const u=()=>{const f=o.length,g=new Array(r);for(let x=0;x<r;x++)g[x]=o[Math.random()*f|0];return g.join("")};if(t==null)return u;if(o.includes(l))throw new su({argument:"separator",message:`The separator "${l}" must not be part of the alphabet "${o}".`});return()=>`${t}${l}${u()}`},Cn=vm();function zo(t){return(t instanceof Error||t instanceof DOMException)&&(t.name==="AbortError"||t.name==="ResponseAborted"||t.name==="TimeoutError")}var bm=["fetch failed","failed to fetch"];function Cm({error:t,url:r,requestBodyValues:o}){if(zo(t))return t;if(t instanceof TypeError&&bm.includes(t.message.toLowerCase())){const l=t.cause;if(l!=null)return new pn({message:`Cannot connect to API: ${l.message}`,cause:l,url:r,requestBodyValues:o,isRetryable:!0})}return t}function Em(t=globalThis){var r,o,l;return t.window?"runtime/browser":(r=t.navigator)!=null&&r.userAgent?`runtime/${t.navigator.userAgent.toLowerCase()}`:(l=(o=t.process)==null?void 0:o.versions)!=null&&l.node?`runtime/node.js/${t.process.version.substring(0)}`:t.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function Am(t){if(t==null)return{};const r={};if(t instanceof Headers)t.forEach((o,l)=>{r[l.toLowerCase()]=o});else{Array.isArray(t)||(t=Object.entries(t));for(const[o,l]of t)l!=null&&(r[o.toLowerCase()]=l)}return r}function vu(t,...r){const o=new Headers(Am(t)),l=o.get("user-agent")||"";return o.set("user-agent",[l,...r].filter(Boolean).join(" ")),Object.fromEntries(o.entries())}var Im="3.0.20";function Sm({apiKey:t,environmentVariableName:r,apiKeyParameterName:o="apiKey",description:l}){if(typeof t=="string")return t;if(t!=null)throw new Ci({message:`${l} API key must be a string.`});if(typeof process>"u")throw new Ci({message:`${l} API key is missing. Pass it using the '${o}' parameter. Environment variables is not supported in this environment.`});if(t=process.env[r],t==null)throw new Ci({message:`${l} API key is missing. Pass it using the '${o}' parameter or the ${r} environment variable.`});if(typeof t!="string")throw new Ci({message:`${l} API key must be a string. The value of the ${r} environment variable is not a string.`});return t}function Tm({settingValue:t,environmentVariableName:r}){if(typeof t=="string")return t;if(!(t!=null||typeof process>"u")&&(t=process.env[r],!(t==null||typeof t!="string")))return t}function Nm(t){var r;const[o,l=""]=t.toLowerCase().split("/");return(r={mpeg:"mp3","x-wav":"wav",opus:"ogg",mp4:"m4a","x-m4a":"m4a"}[l])!=null?r:l}var Om=/"__proto__"\s*:/,km=/"constructor"\s*:/;function $a(t){const r=JSON.parse(t);return r===null||typeof r!="object"||Om.test(t)===!1&&km.test(t)===!1?r:Rm(r)}function Rm(t){let r=[t];for(;r.length;){const o=r;r=[];for(const l of o){if(Object.prototype.hasOwnProperty.call(l,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(l,"constructor")&&Object.prototype.hasOwnProperty.call(l.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const u in l){const f=l[u];f&&typeof f=="object"&&r.push(f)}}}return t}function ss(t){const{stackTraceLimit:r}=Error;try{Error.stackTraceLimit=0}catch{return $a(t)}try{return $a(t)}finally{Error.stackTraceLimit=r}}var zi=Symbol.for("vercel.ai.validator");function Dm(t){return{[zi]:!0,validate:t}}function Mm(t){return typeof t=="object"&&t!==null&&zi in t&&t[zi]===!0&&"validate"in t}function qt(t){let r;return()=>(r==null&&(r=t()),r)}function Pm(t){return Mm(t)?t:typeof t=="function"?t():Bm(t)}function Bm(t){return Dm(async r=>{const o=await t["~standard"].validate(r);return o.issues==null?{success:!0,value:o.value}:{success:!1,error:new Jr({value:r,cause:o.issues})}})}async function Xn({value:t,schema:r}){const o=await as({value:t,schema:r});if(!o.success)throw Jr.wrap({value:t,cause:o.error});return o.value}async function as({value:t,schema:r}){const o=Pm(r);try{if(o.validate==null)return{success:!0,value:t,rawValue:t};const l=await o.validate(t);return l.success?{success:!0,value:l.value,rawValue:t}:{success:!1,error:Jr.wrap({value:t,cause:l.error}),rawValue:t}}catch(l){return{success:!1,error:Jr.wrap({value:t,cause:l}),rawValue:t}}}async function Lm({text:t,schema:r}){try{const o=ss(t);return r==null?o:Xn({value:o,schema:r})}catch(o){throw Ui.isInstance(o)||Jr.isInstance(o)?o:new Ui({text:t,cause:o})}}async function bu({text:t,schema:r}){try{const o=ss(t);return r==null?{success:!0,value:o,rawValue:o}:await as({value:o,schema:r})}catch(o){return{success:!1,error:Ui.isInstance(o)?o:new Ui({text:t,cause:o}),rawValue:void 0}}}function Ua(t){try{return ss(t),!0}catch{return!1}}function Fm({stream:t,schema:r}){return t.pipeThrough(new TextDecoderStream).pipeThrough(new lc).pipeThrough(new TransformStream({async transform({data:o},l){o!=="[DONE]"&&l.enqueue(await bu({text:o,schema:r}))}}))}async function Kn({provider:t,providerOptions:r,schema:o}){if(r?.[t]==null)return;const l=await as({value:r[t],schema:o});if(!l.success)throw new su({argument:"providerOptions",message:`invalid ${t} provider options`,cause:l.error});return l.value}var $m=()=>globalThis.fetch,Fn=async({url:t,headers:r,body:o,failedResponseHandler:l,successfulResponseHandler:u,abortSignal:f,fetch:g})=>Cu({url:t,headers:{"Content-Type":"application/json",...r},body:{content:JSON.stringify(o),values:o},failedResponseHandler:l,successfulResponseHandler:u,abortSignal:f,fetch:g}),Um=async({url:t,headers:r,formData:o,failedResponseHandler:l,successfulResponseHandler:u,abortSignal:f,fetch:g})=>Cu({url:t,headers:r,body:{content:o,values:Object.fromEntries(o.entries())},failedResponseHandler:l,successfulResponseHandler:u,abortSignal:f,fetch:g}),Cu=async({url:t,headers:r={},body:o,successfulResponseHandler:l,failedResponseHandler:u,abortSignal:f,fetch:g=$m()})=>{try{const x=await g(t,{method:"POST",headers:vu(r,`ai-sdk/provider-utils/${Im}`,Em()),body:o.content,signal:f}),y=oi(x);if(!x.ok){let m;try{m=await u({response:x,url:t,requestBodyValues:o.values})}catch(E){throw zo(E)||pn.isInstance(E)?E:new pn({message:"Failed to process error response",cause:E,statusCode:x.status,url:t,responseHeaders:y,requestBodyValues:o.values})}throw m.value}try{return await l({response:x,url:t,requestBodyValues:o.values})}catch(m){throw m instanceof Error&&(zo(m)||pn.isInstance(m))?m:new pn({message:"Failed to process successful response",cause:m,statusCode:x.status,url:t,responseHeaders:y,requestBodyValues:o.values})}}catch(x){throw Cm({error:x,url:t,requestBodyValues:o.values})}};function Er({id:t,name:r,inputSchema:o,outputSchema:l}){return({execute:u,toModelOutput:f,onInputStart:g,onInputDelta:x,onInputAvailable:y,...m})=>({type:"provider-defined",id:t,name:r,args:m,inputSchema:o,outputSchema:l,execute:u,toModelOutput:f,onInputStart:g,onInputDelta:x,onInputAvailable:y})}var zm=({errorSchema:t,errorToMessage:r,isRetryable:o})=>async({response:l,url:u,requestBodyValues:f})=>{const g=await l.text(),x=oi(l);if(g.trim()==="")return{responseHeaders:x,value:new pn({message:l.statusText,url:u,requestBodyValues:f,statusCode:l.status,responseHeaders:x,responseBody:g,isRetryable:o?.(l)})};try{const y=await Lm({text:g,schema:t});return{responseHeaders:x,value:new pn({message:r(y),url:u,requestBodyValues:f,statusCode:l.status,responseHeaders:x,responseBody:g,data:y,isRetryable:o?.(l,y)})}}catch{return{responseHeaders:x,value:new pn({message:l.statusText,url:u,requestBodyValues:f,statusCode:l.status,responseHeaders:x,responseBody:g,isRetryable:o?.(l)})}}},ls=t=>async({response:r})=>{const o=oi(r);if(r.body==null)throw new um({});return{responseHeaders:o,value:Fm({stream:r.body,schema:t})}},Ar=t=>async({response:r,url:o,requestBodyValues:l})=>{const u=await r.text(),f=await bu({text:u,schema:t}),g=oi(r);if(!f.success)throw new pn({message:"Invalid JSON response",cause:f.error,statusCode:r.status,responseHeaders:g,responseBody:u,url:o,requestBodyValues:l});return{responseHeaders:g,value:f.value,rawValue:f.rawValue}},Vm=()=>async({response:t,url:r,requestBodyValues:o})=>{const l=oi(t);if(!t.body)throw new pn({message:"Response body is empty",url:r,requestBodyValues:o,statusCode:t.status,responseHeaders:l,responseBody:void 0});try{const u=await t.arrayBuffer();return{responseHeaders:l,value:new Uint8Array(u)}}catch(u){throw new pn({message:"Failed to read response as array buffer",url:r,requestBodyValues:o,statusCode:t.status,responseHeaders:l,responseBody:void 0,cause:u})}};function Ri(t){if(t.type==="object"){t.additionalProperties=!1;const r=t.properties;if(r!=null)for(const o in r)r[o]=Ri(r[o])}return t.type==="array"&&t.items!=null&&(Array.isArray(t.items)?t.items=t.items.map(r=>Ri(r)):t.items=Ri(t.items)),t}var Zm=(t,r)=>{let o=0;for(;o<t.length&&o<r.length&&t[o]===r[o];o++);return[(t.length-o).toString(),...r.slice(o)].join("/")},jm=Symbol("Let zodToJsonSchema decide on which parser to use"),za={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},Hm=t=>typeof t=="string"?{...za,name:t}:{...za,...t};function sn(){return{}}function Wm(t,r){var o,l,u;const f={type:"array"};return(o=t.type)!=null&&o._def&&((u=(l=t.type)==null?void 0:l._def)==null?void 0:u.typeName)!==ue.ZodAny&&(f.items=Ye(t.type._def,{...r,currentPath:[...r.currentPath,"items"]})),t.minLength&&(f.minItems=t.minLength.value),t.maxLength&&(f.maxItems=t.maxLength.value),t.exactLength&&(f.minItems=t.exactLength.value,f.maxItems=t.exactLength.value),f}function Gm(t){const r={type:"integer",format:"int64"};if(!t.checks)return r;for(const o of t.checks)switch(o.kind){case"min":o.inclusive?r.minimum=o.value:r.exclusiveMinimum=o.value;break;case"max":o.inclusive?r.maximum=o.value:r.exclusiveMaximum=o.value;break;case"multipleOf":r.multipleOf=o.value;break}return r}function Xm(){return{type:"boolean"}}function Eu(t,r){return Ye(t.type._def,r)}var qm=(t,r)=>Ye(t.innerType._def,r);function Au(t,r,o){const l=o??r.dateStrategy;if(Array.isArray(l))return{anyOf:l.map((u,f)=>Au(t,r,u))};switch(l){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Ym(t)}}var Ym=t=>{const r={type:"integer",format:"unix-time"};for(const o of t.checks)switch(o.kind){case"min":r.minimum=o.value;break;case"max":r.maximum=o.value;break}return r};function Km(t,r){return{...Ye(t.innerType._def,r),default:t.defaultValue()}}function Jm(t,r){return r.effectStrategy==="input"?Ye(t.schema._def,r):sn()}function Qm(t){return{type:"string",enum:Array.from(t.values)}}var e2=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function t2(t,r){const o=[Ye(t.left._def,{...r,currentPath:[...r.currentPath,"allOf","0"]}),Ye(t.right._def,{...r,currentPath:[...r.currentPath,"allOf","1"]})].filter(u=>!!u),l=[];return o.forEach(u=>{if(e2(u))l.push(...u.allOf);else{let f=u;if("additionalProperties"in u&&u.additionalProperties===!1){const{additionalProperties:g,...x}=u;f=x}l.push(f)}}),l.length?{allOf:l}:void 0}function n2(t){const r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:{type:r==="bigint"?"integer":r,const:t.value}}var Io=void 0,_n={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(Io===void 0&&(Io=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Io),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Iu(t,r){const o={type:"string"};if(t.checks)for(const l of t.checks)switch(l.kind){case"min":o.minLength=typeof o.minLength=="number"?Math.max(o.minLength,l.value):l.value;break;case"max":o.maxLength=typeof o.maxLength=="number"?Math.min(o.maxLength,l.value):l.value;break;case"email":switch(r.emailStrategy){case"format:email":vn(o,"email",l.message,r);break;case"format:idn-email":vn(o,"idn-email",l.message,r);break;case"pattern:zod":Wt(o,_n.email,l.message,r);break}break;case"url":vn(o,"uri",l.message,r);break;case"uuid":vn(o,"uuid",l.message,r);break;case"regex":Wt(o,l.regex,l.message,r);break;case"cuid":Wt(o,_n.cuid,l.message,r);break;case"cuid2":Wt(o,_n.cuid2,l.message,r);break;case"startsWith":Wt(o,RegExp(`^${So(l.value,r)}`),l.message,r);break;case"endsWith":Wt(o,RegExp(`${So(l.value,r)}$`),l.message,r);break;case"datetime":vn(o,"date-time",l.message,r);break;case"date":vn(o,"date",l.message,r);break;case"time":vn(o,"time",l.message,r);break;case"duration":vn(o,"duration",l.message,r);break;case"length":o.minLength=typeof o.minLength=="number"?Math.max(o.minLength,l.value):l.value,o.maxLength=typeof o.maxLength=="number"?Math.min(o.maxLength,l.value):l.value;break;case"includes":{Wt(o,RegExp(So(l.value,r)),l.message,r);break}case"ip":{l.version!=="v6"&&vn(o,"ipv4",l.message,r),l.version!=="v4"&&vn(o,"ipv6",l.message,r);break}case"base64url":Wt(o,_n.base64url,l.message,r);break;case"jwt":Wt(o,_n.jwt,l.message,r);break;case"cidr":{l.version!=="v6"&&Wt(o,_n.ipv4Cidr,l.message,r),l.version!=="v4"&&Wt(o,_n.ipv6Cidr,l.message,r);break}case"emoji":Wt(o,_n.emoji(),l.message,r);break;case"ulid":{Wt(o,_n.ulid,l.message,r);break}case"base64":{switch(r.base64Strategy){case"format:binary":{vn(o,"binary",l.message,r);break}case"contentEncoding:base64":{o.contentEncoding="base64";break}case"pattern:zod":{Wt(o,_n.base64,l.message,r);break}}break}case"nanoid":Wt(o,_n.nanoid,l.message,r)}return o}function So(t,r){return r.patternStrategy==="escape"?i2(t):t}var r2=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function i2(t){let r="";for(let o=0;o<t.length;o++)r2.has(t[o])||(r+="\\"),r+=t[o];return r}function vn(t,r,o,l){var u;t.format||(u=t.anyOf)!=null&&u.some(f=>f.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format}),delete t.format),t.anyOf.push({format:r,...o&&l.errorMessages&&{errorMessage:{format:o}}})):t.format=r}function Wt(t,r,o,l){var u;t.pattern||(u=t.allOf)!=null&&u.some(f=>f.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern}),delete t.pattern),t.allOf.push({pattern:Va(r,l),...o&&l.errorMessages&&{errorMessage:{pattern:o}}})):t.pattern=Va(r,l)}function Va(t,r){var o;if(!r.applyRegexFlags||!t.flags)return t.source;const l={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},u=l.i?t.source.toLowerCase():t.source;let f="",g=!1,x=!1,y=!1;for(let m=0;m<u.length;m++){if(g){f+=u[m],g=!1;continue}if(l.i){if(x){if(u[m].match(/[a-z]/)){y?(f+=u[m],f+=`${u[m-2]}-${u[m]}`.toUpperCase(),y=!1):u[m+1]==="-"&&((o=u[m+2])!=null&&o.match(/[a-z]/))?(f+=u[m],y=!0):f+=`${u[m]}${u[m].toUpperCase()}`;continue}}else if(u[m].match(/[a-z]/)){f+=`[${u[m]}${u[m].toUpperCase()}]`;continue}}if(l.m){if(u[m]==="^"){f+=`(^|(?<=[\r
45
+ ]))`;continue}else if(u[m]==="$"){f+=`($|(?=[\r
46
+ ]))`;continue}}if(l.s&&u[m]==="."){f+=x?`${u[m]}\r
47
+ `:`[${u[m]}\r
48
+ ]`;continue}f+=u[m],u[m]==="\\"?g=!0:x&&u[m]==="]"?x=!1:!x&&u[m]==="["&&(x=!0)}try{new RegExp(f)}catch{return console.warn(`Could not convert regex pattern at ${r.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return f}function Su(t,r){var o,l,u,f,g,x;const y={type:"object",additionalProperties:(o=Ye(t.valueType._def,{...r,currentPath:[...r.currentPath,"additionalProperties"]}))!=null?o:r.allowedAdditionalProperties};if(((l=t.keyType)==null?void 0:l._def.typeName)===ue.ZodString&&((u=t.keyType._def.checks)!=null&&u.length)){const{type:m,...E}=Iu(t.keyType._def,r);return{...y,propertyNames:E}}else{if(((f=t.keyType)==null?void 0:f._def.typeName)===ue.ZodEnum)return{...y,propertyNames:{enum:t.keyType._def.values}};if(((g=t.keyType)==null?void 0:g._def.typeName)===ue.ZodBranded&&t.keyType._def.type._def.typeName===ue.ZodString&&((x=t.keyType._def.type._def.checks)!=null&&x.length)){const{type:m,...E}=Eu(t.keyType._def,r);return{...y,propertyNames:E}}}return y}function o2(t,r){if(r.mapStrategy==="record")return Su(t,r);const o=Ye(t.keyType._def,{...r,currentPath:[...r.currentPath,"items","items","0"]})||sn(),l=Ye(t.valueType._def,{...r,currentPath:[...r.currentPath,"items","items","1"]})||sn();return{type:"array",maxItems:125,items:{type:"array",items:[o,l],minItems:2,maxItems:2}}}function s2(t){const r=t.values,l=Object.keys(t.values).filter(f=>typeof r[r[f]]!="number").map(f=>r[f]),u=Array.from(new Set(l.map(f=>typeof f)));return{type:u.length===1?u[0]==="string"?"string":"number":["string","number"],enum:l}}function a2(){return{not:sn()}}function l2(){return{type:"null"}}var Vo={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function c2(t,r){const o=t.options instanceof Map?Array.from(t.options.values()):t.options;if(o.every(l=>l._def.typeName in Vo&&(!l._def.checks||!l._def.checks.length))){const l=o.reduce((u,f)=>{const g=Vo[f._def.typeName];return g&&!u.includes(g)?[...u,g]:u},[]);return{type:l.length>1?l:l[0]}}else if(o.every(l=>l._def.typeName==="ZodLiteral"&&!l.description)){const l=o.reduce((u,f)=>{const g=typeof f._def.value;switch(g){case"string":case"number":case"boolean":return[...u,g];case"bigint":return[...u,"integer"];case"object":if(f._def.value===null)return[...u,"null"];case"symbol":case"undefined":case"function":default:return u}},[]);if(l.length===o.length){const u=l.filter((f,g,x)=>x.indexOf(f)===g);return{type:u.length>1?u:u[0],enum:o.reduce((f,g)=>f.includes(g._def.value)?f:[...f,g._def.value],[])}}}else if(o.every(l=>l._def.typeName==="ZodEnum"))return{type:"string",enum:o.reduce((l,u)=>[...l,...u._def.values.filter(f=>!l.includes(f))],[])};return u2(t,r)}var u2=(t,r)=>{const o=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((l,u)=>Ye(l._def,{...r,currentPath:[...r.currentPath,"anyOf",`${u}`]})).filter(l=>!!l&&(!r.strictUnions||typeof l=="object"&&Object.keys(l).length>0));return o.length?{anyOf:o}:void 0};function d2(t,r){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return{type:[Vo[t.innerType._def.typeName],"null"]};const o=Ye(t.innerType._def,{...r,currentPath:[...r.currentPath,"anyOf","0"]});return o&&{anyOf:[o,{type:"null"}]}}function f2(t){const r={type:"number"};if(!t.checks)return r;for(const o of t.checks)switch(o.kind){case"int":r.type="integer";break;case"min":o.inclusive?r.minimum=o.value:r.exclusiveMinimum=o.value;break;case"max":o.inclusive?r.maximum=o.value:r.exclusiveMaximum=o.value;break;case"multipleOf":r.multipleOf=o.value;break}return r}function h2(t,r){const o={type:"object",properties:{}},l=[],u=t.shape();for(const g in u){let x=u[g];if(x===void 0||x._def===void 0)continue;const y=g2(x),m=Ye(x._def,{...r,currentPath:[...r.currentPath,"properties",g],propertyPath:[...r.currentPath,"properties",g]});m!==void 0&&(o.properties[g]=m,y||l.push(g))}l.length&&(o.required=l);const f=p2(t,r);return f!==void 0&&(o.additionalProperties=f),o}function p2(t,r){if(t.catchall._def.typeName!=="ZodNever")return Ye(t.catchall._def,{...r,currentPath:[...r.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return r.allowedAdditionalProperties;case"strict":return r.rejectedAdditionalProperties;case"strip":return r.removeAdditionalStrategy==="strict"?r.allowedAdditionalProperties:r.rejectedAdditionalProperties}}function g2(t){try{return t.isOptional()}catch{return!0}}var m2=(t,r)=>{var o;if(r.currentPath.toString()===((o=r.propertyPath)==null?void 0:o.toString()))return Ye(t.innerType._def,r);const l=Ye(t.innerType._def,{...r,currentPath:[...r.currentPath,"anyOf","1"]});return l?{anyOf:[{not:sn()},l]}:sn()},x2=(t,r)=>{if(r.pipeStrategy==="input")return Ye(t.in._def,r);if(r.pipeStrategy==="output")return Ye(t.out._def,r);const o=Ye(t.in._def,{...r,currentPath:[...r.currentPath,"allOf","0"]}),l=Ye(t.out._def,{...r,currentPath:[...r.currentPath,"allOf",o?"1":"0"]});return{allOf:[o,l].filter(u=>u!==void 0)}};function w2(t,r){return Ye(t.type._def,r)}function y2(t,r){const l={type:"array",uniqueItems:!0,items:Ye(t.valueType._def,{...r,currentPath:[...r.currentPath,"items"]})};return t.minSize&&(l.minItems=t.minSize.value),t.maxSize&&(l.maxItems=t.maxSize.value),l}function _2(t,r){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((o,l)=>Ye(o._def,{...r,currentPath:[...r.currentPath,"items",`${l}`]})).reduce((o,l)=>l===void 0?o:[...o,l],[]),additionalItems:Ye(t.rest._def,{...r,currentPath:[...r.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((o,l)=>Ye(o._def,{...r,currentPath:[...r.currentPath,"items",`${l}`]})).reduce((o,l)=>l===void 0?o:[...o,l],[])}}function v2(){return{not:sn()}}function b2(){return sn()}var C2=(t,r)=>Ye(t.innerType._def,r),E2=(t,r,o)=>{switch(r){case ue.ZodString:return Iu(t,o);case ue.ZodNumber:return f2(t);case ue.ZodObject:return h2(t,o);case ue.ZodBigInt:return Gm(t);case ue.ZodBoolean:return Xm();case ue.ZodDate:return Au(t,o);case ue.ZodUndefined:return v2();case ue.ZodNull:return l2();case ue.ZodArray:return Wm(t,o);case ue.ZodUnion:case ue.ZodDiscriminatedUnion:return c2(t,o);case ue.ZodIntersection:return t2(t,o);case ue.ZodTuple:return _2(t,o);case ue.ZodRecord:return Su(t,o);case ue.ZodLiteral:return n2(t);case ue.ZodEnum:return Qm(t);case ue.ZodNativeEnum:return s2(t);case ue.ZodNullable:return d2(t,o);case ue.ZodOptional:return m2(t,o);case ue.ZodMap:return o2(t,o);case ue.ZodSet:return y2(t,o);case ue.ZodLazy:return()=>t.getter()._def;case ue.ZodPromise:return w2(t,o);case ue.ZodNaN:case ue.ZodNever:return a2();case ue.ZodEffects:return Jm(t,o);case ue.ZodAny:return sn();case ue.ZodUnknown:return b2();case ue.ZodDefault:return Km(t,o);case ue.ZodBranded:return Eu(t,o);case ue.ZodReadonly:return C2(t,o);case ue.ZodCatch:return qm(t,o);case ue.ZodPipeline:return x2(t,o);case ue.ZodFunction:case ue.ZodVoid:case ue.ZodSymbol:return;default:return(l=>{})()}};function Ye(t,r,o=!1){var l;const u=r.seen.get(t);if(r.override){const y=(l=r.override)==null?void 0:l.call(r,t,r,u,o);if(y!==jm)return y}if(u&&!o){const y=A2(u,r);if(y!==void 0)return y}const f={def:t,path:r.currentPath,jsonSchema:void 0};r.seen.set(t,f);const g=E2(t,t.typeName,r),x=typeof g=="function"?Ye(g(),r):g;if(x&&I2(t,r,x),r.postProcess){const y=r.postProcess(x,t,r);return f.jsonSchema=x,y}return f.jsonSchema=x,x}var A2=(t,r)=>{switch(r.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Zm(r.currentPath,t.path)};case"none":case"seen":return t.path.length<r.currentPath.length&&t.path.every((o,l)=>r.currentPath[l]===o)?(console.warn(`Recursive reference detected at ${r.currentPath.join("/")}! Defaulting to any`),sn()):r.$refStrategy==="seen"?sn():void 0}},I2=(t,r,o)=>(t.description&&(o.description=t.description),o),S2=t=>{const r=Hm(t),o=r.name!==void 0?[...r.basePath,r.definitionPath,r.name]:r.basePath;return{...r,currentPath:o,propertyPath:void 0,seen:new Map(Object.entries(r.definitions).map(([l,u])=>[u._def,{def:u._def,path:[...r.basePath,r.definitionPath,l],jsonSchema:void 0}]))}},T2=(t,r)=>{var o;const l=S2(r);let u=typeof r=="object"&&r.definitions?Object.entries(r.definitions).reduce((m,[E,C])=>{var P;return{...m,[E]:(P=Ye(C._def,{...l,currentPath:[...l.basePath,l.definitionPath,E]},!0))!=null?P:sn()}},{}):void 0;const f=typeof r=="string"?r:r?.nameStrategy==="title"?void 0:r?.name,g=(o=Ye(t._def,f===void 0?l:{...l,currentPath:[...l.basePath,l.definitionPath,f]},!1))!=null?o:sn(),x=typeof r=="object"&&r.name!==void 0&&r.nameStrategy==="title"?r.name:void 0;x!==void 0&&(g.title=x);const y=f===void 0?u?{...g,[l.definitionPath]:u}:g:{$ref:[...l.$refStrategy==="relative"?[]:l.basePath,l.definitionPath,f].join("/"),[l.definitionPath]:{...u,[f]:g}};return y.$schema="http://json-schema.org/draft-07/schema#",y},N2=T2;function O2(t,r){var o;const l=(o=void 0)!=null?o:!1;return Tu(()=>N2(t,{$refStrategy:l?"root":"none"}),{validate:async u=>{const f=await t.safeParseAsync(u);return f.success?{success:!0,value:f.data}:{success:!1,error:f.error}}})}function k2(t,r){var o;const l=(o=void 0)!=null?o:!1;return Tu(()=>Ri(Nc(t,{target:"draft-7",io:"input",reused:l?"ref":"inline"})),{validate:async u=>{const f=await ts(t,u);return f.success?{success:!0,value:f.data}:{success:!1,error:f.error}}})}function R2(t){return"_zod"in t}function We(t,r){return R2(t)?k2(t):O2(t)}var D2=Symbol.for("vercel.ai.schema");function Vt(t){let r;return()=>(r==null&&(r=t()),r)}function Tu(t,{validate:r}={}){return{[D2]:!0,_type:void 0,[zi]:!0,get jsonSchema(){return typeof t=="function"&&(t=t()),t},validate:r}}var{btoa:M2,atob:P2}=globalThis;function B2(t){const r=t.replace(/-/g,"+").replace(/_/g,"/"),o=P2(r);return Uint8Array.from(o,l=>l.codePointAt(0))}function L2(t){let r="";for(let o=0;o<t.length;o++)r+=String.fromCodePoint(t[o]);return M2(r)}function vr(t){return t instanceof Uint8Array?L2(t):t}function F2(t){return t?.replace(/\/$/,"")}var cs=B({error:B({message:I(),type:I().nullish(),param:ri().nullish(),code:lt([I(),X()]).nullish()})}),Dn=zm({errorSchema:cs,errorToMessage:t=>t.error.message});function Nu(t){const r=t.startsWith("o3")||t.startsWith("o4-mini")||t.startsWith("gpt-5")&&!t.startsWith("gpt-5-chat"),o=t.startsWith("gpt-4")||t.startsWith("gpt-5-mini")||t.startsWith("gpt-5")&&!t.startsWith("gpt-5-nano")&&!t.startsWith("gpt-5-chat")||t.startsWith("o3")||t.startsWith("o4-mini"),l=!(t.startsWith("gpt-3")||t.startsWith("gpt-4")||t.startsWith("chatgpt-4o")||t.startsWith("gpt-5-chat")),u=t.startsWith("gpt-5.1")||t.startsWith("gpt-5.2");return{supportsFlexProcessing:r,supportsPriorityProcessing:o,isReasoningModel:l,systemMessageMode:l?"developer":"system",supportsNonReasoningParameters:u}}function $2({prompt:t,systemMessageMode:r="system"}){const o=[],l=[];for(const{role:u,content:f}of t)switch(u){case"system":{switch(r){case"system":{o.push({role:"system",content:f});break}case"developer":{o.push({role:"developer",content:f});break}case"remove":{l.push({type:"other",message:"system messages are removed for this model"});break}default:{const g=r;throw new Error(`Unsupported system message mode: ${g}`)}}break}case"user":{if(f.length===1&&f[0].type==="text"){o.push({role:"user",content:f[0].text});break}o.push({role:"user",content:f.map((g,x)=>{var y,m,E;switch(g.type){case"text":return{type:"text",text:g.text};case"file":if(g.mediaType.startsWith("image/")){const C=g.mediaType==="image/*"?"image/jpeg":g.mediaType;return{type:"image_url",image_url:{url:g.data instanceof URL?g.data.toString():`data:${C};base64,${vr(g.data)}`,detail:(m=(y=g.providerOptions)==null?void 0:y.openai)==null?void 0:m.imageDetail}}}else if(g.mediaType.startsWith("audio/")){if(g.data instanceof URL)throw new Ln({functionality:"audio file parts with URLs"});switch(g.mediaType){case"audio/wav":return{type:"input_audio",input_audio:{data:vr(g.data),format:"wav"}};case"audio/mp3":case"audio/mpeg":return{type:"input_audio",input_audio:{data:vr(g.data),format:"mp3"}};default:throw new Ln({functionality:`audio content parts with media type ${g.mediaType}`})}}else if(g.mediaType==="application/pdf"){if(g.data instanceof URL)throw new Ln({functionality:"PDF file parts with URLs"});return{type:"file",file:typeof g.data=="string"&&g.data.startsWith("file-")?{file_id:g.data}:{filename:(E=g.filename)!=null?E:`part-${x}.pdf`,file_data:`data:application/pdf;base64,${vr(g.data)}`}}}else throw new Ln({functionality:`file part media type ${g.mediaType}`})}})});break}case"assistant":{let g="";const x=[];for(const y of f)switch(y.type){case"text":{g+=y.text;break}case"tool-call":{x.push({id:y.toolCallId,type:"function",function:{name:y.toolName,arguments:JSON.stringify(y.input)}});break}}o.push({role:"assistant",content:g,tool_calls:x.length>0?x:void 0});break}case"tool":{for(const g of f){const x=g.output;let y;switch(x.type){case"text":case"error-text":y=x.value;break;case"content":case"json":case"error-json":y=JSON.stringify(x.value);break}o.push({role:"tool",tool_call_id:g.toolCallId,content:y})}break}default:{const g=u;throw new Error(`Unsupported role: ${g}`)}}return{messages:o,warnings:l}}function To({id:t,model:r,created:o}){return{id:t??void 0,modelId:r??void 0,timestamp:o?new Date(o*1e3):void 0}}function Za(t){switch(t){case"stop":return"stop";case"length":return"length";case"content_filter":return"content-filter";case"function_call":case"tool_calls":return"tool-calls";default:return"unknown"}}var U2=qt(()=>We(B({id:I().nullish(),created:X().nullish(),model:I().nullish(),choices:ve(B({message:B({role:ie("assistant").nullish(),content:I().nullish(),tool_calls:ve(B({id:I().nullish(),type:ie("function"),function:B({name:I(),arguments:I()})})).nullish(),annotations:ve(B({type:ie("url_citation"),url_citation:B({start_index:X(),end_index:X(),url:I(),title:I()})})).nullish()}),index:X(),logprobs:B({content:ve(B({token:I(),logprob:X(),top_logprobs:ve(B({token:I(),logprob:X()}))})).nullish()}).nullish(),finish_reason:I().nullish()})),usage:B({prompt_tokens:X().nullish(),completion_tokens:X().nullish(),total_tokens:X().nullish(),prompt_tokens_details:B({cached_tokens:X().nullish()}).nullish(),completion_tokens_details:B({reasoning_tokens:X().nullish(),accepted_prediction_tokens:X().nullish(),rejected_prediction_tokens:X().nullish()}).nullish()}).nullish()}))),z2=qt(()=>We(lt([B({id:I().nullish(),created:X().nullish(),model:I().nullish(),choices:ve(B({delta:B({role:ft(["assistant"]).nullish(),content:I().nullish(),tool_calls:ve(B({index:X(),id:I().nullish(),type:ie("function").nullish(),function:B({name:I().nullish(),arguments:I().nullish()})})).nullish(),annotations:ve(B({type:ie("url_citation"),url_citation:B({start_index:X(),end_index:X(),url:I(),title:I()})})).nullish()}).nullish(),logprobs:B({content:ve(B({token:I(),logprob:X(),top_logprobs:ve(B({token:I(),logprob:X()}))})).nullish()}).nullish(),finish_reason:I().nullish(),index:X()})),usage:B({prompt_tokens:X().nullish(),completion_tokens:X().nullish(),total_tokens:X().nullish(),prompt_tokens_details:B({cached_tokens:X().nullish()}).nullish(),completion_tokens_details:B({reasoning_tokens:X().nullish(),accepted_prediction_tokens:X().nullish(),rejected_prediction_tokens:X().nullish()}).nullish()}).nullish()}),cs]))),V2=qt(()=>We(B({logitBias:Dt(cp(),X()).optional(),logprobs:lt([$t(),X()]).optional(),parallelToolCalls:$t().optional(),user:I().optional(),reasoningEffort:ft(["none","minimal","low","medium","high","xhigh"]).optional(),maxCompletionTokens:X().optional(),store:$t().optional(),metadata:Dt(I().max(64),I().max(512)).optional(),prediction:Dt(I(),ri()).optional(),structuredOutputs:$t().optional(),serviceTier:ft(["auto","flex","priority","default"]).optional(),strictJsonSchema:$t().optional(),textVerbosity:ft(["low","medium","high"]).optional(),promptCacheKey:I().optional(),promptCacheRetention:ft(["in_memory","24h"]).optional(),safetyIdentifier:I().optional()})));function Z2({tools:t,toolChoice:r,structuredOutputs:o,strictJsonSchema:l}){t=t?.length?t:void 0;const u=[];if(t==null)return{tools:void 0,toolChoice:void 0,toolWarnings:u};const f=[];for(const x of t)switch(x.type){case"function":f.push({type:"function",function:{name:x.name,description:x.description,parameters:x.inputSchema,strict:o?l:void 0}});break;default:u.push({type:"unsupported-tool",tool:x});break}if(r==null)return{tools:f,toolChoice:void 0,toolWarnings:u};const g=r.type;switch(g){case"auto":case"none":case"required":return{tools:f,toolChoice:g,toolWarnings:u};case"tool":return{tools:f,toolChoice:{type:"function",function:{name:r.toolName}},toolWarnings:u};default:{const x=g;throw new Ln({functionality:`tool choice type: ${x}`})}}}var j2=class{constructor(t,r){this.specificationVersion="v2",this.supportedUrls={"image/*":[/^https?:\/\/.*$/]},this.modelId=t,this.config=r}get provider(){return this.config.provider}async getArgs({prompt:t,maxOutputTokens:r,temperature:o,topP:l,topK:u,frequencyPenalty:f,presencePenalty:g,stopSequences:x,responseFormat:y,seed:m,tools:E,toolChoice:C,providerOptions:P}){var O,D,R,M;const V=[],U=(O=await Kn({provider:"openai",providerOptions:P,schema:V2}))!=null?O:{},k=(D=U.structuredOutputs)!=null?D:!0,J=Nu(this.modelId);u!=null&&V.push({type:"unsupported-setting",setting:"topK"}),y?.type==="json"&&y.schema!=null&&!k&&V.push({type:"unsupported-setting",setting:"responseFormat",details:"JSON response format schema is only supported with structuredOutputs"});const{messages:be,warnings:Z}=$2({prompt:t,systemMessageMode:J.systemMessageMode});V.push(...Z);const z=(R=U.strictJsonSchema)!=null?R:!1,Y={model:this.modelId,logit_bias:U.logitBias,logprobs:U.logprobs===!0||typeof U.logprobs=="number"?!0:void 0,top_logprobs:typeof U.logprobs=="number"?U.logprobs:typeof U.logprobs=="boolean"&&U.logprobs?0:void 0,user:U.user,parallel_tool_calls:U.parallelToolCalls,max_tokens:r,temperature:o,top_p:l,frequency_penalty:f,presence_penalty:g,response_format:y?.type==="json"?k&&y.schema!=null?{type:"json_schema",json_schema:{schema:y.schema,strict:z,name:(M=y.name)!=null?M:"response",description:y.description}}:{type:"json_object"}:void 0,stop:x,seed:m,verbosity:U.textVerbosity,max_completion_tokens:U.maxCompletionTokens,store:U.store,metadata:U.metadata,prediction:U.prediction,reasoning_effort:U.reasoningEffort,service_tier:U.serviceTier,prompt_cache_key:U.promptCacheKey,prompt_cache_retention:U.promptCacheRetention,safety_identifier:U.safetyIdentifier,messages:be};J.isReasoningModel?((U.reasoningEffort!=="none"||!J.supportsNonReasoningParameters)&&(Y.temperature!=null&&(Y.temperature=void 0,V.push({type:"unsupported-setting",setting:"temperature",details:"temperature is not supported for reasoning models"})),Y.top_p!=null&&(Y.top_p=void 0,V.push({type:"unsupported-setting",setting:"topP",details:"topP is not supported for reasoning models"})),Y.logprobs!=null&&(Y.logprobs=void 0,V.push({type:"other",message:"logprobs is not supported for reasoning models"}))),Y.frequency_penalty!=null&&(Y.frequency_penalty=void 0,V.push({type:"unsupported-setting",setting:"frequencyPenalty",details:"frequencyPenalty is not supported for reasoning models"})),Y.presence_penalty!=null&&(Y.presence_penalty=void 0,V.push({type:"unsupported-setting",setting:"presencePenalty",details:"presencePenalty is not supported for reasoning models"})),Y.logit_bias!=null&&(Y.logit_bias=void 0,V.push({type:"other",message:"logitBias is not supported for reasoning models"})),Y.top_logprobs!=null&&(Y.top_logprobs=void 0,V.push({type:"other",message:"topLogprobs is not supported for reasoning models"})),Y.max_tokens!=null&&(Y.max_completion_tokens==null&&(Y.max_completion_tokens=Y.max_tokens),Y.max_tokens=void 0)):(this.modelId.startsWith("gpt-4o-search-preview")||this.modelId.startsWith("gpt-4o-mini-search-preview"))&&Y.temperature!=null&&(Y.temperature=void 0,V.push({type:"unsupported-setting",setting:"temperature",details:"temperature is not supported for the search preview models and has been removed."})),U.serviceTier==="flex"&&!J.supportsFlexProcessing&&(V.push({type:"unsupported-setting",setting:"serviceTier",details:"flex processing is only available for o3, o4-mini, and gpt-5 models"}),Y.service_tier=void 0),U.serviceTier==="priority"&&!J.supportsPriorityProcessing&&(V.push({type:"unsupported-setting",setting:"serviceTier",details:"priority processing is only available for supported models (gpt-4, gpt-5, gpt-5-mini, o3, o4-mini) and requires Enterprise access. gpt-5-nano is not supported"}),Y.service_tier=void 0);const{tools:W,toolChoice:de,toolWarnings:me}=Z2({tools:E,toolChoice:C,structuredOutputs:k,strictJsonSchema:z});return{args:{...Y,tools:W,tool_choice:de},warnings:[...V,...me]}}async doGenerate(t){var r,o,l,u,f,g,x,y,m,E,C,P,O,D;const{args:R,warnings:M}=await this.getArgs(t),{responseHeaders:V,value:U,rawValue:k}=await Fn({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:Rn(this.config.headers(),t.headers),body:R,failedResponseHandler:Dn,successfulResponseHandler:Ar(U2),abortSignal:t.abortSignal,fetch:this.config.fetch}),J=U.choices[0],be=[],Z=J.message.content;Z!=null&&Z.length>0&&be.push({type:"text",text:Z});for(const de of(r=J.message.tool_calls)!=null?r:[])be.push({type:"tool-call",toolCallId:(o=de.id)!=null?o:Cn(),toolName:de.function.name,input:de.function.arguments});for(const de of(l=J.message.annotations)!=null?l:[])be.push({type:"source",sourceType:"url",id:Cn(),url:de.url_citation.url,title:de.url_citation.title});const z=(u=U.usage)==null?void 0:u.completion_tokens_details,Y=(f=U.usage)==null?void 0:f.prompt_tokens_details,W={openai:{}};return z?.accepted_prediction_tokens!=null&&(W.openai.acceptedPredictionTokens=z?.accepted_prediction_tokens),z?.rejected_prediction_tokens!=null&&(W.openai.rejectedPredictionTokens=z?.rejected_prediction_tokens),((g=J.logprobs)==null?void 0:g.content)!=null&&(W.openai.logprobs=J.logprobs.content),{content:be,finishReason:Za(J.finish_reason),usage:{inputTokens:(y=(x=U.usage)==null?void 0:x.prompt_tokens)!=null?y:void 0,outputTokens:(E=(m=U.usage)==null?void 0:m.completion_tokens)!=null?E:void 0,totalTokens:(P=(C=U.usage)==null?void 0:C.total_tokens)!=null?P:void 0,reasoningTokens:(O=z?.reasoning_tokens)!=null?O:void 0,cachedInputTokens:(D=Y?.cached_tokens)!=null?D:void 0},request:{body:R},response:{...To(U),headers:V,body:k},warnings:M,providerMetadata:W}}async doStream(t){const{args:r,warnings:o}=await this.getArgs(t),l={...r,stream:!0,stream_options:{include_usage:!0}},{responseHeaders:u,value:f}=await Fn({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:Rn(this.config.headers(),t.headers),body:l,failedResponseHandler:Dn,successfulResponseHandler:ls(z2),abortSignal:t.abortSignal,fetch:this.config.fetch}),g=[];let x="unknown";const y={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0};let m=!1,E=!1;const C={openai:{}};return{stream:f.pipeThrough(new TransformStream({start(P){P.enqueue({type:"stream-start",warnings:o})},transform(P,O){var D,R,M,V,U,k,J,be,Z,z,Y,W,de,me,pe,Ce,le,L,te,K,ne,fe,xe,ye;if(t.includeRawChunks&&O.enqueue({type:"raw",rawValue:P.rawValue}),!P.success){x="error",O.enqueue({type:"error",error:P.error});return}const ee=P.value;if("error"in ee){x="error",O.enqueue({type:"error",error:ee.error});return}if(!m){const _e=To(ee);Object.values(_e).some(Boolean)&&(m=!0,O.enqueue({type:"response-metadata",...To(ee)}))}ee.usage!=null&&(y.inputTokens=(D=ee.usage.prompt_tokens)!=null?D:void 0,y.outputTokens=(R=ee.usage.completion_tokens)!=null?R:void 0,y.totalTokens=(M=ee.usage.total_tokens)!=null?M:void 0,y.reasoningTokens=(U=(V=ee.usage.completion_tokens_details)==null?void 0:V.reasoning_tokens)!=null?U:void 0,y.cachedInputTokens=(J=(k=ee.usage.prompt_tokens_details)==null?void 0:k.cached_tokens)!=null?J:void 0,((be=ee.usage.completion_tokens_details)==null?void 0:be.accepted_prediction_tokens)!=null&&(C.openai.acceptedPredictionTokens=(Z=ee.usage.completion_tokens_details)==null?void 0:Z.accepted_prediction_tokens),((z=ee.usage.completion_tokens_details)==null?void 0:z.rejected_prediction_tokens)!=null&&(C.openai.rejectedPredictionTokens=(Y=ee.usage.completion_tokens_details)==null?void 0:Y.rejected_prediction_tokens));const he=ee.choices[0];if(he?.finish_reason!=null&&(x=Za(he.finish_reason)),((W=he?.logprobs)==null?void 0:W.content)!=null&&(C.openai.logprobs=he.logprobs.content),he?.delta==null)return;const Ee=he.delta;if(Ee.content!=null&&(E||(O.enqueue({type:"text-start",id:"0"}),E=!0),O.enqueue({type:"text-delta",id:"0",delta:Ee.content})),Ee.tool_calls!=null)for(const _e of Ee.tool_calls){const T=_e.index;if(g[T]==null){if(_e.type!=="function")throw new Ao({data:_e,message:"Expected 'function' type."});if(_e.id==null)throw new Ao({data:_e,message:"Expected 'id' to be a string."});if(((de=_e.function)==null?void 0:de.name)==null)throw new Ao({data:_e,message:"Expected 'function.name' to be a string."});O.enqueue({type:"tool-input-start",id:_e.id,toolName:_e.function.name}),g[T]={id:_e.id,type:"function",function:{name:_e.function.name,arguments:(me=_e.function.arguments)!=null?me:""},hasFinished:!1};const we=g[T];((pe=we.function)==null?void 0:pe.name)!=null&&((Ce=we.function)==null?void 0:Ce.arguments)!=null&&(we.function.arguments.length>0&&O.enqueue({type:"tool-input-delta",id:we.id,delta:we.function.arguments}),Ua(we.function.arguments)&&(O.enqueue({type:"tool-input-end",id:we.id}),O.enqueue({type:"tool-call",toolCallId:(le=we.id)!=null?le:Cn(),toolName:we.function.name,input:we.function.arguments}),we.hasFinished=!0));continue}const ce=g[T];ce.hasFinished||(((L=_e.function)==null?void 0:L.arguments)!=null&&(ce.function.arguments+=(K=(te=_e.function)==null?void 0:te.arguments)!=null?K:""),O.enqueue({type:"tool-input-delta",id:ce.id,delta:(ne=_e.function.arguments)!=null?ne:""}),((fe=ce.function)==null?void 0:fe.name)!=null&&((xe=ce.function)==null?void 0:xe.arguments)!=null&&Ua(ce.function.arguments)&&(O.enqueue({type:"tool-input-end",id:ce.id}),O.enqueue({type:"tool-call",toolCallId:(ye=ce.id)!=null?ye:Cn(),toolName:ce.function.name,input:ce.function.arguments}),ce.hasFinished=!0))}if(Ee.annotations!=null)for(const _e of Ee.annotations)O.enqueue({type:"source",sourceType:"url",id:Cn(),url:_e.url_citation.url,title:_e.url_citation.title})},flush(P){E&&P.enqueue({type:"text-end",id:"0"}),P.enqueue({type:"finish",finishReason:x,usage:y,...C!=null?{providerMetadata:C}:{}})}})),request:{body:l},response:{headers:u}}}};function H2({prompt:t,user:r="user",assistant:o="assistant"}){let l="";t[0].role==="system"&&(l+=`${t[0].content}
49
49
 
50
- `,t=t.slice(1));for(const{role:u,content:f}of t)switch(u){case"system":throw new C2({message:"Unexpected system message in prompt: ${content}",prompt:t});case"user":{const g=f.map(m=>{switch(m.type){case"text":return m.text}}).filter(Boolean).join("");l+=`${n}:
50
+ `,t=t.slice(1));for(const{role:u,content:f}of t)switch(u){case"system":throw new hm({message:"Unexpected system message in prompt: ${content}",prompt:t});case"user":{const g=f.map(x=>{switch(x.type){case"text":return x.text}}).filter(Boolean).join("");l+=`${r}:
51
51
  ${g}
52
52
 
53
- `;break}case"assistant":{const g=f.map(m=>{switch(m.type){case"text":return m.text;case"tool-call":throw new Zn({functionality:"tool-call messages"})}}).join("");l+=`${o}:
53
+ `;break}case"assistant":{const g=f.map(x=>{switch(x.type){case"text":return x.text;case"tool-call":throw new Ln({functionality:"tool-call messages"})}}).join("");l+=`${o}:
54
54
  ${g}
55
55
 
56
- `;break}case"tool":throw new Zn({functionality:"tool messages"});default:{const g=u;throw new Error(`Unsupported role: ${g}`)}}return l+=`${o}:
56
+ `;break}case"tool":throw new Ln({functionality:"tool messages"});default:{const g=u;throw new Error(`Unsupported role: ${g}`)}}return l+=`${o}:
57
57
  `,{prompt:l,stopSequences:[`
58
- ${n}:`]}}function Ka({id:t,model:n,created:o}){return{id:t??void 0,modelId:n??void 0,timestamp:o!=null?new Date(o*1e3):void 0}}function Ja(t){switch(t){case"stop":return"stop";case"length":return"length";case"content_filter":return"content-filter";case"function_call":case"tool_calls":return"tool-calls";default:return"unknown"}}var tx=Yt(()=>Ke(B({id:I().nullish(),created:W().nullish(),model:I().nullish(),choices:_e(B({text:I(),finish_reason:I(),logprobs:B({tokens:_e(I()),token_logprobs:_e(W()),top_logprobs:_e(Dt(I(),W())).nullish()}).nullish()})),usage:B({prompt_tokens:W(),completion_tokens:W(),total_tokens:W()}).nullish()}))),nx=Yt(()=>Ke(ut([B({id:I().nullish(),created:W().nullish(),model:I().nullish(),choices:_e(B({text:I(),finish_reason:I().nullish(),index:W(),logprobs:B({tokens:_e(I()),token_logprobs:_e(W()),top_logprobs:_e(Dt(I(),W())).nullish()}).nullish()})),usage:B({prompt_tokens:W(),completion_tokens:W(),total_tokens:W()}).nullish()}),ms]))),Qa=Yt(()=>Ke(B({echo:Ft().optional(),logitBias:Dt(I(),W()).optional(),suffix:I().optional(),user:I().optional(),logprobs:ut([Ft(),W()]).optional()}))),rx=class{constructor(t,n){this.specificationVersion="v2",this.supportedUrls={},this.modelId=t,this.config=n}get providerOptionsName(){return this.config.provider.split(".")[0].trim()}get provider(){return this.config.provider}async getArgs({prompt:t,maxOutputTokens:n,temperature:o,topP:l,topK:u,frequencyPenalty:f,presencePenalty:g,stopSequences:m,responseFormat:y,tools:x,toolChoice:A,seed:b,providerOptions:P}){const N=[],R={...await nr({provider:"openai",providerOptions:P,schema:Qa}),...await nr({provider:this.providerOptionsName,providerOptions:P,schema:Qa})};u!=null&&N.push({type:"unsupported-setting",setting:"topK"}),x?.length&&N.push({type:"unsupported-setting",setting:"tools"}),A!=null&&N.push({type:"unsupported-setting",setting:"toolChoice"}),y!=null&&y.type!=="text"&&N.push({type:"unsupported-setting",setting:"responseFormat",details:"JSON response format is not supported."});const{prompt:D,stopSequences:M}=ex({prompt:t}),z=[...M??[],...m??[]];return{args:{model:this.modelId,echo:R.echo,logit_bias:R.logitBias,logprobs:R?.logprobs===!0?0:R?.logprobs===!1?void 0:R?.logprobs,suffix:R.suffix,user:R.user,max_tokens:n,temperature:o,top_p:l,frequency_penalty:f,presence_penalty:g,seed:b,prompt:D,stop:z.length>0?z:void 0},warnings:N}}async doGenerate(t){var n,o,l;const{args:u,warnings:f}=await this.getArgs(t),{responseHeaders:g,value:m,rawValue:y}=await Vn({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:Bn(this.config.headers(),t.headers),body:u,failedResponseHandler:Ln,successfulResponseHandler:Nr(tx),abortSignal:t.abortSignal,fetch:this.config.fetch}),x=m.choices[0],A={openai:{}};return x.logprobs!=null&&(A.openai.logprobs=x.logprobs),{content:[{type:"text",text:x.text}],usage:{inputTokens:(n=m.usage)==null?void 0:n.prompt_tokens,outputTokens:(o=m.usage)==null?void 0:o.completion_tokens,totalTokens:(l=m.usage)==null?void 0:l.total_tokens},finishReason:Ja(x.finish_reason),request:{body:u},response:{...Ka(m),headers:g,body:y},providerMetadata:A,warnings:f}}async doStream(t){const{args:n,warnings:o}=await this.getArgs(t),l={...n,stream:!0,stream_options:{include_usage:!0}},{responseHeaders:u,value:f}=await Vn({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:Bn(this.config.headers(),t.headers),body:l,failedResponseHandler:Ln,successfulResponseHandler:gs(nx),abortSignal:t.abortSignal,fetch:this.config.fetch});let g="unknown";const m={openai:{}},y={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0};let x=!0;return{stream:f.pipeThrough(new TransformStream({start(A){A.enqueue({type:"stream-start",warnings:o})},transform(A,b){if(t.includeRawChunks&&b.enqueue({type:"raw",rawValue:A.rawValue}),!A.success){g="error",b.enqueue({type:"error",error:A.error});return}const P=A.value;if("error"in P){g="error",b.enqueue({type:"error",error:P.error});return}x&&(x=!1,b.enqueue({type:"response-metadata",...Ka(P)}),b.enqueue({type:"text-start",id:"0"})),P.usage!=null&&(y.inputTokens=P.usage.prompt_tokens,y.outputTokens=P.usage.completion_tokens,y.totalTokens=P.usage.total_tokens);const N=P.choices[0];N?.finish_reason!=null&&(g=Ja(N.finish_reason)),N?.logprobs!=null&&(m.openai.logprobs=N.logprobs),N?.text!=null&&N.text.length>0&&b.enqueue({type:"text-delta",id:"0",delta:N.text})},flush(A){x||A.enqueue({type:"text-end",id:"0"}),A.enqueue({type:"finish",finishReason:g,providerMetadata:m,usage:y})}})),request:{body:l},response:{headers:u}}}},ix=Yt(()=>Ke(B({dimensions:W().optional(),user:I().optional()}))),ox=Yt(()=>Ke(B({data:_e(B({embedding:_e(W())})),usage:B({prompt_tokens:W()}).nullish()}))),sx=class{constructor(t,n){this.specificationVersion="v2",this.maxEmbeddingsPerCall=2048,this.supportsParallelCalls=!0,this.modelId=t,this.config=n}get provider(){return this.config.provider}async doEmbed({values:t,headers:n,abortSignal:o,providerOptions:l}){var u;if(t.length>this.maxEmbeddingsPerCall)throw new S2({provider:this.provider,modelId:this.modelId,maxEmbeddingsPerCall:this.maxEmbeddingsPerCall,values:t});const f=(u=await nr({provider:"openai",providerOptions:l,schema:ix}))!=null?u:{},{responseHeaders:g,value:m,rawValue:y}=await Vn({url:this.config.url({path:"/embeddings",modelId:this.modelId}),headers:Bn(this.config.headers(),n),body:{model:this.modelId,input:t,encoding_format:"float",dimensions:f.dimensions,user:f.user},failedResponseHandler:Ln,successfulResponseHandler:Nr(ox),abortSignal:o,fetch:this.config.fetch});return{embeddings:m.data.map(x=>x.embedding),usage:m.usage?{tokens:m.usage.prompt_tokens}:void 0,response:{headers:g,body:y}}}},ax=Yt(()=>Ke(B({created:W().nullish(),data:_e(B({b64_json:I(),revised_prompt:I().nullish()})),background:I().nullish(),output_format:I().nullish(),size:I().nullish(),quality:I().nullish(),usage:B({input_tokens:W().nullish(),output_tokens:W().nullish(),total_tokens:W().nullish(),input_tokens_details:B({image_tokens:W().nullish(),text_tokens:W().nullish()}).nullish()}).nullish()}))),lx={"dall-e-3":1,"dall-e-2":10,"gpt-image-1":10,"gpt-image-1-mini":10,"gpt-image-1.5":10},cx=new Set(["gpt-image-1","gpt-image-1-mini","gpt-image-1.5"]),ux=class{constructor(t,n){this.modelId=t,this.config=n,this.specificationVersion="v2"}get maxImagesPerCall(){var t;return(t=lx[this.modelId])!=null?t:1}get provider(){return this.config.provider}async doGenerate({prompt:t,n,size:o,aspectRatio:l,seed:u,providerOptions:f,headers:g,abortSignal:m}){var y,x,A,b;const P=[];l!=null&&P.push({type:"unsupported-setting",setting:"aspectRatio",details:"This model does not support aspect ratio. Use `size` instead."}),u!=null&&P.push({type:"unsupported-setting",setting:"seed"});const N=(A=(x=(y=this.config._internal)==null?void 0:y.currentDate)==null?void 0:x.call(y))!=null?A:new Date,{value:R,responseHeaders:D}=await Vn({url:this.config.url({path:"/images/generations",modelId:this.modelId}),headers:Bn(this.config.headers(),g),body:{model:this.modelId,prompt:t,n,size:o,...(b=f.openai)!=null?b:{},...cx.has(this.modelId)?{}:{response_format:"b64_json"}},failedResponseHandler:Ln,successfulResponseHandler:Nr(ax),abortSignal:m,fetch:this.config.fetch});return{images:R.data.map(M=>M.b64_json),warnings:P,response:{timestamp:N,modelId:this.modelId,headers:D},providerMetadata:{openai:{images:R.data.map(M=>({...M.revised_prompt?{revisedPrompt:M.revised_prompt}:{},...R.created!=null?{created:R.created}:{},...R.size!=null?{size:R.size}:{},...R.quality!=null?{quality:R.quality}:{},...R.background!=null?{background:R.background}:{},...R.output_format!=null?{outputFormat:R.output_format}:{}}))}}}}},dx=zt(()=>Ke(B({code:I().nullish(),containerId:I()}))),fx=zt(()=>Ke(B({outputs:_e(Lt("type",[B({type:re("logs"),logs:I()}),B({type:re("image"),url:I()})])).nullish()}))),hx=zt(()=>Ke(B({container:ut([I(),B({fileIds:_e(I()).optional()})]).optional()}))),px=Or({id:"openai.code_interpreter",name:"code_interpreter",inputSchema:dx,outputSchema:fx}),gx=(t={})=>px(t),Fu=B({key:I(),type:pt(["eq","ne","gt","gte","lt","lte","in","nin"]),value:ut([I(),W(),Ft(),_e(I())])}),$u=B({type:pt(["and","or"]),filters:_e(ut([Fu,Zc(()=>$u)]))}),mx=zt(()=>Ke(B({vectorStoreIds:_e(I()),maxNumResults:W().optional(),ranking:B({ranker:I().optional(),scoreThreshold:W().optional()}).optional(),filters:ut([Fu,$u]).optional()}))),xx=zt(()=>Ke(B({queries:_e(I()),results:_e(B({attributes:Dt(I(),Qr()),fileId:I(),filename:I(),score:W(),text:I()})).nullable()}))),wx=Or({id:"openai.file_search",name:"file_search",inputSchema:B({}),outputSchema:xx}),yx=zt(()=>Ke(B({background:pt(["auto","opaque","transparent"]).optional(),inputFidelity:pt(["low","high"]).optional(),inputImageMask:B({fileId:I().optional(),imageUrl:I().optional()}).optional(),model:I().optional(),moderation:pt(["auto"]).optional(),outputCompression:W().int().min(0).max(100).optional(),outputFormat:pt(["png","jpeg","webp"]).optional(),partialImages:W().int().min(0).max(3).optional(),quality:pt(["auto","low","medium","high"]).optional(),size:pt(["1024x1024","1024x1536","1536x1024","auto"]).optional()}).strict())),_x=zt(()=>Ke(B({}))),vx=zt(()=>Ke(B({result:I()}))),Cx=Or({id:"openai.image_generation",name:"image_generation",inputSchema:_x,outputSchema:vx}),bx=(t={})=>Cx(t),Uu=zt(()=>Ke(B({action:B({type:re("exec"),command:_e(I()),timeoutMs:W().optional(),user:I().optional(),workingDirectory:I().optional(),env:Dt(I(),I()).optional()})}))),zu=zt(()=>Ke(B({output:I()}))),Ex=Or({id:"openai.local_shell",name:"local_shell",inputSchema:Uu,outputSchema:zu}),Ax=zt(()=>Ke(B({externalWebAccess:Ft().optional(),filters:B({allowedDomains:_e(I()).optional()}).optional(),searchContextSize:pt(["low","medium","high"]).optional(),userLocation:B({type:re("approximate"),country:I().optional(),city:I().optional(),region:I().optional(),timezone:I().optional()}).optional()}))),Ix=zt(()=>Ke(B({}))),Sx=zt(()=>Ke(B({action:Lt("type",[B({type:re("search"),query:I().optional()}),B({type:re("openPage"),url:I().nullish()}),B({type:re("findInPage"),url:I().nullish(),pattern:I().nullish()})]),sources:_e(Lt("type",[B({type:re("url"),url:I()}),B({type:re("api"),name:I()})])).optional()}))),Tx=Or({id:"openai.web_search",name:"web_search",inputSchema:Ix,outputSchema:Sx}),Ox=(t={})=>Tx(t),Nx=zt(()=>Ke(B({searchContextSize:pt(["low","medium","high"]).optional(),userLocation:B({type:re("approximate"),country:I().optional(),city:I().optional(),region:I().optional(),timezone:I().optional()}).optional()}))),kx=zt(()=>Ke(B({}))),Rx=zt(()=>Ke(B({action:Lt("type",[B({type:re("search"),query:I().optional()}),B({type:re("openPage"),url:I().nullish()}),B({type:re("findInPage"),url:I().nullish(),pattern:I().nullish()})])}))),Dx=Or({id:"openai.web_search_preview",name:"web_search_preview",inputSchema:kx,outputSchema:Rx}),Mx={codeInterpreter:gx,fileSearch:wx,imageGeneration:bx,localShell:Ex,webSearchPreview:Dx,webSearch:Ox};function el(t,n){return n?n.some(o=>t.startsWith(o)):!1}async function Px({prompt:t,systemMessageMode:n,fileIdPrefixes:o,store:l,hasLocalShellTool:u=!1}){var f,g,m,y;const x=[],A=[];for(const{role:b,content:P}of t)switch(b){case"system":{switch(n){case"system":{x.push({role:"system",content:P});break}case"developer":{x.push({role:"developer",content:P});break}case"remove":{A.push({type:"other",message:"system messages are removed for this model"});break}default:{const N=n;throw new Error(`Unsupported system message mode: ${N}`)}}break}case"user":{x.push({role:"user",content:P.map((N,R)=>{var D,M,z;switch(N.type){case"text":return{type:"input_text",text:N.text};case"file":if(N.mediaType.startsWith("image/")){const U=N.mediaType==="image/*"?"image/jpeg":N.mediaType;return{type:"input_image",...N.data instanceof URL?{image_url:N.data.toString()}:typeof N.data=="string"&&el(N.data,o)?{file_id:N.data}:{image_url:`data:${U};base64,${Ir(N.data)}`},detail:(M=(D=N.providerOptions)==null?void 0:D.openai)==null?void 0:M.imageDetail}}else{if(N.mediaType==="application/pdf")return N.data instanceof URL?{type:"input_file",file_url:N.data.toString()}:{type:"input_file",...typeof N.data=="string"&&el(N.data,o)?{file_id:N.data}:{filename:(z=N.filename)!=null?z:`part-${R}.pdf`,file_data:`data:application/pdf;base64,${Ir(N.data)}`}};throw new Zn({functionality:`file part media type ${N.mediaType}`})}}})});break}case"assistant":{const N={},R={};for(const D of P)switch(D.type){case"text":{const M=(g=(f=D.providerOptions)==null?void 0:f.openai)==null?void 0:g.itemId;if(l&&M!=null){x.push({type:"item_reference",id:M});break}x.push({role:"assistant",content:[{type:"output_text",text:D.text}],id:M});break}case"tool-call":{if(R[D.toolCallId]=D,D.providerExecuted)break;const M=(y=(m=D.providerOptions)==null?void 0:m.openai)==null?void 0:y.itemId;if(l&&M!=null){x.push({type:"item_reference",id:M});break}if(u&&D.toolName==="local_shell"){const z=await Jn({value:D.input,schema:Uu});x.push({type:"local_shell_call",call_id:D.toolCallId,id:M,action:{type:"exec",command:z.action.command,timeout_ms:z.action.timeoutMs,user:z.action.user,working_directory:z.action.workingDirectory,env:z.action.env}});break}x.push({type:"function_call",call_id:D.toolCallId,name:D.toolName,arguments:JSON.stringify(D.input),id:M});break}case"tool-result":{l?x.push({type:"item_reference",id:D.toolCallId}):A.push({type:"other",message:`Results for OpenAI tool ${D.toolName} are not sent to the API when store is false`});break}case"reasoning":{const M=await nr({provider:"openai",providerOptions:D.providerOptions,schema:Bx}),z=M?.itemId;if(z!=null){const U=N[z];if(l)U===void 0&&(x.push({type:"item_reference",id:z}),N[z]={type:"reasoning",id:z,summary:[]});else{const k=[];D.text.length>0?k.push({type:"summary_text",text:D.text}):U!==void 0&&A.push({type:"other",message:`Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${JSON.stringify(D)}.`}),U===void 0?(N[z]={type:"reasoning",id:z,encrypted_content:M?.reasoningEncryptedContent,summary:k},x.push(N[z])):(U.summary.push(...k),M?.reasoningEncryptedContent!=null&&(U.encrypted_content=M.reasoningEncryptedContent))}}else A.push({type:"other",message:`Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${JSON.stringify(D)}.`});break}}break}case"tool":{for(const N of P){const R=N.output;if(u&&N.toolName==="local_shell"&&R.type==="json"){const M=await Jn({value:R.value,schema:zu});x.push({type:"local_shell_call_output",call_id:N.toolCallId,output:M.output});break}let D;switch(R.type){case"text":case"error-text":D=R.value;break;case"json":case"error-json":D=JSON.stringify(R.value);break;case"content":D=R.value.map(M=>{switch(M.type){case"text":return{type:"input_text",text:M.text};case"media":return M.mediaType.startsWith("image/")?{type:"input_image",image_url:`data:${M.mediaType};base64,${M.data}`}:{type:"input_file",filename:"data",file_data:`data:${M.mediaType};base64,${M.data}`}}});break}x.push({type:"function_call_output",call_id:N.toolCallId,output:D})}break}default:{const N=b;throw new Error(`Unsupported role: ${N}`)}}return{input:x,warnings:A}}var Bx=B({itemId:I().nullish(),reasoningEncryptedContent:I().nullish()});function tl({finishReason:t,hasFunctionCall:n}){switch(t){case void 0:case null:return n?"tool-calls":"stop";case"max_output_tokens":return"length";case"content_filter":return"content-filter";default:return n?"tool-calls":"unknown"}}var Lx=Yt(()=>Ke(ut([B({type:re("response.output_text.delta"),item_id:I(),delta:I(),logprobs:_e(B({token:I(),logprob:W(),top_logprobs:_e(B({token:I(),logprob:W()}))})).nullish()}),B({type:pt(["response.completed","response.incomplete"]),response:B({incomplete_details:B({reason:I()}).nullish(),usage:B({input_tokens:W(),input_tokens_details:B({cached_tokens:W().nullish()}).nullish(),output_tokens:W(),output_tokens_details:B({reasoning_tokens:W().nullish()}).nullish()}),service_tier:I().nullish()})}),B({type:re("response.created"),response:B({id:I(),created_at:W(),model:I(),service_tier:I().nullish()})}),B({type:re("response.output_item.added"),output_index:W(),item:Lt("type",[B({type:re("message"),id:I()}),B({type:re("reasoning"),id:I(),encrypted_content:I().nullish()}),B({type:re("function_call"),id:I(),call_id:I(),name:I(),arguments:I()}),B({type:re("web_search_call"),id:I(),status:I()}),B({type:re("computer_call"),id:I(),status:I()}),B({type:re("file_search_call"),id:I()}),B({type:re("image_generation_call"),id:I()}),B({type:re("code_interpreter_call"),id:I(),container_id:I(),code:I().nullable(),outputs:_e(Lt("type",[B({type:re("logs"),logs:I()}),B({type:re("image"),url:I()})])).nullable(),status:I()})])}),B({type:re("response.output_item.done"),output_index:W(),item:Lt("type",[B({type:re("message"),id:I()}),B({type:re("reasoning"),id:I(),encrypted_content:I().nullish()}),B({type:re("function_call"),id:I(),call_id:I(),name:I(),arguments:I(),status:re("completed")}),B({type:re("code_interpreter_call"),id:I(),code:I().nullable(),container_id:I(),outputs:_e(Lt("type",[B({type:re("logs"),logs:I()}),B({type:re("image"),url:I()})])).nullable()}),B({type:re("image_generation_call"),id:I(),result:I()}),B({type:re("web_search_call"),id:I(),status:I(),action:Lt("type",[B({type:re("search"),query:I().nullish(),sources:_e(Lt("type",[B({type:re("url"),url:I()}),B({type:re("api"),name:I()})])).nullish()}),B({type:re("open_page"),url:I().nullish()}),B({type:re("find_in_page"),url:I().nullish(),pattern:I().nullish()})])}),B({type:re("file_search_call"),id:I(),queries:_e(I()),results:_e(B({attributes:Dt(I(),Qr()),file_id:I(),filename:I(),score:W(),text:I()})).nullish()}),B({type:re("local_shell_call"),id:I(),call_id:I(),action:B({type:re("exec"),command:_e(I()),timeout_ms:W().optional(),user:I().optional(),working_directory:I().optional(),env:Dt(I(),I()).optional()})}),B({type:re("computer_call"),id:I(),status:re("completed")})])}),B({type:re("response.function_call_arguments.delta"),item_id:I(),output_index:W(),delta:I()}),B({type:re("response.image_generation_call.partial_image"),item_id:I(),output_index:W(),partial_image_b64:I()}),B({type:re("response.code_interpreter_call_code.delta"),item_id:I(),output_index:W(),delta:I()}),B({type:re("response.code_interpreter_call_code.done"),item_id:I(),output_index:W(),code:I()}),B({type:re("response.output_text.annotation.added"),annotation:Lt("type",[B({type:re("url_citation"),start_index:W(),end_index:W(),url:I(),title:I()}),B({type:re("file_citation"),file_id:I(),filename:I().nullish(),index:W().nullish(),start_index:W().nullish(),end_index:W().nullish(),quote:I().nullish()})])}),B({type:re("response.reasoning_summary_part.added"),item_id:I(),summary_index:W()}),B({type:re("response.reasoning_summary_text.delta"),item_id:I(),summary_index:W(),delta:I()}),B({type:re("response.reasoning_summary_part.done"),item_id:I(),summary_index:W()}),B({type:re("error"),sequence_number:W(),error:B({type:I(),code:I(),message:I(),param:I().nullish()})}),B({type:I()}).loose().transform(t=>({type:"unknown_chunk",message:t.type}))]))),Fx=Yt(()=>Ke(B({id:I().optional(),created_at:W().optional(),error:B({message:I(),type:I(),param:I().nullish(),code:I()}).nullish(),model:I().optional(),output:_e(Lt("type",[B({type:re("message"),role:re("assistant"),id:I(),content:_e(B({type:re("output_text"),text:I(),logprobs:_e(B({token:I(),logprob:W(),top_logprobs:_e(B({token:I(),logprob:W()}))})).nullish(),annotations:_e(Lt("type",[B({type:re("url_citation"),start_index:W(),end_index:W(),url:I(),title:I()}),B({type:re("file_citation"),file_id:I(),filename:I().nullish(),index:W().nullish(),start_index:W().nullish(),end_index:W().nullish(),quote:I().nullish()}),B({type:re("container_file_citation"),container_id:I(),file_id:I(),filename:I().nullish(),start_index:W().nullish(),end_index:W().nullish(),index:W().nullish()}),B({type:re("file_path"),file_id:I(),index:W().nullish()})]))}))}),B({type:re("web_search_call"),id:I(),status:I(),action:Lt("type",[B({type:re("search"),query:I().nullish(),sources:_e(Lt("type",[B({type:re("url"),url:I()}),B({type:re("api"),name:I()})])).nullish()}),B({type:re("open_page"),url:I().nullish()}),B({type:re("find_in_page"),url:I().nullish(),pattern:I().nullish()})])}),B({type:re("file_search_call"),id:I(),queries:_e(I()),results:_e(B({attributes:Dt(I(),ut([I(),W(),Ft()])),file_id:I(),filename:I(),score:W(),text:I()})).nullish()}),B({type:re("code_interpreter_call"),id:I(),code:I().nullable(),container_id:I(),outputs:_e(Lt("type",[B({type:re("logs"),logs:I()}),B({type:re("image"),url:I()})])).nullable()}),B({type:re("image_generation_call"),id:I(),result:I()}),B({type:re("local_shell_call"),id:I(),call_id:I(),action:B({type:re("exec"),command:_e(I()),timeout_ms:W().optional(),user:I().optional(),working_directory:I().optional(),env:Dt(I(),I()).optional()})}),B({type:re("function_call"),call_id:I(),name:I(),arguments:I(),id:I()}),B({type:re("computer_call"),id:I(),status:I().optional()}),B({type:re("reasoning"),id:I(),encrypted_content:I().nullish(),summary:_e(B({type:re("summary_text"),text:I()}))})])).optional(),service_tier:I().nullish(),incomplete_details:B({reason:I()}).nullish(),usage:B({input_tokens:W(),input_tokens_details:B({cached_tokens:W().nullish()}).nullish(),output_tokens:W(),output_tokens_details:B({reasoning_tokens:W().nullish()}).nullish()}).optional()}))),Zu=20,$x=Yt(()=>Ke(B({conversation:I().nullish(),include:_e(pt(["reasoning.encrypted_content","file_search_call.results","message.output_text.logprobs"])).nullish(),instructions:I().nullish(),logprobs:ut([Ft(),W().min(1).max(Zu)]).optional(),maxToolCalls:W().nullish(),metadata:ai().nullish(),parallelToolCalls:Ft().nullish(),previousResponseId:I().nullish(),promptCacheKey:I().nullish(),promptCacheRetention:pt(["in_memory","24h"]).nullish(),reasoningEffort:I().nullish(),reasoningSummary:I().nullish(),safetyIdentifier:I().nullish(),serviceTier:pt(["auto","flex","priority","default"]).nullish(),store:Ft().nullish(),strictJsonSchema:Ft().nullish(),textVerbosity:pt(["low","medium","high"]).nullish(),truncation:pt(["auto","disabled"]).nullish(),user:I().nullish()})));async function Ux({tools:t,toolChoice:n,strictJsonSchema:o}){t=t?.length?t:void 0;const l=[];if(t==null)return{tools:void 0,toolChoice:void 0,toolWarnings:l};const u=[];for(const g of t)switch(g.type){case"function":u.push({type:"function",name:g.name,description:g.description,parameters:g.inputSchema,strict:o});break;case"provider-defined":{switch(g.id){case"openai.file_search":{const m=await Jn({value:g.args,schema:mx});u.push({type:"file_search",vector_store_ids:m.vectorStoreIds,max_num_results:m.maxNumResults,ranking_options:m.ranking?{ranker:m.ranking.ranker,score_threshold:m.ranking.scoreThreshold}:void 0,filters:m.filters});break}case"openai.local_shell":{u.push({type:"local_shell"});break}case"openai.web_search_preview":{const m=await Jn({value:g.args,schema:Nx});u.push({type:"web_search_preview",search_context_size:m.searchContextSize,user_location:m.userLocation});break}case"openai.web_search":{const m=await Jn({value:g.args,schema:Ax});u.push({type:"web_search",filters:m.filters!=null?{allowed_domains:m.filters.allowedDomains}:void 0,external_web_access:m.externalWebAccess,search_context_size:m.searchContextSize,user_location:m.userLocation});break}case"openai.code_interpreter":{const m=await Jn({value:g.args,schema:hx});u.push({type:"code_interpreter",container:m.container==null?{type:"auto",file_ids:void 0}:typeof m.container=="string"?m.container:{type:"auto",file_ids:m.container.fileIds}});break}case"openai.image_generation":{const m=await Jn({value:g.args,schema:yx});u.push({type:"image_generation",background:m.background,input_fidelity:m.inputFidelity,input_image_mask:m.inputImageMask?{file_id:m.inputImageMask.fileId,image_url:m.inputImageMask.imageUrl}:void 0,model:m.model,size:m.size,quality:m.quality,moderation:m.moderation,output_format:m.outputFormat,output_compression:m.outputCompression});break}}break}default:l.push({type:"unsupported-tool",tool:g});break}if(n==null)return{tools:u,toolChoice:void 0,toolWarnings:l};const f=n.type;switch(f){case"auto":case"none":case"required":return{tools:u,toolChoice:f,toolWarnings:l};case"tool":return{tools:u,toolChoice:n.toolName==="code_interpreter"||n.toolName==="file_search"||n.toolName==="image_generation"||n.toolName==="web_search_preview"||n.toolName==="web_search"?{type:n.toolName}:{type:"function",name:n.toolName},toolWarnings:l};default:{const g=f;throw new Zn({functionality:`tool choice type: ${g}`})}}}var zx=class{constructor(t,n){this.specificationVersion="v2",this.supportedUrls={"image/*":[/^https?:\/\/.*$/],"application/pdf":[/^https?:\/\/.*$/]},this.modelId=t,this.config=n}get provider(){return this.config.provider}async getArgs({maxOutputTokens:t,temperature:n,stopSequences:o,topP:l,topK:u,presencePenalty:f,frequencyPenalty:g,seed:m,prompt:y,providerOptions:x,tools:A,toolChoice:b,responseFormat:P}){var N,R,D,M;const z=[],U=Lu(this.modelId);u!=null&&z.push({type:"unsupported-setting",setting:"topK"}),m!=null&&z.push({type:"unsupported-setting",setting:"seed"}),f!=null&&z.push({type:"unsupported-setting",setting:"presencePenalty"}),g!=null&&z.push({type:"unsupported-setting",setting:"frequencyPenalty"}),o!=null&&z.push({type:"unsupported-setting",setting:"stopSequences"});const k=await nr({provider:"openai",providerOptions:x,schema:$x});k?.conversation&&k?.previousResponseId&&z.push({type:"unsupported-setting",setting:"conversation",details:"conversation and previousResponseId cannot be used together"});const{input:K,warnings:ve}=await Px({prompt:y,systemMessageMode:U.systemMessageMode,fileIdPrefixes:this.config.fileIdPrefixes,store:(N=k?.store)!=null?N:!0,hasLocalShellTool:Y("openai.local_shell")});z.push(...ve);const Q=(R=k?.strictJsonSchema)!=null?R:!1;let j=k?.include;function ie(X){j==null?j=[X]:j.includes(X)||(j=[...j,X])}function Y(X){return A?.find(te=>te.type==="provider-defined"&&te.id===X)!=null}const Ie=typeof k?.logprobs=="number"?k?.logprobs:k?.logprobs===!0?Zu:void 0;Ie&&ie("message.output_text.logprobs");const Ce=(D=A?.find(X=>X.type==="provider-defined"&&(X.id==="openai.web_search"||X.id==="openai.web_search_preview")))==null?void 0:D.name;Ce&&ie("web_search_call.action.sources"),Y("openai.code_interpreter")&&ie("code_interpreter_call.outputs");const he=k?.store;he===!1&&U.isReasoningModel&&ie("reasoning.encrypted_content");const xe={model:this.modelId,input:K,temperature:n,top_p:l,max_output_tokens:t,...(P?.type==="json"||k?.textVerbosity)&&{text:{...P?.type==="json"&&{format:P.schema!=null?{type:"json_schema",strict:Q,name:(M=P.name)!=null?M:"response",description:P.description,schema:P.schema}:{type:"json_object"}},...k?.textVerbosity&&{verbosity:k.textVerbosity}}},conversation:k?.conversation,max_tool_calls:k?.maxToolCalls,metadata:k?.metadata,parallel_tool_calls:k?.parallelToolCalls,previous_response_id:k?.previousResponseId,store:he,user:k?.user,instructions:k?.instructions,service_tier:k?.serviceTier,include:j,prompt_cache_key:k?.promptCacheKey,prompt_cache_retention:k?.promptCacheRetention,safety_identifier:k?.safetyIdentifier,top_logprobs:Ie,truncation:k?.truncation,...U.isReasoningModel&&(k?.reasoningEffort!=null||k?.reasoningSummary!=null)&&{reasoning:{...k?.reasoningEffort!=null&&{effort:k.reasoningEffort},...k?.reasoningSummary!=null&&{summary:k.reasoningSummary}}}};U.isReasoningModel?k?.reasoningEffort==="none"&&U.supportsNonReasoningParameters||(xe.temperature!=null&&(xe.temperature=void 0,z.push({type:"unsupported-setting",setting:"temperature",details:"temperature is not supported for reasoning models"})),xe.top_p!=null&&(xe.top_p=void 0,z.push({type:"unsupported-setting",setting:"topP",details:"topP is not supported for reasoning models"}))):(k?.reasoningEffort!=null&&z.push({type:"unsupported-setting",setting:"reasoningEffort",details:"reasoningEffort is not supported for non-reasoning models"}),k?.reasoningSummary!=null&&z.push({type:"unsupported-setting",setting:"reasoningSummary",details:"reasoningSummary is not supported for non-reasoning models"})),k?.serviceTier==="flex"&&!U.supportsFlexProcessing&&(z.push({type:"unsupported-setting",setting:"serviceTier",details:"flex processing is only available for o3, o4-mini, and gpt-5 models"}),delete xe.service_tier),k?.serviceTier==="priority"&&!U.supportsPriorityProcessing&&(z.push({type:"unsupported-setting",setting:"serviceTier",details:"priority processing is only available for supported models (gpt-4, gpt-5, gpt-5-mini, o3, o4-mini) and requires Enterprise access. gpt-5-nano is not supported"}),delete xe.service_tier);const{tools:le,toolChoice:F,toolWarnings:J}=await Ux({tools:A,toolChoice:b,strictJsonSchema:Q});return{webSearchToolName:Ce,args:{...xe,tools:le,tool_choice:F},warnings:[...z,...J],store:he}}async doGenerate(t){var n,o,l,u,f,g,m,y,x,A,b,P,N,R,D,M,z,U,k,K,ve,Q,j,ie,Y,Ie,Ce,he;const{args:xe,warnings:le,webSearchToolName:F}=await this.getArgs(t),J=this.config.url({path:"/responses",modelId:this.modelId}),X=this.config.provider.replace(".responses",""),{responseHeaders:te,value:pe,rawValue:ge}=await Vn({url:J,headers:Bn(this.config.headers(),t.headers),body:xe,failedResponseHandler:Ln,successfulResponseHandler:Nr(Fx),abortSignal:t.abortSignal,fetch:this.config.fetch});if(pe.error)throw new wn({message:pe.error.message,url:J,requestBodyValues:xe,statusCode:400,responseHeaders:te,responseBody:ge,isRetryable:!1});const ye=[],we=[];let Fe=!1;for(const S of pe.output)switch(S.type){case"reasoning":{S.summary.length===0&&S.summary.push({type:"summary_text",text:""});for(const fe of S.summary)ye.push({type:"reasoning",text:fe.text,providerMetadata:{[X]:{itemId:S.id,reasoningEncryptedContent:(n=S.encrypted_content)!=null?n:null}}});break}case"image_generation_call":{ye.push({type:"tool-call",toolCallId:S.id,toolName:"image_generation",input:"{}",providerExecuted:!0}),ye.push({type:"tool-result",toolCallId:S.id,toolName:"image_generation",result:{result:S.result},providerExecuted:!0});break}case"local_shell_call":{ye.push({type:"tool-call",toolCallId:S.call_id,toolName:"local_shell",input:JSON.stringify({action:S.action}),providerMetadata:{[X]:{itemId:S.id}}});break}case"message":{for(const fe of S.content){(l=(o=t.providerOptions)==null?void 0:o.openai)!=null&&l.logprobs&&fe.logprobs&&we.push(fe.logprobs),ye.push({type:"text",text:fe.text,providerMetadata:{[X]:{itemId:S.id}}});for(const se of fe.annotations)se.type==="url_citation"?ye.push({type:"source",sourceType:"url",id:(g=(f=(u=this.config).generateId)==null?void 0:f.call(u))!=null?g:Sn(),url:se.url,title:se.title}):se.type==="file_citation"?ye.push({type:"source",sourceType:"document",id:(x=(y=(m=this.config).generateId)==null?void 0:y.call(m))!=null?x:Sn(),mediaType:"text/plain",title:(b=(A=se.quote)!=null?A:se.filename)!=null?b:"Document",filename:(P=se.filename)!=null?P:se.file_id,...se.file_id?{providerMetadata:{[X]:{fileId:se.file_id}}}:{}}):se.type==="container_file_citation"?ye.push({type:"source",sourceType:"document",id:(D=(R=(N=this.config).generateId)==null?void 0:R.call(N))!=null?D:Sn(),mediaType:"text/plain",title:(z=(M=se.filename)!=null?M:se.file_id)!=null?z:"Document",filename:(U=se.filename)!=null?U:se.file_id,providerMetadata:{[X]:{fileId:se.file_id,containerId:se.container_id,...se.index!=null?{index:se.index}:{}}}}):se.type==="file_path"&&ye.push({type:"source",sourceType:"document",id:(ve=(K=(k=this.config).generateId)==null?void 0:K.call(k))!=null?ve:Sn(),mediaType:"application/octet-stream",title:se.file_id,filename:se.file_id,providerMetadata:{[X]:{fileId:se.file_id,...se.index!=null?{index:se.index}:{}}}})}break}case"function_call":{Fe=!0,ye.push({type:"tool-call",toolCallId:S.call_id,toolName:S.name,input:S.arguments,providerMetadata:{[X]:{itemId:S.id}}});break}case"web_search_call":{ye.push({type:"tool-call",toolCallId:S.id,toolName:F??"web_search",input:JSON.stringify({}),providerExecuted:!0}),ye.push({type:"tool-result",toolCallId:S.id,toolName:F??"web_search",result:rl(S.action),providerExecuted:!0});break}case"computer_call":{ye.push({type:"tool-call",toolCallId:S.id,toolName:"computer_use",input:"",providerExecuted:!0}),ye.push({type:"tool-result",toolCallId:S.id,toolName:"computer_use",result:{type:"computer_use_tool_result",status:S.status||"completed"},providerExecuted:!0});break}case"file_search_call":{ye.push({type:"tool-call",toolCallId:S.id,toolName:"file_search",input:"{}",providerExecuted:!0}),ye.push({type:"tool-result",toolCallId:S.id,toolName:"file_search",result:{queries:S.queries,results:(j=(Q=S.results)==null?void 0:Q.map(fe=>({attributes:fe.attributes,fileId:fe.file_id,filename:fe.filename,score:fe.score,text:fe.text})))!=null?j:null},providerExecuted:!0});break}case"code_interpreter_call":{ye.push({type:"tool-call",toolCallId:S.id,toolName:"code_interpreter",input:JSON.stringify({code:S.code,containerId:S.container_id}),providerExecuted:!0}),ye.push({type:"tool-result",toolCallId:S.id,toolName:"code_interpreter",result:{outputs:S.outputs},providerExecuted:!0});break}}const Pe={[X]:{...pe.id!=null?{responseId:pe.id}:{}}};we.length>0&&(Pe[X].logprobs=we),typeof pe.service_tier=="string"&&(Pe[X].serviceTier=pe.service_tier);const ne=pe.usage;return{content:ye,finishReason:tl({finishReason:(ie=pe.incomplete_details)==null?void 0:ie.reason,hasFunctionCall:Fe}),usage:{inputTokens:ne.input_tokens,outputTokens:ne.output_tokens,totalTokens:ne.input_tokens+ne.output_tokens,reasoningTokens:(Ie=(Y=ne.output_tokens_details)==null?void 0:Y.reasoning_tokens)!=null?Ie:void 0,cachedInputTokens:(he=(Ce=ne.input_tokens_details)==null?void 0:Ce.cached_tokens)!=null?he:void 0},request:{body:xe},response:{id:pe.id,timestamp:new Date(pe.created_at*1e3),modelId:pe.model,headers:te,body:ge},providerMetadata:Pe,warnings:le}}async doStream(t){const{args:n,warnings:o,webSearchToolName:l,store:u}=await this.getArgs(t),{responseHeaders:f,value:g}=await Vn({url:this.config.url({path:"/responses",modelId:this.modelId}),headers:Bn(this.config.headers(),t.headers),body:{...n,stream:!0},failedResponseHandler:Ln,successfulResponseHandler:gs(Lx),abortSignal:t.abortSignal,fetch:this.config.fetch}),m=this,y=this.config.provider.replace(".responses","");let x="unknown";const A={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0},b=[];let P=null;const N={},R=[];let D=!1;const M={};let z;return{stream:g.pipeThrough(new TransformStream({start(U){U.enqueue({type:"stream-start",warnings:o})},transform(U,k){var K,ve,Q,j,ie,Y,Ie,Ce,he,xe,le,F,J,X,te,pe,ge,ye,we,Fe,Pe,ne;if(t.includeRawChunks&&k.enqueue({type:"raw",rawValue:U.rawValue}),!U.success){x="error",k.enqueue({type:"error",error:U.error});return}const S=U.value;if(nl(S))S.item.type==="function_call"?(N[S.output_index]={toolName:S.item.name,toolCallId:S.item.call_id},k.enqueue({type:"tool-input-start",id:S.item.call_id,toolName:S.item.name})):S.item.type==="web_search_call"?(N[S.output_index]={toolName:l??"web_search",toolCallId:S.item.id},k.enqueue({type:"tool-input-start",id:S.item.id,toolName:l??"web_search",providerExecuted:!0}),k.enqueue({type:"tool-input-end",id:S.item.id}),k.enqueue({type:"tool-call",toolCallId:S.item.id,toolName:l??"web_search",input:JSON.stringify({}),providerExecuted:!0})):S.item.type==="computer_call"?(N[S.output_index]={toolName:"computer_use",toolCallId:S.item.id},k.enqueue({type:"tool-input-start",id:S.item.id,toolName:"computer_use",providerExecuted:!0})):S.item.type==="code_interpreter_call"?(N[S.output_index]={toolName:"code_interpreter",toolCallId:S.item.id,codeInterpreter:{containerId:S.item.container_id}},k.enqueue({type:"tool-input-start",id:S.item.id,toolName:"code_interpreter",providerExecuted:!0}),k.enqueue({type:"tool-input-delta",id:S.item.id,delta:`{"containerId":"${S.item.container_id}","code":"`})):S.item.type==="file_search_call"?k.enqueue({type:"tool-call",toolCallId:S.item.id,toolName:"file_search",input:"{}",providerExecuted:!0}):S.item.type==="image_generation_call"?k.enqueue({type:"tool-call",toolCallId:S.item.id,toolName:"image_generation",input:"{}",providerExecuted:!0}):S.item.type==="message"?(R.splice(0,R.length),k.enqueue({type:"text-start",id:S.item.id,providerMetadata:{[y]:{itemId:S.item.id}}})):nl(S)&&S.item.type==="reasoning"&&(M[S.item.id]={encryptedContent:S.item.encrypted_content,summaryParts:{0:"active"}},k.enqueue({type:"reasoning-start",id:`${S.item.id}:0`,providerMetadata:{[y]:{itemId:S.item.id,reasoningEncryptedContent:(K=S.item.encrypted_content)!=null?K:null}}}));else if(Vx(S)){if(S.item.type==="message")k.enqueue({type:"text-end",id:S.item.id,providerMetadata:{[y]:{itemId:S.item.id,...R.length>0&&{annotations:R}}}});else if(S.item.type==="function_call")N[S.output_index]=void 0,D=!0,k.enqueue({type:"tool-input-end",id:S.item.call_id}),k.enqueue({type:"tool-call",toolCallId:S.item.call_id,toolName:S.item.name,input:S.item.arguments,providerMetadata:{[y]:{itemId:S.item.id}}});else if(S.item.type==="web_search_call")N[S.output_index]=void 0,k.enqueue({type:"tool-result",toolCallId:S.item.id,toolName:l??"web_search",result:rl(S.item.action),providerExecuted:!0});else if(S.item.type==="computer_call")N[S.output_index]=void 0,k.enqueue({type:"tool-input-end",id:S.item.id}),k.enqueue({type:"tool-call",toolCallId:S.item.id,toolName:"computer_use",input:"",providerExecuted:!0}),k.enqueue({type:"tool-result",toolCallId:S.item.id,toolName:"computer_use",result:{type:"computer_use_tool_result",status:S.item.status||"completed"},providerExecuted:!0});else if(S.item.type==="file_search_call")N[S.output_index]=void 0,k.enqueue({type:"tool-result",toolCallId:S.item.id,toolName:"file_search",result:{queries:S.item.queries,results:(Q=(ve=S.item.results)==null?void 0:ve.map(fe=>({attributes:fe.attributes,fileId:fe.file_id,filename:fe.filename,score:fe.score,text:fe.text})))!=null?Q:null},providerExecuted:!0});else if(S.item.type==="code_interpreter_call")N[S.output_index]=void 0,k.enqueue({type:"tool-result",toolCallId:S.item.id,toolName:"code_interpreter",result:{outputs:S.item.outputs},providerExecuted:!0});else if(S.item.type==="image_generation_call")k.enqueue({type:"tool-result",toolCallId:S.item.id,toolName:"image_generation",result:{result:S.item.result},providerExecuted:!0});else if(S.item.type==="local_shell_call")N[S.output_index]=void 0,k.enqueue({type:"tool-call",toolCallId:S.item.call_id,toolName:"local_shell",input:JSON.stringify({action:{type:"exec",command:S.item.action.command,timeoutMs:S.item.action.timeout_ms,user:S.item.action.user,workingDirectory:S.item.action.working_directory,env:S.item.action.env}}),providerMetadata:{[y]:{itemId:S.item.id}}});else if(S.item.type==="reasoning"){const fe=M[S.item.id],se=Object.entries(fe.summaryParts).filter(([Le,$e])=>$e==="active"||$e==="can-conclude").map(([Le])=>Le);for(const Le of se)k.enqueue({type:"reasoning-end",id:`${S.item.id}:${Le}`,providerMetadata:{[y]:{itemId:S.item.id,reasoningEncryptedContent:(j=S.item.encrypted_content)!=null?j:null}}});delete M[S.item.id]}}else if(Wx(S)){const fe=N[S.output_index];fe!=null&&k.enqueue({type:"tool-input-delta",id:fe.toolCallId,delta:S.delta})}else if(Gx(S)){const fe=N[S.output_index];fe!=null&&k.enqueue({type:"tool-input-delta",id:fe.toolCallId,delta:JSON.stringify(S.delta).slice(1,-1)})}else if(Xx(S)){const fe=N[S.output_index];fe!=null&&(k.enqueue({type:"tool-input-delta",id:fe.toolCallId,delta:'"}'}),k.enqueue({type:"tool-input-end",id:fe.toolCallId}),k.enqueue({type:"tool-call",toolCallId:fe.toolCallId,toolName:"code_interpreter",input:JSON.stringify({code:S.code,containerId:fe.codeInterpreter.containerId}),providerExecuted:!0}))}else if(Hx(S))P=S.response.id,k.enqueue({type:"response-metadata",id:S.response.id,timestamp:new Date(S.response.created_at*1e3),modelId:S.response.model});else if(Zx(S))k.enqueue({type:"text-delta",id:S.item_id,delta:S.delta}),(Y=(ie=t.providerOptions)==null?void 0:ie.openai)!=null&&Y.logprobs&&S.logprobs&&b.push(S.logprobs);else if(S.type==="response.reasoning_summary_part.added"){if(S.summary_index>0){const fe=M[S.item_id];fe.summaryParts[S.summary_index]="active";for(const se of Object.keys(fe.summaryParts))fe.summaryParts[se]==="can-conclude"&&(k.enqueue({type:"reasoning-end",id:`${S.item_id}:${se}`,providerMetadata:{[y]:{itemId:S.item_id}}}),fe.summaryParts[se]="concluded");k.enqueue({type:"reasoning-start",id:`${S.item_id}:${S.summary_index}`,providerMetadata:{[y]:{itemId:S.item_id,reasoningEncryptedContent:(Ce=(Ie=M[S.item_id])==null?void 0:Ie.encryptedContent)!=null?Ce:null}}})}}else S.type==="response.reasoning_summary_text.delta"?k.enqueue({type:"reasoning-delta",id:`${S.item_id}:${S.summary_index}`,delta:S.delta,providerMetadata:{[y]:{itemId:S.item_id}}}):S.type==="response.reasoning_summary_part.done"?u?(k.enqueue({type:"reasoning-end",id:`${S.item_id}:${S.summary_index}`,providerMetadata:{[y]:{itemId:S.item_id}}}),M[S.item_id].summaryParts[S.summary_index]="concluded"):M[S.item_id].summaryParts[S.summary_index]="can-conclude":jx(S)?(x=tl({finishReason:(he=S.response.incomplete_details)==null?void 0:he.reason,hasFunctionCall:D}),A.inputTokens=S.response.usage.input_tokens,A.outputTokens=S.response.usage.output_tokens,A.totalTokens=S.response.usage.input_tokens+S.response.usage.output_tokens,A.reasoningTokens=(le=(xe=S.response.usage.output_tokens_details)==null?void 0:xe.reasoning_tokens)!=null?le:void 0,A.cachedInputTokens=(J=(F=S.response.usage.input_tokens_details)==null?void 0:F.cached_tokens)!=null?J:void 0,typeof S.response.service_tier=="string"&&(z=S.response.service_tier)):Yx(S)?(R.push(S.annotation),S.annotation.type==="url_citation"?k.enqueue({type:"source",sourceType:"url",id:(pe=(te=(X=m.config).generateId)==null?void 0:te.call(X))!=null?pe:Sn(),url:S.annotation.url,title:S.annotation.title}):S.annotation.type==="file_citation"&&k.enqueue({type:"source",sourceType:"document",id:(we=(ye=(ge=m.config).generateId)==null?void 0:ye.call(ge))!=null?we:Sn(),mediaType:"text/plain",title:(Pe=(Fe=S.annotation.quote)!=null?Fe:S.annotation.filename)!=null?Pe:"Document",filename:(ne=S.annotation.filename)!=null?ne:S.annotation.file_id,...S.annotation.file_id?{providerMetadata:{[y]:{fileId:S.annotation.file_id}}}:{}})):qx(S)&&k.enqueue({type:"error",error:S})},flush(U){const k={[y]:{responseId:P}};b.length>0&&(k[y].logprobs=b),z!==void 0&&(k[y].serviceTier=z),U.enqueue({type:"finish",finishReason:x,usage:A,providerMetadata:k})}})),request:{body:n},response:{headers:f}}}};function Zx(t){return t.type==="response.output_text.delta"}function Vx(t){return t.type==="response.output_item.done"}function jx(t){return t.type==="response.completed"||t.type==="response.incomplete"}function Hx(t){return t.type==="response.created"}function Wx(t){return t.type==="response.function_call_arguments.delta"}function Gx(t){return t.type==="response.code_interpreter_call_code.delta"}function Xx(t){return t.type==="response.code_interpreter_call_code.done"}function nl(t){return t.type==="response.output_item.added"}function Yx(t){return t.type==="response.output_text.annotation.added"}function qx(t){return t.type==="error"}function rl(t){var n;switch(t.type){case"search":return{action:{type:"search",query:(n=t.query)!=null?n:void 0},...t.sources!=null&&{sources:t.sources}};case"open_page":return{action:{type:"openPage",url:t.url}};case"find_in_page":return{action:{type:"findInPage",url:t.url,pattern:t.pattern}}}}var Kx=Yt(()=>Ke(B({instructions:I().nullish(),speed:W().min(.25).max(4).default(1).nullish()}))),Jx=class{constructor(t,n){this.modelId=t,this.config=n,this.specificationVersion="v2"}get provider(){return this.config.provider}async getArgs({text:t,voice:n="alloy",outputFormat:o="mp3",speed:l,instructions:u,language:f,providerOptions:g}){const m=[],y=await nr({provider:"openai",providerOptions:g,schema:Kx}),x={model:this.modelId,input:t,voice:n,response_format:"mp3",speed:l,instructions:u};if(o&&(["mp3","opus","aac","flac","wav","pcm"].includes(o)?x.response_format=o:m.push({type:"unsupported-setting",setting:"outputFormat",details:`Unsupported output format: ${o}. Using mp3 instead.`})),y){const A={};for(const b in A){const P=A[b];P!==void 0&&(x[b]=P)}}return f&&m.push({type:"unsupported-setting",setting:"language",details:`OpenAI speech models do not support language selection. Language parameter "${f}" was ignored.`}),{requestBody:x,warnings:m}}async doGenerate(t){var n,o,l;const u=(l=(o=(n=this.config._internal)==null?void 0:n.currentDate)==null?void 0:o.call(n))!=null?l:new Date,{requestBody:f,warnings:g}=await this.getArgs(t),{value:m,responseHeaders:y,rawValue:x}=await Vn({url:this.config.url({path:"/audio/speech",modelId:this.modelId}),headers:Bn(this.config.headers(),t.headers),body:f,failedResponseHandler:Ln,successfulResponseHandler:K2(),abortSignal:t.abortSignal,fetch:this.config.fetch});return{audio:m,warnings:g,request:{body:JSON.stringify(f)},response:{timestamp:u,modelId:this.modelId,headers:y,body:x}}}},Qx=Yt(()=>Ke(B({text:I(),language:I().nullish(),duration:W().nullish(),words:_e(B({word:I(),start:W(),end:W()})).nullish(),segments:_e(B({id:W(),seek:W(),start:W(),end:W(),text:I(),tokens:_e(W()),temperature:W(),avg_logprob:W(),compression_ratio:W(),no_speech_prob:W()})).nullish()}))),e3=Yt(()=>Ke(B({include:_e(I()).optional(),language:I().optional(),prompt:I().optional(),temperature:W().min(0).max(1).default(0).optional(),timestampGranularities:_e(pt(["word","segment"])).default(["segment"]).optional()}))),il={afrikaans:"af",arabic:"ar",armenian:"hy",azerbaijani:"az",belarusian:"be",bosnian:"bs",bulgarian:"bg",catalan:"ca",chinese:"zh",croatian:"hr",czech:"cs",danish:"da",dutch:"nl",english:"en",estonian:"et",finnish:"fi",french:"fr",galician:"gl",german:"de",greek:"el",hebrew:"he",hindi:"hi",hungarian:"hu",icelandic:"is",indonesian:"id",italian:"it",japanese:"ja",kannada:"kn",kazakh:"kk",korean:"ko",latvian:"lv",lithuanian:"lt",macedonian:"mk",malay:"ms",marathi:"mr",maori:"mi",nepali:"ne",norwegian:"no",persian:"fa",polish:"pl",portuguese:"pt",romanian:"ro",russian:"ru",serbian:"sr",slovak:"sk",slovenian:"sl",spanish:"es",swahili:"sw",swedish:"sv",tagalog:"tl",tamil:"ta",thai:"th",turkish:"tr",ukrainian:"uk",urdu:"ur",vietnamese:"vi",welsh:"cy"},t3=class{constructor(t,n){this.modelId=t,this.config=n,this.specificationVersion="v2"}get provider(){return this.config.provider}async getArgs({audio:t,mediaType:n,providerOptions:o}){const l=[],u=await nr({provider:"openai",providerOptions:o,schema:e3}),f=new FormData,g=t instanceof Uint8Array?new Blob([t]):new Blob([Hm(t)]);f.append("model",this.modelId);const m=F2(n);if(f.append("file",new File([g],"audio",{type:n}),`audio.${m}`),u){const y={include:u.include,language:u.language,prompt:u.prompt,response_format:["gpt-4o-transcribe","gpt-4o-mini-transcribe"].includes(this.modelId)?"json":"verbose_json",temperature:u.temperature,timestamp_granularities:u.timestampGranularities};for(const[x,A]of Object.entries(y))if(A!=null)if(Array.isArray(A))for(const b of A)f.append(`${x}[]`,String(b));else f.append(x,String(A))}return{formData:f,warnings:l}}async doGenerate(t){var n,o,l,u,f,g,m,y;const x=(l=(o=(n=this.config._internal)==null?void 0:n.currentDate)==null?void 0:o.call(n))!=null?l:new Date,{formData:A,warnings:b}=await this.getArgs(t),{value:P,responseHeaders:N,rawValue:R}=await Y2({url:this.config.url({path:"/audio/transcriptions",modelId:this.modelId}),headers:Bn(this.config.headers(),t.headers),formData:A,failedResponseHandler:Ln,successfulResponseHandler:Nr(Qx),abortSignal:t.abortSignal,fetch:this.config.fetch}),D=P.language!=null&&P.language in il?il[P.language]:void 0;return{text:P.text,segments:(m=(g=(u=P.segments)==null?void 0:u.map(M=>({text:M.text,startSecond:M.start,endSecond:M.end})))!=null?g:(f=P.words)==null?void 0:f.map(M=>({text:M.word,startSecond:M.start,endSecond:M.end})))!=null?m:[],language:D,durationInSeconds:(y=P.duration)!=null?y:void 0,warnings:b,response:{timestamp:x,modelId:this.modelId,headers:N,body:R}}}},n3="2.0.89";function Vu(t={}){var n,o;const l=(n=Gm(L2({settingValue:t.baseURL,environmentVariableName:"OPENAI_BASE_URL"})))!=null?n:"https://api.openai.com/v1",u=(o=t.name)!=null?o:"openai",f=()=>Ou({Authorization:`Bearer ${B2({apiKey:t.apiKey,environmentVariableName:"OPENAI_API_KEY",description:"OpenAI"})}`,"OpenAI-Organization":t.organization,"OpenAI-Project":t.project,...t.headers},`ai-sdk/openai/${n3}`),g=D=>new Qm(D,{provider:`${u}.chat`,url:({path:M})=>`${l}${M}`,headers:f,fetch:t.fetch}),m=D=>new rx(D,{provider:`${u}.completion`,url:({path:M})=>`${l}${M}`,headers:f,fetch:t.fetch}),y=D=>new sx(D,{provider:`${u}.embedding`,url:({path:M})=>`${l}${M}`,headers:f,fetch:t.fetch}),x=D=>new ux(D,{provider:`${u}.image`,url:({path:M})=>`${l}${M}`,headers:f,fetch:t.fetch}),A=D=>new t3(D,{provider:`${u}.transcription`,url:({path:M})=>`${l}${M}`,headers:f,fetch:t.fetch}),b=D=>new Jx(D,{provider:`${u}.speech`,url:({path:M})=>`${l}${M}`,headers:f,fetch:t.fetch}),P=D=>{if(new.target)throw new Error("The OpenAI model function cannot be called with the new keyword.");return N(D)},N=D=>new zx(D,{provider:`${u}.responses`,url:({path:M})=>`${l}${M}`,headers:f,fetch:t.fetch,fileIdPrefixes:["file-"]}),R=function(D){return P(D)};return R.languageModel=P,R.chat=g,R.completion=m,R.responses=N,R.embedding=y,R.textEmbedding=y,R.textEmbeddingModel=y,R.image=x,R.imageModel=x,R.transcription=A,R.transcriptionModel=A,R.speech=b,R.speechModel=b,R.tools=Mx,R}Vu();const r3={deepseek:{prompt:{strategy:"append",id:"5ed1b9071c15d1ed59b5827ea5dcabd4",params:{customComponents:[{name:"选择用户组件",description:"选择用户组件,用于选择用户,支持模糊搜索",component:"TinyUser",schema:{properties:[{property:"modelValue",label:"用户绑定工号",required:!0,description:"用户的工号,双向绑定值",type:"string"},{property:"valueField",label:"值字段",required:!0,description:"用户工号值的绑定字段",type:"string"}]}}],customExamples:[{name:"选择用户示例",schema:{componentName:"Page",state:{reviewer:""},children:[{componentName:"h3",props:{},children:"输入用户名搜索工号并选择用户"},{componentName:"TinyUser",props:{modelValue:{type:"JSExpression",model:!0,value:"this.state.reviewer"},valueField:"uid"}},{componentName:"TinyButton",props:{text:"提交"}}]}}]}}}},Po={model:"deepseek-ai/DeepSeek-V3",maxSteps:15,extraTools:{}},ol={apiKey:"sk-trial",baseURL:"https://agent.opentiny.design/api/v1/ai/prompt",providerType:"deepseek"};class i3 extends dr.BaseModelProvider{transport;agent;systemPrompt;llmConfig={...Po,...ol};isGenuiEnabled;constructor(n,o,l,u,f){super(n);let g;f&&"llm"in f?g={...Po,...f}:g={...Po,...ol,...f||{}},this.llmConfig=g;const m=g.llm?{llm:g.llm}:{...g},y={mcpServers:this.createMcpServers(o.value,l.value),llmConfig:m};this.agent=new Ki.AgentModelProvider(y),this.systemPrompt=u}updateLLMConfig({modelId:n,apiUrl:o,apiKey:l,providerType:u,useReActMode:f}){let g=o;this.isGenuiEnabled?.value?g.includes("/prompt")||(g=g+"/prompt"):g=g.replace("/prompt",""),this.llmConfig.model=n,this.llmConfig.apiKey=l,this.llmConfig.baseURL=g,this.llmConfig.providerType=u,this.llmConfig.useReActMode=f||!1,this.agent.useReActMode=f||!1;let m;if(u==="deepseek")m=iu;else if(u==="openai")m=Vu;else if(typeof u=="function")m=u;else throw new Error(`Unsupported providerType: ${u}`);this.agent.llm=m({apiKey:l,baseURL:g})}createMcpServers(n,o){if(!n)return{};const l=n.includes(",")?n.split(",").map(f=>f.trim()):[n],u={};return l.forEach(f=>{u[`mcp-server-${f}`]={type:"streamableHttp",url:`${o}mcp?sessionId=${f}`}}),u}handleTextStream(n,o,l){return n.type==="text-start"?(o.onData({type:"text-start"}),l++,o.onData({type:"markdown",content:"",delta:"",textId:l})):n.type==="text-delta"?o.onData({type:"markdown",delta:n.text,textId:l}):n.type==="text-end"&&(o.onData({type:"markdown",delta:`
58
+ ${r}:`]}}function ja({id:t,model:r,created:o}){return{id:t??void 0,modelId:r??void 0,timestamp:o!=null?new Date(o*1e3):void 0}}function Ha(t){switch(t){case"stop":return"stop";case"length":return"length";case"content_filter":return"content-filter";case"function_call":case"tool_calls":return"tool-calls";default:return"unknown"}}var W2=qt(()=>We(B({id:I().nullish(),created:X().nullish(),model:I().nullish(),choices:ve(B({text:I(),finish_reason:I(),logprobs:B({tokens:ve(I()),token_logprobs:ve(X()),top_logprobs:ve(Dt(I(),X())).nullish()}).nullish()})),usage:B({prompt_tokens:X(),completion_tokens:X(),total_tokens:X()}).nullish()}))),G2=qt(()=>We(lt([B({id:I().nullish(),created:X().nullish(),model:I().nullish(),choices:ve(B({text:I(),finish_reason:I().nullish(),index:X(),logprobs:B({tokens:ve(I()),token_logprobs:ve(X()),top_logprobs:ve(Dt(I(),X())).nullish()}).nullish()})),usage:B({prompt_tokens:X(),completion_tokens:X(),total_tokens:X()}).nullish()}),cs]))),Wa=qt(()=>We(B({echo:$t().optional(),logitBias:Dt(I(),X()).optional(),suffix:I().optional(),user:I().optional(),logprobs:lt([$t(),X()]).optional()}))),X2=class{constructor(t,r){this.specificationVersion="v2",this.supportedUrls={},this.modelId=t,this.config=r}get providerOptionsName(){return this.config.provider.split(".")[0].trim()}get provider(){return this.config.provider}async getArgs({prompt:t,maxOutputTokens:r,temperature:o,topP:l,topK:u,frequencyPenalty:f,presencePenalty:g,stopSequences:x,responseFormat:y,tools:m,toolChoice:E,seed:C,providerOptions:P}){const O=[],D={...await Kn({provider:"openai",providerOptions:P,schema:Wa}),...await Kn({provider:this.providerOptionsName,providerOptions:P,schema:Wa})};u!=null&&O.push({type:"unsupported-setting",setting:"topK"}),m?.length&&O.push({type:"unsupported-setting",setting:"tools"}),E!=null&&O.push({type:"unsupported-setting",setting:"toolChoice"}),y!=null&&y.type!=="text"&&O.push({type:"unsupported-setting",setting:"responseFormat",details:"JSON response format is not supported."});const{prompt:R,stopSequences:M}=H2({prompt:t}),V=[...M??[],...x??[]];return{args:{model:this.modelId,echo:D.echo,logit_bias:D.logitBias,logprobs:D?.logprobs===!0?0:D?.logprobs===!1?void 0:D?.logprobs,suffix:D.suffix,user:D.user,max_tokens:r,temperature:o,top_p:l,frequency_penalty:f,presence_penalty:g,seed:C,prompt:R,stop:V.length>0?V:void 0},warnings:O}}async doGenerate(t){var r,o,l;const{args:u,warnings:f}=await this.getArgs(t),{responseHeaders:g,value:x,rawValue:y}=await Fn({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:Rn(this.config.headers(),t.headers),body:u,failedResponseHandler:Dn,successfulResponseHandler:Ar(W2),abortSignal:t.abortSignal,fetch:this.config.fetch}),m=x.choices[0],E={openai:{}};return m.logprobs!=null&&(E.openai.logprobs=m.logprobs),{content:[{type:"text",text:m.text}],usage:{inputTokens:(r=x.usage)==null?void 0:r.prompt_tokens,outputTokens:(o=x.usage)==null?void 0:o.completion_tokens,totalTokens:(l=x.usage)==null?void 0:l.total_tokens},finishReason:Ha(m.finish_reason),request:{body:u},response:{...ja(x),headers:g,body:y},providerMetadata:E,warnings:f}}async doStream(t){const{args:r,warnings:o}=await this.getArgs(t),l={...r,stream:!0,stream_options:{include_usage:!0}},{responseHeaders:u,value:f}=await Fn({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:Rn(this.config.headers(),t.headers),body:l,failedResponseHandler:Dn,successfulResponseHandler:ls(G2),abortSignal:t.abortSignal,fetch:this.config.fetch});let g="unknown";const x={openai:{}},y={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0};let m=!0;return{stream:f.pipeThrough(new TransformStream({start(E){E.enqueue({type:"stream-start",warnings:o})},transform(E,C){if(t.includeRawChunks&&C.enqueue({type:"raw",rawValue:E.rawValue}),!E.success){g="error",C.enqueue({type:"error",error:E.error});return}const P=E.value;if("error"in P){g="error",C.enqueue({type:"error",error:P.error});return}m&&(m=!1,C.enqueue({type:"response-metadata",...ja(P)}),C.enqueue({type:"text-start",id:"0"})),P.usage!=null&&(y.inputTokens=P.usage.prompt_tokens,y.outputTokens=P.usage.completion_tokens,y.totalTokens=P.usage.total_tokens);const O=P.choices[0];O?.finish_reason!=null&&(g=Ha(O.finish_reason)),O?.logprobs!=null&&(x.openai.logprobs=O.logprobs),O?.text!=null&&O.text.length>0&&C.enqueue({type:"text-delta",id:"0",delta:O.text})},flush(E){m||E.enqueue({type:"text-end",id:"0"}),E.enqueue({type:"finish",finishReason:g,providerMetadata:x,usage:y})}})),request:{body:l},response:{headers:u}}}},q2=qt(()=>We(B({dimensions:X().optional(),user:I().optional()}))),Y2=qt(()=>We(B({data:ve(B({embedding:ve(X())})),usage:B({prompt_tokens:X()}).nullish()}))),K2=class{constructor(t,r){this.specificationVersion="v2",this.maxEmbeddingsPerCall=2048,this.supportsParallelCalls=!0,this.modelId=t,this.config=r}get provider(){return this.config.provider}async doEmbed({values:t,headers:r,abortSignal:o,providerOptions:l}){var u;if(t.length>this.maxEmbeddingsPerCall)throw new wm({provider:this.provider,modelId:this.modelId,maxEmbeddingsPerCall:this.maxEmbeddingsPerCall,values:t});const f=(u=await Kn({provider:"openai",providerOptions:l,schema:q2}))!=null?u:{},{responseHeaders:g,value:x,rawValue:y}=await Fn({url:this.config.url({path:"/embeddings",modelId:this.modelId}),headers:Rn(this.config.headers(),r),body:{model:this.modelId,input:t,encoding_format:"float",dimensions:f.dimensions,user:f.user},failedResponseHandler:Dn,successfulResponseHandler:Ar(Y2),abortSignal:o,fetch:this.config.fetch});return{embeddings:x.data.map(m=>m.embedding),usage:x.usage?{tokens:x.usage.prompt_tokens}:void 0,response:{headers:g,body:y}}}},J2=qt(()=>We(B({created:X().nullish(),data:ve(B({b64_json:I(),revised_prompt:I().nullish()})),background:I().nullish(),output_format:I().nullish(),size:I().nullish(),quality:I().nullish(),usage:B({input_tokens:X().nullish(),output_tokens:X().nullish(),total_tokens:X().nullish(),input_tokens_details:B({image_tokens:X().nullish(),text_tokens:X().nullish()}).nullish()}).nullish()}))),Q2={"dall-e-3":1,"dall-e-2":10,"gpt-image-1":10,"gpt-image-1-mini":10,"gpt-image-1.5":10},ex=new Set(["gpt-image-1","gpt-image-1-mini","gpt-image-1.5"]),tx=class{constructor(t,r){this.modelId=t,this.config=r,this.specificationVersion="v2"}get maxImagesPerCall(){var t;return(t=Q2[this.modelId])!=null?t:1}get provider(){return this.config.provider}async doGenerate({prompt:t,n:r,size:o,aspectRatio:l,seed:u,providerOptions:f,headers:g,abortSignal:x}){var y,m,E,C;const P=[];l!=null&&P.push({type:"unsupported-setting",setting:"aspectRatio",details:"This model does not support aspect ratio. Use `size` instead."}),u!=null&&P.push({type:"unsupported-setting",setting:"seed"});const O=(E=(m=(y=this.config._internal)==null?void 0:y.currentDate)==null?void 0:m.call(y))!=null?E:new Date,{value:D,responseHeaders:R}=await Fn({url:this.config.url({path:"/images/generations",modelId:this.modelId}),headers:Rn(this.config.headers(),g),body:{model:this.modelId,prompt:t,n:r,size:o,...(C=f.openai)!=null?C:{},...ex.has(this.modelId)?{}:{response_format:"b64_json"}},failedResponseHandler:Dn,successfulResponseHandler:Ar(J2),abortSignal:x,fetch:this.config.fetch});return{images:D.data.map(M=>M.b64_json),warnings:P,response:{timestamp:O,modelId:this.modelId,headers:R},providerMetadata:{openai:{images:D.data.map(M=>({...M.revised_prompt?{revisedPrompt:M.revised_prompt}:{},...D.created!=null?{created:D.created}:{},...D.size!=null?{size:D.size}:{},...D.quality!=null?{quality:D.quality}:{},...D.background!=null?{background:D.background}:{},...D.output_format!=null?{outputFormat:D.output_format}:{}}))}}}}},nx=Vt(()=>We(B({code:I().nullish(),containerId:I()}))),rx=Vt(()=>We(B({outputs:ve(Ft("type",[B({type:ie("logs"),logs:I()}),B({type:ie("image"),url:I()})])).nullish()}))),ix=Vt(()=>We(B({container:lt([I(),B({fileIds:ve(I()).optional()})]).optional()}))),ox=Er({id:"openai.code_interpreter",name:"code_interpreter",inputSchema:nx,outputSchema:rx}),sx=(t={})=>ox(t),Ou=B({key:I(),type:ft(["eq","ne","gt","gte","lt","lte","in","nin"]),value:lt([I(),X(),$t(),ve(I())])}),ku=B({type:ft(["and","or"]),filters:ve(lt([Ou,Mc(()=>ku)]))}),ax=Vt(()=>We(B({vectorStoreIds:ve(I()),maxNumResults:X().optional(),ranking:B({ranker:I().optional(),scoreThreshold:X().optional()}).optional(),filters:lt([Ou,ku]).optional()}))),lx=Vt(()=>We(B({queries:ve(I()),results:ve(B({attributes:Dt(I(),qr()),fileId:I(),filename:I(),score:X(),text:I()})).nullable()}))),cx=Er({id:"openai.file_search",name:"file_search",inputSchema:B({}),outputSchema:lx}),ux=Vt(()=>We(B({background:ft(["auto","opaque","transparent"]).optional(),inputFidelity:ft(["low","high"]).optional(),inputImageMask:B({fileId:I().optional(),imageUrl:I().optional()}).optional(),model:I().optional(),moderation:ft(["auto"]).optional(),outputCompression:X().int().min(0).max(100).optional(),outputFormat:ft(["png","jpeg","webp"]).optional(),partialImages:X().int().min(0).max(3).optional(),quality:ft(["auto","low","medium","high"]).optional(),size:ft(["1024x1024","1024x1536","1536x1024","auto"]).optional()}).strict())),dx=Vt(()=>We(B({}))),fx=Vt(()=>We(B({result:I()}))),hx=Er({id:"openai.image_generation",name:"image_generation",inputSchema:dx,outputSchema:fx}),px=(t={})=>hx(t),Ru=Vt(()=>We(B({action:B({type:ie("exec"),command:ve(I()),timeoutMs:X().optional(),user:I().optional(),workingDirectory:I().optional(),env:Dt(I(),I()).optional()})}))),Du=Vt(()=>We(B({output:I()}))),gx=Er({id:"openai.local_shell",name:"local_shell",inputSchema:Ru,outputSchema:Du}),mx=Vt(()=>We(B({externalWebAccess:$t().optional(),filters:B({allowedDomains:ve(I()).optional()}).optional(),searchContextSize:ft(["low","medium","high"]).optional(),userLocation:B({type:ie("approximate"),country:I().optional(),city:I().optional(),region:I().optional(),timezone:I().optional()}).optional()}))),xx=Vt(()=>We(B({}))),wx=Vt(()=>We(B({action:Ft("type",[B({type:ie("search"),query:I().optional()}),B({type:ie("openPage"),url:I().nullish()}),B({type:ie("findInPage"),url:I().nullish(),pattern:I().nullish()})]),sources:ve(Ft("type",[B({type:ie("url"),url:I()}),B({type:ie("api"),name:I()})])).optional()}))),yx=Er({id:"openai.web_search",name:"web_search",inputSchema:xx,outputSchema:wx}),_x=(t={})=>yx(t),vx=Vt(()=>We(B({searchContextSize:ft(["low","medium","high"]).optional(),userLocation:B({type:ie("approximate"),country:I().optional(),city:I().optional(),region:I().optional(),timezone:I().optional()}).optional()}))),bx=Vt(()=>We(B({}))),Cx=Vt(()=>We(B({action:Ft("type",[B({type:ie("search"),query:I().optional()}),B({type:ie("openPage"),url:I().nullish()}),B({type:ie("findInPage"),url:I().nullish(),pattern:I().nullish()})])}))),Ex=Er({id:"openai.web_search_preview",name:"web_search_preview",inputSchema:bx,outputSchema:Cx}),Ax={codeInterpreter:sx,fileSearch:cx,imageGeneration:px,localShell:gx,webSearchPreview:Ex,webSearch:_x};function Ga(t,r){return r?r.some(o=>t.startsWith(o)):!1}async function Ix({prompt:t,systemMessageMode:r,fileIdPrefixes:o,store:l,hasLocalShellTool:u=!1}){var f,g,x,y;const m=[],E=[];for(const{role:C,content:P}of t)switch(C){case"system":{switch(r){case"system":{m.push({role:"system",content:P});break}case"developer":{m.push({role:"developer",content:P});break}case"remove":{E.push({type:"other",message:"system messages are removed for this model"});break}default:{const O=r;throw new Error(`Unsupported system message mode: ${O}`)}}break}case"user":{m.push({role:"user",content:P.map((O,D)=>{var R,M,V;switch(O.type){case"text":return{type:"input_text",text:O.text};case"file":if(O.mediaType.startsWith("image/")){const U=O.mediaType==="image/*"?"image/jpeg":O.mediaType;return{type:"input_image",...O.data instanceof URL?{image_url:O.data.toString()}:typeof O.data=="string"&&Ga(O.data,o)?{file_id:O.data}:{image_url:`data:${U};base64,${vr(O.data)}`},detail:(M=(R=O.providerOptions)==null?void 0:R.openai)==null?void 0:M.imageDetail}}else{if(O.mediaType==="application/pdf")return O.data instanceof URL?{type:"input_file",file_url:O.data.toString()}:{type:"input_file",...typeof O.data=="string"&&Ga(O.data,o)?{file_id:O.data}:{filename:(V=O.filename)!=null?V:`part-${D}.pdf`,file_data:`data:application/pdf;base64,${vr(O.data)}`}};throw new Ln({functionality:`file part media type ${O.mediaType}`})}}})});break}case"assistant":{const O={},D={};for(const R of P)switch(R.type){case"text":{const M=(g=(f=R.providerOptions)==null?void 0:f.openai)==null?void 0:g.itemId;if(l&&M!=null){m.push({type:"item_reference",id:M});break}m.push({role:"assistant",content:[{type:"output_text",text:R.text}],id:M});break}case"tool-call":{if(D[R.toolCallId]=R,R.providerExecuted)break;const M=(y=(x=R.providerOptions)==null?void 0:x.openai)==null?void 0:y.itemId;if(l&&M!=null){m.push({type:"item_reference",id:M});break}if(u&&R.toolName==="local_shell"){const V=await Xn({value:R.input,schema:Ru});m.push({type:"local_shell_call",call_id:R.toolCallId,id:M,action:{type:"exec",command:V.action.command,timeout_ms:V.action.timeoutMs,user:V.action.user,working_directory:V.action.workingDirectory,env:V.action.env}});break}m.push({type:"function_call",call_id:R.toolCallId,name:R.toolName,arguments:JSON.stringify(R.input),id:M});break}case"tool-result":{l?m.push({type:"item_reference",id:R.toolCallId}):E.push({type:"other",message:`Results for OpenAI tool ${R.toolName} are not sent to the API when store is false`});break}case"reasoning":{const M=await Kn({provider:"openai",providerOptions:R.providerOptions,schema:Sx}),V=M?.itemId;if(V!=null){const U=O[V];if(l)U===void 0&&(m.push({type:"item_reference",id:V}),O[V]={type:"reasoning",id:V,summary:[]});else{const k=[];R.text.length>0?k.push({type:"summary_text",text:R.text}):U!==void 0&&E.push({type:"other",message:`Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${JSON.stringify(R)}.`}),U===void 0?(O[V]={type:"reasoning",id:V,encrypted_content:M?.reasoningEncryptedContent,summary:k},m.push(O[V])):(U.summary.push(...k),M?.reasoningEncryptedContent!=null&&(U.encrypted_content=M.reasoningEncryptedContent))}}else E.push({type:"other",message:`Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${JSON.stringify(R)}.`});break}}break}case"tool":{for(const O of P){const D=O.output;if(u&&O.toolName==="local_shell"&&D.type==="json"){const M=await Xn({value:D.value,schema:Du});m.push({type:"local_shell_call_output",call_id:O.toolCallId,output:M.output});break}let R;switch(D.type){case"text":case"error-text":R=D.value;break;case"json":case"error-json":R=JSON.stringify(D.value);break;case"content":R=D.value.map(M=>{switch(M.type){case"text":return{type:"input_text",text:M.text};case"media":return M.mediaType.startsWith("image/")?{type:"input_image",image_url:`data:${M.mediaType};base64,${M.data}`}:{type:"input_file",filename:"data",file_data:`data:${M.mediaType};base64,${M.data}`}}});break}m.push({type:"function_call_output",call_id:O.toolCallId,output:R})}break}default:{const O=C;throw new Error(`Unsupported role: ${O}`)}}return{input:m,warnings:E}}var Sx=B({itemId:I().nullish(),reasoningEncryptedContent:I().nullish()});function Xa({finishReason:t,hasFunctionCall:r}){switch(t){case void 0:case null:return r?"tool-calls":"stop";case"max_output_tokens":return"length";case"content_filter":return"content-filter";default:return r?"tool-calls":"unknown"}}var Tx=qt(()=>We(lt([B({type:ie("response.output_text.delta"),item_id:I(),delta:I(),logprobs:ve(B({token:I(),logprob:X(),top_logprobs:ve(B({token:I(),logprob:X()}))})).nullish()}),B({type:ft(["response.completed","response.incomplete"]),response:B({incomplete_details:B({reason:I()}).nullish(),usage:B({input_tokens:X(),input_tokens_details:B({cached_tokens:X().nullish()}).nullish(),output_tokens:X(),output_tokens_details:B({reasoning_tokens:X().nullish()}).nullish()}),service_tier:I().nullish()})}),B({type:ie("response.created"),response:B({id:I(),created_at:X(),model:I(),service_tier:I().nullish()})}),B({type:ie("response.output_item.added"),output_index:X(),item:Ft("type",[B({type:ie("message"),id:I()}),B({type:ie("reasoning"),id:I(),encrypted_content:I().nullish()}),B({type:ie("function_call"),id:I(),call_id:I(),name:I(),arguments:I()}),B({type:ie("web_search_call"),id:I(),status:I()}),B({type:ie("computer_call"),id:I(),status:I()}),B({type:ie("file_search_call"),id:I()}),B({type:ie("image_generation_call"),id:I()}),B({type:ie("code_interpreter_call"),id:I(),container_id:I(),code:I().nullable(),outputs:ve(Ft("type",[B({type:ie("logs"),logs:I()}),B({type:ie("image"),url:I()})])).nullable(),status:I()})])}),B({type:ie("response.output_item.done"),output_index:X(),item:Ft("type",[B({type:ie("message"),id:I()}),B({type:ie("reasoning"),id:I(),encrypted_content:I().nullish()}),B({type:ie("function_call"),id:I(),call_id:I(),name:I(),arguments:I(),status:ie("completed")}),B({type:ie("code_interpreter_call"),id:I(),code:I().nullable(),container_id:I(),outputs:ve(Ft("type",[B({type:ie("logs"),logs:I()}),B({type:ie("image"),url:I()})])).nullable()}),B({type:ie("image_generation_call"),id:I(),result:I()}),B({type:ie("web_search_call"),id:I(),status:I(),action:Ft("type",[B({type:ie("search"),query:I().nullish(),sources:ve(Ft("type",[B({type:ie("url"),url:I()}),B({type:ie("api"),name:I()})])).nullish()}),B({type:ie("open_page"),url:I().nullish()}),B({type:ie("find_in_page"),url:I().nullish(),pattern:I().nullish()})])}),B({type:ie("file_search_call"),id:I(),queries:ve(I()),results:ve(B({attributes:Dt(I(),qr()),file_id:I(),filename:I(),score:X(),text:I()})).nullish()}),B({type:ie("local_shell_call"),id:I(),call_id:I(),action:B({type:ie("exec"),command:ve(I()),timeout_ms:X().optional(),user:I().optional(),working_directory:I().optional(),env:Dt(I(),I()).optional()})}),B({type:ie("computer_call"),id:I(),status:ie("completed")})])}),B({type:ie("response.function_call_arguments.delta"),item_id:I(),output_index:X(),delta:I()}),B({type:ie("response.image_generation_call.partial_image"),item_id:I(),output_index:X(),partial_image_b64:I()}),B({type:ie("response.code_interpreter_call_code.delta"),item_id:I(),output_index:X(),delta:I()}),B({type:ie("response.code_interpreter_call_code.done"),item_id:I(),output_index:X(),code:I()}),B({type:ie("response.output_text.annotation.added"),annotation:Ft("type",[B({type:ie("url_citation"),start_index:X(),end_index:X(),url:I(),title:I()}),B({type:ie("file_citation"),file_id:I(),filename:I().nullish(),index:X().nullish(),start_index:X().nullish(),end_index:X().nullish(),quote:I().nullish()})])}),B({type:ie("response.reasoning_summary_part.added"),item_id:I(),summary_index:X()}),B({type:ie("response.reasoning_summary_text.delta"),item_id:I(),summary_index:X(),delta:I()}),B({type:ie("response.reasoning_summary_part.done"),item_id:I(),summary_index:X()}),B({type:ie("error"),sequence_number:X(),error:B({type:I(),code:I(),message:I(),param:I().nullish()})}),B({type:I()}).loose().transform(t=>({type:"unknown_chunk",message:t.type}))]))),Nx=qt(()=>We(B({id:I().optional(),created_at:X().optional(),error:B({message:I(),type:I(),param:I().nullish(),code:I()}).nullish(),model:I().optional(),output:ve(Ft("type",[B({type:ie("message"),role:ie("assistant"),id:I(),content:ve(B({type:ie("output_text"),text:I(),logprobs:ve(B({token:I(),logprob:X(),top_logprobs:ve(B({token:I(),logprob:X()}))})).nullish(),annotations:ve(Ft("type",[B({type:ie("url_citation"),start_index:X(),end_index:X(),url:I(),title:I()}),B({type:ie("file_citation"),file_id:I(),filename:I().nullish(),index:X().nullish(),start_index:X().nullish(),end_index:X().nullish(),quote:I().nullish()}),B({type:ie("container_file_citation"),container_id:I(),file_id:I(),filename:I().nullish(),start_index:X().nullish(),end_index:X().nullish(),index:X().nullish()}),B({type:ie("file_path"),file_id:I(),index:X().nullish()})]))}))}),B({type:ie("web_search_call"),id:I(),status:I(),action:Ft("type",[B({type:ie("search"),query:I().nullish(),sources:ve(Ft("type",[B({type:ie("url"),url:I()}),B({type:ie("api"),name:I()})])).nullish()}),B({type:ie("open_page"),url:I().nullish()}),B({type:ie("find_in_page"),url:I().nullish(),pattern:I().nullish()})])}),B({type:ie("file_search_call"),id:I(),queries:ve(I()),results:ve(B({attributes:Dt(I(),lt([I(),X(),$t()])),file_id:I(),filename:I(),score:X(),text:I()})).nullish()}),B({type:ie("code_interpreter_call"),id:I(),code:I().nullable(),container_id:I(),outputs:ve(Ft("type",[B({type:ie("logs"),logs:I()}),B({type:ie("image"),url:I()})])).nullable()}),B({type:ie("image_generation_call"),id:I(),result:I()}),B({type:ie("local_shell_call"),id:I(),call_id:I(),action:B({type:ie("exec"),command:ve(I()),timeout_ms:X().optional(),user:I().optional(),working_directory:I().optional(),env:Dt(I(),I()).optional()})}),B({type:ie("function_call"),call_id:I(),name:I(),arguments:I(),id:I()}),B({type:ie("computer_call"),id:I(),status:I().optional()}),B({type:ie("reasoning"),id:I(),encrypted_content:I().nullish(),summary:ve(B({type:ie("summary_text"),text:I()}))})])).optional(),service_tier:I().nullish(),incomplete_details:B({reason:I()}).nullish(),usage:B({input_tokens:X(),input_tokens_details:B({cached_tokens:X().nullish()}).nullish(),output_tokens:X(),output_tokens_details:B({reasoning_tokens:X().nullish()}).nullish()}).optional()}))),Mu=20,Ox=qt(()=>We(B({conversation:I().nullish(),include:ve(ft(["reasoning.encrypted_content","file_search_call.results","message.output_text.logprobs"])).nullish(),instructions:I().nullish(),logprobs:lt([$t(),X().min(1).max(Mu)]).optional(),maxToolCalls:X().nullish(),metadata:ri().nullish(),parallelToolCalls:$t().nullish(),previousResponseId:I().nullish(),promptCacheKey:I().nullish(),promptCacheRetention:ft(["in_memory","24h"]).nullish(),reasoningEffort:I().nullish(),reasoningSummary:I().nullish(),safetyIdentifier:I().nullish(),serviceTier:ft(["auto","flex","priority","default"]).nullish(),store:$t().nullish(),strictJsonSchema:$t().nullish(),textVerbosity:ft(["low","medium","high"]).nullish(),truncation:ft(["auto","disabled"]).nullish(),user:I().nullish()})));async function kx({tools:t,toolChoice:r,strictJsonSchema:o}){t=t?.length?t:void 0;const l=[];if(t==null)return{tools:void 0,toolChoice:void 0,toolWarnings:l};const u=[];for(const g of t)switch(g.type){case"function":u.push({type:"function",name:g.name,description:g.description,parameters:g.inputSchema,strict:o});break;case"provider-defined":{switch(g.id){case"openai.file_search":{const x=await Xn({value:g.args,schema:ax});u.push({type:"file_search",vector_store_ids:x.vectorStoreIds,max_num_results:x.maxNumResults,ranking_options:x.ranking?{ranker:x.ranking.ranker,score_threshold:x.ranking.scoreThreshold}:void 0,filters:x.filters});break}case"openai.local_shell":{u.push({type:"local_shell"});break}case"openai.web_search_preview":{const x=await Xn({value:g.args,schema:vx});u.push({type:"web_search_preview",search_context_size:x.searchContextSize,user_location:x.userLocation});break}case"openai.web_search":{const x=await Xn({value:g.args,schema:mx});u.push({type:"web_search",filters:x.filters!=null?{allowed_domains:x.filters.allowedDomains}:void 0,external_web_access:x.externalWebAccess,search_context_size:x.searchContextSize,user_location:x.userLocation});break}case"openai.code_interpreter":{const x=await Xn({value:g.args,schema:ix});u.push({type:"code_interpreter",container:x.container==null?{type:"auto",file_ids:void 0}:typeof x.container=="string"?x.container:{type:"auto",file_ids:x.container.fileIds}});break}case"openai.image_generation":{const x=await Xn({value:g.args,schema:ux});u.push({type:"image_generation",background:x.background,input_fidelity:x.inputFidelity,input_image_mask:x.inputImageMask?{file_id:x.inputImageMask.fileId,image_url:x.inputImageMask.imageUrl}:void 0,model:x.model,size:x.size,quality:x.quality,moderation:x.moderation,output_format:x.outputFormat,output_compression:x.outputCompression});break}}break}default:l.push({type:"unsupported-tool",tool:g});break}if(r==null)return{tools:u,toolChoice:void 0,toolWarnings:l};const f=r.type;switch(f){case"auto":case"none":case"required":return{tools:u,toolChoice:f,toolWarnings:l};case"tool":return{tools:u,toolChoice:r.toolName==="code_interpreter"||r.toolName==="file_search"||r.toolName==="image_generation"||r.toolName==="web_search_preview"||r.toolName==="web_search"?{type:r.toolName}:{type:"function",name:r.toolName},toolWarnings:l};default:{const g=f;throw new Ln({functionality:`tool choice type: ${g}`})}}}var Rx=class{constructor(t,r){this.specificationVersion="v2",this.supportedUrls={"image/*":[/^https?:\/\/.*$/],"application/pdf":[/^https?:\/\/.*$/]},this.modelId=t,this.config=r}get provider(){return this.config.provider}async getArgs({maxOutputTokens:t,temperature:r,stopSequences:o,topP:l,topK:u,presencePenalty:f,frequencyPenalty:g,seed:x,prompt:y,providerOptions:m,tools:E,toolChoice:C,responseFormat:P}){var O,D,R,M;const V=[],U=Nu(this.modelId);u!=null&&V.push({type:"unsupported-setting",setting:"topK"}),x!=null&&V.push({type:"unsupported-setting",setting:"seed"}),f!=null&&V.push({type:"unsupported-setting",setting:"presencePenalty"}),g!=null&&V.push({type:"unsupported-setting",setting:"frequencyPenalty"}),o!=null&&V.push({type:"unsupported-setting",setting:"stopSequences"});const k=await Kn({provider:"openai",providerOptions:m,schema:Ox});k?.conversation&&k?.previousResponseId&&V.push({type:"unsupported-setting",setting:"conversation",details:"conversation and previousResponseId cannot be used together"});const{input:J,warnings:be}=await Ix({prompt:y,systemMessageMode:U.systemMessageMode,fileIdPrefixes:this.config.fileIdPrefixes,store:(O=k?.store)!=null?O:!0,hasLocalShellTool:W("openai.local_shell")});V.push(...be);const Z=(D=k?.strictJsonSchema)!=null?D:!1;let z=k?.include;function Y(K){z==null?z=[K]:z.includes(K)||(z=[...z,K])}function W(K){return E?.find(ne=>ne.type==="provider-defined"&&ne.id===K)!=null}const de=typeof k?.logprobs=="number"?k?.logprobs:k?.logprobs===!0?Mu:void 0;de&&Y("message.output_text.logprobs");const me=(R=E?.find(K=>K.type==="provider-defined"&&(K.id==="openai.web_search"||K.id==="openai.web_search_preview")))==null?void 0:R.name;me&&Y("web_search_call.action.sources"),W("openai.code_interpreter")&&Y("code_interpreter_call.outputs");const pe=k?.store;pe===!1&&U.isReasoningModel&&Y("reasoning.encrypted_content");const Ce={model:this.modelId,input:J,temperature:r,top_p:l,max_output_tokens:t,...(P?.type==="json"||k?.textVerbosity)&&{text:{...P?.type==="json"&&{format:P.schema!=null?{type:"json_schema",strict:Z,name:(M=P.name)!=null?M:"response",description:P.description,schema:P.schema}:{type:"json_object"}},...k?.textVerbosity&&{verbosity:k.textVerbosity}}},conversation:k?.conversation,max_tool_calls:k?.maxToolCalls,metadata:k?.metadata,parallel_tool_calls:k?.parallelToolCalls,previous_response_id:k?.previousResponseId,store:pe,user:k?.user,instructions:k?.instructions,service_tier:k?.serviceTier,include:z,prompt_cache_key:k?.promptCacheKey,prompt_cache_retention:k?.promptCacheRetention,safety_identifier:k?.safetyIdentifier,top_logprobs:de,truncation:k?.truncation,...U.isReasoningModel&&(k?.reasoningEffort!=null||k?.reasoningSummary!=null)&&{reasoning:{...k?.reasoningEffort!=null&&{effort:k.reasoningEffort},...k?.reasoningSummary!=null&&{summary:k.reasoningSummary}}}};U.isReasoningModel?k?.reasoningEffort==="none"&&U.supportsNonReasoningParameters||(Ce.temperature!=null&&(Ce.temperature=void 0,V.push({type:"unsupported-setting",setting:"temperature",details:"temperature is not supported for reasoning models"})),Ce.top_p!=null&&(Ce.top_p=void 0,V.push({type:"unsupported-setting",setting:"topP",details:"topP is not supported for reasoning models"}))):(k?.reasoningEffort!=null&&V.push({type:"unsupported-setting",setting:"reasoningEffort",details:"reasoningEffort is not supported for non-reasoning models"}),k?.reasoningSummary!=null&&V.push({type:"unsupported-setting",setting:"reasoningSummary",details:"reasoningSummary is not supported for non-reasoning models"})),k?.serviceTier==="flex"&&!U.supportsFlexProcessing&&(V.push({type:"unsupported-setting",setting:"serviceTier",details:"flex processing is only available for o3, o4-mini, and gpt-5 models"}),delete Ce.service_tier),k?.serviceTier==="priority"&&!U.supportsPriorityProcessing&&(V.push({type:"unsupported-setting",setting:"serviceTier",details:"priority processing is only available for supported models (gpt-4, gpt-5, gpt-5-mini, o3, o4-mini) and requires Enterprise access. gpt-5-nano is not supported"}),delete Ce.service_tier);const{tools:le,toolChoice:L,toolWarnings:te}=await kx({tools:E,toolChoice:C,strictJsonSchema:Z});return{webSearchToolName:me,args:{...Ce,tools:le,tool_choice:L},warnings:[...V,...te],store:pe}}async doGenerate(t){var r,o,l,u,f,g,x,y,m,E,C,P,O,D,R,M,V,U,k,J,be,Z,z,Y,W,de,me,pe;const{args:Ce,warnings:le,webSearchToolName:L}=await this.getArgs(t),te=this.config.url({path:"/responses",modelId:this.modelId}),K=this.config.provider.replace(".responses",""),{responseHeaders:ne,value:fe,rawValue:xe}=await Fn({url:te,headers:Rn(this.config.headers(),t.headers),body:Ce,failedResponseHandler:Dn,successfulResponseHandler:Ar(Nx),abortSignal:t.abortSignal,fetch:this.config.fetch});if(fe.error)throw new pn({message:fe.error.message,url:te,requestBodyValues:Ce,statusCode:400,responseHeaders:ne,responseBody:xe,isRetryable:!1});const ye=[],ee=[];let he=!1;for(const T of fe.output)switch(T.type){case"reasoning":{T.summary.length===0&&T.summary.push({type:"summary_text",text:""});for(const ce of T.summary)ye.push({type:"reasoning",text:ce.text,providerMetadata:{[K]:{itemId:T.id,reasoningEncryptedContent:(r=T.encrypted_content)!=null?r:null}}});break}case"image_generation_call":{ye.push({type:"tool-call",toolCallId:T.id,toolName:"image_generation",input:"{}",providerExecuted:!0}),ye.push({type:"tool-result",toolCallId:T.id,toolName:"image_generation",result:{result:T.result},providerExecuted:!0});break}case"local_shell_call":{ye.push({type:"tool-call",toolCallId:T.call_id,toolName:"local_shell",input:JSON.stringify({action:T.action}),providerMetadata:{[K]:{itemId:T.id}}});break}case"message":{for(const ce of T.content){(l=(o=t.providerOptions)==null?void 0:o.openai)!=null&&l.logprobs&&ce.logprobs&&ee.push(ce.logprobs),ye.push({type:"text",text:ce.text,providerMetadata:{[K]:{itemId:T.id}}});for(const we of ce.annotations)we.type==="url_citation"?ye.push({type:"source",sourceType:"url",id:(g=(f=(u=this.config).generateId)==null?void 0:f.call(u))!=null?g:Cn(),url:we.url,title:we.title}):we.type==="file_citation"?ye.push({type:"source",sourceType:"document",id:(m=(y=(x=this.config).generateId)==null?void 0:y.call(x))!=null?m:Cn(),mediaType:"text/plain",title:(C=(E=we.quote)!=null?E:we.filename)!=null?C:"Document",filename:(P=we.filename)!=null?P:we.file_id,...we.file_id?{providerMetadata:{[K]:{fileId:we.file_id}}}:{}}):we.type==="container_file_citation"?ye.push({type:"source",sourceType:"document",id:(R=(D=(O=this.config).generateId)==null?void 0:D.call(O))!=null?R:Cn(),mediaType:"text/plain",title:(V=(M=we.filename)!=null?M:we.file_id)!=null?V:"Document",filename:(U=we.filename)!=null?U:we.file_id,providerMetadata:{[K]:{fileId:we.file_id,containerId:we.container_id,...we.index!=null?{index:we.index}:{}}}}):we.type==="file_path"&&ye.push({type:"source",sourceType:"document",id:(be=(J=(k=this.config).generateId)==null?void 0:J.call(k))!=null?be:Cn(),mediaType:"application/octet-stream",title:we.file_id,filename:we.file_id,providerMetadata:{[K]:{fileId:we.file_id,...we.index!=null?{index:we.index}:{}}}})}break}case"function_call":{he=!0,ye.push({type:"tool-call",toolCallId:T.call_id,toolName:T.name,input:T.arguments,providerMetadata:{[K]:{itemId:T.id}}});break}case"web_search_call":{ye.push({type:"tool-call",toolCallId:T.id,toolName:L??"web_search",input:JSON.stringify({}),providerExecuted:!0}),ye.push({type:"tool-result",toolCallId:T.id,toolName:L??"web_search",result:Ya(T.action),providerExecuted:!0});break}case"computer_call":{ye.push({type:"tool-call",toolCallId:T.id,toolName:"computer_use",input:"",providerExecuted:!0}),ye.push({type:"tool-result",toolCallId:T.id,toolName:"computer_use",result:{type:"computer_use_tool_result",status:T.status||"completed"},providerExecuted:!0});break}case"file_search_call":{ye.push({type:"tool-call",toolCallId:T.id,toolName:"file_search",input:"{}",providerExecuted:!0}),ye.push({type:"tool-result",toolCallId:T.id,toolName:"file_search",result:{queries:T.queries,results:(z=(Z=T.results)==null?void 0:Z.map(ce=>({attributes:ce.attributes,fileId:ce.file_id,filename:ce.filename,score:ce.score,text:ce.text})))!=null?z:null},providerExecuted:!0});break}case"code_interpreter_call":{ye.push({type:"tool-call",toolCallId:T.id,toolName:"code_interpreter",input:JSON.stringify({code:T.code,containerId:T.container_id}),providerExecuted:!0}),ye.push({type:"tool-result",toolCallId:T.id,toolName:"code_interpreter",result:{outputs:T.outputs},providerExecuted:!0});break}}const Ee={[K]:{...fe.id!=null?{responseId:fe.id}:{}}};ee.length>0&&(Ee[K].logprobs=ee),typeof fe.service_tier=="string"&&(Ee[K].serviceTier=fe.service_tier);const _e=fe.usage;return{content:ye,finishReason:Xa({finishReason:(Y=fe.incomplete_details)==null?void 0:Y.reason,hasFunctionCall:he}),usage:{inputTokens:_e.input_tokens,outputTokens:_e.output_tokens,totalTokens:_e.input_tokens+_e.output_tokens,reasoningTokens:(de=(W=_e.output_tokens_details)==null?void 0:W.reasoning_tokens)!=null?de:void 0,cachedInputTokens:(pe=(me=_e.input_tokens_details)==null?void 0:me.cached_tokens)!=null?pe:void 0},request:{body:Ce},response:{id:fe.id,timestamp:new Date(fe.created_at*1e3),modelId:fe.model,headers:ne,body:xe},providerMetadata:Ee,warnings:le}}async doStream(t){const{args:r,warnings:o,webSearchToolName:l,store:u}=await this.getArgs(t),{responseHeaders:f,value:g}=await Fn({url:this.config.url({path:"/responses",modelId:this.modelId}),headers:Rn(this.config.headers(),t.headers),body:{...r,stream:!0},failedResponseHandler:Dn,successfulResponseHandler:ls(Tx),abortSignal:t.abortSignal,fetch:this.config.fetch}),x=this,y=this.config.provider.replace(".responses","");let m="unknown";const E={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0},C=[];let P=null;const O={},D=[];let R=!1;const M={};let V;return{stream:g.pipeThrough(new TransformStream({start(U){U.enqueue({type:"stream-start",warnings:o})},transform(U,k){var J,be,Z,z,Y,W,de,me,pe,Ce,le,L,te,K,ne,fe,xe,ye,ee,he,Ee,_e;if(t.includeRawChunks&&k.enqueue({type:"raw",rawValue:U.rawValue}),!U.success){m="error",k.enqueue({type:"error",error:U.error});return}const T=U.value;if(qa(T))T.item.type==="function_call"?(O[T.output_index]={toolName:T.item.name,toolCallId:T.item.call_id},k.enqueue({type:"tool-input-start",id:T.item.call_id,toolName:T.item.name})):T.item.type==="web_search_call"?(O[T.output_index]={toolName:l??"web_search",toolCallId:T.item.id},k.enqueue({type:"tool-input-start",id:T.item.id,toolName:l??"web_search",providerExecuted:!0}),k.enqueue({type:"tool-input-end",id:T.item.id}),k.enqueue({type:"tool-call",toolCallId:T.item.id,toolName:l??"web_search",input:JSON.stringify({}),providerExecuted:!0})):T.item.type==="computer_call"?(O[T.output_index]={toolName:"computer_use",toolCallId:T.item.id},k.enqueue({type:"tool-input-start",id:T.item.id,toolName:"computer_use",providerExecuted:!0})):T.item.type==="code_interpreter_call"?(O[T.output_index]={toolName:"code_interpreter",toolCallId:T.item.id,codeInterpreter:{containerId:T.item.container_id}},k.enqueue({type:"tool-input-start",id:T.item.id,toolName:"code_interpreter",providerExecuted:!0}),k.enqueue({type:"tool-input-delta",id:T.item.id,delta:`{"containerId":"${T.item.container_id}","code":"`})):T.item.type==="file_search_call"?k.enqueue({type:"tool-call",toolCallId:T.item.id,toolName:"file_search",input:"{}",providerExecuted:!0}):T.item.type==="image_generation_call"?k.enqueue({type:"tool-call",toolCallId:T.item.id,toolName:"image_generation",input:"{}",providerExecuted:!0}):T.item.type==="message"?(D.splice(0,D.length),k.enqueue({type:"text-start",id:T.item.id,providerMetadata:{[y]:{itemId:T.item.id}}})):qa(T)&&T.item.type==="reasoning"&&(M[T.item.id]={encryptedContent:T.item.encrypted_content,summaryParts:{0:"active"}},k.enqueue({type:"reasoning-start",id:`${T.item.id}:0`,providerMetadata:{[y]:{itemId:T.item.id,reasoningEncryptedContent:(J=T.item.encrypted_content)!=null?J:null}}}));else if(Mx(T)){if(T.item.type==="message")k.enqueue({type:"text-end",id:T.item.id,providerMetadata:{[y]:{itemId:T.item.id,...D.length>0&&{annotations:D}}}});else if(T.item.type==="function_call")O[T.output_index]=void 0,R=!0,k.enqueue({type:"tool-input-end",id:T.item.call_id}),k.enqueue({type:"tool-call",toolCallId:T.item.call_id,toolName:T.item.name,input:T.item.arguments,providerMetadata:{[y]:{itemId:T.item.id}}});else if(T.item.type==="web_search_call")O[T.output_index]=void 0,k.enqueue({type:"tool-result",toolCallId:T.item.id,toolName:l??"web_search",result:Ya(T.item.action),providerExecuted:!0});else if(T.item.type==="computer_call")O[T.output_index]=void 0,k.enqueue({type:"tool-input-end",id:T.item.id}),k.enqueue({type:"tool-call",toolCallId:T.item.id,toolName:"computer_use",input:"",providerExecuted:!0}),k.enqueue({type:"tool-result",toolCallId:T.item.id,toolName:"computer_use",result:{type:"computer_use_tool_result",status:T.item.status||"completed"},providerExecuted:!0});else if(T.item.type==="file_search_call")O[T.output_index]=void 0,k.enqueue({type:"tool-result",toolCallId:T.item.id,toolName:"file_search",result:{queries:T.item.queries,results:(Z=(be=T.item.results)==null?void 0:be.map(ce=>({attributes:ce.attributes,fileId:ce.file_id,filename:ce.filename,score:ce.score,text:ce.text})))!=null?Z:null},providerExecuted:!0});else if(T.item.type==="code_interpreter_call")O[T.output_index]=void 0,k.enqueue({type:"tool-result",toolCallId:T.item.id,toolName:"code_interpreter",result:{outputs:T.item.outputs},providerExecuted:!0});else if(T.item.type==="image_generation_call")k.enqueue({type:"tool-result",toolCallId:T.item.id,toolName:"image_generation",result:{result:T.item.result},providerExecuted:!0});else if(T.item.type==="local_shell_call")O[T.output_index]=void 0,k.enqueue({type:"tool-call",toolCallId:T.item.call_id,toolName:"local_shell",input:JSON.stringify({action:{type:"exec",command:T.item.action.command,timeoutMs:T.item.action.timeout_ms,user:T.item.action.user,workingDirectory:T.item.action.working_directory,env:T.item.action.env}}),providerMetadata:{[y]:{itemId:T.item.id}}});else if(T.item.type==="reasoning"){const ce=M[T.item.id],we=Object.entries(ce.summaryParts).filter(([mt,ot])=>ot==="active"||ot==="can-conclude").map(([mt])=>mt);for(const mt of we)k.enqueue({type:"reasoning-end",id:`${T.item.id}:${mt}`,providerMetadata:{[y]:{itemId:T.item.id,reasoningEncryptedContent:(z=T.item.encrypted_content)!=null?z:null}}});delete M[T.item.id]}}else if(Lx(T)){const ce=O[T.output_index];ce!=null&&k.enqueue({type:"tool-input-delta",id:ce.toolCallId,delta:T.delta})}else if(Fx(T)){const ce=O[T.output_index];ce!=null&&k.enqueue({type:"tool-input-delta",id:ce.toolCallId,delta:JSON.stringify(T.delta).slice(1,-1)})}else if($x(T)){const ce=O[T.output_index];ce!=null&&(k.enqueue({type:"tool-input-delta",id:ce.toolCallId,delta:'"}'}),k.enqueue({type:"tool-input-end",id:ce.toolCallId}),k.enqueue({type:"tool-call",toolCallId:ce.toolCallId,toolName:"code_interpreter",input:JSON.stringify({code:T.code,containerId:ce.codeInterpreter.containerId}),providerExecuted:!0}))}else if(Bx(T))P=T.response.id,k.enqueue({type:"response-metadata",id:T.response.id,timestamp:new Date(T.response.created_at*1e3),modelId:T.response.model});else if(Dx(T))k.enqueue({type:"text-delta",id:T.item_id,delta:T.delta}),(W=(Y=t.providerOptions)==null?void 0:Y.openai)!=null&&W.logprobs&&T.logprobs&&C.push(T.logprobs);else if(T.type==="response.reasoning_summary_part.added"){if(T.summary_index>0){const ce=M[T.item_id];ce.summaryParts[T.summary_index]="active";for(const we of Object.keys(ce.summaryParts))ce.summaryParts[we]==="can-conclude"&&(k.enqueue({type:"reasoning-end",id:`${T.item_id}:${we}`,providerMetadata:{[y]:{itemId:T.item_id}}}),ce.summaryParts[we]="concluded");k.enqueue({type:"reasoning-start",id:`${T.item_id}:${T.summary_index}`,providerMetadata:{[y]:{itemId:T.item_id,reasoningEncryptedContent:(me=(de=M[T.item_id])==null?void 0:de.encryptedContent)!=null?me:null}}})}}else T.type==="response.reasoning_summary_text.delta"?k.enqueue({type:"reasoning-delta",id:`${T.item_id}:${T.summary_index}`,delta:T.delta,providerMetadata:{[y]:{itemId:T.item_id}}}):T.type==="response.reasoning_summary_part.done"?u?(k.enqueue({type:"reasoning-end",id:`${T.item_id}:${T.summary_index}`,providerMetadata:{[y]:{itemId:T.item_id}}}),M[T.item_id].summaryParts[T.summary_index]="concluded"):M[T.item_id].summaryParts[T.summary_index]="can-conclude":Px(T)?(m=Xa({finishReason:(pe=T.response.incomplete_details)==null?void 0:pe.reason,hasFunctionCall:R}),E.inputTokens=T.response.usage.input_tokens,E.outputTokens=T.response.usage.output_tokens,E.totalTokens=T.response.usage.input_tokens+T.response.usage.output_tokens,E.reasoningTokens=(le=(Ce=T.response.usage.output_tokens_details)==null?void 0:Ce.reasoning_tokens)!=null?le:void 0,E.cachedInputTokens=(te=(L=T.response.usage.input_tokens_details)==null?void 0:L.cached_tokens)!=null?te:void 0,typeof T.response.service_tier=="string"&&(V=T.response.service_tier)):Ux(T)?(D.push(T.annotation),T.annotation.type==="url_citation"?k.enqueue({type:"source",sourceType:"url",id:(fe=(ne=(K=x.config).generateId)==null?void 0:ne.call(K))!=null?fe:Cn(),url:T.annotation.url,title:T.annotation.title}):T.annotation.type==="file_citation"&&k.enqueue({type:"source",sourceType:"document",id:(ee=(ye=(xe=x.config).generateId)==null?void 0:ye.call(xe))!=null?ee:Cn(),mediaType:"text/plain",title:(Ee=(he=T.annotation.quote)!=null?he:T.annotation.filename)!=null?Ee:"Document",filename:(_e=T.annotation.filename)!=null?_e:T.annotation.file_id,...T.annotation.file_id?{providerMetadata:{[y]:{fileId:T.annotation.file_id}}}:{}})):zx(T)&&k.enqueue({type:"error",error:T})},flush(U){const k={[y]:{responseId:P}};C.length>0&&(k[y].logprobs=C),V!==void 0&&(k[y].serviceTier=V),U.enqueue({type:"finish",finishReason:m,usage:E,providerMetadata:k})}})),request:{body:r},response:{headers:f}}}};function Dx(t){return t.type==="response.output_text.delta"}function Mx(t){return t.type==="response.output_item.done"}function Px(t){return t.type==="response.completed"||t.type==="response.incomplete"}function Bx(t){return t.type==="response.created"}function Lx(t){return t.type==="response.function_call_arguments.delta"}function Fx(t){return t.type==="response.code_interpreter_call_code.delta"}function $x(t){return t.type==="response.code_interpreter_call_code.done"}function qa(t){return t.type==="response.output_item.added"}function Ux(t){return t.type==="response.output_text.annotation.added"}function zx(t){return t.type==="error"}function Ya(t){var r;switch(t.type){case"search":return{action:{type:"search",query:(r=t.query)!=null?r:void 0},...t.sources!=null&&{sources:t.sources}};case"open_page":return{action:{type:"openPage",url:t.url}};case"find_in_page":return{action:{type:"findInPage",url:t.url,pattern:t.pattern}}}}var Vx=qt(()=>We(B({instructions:I().nullish(),speed:X().min(.25).max(4).default(1).nullish()}))),Zx=class{constructor(t,r){this.modelId=t,this.config=r,this.specificationVersion="v2"}get provider(){return this.config.provider}async getArgs({text:t,voice:r="alloy",outputFormat:o="mp3",speed:l,instructions:u,language:f,providerOptions:g}){const x=[],y=await Kn({provider:"openai",providerOptions:g,schema:Vx}),m={model:this.modelId,input:t,voice:r,response_format:"mp3",speed:l,instructions:u};if(o&&(["mp3","opus","aac","flac","wav","pcm"].includes(o)?m.response_format=o:x.push({type:"unsupported-setting",setting:"outputFormat",details:`Unsupported output format: ${o}. Using mp3 instead.`})),y){const E={};for(const C in E){const P=E[C];P!==void 0&&(m[C]=P)}}return f&&x.push({type:"unsupported-setting",setting:"language",details:`OpenAI speech models do not support language selection. Language parameter "${f}" was ignored.`}),{requestBody:m,warnings:x}}async doGenerate(t){var r,o,l;const u=(l=(o=(r=this.config._internal)==null?void 0:r.currentDate)==null?void 0:o.call(r))!=null?l:new Date,{requestBody:f,warnings:g}=await this.getArgs(t),{value:x,responseHeaders:y,rawValue:m}=await Fn({url:this.config.url({path:"/audio/speech",modelId:this.modelId}),headers:Rn(this.config.headers(),t.headers),body:f,failedResponseHandler:Dn,successfulResponseHandler:Vm(),abortSignal:t.abortSignal,fetch:this.config.fetch});return{audio:x,warnings:g,request:{body:JSON.stringify(f)},response:{timestamp:u,modelId:this.modelId,headers:y,body:m}}}},jx=qt(()=>We(B({text:I(),language:I().nullish(),duration:X().nullish(),words:ve(B({word:I(),start:X(),end:X()})).nullish(),segments:ve(B({id:X(),seek:X(),start:X(),end:X(),text:I(),tokens:ve(X()),temperature:X(),avg_logprob:X(),compression_ratio:X(),no_speech_prob:X()})).nullish()}))),Hx=qt(()=>We(B({include:ve(I()).optional(),language:I().optional(),prompt:I().optional(),temperature:X().min(0).max(1).default(0).optional(),timestampGranularities:ve(ft(["word","segment"])).default(["segment"]).optional()}))),Ka={afrikaans:"af",arabic:"ar",armenian:"hy",azerbaijani:"az",belarusian:"be",bosnian:"bs",bulgarian:"bg",catalan:"ca",chinese:"zh",croatian:"hr",czech:"cs",danish:"da",dutch:"nl",english:"en",estonian:"et",finnish:"fi",french:"fr",galician:"gl",german:"de",greek:"el",hebrew:"he",hindi:"hi",hungarian:"hu",icelandic:"is",indonesian:"id",italian:"it",japanese:"ja",kannada:"kn",kazakh:"kk",korean:"ko",latvian:"lv",lithuanian:"lt",macedonian:"mk",malay:"ms",marathi:"mr",maori:"mi",nepali:"ne",norwegian:"no",persian:"fa",polish:"pl",portuguese:"pt",romanian:"ro",russian:"ru",serbian:"sr",slovak:"sk",slovenian:"sl",spanish:"es",swahili:"sw",swedish:"sv",tagalog:"tl",tamil:"ta",thai:"th",turkish:"tr",ukrainian:"uk",urdu:"ur",vietnamese:"vi",welsh:"cy"},Wx=class{constructor(t,r){this.modelId=t,this.config=r,this.specificationVersion="v2"}get provider(){return this.config.provider}async getArgs({audio:t,mediaType:r,providerOptions:o}){const l=[],u=await Kn({provider:"openai",providerOptions:o,schema:Hx}),f=new FormData,g=t instanceof Uint8Array?new Blob([t]):new Blob([B2(t)]);f.append("model",this.modelId);const x=Nm(r);if(f.append("file",new File([g],"audio",{type:r}),`audio.${x}`),u){const y={include:u.include,language:u.language,prompt:u.prompt,response_format:["gpt-4o-transcribe","gpt-4o-mini-transcribe"].includes(this.modelId)?"json":"verbose_json",temperature:u.temperature,timestamp_granularities:u.timestampGranularities};for(const[m,E]of Object.entries(y))if(E!=null)if(Array.isArray(E))for(const C of E)f.append(`${m}[]`,String(C));else f.append(m,String(E))}return{formData:f,warnings:l}}async doGenerate(t){var r,o,l,u,f,g,x,y;const m=(l=(o=(r=this.config._internal)==null?void 0:r.currentDate)==null?void 0:o.call(r))!=null?l:new Date,{formData:E,warnings:C}=await this.getArgs(t),{value:P,responseHeaders:O,rawValue:D}=await Um({url:this.config.url({path:"/audio/transcriptions",modelId:this.modelId}),headers:Rn(this.config.headers(),t.headers),formData:E,failedResponseHandler:Dn,successfulResponseHandler:Ar(jx),abortSignal:t.abortSignal,fetch:this.config.fetch}),R=P.language!=null&&P.language in Ka?Ka[P.language]:void 0;return{text:P.text,segments:(x=(g=(u=P.segments)==null?void 0:u.map(M=>({text:M.text,startSecond:M.start,endSecond:M.end})))!=null?g:(f=P.words)==null?void 0:f.map(M=>({text:M.word,startSecond:M.start,endSecond:M.end})))!=null?x:[],language:R,durationInSeconds:(y=P.duration)!=null?y:void 0,warnings:C,response:{timestamp:m,modelId:this.modelId,headers:O,body:D}}}},Gx="2.0.89";function Pu(t={}){var r,o;const l=(r=F2(Tm({settingValue:t.baseURL,environmentVariableName:"OPENAI_BASE_URL"})))!=null?r:"https://api.openai.com/v1",u=(o=t.name)!=null?o:"openai",f=()=>vu({Authorization:`Bearer ${Sm({apiKey:t.apiKey,environmentVariableName:"OPENAI_API_KEY",description:"OpenAI"})}`,"OpenAI-Organization":t.organization,"OpenAI-Project":t.project,...t.headers},`ai-sdk/openai/${Gx}`),g=R=>new j2(R,{provider:`${u}.chat`,url:({path:M})=>`${l}${M}`,headers:f,fetch:t.fetch}),x=R=>new X2(R,{provider:`${u}.completion`,url:({path:M})=>`${l}${M}`,headers:f,fetch:t.fetch}),y=R=>new K2(R,{provider:`${u}.embedding`,url:({path:M})=>`${l}${M}`,headers:f,fetch:t.fetch}),m=R=>new tx(R,{provider:`${u}.image`,url:({path:M})=>`${l}${M}`,headers:f,fetch:t.fetch}),E=R=>new Wx(R,{provider:`${u}.transcription`,url:({path:M})=>`${l}${M}`,headers:f,fetch:t.fetch}),C=R=>new Zx(R,{provider:`${u}.speech`,url:({path:M})=>`${l}${M}`,headers:f,fetch:t.fetch}),P=R=>{if(new.target)throw new Error("The OpenAI model function cannot be called with the new keyword.");return O(R)},O=R=>new Rx(R,{provider:`${u}.responses`,url:({path:M})=>`${l}${M}`,headers:f,fetch:t.fetch,fileIdPrefixes:["file-"]}),D=function(R){return P(R)};return D.languageModel=P,D.chat=g,D.completion=x,D.responses=O,D.embedding=y,D.textEmbedding=y,D.textEmbeddingModel=y,D.image=m,D.imageModel=m,D.transcription=E,D.transcriptionModel=E,D.speech=C,D.speechModel=C,D.tools=Ax,D}Pu();const Xx={deepseek:{prompt:{strategy:"append",id:"5ed1b9071c15d1ed59b5827ea5dcabd4",params:{customComponents:[{name:"选择用户组件",description:"选择用户组件,用于选择用户,支持模糊搜索",component:"TinyUser",schema:{properties:[{property:"modelValue",label:"用户绑定工号",required:!0,description:"用户的工号,双向绑定值",type:"string"},{property:"valueField",label:"值字段",required:!0,description:"用户工号值的绑定字段",type:"string"}]}}],customExamples:[{name:"选择用户示例",schema:{componentName:"Page",state:{reviewer:""},children:[{componentName:"h3",props:{},children:"输入用户名搜索工号并选择用户"},{componentName:"TinyUser",props:{modelValue:{type:"JSExpression",model:!0,value:"this.state.reviewer"},valueField:"uid"}},{componentName:"TinyButton",props:{text:"提交"}}]}}]}}}},No={model:"deepseek-ai/DeepSeek-V3",maxSteps:15,extraTools:{}},Ja={apiKey:"sk-trial",baseURL:"https://agent.opentiny.design/api/v1/ai/prompt",providerType:"deepseek"};class qx extends or.BaseModelProvider{transport;agent;systemPrompt;llmConfig={...No,...Ja};isGenuiEnabled;constructor(r,o,l,u,f){super(r);let g;f&&"llm"in f?g={...No,...f}:g={...No,...Ja,...f||{}},this.llmConfig=g;const x=g.llm?{llm:g.llm}:{...g},y={mcpServers:this.createMcpServers(o.value,l.value),llmConfig:x};this.agent=new Hi.AgentModelProvider(y),this.systemPrompt=u}updateLLMConfig({modelId:r,baseURL:o,apiKey:l,providerType:u,useReActMode:f,llm:g}){if(g)this.agent.llm=g,this.llmConfig.model=r,this.llmConfig.useReActMode=f||!1,this.agent.useReActMode=f||!1;else if(u&&o&&l){this.isGenuiEnabled?.value?o.includes("/prompt")||(o=o+"/prompt"):o=o.replace("/prompt",""),this.llmConfig.model=r,this.llmConfig.apiKey=l,this.llmConfig.baseURL=o,this.llmConfig.providerType=u,this.llmConfig.useReActMode=f||!1,this.agent.useReActMode=f||!1;let x;if(u==="deepseek")x=Yc;else if(u==="openai")x=Pu;else if(typeof u=="function")x=u;else throw new Error(`Unsupported providerType: ${u}`);this.agent.llm=x({apiKey:l,baseURL:o})}}createMcpServers(r,o){if(!r)return{};const l=r.includes(",")?r.split(",").map(f=>f.trim()):[r],u={};return l.forEach(f=>{u[`mcp-server-${f}`]={type:"streamableHttp",url:`${o}mcp?sessionId=${f}`}}),u}handleTextStream(r,o,l){return r.type==="text-start"?(o.onData({type:"text-start"}),l++,o.onData({type:"markdown",content:"",delta:"",textId:l})):r.type==="text-delta"?o.onData({type:"markdown",delta:r.text,textId:l}):r.type==="text-end"&&(o.onData({type:"markdown",delta:`
59
59
 
60
- `,textId:l}),o.onData({type:"text-end"})),l}handleToolStream(n,o){const u={"tool-input-start":()=>o.onData({type:"tool",id:n.id,name:n.toolName,status:"running",content:""}),"tool-input-delta":()=>o.onData({type:"tool",id:n.id,status:"running",delta:n.delta}),"tool-result":()=>o.onData({type:"tool",id:n.toolCallId,status:"success",delta:""}),"tool-error":()=>o.onData({type:"tool",id:n.toolCallId,status:"error",delta:n?.error?.message||"工具执行失败"})}[n.type];u&&u()}handleReasonStream(n,o,l){return n.type==="reasoning-start"?(l++,o.onData({type:"collapsible-text",title:"思考过程",content:"",delta:"",thinkId:l})):n.type==="reasoning-delta"?o.onData({type:"collapsible-text",delta:n.text,thinkId:l}):n.type==="reasoning-end"&&o.onData({type:"collapsible-text",delta:" ",thinkId:l}),l}cleanupOldSnapshotsInMessages(n){if(!n||n.length===0)return n;const l=this.agent.useReActMode===!0?"user":"tool",u=n[n.length-1];if(!u||u.role!==l||!this.isSnapshotContent(u.content))return n;const f=[...n];for(let g=f.length-2;g>=0;g--){const m=f[g];m.role===l&&this.isSnapshotContent(m.content)&&this.replaceSnapshotWithPlaceholder(m)}return f}removeSnapshotData(n){if(!n)return n;const o=["无障碍树快照:","无障碍树快照:","快照内容:","快照内容:","页面无障碍树快照:","页面无障碍树快照:","操作后的页面快照:","操作后的页面快照:"];let l=-1;for(const f of o){const g=n.indexOf(f);if(g!==-1){l=g;break}}if(l!==-1){const f=n.substring(0,l).trim();return f?`${f} 📸 [历史快照已清理]`:"📸 历史快照已清理"}const u=["已成功获取页面无障碍树快照","takeSnapshot","snapshotId_counter"];for(const f of u)if(n.startsWith(f))return"📸 历史快照已清理";return n}replaceSnapshotWithPlaceholder(n){if(Array.isArray(n.content)){const o=n.content[0];if(o?.output?.value?.content){const l=o.output.value.content;Array.isArray(l)&&(o.output.value.content=l.map(u=>u.type==="image"||u.type==="image_url"?null:u.type==="text"&&u.text&&this.isSnapshotContent(u.text)?{type:"text",text:this.removeSnapshotData(u.text)}:u).filter(u=>u!==null)),o.output.value.screenshot&&delete o.output.value.screenshot}else n.content=n.content.filter(l=>l.type!=="image"&&l.type!=="image_url")}else typeof n.content=="string"&&this.isSnapshotContent(n.content)&&(n.content=this.removeSnapshotData(n.content))}isSnapshotContent(n){if(!n)return!1;const o=["无障碍树快照","takeSnapshot","snapshotId_counter","UID 格式","快照 ID","操作后的页面快照","已成功获取页面无障碍树快照","快照内容:"];if(typeof n=="string")return o.some(l=>n.includes(l));if(Array.isArray(n))for(const l of n){const u=l?.output?.value?.content?.[0]?.text;if(u&&o.some(f=>u.includes(f))||l.type==="text"&&l.text&&o.some(f=>l.text.includes(f))||l.type==="image"||l.type==="image_url")return!0}return!1}async chatStream(n,o){let l=n.messages[n.messages.length-1];if(!l)return;if(this.llmConfig.beforeChatStream)try{const A=await this.llmConfig.beforeChatStream(l,this.systemPrompt);A&&(l=A)}catch(A){console.error("[beforeChatStream] 钩子执行失败:",A)}const u={model:this.llmConfig.model,system:this.systemPrompt,abortSignal:n.options?.signal,toolChoice:"auto",tools:{"get-today":r2,...this.llmConfig.extraTools||{}},maxSteps:this.llmConfig.maxSteps,providerOptions:this.llmConfig.providerOptions||r3,prepareStep:({messages:A})=>({messages:this.cleanupOldSnapshotsInMessages(A)}),onFinish:async()=>{await this.agent.closeAll()}},f={role:"user",content:l.content},g=[...this.agent.messages,f];u.messages=g;const m=await this.agent.chatStream(u);let y=1,x=1;try{for await(const A of m.fullStream){if(A.type==="error"){const b=A.error?.data?.error?.message||A.error?.message||A.error||"访问大模型出错";o.onData({type:"markdown",content:"",delta:"",textId:y}),o.onData({type:"markdown",delta:b,textId:y}),o.onError(b)}(A.type.includes("start-")||A.type.includes("-start"))&&o.onData({type:"start"}),A.type.startsWith("text-")?y=this.handleTextStream(A,o,y):A.type.startsWith("tool-")?this.handleToolStream(A,o):A.type.startsWith("reasoning-")&&(x=this.handleReasonStream(A,o,x))}}finally{o.onDone()}}chat(n){throw new Error("Method not implemented.")}}const o3={width:"100.000000",height:"100.000000",viewBox:"0 0 100 100",fill:"none",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"};function s3(t,n){return C.openBlock(),C.createElementBlock("svg",o3,[...n[0]||(n[0]=[C.createStaticVNode('<desc> Created with Pixso. </desc><defs><radialGradient gradientTransform="translate(32.4474 65.1156) rotate(128.932) scale(22.991 20.6919)" cx="0.000000" cy="0.000000" r="1.000000" id="paint_radial_9_3090_0" gradientUnits="userSpaceOnUse"><stop stop-color="#5ADDF8"></stop><stop stop-color="#AEBFFF"></stop><stop offset="0.329153" stop-color="#1476FF"></stop><stop offset="0.667785" stop-color="#655AF8"></stop><stop offset="0.868255" stop-color="#948CFF"></stop><stop offset="1.000000" stop-color="#D25AF8"></stop><stop offset="1.000000" stop-color="#5A8BF8"></stop></radialGradient><linearGradient x1="30.999874" y1="85.000229" x2="30.499891" y2="70.500214" id="paint_linear_9_3092_0" gradientUnits="userSpaceOnUse"><stop stop-color="#000000" stop-opacity="0.000000"></stop><stop offset="1.000000" stop-color="#000000"></stop></linearGradient><radialGradient gradientTransform="translate(26.9999 24.7118) rotate(38.3655) scale(77.7996 109.496)" cx="0.000000" cy="0.000000" r="1.000000" id="paint_radial_9_3094_0" gradientUnits="userSpaceOnUse"><stop stop-color="#5ADDF8"></stop><stop stop-color="#AEBFFF"></stop><stop offset="0.329153" stop-color="#1476FF"></stop><stop offset="0.667785" stop-color="#655AF8"></stop><stop offset="0.868255" stop-color="#948CFF"></stop><stop offset="1.000000" stop-color="#D25AF8"></stop><stop offset="1.000000" stop-color="#5A8BF8"></stop></radialGradient></defs><rect id="NEXT-LOGO-无背景渐变-右" width="100.000000" height="99.999939" transform="matrix(-1 0 0 1 100 0)" fill="#FFFFFF" fill-opacity="0"></rect>',3),C.createElementVNode("mask",{id:"mask9_3088","mask-type":"alpha",maskUnits:"userSpaceOnUse",x:"0.000061",y:"0.000061",width:"99.999939",height:"99.999939"},[C.createElementVNode("rect",{id:"画板 1773",width:"99.999962",height:"99.999947",transform:"matrix(-1 0 0 1 100 6.10352e-05)",fill:"#000000","fill-opacity":"1.000000"})],-1),C.createStaticVNode('<g mask="url(#mask9_3088)"><path id="矢量 1" d="M35.93 81.01L36 63L18 63.07L32.48 82.23C33.61 83.71 35.93 82.9 35.93 81.01Z" fill="url(#paint_radial_9_3090_0)" fill-opacity="1.000000" fill-rule="evenodd"></path><g opacity="0.100000" style="mix-blend-mode:normal;"><path id="矢量 1" d="M35.93 81.01L36 63L18 63.07L32.48 82.23C33.61 83.71 35.93 82.9 35.93 81.01Z" fill="url(#paint_linear_9_3092_0)" fill-opacity="1.000000" fill-rule="evenodd"></path></g><rect id="矩形 5" x="12.000000" y="19.000183" rx="26.999992" width="75.999977" height="53.999985" fill="url(#paint_radial_9_3094_0)" fill-opacity="1.000000"></rect><rect id="矩形 5" rx="26.499992" width="74.999977" height="52.999985" transform="matrix(-1 0 0 1 87.5 19.5002)" fill="#000000" fill-opacity="0"></rect><rect id="矩形 5" rx="26.499992" width="74.999977" height="52.999985" transform="matrix(-1 0 0 1 87.5 19.5002)" stroke="#000000" stroke-opacity="0" stroke-width="1.000000"></rect><path id="path" d="M45.39 59.06C44.22 60.05 42.9 60.66 41.43 60.89C39.95 61.12 38.57 61.04 37.28 60.65C36 60.26 34.04 58.58 34.04 58.58C34.04 58.58 29.02 54.73 29.02 45.61C29.02 36.5 33.5 32.5 33.5 32.5C33.5 32.5 34.72 31.31 36.5 31C38.29 30.68 39.43 30.98 40.66 31.33C50.89 34.23 62.38 34.33 72.58 31.33C73.81 30.98 74.91 30.93 75.89 31.17C76.87 31.42 77.71 31.89 78.42 32.59C81.65 35.81 82.87 41.06 83 45.61C83.12 50.09 81.97 55.24 78.94 58.54C78.04 59.52 76.98 60.22 75.78 60.63C74.58 61.04 73.32 61.12 71.99 60.89C70.66 60.66 69.48 60.05 68.46 59.06C68.01 58.62 67.39 58.07 66.57 57.4C65.76 56.73 64.83 56.08 63.79 55.44C62.75 54.8 61.62 54.25 60.39 53.8C59.16 53.35 57.91 53.13 56.62 53.13C55.36 53.13 54.16 53.36 53 53.83C51.85 54.29 50.79 54.84 49.82 55.48C48.86 56.12 48 56.78 47.26 57.45C46.51 58.11 45.89 58.65 45.39 59.06Z" fill="#FFFFFF" fill-opacity="1.000000" fill-rule="nonzero"></path><rect id="矩形 841" rx="2.000000" width="3.999999" height="11.999996" transform="matrix(-0.999983 0.00577157 0.00577157 0.999983 76.1109 38.0356)" fill="#1476FF" fill-opacity="1.000000"></rect><path id="合并" d="M42.96 38C43.77 37.97 44.55 38.42 44.92 39.19L48.73 47.11C49.22 48.13 48.79 49.34 47.75 49.81C46.72 50.28 45.48 49.83 44.99 48.8L42.96 44.59L40.94 48.81C40.45 49.83 39.21 50.28 38.18 49.81C37.14 49.34 36.7 48.13 37.2 47.11L41 39.19C41.37 38.42 42.16 37.98 42.96 38Z" fill="#1476FF" fill-opacity="1.000000" fill-rule="evenodd"></path></g>',1)])])}const sl={render:s3};function a3(t){const n=[];let o=0;for(;o<t.length;){const l="```schemaJson",u=t.indexOf(l,o),f=l.length;if(u===-1){const x=t.slice(o).trim();x&&n.push({type:"markdown",content:x});break}const g=t.slice(o,u).trim();g&&n.push({type:"markdown",content:g});const m=t.indexOf("```",u+f);let y;m===-1?(y=t.slice(u+f).trim(),o=t.length):(y=t.slice(u+f,m).trim(),o=m+3),n.push({type:"schema-card",content:y})}return n}const l3={viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",fill:"none"};function c3(t,n){return C.openBlock(),C.createElementBlock("svg",l3,[...n[0]||(n[0]=[C.createStaticVNode('<rect id="阿里云百炼" width="48.000000" height="48.000000" x="0.000000" y="0.000000"></rect><g id="组合 5451"><path id="矢量 141" d="M7 14L7 34L15.6608 29L15.6608 19L7 14Z" fill="rgb(4,35,219)" fill-rule="nonzero"></path><path id="矢量 142" d="M15.6606 19L15.6606 29L24.3206 24L15.6606 19Z" fill="rgb(28,84,228)" fill-rule="nonzero"></path><path id="矢量 143" d="M24.3206 24L15.6606 19L32.9773 8.99414L41.6415 14L24.3206 24Z" fill="rgb(171,155,255)" fill-rule="nonzero"></path><path id="矢量 144" d="M15.6608 19L7 14L24.3208 4L32.9775 8.99417L15.6608 19Z" fill="rgb(115,71,255)" fill-rule="nonzero"></path><path id="矢量 145" d="M41.6415 34L24.3206 44L15.6606 39L32.9806 29L41.6415 34Z" fill="rgb(0,207,202)" fill-rule="nonzero"></path><path id="矢量 146" d="M32.9808 29L41.6417 24L41.6417 34L32.9808 29ZM15.6608 39L7 34L24.3208 24L32.9808 29L15.6608 39Z" fill="rgb(0,235,210)" fill-rule="nonzero"></path></g>',2)])])}const u3={render:c3},d3={viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",fill:"none"};function f3(t,n){return C.openBlock(),C.createElementBlock("svg",d3,[...n[0]||(n[0]=[C.createElementVNode("rect",{id:"deepseek",width:"48.000000",height:"48.000000",x:"0.000000",y:"0.000000"},null,-1),C.createElementVNode("path",{id:"矢量 122",d:"M47.4955 9.02617C46.9872 8.77197 46.7678 9.2565 46.4708 9.50273C46.3696 9.58218 46.2833 9.68546 46.1969 9.78076C45.4541 10.5909 44.5864 11.1232 43.4515 11.0596C41.7933 10.9643 40.3774 11.4965 39.1263 12.7912C38.8603 11.1946 37.9766 10.2415 36.6312 9.62983C35.9262 9.31213 35.2153 8.99437 34.7218 8.30328C34.3783 7.81082 34.2849 7.26274 34.1122 6.72263C34.003 6.39695 33.8937 6.06335 33.5264 6.00772C33.1263 5.94416 32.9704 6.28575 32.8135 6.5717C32.188 7.73935 31.9447 9.02617 31.9695 10.3288C32.0231 13.2599 33.2365 15.5952 35.6453 17.2554C35.9193 17.446 35.9898 17.6366 35.9034 17.9146C35.7396 18.4865 35.543 19.0426 35.3712 19.6145C35.2619 19.9799 35.0982 20.0593 34.7139 19.9004C33.3923 19.3365 32.2505 18.5024 31.2407 17.4937C29.528 15.8017 27.979 13.9351 26.0478 12.4735C25.6005 12.1363 25.1415 11.8159 24.6707 11.5124C22.6997 9.55836 24.9288 7.95383 25.4451 7.76317C25.9843 7.5646 25.6328 6.88148 23.8883 6.88941C22.1437 6.89733 20.5481 7.49312 18.5146 8.28743C18.2168 8.40656 17.904 8.49393 17.5843 8.56547C15.7375 8.20798 13.8212 8.12858 11.8185 8.35891C8.04843 8.78787 5.0369 10.6069 2.82276 13.7127C0.163756 17.446 -0.462801 21.6877 0.304738 26.1121C1.109 30.7748 3.44128 34.6352 7.02373 37.6536C10.7392 40.7832 15.0176 42.3163 19.8988 42.0224C22.8636 41.8476 26.164 41.4426 29.8874 38.2255C30.8266 38.7021 31.8126 38.8928 33.447 39.0357C34.707 39.1549 35.9193 38.9722 36.8576 38.7736C38.3281 38.4559 38.2258 37.0658 37.6946 36.8116C33.3844 34.7622 34.3306 35.5963 33.4708 34.9212C35.6611 32.276 38.9615 29.5276 40.2523 20.6233C40.3546 19.9164 40.2682 19.4715 40.2523 18.8996C40.2444 18.5501 40.3218 18.415 40.714 18.3754C41.7933 18.2483 42.8418 17.9464 43.804 17.4063C46.596 15.8494 47.7229 13.2917 47.989 10.2256C48.0288 9.75694 47.9811 9.2724 47.4955 9.02618M23.1604 36.621C18.9843 33.2689 16.9577 32.1648 16.1207 32.2125C15.3383 32.2601 15.4793 33.1736 15.6511 33.7694C15.8308 34.3572 16.0661 34.7622 16.3947 35.2786C16.6212 35.6202 16.7781 36.1285 16.1674 36.5098C14.822 37.3597 12.4837 36.2238 12.3745 36.1683C9.65197 34.5319 7.3752 32.3713 5.77166 29.4165C4.22276 26.5728 3.32418 23.5226 3.17522 20.2659C3.13549 19.4795 3.36287 19.2014 4.12844 19.0584C5.1437 18.8606 6.1634 18.8342 7.18755 18.979C11.4511 19.6146 15.0812 21.5606 18.1234 24.6426C19.86 26.398 21.1736 28.4951 22.5279 30.5445C23.9667 32.7208 25.5156 34.7941 27.4865 36.4939C28.1826 37.0896 28.7376 37.5424 29.2698 37.876C27.6662 38.0587 24.9904 38.0984 23.1604 36.621M25.1631 23.4749C25.1631 23.1254 25.4372 22.8474 25.7817 22.8474C25.8598 22.8487 25.93 22.862 25.9922 22.8871C26.0515 22.9099 26.106 22.941 26.1557 22.9805C26.2055 23.0199 26.2482 23.0659 26.2839 23.1185C26.3195 23.171 26.3465 23.2277 26.3649 23.2885C26.3832 23.3493 26.392 23.4114 26.3914 23.4749C26.3919 23.5159 26.3884 23.5564 26.3809 23.5967C26.3734 23.6369 26.362 23.676 26.3467 23.714C26.3314 23.752 26.3126 23.7881 26.2901 23.8223C26.2677 23.8566 26.2421 23.8883 26.2134 23.9175C26.1847 23.9467 26.1534 23.9727 26.1195 23.9957C26.0857 24.0187 26.0499 24.0381 26.0121 24.054C25.9744 24.0699 25.9355 24.0819 25.8953 24.09C25.8552 24.0982 25.8147 24.1023 25.7738 24.1025C25.733 24.1023 25.6926 24.0982 25.6527 24.09C25.6127 24.0818 25.574 24.0698 25.5364 24.0539C25.4989 24.038 25.4633 24.0185 25.4296 23.9955C25.396 23.9724 25.3649 23.9463 25.3365 23.9171C25.3081 23.8879 25.2828 23.8561 25.2607 23.8218C25.2386 23.7876 25.2201 23.7514 25.2052 23.7135C25.1903 23.6755 25.1793 23.6365 25.1722 23.5963C25.1652 23.5561 25.1621 23.5157 25.1631 23.4749ZM31.3817 26.7316C30.9835 26.8985 30.5844 27.0415 30.2001 27.0573C29.6064 27.0891 28.957 26.8429 28.6056 26.541C28.0575 26.0723 27.6662 25.8102 27.5024 24.9921C27.4319 24.6426 27.4706 24.1025 27.5332 23.7927C27.6742 23.1254 27.5173 22.6965 27.0566 22.3073C26.6813 21.9895 26.2037 21.9021 25.6795 21.9021C25.4838 21.9021 25.3042 21.8148 25.1711 21.7433C25.1387 21.7278 25.1082 21.7091 25.0797 21.6873C25.0511 21.6655 25.0251 21.641 25.0017 21.6138C24.9782 21.5867 24.9577 21.5574 24.9403 21.5259C24.9229 21.4945 24.9089 21.4617 24.8982 21.4274C24.8876 21.3931 24.8806 21.358 24.8772 21.3223C24.8738 21.2865 24.8741 21.2508 24.8781 21.2151C24.8821 21.1794 24.8897 21.1445 24.9009 21.1104C24.9122 21.0762 24.9267 21.0436 24.9447 21.0125C24.9993 20.9013 25.2654 20.6312 25.328 20.5836C26.0398 20.1705 26.861 20.3056 27.6196 20.6154C28.3235 20.9092 28.8547 21.4494 29.6223 22.212C30.4047 23.1334 30.5457 23.3876 30.9905 24.0786C31.343 24.6187 31.6637 25.1748 31.8822 25.8102C32.0161 26.2074 31.8434 26.533 31.3817 26.7316L31.3817 26.7316Z",fill:"rgb(77,107,254)","fill-rule":"nonzero"},null,-1)])])}const al={render:f3},Qn=[{id:"deepseek-ai/DeepSeek-V3",label:"DeepSeek-V3",apiKey:"sk-trial",apiUrl:"https://agent.opentiny.design/api/v1/ai",providerType:"deepseek",useReActMode:!1,icon:al,isDefault:!0},{id:"deepseek-ai/DeepSeek-R1",label:"DeepSeek-R1",apiKey:"sk-trial",apiUrl:"https://agent.opentiny.design/api/v1/ai",providerType:"deepseek",useReActMode:!1,icon:al},{id:"qwen-vl-max",label:"qwen-vl-max",apiKey:"sk-trial",apiUrl:"https://agent.opentiny.design/api/v1/ai",providerType:"deepseek",useReActMode:!0,icon:u3}];function ju(){return Qn.find(n=>n.isDefault)||Qn[0]}function h3(t){return Qn.find(n=>n.id===t)}const gn={SELECTED_MODEL:"next-remoter-selected-model",GENUI_ENABLED:"next-remoter-genui-enabled",LOCAL_TOOL_STORAGE:"local-tool-storage",MCP_SESSION_ID:"mcp-sessionId"};class p3{getItem(n){try{const o=localStorage.getItem(n);return o===null?null:JSON.parse(o)}catch(o){return console.warn(`[StorageManager] Failed to get item "${n}":`,o),null}}setItem(n,o){try{localStorage.setItem(n,JSON.stringify(o))}catch(l){throw console.error(`[StorageManager] Failed to set item "${n}":`,l),l}}removeItem(n){try{localStorage.removeItem(n)}catch(o){throw console.error(`[StorageManager] Failed to remove item "${n}":`,o),o}}clear(){try{localStorage.clear()}catch(n){throw console.error("[StorageManager] Failed to clear storage:",n),n}}}class xs{adapter;constructor(n={}){n.adapter?this.adapter=n.adapter:this.adapter=new p3}getItem(n){const o=this.adapter.getItem(n);return o instanceof Promise?(console.warn(`[StorageManager] Async storage adapter detected, but sync method called for key: ${n}`),null):o}async getItemAsync(n){const o=this.adapter.getItem(n);return o instanceof Promise?o:Promise.resolve(o)}setItem(n,o){const l=this.adapter.setItem(n,o);l instanceof Promise&&l.catch(u=>{console.error(`[StorageManager] Failed to set item "${n}":`,u)})}async setItemAsync(n,o){const l=this.adapter.setItem(n,o);return l instanceof Promise?l:Promise.resolve()}removeItem(n){const o=this.adapter.removeItem(n);o instanceof Promise&&o.catch(l=>{console.error(`[StorageManager] Failed to remove item "${n}":`,l)})}async removeItemAsync(n){const o=this.adapter.removeItem(n);return o instanceof Promise?o:Promise.resolve()}clear(){const n=this.adapter.clear();n instanceof Promise&&n.catch(o=>{console.error("[StorageManager] Failed to clear storage:",o)})}async clearAsync(){const n=this.adapter.clear();return n instanceof Promise?n:Promise.resolve()}setAdapter(n){this.adapter=n}}let Bo=null;function $n(t){return Bo||(Bo=new xs(t)),Bo}function g3(t){return new xs(t)}const mn={getItem:t=>$n().getItem(t),getItemAsync:t=>$n().getItemAsync(t),setItem:(t,n)=>{$n().setItem(t,n)},setItemAsync:(t,n)=>$n().setItemAsync(t,n),removeItem:t=>{$n().removeItem(t)},removeItemAsync:t=>$n().removeItemAsync(t),clear:()=>{$n().clear()},clearAsync:()=>$n().clearAsync()},m3=()=>{try{const o=mn.getItem(gn.SELECTED_MODEL);if(o&&Qn.some(l=>l.id===o))return o}catch(o){console.warn("[useModel] Failed to parse stored model:",o)}const n=ju().id;return mn.setItem(gn.SELECTED_MODEL,n),n},Fi=C.ref(m3());C.watch(Fi,t=>{try{mn.setItem(gn.SELECTED_MODEL,t),console.log("[useModel] Model changed to:",t)}catch(n){console.error("[useModel] Failed to save model to storage:",n)}});function to(){const t=C.computed(()=>Qn.find(l=>l.id===Fi.value)),n=C.computed(()=>Qn);return{selectedModelId:Fi,selectedModel:t,availableModels:n,setSelectedModel:l=>{Qn.find(f=>f.id===l)?Fi.value=l:console.warn(`[useModel] Model not found: ${l}`)}}}function qo(){}const Zt=Object.assign,no=typeof window<"u",ro=t=>t!==null&&typeof t=="object",rr=t=>t!=null,Xi=t=>typeof t=="function",x3=t=>ro(t)&&Xi(t.then)&&Xi(t.catch),Hu=t=>typeof t=="number"||/^\d+(\.\d+)?$/.test(t),w3=()=>no?/ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()):!1;function ll(t,n){const o=n.split(".");let l=t;return o.forEach(u=>{var f;l=ro(l)&&(f=l[u])!=null?f:""}),l}function Wu(t,n,o){return n.reduce((l,u)=>(l[u]=t[u],l),{})}const ri=null,Xt=[Number,String],Tn={type:Boolean,default:!0},y3=t=>({type:Number,default:t}),Nt=t=>({type:String,default:t});var ws=typeof window<"u",_3=t=>t===window,cl=(t,n)=>({top:0,left:0,right:t,bottom:n,width:t,height:n}),v3=t=>{const n=C.unref(t);if(_3(n)){const o=n.innerWidth,l=n.innerHeight;return cl(o,l)}return n?.getBoundingClientRect?n.getBoundingClientRect():cl(0,0)};function C3(t){const n=C.inject(t,null);if(n){const o=C.getCurrentInstance(),{link:l,unlink:u,internalChildren:f}=n;l(o),C.onUnmounted(()=>u(o));const g=C.computed(()=>f.indexOf(o));return{parent:n,index:g}}return{parent:null,index:C.ref(-1)}}function b3(t){const n=[],o=l=>{Array.isArray(l)&&l.forEach(u=>{var f;C.isVNode(u)&&(n.push(u),(f=u.component)!=null&&f.subTree&&(n.push(u.component.subTree),o(u.component.subTree.children)),u.children&&o(u.children))})};return o(t),n}var ul=(t,n)=>{const o=t.indexOf(n);return o===-1?t.findIndex(l=>n.key!==void 0&&n.key!==null&&l.type===n.type&&l.key===n.key):o};function E3(t,n,o){const l=b3(t.subTree.children);o.sort((f,g)=>ul(l,f.vnode)-ul(l,g.vnode));const u=o.map(f=>f.proxy);n.sort((f,g)=>{const m=u.indexOf(f),y=u.indexOf(g);return m-y})}function A3(t){const n=C.reactive([]),o=C.reactive([]),l=C.getCurrentInstance();return{children:n,linkChildren:f=>{const g=y=>{y.proxy&&(o.push(y),n.push(y.proxy),E3(l,n,o))},m=y=>{const x=o.indexOf(y);n.splice(x,1),o.splice(x,1)};C.provide(t,Object.assign({link:g,unlink:m,children:n,internalChildren:o},f))}}}function Gu(t){let n;C.onMounted(()=>{t(),C.nextTick(()=>{n=!0})}),C.onActivated(()=>{n&&t()})}function Xu(t,n,o={}){if(!ws)return;const{target:l=window,passive:u=!1,capture:f=!1}=o;let g=!1,m;const y=b=>{if(g)return;const P=C.unref(b);P&&!m&&(P.addEventListener(t,n,{capture:f,passive:u}),m=!0)},x=b=>{if(g)return;const P=C.unref(b);P&&m&&(P.removeEventListener(t,n,f),m=!1)};C.onUnmounted(()=>x(l)),C.onDeactivated(()=>x(l)),Gu(()=>y(l));let A;return C.isRef(l)&&(A=C.watch(l,(b,P)=>{x(P),y(b)})),()=>{A?.(),x(l),g=!0}}var Oi,Lo;function I3(){if(!Oi&&(Oi=C.ref(0),Lo=C.ref(0),ws)){const t=()=>{Oi.value=window.innerWidth,Lo.value=window.innerHeight};t(),window.addEventListener("resize",t,{passive:!0}),window.addEventListener("orientationchange",t,{passive:!0})}return{width:Oi,height:Lo}}var S3=/scroll|auto|overlay/i,T3=ws?window:void 0;function O3(t){return t.tagName!=="HTML"&&t.tagName!=="BODY"&&t.nodeType===1}function N3(t,n=T3){let o=t;for(;o&&o!==n&&O3(o);){const{overflowY:l}=window.getComputedStyle(o);if(S3.test(l))return o;o=o.parentNode}return n}w3();const k3=t=>t.stopPropagation();function ys(t,n){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),n&&k3(t)}const{width:R3,height:D3}=I3();function xn(t){if(rr(t))return Hu(t)?`${t}px`:String(t)}function M3(t){if(rr(t)){if(Array.isArray(t))return{width:xn(t[0]),height:xn(t[1])};const n=xn(t);return{width:n,height:n}}}function P3(t){const n={};return t!==void 0&&(n.zIndex=+t),n}const B3=/-(\w)/g,Yu=t=>t.replace(B3,(n,o)=>o.toUpperCase()),L3=t=>t.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""),{hasOwnProperty:F3}=Object.prototype;function $3(t,n,o){const l=n[o];rr(l)&&(!F3.call(t,o)||!ro(l)?t[o]=l:t[o]=qu(Object(t[o]),l))}function qu(t,n){return Object.keys(n).forEach(o=>{$3(t,n,o)}),t}var U3={name:"姓名",tel:"电话",save:"保存",clear:"清空",cancel:"取消",confirm:"确认",delete:"删除",loading:"加载中...",noCoupon:"暂无优惠券",nameEmpty:"请填写姓名",addContact:"添加联系人",telInvalid:"请填写正确的电话",vanCalendar:{end:"结束",start:"开始",title:"日期选择",weekdays:["日","一","二","三","四","五","六"],monthTitle:(t,n)=>`${t}年${n}月`,rangePrompt:t=>`最多选择 ${t} 天`},vanCascader:{select:"请选择"},vanPagination:{prev:"上一页",next:"下一页"},vanPullRefresh:{pulling:"下拉即可刷新...",loosing:"释放即可刷新..."},vanSubmitBar:{label:"合计:"},vanCoupon:{unlimited:"无门槛",discount:t=>`${t}折`,condition:t=>`满${t}元可用`},vanCouponCell:{title:"优惠券",count:t=>`${t}张可用`},vanCouponList:{exchange:"兑换",close:"不使用",enable:"可用",disabled:"不可用",placeholder:"输入优惠码"},vanAddressEdit:{area:"地区",areaEmpty:"请选择地区",addressEmpty:"请填写详细地址",addressDetail:"详细地址",defaultAddress:"设为默认收货地址"},vanAddressList:{add:"新增地址"}};const dl=C.ref("zh-CN"),fl=C.reactive({"zh-CN":U3}),z3={messages(){return fl[dl.value]},use(t,n){dl.value=t,this.add({[t]:n})},add(t={}){qu(fl,t)}};var Z3=z3;function V3(t){const n=Yu(t)+".";return(o,...l)=>{const u=Z3.messages(),f=ll(u,n+o)||ll(u,o);return Xi(f)?f(...l):f}}function Ko(t,n){return n?typeof n=="string"?` ${t}--${n}`:Array.isArray(n)?n.reduce((o,l)=>o+Ko(t,l),""):Object.keys(n).reduce((o,l)=>o+(n[l]?Ko(t,l):""),""):""}function j3(t){return(n,o)=>(n&&typeof n!="string"&&(o=n,n=""),n=n?`${t}__${n}`:t,`${n}${Ko(n,o)}`)}function On(t){const n=`van-${t}`;return[n,j3(n),V3(n)]}const _s="van-hairline",H3=`${_s}--top`,W3=`${_s}--left`,G3=`${_s}--surround`,X3="van-haptics-feedback",hl=5;function Ku(t,{args:n=[],done:o,canceled:l,error:u}){if(t){const f=t.apply(null,n);x3(f)?f.then(g=>{g?o():l&&l()}).catch(u||qo):f?o():l&&l()}else o()}function jn(t){return t.install=n=>{const{name:o}=t;o&&(n.component(o,t),n.component(Yu(`-${o}`),t))},t}const Ju=Symbol();function Y3(t){const n=C.inject(Ju,null);n&&C.watch(n,o=>{o&&t()})}const q3=(t,n)=>{const o=C.ref(),l=()=>{o.value=v3(t).height};return C.onMounted(()=>{C.nextTick(l);for(let u=1;u<=3;u++)setTimeout(l,100*u)}),Y3(()=>C.nextTick(l)),C.watch([R3,D3],l),o};function K3(t,n){const o=q3(t);return l=>C.createVNode("div",{class:n("placeholder"),style:{height:o.value?`${o.value}px`:void 0}},[l()])}const[Qu,pl]=On("action-bar"),e1=Symbol(Qu),J3={placeholder:Boolean,safeAreaInsetBottom:Tn};var Q3=C.defineComponent({name:Qu,props:J3,setup(t,{slots:n}){const o=C.ref(),l=K3(o,pl),{linkChildren:u}=A3(e1);u();const f=()=>{var g;return C.createVNode("div",{ref:o,class:[pl(),{"van-safe-area-bottom":t.safeAreaInsetBottom}]},[(g=n.default)==null?void 0:g.call(n)])};return()=>t.placeholder?l(f):f()}});const ew=jn(Q3);function vs(t){const n=C.getCurrentInstance();n&&Zt(n.proxy,t)}const t1={to:[String,Object],url:String,replace:Boolean};function tw({to:t,url:n,replace:o,$router:l}){t&&l?l[o?"replace":"push"](t):n&&(o?location.replace(n):location.href=n)}function n1(){const t=C.getCurrentInstance().proxy;return()=>tw(t)}const[nw,gl]=On("badge"),rw={dot:Boolean,max:Xt,tag:Nt("div"),color:String,offset:Array,content:Xt,showZero:Tn,position:Nt("top-right")};var iw=C.defineComponent({name:nw,props:rw,setup(t,{slots:n}){const o=()=>{if(n.content)return!0;const{content:m,showZero:y}=t;return rr(m)&&m!==""&&(y||m!==0&&m!=="0")},l=()=>{const{dot:m,max:y,content:x}=t;if(!m&&o())return n.content?n.content():rr(y)&&Hu(x)&&+x>+y?`${y}+`:x},u=m=>m.startsWith("-")?m.replace("-",""):`-${m}`,f=C.computed(()=>{const m={background:t.color};if(t.offset){const[y,x]=t.offset,{position:A}=t,[b,P]=A.split("-");n.default?(typeof x=="number"?m[b]=xn(b==="top"?x:-x):m[b]=b==="top"?xn(x):u(x),typeof y=="number"?m[P]=xn(P==="left"?y:-y):m[P]=P==="left"?xn(y):u(y)):(m.marginTop=xn(x),m.marginLeft=xn(y))}return m}),g=()=>{if(o()||t.dot)return C.createVNode("div",{class:gl([t.position,{dot:t.dot,fixed:!!n.default}]),style:f.value},[l()])};return()=>{if(n.default){const{tag:m}=t;return C.createVNode(m,{class:gl("wrapper")},{default:()=>[n.default(),g()]})}return g()}}});const ow=jn(iw);let r1=2e3;const sw=()=>++r1,aw=t=>{r1=t},[i1,lw]=On("config-provider"),o1=Symbol(i1),cw={tag:Nt("div"),theme:Nt("light"),zIndex:Number,themeVars:Object,themeVarsDark:Object,themeVarsLight:Object,themeVarsScope:Nt("local"),iconPrefix:String};function uw(t){return t.replace(/([a-zA-Z])(\d)/g,"$1-$2")}function dw(t){const n={};return Object.keys(t).forEach(o=>{const l=uw(L3(o));n[`--van-${l}`]=t[o]}),n}function Ni(t={},n={}){Object.keys(t).forEach(o=>{t[o]!==n[o]&&document.documentElement.style.setProperty(o,t[o])}),Object.keys(n).forEach(o=>{t[o]||document.documentElement.style.removeProperty(o)})}C.defineComponent({name:i1,props:cw,setup(t,{slots:n}){const o=C.computed(()=>dw(Zt({},t.themeVars,t.theme==="dark"?t.themeVarsDark:t.themeVarsLight)));if(no){const l=()=>{document.documentElement.classList.add(`van-theme-${t.theme}`)},u=(f=t.theme)=>{document.documentElement.classList.remove(`van-theme-${f}`)};C.watch(()=>t.theme,(f,g)=>{g&&u(g),l()},{immediate:!0}),C.onActivated(l),C.onDeactivated(u),C.onBeforeUnmount(u),C.watch(o,(f,g)=>{t.themeVarsScope==="global"&&Ni(f,g)}),C.watch(()=>t.themeVarsScope,(f,g)=>{g==="global"&&Ni({},o.value),f==="global"&&Ni(o.value,{})}),t.themeVarsScope==="global"&&Ni(o.value,{})}return C.provide(o1,t),C.watchEffect(()=>{t.zIndex!==void 0&&aw(t.zIndex)}),()=>C.createVNode(t.tag,{class:lw(),style:t.themeVarsScope==="local"?o.value:void 0},{default:()=>{var l;return[(l=n.default)==null?void 0:l.call(n)]}})}});const[fw,ml]=On("icon"),hw=t=>t?.includes("/"),pw={dot:Boolean,tag:Nt("i"),name:String,size:Xt,badge:Xt,color:String,badgeProps:Object,classPrefix:String};var gw=C.defineComponent({name:fw,props:pw,setup(t,{slots:n}){const o=C.inject(o1,null),l=C.computed(()=>t.classPrefix||o?.iconPrefix||ml());return()=>{const{tag:u,dot:f,name:g,size:m,badge:y,color:x}=t,A=hw(g);return C.createVNode(ow,C.mergeProps({dot:f,tag:u,class:[l.value,A?"":`${l.value}-${g}`],style:{color:x,fontSize:xn(m)},content:y},t.badgeProps),{default:()=>{var b;return[(b=n.default)==null?void 0:b.call(n),A&&C.createVNode("img",{class:ml("image"),src:g},null)]}})}}});const io=jn(gw),[mw,Yr]=On("loading"),xw=Array(12).fill(null).map((t,n)=>C.createVNode("i",{class:Yr("line",String(n+1))},null)),ww=C.createVNode("svg",{class:Yr("circular"),viewBox:"25 25 50 50"},[C.createVNode("circle",{cx:"50",cy:"50",r:"20",fill:"none"},null)]),yw={size:Xt,type:Nt("circular"),color:String,vertical:Boolean,textSize:Xt,textColor:String};var _w=C.defineComponent({name:mw,props:yw,setup(t,{slots:n}){const o=C.computed(()=>Zt({color:t.color},M3(t.size))),l=()=>{const f=t.type==="spinner"?xw:ww;return C.createVNode("span",{class:Yr("spinner",t.type),style:o.value},[n.icon?n.icon():f])},u=()=>{var f;if(n.default)return C.createVNode("span",{class:Yr("text"),style:{fontSize:xn(t.textSize),color:(f=t.textColor)!=null?f:t.color}},[n.default()])};return()=>{const{type:f,vertical:g}=t;return C.createVNode("div",{class:Yr([f,{vertical:g}]),"aria-live":"polite","aria-busy":!0},[l(),u()])}}});const s1=jn(_w),[vw,Er]=On("button"),Cw=Zt({},t1,{tag:Nt("button"),text:String,icon:String,type:Nt("default"),size:Nt("normal"),color:String,block:Boolean,plain:Boolean,round:Boolean,square:Boolean,loading:Boolean,hairline:Boolean,disabled:Boolean,iconPrefix:String,nativeType:Nt("button"),loadingSize:Xt,loadingText:String,loadingType:String,iconPosition:Nt("left")});var bw=C.defineComponent({name:vw,props:Cw,emits:["click"],setup(t,{emit:n,slots:o}){const l=n1(),u=()=>o.loading?o.loading():C.createVNode(s1,{size:t.loadingSize,type:t.loadingType,class:Er("loading")},null),f=()=>{if(t.loading)return u();if(o.icon)return C.createVNode("div",{class:Er("icon")},[o.icon()]);if(t.icon)return C.createVNode(io,{name:t.icon,class:Er("icon"),classPrefix:t.iconPrefix},null)},g=()=>{let x;if(t.loading?x=t.loadingText:x=o.default?o.default():t.text,x)return C.createVNode("span",{class:Er("text")},[x])},m=()=>{const{color:x,plain:A}=t;if(x){const b={color:A?x:"white"};return A||(b.background=x),x.includes("gradient")?b.border=0:b.borderColor=x,b}},y=x=>{t.loading?ys(x):t.disabled||(n("click",x),l())};return()=>{const{tag:x,type:A,size:b,block:P,round:N,plain:R,square:D,loading:M,disabled:z,hairline:U,nativeType:k,iconPosition:K}=t,ve=[Er([A,b,{plain:R,block:P,round:N,square:D,loading:M,disabled:z,hairline:U}]),{[G3]:U}];return C.createVNode(x,{type:k,class:ve,style:m(),disabled:z,onClick:y},{default:()=>[C.createVNode("div",{class:Er("content")},[K==="left"&&f(),g(),K==="right"&&f()])]})}}});const Jo=jn(bw),[Ew,Aw]=On("action-bar-button"),Iw=Zt({},t1,{type:String,text:String,icon:String,color:String,loading:Boolean,disabled:Boolean});var Sw=C.defineComponent({name:Ew,props:Iw,setup(t,{slots:n}){const o=n1(),{parent:l,index:u}=C3(e1),f=C.computed(()=>{if(l){const m=l.children[u.value-1];return!(m&&"isButton"in m)}}),g=C.computed(()=>{if(l){const m=l.children[u.value+1];return!(m&&"isButton"in m)}});return vs({isButton:!0}),()=>{const{type:m,icon:y,text:x,color:A,loading:b,disabled:P}=t;return C.createVNode(Jo,{class:Aw([m,{last:g.value,first:f.value}]),size:"large",type:m,icon:y,color:A,loading:b,disabled:P,onClick:o},{default:()=>[n.default?n.default():x]})}}});const xl=jn(Sw),Cs={show:Boolean,zIndex:Xt,overlay:Tn,duration:Xt,teleport:[String,Object],lockScroll:Tn,lazyRender:Tn,beforeClose:Function,overlayProps:Object,overlayStyle:Object,overlayClass:ri,transitionAppear:Boolean,closeOnClickOverlay:Tn},Tw=Object.keys(Cs);function Ow(t,n){return t>n?"horizontal":n>t?"vertical":""}function Nw(){const t=C.ref(0),n=C.ref(0),o=C.ref(0),l=C.ref(0),u=C.ref(0),f=C.ref(0),g=C.ref(""),m=C.ref(!0),y=()=>g.value==="vertical",x=()=>g.value==="horizontal",A=()=>{o.value=0,l.value=0,u.value=0,f.value=0,g.value="",m.value=!0};return{move:(N=>{const R=N.touches[0];o.value=(R.clientX<0?0:R.clientX)-t.value,l.value=R.clientY-n.value,u.value=Math.abs(o.value),f.value=Math.abs(l.value);const D=10;(!g.value||u.value<D&&f.value<D)&&(g.value=Ow(u.value,f.value)),m.value&&(u.value>hl||f.value>hl)&&(m.value=!1)}),start:(N=>{A(),t.value=N.touches[0].clientX,n.value=N.touches[0].clientY}),reset:A,startX:t,startY:n,deltaX:o,deltaY:l,offsetX:u,offsetY:f,direction:g,isVertical:y,isHorizontal:x,isTap:m}}let Zr=0;const wl="van-overflow-hidden";function kw(t,n){const o=Nw(),l="01",u="10",f=A=>{o.move(A);const b=o.deltaY.value>0?u:l,P=N3(A.target,t.value),{scrollHeight:N,offsetHeight:R,scrollTop:D}=P;let M="11";D===0?M=R>=N?"00":"01":D+R>=N&&(M="10"),M!=="11"&&o.isVertical()&&!(parseInt(M,2)&parseInt(b,2))&&ys(A,!0)},g=()=>{document.addEventListener("touchstart",o.start),document.addEventListener("touchmove",f,{passive:!1}),Zr||document.body.classList.add(wl),Zr++},m=()=>{Zr&&(document.removeEventListener("touchstart",o.start),document.removeEventListener("touchmove",f),Zr--,Zr||document.body.classList.remove(wl))},y=()=>n()&&g(),x=()=>n()&&m();Gu(y),C.onDeactivated(x),C.onBeforeUnmount(x),C.watch(n,A=>{A?g():m()})}function a1(t){const n=C.ref(!1);return C.watch(t,o=>{o&&(n.value=o)},{immediate:!0}),o=>()=>n.value?o():null}const yl=()=>{var t;const{scopeId:n}=((t=C.getCurrentInstance())==null?void 0:t.vnode)||{};return n?{[n]:""}:null},[Rw,Dw]=On("overlay"),Mw={show:Boolean,zIndex:Xt,duration:Xt,className:ri,lockScroll:Tn,lazyRender:Tn,customStyle:Object,teleport:[String,Object]};var Pw=C.defineComponent({name:Rw,inheritAttrs:!1,props:Mw,setup(t,{attrs:n,slots:o}){const l=C.ref(),u=a1(()=>t.show||!t.lazyRender),f=m=>{t.lockScroll&&ys(m,!0)},g=u(()=>{var m;const y=Zt(P3(t.zIndex),t.customStyle);return rr(t.duration)&&(y.animationDuration=`${t.duration}s`),C.withDirectives(C.createVNode("div",C.mergeProps({ref:l,style:y,class:[Dw(),t.className]},n),[(m=o.default)==null?void 0:m.call(o)]),[[C.vShow,t.show]])});return Xu("touchmove",f,{target:l}),()=>{const m=C.createVNode(C.Transition,{name:"van-fade",appear:!0},{default:g});return t.teleport?C.createVNode(C.Teleport,{to:t.teleport},{default:()=>[m]}):m}}});const Bw=jn(Pw),Lw=Zt({},Cs,{round:Boolean,position:Nt("center"),closeIcon:Nt("cross"),closeable:Boolean,transition:String,iconPrefix:String,closeOnPopstate:Boolean,closeIconPosition:Nt("top-right"),destroyOnClose:Boolean,safeAreaInsetTop:Boolean,safeAreaInsetBottom:Boolean}),[Fw,_l]=On("popup");var $w=C.defineComponent({name:Fw,inheritAttrs:!1,props:Lw,emits:["open","close","opened","closed","keydown","update:show","clickOverlay","clickCloseIcon"],setup(t,{emit:n,attrs:o,slots:l}){let u,f;const g=C.ref(),m=C.ref(),y=a1(()=>t.show||!t.lazyRender),x=C.computed(()=>{const Q={zIndex:g.value};if(rr(t.duration)){const j=t.position==="center"?"animationDuration":"transitionDuration";Q[j]=`${t.duration}s`}return Q}),A=()=>{u||(u=!0,g.value=t.zIndex!==void 0?+t.zIndex:sw(),n("open"))},b=()=>{u&&Ku(t.beforeClose,{done(){u=!1,n("close"),n("update:show",!1)}})},P=Q=>{n("clickOverlay",Q),t.closeOnClickOverlay&&b()},N=()=>{if(t.overlay){const Q=Zt({show:t.show,class:t.overlayClass,zIndex:g.value,duration:t.duration,customStyle:t.overlayStyle,role:t.closeOnClickOverlay?"button":void 0,tabindex:t.closeOnClickOverlay?0:void 0},t.overlayProps);return C.createVNode(Bw,C.mergeProps(Q,yl(),{onClick:P}),{default:l["overlay-content"]})}},R=Q=>{n("clickCloseIcon",Q),b()},D=()=>{if(t.closeable)return C.createVNode(io,{role:"button",tabindex:0,name:t.closeIcon,class:[_l("close-icon",t.closeIconPosition),X3],classPrefix:t.iconPrefix,onClick:R},null)};let M;const z=()=>{M&&clearTimeout(M),M=setTimeout(()=>{n("opened")})},U=()=>n("closed"),k=Q=>n("keydown",Q),K=y(()=>{var Q;const{destroyOnClose:j,round:ie,position:Y,safeAreaInsetTop:Ie,safeAreaInsetBottom:Ce,show:he}=t;if(!(!he&&j))return C.withDirectives(C.createVNode("div",C.mergeProps({ref:m,style:x.value,role:"dialog",tabindex:0,class:[_l({round:ie,[Y]:Y}),{"van-safe-area-top":Ie,"van-safe-area-bottom":Ce}],onKeydown:k},o,yl()),[(Q=l.default)==null?void 0:Q.call(l),D()]),[[C.vShow,he]])}),ve=()=>{const{position:Q,transition:j,transitionAppear:ie}=t,Y=Q==="center"?"van-fade":`van-popup-slide-${Q}`;return C.createVNode(C.Transition,{name:j||Y,appear:ie,onAfterEnter:z,onAfterLeave:U},{default:K})};return C.watch(()=>t.show,Q=>{Q&&!u&&(A(),o.tabindex===0&&C.nextTick(()=>{var j;(j=m.value)==null||j.focus()})),!Q&&u&&(u=!1,n("close"))}),vs({popupRef:m}),kw(m,()=>t.show&&t.lockScroll),Xu("popstate",()=>{t.closeOnPopstate&&(b(),f=!1)}),C.onMounted(()=>{t.show&&A()}),C.onActivated(()=>{f&&(n("update:show",!0),f=!1)}),C.onDeactivated(()=>{t.show&&t.teleport&&(b(),f=!0)}),C.provide(Ju,()=>t.show),()=>t.teleport?C.createVNode(C.Teleport,{to:t.teleport},{default:()=>[N(),ve()]}):C.createVNode(C.Fragment,null,[N(),ve()])}});const l1=jn($w);let Vr=0;function Uw(t){t?(Vr||document.body.classList.add("van-toast--unclickable"),Vr++):Vr&&(Vr--,Vr||document.body.classList.remove("van-toast--unclickable"))}const[zw,Ar]=On("toast"),Zw=["show","overlay","teleport","transition","overlayClass","overlayStyle","closeOnClickOverlay","zIndex"],Vw={icon:String,show:Boolean,type:Nt("text"),overlay:Boolean,message:Xt,iconSize:Xt,duration:y3(2e3),position:Nt("middle"),teleport:[String,Object],wordBreak:String,className:ri,iconPrefix:String,transition:Nt("van-fade"),loadingType:String,forbidClick:Boolean,overlayClass:ri,overlayStyle:Object,closeOnClick:Boolean,closeOnClickOverlay:Boolean,zIndex:Xt};var jw=C.defineComponent({name:zw,props:Vw,emits:["update:show"],setup(t,{emit:n,slots:o}){let l,u=!1;const f=()=>{const b=t.show&&t.forbidClick;u!==b&&(u=b,Uw(u))},g=b=>n("update:show",b),m=()=>{t.closeOnClick&&g(!1)},y=()=>clearTimeout(l),x=()=>{const{icon:b,type:P,iconSize:N,iconPrefix:R,loadingType:D}=t;if(b||P==="success"||P==="fail")return C.createVNode(io,{name:b||P,size:N,class:Ar("icon"),classPrefix:R},null);if(P==="loading")return C.createVNode(s1,{class:Ar("loading"),size:N,type:D},null)},A=()=>{const{type:b,message:P}=t;if(o.message)return C.createVNode("div",{class:Ar("text")},[o.message()]);if(rr(P)&&P!=="")return b==="html"?C.createVNode("div",{key:0,class:Ar("text"),innerHTML:String(P)},null):C.createVNode("div",{class:Ar("text")},[P])};return C.watch(()=>[t.show,t.forbidClick],f),C.watch(()=>[t.show,t.type,t.message,t.duration],()=>{y(),t.show&&t.duration>0&&(l=setTimeout(()=>{g(!1)},t.duration))}),C.onMounted(f),C.onUnmounted(f),()=>C.createVNode(l1,C.mergeProps({class:[Ar([t.position,t.wordBreak==="normal"?"break-normal":t.wordBreak,{[t.type]:!t.icon}]),t.className],lockScroll:!1,onClick:m,onClosed:y,"onUpdate:show":g},Wu(t,Zw)),{default:()=>[x(),A()]})}});function c1(){const t=C.reactive({show:!1}),n=u=>{t.show=u},o=u=>{Zt(t,u,{transitionAppear:!0}),n(!0)},l=()=>n(!1);return vs({open:o,close:l,toggle:n}),{open:o,close:l,state:t,toggle:n}}function u1(t){const n=C.createApp(t),o=document.createElement("div");return document.body.appendChild(o),{instance:n.mount(o),unmount(){n.unmount(),document.body.removeChild(o)}}}const Hw={icon:"",type:"text",message:"",className:"",overlay:!1,onClose:void 0,onOpened:void 0,duration:2e3,teleport:"body",iconSize:void 0,iconPrefix:void 0,position:"middle",transition:"van-fade",forbidClick:!1,loadingType:void 0,overlayClass:"",overlayStyle:void 0,closeOnClick:!1,closeOnClickOverlay:!1};let ki=[],Ww=!1,vl=Zt({},Hw);const Gw=new Map;function d1(t){return ro(t)?t:{message:t}}function Xw(){const{instance:t}=u1({setup(){const n=C.ref(""),{open:o,state:l,close:u,toggle:f}=c1(),g=()=>{},m=()=>{const y={onClosed:g,"onUpdate:show":f};return C.createVNode(jw,C.mergeProps(l,y),null)};return C.watch(n,y=>{l.message=y}),C.getCurrentInstance().render=m,{open:o,close:u,message:n}}});return t}function Yw(){if(!ki.length||Ww){const t=Xw();ki.push(t)}return ki[ki.length-1]}function ht(t={}){if(!no)return{};const n=Yw(),o=d1(t);return n.open(Zt({},vl,Gw.get(o.type||vl.type),o)),n}const qw=t=>n=>ht(Zt({type:t},d1(n))),f1=qw("loading"),[Kw,In,Ri]=On("dialog"),Jw=Zt({},Cs,{title:String,theme:String,width:Xt,message:[String,Function],callback:Function,allowHtml:Boolean,className:ri,transition:Nt("van-dialog-bounce"),messageAlign:String,closeOnPopstate:Tn,showCancelButton:Boolean,cancelButtonText:String,cancelButtonColor:String,cancelButtonDisabled:Boolean,confirmButtonText:String,confirmButtonColor:String,confirmButtonDisabled:Boolean,showConfirmButton:Tn,closeOnClickOverlay:Boolean,keyboardEnabled:Tn,destroyOnClose:Boolean}),Qw=[...Tw,"transition","closeOnPopstate","destroyOnClose"];var h1=C.defineComponent({name:Kw,props:Jw,emits:["confirm","cancel","keydown","update:show"],setup(t,{emit:n,slots:o}){const l=C.ref(),u=C.reactive({confirm:!1,cancel:!1}),f=z=>n("update:show",z),g=z=>{var U;f(!1),(U=t.callback)==null||U.call(t,z)},m=z=>()=>{t.show&&(n(z),t.beforeClose?(u[z]=!0,Ku(t.beforeClose,{args:[z],done(){g(z),u[z]=!1},canceled(){u[z]=!1}})):g(z))},y=m("cancel"),x=m("confirm"),A=C.withKeys(z=>{var U,k;if(!t.keyboardEnabled||z.target!==((k=(U=l.value)==null?void 0:U.popupRef)==null?void 0:k.value))return;({Enter:t.showConfirmButton?x:qo,Escape:t.showCancelButton?y:qo})[z.key](),n("keydown",z)},["enter","esc"]),b=()=>{const z=o.title?o.title():t.title;if(z)return C.createVNode("div",{class:In("header",{isolated:!t.message&&!o.default})},[z])},P=z=>{const{message:U,allowHtml:k,messageAlign:K}=t,ve=In("message",{"has-title":z,[K]:K}),Q=Xi(U)?U():U;return k&&typeof Q=="string"?C.createVNode("div",{class:ve,innerHTML:Q},null):C.createVNode("div",{class:ve},[Q])},N=()=>{if(o.default)return C.createVNode("div",{class:In("content")},[o.default()]);const{title:z,message:U,allowHtml:k}=t;if(U){const K=!!(z||o.title);return C.createVNode("div",{key:k?1:0,class:In("content",{isolated:!K})},[P(K)])}},R=()=>C.createVNode("div",{class:[H3,In("footer")]},[t.showCancelButton&&C.createVNode(Jo,{size:"large",text:t.cancelButtonText||Ri("cancel"),class:In("cancel"),style:{color:t.cancelButtonColor},loading:u.cancel,disabled:t.cancelButtonDisabled,onClick:y},null),t.showConfirmButton&&C.createVNode(Jo,{size:"large",text:t.confirmButtonText||Ri("confirm"),class:[In("confirm"),{[W3]:t.showCancelButton}],style:{color:t.confirmButtonColor},loading:u.confirm,disabled:t.confirmButtonDisabled,onClick:x},null)]),D=()=>C.createVNode(ew,{class:In("footer")},{default:()=>[t.showCancelButton&&C.createVNode(xl,{type:"warning",text:t.cancelButtonText||Ri("cancel"),class:In("cancel"),color:t.cancelButtonColor,loading:u.cancel,disabled:t.cancelButtonDisabled,onClick:y},null),t.showConfirmButton&&C.createVNode(xl,{type:"danger",text:t.confirmButtonText||Ri("confirm"),class:In("confirm"),color:t.confirmButtonColor,loading:u.confirm,disabled:t.confirmButtonDisabled,onClick:x},null)]}),M=()=>o.footer?o.footer():t.theme==="round-button"?D():R();return()=>{const{width:z,title:U,theme:k,message:K,className:ve}=t;return C.createVNode(l1,C.mergeProps({ref:l,role:"dialog",class:[In([k]),ve],style:{width:xn(z)},tabindex:0,"aria-labelledby":U||K,onKeydown:A,"onUpdate:show":f},Wu(t,Qw)),{default:()=>[b(),N(),M()]})}}});let Qo;const ey={title:"",width:"",theme:null,message:"",overlay:!0,callback:null,teleport:"body",className:"",allowHtml:!1,lockScroll:!0,transition:void 0,beforeClose:null,overlayClass:"",overlayStyle:void 0,messageAlign:"",cancelButtonText:"",cancelButtonColor:null,cancelButtonDisabled:!1,confirmButtonText:"",confirmButtonColor:null,confirmButtonDisabled:!1,showConfirmButton:!0,showCancelButton:!1,closeOnPopstate:!0,closeOnClickOverlay:!1,destroyOnClose:!1};let ty=Zt({},ey);function ny(){({instance:Qo}=u1({setup(){const{state:n,toggle:o}=c1();return()=>C.createVNode(h1,C.mergeProps(n,{"onUpdate:show":o}),null)}}))}function ry(t){return no?new Promise((n,o)=>{Qo||ny(),Qo.open(Zt({},ty,t,{callback:l=>{(l==="confirm"?n:o)(l)}}))}):Promise.resolve(void 0)}const iy=t=>ry(Zt({showCancelButton:!0},t));jn(h1);let Di="",Mi=0;const oy=({sessionId:t,agentRoot:n,systemPrompt:o,llmConfig:l,skills:u=[],isGenuiEnabled:f=C.ref(!1),inBrowserExt:g=C.ref(!1)})=>{const m=new i3({provider:"custom"},t,n,o,l);m.isGenuiEnabled=f;const y=new dr.AIClient({providerImplementation:m,provider:"custom"}),x=C.ref(!1),A=C.h(sl,{style:{fontSize:"32px"}}),b=C.h($i.IconUser,{style:{fontSize:"32px"}}),P=C.h(sl,{style:{width:"48px",height:"48px"}}),{messageManager:N,createConversation:R,getCurrentConversation:D,switchConversation:M,deleteConversation:z,updateTitle:U,state:k}=dr.useConversation({client:y,events:{onLoaded(){pe()},onReceiveData(ne,S,fe){fe();let se=S.value[S.value.length-1];if(ne.type==="start"&&(Di="",Mi=0),["text-start","tool"].includes(ne.type)&&(Di="",Mi=0),ne.type,se.role!=="assistant"){const Le={role:"assistant",content:"",uiContent:[]};S.value.push(Le),se=Le}if(ne.type==="tool"){const Le=se.uiContent.find($e=>$e.id===ne.id);Le?(Le.content+=ne.delta,Le.status=ne.status):se.uiContent.push(ne)}else if(ne.type==="markdown"){Di+=ne.delta;const Le=a3(Di),$e=Le.length;if($e===0)return;$e>Mi?se.uiContent.push(Le[$e-1]):se.uiContent[se.uiContent.length-1]=Le[$e-1],Mi=$e}else if(ne.type==="collapsible-text"){const Le=se.uiContent.find($e=>$e.type===ne.type&&$e.thinkId===ne.thinkId);Le?(Le.content+=ne.delta,se.content+=ne.delta):se.uiContent.push(ne)}}}}),{messageState:K,inputMessage:ve,sendMessage:Q,abortRequest:j,messages:ie,addMessage:Y,send:Ie}=N,Ce={assistant:{type:"markdown",placement:"start",avatar:A,maxWidth:"80%",customContentField:"uiContent"},user:{placement:"end",avatar:b,maxWidth:"80%"}},he=C.ref(),xe=ne=>{for(const S in m.agent.mcpTools){const fe=m.agent.mcpTools[S];if(fe&&fe[ne])return!m.agent.ignoreToolnames.includes(ne)}return!1},le=async ne=>{if(ne.length===0)return!1;const S=[];for(const fe of ne){const se=u.find(Le=>Le.label===fe.content);if(se?.tools&&se.tools.length>0){const Le=[];for(const $e of se.tools)xe($e)||Le.push($e);Le.length>0&&S.push({skillLabel:fe.content||se.label,toolNames:Le})}}if(S.length>0){const fe=S.map(se=>`${se.skillLabel} 需要以下工具:${se.toolNames.join("、")}`).join(`
61
- `);try{return await iy({title:"工具未准备好",message:`无法发送消息:
62
- ${fe}
60
+ `,textId:l}),o.onData({type:"text-end"})),l}handleToolStream(r,o){const u={"tool-input-start":()=>o.onData({type:"tool",id:r.id,name:r.toolName,status:"running",content:""}),"tool-input-delta":()=>o.onData({type:"tool",id:r.id,status:"running",delta:r.delta}),"tool-result":()=>o.onData({type:"tool",id:r.toolCallId,status:"success",delta:""}),"tool-error":()=>o.onData({type:"tool",id:r.toolCallId,status:"error",delta:r?.error?.message||"工具执行失败"})}[r.type];u&&u()}handleReasonStream(r,o,l){return r.type==="reasoning-start"?(l++,o.onData({type:"collapsible-text",title:"思考过程",content:"",delta:"",thinkId:l})):r.type==="reasoning-delta"?o.onData({type:"collapsible-text",delta:r.text,thinkId:l}):r.type==="reasoning-end"&&o.onData({type:"collapsible-text",delta:" ",thinkId:l}),l}cleanupOldSnapshotsInMessages(r){if(!r||r.length===0)return r;const l=this.agent.useReActMode===!0?"user":"tool",u=r[r.length-1];if(!u||u.role!==l||!this.isSnapshotContent(u.content))return r;const f=[...r];for(let g=f.length-2;g>=0;g--){const x=f[g];x.role===l&&this.isSnapshotContent(x.content)&&this.replaceSnapshotWithPlaceholder(x)}return f}removeSnapshotData(r){if(!r)return r;const o=["无障碍树快照:","无障碍树快照:","快照内容:","快照内容:","页面无障碍树快照:","页面无障碍树快照:","操作后的页面快照:","操作后的页面快照:"];let l=-1;for(const f of o){const g=r.indexOf(f);if(g!==-1){l=g;break}}if(l!==-1){const f=r.substring(0,l).trim();return f?`${f} 📸 [历史快照已清理]`:"📸 历史快照已清理"}const u=["已成功获取页面无障碍树快照","takeSnapshot","snapshotId_counter"];for(const f of u)if(r.startsWith(f))return"📸 历史快照已清理";return r}replaceSnapshotWithPlaceholder(r){if(Array.isArray(r.content)){const o=r.content[0];if(o?.output?.value?.content){const l=o.output.value.content;Array.isArray(l)&&(o.output.value.content=l.map(u=>u.type==="image"||u.type==="image_url"?null:u.type==="text"&&u.text&&this.isSnapshotContent(u.text)?{type:"text",text:this.removeSnapshotData(u.text)}:u).filter(u=>u!==null)),o.output.value.screenshot&&delete o.output.value.screenshot}else r.content=r.content.filter(l=>l.type!=="image"&&l.type!=="image_url")}else typeof r.content=="string"&&this.isSnapshotContent(r.content)&&(r.content=this.removeSnapshotData(r.content))}isSnapshotContent(r){if(!r)return!1;const o=["无障碍树快照","takeSnapshot","snapshotId_counter","UID 格式","快照 ID","操作后的页面快照","已成功获取页面无障碍树快照","快照内容:"];if(typeof r=="string")return o.some(l=>r.includes(l));if(Array.isArray(r))for(const l of r){const u=l?.output?.value?.content?.[0]?.text;if(u&&o.some(f=>u.includes(f))||l.type==="text"&&l.text&&o.some(f=>l.text.includes(f))||l.type==="image"||l.type==="image_url")return!0}return!1}async chatStream(r,o){let l=r.messages[r.messages.length-1];if(!l)return;if(this.llmConfig.beforeChatStream)try{const E=await this.llmConfig.beforeChatStream(l,this.systemPrompt);E&&(l=E)}catch(E){console.error("[beforeChatStream] 钩子执行失败:",E)}const u={model:this.llmConfig.model,system:this.systemPrompt,abortSignal:r.options?.signal,toolChoice:"auto",tools:{"get-today":Xg,...this.llmConfig.extraTools||{}},maxSteps:this.llmConfig.maxSteps,providerOptions:this.llmConfig.providerOptions||Xx,prepareStep:({messages:E})=>({messages:this.cleanupOldSnapshotsInMessages(E)}),onFinish:async()=>{await this.agent.closeAll()}},f={role:"user",content:l.content},g=[...this.agent.messages,f];u.messages=g;const x=await this.agent.chatStream(u);let y=1,m=1;try{for await(const E of x.fullStream){if(E.type==="error"){const C=E.error?.data?.error?.message||E.error?.message||E.error||"访问大模型出错";o.onData({type:"markdown",content:"",delta:"",textId:y}),o.onData({type:"markdown",delta:C,textId:y}),o.onError(C)}(E.type.includes("start-")||E.type.includes("-start"))&&o.onData({type:"start"}),E.type.startsWith("text-")?y=this.handleTextStream(E,o,y):E.type.startsWith("tool-")?this.handleToolStream(E,o):E.type.startsWith("reasoning-")&&(m=this.handleReasonStream(E,o,m))}}finally{o.onDone()}}chat(r){throw new Error("Method not implemented.")}}const Yx={width:"100.000000",height:"100.000000",viewBox:"0 0 100 100",fill:"none",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"};function Kx(t,r){return _.openBlock(),_.createElementBlock("svg",Yx,[...r[0]||(r[0]=[_.createStaticVNode('<desc> Created with Pixso. </desc><defs><radialGradient gradientTransform="translate(32.4474 65.1156) rotate(128.932) scale(22.991 20.6919)" cx="0.000000" cy="0.000000" r="1.000000" id="paint_radial_9_3090_0" gradientUnits="userSpaceOnUse"><stop stop-color="#5ADDF8"></stop><stop stop-color="#AEBFFF"></stop><stop offset="0.329153" stop-color="#1476FF"></stop><stop offset="0.667785" stop-color="#655AF8"></stop><stop offset="0.868255" stop-color="#948CFF"></stop><stop offset="1.000000" stop-color="#D25AF8"></stop><stop offset="1.000000" stop-color="#5A8BF8"></stop></radialGradient><linearGradient x1="30.999874" y1="85.000229" x2="30.499891" y2="70.500214" id="paint_linear_9_3092_0" gradientUnits="userSpaceOnUse"><stop stop-color="#000000" stop-opacity="0.000000"></stop><stop offset="1.000000" stop-color="#000000"></stop></linearGradient><radialGradient gradientTransform="translate(26.9999 24.7118) rotate(38.3655) scale(77.7996 109.496)" cx="0.000000" cy="0.000000" r="1.000000" id="paint_radial_9_3094_0" gradientUnits="userSpaceOnUse"><stop stop-color="#5ADDF8"></stop><stop stop-color="#AEBFFF"></stop><stop offset="0.329153" stop-color="#1476FF"></stop><stop offset="0.667785" stop-color="#655AF8"></stop><stop offset="0.868255" stop-color="#948CFF"></stop><stop offset="1.000000" stop-color="#D25AF8"></stop><stop offset="1.000000" stop-color="#5A8BF8"></stop></radialGradient></defs><rect id="NEXT-LOGO-无背景渐变-右" width="100.000000" height="99.999939" transform="matrix(-1 0 0 1 100 0)" fill="#FFFFFF" fill-opacity="0"></rect>',3),_.createElementVNode("mask",{id:"mask9_3088","mask-type":"alpha",maskUnits:"userSpaceOnUse",x:"0.000061",y:"0.000061",width:"99.999939",height:"99.999939"},[_.createElementVNode("rect",{id:"画板 1773",width:"99.999962",height:"99.999947",transform:"matrix(-1 0 0 1 100 6.10352e-05)",fill:"#000000","fill-opacity":"1.000000"})],-1),_.createStaticVNode('<g mask="url(#mask9_3088)"><path id="矢量 1" d="M35.93 81.01L36 63L18 63.07L32.48 82.23C33.61 83.71 35.93 82.9 35.93 81.01Z" fill="url(#paint_radial_9_3090_0)" fill-opacity="1.000000" fill-rule="evenodd"></path><g opacity="0.100000" style="mix-blend-mode:normal;"><path id="矢量 1" d="M35.93 81.01L36 63L18 63.07L32.48 82.23C33.61 83.71 35.93 82.9 35.93 81.01Z" fill="url(#paint_linear_9_3092_0)" fill-opacity="1.000000" fill-rule="evenodd"></path></g><rect id="矩形 5" x="12.000000" y="19.000183" rx="26.999992" width="75.999977" height="53.999985" fill="url(#paint_radial_9_3094_0)" fill-opacity="1.000000"></rect><rect id="矩形 5" rx="26.499992" width="74.999977" height="52.999985" transform="matrix(-1 0 0 1 87.5 19.5002)" fill="#000000" fill-opacity="0"></rect><rect id="矩形 5" rx="26.499992" width="74.999977" height="52.999985" transform="matrix(-1 0 0 1 87.5 19.5002)" stroke="#000000" stroke-opacity="0" stroke-width="1.000000"></rect><path id="path" d="M45.39 59.06C44.22 60.05 42.9 60.66 41.43 60.89C39.95 61.12 38.57 61.04 37.28 60.65C36 60.26 34.04 58.58 34.04 58.58C34.04 58.58 29.02 54.73 29.02 45.61C29.02 36.5 33.5 32.5 33.5 32.5C33.5 32.5 34.72 31.31 36.5 31C38.29 30.68 39.43 30.98 40.66 31.33C50.89 34.23 62.38 34.33 72.58 31.33C73.81 30.98 74.91 30.93 75.89 31.17C76.87 31.42 77.71 31.89 78.42 32.59C81.65 35.81 82.87 41.06 83 45.61C83.12 50.09 81.97 55.24 78.94 58.54C78.04 59.52 76.98 60.22 75.78 60.63C74.58 61.04 73.32 61.12 71.99 60.89C70.66 60.66 69.48 60.05 68.46 59.06C68.01 58.62 67.39 58.07 66.57 57.4C65.76 56.73 64.83 56.08 63.79 55.44C62.75 54.8 61.62 54.25 60.39 53.8C59.16 53.35 57.91 53.13 56.62 53.13C55.36 53.13 54.16 53.36 53 53.83C51.85 54.29 50.79 54.84 49.82 55.48C48.86 56.12 48 56.78 47.26 57.45C46.51 58.11 45.89 58.65 45.39 59.06Z" fill="#FFFFFF" fill-opacity="1.000000" fill-rule="nonzero"></path><rect id="矩形 841" rx="2.000000" width="3.999999" height="11.999996" transform="matrix(-0.999983 0.00577157 0.00577157 0.999983 76.1109 38.0356)" fill="#1476FF" fill-opacity="1.000000"></rect><path id="合并" d="M42.96 38C43.77 37.97 44.55 38.42 44.92 39.19L48.73 47.11C49.22 48.13 48.79 49.34 47.75 49.81C46.72 50.28 45.48 49.83 44.99 48.8L42.96 44.59L40.94 48.81C40.45 49.83 39.21 50.28 38.18 49.81C37.14 49.34 36.7 48.13 37.2 47.11L41 39.19C41.37 38.42 42.16 37.98 42.96 38Z" fill="#1476FF" fill-opacity="1.000000" fill-rule="evenodd"></path></g>',1)])])}const Qa={render:Kx};function Jx(t){const r=[];let o=0;for(;o<t.length;){const l="```schemaJson",u=t.indexOf(l,o),f=l.length;if(u===-1){const m=t.slice(o).trim();m&&r.push({type:"markdown",content:m});break}const g=t.slice(o,u).trim();g&&r.push({type:"markdown",content:g});const x=t.indexOf("```",u+f);let y;x===-1?(y=t.slice(u+f).trim(),o=t.length):(y=t.slice(u+f,x).trim(),o=x+3),r.push({type:"schema-card",content:y})}return r}function Zo(){}const Zt=Object.assign,qi=typeof window<"u",Yi=t=>t!==null&&typeof t=="object",Jn=t=>t!=null,Vi=t=>typeof t=="function",Qx=t=>Yi(t)&&Vi(t.then)&&Vi(t.catch),Bu=t=>typeof t=="number"||/^\d+(\.\d+)?$/.test(t),ew=()=>qi?/ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()):!1;function el(t,r){const o=r.split(".");let l=t;return o.forEach(u=>{var f;l=Yi(l)&&(f=l[u])!=null?f:""}),l}function Lu(t,r,o){return r.reduce((l,u)=>(l[u]=t[u],l),{})}const Qr=null,Xt=[Number,String],En={type:Boolean,default:!0},tw=t=>({type:Number,default:t}),Ot=t=>({type:String,default:t});var us=typeof window<"u",nw=t=>t===window,tl=(t,r)=>({top:0,left:0,right:t,bottom:r,width:t,height:r}),rw=t=>{const r=_.unref(t);if(nw(r)){const o=r.innerWidth,l=r.innerHeight;return tl(o,l)}return r?.getBoundingClientRect?r.getBoundingClientRect():tl(0,0)};function iw(t){const r=_.inject(t,null);if(r){const o=_.getCurrentInstance(),{link:l,unlink:u,internalChildren:f}=r;l(o),_.onUnmounted(()=>u(o));const g=_.computed(()=>f.indexOf(o));return{parent:r,index:g}}return{parent:null,index:_.ref(-1)}}function ow(t){const r=[],o=l=>{Array.isArray(l)&&l.forEach(u=>{var f;_.isVNode(u)&&(r.push(u),(f=u.component)!=null&&f.subTree&&(r.push(u.component.subTree),o(u.component.subTree.children)),u.children&&o(u.children))})};return o(t),r}var nl=(t,r)=>{const o=t.indexOf(r);return o===-1?t.findIndex(l=>r.key!==void 0&&r.key!==null&&l.type===r.type&&l.key===r.key):o};function sw(t,r,o){const l=ow(t.subTree.children);o.sort((f,g)=>nl(l,f.vnode)-nl(l,g.vnode));const u=o.map(f=>f.proxy);r.sort((f,g)=>{const x=u.indexOf(f),y=u.indexOf(g);return x-y})}function aw(t){const r=_.reactive([]),o=_.reactive([]),l=_.getCurrentInstance();return{children:r,linkChildren:f=>{const g=y=>{y.proxy&&(o.push(y),r.push(y.proxy),sw(l,r,o))},x=y=>{const m=o.indexOf(y);r.splice(m,1),o.splice(m,1)};_.provide(t,Object.assign({link:g,unlink:x,children:r,internalChildren:o},f))}}}function Fu(t){let r;_.onMounted(()=>{t(),_.nextTick(()=>{r=!0})}),_.onActivated(()=>{r&&t()})}function $u(t,r,o={}){if(!us)return;const{target:l=window,passive:u=!1,capture:f=!1}=o;let g=!1,x;const y=C=>{if(g)return;const P=_.unref(C);P&&!x&&(P.addEventListener(t,r,{capture:f,passive:u}),x=!0)},m=C=>{if(g)return;const P=_.unref(C);P&&x&&(P.removeEventListener(t,r,f),x=!1)};_.onUnmounted(()=>m(l)),_.onDeactivated(()=>m(l)),Fu(()=>y(l));let E;return _.isRef(l)&&(E=_.watch(l,(C,P)=>{m(P),y(C)})),()=>{E?.(),m(l),g=!0}}var Ei,Oo;function lw(){if(!Ei&&(Ei=_.ref(0),Oo=_.ref(0),us)){const t=()=>{Ei.value=window.innerWidth,Oo.value=window.innerHeight};t(),window.addEventListener("resize",t,{passive:!0}),window.addEventListener("orientationchange",t,{passive:!0})}return{width:Ei,height:Oo}}var cw=/scroll|auto|overlay/i,uw=us?window:void 0;function dw(t){return t.tagName!=="HTML"&&t.tagName!=="BODY"&&t.nodeType===1}function fw(t,r=uw){let o=t;for(;o&&o!==r&&dw(o);){const{overflowY:l}=window.getComputedStyle(o);if(cw.test(l))return o;o=o.parentNode}return r}ew();const hw=t=>t.stopPropagation();function ds(t,r){(typeof t.cancelable!="boolean"||t.cancelable)&&t.preventDefault(),r&&hw(t)}const{width:pw,height:gw}=lw();function hn(t){if(Jn(t))return Bu(t)?`${t}px`:String(t)}function mw(t){if(Jn(t)){if(Array.isArray(t))return{width:hn(t[0]),height:hn(t[1])};const r=hn(t);return{width:r,height:r}}}function xw(t){const r={};return t!==void 0&&(r.zIndex=+t),r}const ww=/-(\w)/g,Uu=t=>t.replace(ww,(r,o)=>o.toUpperCase()),yw=t=>t.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""),{hasOwnProperty:_w}=Object.prototype;function vw(t,r,o){const l=r[o];Jn(l)&&(!_w.call(t,o)||!Yi(l)?t[o]=l:t[o]=zu(Object(t[o]),l))}function zu(t,r){return Object.keys(r).forEach(o=>{vw(t,r,o)}),t}var bw={name:"姓名",tel:"电话",save:"保存",clear:"清空",cancel:"取消",confirm:"确认",delete:"删除",loading:"加载中...",noCoupon:"暂无优惠券",nameEmpty:"请填写姓名",addContact:"添加联系人",telInvalid:"请填写正确的电话",vanCalendar:{end:"结束",start:"开始",title:"日期选择",weekdays:["日","一","二","三","四","五","六"],monthTitle:(t,r)=>`${t}年${r}月`,rangePrompt:t=>`最多选择 ${t} 天`},vanCascader:{select:"请选择"},vanPagination:{prev:"上一页",next:"下一页"},vanPullRefresh:{pulling:"下拉即可刷新...",loosing:"释放即可刷新..."},vanSubmitBar:{label:"合计:"},vanCoupon:{unlimited:"无门槛",discount:t=>`${t}折`,condition:t=>`满${t}元可用`},vanCouponCell:{title:"优惠券",count:t=>`${t}张可用`},vanCouponList:{exchange:"兑换",close:"不使用",enable:"可用",disabled:"不可用",placeholder:"输入优惠码"},vanAddressEdit:{area:"地区",areaEmpty:"请选择地区",addressEmpty:"请填写详细地址",addressDetail:"详细地址",defaultAddress:"设为默认收货地址"},vanAddressList:{add:"新增地址"}};const rl=_.ref("zh-CN"),il=_.reactive({"zh-CN":bw}),Cw={messages(){return il[rl.value]},use(t,r){rl.value=t,this.add({[t]:r})},add(t={}){zu(il,t)}};var Ew=Cw;function Aw(t){const r=Uu(t)+".";return(o,...l)=>{const u=Ew.messages(),f=el(u,r+o)||el(u,o);return Vi(f)?f(...l):f}}function jo(t,r){return r?typeof r=="string"?` ${t}--${r}`:Array.isArray(r)?r.reduce((o,l)=>o+jo(t,l),""):Object.keys(r).reduce((o,l)=>o+(r[l]?jo(t,l):""),""):""}function Iw(t){return(r,o)=>(r&&typeof r!="string"&&(o=r,r=""),r=r?`${t}__${r}`:t,`${r}${jo(r,o)}`)}function An(t){const r=`van-${t}`;return[r,Iw(r),Aw(r)]}const fs="van-hairline",Sw=`${fs}--top`,Tw=`${fs}--left`,Nw=`${fs}--surround`,Ow="van-haptics-feedback",ol=5;function Vu(t,{args:r=[],done:o,canceled:l,error:u}){if(t){const f=t.apply(null,r);Qx(f)?f.then(g=>{g?o():l&&l()}).catch(u||Zo):f?o():l&&l()}else o()}function $n(t){return t.install=r=>{const{name:o}=t;o&&(r.component(o,t),r.component(Uu(`-${o}`),t))},t}const Zu=Symbol();function kw(t){const r=_.inject(Zu,null);r&&_.watch(r,o=>{o&&t()})}const Rw=(t,r)=>{const o=_.ref(),l=()=>{o.value=rw(t).height};return _.onMounted(()=>{_.nextTick(l);for(let u=1;u<=3;u++)setTimeout(l,100*u)}),kw(()=>_.nextTick(l)),_.watch([pw,gw],l),o};function Dw(t,r){const o=Rw(t);return l=>_.createVNode("div",{class:r("placeholder"),style:{height:o.value?`${o.value}px`:void 0}},[l()])}const[ju,sl]=An("action-bar"),Hu=Symbol(ju),Mw={placeholder:Boolean,safeAreaInsetBottom:En};var Pw=_.defineComponent({name:ju,props:Mw,setup(t,{slots:r}){const o=_.ref(),l=Dw(o,sl),{linkChildren:u}=aw(Hu);u();const f=()=>{var g;return _.createVNode("div",{ref:o,class:[sl(),{"van-safe-area-bottom":t.safeAreaInsetBottom}]},[(g=r.default)==null?void 0:g.call(r)])};return()=>t.placeholder?l(f):f()}});const Bw=$n(Pw);function hs(t){const r=_.getCurrentInstance();r&&Zt(r.proxy,t)}const Wu={to:[String,Object],url:String,replace:Boolean};function Lw({to:t,url:r,replace:o,$router:l}){t&&l?l[o?"replace":"push"](t):r&&(o?location.replace(r):location.href=r)}function Gu(){const t=_.getCurrentInstance().proxy;return()=>Lw(t)}const[Fw,al]=An("badge"),$w={dot:Boolean,max:Xt,tag:Ot("div"),color:String,offset:Array,content:Xt,showZero:En,position:Ot("top-right")};var Uw=_.defineComponent({name:Fw,props:$w,setup(t,{slots:r}){const o=()=>{if(r.content)return!0;const{content:x,showZero:y}=t;return Jn(x)&&x!==""&&(y||x!==0&&x!=="0")},l=()=>{const{dot:x,max:y,content:m}=t;if(!x&&o())return r.content?r.content():Jn(y)&&Bu(m)&&+m>+y?`${y}+`:m},u=x=>x.startsWith("-")?x.replace("-",""):`-${x}`,f=_.computed(()=>{const x={background:t.color};if(t.offset){const[y,m]=t.offset,{position:E}=t,[C,P]=E.split("-");r.default?(typeof m=="number"?x[C]=hn(C==="top"?m:-m):x[C]=C==="top"?hn(m):u(m),typeof y=="number"?x[P]=hn(P==="left"?y:-y):x[P]=P==="left"?hn(y):u(y)):(x.marginTop=hn(m),x.marginLeft=hn(y))}return x}),g=()=>{if(o()||t.dot)return _.createVNode("div",{class:al([t.position,{dot:t.dot,fixed:!!r.default}]),style:f.value},[l()])};return()=>{if(r.default){const{tag:x}=t;return _.createVNode(x,{class:al("wrapper")},{default:()=>[r.default(),g()]})}return g()}}});const zw=$n(Uw);let Xu=2e3;const Vw=()=>++Xu,Zw=t=>{Xu=t},[qu,jw]=An("config-provider"),Yu=Symbol(qu),Hw={tag:Ot("div"),theme:Ot("light"),zIndex:Number,themeVars:Object,themeVarsDark:Object,themeVarsLight:Object,themeVarsScope:Ot("local"),iconPrefix:String};function Ww(t){return t.replace(/([a-zA-Z])(\d)/g,"$1-$2")}function Gw(t){const r={};return Object.keys(t).forEach(o=>{const l=Ww(yw(o));r[`--van-${l}`]=t[o]}),r}function Ai(t={},r={}){Object.keys(t).forEach(o=>{t[o]!==r[o]&&document.documentElement.style.setProperty(o,t[o])}),Object.keys(r).forEach(o=>{t[o]||document.documentElement.style.removeProperty(o)})}_.defineComponent({name:qu,props:Hw,setup(t,{slots:r}){const o=_.computed(()=>Gw(Zt({},t.themeVars,t.theme==="dark"?t.themeVarsDark:t.themeVarsLight)));if(qi){const l=()=>{document.documentElement.classList.add(`van-theme-${t.theme}`)},u=(f=t.theme)=>{document.documentElement.classList.remove(`van-theme-${f}`)};_.watch(()=>t.theme,(f,g)=>{g&&u(g),l()},{immediate:!0}),_.onActivated(l),_.onDeactivated(u),_.onBeforeUnmount(u),_.watch(o,(f,g)=>{t.themeVarsScope==="global"&&Ai(f,g)}),_.watch(()=>t.themeVarsScope,(f,g)=>{g==="global"&&Ai({},o.value),f==="global"&&Ai(o.value,{})}),t.themeVarsScope==="global"&&Ai(o.value,{})}return _.provide(Yu,t),_.watchEffect(()=>{t.zIndex!==void 0&&Zw(t.zIndex)}),()=>_.createVNode(t.tag,{class:jw(),style:t.themeVarsScope==="local"?o.value:void 0},{default:()=>{var l;return[(l=r.default)==null?void 0:l.call(r)]}})}});const[Xw,ll]=An("icon"),qw=t=>t?.includes("/"),Yw={dot:Boolean,tag:Ot("i"),name:String,size:Xt,badge:Xt,color:String,badgeProps:Object,classPrefix:String};var Kw=_.defineComponent({name:Xw,props:Yw,setup(t,{slots:r}){const o=_.inject(Yu,null),l=_.computed(()=>t.classPrefix||o?.iconPrefix||ll());return()=>{const{tag:u,dot:f,name:g,size:x,badge:y,color:m}=t,E=qw(g);return _.createVNode(zw,_.mergeProps({dot:f,tag:u,class:[l.value,E?"":`${l.value}-${g}`],style:{color:m,fontSize:hn(x)},content:y},t.badgeProps),{default:()=>{var C;return[(C=r.default)==null?void 0:C.call(r),E&&_.createVNode("img",{class:ll("image"),src:g},null)]}})}}});const Ki=$n(Kw),[Jw,Hr]=An("loading"),Qw=Array(12).fill(null).map((t,r)=>_.createVNode("i",{class:Hr("line",String(r+1))},null)),e3=_.createVNode("svg",{class:Hr("circular"),viewBox:"25 25 50 50"},[_.createVNode("circle",{cx:"50",cy:"50",r:"20",fill:"none"},null)]),t3={size:Xt,type:Ot("circular"),color:String,vertical:Boolean,textSize:Xt,textColor:String};var n3=_.defineComponent({name:Jw,props:t3,setup(t,{slots:r}){const o=_.computed(()=>Zt({color:t.color},mw(t.size))),l=()=>{const f=t.type==="spinner"?Qw:e3;return _.createVNode("span",{class:Hr("spinner",t.type),style:o.value},[r.icon?r.icon():f])},u=()=>{var f;if(r.default)return _.createVNode("span",{class:Hr("text"),style:{fontSize:hn(t.textSize),color:(f=t.textColor)!=null?f:t.color}},[r.default()])};return()=>{const{type:f,vertical:g}=t;return _.createVNode("div",{class:Hr([f,{vertical:g}]),"aria-live":"polite","aria-busy":!0},[l(),u()])}}});const Ku=$n(n3),[r3,yr]=An("button"),i3=Zt({},Wu,{tag:Ot("button"),text:String,icon:String,type:Ot("default"),size:Ot("normal"),color:String,block:Boolean,plain:Boolean,round:Boolean,square:Boolean,loading:Boolean,hairline:Boolean,disabled:Boolean,iconPrefix:String,nativeType:Ot("button"),loadingSize:Xt,loadingText:String,loadingType:String,iconPosition:Ot("left")});var o3=_.defineComponent({name:r3,props:i3,emits:["click"],setup(t,{emit:r,slots:o}){const l=Gu(),u=()=>o.loading?o.loading():_.createVNode(Ku,{size:t.loadingSize,type:t.loadingType,class:yr("loading")},null),f=()=>{if(t.loading)return u();if(o.icon)return _.createVNode("div",{class:yr("icon")},[o.icon()]);if(t.icon)return _.createVNode(Ki,{name:t.icon,class:yr("icon"),classPrefix:t.iconPrefix},null)},g=()=>{let m;if(t.loading?m=t.loadingText:m=o.default?o.default():t.text,m)return _.createVNode("span",{class:yr("text")},[m])},x=()=>{const{color:m,plain:E}=t;if(m){const C={color:E?m:"white"};return E||(C.background=m),m.includes("gradient")?C.border=0:C.borderColor=m,C}},y=m=>{t.loading?ds(m):t.disabled||(r("click",m),l())};return()=>{const{tag:m,type:E,size:C,block:P,round:O,plain:D,square:R,loading:M,disabled:V,hairline:U,nativeType:k,iconPosition:J}=t,be=[yr([E,C,{plain:D,block:P,round:O,square:R,loading:M,disabled:V,hairline:U}]),{[Nw]:U}];return _.createVNode(m,{type:k,class:be,style:x(),disabled:V,onClick:y},{default:()=>[_.createVNode("div",{class:yr("content")},[J==="left"&&f(),g(),J==="right"&&f()])]})}}});const Ho=$n(o3),[s3,a3]=An("action-bar-button"),l3=Zt({},Wu,{type:String,text:String,icon:String,color:String,loading:Boolean,disabled:Boolean});var c3=_.defineComponent({name:s3,props:l3,setup(t,{slots:r}){const o=Gu(),{parent:l,index:u}=iw(Hu),f=_.computed(()=>{if(l){const x=l.children[u.value-1];return!(x&&"isButton"in x)}}),g=_.computed(()=>{if(l){const x=l.children[u.value+1];return!(x&&"isButton"in x)}});return hs({isButton:!0}),()=>{const{type:x,icon:y,text:m,color:E,loading:C,disabled:P}=t;return _.createVNode(Ho,{class:a3([x,{last:g.value,first:f.value}]),size:"large",type:x,icon:y,color:E,loading:C,disabled:P,onClick:o},{default:()=>[r.default?r.default():m]})}}});const cl=$n(c3),ps={show:Boolean,zIndex:Xt,overlay:En,duration:Xt,teleport:[String,Object],lockScroll:En,lazyRender:En,beforeClose:Function,overlayProps:Object,overlayStyle:Object,overlayClass:Qr,transitionAppear:Boolean,closeOnClickOverlay:En},u3=Object.keys(ps);function d3(t,r){return t>r?"horizontal":r>t?"vertical":""}function f3(){const t=_.ref(0),r=_.ref(0),o=_.ref(0),l=_.ref(0),u=_.ref(0),f=_.ref(0),g=_.ref(""),x=_.ref(!0),y=()=>g.value==="vertical",m=()=>g.value==="horizontal",E=()=>{o.value=0,l.value=0,u.value=0,f.value=0,g.value="",x.value=!0};return{move:(O=>{const D=O.touches[0];o.value=(D.clientX<0?0:D.clientX)-t.value,l.value=D.clientY-r.value,u.value=Math.abs(o.value),f.value=Math.abs(l.value);const R=10;(!g.value||u.value<R&&f.value<R)&&(g.value=d3(u.value,f.value)),x.value&&(u.value>ol||f.value>ol)&&(x.value=!1)}),start:(O=>{E(),t.value=O.touches[0].clientX,r.value=O.touches[0].clientY}),reset:E,startX:t,startY:r,deltaX:o,deltaY:l,offsetX:u,offsetY:f,direction:g,isVertical:y,isHorizontal:m,isTap:x}}let Fr=0;const ul="van-overflow-hidden";function h3(t,r){const o=f3(),l="01",u="10",f=E=>{o.move(E);const C=o.deltaY.value>0?u:l,P=fw(E.target,t.value),{scrollHeight:O,offsetHeight:D,scrollTop:R}=P;let M="11";R===0?M=D>=O?"00":"01":R+D>=O&&(M="10"),M!=="11"&&o.isVertical()&&!(parseInt(M,2)&parseInt(C,2))&&ds(E,!0)},g=()=>{document.addEventListener("touchstart",o.start),document.addEventListener("touchmove",f,{passive:!1}),Fr||document.body.classList.add(ul),Fr++},x=()=>{Fr&&(document.removeEventListener("touchstart",o.start),document.removeEventListener("touchmove",f),Fr--,Fr||document.body.classList.remove(ul))},y=()=>r()&&g(),m=()=>r()&&x();Fu(y),_.onDeactivated(m),_.onBeforeUnmount(m),_.watch(r,E=>{E?g():x()})}function Ju(t){const r=_.ref(!1);return _.watch(t,o=>{o&&(r.value=o)},{immediate:!0}),o=>()=>r.value?o():null}const dl=()=>{var t;const{scopeId:r}=((t=_.getCurrentInstance())==null?void 0:t.vnode)||{};return r?{[r]:""}:null},[p3,g3]=An("overlay"),m3={show:Boolean,zIndex:Xt,duration:Xt,className:Qr,lockScroll:En,lazyRender:En,customStyle:Object,teleport:[String,Object]};var x3=_.defineComponent({name:p3,inheritAttrs:!1,props:m3,setup(t,{attrs:r,slots:o}){const l=_.ref(),u=Ju(()=>t.show||!t.lazyRender),f=x=>{t.lockScroll&&ds(x,!0)},g=u(()=>{var x;const y=Zt(xw(t.zIndex),t.customStyle);return Jn(t.duration)&&(y.animationDuration=`${t.duration}s`),_.withDirectives(_.createVNode("div",_.mergeProps({ref:l,style:y,class:[g3(),t.className]},r),[(x=o.default)==null?void 0:x.call(o)]),[[_.vShow,t.show]])});return $u("touchmove",f,{target:l}),()=>{const x=_.createVNode(_.Transition,{name:"van-fade",appear:!0},{default:g});return t.teleport?_.createVNode(_.Teleport,{to:t.teleport},{default:()=>[x]}):x}}});const w3=$n(x3),y3=Zt({},ps,{round:Boolean,position:Ot("center"),closeIcon:Ot("cross"),closeable:Boolean,transition:String,iconPrefix:String,closeOnPopstate:Boolean,closeIconPosition:Ot("top-right"),destroyOnClose:Boolean,safeAreaInsetTop:Boolean,safeAreaInsetBottom:Boolean}),[_3,fl]=An("popup");var v3=_.defineComponent({name:_3,inheritAttrs:!1,props:y3,emits:["open","close","opened","closed","keydown","update:show","clickOverlay","clickCloseIcon"],setup(t,{emit:r,attrs:o,slots:l}){let u,f;const g=_.ref(),x=_.ref(),y=Ju(()=>t.show||!t.lazyRender),m=_.computed(()=>{const Z={zIndex:g.value};if(Jn(t.duration)){const z=t.position==="center"?"animationDuration":"transitionDuration";Z[z]=`${t.duration}s`}return Z}),E=()=>{u||(u=!0,g.value=t.zIndex!==void 0?+t.zIndex:Vw(),r("open"))},C=()=>{u&&Vu(t.beforeClose,{done(){u=!1,r("close"),r("update:show",!1)}})},P=Z=>{r("clickOverlay",Z),t.closeOnClickOverlay&&C()},O=()=>{if(t.overlay){const Z=Zt({show:t.show,class:t.overlayClass,zIndex:g.value,duration:t.duration,customStyle:t.overlayStyle,role:t.closeOnClickOverlay?"button":void 0,tabindex:t.closeOnClickOverlay?0:void 0},t.overlayProps);return _.createVNode(w3,_.mergeProps(Z,dl(),{onClick:P}),{default:l["overlay-content"]})}},D=Z=>{r("clickCloseIcon",Z),C()},R=()=>{if(t.closeable)return _.createVNode(Ki,{role:"button",tabindex:0,name:t.closeIcon,class:[fl("close-icon",t.closeIconPosition),Ow],classPrefix:t.iconPrefix,onClick:D},null)};let M;const V=()=>{M&&clearTimeout(M),M=setTimeout(()=>{r("opened")})},U=()=>r("closed"),k=Z=>r("keydown",Z),J=y(()=>{var Z;const{destroyOnClose:z,round:Y,position:W,safeAreaInsetTop:de,safeAreaInsetBottom:me,show:pe}=t;if(!(!pe&&z))return _.withDirectives(_.createVNode("div",_.mergeProps({ref:x,style:m.value,role:"dialog",tabindex:0,class:[fl({round:Y,[W]:W}),{"van-safe-area-top":de,"van-safe-area-bottom":me}],onKeydown:k},o,dl()),[(Z=l.default)==null?void 0:Z.call(l),R()]),[[_.vShow,pe]])}),be=()=>{const{position:Z,transition:z,transitionAppear:Y}=t,W=Z==="center"?"van-fade":`van-popup-slide-${Z}`;return _.createVNode(_.Transition,{name:z||W,appear:Y,onAfterEnter:V,onAfterLeave:U},{default:J})};return _.watch(()=>t.show,Z=>{Z&&!u&&(E(),o.tabindex===0&&_.nextTick(()=>{var z;(z=x.value)==null||z.focus()})),!Z&&u&&(u=!1,r("close"))}),hs({popupRef:x}),h3(x,()=>t.show&&t.lockScroll),$u("popstate",()=>{t.closeOnPopstate&&(C(),f=!1)}),_.onMounted(()=>{t.show&&E()}),_.onActivated(()=>{f&&(r("update:show",!0),f=!1)}),_.onDeactivated(()=>{t.show&&t.teleport&&(C(),f=!0)}),_.provide(Zu,()=>t.show),()=>t.teleport?_.createVNode(_.Teleport,{to:t.teleport},{default:()=>[O(),be()]}):_.createVNode(_.Fragment,null,[O(),be()])}});const Qu=$n(v3);let $r=0;function b3(t){t?($r||document.body.classList.add("van-toast--unclickable"),$r++):$r&&($r--,$r||document.body.classList.remove("van-toast--unclickable"))}const[C3,_r]=An("toast"),E3=["show","overlay","teleport","transition","overlayClass","overlayStyle","closeOnClickOverlay","zIndex"],A3={icon:String,show:Boolean,type:Ot("text"),overlay:Boolean,message:Xt,iconSize:Xt,duration:tw(2e3),position:Ot("middle"),teleport:[String,Object],wordBreak:String,className:Qr,iconPrefix:String,transition:Ot("van-fade"),loadingType:String,forbidClick:Boolean,overlayClass:Qr,overlayStyle:Object,closeOnClick:Boolean,closeOnClickOverlay:Boolean,zIndex:Xt};var I3=_.defineComponent({name:C3,props:A3,emits:["update:show"],setup(t,{emit:r,slots:o}){let l,u=!1;const f=()=>{const C=t.show&&t.forbidClick;u!==C&&(u=C,b3(u))},g=C=>r("update:show",C),x=()=>{t.closeOnClick&&g(!1)},y=()=>clearTimeout(l),m=()=>{const{icon:C,type:P,iconSize:O,iconPrefix:D,loadingType:R}=t;if(C||P==="success"||P==="fail")return _.createVNode(Ki,{name:C||P,size:O,class:_r("icon"),classPrefix:D},null);if(P==="loading")return _.createVNode(Ku,{class:_r("loading"),size:O,type:R},null)},E=()=>{const{type:C,message:P}=t;if(o.message)return _.createVNode("div",{class:_r("text")},[o.message()]);if(Jn(P)&&P!=="")return C==="html"?_.createVNode("div",{key:0,class:_r("text"),innerHTML:String(P)},null):_.createVNode("div",{class:_r("text")},[P])};return _.watch(()=>[t.show,t.forbidClick],f),_.watch(()=>[t.show,t.type,t.message,t.duration],()=>{y(),t.show&&t.duration>0&&(l=setTimeout(()=>{g(!1)},t.duration))}),_.onMounted(f),_.onUnmounted(f),()=>_.createVNode(Qu,_.mergeProps({class:[_r([t.position,t.wordBreak==="normal"?"break-normal":t.wordBreak,{[t.type]:!t.icon}]),t.className],lockScroll:!1,onClick:x,onClosed:y,"onUpdate:show":g},Lu(t,E3)),{default:()=>[m(),E()]})}});function e1(){const t=_.reactive({show:!1}),r=u=>{t.show=u},o=u=>{Zt(t,u,{transitionAppear:!0}),r(!0)},l=()=>r(!1);return hs({open:o,close:l,toggle:r}),{open:o,close:l,state:t,toggle:r}}function t1(t){const r=_.createApp(t),o=document.createElement("div");return document.body.appendChild(o),{instance:r.mount(o),unmount(){r.unmount(),document.body.removeChild(o)}}}const S3={icon:"",type:"text",message:"",className:"",overlay:!1,onClose:void 0,onOpened:void 0,duration:2e3,teleport:"body",iconSize:void 0,iconPrefix:void 0,position:"middle",transition:"van-fade",forbidClick:!1,loadingType:void 0,overlayClass:"",overlayStyle:void 0,closeOnClick:!1,closeOnClickOverlay:!1};let Ii=[],T3=!1,hl=Zt({},S3);const N3=new Map;function n1(t){return Yi(t)?t:{message:t}}function O3(){const{instance:t}=t1({setup(){const r=_.ref(""),{open:o,state:l,close:u,toggle:f}=e1(),g=()=>{},x=()=>{const y={onClosed:g,"onUpdate:show":f};return _.createVNode(I3,_.mergeProps(l,y),null)};return _.watch(r,y=>{l.message=y}),_.getCurrentInstance().render=x,{open:o,close:u,message:r}}});return t}function k3(){if(!Ii.length||T3){const t=O3();Ii.push(t)}return Ii[Ii.length-1]}function dt(t={}){if(!qi)return{};const r=k3(),o=n1(t);return r.open(Zt({},hl,N3.get(o.type||hl.type),o)),r}const R3=t=>r=>dt(Zt({type:t},n1(r))),r1=R3("loading"),[D3,bn,Si]=An("dialog"),M3=Zt({},ps,{title:String,theme:String,width:Xt,message:[String,Function],callback:Function,allowHtml:Boolean,className:Qr,transition:Ot("van-dialog-bounce"),messageAlign:String,closeOnPopstate:En,showCancelButton:Boolean,cancelButtonText:String,cancelButtonColor:String,cancelButtonDisabled:Boolean,confirmButtonText:String,confirmButtonColor:String,confirmButtonDisabled:Boolean,showConfirmButton:En,closeOnClickOverlay:Boolean,keyboardEnabled:En,destroyOnClose:Boolean}),P3=[...u3,"transition","closeOnPopstate","destroyOnClose"];var i1=_.defineComponent({name:D3,props:M3,emits:["confirm","cancel","keydown","update:show"],setup(t,{emit:r,slots:o}){const l=_.ref(),u=_.reactive({confirm:!1,cancel:!1}),f=V=>r("update:show",V),g=V=>{var U;f(!1),(U=t.callback)==null||U.call(t,V)},x=V=>()=>{t.show&&(r(V),t.beforeClose?(u[V]=!0,Vu(t.beforeClose,{args:[V],done(){g(V),u[V]=!1},canceled(){u[V]=!1}})):g(V))},y=x("cancel"),m=x("confirm"),E=_.withKeys(V=>{var U,k;if(!t.keyboardEnabled||V.target!==((k=(U=l.value)==null?void 0:U.popupRef)==null?void 0:k.value))return;({Enter:t.showConfirmButton?m:Zo,Escape:t.showCancelButton?y:Zo})[V.key](),r("keydown",V)},["enter","esc"]),C=()=>{const V=o.title?o.title():t.title;if(V)return _.createVNode("div",{class:bn("header",{isolated:!t.message&&!o.default})},[V])},P=V=>{const{message:U,allowHtml:k,messageAlign:J}=t,be=bn("message",{"has-title":V,[J]:J}),Z=Vi(U)?U():U;return k&&typeof Z=="string"?_.createVNode("div",{class:be,innerHTML:Z},null):_.createVNode("div",{class:be},[Z])},O=()=>{if(o.default)return _.createVNode("div",{class:bn("content")},[o.default()]);const{title:V,message:U,allowHtml:k}=t;if(U){const J=!!(V||o.title);return _.createVNode("div",{key:k?1:0,class:bn("content",{isolated:!J})},[P(J)])}},D=()=>_.createVNode("div",{class:[Sw,bn("footer")]},[t.showCancelButton&&_.createVNode(Ho,{size:"large",text:t.cancelButtonText||Si("cancel"),class:bn("cancel"),style:{color:t.cancelButtonColor},loading:u.cancel,disabled:t.cancelButtonDisabled,onClick:y},null),t.showConfirmButton&&_.createVNode(Ho,{size:"large",text:t.confirmButtonText||Si("confirm"),class:[bn("confirm"),{[Tw]:t.showCancelButton}],style:{color:t.confirmButtonColor},loading:u.confirm,disabled:t.confirmButtonDisabled,onClick:m},null)]),R=()=>_.createVNode(Bw,{class:bn("footer")},{default:()=>[t.showCancelButton&&_.createVNode(cl,{type:"warning",text:t.cancelButtonText||Si("cancel"),class:bn("cancel"),color:t.cancelButtonColor,loading:u.cancel,disabled:t.cancelButtonDisabled,onClick:y},null),t.showConfirmButton&&_.createVNode(cl,{type:"danger",text:t.confirmButtonText||Si("confirm"),class:bn("confirm"),color:t.confirmButtonColor,loading:u.confirm,disabled:t.confirmButtonDisabled,onClick:m},null)]}),M=()=>o.footer?o.footer():t.theme==="round-button"?R():D();return()=>{const{width:V,title:U,theme:k,message:J,className:be}=t;return _.createVNode(Qu,_.mergeProps({ref:l,role:"dialog",class:[bn([k]),be],style:{width:hn(V)},tabindex:0,"aria-labelledby":U||J,onKeydown:E,"onUpdate:show":f},Lu(t,P3)),{default:()=>[C(),O(),M()]})}}});let Wo;const B3={title:"",width:"",theme:null,message:"",overlay:!0,callback:null,teleport:"body",className:"",allowHtml:!1,lockScroll:!0,transition:void 0,beforeClose:null,overlayClass:"",overlayStyle:void 0,messageAlign:"",cancelButtonText:"",cancelButtonColor:null,cancelButtonDisabled:!1,confirmButtonText:"",confirmButtonColor:null,confirmButtonDisabled:!1,showConfirmButton:!0,showCancelButton:!1,closeOnPopstate:!0,closeOnClickOverlay:!1,destroyOnClose:!1};let L3=Zt({},B3);function F3(){({instance:Wo}=t1({setup(){const{state:r,toggle:o}=e1();return()=>_.createVNode(i1,_.mergeProps(r,{"onUpdate:show":o}),null)}}))}function $3(t){return qi?new Promise((r,o)=>{Wo||F3(),Wo.open(Zt({},L3,t,{callback:l=>{(l==="confirm"?r:o)(l)}}))}):Promise.resolve(void 0)}const U3=t=>$3(Zt({showCancelButton:!0},t));$n(i1);let Ti="",Ni=0;const z3=({sessionId:t,agentRoot:r,systemPrompt:o,llmConfig:l,skills:u=[]})=>{const f=new qx({provider:"custom"},t,r,o,l),g=new or.AIClient({providerImplementation:f,provider:"custom"}),x=_.ref(!1),y=_.h(Qa,{style:{fontSize:"32px"}}),m=_.h(Di.IconUser,{style:{fontSize:"32px"}}),E=_.h(Qa,{style:{width:"48px",height:"48px"}}),{messageManager:C,createConversation:P,getCurrentConversation:O,switchConversation:D,deleteConversation:R,updateTitle:M,state:V}=or.useConversation({client:g,events:{onLoaded(){K()},onReceiveData(ee,he,Ee){Ee();let _e=he.value[he.value.length-1];if(ee.type==="start"&&(Ti="",Ni=0),["text-start","tool"].includes(ee.type)&&(Ti="",Ni=0),ee.type,_e.role!=="assistant"){const T={role:"assistant",content:"",uiContent:[]};he.value.push(T),_e=T}if(ee.type==="tool"){const T=_e.uiContent.find(ce=>ce.id===ee.id);T?(T.content+=ee.delta,T.status=ee.status):_e.uiContent.push(ee)}else if(ee.type==="markdown"){Ti+=ee.delta;const T=Jx(Ti),ce=T.length;if(ce===0)return;ce>Ni?_e.uiContent.push(T[ce-1]):_e.uiContent[_e.uiContent.length-1]=T[ce-1],Ni=ce}else if(ee.type==="collapsible-text"){const T=_e.uiContent.find(ce=>ce.type===ee.type&&ce.thinkId===ee.thinkId);T?(T.content+=ee.delta,_e.content+=ee.delta):_e.uiContent.push(ee)}}}}),{messageState:U,inputMessage:k,sendMessage:J,abortRequest:be,messages:Z,addMessage:z,send:Y}=C,W={assistant:{type:"markdown",placement:"start",avatar:y,maxWidth:"80%",customContentField:"uiContent"},user:{placement:"end",avatar:m,maxWidth:"80%"}},de=_.ref(),me=ee=>{for(const he in f.agent.mcpTools){const Ee=f.agent.mcpTools[he];if(Ee&&Ee[ee])return!f.agent.ignoreToolnames.includes(ee)}return!1},pe=async ee=>{if(ee.length===0)return!1;const he=[];for(const Ee of ee){const _e=u.find(T=>T.label===Ee.content);if(_e?.tools&&_e.tools.length>0){const T=[];for(const ce of _e.tools)me(ce)||T.push(ce);T.length>0&&he.push({skillLabel:Ee.content||_e.label,toolNames:T})}}if(he.length>0){const Ee=he.map(_e=>`${_e.skillLabel} 需要以下工具:${_e.toolNames.join("、")}`).join(`
61
+ `);try{return await U3({title:"工具未准备好",message:`无法发送消息:
62
+ ${Ee}
63
63
 
64
64
  请先加载或启用对应的工具。
65
65
 
66
- 是否仍然发送?`,confirmButtonText:"仍然发送",cancelButtonText:"确定",showCancelButton:!0}),!1}catch{return!0}}return!1},F=ne=>ne.map(S=>{if(S.type==="mention")return`@${S.content}`;if(S.type==="text")return S.content}).join(" "),J=ne=>ne.map(S=>S.value).filter(S=>S&&typeof S=="string"&&S.length>0),X=(ne,S)=>{if(ne.length>0){let fe="";if(ne.length===1)fe=ne[0];else{const Le=S.map($e=>$e.content);fe=`# 多专家协作模式
66
+ 是否仍然发送?`,confirmButtonText:"仍然发送",cancelButtonText:"确定",showCancelButton:!0}),!1}catch{return!0}}return!1},Ce=ee=>ee.map(he=>{if(he.type==="mention")return`@${he.content}`;if(he.type==="text")return he.content}).join(" "),le=ee=>ee.map(he=>he.value).filter(he=>he&&typeof he=="string"&&he.length>0),L=(ee,he)=>{if(ee.length>0){let Ee="";if(ee.length===1)Ee=ee[0];else{const T=he.map(ce=>ce.content);Ee=`# 多专家协作模式
67
67
 
68
- 你同时具备以下 ${ne.length} 位专家的能力,请根据用户需求选择合适的专家视角来回答问题:
68
+ 你同时具备以下 ${ee.length} 位专家的能力,请根据用户需求选择合适的专家视角来回答问题:
69
69
 
70
- `,ne.forEach(($e,Xe)=>{fe+=`## ${Le[Xe]}(专家 ${Xe+1})
70
+ `,ee.forEach((ce,we)=>{Ee+=`## ${T[we]}(专家 ${we+1})
71
71
 
72
- ${$e}
72
+ ${ce}
73
73
 
74
74
  ---
75
75
 
76
- `})}const se=o?`${o}
76
+ `})}const _e=o?`${o}
77
77
 
78
- ${fe}`:fe;m.systemPrompt=se}else m.systemPrompt=o},te=async(ne,S,fe)=>{if(S&&S.length>0){const Le=S.filter(qt=>qt.type==="mention");if(await le(Le))return!1;ve.value=F(S);const Xe=J(Le);X(Xe,Le)}const se=D();if(se&&se.title==="新会话"&&U(se.id,ve.value.slice(0,15)),fe&&fe.length>0){const Le=[{type:"text",text:ve.value},...fe.map($e=>({type:"image",image:$e}))];Y({role:"user",content:Le}),Ie()}else Q(ve.value);return!0},pe=()=>{j();const ne=[];m.agent.messages=ne,R();const S=D();S.aiSdkMessages=ne},ge=ne=>{j(),M(ne.id);const S=D();m.agent.messages=S.aiSdkMessages,x.value=!1,Fe()},ye=(ne,S)=>{S.title=ne},we=(ne,S)=>{if(ne.id==="delete"){if(k.currentId===S.id){ht("不允许删除当前会话");return}z(S.id)}},Fe=()=>{C.nextTick(()=>{const ne=document.querySelector("div.tr-bubble-list");ne&&ne.scrollTo({top:ne.scrollHeight,behavior:"smooth"})})};C.watch(()=>ie.value[ie.value.length-1]?.content,Fe),C.onMounted(()=>{he.value?.focus()}),C.onUnmounted(()=>{m.agent.closeAll()});const{selectedModel:Pe}=to();return g.value&&C.watch(Pe,ne=>{ne&&m.updateLLMConfig({modelId:ne.id,apiUrl:ne.apiUrl,apiKey:ne.apiKey,providerType:ne.providerType,useReActMode:ne.useReActMode})},{immediate:!0}),{agent:m.agent,customAgentProvider:m,client:y,showHistory:x,aiAvatar:A,userAvatar:b,welcomeIcon:P,messageManager:N,addMessage:Y,send:Ie,conversationState:k,messages:ie,messageState:K,inputMessage:ve,sendMessage:Q,abortRequest:j,roles:Ce,senderRef:he,handleSendMessage:te,createConversation:R,handleHistorySelect:ge,handleCreateConversation:pe,handleHistoryUpdateTitle:ye,handleHistoryDelete:we}},sy=t=>{try{const n=JSON.parse(t),o=[];if(!n.mcpServers||typeof n.mcpServers!="object")throw new Error("JSON 格式错误:缺少 mcpServers 字段");for(const[l,u]of Object.entries(n.mcpServers)){const f=ay(u);f&&o.push({name:l,config:f})}return o}catch(n){throw new Error(`JSON 解析失败: ${n instanceof Error?n.message:"未知错误"}`)}},ay=t=>{if(!t||typeof t!="object"||!t.url)return null;const{type:n,url:o,sessionId:l}=t;return n==="extension"?l?{type:"extension",url:o,sessionId:l,useAISdkClient:!0}:null:n==="streamableHttp"||n==="sse"?{type:n,url:o,useAISdkClient:!0}:{type:"streamableHttp",url:o,useAISdkClient:!0}},ly=(t,n,o)=>{const l=async(f,g,m,y,x)=>{if(await t.insertMcpServer(f,g)){const b=t.mcpTools[f];if(b){const N={id:`plugin-${f.replace("mcp-server-","")}`,name:m,icon:x||o,description:y||(typeof g=="object"&&"url"in g?g.url:""),enabled:!0,expanded:!0,tools:Object.keys(b).map(R=>({id:R,name:R,description:b[R].description,enabled:!0})),originMcpConfig:C.markRaw(g)};return n.value.push(N),!0}else return await t.removeMcpServer(f),!1}else return!1};return{handleCustomAdd:async(f,g)=>{f1("添加工具中...");try{if(f==="code"){if(typeof g!="string"){ht("添加工具失败:code 类型需要 JSON 字符串格式");return}const z=sy(g);if(z.length===0){ht("添加工具失败:JSON 配置格式不正确或未找到有效的服务器配置");return}let U=0,k=0;for(const{name:K,config:ve}of z){const Q=`mcp-server-${K}`;await l(Q,ve,K)?U++:k++}await t.closeAll(),k===0?ht(`成功添加 ${U} 个工具`):U>0?ht(`成功添加 ${U} 个工具,${k} 个失败`):ht("添加工具失败:所有服务器都无法连接");return}if(typeof g=="string"){ht("添加工具失败:数据格式不正确");return}const{description:m,headers:y,name:x,thumbnail:A,type:b,url:P}=g;if(!x||!P||!b){ht("添加工具失败:缺少必要参数(名称、URL或类型)");return}const R=`mcp-server-${`custom-${x}-${Date.now()}`}`;await l(R,{type:b,url:P,useAISdkClient:!0},x,m,A)?(await t.closeAll(),ht("添加工具完成")):ht("重复添加工具或无法获取工具列表")}catch(m){console.error("handleCustomAdd error:",m),ht(`添加工具失败:${m instanceof Error?m.message:"未知错误"}`)}}}};var Ae;(function(t){t[t.QR_CODE=0]="QR_CODE",t[t.AZTEC=1]="AZTEC",t[t.CODABAR=2]="CODABAR",t[t.CODE_39=3]="CODE_39",t[t.CODE_93=4]="CODE_93",t[t.CODE_128=5]="CODE_128",t[t.DATA_MATRIX=6]="DATA_MATRIX",t[t.MAXICODE=7]="MAXICODE",t[t.ITF=8]="ITF",t[t.EAN_13=9]="EAN_13",t[t.EAN_8=10]="EAN_8",t[t.PDF_417=11]="PDF_417",t[t.RSS_14=12]="RSS_14",t[t.RSS_EXPANDED=13]="RSS_EXPANDED",t[t.UPC_A=14]="UPC_A",t[t.UPC_E=15]="UPC_E",t[t.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(Ae||(Ae={}));var Cl=new Map([[Ae.QR_CODE,"QR_CODE"],[Ae.AZTEC,"AZTEC"],[Ae.CODABAR,"CODABAR"],[Ae.CODE_39,"CODE_39"],[Ae.CODE_93,"CODE_93"],[Ae.CODE_128,"CODE_128"],[Ae.DATA_MATRIX,"DATA_MATRIX"],[Ae.MAXICODE,"MAXICODE"],[Ae.ITF,"ITF"],[Ae.EAN_13,"EAN_13"],[Ae.EAN_8,"EAN_8"],[Ae.PDF_417,"PDF_417"],[Ae.RSS_14,"RSS_14"],[Ae.RSS_EXPANDED,"RSS_EXPANDED"],[Ae.UPC_A,"UPC_A"],[Ae.UPC_E,"UPC_E"],[Ae.UPC_EAN_EXTENSION,"UPC_EAN_EXTENSION"]]),bl;(function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.URL=1]="URL"})(bl||(bl={}));function cy(t){return Object.values(Ae).includes(t)}var ii;(function(t){t[t.SCAN_TYPE_CAMERA=0]="SCAN_TYPE_CAMERA",t[t.SCAN_TYPE_FILE=1]="SCAN_TYPE_FILE"})(ii||(ii={}));var uy=(function(){function t(){}return t.GITHUB_PROJECT_URL="https://github.com/mebjas/html5-qrcode",t.SCAN_DEFAULT_FPS=2,t.DEFAULT_DISABLE_FLIP=!1,t.DEFAULT_REMEMBER_LAST_CAMERA_USED=!0,t.DEFAULT_SUPPORTED_SCAN_TYPE=[ii.SCAN_TYPE_CAMERA,ii.SCAN_TYPE_FILE],t})(),p1=(function(){function t(n,o){this.format=n,this.formatName=o}return t.prototype.toString=function(){return this.formatName},t.create=function(n){if(!Cl.has(n))throw"".concat(n," not in html5QrcodeSupportedFormatsTextMap");return new t(n,Cl.get(n))},t})(),El=(function(){function t(){}return t.createFromText=function(n){var o={text:n};return{decodedText:n,result:o}},t.createFromQrcodeResult=function(n){return{decodedText:n.text,result:n}},t})(),es;(function(t){t[t.UNKWOWN_ERROR=0]="UNKWOWN_ERROR",t[t.IMPLEMENTATION_ERROR=1]="IMPLEMENTATION_ERROR",t[t.NO_CODE_FOUND_ERROR=2]="NO_CODE_FOUND_ERROR"})(es||(es={}));var dy=(function(){function t(){}return t.createFrom=function(n){return{errorMessage:n,type:es.UNKWOWN_ERROR}},t})(),fy=(function(){function t(n){this.verbose=n}return t.prototype.log=function(n){this.verbose&&console.log(n)},t.prototype.warn=function(n){this.verbose&&console.warn(n)},t.prototype.logError=function(n,o){(this.verbose||o===!0)&&console.error(n)},t.prototype.logErrors=function(n){if(n.length===0)throw"Logger#logError called without arguments";this.verbose&&console.error(n)},t})();function Un(t){return typeof t>"u"||t===null}var Sr=(function(){function t(){}return t.codeParseError=function(n){return"QR code parse error, error = ".concat(n)},t.errorGettingUserMedia=function(n){return"Error getting userMedia, error = ".concat(n)},t.onlyDeviceSupportedError=function(){return"The device doesn't support navigator.mediaDevices , only supported cameraIdOrConfig in this case is deviceId parameter (string)."},t.cameraStreamingNotSupported=function(){return"Camera streaming not supported by the browser."},t.unableToQuerySupportedDevices=function(){return"Unable to query supported devices, unknown error."},t.insecureContextCameraQueryError=function(){return"Camera access is only supported in secure context like https or localhost."},t.scannerPaused=function(){return"Scanner paused"},t})(),g1=(function(){function t(){}return t.isMediaStreamConstraintsValid=function(n,o){if(typeof n!="object"){var l=typeof n;return o.logError("videoConstraints should be of type object, the "+"object passed is of type ".concat(l,"."),!0),!1}for(var u=["autoGainControl","channelCount","echoCancellation","latency","noiseSuppression","sampleRate","sampleSize","volume"],f=new Set(u),g=Object.keys(n),m=0,y=g;m<y.length;m++){var x=y[m];if(f.has(x))return o.logError("".concat(x," is not supported videoConstaints."),!0),!1}return!0},t})(),Wr={exports:{}},hy=Wr.exports,Al;function py(){return Al||(Al=1,(function(t,n){(function(o,l){l(n)})(hy,(function(o){function l(_){return _==null}var u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(_,e){_.__proto__=e}||function(_,e){for(var r in e)e.hasOwnProperty(r)&&(_[r]=e[r])};function f(_,e){u(_,e);function r(){this.constructor=_}_.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function g(_,e){var r=Object.setPrototypeOf;r?r(_,e):_.__proto__=e}function m(_,e){e===void 0&&(e=_.constructor);var r=Error.captureStackTrace;r&&r(_,e)}var y=(function(_){f(e,_);function e(r){var i=this.constructor,s=_.call(this,r)||this;return Object.defineProperty(s,"name",{value:i.name,enumerable:!1}),g(s,i.prototype),m(s),s}return e})(Error);class x extends y{constructor(e=void 0){super(e),this.message=e}getKind(){return this.constructor.kind}}x.kind="Exception";class A extends x{}A.kind="ArgumentException";class b extends x{}b.kind="IllegalArgumentException";class P{constructor(e){if(this.binarizer=e,e===null)throw new b("Binarizer must be non-null.")}getWidth(){return this.binarizer.getWidth()}getHeight(){return this.binarizer.getHeight()}getBlackRow(e,r){return this.binarizer.getBlackRow(e,r)}getBlackMatrix(){return(this.matrix===null||this.matrix===void 0)&&(this.matrix=this.binarizer.getBlackMatrix()),this.matrix}isCropSupported(){return this.binarizer.getLuminanceSource().isCropSupported()}crop(e,r,i,s){const a=this.binarizer.getLuminanceSource().crop(e,r,i,s);return new P(this.binarizer.createBinarizer(a))}isRotateSupported(){return this.binarizer.getLuminanceSource().isRotateSupported()}rotateCounterClockwise(){const e=this.binarizer.getLuminanceSource().rotateCounterClockwise();return new P(this.binarizer.createBinarizer(e))}rotateCounterClockwise45(){const e=this.binarizer.getLuminanceSource().rotateCounterClockwise45();return new P(this.binarizer.createBinarizer(e))}toString(){try{return this.getBlackMatrix().toString()}catch{return""}}}class N extends x{static getChecksumInstance(){return new N}}N.kind="ChecksumException";class R{constructor(e){this.source=e}getLuminanceSource(){return this.source}getWidth(){return this.source.getWidth()}getHeight(){return this.source.getHeight()}}class D{static arraycopy(e,r,i,s,a){for(;a--;)i[s++]=e[r++]}static currentTimeMillis(){return Date.now()}}class M extends x{}M.kind="IndexOutOfBoundsException";class z extends M{constructor(e=void 0,r=void 0){super(r),this.index=e,this.message=r}}z.kind="ArrayIndexOutOfBoundsException";class U{static fill(e,r){for(let i=0,s=e.length;i<s;i++)e[i]=r}static fillWithin(e,r,i,s){U.rangeCheck(e.length,r,i);for(let a=r;a<i;a++)e[a]=s}static rangeCheck(e,r,i){if(r>i)throw new b("fromIndex("+r+") > toIndex("+i+")");if(r<0)throw new z(r);if(i>e)throw new z(i)}static asList(...e){return e}static create(e,r,i){return Array.from({length:e}).map(a=>Array.from({length:r}).fill(i))}static createInt32Array(e,r,i){return Array.from({length:e}).map(a=>Int32Array.from({length:r}).fill(i))}static equals(e,r){if(!e||!r||!e.length||!r.length||e.length!==r.length)return!1;for(let i=0,s=e.length;i<s;i++)if(e[i]!==r[i])return!1;return!0}static hashCode(e){if(e===null)return 0;let r=1;for(const i of e)r=31*r+i;return r}static fillUint8Array(e,r){for(let i=0;i!==e.length;i++)e[i]=r}static copyOf(e,r){return e.slice(0,r)}static copyOfUint8Array(e,r){if(e.length<=r){const i=new Uint8Array(r);return i.set(e),i}return e.slice(0,r)}static copyOfRange(e,r,i){const s=i-r,a=new Int32Array(s);return D.arraycopy(e,r,a,0,s),a}static binarySearch(e,r,i){i===void 0&&(i=U.numberComparator);let s=0,a=e.length-1;for(;s<=a;){const c=a+s>>1,d=i(r,e[c]);if(d>0)s=c+1;else if(d<0)a=c-1;else return c}return-s-1}static numberComparator(e,r){return e-r}}class k{static numberOfTrailingZeros(e){let r;if(e===0)return 32;let i=31;return r=e<<16,r!==0&&(i-=16,e=r),r=e<<8,r!==0&&(i-=8,e=r),r=e<<4,r!==0&&(i-=4,e=r),r=e<<2,r!==0&&(i-=2,e=r),i-(e<<1>>>31)}static numberOfLeadingZeros(e){if(e===0)return 32;let r=1;return e>>>16||(r+=16,e<<=16),e>>>24||(r+=8,e<<=8),e>>>28||(r+=4,e<<=4),e>>>30||(r+=2,e<<=2),r-=e>>>31,r}static toHexString(e){return e.toString(16)}static toBinaryString(e){return String(parseInt(String(e),2))}static bitCount(e){return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),e=e+(e>>>4)&252645135,e=e+(e>>>8),e=e+(e>>>16),e&63}static truncDivision(e,r){return Math.trunc(e/r)}static parseInt(e,r=void 0){return parseInt(e,r)}}k.MIN_VALUE_32_BITS=-2147483648,k.MAX_VALUE=Number.MAX_SAFE_INTEGER;class K{constructor(e,r){e===void 0?(this.size=0,this.bits=new Int32Array(1)):(this.size=e,r==null?this.bits=K.makeArray(e):this.bits=r)}getSize(){return this.size}getSizeInBytes(){return Math.floor((this.size+7)/8)}ensureCapacity(e){if(e>this.bits.length*32){const r=K.makeArray(e);D.arraycopy(this.bits,0,r,0,this.bits.length),this.bits=r}}get(e){return(this.bits[Math.floor(e/32)]&1<<(e&31))!==0}set(e){this.bits[Math.floor(e/32)]|=1<<(e&31)}flip(e){this.bits[Math.floor(e/32)]^=1<<(e&31)}getNextSet(e){const r=this.size;if(e>=r)return r;const i=this.bits;let s=Math.floor(e/32),a=i[s];a&=~((1<<(e&31))-1);const c=i.length;for(;a===0;){if(++s===c)return r;a=i[s]}const d=s*32+k.numberOfTrailingZeros(a);return d>r?r:d}getNextUnset(e){const r=this.size;if(e>=r)return r;const i=this.bits;let s=Math.floor(e/32),a=~i[s];a&=~((1<<(e&31))-1);const c=i.length;for(;a===0;){if(++s===c)return r;a=~i[s]}const d=s*32+k.numberOfTrailingZeros(a);return d>r?r:d}setBulk(e,r){this.bits[Math.floor(e/32)]=r}setRange(e,r){if(r<e||e<0||r>this.size)throw new b;if(r===e)return;r--;const i=Math.floor(e/32),s=Math.floor(r/32),a=this.bits;for(let c=i;c<=s;c++){const d=c>i?0:e&31,p=(2<<(c<s?31:r&31))-(1<<d);a[c]|=p}}clear(){const e=this.bits.length,r=this.bits;for(let i=0;i<e;i++)r[i]=0}isRange(e,r,i){if(r<e||e<0||r>this.size)throw new b;if(r===e)return!0;r--;const s=Math.floor(e/32),a=Math.floor(r/32),c=this.bits;for(let d=s;d<=a;d++){const h=d>s?0:e&31,w=(2<<(d<a?31:r&31))-(1<<h)&4294967295;if((c[d]&w)!==(i?w:0))return!1}return!0}appendBit(e){this.ensureCapacity(this.size+1),e&&(this.bits[Math.floor(this.size/32)]|=1<<(this.size&31)),this.size++}appendBits(e,r){if(r<0||r>32)throw new b("Num bits must be between 0 and 32");this.ensureCapacity(this.size+r);for(let i=r;i>0;i--)this.appendBit((e>>i-1&1)===1)}appendBitArray(e){const r=e.size;this.ensureCapacity(this.size+r);for(let i=0;i<r;i++)this.appendBit(e.get(i))}xor(e){if(this.size!==e.size)throw new b("Sizes don't match");const r=this.bits;for(let i=0,s=r.length;i<s;i++)r[i]^=e.bits[i]}toBytes(e,r,i,s){for(let a=0;a<s;a++){let c=0;for(let d=0;d<8;d++)this.get(e)&&(c|=1<<7-d),e++;r[i+a]=c}}getBitArray(){return this.bits}reverse(){const e=new Int32Array(this.bits.length),r=Math.floor((this.size-1)/32),i=r+1,s=this.bits;for(let a=0;a<i;a++){let c=s[a];c=c>>1&1431655765|(c&1431655765)<<1,c=c>>2&858993459|(c&858993459)<<2,c=c>>4&252645135|(c&252645135)<<4,c=c>>8&16711935|(c&16711935)<<8,c=c>>16&65535|(c&65535)<<16,e[r-a]=c}if(this.size!==i*32){const a=i*32-this.size;let c=e[0]>>>a;for(let d=1;d<i;d++){const h=e[d];c|=h<<32-a,e[d-1]=c,c=h>>>a}e[i-1]=c}this.bits=e}static makeArray(e){return new Int32Array(Math.floor((e+31)/32))}equals(e){if(!(e instanceof K))return!1;const r=e;return this.size===r.size&&U.equals(this.bits,r.bits)}hashCode(){return 31*this.size+U.hashCode(this.bits)}toString(){let e="";for(let r=0,i=this.size;r<i;r++)(r&7)===0&&(e+=" "),e+=this.get(r)?"X":".";return e}clone(){return new K(this.size,this.bits.slice())}}var ve;(function(_){_[_.OTHER=0]="OTHER",_[_.PURE_BARCODE=1]="PURE_BARCODE",_[_.POSSIBLE_FORMATS=2]="POSSIBLE_FORMATS",_[_.TRY_HARDER=3]="TRY_HARDER",_[_.CHARACTER_SET=4]="CHARACTER_SET",_[_.ALLOWED_LENGTHS=5]="ALLOWED_LENGTHS",_[_.ASSUME_CODE_39_CHECK_DIGIT=6]="ASSUME_CODE_39_CHECK_DIGIT",_[_.ASSUME_GS1=7]="ASSUME_GS1",_[_.RETURN_CODABAR_START_END=8]="RETURN_CODABAR_START_END",_[_.NEED_RESULT_POINT_CALLBACK=9]="NEED_RESULT_POINT_CALLBACK",_[_.ALLOWED_EAN_EXTENSIONS=10]="ALLOWED_EAN_EXTENSIONS"})(ve||(ve={}));var Q=ve;class j extends x{static getFormatInstance(){return new j}}j.kind="FormatException";var ie;(function(_){_[_.Cp437=0]="Cp437",_[_.ISO8859_1=1]="ISO8859_1",_[_.ISO8859_2=2]="ISO8859_2",_[_.ISO8859_3=3]="ISO8859_3",_[_.ISO8859_4=4]="ISO8859_4",_[_.ISO8859_5=5]="ISO8859_5",_[_.ISO8859_6=6]="ISO8859_6",_[_.ISO8859_7=7]="ISO8859_7",_[_.ISO8859_8=8]="ISO8859_8",_[_.ISO8859_9=9]="ISO8859_9",_[_.ISO8859_10=10]="ISO8859_10",_[_.ISO8859_11=11]="ISO8859_11",_[_.ISO8859_13=12]="ISO8859_13",_[_.ISO8859_14=13]="ISO8859_14",_[_.ISO8859_15=14]="ISO8859_15",_[_.ISO8859_16=15]="ISO8859_16",_[_.SJIS=16]="SJIS",_[_.Cp1250=17]="Cp1250",_[_.Cp1251=18]="Cp1251",_[_.Cp1252=19]="Cp1252",_[_.Cp1256=20]="Cp1256",_[_.UnicodeBigUnmarked=21]="UnicodeBigUnmarked",_[_.UTF8=22]="UTF8",_[_.ASCII=23]="ASCII",_[_.Big5=24]="Big5",_[_.GB18030=25]="GB18030",_[_.EUC_KR=26]="EUC_KR"})(ie||(ie={}));class Y{constructor(e,r,i,...s){this.valueIdentifier=e,this.name=i,typeof r=="number"?this.values=Int32Array.from([r]):this.values=r,this.otherEncodingNames=s,Y.VALUE_IDENTIFIER_TO_ECI.set(e,this),Y.NAME_TO_ECI.set(i,this);const a=this.values;for(let c=0,d=a.length;c!==d;c++){const h=a[c];Y.VALUES_TO_ECI.set(h,this)}for(const c of s)Y.NAME_TO_ECI.set(c,this)}getValueIdentifier(){return this.valueIdentifier}getName(){return this.name}getValue(){return this.values[0]}static getCharacterSetECIByValue(e){if(e<0||e>=900)throw new j("incorect value");const r=Y.VALUES_TO_ECI.get(e);if(r===void 0)throw new j("incorect value");return r}static getCharacterSetECIByName(e){const r=Y.NAME_TO_ECI.get(e);if(r===void 0)throw new j("incorect value");return r}equals(e){if(!(e instanceof Y))return!1;const r=e;return this.getName()===r.getName()}}Y.VALUE_IDENTIFIER_TO_ECI=new Map,Y.VALUES_TO_ECI=new Map,Y.NAME_TO_ECI=new Map,Y.Cp437=new Y(ie.Cp437,Int32Array.from([0,2]),"Cp437"),Y.ISO8859_1=new Y(ie.ISO8859_1,Int32Array.from([1,3]),"ISO-8859-1","ISO88591","ISO8859_1"),Y.ISO8859_2=new Y(ie.ISO8859_2,4,"ISO-8859-2","ISO88592","ISO8859_2"),Y.ISO8859_3=new Y(ie.ISO8859_3,5,"ISO-8859-3","ISO88593","ISO8859_3"),Y.ISO8859_4=new Y(ie.ISO8859_4,6,"ISO-8859-4","ISO88594","ISO8859_4"),Y.ISO8859_5=new Y(ie.ISO8859_5,7,"ISO-8859-5","ISO88595","ISO8859_5"),Y.ISO8859_6=new Y(ie.ISO8859_6,8,"ISO-8859-6","ISO88596","ISO8859_6"),Y.ISO8859_7=new Y(ie.ISO8859_7,9,"ISO-8859-7","ISO88597","ISO8859_7"),Y.ISO8859_8=new Y(ie.ISO8859_8,10,"ISO-8859-8","ISO88598","ISO8859_8"),Y.ISO8859_9=new Y(ie.ISO8859_9,11,"ISO-8859-9","ISO88599","ISO8859_9"),Y.ISO8859_10=new Y(ie.ISO8859_10,12,"ISO-8859-10","ISO885910","ISO8859_10"),Y.ISO8859_11=new Y(ie.ISO8859_11,13,"ISO-8859-11","ISO885911","ISO8859_11"),Y.ISO8859_13=new Y(ie.ISO8859_13,15,"ISO-8859-13","ISO885913","ISO8859_13"),Y.ISO8859_14=new Y(ie.ISO8859_14,16,"ISO-8859-14","ISO885914","ISO8859_14"),Y.ISO8859_15=new Y(ie.ISO8859_15,17,"ISO-8859-15","ISO885915","ISO8859_15"),Y.ISO8859_16=new Y(ie.ISO8859_16,18,"ISO-8859-16","ISO885916","ISO8859_16"),Y.SJIS=new Y(ie.SJIS,20,"SJIS","Shift_JIS"),Y.Cp1250=new Y(ie.Cp1250,21,"Cp1250","windows-1250"),Y.Cp1251=new Y(ie.Cp1251,22,"Cp1251","windows-1251"),Y.Cp1252=new Y(ie.Cp1252,23,"Cp1252","windows-1252"),Y.Cp1256=new Y(ie.Cp1256,24,"Cp1256","windows-1256"),Y.UnicodeBigUnmarked=new Y(ie.UnicodeBigUnmarked,25,"UnicodeBigUnmarked","UTF-16BE","UnicodeBig"),Y.UTF8=new Y(ie.UTF8,26,"UTF8","UTF-8"),Y.ASCII=new Y(ie.ASCII,Int32Array.from([27,170]),"ASCII","US-ASCII"),Y.Big5=new Y(ie.Big5,28,"Big5"),Y.GB18030=new Y(ie.GB18030,29,"GB18030","GB2312","EUC_CN","GBK"),Y.EUC_KR=new Y(ie.EUC_KR,30,"EUC_KR","EUC-KR");class Ie extends x{}Ie.kind="UnsupportedOperationException";class Ce{static decode(e,r){const i=this.encodingName(r);return this.customDecoder?this.customDecoder(e,i):typeof TextDecoder>"u"||this.shouldDecodeOnFallback(i)?this.decodeFallback(e,i):new TextDecoder(i).decode(e)}static shouldDecodeOnFallback(e){return!Ce.isBrowser()&&e==="ISO-8859-1"}static encode(e,r){const i=this.encodingName(r);return this.customEncoder?this.customEncoder(e,i):typeof TextEncoder>"u"?this.encodeFallback(e):new TextEncoder().encode(e)}static isBrowser(){return typeof window<"u"&&{}.toString.call(window)==="[object Window]"}static encodingName(e){return typeof e=="string"?e:e.getName()}static encodingCharacterSet(e){return e instanceof Y?e:Y.getCharacterSetECIByName(e)}static decodeFallback(e,r){const i=this.encodingCharacterSet(r);if(Ce.isDecodeFallbackSupported(i)){let s="";for(let a=0,c=e.length;a<c;a++){let d=e[a].toString(16);d.length<2&&(d="0"+d),s+="%"+d}return decodeURIComponent(s)}if(i.equals(Y.UnicodeBigUnmarked))return String.fromCharCode.apply(null,new Uint16Array(e.buffer));throw new Ie(`Encoding ${this.encodingName(r)} not supported by fallback.`)}static isDecodeFallbackSupported(e){return e.equals(Y.UTF8)||e.equals(Y.ISO8859_1)||e.equals(Y.ASCII)}static encodeFallback(e){const i=btoa(unescape(encodeURIComponent(e))).split(""),s=[];for(let a=0;a<i.length;a++)s.push(i[a].charCodeAt(0));return new Uint8Array(s)}}class he{static castAsNonUtf8Char(e,r=null){const i=r?r.getName():this.ISO88591;return Ce.decode(new Uint8Array([e]),i)}static guessEncoding(e,r){if(r!=null&&r.get(Q.CHARACTER_SET)!==void 0)return r.get(Q.CHARACTER_SET).toString();const i=e.length;let s=!0,a=!0,c=!0,d=0,h=0,p=0,w=0,v=0,E=0,O=0,L=0,$=0,Z=0,G=0;const ae=e.length>3&&e[0]===239&&e[1]===187&&e[2]===191;for(let ce=0;ce<i&&(s||a||c);ce++){const oe=e[ce]&255;c&&(d>0?(oe&128)===0?c=!1:d--:(oe&128)!==0&&((oe&64)===0?c=!1:(d++,(oe&32)===0?h++:(d++,(oe&16)===0?p++:(d++,(oe&8)===0?w++:c=!1))))),s&&(oe>127&&oe<160?s=!1:oe>159&&(oe<192||oe===215||oe===247)&&G++),a&&(v>0?oe<64||oe===127||oe>252?a=!1:v--:oe===128||oe===160||oe>239?a=!1:oe>160&&oe<224?(E++,L=0,O++,O>$&&($=O)):oe>127?(v++,O=0,L++,L>Z&&(Z=L)):(O=0,L=0))}return c&&d>0&&(c=!1),a&&v>0&&(a=!1),c&&(ae||h+p+w>0)?he.UTF8:a&&(he.ASSUME_SHIFT_JIS||$>=3||Z>=3)?he.SHIFT_JIS:s&&a?$===2&&E===2||G*10>=i?he.SHIFT_JIS:he.ISO88591:s?he.ISO88591:a?he.SHIFT_JIS:c?he.UTF8:he.PLATFORM_DEFAULT_ENCODING}static format(e,...r){let i=-1;function s(c,d,h,p,w,v){if(c==="%%")return"%";if(r[++i]===void 0)return;c=p?parseInt(p.substr(1)):void 0;let E=w?parseInt(w.substr(1)):void 0,O;switch(v){case"s":O=r[i];break;case"c":O=r[i][0];break;case"f":O=parseFloat(r[i]).toFixed(c);break;case"p":O=parseFloat(r[i]).toPrecision(c);break;case"e":O=parseFloat(r[i]).toExponential(c);break;case"x":O=parseInt(r[i]).toString(E||16);break;case"d":O=parseFloat(parseInt(r[i],E||10).toPrecision(c)).toFixed(0);break}O=typeof O=="object"?JSON.stringify(O):(+O).toString(E);let L=parseInt(h),$=h&&h[0]+""=="0"?"0":" ";for(;O.length<L;)O=d!==void 0?O+$:$+O;return O}let a=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return e.replace(a,s)}static getBytes(e,r){return Ce.encode(e,r)}static getCharCode(e,r=0){return e.charCodeAt(r)}static getCharAt(e){return String.fromCharCode(e)}}he.SHIFT_JIS=Y.SJIS.getName(),he.GB2312="GB2312",he.ISO88591=Y.ISO8859_1.getName(),he.EUC_JP="EUC_JP",he.UTF8=Y.UTF8.getName(),he.PLATFORM_DEFAULT_ENCODING=he.UTF8,he.ASSUME_SHIFT_JIS=!1;class xe{constructor(e=""){this.value=e}enableDecoding(e){return this.encoding=e,this}append(e){return typeof e=="string"?this.value+=e.toString():this.encoding?this.value+=he.castAsNonUtf8Char(e,this.encoding):this.value+=String.fromCharCode(e),this}appendChars(e,r,i){for(let s=r;r<r+i;s++)this.append(e[s]);return this}length(){return this.value.length}charAt(e){return this.value.charAt(e)}deleteCharAt(e){this.value=this.value.substr(0,e)+this.value.substring(e+1)}setCharAt(e,r){this.value=this.value.substr(0,e)+r+this.value.substr(e+1)}substring(e,r){return this.value.substring(e,r)}setLengthToZero(){this.value=""}toString(){return this.value}insert(e,r){this.value=this.value.substr(0,e)+r+this.value.substr(e+r.length)}}class le{constructor(e,r,i,s){if(this.width=e,this.height=r,this.rowSize=i,this.bits=s,r==null&&(r=e),this.height=r,e<1||r<1)throw new b("Both dimensions must be greater than 0");i==null&&(i=Math.floor((e+31)/32)),this.rowSize=i,s==null&&(this.bits=new Int32Array(this.rowSize*this.height))}static parseFromBooleanArray(e){const r=e.length,i=e[0].length,s=new le(i,r);for(let a=0;a<r;a++){const c=e[a];for(let d=0;d<i;d++)c[d]&&s.set(d,a)}return s}static parseFromString(e,r,i){if(e===null)throw new b("stringRepresentation cannot be null");const s=new Array(e.length);let a=0,c=0,d=-1,h=0,p=0;for(;p<e.length;)if(e.charAt(p)===`
79
- `||e.charAt(p)==="\r"){if(a>c){if(d===-1)d=a-c;else if(a-c!==d)throw new b("row lengths do not match");c=a,h++}p++}else if(e.substring(p,p+r.length)===r)p+=r.length,s[a]=!0,a++;else if(e.substring(p,p+i.length)===i)p+=i.length,s[a]=!1,a++;else throw new b("illegal character encountered: "+e.substring(p));if(a>c){if(d===-1)d=a-c;else if(a-c!==d)throw new b("row lengths do not match");h++}const w=new le(d,h);for(let v=0;v<a;v++)s[v]&&w.set(Math.floor(v%d),Math.floor(v/d));return w}get(e,r){const i=r*this.rowSize+Math.floor(e/32);return(this.bits[i]>>>(e&31)&1)!==0}set(e,r){const i=r*this.rowSize+Math.floor(e/32);this.bits[i]|=1<<(e&31)&4294967295}unset(e,r){const i=r*this.rowSize+Math.floor(e/32);this.bits[i]&=~(1<<(e&31)&4294967295)}flip(e,r){const i=r*this.rowSize+Math.floor(e/32);this.bits[i]^=1<<(e&31)&4294967295}xor(e){if(this.width!==e.getWidth()||this.height!==e.getHeight()||this.rowSize!==e.getRowSize())throw new b("input matrix dimensions do not match");const r=new K(Math.floor(this.width/32)+1),i=this.rowSize,s=this.bits;for(let a=0,c=this.height;a<c;a++){const d=a*i,h=e.getRow(a,r).getBitArray();for(let p=0;p<i;p++)s[d+p]^=h[p]}}clear(){const e=this.bits,r=e.length;for(let i=0;i<r;i++)e[i]=0}setRegion(e,r,i,s){if(r<0||e<0)throw new b("Left and top must be nonnegative");if(s<1||i<1)throw new b("Height and width must be at least 1");const a=e+i,c=r+s;if(c>this.height||a>this.width)throw new b("The region must fit inside the matrix");const d=this.rowSize,h=this.bits;for(let p=r;p<c;p++){const w=p*d;for(let v=e;v<a;v++)h[w+Math.floor(v/32)]|=1<<(v&31)&4294967295}}getRow(e,r){r==null||r.getSize()<this.width?r=new K(this.width):r.clear();const i=this.rowSize,s=this.bits,a=e*i;for(let c=0;c<i;c++)r.setBulk(c*32,s[a+c]);return r}setRow(e,r){D.arraycopy(r.getBitArray(),0,this.bits,e*this.rowSize,this.rowSize)}rotate180(){const e=this.getWidth(),r=this.getHeight();let i=new K(e),s=new K(e);for(let a=0,c=Math.floor((r+1)/2);a<c;a++)i=this.getRow(a,i),s=this.getRow(r-1-a,s),i.reverse(),s.reverse(),this.setRow(a,s),this.setRow(r-1-a,i)}getEnclosingRectangle(){const e=this.width,r=this.height,i=this.rowSize,s=this.bits;let a=e,c=r,d=-1,h=-1;for(let p=0;p<r;p++)for(let w=0;w<i;w++){const v=s[p*i+w];if(v!==0){if(p<c&&(c=p),p>h&&(h=p),w*32<a){let E=0;for(;(v<<31-E&4294967295)===0;)E++;w*32+E<a&&(a=w*32+E)}if(w*32+31>d){let E=31;for(;!(v>>>E);)E--;w*32+E>d&&(d=w*32+E)}}}return d<a||h<c?null:Int32Array.from([a,c,d-a+1,h-c+1])}getTopLeftOnBit(){const e=this.rowSize,r=this.bits;let i=0;for(;i<r.length&&r[i]===0;)i++;if(i===r.length)return null;const s=i/e;let a=i%e*32;const c=r[i];let d=0;for(;(c<<31-d&4294967295)===0;)d++;return a+=d,Int32Array.from([a,s])}getBottomRightOnBit(){const e=this.rowSize,r=this.bits;let i=r.length-1;for(;i>=0&&r[i]===0;)i--;if(i<0)return null;const s=Math.floor(i/e);let a=Math.floor(i%e)*32;const c=r[i];let d=31;for(;!(c>>>d);)d--;return a+=d,Int32Array.from([a,s])}getWidth(){return this.width}getHeight(){return this.height}getRowSize(){return this.rowSize}equals(e){if(!(e instanceof le))return!1;const r=e;return this.width===r.width&&this.height===r.height&&this.rowSize===r.rowSize&&U.equals(this.bits,r.bits)}hashCode(){let e=this.width;return e=31*e+this.width,e=31*e+this.height,e=31*e+this.rowSize,e=31*e+U.hashCode(this.bits),e}toString(e="X ",r=" ",i=`
80
- `){return this.buildToString(e,r,i)}buildToString(e,r,i){let s=new xe;for(let a=0,c=this.height;a<c;a++){for(let d=0,h=this.width;d<h;d++)s.append(this.get(d,a)?e:r);s.append(i)}return s.toString()}clone(){return new le(this.width,this.height,this.rowSize,this.bits.slice())}}class F extends x{static getNotFoundInstance(){return new F}}F.kind="NotFoundException";class J extends R{constructor(e){super(e),this.luminances=J.EMPTY,this.buckets=new Int32Array(J.LUMINANCE_BUCKETS)}getBlackRow(e,r){const i=this.getLuminanceSource(),s=i.getWidth();r==null||r.getSize()<s?r=new K(s):r.clear(),this.initArrays(s);const a=i.getRow(e,this.luminances),c=this.buckets;for(let h=0;h<s;h++)c[(a[h]&255)>>J.LUMINANCE_SHIFT]++;const d=J.estimateBlackPoint(c);if(s<3)for(let h=0;h<s;h++)(a[h]&255)<d&&r.set(h);else{let h=a[0]&255,p=a[1]&255;for(let w=1;w<s-1;w++){const v=a[w+1]&255;(p*4-h-v)/2<d&&r.set(w),h=p,p=v}}return r}getBlackMatrix(){const e=this.getLuminanceSource(),r=e.getWidth(),i=e.getHeight(),s=new le(r,i);this.initArrays(r);const a=this.buckets;for(let h=1;h<5;h++){const p=Math.floor(i*h/5),w=e.getRow(p,this.luminances),v=Math.floor(r*4/5);for(let E=Math.floor(r/5);E<v;E++){const O=w[E]&255;a[O>>J.LUMINANCE_SHIFT]++}}const c=J.estimateBlackPoint(a),d=e.getMatrix();for(let h=0;h<i;h++){const p=h*r;for(let w=0;w<r;w++)(d[p+w]&255)<c&&s.set(w,h)}return s}createBinarizer(e){return new J(e)}initArrays(e){this.luminances.length<e&&(this.luminances=new Uint8ClampedArray(e));const r=this.buckets;for(let i=0;i<J.LUMINANCE_BUCKETS;i++)r[i]=0}static estimateBlackPoint(e){const r=e.length;let i=0,s=0,a=0;for(let w=0;w<r;w++)e[w]>a&&(s=w,a=e[w]),e[w]>i&&(i=e[w]);let c=0,d=0;for(let w=0;w<r;w++){const v=w-s,E=e[w]*v*v;E>d&&(c=w,d=E)}if(s>c){const w=s;s=c,c=w}if(c-s<=r/16)throw new F;let h=c-1,p=-1;for(let w=c-1;w>s;w--){const v=w-s,E=v*v*(c-w)*(i-e[w]);E>p&&(h=w,p=E)}return h<<J.LUMINANCE_SHIFT}}J.LUMINANCE_BITS=5,J.LUMINANCE_SHIFT=8-J.LUMINANCE_BITS,J.LUMINANCE_BUCKETS=1<<J.LUMINANCE_BITS,J.EMPTY=Uint8ClampedArray.from([0]);class X extends J{constructor(e){super(e),this.matrix=null}getBlackMatrix(){if(this.matrix!==null)return this.matrix;const e=this.getLuminanceSource(),r=e.getWidth(),i=e.getHeight();if(r>=X.MINIMUM_DIMENSION&&i>=X.MINIMUM_DIMENSION){const s=e.getMatrix();let a=r>>X.BLOCK_SIZE_POWER;(r&X.BLOCK_SIZE_MASK)!==0&&a++;let c=i>>X.BLOCK_SIZE_POWER;(i&X.BLOCK_SIZE_MASK)!==0&&c++;const d=X.calculateBlackPoints(s,a,c,r,i),h=new le(r,i);X.calculateThresholdForBlock(s,a,c,r,i,d,h),this.matrix=h}else this.matrix=super.getBlackMatrix();return this.matrix}createBinarizer(e){return new X(e)}static calculateThresholdForBlock(e,r,i,s,a,c,d){const h=a-X.BLOCK_SIZE,p=s-X.BLOCK_SIZE;for(let w=0;w<i;w++){let v=w<<X.BLOCK_SIZE_POWER;v>h&&(v=h);const E=X.cap(w,2,i-3);for(let O=0;O<r;O++){let L=O<<X.BLOCK_SIZE_POWER;L>p&&(L=p);const $=X.cap(O,2,r-3);let Z=0;for(let ae=-2;ae<=2;ae++){const ce=c[E+ae];Z+=ce[$-2]+ce[$-1]+ce[$]+ce[$+1]+ce[$+2]}const G=Z/25;X.thresholdBlock(e,L,v,G,s,d)}}}static cap(e,r,i){return e<r?r:e>i?i:e}static thresholdBlock(e,r,i,s,a,c){for(let d=0,h=i*a+r;d<X.BLOCK_SIZE;d++,h+=a)for(let p=0;p<X.BLOCK_SIZE;p++)(e[h+p]&255)<=s&&c.set(r+p,i+d)}static calculateBlackPoints(e,r,i,s,a){const c=a-X.BLOCK_SIZE,d=s-X.BLOCK_SIZE,h=new Array(i);for(let p=0;p<i;p++){h[p]=new Int32Array(r);let w=p<<X.BLOCK_SIZE_POWER;w>c&&(w=c);for(let v=0;v<r;v++){let E=v<<X.BLOCK_SIZE_POWER;E>d&&(E=d);let O=0,L=255,$=0;for(let G=0,ae=w*s+E;G<X.BLOCK_SIZE;G++,ae+=s){for(let ce=0;ce<X.BLOCK_SIZE;ce++){const oe=e[ae+ce]&255;O+=oe,oe<L&&(L=oe),oe>$&&($=oe)}if($-L>X.MIN_DYNAMIC_RANGE)for(G++,ae+=s;G<X.BLOCK_SIZE;G++,ae+=s)for(let ce=0;ce<X.BLOCK_SIZE;ce++)O+=e[ae+ce]&255}let Z=O>>X.BLOCK_SIZE_POWER*2;if($-L<=X.MIN_DYNAMIC_RANGE&&(Z=L/2,p>0&&v>0)){const G=(h[p-1][v]+2*h[p][v-1]+h[p-1][v-1])/4;L<G&&(Z=G)}h[p][v]=Z}}return h}}X.BLOCK_SIZE_POWER=3,X.BLOCK_SIZE=1<<X.BLOCK_SIZE_POWER,X.BLOCK_SIZE_MASK=X.BLOCK_SIZE-1,X.MINIMUM_DIMENSION=X.BLOCK_SIZE*5,X.MIN_DYNAMIC_RANGE=24;class te{constructor(e,r){this.width=e,this.height=r}getWidth(){return this.width}getHeight(){return this.height}isCropSupported(){return!1}crop(e,r,i,s){throw new Ie("This luminance source does not support cropping.")}isRotateSupported(){return!1}rotateCounterClockwise(){throw new Ie("This luminance source does not support rotation by 90 degrees.")}rotateCounterClockwise45(){throw new Ie("This luminance source does not support rotation by 45 degrees.")}toString(){const e=new Uint8ClampedArray(this.width);let r=new xe;for(let i=0;i<this.height;i++){const s=this.getRow(i,e);for(let a=0;a<this.width;a++){const c=s[a]&255;let d;c<64?d="#":c<128?d="+":c<192?d=".":d=" ",r.append(d)}r.append(`
81
- `)}return r.toString()}}class pe extends te{constructor(e){super(e.getWidth(),e.getHeight()),this.delegate=e}getRow(e,r){const i=this.delegate.getRow(e,r),s=this.getWidth();for(let a=0;a<s;a++)i[a]=255-(i[a]&255);return i}getMatrix(){const e=this.delegate.getMatrix(),r=this.getWidth()*this.getHeight(),i=new Uint8ClampedArray(r);for(let s=0;s<r;s++)i[s]=255-(e[s]&255);return i}isCropSupported(){return this.delegate.isCropSupported()}crop(e,r,i,s){return new pe(this.delegate.crop(e,r,i,s))}isRotateSupported(){return this.delegate.isRotateSupported()}invert(){return this.delegate}rotateCounterClockwise(){return new pe(this.delegate.rotateCounterClockwise())}rotateCounterClockwise45(){return new pe(this.delegate.rotateCounterClockwise45())}}class ge extends te{constructor(e){super(e.width,e.height),this.canvas=e,this.tempCanvasElement=null,this.buffer=ge.makeBufferFromCanvasImageData(e)}static makeBufferFromCanvasImageData(e){const r=e.getContext("2d").getImageData(0,0,e.width,e.height);return ge.toGrayscaleBuffer(r.data,e.width,e.height)}static toGrayscaleBuffer(e,r,i){const s=new Uint8ClampedArray(r*i);for(let a=0,c=0,d=e.length;a<d;a+=4,c++){let h;if(e[a+3]===0)h=255;else{const w=e[a],v=e[a+1],E=e[a+2];h=306*w+601*v+117*E+512>>10}s[c]=h}return s}getRow(e,r){if(e<0||e>=this.getHeight())throw new b("Requested row is outside the image: "+e);const i=this.getWidth(),s=e*i;return r===null?r=this.buffer.slice(s,s+i):(r.length<i&&(r=new Uint8ClampedArray(i)),r.set(this.buffer.slice(s,s+i))),r}getMatrix(){return this.buffer}isCropSupported(){return!0}crop(e,r,i,s){return super.crop(e,r,i,s),this}isRotateSupported(){return!0}rotateCounterClockwise(){return this.rotate(-90),this}rotateCounterClockwise45(){return this.rotate(-45),this}getTempCanvasElement(){if(this.tempCanvasElement===null){const e=this.canvas.ownerDocument.createElement("canvas");e.width=this.canvas.width,e.height=this.canvas.height,this.tempCanvasElement=e}return this.tempCanvasElement}rotate(e){const r=this.getTempCanvasElement(),i=r.getContext("2d"),s=e*ge.DEGREE_TO_RADIANS,a=this.canvas.width,c=this.canvas.height,d=Math.ceil(Math.abs(Math.cos(s))*a+Math.abs(Math.sin(s))*c),h=Math.ceil(Math.abs(Math.sin(s))*a+Math.abs(Math.cos(s))*c);return r.width=d,r.height=h,i.translate(d/2,h/2),i.rotate(s),i.drawImage(this.canvas,a/-2,c/-2),this.buffer=ge.makeBufferFromCanvasImageData(r),this}invert(){return new pe(this)}}ge.DEGREE_TO_RADIANS=Math.PI/180;class ye{constructor(e,r,i){this.deviceId=e,this.label=r,this.kind="videoinput",this.groupId=i||void 0}toJSON(){return{kind:this.kind,groupId:this.groupId,deviceId:this.deviceId,label:this.label}}}var we=(globalThis||Si||self||window||void 0)&&(globalThis||Si||self||window||void 0).__awaiter||function(_,e,r,i){function s(a){return a instanceof r?a:new r(function(c){c(a)})}return new(r||(r=Promise))(function(a,c){function d(w){try{p(i.next(w))}catch(v){c(v)}}function h(w){try{p(i.throw(w))}catch(v){c(v)}}function p(w){w.done?a(w.value):s(w.value).then(d,h)}p((i=i.apply(_,e||[])).next())})};class Fe{constructor(e,r=500,i){this.reader=e,this.timeBetweenScansMillis=r,this._hints=i,this._stopContinuousDecode=!1,this._stopAsyncDecode=!1,this._timeBetweenDecodingAttempts=0}get hasNavigator(){return typeof navigator<"u"}get isMediaDevicesSuported(){return this.hasNavigator&&!!navigator.mediaDevices}get canEnumerateDevices(){return!!(this.isMediaDevicesSuported&&navigator.mediaDevices.enumerateDevices)}get timeBetweenDecodingAttempts(){return this._timeBetweenDecodingAttempts}set timeBetweenDecodingAttempts(e){this._timeBetweenDecodingAttempts=e<0?0:e}set hints(e){this._hints=e||null}get hints(){return this._hints}listVideoInputDevices(){return we(this,void 0,void 0,function*(){if(!this.hasNavigator)throw new Error("Can't enumerate devices, navigator is not present.");if(!this.canEnumerateDevices)throw new Error("Can't enumerate devices, method not supported.");const e=yield navigator.mediaDevices.enumerateDevices(),r=[];for(const i of e){const s=i.kind==="video"?"videoinput":i.kind;if(s!=="videoinput")continue;const a=i.deviceId||i.id,c=i.label||`Video device ${r.length+1}`,d=i.groupId,h={deviceId:a,label:c,kind:s,groupId:d};r.push(h)}return r})}getVideoInputDevices(){return we(this,void 0,void 0,function*(){return(yield this.listVideoInputDevices()).map(r=>new ye(r.deviceId,r.label))})}findDeviceById(e){return we(this,void 0,void 0,function*(){const r=yield this.listVideoInputDevices();return r?r.find(i=>i.deviceId===e):null})}decodeFromInputVideoDevice(e,r){return we(this,void 0,void 0,function*(){return yield this.decodeOnceFromVideoDevice(e,r)})}decodeOnceFromVideoDevice(e,r){return we(this,void 0,void 0,function*(){this.reset();let i;e?i={deviceId:{exact:e}}:i={facingMode:"environment"};const s={video:i};return yield this.decodeOnceFromConstraints(s,r)})}decodeOnceFromConstraints(e,r){return we(this,void 0,void 0,function*(){const i=yield navigator.mediaDevices.getUserMedia(e);return yield this.decodeOnceFromStream(i,r)})}decodeOnceFromStream(e,r){return we(this,void 0,void 0,function*(){this.reset();const i=yield this.attachStreamToVideo(e,r);return yield this.decodeOnce(i)})}decodeFromInputVideoDeviceContinuously(e,r,i){return we(this,void 0,void 0,function*(){return yield this.decodeFromVideoDevice(e,r,i)})}decodeFromVideoDevice(e,r,i){return we(this,void 0,void 0,function*(){let s;e?s={deviceId:{exact:e}}:s={facingMode:"environment"};const a={video:s};return yield this.decodeFromConstraints(a,r,i)})}decodeFromConstraints(e,r,i){return we(this,void 0,void 0,function*(){const s=yield navigator.mediaDevices.getUserMedia(e);return yield this.decodeFromStream(s,r,i)})}decodeFromStream(e,r,i){return we(this,void 0,void 0,function*(){this.reset();const s=yield this.attachStreamToVideo(e,r);return yield this.decodeContinuously(s,i)})}stopAsyncDecode(){this._stopAsyncDecode=!0}stopContinuousDecode(){this._stopContinuousDecode=!0}attachStreamToVideo(e,r){return we(this,void 0,void 0,function*(){const i=this.prepareVideoElement(r);return this.addVideoSource(i,e),this.videoElement=i,this.stream=e,yield this.playVideoOnLoadAsync(i),i})}playVideoOnLoadAsync(e){return new Promise((r,i)=>this.playVideoOnLoad(e,()=>r()))}playVideoOnLoad(e,r){this.videoEndedListener=()=>this.stopStreams(),this.videoCanPlayListener=()=>this.tryPlayVideo(e),e.addEventListener("ended",this.videoEndedListener),e.addEventListener("canplay",this.videoCanPlayListener),e.addEventListener("playing",r),this.tryPlayVideo(e)}isVideoPlaying(e){return e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>2}tryPlayVideo(e){return we(this,void 0,void 0,function*(){if(this.isVideoPlaying(e)){console.warn("Trying to play video that is already playing.");return}try{yield e.play()}catch{console.warn("It was not possible to play the video.")}})}getMediaElement(e,r){const i=document.getElementById(e);if(!i)throw new A(`element with id '${e}' not found`);if(i.nodeName.toLowerCase()!==r.toLowerCase())throw new A(`element with id '${e}' must be an ${r} element`);return i}decodeFromImage(e,r){if(!e&&!r)throw new A("either imageElement with a src set or an url must be provided");return r&&!e?this.decodeFromImageUrl(r):this.decodeFromImageElement(e)}decodeFromVideo(e,r){if(!e&&!r)throw new A("Either an element with a src set or an URL must be provided");return r&&!e?this.decodeFromVideoUrl(r):this.decodeFromVideoElement(e)}decodeFromVideoContinuously(e,r,i){if(e===void 0&&r===void 0)throw new A("Either an element with a src set or an URL must be provided");return r&&!e?this.decodeFromVideoUrlContinuously(r,i):this.decodeFromVideoElementContinuously(e,i)}decodeFromImageElement(e){if(!e)throw new A("An image element must be provided.");this.reset();const r=this.prepareImageElement(e);this.imageElement=r;let i;return this.isImageLoaded(r)?i=this.decodeOnce(r,!1,!0):i=this._decodeOnLoadImage(r),i}decodeFromVideoElement(e){const r=this._decodeFromVideoElementSetup(e);return this._decodeOnLoadVideo(r)}decodeFromVideoElementContinuously(e,r){const i=this._decodeFromVideoElementSetup(e);return this._decodeOnLoadVideoContinuously(i,r)}_decodeFromVideoElementSetup(e){if(!e)throw new A("A video element must be provided.");this.reset();const r=this.prepareVideoElement(e);return this.videoElement=r,r}decodeFromImageUrl(e){if(!e)throw new A("An URL must be provided.");this.reset();const r=this.prepareImageElement();this.imageElement=r;const i=this._decodeOnLoadImage(r);return r.src=e,i}decodeFromVideoUrl(e){if(!e)throw new A("An URL must be provided.");this.reset();const r=this.prepareVideoElement(),i=this.decodeFromVideoElement(r);return r.src=e,i}decodeFromVideoUrlContinuously(e,r){if(!e)throw new A("An URL must be provided.");this.reset();const i=this.prepareVideoElement(),s=this.decodeFromVideoElementContinuously(i,r);return i.src=e,s}_decodeOnLoadImage(e){return new Promise((r,i)=>{this.imageLoadedListener=()=>this.decodeOnce(e,!1,!0).then(r,i),e.addEventListener("load",this.imageLoadedListener)})}_decodeOnLoadVideo(e){return we(this,void 0,void 0,function*(){return yield this.playVideoOnLoadAsync(e),yield this.decodeOnce(e)})}_decodeOnLoadVideoContinuously(e,r){return we(this,void 0,void 0,function*(){yield this.playVideoOnLoadAsync(e),this.decodeContinuously(e,r)})}isImageLoaded(e){return!(!e.complete||e.naturalWidth===0)}prepareImageElement(e){let r;return typeof e>"u"&&(r=document.createElement("img"),r.width=200,r.height=200),typeof e=="string"&&(r=this.getMediaElement(e,"img")),e instanceof HTMLImageElement&&(r=e),r}prepareVideoElement(e){let r;return!e&&typeof document<"u"&&(r=document.createElement("video"),r.width=200,r.height=200),typeof e=="string"&&(r=this.getMediaElement(e,"video")),e instanceof HTMLVideoElement&&(r=e),r.setAttribute("autoplay","true"),r.setAttribute("muted","true"),r.setAttribute("playsinline","true"),r}decodeOnce(e,r=!0,i=!0){this._stopAsyncDecode=!1;const s=(a,c)=>{if(this._stopAsyncDecode){c(new F("Video stream has ended before any code could be detected.")),this._stopAsyncDecode=void 0;return}try{const d=this.decode(e);a(d)}catch(d){const h=r&&d instanceof F,w=(d instanceof N||d instanceof j)&&i;if(h||w)return setTimeout(s,this._timeBetweenDecodingAttempts,a,c);c(d)}};return new Promise((a,c)=>s(a,c))}decodeContinuously(e,r){this._stopContinuousDecode=!1;const i=()=>{if(this._stopContinuousDecode){this._stopContinuousDecode=void 0;return}try{const s=this.decode(e);r(s,null),setTimeout(i,this.timeBetweenScansMillis)}catch(s){r(null,s);const a=s instanceof N||s instanceof j,c=s instanceof F;(a||c)&&setTimeout(i,this._timeBetweenDecodingAttempts)}};i()}decode(e){const r=this.createBinaryBitmap(e);return this.decodeBitmap(r)}_isHTMLVideoElement(e){return e.videoWidth!==0}drawFrameOnCanvas(e,r,i){r||(r={sx:0,sy:0,sWidth:e.videoWidth,sHeight:e.videoHeight,dx:0,dy:0,dWidth:e.videoWidth,dHeight:e.videoHeight}),i||(i=this.captureCanvasContext),i.drawImage(e,r.sx,r.sy,r.sWidth,r.sHeight,r.dx,r.dy,r.dWidth,r.dHeight)}drawImageOnCanvas(e,r,i=this.captureCanvasContext){r||(r={sx:0,sy:0,sWidth:e.naturalWidth,sHeight:e.naturalHeight,dx:0,dy:0,dWidth:e.naturalWidth,dHeight:e.naturalHeight}),i||(i=this.captureCanvasContext),i.drawImage(e,r.sx,r.sy,r.sWidth,r.sHeight,r.dx,r.dy,r.dWidth,r.dHeight)}createBinaryBitmap(e){this.getCaptureCanvasContext(e),this._isHTMLVideoElement(e)?this.drawFrameOnCanvas(e):this.drawImageOnCanvas(e);const r=this.getCaptureCanvas(e),i=new ge(r),s=new X(i);return new P(s)}getCaptureCanvasContext(e){if(!this.captureCanvasContext){const i=this.getCaptureCanvas(e).getContext("2d");this.captureCanvasContext=i}return this.captureCanvasContext}getCaptureCanvas(e){if(!this.captureCanvas){const r=this.createCaptureCanvas(e);this.captureCanvas=r}return this.captureCanvas}decodeBitmap(e){return this.reader.decode(e,this._hints)}createCaptureCanvas(e){if(typeof document>"u")return this._destroyCaptureCanvas(),null;const r=document.createElement("canvas");let i,s;return typeof e<"u"&&(e instanceof HTMLVideoElement?(i=e.videoWidth,s=e.videoHeight):e instanceof HTMLImageElement&&(i=e.naturalWidth||e.width,s=e.naturalHeight||e.height)),r.style.width=i+"px",r.style.height=s+"px",r.width=i,r.height=s,r}stopStreams(){this.stream&&(this.stream.getVideoTracks().forEach(e=>e.stop()),this.stream=void 0),this._stopAsyncDecode===!1&&this.stopAsyncDecode(),this._stopContinuousDecode===!1&&this.stopContinuousDecode()}reset(){this.stopStreams(),this._destroyVideoElement(),this._destroyImageElement(),this._destroyCaptureCanvas()}_destroyVideoElement(){this.videoElement&&(typeof this.videoEndedListener<"u"&&this.videoElement.removeEventListener("ended",this.videoEndedListener),typeof this.videoPlayingEventListener<"u"&&this.videoElement.removeEventListener("playing",this.videoPlayingEventListener),typeof this.videoCanPlayListener<"u"&&this.videoElement.removeEventListener("loadedmetadata",this.videoCanPlayListener),this.cleanVideoSource(this.videoElement),this.videoElement=void 0)}_destroyImageElement(){this.imageElement&&(this.imageLoadedListener!==void 0&&this.imageElement.removeEventListener("load",this.imageLoadedListener),this.imageElement.src=void 0,this.imageElement.removeAttribute("src"),this.imageElement=void 0)}_destroyCaptureCanvas(){this.captureCanvasContext=void 0,this.captureCanvas=void 0}addVideoSource(e,r){try{e.srcObject=r}catch{e.src=URL.createObjectURL(r)}}cleanVideoSource(e){try{e.srcObject=null}catch{e.src=""}this.videoElement.removeAttribute("src")}}class Pe{constructor(e,r,i=r==null?0:8*r.length,s,a,c=D.currentTimeMillis()){this.text=e,this.rawBytes=r,this.numBits=i,this.resultPoints=s,this.format=a,this.timestamp=c,this.text=e,this.rawBytes=r,i==null?this.numBits=r==null?0:8*r.length:this.numBits=i,this.resultPoints=s,this.format=a,this.resultMetadata=null,c==null?this.timestamp=D.currentTimeMillis():this.timestamp=c}getText(){return this.text}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}getResultPoints(){return this.resultPoints}getBarcodeFormat(){return this.format}getResultMetadata(){return this.resultMetadata}putMetadata(e,r){this.resultMetadata===null&&(this.resultMetadata=new Map),this.resultMetadata.set(e,r)}putAllMetadata(e){e!==null&&(this.resultMetadata===null?this.resultMetadata=e:this.resultMetadata=new Map(e))}addResultPoints(e){const r=this.resultPoints;if(r===null)this.resultPoints=e;else if(e!==null&&e.length>0){const i=new Array(r.length+e.length);D.arraycopy(r,0,i,0,r.length),D.arraycopy(e,0,i,r.length,e.length),this.resultPoints=i}}getTimestamp(){return this.timestamp}toString(){return this.text}}var ne;(function(_){_[_.AZTEC=0]="AZTEC",_[_.CODABAR=1]="CODABAR",_[_.CODE_39=2]="CODE_39",_[_.CODE_93=3]="CODE_93",_[_.CODE_128=4]="CODE_128",_[_.DATA_MATRIX=5]="DATA_MATRIX",_[_.EAN_8=6]="EAN_8",_[_.EAN_13=7]="EAN_13",_[_.ITF=8]="ITF",_[_.MAXICODE=9]="MAXICODE",_[_.PDF_417=10]="PDF_417",_[_.QR_CODE=11]="QR_CODE",_[_.RSS_14=12]="RSS_14",_[_.RSS_EXPANDED=13]="RSS_EXPANDED",_[_.UPC_A=14]="UPC_A",_[_.UPC_E=15]="UPC_E",_[_.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(ne||(ne={}));var S=ne,fe;(function(_){_[_.OTHER=0]="OTHER",_[_.ORIENTATION=1]="ORIENTATION",_[_.BYTE_SEGMENTS=2]="BYTE_SEGMENTS",_[_.ERROR_CORRECTION_LEVEL=3]="ERROR_CORRECTION_LEVEL",_[_.ISSUE_NUMBER=4]="ISSUE_NUMBER",_[_.SUGGESTED_PRICE=5]="SUGGESTED_PRICE",_[_.POSSIBLE_COUNTRY=6]="POSSIBLE_COUNTRY",_[_.UPC_EAN_EXTENSION=7]="UPC_EAN_EXTENSION",_[_.PDF417_EXTRA_METADATA=8]="PDF417_EXTRA_METADATA",_[_.STRUCTURED_APPEND_SEQUENCE=9]="STRUCTURED_APPEND_SEQUENCE",_[_.STRUCTURED_APPEND_PARITY=10]="STRUCTURED_APPEND_PARITY"})(fe||(fe={}));var se=fe;class Le{constructor(e,r,i,s,a=-1,c=-1){this.rawBytes=e,this.text=r,this.byteSegments=i,this.ecLevel=s,this.structuredAppendSequenceNumber=a,this.structuredAppendParity=c,this.numBits=e==null?0:8*e.length}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}setNumBits(e){this.numBits=e}getText(){return this.text}getByteSegments(){return this.byteSegments}getECLevel(){return this.ecLevel}getErrorsCorrected(){return this.errorsCorrected}setErrorsCorrected(e){this.errorsCorrected=e}getErasures(){return this.erasures}setErasures(e){this.erasures=e}getOther(){return this.other}setOther(e){this.other=e}hasStructuredAppend(){return this.structuredAppendParity>=0&&this.structuredAppendSequenceNumber>=0}getStructuredAppendParity(){return this.structuredAppendParity}getStructuredAppendSequenceNumber(){return this.structuredAppendSequenceNumber}}class $e{exp(e){return this.expTable[e]}log(e){if(e===0)throw new b;return this.logTable[e]}static addOrSubtract(e,r){return e^r}}class Xe{constructor(e,r){if(r.length===0)throw new b;this.field=e;const i=r.length;if(i>1&&r[0]===0){let s=1;for(;s<i&&r[s]===0;)s++;s===i?this.coefficients=Int32Array.from([0]):(this.coefficients=new Int32Array(i-s),D.arraycopy(r,s,this.coefficients,0,this.coefficients.length))}else this.coefficients=r}getCoefficients(){return this.coefficients}getDegree(){return this.coefficients.length-1}isZero(){return this.coefficients[0]===0}getCoefficient(e){return this.coefficients[this.coefficients.length-1-e]}evaluateAt(e){if(e===0)return this.getCoefficient(0);const r=this.coefficients;let i;if(e===1){i=0;for(let c=0,d=r.length;c!==d;c++){const h=r[c];i=$e.addOrSubtract(i,h)}return i}i=r[0];const s=r.length,a=this.field;for(let c=1;c<s;c++)i=$e.addOrSubtract(a.multiply(e,i),r[c]);return i}addOrSubtract(e){if(!this.field.equals(e.field))throw new b("GenericGFPolys do not have same GenericGF field");if(this.isZero())return e;if(e.isZero())return this;let r=this.coefficients,i=e.coefficients;if(r.length>i.length){const c=r;r=i,i=c}let s=new Int32Array(i.length);const a=i.length-r.length;D.arraycopy(i,0,s,0,a);for(let c=a;c<i.length;c++)s[c]=$e.addOrSubtract(r[c-a],i[c]);return new Xe(this.field,s)}multiply(e){if(!this.field.equals(e.field))throw new b("GenericGFPolys do not have same GenericGF field");if(this.isZero()||e.isZero())return this.field.getZero();const r=this.coefficients,i=r.length,s=e.coefficients,a=s.length,c=new Int32Array(i+a-1),d=this.field;for(let h=0;h<i;h++){const p=r[h];for(let w=0;w<a;w++)c[h+w]=$e.addOrSubtract(c[h+w],d.multiply(p,s[w]))}return new Xe(d,c)}multiplyScalar(e){if(e===0)return this.field.getZero();if(e===1)return this;const r=this.coefficients.length,i=this.field,s=new Int32Array(r),a=this.coefficients;for(let c=0;c<r;c++)s[c]=i.multiply(a[c],e);return new Xe(i,s)}multiplyByMonomial(e,r){if(e<0)throw new b;if(r===0)return this.field.getZero();const i=this.coefficients,s=i.length,a=new Int32Array(s+e),c=this.field;for(let d=0;d<s;d++)a[d]=c.multiply(i[d],r);return new Xe(c,a)}divide(e){if(!this.field.equals(e.field))throw new b("GenericGFPolys do not have same GenericGF field");if(e.isZero())throw new b("Divide by 0");const r=this.field;let i=r.getZero(),s=this;const a=e.getCoefficient(e.getDegree()),c=r.inverse(a);for(;s.getDegree()>=e.getDegree()&&!s.isZero();){const d=s.getDegree()-e.getDegree(),h=r.multiply(s.getCoefficient(s.getDegree()),c),p=e.multiplyByMonomial(d,h),w=r.buildMonomial(d,h);i=i.addOrSubtract(w),s=s.addOrSubtract(p)}return[i,s]}toString(){let e="";for(let r=this.getDegree();r>=0;r--){let i=this.getCoefficient(r);if(i!==0){if(i<0?(e+=" - ",i=-i):e.length>0&&(e+=" + "),r===0||i!==1){const s=this.field.log(i);s===0?e+="1":s===1?e+="a":(e+="a^",e+=s)}r!==0&&(r===1?e+="x":(e+="x^",e+=r))}}return e}}class qt extends x{}qt.kind="ArithmeticException";class je extends $e{constructor(e,r,i){super(),this.primitive=e,this.size=r,this.generatorBase=i;const s=new Int32Array(r);let a=1;for(let d=0;d<r;d++)s[d]=a,a*=2,a>=r&&(a^=e,a&=r-1);this.expTable=s;const c=new Int32Array(r);for(let d=0;d<r-1;d++)c[s[d]]=d;this.logTable=c,this.zero=new Xe(this,Int32Array.from([0])),this.one=new Xe(this,Int32Array.from([1]))}getZero(){return this.zero}getOne(){return this.one}buildMonomial(e,r){if(e<0)throw new b;if(r===0)return this.zero;const i=new Int32Array(e+1);return i[0]=r,new Xe(this,i)}inverse(e){if(e===0)throw new qt;return this.expTable[this.size-this.logTable[e]-1]}multiply(e,r){return e===0||r===0?0:this.expTable[(this.logTable[e]+this.logTable[r])%(this.size-1)]}getSize(){return this.size}getGeneratorBase(){return this.generatorBase}toString(){return"GF(0x"+k.toHexString(this.primitive)+","+this.size+")"}equals(e){return e===this}}je.AZTEC_DATA_12=new je(4201,4096,1),je.AZTEC_DATA_10=new je(1033,1024,1),je.AZTEC_DATA_6=new je(67,64,1),je.AZTEC_PARAM=new je(19,16,1),je.QR_CODE_FIELD_256=new je(285,256,0),je.DATA_MATRIX_FIELD_256=new je(301,256,1),je.AZTEC_DATA_8=je.DATA_MATRIX_FIELD_256,je.MAXICODE_FIELD_64=je.AZTEC_DATA_6;class be extends x{}be.kind="ReedSolomonException";class ue extends x{}ue.kind="IllegalStateException";class De{constructor(e){this.field=e}decode(e,r){const i=this.field,s=new Xe(i,e),a=new Int32Array(r);let c=!0;for(let O=0;O<r;O++){const L=s.evaluateAt(i.exp(O+i.getGeneratorBase()));a[a.length-1-O]=L,L!==0&&(c=!1)}if(c)return;const d=new Xe(i,a),h=this.runEuclideanAlgorithm(i.buildMonomial(r,1),d,r),p=h[0],w=h[1],v=this.findErrorLocations(p),E=this.findErrorMagnitudes(w,v);for(let O=0;O<v.length;O++){const L=e.length-1-i.log(v[O]);if(L<0)throw new be("Bad error location");e[L]=je.addOrSubtract(e[L],E[O])}}runEuclideanAlgorithm(e,r,i){if(e.getDegree()<r.getDegree()){const O=e;e=r,r=O}const s=this.field;let a=e,c=r,d=s.getZero(),h=s.getOne();for(;c.getDegree()>=(i/2|0);){let O=a,L=d;if(a=c,d=h,a.isZero())throw new be("r_{i-1} was zero");c=O;let $=s.getZero();const Z=a.getCoefficient(a.getDegree()),G=s.inverse(Z);for(;c.getDegree()>=a.getDegree()&&!c.isZero();){const ae=c.getDegree()-a.getDegree(),ce=s.multiply(c.getCoefficient(c.getDegree()),G);$=$.addOrSubtract(s.buildMonomial(ae,ce)),c=c.addOrSubtract(a.multiplyByMonomial(ae,ce))}if(h=$.multiply(d).addOrSubtract(L),c.getDegree()>=a.getDegree())throw new ue("Division algorithm failed to reduce polynomial?")}const p=h.getCoefficient(0);if(p===0)throw new be("sigmaTilde(0) was zero");const w=s.inverse(p),v=h.multiplyScalar(w),E=c.multiplyScalar(w);return[v,E]}findErrorLocations(e){const r=e.getDegree();if(r===1)return Int32Array.from([e.getCoefficient(1)]);const i=new Int32Array(r);let s=0;const a=this.field;for(let c=1;c<a.getSize()&&s<r;c++)e.evaluateAt(c)===0&&(i[s]=a.inverse(c),s++);if(s!==r)throw new be("Error locator degree does not match number of roots");return i}findErrorMagnitudes(e,r){const i=r.length,s=new Int32Array(i),a=this.field;for(let c=0;c<i;c++){const d=a.inverse(r[c]);let h=1;for(let p=0;p<i;p++)if(c!==p){const w=a.multiply(r[p],d),v=(w&1)===0?w|1:w&-2;h=a.multiply(h,v)}s[c]=a.multiply(e.evaluateAt(d),a.inverse(h)),a.getGeneratorBase()!==0&&(s[c]=a.multiply(s[c],d))}return s}}var Ue;(function(_){_[_.UPPER=0]="UPPER",_[_.LOWER=1]="LOWER",_[_.MIXED=2]="MIXED",_[_.DIGIT=3]="DIGIT",_[_.PUNCT=4]="PUNCT",_[_.BINARY=5]="BINARY"})(Ue||(Ue={}));class Oe{decode(e){this.ddata=e;let r=e.getBits(),i=this.extractBits(r),s=this.correctBits(i),a=Oe.convertBoolArrayToByteArray(s),c=Oe.getEncodedData(s),d=new Le(a,c,null,null);return d.setNumBits(s.length),d}static highLevelDecode(e){return this.getEncodedData(e)}static getEncodedData(e){let r=e.length,i=Ue.UPPER,s=Ue.UPPER,a="",c=0;for(;c<r;)if(s===Ue.BINARY){if(r-c<5)break;let d=Oe.readCode(e,c,5);if(c+=5,d===0){if(r-c<11)break;d=Oe.readCode(e,c,11)+31,c+=11}for(let h=0;h<d;h++){if(r-c<8){c=r;break}const p=Oe.readCode(e,c,8);a+=he.castAsNonUtf8Char(p),c+=8}s=i}else{let d=s===Ue.DIGIT?4:5;if(r-c<d)break;let h=Oe.readCode(e,c,d);c+=d;let p=Oe.getCharacter(s,h);p.startsWith("CTRL_")?(i=s,s=Oe.getTable(p.charAt(5)),p.charAt(6)==="L"&&(i=s)):(a+=p,s=i)}return a}static getTable(e){switch(e){case"L":return Ue.LOWER;case"P":return Ue.PUNCT;case"M":return Ue.MIXED;case"D":return Ue.DIGIT;case"B":return Ue.BINARY;case"U":default:return Ue.UPPER}}static getCharacter(e,r){switch(e){case Ue.UPPER:return Oe.UPPER_TABLE[r];case Ue.LOWER:return Oe.LOWER_TABLE[r];case Ue.MIXED:return Oe.MIXED_TABLE[r];case Ue.PUNCT:return Oe.PUNCT_TABLE[r];case Ue.DIGIT:return Oe.DIGIT_TABLE[r];default:throw new ue("Bad table")}}correctBits(e){let r,i;this.ddata.getNbLayers()<=2?(i=6,r=je.AZTEC_DATA_6):this.ddata.getNbLayers()<=8?(i=8,r=je.AZTEC_DATA_8):this.ddata.getNbLayers()<=22?(i=10,r=je.AZTEC_DATA_10):(i=12,r=je.AZTEC_DATA_12);let s=this.ddata.getNbDatablocks(),a=e.length/i;if(a<s)throw new j;let c=e.length%i,d=new Int32Array(a);for(let E=0;E<a;E++,c+=i)d[E]=Oe.readCode(e,c,i);try{new De(r).decode(d,a-s)}catch(E){throw new j(E)}let h=(1<<i)-1,p=0;for(let E=0;E<s;E++){let O=d[E];if(O===0||O===h)throw new j;(O===1||O===h-1)&&p++}let w=new Array(s*i-p),v=0;for(let E=0;E<s;E++){let O=d[E];if(O===1||O===h-1)w.fill(O>1,v,v+i-1),v+=i-1;else for(let L=i-1;L>=0;--L)w[v++]=(O&1<<L)!==0}return w}extractBits(e){let r=this.ddata.isCompact(),i=this.ddata.getNbLayers(),s=(r?11:14)+i*4,a=new Int32Array(s),c=new Array(this.totalBitsInLayer(i,r));if(r)for(let d=0;d<a.length;d++)a[d]=d;else{let d=s+1+2*k.truncDivision(k.truncDivision(s,2)-1,15),h=s/2,p=k.truncDivision(d,2);for(let w=0;w<h;w++){let v=w+k.truncDivision(w,15);a[h-w-1]=p-v-1,a[h+w]=p+v+1}}for(let d=0,h=0;d<i;d++){let p=(i-d)*4+(r?9:12),w=d*2,v=s-1-w;for(let E=0;E<p;E++){let O=E*2;for(let L=0;L<2;L++)c[h+O+L]=e.get(a[w+L],a[w+E]),c[h+2*p+O+L]=e.get(a[w+E],a[v-L]),c[h+4*p+O+L]=e.get(a[v-L],a[v-E]),c[h+6*p+O+L]=e.get(a[v-E],a[w+L])}h+=p*8}return c}static readCode(e,r,i){let s=0;for(let a=r;a<r+i;a++)s<<=1,e[a]&&(s|=1);return s}static readByte(e,r){let i=e.length-r;return i>=8?Oe.readCode(e,r,8):Oe.readCode(e,r,i)<<8-i}static convertBoolArrayToByteArray(e){let r=new Uint8Array((e.length+7)/8);for(let i=0;i<r.length;i++)r[i]=Oe.readByte(e,8*i);return r}totalBitsInLayer(e,r){return((r?88:112)+16*e)*e}}Oe.UPPER_TABLE=["CTRL_PS"," ","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","CTRL_LL","CTRL_ML","CTRL_DL","CTRL_BS"],Oe.LOWER_TABLE=["CTRL_PS"," ","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","CTRL_US","CTRL_ML","CTRL_DL","CTRL_BS"],Oe.MIXED_TABLE=["CTRL_PS"," ","\\1","\\2","\\3","\\4","\\5","\\6","\\7","\b"," ",`
82
- `,"\\13","\f","\r","\\33","\\34","\\35","\\36","\\37","@","\\","^","_","`","|","~","\\177","CTRL_LL","CTRL_UL","CTRL_PL","CTRL_BS"],Oe.PUNCT_TABLE=["","\r",`\r
83
- `,". ",", ",": ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","[","]","{","}","CTRL_UL"],Oe.DIGIT_TABLE=["CTRL_PS"," ","0","1","2","3","4","5","6","7","8","9",",",".","CTRL_UL","CTRL_US"];class ke{constructor(){}static round(e){return e===NaN?0:e<=Number.MIN_SAFE_INTEGER?Number.MIN_SAFE_INTEGER:e>=Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:e+(e<0?-.5:.5)|0}static distance(e,r,i,s){const a=e-i,c=r-s;return Math.sqrt(a*a+c*c)}static sum(e){let r=0;for(let i=0,s=e.length;i!==s;i++){const a=e[i];r+=a}return r}}class cn{static floatToIntBits(e){return e}}cn.MAX_VALUE=Number.MAX_SAFE_INTEGER;class Se{constructor(e,r){this.x=e,this.y=r}getX(){return this.x}getY(){return this.y}equals(e){if(e instanceof Se){const r=e;return this.x===r.x&&this.y===r.y}return!1}hashCode(){return 31*cn.floatToIntBits(this.x)+cn.floatToIntBits(this.y)}toString(){return"("+this.x+","+this.y+")"}static orderBestPatterns(e){const r=this.distance(e[0],e[1]),i=this.distance(e[1],e[2]),s=this.distance(e[0],e[2]);let a,c,d;if(i>=r&&i>=s?(c=e[0],a=e[1],d=e[2]):s>=i&&s>=r?(c=e[1],a=e[0],d=e[2]):(c=e[2],a=e[0],d=e[1]),this.crossProductZ(a,c,d)<0){const h=a;a=d,d=h}e[0]=a,e[1]=c,e[2]=d}static distance(e,r){return ke.distance(e.x,e.y,r.x,r.y)}static crossProductZ(e,r,i){const s=r.x,a=r.y;return(i.x-s)*(e.y-a)-(i.y-a)*(e.x-s)}}class ir{constructor(e,r){this.bits=e,this.points=r}getBits(){return this.bits}getPoints(){return this.points}}class pr extends ir{constructor(e,r,i,s,a){super(e,r),this.compact=i,this.nbDatablocks=s,this.nbLayers=a}getNbLayers(){return this.nbLayers}getNbDatablocks(){return this.nbDatablocks}isCompact(){return this.compact}}class yn{constructor(e,r,i,s){this.image=e,this.height=e.getHeight(),this.width=e.getWidth(),r==null&&(r=yn.INIT_SIZE),i==null&&(i=e.getWidth()/2|0),s==null&&(s=e.getHeight()/2|0);const a=r/2|0;if(this.leftInit=i-a,this.rightInit=i+a,this.upInit=s-a,this.downInit=s+a,this.upInit<0||this.leftInit<0||this.downInit>=this.height||this.rightInit>=this.width)throw new F}detect(){let e=this.leftInit,r=this.rightInit,i=this.upInit,s=this.downInit,a=!1,c=!0,d=!1,h=!1,p=!1,w=!1,v=!1;const E=this.width,O=this.height;for(;c;){c=!1;let L=!0;for(;(L||!h)&&r<E;)L=this.containsBlackPoint(i,s,r,!1),L?(r++,c=!0,h=!0):h||r++;if(r>=E){a=!0;break}let $=!0;for(;($||!p)&&s<O;)$=this.containsBlackPoint(e,r,s,!0),$?(s++,c=!0,p=!0):p||s++;if(s>=O){a=!0;break}let Z=!0;for(;(Z||!w)&&e>=0;)Z=this.containsBlackPoint(i,s,e,!1),Z?(e--,c=!0,w=!0):w||e--;if(e<0){a=!0;break}let G=!0;for(;(G||!v)&&i>=0;)G=this.containsBlackPoint(e,r,i,!0),G?(i--,c=!0,v=!0):v||i--;if(i<0){a=!0;break}c&&(d=!0)}if(!a&&d){const L=r-e;let $=null;for(let ce=1;$===null&&ce<L;ce++)$=this.getBlackPointOnSegment(e,s-ce,e+ce,s);if($==null)throw new F;let Z=null;for(let ce=1;Z===null&&ce<L;ce++)Z=this.getBlackPointOnSegment(e,i+ce,e+ce,i);if(Z==null)throw new F;let G=null;for(let ce=1;G===null&&ce<L;ce++)G=this.getBlackPointOnSegment(r,i+ce,r-ce,i);if(G==null)throw new F;let ae=null;for(let ce=1;ae===null&&ce<L;ce++)ae=this.getBlackPointOnSegment(r,s-ce,r-ce,s);if(ae==null)throw new F;return this.centerEdges(ae,$,G,Z)}else throw new F}getBlackPointOnSegment(e,r,i,s){const a=ke.round(ke.distance(e,r,i,s)),c=(i-e)/a,d=(s-r)/a,h=this.image;for(let p=0;p<a;p++){const w=ke.round(e+p*c),v=ke.round(r+p*d);if(h.get(w,v))return new Se(w,v)}return null}centerEdges(e,r,i,s){const a=e.getX(),c=e.getY(),d=r.getX(),h=r.getY(),p=i.getX(),w=i.getY(),v=s.getX(),E=s.getY(),O=yn.CORR;return a<this.width/2?[new Se(v-O,E+O),new Se(d+O,h+O),new Se(p-O,w-O),new Se(a+O,c-O)]:[new Se(v+O,E+O),new Se(d+O,h-O),new Se(p-O,w+O),new Se(a-O,c-O)]}containsBlackPoint(e,r,i,s){const a=this.image;if(s){for(let c=e;c<=r;c++)if(a.get(c,i))return!0}else for(let c=e;c<=r;c++)if(a.get(i,c))return!0;return!1}}yn.INIT_SIZE=10,yn.CORR=1;class un{static checkAndNudgePoints(e,r){const i=e.getWidth(),s=e.getHeight();let a=!0;for(let c=0;c<r.length&&a;c+=2){const d=Math.floor(r[c]),h=Math.floor(r[c+1]);if(d<-1||d>i||h<-1||h>s)throw new F;a=!1,d===-1?(r[c]=0,a=!0):d===i&&(r[c]=i-1,a=!0),h===-1?(r[c+1]=0,a=!0):h===s&&(r[c+1]=s-1,a=!0)}a=!0;for(let c=r.length-2;c>=0&&a;c-=2){const d=Math.floor(r[c]),h=Math.floor(r[c+1]);if(d<-1||d>i||h<-1||h>s)throw new F;a=!1,d===-1?(r[c]=0,a=!0):d===i&&(r[c]=i-1,a=!0),h===-1?(r[c+1]=0,a=!0):h===s&&(r[c+1]=s-1,a=!0)}}}class Kt{constructor(e,r,i,s,a,c,d,h,p){this.a11=e,this.a21=r,this.a31=i,this.a12=s,this.a22=a,this.a32=c,this.a13=d,this.a23=h,this.a33=p}static quadrilateralToQuadrilateral(e,r,i,s,a,c,d,h,p,w,v,E,O,L,$,Z){const G=Kt.quadrilateralToSquare(e,r,i,s,a,c,d,h);return Kt.squareToQuadrilateral(p,w,v,E,O,L,$,Z).times(G)}transformPoints(e){const r=e.length,i=this.a11,s=this.a12,a=this.a13,c=this.a21,d=this.a22,h=this.a23,p=this.a31,w=this.a32,v=this.a33;for(let E=0;E<r;E+=2){const O=e[E],L=e[E+1],$=a*O+h*L+v;e[E]=(i*O+c*L+p)/$,e[E+1]=(s*O+d*L+w)/$}}transformPointsWithValues(e,r){const i=this.a11,s=this.a12,a=this.a13,c=this.a21,d=this.a22,h=this.a23,p=this.a31,w=this.a32,v=this.a33,E=e.length;for(let O=0;O<E;O++){const L=e[O],$=r[O],Z=a*L+h*$+v;e[O]=(i*L+c*$+p)/Z,r[O]=(s*L+d*$+w)/Z}}static squareToQuadrilateral(e,r,i,s,a,c,d,h){const p=e-i+a-d,w=r-s+c-h;if(p===0&&w===0)return new Kt(i-e,a-i,e,s-r,c-s,r,0,0,1);{const v=i-a,E=d-a,O=s-c,L=h-c,$=v*L-E*O,Z=(p*L-E*w)/$,G=(v*w-p*O)/$;return new Kt(i-e+Z*i,d-e+G*d,e,s-r+Z*s,h-r+G*h,r,Z,G,1)}}static quadrilateralToSquare(e,r,i,s,a,c,d,h){return Kt.squareToQuadrilateral(e,r,i,s,a,c,d,h).buildAdjoint()}buildAdjoint(){return new Kt(this.a22*this.a33-this.a23*this.a32,this.a23*this.a31-this.a21*this.a33,this.a21*this.a32-this.a22*this.a31,this.a13*this.a32-this.a12*this.a33,this.a11*this.a33-this.a13*this.a31,this.a12*this.a31-this.a11*this.a32,this.a12*this.a23-this.a13*this.a22,this.a13*this.a21-this.a11*this.a23,this.a11*this.a22-this.a12*this.a21)}times(e){return new Kt(this.a11*e.a11+this.a21*e.a12+this.a31*e.a13,this.a11*e.a21+this.a21*e.a22+this.a31*e.a23,this.a11*e.a31+this.a21*e.a32+this.a31*e.a33,this.a12*e.a11+this.a22*e.a12+this.a32*e.a13,this.a12*e.a21+this.a22*e.a22+this.a32*e.a23,this.a12*e.a31+this.a22*e.a32+this.a32*e.a33,this.a13*e.a11+this.a23*e.a12+this.a33*e.a13,this.a13*e.a21+this.a23*e.a22+this.a33*e.a23,this.a13*e.a31+this.a23*e.a32+this.a33*e.a33)}}class di extends un{sampleGrid(e,r,i,s,a,c,d,h,p,w,v,E,O,L,$,Z,G,ae,ce){const oe=Kt.quadrilateralToQuadrilateral(s,a,c,d,h,p,w,v,E,O,L,$,Z,G,ae,ce);return this.sampleGridWithTransform(e,r,i,oe)}sampleGridWithTransform(e,r,i,s){if(r<=0||i<=0)throw new F;const a=new le(r,i),c=new Float32Array(2*r);for(let d=0;d<i;d++){const h=c.length,p=d+.5;for(let w=0;w<h;w+=2)c[w]=w/2+.5,c[w+1]=p;s.transformPoints(c),un.checkAndNudgePoints(e,c);try{for(let w=0;w<h;w+=2)e.get(Math.floor(c[w]),Math.floor(c[w+1]))&&a.set(w/2,d)}catch{throw new F}}return a}}class Hn{static setGridSampler(e){Hn.gridSampler=e}static getInstance(){return Hn.gridSampler}}Hn.gridSampler=new di;class Vt{constructor(e,r){this.x=e,this.y=r}toResultPoint(){return new Se(this.getX(),this.getY())}getX(){return this.x}getY(){return this.y}}class As{constructor(e){this.EXPECTED_CORNER_BITS=new Int32Array([3808,476,2107,1799]),this.image=e}detect(){return this.detectMirror(!1)}detectMirror(e){let r=this.getMatrixCenter(),i=this.getBullsEyeCorners(r);if(e){let c=i[0];i[0]=i[2],i[2]=c}this.extractParameters(i);let s=this.sampleGrid(this.image,i[this.shift%4],i[(this.shift+1)%4],i[(this.shift+2)%4],i[(this.shift+3)%4]),a=this.getMatrixCornerPoints(i);return new pr(s,a,this.compact,this.nbDataBlocks,this.nbLayers)}extractParameters(e){if(!this.isValidPoint(e[0])||!this.isValidPoint(e[1])||!this.isValidPoint(e[2])||!this.isValidPoint(e[3]))throw new F;let r=2*this.nbCenterLayers,i=new Int32Array([this.sampleLine(e[0],e[1],r),this.sampleLine(e[1],e[2],r),this.sampleLine(e[2],e[3],r),this.sampleLine(e[3],e[0],r)]);this.shift=this.getRotation(i,r);let s=0;for(let c=0;c<4;c++){let d=i[(this.shift+c)%4];this.compact?(s<<=7,s+=d>>1&127):(s<<=10,s+=(d>>2&992)+(d>>1&31))}let a=this.getCorrectedParameterData(s,this.compact);this.compact?(this.nbLayers=(a>>6)+1,this.nbDataBlocks=(a&63)+1):(this.nbLayers=(a>>11)+1,this.nbDataBlocks=(a&2047)+1)}getRotation(e,r){let i=0;e.forEach((s,a,c)=>{let d=(s>>r-2<<1)+(s&1);i=(i<<3)+d}),i=((i&1)<<11)+(i>>1);for(let s=0;s<4;s++)if(k.bitCount(i^this.EXPECTED_CORNER_BITS[s])<=2)return s;throw new F}getCorrectedParameterData(e,r){let i,s;r?(i=7,s=2):(i=10,s=4);let a=i-s,c=new Int32Array(i);for(let h=i-1;h>=0;--h)c[h]=e&15,e>>=4;try{new De(je.AZTEC_PARAM).decode(c,a)}catch{throw new F}let d=0;for(let h=0;h<s;h++)d=(d<<4)+c[h];return d}getBullsEyeCorners(e){let r=e,i=e,s=e,a=e,c=!0;for(this.nbCenterLayers=1;this.nbCenterLayers<9;this.nbCenterLayers++){let v=this.getFirstDifferent(r,c,1,-1),E=this.getFirstDifferent(i,c,1,1),O=this.getFirstDifferent(s,c,-1,1),L=this.getFirstDifferent(a,c,-1,-1);if(this.nbCenterLayers>2){let $=this.distancePoint(L,v)*this.nbCenterLayers/(this.distancePoint(a,r)*(this.nbCenterLayers+2));if($<.75||$>1.25||!this.isWhiteOrBlackRectangle(v,E,O,L))break}r=v,i=E,s=O,a=L,c=!c}if(this.nbCenterLayers!==5&&this.nbCenterLayers!==7)throw new F;this.compact=this.nbCenterLayers===5;let d=new Se(r.getX()+.5,r.getY()-.5),h=new Se(i.getX()+.5,i.getY()+.5),p=new Se(s.getX()-.5,s.getY()+.5),w=new Se(a.getX()-.5,a.getY()-.5);return this.expandSquare([d,h,p,w],2*this.nbCenterLayers-3,2*this.nbCenterLayers)}getMatrixCenter(){let e,r,i,s;try{let d=new yn(this.image).detect();e=d[0],r=d[1],i=d[2],s=d[3]}catch{let h=this.image.getWidth()/2,p=this.image.getHeight()/2;e=this.getFirstDifferent(new Vt(h+7,p-7),!1,1,-1).toResultPoint(),r=this.getFirstDifferent(new Vt(h+7,p+7),!1,1,1).toResultPoint(),i=this.getFirstDifferent(new Vt(h-7,p+7),!1,-1,1).toResultPoint(),s=this.getFirstDifferent(new Vt(h-7,p-7),!1,-1,-1).toResultPoint()}let a=ke.round((e.getX()+s.getX()+r.getX()+i.getX())/4),c=ke.round((e.getY()+s.getY()+r.getY()+i.getY())/4);try{let d=new yn(this.image,15,a,c).detect();e=d[0],r=d[1],i=d[2],s=d[3]}catch{e=this.getFirstDifferent(new Vt(a+7,c-7),!1,1,-1).toResultPoint(),r=this.getFirstDifferent(new Vt(a+7,c+7),!1,1,1).toResultPoint(),i=this.getFirstDifferent(new Vt(a-7,c+7),!1,-1,1).toResultPoint(),s=this.getFirstDifferent(new Vt(a-7,c-7),!1,-1,-1).toResultPoint()}return a=ke.round((e.getX()+s.getX()+r.getX()+i.getX())/4),c=ke.round((e.getY()+s.getY()+r.getY()+i.getY())/4),new Vt(a,c)}getMatrixCornerPoints(e){return this.expandSquare(e,2*this.nbCenterLayers,this.getDimension())}sampleGrid(e,r,i,s,a){let c=Hn.getInstance(),d=this.getDimension(),h=d/2-this.nbCenterLayers,p=d/2+this.nbCenterLayers;return c.sampleGrid(e,d,d,h,h,p,h,p,p,h,p,r.getX(),r.getY(),i.getX(),i.getY(),s.getX(),s.getY(),a.getX(),a.getY())}sampleLine(e,r,i){let s=0,a=this.distanceResultPoint(e,r),c=a/i,d=e.getX(),h=e.getY(),p=c*(r.getX()-e.getX())/a,w=c*(r.getY()-e.getY())/a;for(let v=0;v<i;v++)this.image.get(ke.round(d+v*p),ke.round(h+v*w))&&(s|=1<<i-v-1);return s}isWhiteOrBlackRectangle(e,r,i,s){let a=3;e=new Vt(e.getX()-a,e.getY()+a),r=new Vt(r.getX()-a,r.getY()-a),i=new Vt(i.getX()+a,i.getY()-a),s=new Vt(s.getX()+a,s.getY()+a);let c=this.getColor(s,e);if(c===0)return!1;let d=this.getColor(e,r);return d!==c||(d=this.getColor(r,i),d!==c)?!1:(d=this.getColor(i,s),d===c)}getColor(e,r){let i=this.distancePoint(e,r),s=(r.getX()-e.getX())/i,a=(r.getY()-e.getY())/i,c=0,d=e.getX(),h=e.getY(),p=this.image.get(e.getX(),e.getY()),w=Math.ceil(i);for(let E=0;E<w;E++)d+=s,h+=a,this.image.get(ke.round(d),ke.round(h))!==p&&c++;let v=c/i;return v>.1&&v<.9?0:v<=.1===p?1:-1}getFirstDifferent(e,r,i,s){let a=e.getX()+i,c=e.getY()+s;for(;this.isValid(a,c)&&this.image.get(a,c)===r;)a+=i,c+=s;for(a-=i,c-=s;this.isValid(a,c)&&this.image.get(a,c)===r;)a+=i;for(a-=i;this.isValid(a,c)&&this.image.get(a,c)===r;)c+=s;return c-=s,new Vt(a,c)}expandSquare(e,r,i){let s=i/(2*r),a=e[0].getX()-e[2].getX(),c=e[0].getY()-e[2].getY(),d=(e[0].getX()+e[2].getX())/2,h=(e[0].getY()+e[2].getY())/2,p=new Se(d+s*a,h+s*c),w=new Se(d-s*a,h-s*c);a=e[1].getX()-e[3].getX(),c=e[1].getY()-e[3].getY(),d=(e[1].getX()+e[3].getX())/2,h=(e[1].getY()+e[3].getY())/2;let v=new Se(d+s*a,h+s*c),E=new Se(d-s*a,h-s*c);return[p,v,w,E]}isValid(e,r){return e>=0&&e<this.image.getWidth()&&r>0&&r<this.image.getHeight()}isValidPoint(e){let r=ke.round(e.getX()),i=ke.round(e.getY());return this.isValid(r,i)}distancePoint(e,r){return ke.distance(e.getX(),e.getY(),r.getX(),r.getY())}distanceResultPoint(e,r){return ke.distance(e.getX(),e.getY(),r.getX(),r.getY())}getDimension(){return this.compact?4*this.nbLayers+11:this.nbLayers<=4?4*this.nbLayers+15:4*this.nbLayers+2*(k.truncDivision(this.nbLayers-4,8)+1)+15}}class fi{decode(e,r=null){let i=null,s=new As(e.getBlackMatrix()),a=null,c=null;try{let w=s.detectMirror(!1);a=w.getPoints(),this.reportFoundResultPoints(r,a),c=new Oe().decode(w)}catch(w){i=w}if(c==null)try{let w=s.detectMirror(!0);a=w.getPoints(),this.reportFoundResultPoints(r,a),c=new Oe().decode(w)}catch(w){throw i??w}let d=new Pe(c.getText(),c.getRawBytes(),c.getNumBits(),a,S.AZTEC,D.currentTimeMillis()),h=c.getByteSegments();h!=null&&d.putMetadata(se.BYTE_SEGMENTS,h);let p=c.getECLevel();return p!=null&&d.putMetadata(se.ERROR_CORRECTION_LEVEL,p),d}reportFoundResultPoints(e,r){if(e!=null){let i=e.get(Q.NEED_RESULT_POINT_CALLBACK);i!=null&&r.forEach((s,a,c)=>{i.foundPossibleResultPoint(s)})}}reset(){}}class w1 extends Fe{constructor(e=500){super(new fi,e)}}class bt{decode(e,r){try{return this.doDecode(e,r)}catch{if(r&&r.get(Q.TRY_HARDER)===!0&&e.isRotateSupported()){const a=e.rotateCounterClockwise(),c=this.doDecode(a,r),d=c.getResultMetadata();let h=270;d!==null&&d.get(se.ORIENTATION)===!0&&(h=h+d.get(se.ORIENTATION)%360),c.putMetadata(se.ORIENTATION,h);const p=c.getResultPoints();if(p!==null){const w=a.getHeight();for(let v=0;v<p.length;v++)p[v]=new Se(w-p[v].getY()-1,p[v].getX())}return c}else throw new F}}reset(){}doDecode(e,r){const i=e.getWidth(),s=e.getHeight();let a=new K(i);const c=r&&r.get(Q.TRY_HARDER)===!0,d=Math.max(1,s>>(c?8:5));let h;c?h=s:h=15;const p=Math.trunc(s/2);for(let w=0;w<h;w++){const v=Math.trunc((w+1)/2),E=(w&1)===0,O=p+d*(E?v:-v);if(O<0||O>=s)break;try{a=e.getBlackRow(O,a)}catch{continue}for(let L=0;L<2;L++){if(L===1&&(a.reverse(),r&&r.get(Q.NEED_RESULT_POINT_CALLBACK)===!0)){const $=new Map;r.forEach((Z,G)=>$.set(G,Z)),$.delete(Q.NEED_RESULT_POINT_CALLBACK),r=$}try{const $=this.decodeRow(O,a,r);if(L===1){$.putMetadata(se.ORIENTATION,180);const Z=$.getResultPoints();Z!==null&&(Z[0]=new Se(i-Z[0].getX()-1,Z[0].getY()),Z[1]=new Se(i-Z[1].getX()-1,Z[1].getY()))}return $}catch{}}}throw new F}static recordPattern(e,r,i){const s=i.length;for(let p=0;p<s;p++)i[p]=0;const a=e.getSize();if(r>=a)throw new F;let c=!e.get(r),d=0,h=r;for(;h<a;){if(e.get(h)!==c)i[d]++;else{if(++d===s)break;i[d]=1,c=!c}h++}if(!(d===s||d===s-1&&h===a))throw new F}static recordPatternInReverse(e,r,i){let s=i.length,a=e.get(r);for(;r>0&&s>=0;)e.get(--r)!==a&&(s--,a=!a);if(s>=0)throw new F;bt.recordPattern(e,r+1,i)}static patternMatchVariance(e,r,i){const s=e.length;let a=0,c=0;for(let p=0;p<s;p++)a+=e[p],c+=r[p];if(a<c)return Number.POSITIVE_INFINITY;const d=a/c;i*=d;let h=0;for(let p=0;p<s;p++){const w=e[p],v=r[p]*d,E=w>v?w-v:v-w;if(E>i)return Number.POSITIVE_INFINITY;h+=E}return h/a}}class me extends bt{static findStartPattern(e){const r=e.getSize(),i=e.getNextSet(0);let s=0,a=Int32Array.from([0,0,0,0,0,0]),c=i,d=!1;const h=6;for(let p=i;p<r;p++)if(e.get(p)!==d)a[s]++;else{if(s===h-1){let w=me.MAX_AVG_VARIANCE,v=-1;for(let E=me.CODE_START_A;E<=me.CODE_START_C;E++){const O=bt.patternMatchVariance(a,me.CODE_PATTERNS[E],me.MAX_INDIVIDUAL_VARIANCE);O<w&&(w=O,v=E)}if(v>=0&&e.isRange(Math.max(0,c-(p-c)/2),c,!1))return Int32Array.from([c,p,v]);c+=a[0]+a[1],a=a.slice(2,a.length-1),a[s-1]=0,a[s]=0,s--}else s++;a[s]=1,d=!d}throw new F}static decodeCode(e,r,i){bt.recordPattern(e,i,r);let s=me.MAX_AVG_VARIANCE,a=-1;for(let c=0;c<me.CODE_PATTERNS.length;c++){const d=me.CODE_PATTERNS[c],h=this.patternMatchVariance(r,d,me.MAX_INDIVIDUAL_VARIANCE);h<s&&(s=h,a=c)}if(a>=0)return a;throw new F}decodeRow(e,r,i){const s=i&&i.get(Q.ASSUME_GS1)===!0,a=me.findStartPattern(r),c=a[2];let d=0;const h=new Uint8Array(20);h[d++]=c;let p;switch(c){case me.CODE_START_A:p=me.CODE_CODE_A;break;case me.CODE_START_B:p=me.CODE_CODE_B;break;case me.CODE_START_C:p=me.CODE_CODE_C;break;default:throw new j}let w=!1,v=!1,E="",O=a[0],L=a[1];const $=Int32Array.from([0,0,0,0,0,0]);let Z=0,G=0,ae=c,ce=0,oe=!0,He=!1,ze=!1;for(;!w;){const br=v;switch(v=!1,Z=G,G=me.decodeCode(r,$,L),h[d++]=G,G!==me.CODE_STOP&&(oe=!0),G!==me.CODE_STOP&&(ce++,ae+=ce*G),O=L,L+=$.reduce((G1,X1)=>G1+X1,0),G){case me.CODE_START_A:case me.CODE_START_B:case me.CODE_START_C:throw new j}switch(p){case me.CODE_CODE_A:if(G<64)ze===He?E+=String.fromCharCode(32+G):E+=String.fromCharCode(32+G+128),ze=!1;else if(G<96)ze===He?E+=String.fromCharCode(G-64):E+=String.fromCharCode(G+64),ze=!1;else switch(G!==me.CODE_STOP&&(oe=!1),G){case me.CODE_FNC_1:s&&(E.length===0?E+="]C1":E+="");break;case me.CODE_FNC_2:case me.CODE_FNC_3:break;case me.CODE_FNC_4_A:!He&&ze?(He=!0,ze=!1):He&&ze?(He=!1,ze=!1):ze=!0;break;case me.CODE_SHIFT:v=!0,p=me.CODE_CODE_B;break;case me.CODE_CODE_B:p=me.CODE_CODE_B;break;case me.CODE_CODE_C:p=me.CODE_CODE_C;break;case me.CODE_STOP:w=!0;break}break;case me.CODE_CODE_B:if(G<96)ze===He?E+=String.fromCharCode(32+G):E+=String.fromCharCode(32+G+128),ze=!1;else switch(G!==me.CODE_STOP&&(oe=!1),G){case me.CODE_FNC_1:s&&(E.length===0?E+="]C1":E+="");break;case me.CODE_FNC_2:case me.CODE_FNC_3:break;case me.CODE_FNC_4_B:!He&&ze?(He=!0,ze=!1):He&&ze?(He=!1,ze=!1):ze=!0;break;case me.CODE_SHIFT:v=!0,p=me.CODE_CODE_A;break;case me.CODE_CODE_A:p=me.CODE_CODE_A;break;case me.CODE_CODE_C:p=me.CODE_CODE_C;break;case me.CODE_STOP:w=!0;break}break;case me.CODE_CODE_C:if(G<100)G<10&&(E+="0"),E+=G;else switch(G!==me.CODE_STOP&&(oe=!1),G){case me.CODE_FNC_1:s&&(E.length===0?E+="]C1":E+="");break;case me.CODE_CODE_A:p=me.CODE_CODE_A;break;case me.CODE_CODE_B:p=me.CODE_CODE_B;break;case me.CODE_STOP:w=!0;break}break}br&&(p=p===me.CODE_CODE_A?me.CODE_CODE_B:me.CODE_CODE_A)}const tn=L-O;if(L=r.getNextUnset(L),!r.isRange(L,Math.min(r.getSize(),L+(L-O)/2),!1))throw new F;if(ae-=ce*Z,ae%103!==Z)throw new N;const vn=E.length;if(vn===0)throw new F;vn>0&&oe&&(p===me.CODE_CODE_C?E=E.substring(0,vn-2):E=E.substring(0,vn-1));const nn=(a[1]+a[0])/2,ot=O+tn/2,Bt=h.length,on=new Uint8Array(Bt);for(let br=0;br<Bt;br++)on[br]=h[br];const Cr=[new Se(nn,e),new Se(ot,e)];return new Pe(E,on,0,Cr,S.CODE_128,new Date().getTime())}}me.CODE_PATTERNS=[Int32Array.from([2,1,2,2,2,2]),Int32Array.from([2,2,2,1,2,2]),Int32Array.from([2,2,2,2,2,1]),Int32Array.from([1,2,1,2,2,3]),Int32Array.from([1,2,1,3,2,2]),Int32Array.from([1,3,1,2,2,2]),Int32Array.from([1,2,2,2,1,3]),Int32Array.from([1,2,2,3,1,2]),Int32Array.from([1,3,2,2,1,2]),Int32Array.from([2,2,1,2,1,3]),Int32Array.from([2,2,1,3,1,2]),Int32Array.from([2,3,1,2,1,2]),Int32Array.from([1,1,2,2,3,2]),Int32Array.from([1,2,2,1,3,2]),Int32Array.from([1,2,2,2,3,1]),Int32Array.from([1,1,3,2,2,2]),Int32Array.from([1,2,3,1,2,2]),Int32Array.from([1,2,3,2,2,1]),Int32Array.from([2,2,3,2,1,1]),Int32Array.from([2,2,1,1,3,2]),Int32Array.from([2,2,1,2,3,1]),Int32Array.from([2,1,3,2,1,2]),Int32Array.from([2,2,3,1,1,2]),Int32Array.from([3,1,2,1,3,1]),Int32Array.from([3,1,1,2,2,2]),Int32Array.from([3,2,1,1,2,2]),Int32Array.from([3,2,1,2,2,1]),Int32Array.from([3,1,2,2,1,2]),Int32Array.from([3,2,2,1,1,2]),Int32Array.from([3,2,2,2,1,1]),Int32Array.from([2,1,2,1,2,3]),Int32Array.from([2,1,2,3,2,1]),Int32Array.from([2,3,2,1,2,1]),Int32Array.from([1,1,1,3,2,3]),Int32Array.from([1,3,1,1,2,3]),Int32Array.from([1,3,1,3,2,1]),Int32Array.from([1,1,2,3,1,3]),Int32Array.from([1,3,2,1,1,3]),Int32Array.from([1,3,2,3,1,1]),Int32Array.from([2,1,1,3,1,3]),Int32Array.from([2,3,1,1,1,3]),Int32Array.from([2,3,1,3,1,1]),Int32Array.from([1,1,2,1,3,3]),Int32Array.from([1,1,2,3,3,1]),Int32Array.from([1,3,2,1,3,1]),Int32Array.from([1,1,3,1,2,3]),Int32Array.from([1,1,3,3,2,1]),Int32Array.from([1,3,3,1,2,1]),Int32Array.from([3,1,3,1,2,1]),Int32Array.from([2,1,1,3,3,1]),Int32Array.from([2,3,1,1,3,1]),Int32Array.from([2,1,3,1,1,3]),Int32Array.from([2,1,3,3,1,1]),Int32Array.from([2,1,3,1,3,1]),Int32Array.from([3,1,1,1,2,3]),Int32Array.from([3,1,1,3,2,1]),Int32Array.from([3,3,1,1,2,1]),Int32Array.from([3,1,2,1,1,3]),Int32Array.from([3,1,2,3,1,1]),Int32Array.from([3,3,2,1,1,1]),Int32Array.from([3,1,4,1,1,1]),Int32Array.from([2,2,1,4,1,1]),Int32Array.from([4,3,1,1,1,1]),Int32Array.from([1,1,1,2,2,4]),Int32Array.from([1,1,1,4,2,2]),Int32Array.from([1,2,1,1,2,4]),Int32Array.from([1,2,1,4,2,1]),Int32Array.from([1,4,1,1,2,2]),Int32Array.from([1,4,1,2,2,1]),Int32Array.from([1,1,2,2,1,4]),Int32Array.from([1,1,2,4,1,2]),Int32Array.from([1,2,2,1,1,4]),Int32Array.from([1,2,2,4,1,1]),Int32Array.from([1,4,2,1,1,2]),Int32Array.from([1,4,2,2,1,1]),Int32Array.from([2,4,1,2,1,1]),Int32Array.from([2,2,1,1,1,4]),Int32Array.from([4,1,3,1,1,1]),Int32Array.from([2,4,1,1,1,2]),Int32Array.from([1,3,4,1,1,1]),Int32Array.from([1,1,1,2,4,2]),Int32Array.from([1,2,1,1,4,2]),Int32Array.from([1,2,1,2,4,1]),Int32Array.from([1,1,4,2,1,2]),Int32Array.from([1,2,4,1,1,2]),Int32Array.from([1,2,4,2,1,1]),Int32Array.from([4,1,1,2,1,2]),Int32Array.from([4,2,1,1,1,2]),Int32Array.from([4,2,1,2,1,1]),Int32Array.from([2,1,2,1,4,1]),Int32Array.from([2,1,4,1,2,1]),Int32Array.from([4,1,2,1,2,1]),Int32Array.from([1,1,1,1,4,3]),Int32Array.from([1,1,1,3,4,1]),Int32Array.from([1,3,1,1,4,1]),Int32Array.from([1,1,4,1,1,3]),Int32Array.from([1,1,4,3,1,1]),Int32Array.from([4,1,1,1,1,3]),Int32Array.from([4,1,1,3,1,1]),Int32Array.from([1,1,3,1,4,1]),Int32Array.from([1,1,4,1,3,1]),Int32Array.from([3,1,1,1,4,1]),Int32Array.from([4,1,1,1,3,1]),Int32Array.from([2,1,1,4,1,2]),Int32Array.from([2,1,1,2,1,4]),Int32Array.from([2,1,1,2,3,2]),Int32Array.from([2,3,3,1,1,1,2])],me.MAX_AVG_VARIANCE=.25,me.MAX_INDIVIDUAL_VARIANCE=.7,me.CODE_SHIFT=98,me.CODE_CODE_C=99,me.CODE_CODE_B=100,me.CODE_CODE_A=101,me.CODE_FNC_1=102,me.CODE_FNC_2=97,me.CODE_FNC_3=96,me.CODE_FNC_4_A=101,me.CODE_FNC_4_B=100,me.CODE_START_A=103,me.CODE_START_B=104,me.CODE_START_C=105,me.CODE_STOP=106;class It extends bt{constructor(e=!1,r=!1){super(),this.usingCheckDigit=e,this.extendedMode=r,this.decodeRowResult="",this.counters=new Int32Array(9)}decodeRow(e,r,i){let s=this.counters;s.fill(0),this.decodeRowResult="";let a=It.findAsteriskPattern(r,s),c=r.getNextSet(a[1]),d=r.getSize(),h,p;do{It.recordPattern(r,c,s);let $=It.toNarrowWidePattern(s);if($<0)throw new F;h=It.patternToChar($),this.decodeRowResult+=h,p=c;for(let Z of s)c+=Z;c=r.getNextSet(c)}while(h!=="*");this.decodeRowResult=this.decodeRowResult.substring(0,this.decodeRowResult.length-1);let w=0;for(let $ of s)w+=$;let v=c-p-w;if(c!==d&&v*2<w)throw new F;if(this.usingCheckDigit){let $=this.decodeRowResult.length-1,Z=0;for(let G=0;G<$;G++)Z+=It.ALPHABET_STRING.indexOf(this.decodeRowResult.charAt(G));if(this.decodeRowResult.charAt($)!==It.ALPHABET_STRING.charAt(Z%43))throw new N;this.decodeRowResult=this.decodeRowResult.substring(0,$)}if(this.decodeRowResult.length===0)throw new F;let E;this.extendedMode?E=It.decodeExtended(this.decodeRowResult):E=this.decodeRowResult;let O=(a[1]+a[0])/2,L=p+w/2;return new Pe(E,null,0,[new Se(O,e),new Se(L,e)],S.CODE_39,new Date().getTime())}static findAsteriskPattern(e,r){let i=e.getSize(),s=e.getNextSet(0),a=0,c=s,d=!1,h=r.length;for(let p=s;p<i;p++)if(e.get(p)!==d)r[a]++;else{if(a===h-1){if(this.toNarrowWidePattern(r)===It.ASTERISK_ENCODING&&e.isRange(Math.max(0,c-Math.floor((p-c)/2)),c,!1))return[c,p];c+=r[0]+r[1],r.copyWithin(0,2,2+a-1),r[a-1]=0,r[a]=0,a--}else a++;r[a]=1,d=!d}throw new F}static toNarrowWidePattern(e){let r=e.length,i=0,s;do{let a=2147483647;for(let h of e)h<a&&h>i&&(a=h);i=a,s=0;let c=0,d=0;for(let h=0;h<r;h++){let p=e[h];p>i&&(d|=1<<r-1-h,s++,c+=p)}if(s===3){for(let h=0;h<r&&s>0;h++){let p=e[h];if(p>i&&(s--,p*2>=c))return-1}return d}}while(s>3);return-1}static patternToChar(e){for(let r=0;r<It.CHARACTER_ENCODINGS.length;r++)if(It.CHARACTER_ENCODINGS[r]===e)return It.ALPHABET_STRING.charAt(r);if(e===It.ASTERISK_ENCODING)return"*";throw new F}static decodeExtended(e){let r=e.length,i="";for(let s=0;s<r;s++){let a=e.charAt(s);if(a==="+"||a==="$"||a==="%"||a==="/"){let c=e.charAt(s+1),d="\0";switch(a){case"+":if(c>="A"&&c<="Z")d=String.fromCharCode(c.charCodeAt(0)+32);else throw new j;break;case"$":if(c>="A"&&c<="Z")d=String.fromCharCode(c.charCodeAt(0)-64);else throw new j;break;case"%":if(c>="A"&&c<="E")d=String.fromCharCode(c.charCodeAt(0)-38);else if(c>="F"&&c<="J")d=String.fromCharCode(c.charCodeAt(0)-11);else if(c>="K"&&c<="O")d=String.fromCharCode(c.charCodeAt(0)+16);else if(c>="P"&&c<="T")d=String.fromCharCode(c.charCodeAt(0)+43);else if(c==="U")d="\0";else if(c==="V")d="@";else if(c==="W")d="`";else if(c==="X"||c==="Y"||c==="Z")d="";else throw new j;break;case"/":if(c>="A"&&c<="O")d=String.fromCharCode(c.charCodeAt(0)-32);else if(c==="Z")d=":";else throw new j;break}i+=d,s++}else i+=a}return i}}It.ALPHABET_STRING="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%",It.CHARACTER_ENCODINGS=[52,289,97,352,49,304,112,37,292,100,265,73,328,25,280,88,13,268,76,28,259,67,322,19,274,82,7,262,70,22,385,193,448,145,400,208,133,388,196,168,162,138,42],It.ASTERISK_ENCODING=148;class rt extends bt{constructor(){super(...arguments),this.narrowLineWidth=-1}decodeRow(e,r,i){let s=this.decodeStart(r),a=this.decodeEnd(r),c=new xe;rt.decodeMiddle(r,s[1],a[0],c);let d=c.toString(),h=null;i!=null&&(h=i.get(Q.ALLOWED_LENGTHS)),h==null&&(h=rt.DEFAULT_ALLOWED_LENGTHS);let p=d.length,w=!1,v=0;for(let L of h){if(p===L){w=!0;break}L>v&&(v=L)}if(!w&&p>v&&(w=!0),!w)throw new j;const E=[new Se(s[1],e),new Se(a[0],e)];return new Pe(d,null,0,E,S.ITF,new Date().getTime())}static decodeMiddle(e,r,i,s){let a=new Int32Array(10),c=new Int32Array(5),d=new Int32Array(5);for(a.fill(0),c.fill(0),d.fill(0);r<i;){bt.recordPattern(e,r,a);for(let p=0;p<5;p++){let w=2*p;c[p]=a[w],d[p]=a[w+1]}let h=rt.decodeDigit(c);s.append(h.toString()),h=this.decodeDigit(d),s.append(h.toString()),a.forEach(function(p){r+=p})}}decodeStart(e){let r=rt.skipWhiteSpace(e),i=rt.findGuardPattern(e,r,rt.START_PATTERN);return this.narrowLineWidth=(i[1]-i[0])/4,this.validateQuietZone(e,i[0]),i}validateQuietZone(e,r){let i=this.narrowLineWidth*10;i=i<r?i:r;for(let s=r-1;i>0&&s>=0&&!e.get(s);s--)i--;if(i!==0)throw new F}static skipWhiteSpace(e){const r=e.getSize(),i=e.getNextSet(0);if(i===r)throw new F;return i}decodeEnd(e){e.reverse();try{let r=rt.skipWhiteSpace(e),i;try{i=rt.findGuardPattern(e,r,rt.END_PATTERN_REVERSED[0])}catch(a){a instanceof F&&(i=rt.findGuardPattern(e,r,rt.END_PATTERN_REVERSED[1]))}this.validateQuietZone(e,i[0]);let s=i[0];return i[0]=e.getSize()-i[1],i[1]=e.getSize()-s,i}finally{e.reverse()}}static findGuardPattern(e,r,i){let s=i.length,a=new Int32Array(s),c=e.getSize(),d=!1,h=0,p=r;a.fill(0);for(let w=r;w<c;w++)if(e.get(w)!==d)a[h]++;else{if(h===s-1){if(bt.patternMatchVariance(a,i,rt.MAX_INDIVIDUAL_VARIANCE)<rt.MAX_AVG_VARIANCE)return[p,w];p+=a[0]+a[1],D.arraycopy(a,2,a,0,h-1),a[h-1]=0,a[h]=0,h--}else h++;a[h]=1,d=!d}throw new F}static decodeDigit(e){let r=rt.MAX_AVG_VARIANCE,i=-1,s=rt.PATTERNS.length;for(let a=0;a<s;a++){let c=rt.PATTERNS[a],d=bt.patternMatchVariance(e,c,rt.MAX_INDIVIDUAL_VARIANCE);d<r?(r=d,i=a):d===r&&(i=-1)}if(i>=0)return i%10;throw new F}}rt.PATTERNS=[Int32Array.from([1,1,2,2,1]),Int32Array.from([2,1,1,1,2]),Int32Array.from([1,2,1,1,2]),Int32Array.from([2,2,1,1,1]),Int32Array.from([1,1,2,1,2]),Int32Array.from([2,1,2,1,1]),Int32Array.from([1,2,2,1,1]),Int32Array.from([1,1,1,2,2]),Int32Array.from([2,1,1,2,1]),Int32Array.from([1,2,1,2,1]),Int32Array.from([1,1,3,3,1]),Int32Array.from([3,1,1,1,3]),Int32Array.from([1,3,1,1,3]),Int32Array.from([3,3,1,1,1]),Int32Array.from([1,1,3,1,3]),Int32Array.from([3,1,3,1,1]),Int32Array.from([1,3,3,1,1]),Int32Array.from([1,1,1,3,3]),Int32Array.from([3,1,1,3,1]),Int32Array.from([1,3,1,3,1])],rt.MAX_AVG_VARIANCE=.38,rt.MAX_INDIVIDUAL_VARIANCE=.5,rt.DEFAULT_ALLOWED_LENGTHS=[6,8,10,12,14],rt.START_PATTERN=Int32Array.from([1,1,1,1]),rt.END_PATTERN_REVERSED=[Int32Array.from([1,1,2]),Int32Array.from([1,1,3])];class wt extends bt{constructor(){super(...arguments),this.decodeRowStringBuffer=""}static findStartGuardPattern(e){let r=!1,i,s=0,a=Int32Array.from([0,0,0]);for(;!r;){a=Int32Array.from([0,0,0]),i=wt.findGuardPattern(e,s,!1,this.START_END_PATTERN,a);let c=i[0];s=i[1];let d=c-(s-c);d>=0&&(r=e.isRange(d,c,!1))}return i}static checkChecksum(e){return wt.checkStandardUPCEANChecksum(e)}static checkStandardUPCEANChecksum(e){let r=e.length;if(r===0)return!1;let i=parseInt(e.charAt(r-1),10);return wt.getStandardUPCEANChecksum(e.substring(0,r-1))===i}static getStandardUPCEANChecksum(e){let r=e.length,i=0;for(let s=r-1;s>=0;s-=2){let a=e.charAt(s).charCodeAt(0)-48;if(a<0||a>9)throw new j;i+=a}i*=3;for(let s=r-2;s>=0;s-=2){let a=e.charAt(s).charCodeAt(0)-48;if(a<0||a>9)throw new j;i+=a}return(1e3-i)%10}static decodeEnd(e,r){return wt.findGuardPattern(e,r,!1,wt.START_END_PATTERN,new Int32Array(wt.START_END_PATTERN.length).fill(0))}static findGuardPatternWithoutCounters(e,r,i,s){return this.findGuardPattern(e,r,i,s,new Int32Array(s.length))}static findGuardPattern(e,r,i,s,a){let c=e.getSize();r=i?e.getNextUnset(r):e.getNextSet(r);let d=0,h=r,p=s.length,w=i;for(let v=r;v<c;v++)if(e.get(v)!==w)a[d]++;else{if(d===p-1){if(bt.patternMatchVariance(a,s,wt.MAX_INDIVIDUAL_VARIANCE)<wt.MAX_AVG_VARIANCE)return Int32Array.from([h,v]);h+=a[0]+a[1];let E=a.slice(2,a.length-1);for(let O=0;O<d-1;O++)a[O]=E[O];a[d-1]=0,a[d]=0,d--}else d++;a[d]=1,w=!w}throw new F}static decodeDigit(e,r,i,s){this.recordPattern(e,i,r);let a=this.MAX_AVG_VARIANCE,c=-1,d=s.length;for(let h=0;h<d;h++){let p=s[h],w=bt.patternMatchVariance(r,p,wt.MAX_INDIVIDUAL_VARIANCE);w<a&&(a=w,c=h)}if(c>=0)return c;throw new F}}wt.MAX_AVG_VARIANCE=.48,wt.MAX_INDIVIDUAL_VARIANCE=.7,wt.START_END_PATTERN=Int32Array.from([1,1,1]),wt.MIDDLE_PATTERN=Int32Array.from([1,1,1,1,1]),wt.END_PATTERN=Int32Array.from([1,1,1,1,1,1]),wt.L_PATTERNS=[Int32Array.from([3,2,1,1]),Int32Array.from([2,2,2,1]),Int32Array.from([2,1,2,2]),Int32Array.from([1,4,1,1]),Int32Array.from([1,1,3,2]),Int32Array.from([1,2,3,1]),Int32Array.from([1,1,1,4]),Int32Array.from([1,3,1,2]),Int32Array.from([1,2,1,3]),Int32Array.from([3,1,1,2])];class kr{constructor(){this.CHECK_DIGIT_ENCODINGS=[24,20,18,17,12,6,3,10,9,5],this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(e,r,i){let s=this.decodeRowStringBuffer,a=this.decodeMiddle(r,i,s),c=s.toString(),d=kr.parseExtensionString(c),h=[new Se((i[0]+i[1])/2,e),new Se(a,e)],p=new Pe(c,null,0,h,S.UPC_EAN_EXTENSION,new Date().getTime());return d!=null&&p.putAllMetadata(d),p}decodeMiddle(e,r,i){let s=this.decodeMiddleCounters;s[0]=0,s[1]=0,s[2]=0,s[3]=0;let a=e.getSize(),c=r[1],d=0;for(let p=0;p<5&&c<a;p++){let w=wt.decodeDigit(e,s,c,wt.L_AND_G_PATTERNS);i+=String.fromCharCode(48+w%10);for(let v of s)c+=v;w>=10&&(d|=1<<4-p),p!==4&&(c=e.getNextSet(c),c=e.getNextUnset(c))}if(i.length!==5)throw new F;let h=this.determineCheckDigit(d);if(kr.extensionChecksum(i.toString())!==h)throw new F;return c}static extensionChecksum(e){let r=e.length,i=0;for(let s=r-2;s>=0;s-=2)i+=e.charAt(s).charCodeAt(0)-48;i*=3;for(let s=r-1;s>=0;s-=2)i+=e.charAt(s).charCodeAt(0)-48;return i*=3,i%10}determineCheckDigit(e){for(let r=0;r<10;r++)if(e===this.CHECK_DIGIT_ENCODINGS[r])return r;throw new F}static parseExtensionString(e){if(e.length!==5)return null;let r=kr.parseExtension5String(e);return r==null?null:new Map([[se.SUGGESTED_PRICE,r]])}static parseExtension5String(e){let r;switch(e.charAt(0)){case"0":r="£";break;case"5":r="$";break;case"9":switch(e){case"90000":return null;case"99991":return"0.00";case"99990":return"Used"}r="";break;default:r="";break}let i=parseInt(e.substring(1)),s=(i/100).toString(),a=i%100,c=a<10?"0"+a:a.toString();return r+s+"."+c}}class oo{constructor(){this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(e,r,i){let s=this.decodeRowStringBuffer,a=this.decodeMiddle(r,i,s),c=s.toString(),d=oo.parseExtensionString(c),h=[new Se((i[0]+i[1])/2,e),new Se(a,e)],p=new Pe(c,null,0,h,S.UPC_EAN_EXTENSION,new Date().getTime());return d!=null&&p.putAllMetadata(d),p}decodeMiddle(e,r,i){let s=this.decodeMiddleCounters;s[0]=0,s[1]=0,s[2]=0,s[3]=0;let a=e.getSize(),c=r[1],d=0;for(let h=0;h<2&&c<a;h++){let p=wt.decodeDigit(e,s,c,wt.L_AND_G_PATTERNS);i+=String.fromCharCode(48+p%10);for(let w of s)c+=w;p>=10&&(d|=1<<1-h),h!==1&&(c=e.getNextSet(c),c=e.getNextUnset(c))}if(i.length!==2)throw new F;if(parseInt(i.toString())%4!==d)throw new F;return c}static parseExtensionString(e){return e.length!==2?null:new Map([[se.ISSUE_NUMBER,parseInt(e)]])}}class Is{static decodeRow(e,r,i){let s=wt.findGuardPattern(r,i,!1,this.EXTENSION_START_PATTERN,new Int32Array(this.EXTENSION_START_PATTERN.length).fill(0));try{return new kr().decodeRow(e,r,s)}catch{return new oo().decodeRow(e,r,s)}}}Is.EXTENSION_START_PATTERN=Int32Array.from([1,1,2]);class Ye extends wt{constructor(){super(),this.decodeRowStringBuffer="",Ye.L_AND_G_PATTERNS=Ye.L_PATTERNS.map(e=>Int32Array.from(e));for(let e=10;e<20;e++){let r=Ye.L_PATTERNS[e-10],i=new Int32Array(r.length);for(let s=0;s<r.length;s++)i[s]=r[r.length-s-1];Ye.L_AND_G_PATTERNS[e]=i}}decodeRow(e,r,i){let s=Ye.findStartGuardPattern(r),a=i==null?null:i.get(Q.NEED_RESULT_POINT_CALLBACK);if(a!=null){const oe=new Se((s[0]+s[1])/2,e);a.foundPossibleResultPoint(oe)}let c=this.decodeMiddle(r,s,this.decodeRowStringBuffer),d=c.rowOffset,h=c.resultString;if(a!=null){const oe=new Se(d,e);a.foundPossibleResultPoint(oe)}let p=this.decodeEnd(r,d);if(a!=null){const oe=new Se((p[0]+p[1])/2,e);a.foundPossibleResultPoint(oe)}let w=p[1],v=w+(w-p[0]);if(v>=r.getSize()||!r.isRange(w,v,!1))throw new F;let E=h.toString();if(E.length<8)throw new j;if(!Ye.checkChecksum(E))throw new N;let O=(s[1]+s[0])/2,L=(p[1]+p[0])/2,$=this.getBarcodeFormat(),Z=[new Se(O,e),new Se(L,e)],G=new Pe(E,null,0,Z,$,new Date().getTime()),ae=0;try{let oe=Is.decodeRow(e,r,p[1]);G.putMetadata(se.UPC_EAN_EXTENSION,oe.getText()),G.putAllMetadata(oe.getResultMetadata()),G.addResultPoints(oe.getResultPoints()),ae=oe.getText().length}catch{}let ce=i==null?null:i.get(Q.ALLOWED_EAN_EXTENSIONS);if(ce!=null){let oe=!1;for(let He in ce)if(ae.toString()===He){oe=!0;break}if(!oe)throw new F}return G}decodeEnd(e,r){return Ye.findGuardPattern(e,r,!1,Ye.START_END_PATTERN,new Int32Array(Ye.START_END_PATTERN.length).fill(0))}static checkChecksum(e){return Ye.checkStandardUPCEANChecksum(e)}static checkStandardUPCEANChecksum(e){let r=e.length;if(r===0)return!1;let i=parseInt(e.charAt(r-1),10);return Ye.getStandardUPCEANChecksum(e.substring(0,r-1))===i}static getStandardUPCEANChecksum(e){let r=e.length,i=0;for(let s=r-1;s>=0;s-=2){let a=e.charAt(s).charCodeAt(0)-48;if(a<0||a>9)throw new j;i+=a}i*=3;for(let s=r-2;s>=0;s-=2){let a=e.charAt(s).charCodeAt(0)-48;if(a<0||a>9)throw new j;i+=a}return(1e3-i)%10}}class or extends Ye{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(e,r,i){let s=this.decodeMiddleCounters;s[0]=0,s[1]=0,s[2]=0,s[3]=0;let a=e.getSize(),c=r[1],d=0;for(let p=0;p<6&&c<a;p++){let w=Ye.decodeDigit(e,s,c,Ye.L_AND_G_PATTERNS);i+=String.fromCharCode(48+w%10);for(let v of s)c+=v;w>=10&&(d|=1<<5-p)}i=or.determineFirstDigit(i,d),c=Ye.findGuardPattern(e,c,!0,Ye.MIDDLE_PATTERN,new Int32Array(Ye.MIDDLE_PATTERN.length).fill(0))[1];for(let p=0;p<6&&c<a;p++){let w=Ye.decodeDigit(e,s,c,Ye.L_PATTERNS);i+=String.fromCharCode(48+w);for(let v of s)c+=v}return{rowOffset:c,resultString:i}}getBarcodeFormat(){return S.EAN_13}static determineFirstDigit(e,r){for(let i=0;i<10;i++)if(r===this.FIRST_DIGIT_ENCODINGS[i])return e=String.fromCharCode(48+i)+e,e;throw new F}}or.FIRST_DIGIT_ENCODINGS=[0,11,13,14,19,25,28,21,22,26];class Ss extends Ye{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(e,r,i){const s=this.decodeMiddleCounters;s[0]=0,s[1]=0,s[2]=0,s[3]=0;let a=e.getSize(),c=r[1];for(let h=0;h<4&&c<a;h++){let p=Ye.decodeDigit(e,s,c,Ye.L_PATTERNS);i+=String.fromCharCode(48+p);for(let w of s)c+=w}c=Ye.findGuardPattern(e,c,!0,Ye.MIDDLE_PATTERN,new Int32Array(Ye.MIDDLE_PATTERN.length).fill(0))[1];for(let h=0;h<4&&c<a;h++){let p=Ye.decodeDigit(e,s,c,Ye.L_PATTERNS);i+=String.fromCharCode(48+p);for(let w of s)c+=w}return{rowOffset:c,resultString:i}}getBarcodeFormat(){return S.EAN_8}}class Ts extends Ye{constructor(){super(...arguments),this.ean13Reader=new or}getBarcodeFormat(){return S.UPC_A}decode(e,r){return this.maybeReturnResult(this.ean13Reader.decode(e))}decodeRow(e,r,i){return this.maybeReturnResult(this.ean13Reader.decodeRow(e,r,i))}decodeMiddle(e,r,i){return this.ean13Reader.decodeMiddle(e,r,i)}maybeReturnResult(e){let r=e.getText();if(r.charAt(0)==="0"){let i=new Pe(r.substring(1),null,null,e.getResultPoints(),S.UPC_A);return e.getResultMetadata()!=null&&i.putAllMetadata(e.getResultMetadata()),i}else throw new F}reset(){this.ean13Reader.reset()}}class _n extends Ye{constructor(){super(),this.decodeMiddleCounters=new Int32Array(4)}decodeMiddle(e,r,i){const s=this.decodeMiddleCounters.map(p=>p);s[0]=0,s[1]=0,s[2]=0,s[3]=0;const a=e.getSize();let c=r[1],d=0;for(let p=0;p<6&&c<a;p++){const w=_n.decodeDigit(e,s,c,_n.L_AND_G_PATTERNS);i+=String.fromCharCode(48+w%10);for(let v of s)c+=v;w>=10&&(d|=1<<5-p)}let h=_n.determineNumSysAndCheckDigit(i,d);return{rowOffset:c,resultString:h}}decodeEnd(e,r){return _n.findGuardPatternWithoutCounters(e,r,!0,_n.MIDDLE_END_PATTERN)}checkChecksum(e){return Ye.checkChecksum(_n.convertUPCEtoUPCA(e))}static determineNumSysAndCheckDigit(e,r){for(let i=0;i<=1;i++)for(let s=0;s<10;s++)if(r===this.NUMSYS_AND_CHECK_DIGIT_PATTERNS[i][s]){let a=String.fromCharCode(48+i),c=String.fromCharCode(48+s);return a+e+c}throw F.getNotFoundInstance()}getBarcodeFormat(){return S.UPC_E}static convertUPCEtoUPCA(e){const r=e.slice(1,7).split("").map(a=>a.charCodeAt(0)),i=new xe;i.append(e.charAt(0));let s=r[5];switch(s){case 0:case 1:case 2:i.appendChars(r,0,2),i.append(s),i.append("0000"),i.appendChars(r,2,3);break;case 3:i.appendChars(r,0,3),i.append("00000"),i.appendChars(r,3,2);break;case 4:i.appendChars(r,0,4),i.append("00000"),i.append(r[4]);break;default:i.appendChars(r,0,5),i.append("0000"),i.append(s);break}return e.length>=8&&i.append(e.charAt(7)),i.toString()}}_n.MIDDLE_END_PATTERN=Int32Array.from([1,1,1,1,1,1]),_n.NUMSYS_AND_CHECK_DIGIT_PATTERNS=[Int32Array.from([56,52,50,49,44,38,35,42,41,37]),Int32Array.from([7,11,13,14,19,25,28,21,22,26])];class so extends bt{constructor(e){super();let r=e==null?null:e.get(Q.POSSIBLE_FORMATS),i=[];l(r)?(i.push(new or),i.push(new Ts),i.push(new Ss),i.push(new _n)):(r.indexOf(S.EAN_13)>-1&&i.push(new or),r.indexOf(S.UPC_A)>-1&&i.push(new Ts),r.indexOf(S.EAN_8)>-1&&i.push(new Ss),r.indexOf(S.UPC_E)>-1&&i.push(new _n)),this.readers=i}decodeRow(e,r,i){for(let s of this.readers)try{const a=s.decodeRow(e,r,i),c=a.getBarcodeFormat()===S.EAN_13&&a.getText().charAt(0)==="0",d=i==null?null:i.get(Q.POSSIBLE_FORMATS),h=d==null||d.includes(S.UPC_A);if(c&&h){const p=a.getRawBytes(),w=new Pe(a.getText().substring(1),p,p?p.length:null,a.getResultPoints(),S.UPC_A);return w.putAllMetadata(a.getResultMetadata()),w}return a}catch{}throw new F}reset(){for(let e of this.readers)e.reset()}}class $t extends bt{constructor(){super(),this.decodeFinderCounters=new Int32Array(4),this.dataCharacterCounters=new Int32Array(8),this.oddRoundingErrors=new Array(4),this.evenRoundingErrors=new Array(4),this.oddCounts=new Array(this.dataCharacterCounters.length/2),this.evenCounts=new Array(this.dataCharacterCounters.length/2)}getDecodeFinderCounters(){return this.decodeFinderCounters}getDataCharacterCounters(){return this.dataCharacterCounters}getOddRoundingErrors(){return this.oddRoundingErrors}getEvenRoundingErrors(){return this.evenRoundingErrors}getOddCounts(){return this.oddCounts}getEvenCounts(){return this.evenCounts}parseFinderValue(e,r){for(let i=0;i<r.length;i++)if(bt.patternMatchVariance(e,r[i],$t.MAX_INDIVIDUAL_VARIANCE)<$t.MAX_AVG_VARIANCE)return i;throw new F}static count(e){return ke.sum(new Int32Array(e))}static increment(e,r){let i=0,s=r[0];for(let a=1;a<e.length;a++)r[a]>s&&(s=r[a],i=a);e[i]++}static decrement(e,r){let i=0,s=r[0];for(let a=1;a<e.length;a++)r[a]<s&&(s=r[a],i=a);e[i]--}static isFinderPattern(e){let r=e[0]+e[1],i=r+e[2]+e[3],s=r/i;if(s>=$t.MIN_FINDER_PATTERN_RATIO&&s<=$t.MAX_FINDER_PATTERN_RATIO){let a=Number.MAX_SAFE_INTEGER,c=Number.MIN_SAFE_INTEGER;for(let d of e)d>c&&(c=d),d<a&&(a=d);return c<10*a}return!1}}$t.MAX_AVG_VARIANCE=.2,$t.MAX_INDIVIDUAL_VARIANCE=.45,$t.MIN_FINDER_PATTERN_RATIO=9.5/12,$t.MAX_FINDER_PATTERN_RATIO=12.5/14;class gr{constructor(e,r){this.value=e,this.checksumPortion=r}getValue(){return this.value}getChecksumPortion(){return this.checksumPortion}toString(){return this.value+"("+this.checksumPortion+")"}equals(e){if(!(e instanceof gr))return!1;const r=e;return this.value===r.value&&this.checksumPortion===r.checksumPortion}hashCode(){return this.value^this.checksumPortion}}class hi{constructor(e,r,i,s,a){this.value=e,this.startEnd=r,this.value=e,this.startEnd=r,this.resultPoints=new Array,this.resultPoints.push(new Se(i,a)),this.resultPoints.push(new Se(s,a))}getValue(){return this.value}getStartEnd(){return this.startEnd}getResultPoints(){return this.resultPoints}equals(e){if(!(e instanceof hi))return!1;const r=e;return this.value===r.value}hashCode(){return this.value}}class Nn{constructor(){}static getRSSvalue(e,r,i){let s=0;for(let h of e)s+=h;let a=0,c=0,d=e.length;for(let h=0;h<d-1;h++){let p;for(p=1,c|=1<<h;p<e[h];p++,c&=~(1<<h)){let w=Nn.combins(s-p-1,d-h-2);if(i&&c===0&&s-p-(d-h-1)>=d-h-1&&(w-=Nn.combins(s-p-(d-h),d-h-2)),d-h-1>1){let v=0;for(let E=s-p-(d-h-2);E>r;E--)v+=Nn.combins(s-p-E-1,d-h-3);w-=v*(d-1-h)}else s-p>r&&w--;a+=w}s-=p}return a}static combins(e,r){let i,s;e-r>r?(s=r,i=e-r):(s=e-r,i=r);let a=1,c=1;for(let d=e;d>i;d--)a*=d,c<=s&&(a/=c,c++);for(;c<=s;)a/=c,c++;return a}}class y1{static buildBitArray(e){let r=e.length*2-1;e[e.length-1].getRightChar()==null&&(r-=1);let i=12*r,s=new K(i),a=0,d=e[0].getRightChar().getValue();for(let h=11;h>=0;--h)(d&1<<h)!=0&&s.set(a),a++;for(let h=1;h<e.length;++h){let p=e[h],w=p.getLeftChar().getValue();for(let v=11;v>=0;--v)(w&1<<v)!=0&&s.set(a),a++;if(p.getRightChar()!=null){let v=p.getRightChar().getValue();for(let E=11;E>=0;--E)(v&1<<E)!=0&&s.set(a),a++}}return s}}class sr{constructor(e,r){r?this.decodedInformation=null:(this.finished=e,this.decodedInformation=r)}getDecodedInformation(){return this.decodedInformation}isFinished(){return this.finished}}class ao{constructor(e){this.newPosition=e}getNewPosition(){return this.newPosition}}class Jt extends ao{constructor(e,r){super(e),this.value=r}getValue(){return this.value}isFNC1(){return this.value===Jt.FNC1}}Jt.FNC1="$";class ar extends ao{constructor(e,r,i){super(e),i?(this.remaining=!0,this.remainingValue=this.remainingValue):(this.remaining=!1,this.remainingValue=0),this.newString=r}getNewString(){return this.newString}isRemaining(){return this.remaining}getRemainingValue(){return this.remainingValue}}class dn extends ao{constructor(e,r,i){if(super(e),r<0||r>10||i<0||i>10)throw new j;this.firstDigit=r,this.secondDigit=i}getFirstDigit(){return this.firstDigit}getSecondDigit(){return this.secondDigit}getValue(){return this.firstDigit*10+this.secondDigit}isFirstDigitFNC1(){return this.firstDigit===dn.FNC1}isSecondDigitFNC1(){return this.secondDigit===dn.FNC1}isAnyFNC1(){return this.firstDigit===dn.FNC1||this.secondDigit===dn.FNC1}}dn.FNC1=10;class Ee{constructor(){}static parseFieldsInGeneralPurpose(e){if(!e)return null;if(e.length<2)throw new F;let r=e.substring(0,2);for(let a of Ee.TWO_DIGIT_DATA_LENGTH)if(a[0]===r)return a[1]===Ee.VARIABLE_LENGTH?Ee.processVariableAI(2,a[2],e):Ee.processFixedAI(2,a[1],e);if(e.length<3)throw new F;let i=e.substring(0,3);for(let a of Ee.THREE_DIGIT_DATA_LENGTH)if(a[0]===i)return a[1]===Ee.VARIABLE_LENGTH?Ee.processVariableAI(3,a[2],e):Ee.processFixedAI(3,a[1],e);for(let a of Ee.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH)if(a[0]===i)return a[1]===Ee.VARIABLE_LENGTH?Ee.processVariableAI(4,a[2],e):Ee.processFixedAI(4,a[1],e);if(e.length<4)throw new F;let s=e.substring(0,4);for(let a of Ee.FOUR_DIGIT_DATA_LENGTH)if(a[0]===s)return a[1]===Ee.VARIABLE_LENGTH?Ee.processVariableAI(4,a[2],e):Ee.processFixedAI(4,a[1],e);throw new F}static processFixedAI(e,r,i){if(i.length<e)throw new F;let s=i.substring(0,e);if(i.length<e+r)throw new F;let a=i.substring(e,e+r),c=i.substring(e+r),d="("+s+")"+a,h=Ee.parseFieldsInGeneralPurpose(c);return h==null?d:d+h}static processVariableAI(e,r,i){let s=i.substring(0,e),a;i.length<e+r?a=i.length:a=e+r;let c=i.substring(e,a),d=i.substring(a),h="("+s+")"+c,p=Ee.parseFieldsInGeneralPurpose(d);return p==null?h:h+p}}Ee.VARIABLE_LENGTH=[],Ee.TWO_DIGIT_DATA_LENGTH=[["00",18],["01",14],["02",14],["10",Ee.VARIABLE_LENGTH,20],["11",6],["12",6],["13",6],["15",6],["17",6],["20",2],["21",Ee.VARIABLE_LENGTH,20],["22",Ee.VARIABLE_LENGTH,29],["30",Ee.VARIABLE_LENGTH,8],["37",Ee.VARIABLE_LENGTH,8],["90",Ee.VARIABLE_LENGTH,30],["91",Ee.VARIABLE_LENGTH,30],["92",Ee.VARIABLE_LENGTH,30],["93",Ee.VARIABLE_LENGTH,30],["94",Ee.VARIABLE_LENGTH,30],["95",Ee.VARIABLE_LENGTH,30],["96",Ee.VARIABLE_LENGTH,30],["97",Ee.VARIABLE_LENGTH,3],["98",Ee.VARIABLE_LENGTH,30],["99",Ee.VARIABLE_LENGTH,30]],Ee.THREE_DIGIT_DATA_LENGTH=[["240",Ee.VARIABLE_LENGTH,30],["241",Ee.VARIABLE_LENGTH,30],["242",Ee.VARIABLE_LENGTH,6],["250",Ee.VARIABLE_LENGTH,30],["251",Ee.VARIABLE_LENGTH,30],["253",Ee.VARIABLE_LENGTH,17],["254",Ee.VARIABLE_LENGTH,20],["400",Ee.VARIABLE_LENGTH,30],["401",Ee.VARIABLE_LENGTH,30],["402",17],["403",Ee.VARIABLE_LENGTH,30],["410",13],["411",13],["412",13],["413",13],["414",13],["420",Ee.VARIABLE_LENGTH,20],["421",Ee.VARIABLE_LENGTH,15],["422",3],["423",Ee.VARIABLE_LENGTH,15],["424",3],["425",3],["426",3]],Ee.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH=[["310",6],["311",6],["312",6],["313",6],["314",6],["315",6],["316",6],["320",6],["321",6],["322",6],["323",6],["324",6],["325",6],["326",6],["327",6],["328",6],["329",6],["330",6],["331",6],["332",6],["333",6],["334",6],["335",6],["336",6],["340",6],["341",6],["342",6],["343",6],["344",6],["345",6],["346",6],["347",6],["348",6],["349",6],["350",6],["351",6],["352",6],["353",6],["354",6],["355",6],["356",6],["357",6],["360",6],["361",6],["362",6],["363",6],["364",6],["365",6],["366",6],["367",6],["368",6],["369",6],["390",Ee.VARIABLE_LENGTH,15],["391",Ee.VARIABLE_LENGTH,18],["392",Ee.VARIABLE_LENGTH,15],["393",Ee.VARIABLE_LENGTH,18],["703",Ee.VARIABLE_LENGTH,30]],Ee.FOUR_DIGIT_DATA_LENGTH=[["7001",13],["7002",Ee.VARIABLE_LENGTH,30],["7003",10],["8001",14],["8002",Ee.VARIABLE_LENGTH,20],["8003",Ee.VARIABLE_LENGTH,30],["8004",Ee.VARIABLE_LENGTH,30],["8005",6],["8006",18],["8007",Ee.VARIABLE_LENGTH,30],["8008",Ee.VARIABLE_LENGTH,12],["8018",18],["8020",Ee.VARIABLE_LENGTH,25],["8100",6],["8101",10],["8102",2],["8110",Ee.VARIABLE_LENGTH,70],["8200",Ee.VARIABLE_LENGTH,70]];class mr{constructor(e){this.buffer=new xe,this.information=e}decodeAllCodes(e,r){let i=r,s=null;do{let a=this.decodeGeneralPurposeField(i,s),c=Ee.parseFieldsInGeneralPurpose(a.getNewString());if(c!=null&&e.append(c),a.isRemaining()?s=""+a.getRemainingValue():s=null,i===a.getNewPosition())break;i=a.getNewPosition()}while(!0);return e.toString()}isStillNumeric(e){if(e+7>this.information.getSize())return e+4<=this.information.getSize();for(let r=e;r<e+3;++r)if(this.information.get(r))return!0;return this.information.get(e+3)}decodeNumeric(e){if(e+7>this.information.getSize()){let a=this.extractNumericValueFromBitArray(e,4);return a===0?new dn(this.information.getSize(),dn.FNC1,dn.FNC1):new dn(this.information.getSize(),a-1,dn.FNC1)}let r=this.extractNumericValueFromBitArray(e,7),i=(r-8)/11,s=(r-8)%11;return new dn(e+7,i,s)}extractNumericValueFromBitArray(e,r){return mr.extractNumericValueFromBitArray(this.information,e,r)}static extractNumericValueFromBitArray(e,r,i){let s=0;for(let a=0;a<i;++a)e.get(r+a)&&(s|=1<<i-a-1);return s}decodeGeneralPurposeField(e,r){this.buffer.setLengthToZero(),r!=null&&this.buffer.append(r),this.current.setPosition(e);let i=this.parseBlocks();return i!=null&&i.isRemaining()?new ar(this.current.getPosition(),this.buffer.toString(),i.getRemainingValue()):new ar(this.current.getPosition(),this.buffer.toString())}parseBlocks(){let e,r;do{let i=this.current.getPosition();if(this.current.isAlpha()?(r=this.parseAlphaBlock(),e=r.isFinished()):this.current.isIsoIec646()?(r=this.parseIsoIec646Block(),e=r.isFinished()):(r=this.parseNumericBlock(),e=r.isFinished()),!(i!==this.current.getPosition())&&!e)break}while(!e);return r.getDecodedInformation()}parseNumericBlock(){for(;this.isStillNumeric(this.current.getPosition());){let e=this.decodeNumeric(this.current.getPosition());if(this.current.setPosition(e.getNewPosition()),e.isFirstDigitFNC1()){let r;return e.isSecondDigitFNC1()?r=new ar(this.current.getPosition(),this.buffer.toString()):r=new ar(this.current.getPosition(),this.buffer.toString(),e.getSecondDigit()),new sr(!0,r)}if(this.buffer.append(e.getFirstDigit()),e.isSecondDigitFNC1()){let r=new ar(this.current.getPosition(),this.buffer.toString());return new sr(!0,r)}this.buffer.append(e.getSecondDigit())}return this.isNumericToAlphaNumericLatch(this.current.getPosition())&&(this.current.setAlpha(),this.current.incrementPosition(4)),new sr(!1)}parseIsoIec646Block(){for(;this.isStillIsoIec646(this.current.getPosition());){let e=this.decodeIsoIec646(this.current.getPosition());if(this.current.setPosition(e.getNewPosition()),e.isFNC1()){let r=new ar(this.current.getPosition(),this.buffer.toString());return new sr(!0,r)}this.buffer.append(e.getValue())}return this.isAlphaOr646ToNumericLatch(this.current.getPosition())?(this.current.incrementPosition(3),this.current.setNumeric()):this.isAlphaTo646ToAlphaLatch(this.current.getPosition())&&(this.current.getPosition()+5<this.information.getSize()?this.current.incrementPosition(5):this.current.setPosition(this.information.getSize()),this.current.setAlpha()),new sr(!1)}parseAlphaBlock(){for(;this.isStillAlpha(this.current.getPosition());){let e=this.decodeAlphanumeric(this.current.getPosition());if(this.current.setPosition(e.getNewPosition()),e.isFNC1()){let r=new ar(this.current.getPosition(),this.buffer.toString());return new sr(!0,r)}this.buffer.append(e.getValue())}return this.isAlphaOr646ToNumericLatch(this.current.getPosition())?(this.current.incrementPosition(3),this.current.setNumeric()):this.isAlphaTo646ToAlphaLatch(this.current.getPosition())&&(this.current.getPosition()+5<this.information.getSize()?this.current.incrementPosition(5):this.current.setPosition(this.information.getSize()),this.current.setIsoIec646()),new sr(!1)}isStillIsoIec646(e){if(e+5>this.information.getSize())return!1;let r=this.extractNumericValueFromBitArray(e,5);if(r>=5&&r<16)return!0;if(e+7>this.information.getSize())return!1;let i=this.extractNumericValueFromBitArray(e,7);if(i>=64&&i<116)return!0;if(e+8>this.information.getSize())return!1;let s=this.extractNumericValueFromBitArray(e,8);return s>=232&&s<253}decodeIsoIec646(e){let r=this.extractNumericValueFromBitArray(e,5);if(r===15)return new Jt(e+5,Jt.FNC1);if(r>=5&&r<15)return new Jt(e+5,"0"+(r-5));let i=this.extractNumericValueFromBitArray(e,7);if(i>=64&&i<90)return new Jt(e+7,""+(i+1));if(i>=90&&i<116)return new Jt(e+7,""+(i+7));let s=this.extractNumericValueFromBitArray(e,8),a;switch(s){case 232:a="!";break;case 233:a='"';break;case 234:a="%";break;case 235:a="&";break;case 236:a="'";break;case 237:a="(";break;case 238:a=")";break;case 239:a="*";break;case 240:a="+";break;case 241:a=",";break;case 242:a="-";break;case 243:a=".";break;case 244:a="/";break;case 245:a=":";break;case 246:a=";";break;case 247:a="<";break;case 248:a="=";break;case 249:a=">";break;case 250:a="?";break;case 251:a="_";break;case 252:a=" ";break;default:throw new j}return new Jt(e+8,a)}isStillAlpha(e){if(e+5>this.information.getSize())return!1;let r=this.extractNumericValueFromBitArray(e,5);if(r>=5&&r<16)return!0;if(e+6>this.information.getSize())return!1;let i=this.extractNumericValueFromBitArray(e,6);return i>=16&&i<63}decodeAlphanumeric(e){let r=this.extractNumericValueFromBitArray(e,5);if(r===15)return new Jt(e+5,Jt.FNC1);if(r>=5&&r<15)return new Jt(e+5,"0"+(r-5));let i=this.extractNumericValueFromBitArray(e,6);if(i>=32&&i<58)return new Jt(e+6,""+(i+33));let s;switch(i){case 58:s="*";break;case 59:s=",";break;case 60:s="-";break;case 61:s=".";break;case 62:s="/";break;default:throw new ue("Decoding invalid alphanumeric value: "+i)}return new Jt(e+6,s)}isAlphaTo646ToAlphaLatch(e){if(e+1>this.information.getSize())return!1;for(let r=0;r<5&&r+e<this.information.getSize();++r)if(r===2){if(!this.information.get(e+2))return!1}else if(this.information.get(e+r))return!1;return!0}isAlphaOr646ToNumericLatch(e){if(e+3>this.information.getSize())return!1;for(let r=e;r<e+3;++r)if(this.information.get(r))return!1;return!0}isNumericToAlphaNumericLatch(e){if(e+1>this.information.getSize())return!1;for(let r=0;r<4&&r+e<this.information.getSize();++r)if(this.information.get(e+r))return!1;return!0}}class lo{constructor(e){this.information=e,this.generalDecoder=new mr(e)}getInformation(){return this.information}getGeneralDecoder(){return this.generalDecoder}}class Qt extends lo{constructor(e){super(e)}encodeCompressedGtin(e,r){e.append("(01)");let i=e.length();e.append("9"),this.encodeCompressedGtinWithoutAI(e,r,i)}encodeCompressedGtinWithoutAI(e,r,i){for(let s=0;s<4;++s){let a=this.getGeneralDecoder().extractNumericValueFromBitArray(r+10*s,10);a/100===0&&e.append("0"),a/10===0&&e.append("0"),e.append(a)}Qt.appendCheckDigit(e,i)}static appendCheckDigit(e,r){let i=0;for(let s=0;s<13;s++){let a=e.charAt(s+r).charCodeAt(0)-48;i+=(s&1)===0?3*a:a}i=10-i%10,i===10&&(i=0),e.append(i)}}Qt.GTIN_SIZE=40;class xr extends Qt{constructor(e){super(e)}parseInformation(){let e=new xe;e.append("(01)");let r=e.length(),i=this.getGeneralDecoder().extractNumericValueFromBitArray(xr.HEADER_SIZE,4);return e.append(i),this.encodeCompressedGtinWithoutAI(e,xr.HEADER_SIZE+4,r),this.getGeneralDecoder().decodeAllCodes(e,xr.HEADER_SIZE+44)}}xr.HEADER_SIZE=4;class pi extends lo{constructor(e){super(e)}parseInformation(){let e=new xe;return this.getGeneralDecoder().decodeAllCodes(e,pi.HEADER_SIZE)}}pi.HEADER_SIZE=5;class gi extends Qt{constructor(e){super(e)}encodeCompressedWeight(e,r,i){let s=this.getGeneralDecoder().extractNumericValueFromBitArray(r,i);this.addWeightCode(e,s);let a=this.checkWeight(s),c=1e5;for(let d=0;d<5;++d)a/c===0&&e.append("0"),c/=10;e.append(a)}}class kn extends gi{constructor(e){super(e)}parseInformation(){if(this.getInformation().getSize()!=kn.HEADER_SIZE+gi.GTIN_SIZE+kn.WEIGHT_SIZE)throw new F;let e=new xe;return this.encodeCompressedGtin(e,kn.HEADER_SIZE),this.encodeCompressedWeight(e,kn.HEADER_SIZE+gi.GTIN_SIZE,kn.WEIGHT_SIZE),e.toString()}}kn.HEADER_SIZE=5,kn.WEIGHT_SIZE=15;class _1 extends kn{constructor(e){super(e)}addWeightCode(e,r){e.append("(3103)")}checkWeight(e){return e}}class v1 extends kn{constructor(e){super(e)}addWeightCode(e,r){r<1e4?e.append("(3202)"):e.append("(3203)")}checkWeight(e){return e<1e4?e:e-1e4}}class Rn extends Qt{constructor(e){super(e)}parseInformation(){if(this.getInformation().getSize()<Rn.HEADER_SIZE+Qt.GTIN_SIZE)throw new F;let e=new xe;this.encodeCompressedGtin(e,Rn.HEADER_SIZE);let r=this.getGeneralDecoder().extractNumericValueFromBitArray(Rn.HEADER_SIZE+Qt.GTIN_SIZE,Rn.LAST_DIGIT_SIZE);e.append("(392"),e.append(r),e.append(")");let i=this.getGeneralDecoder().decodeGeneralPurposeField(Rn.HEADER_SIZE+Qt.GTIN_SIZE+Rn.LAST_DIGIT_SIZE,null);return e.append(i.getNewString()),e.toString()}}Rn.HEADER_SIZE=8,Rn.LAST_DIGIT_SIZE=2;class jt extends Qt{constructor(e){super(e)}parseInformation(){if(this.getInformation().getSize()<jt.HEADER_SIZE+Qt.GTIN_SIZE)throw new F;let e=new xe;this.encodeCompressedGtin(e,jt.HEADER_SIZE);let r=this.getGeneralDecoder().extractNumericValueFromBitArray(jt.HEADER_SIZE+Qt.GTIN_SIZE,jt.LAST_DIGIT_SIZE);e.append("(393"),e.append(r),e.append(")");let i=this.getGeneralDecoder().extractNumericValueFromBitArray(jt.HEADER_SIZE+Qt.GTIN_SIZE+jt.LAST_DIGIT_SIZE,jt.FIRST_THREE_DIGITS_SIZE);i/100==0&&e.append("0"),i/10==0&&e.append("0"),e.append(i);let s=this.getGeneralDecoder().decodeGeneralPurposeField(jt.HEADER_SIZE+Qt.GTIN_SIZE+jt.LAST_DIGIT_SIZE+jt.FIRST_THREE_DIGITS_SIZE,null);return e.append(s.getNewString()),e.toString()}}jt.HEADER_SIZE=8,jt.LAST_DIGIT_SIZE=2,jt.FIRST_THREE_DIGITS_SIZE=10;class ft extends gi{constructor(e,r,i){super(e),this.dateCode=i,this.firstAIdigits=r}parseInformation(){if(this.getInformation().getSize()!=ft.HEADER_SIZE+ft.GTIN_SIZE+ft.WEIGHT_SIZE+ft.DATE_SIZE)throw new F;let e=new xe;return this.encodeCompressedGtin(e,ft.HEADER_SIZE),this.encodeCompressedWeight(e,ft.HEADER_SIZE+ft.GTIN_SIZE,ft.WEIGHT_SIZE),this.encodeCompressedDate(e,ft.HEADER_SIZE+ft.GTIN_SIZE+ft.WEIGHT_SIZE),e.toString()}encodeCompressedDate(e,r){let i=this.getGeneralDecoder().extractNumericValueFromBitArray(r,ft.DATE_SIZE);if(i==38400)return;e.append("("),e.append(this.dateCode),e.append(")");let s=i%32;i/=32;let a=i%12+1;i/=12;let c=i;c/10==0&&e.append("0"),e.append(c),a/10==0&&e.append("0"),e.append(a),s/10==0&&e.append("0"),e.append(s)}addWeightCode(e,r){e.append("("),e.append(this.firstAIdigits),e.append(r/1e5),e.append(")")}checkWeight(e){return e%1e5}}ft.HEADER_SIZE=8,ft.WEIGHT_SIZE=20,ft.DATE_SIZE=16;function Os(_){try{if(_.get(1))return new xr(_);if(!_.get(2))return new pi(_);switch(mr.extractNumericValueFromBitArray(_,1,4)){case 4:return new _1(_);case 5:return new v1(_)}switch(mr.extractNumericValueFromBitArray(_,1,5)){case 12:return new Rn(_);case 13:return new jt(_)}switch(mr.extractNumericValueFromBitArray(_,1,7)){case 56:return new ft(_,"310","11");case 57:return new ft(_,"320","11");case 58:return new ft(_,"310","13");case 59:return new ft(_,"320","13");case 60:return new ft(_,"310","15");case 61:return new ft(_,"320","15");case 62:return new ft(_,"310","17");case 63:return new ft(_,"320","17")}}catch(e){throw console.log(e),new ue("unknown decoder: "+_)}}class Wn{constructor(e,r,i,s){this.leftchar=e,this.rightchar=r,this.finderpattern=i,this.maybeLast=s}mayBeLast(){return this.maybeLast}getLeftChar(){return this.leftchar}getRightChar(){return this.rightchar}getFinderPattern(){return this.finderpattern}mustBeLast(){return this.rightchar==null}toString(){return"[ "+this.leftchar+", "+this.rightchar+" : "+(this.finderpattern==null?"null":this.finderpattern.getValue())+" ]"}static equals(e,r){return e instanceof Wn?Wn.equalsOrNull(e.leftchar,r.leftchar)&&Wn.equalsOrNull(e.rightchar,r.rightchar)&&Wn.equalsOrNull(e.finderpattern,r.finderpattern):!1}static equalsOrNull(e,r){return e===null?r===null:Wn.equals(e,r)}hashCode(){return this.leftchar.getValue()^this.rightchar.getValue()^this.finderpattern.getValue()}}class co{constructor(e,r,i){this.pairs=e,this.rowNumber=r,this.wasReversed=i}getPairs(){return this.pairs}getRowNumber(){return this.rowNumber}isReversed(){return this.wasReversed}isEquivalent(e){return this.checkEqualitity(this,e)}toString(){return"{ "+this.pairs+" }"}equals(e,r){return e instanceof co?this.checkEqualitity(e,r)&&e.wasReversed===r.wasReversed:!1}checkEqualitity(e,r){if(!e||!r)return;let i;return e.forEach((s,a)=>{r.forEach(c=>{s.getLeftChar().getValue()===c.getLeftChar().getValue()&&s.getRightChar().getValue()===c.getRightChar().getValue()&&s.getFinderPatter().getValue()===c.getFinderPatter().getValue()&&(i=!0)})}),i}}class ee extends $t{constructor(e){super(...arguments),this.pairs=new Array(ee.MAX_PAIRS),this.rows=new Array,this.startEnd=[2],this.verbose=e===!0}decodeRow(e,r,i){this.pairs.length=0,this.startFromEven=!1;try{return ee.constructResult(this.decodeRow2pairs(e,r))}catch(s){this.verbose&&console.log(s)}return this.pairs.length=0,this.startFromEven=!0,ee.constructResult(this.decodeRow2pairs(e,r))}reset(){this.pairs.length=0,this.rows.length=0}decodeRow2pairs(e,r){let i=!1;for(;!i;)try{this.pairs.push(this.retrieveNextPair(r,this.pairs,e))}catch(a){if(a instanceof F){if(!this.pairs.length)throw new F;i=!0}}if(this.checkChecksum())return this.pairs;let s;if(this.rows.length?s=!0:s=!1,this.storeRow(e,!1),s){let a=this.checkRowsBoolean(!1);if(a!=null||(a=this.checkRowsBoolean(!0),a!=null))return a}throw new F}checkRowsBoolean(e){if(this.rows.length>25)return this.rows.length=0,null;this.pairs.length=0,e&&(this.rows=this.rows.reverse());let r=null;try{r=this.checkRows(new Array,0)}catch(i){this.verbose&&console.log(i)}return e&&(this.rows=this.rows.reverse()),r}checkRows(e,r){for(let i=r;i<this.rows.length;i++){let s=this.rows[i];this.pairs.length=0;for(let c of e)this.pairs.push(c.getPairs());if(this.pairs.push(s.getPairs()),!ee.isValidSequence(this.pairs))continue;if(this.checkChecksum())return this.pairs;let a=new Array(e);a.push(s);try{return this.checkRows(a,i+1)}catch(c){this.verbose&&console.log(c)}}throw new F}static isValidSequence(e){for(let r of ee.FINDER_PATTERN_SEQUENCES){if(e.length>r.length)continue;let i=!0;for(let s=0;s<e.length;s++)if(e[s].getFinderPattern().getValue()!=r[s]){i=!1;break}if(i)return!0}return!1}storeRow(e,r){let i=0,s=!1,a=!1;for(;i<this.rows.length;){let c=this.rows[i];if(c.getRowNumber()>e){a=c.isEquivalent(this.pairs);break}s=c.isEquivalent(this.pairs),i++}a||s||ee.isPartialRow(this.pairs,this.rows)||(this.rows.push(i,new co(this.pairs,e,r)),this.removePartialRows(this.pairs,this.rows))}removePartialRows(e,r){for(let i of r)if(i.getPairs().length!==e.length){for(let s of i.getPairs())for(let a of e)if(Wn.equals(s,a))break}}static isPartialRow(e,r){for(let i of r){let s=!0;for(let a of e){let c=!1;for(let d of i.getPairs())if(a.equals(d)){c=!0;break}if(!c){s=!1;break}}if(s)return!0}return!1}getRows(){return this.rows}static constructResult(e){let r=y1.buildBitArray(e),s=Os(r).parseInformation(),a=e[0].getFinderPattern().getResultPoints(),c=e[e.length-1].getFinderPattern().getResultPoints(),d=[a[0],a[1],c[0],c[1]];return new Pe(s,null,null,d,S.RSS_EXPANDED,null)}checkChecksum(){let e=this.pairs.get(0),r=e.getLeftChar(),i=e.getRightChar();if(i==null)return!1;let s=i.getChecksumPortion(),a=2;for(let d=1;d<this.pairs.size();++d){let h=this.pairs.get(d);s+=h.getLeftChar().getChecksumPortion(),a++;let p=h.getRightChar();p!=null&&(s+=p.getChecksumPortion(),a++)}return s%=211,211*(a-4)+s==r.getValue()}static getNextSecondBar(e,r){let i;return e.get(r)?(i=e.getNextUnset(r),i=e.getNextSet(i)):(i=e.getNextSet(r),i=e.getNextUnset(i)),i}retrieveNextPair(e,r,i){let s=r.length%2==0;this.startFromEven&&(s=!s);let a,c=!0,d=-1;do this.findNextPair(e,r,d),a=this.parseFoundFinderPattern(e,i,s),a==null?d=ee.getNextSecondBar(e,this.startEnd[0]):c=!1;while(c);let h=this.decodeDataCharacter(e,a,s,!0);if(!this.isEmptyPair(r)&&r[r.length-1].mustBeLast())throw new F;let p;try{p=this.decodeDataCharacter(e,a,s,!1)}catch(w){p=null,this.verbose&&console.log(w)}return new Wn(h,p,a,!0)}isEmptyPair(e){return e.length===0}findNextPair(e,r,i){let s=this.getDecodeFinderCounters();s[0]=0,s[1]=0,s[2]=0,s[3]=0;let a=e.getSize(),c;i>=0?c=i:this.isEmptyPair(r)?c=0:c=r[r.length-1].getFinderPattern().getStartEnd()[1];let d=r.length%2!=0;this.startFromEven&&(d=!d);let h=!1;for(;c<a&&(h=!e.get(c),!!h);)c++;let p=0,w=c;for(let v=c;v<a;v++)if(e.get(v)!=h)s[p]++;else{if(p==3){if(d&&ee.reverseCounters(s),ee.isFinderPattern(s)){this.startEnd[0]=w,this.startEnd[1]=v;return}d&&ee.reverseCounters(s),w+=s[0]+s[1],s[0]=s[2],s[1]=s[3],s[2]=0,s[3]=0,p--}else p++;s[p]=1,h=!h}throw new F}static reverseCounters(e){let r=e.length;for(let i=0;i<r/2;++i){let s=e[i];e[i]=e[r-i-1],e[r-i-1]=s}}parseFoundFinderPattern(e,r,i){let s,a,c;if(i){let p=this.startEnd[0]-1;for(;p>=0&&!e.get(p);)p--;p++,s=this.startEnd[0]-p,a=p,c=this.startEnd[1]}else a=this.startEnd[0],c=e.getNextUnset(this.startEnd[1]+1),s=c-this.startEnd[1];let d=this.getDecodeFinderCounters();D.arraycopy(d,0,d,1,d.length-1),d[0]=s;let h;try{h=this.parseFinderValue(d,ee.FINDER_PATTERNS)}catch{return null}return new hi(h,[a,c],a,c,r)}decodeDataCharacter(e,r,i,s){let a=this.getDataCharacterCounters();for(let ot=0;ot<a.length;ot++)a[ot]=0;if(s)ee.recordPatternInReverse(e,r.getStartEnd()[0],a);else{ee.recordPattern(e,r.getStartEnd()[1],a);for(let ot=0,Bt=a.length-1;ot<Bt;ot++,Bt--){let on=a[ot];a[ot]=a[Bt],a[Bt]=on}}let c=17,d=ke.sum(new Int32Array(a))/c,h=(r.getStartEnd()[1]-r.getStartEnd()[0])/15;if(Math.abs(d-h)/h>.3)throw new F;let p=this.getOddCounts(),w=this.getEvenCounts(),v=this.getOddRoundingErrors(),E=this.getEvenRoundingErrors();for(let ot=0;ot<a.length;ot++){let Bt=1*a[ot]/d,on=Bt+.5;if(on<1){if(Bt<.3)throw new F;on=1}else if(on>8){if(Bt>8.7)throw new F;on=8}let Cr=ot/2;(ot&1)==0?(p[Cr]=on,v[Cr]=Bt-on):(w[Cr]=on,E[Cr]=Bt-on)}this.adjustOddEvenCounts(c);let O=4*r.getValue()+(i?0:2)+(s?0:1)-1,L=0,$=0;for(let ot=p.length-1;ot>=0;ot--){if(ee.isNotA1left(r,i,s)){let Bt=ee.WEIGHTS[O][2*ot];$+=p[ot]*Bt}L+=p[ot]}let Z=0;for(let ot=w.length-1;ot>=0;ot--)if(ee.isNotA1left(r,i,s)){let Bt=ee.WEIGHTS[O][2*ot+1];Z+=w[ot]*Bt}let G=$+Z;if((L&1)!=0||L>13||L<4)throw new F;let ae=(13-L)/2,ce=ee.SYMBOL_WIDEST[ae],oe=9-ce,He=Nn.getRSSvalue(p,ce,!0),ze=Nn.getRSSvalue(w,oe,!1),tn=ee.EVEN_TOTAL_SUBSET[ae],vn=ee.GSUM[ae],nn=He*tn+ze+vn;return new gr(nn,G)}static isNotA1left(e,r,i){return!(e.getValue()==0&&r&&i)}adjustOddEvenCounts(e){let r=ke.sum(new Int32Array(this.getOddCounts())),i=ke.sum(new Int32Array(this.getEvenCounts())),s=!1,a=!1;r>13?a=!0:r<4&&(s=!0);let c=!1,d=!1;i>13?d=!0:i<4&&(c=!0);let h=r+i-e,p=(r&1)==1,w=(i&1)==0;if(h==1)if(p){if(w)throw new F;a=!0}else{if(!w)throw new F;d=!0}else if(h==-1)if(p){if(w)throw new F;s=!0}else{if(!w)throw new F;c=!0}else if(h==0){if(p){if(!w)throw new F;r<i?(s=!0,d=!0):(a=!0,c=!0)}else if(w)throw new F}else throw new F;if(s){if(a)throw new F;ee.increment(this.getOddCounts(),this.getOddRoundingErrors())}if(a&&ee.decrement(this.getOddCounts(),this.getOddRoundingErrors()),c){if(d)throw new F;ee.increment(this.getEvenCounts(),this.getOddRoundingErrors())}d&&ee.decrement(this.getEvenCounts(),this.getEvenRoundingErrors())}}ee.SYMBOL_WIDEST=[7,5,4,3,1],ee.EVEN_TOTAL_SUBSET=[4,20,52,104,204],ee.GSUM=[0,348,1388,2948,3988],ee.FINDER_PATTERNS=[Int32Array.from([1,8,4,1]),Int32Array.from([3,6,4,1]),Int32Array.from([3,4,6,1]),Int32Array.from([3,2,8,1]),Int32Array.from([2,6,5,1]),Int32Array.from([2,2,9,1])],ee.WEIGHTS=[[1,3,9,27,81,32,96,77],[20,60,180,118,143,7,21,63],[189,145,13,39,117,140,209,205],[193,157,49,147,19,57,171,91],[62,186,136,197,169,85,44,132],[185,133,188,142,4,12,36,108],[113,128,173,97,80,29,87,50],[150,28,84,41,123,158,52,156],[46,138,203,187,139,206,196,166],[76,17,51,153,37,111,122,155],[43,129,176,106,107,110,119,146],[16,48,144,10,30,90,59,177],[109,116,137,200,178,112,125,164],[70,210,208,202,184,130,179,115],[134,191,151,31,93,68,204,190],[148,22,66,198,172,94,71,2],[6,18,54,162,64,192,154,40],[120,149,25,75,14,42,126,167],[79,26,78,23,69,207,199,175],[103,98,83,38,114,131,182,124],[161,61,183,127,170,88,53,159],[55,165,73,8,24,72,5,15],[45,135,194,160,58,174,100,89]],ee.FINDER_PAT_A=0,ee.FINDER_PAT_B=1,ee.FINDER_PAT_C=2,ee.FINDER_PAT_D=3,ee.FINDER_PAT_E=4,ee.FINDER_PAT_F=5,ee.FINDER_PATTERN_SEQUENCES=[[ee.FINDER_PAT_A,ee.FINDER_PAT_A],[ee.FINDER_PAT_A,ee.FINDER_PAT_B,ee.FINDER_PAT_B],[ee.FINDER_PAT_A,ee.FINDER_PAT_C,ee.FINDER_PAT_B,ee.FINDER_PAT_D],[ee.FINDER_PAT_A,ee.FINDER_PAT_E,ee.FINDER_PAT_B,ee.FINDER_PAT_D,ee.FINDER_PAT_C],[ee.FINDER_PAT_A,ee.FINDER_PAT_E,ee.FINDER_PAT_B,ee.FINDER_PAT_D,ee.FINDER_PAT_D,ee.FINDER_PAT_F],[ee.FINDER_PAT_A,ee.FINDER_PAT_E,ee.FINDER_PAT_B,ee.FINDER_PAT_D,ee.FINDER_PAT_E,ee.FINDER_PAT_F,ee.FINDER_PAT_F],[ee.FINDER_PAT_A,ee.FINDER_PAT_A,ee.FINDER_PAT_B,ee.FINDER_PAT_B,ee.FINDER_PAT_C,ee.FINDER_PAT_C,ee.FINDER_PAT_D,ee.FINDER_PAT_D],[ee.FINDER_PAT_A,ee.FINDER_PAT_A,ee.FINDER_PAT_B,ee.FINDER_PAT_B,ee.FINDER_PAT_C,ee.FINDER_PAT_C,ee.FINDER_PAT_D,ee.FINDER_PAT_E,ee.FINDER_PAT_E],[ee.FINDER_PAT_A,ee.FINDER_PAT_A,ee.FINDER_PAT_B,ee.FINDER_PAT_B,ee.FINDER_PAT_C,ee.FINDER_PAT_C,ee.FINDER_PAT_D,ee.FINDER_PAT_E,ee.FINDER_PAT_F,ee.FINDER_PAT_F],[ee.FINDER_PAT_A,ee.FINDER_PAT_A,ee.FINDER_PAT_B,ee.FINDER_PAT_B,ee.FINDER_PAT_C,ee.FINDER_PAT_D,ee.FINDER_PAT_D,ee.FINDER_PAT_E,ee.FINDER_PAT_E,ee.FINDER_PAT_F,ee.FINDER_PAT_F]],ee.MAX_PAIRS=11;class C1 extends gr{constructor(e,r,i){super(e,r),this.count=0,this.finderPattern=i}getFinderPattern(){return this.finderPattern}getCount(){return this.count}incrementCount(){this.count++}}class yt extends $t{constructor(){super(...arguments),this.possibleLeftPairs=[],this.possibleRightPairs=[]}decodeRow(e,r,i){const s=this.decodePair(r,!1,e,i);yt.addOrTally(this.possibleLeftPairs,s),r.reverse();let a=this.decodePair(r,!0,e,i);yt.addOrTally(this.possibleRightPairs,a),r.reverse();for(let c of this.possibleLeftPairs)if(c.getCount()>1){for(let d of this.possibleRightPairs)if(d.getCount()>1&&yt.checkChecksum(c,d))return yt.constructResult(c,d)}throw new F}static addOrTally(e,r){if(r==null)return;let i=!1;for(let s of e)if(s.getValue()===r.getValue()){s.incrementCount(),i=!0;break}i||e.push(r)}reset(){this.possibleLeftPairs.length=0,this.possibleRightPairs.length=0}static constructResult(e,r){let i=4537077*e.getValue()+r.getValue(),s=new String(i).toString(),a=new xe;for(let p=13-s.length;p>0;p--)a.append("0");a.append(s);let c=0;for(let p=0;p<13;p++){let w=a.charAt(p).charCodeAt(0)-48;c+=(p&1)===0?3*w:w}c=10-c%10,c===10&&(c=0),a.append(c.toString());let d=e.getFinderPattern().getResultPoints(),h=r.getFinderPattern().getResultPoints();return new Pe(a.toString(),null,0,[d[0],d[1],h[0],h[1]],S.RSS_14,new Date().getTime())}static checkChecksum(e,r){let i=(e.getChecksumPortion()+16*r.getChecksumPortion())%79,s=9*e.getFinderPattern().getValue()+r.getFinderPattern().getValue();return s>72&&s--,s>8&&s--,i===s}decodePair(e,r,i,s){try{let a=this.findFinderPattern(e,r),c=this.parseFoundFinderPattern(e,i,r,a),d=s==null?null:s.get(Q.NEED_RESULT_POINT_CALLBACK);if(d!=null){let w=(a[0]+a[1])/2;r&&(w=e.getSize()-1-w),d.foundPossibleResultPoint(new Se(w,i))}let h=this.decodeDataCharacter(e,c,!0),p=this.decodeDataCharacter(e,c,!1);return new C1(1597*h.getValue()+p.getValue(),h.getChecksumPortion()+4*p.getChecksumPortion(),c)}catch{return null}}decodeDataCharacter(e,r,i){let s=this.getDataCharacterCounters();for(let Z=0;Z<s.length;Z++)s[Z]=0;if(i)bt.recordPatternInReverse(e,r.getStartEnd()[0],s);else{bt.recordPattern(e,r.getStartEnd()[1]+1,s);for(let Z=0,G=s.length-1;Z<G;Z++,G--){let ae=s[Z];s[Z]=s[G],s[G]=ae}}let a=i?16:15,c=ke.sum(new Int32Array(s))/a,d=this.getOddCounts(),h=this.getEvenCounts(),p=this.getOddRoundingErrors(),w=this.getEvenRoundingErrors();for(let Z=0;Z<s.length;Z++){let G=s[Z]/c,ae=Math.floor(G+.5);ae<1?ae=1:ae>8&&(ae=8);let ce=Math.floor(Z/2);(Z&1)===0?(d[ce]=ae,p[ce]=G-ae):(h[ce]=ae,w[ce]=G-ae)}this.adjustOddEvenCounts(i,a);let v=0,E=0;for(let Z=d.length-1;Z>=0;Z--)E*=9,E+=d[Z],v+=d[Z];let O=0,L=0;for(let Z=h.length-1;Z>=0;Z--)O*=9,O+=h[Z],L+=h[Z];let $=E+3*O;if(i){if((v&1)!==0||v>12||v<4)throw new F;let Z=(12-v)/2,G=yt.OUTSIDE_ODD_WIDEST[Z],ae=9-G,ce=Nn.getRSSvalue(d,G,!1),oe=Nn.getRSSvalue(h,ae,!0),He=yt.OUTSIDE_EVEN_TOTAL_SUBSET[Z],ze=yt.OUTSIDE_GSUM[Z];return new gr(ce*He+oe+ze,$)}else{if((L&1)!==0||L>10||L<4)throw new F;let Z=(10-L)/2,G=yt.INSIDE_ODD_WIDEST[Z],ae=9-G,ce=Nn.getRSSvalue(d,G,!0),oe=Nn.getRSSvalue(h,ae,!1),He=yt.INSIDE_ODD_TOTAL_SUBSET[Z],ze=yt.INSIDE_GSUM[Z];return new gr(oe*He+ce+ze,$)}}findFinderPattern(e,r){let i=this.getDecodeFinderCounters();i[0]=0,i[1]=0,i[2]=0,i[3]=0;let s=e.getSize(),a=!1,c=0;for(;c<s&&(a=!e.get(c),r!==a);)c++;let d=0,h=c;for(let p=c;p<s;p++)if(e.get(p)!==a)i[d]++;else{if(d===3){if($t.isFinderPattern(i))return[h,p];h+=i[0]+i[1],i[0]=i[2],i[1]=i[3],i[2]=0,i[3]=0,d--}else d++;i[d]=1,a=!a}throw new F}parseFoundFinderPattern(e,r,i,s){let a=e.get(s[0]),c=s[0]-1;for(;c>=0&&a!==e.get(c);)c--;c++;const d=s[0]-c,h=this.getDecodeFinderCounters(),p=new Int32Array(h.length);D.arraycopy(h,0,p,1,h.length-1),p[0]=d;const w=this.parseFinderValue(p,yt.FINDER_PATTERNS);let v=c,E=s[1];return i&&(v=e.getSize()-1-v,E=e.getSize()-1-E),new hi(w,[c,s[1]],v,E,r)}adjustOddEvenCounts(e,r){let i=ke.sum(new Int32Array(this.getOddCounts())),s=ke.sum(new Int32Array(this.getEvenCounts())),a=!1,c=!1,d=!1,h=!1;e?(i>12?c=!0:i<4&&(a=!0),s>12?h=!0:s<4&&(d=!0)):(i>11?c=!0:i<5&&(a=!0),s>10?h=!0:s<4&&(d=!0));let p=i+s-r,w=(i&1)===(e?1:0),v=(s&1)===1;if(p===1)if(w){if(v)throw new F;c=!0}else{if(!v)throw new F;h=!0}else if(p===-1)if(w){if(v)throw new F;a=!0}else{if(!v)throw new F;d=!0}else if(p===0){if(w){if(!v)throw new F;i<s?(a=!0,h=!0):(c=!0,d=!0)}else if(v)throw new F}else throw new F;if(a){if(c)throw new F;$t.increment(this.getOddCounts(),this.getOddRoundingErrors())}if(c&&$t.decrement(this.getOddCounts(),this.getOddRoundingErrors()),d){if(h)throw new F;$t.increment(this.getEvenCounts(),this.getOddRoundingErrors())}h&&$t.decrement(this.getEvenCounts(),this.getEvenRoundingErrors())}}yt.OUTSIDE_EVEN_TOTAL_SUBSET=[1,10,34,70,126],yt.INSIDE_ODD_TOTAL_SUBSET=[4,20,48,81],yt.OUTSIDE_GSUM=[0,161,961,2015,2715],yt.INSIDE_GSUM=[0,336,1036,1516],yt.OUTSIDE_ODD_WIDEST=[8,6,4,3,1],yt.INSIDE_ODD_WIDEST=[2,4,6,8],yt.FINDER_PATTERNS=[Int32Array.from([3,8,2,1]),Int32Array.from([3,5,5,1]),Int32Array.from([3,3,7,1]),Int32Array.from([3,1,9,1]),Int32Array.from([2,7,4,1]),Int32Array.from([2,5,6,1]),Int32Array.from([2,3,8,1]),Int32Array.from([1,5,7,1]),Int32Array.from([1,3,9,1])];class wr extends bt{constructor(e,r){super(),this.readers=[],this.verbose=r===!0;const i=e?e.get(Q.POSSIBLE_FORMATS):null,s=e&&e.get(Q.ASSUME_CODE_39_CHECK_DIGIT)!==void 0;i?((i.includes(S.EAN_13)||i.includes(S.UPC_A)||i.includes(S.EAN_8)||i.includes(S.UPC_E))&&this.readers.push(new so(e)),i.includes(S.CODE_39)&&this.readers.push(new It(s)),i.includes(S.CODE_128)&&this.readers.push(new me),i.includes(S.ITF)&&this.readers.push(new rt),i.includes(S.RSS_14)&&this.readers.push(new yt),i.includes(S.RSS_EXPANDED)&&this.readers.push(new ee(this.verbose))):(this.readers.push(new so(e)),this.readers.push(new It),this.readers.push(new so(e)),this.readers.push(new me),this.readers.push(new rt),this.readers.push(new yt),this.readers.push(new ee(this.verbose)))}decodeRow(e,r,i){for(let s=0;s<this.readers.length;s++)try{return this.readers[s].decodeRow(e,r,i)}catch{}throw new F}reset(){this.readers.forEach(e=>e.reset())}}class b1 extends Fe{constructor(e=500,r){super(new wr(r),e,r)}}class Je{constructor(e,r,i){this.ecCodewords=e,this.ecBlocks=[r],i&&this.ecBlocks.push(i)}getECCodewords(){return this.ecCodewords}getECBlocks(){return this.ecBlocks}}class qe{constructor(e,r){this.count=e,this.dataCodewords=r}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class We{constructor(e,r,i,s,a,c){this.versionNumber=e,this.symbolSizeRows=r,this.symbolSizeColumns=i,this.dataRegionSizeRows=s,this.dataRegionSizeColumns=a,this.ecBlocks=c;let d=0;const h=c.getECCodewords(),p=c.getECBlocks();for(let w of p)d+=w.getCount()*(w.getDataCodewords()+h);this.totalCodewords=d}getVersionNumber(){return this.versionNumber}getSymbolSizeRows(){return this.symbolSizeRows}getSymbolSizeColumns(){return this.symbolSizeColumns}getDataRegionSizeRows(){return this.dataRegionSizeRows}getDataRegionSizeColumns(){return this.dataRegionSizeColumns}getTotalCodewords(){return this.totalCodewords}getECBlocks(){return this.ecBlocks}static getVersionForDimensions(e,r){if((e&1)!==0||(r&1)!==0)throw new j;for(let i of We.VERSIONS)if(i.symbolSizeRows===e&&i.symbolSizeColumns===r)return i;throw new j}toString(){return""+this.versionNumber}static buildVersions(){return[new We(1,10,10,8,8,new Je(5,new qe(1,3))),new We(2,12,12,10,10,new Je(7,new qe(1,5))),new We(3,14,14,12,12,new Je(10,new qe(1,8))),new We(4,16,16,14,14,new Je(12,new qe(1,12))),new We(5,18,18,16,16,new Je(14,new qe(1,18))),new We(6,20,20,18,18,new Je(18,new qe(1,22))),new We(7,22,22,20,20,new Je(20,new qe(1,30))),new We(8,24,24,22,22,new Je(24,new qe(1,36))),new We(9,26,26,24,24,new Je(28,new qe(1,44))),new We(10,32,32,14,14,new Je(36,new qe(1,62))),new We(11,36,36,16,16,new Je(42,new qe(1,86))),new We(12,40,40,18,18,new Je(48,new qe(1,114))),new We(13,44,44,20,20,new Je(56,new qe(1,144))),new We(14,48,48,22,22,new Je(68,new qe(1,174))),new We(15,52,52,24,24,new Je(42,new qe(2,102))),new We(16,64,64,14,14,new Je(56,new qe(2,140))),new We(17,72,72,16,16,new Je(36,new qe(4,92))),new We(18,80,80,18,18,new Je(48,new qe(4,114))),new We(19,88,88,20,20,new Je(56,new qe(4,144))),new We(20,96,96,22,22,new Je(68,new qe(4,174))),new We(21,104,104,24,24,new Je(56,new qe(6,136))),new We(22,120,120,18,18,new Je(68,new qe(6,175))),new We(23,132,132,20,20,new Je(62,new qe(8,163))),new We(24,144,144,22,22,new Je(62,new qe(8,156),new qe(2,155))),new We(25,8,18,6,16,new Je(7,new qe(1,5))),new We(26,8,32,6,14,new Je(11,new qe(1,10))),new We(27,12,26,10,24,new Je(14,new qe(1,16))),new We(28,12,36,10,16,new Je(18,new qe(1,22))),new We(29,16,36,14,16,new Je(24,new qe(1,32))),new We(30,16,48,14,22,new Je(28,new qe(1,49)))]}}We.VERSIONS=We.buildVersions();class uo{constructor(e){const r=e.getHeight();if(r<8||r>144||(r&1)!==0)throw new j;this.version=uo.readVersion(e),this.mappingBitMatrix=this.extractDataRegion(e),this.readMappingMatrix=new le(this.mappingBitMatrix.getWidth(),this.mappingBitMatrix.getHeight())}getVersion(){return this.version}static readVersion(e){const r=e.getHeight(),i=e.getWidth();return We.getVersionForDimensions(r,i)}readCodewords(){const e=new Int8Array(this.version.getTotalCodewords());let r=0,i=4,s=0;const a=this.mappingBitMatrix.getHeight(),c=this.mappingBitMatrix.getWidth();let d=!1,h=!1,p=!1,w=!1;do if(i===a&&s===0&&!d)e[r++]=this.readCorner1(a,c)&255,i-=2,s+=2,d=!0;else if(i===a-2&&s===0&&(c&3)!==0&&!h)e[r++]=this.readCorner2(a,c)&255,i-=2,s+=2,h=!0;else if(i===a+4&&s===2&&(c&7)===0&&!p)e[r++]=this.readCorner3(a,c)&255,i-=2,s+=2,p=!0;else if(i===a-2&&s===0&&(c&7)===4&&!w)e[r++]=this.readCorner4(a,c)&255,i-=2,s+=2,w=!0;else{do i<a&&s>=0&&!this.readMappingMatrix.get(s,i)&&(e[r++]=this.readUtah(i,s,a,c)&255),i-=2,s+=2;while(i>=0&&s<c);i+=1,s+=3;do i>=0&&s<c&&!this.readMappingMatrix.get(s,i)&&(e[r++]=this.readUtah(i,s,a,c)&255),i+=2,s-=2;while(i<a&&s>=0);i+=3,s+=1}while(i<a||s<c);if(r!==this.version.getTotalCodewords())throw new j;return e}readModule(e,r,i,s){return e<0&&(e+=i,r+=4-(i+4&7)),r<0&&(r+=s,e+=4-(s+4&7)),this.readMappingMatrix.set(r,e),this.mappingBitMatrix.get(r,e)}readUtah(e,r,i,s){let a=0;return this.readModule(e-2,r-2,i,s)&&(a|=1),a<<=1,this.readModule(e-2,r-1,i,s)&&(a|=1),a<<=1,this.readModule(e-1,r-2,i,s)&&(a|=1),a<<=1,this.readModule(e-1,r-1,i,s)&&(a|=1),a<<=1,this.readModule(e-1,r,i,s)&&(a|=1),a<<=1,this.readModule(e,r-2,i,s)&&(a|=1),a<<=1,this.readModule(e,r-1,i,s)&&(a|=1),a<<=1,this.readModule(e,r,i,s)&&(a|=1),a}readCorner1(e,r){let i=0;return this.readModule(e-1,0,e,r)&&(i|=1),i<<=1,this.readModule(e-1,1,e,r)&&(i|=1),i<<=1,this.readModule(e-1,2,e,r)&&(i|=1),i<<=1,this.readModule(0,r-2,e,r)&&(i|=1),i<<=1,this.readModule(0,r-1,e,r)&&(i|=1),i<<=1,this.readModule(1,r-1,e,r)&&(i|=1),i<<=1,this.readModule(2,r-1,e,r)&&(i|=1),i<<=1,this.readModule(3,r-1,e,r)&&(i|=1),i}readCorner2(e,r){let i=0;return this.readModule(e-3,0,e,r)&&(i|=1),i<<=1,this.readModule(e-2,0,e,r)&&(i|=1),i<<=1,this.readModule(e-1,0,e,r)&&(i|=1),i<<=1,this.readModule(0,r-4,e,r)&&(i|=1),i<<=1,this.readModule(0,r-3,e,r)&&(i|=1),i<<=1,this.readModule(0,r-2,e,r)&&(i|=1),i<<=1,this.readModule(0,r-1,e,r)&&(i|=1),i<<=1,this.readModule(1,r-1,e,r)&&(i|=1),i}readCorner3(e,r){let i=0;return this.readModule(e-1,0,e,r)&&(i|=1),i<<=1,this.readModule(e-1,r-1,e,r)&&(i|=1),i<<=1,this.readModule(0,r-3,e,r)&&(i|=1),i<<=1,this.readModule(0,r-2,e,r)&&(i|=1),i<<=1,this.readModule(0,r-1,e,r)&&(i|=1),i<<=1,this.readModule(1,r-3,e,r)&&(i|=1),i<<=1,this.readModule(1,r-2,e,r)&&(i|=1),i<<=1,this.readModule(1,r-1,e,r)&&(i|=1),i}readCorner4(e,r){let i=0;return this.readModule(e-3,0,e,r)&&(i|=1),i<<=1,this.readModule(e-2,0,e,r)&&(i|=1),i<<=1,this.readModule(e-1,0,e,r)&&(i|=1),i<<=1,this.readModule(0,r-2,e,r)&&(i|=1),i<<=1,this.readModule(0,r-1,e,r)&&(i|=1),i<<=1,this.readModule(1,r-1,e,r)&&(i|=1),i<<=1,this.readModule(2,r-1,e,r)&&(i|=1),i<<=1,this.readModule(3,r-1,e,r)&&(i|=1),i}extractDataRegion(e){const r=this.version.getSymbolSizeRows(),i=this.version.getSymbolSizeColumns();if(e.getHeight()!==r)throw new b("Dimension of bitMatrix must match the version size");const s=this.version.getDataRegionSizeRows(),a=this.version.getDataRegionSizeColumns(),c=r/s|0,d=i/a|0,h=c*s,p=d*a,w=new le(p,h);for(let v=0;v<c;++v){const E=v*s;for(let O=0;O<d;++O){const L=O*a;for(let $=0;$<s;++$){const Z=v*(s+2)+1+$,G=E+$;for(let ae=0;ae<a;++ae){const ce=O*(a+2)+1+ae;if(e.get(ce,Z)){const oe=L+ae;w.set(oe,G)}}}}}return w}}class fo{constructor(e,r){this.numDataCodewords=e,this.codewords=r}static getDataBlocks(e,r){const i=r.getECBlocks();let s=0;const a=i.getECBlocks();for(let $ of a)s+=$.getCount();const c=new Array(s);let d=0;for(let $ of a)for(let Z=0;Z<$.getCount();Z++){const G=$.getDataCodewords(),ae=i.getECCodewords()+G;c[d++]=new fo(G,new Uint8Array(ae))}const p=c[0].codewords.length-i.getECCodewords(),w=p-1;let v=0;for(let $=0;$<w;$++)for(let Z=0;Z<d;Z++)c[Z].codewords[$]=e[v++];const E=r.getVersionNumber()===24,O=E?8:d;for(let $=0;$<O;$++)c[$].codewords[p-1]=e[v++];const L=c[0].codewords.length;for(let $=p;$<L;$++)for(let Z=0;Z<d;Z++){const G=E?(Z+8)%d:Z,ae=E&&G>7?$-1:$;c[G].codewords[ae]=e[v++]}if(v!==e.length)throw new b;return c}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}class ho{constructor(e){this.bytes=e,this.byteOffset=0,this.bitOffset=0}getBitOffset(){return this.bitOffset}getByteOffset(){return this.byteOffset}readBits(e){if(e<1||e>32||e>this.available())throw new b(""+e);let r=0,i=this.bitOffset,s=this.byteOffset;const a=this.bytes;if(i>0){const c=8-i,d=e<c?e:c,h=c-d,p=255>>8-d<<h;r=(a[s]&p)>>h,e-=d,i+=d,i===8&&(i=0,s++)}if(e>0){for(;e>=8;)r=r<<8|a[s]&255,s++,e-=8;if(e>0){const c=8-e,d=255>>c<<c;r=r<<e|(a[s]&d)>>c,i+=e}}return this.bitOffset=i,this.byteOffset=s,r}available(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset}}var St;(function(_){_[_.PAD_ENCODE=0]="PAD_ENCODE",_[_.ASCII_ENCODE=1]="ASCII_ENCODE",_[_.C40_ENCODE=2]="C40_ENCODE",_[_.TEXT_ENCODE=3]="TEXT_ENCODE",_[_.ANSIX12_ENCODE=4]="ANSIX12_ENCODE",_[_.EDIFACT_ENCODE=5]="EDIFACT_ENCODE",_[_.BASE256_ENCODE=6]="BASE256_ENCODE"})(St||(St={}));class Gn{static decode(e){const r=new ho(e),i=new xe,s=new xe,a=new Array;let c=St.ASCII_ENCODE;do if(c===St.ASCII_ENCODE)c=this.decodeAsciiSegment(r,i,s);else{switch(c){case St.C40_ENCODE:this.decodeC40Segment(r,i);break;case St.TEXT_ENCODE:this.decodeTextSegment(r,i);break;case St.ANSIX12_ENCODE:this.decodeAnsiX12Segment(r,i);break;case St.EDIFACT_ENCODE:this.decodeEdifactSegment(r,i);break;case St.BASE256_ENCODE:this.decodeBase256Segment(r,i,a);break;default:throw new j}c=St.ASCII_ENCODE}while(c!==St.PAD_ENCODE&&r.available()>0);return s.length()>0&&i.append(s.toString()),new Le(e,i.toString(),a.length===0?null:a,null)}static decodeAsciiSegment(e,r,i){let s=!1;do{let a=e.readBits(8);if(a===0)throw new j;if(a<=128)return s&&(a+=128),r.append(String.fromCharCode(a-1)),St.ASCII_ENCODE;if(a===129)return St.PAD_ENCODE;if(a<=229){const c=a-130;c<10&&r.append("0"),r.append(""+c)}else switch(a){case 230:return St.C40_ENCODE;case 231:return St.BASE256_ENCODE;case 232:r.append("");break;case 233:case 234:break;case 235:s=!0;break;case 236:r.append("[)>05"),i.insert(0,"");break;case 237:r.append("[)>06"),i.insert(0,"");break;case 238:return St.ANSIX12_ENCODE;case 239:return St.TEXT_ENCODE;case 240:return St.EDIFACT_ENCODE;case 241:break;default:if(a!==254||e.available()!==0)throw new j;break}}while(e.available()>0);return St.ASCII_ENCODE}static decodeC40Segment(e,r){let i=!1;const s=[];let a=0;do{if(e.available()===8)return;const c=e.readBits(8);if(c===254)return;this.parseTwoBytes(c,e.readBits(8),s);for(let d=0;d<3;d++){const h=s[d];switch(a){case 0:if(h<3)a=h+1;else if(h<this.C40_BASIC_SET_CHARS.length){const p=this.C40_BASIC_SET_CHARS[h];i?(r.append(String.fromCharCode(p.charCodeAt(0)+128)),i=!1):r.append(p)}else throw new j;break;case 1:i?(r.append(String.fromCharCode(h+128)),i=!1):r.append(String.fromCharCode(h)),a=0;break;case 2:if(h<this.C40_SHIFT2_SET_CHARS.length){const p=this.C40_SHIFT2_SET_CHARS[h];i?(r.append(String.fromCharCode(p.charCodeAt(0)+128)),i=!1):r.append(p)}else switch(h){case 27:r.append("");break;case 30:i=!0;break;default:throw new j}a=0;break;case 3:i?(r.append(String.fromCharCode(h+224)),i=!1):r.append(String.fromCharCode(h+96)),a=0;break;default:throw new j}}}while(e.available()>0)}static decodeTextSegment(e,r){let i=!1,s=[],a=0;do{if(e.available()===8)return;const c=e.readBits(8);if(c===254)return;this.parseTwoBytes(c,e.readBits(8),s);for(let d=0;d<3;d++){const h=s[d];switch(a){case 0:if(h<3)a=h+1;else if(h<this.TEXT_BASIC_SET_CHARS.length){const p=this.TEXT_BASIC_SET_CHARS[h];i?(r.append(String.fromCharCode(p.charCodeAt(0)+128)),i=!1):r.append(p)}else throw new j;break;case 1:i?(r.append(String.fromCharCode(h+128)),i=!1):r.append(String.fromCharCode(h)),a=0;break;case 2:if(h<this.TEXT_SHIFT2_SET_CHARS.length){const p=this.TEXT_SHIFT2_SET_CHARS[h];i?(r.append(String.fromCharCode(p.charCodeAt(0)+128)),i=!1):r.append(p)}else switch(h){case 27:r.append("");break;case 30:i=!0;break;default:throw new j}a=0;break;case 3:if(h<this.TEXT_SHIFT3_SET_CHARS.length){const p=this.TEXT_SHIFT3_SET_CHARS[h];i?(r.append(String.fromCharCode(p.charCodeAt(0)+128)),i=!1):r.append(p),a=0}else throw new j;break;default:throw new j}}}while(e.available()>0)}static decodeAnsiX12Segment(e,r){const i=[];do{if(e.available()===8)return;const s=e.readBits(8);if(s===254)return;this.parseTwoBytes(s,e.readBits(8),i);for(let a=0;a<3;a++){const c=i[a];switch(c){case 0:r.append("\r");break;case 1:r.append("*");break;case 2:r.append(">");break;case 3:r.append(" ");break;default:if(c<14)r.append(String.fromCharCode(c+44));else if(c<40)r.append(String.fromCharCode(c+51));else throw new j;break}}}while(e.available()>0)}static parseTwoBytes(e,r,i){let s=(e<<8)+r-1,a=Math.floor(s/1600);i[0]=a,s-=a*1600,a=Math.floor(s/40),i[1]=a,i[2]=s-a*40}static decodeEdifactSegment(e,r){do{if(e.available()<=16)return;for(let i=0;i<4;i++){let s=e.readBits(6);if(s===31){const a=8-e.getBitOffset();a!==8&&e.readBits(a);return}(s&32)===0&&(s|=64),r.append(String.fromCharCode(s))}}while(e.available()>0)}static decodeBase256Segment(e,r,i){let s=1+e.getByteOffset();const a=this.unrandomize255State(e.readBits(8),s++);let c;if(a===0?c=e.available()/8|0:a<250?c=a:c=250*(a-249)+this.unrandomize255State(e.readBits(8),s++),c<0)throw new j;const d=new Uint8Array(c);for(let h=0;h<c;h++){if(e.available()<8)throw new j;d[h]=this.unrandomize255State(e.readBits(8),s++)}i.push(d);try{r.append(Ce.decode(d,he.ISO88591))}catch(h){throw new ue("Platform does not support required encoding: "+h.message)}}static unrandomize255State(e,r){const i=149*r%255+1,s=e-i;return s>=0?s:s+256}}Gn.C40_BASIC_SET_CHARS=["*","*","*"," ","0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],Gn.C40_SHIFT2_SET_CHARS=["!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_"],Gn.TEXT_BASIC_SET_CHARS=["*","*","*"," ","0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],Gn.TEXT_SHIFT2_SET_CHARS=Gn.C40_SHIFT2_SET_CHARS,Gn.TEXT_SHIFT3_SET_CHARS=["`","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","{","|","}","~",""];class E1{constructor(){this.rsDecoder=new De(je.DATA_MATRIX_FIELD_256)}decode(e){const r=new uo(e),i=r.getVersion(),s=r.readCodewords(),a=fo.getDataBlocks(s,i);let c=0;for(let p of a)c+=p.getNumDataCodewords();const d=new Uint8Array(c),h=a.length;for(let p=0;p<h;p++){const w=a[p],v=w.getCodewords(),E=w.getNumDataCodewords();this.correctErrors(v,E);for(let O=0;O<E;O++)d[O*h+p]=v[O]}return Gn.decode(d)}correctErrors(e,r){const i=new Int32Array(e);try{this.rsDecoder.decode(i,e.length-r)}catch{throw new N}for(let s=0;s<r;s++)e[s]=i[s]}}class Ct{constructor(e){this.image=e,this.rectangleDetector=new yn(this.image)}detect(){const e=this.rectangleDetector.detect();let r=this.detectSolid1(e);if(r=this.detectSolid2(r),r[3]=this.correctTopRight(r),!r[3])throw new F;r=this.shiftToModuleCenter(r);const i=r[0],s=r[1],a=r[2],c=r[3];let d=this.transitionsBetween(i,c)+1,h=this.transitionsBetween(a,c)+1;(d&1)===1&&(d+=1),(h&1)===1&&(h+=1),4*d<7*h&&4*h<7*d&&(d=h=Math.max(d,h));let p=Ct.sampleGrid(this.image,i,s,a,c,d,h);return new ir(p,[i,s,a,c])}static shiftPoint(e,r,i){let s=(r.getX()-e.getX())/(i+1),a=(r.getY()-e.getY())/(i+1);return new Se(e.getX()+s,e.getY()+a)}static moveAway(e,r,i){let s=e.getX(),a=e.getY();return s<r?s-=1:s+=1,a<i?a-=1:a+=1,new Se(s,a)}detectSolid1(e){let r=e[0],i=e[1],s=e[3],a=e[2],c=this.transitionsBetween(r,i),d=this.transitionsBetween(i,s),h=this.transitionsBetween(s,a),p=this.transitionsBetween(a,r),w=c,v=[a,r,i,s];return w>d&&(w=d,v[0]=r,v[1]=i,v[2]=s,v[3]=a),w>h&&(w=h,v[0]=i,v[1]=s,v[2]=a,v[3]=r),w>p&&(v[0]=s,v[1]=a,v[2]=r,v[3]=i),v}detectSolid2(e){let r=e[0],i=e[1],s=e[2],a=e[3],c=this.transitionsBetween(r,a),d=Ct.shiftPoint(i,s,(c+1)*4),h=Ct.shiftPoint(s,i,(c+1)*4),p=this.transitionsBetween(d,r),w=this.transitionsBetween(h,a);return p<w?(e[0]=r,e[1]=i,e[2]=s,e[3]=a):(e[0]=i,e[1]=s,e[2]=a,e[3]=r),e}correctTopRight(e){let r=e[0],i=e[1],s=e[2],a=e[3],c=this.transitionsBetween(r,a),d=this.transitionsBetween(i,a),h=Ct.shiftPoint(r,i,(d+1)*4),p=Ct.shiftPoint(s,i,(c+1)*4);c=this.transitionsBetween(h,a),d=this.transitionsBetween(p,a);let w=new Se(a.getX()+(s.getX()-i.getX())/(c+1),a.getY()+(s.getY()-i.getY())/(c+1)),v=new Se(a.getX()+(r.getX()-i.getX())/(d+1),a.getY()+(r.getY()-i.getY())/(d+1));if(!this.isValid(w))return this.isValid(v)?v:null;if(!this.isValid(v))return w;let E=this.transitionsBetween(h,w)+this.transitionsBetween(p,w),O=this.transitionsBetween(h,v)+this.transitionsBetween(p,v);return E>O?w:v}shiftToModuleCenter(e){let r=e[0],i=e[1],s=e[2],a=e[3],c=this.transitionsBetween(r,a)+1,d=this.transitionsBetween(s,a)+1,h=Ct.shiftPoint(r,i,d*4),p=Ct.shiftPoint(s,i,c*4);c=this.transitionsBetween(h,a)+1,d=this.transitionsBetween(p,a)+1,(c&1)===1&&(c+=1),(d&1)===1&&(d+=1);let w=(r.getX()+i.getX()+s.getX()+a.getX())/4,v=(r.getY()+i.getY()+s.getY()+a.getY())/4;r=Ct.moveAway(r,w,v),i=Ct.moveAway(i,w,v),s=Ct.moveAway(s,w,v),a=Ct.moveAway(a,w,v);let E,O;return h=Ct.shiftPoint(r,i,d*4),h=Ct.shiftPoint(h,a,c*4),E=Ct.shiftPoint(i,r,d*4),E=Ct.shiftPoint(E,s,c*4),p=Ct.shiftPoint(s,a,d*4),p=Ct.shiftPoint(p,i,c*4),O=Ct.shiftPoint(a,s,d*4),O=Ct.shiftPoint(O,r,c*4),[h,E,p,O]}isValid(e){return e.getX()>=0&&e.getX()<this.image.getWidth()&&e.getY()>0&&e.getY()<this.image.getHeight()}static sampleGrid(e,r,i,s,a,c,d){return Hn.getInstance().sampleGrid(e,c,d,.5,.5,c-.5,.5,c-.5,d-.5,.5,d-.5,r.getX(),r.getY(),a.getX(),a.getY(),s.getX(),s.getY(),i.getX(),i.getY())}transitionsBetween(e,r){let i=Math.trunc(e.getX()),s=Math.trunc(e.getY()),a=Math.trunc(r.getX()),c=Math.trunc(r.getY()),d=Math.abs(c-s)>Math.abs(a-i);if(d){let $=i;i=s,s=$,$=a,a=c,c=$}let h=Math.abs(a-i),p=Math.abs(c-s),w=-h/2,v=s<c?1:-1,E=i<a?1:-1,O=0,L=this.image.get(d?s:i,d?i:s);for(let $=i,Z=s;$!==a;$+=E){let G=this.image.get(d?Z:$,d?$:Z);if(G!==L&&(O++,L=G),w+=p,w>0){if(Z===c)break;Z+=v,w-=h}}return O}}class Xn{constructor(){this.decoder=new E1}decode(e,r=null){let i,s;if(r!=null&&r.has(Q.PURE_BARCODE)){const p=Xn.extractPureBits(e.getBlackMatrix());i=this.decoder.decode(p),s=Xn.NO_POINTS}else{const p=new Ct(e.getBlackMatrix()).detect();i=this.decoder.decode(p.getBits()),s=p.getPoints()}const a=i.getRawBytes(),c=new Pe(i.getText(),a,8*a.length,s,S.DATA_MATRIX,D.currentTimeMillis()),d=i.getByteSegments();d!=null&&c.putMetadata(se.BYTE_SEGMENTS,d);const h=i.getECLevel();return h!=null&&c.putMetadata(se.ERROR_CORRECTION_LEVEL,h),c}reset(){}static extractPureBits(e){const r=e.getTopLeftOnBit(),i=e.getBottomRightOnBit();if(r==null||i==null)throw new F;const s=this.moduleSize(r,e);let a=r[1];const c=i[1];let d=r[0];const p=(i[0]-d+1)/s,w=(c-a+1)/s;if(p<=0||w<=0)throw new F;const v=s/2;a+=v,d+=v;const E=new le(p,w);for(let O=0;O<w;O++){const L=a+O*s;for(let $=0;$<p;$++)e.get(d+$*s,L)&&E.set($,O)}return E}static moduleSize(e,r){const i=r.getWidth();let s=e[0];const a=e[1];for(;s<i&&r.get(s,a);)s++;if(s===i)throw new F;const c=s-e[0];if(c===0)throw new F;return c}}Xn.NO_POINTS=[];class A1 extends Fe{constructor(e=500){super(new Xn,e)}}var yr;(function(_){_[_.L=0]="L",_[_.M=1]="M",_[_.Q=2]="Q",_[_.H=3]="H"})(yr||(yr={}));class at{constructor(e,r,i){this.value=e,this.stringValue=r,this.bits=i,at.FOR_BITS.set(i,this),at.FOR_VALUE.set(e,this)}getValue(){return this.value}getBits(){return this.bits}static fromString(e){switch(e){case"L":return at.L;case"M":return at.M;case"Q":return at.Q;case"H":return at.H;default:throw new A(e+"not available")}}toString(){return this.stringValue}equals(e){if(!(e instanceof at))return!1;const r=e;return this.value===r.value}static forBits(e){if(e<0||e>=at.FOR_BITS.size)throw new b;return at.FOR_BITS.get(e)}}at.FOR_BITS=new Map,at.FOR_VALUE=new Map,at.L=new at(yr.L,"L",1),at.M=new at(yr.M,"M",0),at.Q=new at(yr.Q,"Q",3),at.H=new at(yr.H,"H",2);class Ut{constructor(e){this.errorCorrectionLevel=at.forBits(e>>3&3),this.dataMask=e&7}static numBitsDiffering(e,r){return k.bitCount(e^r)}static decodeFormatInformation(e,r){const i=Ut.doDecodeFormatInformation(e,r);return i!==null?i:Ut.doDecodeFormatInformation(e^Ut.FORMAT_INFO_MASK_QR,r^Ut.FORMAT_INFO_MASK_QR)}static doDecodeFormatInformation(e,r){let i=Number.MAX_SAFE_INTEGER,s=0;for(const a of Ut.FORMAT_INFO_DECODE_LOOKUP){const c=a[0];if(c===e||c===r)return new Ut(a[1]);let d=Ut.numBitsDiffering(e,c);d<i&&(s=a[1],i=d),e!==r&&(d=Ut.numBitsDiffering(r,c),d<i&&(s=a[1],i=d))}return i<=3?new Ut(s):null}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getDataMask(){return this.dataMask}hashCode(){return this.errorCorrectionLevel.getBits()<<3|this.dataMask}equals(e){if(!(e instanceof Ut))return!1;const r=e;return this.errorCorrectionLevel===r.errorCorrectionLevel&&this.dataMask===r.dataMask}}Ut.FORMAT_INFO_MASK_QR=21522,Ut.FORMAT_INFO_DECODE_LOOKUP=[Int32Array.from([21522,0]),Int32Array.from([20773,1]),Int32Array.from([24188,2]),Int32Array.from([23371,3]),Int32Array.from([17913,4]),Int32Array.from([16590,5]),Int32Array.from([20375,6]),Int32Array.from([19104,7]),Int32Array.from([30660,8]),Int32Array.from([29427,9]),Int32Array.from([32170,10]),Int32Array.from([30877,11]),Int32Array.from([26159,12]),Int32Array.from([25368,13]),Int32Array.from([27713,14]),Int32Array.from([26998,15]),Int32Array.from([5769,16]),Int32Array.from([5054,17]),Int32Array.from([7399,18]),Int32Array.from([6608,19]),Int32Array.from([1890,20]),Int32Array.from([597,21]),Int32Array.from([3340,22]),Int32Array.from([2107,23]),Int32Array.from([13663,24]),Int32Array.from([12392,25]),Int32Array.from([16177,26]),Int32Array.from([14854,27]),Int32Array.from([9396,28]),Int32Array.from([8579,29]),Int32Array.from([11994,30]),Int32Array.from([11245,31])];class V{constructor(e,...r){this.ecCodewordsPerBlock=e,this.ecBlocks=r}getECCodewordsPerBlock(){return this.ecCodewordsPerBlock}getNumBlocks(){let e=0;const r=this.ecBlocks;for(const i of r)e+=i.getCount();return e}getTotalECCodewords(){return this.ecCodewordsPerBlock*this.getNumBlocks()}getECBlocks(){return this.ecBlocks}}class T{constructor(e,r){this.count=e,this.dataCodewords=r}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class Ne{constructor(e,r,...i){this.versionNumber=e,this.alignmentPatternCenters=r,this.ecBlocks=i;let s=0;const a=i[0].getECCodewordsPerBlock(),c=i[0].getECBlocks();for(const d of c)s+=d.getCount()*(d.getDataCodewords()+a);this.totalCodewords=s}getVersionNumber(){return this.versionNumber}getAlignmentPatternCenters(){return this.alignmentPatternCenters}getTotalCodewords(){return this.totalCodewords}getDimensionForVersion(){return 17+4*this.versionNumber}getECBlocksForLevel(e){return this.ecBlocks[e.getValue()]}static getProvisionalVersionForDimension(e){if(e%4!==1)throw new j;try{return this.getVersionForNumber((e-17)/4)}catch{throw new j}}static getVersionForNumber(e){if(e<1||e>40)throw new b;return Ne.VERSIONS[e-1]}static decodeVersionInformation(e){let r=Number.MAX_SAFE_INTEGER,i=0;for(let s=0;s<Ne.VERSION_DECODE_INFO.length;s++){const a=Ne.VERSION_DECODE_INFO[s];if(a===e)return Ne.getVersionForNumber(s+7);const c=Ut.numBitsDiffering(e,a);c<r&&(i=s+7,r=c)}return r<=3?Ne.getVersionForNumber(i):null}buildFunctionPattern(){const e=this.getDimensionForVersion(),r=new le(e);r.setRegion(0,0,9,9),r.setRegion(e-8,0,8,9),r.setRegion(0,e-8,9,8);const i=this.alignmentPatternCenters.length;for(let s=0;s<i;s++){const a=this.alignmentPatternCenters[s]-2;for(let c=0;c<i;c++)s===0&&(c===0||c===i-1)||s===i-1&&c===0||r.setRegion(this.alignmentPatternCenters[c]-2,a,5,5)}return r.setRegion(6,9,1,e-17),r.setRegion(9,6,e-17,1),this.versionNumber>6&&(r.setRegion(e-11,0,3,6),r.setRegion(0,e-11,6,3)),r}toString(){return""+this.versionNumber}}Ne.VERSION_DECODE_INFO=Int32Array.from([31892,34236,39577,42195,48118,51042,55367,58893,63784,68472,70749,76311,79154,84390,87683,92361,96236,102084,102881,110507,110734,117786,119615,126325,127568,133589,136944,141498,145311,150283,152622,158308,161089,167017]),Ne.VERSIONS=[new Ne(1,new Int32Array(0),new V(7,new T(1,19)),new V(10,new T(1,16)),new V(13,new T(1,13)),new V(17,new T(1,9))),new Ne(2,Int32Array.from([6,18]),new V(10,new T(1,34)),new V(16,new T(1,28)),new V(22,new T(1,22)),new V(28,new T(1,16))),new Ne(3,Int32Array.from([6,22]),new V(15,new T(1,55)),new V(26,new T(1,44)),new V(18,new T(2,17)),new V(22,new T(2,13))),new Ne(4,Int32Array.from([6,26]),new V(20,new T(1,80)),new V(18,new T(2,32)),new V(26,new T(2,24)),new V(16,new T(4,9))),new Ne(5,Int32Array.from([6,30]),new V(26,new T(1,108)),new V(24,new T(2,43)),new V(18,new T(2,15),new T(2,16)),new V(22,new T(2,11),new T(2,12))),new Ne(6,Int32Array.from([6,34]),new V(18,new T(2,68)),new V(16,new T(4,27)),new V(24,new T(4,19)),new V(28,new T(4,15))),new Ne(7,Int32Array.from([6,22,38]),new V(20,new T(2,78)),new V(18,new T(4,31)),new V(18,new T(2,14),new T(4,15)),new V(26,new T(4,13),new T(1,14))),new Ne(8,Int32Array.from([6,24,42]),new V(24,new T(2,97)),new V(22,new T(2,38),new T(2,39)),new V(22,new T(4,18),new T(2,19)),new V(26,new T(4,14),new T(2,15))),new Ne(9,Int32Array.from([6,26,46]),new V(30,new T(2,116)),new V(22,new T(3,36),new T(2,37)),new V(20,new T(4,16),new T(4,17)),new V(24,new T(4,12),new T(4,13))),new Ne(10,Int32Array.from([6,28,50]),new V(18,new T(2,68),new T(2,69)),new V(26,new T(4,43),new T(1,44)),new V(24,new T(6,19),new T(2,20)),new V(28,new T(6,15),new T(2,16))),new Ne(11,Int32Array.from([6,30,54]),new V(20,new T(4,81)),new V(30,new T(1,50),new T(4,51)),new V(28,new T(4,22),new T(4,23)),new V(24,new T(3,12),new T(8,13))),new Ne(12,Int32Array.from([6,32,58]),new V(24,new T(2,92),new T(2,93)),new V(22,new T(6,36),new T(2,37)),new V(26,new T(4,20),new T(6,21)),new V(28,new T(7,14),new T(4,15))),new Ne(13,Int32Array.from([6,34,62]),new V(26,new T(4,107)),new V(22,new T(8,37),new T(1,38)),new V(24,new T(8,20),new T(4,21)),new V(22,new T(12,11),new T(4,12))),new Ne(14,Int32Array.from([6,26,46,66]),new V(30,new T(3,115),new T(1,116)),new V(24,new T(4,40),new T(5,41)),new V(20,new T(11,16),new T(5,17)),new V(24,new T(11,12),new T(5,13))),new Ne(15,Int32Array.from([6,26,48,70]),new V(22,new T(5,87),new T(1,88)),new V(24,new T(5,41),new T(5,42)),new V(30,new T(5,24),new T(7,25)),new V(24,new T(11,12),new T(7,13))),new Ne(16,Int32Array.from([6,26,50,74]),new V(24,new T(5,98),new T(1,99)),new V(28,new T(7,45),new T(3,46)),new V(24,new T(15,19),new T(2,20)),new V(30,new T(3,15),new T(13,16))),new Ne(17,Int32Array.from([6,30,54,78]),new V(28,new T(1,107),new T(5,108)),new V(28,new T(10,46),new T(1,47)),new V(28,new T(1,22),new T(15,23)),new V(28,new T(2,14),new T(17,15))),new Ne(18,Int32Array.from([6,30,56,82]),new V(30,new T(5,120),new T(1,121)),new V(26,new T(9,43),new T(4,44)),new V(28,new T(17,22),new T(1,23)),new V(28,new T(2,14),new T(19,15))),new Ne(19,Int32Array.from([6,30,58,86]),new V(28,new T(3,113),new T(4,114)),new V(26,new T(3,44),new T(11,45)),new V(26,new T(17,21),new T(4,22)),new V(26,new T(9,13),new T(16,14))),new Ne(20,Int32Array.from([6,34,62,90]),new V(28,new T(3,107),new T(5,108)),new V(26,new T(3,41),new T(13,42)),new V(30,new T(15,24),new T(5,25)),new V(28,new T(15,15),new T(10,16))),new Ne(21,Int32Array.from([6,28,50,72,94]),new V(28,new T(4,116),new T(4,117)),new V(26,new T(17,42)),new V(28,new T(17,22),new T(6,23)),new V(30,new T(19,16),new T(6,17))),new Ne(22,Int32Array.from([6,26,50,74,98]),new V(28,new T(2,111),new T(7,112)),new V(28,new T(17,46)),new V(30,new T(7,24),new T(16,25)),new V(24,new T(34,13))),new Ne(23,Int32Array.from([6,30,54,78,102]),new V(30,new T(4,121),new T(5,122)),new V(28,new T(4,47),new T(14,48)),new V(30,new T(11,24),new T(14,25)),new V(30,new T(16,15),new T(14,16))),new Ne(24,Int32Array.from([6,28,54,80,106]),new V(30,new T(6,117),new T(4,118)),new V(28,new T(6,45),new T(14,46)),new V(30,new T(11,24),new T(16,25)),new V(30,new T(30,16),new T(2,17))),new Ne(25,Int32Array.from([6,32,58,84,110]),new V(26,new T(8,106),new T(4,107)),new V(28,new T(8,47),new T(13,48)),new V(30,new T(7,24),new T(22,25)),new V(30,new T(22,15),new T(13,16))),new Ne(26,Int32Array.from([6,30,58,86,114]),new V(28,new T(10,114),new T(2,115)),new V(28,new T(19,46),new T(4,47)),new V(28,new T(28,22),new T(6,23)),new V(30,new T(33,16),new T(4,17))),new Ne(27,Int32Array.from([6,34,62,90,118]),new V(30,new T(8,122),new T(4,123)),new V(28,new T(22,45),new T(3,46)),new V(30,new T(8,23),new T(26,24)),new V(30,new T(12,15),new T(28,16))),new Ne(28,Int32Array.from([6,26,50,74,98,122]),new V(30,new T(3,117),new T(10,118)),new V(28,new T(3,45),new T(23,46)),new V(30,new T(4,24),new T(31,25)),new V(30,new T(11,15),new T(31,16))),new Ne(29,Int32Array.from([6,30,54,78,102,126]),new V(30,new T(7,116),new T(7,117)),new V(28,new T(21,45),new T(7,46)),new V(30,new T(1,23),new T(37,24)),new V(30,new T(19,15),new T(26,16))),new Ne(30,Int32Array.from([6,26,52,78,104,130]),new V(30,new T(5,115),new T(10,116)),new V(28,new T(19,47),new T(10,48)),new V(30,new T(15,24),new T(25,25)),new V(30,new T(23,15),new T(25,16))),new Ne(31,Int32Array.from([6,30,56,82,108,134]),new V(30,new T(13,115),new T(3,116)),new V(28,new T(2,46),new T(29,47)),new V(30,new T(42,24),new T(1,25)),new V(30,new T(23,15),new T(28,16))),new Ne(32,Int32Array.from([6,34,60,86,112,138]),new V(30,new T(17,115)),new V(28,new T(10,46),new T(23,47)),new V(30,new T(10,24),new T(35,25)),new V(30,new T(19,15),new T(35,16))),new Ne(33,Int32Array.from([6,30,58,86,114,142]),new V(30,new T(17,115),new T(1,116)),new V(28,new T(14,46),new T(21,47)),new V(30,new T(29,24),new T(19,25)),new V(30,new T(11,15),new T(46,16))),new Ne(34,Int32Array.from([6,34,62,90,118,146]),new V(30,new T(13,115),new T(6,116)),new V(28,new T(14,46),new T(23,47)),new V(30,new T(44,24),new T(7,25)),new V(30,new T(59,16),new T(1,17))),new Ne(35,Int32Array.from([6,30,54,78,102,126,150]),new V(30,new T(12,121),new T(7,122)),new V(28,new T(12,47),new T(26,48)),new V(30,new T(39,24),new T(14,25)),new V(30,new T(22,15),new T(41,16))),new Ne(36,Int32Array.from([6,24,50,76,102,128,154]),new V(30,new T(6,121),new T(14,122)),new V(28,new T(6,47),new T(34,48)),new V(30,new T(46,24),new T(10,25)),new V(30,new T(2,15),new T(64,16))),new Ne(37,Int32Array.from([6,28,54,80,106,132,158]),new V(30,new T(17,122),new T(4,123)),new V(28,new T(29,46),new T(14,47)),new V(30,new T(49,24),new T(10,25)),new V(30,new T(24,15),new T(46,16))),new Ne(38,Int32Array.from([6,32,58,84,110,136,162]),new V(30,new T(4,122),new T(18,123)),new V(28,new T(13,46),new T(32,47)),new V(30,new T(48,24),new T(14,25)),new V(30,new T(42,15),new T(32,16))),new Ne(39,Int32Array.from([6,26,54,82,110,138,166]),new V(30,new T(20,117),new T(4,118)),new V(28,new T(40,47),new T(7,48)),new V(30,new T(43,24),new T(22,25)),new V(30,new T(10,15),new T(67,16))),new Ne(40,Int32Array.from([6,30,58,86,114,142,170]),new V(30,new T(19,118),new T(6,119)),new V(28,new T(18,47),new T(31,48)),new V(30,new T(34,24),new T(34,25)),new V(30,new T(20,15),new T(61,16)))];var kt;(function(_){_[_.DATA_MASK_000=0]="DATA_MASK_000",_[_.DATA_MASK_001=1]="DATA_MASK_001",_[_.DATA_MASK_010=2]="DATA_MASK_010",_[_.DATA_MASK_011=3]="DATA_MASK_011",_[_.DATA_MASK_100=4]="DATA_MASK_100",_[_.DATA_MASK_101=5]="DATA_MASK_101",_[_.DATA_MASK_110=6]="DATA_MASK_110",_[_.DATA_MASK_111=7]="DATA_MASK_111"})(kt||(kt={}));class fn{constructor(e,r){this.value=e,this.isMasked=r}unmaskBitMatrix(e,r){for(let i=0;i<r;i++)for(let s=0;s<r;s++)this.isMasked(i,s)&&e.flip(s,i)}}fn.values=new Map([[kt.DATA_MASK_000,new fn(kt.DATA_MASK_000,(_,e)=>(_+e&1)===0)],[kt.DATA_MASK_001,new fn(kt.DATA_MASK_001,(_,e)=>(_&1)===0)],[kt.DATA_MASK_010,new fn(kt.DATA_MASK_010,(_,e)=>e%3===0)],[kt.DATA_MASK_011,new fn(kt.DATA_MASK_011,(_,e)=>(_+e)%3===0)],[kt.DATA_MASK_100,new fn(kt.DATA_MASK_100,(_,e)=>(Math.floor(_/2)+Math.floor(e/3)&1)===0)],[kt.DATA_MASK_101,new fn(kt.DATA_MASK_101,(_,e)=>_*e%6===0)],[kt.DATA_MASK_110,new fn(kt.DATA_MASK_110,(_,e)=>_*e%6<3)],[kt.DATA_MASK_111,new fn(kt.DATA_MASK_111,(_,e)=>(_+e+_*e%3&1)===0)]]);class I1{constructor(e){const r=e.getHeight();if(r<21||(r&3)!==1)throw new j;this.bitMatrix=e}readFormatInformation(){if(this.parsedFormatInfo!==null&&this.parsedFormatInfo!==void 0)return this.parsedFormatInfo;let e=0;for(let a=0;a<6;a++)e=this.copyBit(a,8,e);e=this.copyBit(7,8,e),e=this.copyBit(8,8,e),e=this.copyBit(8,7,e);for(let a=5;a>=0;a--)e=this.copyBit(8,a,e);const r=this.bitMatrix.getHeight();let i=0;const s=r-7;for(let a=r-1;a>=s;a--)i=this.copyBit(8,a,i);for(let a=r-8;a<r;a++)i=this.copyBit(a,8,i);if(this.parsedFormatInfo=Ut.decodeFormatInformation(e,i),this.parsedFormatInfo!==null)return this.parsedFormatInfo;throw new j}readVersion(){if(this.parsedVersion!==null&&this.parsedVersion!==void 0)return this.parsedVersion;const e=this.bitMatrix.getHeight(),r=Math.floor((e-17)/4);if(r<=6)return Ne.getVersionForNumber(r);let i=0;const s=e-11;for(let c=5;c>=0;c--)for(let d=e-9;d>=s;d--)i=this.copyBit(d,c,i);let a=Ne.decodeVersionInformation(i);if(a!==null&&a.getDimensionForVersion()===e)return this.parsedVersion=a,a;i=0;for(let c=5;c>=0;c--)for(let d=e-9;d>=s;d--)i=this.copyBit(c,d,i);if(a=Ne.decodeVersionInformation(i),a!==null&&a.getDimensionForVersion()===e)return this.parsedVersion=a,a;throw new j}copyBit(e,r,i){return(this.isMirror?this.bitMatrix.get(r,e):this.bitMatrix.get(e,r))?i<<1|1:i<<1}readCodewords(){const e=this.readFormatInformation(),r=this.readVersion(),i=fn.values.get(e.getDataMask()),s=this.bitMatrix.getHeight();i.unmaskBitMatrix(this.bitMatrix,s);const a=r.buildFunctionPattern();let c=!0;const d=new Uint8Array(r.getTotalCodewords());let h=0,p=0,w=0;for(let v=s-1;v>0;v-=2){v===6&&v--;for(let E=0;E<s;E++){const O=c?s-1-E:E;for(let L=0;L<2;L++)a.get(v-L,O)||(w++,p<<=1,this.bitMatrix.get(v-L,O)&&(p|=1),w===8&&(d[h++]=p,w=0,p=0))}c=!c}if(h!==r.getTotalCodewords())throw new j;return d}remask(){if(this.parsedFormatInfo===null)return;const e=fn.values[this.parsedFormatInfo.getDataMask()],r=this.bitMatrix.getHeight();e.unmaskBitMatrix(this.bitMatrix,r)}setMirror(e){this.parsedVersion=null,this.parsedFormatInfo=null,this.isMirror=e}mirror(){const e=this.bitMatrix;for(let r=0,i=e.getWidth();r<i;r++)for(let s=r+1,a=e.getHeight();s<a;s++)e.get(r,s)!==e.get(s,r)&&(e.flip(s,r),e.flip(r,s))}}class po{constructor(e,r){this.numDataCodewords=e,this.codewords=r}static getDataBlocks(e,r,i){if(e.length!==r.getTotalCodewords())throw new b;const s=r.getECBlocksForLevel(i);let a=0;const c=s.getECBlocks();for(const L of c)a+=L.getCount();const d=new Array(a);let h=0;for(const L of c)for(let $=0;$<L.getCount();$++){const Z=L.getDataCodewords(),G=s.getECCodewordsPerBlock()+Z;d[h++]=new po(Z,new Uint8Array(G))}const p=d[0].codewords.length;let w=d.length-1;for(;w>=0&&d[w].codewords.length!==p;)w--;w++;const v=p-s.getECCodewordsPerBlock();let E=0;for(let L=0;L<v;L++)for(let $=0;$<h;$++)d[$].codewords[L]=e[E++];for(let L=w;L<h;L++)d[L].codewords[v]=e[E++];const O=d[0].codewords.length;for(let L=v;L<O;L++)for(let $=0;$<h;$++){const Z=$<w?L:L+1;d[$].codewords[Z]=e[E++]}return d}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}var hn;(function(_){_[_.TERMINATOR=0]="TERMINATOR",_[_.NUMERIC=1]="NUMERIC",_[_.ALPHANUMERIC=2]="ALPHANUMERIC",_[_.STRUCTURED_APPEND=3]="STRUCTURED_APPEND",_[_.BYTE=4]="BYTE",_[_.ECI=5]="ECI",_[_.KANJI=6]="KANJI",_[_.FNC1_FIRST_POSITION=7]="FNC1_FIRST_POSITION",_[_.FNC1_SECOND_POSITION=8]="FNC1_SECOND_POSITION",_[_.HANZI=9]="HANZI"})(hn||(hn={}));class Re{constructor(e,r,i,s){this.value=e,this.stringValue=r,this.characterCountBitsForVersions=i,this.bits=s,Re.FOR_BITS.set(s,this),Re.FOR_VALUE.set(e,this)}static forBits(e){const r=Re.FOR_BITS.get(e);if(r===void 0)throw new b;return r}getCharacterCountBits(e){const r=e.getVersionNumber();let i;return r<=9?i=0:r<=26?i=1:i=2,this.characterCountBitsForVersions[i]}getValue(){return this.value}getBits(){return this.bits}equals(e){if(!(e instanceof Re))return!1;const r=e;return this.value===r.value}toString(){return this.stringValue}}Re.FOR_BITS=new Map,Re.FOR_VALUE=new Map,Re.TERMINATOR=new Re(hn.TERMINATOR,"TERMINATOR",Int32Array.from([0,0,0]),0),Re.NUMERIC=new Re(hn.NUMERIC,"NUMERIC",Int32Array.from([10,12,14]),1),Re.ALPHANUMERIC=new Re(hn.ALPHANUMERIC,"ALPHANUMERIC",Int32Array.from([9,11,13]),2),Re.STRUCTURED_APPEND=new Re(hn.STRUCTURED_APPEND,"STRUCTURED_APPEND",Int32Array.from([0,0,0]),3),Re.BYTE=new Re(hn.BYTE,"BYTE",Int32Array.from([8,16,16]),4),Re.ECI=new Re(hn.ECI,"ECI",Int32Array.from([0,0,0]),7),Re.KANJI=new Re(hn.KANJI,"KANJI",Int32Array.from([8,10,12]),8),Re.FNC1_FIRST_POSITION=new Re(hn.FNC1_FIRST_POSITION,"FNC1_FIRST_POSITION",Int32Array.from([0,0,0]),5),Re.FNC1_SECOND_POSITION=new Re(hn.FNC1_SECOND_POSITION,"FNC1_SECOND_POSITION",Int32Array.from([0,0,0]),9),Re.HANZI=new Re(hn.HANZI,"HANZI",Int32Array.from([8,10,12]),13);class mt{static decode(e,r,i,s){const a=new ho(e);let c=new xe;const d=new Array;let h=-1,p=-1;try{let w=null,v=!1,E;do{if(a.available()<4)E=Re.TERMINATOR;else{const O=a.readBits(4);E=Re.forBits(O)}switch(E){case Re.TERMINATOR:break;case Re.FNC1_FIRST_POSITION:case Re.FNC1_SECOND_POSITION:v=!0;break;case Re.STRUCTURED_APPEND:if(a.available()<16)throw new j;h=a.readBits(8),p=a.readBits(8);break;case Re.ECI:const O=mt.parseECIValue(a);if(w=Y.getCharacterSetECIByValue(O),w===null)throw new j;break;case Re.HANZI:const L=a.readBits(4),$=a.readBits(E.getCharacterCountBits(r));L===mt.GB2312_SUBSET&&mt.decodeHanziSegment(a,c,$);break;default:const Z=a.readBits(E.getCharacterCountBits(r));switch(E){case Re.NUMERIC:mt.decodeNumericSegment(a,c,Z);break;case Re.ALPHANUMERIC:mt.decodeAlphanumericSegment(a,c,Z,v);break;case Re.BYTE:mt.decodeByteSegment(a,c,Z,w,d,s);break;case Re.KANJI:mt.decodeKanjiSegment(a,c,Z);break;default:throw new j}break}}while(E!==Re.TERMINATOR)}catch{throw new j}return new Le(e,c.toString(),d.length===0?null:d,i===null?null:i.toString(),h,p)}static decodeHanziSegment(e,r,i){if(i*13>e.available())throw new j;const s=new Uint8Array(2*i);let a=0;for(;i>0;){const c=e.readBits(13);let d=c/96<<8&4294967295|c%96;d<959?d+=41377:d+=42657,s[a]=d>>8&255,s[a+1]=d&255,a+=2,i--}try{r.append(Ce.decode(s,he.GB2312))}catch(c){throw new j(c)}}static decodeKanjiSegment(e,r,i){if(i*13>e.available())throw new j;const s=new Uint8Array(2*i);let a=0;for(;i>0;){const c=e.readBits(13);let d=c/192<<8&4294967295|c%192;d<7936?d+=33088:d+=49472,s[a]=d>>8,s[a+1]=d,a+=2,i--}try{r.append(Ce.decode(s,he.SHIFT_JIS))}catch(c){throw new j(c)}}static decodeByteSegment(e,r,i,s,a,c){if(8*i>e.available())throw new j;const d=new Uint8Array(i);for(let p=0;p<i;p++)d[p]=e.readBits(8);let h;s===null?h=he.guessEncoding(d,c):h=s.getName();try{r.append(Ce.decode(d,h))}catch(p){throw new j(p)}a.push(d)}static toAlphaNumericChar(e){if(e>=mt.ALPHANUMERIC_CHARS.length)throw new j;return mt.ALPHANUMERIC_CHARS[e]}static decodeAlphanumericSegment(e,r,i,s){const a=r.length();for(;i>1;){if(e.available()<11)throw new j;const c=e.readBits(11);r.append(mt.toAlphaNumericChar(Math.floor(c/45))),r.append(mt.toAlphaNumericChar(c%45)),i-=2}if(i===1){if(e.available()<6)throw new j;r.append(mt.toAlphaNumericChar(e.readBits(6)))}if(s)for(let c=a;c<r.length();c++)r.charAt(c)==="%"&&(c<r.length()-1&&r.charAt(c+1)==="%"?r.deleteCharAt(c+1):r.setCharAt(c,""))}static decodeNumericSegment(e,r,i){for(;i>=3;){if(e.available()<10)throw new j;const s=e.readBits(10);if(s>=1e3)throw new j;r.append(mt.toAlphaNumericChar(Math.floor(s/100))),r.append(mt.toAlphaNumericChar(Math.floor(s/10)%10)),r.append(mt.toAlphaNumericChar(s%10)),i-=3}if(i===2){if(e.available()<7)throw new j;const s=e.readBits(7);if(s>=100)throw new j;r.append(mt.toAlphaNumericChar(Math.floor(s/10))),r.append(mt.toAlphaNumericChar(s%10))}else if(i===1){if(e.available()<4)throw new j;const s=e.readBits(4);if(s>=10)throw new j;r.append(mt.toAlphaNumericChar(s))}}static parseECIValue(e){const r=e.readBits(8);if((r&128)===0)return r&127;if((r&192)===128){const i=e.readBits(8);return(r&63)<<8&4294967295|i}if((r&224)===192){const i=e.readBits(16);return(r&31)<<16&4294967295|i}throw new j}}mt.ALPHANUMERIC_CHARS="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",mt.GB2312_SUBSET=1;class Ns{constructor(e){this.mirrored=e}isMirrored(){return this.mirrored}applyMirroredCorrection(e){if(!this.mirrored||e===null||e.length<3)return;const r=e[0];e[0]=e[2],e[2]=r}}class S1{constructor(){this.rsDecoder=new De(je.QR_CODE_FIELD_256)}decodeBooleanArray(e,r){return this.decodeBitMatrix(le.parseFromBooleanArray(e),r)}decodeBitMatrix(e,r){const i=new I1(e);let s=null;try{return this.decodeBitMatrixParser(i,r)}catch(a){s=a}try{i.remask(),i.setMirror(!0),i.readVersion(),i.readFormatInformation(),i.mirror();const a=this.decodeBitMatrixParser(i,r);return a.setOther(new Ns(!0)),a}catch(a){throw s!==null?s:a}}decodeBitMatrixParser(e,r){const i=e.readVersion(),s=e.readFormatInformation().getErrorCorrectionLevel(),a=e.readCodewords(),c=po.getDataBlocks(a,i,s);let d=0;for(const w of c)d+=w.getNumDataCodewords();const h=new Uint8Array(d);let p=0;for(const w of c){const v=w.getCodewords(),E=w.getNumDataCodewords();this.correctErrors(v,E);for(let O=0;O<E;O++)h[p++]=v[O]}return mt.decode(h,i,s,r)}correctErrors(e,r){const i=new Int32Array(e);try{this.rsDecoder.decode(i,e.length-r)}catch{throw new N}for(let s=0;s<r;s++)e[s]=i[s]}}class go extends Se{constructor(e,r,i){super(e,r),this.estimatedModuleSize=i}aboutEquals(e,r,i){if(Math.abs(r-this.getY())<=e&&Math.abs(i-this.getX())<=e){const s=Math.abs(e-this.estimatedModuleSize);return s<=1||s<=this.estimatedModuleSize}return!1}combineEstimate(e,r,i){const s=(this.getX()+r)/2,a=(this.getY()+e)/2,c=(this.estimatedModuleSize+i)/2;return new go(s,a,c)}}class mi{constructor(e,r,i,s,a,c,d){this.image=e,this.startX=r,this.startY=i,this.width=s,this.height=a,this.moduleSize=c,this.resultPointCallback=d,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(3)}find(){const e=this.startX,r=this.height,i=this.width,s=e+i,a=this.startY+r/2,c=new Int32Array(3),d=this.image;for(let h=0;h<r;h++){const p=a+((h&1)===0?Math.floor((h+1)/2):-Math.floor((h+1)/2));c[0]=0,c[1]=0,c[2]=0;let w=e;for(;w<s&&!d.get(w,p);)w++;let v=0;for(;w<s;){if(d.get(w,p))if(v===1)c[1]++;else if(v===2){if(this.foundPatternCross(c)){const E=this.handlePossibleCenter(c,p,w);if(E!==null)return E}c[0]=c[2],c[1]=1,c[2]=0,v=1}else c[++v]++;else v===1&&v++,c[v]++;w++}if(this.foundPatternCross(c)){const E=this.handlePossibleCenter(c,p,s);if(E!==null)return E}}if(this.possibleCenters.length!==0)return this.possibleCenters[0];throw new F}static centerFromEnd(e,r){return r-e[2]-e[1]/2}foundPatternCross(e){const r=this.moduleSize,i=r/2;for(let s=0;s<3;s++)if(Math.abs(r-e[s])>=i)return!1;return!0}crossCheckVertical(e,r,i,s){const a=this.image,c=a.getHeight(),d=this.crossCheckStateCount;d[0]=0,d[1]=0,d[2]=0;let h=e;for(;h>=0&&a.get(r,h)&&d[1]<=i;)d[1]++,h--;if(h<0||d[1]>i)return NaN;for(;h>=0&&!a.get(r,h)&&d[0]<=i;)d[0]++,h--;if(d[0]>i)return NaN;for(h=e+1;h<c&&a.get(r,h)&&d[1]<=i;)d[1]++,h++;if(h===c||d[1]>i)return NaN;for(;h<c&&!a.get(r,h)&&d[2]<=i;)d[2]++,h++;if(d[2]>i)return NaN;const p=d[0]+d[1]+d[2];return 5*Math.abs(p-s)>=2*s?NaN:this.foundPatternCross(d)?mi.centerFromEnd(d,h):NaN}handlePossibleCenter(e,r,i){const s=e[0]+e[1]+e[2],a=mi.centerFromEnd(e,i),c=this.crossCheckVertical(r,a,2*e[1],s);if(!isNaN(c)){const d=(e[0]+e[1]+e[2])/3;for(const p of this.possibleCenters)if(p.aboutEquals(d,c,a))return p.combineEstimate(c,a,d);const h=new go(a,c,d);this.possibleCenters.push(h),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(h)}return null}}class mo extends Se{constructor(e,r,i,s){super(e,r),this.estimatedModuleSize=i,this.count=s,s===void 0&&(this.count=1)}getEstimatedModuleSize(){return this.estimatedModuleSize}getCount(){return this.count}aboutEquals(e,r,i){if(Math.abs(r-this.getY())<=e&&Math.abs(i-this.getX())<=e){const s=Math.abs(e-this.estimatedModuleSize);return s<=1||s<=this.estimatedModuleSize}return!1}combineEstimate(e,r,i){const s=this.count+1,a=(this.count*this.getX()+r)/s,c=(this.count*this.getY()+e)/s,d=(this.count*this.estimatedModuleSize+i)/s;return new mo(a,c,d,s)}}class T1{constructor(e){this.bottomLeft=e[0],this.topLeft=e[1],this.topRight=e[2]}getBottomLeft(){return this.bottomLeft}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}}class Rt{constructor(e,r){this.image=e,this.resultPointCallback=r,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(5),this.resultPointCallback=r}getImage(){return this.image}getPossibleCenters(){return this.possibleCenters}find(e){const r=e!=null&&e.get(Q.TRY_HARDER)!==void 0,i=e!=null&&e.get(Q.PURE_BARCODE)!==void 0,s=this.image,a=s.getHeight(),c=s.getWidth();let d=Math.floor(3*a/(4*Rt.MAX_MODULES));(d<Rt.MIN_SKIP||r)&&(d=Rt.MIN_SKIP);let h=!1;const p=new Int32Array(5);for(let v=d-1;v<a&&!h;v+=d){p[0]=0,p[1]=0,p[2]=0,p[3]=0,p[4]=0;let E=0;for(let O=0;O<c;O++)if(s.get(O,v))(E&1)===1&&E++,p[E]++;else if((E&1)===0)if(E===4)if(Rt.foundPatternCross(p)){if(this.handlePossibleCenter(p,v,O,i)===!0)if(d=2,this.hasSkipped===!0)h=this.haveMultiplyConfirmedCenters();else{const $=this.findRowSkip();$>p[2]&&(v+=$-p[2]-d,O=c-1)}else{p[0]=p[2],p[1]=p[3],p[2]=p[4],p[3]=1,p[4]=0,E=3;continue}E=0,p[0]=0,p[1]=0,p[2]=0,p[3]=0,p[4]=0}else p[0]=p[2],p[1]=p[3],p[2]=p[4],p[3]=1,p[4]=0,E=3;else p[++E]++;else p[E]++;Rt.foundPatternCross(p)&&this.handlePossibleCenter(p,v,c,i)===!0&&(d=p[0],this.hasSkipped&&(h=this.haveMultiplyConfirmedCenters()))}const w=this.selectBestPatterns();return Se.orderBestPatterns(w),new T1(w)}static centerFromEnd(e,r){return r-e[4]-e[3]-e[2]/2}static foundPatternCross(e){let r=0;for(let a=0;a<5;a++){const c=e[a];if(c===0)return!1;r+=c}if(r<7)return!1;const i=r/7,s=i/2;return Math.abs(i-e[0])<s&&Math.abs(i-e[1])<s&&Math.abs(3*i-e[2])<3*s&&Math.abs(i-e[3])<s&&Math.abs(i-e[4])<s}getCrossCheckStateCount(){const e=this.crossCheckStateCount;return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e}crossCheckDiagonal(e,r,i,s){const a=this.getCrossCheckStateCount();let c=0;const d=this.image;for(;e>=c&&r>=c&&d.get(r-c,e-c);)a[2]++,c++;if(e<c||r<c)return!1;for(;e>=c&&r>=c&&!d.get(r-c,e-c)&&a[1]<=i;)a[1]++,c++;if(e<c||r<c||a[1]>i)return!1;for(;e>=c&&r>=c&&d.get(r-c,e-c)&&a[0]<=i;)a[0]++,c++;if(a[0]>i)return!1;const h=d.getHeight(),p=d.getWidth();for(c=1;e+c<h&&r+c<p&&d.get(r+c,e+c);)a[2]++,c++;if(e+c>=h||r+c>=p)return!1;for(;e+c<h&&r+c<p&&!d.get(r+c,e+c)&&a[3]<i;)a[3]++,c++;if(e+c>=h||r+c>=p||a[3]>=i)return!1;for(;e+c<h&&r+c<p&&d.get(r+c,e+c)&&a[4]<i;)a[4]++,c++;if(a[4]>=i)return!1;const w=a[0]+a[1]+a[2]+a[3]+a[4];return Math.abs(w-s)<2*s&&Rt.foundPatternCross(a)}crossCheckVertical(e,r,i,s){const a=this.image,c=a.getHeight(),d=this.getCrossCheckStateCount();let h=e;for(;h>=0&&a.get(r,h);)d[2]++,h--;if(h<0)return NaN;for(;h>=0&&!a.get(r,h)&&d[1]<=i;)d[1]++,h--;if(h<0||d[1]>i)return NaN;for(;h>=0&&a.get(r,h)&&d[0]<=i;)d[0]++,h--;if(d[0]>i)return NaN;for(h=e+1;h<c&&a.get(r,h);)d[2]++,h++;if(h===c)return NaN;for(;h<c&&!a.get(r,h)&&d[3]<i;)d[3]++,h++;if(h===c||d[3]>=i)return NaN;for(;h<c&&a.get(r,h)&&d[4]<i;)d[4]++,h++;if(d[4]>=i)return NaN;const p=d[0]+d[1]+d[2]+d[3]+d[4];return 5*Math.abs(p-s)>=2*s?NaN:Rt.foundPatternCross(d)?Rt.centerFromEnd(d,h):NaN}crossCheckHorizontal(e,r,i,s){const a=this.image,c=a.getWidth(),d=this.getCrossCheckStateCount();let h=e;for(;h>=0&&a.get(h,r);)d[2]++,h--;if(h<0)return NaN;for(;h>=0&&!a.get(h,r)&&d[1]<=i;)d[1]++,h--;if(h<0||d[1]>i)return NaN;for(;h>=0&&a.get(h,r)&&d[0]<=i;)d[0]++,h--;if(d[0]>i)return NaN;for(h=e+1;h<c&&a.get(h,r);)d[2]++,h++;if(h===c)return NaN;for(;h<c&&!a.get(h,r)&&d[3]<i;)d[3]++,h++;if(h===c||d[3]>=i)return NaN;for(;h<c&&a.get(h,r)&&d[4]<i;)d[4]++,h++;if(d[4]>=i)return NaN;const p=d[0]+d[1]+d[2]+d[3]+d[4];return 5*Math.abs(p-s)>=s?NaN:Rt.foundPatternCross(d)?Rt.centerFromEnd(d,h):NaN}handlePossibleCenter(e,r,i,s){const a=e[0]+e[1]+e[2]+e[3]+e[4];let c=Rt.centerFromEnd(e,i),d=this.crossCheckVertical(r,Math.floor(c),e[2],a);if(!isNaN(d)&&(c=this.crossCheckHorizontal(Math.floor(c),Math.floor(d),e[2],a),!isNaN(c)&&(!s||this.crossCheckDiagonal(Math.floor(d),Math.floor(c),e[2],a)))){const h=a/7;let p=!1;const w=this.possibleCenters;for(let v=0,E=w.length;v<E;v++){const O=w[v];if(O.aboutEquals(h,d,c)){w[v]=O.combineEstimate(d,c,h),p=!0;break}}if(!p){const v=new mo(c,d,h);w.push(v),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(v)}return!0}return!1}findRowSkip(){if(this.possibleCenters.length<=1)return 0;let r=null;for(const i of this.possibleCenters)if(i.getCount()>=Rt.CENTER_QUORUM)if(r==null)r=i;else return this.hasSkipped=!0,Math.floor((Math.abs(r.getX()-i.getX())-Math.abs(r.getY()-i.getY()))/2);return 0}haveMultiplyConfirmedCenters(){let e=0,r=0;const i=this.possibleCenters.length;for(const c of this.possibleCenters)c.getCount()>=Rt.CENTER_QUORUM&&(e++,r+=c.getEstimatedModuleSize());if(e<3)return!1;const s=r/i;let a=0;for(const c of this.possibleCenters)a+=Math.abs(c.getEstimatedModuleSize()-s);return a<=.05*r}selectBestPatterns(){const e=this.possibleCenters.length;if(e<3)throw new F;const r=this.possibleCenters;let i;if(e>3){let s=0,a=0;for(const h of this.possibleCenters){const p=h.getEstimatedModuleSize();s+=p,a+=p*p}i=s/e;let c=Math.sqrt(a/e-i*i);r.sort((h,p)=>{const w=Math.abs(p.getEstimatedModuleSize()-i),v=Math.abs(h.getEstimatedModuleSize()-i);return w<v?-1:w>v?1:0});const d=Math.max(.2*i,c);for(let h=0;h<r.length&&r.length>3;h++){const p=r[h];Math.abs(p.getEstimatedModuleSize()-i)>d&&(r.splice(h,1),h--)}}if(r.length>3){let s=0;for(const a of r)s+=a.getEstimatedModuleSize();i=s/r.length,r.sort((a,c)=>{if(c.getCount()===a.getCount()){const d=Math.abs(c.getEstimatedModuleSize()-i),h=Math.abs(a.getEstimatedModuleSize()-i);return d<h?1:d>h?-1:0}else return c.getCount()-a.getCount()}),r.splice(3)}return[r[0],r[1],r[2]]}}Rt.CENTER_QUORUM=2,Rt.MIN_SKIP=3,Rt.MAX_MODULES=57;class Rr{constructor(e){this.image=e}getImage(){return this.image}getResultPointCallback(){return this.resultPointCallback}detect(e){this.resultPointCallback=e==null?null:e.get(Q.NEED_RESULT_POINT_CALLBACK);const i=new Rt(this.image,this.resultPointCallback).find(e);return this.processFinderPatternInfo(i)}processFinderPatternInfo(e){const r=e.getTopLeft(),i=e.getTopRight(),s=e.getBottomLeft(),a=this.calculateModuleSize(r,i,s);if(a<1)throw new F("No pattern found in proccess finder.");const c=Rr.computeDimension(r,i,s,a),d=Ne.getProvisionalVersionForDimension(c),h=d.getDimensionForVersion()-7;let p=null;if(d.getAlignmentPatternCenters().length>0){const O=i.getX()-r.getX()+s.getX(),L=i.getY()-r.getY()+s.getY(),$=1-3/h,Z=Math.floor(r.getX()+$*(O-r.getX())),G=Math.floor(r.getY()+$*(L-r.getY()));for(let ae=4;ae<=16;ae<<=1)try{p=this.findAlignmentInRegion(a,Z,G,ae);break}catch(ce){if(!(ce instanceof F))throw ce}}const w=Rr.createTransform(r,i,s,p,c),v=Rr.sampleGrid(this.image,w,c);let E;return p===null?E=[s,r,i]:E=[s,r,i,p],new ir(v,E)}static createTransform(e,r,i,s,a){const c=a-3.5;let d,h,p,w;return s!==null?(d=s.getX(),h=s.getY(),p=c-3,w=p):(d=r.getX()-e.getX()+i.getX(),h=r.getY()-e.getY()+i.getY(),p=c,w=c),Kt.quadrilateralToQuadrilateral(3.5,3.5,c,3.5,p,w,3.5,c,e.getX(),e.getY(),r.getX(),r.getY(),d,h,i.getX(),i.getY())}static sampleGrid(e,r,i){return Hn.getInstance().sampleGridWithTransform(e,i,i,r)}static computeDimension(e,r,i,s){const a=ke.round(Se.distance(e,r)/s),c=ke.round(Se.distance(e,i)/s);let d=Math.floor((a+c)/2)+7;switch(d&3){case 0:d++;break;case 2:d--;break;case 3:throw new F("Dimensions could be not found.")}return d}calculateModuleSize(e,r,i){return(this.calculateModuleSizeOneWay(e,r)+this.calculateModuleSizeOneWay(e,i))/2}calculateModuleSizeOneWay(e,r){const i=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(e.getX()),Math.floor(e.getY()),Math.floor(r.getX()),Math.floor(r.getY())),s=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(r.getX()),Math.floor(r.getY()),Math.floor(e.getX()),Math.floor(e.getY()));return isNaN(i)?s/7:isNaN(s)?i/7:(i+s)/14}sizeOfBlackWhiteBlackRunBothWays(e,r,i,s){let a=this.sizeOfBlackWhiteBlackRun(e,r,i,s),c=1,d=e-(i-e);d<0?(c=e/(e-d),d=0):d>=this.image.getWidth()&&(c=(this.image.getWidth()-1-e)/(d-e),d=this.image.getWidth()-1);let h=Math.floor(r-(s-r)*c);return c=1,h<0?(c=r/(r-h),h=0):h>=this.image.getHeight()&&(c=(this.image.getHeight()-1-r)/(h-r),h=this.image.getHeight()-1),d=Math.floor(e+(d-e)*c),a+=this.sizeOfBlackWhiteBlackRun(e,r,d,h),a-1}sizeOfBlackWhiteBlackRun(e,r,i,s){const a=Math.abs(s-r)>Math.abs(i-e);if(a){let O=e;e=r,r=O,O=i,i=s,s=O}const c=Math.abs(i-e),d=Math.abs(s-r);let h=-c/2;const p=e<i?1:-1,w=r<s?1:-1;let v=0;const E=i+p;for(let O=e,L=r;O!==E;O+=p){const $=a?L:O,Z=a?O:L;if(v===1===this.image.get($,Z)){if(v===2)return ke.distance(O,L,e,r);v++}if(h+=d,h>0){if(L===s)break;L+=w,h-=c}}return v===2?ke.distance(i+p,s,e,r):NaN}findAlignmentInRegion(e,r,i,s){const a=Math.floor(s*e),c=Math.max(0,r-a),d=Math.min(this.image.getWidth()-1,r+a);if(d-c<e*3)throw new F("Alignment top exceeds estimated module size.");const h=Math.max(0,i-a),p=Math.min(this.image.getHeight()-1,i+a);if(p-h<e*3)throw new F("Alignment bottom exceeds estimated module size.");return new mi(this.image,c,h,d-c,p-h,e,this.resultPointCallback).find()}}class Yn{constructor(){this.decoder=new S1}getDecoder(){return this.decoder}decode(e,r){let i,s;if(r!=null&&r.get(Q.PURE_BARCODE)!==void 0){const h=Yn.extractPureBits(e.getBlackMatrix());i=this.decoder.decodeBitMatrix(h,r),s=Yn.NO_POINTS}else{const h=new Rr(e.getBlackMatrix()).detect(r);i=this.decoder.decodeBitMatrix(h.getBits(),r),s=h.getPoints()}i.getOther()instanceof Ns&&i.getOther().applyMirroredCorrection(s);const a=new Pe(i.getText(),i.getRawBytes(),void 0,s,S.QR_CODE,void 0),c=i.getByteSegments();c!==null&&a.putMetadata(se.BYTE_SEGMENTS,c);const d=i.getECLevel();return d!==null&&a.putMetadata(se.ERROR_CORRECTION_LEVEL,d),i.hasStructuredAppend()&&(a.putMetadata(se.STRUCTURED_APPEND_SEQUENCE,i.getStructuredAppendSequenceNumber()),a.putMetadata(se.STRUCTURED_APPEND_PARITY,i.getStructuredAppendParity())),a}reset(){}static extractPureBits(e){const r=e.getTopLeftOnBit(),i=e.getBottomRightOnBit();if(r===null||i===null)throw new F;const s=this.moduleSize(r,e);let a=r[1],c=i[1],d=r[0],h=i[0];if(d>=h||a>=c)throw new F;if(c-a!==h-d&&(h=d+(c-a),h>=e.getWidth()))throw new F;const p=Math.round((h-d+1)/s),w=Math.round((c-a+1)/s);if(p<=0||w<=0)throw new F;if(w!==p)throw new F;const v=Math.floor(s/2);a+=v,d+=v;const E=d+Math.floor((p-1)*s)-h;if(E>0){if(E>v)throw new F;d-=E}const O=a+Math.floor((w-1)*s)-c;if(O>0){if(O>v)throw new F;a-=O}const L=new le(p,w);for(let $=0;$<w;$++){const Z=a+Math.floor($*s);for(let G=0;G<p;G++)e.get(d+Math.floor(G*s),Z)&&L.set(G,$)}return L}static moduleSize(e,r){const i=r.getHeight(),s=r.getWidth();let a=e[0],c=e[1],d=!0,h=0;for(;a<s&&c<i;){if(d!==r.get(a,c)){if(++h===5)break;d=!d}a++,c++}if(a===s||c===i)throw new F;return(a-e[0])/7}}Yn.NO_POINTS=new Array;class Be{PDF417Common(){}static getBitCountSum(e){return ke.sum(e)}static toIntArray(e){if(e==null||!e.length)return Be.EMPTY_INT_ARRAY;const r=new Int32Array(e.length);let i=0;for(const s of e)r[i++]=s;return r}static getCodeword(e){const r=U.binarySearch(Be.SYMBOL_TABLE,e&262143);return r<0?-1:(Be.CODEWORD_TABLE[r]-1)%Be.NUMBER_OF_CODEWORDS}}Be.NUMBER_OF_CODEWORDS=929,Be.MAX_CODEWORDS_IN_BARCODE=Be.NUMBER_OF_CODEWORDS-1,Be.MIN_ROWS_IN_BARCODE=3,Be.MAX_ROWS_IN_BARCODE=90,Be.MODULES_IN_CODEWORD=17,Be.MODULES_IN_STOP_PATTERN=18,Be.BARS_IN_MODULE=8,Be.EMPTY_INT_ARRAY=new Int32Array([]),Be.SYMBOL_TABLE=Int32Array.from([66142,66170,66206,66236,66290,66292,66350,66382,66396,66454,66470,66476,66594,66600,66614,66626,66628,66632,66640,66654,66662,66668,66682,66690,66718,66720,66748,66758,66776,66798,66802,66804,66820,66824,66832,66846,66848,66876,66880,66936,66950,66956,66968,66992,67006,67022,67036,67042,67044,67048,67062,67118,67150,67164,67214,67228,67256,67294,67322,67350,67366,67372,67398,67404,67416,67438,67474,67476,67490,67492,67496,67510,67618,67624,67650,67656,67664,67678,67686,67692,67706,67714,67716,67728,67742,67744,67772,67782,67788,67800,67822,67826,67828,67842,67848,67870,67872,67900,67904,67960,67974,67992,68016,68030,68046,68060,68066,68068,68072,68086,68104,68112,68126,68128,68156,68160,68216,68336,68358,68364,68376,68400,68414,68448,68476,68494,68508,68536,68546,68548,68552,68560,68574,68582,68588,68654,68686,68700,68706,68708,68712,68726,68750,68764,68792,68802,68804,68808,68816,68830,68838,68844,68858,68878,68892,68920,68976,68990,68994,68996,69e3,69008,69022,69024,69052,69062,69068,69080,69102,69106,69108,69142,69158,69164,69190,69208,69230,69254,69260,69272,69296,69310,69326,69340,69386,69394,69396,69410,69416,69430,69442,69444,69448,69456,69470,69478,69484,69554,69556,69666,69672,69698,69704,69712,69726,69754,69762,69764,69776,69790,69792,69820,69830,69836,69848,69870,69874,69876,69890,69918,69920,69948,69952,70008,70022,70040,70064,70078,70094,70108,70114,70116,70120,70134,70152,70174,70176,70264,70384,70412,70448,70462,70496,70524,70542,70556,70584,70594,70600,70608,70622,70630,70636,70664,70672,70686,70688,70716,70720,70776,70896,71136,71180,71192,71216,71230,71264,71292,71360,71416,71452,71480,71536,71550,71554,71556,71560,71568,71582,71584,71612,71622,71628,71640,71662,71726,71732,71758,71772,71778,71780,71784,71798,71822,71836,71864,71874,71880,71888,71902,71910,71916,71930,71950,71964,71992,72048,72062,72066,72068,72080,72094,72096,72124,72134,72140,72152,72174,72178,72180,72206,72220,72248,72304,72318,72416,72444,72456,72464,72478,72480,72508,72512,72568,72588,72600,72624,72638,72654,72668,72674,72676,72680,72694,72726,72742,72748,72774,72780,72792,72814,72838,72856,72880,72894,72910,72924,72930,72932,72936,72950,72966,72972,72984,73008,73022,73056,73084,73102,73116,73144,73156,73160,73168,73182,73190,73196,73210,73226,73234,73236,73250,73252,73256,73270,73282,73284,73296,73310,73318,73324,73346,73348,73352,73360,73374,73376,73404,73414,73420,73432,73454,73498,73518,73522,73524,73550,73564,73570,73572,73576,73590,73800,73822,73858,73860,73872,73886,73888,73916,73944,73970,73972,73992,74014,74016,74044,74048,74104,74118,74136,74160,74174,74210,74212,74216,74230,74244,74256,74270,74272,74360,74480,74502,74508,74544,74558,74592,74620,74638,74652,74680,74690,74696,74704,74726,74732,74782,74784,74812,74992,75232,75288,75326,75360,75388,75456,75512,75576,75632,75646,75650,75652,75664,75678,75680,75708,75718,75724,75736,75758,75808,75836,75840,75896,76016,76256,76736,76824,76848,76862,76896,76924,76992,77048,77296,77340,77368,77424,77438,77536,77564,77572,77576,77584,77600,77628,77632,77688,77702,77708,77720,77744,77758,77774,77788,77870,77902,77916,77922,77928,77966,77980,78008,78018,78024,78032,78046,78060,78074,78094,78136,78192,78206,78210,78212,78224,78238,78240,78268,78278,78284,78296,78322,78324,78350,78364,78448,78462,78560,78588,78600,78622,78624,78652,78656,78712,78726,78744,78768,78782,78798,78812,78818,78820,78824,78838,78862,78876,78904,78960,78974,79072,79100,79296,79352,79368,79376,79390,79392,79420,79424,79480,79600,79628,79640,79664,79678,79712,79740,79772,79800,79810,79812,79816,79824,79838,79846,79852,79894,79910,79916,79942,79948,79960,79982,79988,80006,80024,80048,80062,80078,80092,80098,80100,80104,80134,80140,80176,80190,80224,80252,80270,80284,80312,80328,80336,80350,80358,80364,80378,80390,80396,80408,80432,80446,80480,80508,80576,80632,80654,80668,80696,80752,80766,80776,80784,80798,80800,80828,80844,80856,80878,80882,80884,80914,80916,80930,80932,80936,80950,80962,80968,80976,80990,80998,81004,81026,81028,81040,81054,81056,81084,81094,81100,81112,81134,81154,81156,81160,81168,81182,81184,81212,81216,81272,81286,81292,81304,81328,81342,81358,81372,81380,81384,81398,81434,81454,81458,81460,81486,81500,81506,81508,81512,81526,81550,81564,81592,81602,81604,81608,81616,81630,81638,81644,81702,81708,81722,81734,81740,81752,81774,81778,81780,82050,82078,82080,82108,82180,82184,82192,82206,82208,82236,82240,82296,82316,82328,82352,82366,82402,82404,82408,82440,82448,82462,82464,82492,82496,82552,82672,82694,82700,82712,82736,82750,82784,82812,82830,82882,82884,82888,82896,82918,82924,82952,82960,82974,82976,83004,83008,83064,83184,83424,83468,83480,83504,83518,83552,83580,83648,83704,83740,83768,83824,83838,83842,83844,83848,83856,83872,83900,83910,83916,83928,83950,83984,84e3,84028,84032,84088,84208,84448,84928,85040,85054,85088,85116,85184,85240,85488,85560,85616,85630,85728,85756,85764,85768,85776,85790,85792,85820,85824,85880,85894,85900,85912,85936,85966,85980,86048,86080,86136,86256,86496,86976,88160,88188,88256,88312,88560,89056,89200,89214,89312,89340,89536,89592,89608,89616,89632,89664,89720,89840,89868,89880,89904,89952,89980,89998,90012,90040,90190,90204,90254,90268,90296,90306,90308,90312,90334,90382,90396,90424,90480,90494,90500,90504,90512,90526,90528,90556,90566,90572,90584,90610,90612,90638,90652,90680,90736,90750,90848,90876,90884,90888,90896,90910,90912,90940,90944,91e3,91014,91020,91032,91056,91070,91086,91100,91106,91108,91112,91126,91150,91164,91192,91248,91262,91360,91388,91584,91640,91664,91678,91680,91708,91712,91768,91888,91928,91952,91966,92e3,92028,92046,92060,92088,92098,92100,92104,92112,92126,92134,92140,92188,92216,92272,92384,92412,92608,92664,93168,93200,93214,93216,93244,93248,93304,93424,93664,93720,93744,93758,93792,93820,93888,93944,93980,94008,94064,94078,94084,94088,94096,94110,94112,94140,94150,94156,94168,94246,94252,94278,94284,94296,94318,94342,94348,94360,94384,94398,94414,94428,94440,94470,94476,94488,94512,94526,94560,94588,94606,94620,94648,94658,94660,94664,94672,94686,94694,94700,94714,94726,94732,94744,94768,94782,94816,94844,94912,94968,94990,95004,95032,95088,95102,95112,95120,95134,95136,95164,95180,95192,95214,95218,95220,95244,95256,95280,95294,95328,95356,95424,95480,95728,95758,95772,95800,95856,95870,95968,95996,96008,96016,96030,96032,96060,96064,96120,96152,96176,96190,96220,96226,96228,96232,96290,96292,96296,96310,96322,96324,96328,96336,96350,96358,96364,96386,96388,96392,96400,96414,96416,96444,96454,96460,96472,96494,96498,96500,96514,96516,96520,96528,96542,96544,96572,96576,96632,96646,96652,96664,96688,96702,96718,96732,96738,96740,96744,96758,96772,96776,96784,96798,96800,96828,96832,96888,97008,97030,97036,97048,97072,97086,97120,97148,97166,97180,97208,97220,97224,97232,97246,97254,97260,97326,97330,97332,97358,97372,97378,97380,97384,97398,97422,97436,97464,97474,97476,97480,97488,97502,97510,97516,97550,97564,97592,97648,97666,97668,97672,97680,97694,97696,97724,97734,97740,97752,97774,97830,97836,97850,97862,97868,97880,97902,97906,97908,97926,97932,97944,97968,97998,98012,98018,98020,98024,98038,98618,98674,98676,98838,98854,98874,98892,98904,98926,98930,98932,98968,99006,99042,99044,99048,99062,99166,99194,99246,99286,99350,99366,99372,99386,99398,99416,99438,99442,99444,99462,99504,99518,99534,99548,99554,99556,99560,99574,99590,99596,99608,99632,99646,99680,99708,99726,99740,99768,99778,99780,99784,99792,99806,99814,99820,99834,99858,99860,99874,99880,99894,99906,99920,99934,99962,99970,99972,99976,99984,99998,1e5,100028,100038,100044,100056,100078,100082,100084,100142,100174,100188,100246,100262,100268,100306,100308,100390,100396,100410,100422,100428,100440,100462,100466,100468,100486,100504,100528,100542,100558,100572,100578,100580,100584,100598,100620,100656,100670,100704,100732,100750,100792,100802,100808,100816,100830,100838,100844,100858,100888,100912,100926,100960,100988,101056,101112,101148,101176,101232,101246,101250,101252,101256,101264,101278,101280,101308,101318,101324,101336,101358,101362,101364,101410,101412,101416,101430,101442,101448,101456,101470,101478,101498,101506,101508,101520,101534,101536,101564,101580,101618,101620,101636,101640,101648,101662,101664,101692,101696,101752,101766,101784,101838,101858,101860,101864,101934,101938,101940,101966,101980,101986,101988,101992,102030,102044,102072,102082,102084,102088,102096,102138,102166,102182,102188,102214,102220,102232,102254,102282,102290,102292,102306,102308,102312,102326,102444,102458,102470,102476,102488,102514,102516,102534,102552,102576,102590,102606,102620,102626,102632,102646,102662,102668,102704,102718,102752,102780,102798,102812,102840,102850,102856,102864,102878,102886,102892,102906,102936,102974,103008,103036,103104,103160,103224,103280,103294,103298,103300,103312,103326,103328,103356,103366,103372,103384,103406,103410,103412,103472,103486,103520,103548,103616,103672,103920,103992,104048,104062,104160,104188,104194,104196,104200,104208,104224,104252,104256,104312,104326,104332,104344,104368,104382,104398,104412,104418,104420,104424,104482,104484,104514,104520,104528,104542,104550,104570,104578,104580,104592,104606,104608,104636,104652,104690,104692,104706,104712,104734,104736,104764,104768,104824,104838,104856,104910,104930,104932,104936,104968,104976,104990,104992,105020,105024,105080,105200,105240,105278,105312,105372,105410,105412,105416,105424,105446,105518,105524,105550,105564,105570,105572,105576,105614,105628,105656,105666,105672,105680,105702,105722,105742,105756,105784,105840,105854,105858,105860,105864,105872,105888,105932,105970,105972,106006,106022,106028,106054,106060,106072,106100,106118,106124,106136,106160,106174,106190,106210,106212,106216,106250,106258,106260,106274,106276,106280,106306,106308,106312,106320,106334,106348,106394,106414,106418,106420,106566,106572,106610,106612,106630,106636,106648,106672,106686,106722,106724,106728,106742,106758,106764,106776,106800,106814,106848,106876,106894,106908,106936,106946,106948,106952,106960,106974,106982,106988,107032,107056,107070,107104,107132,107200,107256,107292,107320,107376,107390,107394,107396,107400,107408,107422,107424,107452,107462,107468,107480,107502,107506,107508,107544,107568,107582,107616,107644,107712,107768,108016,108060,108088,108144,108158,108256,108284,108290,108292,108296,108304,108318,108320,108348,108352,108408,108422,108428,108440,108464,108478,108494,108508,108514,108516,108520,108592,108640,108668,108736,108792,109040,109536,109680,109694,109792,109820,110016,110072,110084,110088,110096,110112,110140,110144,110200,110320,110342,110348,110360,110384,110398,110432,110460,110478,110492,110520,110532,110536,110544,110558,110658,110686,110714,110722,110724,110728,110736,110750,110752,110780,110796,110834,110836,110850,110852,110856,110864,110878,110880,110908,110912,110968,110982,111e3,111054,111074,111076,111080,111108,111112,111120,111134,111136,111164,111168,111224,111344,111372,111422,111456,111516,111554,111556,111560,111568,111590,111632,111646,111648,111676,111680,111736,111856,112096,112152,112224,112252,112320,112440,112514,112516,112520,112528,112542,112544,112588,112686,112718,112732,112782,112796,112824,112834,112836,112840,112848,112870,112890,112910,112924,112952,113008,113022,113026,113028,113032,113040,113054,113056,113100,113138,113140,113166,113180,113208,113264,113278,113376,113404,113416,113424,113440,113468,113472,113560,113614,113634,113636,113640,113686,113702,113708,113734,113740,113752,113778,113780,113798,113804,113816,113840,113854,113870,113890,113892,113896,113926,113932,113944,113968,113982,114016,114044,114076,114114,114116,114120,114128,114150,114170,114194,114196,114210,114212,114216,114242,114244,114248,114256,114270,114278,114306,114308,114312,114320,114334,114336,114364,114380,114420,114458,114478,114482,114484,114510,114524,114530,114532,114536,114842,114866,114868,114970,114994,114996,115042,115044,115048,115062,115130,115226,115250,115252,115278,115292,115298,115300,115304,115318,115342,115394,115396,115400,115408,115422,115430,115436,115450,115478,115494,115514,115526,115532,115570,115572,115738,115758,115762,115764,115790,115804,115810,115812,115816,115830,115854,115868,115896,115906,115912,115920,115934,115942,115948,115962,115996,116024,116080,116094,116098,116100,116104,116112,116126,116128,116156,116166,116172,116184,116206,116210,116212,116246,116262,116268,116282,116294,116300,116312,116334,116338,116340,116358,116364,116376,116400,116414,116430,116444,116450,116452,116456,116498,116500,116514,116520,116534,116546,116548,116552,116560,116574,116582,116588,116602,116654,116694,116714,116762,116782,116786,116788,116814,116828,116834,116836,116840,116854,116878,116892,116920,116930,116936,116944,116958,116966,116972,116986,117006,117048,117104,117118,117122,117124,117136,117150,117152,117180,117190,117196,117208,117230,117234,117236,117304,117360,117374,117472,117500,117506,117508,117512,117520,117536,117564,117568,117624,117638,117644,117656,117680,117694,117710,117724,117730,117732,117736,117750,117782,117798,117804,117818,117830,117848,117874,117876,117894,117936,117950,117966,117986,117988,117992,118022,118028,118040,118064,118078,118112,118140,118172,118210,118212,118216,118224,118238,118246,118266,118306,118312,118338,118352,118366,118374,118394,118402,118404,118408,118416,118430,118432,118460,118476,118514,118516,118574,118578,118580,118606,118620,118626,118628,118632,118678,118694,118700,118730,118738,118740,118830,118834,118836,118862,118876,118882,118884,118888,118902,118926,118940,118968,118978,118980,118984,118992,119006,119014,119020,119034,119068,119096,119152,119166,119170,119172,119176,119184,119198,119200,119228,119238,119244,119256,119278,119282,119284,119324,119352,119408,119422,119520,119548,119554,119556,119560,119568,119582,119584,119612,119616,119672,119686,119692,119704,119728,119742,119758,119772,119778,119780,119784,119798,119920,119934,120032,120060,120256,120312,120324,120328,120336,120352,120384,120440,120560,120582,120588,120600,120624,120638,120672,120700,120718,120732,120760,120770,120772,120776,120784,120798,120806,120812,120870,120876,120890,120902,120908,120920,120946,120948,120966,120972,120984,121008,121022,121038,121058,121060,121064,121078,121100,121112,121136,121150,121184,121212,121244,121282,121284,121288,121296,121318,121338,121356,121368,121392,121406,121440,121468,121536,121592,121656,121730,121732,121736,121744,121758,121760,121804,121842,121844,121890,121922,121924,121928,121936,121950,121958,121978,121986,121988,121992,122e3,122014,122016,122044,122060,122098,122100,122116,122120,122128,122142,122144,122172,122176,122232,122246,122264,122318,122338,122340,122344,122414,122418,122420,122446,122460,122466,122468,122472,122510,122524,122552,122562,122564,122568,122576,122598,122618,122646,122662,122668,122694,122700,122712,122738,122740,122762,122770,122772,122786,122788,122792,123018,123026,123028,123042,123044,123048,123062,123098,123146,123154,123156,123170,123172,123176,123190,123202,123204,123208,123216,123238,123244,123258,123290,123314,123316,123402,123410,123412,123426,123428,123432,123446,123458,123464,123472,123486,123494,123500,123514,123522,123524,123528,123536,123552,123580,123590,123596,123608,123630,123634,123636,123674,123698,123700,123740,123746,123748,123752,123834,123914,123922,123924,123938,123944,123958,123970,123976,123984,123998,124006,124012,124026,124034,124036,124048,124062,124064,124092,124102,124108,124120,124142,124146,124148,124162,124164,124168,124176,124190,124192,124220,124224,124280,124294,124300,124312,124336,124350,124366,124380,124386,124388,124392,124406,124442,124462,124466,124468,124494,124508,124514,124520,124558,124572,124600,124610,124612,124616,124624,124646,124666,124694,124710,124716,124730,124742,124748,124760,124786,124788,124818,124820,124834,124836,124840,124854,124946,124948,124962,124964,124968,124982,124994,124996,125e3,125008,125022,125030,125036,125050,125058,125060,125064,125072,125086,125088,125116,125126,125132,125144,125166,125170,125172,125186,125188,125192,125200,125216,125244,125248,125304,125318,125324,125336,125360,125374,125390,125404,125410,125412,125416,125430,125444,125448,125456,125472,125504,125560,125680,125702,125708,125720,125744,125758,125792,125820,125838,125852,125880,125890,125892,125896,125904,125918,125926,125932,125978,125998,126002,126004,126030,126044,126050,126052,126056,126094,126108,126136,126146,126148,126152,126160,126182,126202,126222,126236,126264,126320,126334,126338,126340,126344,126352,126366,126368,126412,126450,126452,126486,126502,126508,126522,126534,126540,126552,126574,126578,126580,126598,126604,126616,126640,126654,126670,126684,126690,126692,126696,126738,126754,126756,126760,126774,126786,126788,126792,126800,126814,126822,126828,126842,126894,126898,126900,126934,127126,127142,127148,127162,127178,127186,127188,127254,127270,127276,127290,127302,127308,127320,127342,127346,127348,127370,127378,127380,127394,127396,127400,127450,127510,127526,127532,127546,127558,127576,127598,127602,127604,127622,127628,127640,127664,127678,127694,127708,127714,127716,127720,127734,127754,127762,127764,127778,127784,127810,127812,127816,127824,127838,127846,127866,127898,127918,127922,127924,128022,128038,128044,128058,128070,128076,128088,128110,128114,128116,128134,128140,128152,128176,128190,128206,128220,128226,128228,128232,128246,128262,128268,128280,128304,128318,128352,128380,128398,128412,128440,128450,128452,128456,128464,128478,128486,128492,128506,128522,128530,128532,128546,128548,128552,128566,128578,128580,128584,128592,128606,128614,128634,128642,128644,128648,128656,128670,128672,128700,128716,128754,128756,128794,128814,128818,128820,128846,128860,128866,128868,128872,128886,128918,128934,128940,128954,128978,128980,129178,129198,129202,129204,129238,129258,129306,129326,129330,129332,129358,129372,129378,129380,129384,129398,129430,129446,129452,129466,129482,129490,129492,129562,129582,129586,129588,129614,129628,129634,129636,129640,129654,129678,129692,129720,129730,129732,129736,129744,129758,129766,129772,129814,129830,129836,129850,129862,129868,129880,129902,129906,129908,129930,129938,129940,129954,129956,129960,129974,130010]),Be.CODEWORD_TABLE=Int32Array.from([2627,1819,2622,2621,1813,1812,2729,2724,2723,2779,2774,2773,902,896,908,868,865,861,859,2511,873,871,1780,835,2493,825,2491,842,837,844,1764,1762,811,810,809,2483,807,2482,806,2480,815,814,813,812,2484,817,816,1745,1744,1742,1746,2655,2637,2635,2626,2625,2623,2628,1820,2752,2739,2737,2728,2727,2725,2730,2785,2783,2778,2777,2775,2780,787,781,747,739,736,2413,754,752,1719,692,689,681,2371,678,2369,700,697,694,703,1688,1686,642,638,2343,631,2341,627,2338,651,646,643,2345,654,652,1652,1650,1647,1654,601,599,2322,596,2321,594,2319,2317,611,610,608,606,2324,603,2323,615,614,612,1617,1616,1614,1612,616,1619,1618,2575,2538,2536,905,901,898,909,2509,2507,2504,870,867,864,860,2512,875,872,1781,2490,2489,2487,2485,1748,836,834,832,830,2494,827,2492,843,841,839,845,1765,1763,2701,2676,2674,2653,2648,2656,2634,2633,2631,2629,1821,2638,2636,2770,2763,2761,2750,2745,2753,2736,2735,2733,2731,1848,2740,2738,2786,2784,591,588,576,569,566,2296,1590,537,534,526,2276,522,2274,545,542,539,548,1572,1570,481,2245,466,2242,462,2239,492,485,482,2249,496,494,1534,1531,1528,1538,413,2196,406,2191,2188,425,419,2202,415,2199,432,430,427,1472,1467,1464,433,1476,1474,368,367,2160,365,2159,362,2157,2155,2152,378,377,375,2166,372,2165,369,2162,383,381,379,2168,1419,1418,1416,1414,385,1411,384,1423,1422,1420,1424,2461,802,2441,2439,790,786,783,794,2409,2406,2403,750,742,738,2414,756,753,1720,2367,2365,2362,2359,1663,693,691,684,2373,680,2370,702,699,696,704,1690,1687,2337,2336,2334,2332,1624,2329,1622,640,637,2344,634,2342,630,2340,650,648,645,2346,655,653,1653,1651,1649,1655,2612,2597,2595,2571,2568,2565,2576,2534,2529,2526,1787,2540,2537,907,904,900,910,2503,2502,2500,2498,1768,2495,1767,2510,2508,2506,869,866,863,2513,876,874,1782,2720,2713,2711,2697,2694,2691,2702,2672,2670,2664,1828,2678,2675,2647,2646,2644,2642,1823,2639,1822,2654,2652,2650,2657,2771,1855,2765,2762,1850,1849,2751,2749,2747,2754,353,2148,344,342,336,2142,332,2140,345,1375,1373,306,2130,299,2128,295,2125,319,314,311,2132,1354,1352,1349,1356,262,257,2101,253,2096,2093,274,273,267,2107,263,2104,280,278,275,1316,1311,1308,1320,1318,2052,202,2050,2044,2040,219,2063,212,2060,208,2055,224,221,2066,1260,1258,1252,231,1248,229,1266,1264,1261,1268,155,1998,153,1996,1994,1991,1988,165,164,2007,162,2006,159,2003,2e3,172,171,169,2012,166,2010,1186,1184,1182,1179,175,1176,173,1192,1191,1189,1187,176,1194,1193,2313,2307,2305,592,589,2294,2292,2289,578,572,568,2297,580,1591,2272,2267,2264,1547,538,536,529,2278,525,2275,547,544,541,1574,1571,2237,2235,2229,1493,2225,1489,478,2247,470,2244,465,2241,493,488,484,2250,498,495,1536,1533,1530,1539,2187,2186,2184,2182,1432,2179,1430,2176,1427,414,412,2197,409,2195,405,2193,2190,426,424,421,2203,418,2201,431,429,1473,1471,1469,1466,434,1477,1475,2478,2472,2470,2459,2457,2454,2462,803,2437,2432,2429,1726,2443,2440,792,789,785,2401,2399,2393,1702,2389,1699,2411,2408,2405,745,741,2415,758,755,1721,2358,2357,2355,2353,1661,2350,1660,2347,1657,2368,2366,2364,2361,1666,690,687,2374,683,2372,701,698,705,1691,1689,2619,2617,2610,2608,2605,2613,2593,2588,2585,1803,2599,2596,2563,2561,2555,1797,2551,1795,2573,2570,2567,2577,2525,2524,2522,2520,1786,2517,1785,2514,1783,2535,2533,2531,2528,1788,2541,2539,906,903,911,2721,1844,2715,2712,1838,1836,2699,2696,2693,2703,1827,1826,1824,2673,2671,2669,2666,1829,2679,2677,1858,1857,2772,1854,1853,1851,1856,2766,2764,143,1987,139,1986,135,133,131,1984,128,1983,125,1981,138,137,136,1985,1133,1132,1130,112,110,1974,107,1973,104,1971,1969,122,121,119,117,1977,114,1976,124,1115,1114,1112,1110,1117,1116,84,83,1953,81,1952,78,1950,1948,1945,94,93,91,1959,88,1958,85,1955,99,97,95,1961,1086,1085,1083,1081,1078,100,1090,1089,1087,1091,49,47,1917,44,1915,1913,1910,1907,59,1926,56,1925,53,1922,1919,66,64,1931,61,1929,1042,1040,1038,71,1035,70,1032,68,1048,1047,1045,1043,1050,1049,12,10,1869,1867,1864,1861,21,1880,19,1877,1874,1871,28,1888,25,1886,22,1883,982,980,977,974,32,30,991,989,987,984,34,995,994,992,2151,2150,2147,2146,2144,356,355,354,2149,2139,2138,2136,2134,1359,343,341,338,2143,335,2141,348,347,346,1376,1374,2124,2123,2121,2119,1326,2116,1324,310,308,305,2131,302,2129,298,2127,320,318,316,313,2133,322,321,1355,1353,1351,1357,2092,2091,2089,2087,1276,2084,1274,2081,1271,259,2102,256,2100,252,2098,2095,272,269,2108,266,2106,281,279,277,1317,1315,1313,1310,282,1321,1319,2039,2037,2035,2032,1203,2029,1200,1197,207,2053,205,2051,201,2049,2046,2043,220,218,2064,215,2062,211,2059,228,226,223,2069,1259,1257,1254,232,1251,230,1267,1265,1263,2316,2315,2312,2311,2309,2314,2304,2303,2301,2299,1593,2308,2306,590,2288,2287,2285,2283,1578,2280,1577,2295,2293,2291,579,577,574,571,2298,582,581,1592,2263,2262,2260,2258,1545,2255,1544,2252,1541,2273,2271,2269,2266,1550,535,532,2279,528,2277,546,543,549,1575,1573,2224,2222,2220,1486,2217,1485,2214,1482,1479,2238,2236,2234,2231,1496,2228,1492,480,477,2248,473,2246,469,2243,490,487,2251,497,1537,1535,1532,2477,2476,2474,2479,2469,2468,2466,2464,1730,2473,2471,2453,2452,2450,2448,1729,2445,1728,2460,2458,2456,2463,805,804,2428,2427,2425,2423,1725,2420,1724,2417,1722,2438,2436,2434,2431,1727,2444,2442,793,791,788,795,2388,2386,2384,1697,2381,1696,2378,1694,1692,2402,2400,2398,2395,1703,2392,1701,2412,2410,2407,751,748,744,2416,759,757,1807,2620,2618,1806,1805,2611,2609,2607,2614,1802,1801,1799,2594,2592,2590,2587,1804,2600,2598,1794,1793,1791,1789,2564,2562,2560,2557,1798,2554,1796,2574,2572,2569,2578,1847,1846,2722,1843,1842,1840,1845,2716,2714,1835,1834,1832,1830,1839,1837,2700,2698,2695,2704,1817,1811,1810,897,862,1777,829,826,838,1760,1758,808,2481,1741,1740,1738,1743,2624,1818,2726,2776,782,740,737,1715,686,679,695,1682,1680,639,628,2339,647,644,1645,1643,1640,1648,602,600,597,595,2320,593,2318,609,607,604,1611,1610,1608,1606,613,1615,1613,2328,926,924,892,886,899,857,850,2505,1778,824,823,821,819,2488,818,2486,833,831,828,840,1761,1759,2649,2632,2630,2746,2734,2732,2782,2781,570,567,1587,531,527,523,540,1566,1564,476,467,463,2240,486,483,1524,1521,1518,1529,411,403,2192,399,2189,423,416,1462,1457,1454,428,1468,1465,2210,366,363,2158,360,2156,357,2153,376,373,370,2163,1410,1409,1407,1405,382,1402,380,1417,1415,1412,1421,2175,2174,777,774,771,784,732,725,722,2404,743,1716,676,674,668,2363,665,2360,685,1684,1681,626,624,622,2335,620,2333,617,2330,641,635,649,1646,1644,1642,2566,928,925,2530,2527,894,891,888,2501,2499,2496,858,856,854,851,1779,2692,2668,2665,2645,2643,2640,2651,2768,2759,2757,2744,2743,2741,2748,352,1382,340,337,333,1371,1369,307,300,296,2126,315,312,1347,1342,1350,261,258,250,2097,246,2094,271,268,264,1306,1301,1298,276,1312,1309,2115,203,2048,195,2045,191,2041,213,209,2056,1246,1244,1238,225,1234,222,1256,1253,1249,1262,2080,2079,154,1997,150,1995,147,1992,1989,163,160,2004,156,2001,1175,1174,1172,1170,1167,170,1164,167,1185,1183,1180,1177,174,1190,1188,2025,2024,2022,587,586,564,559,556,2290,573,1588,520,518,512,2268,508,2265,530,1568,1565,461,457,2233,450,2230,446,2226,479,471,489,1526,1523,1520,397,395,2185,392,2183,389,2180,2177,410,2194,402,422,1463,1461,1459,1456,1470,2455,799,2433,2430,779,776,773,2397,2394,2390,734,728,724,746,1717,2356,2354,2351,2348,1658,677,675,673,670,667,688,1685,1683,2606,2589,2586,2559,2556,2552,927,2523,2521,2518,2515,1784,2532,895,893,890,2718,2709,2707,2689,2687,2684,2663,2662,2660,2658,1825,2667,2769,1852,2760,2758,142,141,1139,1138,134,132,129,126,1982,1129,1128,1126,1131,113,111,108,105,1972,101,1970,120,118,115,1109,1108,1106,1104,123,1113,1111,82,79,1951,75,1949,72,1946,92,89,86,1956,1077,1076,1074,1072,98,1069,96,1084,1082,1079,1088,1968,1967,48,45,1916,42,1914,39,1911,1908,60,57,54,1923,50,1920,1031,1030,1028,1026,67,1023,65,1020,62,1041,1039,1036,1033,69,1046,1044,1944,1943,1941,11,9,1868,7,1865,1862,1859,20,1878,16,1875,13,1872,970,968,966,963,29,960,26,23,983,981,978,975,33,971,31,990,988,985,1906,1904,1902,993,351,2145,1383,331,330,328,326,2137,323,2135,339,1372,1370,294,293,291,289,2122,286,2120,283,2117,309,303,317,1348,1346,1344,245,244,242,2090,239,2088,236,2085,2082,260,2099,249,270,1307,1305,1303,1300,1314,189,2038,186,2036,183,2033,2030,2026,206,198,2047,194,216,1247,1245,1243,1240,227,1237,1255,2310,2302,2300,2286,2284,2281,565,563,561,558,575,1589,2261,2259,2256,2253,1542,521,519,517,514,2270,511,533,1569,1567,2223,2221,2218,2215,1483,2211,1480,459,456,453,2232,449,474,491,1527,1525,1522,2475,2467,2465,2451,2449,2446,801,800,2426,2424,2421,2418,1723,2435,780,778,775,2387,2385,2382,2379,1695,2375,1693,2396,735,733,730,727,749,1718,2616,2615,2604,2603,2601,2584,2583,2581,2579,1800,2591,2550,2549,2547,2545,1792,2542,1790,2558,929,2719,1841,2710,2708,1833,1831,2690,2688,2686,1815,1809,1808,1774,1756,1754,1737,1736,1734,1739,1816,1711,1676,1674,633,629,1638,1636,1633,1641,598,1605,1604,1602,1600,605,1609,1607,2327,887,853,1775,822,820,1757,1755,1584,524,1560,1558,468,464,1514,1511,1508,1519,408,404,400,1452,1447,1444,417,1458,1455,2208,364,361,358,2154,1401,1400,1398,1396,374,1393,371,1408,1406,1403,1413,2173,2172,772,726,723,1712,672,669,666,682,1678,1675,625,623,621,618,2331,636,632,1639,1637,1635,920,918,884,880,889,849,848,847,846,2497,855,852,1776,2641,2742,2787,1380,334,1367,1365,301,297,1340,1338,1335,1343,255,251,247,1296,1291,1288,265,1302,1299,2113,204,196,192,2042,1232,1230,1224,214,1220,210,1242,1239,1235,1250,2077,2075,151,148,1993,144,1990,1163,1162,1160,1158,1155,161,1152,157,1173,1171,1168,1165,168,1181,1178,2021,2020,2018,2023,585,560,557,1585,516,509,1562,1559,458,447,2227,472,1516,1513,1510,398,396,393,390,2181,386,2178,407,1453,1451,1449,1446,420,1460,2209,769,764,720,712,2391,729,1713,664,663,661,659,2352,656,2349,671,1679,1677,2553,922,919,2519,2516,885,883,881,2685,2661,2659,2767,2756,2755,140,1137,1136,130,127,1125,1124,1122,1127,109,106,102,1103,1102,1100,1098,116,1107,1105,1980,80,76,73,1947,1068,1067,1065,1063,90,1060,87,1075,1073,1070,1080,1966,1965,46,43,40,1912,36,1909,1019,1018,1016,1014,58,1011,55,1008,51,1029,1027,1024,1021,63,1037,1034,1940,1939,1937,1942,8,1866,4,1863,1,1860,956,954,952,949,946,17,14,969,967,964,961,27,957,24,979,976,972,1901,1900,1898,1896,986,1905,1903,350,349,1381,329,327,324,1368,1366,292,290,287,284,2118,304,1341,1339,1337,1345,243,240,237,2086,233,2083,254,1297,1295,1293,1290,1304,2114,190,187,184,2034,180,2031,177,2027,199,1233,1231,1229,1226,217,1223,1241,2078,2076,584,555,554,552,550,2282,562,1586,507,506,504,502,2257,499,2254,515,1563,1561,445,443,441,2219,438,2216,435,2212,460,454,475,1517,1515,1512,2447,798,797,2422,2419,770,768,766,2383,2380,2376,721,719,717,714,731,1714,2602,2582,2580,2548,2546,2543,923,921,2717,2706,2705,2683,2682,2680,1771,1752,1750,1733,1732,1731,1735,1814,1707,1670,1668,1631,1629,1626,1634,1599,1598,1596,1594,1603,1601,2326,1772,1753,1751,1581,1554,1552,1504,1501,1498,1509,1442,1437,1434,401,1448,1445,2206,1392,1391,1389,1387,1384,359,1399,1397,1394,1404,2171,2170,1708,1672,1669,619,1632,1630,1628,1773,1378,1363,1361,1333,1328,1336,1286,1281,1278,248,1292,1289,2111,1218,1216,1210,197,1206,193,1228,1225,1221,1236,2073,2071,1151,1150,1148,1146,152,1143,149,1140,145,1161,1159,1156,1153,158,1169,1166,2017,2016,2014,2019,1582,510,1556,1553,452,448,1506,1500,394,391,387,1443,1441,1439,1436,1450,2207,765,716,713,1709,662,660,657,1673,1671,916,914,879,878,877,882,1135,1134,1121,1120,1118,1123,1097,1096,1094,1092,103,1101,1099,1979,1059,1058,1056,1054,77,1051,74,1066,1064,1061,1071,1964,1963,1007,1006,1004,1002,999,41,996,37,1017,1015,1012,1009,52,1025,1022,1936,1935,1933,1938,942,940,938,935,932,5,2,955,953,950,947,18,943,15,965,962,958,1895,1894,1892,1890,973,1899,1897,1379,325,1364,1362,288,285,1334,1332,1330,241,238,234,1287,1285,1283,1280,1294,2112,188,185,181,178,2028,1219,1217,1215,1212,200,1209,1227,2074,2072,583,553,551,1583,505,503,500,513,1557,1555,444,442,439,436,2213,455,451,1507,1505,1502,796,763,762,760,767,711,710,708,706,2377,718,715,1710,2544,917,915,2681,1627,1597,1595,2325,1769,1749,1747,1499,1438,1435,2204,1390,1388,1385,1395,2169,2167,1704,1665,1662,1625,1623,1620,1770,1329,1282,1279,2109,1214,1207,1222,2068,2065,1149,1147,1144,1141,146,1157,1154,2013,2011,2008,2015,1579,1549,1546,1495,1487,1433,1431,1428,1425,388,1440,2205,1705,658,1667,1664,1119,1095,1093,1978,1057,1055,1052,1062,1962,1960,1005,1003,1e3,997,38,1013,1010,1932,1930,1927,1934,941,939,936,933,6,930,3,951,948,944,1889,1887,1884,1881,959,1893,1891,35,1377,1360,1358,1327,1325,1322,1331,1277,1275,1272,1269,235,1284,2110,1205,1204,1201,1198,182,1195,179,1213,2070,2067,1580,501,1551,1548,440,437,1497,1494,1490,1503,761,709,707,1706,913,912,2198,1386,2164,2161,1621,1766,2103,1208,2058,2054,1145,1142,2005,2002,1999,2009,1488,1429,1426,2200,1698,1659,1656,1975,1053,1957,1954,1001,998,1924,1921,1918,1928,937,934,931,1879,1876,1873,1870,945,1885,1882,1323,1273,1270,2105,1202,1199,1196,1211,2061,2057,1576,1543,1540,1484,1481,1478,1491,1700]);class O1{constructor(e,r){this.bits=e,this.points=r}getBits(){return this.bits}getPoints(){return this.points}}class Ze{static detectMultiple(e,r,i){let s=e.getBlackMatrix(),a=Ze.detect(i,s);return a.length||(s=s.clone(),s.rotate180(),a=Ze.detect(i,s)),new O1(s,a)}static detect(e,r){const i=new Array;let s=0,a=0,c=!1;for(;s<r.getHeight();){const d=Ze.findVertices(r,s,a);if(d[0]==null&&d[3]==null){if(!c)break;c=!1,a=0;for(const h of i)h[1]!=null&&(s=Math.trunc(Math.max(s,h[1].getY()))),h[3]!=null&&(s=Math.max(s,Math.trunc(h[3].getY())));s+=Ze.ROW_STEP;continue}if(c=!0,i.push(d),!e)break;d[2]!=null?(a=Math.trunc(d[2].getX()),s=Math.trunc(d[2].getY())):(a=Math.trunc(d[4].getX()),s=Math.trunc(d[4].getY()))}return i}static findVertices(e,r,i){const s=e.getHeight(),a=e.getWidth(),c=new Array(8);return Ze.copyToResult(c,Ze.findRowsWithPattern(e,s,a,r,i,Ze.START_PATTERN),Ze.INDEXES_START_PATTERN),c[4]!=null&&(i=Math.trunc(c[4].getX()),r=Math.trunc(c[4].getY())),Ze.copyToResult(c,Ze.findRowsWithPattern(e,s,a,r,i,Ze.STOP_PATTERN),Ze.INDEXES_STOP_PATTERN),c}static copyToResult(e,r,i){for(let s=0;s<i.length;s++)e[i[s]]=r[s]}static findRowsWithPattern(e,r,i,s,a,c){const d=new Array(4);let h=!1;const p=new Int32Array(c.length);for(;s<r;s+=Ze.ROW_STEP){let v=Ze.findGuardPattern(e,a,s,i,!1,c,p);if(v!=null){for(;s>0;){const E=Ze.findGuardPattern(e,a,--s,i,!1,c,p);if(E!=null)v=E;else{s++;break}}d[0]=new Se(v[0],s),d[1]=new Se(v[1],s),h=!0;break}}let w=s+1;if(h){let v=0,E=Int32Array.from([Math.trunc(d[0].getX()),Math.trunc(d[1].getX())]);for(;w<r;w++){const O=Ze.findGuardPattern(e,E[0],w,i,!1,c,p);if(O!=null&&Math.abs(E[0]-O[0])<Ze.MAX_PATTERN_DRIFT&&Math.abs(E[1]-O[1])<Ze.MAX_PATTERN_DRIFT)E=O,v=0;else{if(v>Ze.SKIPPED_ROW_COUNT_MAX)break;v++}}w-=v+1,d[2]=new Se(E[0],w),d[3]=new Se(E[1],w)}return w-s<Ze.BARCODE_MIN_HEIGHT&&U.fill(d,null),d}static findGuardPattern(e,r,i,s,a,c,d){U.fillWithin(d,0,d.length,0);let h=r,p=0;for(;e.get(h,i)&&h>0&&p++<Ze.MAX_PIXEL_DRIFT;)h--;let w=h,v=0,E=c.length;for(let O=a;w<s;w++)if(e.get(w,i)!==O)d[v]++;else{if(v===E-1){if(Ze.patternMatchVariance(d,c,Ze.MAX_INDIVIDUAL_VARIANCE)<Ze.MAX_AVG_VARIANCE)return new Int32Array([h,w]);h+=d[0]+d[1],D.arraycopy(d,2,d,0,v-1),d[v-1]=0,d[v]=0,v--}else v++;d[v]=1,O=!O}return v===E-1&&Ze.patternMatchVariance(d,c,Ze.MAX_INDIVIDUAL_VARIANCE)<Ze.MAX_AVG_VARIANCE?new Int32Array([h,w-1]):null}static patternMatchVariance(e,r,i){let s=e.length,a=0,c=0;for(let p=0;p<s;p++)a+=e[p],c+=r[p];if(a<c)return 1/0;let d=a/c;i*=d;let h=0;for(let p=0;p<s;p++){let w=e[p],v=r[p]*d,E=w>v?w-v:v-w;if(E>i)return 1/0;h+=E}return h/a}}Ze.INDEXES_START_PATTERN=Int32Array.from([0,4,1,5]),Ze.INDEXES_STOP_PATTERN=Int32Array.from([6,2,7,3]),Ze.MAX_AVG_VARIANCE=.42,Ze.MAX_INDIVIDUAL_VARIANCE=.8,Ze.START_PATTERN=Int32Array.from([8,1,1,1,1,1,1,3]),Ze.STOP_PATTERN=Int32Array.from([7,1,1,3,1,1,1,2,1]),Ze.MAX_PIXEL_DRIFT=3,Ze.MAX_PATTERN_DRIFT=5,Ze.SKIPPED_ROW_COUNT_MAX=25,Ze.ROW_STEP=5,Ze.BARCODE_MIN_HEIGHT=10;class Mt{constructor(e,r){if(r.length===0)throw new b;this.field=e;let i=r.length;if(i>1&&r[0]===0){let s=1;for(;s<i&&r[s]===0;)s++;s===i?this.coefficients=new Int32Array([0]):(this.coefficients=new Int32Array(i-s),D.arraycopy(r,s,this.coefficients,0,this.coefficients.length))}else this.coefficients=r}getCoefficients(){return this.coefficients}getDegree(){return this.coefficients.length-1}isZero(){return this.coefficients[0]===0}getCoefficient(e){return this.coefficients[this.coefficients.length-1-e]}evaluateAt(e){if(e===0)return this.getCoefficient(0);if(e===1){let s=0;for(let a of this.coefficients)s=this.field.add(s,a);return s}let r=this.coefficients[0],i=this.coefficients.length;for(let s=1;s<i;s++)r=this.field.add(this.field.multiply(e,r),this.coefficients[s]);return r}add(e){if(!this.field.equals(e.field))throw new b("ModulusPolys do not have same ModulusGF field");if(this.isZero())return e;if(e.isZero())return this;let r=this.coefficients,i=e.coefficients;if(r.length>i.length){let c=r;r=i,i=c}let s=new Int32Array(i.length),a=i.length-r.length;D.arraycopy(i,0,s,0,a);for(let c=a;c<i.length;c++)s[c]=this.field.add(r[c-a],i[c]);return new Mt(this.field,s)}subtract(e){if(!this.field.equals(e.field))throw new b("ModulusPolys do not have same ModulusGF field");return e.isZero()?this:this.add(e.negative())}multiply(e){return e instanceof Mt?this.multiplyOther(e):this.multiplyScalar(e)}multiplyOther(e){if(!this.field.equals(e.field))throw new b("ModulusPolys do not have same ModulusGF field");if(this.isZero()||e.isZero())return new Mt(this.field,new Int32Array([0]));let r=this.coefficients,i=r.length,s=e.coefficients,a=s.length,c=new Int32Array(i+a-1);for(let d=0;d<i;d++){let h=r[d];for(let p=0;p<a;p++)c[d+p]=this.field.add(c[d+p],this.field.multiply(h,s[p]))}return new Mt(this.field,c)}negative(){let e=this.coefficients.length,r=new Int32Array(e);for(let i=0;i<e;i++)r[i]=this.field.subtract(0,this.coefficients[i]);return new Mt(this.field,r)}multiplyScalar(e){if(e===0)return new Mt(this.field,new Int32Array([0]));if(e===1)return this;let r=this.coefficients.length,i=new Int32Array(r);for(let s=0;s<r;s++)i[s]=this.field.multiply(this.coefficients[s],e);return new Mt(this.field,i)}multiplyByMonomial(e,r){if(e<0)throw new b;if(r===0)return new Mt(this.field,new Int32Array([0]));let i=this.coefficients.length,s=new Int32Array(i+e);for(let a=0;a<i;a++)s[a]=this.field.multiply(this.coefficients[a],r);return new Mt(this.field,s)}toString(){let e=new xe;for(let r=this.getDegree();r>=0;r--){let i=this.getCoefficient(r);i!==0&&(i<0?(e.append(" - "),i=-i):e.length()>0&&e.append(" + "),(r===0||i!==1)&&e.append(i),r!==0&&(r===1?e.append("x"):(e.append("x^"),e.append(r))))}return e.toString()}}class N1{add(e,r){return(e+r)%this.modulus}subtract(e,r){return(this.modulus+e-r)%this.modulus}exp(e){return this.expTable[e]}log(e){if(e===0)throw new b;return this.logTable[e]}inverse(e){if(e===0)throw new qt;return this.expTable[this.modulus-this.logTable[e]-1]}multiply(e,r){return e===0||r===0?0:this.expTable[(this.logTable[e]+this.logTable[r])%(this.modulus-1)]}getSize(){return this.modulus}equals(e){return e===this}}class xo extends N1{constructor(e,r){super(),this.modulus=e,this.expTable=new Int32Array(e),this.logTable=new Int32Array(e);let i=1;for(let s=0;s<e;s++)this.expTable[s]=i,i=i*r%e;for(let s=0;s<e-1;s++)this.logTable[this.expTable[s]]=s;this.zero=new Mt(this,new Int32Array([0])),this.one=new Mt(this,new Int32Array([1]))}getZero(){return this.zero}getOne(){return this.one}buildMonomial(e,r){if(e<0)throw new b;if(r===0)return this.zero;let i=new Int32Array(e+1);return i[0]=r,new Mt(this,i)}}xo.PDF417_GF=new xo(Be.NUMBER_OF_CODEWORDS,3);class ks{constructor(){this.field=xo.PDF417_GF}decode(e,r,i){let s=new Mt(this.field,e),a=new Int32Array(r),c=!1;for(let L=r;L>0;L--){let $=s.evaluateAt(this.field.exp(L));a[r-L]=$,$!==0&&(c=!0)}if(!c)return 0;let d=this.field.getOne();if(i!=null)for(const L of i){let $=this.field.exp(e.length-1-L),Z=new Mt(this.field,new Int32Array([this.field.subtract(0,$),1]));d=d.multiply(Z)}let h=new Mt(this.field,a),p=this.runEuclideanAlgorithm(this.field.buildMonomial(r,1),h,r),w=p[0],v=p[1],E=this.findErrorLocations(w),O=this.findErrorMagnitudes(v,w,E);for(let L=0;L<E.length;L++){let $=e.length-1-this.field.log(E[L]);if($<0)throw N.getChecksumInstance();e[$]=this.field.subtract(e[$],O[L])}return E.length}runEuclideanAlgorithm(e,r,i){if(e.getDegree()<r.getDegree()){let E=e;e=r,r=E}let s=e,a=r,c=this.field.getZero(),d=this.field.getOne();for(;a.getDegree()>=Math.round(i/2);){let E=s,O=c;if(s=a,c=d,s.isZero())throw N.getChecksumInstance();a=E;let L=this.field.getZero(),$=s.getCoefficient(s.getDegree()),Z=this.field.inverse($);for(;a.getDegree()>=s.getDegree()&&!a.isZero();){let G=a.getDegree()-s.getDegree(),ae=this.field.multiply(a.getCoefficient(a.getDegree()),Z);L=L.add(this.field.buildMonomial(G,ae)),a=a.subtract(s.multiplyByMonomial(G,ae))}d=L.multiply(c).subtract(O).negative()}let h=d.getCoefficient(0);if(h===0)throw N.getChecksumInstance();let p=this.field.inverse(h),w=d.multiply(p),v=a.multiply(p);return[w,v]}findErrorLocations(e){let r=e.getDegree(),i=new Int32Array(r),s=0;for(let a=1;a<this.field.getSize()&&s<r;a++)e.evaluateAt(a)===0&&(i[s]=this.field.inverse(a),s++);if(s!==r)throw N.getChecksumInstance();return i}findErrorMagnitudes(e,r,i){let s=r.getDegree(),a=new Int32Array(s);for(let p=1;p<=s;p++)a[s-p]=this.field.multiply(p,r.getCoefficient(p));let c=new Mt(this.field,a),d=i.length,h=new Int32Array(d);for(let p=0;p<d;p++){let w=this.field.inverse(i[p]),v=this.field.subtract(0,e.evaluateAt(w)),E=this.field.inverse(c.evaluateAt(w));h[p]=this.field.multiply(v,E)}return h}}class lr{constructor(e,r,i,s,a){e instanceof lr?this.constructor_2(e):this.constructor_1(e,r,i,s,a)}constructor_1(e,r,i,s,a){const c=r==null||i==null,d=s==null||a==null;if(c&&d)throw new F;c?(r=new Se(0,s.getY()),i=new Se(0,a.getY())):d&&(s=new Se(e.getWidth()-1,r.getY()),a=new Se(e.getWidth()-1,i.getY())),this.image=e,this.topLeft=r,this.bottomLeft=i,this.topRight=s,this.bottomRight=a,this.minX=Math.trunc(Math.min(r.getX(),i.getX())),this.maxX=Math.trunc(Math.max(s.getX(),a.getX())),this.minY=Math.trunc(Math.min(r.getY(),s.getY())),this.maxY=Math.trunc(Math.max(i.getY(),a.getY()))}constructor_2(e){this.image=e.image,this.topLeft=e.getTopLeft(),this.bottomLeft=e.getBottomLeft(),this.topRight=e.getTopRight(),this.bottomRight=e.getBottomRight(),this.minX=e.getMinX(),this.maxX=e.getMaxX(),this.minY=e.getMinY(),this.maxY=e.getMaxY()}static merge(e,r){return e==null?r:r==null?e:new lr(e.image,e.topLeft,e.bottomLeft,r.topRight,r.bottomRight)}addMissingRows(e,r,i){let s=this.topLeft,a=this.bottomLeft,c=this.topRight,d=this.bottomRight;if(e>0){let h=i?this.topLeft:this.topRight,p=Math.trunc(h.getY()-e);p<0&&(p=0);let w=new Se(h.getX(),p);i?s=w:c=w}if(r>0){let h=i?this.bottomLeft:this.bottomRight,p=Math.trunc(h.getY()+r);p>=this.image.getHeight()&&(p=this.image.getHeight()-1);let w=new Se(h.getX(),p);i?a=w:d=w}return new lr(this.image,s,a,c,d)}getMinX(){return this.minX}getMaxX(){return this.maxX}getMinY(){return this.minY}getMaxY(){return this.maxY}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}getBottomLeft(){return this.bottomLeft}getBottomRight(){return this.bottomRight}}class k1{constructor(e,r,i,s){this.columnCount=e,this.errorCorrectionLevel=s,this.rowCountUpperPart=r,this.rowCountLowerPart=i,this.rowCount=r+i}getColumnCount(){return this.columnCount}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getRowCount(){return this.rowCount}getRowCountUpperPart(){return this.rowCountUpperPart}getRowCountLowerPart(){return this.rowCountLowerPart}}class Dr{constructor(){this.buffer=""}static form(e,r){let i=-1;function s(c,d,h,p,w,v){if(c==="%%")return"%";if(r[++i]===void 0)return;c=p?parseInt(p.substr(1)):void 0;let E=w?parseInt(w.substr(1)):void 0,O;switch(v){case"s":O=r[i];break;case"c":O=r[i][0];break;case"f":O=parseFloat(r[i]).toFixed(c);break;case"p":O=parseFloat(r[i]).toPrecision(c);break;case"e":O=parseFloat(r[i]).toExponential(c);break;case"x":O=parseInt(r[i]).toString(E||16);break;case"d":O=parseFloat(parseInt(r[i],E||10).toPrecision(c)).toFixed(0);break}O=typeof O=="object"?JSON.stringify(O):(+O).toString(E);let L=parseInt(h),$=h&&h[0]+""=="0"?"0":" ";for(;O.length<L;)O=d!==void 0?O+$:$+O;return O}let a=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return e.replace(a,s)}format(e,...r){this.buffer+=Dr.form(e,r)}toString(){return this.buffer}}class Mr{constructor(e){this.boundingBox=new lr(e),this.codewords=new Array(e.getMaxY()-e.getMinY()+1)}getCodewordNearby(e){let r=this.getCodeword(e);if(r!=null)return r;for(let i=1;i<Mr.MAX_NEARBY_DISTANCE;i++){let s=this.imageRowToCodewordIndex(e)-i;if(s>=0&&(r=this.codewords[s],r!=null)||(s=this.imageRowToCodewordIndex(e)+i,s<this.codewords.length&&(r=this.codewords[s],r!=null)))return r}return null}imageRowToCodewordIndex(e){return e-this.boundingBox.getMinY()}setCodeword(e,r){this.codewords[this.imageRowToCodewordIndex(e)]=r}getCodeword(e){return this.codewords[this.imageRowToCodewordIndex(e)]}getBoundingBox(){return this.boundingBox}getCodewords(){return this.codewords}toString(){const e=new Dr;let r=0;for(const i of this.codewords){if(i==null){e.format("%3d: | %n",r++);continue}e.format("%3d: %3d|%3d%n",r++,i.getRowNumber(),i.getValue())}return e.toString()}}Mr.MAX_NEARBY_DISTANCE=5;class Pr{constructor(){this.values=new Map}setValue(e){e=Math.trunc(e);let r=this.values.get(e);r==null&&(r=0),r++,this.values.set(e,r)}getValue(){let e=-1,r=new Array;for(const[i,s]of this.values.entries()){const a={getKey:()=>i,getValue:()=>s};a.getValue()>e?(e=a.getValue(),r=[],r.push(a.getKey())):a.getValue()===e&&r.push(a.getKey())}return Be.toIntArray(r)}getConfidence(e){return this.values.get(e)}}class Rs extends Mr{constructor(e,r){super(e),this._isLeft=r}setRowNumbers(){for(let e of this.getCodewords())e?.setRowNumberAsRowIndicatorColumn()}adjustCompleteIndicatorColumnRowNumbers(e){let r=this.getCodewords();this.setRowNumbers(),this.removeIncorrectCodewords(r,e);let i=this.getBoundingBox(),s=this._isLeft?i.getTopLeft():i.getTopRight(),a=this._isLeft?i.getBottomLeft():i.getBottomRight(),c=this.imageRowToCodewordIndex(Math.trunc(s.getY())),d=this.imageRowToCodewordIndex(Math.trunc(a.getY())),h=-1,p=1,w=0;for(let v=c;v<d;v++){if(r[v]==null)continue;let E=r[v],O=E.getRowNumber()-h;if(O===0)w++;else if(O===1)p=Math.max(p,w),w=1,h=E.getRowNumber();else if(O<0||E.getRowNumber()>=e.getRowCount()||O>v)r[v]=null;else{let L;p>2?L=(p-2)*O:L=O;let $=L>=v;for(let Z=1;Z<=L&&!$;Z++)$=r[v-Z]!=null;$?r[v]=null:(h=E.getRowNumber(),w=1)}}}getRowHeights(){let e=this.getBarcodeMetadata();if(e==null)return null;this.adjustIncompleteIndicatorColumnRowNumbers(e);let r=new Int32Array(e.getRowCount());for(let i of this.getCodewords())if(i!=null){let s=i.getRowNumber();if(s>=r.length)continue;r[s]++}return r}adjustIncompleteIndicatorColumnRowNumbers(e){let r=this.getBoundingBox(),i=this._isLeft?r.getTopLeft():r.getTopRight(),s=this._isLeft?r.getBottomLeft():r.getBottomRight(),a=this.imageRowToCodewordIndex(Math.trunc(i.getY())),c=this.imageRowToCodewordIndex(Math.trunc(s.getY())),d=this.getCodewords(),h=-1;for(let p=a;p<c;p++){if(d[p]==null)continue;let w=d[p];w.setRowNumberAsRowIndicatorColumn();let v=w.getRowNumber()-h;v===0||(v===1?h=w.getRowNumber():w.getRowNumber()>=e.getRowCount()?d[p]=null:h=w.getRowNumber())}}getBarcodeMetadata(){let e=this.getCodewords(),r=new Pr,i=new Pr,s=new Pr,a=new Pr;for(let d of e){if(d==null)continue;d.setRowNumberAsRowIndicatorColumn();let h=d.getValue()%30,p=d.getRowNumber();switch(this._isLeft||(p+=2),p%3){case 0:i.setValue(h*3+1);break;case 1:a.setValue(h/3),s.setValue(h%3);break;case 2:r.setValue(h+1);break}}if(r.getValue().length===0||i.getValue().length===0||s.getValue().length===0||a.getValue().length===0||r.getValue()[0]<1||i.getValue()[0]+s.getValue()[0]<Be.MIN_ROWS_IN_BARCODE||i.getValue()[0]+s.getValue()[0]>Be.MAX_ROWS_IN_BARCODE)return null;let c=new k1(r.getValue()[0],i.getValue()[0],s.getValue()[0],a.getValue()[0]);return this.removeIncorrectCodewords(e,c),c}removeIncorrectCodewords(e,r){for(let i=0;i<e.length;i++){let s=e[i];if(e[i]==null)continue;let a=s.getValue()%30,c=s.getRowNumber();if(c>r.getRowCount()){e[i]=null;continue}switch(this._isLeft||(c+=2),c%3){case 0:a*3+1!==r.getRowCountUpperPart()&&(e[i]=null);break;case 1:(Math.trunc(a/3)!==r.getErrorCorrectionLevel()||a%3!==r.getRowCountLowerPart())&&(e[i]=null);break;case 2:a+1!==r.getColumnCount()&&(e[i]=null);break}}}isLeft(){return this._isLeft}toString(){return"IsLeft: "+this._isLeft+`
84
- `+super.toString()}}class Br{constructor(e,r){this.ADJUST_ROW_NUMBER_SKIP=2,this.barcodeMetadata=e,this.barcodeColumnCount=e.getColumnCount(),this.boundingBox=r,this.detectionResultColumns=new Array(this.barcodeColumnCount+2)}getDetectionResultColumns(){this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[0]),this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[this.barcodeColumnCount+1]);let e=Be.MAX_CODEWORDS_IN_BARCODE,r;do r=e,e=this.adjustRowNumbersAndGetCount();while(e>0&&e<r);return this.detectionResultColumns}adjustIndicatorColumnRowNumbers(e){e?.adjustCompleteIndicatorColumnRowNumbers(this.barcodeMetadata)}adjustRowNumbersAndGetCount(){let e=this.adjustRowNumbersByRow();if(e===0)return 0;for(let r=1;r<this.barcodeColumnCount+1;r++){let i=this.detectionResultColumns[r].getCodewords();for(let s=0;s<i.length;s++)i[s]!=null&&(i[s].hasValidRowNumber()||this.adjustRowNumbers(r,s,i))}return e}adjustRowNumbersByRow(){return this.adjustRowNumbersFromBothRI(),this.adjustRowNumbersFromLRI()+this.adjustRowNumbersFromRRI()}adjustRowNumbersFromBothRI(){if(this.detectionResultColumns[0]==null||this.detectionResultColumns[this.barcodeColumnCount+1]==null)return;let e=this.detectionResultColumns[0].getCodewords(),r=this.detectionResultColumns[this.barcodeColumnCount+1].getCodewords();for(let i=0;i<e.length;i++)if(e[i]!=null&&r[i]!=null&&e[i].getRowNumber()===r[i].getRowNumber())for(let s=1;s<=this.barcodeColumnCount;s++){let a=this.detectionResultColumns[s].getCodewords()[i];a!=null&&(a.setRowNumber(e[i].getRowNumber()),a.hasValidRowNumber()||(this.detectionResultColumns[s].getCodewords()[i]=null))}}adjustRowNumbersFromRRI(){if(this.detectionResultColumns[this.barcodeColumnCount+1]==null)return 0;let e=0,r=this.detectionResultColumns[this.barcodeColumnCount+1].getCodewords();for(let i=0;i<r.length;i++){if(r[i]==null)continue;let s=r[i].getRowNumber(),a=0;for(let c=this.barcodeColumnCount+1;c>0&&a<this.ADJUST_ROW_NUMBER_SKIP;c--){let d=this.detectionResultColumns[c].getCodewords()[i];d!=null&&(a=Br.adjustRowNumberIfValid(s,a,d),d.hasValidRowNumber()||e++)}}return e}adjustRowNumbersFromLRI(){if(this.detectionResultColumns[0]==null)return 0;let e=0,r=this.detectionResultColumns[0].getCodewords();for(let i=0;i<r.length;i++){if(r[i]==null)continue;let s=r[i].getRowNumber(),a=0;for(let c=1;c<this.barcodeColumnCount+1&&a<this.ADJUST_ROW_NUMBER_SKIP;c++){let d=this.detectionResultColumns[c].getCodewords()[i];d!=null&&(a=Br.adjustRowNumberIfValid(s,a,d),d.hasValidRowNumber()||e++)}}return e}static adjustRowNumberIfValid(e,r,i){return i==null||i.hasValidRowNumber()||(i.isValidRowNumber(e)?(i.setRowNumber(e),r=0):++r),r}adjustRowNumbers(e,r,i){if(!this.detectionResultColumns[e-1])return;let s=i[r],a=this.detectionResultColumns[e-1].getCodewords(),c=a;this.detectionResultColumns[e+1]!=null&&(c=this.detectionResultColumns[e+1].getCodewords());let d=new Array(14);d[2]=a[r],d[3]=c[r],r>0&&(d[0]=i[r-1],d[4]=a[r-1],d[5]=c[r-1]),r>1&&(d[8]=i[r-2],d[10]=a[r-2],d[11]=c[r-2]),r<i.length-1&&(d[1]=i[r+1],d[6]=a[r+1],d[7]=c[r+1]),r<i.length-2&&(d[9]=i[r+2],d[12]=a[r+2],d[13]=c[r+2]);for(let h of d)if(Br.adjustRowNumber(s,h))return}static adjustRowNumber(e,r){return r==null?!1:r.hasValidRowNumber()&&r.getBucket()===e.getBucket()?(e.setRowNumber(r.getRowNumber()),!0):!1}getBarcodeColumnCount(){return this.barcodeColumnCount}getBarcodeRowCount(){return this.barcodeMetadata.getRowCount()}getBarcodeECLevel(){return this.barcodeMetadata.getErrorCorrectionLevel()}setBoundingBox(e){this.boundingBox=e}getBoundingBox(){return this.boundingBox}setDetectionResultColumn(e,r){this.detectionResultColumns[e]=r}getDetectionResultColumn(e){return this.detectionResultColumns[e]}toString(){let e=this.detectionResultColumns[0];e==null&&(e=this.detectionResultColumns[this.barcodeColumnCount+1]);let r=new Dr;for(let i=0;i<e.getCodewords().length;i++){r.format("CW %3d:",i);for(let s=0;s<this.barcodeColumnCount+2;s++){if(this.detectionResultColumns[s]==null){r.format(" | ");continue}let a=this.detectionResultColumns[s].getCodewords()[i];if(a==null){r.format(" | ");continue}r.format(" %3d|%3d",a.getRowNumber(),a.getValue())}r.format("%n")}return r.toString()}}class Lr{constructor(e,r,i,s){this.rowNumber=Lr.BARCODE_ROW_UNKNOWN,this.startX=Math.trunc(e),this.endX=Math.trunc(r),this.bucket=Math.trunc(i),this.value=Math.trunc(s)}hasValidRowNumber(){return this.isValidRowNumber(this.rowNumber)}isValidRowNumber(e){return e!==Lr.BARCODE_ROW_UNKNOWN&&this.bucket===e%3*3}setRowNumberAsRowIndicatorColumn(){this.rowNumber=Math.trunc(Math.trunc(this.value/30)*3+Math.trunc(this.bucket/3))}getWidth(){return this.endX-this.startX}getStartX(){return this.startX}getEndX(){return this.endX}getBucket(){return this.bucket}getValue(){return this.value}getRowNumber(){return this.rowNumber}setRowNumber(e){this.rowNumber=e}toString(){return this.rowNumber+"|"+this.value}}Lr.BARCODE_ROW_UNKNOWN=-1;class en{static initialize(){for(let e=0;e<Be.SYMBOL_TABLE.length;e++){let r=Be.SYMBOL_TABLE[e],i=r&1;for(let s=0;s<Be.BARS_IN_MODULE;s++){let a=0;for(;(r&1)===i;)a+=1,r>>=1;i=r&1,en.RATIOS_TABLE[e]||(en.RATIOS_TABLE[e]=new Array(Be.BARS_IN_MODULE)),en.RATIOS_TABLE[e][Be.BARS_IN_MODULE-s-1]=Math.fround(a/Be.MODULES_IN_CODEWORD)}}this.bSymbolTableReady=!0}static getDecodedValue(e){let r=en.getDecodedCodewordValue(en.sampleBitCounts(e));return r!==-1?r:en.getClosestDecodedValue(e)}static sampleBitCounts(e){let r=ke.sum(e),i=new Int32Array(Be.BARS_IN_MODULE),s=0,a=0;for(let c=0;c<Be.MODULES_IN_CODEWORD;c++){let d=r/(2*Be.MODULES_IN_CODEWORD)+c*r/Be.MODULES_IN_CODEWORD;a+e[s]<=d&&(a+=e[s],s++),i[s]++}return i}static getDecodedCodewordValue(e){let r=en.getBitValue(e);return Be.getCodeword(r)===-1?-1:r}static getBitValue(e){let r=0;for(let i=0;i<e.length;i++)for(let s=0;s<e[i];s++)r=r<<1|(i%2===0?1:0);return Math.trunc(r)}static getClosestDecodedValue(e){let r=ke.sum(e),i=new Array(Be.BARS_IN_MODULE);if(r>1)for(let c=0;c<i.length;c++)i[c]=Math.fround(e[c]/r);let s=cn.MAX_VALUE,a=-1;this.bSymbolTableReady||en.initialize();for(let c=0;c<en.RATIOS_TABLE.length;c++){let d=0,h=en.RATIOS_TABLE[c];for(let p=0;p<Be.BARS_IN_MODULE;p++){let w=Math.fround(h[p]-i[p]);if(d+=Math.fround(w*w),d>=s)break}d<s&&(s=d,a=Be.SYMBOL_TABLE[c])}return a}}en.bSymbolTableReady=!1,en.RATIOS_TABLE=new Array(Be.SYMBOL_TABLE.length).map(_=>new Array(Be.BARS_IN_MODULE));class Ds{constructor(){this.segmentCount=-1,this.fileSize=-1,this.timestamp=-1,this.checksum=-1}getSegmentIndex(){return this.segmentIndex}setSegmentIndex(e){this.segmentIndex=e}getFileId(){return this.fileId}setFileId(e){this.fileId=e}getOptionalData(){return this.optionalData}setOptionalData(e){this.optionalData=e}isLastSegment(){return this.lastSegment}setLastSegment(e){this.lastSegment=e}getSegmentCount(){return this.segmentCount}setSegmentCount(e){this.segmentCount=e}getSender(){return this.sender||null}setSender(e){this.sender=e}getAddressee(){return this.addressee||null}setAddressee(e){this.addressee=e}getFileName(){return this.fileName}setFileName(e){this.fileName=e}getFileSize(){return this.fileSize}setFileSize(e){this.fileSize=e}getChecksum(){return this.checksum}setChecksum(e){this.checksum=e}getTimestamp(){return this.timestamp}setTimestamp(e){this.timestamp=e}}class Ms{static parseLong(e,r=void 0){return parseInt(e,r)}}class Ps extends x{}Ps.kind="NullPointerException";class R1{writeBytes(e){this.writeBytesOffset(e,0,e.length)}writeBytesOffset(e,r,i){if(e==null)throw new Ps;if(r<0||r>e.length||i<0||r+i>e.length||r+i<0)throw new M;if(i===0)return;for(let s=0;s<i;s++)this.write(e[r+s])}flush(){}close(){}}class D1 extends x{}class M1 extends R1{constructor(e=32){if(super(),this.count=0,e<0)throw new b("Negative initial size: "+e);this.buf=new Uint8Array(e)}ensureCapacity(e){e-this.buf.length>0&&this.grow(e)}grow(e){let i=this.buf.length<<1;if(i-e<0&&(i=e),i<0){if(e<0)throw new D1;i=k.MAX_VALUE}this.buf=U.copyOfUint8Array(this.buf,i)}write(e){this.ensureCapacity(this.count+1),this.buf[this.count]=e,this.count+=1}writeBytesOffset(e,r,i){if(r<0||r>e.length||i<0||r+i-e.length>0)throw new M;this.ensureCapacity(this.count+i),D.arraycopy(e,r,this.buf,this.count,i),this.count+=i}writeTo(e){e.writeBytesOffset(this.buf,0,this.count)}reset(){this.count=0}toByteArray(){return U.copyOfUint8Array(this.buf,this.count)}size(){return this.count}toString(e){return e?typeof e=="string"?this.toString_string(e):this.toString_number(e):this.toString_void()}toString_void(){return new String(this.buf).toString()}toString_string(e){return new String(this.buf).toString()}toString_number(e){return new String(this.buf).toString()}close(){}}var nt;(function(_){_[_.ALPHA=0]="ALPHA",_[_.LOWER=1]="LOWER",_[_.MIXED=2]="MIXED",_[_.PUNCT=3]="PUNCT",_[_.ALPHA_SHIFT=4]="ALPHA_SHIFT",_[_.PUNCT_SHIFT=5]="PUNCT_SHIFT"})(nt||(nt={}));function Bs(){if(typeof window<"u")return window.BigInt||null;if(typeof Si<"u")return Si.BigInt||null;if(typeof self<"u")return self.BigInt||null;throw new Error("Can't search globals for BigInt!")}let xi;function qn(_){if(typeof xi>"u"&&(xi=Bs()),xi===null)throw new Error("BigInt is not supported!");return xi(_)}function P1(){let _=[];_[0]=qn(1);let e=qn(900);_[1]=e;for(let r=2;r<16;r++)_[r]=_[r-1]*e;return _}class H{static decode(e,r){let i=new xe(""),s=Y.ISO8859_1;i.enableDecoding(s);let a=1,c=e[a++],d=new Ds;for(;a<e[0];){switch(c){case H.TEXT_COMPACTION_MODE_LATCH:a=H.textCompaction(e,a,i);break;case H.BYTE_COMPACTION_MODE_LATCH:case H.BYTE_COMPACTION_MODE_LATCH_6:a=H.byteCompaction(c,e,s,a,i);break;case H.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:i.append(e[a++]);break;case H.NUMERIC_COMPACTION_MODE_LATCH:a=H.numericCompaction(e,a,i);break;case H.ECI_CHARSET:Y.getCharacterSetECIByValue(e[a++]);break;case H.ECI_GENERAL_PURPOSE:a+=2;break;case H.ECI_USER_DEFINED:a++;break;case H.BEGIN_MACRO_PDF417_CONTROL_BLOCK:a=H.decodeMacroBlock(e,a,d);break;case H.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case H.MACRO_PDF417_TERMINATOR:throw new j;default:a--,a=H.textCompaction(e,a,i);break}if(a<e.length)c=e[a++];else throw j.getFormatInstance()}if(i.length()===0)throw j.getFormatInstance();let h=new Le(null,i.toString(),null,r);return h.setOther(d),h}static decodeMacroBlock(e,r,i){if(r+H.NUMBER_OF_SEQUENCE_CODEWORDS>e[0])throw j.getFormatInstance();let s=new Int32Array(H.NUMBER_OF_SEQUENCE_CODEWORDS);for(let d=0;d<H.NUMBER_OF_SEQUENCE_CODEWORDS;d++,r++)s[d]=e[r];i.setSegmentIndex(k.parseInt(H.decodeBase900toBase10(s,H.NUMBER_OF_SEQUENCE_CODEWORDS)));let a=new xe;r=H.textCompaction(e,r,a),i.setFileId(a.toString());let c=-1;for(e[r]===H.BEGIN_MACRO_PDF417_OPTIONAL_FIELD&&(c=r+1);r<e[0];)switch(e[r]){case H.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:switch(r++,e[r]){case H.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME:let d=new xe;r=H.textCompaction(e,r+1,d),i.setFileName(d.toString());break;case H.MACRO_PDF417_OPTIONAL_FIELD_SENDER:let h=new xe;r=H.textCompaction(e,r+1,h),i.setSender(h.toString());break;case H.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE:let p=new xe;r=H.textCompaction(e,r+1,p),i.setAddressee(p.toString());break;case H.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT:let w=new xe;r=H.numericCompaction(e,r+1,w),i.setSegmentCount(k.parseInt(w.toString()));break;case H.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP:let v=new xe;r=H.numericCompaction(e,r+1,v),i.setTimestamp(Ms.parseLong(v.toString()));break;case H.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM:let E=new xe;r=H.numericCompaction(e,r+1,E),i.setChecksum(k.parseInt(E.toString()));break;case H.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE:let O=new xe;r=H.numericCompaction(e,r+1,O),i.setFileSize(Ms.parseLong(O.toString()));break;default:throw j.getFormatInstance()}break;case H.MACRO_PDF417_TERMINATOR:r++,i.setLastSegment(!0);break;default:throw j.getFormatInstance()}if(c!==-1){let d=r-c;i.isLastSegment()&&d--,i.setOptionalData(U.copyOfRange(e,c,c+d))}return r}static textCompaction(e,r,i){let s=new Int32Array((e[0]-r)*2),a=new Int32Array((e[0]-r)*2),c=0,d=!1;for(;r<e[0]&&!d;){let h=e[r++];if(h<H.TEXT_COMPACTION_MODE_LATCH)s[c]=h/30,s[c+1]=h%30,c+=2;else switch(h){case H.TEXT_COMPACTION_MODE_LATCH:s[c++]=H.TEXT_COMPACTION_MODE_LATCH;break;case H.BYTE_COMPACTION_MODE_LATCH:case H.BYTE_COMPACTION_MODE_LATCH_6:case H.NUMERIC_COMPACTION_MODE_LATCH:case H.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case H.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case H.MACRO_PDF417_TERMINATOR:r--,d=!0;break;case H.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:s[c]=H.MODE_SHIFT_TO_BYTE_COMPACTION_MODE,h=e[r++],a[c]=h,c++;break}}return H.decodeTextCompaction(s,a,c,i),r}static decodeTextCompaction(e,r,i,s){let a=nt.ALPHA,c=nt.ALPHA,d=0;for(;d<i;){let h=e[d],p="";switch(a){case nt.ALPHA:if(h<26)p=String.fromCharCode(65+h);else switch(h){case 26:p=" ";break;case H.LL:a=nt.LOWER;break;case H.ML:a=nt.MIXED;break;case H.PS:c=a,a=nt.PUNCT_SHIFT;break;case H.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:s.append(r[d]);break;case H.TEXT_COMPACTION_MODE_LATCH:a=nt.ALPHA;break}break;case nt.LOWER:if(h<26)p=String.fromCharCode(97+h);else switch(h){case 26:p=" ";break;case H.AS:c=a,a=nt.ALPHA_SHIFT;break;case H.ML:a=nt.MIXED;break;case H.PS:c=a,a=nt.PUNCT_SHIFT;break;case H.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:s.append(r[d]);break;case H.TEXT_COMPACTION_MODE_LATCH:a=nt.ALPHA;break}break;case nt.MIXED:if(h<H.PL)p=H.MIXED_CHARS[h];else switch(h){case H.PL:a=nt.PUNCT;break;case 26:p=" ";break;case H.LL:a=nt.LOWER;break;case H.AL:a=nt.ALPHA;break;case H.PS:c=a,a=nt.PUNCT_SHIFT;break;case H.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:s.append(r[d]);break;case H.TEXT_COMPACTION_MODE_LATCH:a=nt.ALPHA;break}break;case nt.PUNCT:if(h<H.PAL)p=H.PUNCT_CHARS[h];else switch(h){case H.PAL:a=nt.ALPHA;break;case H.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:s.append(r[d]);break;case H.TEXT_COMPACTION_MODE_LATCH:a=nt.ALPHA;break}break;case nt.ALPHA_SHIFT:if(a=c,h<26)p=String.fromCharCode(65+h);else switch(h){case 26:p=" ";break;case H.TEXT_COMPACTION_MODE_LATCH:a=nt.ALPHA;break}break;case nt.PUNCT_SHIFT:if(a=c,h<H.PAL)p=H.PUNCT_CHARS[h];else switch(h){case H.PAL:a=nt.ALPHA;break;case H.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:s.append(r[d]);break;case H.TEXT_COMPACTION_MODE_LATCH:a=nt.ALPHA;break}break}p!==""&&s.append(p),d++}}static byteCompaction(e,r,i,s,a){let c=new M1,d=0,h=0,p=!1;switch(e){case H.BYTE_COMPACTION_MODE_LATCH:let w=new Int32Array(6),v=r[s++];for(;s<r[0]&&!p;)switch(w[d++]=v,h=900*h+v,v=r[s++],v){case H.TEXT_COMPACTION_MODE_LATCH:case H.BYTE_COMPACTION_MODE_LATCH:case H.NUMERIC_COMPACTION_MODE_LATCH:case H.BYTE_COMPACTION_MODE_LATCH_6:case H.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case H.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case H.MACRO_PDF417_TERMINATOR:s--,p=!0;break;default:if(d%5===0&&d>0){for(let E=0;E<6;++E)c.write(Number(qn(h)>>qn(8*(5-E))));h=0,d=0}break}s===r[0]&&v<H.TEXT_COMPACTION_MODE_LATCH&&(w[d++]=v);for(let E=0;E<d;E++)c.write(w[E]);break;case H.BYTE_COMPACTION_MODE_LATCH_6:for(;s<r[0]&&!p;){let E=r[s++];if(E<H.TEXT_COMPACTION_MODE_LATCH)d++,h=900*h+E;else switch(E){case H.TEXT_COMPACTION_MODE_LATCH:case H.BYTE_COMPACTION_MODE_LATCH:case H.NUMERIC_COMPACTION_MODE_LATCH:case H.BYTE_COMPACTION_MODE_LATCH_6:case H.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case H.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case H.MACRO_PDF417_TERMINATOR:s--,p=!0;break}if(d%5===0&&d>0){for(let O=0;O<6;++O)c.write(Number(qn(h)>>qn(8*(5-O))));h=0,d=0}}break}return a.append(Ce.decode(c.toByteArray(),i)),s}static numericCompaction(e,r,i){let s=0,a=!1,c=new Int32Array(H.MAX_NUMERIC_CODEWORDS);for(;r<e[0]&&!a;){let d=e[r++];if(r===e[0]&&(a=!0),d<H.TEXT_COMPACTION_MODE_LATCH)c[s]=d,s++;else switch(d){case H.TEXT_COMPACTION_MODE_LATCH:case H.BYTE_COMPACTION_MODE_LATCH:case H.BYTE_COMPACTION_MODE_LATCH_6:case H.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case H.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case H.MACRO_PDF417_TERMINATOR:r--,a=!0;break}(s%H.MAX_NUMERIC_CODEWORDS===0||d===H.NUMERIC_COMPACTION_MODE_LATCH||a)&&s>0&&(i.append(H.decodeBase900toBase10(c,s)),s=0)}return r}static decodeBase900toBase10(e,r){let i=qn(0);for(let a=0;a<r;a++)i+=H.EXP900[r-a-1]*qn(e[a]);let s=i.toString();if(s.charAt(0)!=="1")throw new j;return s.substring(1)}}H.TEXT_COMPACTION_MODE_LATCH=900,H.BYTE_COMPACTION_MODE_LATCH=901,H.NUMERIC_COMPACTION_MODE_LATCH=902,H.BYTE_COMPACTION_MODE_LATCH_6=924,H.ECI_USER_DEFINED=925,H.ECI_GENERAL_PURPOSE=926,H.ECI_CHARSET=927,H.BEGIN_MACRO_PDF417_CONTROL_BLOCK=928,H.BEGIN_MACRO_PDF417_OPTIONAL_FIELD=923,H.MACRO_PDF417_TERMINATOR=922,H.MODE_SHIFT_TO_BYTE_COMPACTION_MODE=913,H.MAX_NUMERIC_CODEWORDS=15,H.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME=0,H.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT=1,H.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP=2,H.MACRO_PDF417_OPTIONAL_FIELD_SENDER=3,H.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE=4,H.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE=5,H.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM=6,H.PL=25,H.LL=27,H.AS=27,H.ML=28,H.AL=28,H.PS=29,H.PAL=29,H.PUNCT_CHARS=`;<>@[\\]_\`~!\r ,:
85
- -.$/"|*()?{}'`,H.MIXED_CHARS="0123456789&\r ,:#-.$/+%*=^",H.EXP900=Bs()?P1():[],H.NUMBER_OF_SEQUENCE_CODEWORDS=2;class Ve{constructor(){}static decode(e,r,i,s,a,c,d){let h=new lr(e,r,i,s,a),p=null,w=null,v;for(let L=!0;;L=!1){if(r!=null&&(p=Ve.getRowIndicatorColumn(e,h,r,!0,c,d)),s!=null&&(w=Ve.getRowIndicatorColumn(e,h,s,!1,c,d)),v=Ve.merge(p,w),v==null)throw F.getNotFoundInstance();let $=v.getBoundingBox();if(L&&$!=null&&($.getMinY()<h.getMinY()||$.getMaxY()>h.getMaxY()))h=$;else break}v.setBoundingBox(h);let E=v.getBarcodeColumnCount()+1;v.setDetectionResultColumn(0,p),v.setDetectionResultColumn(E,w);let O=p!=null;for(let L=1;L<=E;L++){let $=O?L:E-L;if(v.getDetectionResultColumn($)!==void 0)continue;let Z;$===0||$===E?Z=new Rs(h,$===0):Z=new Mr(h),v.setDetectionResultColumn($,Z);let G=-1,ae=G;for(let ce=h.getMinY();ce<=h.getMaxY();ce++){if(G=Ve.getStartColumn(v,$,ce,O),G<0||G>h.getMaxX()){if(ae===-1)continue;G=ae}let oe=Ve.detectCodeword(e,h.getMinX(),h.getMaxX(),O,G,ce,c,d);oe!=null&&(Z.setCodeword(ce,oe),ae=G,c=Math.min(c,oe.getWidth()),d=Math.max(d,oe.getWidth()))}}return Ve.createDecoderResult(v)}static merge(e,r){if(e==null&&r==null)return null;let i=Ve.getBarcodeMetadata(e,r);if(i==null)return null;let s=lr.merge(Ve.adjustBoundingBox(e),Ve.adjustBoundingBox(r));return new Br(i,s)}static adjustBoundingBox(e){if(e==null)return null;let r=e.getRowHeights();if(r==null)return null;let i=Ve.getMax(r),s=0;for(let d of r)if(s+=i-d,d>0)break;let a=e.getCodewords();for(let d=0;s>0&&a[d]==null;d++)s--;let c=0;for(let d=r.length-1;d>=0&&(c+=i-r[d],!(r[d]>0));d--);for(let d=a.length-1;c>0&&a[d]==null;d--)c--;return e.getBoundingBox().addMissingRows(s,c,e.isLeft())}static getMax(e){let r=-1;for(let i of e)r=Math.max(r,i);return r}static getBarcodeMetadata(e,r){let i;if(e==null||(i=e.getBarcodeMetadata())==null)return r==null?null:r.getBarcodeMetadata();let s;return r==null||(s=r.getBarcodeMetadata())==null?i:i.getColumnCount()!==s.getColumnCount()&&i.getErrorCorrectionLevel()!==s.getErrorCorrectionLevel()&&i.getRowCount()!==s.getRowCount()?null:i}static getRowIndicatorColumn(e,r,i,s,a,c){let d=new Rs(r,s);for(let h=0;h<2;h++){let p=h===0?1:-1,w=Math.trunc(Math.trunc(i.getX()));for(let v=Math.trunc(Math.trunc(i.getY()));v<=r.getMaxY()&&v>=r.getMinY();v+=p){let E=Ve.detectCodeword(e,0,e.getWidth(),s,w,v,a,c);E!=null&&(d.setCodeword(v,E),s?w=E.getStartX():w=E.getEndX())}}return d}static adjustCodewordCount(e,r){let i=r[0][1],s=i.getValue(),a=e.getBarcodeColumnCount()*e.getBarcodeRowCount()-Ve.getNumberOfECCodeWords(e.getBarcodeECLevel());if(s.length===0){if(a<1||a>Be.MAX_CODEWORDS_IN_BARCODE)throw F.getNotFoundInstance();i.setValue(a)}else s[0]!==a&&i.setValue(a)}static createDecoderResult(e){let r=Ve.createBarcodeMatrix(e);Ve.adjustCodewordCount(e,r);let i=new Array,s=new Int32Array(e.getBarcodeRowCount()*e.getBarcodeColumnCount()),a=[],c=new Array;for(let h=0;h<e.getBarcodeRowCount();h++)for(let p=0;p<e.getBarcodeColumnCount();p++){let w=r[h][p+1].getValue(),v=h*e.getBarcodeColumnCount()+p;w.length===0?i.push(v):w.length===1?s[v]=w[0]:(c.push(v),a.push(w))}let d=new Array(a.length);for(let h=0;h<d.length;h++)d[h]=a[h];return Ve.createDecoderResultFromAmbiguousValues(e.getBarcodeECLevel(),s,Be.toIntArray(i),Be.toIntArray(c),d)}static createDecoderResultFromAmbiguousValues(e,r,i,s,a){let c=new Int32Array(s.length),d=100;for(;d-- >0;){for(let h=0;h<c.length;h++)r[s[h]]=a[h][c[h]];try{return Ve.decodeCodewords(r,e,i)}catch(h){if(!(h instanceof N))throw h}if(c.length===0)throw N.getChecksumInstance();for(let h=0;h<c.length;h++)if(c[h]<a[h].length-1){c[h]++;break}else if(c[h]=0,h===c.length-1)throw N.getChecksumInstance()}throw N.getChecksumInstance()}static createBarcodeMatrix(e){let r=Array.from({length:e.getBarcodeRowCount()},()=>new Array(e.getBarcodeColumnCount()+2));for(let s=0;s<r.length;s++)for(let a=0;a<r[s].length;a++)r[s][a]=new Pr;let i=0;for(let s of e.getDetectionResultColumns()){if(s!=null){for(let a of s.getCodewords())if(a!=null){let c=a.getRowNumber();if(c>=0){if(c>=r.length)continue;r[c][i].setValue(a.getValue())}}}i++}return r}static isValidBarcodeColumn(e,r){return r>=0&&r<=e.getBarcodeColumnCount()+1}static getStartColumn(e,r,i,s){let a=s?1:-1,c=null;if(Ve.isValidBarcodeColumn(e,r-a)&&(c=e.getDetectionResultColumn(r-a).getCodeword(i)),c!=null)return s?c.getEndX():c.getStartX();if(c=e.getDetectionResultColumn(r).getCodewordNearby(i),c!=null)return s?c.getStartX():c.getEndX();if(Ve.isValidBarcodeColumn(e,r-a)&&(c=e.getDetectionResultColumn(r-a).getCodewordNearby(i)),c!=null)return s?c.getEndX():c.getStartX();let d=0;for(;Ve.isValidBarcodeColumn(e,r-a);){r-=a;for(let h of e.getDetectionResultColumn(r).getCodewords())if(h!=null)return(s?h.getEndX():h.getStartX())+a*d*(h.getEndX()-h.getStartX());d++}return s?e.getBoundingBox().getMinX():e.getBoundingBox().getMaxX()}static detectCodeword(e,r,i,s,a,c,d,h){a=Ve.adjustCodewordStartColumn(e,r,i,s,a,c);let p=Ve.getModuleBitCount(e,r,i,s,a,c);if(p==null)return null;let w,v=ke.sum(p);if(s)w=a+v;else{for(let L=0;L<p.length/2;L++){let $=p[L];p[L]=p[p.length-1-L],p[p.length-1-L]=$}w=a,a=w-v}if(!Ve.checkCodewordSkew(v,d,h))return null;let E=en.getDecodedValue(p),O=Be.getCodeword(E);return O===-1?null:new Lr(a,w,Ve.getCodewordBucketNumber(E),O)}static getModuleBitCount(e,r,i,s,a,c){let d=a,h=new Int32Array(8),p=0,w=s?1:-1,v=s;for(;(s?d<i:d>=r)&&p<h.length;)e.get(d,c)===v?(h[p]++,d+=w):(p++,v=!v);return p===h.length||d===(s?i:r)&&p===h.length-1?h:null}static getNumberOfECCodeWords(e){return 2<<e}static adjustCodewordStartColumn(e,r,i,s,a,c){let d=a,h=s?-1:1;for(let p=0;p<2;p++){for(;(s?d>=r:d<i)&&s===e.get(d,c);){if(Math.abs(a-d)>Ve.CODEWORD_SKEW_SIZE)return a;d+=h}h=-h,s=!s}return d}static checkCodewordSkew(e,r,i){return r-Ve.CODEWORD_SKEW_SIZE<=e&&e<=i+Ve.CODEWORD_SKEW_SIZE}static decodeCodewords(e,r,i){if(e.length===0)throw j.getFormatInstance();let s=1<<r+1,a=Ve.correctErrors(e,i,s);Ve.verifyCodewordCount(e,s);let c=H.decode(e,""+r);return c.setErrorsCorrected(a),c.setErasures(i.length),c}static correctErrors(e,r,i){if(r!=null&&r.length>i/2+Ve.MAX_ERRORS||i<0||i>Ve.MAX_EC_CODEWORDS)throw N.getChecksumInstance();return Ve.errorCorrection.decode(e,i,r)}static verifyCodewordCount(e,r){if(e.length<4)throw j.getFormatInstance();let i=e[0];if(i>e.length)throw j.getFormatInstance();if(i===0)if(r<e.length)e[0]=e.length-r;else throw j.getFormatInstance()}static getBitCountForCodeword(e){let r=new Int32Array(8),i=0,s=r.length-1;for(;!((e&1)!==i&&(i=e&1,s--,s<0));)r[s]++,e>>=1;return r}static getCodewordBucketNumber(e){return e instanceof Int32Array?this.getCodewordBucketNumber_Int32Array(e):this.getCodewordBucketNumber_number(e)}static getCodewordBucketNumber_number(e){return Ve.getCodewordBucketNumber(Ve.getBitCountForCodeword(e))}static getCodewordBucketNumber_Int32Array(e){return(e[0]-e[2]+e[4]-e[6]+9)%9}static toString(e){let r=new Dr;for(let i=0;i<e.length;i++){r.format("Row %2d: ",i);for(let s=0;s<e[i].length;s++){let a=e[i][s];a.getValue().length===0?r.format(" ",null):r.format("%4d(%2d)",a.getValue()[0],a.getConfidence(a.getValue()[0]))}r.format("%n")}return r.toString()}}Ve.CODEWORD_SKEW_SIZE=2,Ve.MAX_ERRORS=3,Ve.MAX_EC_CODEWORDS=512,Ve.errorCorrection=new ks;class Pt{decode(e,r=null){let i=Pt.decode(e,r,!1);if(i==null||i.length===0||i[0]==null)throw F.getNotFoundInstance();return i[0]}decodeMultiple(e,r=null){try{return Pt.decode(e,r,!0)}catch(i){throw i instanceof j||i instanceof N?F.getNotFoundInstance():i}}static decode(e,r,i){const s=new Array,a=Ze.detectMultiple(e,r,i);for(const c of a.getPoints()){const d=Ve.decode(a.getBits(),c[4],c[5],c[6],c[7],Pt.getMinCodewordWidth(c),Pt.getMaxCodewordWidth(c)),h=new Pe(d.getText(),d.getRawBytes(),void 0,c,S.PDF_417);h.putMetadata(se.ERROR_CORRECTION_LEVEL,d.getECLevel());const p=d.getOther();p!=null&&h.putMetadata(se.PDF417_EXTRA_METADATA,p),s.push(h)}return s.map(c=>c)}static getMaxWidth(e,r){return e==null||r==null?0:Math.trunc(Math.abs(e.getX()-r.getX()))}static getMinWidth(e,r){return e==null||r==null?k.MAX_VALUE:Math.trunc(Math.abs(e.getX()-r.getX()))}static getMaxCodewordWidth(e){return Math.floor(Math.max(Math.max(Pt.getMaxWidth(e[0],e[4]),Pt.getMaxWidth(e[6],e[2])*Be.MODULES_IN_CODEWORD/Be.MODULES_IN_STOP_PATTERN),Math.max(Pt.getMaxWidth(e[1],e[5]),Pt.getMaxWidth(e[7],e[3])*Be.MODULES_IN_CODEWORD/Be.MODULES_IN_STOP_PATTERN)))}static getMinCodewordWidth(e){return Math.floor(Math.min(Math.min(Pt.getMinWidth(e[0],e[4]),Pt.getMinWidth(e[6],e[2])*Be.MODULES_IN_CODEWORD/Be.MODULES_IN_STOP_PATTERN),Math.min(Pt.getMinWidth(e[1],e[5]),Pt.getMinWidth(e[7],e[3])*Be.MODULES_IN_CODEWORD/Be.MODULES_IN_STOP_PATTERN)))}reset(){}}class wi extends x{}wi.kind="ReaderException";class Ls{constructor(e,r){this.verbose=e===!0,r&&this.setHints(r)}decode(e,r){return r&&this.setHints(r),this.decodeInternal(e)}decodeWithState(e){return(this.readers===null||this.readers===void 0)&&this.setHints(null),this.decodeInternal(e)}setHints(e){this.hints=e;const r=!l(e)&&e.get(Q.TRY_HARDER)===!0,i=l(e)?null:e.get(Q.POSSIBLE_FORMATS),s=new Array;if(!l(i)){const a=i.some(c=>c===S.UPC_A||c===S.UPC_E||c===S.EAN_13||c===S.EAN_8||c===S.CODABAR||c===S.CODE_39||c===S.CODE_93||c===S.CODE_128||c===S.ITF||c===S.RSS_14||c===S.RSS_EXPANDED);a&&!r&&s.push(new wr(e,this.verbose)),i.includes(S.QR_CODE)&&s.push(new Yn),i.includes(S.DATA_MATRIX)&&s.push(new Xn),i.includes(S.AZTEC)&&s.push(new fi),i.includes(S.PDF_417)&&s.push(new Pt),a&&r&&s.push(new wr(e,this.verbose))}s.length===0&&(r||s.push(new wr(e,this.verbose)),s.push(new Yn),s.push(new Xn),s.push(new fi),s.push(new Pt),r&&s.push(new wr(e,this.verbose))),this.readers=s}reset(){if(this.readers!==null)for(const e of this.readers)e.reset()}decodeInternal(e){if(this.readers===null)throw new wi("No readers where selected, nothing can be read.");for(const r of this.readers)try{return r.decode(e,this.hints)}catch(i){if(i instanceof wi)continue}throw new F("No MultiFormat Readers were able to detect the code.")}}class B1 extends Fe{constructor(e=null,r=500){const i=new Ls;i.setHints(e),super(i,r)}decodeBitmap(e){return this.reader.decodeWithState(e)}}class L1 extends Fe{constructor(e=500){super(new Pt,e)}}class F1 extends Fe{constructor(e=500){super(new Yn,e)}}var wo;(function(_){_[_.ERROR_CORRECTION=0]="ERROR_CORRECTION",_[_.CHARACTER_SET=1]="CHARACTER_SET",_[_.DATA_MATRIX_SHAPE=2]="DATA_MATRIX_SHAPE",_[_.MIN_SIZE=3]="MIN_SIZE",_[_.MAX_SIZE=4]="MAX_SIZE",_[_.MARGIN=5]="MARGIN",_[_.PDF417_COMPACT=6]="PDF417_COMPACT",_[_.PDF417_COMPACTION=7]="PDF417_COMPACTION",_[_.PDF417_DIMENSIONS=8]="PDF417_DIMENSIONS",_[_.AZTEC_LAYERS=9]="AZTEC_LAYERS",_[_.QR_VERSION=10]="QR_VERSION"})(wo||(wo={}));var Tt=wo;class yo{constructor(e){this.field=e,this.cachedGenerators=[],this.cachedGenerators.push(new Xe(e,Int32Array.from([1])))}buildGenerator(e){const r=this.cachedGenerators;if(e>=r.length){let i=r[r.length-1];const s=this.field;for(let a=r.length;a<=e;a++){const c=i.multiply(new Xe(s,Int32Array.from([1,s.exp(a-1+s.getGeneratorBase())])));r.push(c),i=c}}return r[e]}encode(e,r){if(r===0)throw new b("No error correction bytes");const i=e.length-r;if(i<=0)throw new b("No data bytes provided");const s=this.buildGenerator(r),a=new Int32Array(i);D.arraycopy(e,0,a,0,i);let c=new Xe(this.field,a);c=c.multiplyByMonomial(r,1);const h=c.divide(s)[1].getCoefficients(),p=r-h.length;for(let w=0;w<p;w++)e[i+w]=0;D.arraycopy(h,0,e,i+p,h.length)}}class _t{constructor(){}static applyMaskPenaltyRule1(e){return _t.applyMaskPenaltyRule1Internal(e,!0)+_t.applyMaskPenaltyRule1Internal(e,!1)}static applyMaskPenaltyRule2(e){let r=0;const i=e.getArray(),s=e.getWidth(),a=e.getHeight();for(let c=0;c<a-1;c++){const d=i[c];for(let h=0;h<s-1;h++){const p=d[h];p===d[h+1]&&p===i[c+1][h]&&p===i[c+1][h+1]&&r++}}return _t.N2*r}static applyMaskPenaltyRule3(e){let r=0;const i=e.getArray(),s=e.getWidth(),a=e.getHeight();for(let c=0;c<a;c++)for(let d=0;d<s;d++){const h=i[c];d+6<s&&h[d]===1&&h[d+1]===0&&h[d+2]===1&&h[d+3]===1&&h[d+4]===1&&h[d+5]===0&&h[d+6]===1&&(_t.isWhiteHorizontal(h,d-4,d)||_t.isWhiteHorizontal(h,d+7,d+11))&&r++,c+6<a&&i[c][d]===1&&i[c+1][d]===0&&i[c+2][d]===1&&i[c+3][d]===1&&i[c+4][d]===1&&i[c+5][d]===0&&i[c+6][d]===1&&(_t.isWhiteVertical(i,d,c-4,c)||_t.isWhiteVertical(i,d,c+7,c+11))&&r++}return r*_t.N3}static isWhiteHorizontal(e,r,i){r=Math.max(r,0),i=Math.min(i,e.length);for(let s=r;s<i;s++)if(e[s]===1)return!1;return!0}static isWhiteVertical(e,r,i,s){i=Math.max(i,0),s=Math.min(s,e.length);for(let a=i;a<s;a++)if(e[a][r]===1)return!1;return!0}static applyMaskPenaltyRule4(e){let r=0;const i=e.getArray(),s=e.getWidth(),a=e.getHeight();for(let h=0;h<a;h++){const p=i[h];for(let w=0;w<s;w++)p[w]===1&&r++}const c=e.getHeight()*e.getWidth();return Math.floor(Math.abs(r*2-c)*10/c)*_t.N4}static getDataMaskBit(e,r,i){let s,a;switch(e){case 0:s=i+r&1;break;case 1:s=i&1;break;case 2:s=r%3;break;case 3:s=(i+r)%3;break;case 4:s=Math.floor(i/2)+Math.floor(r/3)&1;break;case 5:a=i*r,s=(a&1)+a%3;break;case 6:a=i*r,s=(a&1)+a%3&1;break;case 7:a=i*r,s=a%3+(i+r&1)&1;break;default:throw new b("Invalid mask pattern: "+e)}return s===0}static applyMaskPenaltyRule1Internal(e,r){let i=0;const s=r?e.getHeight():e.getWidth(),a=r?e.getWidth():e.getHeight(),c=e.getArray();for(let d=0;d<s;d++){let h=0,p=-1;for(let w=0;w<a;w++){const v=r?c[d][w]:c[w][d];v===p?h++:(h>=5&&(i+=_t.N1+(h-5)),h=1,p=v)}h>=5&&(i+=_t.N1+(h-5))}return i}}_t.N1=3,_t.N2=3,_t.N3=40,_t.N4=10;class yi{constructor(e,r){this.width=e,this.height=r;const i=new Array(r);for(let s=0;s!==r;s++)i[s]=new Uint8Array(e);this.bytes=i}getHeight(){return this.height}getWidth(){return this.width}get(e,r){return this.bytes[r][e]}getArray(){return this.bytes}setNumber(e,r,i){this.bytes[r][e]=i}setBoolean(e,r,i){this.bytes[r][e]=i?1:0}clear(e){for(const r of this.bytes)U.fill(r,e)}equals(e){if(!(e instanceof yi))return!1;const r=e;if(this.width!==r.width||this.height!==r.height)return!1;for(let i=0,s=this.height;i<s;++i){const a=this.bytes[i],c=r.bytes[i];for(let d=0,h=this.width;d<h;++d)if(a[d]!==c[d])return!1}return!0}toString(){const e=new xe;for(let r=0,i=this.height;r<i;++r){const s=this.bytes[r];for(let a=0,c=this.width;a<c;++a)switch(s[a]){case 0:e.append(" 0");break;case 1:e.append(" 1");break;default:e.append(" ");break}e.append(`
86
- `)}return e.toString()}}class cr{constructor(){this.maskPattern=-1}getMode(){return this.mode}getECLevel(){return this.ecLevel}getVersion(){return this.version}getMaskPattern(){return this.maskPattern}getMatrix(){return this.matrix}toString(){const e=new xe;return e.append(`<<
78
+ ${Ee}`:Ee;f.systemPrompt=_e}else f.systemPrompt=o},te=async(ee,he,Ee)=>{if(he&&he.length>0){const T=he.filter(mt=>mt.type==="mention");if(await pe(T))return!1;k.value=Ce(he);const we=le(T);L(we,T)}const _e=O();if(_e&&_e.title==="新会话"&&M(_e.id,k.value.slice(0,15)),Ee&&Ee.length>0){const T=[{type:"text",text:k.value},...Ee.map(ce=>({type:"image",image:ce}))];z({role:"user",content:T}),Y()}else J(k.value);return!0},K=()=>{be();const ee=[];f.agent.messages=ee,P();const he=O();he.aiSdkMessages=ee},ne=ee=>{be(),D(ee.id);const he=O();f.agent.messages=he.aiSdkMessages,x.value=!1,ye()},fe=(ee,he)=>{he.title=ee},xe=(ee,he)=>{if(ee.id==="delete"){if(V.currentId===he.id){dt("不允许删除当前会话");return}R(he.id)}},ye=()=>{_.nextTick(()=>{const ee=document.querySelector("div.tr-bubble-list");ee&&ee.scrollTo({top:ee.scrollHeight,behavior:"smooth"})})};return _.watch(()=>Z.value[Z.value.length-1]?.content,ye),_.onMounted(()=>{de.value?.focus()}),_.onUnmounted(()=>{f.agent.closeAll()}),{agent:f.agent,customAgentProvider:f,client:g,showHistory:x,aiAvatar:y,userAvatar:m,welcomeIcon:E,messageManager:C,addMessage:z,send:Y,conversationState:V,messages:Z,messageState:U,inputMessage:k,sendMessage:J,abortRequest:be,roles:W,senderRef:de,handleSendMessage:te,createConversation:P,handleHistorySelect:ne,handleCreateConversation:K,handleHistoryUpdateTitle:fe,handleHistoryDelete:xe}},V3=t=>{try{const r=JSON.parse(t),o=[];if(!r.mcpServers||typeof r.mcpServers!="object")throw new Error("JSON 格式错误:缺少 mcpServers 字段");for(const[l,u]of Object.entries(r.mcpServers)){const f=Z3(u);f&&o.push({name:l,config:f})}return o}catch(r){throw new Error(`JSON 解析失败: ${r instanceof Error?r.message:"未知错误"}`)}},Z3=t=>{if(!t||typeof t!="object"||!t.url)return null;const{type:r,url:o,sessionId:l}=t;return r==="extension"?l?{type:"extension",url:o,sessionId:l,useAISdkClient:!0}:null:r==="streamableHttp"||r==="sse"?{type:r,url:o,useAISdkClient:!0}:{type:"streamableHttp",url:o,useAISdkClient:!0}},j3=(t,r,o)=>{const l=async(f,g,x,y,m)=>{if(await t.insertMcpServer(f,g)){const C=t.mcpTools[f];if(C){const O={id:`plugin-${f.replace("mcp-server-","")}`,name:x,icon:m||o,description:y||(typeof g=="object"&&"url"in g?g.url:""),enabled:!0,expanded:!0,tools:Object.keys(C).map(D=>({id:D,name:D,description:C[D].description,enabled:!0})),originMcpConfig:_.markRaw(g)};return r.value.push(O),!0}else return await t.removeMcpServer(f),!1}else return!1};return{handleCustomAdd:async(f,g)=>{r1("添加工具中...");try{if(f==="code"){if(typeof g!="string"){dt("添加工具失败:code 类型需要 JSON 字符串格式");return}const V=V3(g);if(V.length===0){dt("添加工具失败:JSON 配置格式不正确或未找到有效的服务器配置");return}let U=0,k=0;for(const{name:J,config:be}of V){const Z=`mcp-server-${J}`;await l(Z,be,J)?U++:k++}await t.closeAll(),k===0?dt(`成功添加 ${U} 个工具`):U>0?dt(`成功添加 ${U} 个工具,${k} 个失败`):dt("添加工具失败:所有服务器都无法连接");return}if(typeof g=="string"){dt("添加工具失败:数据格式不正确");return}const{description:x,headers:y,name:m,thumbnail:E,type:C,url:P}=g;if(!m||!P||!C){dt("添加工具失败:缺少必要参数(名称、URL或类型)");return}const D=`mcp-server-${`custom-${m}-${Date.now()}`}`;await l(D,{type:C,url:P,useAISdkClient:!0},m,x,E)?(await t.closeAll(),dt("添加工具完成")):dt("重复添加工具或无法获取工具列表")}catch(x){console.error("handleCustomAdd error:",x),dt(`添加工具失败:${x instanceof Error?x.message:"未知错误"}`)}}}};function H3(t,r,o){const l=_.ref([]),u=_.ref([]),f=_.ref(!1),g=Z=>Z==="mcp-server-localhost",x=(Z,z)=>{z?t.ignoreToolnames=t.ignoreToolnames.filter(Y=>Y!==Z):t.ignoreToolnames.includes(Z)||t.ignoreToolnames.push(Z)},y=(Z,z)=>{r.value||(r.value={});const Y={...r.value};Z===null?Object.keys(Y).forEach(W=>{Y[W]=z}):Y[Z]=z,r.value=Y},m=Z=>{const z=u.value.find(Y=>Y.id===Z);z&&(z.addState="idle")},E=Z=>{const z=t.mcpTools[Z];if(!z)return[];const Y=g(Z),W=r.value||{};return Object.keys(z).map(de=>{const me=Y?!!W[de]:!0;return x(de,me),{id:de,name:de,description:z[de].description,enabled:me}})},C=async Z=>{const z=Z.pluginId;if(!await t.insertMcpServer(z,Z.mcpServer))return!1;if(!t.mcpTools[z])return await t.removeMcpServer(z),!1;const de=E(z);if(de.length===0)return await t.removeMcpServer(z),!1;const me=l.value.find(Ce=>Ce.id===Z.pluginId);if(me)return me.tools=de,me.originMcpConfig=_.markRaw(Z.mcpServer),!0;const pe={id:Z.pluginId,name:Z.name,icon:Z.icon||o,description:Z.description,enabled:!0,expanded:!1,tools:de,originMcpConfig:_.markRaw(Z.mcpServer)};return l.value.push(pe),!0},P=async(Z,z)=>{let Y,W;if("type"in z&&z.type==="local")Y="本地工具",W="本地工具列表";else{const de=new URL(z.url);Y=de.origin,W=de.searchParams.get("sessionId")||("sessionId"in z?z.sessionId:"")||""}await C({pluginId:Z,name:Y,description:W,mcpServer:z})},O=(Z,z)=>{const Y=g(Z.id);Z.tools.forEach(W=>{W.enabled=z,x(W.id,z),Y&&y(W.id,z)})},D=(Z,z,Y)=>{const W=g(Z.id);Z.tools.forEach(de=>{de.id===z&&(de.enabled=Y)}),x(z,Y),W&&y(z,Y)},R=async Z=>{const z=l.value.find(W=>W.id===Z.id);if(!z)return;l.value=l.value.filter(W=>W.id!==z.id),m(z.id);const Y=Z.id;await t.removeMcpServer(Y)},M=async Z=>{Z.addState="loading";const z={type:Z.type,url:Z.url,useAISdkClient:!0},Y=await C({pluginId:Z.id,name:Z.name,description:Z.description||"",icon:Z.icon,mcpServer:z});Z.addState=Y?"added":"idle"},V=async(Z,z)=>{const Y={type:"streamableHttp",url:`${z}mcp?sessionId=${Z}`},W=new URL(`${z}mcp?sessionId=${Z}`);return await C({pluginId:`plugin-${Z}`,name:W.origin,description:Z,mcpServer:Y})},U=async Z=>{const z=Z,Y=l.value.find(W=>W.id===z);return await t.removeMcpServer(Z),Y?(l.value=l.value.filter(W=>W.id!==z),m(z),Y):null},k=()=>{l.value.forEach(Z=>{const z=Z.id,Y=t.mcpClients[z],W=t.mcpTools[z];Y===null&&(Z.name="❌"+Z.name.replace("❌","")),W===null?Z.tools.forEach(de=>de.enabled=!1):W&&(Z.tools=Object.keys(W).map(de=>({id:de,name:de,description:W[de].description,enabled:!t.ignoreToolnames.includes(de)})))})};return{installedPlugins:l,marketPlugins:u,pluginVisible:f,loadMcpServerToPlugin:P,togglePlugin:O,toggleTool:D,deletePlugin:R,addPluginFromMarket:M,addPluginFromScan:V,handleClientDisconnected:U,syncInstalledPluginsTools:k,searchPlugin:(Z,z)=>Z.trim()===""||z.name.toLowerCase().includes(Z.toLowerCase()),initPluginSystem:Z=>{t.onUpdatedTools=k,t.onClientDisconnected=async z=>{const Y=await U(z);Y&&Z&&Z(Y.name)}}}}var Ie;(function(t){t[t.QR_CODE=0]="QR_CODE",t[t.AZTEC=1]="AZTEC",t[t.CODABAR=2]="CODABAR",t[t.CODE_39=3]="CODE_39",t[t.CODE_93=4]="CODE_93",t[t.CODE_128=5]="CODE_128",t[t.DATA_MATRIX=6]="DATA_MATRIX",t[t.MAXICODE=7]="MAXICODE",t[t.ITF=8]="ITF",t[t.EAN_13=9]="EAN_13",t[t.EAN_8=10]="EAN_8",t[t.PDF_417=11]="PDF_417",t[t.RSS_14=12]="RSS_14",t[t.RSS_EXPANDED=13]="RSS_EXPANDED",t[t.UPC_A=14]="UPC_A",t[t.UPC_E=15]="UPC_E",t[t.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(Ie||(Ie={}));var pl=new Map([[Ie.QR_CODE,"QR_CODE"],[Ie.AZTEC,"AZTEC"],[Ie.CODABAR,"CODABAR"],[Ie.CODE_39,"CODE_39"],[Ie.CODE_93,"CODE_93"],[Ie.CODE_128,"CODE_128"],[Ie.DATA_MATRIX,"DATA_MATRIX"],[Ie.MAXICODE,"MAXICODE"],[Ie.ITF,"ITF"],[Ie.EAN_13,"EAN_13"],[Ie.EAN_8,"EAN_8"],[Ie.PDF_417,"PDF_417"],[Ie.RSS_14,"RSS_14"],[Ie.RSS_EXPANDED,"RSS_EXPANDED"],[Ie.UPC_A,"UPC_A"],[Ie.UPC_E,"UPC_E"],[Ie.UPC_EAN_EXTENSION,"UPC_EAN_EXTENSION"]]),gl;(function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.URL=1]="URL"})(gl||(gl={}));function W3(t){return Object.values(Ie).includes(t)}var ei;(function(t){t[t.SCAN_TYPE_CAMERA=0]="SCAN_TYPE_CAMERA",t[t.SCAN_TYPE_FILE=1]="SCAN_TYPE_FILE"})(ei||(ei={}));var G3=(function(){function t(){}return t.GITHUB_PROJECT_URL="https://github.com/mebjas/html5-qrcode",t.SCAN_DEFAULT_FPS=2,t.DEFAULT_DISABLE_FLIP=!1,t.DEFAULT_REMEMBER_LAST_CAMERA_USED=!0,t.DEFAULT_SUPPORTED_SCAN_TYPE=[ei.SCAN_TYPE_CAMERA,ei.SCAN_TYPE_FILE],t})(),o1=(function(){function t(r,o){this.format=r,this.formatName=o}return t.prototype.toString=function(){return this.formatName},t.create=function(r){if(!pl.has(r))throw"".concat(r," not in html5QrcodeSupportedFormatsTextMap");return new t(r,pl.get(r))},t})(),ml=(function(){function t(){}return t.createFromText=function(r){var o={text:r};return{decodedText:r,result:o}},t.createFromQrcodeResult=function(r){return{decodedText:r.text,result:r}},t})(),Go;(function(t){t[t.UNKWOWN_ERROR=0]="UNKWOWN_ERROR",t[t.IMPLEMENTATION_ERROR=1]="IMPLEMENTATION_ERROR",t[t.NO_CODE_FOUND_ERROR=2]="NO_CODE_FOUND_ERROR"})(Go||(Go={}));var X3=(function(){function t(){}return t.createFrom=function(r){return{errorMessage:r,type:Go.UNKWOWN_ERROR}},t})(),q3=(function(){function t(r){this.verbose=r}return t.prototype.log=function(r){this.verbose&&console.log(r)},t.prototype.warn=function(r){this.verbose&&console.warn(r)},t.prototype.logError=function(r,o){(this.verbose||o===!0)&&console.error(r)},t.prototype.logErrors=function(r){if(r.length===0)throw"Logger#logError called without arguments";this.verbose&&console.error(r)},t})();function Pn(t){return typeof t>"u"||t===null}var br=(function(){function t(){}return t.codeParseError=function(r){return"QR code parse error, error = ".concat(r)},t.errorGettingUserMedia=function(r){return"Error getting userMedia, error = ".concat(r)},t.onlyDeviceSupportedError=function(){return"The device doesn't support navigator.mediaDevices , only supported cameraIdOrConfig in this case is deviceId parameter (string)."},t.cameraStreamingNotSupported=function(){return"Camera streaming not supported by the browser."},t.unableToQuerySupportedDevices=function(){return"Unable to query supported devices, unknown error."},t.insecureContextCameraQueryError=function(){return"Camera access is only supported in secure context like https or localhost."},t.scannerPaused=function(){return"Scanner paused"},t})(),s1=(function(){function t(){}return t.isMediaStreamConstraintsValid=function(r,o){if(typeof r!="object"){var l=typeof r;return o.logError("videoConstraints should be of type object, the "+"object passed is of type ".concat(l,"."),!0),!1}for(var u=["autoGainControl","channelCount","echoCancellation","latency","noiseSuppression","sampleRate","sampleSize","volume"],f=new Set(u),g=Object.keys(r),x=0,y=g;x<y.length;x++){var m=y[x];if(f.has(m))return o.logError("".concat(m," is not supported videoConstaints."),!0),!1}return!0},t})(),Vr={exports:{}},Y3=Vr.exports,xl;function K3(){return xl||(xl=1,(function(t,r){(function(o,l){l(r)})(Y3,(function(o){function l(v){return v==null}var u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(v,e){v.__proto__=e}||function(v,e){for(var n in e)e.hasOwnProperty(n)&&(v[n]=e[n])};function f(v,e){u(v,e);function n(){this.constructor=v}v.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function g(v,e){var n=Object.setPrototypeOf;n?n(v,e):v.__proto__=e}function x(v,e){e===void 0&&(e=v.constructor);var n=Error.captureStackTrace;n&&n(v,e)}var y=(function(v){f(e,v);function e(n){var i=this.constructor,s=v.call(this,n)||this;return Object.defineProperty(s,"name",{value:i.name,enumerable:!1}),g(s,i.prototype),x(s),s}return e})(Error);class m extends y{constructor(e=void 0){super(e),this.message=e}getKind(){return this.constructor.kind}}m.kind="Exception";class E extends m{}E.kind="ArgumentException";class C extends m{}C.kind="IllegalArgumentException";class P{constructor(e){if(this.binarizer=e,e===null)throw new C("Binarizer must be non-null.")}getWidth(){return this.binarizer.getWidth()}getHeight(){return this.binarizer.getHeight()}getBlackRow(e,n){return this.binarizer.getBlackRow(e,n)}getBlackMatrix(){return(this.matrix===null||this.matrix===void 0)&&(this.matrix=this.binarizer.getBlackMatrix()),this.matrix}isCropSupported(){return this.binarizer.getLuminanceSource().isCropSupported()}crop(e,n,i,s){const a=this.binarizer.getLuminanceSource().crop(e,n,i,s);return new P(this.binarizer.createBinarizer(a))}isRotateSupported(){return this.binarizer.getLuminanceSource().isRotateSupported()}rotateCounterClockwise(){const e=this.binarizer.getLuminanceSource().rotateCounterClockwise();return new P(this.binarizer.createBinarizer(e))}rotateCounterClockwise45(){const e=this.binarizer.getLuminanceSource().rotateCounterClockwise45();return new P(this.binarizer.createBinarizer(e))}toString(){try{return this.getBlackMatrix().toString()}catch{return""}}}class O extends m{static getChecksumInstance(){return new O}}O.kind="ChecksumException";class D{constructor(e){this.source=e}getLuminanceSource(){return this.source}getWidth(){return this.source.getWidth()}getHeight(){return this.source.getHeight()}}class R{static arraycopy(e,n,i,s,a){for(;a--;)i[s++]=e[n++]}static currentTimeMillis(){return Date.now()}}class M extends m{}M.kind="IndexOutOfBoundsException";class V extends M{constructor(e=void 0,n=void 0){super(n),this.index=e,this.message=n}}V.kind="ArrayIndexOutOfBoundsException";class U{static fill(e,n){for(let i=0,s=e.length;i<s;i++)e[i]=n}static fillWithin(e,n,i,s){U.rangeCheck(e.length,n,i);for(let a=n;a<i;a++)e[a]=s}static rangeCheck(e,n,i){if(n>i)throw new C("fromIndex("+n+") > toIndex("+i+")");if(n<0)throw new V(n);if(i>e)throw new V(i)}static asList(...e){return e}static create(e,n,i){return Array.from({length:e}).map(a=>Array.from({length:n}).fill(i))}static createInt32Array(e,n,i){return Array.from({length:e}).map(a=>Int32Array.from({length:n}).fill(i))}static equals(e,n){if(!e||!n||!e.length||!n.length||e.length!==n.length)return!1;for(let i=0,s=e.length;i<s;i++)if(e[i]!==n[i])return!1;return!0}static hashCode(e){if(e===null)return 0;let n=1;for(const i of e)n=31*n+i;return n}static fillUint8Array(e,n){for(let i=0;i!==e.length;i++)e[i]=n}static copyOf(e,n){return e.slice(0,n)}static copyOfUint8Array(e,n){if(e.length<=n){const i=new Uint8Array(n);return i.set(e),i}return e.slice(0,n)}static copyOfRange(e,n,i){const s=i-n,a=new Int32Array(s);return R.arraycopy(e,n,a,0,s),a}static binarySearch(e,n,i){i===void 0&&(i=U.numberComparator);let s=0,a=e.length-1;for(;s<=a;){const c=a+s>>1,d=i(n,e[c]);if(d>0)s=c+1;else if(d<0)a=c-1;else return c}return-s-1}static numberComparator(e,n){return e-n}}class k{static numberOfTrailingZeros(e){let n;if(e===0)return 32;let i=31;return n=e<<16,n!==0&&(i-=16,e=n),n=e<<8,n!==0&&(i-=8,e=n),n=e<<4,n!==0&&(i-=4,e=n),n=e<<2,n!==0&&(i-=2,e=n),i-(e<<1>>>31)}static numberOfLeadingZeros(e){if(e===0)return 32;let n=1;return e>>>16||(n+=16,e<<=16),e>>>24||(n+=8,e<<=8),e>>>28||(n+=4,e<<=4),e>>>30||(n+=2,e<<=2),n-=e>>>31,n}static toHexString(e){return e.toString(16)}static toBinaryString(e){return String(parseInt(String(e),2))}static bitCount(e){return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),e=e+(e>>>4)&252645135,e=e+(e>>>8),e=e+(e>>>16),e&63}static truncDivision(e,n){return Math.trunc(e/n)}static parseInt(e,n=void 0){return parseInt(e,n)}}k.MIN_VALUE_32_BITS=-2147483648,k.MAX_VALUE=Number.MAX_SAFE_INTEGER;class J{constructor(e,n){e===void 0?(this.size=0,this.bits=new Int32Array(1)):(this.size=e,n==null?this.bits=J.makeArray(e):this.bits=n)}getSize(){return this.size}getSizeInBytes(){return Math.floor((this.size+7)/8)}ensureCapacity(e){if(e>this.bits.length*32){const n=J.makeArray(e);R.arraycopy(this.bits,0,n,0,this.bits.length),this.bits=n}}get(e){return(this.bits[Math.floor(e/32)]&1<<(e&31))!==0}set(e){this.bits[Math.floor(e/32)]|=1<<(e&31)}flip(e){this.bits[Math.floor(e/32)]^=1<<(e&31)}getNextSet(e){const n=this.size;if(e>=n)return n;const i=this.bits;let s=Math.floor(e/32),a=i[s];a&=~((1<<(e&31))-1);const c=i.length;for(;a===0;){if(++s===c)return n;a=i[s]}const d=s*32+k.numberOfTrailingZeros(a);return d>n?n:d}getNextUnset(e){const n=this.size;if(e>=n)return n;const i=this.bits;let s=Math.floor(e/32),a=~i[s];a&=~((1<<(e&31))-1);const c=i.length;for(;a===0;){if(++s===c)return n;a=~i[s]}const d=s*32+k.numberOfTrailingZeros(a);return d>n?n:d}setBulk(e,n){this.bits[Math.floor(e/32)]=n}setRange(e,n){if(n<e||e<0||n>this.size)throw new C;if(n===e)return;n--;const i=Math.floor(e/32),s=Math.floor(n/32),a=this.bits;for(let c=i;c<=s;c++){const d=c>i?0:e&31,p=(2<<(c<s?31:n&31))-(1<<d);a[c]|=p}}clear(){const e=this.bits.length,n=this.bits;for(let i=0;i<e;i++)n[i]=0}isRange(e,n,i){if(n<e||e<0||n>this.size)throw new C;if(n===e)return!0;n--;const s=Math.floor(e/32),a=Math.floor(n/32),c=this.bits;for(let d=s;d<=a;d++){const h=d>s?0:e&31,w=(2<<(d<a?31:n&31))-(1<<h)&4294967295;if((c[d]&w)!==(i?w:0))return!1}return!0}appendBit(e){this.ensureCapacity(this.size+1),e&&(this.bits[Math.floor(this.size/32)]|=1<<(this.size&31)),this.size++}appendBits(e,n){if(n<0||n>32)throw new C("Num bits must be between 0 and 32");this.ensureCapacity(this.size+n);for(let i=n;i>0;i--)this.appendBit((e>>i-1&1)===1)}appendBitArray(e){const n=e.size;this.ensureCapacity(this.size+n);for(let i=0;i<n;i++)this.appendBit(e.get(i))}xor(e){if(this.size!==e.size)throw new C("Sizes don't match");const n=this.bits;for(let i=0,s=n.length;i<s;i++)n[i]^=e.bits[i]}toBytes(e,n,i,s){for(let a=0;a<s;a++){let c=0;for(let d=0;d<8;d++)this.get(e)&&(c|=1<<7-d),e++;n[i+a]=c}}getBitArray(){return this.bits}reverse(){const e=new Int32Array(this.bits.length),n=Math.floor((this.size-1)/32),i=n+1,s=this.bits;for(let a=0;a<i;a++){let c=s[a];c=c>>1&1431655765|(c&1431655765)<<1,c=c>>2&858993459|(c&858993459)<<2,c=c>>4&252645135|(c&252645135)<<4,c=c>>8&16711935|(c&16711935)<<8,c=c>>16&65535|(c&65535)<<16,e[n-a]=c}if(this.size!==i*32){const a=i*32-this.size;let c=e[0]>>>a;for(let d=1;d<i;d++){const h=e[d];c|=h<<32-a,e[d-1]=c,c=h>>>a}e[i-1]=c}this.bits=e}static makeArray(e){return new Int32Array(Math.floor((e+31)/32))}equals(e){if(!(e instanceof J))return!1;const n=e;return this.size===n.size&&U.equals(this.bits,n.bits)}hashCode(){return 31*this.size+U.hashCode(this.bits)}toString(){let e="";for(let n=0,i=this.size;n<i;n++)(n&7)===0&&(e+=" "),e+=this.get(n)?"X":".";return e}clone(){return new J(this.size,this.bits.slice())}}var be;(function(v){v[v.OTHER=0]="OTHER",v[v.PURE_BARCODE=1]="PURE_BARCODE",v[v.POSSIBLE_FORMATS=2]="POSSIBLE_FORMATS",v[v.TRY_HARDER=3]="TRY_HARDER",v[v.CHARACTER_SET=4]="CHARACTER_SET",v[v.ALLOWED_LENGTHS=5]="ALLOWED_LENGTHS",v[v.ASSUME_CODE_39_CHECK_DIGIT=6]="ASSUME_CODE_39_CHECK_DIGIT",v[v.ASSUME_GS1=7]="ASSUME_GS1",v[v.RETURN_CODABAR_START_END=8]="RETURN_CODABAR_START_END",v[v.NEED_RESULT_POINT_CALLBACK=9]="NEED_RESULT_POINT_CALLBACK",v[v.ALLOWED_EAN_EXTENSIONS=10]="ALLOWED_EAN_EXTENSIONS"})(be||(be={}));var Z=be;class z extends m{static getFormatInstance(){return new z}}z.kind="FormatException";var Y;(function(v){v[v.Cp437=0]="Cp437",v[v.ISO8859_1=1]="ISO8859_1",v[v.ISO8859_2=2]="ISO8859_2",v[v.ISO8859_3=3]="ISO8859_3",v[v.ISO8859_4=4]="ISO8859_4",v[v.ISO8859_5=5]="ISO8859_5",v[v.ISO8859_6=6]="ISO8859_6",v[v.ISO8859_7=7]="ISO8859_7",v[v.ISO8859_8=8]="ISO8859_8",v[v.ISO8859_9=9]="ISO8859_9",v[v.ISO8859_10=10]="ISO8859_10",v[v.ISO8859_11=11]="ISO8859_11",v[v.ISO8859_13=12]="ISO8859_13",v[v.ISO8859_14=13]="ISO8859_14",v[v.ISO8859_15=14]="ISO8859_15",v[v.ISO8859_16=15]="ISO8859_16",v[v.SJIS=16]="SJIS",v[v.Cp1250=17]="Cp1250",v[v.Cp1251=18]="Cp1251",v[v.Cp1252=19]="Cp1252",v[v.Cp1256=20]="Cp1256",v[v.UnicodeBigUnmarked=21]="UnicodeBigUnmarked",v[v.UTF8=22]="UTF8",v[v.ASCII=23]="ASCII",v[v.Big5=24]="Big5",v[v.GB18030=25]="GB18030",v[v.EUC_KR=26]="EUC_KR"})(Y||(Y={}));class W{constructor(e,n,i,...s){this.valueIdentifier=e,this.name=i,typeof n=="number"?this.values=Int32Array.from([n]):this.values=n,this.otherEncodingNames=s,W.VALUE_IDENTIFIER_TO_ECI.set(e,this),W.NAME_TO_ECI.set(i,this);const a=this.values;for(let c=0,d=a.length;c!==d;c++){const h=a[c];W.VALUES_TO_ECI.set(h,this)}for(const c of s)W.NAME_TO_ECI.set(c,this)}getValueIdentifier(){return this.valueIdentifier}getName(){return this.name}getValue(){return this.values[0]}static getCharacterSetECIByValue(e){if(e<0||e>=900)throw new z("incorect value");const n=W.VALUES_TO_ECI.get(e);if(n===void 0)throw new z("incorect value");return n}static getCharacterSetECIByName(e){const n=W.NAME_TO_ECI.get(e);if(n===void 0)throw new z("incorect value");return n}equals(e){if(!(e instanceof W))return!1;const n=e;return this.getName()===n.getName()}}W.VALUE_IDENTIFIER_TO_ECI=new Map,W.VALUES_TO_ECI=new Map,W.NAME_TO_ECI=new Map,W.Cp437=new W(Y.Cp437,Int32Array.from([0,2]),"Cp437"),W.ISO8859_1=new W(Y.ISO8859_1,Int32Array.from([1,3]),"ISO-8859-1","ISO88591","ISO8859_1"),W.ISO8859_2=new W(Y.ISO8859_2,4,"ISO-8859-2","ISO88592","ISO8859_2"),W.ISO8859_3=new W(Y.ISO8859_3,5,"ISO-8859-3","ISO88593","ISO8859_3"),W.ISO8859_4=new W(Y.ISO8859_4,6,"ISO-8859-4","ISO88594","ISO8859_4"),W.ISO8859_5=new W(Y.ISO8859_5,7,"ISO-8859-5","ISO88595","ISO8859_5"),W.ISO8859_6=new W(Y.ISO8859_6,8,"ISO-8859-6","ISO88596","ISO8859_6"),W.ISO8859_7=new W(Y.ISO8859_7,9,"ISO-8859-7","ISO88597","ISO8859_7"),W.ISO8859_8=new W(Y.ISO8859_8,10,"ISO-8859-8","ISO88598","ISO8859_8"),W.ISO8859_9=new W(Y.ISO8859_9,11,"ISO-8859-9","ISO88599","ISO8859_9"),W.ISO8859_10=new W(Y.ISO8859_10,12,"ISO-8859-10","ISO885910","ISO8859_10"),W.ISO8859_11=new W(Y.ISO8859_11,13,"ISO-8859-11","ISO885911","ISO8859_11"),W.ISO8859_13=new W(Y.ISO8859_13,15,"ISO-8859-13","ISO885913","ISO8859_13"),W.ISO8859_14=new W(Y.ISO8859_14,16,"ISO-8859-14","ISO885914","ISO8859_14"),W.ISO8859_15=new W(Y.ISO8859_15,17,"ISO-8859-15","ISO885915","ISO8859_15"),W.ISO8859_16=new W(Y.ISO8859_16,18,"ISO-8859-16","ISO885916","ISO8859_16"),W.SJIS=new W(Y.SJIS,20,"SJIS","Shift_JIS"),W.Cp1250=new W(Y.Cp1250,21,"Cp1250","windows-1250"),W.Cp1251=new W(Y.Cp1251,22,"Cp1251","windows-1251"),W.Cp1252=new W(Y.Cp1252,23,"Cp1252","windows-1252"),W.Cp1256=new W(Y.Cp1256,24,"Cp1256","windows-1256"),W.UnicodeBigUnmarked=new W(Y.UnicodeBigUnmarked,25,"UnicodeBigUnmarked","UTF-16BE","UnicodeBig"),W.UTF8=new W(Y.UTF8,26,"UTF8","UTF-8"),W.ASCII=new W(Y.ASCII,Int32Array.from([27,170]),"ASCII","US-ASCII"),W.Big5=new W(Y.Big5,28,"Big5"),W.GB18030=new W(Y.GB18030,29,"GB18030","GB2312","EUC_CN","GBK"),W.EUC_KR=new W(Y.EUC_KR,30,"EUC_KR","EUC-KR");class de extends m{}de.kind="UnsupportedOperationException";class me{static decode(e,n){const i=this.encodingName(n);return this.customDecoder?this.customDecoder(e,i):typeof TextDecoder>"u"||this.shouldDecodeOnFallback(i)?this.decodeFallback(e,i):new TextDecoder(i).decode(e)}static shouldDecodeOnFallback(e){return!me.isBrowser()&&e==="ISO-8859-1"}static encode(e,n){const i=this.encodingName(n);return this.customEncoder?this.customEncoder(e,i):typeof TextEncoder>"u"?this.encodeFallback(e):new TextEncoder().encode(e)}static isBrowser(){return typeof window<"u"&&{}.toString.call(window)==="[object Window]"}static encodingName(e){return typeof e=="string"?e:e.getName()}static encodingCharacterSet(e){return e instanceof W?e:W.getCharacterSetECIByName(e)}static decodeFallback(e,n){const i=this.encodingCharacterSet(n);if(me.isDecodeFallbackSupported(i)){let s="";for(let a=0,c=e.length;a<c;a++){let d=e[a].toString(16);d.length<2&&(d="0"+d),s+="%"+d}return decodeURIComponent(s)}if(i.equals(W.UnicodeBigUnmarked))return String.fromCharCode.apply(null,new Uint16Array(e.buffer));throw new de(`Encoding ${this.encodingName(n)} not supported by fallback.`)}static isDecodeFallbackSupported(e){return e.equals(W.UTF8)||e.equals(W.ISO8859_1)||e.equals(W.ASCII)}static encodeFallback(e){const i=btoa(unescape(encodeURIComponent(e))).split(""),s=[];for(let a=0;a<i.length;a++)s.push(i[a].charCodeAt(0));return new Uint8Array(s)}}class pe{static castAsNonUtf8Char(e,n=null){const i=n?n.getName():this.ISO88591;return me.decode(new Uint8Array([e]),i)}static guessEncoding(e,n){if(n!=null&&n.get(Z.CHARACTER_SET)!==void 0)return n.get(Z.CHARACTER_SET).toString();const i=e.length;let s=!0,a=!0,c=!0,d=0,h=0,p=0,w=0,b=0,A=0,N=0,F=0,$=0,j=0,q=0;const se=e.length>3&&e[0]===239&&e[1]===187&&e[2]===191;for(let ae=0;ae<i&&(s||a||c);ae++){const oe=e[ae]&255;c&&(d>0?(oe&128)===0?c=!1:d--:(oe&128)!==0&&((oe&64)===0?c=!1:(d++,(oe&32)===0?h++:(d++,(oe&16)===0?p++:(d++,(oe&8)===0?w++:c=!1))))),s&&(oe>127&&oe<160?s=!1:oe>159&&(oe<192||oe===215||oe===247)&&q++),a&&(b>0?oe<64||oe===127||oe>252?a=!1:b--:oe===128||oe===160||oe>239?a=!1:oe>160&&oe<224?(A++,F=0,N++,N>$&&($=N)):oe>127?(b++,N=0,F++,F>j&&(j=F)):(N=0,F=0))}return c&&d>0&&(c=!1),a&&b>0&&(a=!1),c&&(se||h+p+w>0)?pe.UTF8:a&&(pe.ASSUME_SHIFT_JIS||$>=3||j>=3)?pe.SHIFT_JIS:s&&a?$===2&&A===2||q*10>=i?pe.SHIFT_JIS:pe.ISO88591:s?pe.ISO88591:a?pe.SHIFT_JIS:c?pe.UTF8:pe.PLATFORM_DEFAULT_ENCODING}static format(e,...n){let i=-1;function s(c,d,h,p,w,b){if(c==="%%")return"%";if(n[++i]===void 0)return;c=p?parseInt(p.substr(1)):void 0;let A=w?parseInt(w.substr(1)):void 0,N;switch(b){case"s":N=n[i];break;case"c":N=n[i][0];break;case"f":N=parseFloat(n[i]).toFixed(c);break;case"p":N=parseFloat(n[i]).toPrecision(c);break;case"e":N=parseFloat(n[i]).toExponential(c);break;case"x":N=parseInt(n[i]).toString(A||16);break;case"d":N=parseFloat(parseInt(n[i],A||10).toPrecision(c)).toFixed(0);break}N=typeof N=="object"?JSON.stringify(N):(+N).toString(A);let F=parseInt(h),$=h&&h[0]+""=="0"?"0":" ";for(;N.length<F;)N=d!==void 0?N+$:$+N;return N}let a=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return e.replace(a,s)}static getBytes(e,n){return me.encode(e,n)}static getCharCode(e,n=0){return e.charCodeAt(n)}static getCharAt(e){return String.fromCharCode(e)}}pe.SHIFT_JIS=W.SJIS.getName(),pe.GB2312="GB2312",pe.ISO88591=W.ISO8859_1.getName(),pe.EUC_JP="EUC_JP",pe.UTF8=W.UTF8.getName(),pe.PLATFORM_DEFAULT_ENCODING=pe.UTF8,pe.ASSUME_SHIFT_JIS=!1;class Ce{constructor(e=""){this.value=e}enableDecoding(e){return this.encoding=e,this}append(e){return typeof e=="string"?this.value+=e.toString():this.encoding?this.value+=pe.castAsNonUtf8Char(e,this.encoding):this.value+=String.fromCharCode(e),this}appendChars(e,n,i){for(let s=n;n<n+i;s++)this.append(e[s]);return this}length(){return this.value.length}charAt(e){return this.value.charAt(e)}deleteCharAt(e){this.value=this.value.substr(0,e)+this.value.substring(e+1)}setCharAt(e,n){this.value=this.value.substr(0,e)+n+this.value.substr(e+1)}substring(e,n){return this.value.substring(e,n)}setLengthToZero(){this.value=""}toString(){return this.value}insert(e,n){this.value=this.value.substr(0,e)+n+this.value.substr(e+n.length)}}class le{constructor(e,n,i,s){if(this.width=e,this.height=n,this.rowSize=i,this.bits=s,n==null&&(n=e),this.height=n,e<1||n<1)throw new C("Both dimensions must be greater than 0");i==null&&(i=Math.floor((e+31)/32)),this.rowSize=i,s==null&&(this.bits=new Int32Array(this.rowSize*this.height))}static parseFromBooleanArray(e){const n=e.length,i=e[0].length,s=new le(i,n);for(let a=0;a<n;a++){const c=e[a];for(let d=0;d<i;d++)c[d]&&s.set(d,a)}return s}static parseFromString(e,n,i){if(e===null)throw new C("stringRepresentation cannot be null");const s=new Array(e.length);let a=0,c=0,d=-1,h=0,p=0;for(;p<e.length;)if(e.charAt(p)===`
79
+ `||e.charAt(p)==="\r"){if(a>c){if(d===-1)d=a-c;else if(a-c!==d)throw new C("row lengths do not match");c=a,h++}p++}else if(e.substring(p,p+n.length)===n)p+=n.length,s[a]=!0,a++;else if(e.substring(p,p+i.length)===i)p+=i.length,s[a]=!1,a++;else throw new C("illegal character encountered: "+e.substring(p));if(a>c){if(d===-1)d=a-c;else if(a-c!==d)throw new C("row lengths do not match");h++}const w=new le(d,h);for(let b=0;b<a;b++)s[b]&&w.set(Math.floor(b%d),Math.floor(b/d));return w}get(e,n){const i=n*this.rowSize+Math.floor(e/32);return(this.bits[i]>>>(e&31)&1)!==0}set(e,n){const i=n*this.rowSize+Math.floor(e/32);this.bits[i]|=1<<(e&31)&4294967295}unset(e,n){const i=n*this.rowSize+Math.floor(e/32);this.bits[i]&=~(1<<(e&31)&4294967295)}flip(e,n){const i=n*this.rowSize+Math.floor(e/32);this.bits[i]^=1<<(e&31)&4294967295}xor(e){if(this.width!==e.getWidth()||this.height!==e.getHeight()||this.rowSize!==e.getRowSize())throw new C("input matrix dimensions do not match");const n=new J(Math.floor(this.width/32)+1),i=this.rowSize,s=this.bits;for(let a=0,c=this.height;a<c;a++){const d=a*i,h=e.getRow(a,n).getBitArray();for(let p=0;p<i;p++)s[d+p]^=h[p]}}clear(){const e=this.bits,n=e.length;for(let i=0;i<n;i++)e[i]=0}setRegion(e,n,i,s){if(n<0||e<0)throw new C("Left and top must be nonnegative");if(s<1||i<1)throw new C("Height and width must be at least 1");const a=e+i,c=n+s;if(c>this.height||a>this.width)throw new C("The region must fit inside the matrix");const d=this.rowSize,h=this.bits;for(let p=n;p<c;p++){const w=p*d;for(let b=e;b<a;b++)h[w+Math.floor(b/32)]|=1<<(b&31)&4294967295}}getRow(e,n){n==null||n.getSize()<this.width?n=new J(this.width):n.clear();const i=this.rowSize,s=this.bits,a=e*i;for(let c=0;c<i;c++)n.setBulk(c*32,s[a+c]);return n}setRow(e,n){R.arraycopy(n.getBitArray(),0,this.bits,e*this.rowSize,this.rowSize)}rotate180(){const e=this.getWidth(),n=this.getHeight();let i=new J(e),s=new J(e);for(let a=0,c=Math.floor((n+1)/2);a<c;a++)i=this.getRow(a,i),s=this.getRow(n-1-a,s),i.reverse(),s.reverse(),this.setRow(a,s),this.setRow(n-1-a,i)}getEnclosingRectangle(){const e=this.width,n=this.height,i=this.rowSize,s=this.bits;let a=e,c=n,d=-1,h=-1;for(let p=0;p<n;p++)for(let w=0;w<i;w++){const b=s[p*i+w];if(b!==0){if(p<c&&(c=p),p>h&&(h=p),w*32<a){let A=0;for(;(b<<31-A&4294967295)===0;)A++;w*32+A<a&&(a=w*32+A)}if(w*32+31>d){let A=31;for(;!(b>>>A);)A--;w*32+A>d&&(d=w*32+A)}}}return d<a||h<c?null:Int32Array.from([a,c,d-a+1,h-c+1])}getTopLeftOnBit(){const e=this.rowSize,n=this.bits;let i=0;for(;i<n.length&&n[i]===0;)i++;if(i===n.length)return null;const s=i/e;let a=i%e*32;const c=n[i];let d=0;for(;(c<<31-d&4294967295)===0;)d++;return a+=d,Int32Array.from([a,s])}getBottomRightOnBit(){const e=this.rowSize,n=this.bits;let i=n.length-1;for(;i>=0&&n[i]===0;)i--;if(i<0)return null;const s=Math.floor(i/e);let a=Math.floor(i%e)*32;const c=n[i];let d=31;for(;!(c>>>d);)d--;return a+=d,Int32Array.from([a,s])}getWidth(){return this.width}getHeight(){return this.height}getRowSize(){return this.rowSize}equals(e){if(!(e instanceof le))return!1;const n=e;return this.width===n.width&&this.height===n.height&&this.rowSize===n.rowSize&&U.equals(this.bits,n.bits)}hashCode(){let e=this.width;return e=31*e+this.width,e=31*e+this.height,e=31*e+this.rowSize,e=31*e+U.hashCode(this.bits),e}toString(e="X ",n=" ",i=`
80
+ `){return this.buildToString(e,n,i)}buildToString(e,n,i){let s=new Ce;for(let a=0,c=this.height;a<c;a++){for(let d=0,h=this.width;d<h;d++)s.append(this.get(d,a)?e:n);s.append(i)}return s.toString()}clone(){return new le(this.width,this.height,this.rowSize,this.bits.slice())}}class L extends m{static getNotFoundInstance(){return new L}}L.kind="NotFoundException";class te extends D{constructor(e){super(e),this.luminances=te.EMPTY,this.buckets=new Int32Array(te.LUMINANCE_BUCKETS)}getBlackRow(e,n){const i=this.getLuminanceSource(),s=i.getWidth();n==null||n.getSize()<s?n=new J(s):n.clear(),this.initArrays(s);const a=i.getRow(e,this.luminances),c=this.buckets;for(let h=0;h<s;h++)c[(a[h]&255)>>te.LUMINANCE_SHIFT]++;const d=te.estimateBlackPoint(c);if(s<3)for(let h=0;h<s;h++)(a[h]&255)<d&&n.set(h);else{let h=a[0]&255,p=a[1]&255;for(let w=1;w<s-1;w++){const b=a[w+1]&255;(p*4-h-b)/2<d&&n.set(w),h=p,p=b}}return n}getBlackMatrix(){const e=this.getLuminanceSource(),n=e.getWidth(),i=e.getHeight(),s=new le(n,i);this.initArrays(n);const a=this.buckets;for(let h=1;h<5;h++){const p=Math.floor(i*h/5),w=e.getRow(p,this.luminances),b=Math.floor(n*4/5);for(let A=Math.floor(n/5);A<b;A++){const N=w[A]&255;a[N>>te.LUMINANCE_SHIFT]++}}const c=te.estimateBlackPoint(a),d=e.getMatrix();for(let h=0;h<i;h++){const p=h*n;for(let w=0;w<n;w++)(d[p+w]&255)<c&&s.set(w,h)}return s}createBinarizer(e){return new te(e)}initArrays(e){this.luminances.length<e&&(this.luminances=new Uint8ClampedArray(e));const n=this.buckets;for(let i=0;i<te.LUMINANCE_BUCKETS;i++)n[i]=0}static estimateBlackPoint(e){const n=e.length;let i=0,s=0,a=0;for(let w=0;w<n;w++)e[w]>a&&(s=w,a=e[w]),e[w]>i&&(i=e[w]);let c=0,d=0;for(let w=0;w<n;w++){const b=w-s,A=e[w]*b*b;A>d&&(c=w,d=A)}if(s>c){const w=s;s=c,c=w}if(c-s<=n/16)throw new L;let h=c-1,p=-1;for(let w=c-1;w>s;w--){const b=w-s,A=b*b*(c-w)*(i-e[w]);A>p&&(h=w,p=A)}return h<<te.LUMINANCE_SHIFT}}te.LUMINANCE_BITS=5,te.LUMINANCE_SHIFT=8-te.LUMINANCE_BITS,te.LUMINANCE_BUCKETS=1<<te.LUMINANCE_BITS,te.EMPTY=Uint8ClampedArray.from([0]);class K extends te{constructor(e){super(e),this.matrix=null}getBlackMatrix(){if(this.matrix!==null)return this.matrix;const e=this.getLuminanceSource(),n=e.getWidth(),i=e.getHeight();if(n>=K.MINIMUM_DIMENSION&&i>=K.MINIMUM_DIMENSION){const s=e.getMatrix();let a=n>>K.BLOCK_SIZE_POWER;(n&K.BLOCK_SIZE_MASK)!==0&&a++;let c=i>>K.BLOCK_SIZE_POWER;(i&K.BLOCK_SIZE_MASK)!==0&&c++;const d=K.calculateBlackPoints(s,a,c,n,i),h=new le(n,i);K.calculateThresholdForBlock(s,a,c,n,i,d,h),this.matrix=h}else this.matrix=super.getBlackMatrix();return this.matrix}createBinarizer(e){return new K(e)}static calculateThresholdForBlock(e,n,i,s,a,c,d){const h=a-K.BLOCK_SIZE,p=s-K.BLOCK_SIZE;for(let w=0;w<i;w++){let b=w<<K.BLOCK_SIZE_POWER;b>h&&(b=h);const A=K.cap(w,2,i-3);for(let N=0;N<n;N++){let F=N<<K.BLOCK_SIZE_POWER;F>p&&(F=p);const $=K.cap(N,2,n-3);let j=0;for(let se=-2;se<=2;se++){const ae=c[A+se];j+=ae[$-2]+ae[$-1]+ae[$]+ae[$+1]+ae[$+2]}const q=j/25;K.thresholdBlock(e,F,b,q,s,d)}}}static cap(e,n,i){return e<n?n:e>i?i:e}static thresholdBlock(e,n,i,s,a,c){for(let d=0,h=i*a+n;d<K.BLOCK_SIZE;d++,h+=a)for(let p=0;p<K.BLOCK_SIZE;p++)(e[h+p]&255)<=s&&c.set(n+p,i+d)}static calculateBlackPoints(e,n,i,s,a){const c=a-K.BLOCK_SIZE,d=s-K.BLOCK_SIZE,h=new Array(i);for(let p=0;p<i;p++){h[p]=new Int32Array(n);let w=p<<K.BLOCK_SIZE_POWER;w>c&&(w=c);for(let b=0;b<n;b++){let A=b<<K.BLOCK_SIZE_POWER;A>d&&(A=d);let N=0,F=255,$=0;for(let q=0,se=w*s+A;q<K.BLOCK_SIZE;q++,se+=s){for(let ae=0;ae<K.BLOCK_SIZE;ae++){const oe=e[se+ae]&255;N+=oe,oe<F&&(F=oe),oe>$&&($=oe)}if($-F>K.MIN_DYNAMIC_RANGE)for(q++,se+=s;q<K.BLOCK_SIZE;q++,se+=s)for(let ae=0;ae<K.BLOCK_SIZE;ae++)N+=e[se+ae]&255}let j=N>>K.BLOCK_SIZE_POWER*2;if($-F<=K.MIN_DYNAMIC_RANGE&&(j=F/2,p>0&&b>0)){const q=(h[p-1][b]+2*h[p][b-1]+h[p-1][b-1])/4;F<q&&(j=q)}h[p][b]=j}}return h}}K.BLOCK_SIZE_POWER=3,K.BLOCK_SIZE=1<<K.BLOCK_SIZE_POWER,K.BLOCK_SIZE_MASK=K.BLOCK_SIZE-1,K.MINIMUM_DIMENSION=K.BLOCK_SIZE*5,K.MIN_DYNAMIC_RANGE=24;class ne{constructor(e,n){this.width=e,this.height=n}getWidth(){return this.width}getHeight(){return this.height}isCropSupported(){return!1}crop(e,n,i,s){throw new de("This luminance source does not support cropping.")}isRotateSupported(){return!1}rotateCounterClockwise(){throw new de("This luminance source does not support rotation by 90 degrees.")}rotateCounterClockwise45(){throw new de("This luminance source does not support rotation by 45 degrees.")}toString(){const e=new Uint8ClampedArray(this.width);let n=new Ce;for(let i=0;i<this.height;i++){const s=this.getRow(i,e);for(let a=0;a<this.width;a++){const c=s[a]&255;let d;c<64?d="#":c<128?d="+":c<192?d=".":d=" ",n.append(d)}n.append(`
81
+ `)}return n.toString()}}class fe extends ne{constructor(e){super(e.getWidth(),e.getHeight()),this.delegate=e}getRow(e,n){const i=this.delegate.getRow(e,n),s=this.getWidth();for(let a=0;a<s;a++)i[a]=255-(i[a]&255);return i}getMatrix(){const e=this.delegate.getMatrix(),n=this.getWidth()*this.getHeight(),i=new Uint8ClampedArray(n);for(let s=0;s<n;s++)i[s]=255-(e[s]&255);return i}isCropSupported(){return this.delegate.isCropSupported()}crop(e,n,i,s){return new fe(this.delegate.crop(e,n,i,s))}isRotateSupported(){return this.delegate.isRotateSupported()}invert(){return this.delegate}rotateCounterClockwise(){return new fe(this.delegate.rotateCounterClockwise())}rotateCounterClockwise45(){return new fe(this.delegate.rotateCounterClockwise45())}}class xe extends ne{constructor(e){super(e.width,e.height),this.canvas=e,this.tempCanvasElement=null,this.buffer=xe.makeBufferFromCanvasImageData(e)}static makeBufferFromCanvasImageData(e){const n=e.getContext("2d").getImageData(0,0,e.width,e.height);return xe.toGrayscaleBuffer(n.data,e.width,e.height)}static toGrayscaleBuffer(e,n,i){const s=new Uint8ClampedArray(n*i);for(let a=0,c=0,d=e.length;a<d;a+=4,c++){let h;if(e[a+3]===0)h=255;else{const w=e[a],b=e[a+1],A=e[a+2];h=306*w+601*b+117*A+512>>10}s[c]=h}return s}getRow(e,n){if(e<0||e>=this.getHeight())throw new C("Requested row is outside the image: "+e);const i=this.getWidth(),s=e*i;return n===null?n=this.buffer.slice(s,s+i):(n.length<i&&(n=new Uint8ClampedArray(i)),n.set(this.buffer.slice(s,s+i))),n}getMatrix(){return this.buffer}isCropSupported(){return!0}crop(e,n,i,s){return super.crop(e,n,i,s),this}isRotateSupported(){return!0}rotateCounterClockwise(){return this.rotate(-90),this}rotateCounterClockwise45(){return this.rotate(-45),this}getTempCanvasElement(){if(this.tempCanvasElement===null){const e=this.canvas.ownerDocument.createElement("canvas");e.width=this.canvas.width,e.height=this.canvas.height,this.tempCanvasElement=e}return this.tempCanvasElement}rotate(e){const n=this.getTempCanvasElement(),i=n.getContext("2d"),s=e*xe.DEGREE_TO_RADIANS,a=this.canvas.width,c=this.canvas.height,d=Math.ceil(Math.abs(Math.cos(s))*a+Math.abs(Math.sin(s))*c),h=Math.ceil(Math.abs(Math.sin(s))*a+Math.abs(Math.cos(s))*c);return n.width=d,n.height=h,i.translate(d/2,h/2),i.rotate(s),i.drawImage(this.canvas,a/-2,c/-2),this.buffer=xe.makeBufferFromCanvasImageData(n),this}invert(){return new fe(this)}}xe.DEGREE_TO_RADIANS=Math.PI/180;class ye{constructor(e,n,i){this.deviceId=e,this.label=n,this.kind="videoinput",this.groupId=i||void 0}toJSON(){return{kind:this.kind,groupId:this.groupId,deviceId:this.deviceId,label:this.label}}}var ee=(globalThis||bi||self||window||void 0)&&(globalThis||bi||self||window||void 0).__awaiter||function(v,e,n,i){function s(a){return a instanceof n?a:new n(function(c){c(a)})}return new(n||(n=Promise))(function(a,c){function d(w){try{p(i.next(w))}catch(b){c(b)}}function h(w){try{p(i.throw(w))}catch(b){c(b)}}function p(w){w.done?a(w.value):s(w.value).then(d,h)}p((i=i.apply(v,e||[])).next())})};class he{constructor(e,n=500,i){this.reader=e,this.timeBetweenScansMillis=n,this._hints=i,this._stopContinuousDecode=!1,this._stopAsyncDecode=!1,this._timeBetweenDecodingAttempts=0}get hasNavigator(){return typeof navigator<"u"}get isMediaDevicesSuported(){return this.hasNavigator&&!!navigator.mediaDevices}get canEnumerateDevices(){return!!(this.isMediaDevicesSuported&&navigator.mediaDevices.enumerateDevices)}get timeBetweenDecodingAttempts(){return this._timeBetweenDecodingAttempts}set timeBetweenDecodingAttempts(e){this._timeBetweenDecodingAttempts=e<0?0:e}set hints(e){this._hints=e||null}get hints(){return this._hints}listVideoInputDevices(){return ee(this,void 0,void 0,function*(){if(!this.hasNavigator)throw new Error("Can't enumerate devices, navigator is not present.");if(!this.canEnumerateDevices)throw new Error("Can't enumerate devices, method not supported.");const e=yield navigator.mediaDevices.enumerateDevices(),n=[];for(const i of e){const s=i.kind==="video"?"videoinput":i.kind;if(s!=="videoinput")continue;const a=i.deviceId||i.id,c=i.label||`Video device ${n.length+1}`,d=i.groupId,h={deviceId:a,label:c,kind:s,groupId:d};n.push(h)}return n})}getVideoInputDevices(){return ee(this,void 0,void 0,function*(){return(yield this.listVideoInputDevices()).map(n=>new ye(n.deviceId,n.label))})}findDeviceById(e){return ee(this,void 0,void 0,function*(){const n=yield this.listVideoInputDevices();return n?n.find(i=>i.deviceId===e):null})}decodeFromInputVideoDevice(e,n){return ee(this,void 0,void 0,function*(){return yield this.decodeOnceFromVideoDevice(e,n)})}decodeOnceFromVideoDevice(e,n){return ee(this,void 0,void 0,function*(){this.reset();let i;e?i={deviceId:{exact:e}}:i={facingMode:"environment"};const s={video:i};return yield this.decodeOnceFromConstraints(s,n)})}decodeOnceFromConstraints(e,n){return ee(this,void 0,void 0,function*(){const i=yield navigator.mediaDevices.getUserMedia(e);return yield this.decodeOnceFromStream(i,n)})}decodeOnceFromStream(e,n){return ee(this,void 0,void 0,function*(){this.reset();const i=yield this.attachStreamToVideo(e,n);return yield this.decodeOnce(i)})}decodeFromInputVideoDeviceContinuously(e,n,i){return ee(this,void 0,void 0,function*(){return yield this.decodeFromVideoDevice(e,n,i)})}decodeFromVideoDevice(e,n,i){return ee(this,void 0,void 0,function*(){let s;e?s={deviceId:{exact:e}}:s={facingMode:"environment"};const a={video:s};return yield this.decodeFromConstraints(a,n,i)})}decodeFromConstraints(e,n,i){return ee(this,void 0,void 0,function*(){const s=yield navigator.mediaDevices.getUserMedia(e);return yield this.decodeFromStream(s,n,i)})}decodeFromStream(e,n,i){return ee(this,void 0,void 0,function*(){this.reset();const s=yield this.attachStreamToVideo(e,n);return yield this.decodeContinuously(s,i)})}stopAsyncDecode(){this._stopAsyncDecode=!0}stopContinuousDecode(){this._stopContinuousDecode=!0}attachStreamToVideo(e,n){return ee(this,void 0,void 0,function*(){const i=this.prepareVideoElement(n);return this.addVideoSource(i,e),this.videoElement=i,this.stream=e,yield this.playVideoOnLoadAsync(i),i})}playVideoOnLoadAsync(e){return new Promise((n,i)=>this.playVideoOnLoad(e,()=>n()))}playVideoOnLoad(e,n){this.videoEndedListener=()=>this.stopStreams(),this.videoCanPlayListener=()=>this.tryPlayVideo(e),e.addEventListener("ended",this.videoEndedListener),e.addEventListener("canplay",this.videoCanPlayListener),e.addEventListener("playing",n),this.tryPlayVideo(e)}isVideoPlaying(e){return e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>2}tryPlayVideo(e){return ee(this,void 0,void 0,function*(){if(this.isVideoPlaying(e)){console.warn("Trying to play video that is already playing.");return}try{yield e.play()}catch{console.warn("It was not possible to play the video.")}})}getMediaElement(e,n){const i=document.getElementById(e);if(!i)throw new E(`element with id '${e}' not found`);if(i.nodeName.toLowerCase()!==n.toLowerCase())throw new E(`element with id '${e}' must be an ${n} element`);return i}decodeFromImage(e,n){if(!e&&!n)throw new E("either imageElement with a src set or an url must be provided");return n&&!e?this.decodeFromImageUrl(n):this.decodeFromImageElement(e)}decodeFromVideo(e,n){if(!e&&!n)throw new E("Either an element with a src set or an URL must be provided");return n&&!e?this.decodeFromVideoUrl(n):this.decodeFromVideoElement(e)}decodeFromVideoContinuously(e,n,i){if(e===void 0&&n===void 0)throw new E("Either an element with a src set or an URL must be provided");return n&&!e?this.decodeFromVideoUrlContinuously(n,i):this.decodeFromVideoElementContinuously(e,i)}decodeFromImageElement(e){if(!e)throw new E("An image element must be provided.");this.reset();const n=this.prepareImageElement(e);this.imageElement=n;let i;return this.isImageLoaded(n)?i=this.decodeOnce(n,!1,!0):i=this._decodeOnLoadImage(n),i}decodeFromVideoElement(e){const n=this._decodeFromVideoElementSetup(e);return this._decodeOnLoadVideo(n)}decodeFromVideoElementContinuously(e,n){const i=this._decodeFromVideoElementSetup(e);return this._decodeOnLoadVideoContinuously(i,n)}_decodeFromVideoElementSetup(e){if(!e)throw new E("A video element must be provided.");this.reset();const n=this.prepareVideoElement(e);return this.videoElement=n,n}decodeFromImageUrl(e){if(!e)throw new E("An URL must be provided.");this.reset();const n=this.prepareImageElement();this.imageElement=n;const i=this._decodeOnLoadImage(n);return n.src=e,i}decodeFromVideoUrl(e){if(!e)throw new E("An URL must be provided.");this.reset();const n=this.prepareVideoElement(),i=this.decodeFromVideoElement(n);return n.src=e,i}decodeFromVideoUrlContinuously(e,n){if(!e)throw new E("An URL must be provided.");this.reset();const i=this.prepareVideoElement(),s=this.decodeFromVideoElementContinuously(i,n);return i.src=e,s}_decodeOnLoadImage(e){return new Promise((n,i)=>{this.imageLoadedListener=()=>this.decodeOnce(e,!1,!0).then(n,i),e.addEventListener("load",this.imageLoadedListener)})}_decodeOnLoadVideo(e){return ee(this,void 0,void 0,function*(){return yield this.playVideoOnLoadAsync(e),yield this.decodeOnce(e)})}_decodeOnLoadVideoContinuously(e,n){return ee(this,void 0,void 0,function*(){yield this.playVideoOnLoadAsync(e),this.decodeContinuously(e,n)})}isImageLoaded(e){return!(!e.complete||e.naturalWidth===0)}prepareImageElement(e){let n;return typeof e>"u"&&(n=document.createElement("img"),n.width=200,n.height=200),typeof e=="string"&&(n=this.getMediaElement(e,"img")),e instanceof HTMLImageElement&&(n=e),n}prepareVideoElement(e){let n;return!e&&typeof document<"u"&&(n=document.createElement("video"),n.width=200,n.height=200),typeof e=="string"&&(n=this.getMediaElement(e,"video")),e instanceof HTMLVideoElement&&(n=e),n.setAttribute("autoplay","true"),n.setAttribute("muted","true"),n.setAttribute("playsinline","true"),n}decodeOnce(e,n=!0,i=!0){this._stopAsyncDecode=!1;const s=(a,c)=>{if(this._stopAsyncDecode){c(new L("Video stream has ended before any code could be detected.")),this._stopAsyncDecode=void 0;return}try{const d=this.decode(e);a(d)}catch(d){const h=n&&d instanceof L,w=(d instanceof O||d instanceof z)&&i;if(h||w)return setTimeout(s,this._timeBetweenDecodingAttempts,a,c);c(d)}};return new Promise((a,c)=>s(a,c))}decodeContinuously(e,n){this._stopContinuousDecode=!1;const i=()=>{if(this._stopContinuousDecode){this._stopContinuousDecode=void 0;return}try{const s=this.decode(e);n(s,null),setTimeout(i,this.timeBetweenScansMillis)}catch(s){n(null,s);const a=s instanceof O||s instanceof z,c=s instanceof L;(a||c)&&setTimeout(i,this._timeBetweenDecodingAttempts)}};i()}decode(e){const n=this.createBinaryBitmap(e);return this.decodeBitmap(n)}_isHTMLVideoElement(e){return e.videoWidth!==0}drawFrameOnCanvas(e,n,i){n||(n={sx:0,sy:0,sWidth:e.videoWidth,sHeight:e.videoHeight,dx:0,dy:0,dWidth:e.videoWidth,dHeight:e.videoHeight}),i||(i=this.captureCanvasContext),i.drawImage(e,n.sx,n.sy,n.sWidth,n.sHeight,n.dx,n.dy,n.dWidth,n.dHeight)}drawImageOnCanvas(e,n,i=this.captureCanvasContext){n||(n={sx:0,sy:0,sWidth:e.naturalWidth,sHeight:e.naturalHeight,dx:0,dy:0,dWidth:e.naturalWidth,dHeight:e.naturalHeight}),i||(i=this.captureCanvasContext),i.drawImage(e,n.sx,n.sy,n.sWidth,n.sHeight,n.dx,n.dy,n.dWidth,n.dHeight)}createBinaryBitmap(e){this.getCaptureCanvasContext(e),this._isHTMLVideoElement(e)?this.drawFrameOnCanvas(e):this.drawImageOnCanvas(e);const n=this.getCaptureCanvas(e),i=new xe(n),s=new K(i);return new P(s)}getCaptureCanvasContext(e){if(!this.captureCanvasContext){const i=this.getCaptureCanvas(e).getContext("2d");this.captureCanvasContext=i}return this.captureCanvasContext}getCaptureCanvas(e){if(!this.captureCanvas){const n=this.createCaptureCanvas(e);this.captureCanvas=n}return this.captureCanvas}decodeBitmap(e){return this.reader.decode(e,this._hints)}createCaptureCanvas(e){if(typeof document>"u")return this._destroyCaptureCanvas(),null;const n=document.createElement("canvas");let i,s;return typeof e<"u"&&(e instanceof HTMLVideoElement?(i=e.videoWidth,s=e.videoHeight):e instanceof HTMLImageElement&&(i=e.naturalWidth||e.width,s=e.naturalHeight||e.height)),n.style.width=i+"px",n.style.height=s+"px",n.width=i,n.height=s,n}stopStreams(){this.stream&&(this.stream.getVideoTracks().forEach(e=>e.stop()),this.stream=void 0),this._stopAsyncDecode===!1&&this.stopAsyncDecode(),this._stopContinuousDecode===!1&&this.stopContinuousDecode()}reset(){this.stopStreams(),this._destroyVideoElement(),this._destroyImageElement(),this._destroyCaptureCanvas()}_destroyVideoElement(){this.videoElement&&(typeof this.videoEndedListener<"u"&&this.videoElement.removeEventListener("ended",this.videoEndedListener),typeof this.videoPlayingEventListener<"u"&&this.videoElement.removeEventListener("playing",this.videoPlayingEventListener),typeof this.videoCanPlayListener<"u"&&this.videoElement.removeEventListener("loadedmetadata",this.videoCanPlayListener),this.cleanVideoSource(this.videoElement),this.videoElement=void 0)}_destroyImageElement(){this.imageElement&&(this.imageLoadedListener!==void 0&&this.imageElement.removeEventListener("load",this.imageLoadedListener),this.imageElement.src=void 0,this.imageElement.removeAttribute("src"),this.imageElement=void 0)}_destroyCaptureCanvas(){this.captureCanvasContext=void 0,this.captureCanvas=void 0}addVideoSource(e,n){try{e.srcObject=n}catch{e.src=URL.createObjectURL(n)}}cleanVideoSource(e){try{e.srcObject=null}catch{e.src=""}this.videoElement.removeAttribute("src")}}class Ee{constructor(e,n,i=n==null?0:8*n.length,s,a,c=R.currentTimeMillis()){this.text=e,this.rawBytes=n,this.numBits=i,this.resultPoints=s,this.format=a,this.timestamp=c,this.text=e,this.rawBytes=n,i==null?this.numBits=n==null?0:8*n.length:this.numBits=i,this.resultPoints=s,this.format=a,this.resultMetadata=null,c==null?this.timestamp=R.currentTimeMillis():this.timestamp=c}getText(){return this.text}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}getResultPoints(){return this.resultPoints}getBarcodeFormat(){return this.format}getResultMetadata(){return this.resultMetadata}putMetadata(e,n){this.resultMetadata===null&&(this.resultMetadata=new Map),this.resultMetadata.set(e,n)}putAllMetadata(e){e!==null&&(this.resultMetadata===null?this.resultMetadata=e:this.resultMetadata=new Map(e))}addResultPoints(e){const n=this.resultPoints;if(n===null)this.resultPoints=e;else if(e!==null&&e.length>0){const i=new Array(n.length+e.length);R.arraycopy(n,0,i,0,n.length),R.arraycopy(e,0,i,n.length,e.length),this.resultPoints=i}}getTimestamp(){return this.timestamp}toString(){return this.text}}var _e;(function(v){v[v.AZTEC=0]="AZTEC",v[v.CODABAR=1]="CODABAR",v[v.CODE_39=2]="CODE_39",v[v.CODE_93=3]="CODE_93",v[v.CODE_128=4]="CODE_128",v[v.DATA_MATRIX=5]="DATA_MATRIX",v[v.EAN_8=6]="EAN_8",v[v.EAN_13=7]="EAN_13",v[v.ITF=8]="ITF",v[v.MAXICODE=9]="MAXICODE",v[v.PDF_417=10]="PDF_417",v[v.QR_CODE=11]="QR_CODE",v[v.RSS_14=12]="RSS_14",v[v.RSS_EXPANDED=13]="RSS_EXPANDED",v[v.UPC_A=14]="UPC_A",v[v.UPC_E=15]="UPC_E",v[v.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(_e||(_e={}));var T=_e,ce;(function(v){v[v.OTHER=0]="OTHER",v[v.ORIENTATION=1]="ORIENTATION",v[v.BYTE_SEGMENTS=2]="BYTE_SEGMENTS",v[v.ERROR_CORRECTION_LEVEL=3]="ERROR_CORRECTION_LEVEL",v[v.ISSUE_NUMBER=4]="ISSUE_NUMBER",v[v.SUGGESTED_PRICE=5]="SUGGESTED_PRICE",v[v.POSSIBLE_COUNTRY=6]="POSSIBLE_COUNTRY",v[v.UPC_EAN_EXTENSION=7]="UPC_EAN_EXTENSION",v[v.PDF417_EXTRA_METADATA=8]="PDF417_EXTRA_METADATA",v[v.STRUCTURED_APPEND_SEQUENCE=9]="STRUCTURED_APPEND_SEQUENCE",v[v.STRUCTURED_APPEND_PARITY=10]="STRUCTURED_APPEND_PARITY"})(ce||(ce={}));var we=ce;class mt{constructor(e,n,i,s,a=-1,c=-1){this.rawBytes=e,this.text=n,this.byteSegments=i,this.ecLevel=s,this.structuredAppendSequenceNumber=a,this.structuredAppendParity=c,this.numBits=e==null?0:8*e.length}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}setNumBits(e){this.numBits=e}getText(){return this.text}getByteSegments(){return this.byteSegments}getECLevel(){return this.ecLevel}getErrorsCorrected(){return this.errorsCorrected}setErrorsCorrected(e){this.errorsCorrected=e}getErasures(){return this.erasures}setErasures(e){this.erasures=e}getOther(){return this.other}setOther(e){this.other=e}hasStructuredAppend(){return this.structuredAppendParity>=0&&this.structuredAppendSequenceNumber>=0}getStructuredAppendParity(){return this.structuredAppendParity}getStructuredAppendSequenceNumber(){return this.structuredAppendSequenceNumber}}class ot{exp(e){return this.expTable[e]}log(e){if(e===0)throw new C;return this.logTable[e]}static addOrSubtract(e,n){return e^n}}class Qe{constructor(e,n){if(n.length===0)throw new C;this.field=e;const i=n.length;if(i>1&&n[0]===0){let s=1;for(;s<i&&n[s]===0;)s++;s===i?this.coefficients=Int32Array.from([0]):(this.coefficients=new Int32Array(i-s),R.arraycopy(n,s,this.coefficients,0,this.coefficients.length))}else this.coefficients=n}getCoefficients(){return this.coefficients}getDegree(){return this.coefficients.length-1}isZero(){return this.coefficients[0]===0}getCoefficient(e){return this.coefficients[this.coefficients.length-1-e]}evaluateAt(e){if(e===0)return this.getCoefficient(0);const n=this.coefficients;let i;if(e===1){i=0;for(let c=0,d=n.length;c!==d;c++){const h=n[c];i=ot.addOrSubtract(i,h)}return i}i=n[0];const s=n.length,a=this.field;for(let c=1;c<s;c++)i=ot.addOrSubtract(a.multiply(e,i),n[c]);return i}addOrSubtract(e){if(!this.field.equals(e.field))throw new C("GenericGFPolys do not have same GenericGF field");if(this.isZero())return e;if(e.isZero())return this;let n=this.coefficients,i=e.coefficients;if(n.length>i.length){const c=n;n=i,i=c}let s=new Int32Array(i.length);const a=i.length-n.length;R.arraycopy(i,0,s,0,a);for(let c=a;c<i.length;c++)s[c]=ot.addOrSubtract(n[c-a],i[c]);return new Qe(this.field,s)}multiply(e){if(!this.field.equals(e.field))throw new C("GenericGFPolys do not have same GenericGF field");if(this.isZero()||e.isZero())return this.field.getZero();const n=this.coefficients,i=n.length,s=e.coefficients,a=s.length,c=new Int32Array(i+a-1),d=this.field;for(let h=0;h<i;h++){const p=n[h];for(let w=0;w<a;w++)c[h+w]=ot.addOrSubtract(c[h+w],d.multiply(p,s[w]))}return new Qe(d,c)}multiplyScalar(e){if(e===0)return this.field.getZero();if(e===1)return this;const n=this.coefficients.length,i=this.field,s=new Int32Array(n),a=this.coefficients;for(let c=0;c<n;c++)s[c]=i.multiply(a[c],e);return new Qe(i,s)}multiplyByMonomial(e,n){if(e<0)throw new C;if(n===0)return this.field.getZero();const i=this.coefficients,s=i.length,a=new Int32Array(s+e),c=this.field;for(let d=0;d<s;d++)a[d]=c.multiply(i[d],n);return new Qe(c,a)}divide(e){if(!this.field.equals(e.field))throw new C("GenericGFPolys do not have same GenericGF field");if(e.isZero())throw new C("Divide by 0");const n=this.field;let i=n.getZero(),s=this;const a=e.getCoefficient(e.getDegree()),c=n.inverse(a);for(;s.getDegree()>=e.getDegree()&&!s.isZero();){const d=s.getDegree()-e.getDegree(),h=n.multiply(s.getCoefficient(s.getDegree()),c),p=e.multiplyByMonomial(d,h),w=n.buildMonomial(d,h);i=i.addOrSubtract(w),s=s.addOrSubtract(p)}return[i,s]}toString(){let e="";for(let n=this.getDegree();n>=0;n--){let i=this.getCoefficient(n);if(i!==0){if(i<0?(e+=" - ",i=-i):e.length>0&&(e+=" + "),n===0||i!==1){const s=this.field.log(i);s===0?e+="1":s===1?e+="a":(e+="a^",e+=s)}n!==0&&(n===1?e+="x":(e+="x^",e+=n))}}return e}}class an extends m{}an.kind="ArithmeticException";class Fe extends ot{constructor(e,n,i){super(),this.primitive=e,this.size=n,this.generatorBase=i;const s=new Int32Array(n);let a=1;for(let d=0;d<n;d++)s[d]=a,a*=2,a>=n&&(a^=e,a&=n-1);this.expTable=s;const c=new Int32Array(n);for(let d=0;d<n-1;d++)c[s[d]]=d;this.logTable=c,this.zero=new Qe(this,Int32Array.from([0])),this.one=new Qe(this,Int32Array.from([1]))}getZero(){return this.zero}getOne(){return this.one}buildMonomial(e,n){if(e<0)throw new C;if(n===0)return this.zero;const i=new Int32Array(e+1);return i[0]=n,new Qe(this,i)}inverse(e){if(e===0)throw new an;return this.expTable[this.size-this.logTable[e]-1]}multiply(e,n){return e===0||n===0?0:this.expTable[(this.logTable[e]+this.logTable[n])%(this.size-1)]}getSize(){return this.size}getGeneratorBase(){return this.generatorBase}toString(){return"GF(0x"+k.toHexString(this.primitive)+","+this.size+")"}equals(e){return e===this}}Fe.AZTEC_DATA_12=new Fe(4201,4096,1),Fe.AZTEC_DATA_10=new Fe(1033,1024,1),Fe.AZTEC_DATA_6=new Fe(67,64,1),Fe.AZTEC_PARAM=new Fe(19,16,1),Fe.QR_CODE_FIELD_256=new Fe(285,256,0),Fe.DATA_MATRIX_FIELD_256=new Fe(301,256,1),Fe.AZTEC_DATA_8=Fe.DATA_MATRIX_FIELD_256,Fe.MAXICODE_FIELD_64=Fe.AZTEC_DATA_6;class Un extends m{}Un.kind="ReedSolomonException";class ln extends m{}ln.kind="IllegalStateException";class zn{constructor(e){this.field=e}decode(e,n){const i=this.field,s=new Qe(i,e),a=new Int32Array(n);let c=!0;for(let N=0;N<n;N++){const F=s.evaluateAt(i.exp(N+i.getGeneratorBase()));a[a.length-1-N]=F,F!==0&&(c=!1)}if(c)return;const d=new Qe(i,a),h=this.runEuclideanAlgorithm(i.buildMonomial(n,1),d,n),p=h[0],w=h[1],b=this.findErrorLocations(p),A=this.findErrorMagnitudes(w,b);for(let N=0;N<b.length;N++){const F=e.length-1-i.log(b[N]);if(F<0)throw new Un("Bad error location");e[F]=Fe.addOrSubtract(e[F],A[N])}}runEuclideanAlgorithm(e,n,i){if(e.getDegree()<n.getDegree()){const N=e;e=n,n=N}const s=this.field;let a=e,c=n,d=s.getZero(),h=s.getOne();for(;c.getDegree()>=(i/2|0);){let N=a,F=d;if(a=c,d=h,a.isZero())throw new Un("r_{i-1} was zero");c=N;let $=s.getZero();const j=a.getCoefficient(a.getDegree()),q=s.inverse(j);for(;c.getDegree()>=a.getDegree()&&!c.isZero();){const se=c.getDegree()-a.getDegree(),ae=s.multiply(c.getCoefficient(c.getDegree()),q);$=$.addOrSubtract(s.buildMonomial(se,ae)),c=c.addOrSubtract(a.multiplyByMonomial(se,ae))}if(h=$.multiply(d).addOrSubtract(F),c.getDegree()>=a.getDegree())throw new ln("Division algorithm failed to reduce polynomial?")}const p=h.getCoefficient(0);if(p===0)throw new Un("sigmaTilde(0) was zero");const w=s.inverse(p),b=h.multiplyScalar(w),A=c.multiplyScalar(w);return[b,A]}findErrorLocations(e){const n=e.getDegree();if(n===1)return Int32Array.from([e.getCoefficient(1)]);const i=new Int32Array(n);let s=0;const a=this.field;for(let c=1;c<a.getSize()&&s<n;c++)e.evaluateAt(c)===0&&(i[s]=a.inverse(c),s++);if(s!==n)throw new Un("Error locator degree does not match number of roots");return i}findErrorMagnitudes(e,n){const i=n.length,s=new Int32Array(i),a=this.field;for(let c=0;c<i;c++){const d=a.inverse(n[c]);let h=1;for(let p=0;p<i;p++)if(c!==p){const w=a.multiply(n[p],d),b=(w&1)===0?w|1:w&-2;h=a.multiply(h,b)}s[c]=a.multiply(e.evaluateAt(d),a.inverse(h)),a.getGeneratorBase()!==0&&(s[c]=a.multiply(s[c],d))}return s}}var At;(function(v){v[v.UPPER=0]="UPPER",v[v.LOWER=1]="LOWER",v[v.MIXED=2]="MIXED",v[v.DIGIT=3]="DIGIT",v[v.PUNCT=4]="PUNCT",v[v.BINARY=5]="BINARY"})(At||(At={}));class Ke{decode(e){this.ddata=e;let n=e.getBits(),i=this.extractBits(n),s=this.correctBits(i),a=Ke.convertBoolArrayToByteArray(s),c=Ke.getEncodedData(s),d=new mt(a,c,null,null);return d.setNumBits(s.length),d}static highLevelDecode(e){return this.getEncodedData(e)}static getEncodedData(e){let n=e.length,i=At.UPPER,s=At.UPPER,a="",c=0;for(;c<n;)if(s===At.BINARY){if(n-c<5)break;let d=Ke.readCode(e,c,5);if(c+=5,d===0){if(n-c<11)break;d=Ke.readCode(e,c,11)+31,c+=11}for(let h=0;h<d;h++){if(n-c<8){c=n;break}const p=Ke.readCode(e,c,8);a+=pe.castAsNonUtf8Char(p),c+=8}s=i}else{let d=s===At.DIGIT?4:5;if(n-c<d)break;let h=Ke.readCode(e,c,d);c+=d;let p=Ke.getCharacter(s,h);p.startsWith("CTRL_")?(i=s,s=Ke.getTable(p.charAt(5)),p.charAt(6)==="L"&&(i=s)):(a+=p,s=i)}return a}static getTable(e){switch(e){case"L":return At.LOWER;case"P":return At.PUNCT;case"M":return At.MIXED;case"D":return At.DIGIT;case"B":return At.BINARY;case"U":default:return At.UPPER}}static getCharacter(e,n){switch(e){case At.UPPER:return Ke.UPPER_TABLE[n];case At.LOWER:return Ke.LOWER_TABLE[n];case At.MIXED:return Ke.MIXED_TABLE[n];case At.PUNCT:return Ke.PUNCT_TABLE[n];case At.DIGIT:return Ke.DIGIT_TABLE[n];default:throw new ln("Bad table")}}correctBits(e){let n,i;this.ddata.getNbLayers()<=2?(i=6,n=Fe.AZTEC_DATA_6):this.ddata.getNbLayers()<=8?(i=8,n=Fe.AZTEC_DATA_8):this.ddata.getNbLayers()<=22?(i=10,n=Fe.AZTEC_DATA_10):(i=12,n=Fe.AZTEC_DATA_12);let s=this.ddata.getNbDatablocks(),a=e.length/i;if(a<s)throw new z;let c=e.length%i,d=new Int32Array(a);for(let A=0;A<a;A++,c+=i)d[A]=Ke.readCode(e,c,i);try{new zn(n).decode(d,a-s)}catch(A){throw new z(A)}let h=(1<<i)-1,p=0;for(let A=0;A<s;A++){let N=d[A];if(N===0||N===h)throw new z;(N===1||N===h-1)&&p++}let w=new Array(s*i-p),b=0;for(let A=0;A<s;A++){let N=d[A];if(N===1||N===h-1)w.fill(N>1,b,b+i-1),b+=i-1;else for(let F=i-1;F>=0;--F)w[b++]=(N&1<<F)!==0}return w}extractBits(e){let n=this.ddata.isCompact(),i=this.ddata.getNbLayers(),s=(n?11:14)+i*4,a=new Int32Array(s),c=new Array(this.totalBitsInLayer(i,n));if(n)for(let d=0;d<a.length;d++)a[d]=d;else{let d=s+1+2*k.truncDivision(k.truncDivision(s,2)-1,15),h=s/2,p=k.truncDivision(d,2);for(let w=0;w<h;w++){let b=w+k.truncDivision(w,15);a[h-w-1]=p-b-1,a[h+w]=p+b+1}}for(let d=0,h=0;d<i;d++){let p=(i-d)*4+(n?9:12),w=d*2,b=s-1-w;for(let A=0;A<p;A++){let N=A*2;for(let F=0;F<2;F++)c[h+N+F]=e.get(a[w+F],a[w+A]),c[h+2*p+N+F]=e.get(a[w+A],a[b-F]),c[h+4*p+N+F]=e.get(a[b-F],a[b-A]),c[h+6*p+N+F]=e.get(a[b-A],a[w+F])}h+=p*8}return c}static readCode(e,n,i){let s=0;for(let a=n;a<n+i;a++)s<<=1,e[a]&&(s|=1);return s}static readByte(e,n){let i=e.length-n;return i>=8?Ke.readCode(e,n,8):Ke.readCode(e,n,i)<<8-i}static convertBoolArrayToByteArray(e){let n=new Uint8Array((e.length+7)/8);for(let i=0;i<n.length;i++)n[i]=Ke.readByte(e,8*i);return n}totalBitsInLayer(e,n){return((n?88:112)+16*e)*e}}Ke.UPPER_TABLE=["CTRL_PS"," ","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","CTRL_LL","CTRL_ML","CTRL_DL","CTRL_BS"],Ke.LOWER_TABLE=["CTRL_PS"," ","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","CTRL_US","CTRL_ML","CTRL_DL","CTRL_BS"],Ke.MIXED_TABLE=["CTRL_PS"," ","\\1","\\2","\\3","\\4","\\5","\\6","\\7","\b"," ",`
82
+ `,"\\13","\f","\r","\\33","\\34","\\35","\\36","\\37","@","\\","^","_","`","|","~","\\177","CTRL_LL","CTRL_UL","CTRL_PL","CTRL_BS"],Ke.PUNCT_TABLE=["","\r",`\r
83
+ `,". ",", ",": ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","[","]","{","}","CTRL_UL"],Ke.DIGIT_TABLE=["CTRL_PS"," ","0","1","2","3","4","5","6","7","8","9",",",".","CTRL_UL","CTRL_US"];class ze{constructor(){}static round(e){return e===NaN?0:e<=Number.MIN_SAFE_INTEGER?Number.MIN_SAFE_INTEGER:e>=Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:e+(e<0?-.5:.5)|0}static distance(e,n,i,s){const a=e-i,c=n-s;return Math.sqrt(a*a+c*c)}static sum(e){let n=0;for(let i=0,s=e.length;i!==s;i++){const a=e[i];n+=a}return n}}class lr{static floatToIntBits(e){return e}}lr.MAX_VALUE=Number.MAX_SAFE_INTEGER;class Se{constructor(e,n){this.x=e,this.y=n}getX(){return this.x}getY(){return this.y}equals(e){if(e instanceof Se){const n=e;return this.x===n.x&&this.y===n.y}return!1}hashCode(){return 31*lr.floatToIntBits(this.x)+lr.floatToIntBits(this.y)}toString(){return"("+this.x+","+this.y+")"}static orderBestPatterns(e){const n=this.distance(e[0],e[1]),i=this.distance(e[1],e[2]),s=this.distance(e[0],e[2]);let a,c,d;if(i>=n&&i>=s?(c=e[0],a=e[1],d=e[2]):s>=i&&s>=n?(c=e[1],a=e[0],d=e[2]):(c=e[2],a=e[0],d=e[1]),this.crossProductZ(a,c,d)<0){const h=a;a=d,d=h}e[0]=a,e[1]=c,e[2]=d}static distance(e,n){return ze.distance(e.x,e.y,n.x,n.y)}static crossProductZ(e,n,i){const s=n.x,a=n.y;return(i.x-s)*(e.y-a)-(i.y-a)*(e.x-s)}}class cr{constructor(e,n){this.bits=e,this.points=n}getBits(){return this.bits}getPoints(){return this.points}}class si extends cr{constructor(e,n,i,s,a){super(e,n),this.compact=i,this.nbDatablocks=s,this.nbLayers=a}getNbLayers(){return this.nbLayers}getNbDatablocks(){return this.nbDatablocks}isCompact(){return this.compact}}class $e{constructor(e,n,i,s){this.image=e,this.height=e.getHeight(),this.width=e.getWidth(),n==null&&(n=$e.INIT_SIZE),i==null&&(i=e.getWidth()/2|0),s==null&&(s=e.getHeight()/2|0);const a=n/2|0;if(this.leftInit=i-a,this.rightInit=i+a,this.upInit=s-a,this.downInit=s+a,this.upInit<0||this.leftInit<0||this.downInit>=this.height||this.rightInit>=this.width)throw new L}detect(){let e=this.leftInit,n=this.rightInit,i=this.upInit,s=this.downInit,a=!1,c=!0,d=!1,h=!1,p=!1,w=!1,b=!1;const A=this.width,N=this.height;for(;c;){c=!1;let F=!0;for(;(F||!h)&&n<A;)F=this.containsBlackPoint(i,s,n,!1),F?(n++,c=!0,h=!0):h||n++;if(n>=A){a=!0;break}let $=!0;for(;($||!p)&&s<N;)$=this.containsBlackPoint(e,n,s,!0),$?(s++,c=!0,p=!0):p||s++;if(s>=N){a=!0;break}let j=!0;for(;(j||!w)&&e>=0;)j=this.containsBlackPoint(i,s,e,!1),j?(e--,c=!0,w=!0):w||e--;if(e<0){a=!0;break}let q=!0;for(;(q||!b)&&i>=0;)q=this.containsBlackPoint(e,n,i,!0),q?(i--,c=!0,b=!0):b||i--;if(i<0){a=!0;break}c&&(d=!0)}if(!a&&d){const F=n-e;let $=null;for(let ae=1;$===null&&ae<F;ae++)$=this.getBlackPointOnSegment(e,s-ae,e+ae,s);if($==null)throw new L;let j=null;for(let ae=1;j===null&&ae<F;ae++)j=this.getBlackPointOnSegment(e,i+ae,e+ae,i);if(j==null)throw new L;let q=null;for(let ae=1;q===null&&ae<F;ae++)q=this.getBlackPointOnSegment(n,i+ae,n-ae,i);if(q==null)throw new L;let se=null;for(let ae=1;se===null&&ae<F;ae++)se=this.getBlackPointOnSegment(n,s-ae,n-ae,s);if(se==null)throw new L;return this.centerEdges(se,$,q,j)}else throw new L}getBlackPointOnSegment(e,n,i,s){const a=ze.round(ze.distance(e,n,i,s)),c=(i-e)/a,d=(s-n)/a,h=this.image;for(let p=0;p<a;p++){const w=ze.round(e+p*c),b=ze.round(n+p*d);if(h.get(w,b))return new Se(w,b)}return null}centerEdges(e,n,i,s){const a=e.getX(),c=e.getY(),d=n.getX(),h=n.getY(),p=i.getX(),w=i.getY(),b=s.getX(),A=s.getY(),N=$e.CORR;return a<this.width/2?[new Se(b-N,A+N),new Se(d+N,h+N),new Se(p-N,w-N),new Se(a+N,c-N)]:[new Se(b+N,A+N),new Se(d+N,h-N),new Se(p-N,w+N),new Se(a-N,c-N)]}containsBlackPoint(e,n,i,s){const a=this.image;if(s){for(let c=e;c<=n;c++)if(a.get(c,i))return!0}else for(let c=e;c<=n;c++)if(a.get(i,c))return!0;return!1}}$e.INIT_SIZE=10,$e.CORR=1;class De{static checkAndNudgePoints(e,n){const i=e.getWidth(),s=e.getHeight();let a=!0;for(let c=0;c<n.length&&a;c+=2){const d=Math.floor(n[c]),h=Math.floor(n[c+1]);if(d<-1||d>i||h<-1||h>s)throw new L;a=!1,d===-1?(n[c]=0,a=!0):d===i&&(n[c]=i-1,a=!0),h===-1?(n[c+1]=0,a=!0):h===s&&(n[c+1]=s-1,a=!0)}a=!0;for(let c=n.length-2;c>=0&&a;c-=2){const d=Math.floor(n[c]),h=Math.floor(n[c+1]);if(d<-1||d>i||h<-1||h>s)throw new L;a=!1,d===-1?(n[c]=0,a=!0):d===i&&(n[c]=i-1,a=!0),h===-1?(n[c+1]=0,a=!0):h===s&&(n[c+1]=s-1,a=!0)}}}class Be{constructor(e,n,i,s,a,c,d,h,p){this.a11=e,this.a21=n,this.a31=i,this.a12=s,this.a22=a,this.a32=c,this.a13=d,this.a23=h,this.a33=p}static quadrilateralToQuadrilateral(e,n,i,s,a,c,d,h,p,w,b,A,N,F,$,j){const q=Be.quadrilateralToSquare(e,n,i,s,a,c,d,h);return Be.squareToQuadrilateral(p,w,b,A,N,F,$,j).times(q)}transformPoints(e){const n=e.length,i=this.a11,s=this.a12,a=this.a13,c=this.a21,d=this.a22,h=this.a23,p=this.a31,w=this.a32,b=this.a33;for(let A=0;A<n;A+=2){const N=e[A],F=e[A+1],$=a*N+h*F+b;e[A]=(i*N+c*F+p)/$,e[A+1]=(s*N+d*F+w)/$}}transformPointsWithValues(e,n){const i=this.a11,s=this.a12,a=this.a13,c=this.a21,d=this.a22,h=this.a23,p=this.a31,w=this.a32,b=this.a33,A=e.length;for(let N=0;N<A;N++){const F=e[N],$=n[N],j=a*F+h*$+b;e[N]=(i*F+c*$+p)/j,n[N]=(s*F+d*$+w)/j}}static squareToQuadrilateral(e,n,i,s,a,c,d,h){const p=e-i+a-d,w=n-s+c-h;if(p===0&&w===0)return new Be(i-e,a-i,e,s-n,c-s,n,0,0,1);{const b=i-a,A=d-a,N=s-c,F=h-c,$=b*F-A*N,j=(p*F-A*w)/$,q=(b*w-p*N)/$;return new Be(i-e+j*i,d-e+q*d,e,s-n+j*s,h-n+q*h,n,j,q,1)}}static quadrilateralToSquare(e,n,i,s,a,c,d,h){return Be.squareToQuadrilateral(e,n,i,s,a,c,d,h).buildAdjoint()}buildAdjoint(){return new Be(this.a22*this.a33-this.a23*this.a32,this.a23*this.a31-this.a21*this.a33,this.a21*this.a32-this.a22*this.a31,this.a13*this.a32-this.a12*this.a33,this.a11*this.a33-this.a13*this.a31,this.a12*this.a31-this.a11*this.a32,this.a12*this.a23-this.a13*this.a22,this.a13*this.a21-this.a11*this.a23,this.a11*this.a22-this.a12*this.a21)}times(e){return new Be(this.a11*e.a11+this.a21*e.a12+this.a31*e.a13,this.a11*e.a21+this.a21*e.a22+this.a31*e.a23,this.a11*e.a31+this.a21*e.a32+this.a31*e.a33,this.a12*e.a11+this.a22*e.a12+this.a32*e.a13,this.a12*e.a21+this.a22*e.a22+this.a32*e.a23,this.a12*e.a31+this.a22*e.a32+this.a32*e.a33,this.a13*e.a11+this.a23*e.a12+this.a33*e.a13,this.a13*e.a21+this.a23*e.a22+this.a33*e.a23,this.a13*e.a31+this.a23*e.a32+this.a33*e.a33)}}class Ji extends De{sampleGrid(e,n,i,s,a,c,d,h,p,w,b,A,N,F,$,j,q,se,ae){const oe=Be.quadrilateralToQuadrilateral(s,a,c,d,h,p,w,b,A,N,F,$,j,q,se,ae);return this.sampleGridWithTransform(e,n,i,oe)}sampleGridWithTransform(e,n,i,s){if(n<=0||i<=0)throw new L;const a=new le(n,i),c=new Float32Array(2*n);for(let d=0;d<i;d++){const h=c.length,p=d+.5;for(let w=0;w<h;w+=2)c[w]=w/2+.5,c[w+1]=p;s.transformPoints(c),De.checkAndNudgePoints(e,c);try{for(let w=0;w<h;w+=2)e.get(Math.floor(c[w]),Math.floor(c[w+1]))&&a.set(w/2,d)}catch{throw new L}}return a}}class gn{static setGridSampler(e){gn.gridSampler=e}static getInstance(){return gn.gridSampler}}gn.gridSampler=new Ji;class Mt{constructor(e,n){this.x=e,this.y=n}toResultPoint(){return new Se(this.getX(),this.getY())}getX(){return this.x}getY(){return this.y}}class ws{constructor(e){this.EXPECTED_CORNER_BITS=new Int32Array([3808,476,2107,1799]),this.image=e}detect(){return this.detectMirror(!1)}detectMirror(e){let n=this.getMatrixCenter(),i=this.getBullsEyeCorners(n);if(e){let c=i[0];i[0]=i[2],i[2]=c}this.extractParameters(i);let s=this.sampleGrid(this.image,i[this.shift%4],i[(this.shift+1)%4],i[(this.shift+2)%4],i[(this.shift+3)%4]),a=this.getMatrixCornerPoints(i);return new si(s,a,this.compact,this.nbDataBlocks,this.nbLayers)}extractParameters(e){if(!this.isValidPoint(e[0])||!this.isValidPoint(e[1])||!this.isValidPoint(e[2])||!this.isValidPoint(e[3]))throw new L;let n=2*this.nbCenterLayers,i=new Int32Array([this.sampleLine(e[0],e[1],n),this.sampleLine(e[1],e[2],n),this.sampleLine(e[2],e[3],n),this.sampleLine(e[3],e[0],n)]);this.shift=this.getRotation(i,n);let s=0;for(let c=0;c<4;c++){let d=i[(this.shift+c)%4];this.compact?(s<<=7,s+=d>>1&127):(s<<=10,s+=(d>>2&992)+(d>>1&31))}let a=this.getCorrectedParameterData(s,this.compact);this.compact?(this.nbLayers=(a>>6)+1,this.nbDataBlocks=(a&63)+1):(this.nbLayers=(a>>11)+1,this.nbDataBlocks=(a&2047)+1)}getRotation(e,n){let i=0;e.forEach((s,a,c)=>{let d=(s>>n-2<<1)+(s&1);i=(i<<3)+d}),i=((i&1)<<11)+(i>>1);for(let s=0;s<4;s++)if(k.bitCount(i^this.EXPECTED_CORNER_BITS[s])<=2)return s;throw new L}getCorrectedParameterData(e,n){let i,s;n?(i=7,s=2):(i=10,s=4);let a=i-s,c=new Int32Array(i);for(let h=i-1;h>=0;--h)c[h]=e&15,e>>=4;try{new zn(Fe.AZTEC_PARAM).decode(c,a)}catch{throw new L}let d=0;for(let h=0;h<s;h++)d=(d<<4)+c[h];return d}getBullsEyeCorners(e){let n=e,i=e,s=e,a=e,c=!0;for(this.nbCenterLayers=1;this.nbCenterLayers<9;this.nbCenterLayers++){let b=this.getFirstDifferent(n,c,1,-1),A=this.getFirstDifferent(i,c,1,1),N=this.getFirstDifferent(s,c,-1,1),F=this.getFirstDifferent(a,c,-1,-1);if(this.nbCenterLayers>2){let $=this.distancePoint(F,b)*this.nbCenterLayers/(this.distancePoint(a,n)*(this.nbCenterLayers+2));if($<.75||$>1.25||!this.isWhiteOrBlackRectangle(b,A,N,F))break}n=b,i=A,s=N,a=F,c=!c}if(this.nbCenterLayers!==5&&this.nbCenterLayers!==7)throw new L;this.compact=this.nbCenterLayers===5;let d=new Se(n.getX()+.5,n.getY()-.5),h=new Se(i.getX()+.5,i.getY()+.5),p=new Se(s.getX()-.5,s.getY()+.5),w=new Se(a.getX()-.5,a.getY()-.5);return this.expandSquare([d,h,p,w],2*this.nbCenterLayers-3,2*this.nbCenterLayers)}getMatrixCenter(){let e,n,i,s;try{let d=new $e(this.image).detect();e=d[0],n=d[1],i=d[2],s=d[3]}catch{let h=this.image.getWidth()/2,p=this.image.getHeight()/2;e=this.getFirstDifferent(new Mt(h+7,p-7),!1,1,-1).toResultPoint(),n=this.getFirstDifferent(new Mt(h+7,p+7),!1,1,1).toResultPoint(),i=this.getFirstDifferent(new Mt(h-7,p+7),!1,-1,1).toResultPoint(),s=this.getFirstDifferent(new Mt(h-7,p-7),!1,-1,-1).toResultPoint()}let a=ze.round((e.getX()+s.getX()+n.getX()+i.getX())/4),c=ze.round((e.getY()+s.getY()+n.getY()+i.getY())/4);try{let d=new $e(this.image,15,a,c).detect();e=d[0],n=d[1],i=d[2],s=d[3]}catch{e=this.getFirstDifferent(new Mt(a+7,c-7),!1,1,-1).toResultPoint(),n=this.getFirstDifferent(new Mt(a+7,c+7),!1,1,1).toResultPoint(),i=this.getFirstDifferent(new Mt(a-7,c+7),!1,-1,1).toResultPoint(),s=this.getFirstDifferent(new Mt(a-7,c-7),!1,-1,-1).toResultPoint()}return a=ze.round((e.getX()+s.getX()+n.getX()+i.getX())/4),c=ze.round((e.getY()+s.getY()+n.getY()+i.getY())/4),new Mt(a,c)}getMatrixCornerPoints(e){return this.expandSquare(e,2*this.nbCenterLayers,this.getDimension())}sampleGrid(e,n,i,s,a){let c=gn.getInstance(),d=this.getDimension(),h=d/2-this.nbCenterLayers,p=d/2+this.nbCenterLayers;return c.sampleGrid(e,d,d,h,h,p,h,p,p,h,p,n.getX(),n.getY(),i.getX(),i.getY(),s.getX(),s.getY(),a.getX(),a.getY())}sampleLine(e,n,i){let s=0,a=this.distanceResultPoint(e,n),c=a/i,d=e.getX(),h=e.getY(),p=c*(n.getX()-e.getX())/a,w=c*(n.getY()-e.getY())/a;for(let b=0;b<i;b++)this.image.get(ze.round(d+b*p),ze.round(h+b*w))&&(s|=1<<i-b-1);return s}isWhiteOrBlackRectangle(e,n,i,s){let a=3;e=new Mt(e.getX()-a,e.getY()+a),n=new Mt(n.getX()-a,n.getY()-a),i=new Mt(i.getX()+a,i.getY()-a),s=new Mt(s.getX()+a,s.getY()+a);let c=this.getColor(s,e);if(c===0)return!1;let d=this.getColor(e,n);return d!==c||(d=this.getColor(n,i),d!==c)?!1:(d=this.getColor(i,s),d===c)}getColor(e,n){let i=this.distancePoint(e,n),s=(n.getX()-e.getX())/i,a=(n.getY()-e.getY())/i,c=0,d=e.getX(),h=e.getY(),p=this.image.get(e.getX(),e.getY()),w=Math.ceil(i);for(let A=0;A<w;A++)d+=s,h+=a,this.image.get(ze.round(d),ze.round(h))!==p&&c++;let b=c/i;return b>.1&&b<.9?0:b<=.1===p?1:-1}getFirstDifferent(e,n,i,s){let a=e.getX()+i,c=e.getY()+s;for(;this.isValid(a,c)&&this.image.get(a,c)===n;)a+=i,c+=s;for(a-=i,c-=s;this.isValid(a,c)&&this.image.get(a,c)===n;)a+=i;for(a-=i;this.isValid(a,c)&&this.image.get(a,c)===n;)c+=s;return c-=s,new Mt(a,c)}expandSquare(e,n,i){let s=i/(2*n),a=e[0].getX()-e[2].getX(),c=e[0].getY()-e[2].getY(),d=(e[0].getX()+e[2].getX())/2,h=(e[0].getY()+e[2].getY())/2,p=new Se(d+s*a,h+s*c),w=new Se(d-s*a,h-s*c);a=e[1].getX()-e[3].getX(),c=e[1].getY()-e[3].getY(),d=(e[1].getX()+e[3].getX())/2,h=(e[1].getY()+e[3].getY())/2;let b=new Se(d+s*a,h+s*c),A=new Se(d-s*a,h-s*c);return[p,b,w,A]}isValid(e,n){return e>=0&&e<this.image.getWidth()&&n>0&&n<this.image.getHeight()}isValidPoint(e){let n=ze.round(e.getX()),i=ze.round(e.getY());return this.isValid(n,i)}distancePoint(e,n){return ze.distance(e.getX(),e.getY(),n.getX(),n.getY())}distanceResultPoint(e,n){return ze.distance(e.getX(),e.getY(),n.getX(),n.getY())}getDimension(){return this.compact?4*this.nbLayers+11:this.nbLayers<=4?4*this.nbLayers+15:4*this.nbLayers+2*(k.truncDivision(this.nbLayers-4,8)+1)+15}}class ai{decode(e,n=null){let i=null,s=new ws(e.getBlackMatrix()),a=null,c=null;try{let w=s.detectMirror(!1);a=w.getPoints(),this.reportFoundResultPoints(n,a),c=new Ke().decode(w)}catch(w){i=w}if(c==null)try{let w=s.detectMirror(!0);a=w.getPoints(),this.reportFoundResultPoints(n,a),c=new Ke().decode(w)}catch(w){throw i??w}let d=new Ee(c.getText(),c.getRawBytes(),c.getNumBits(),a,T.AZTEC,R.currentTimeMillis()),h=c.getByteSegments();h!=null&&d.putMetadata(we.BYTE_SEGMENTS,h);let p=c.getECLevel();return p!=null&&d.putMetadata(we.ERROR_CORRECTION_LEVEL,p),d}reportFoundResultPoints(e,n){if(e!=null){let i=e.get(Z.NEED_RESULT_POINT_CALLBACK);i!=null&&n.forEach((s,a,c)=>{i.foundPossibleResultPoint(s)})}}reset(){}}class c1 extends he{constructor(e=500){super(new ai,e)}}class bt{decode(e,n){try{return this.doDecode(e,n)}catch{if(n&&n.get(Z.TRY_HARDER)===!0&&e.isRotateSupported()){const a=e.rotateCounterClockwise(),c=this.doDecode(a,n),d=c.getResultMetadata();let h=270;d!==null&&d.get(we.ORIENTATION)===!0&&(h=h+d.get(we.ORIENTATION)%360),c.putMetadata(we.ORIENTATION,h);const p=c.getResultPoints();if(p!==null){const w=a.getHeight();for(let b=0;b<p.length;b++)p[b]=new Se(w-p[b].getY()-1,p[b].getX())}return c}else throw new L}}reset(){}doDecode(e,n){const i=e.getWidth(),s=e.getHeight();let a=new J(i);const c=n&&n.get(Z.TRY_HARDER)===!0,d=Math.max(1,s>>(c?8:5));let h;c?h=s:h=15;const p=Math.trunc(s/2);for(let w=0;w<h;w++){const b=Math.trunc((w+1)/2),A=(w&1)===0,N=p+d*(A?b:-b);if(N<0||N>=s)break;try{a=e.getBlackRow(N,a)}catch{continue}for(let F=0;F<2;F++){if(F===1&&(a.reverse(),n&&n.get(Z.NEED_RESULT_POINT_CALLBACK)===!0)){const $=new Map;n.forEach((j,q)=>$.set(q,j)),$.delete(Z.NEED_RESULT_POINT_CALLBACK),n=$}try{const $=this.decodeRow(N,a,n);if(F===1){$.putMetadata(we.ORIENTATION,180);const j=$.getResultPoints();j!==null&&(j[0]=new Se(i-j[0].getX()-1,j[0].getY()),j[1]=new Se(i-j[1].getX()-1,j[1].getY()))}return $}catch{}}}throw new L}static recordPattern(e,n,i){const s=i.length;for(let p=0;p<s;p++)i[p]=0;const a=e.getSize();if(n>=a)throw new L;let c=!e.get(n),d=0,h=n;for(;h<a;){if(e.get(h)!==c)i[d]++;else{if(++d===s)break;i[d]=1,c=!c}h++}if(!(d===s||d===s-1&&h===a))throw new L}static recordPatternInReverse(e,n,i){let s=i.length,a=e.get(n);for(;n>0&&s>=0;)e.get(--n)!==a&&(s--,a=!a);if(s>=0)throw new L;bt.recordPattern(e,n+1,i)}static patternMatchVariance(e,n,i){const s=e.length;let a=0,c=0;for(let p=0;p<s;p++)a+=e[p],c+=n[p];if(a<c)return Number.POSITIVE_INFINITY;const d=a/c;i*=d;let h=0;for(let p=0;p<s;p++){const w=e[p],b=n[p]*d,A=w>b?w-b:b-w;if(A>i)return Number.POSITIVE_INFINITY;h+=A}return h/a}}class ge extends bt{static findStartPattern(e){const n=e.getSize(),i=e.getNextSet(0);let s=0,a=Int32Array.from([0,0,0,0,0,0]),c=i,d=!1;const h=6;for(let p=i;p<n;p++)if(e.get(p)!==d)a[s]++;else{if(s===h-1){let w=ge.MAX_AVG_VARIANCE,b=-1;for(let A=ge.CODE_START_A;A<=ge.CODE_START_C;A++){const N=bt.patternMatchVariance(a,ge.CODE_PATTERNS[A],ge.MAX_INDIVIDUAL_VARIANCE);N<w&&(w=N,b=A)}if(b>=0&&e.isRange(Math.max(0,c-(p-c)/2),c,!1))return Int32Array.from([c,p,b]);c+=a[0]+a[1],a=a.slice(2,a.length-1),a[s-1]=0,a[s]=0,s--}else s++;a[s]=1,d=!d}throw new L}static decodeCode(e,n,i){bt.recordPattern(e,i,n);let s=ge.MAX_AVG_VARIANCE,a=-1;for(let c=0;c<ge.CODE_PATTERNS.length;c++){const d=ge.CODE_PATTERNS[c],h=this.patternMatchVariance(n,d,ge.MAX_INDIVIDUAL_VARIANCE);h<s&&(s=h,a=c)}if(a>=0)return a;throw new L}decodeRow(e,n,i){const s=i&&i.get(Z.ASSUME_GS1)===!0,a=ge.findStartPattern(n),c=a[2];let d=0;const h=new Uint8Array(20);h[d++]=c;let p;switch(c){case ge.CODE_START_A:p=ge.CODE_CODE_A;break;case ge.CODE_START_B:p=ge.CODE_CODE_B;break;case ge.CODE_START_C:p=ge.CODE_CODE_C;break;default:throw new z}let w=!1,b=!1,A="",N=a[0],F=a[1];const $=Int32Array.from([0,0,0,0,0,0]);let j=0,q=0,se=c,ae=0,oe=!0,Ue=!1,Me=!1;for(;!w;){const wr=b;switch(b=!1,j=q,q=ge.decodeCode(n,$,F),h[d++]=q,q!==ge.CODE_STOP&&(oe=!0),q!==ge.CODE_STOP&&(ae++,se+=ae*q),N=F,F+=$.reduce((F1,$1)=>F1+$1,0),q){case ge.CODE_START_A:case ge.CODE_START_B:case ge.CODE_START_C:throw new z}switch(p){case ge.CODE_CODE_A:if(q<64)Me===Ue?A+=String.fromCharCode(32+q):A+=String.fromCharCode(32+q+128),Me=!1;else if(q<96)Me===Ue?A+=String.fromCharCode(q-64):A+=String.fromCharCode(q+64),Me=!1;else switch(q!==ge.CODE_STOP&&(oe=!1),q){case ge.CODE_FNC_1:s&&(A.length===0?A+="]C1":A+="");break;case ge.CODE_FNC_2:case ge.CODE_FNC_3:break;case ge.CODE_FNC_4_A:!Ue&&Me?(Ue=!0,Me=!1):Ue&&Me?(Ue=!1,Me=!1):Me=!0;break;case ge.CODE_SHIFT:b=!0,p=ge.CODE_CODE_B;break;case ge.CODE_CODE_B:p=ge.CODE_CODE_B;break;case ge.CODE_CODE_C:p=ge.CODE_CODE_C;break;case ge.CODE_STOP:w=!0;break}break;case ge.CODE_CODE_B:if(q<96)Me===Ue?A+=String.fromCharCode(32+q):A+=String.fromCharCode(32+q+128),Me=!1;else switch(q!==ge.CODE_STOP&&(oe=!1),q){case ge.CODE_FNC_1:s&&(A.length===0?A+="]C1":A+="");break;case ge.CODE_FNC_2:case ge.CODE_FNC_3:break;case ge.CODE_FNC_4_B:!Ue&&Me?(Ue=!0,Me=!1):Ue&&Me?(Ue=!1,Me=!1):Me=!0;break;case ge.CODE_SHIFT:b=!0,p=ge.CODE_CODE_A;break;case ge.CODE_CODE_A:p=ge.CODE_CODE_A;break;case ge.CODE_CODE_C:p=ge.CODE_CODE_C;break;case ge.CODE_STOP:w=!0;break}break;case ge.CODE_CODE_C:if(q<100)q<10&&(A+="0"),A+=q;else switch(q!==ge.CODE_STOP&&(oe=!1),q){case ge.CODE_FNC_1:s&&(A.length===0?A+="]C1":A+="");break;case ge.CODE_CODE_A:p=ge.CODE_CODE_A;break;case ge.CODE_CODE_B:p=ge.CODE_CODE_B;break;case ge.CODE_STOP:w=!0;break}break}wr&&(p=p===ge.CODE_CODE_A?ge.CODE_CODE_B:ge.CODE_CODE_A)}const Qt=F-N;if(F=n.getNextUnset(F),!n.isRange(F,Math.min(n.getSize(),F+(F-N)/2),!1))throw new L;if(se-=ae*j,se%103!==j)throw new O;const xn=A.length;if(xn===0)throw new L;xn>0&&oe&&(p===ge.CODE_CODE_C?A=A.substring(0,xn-2):A=A.substring(0,xn-1));const en=(a[1]+a[0])/2,nt=N+Qt/2,Lt=h.length,nn=new Uint8Array(Lt);for(let wr=0;wr<Lt;wr++)nn[wr]=h[wr];const xr=[new Se(en,e),new Se(nt,e)];return new Ee(A,nn,0,xr,T.CODE_128,new Date().getTime())}}ge.CODE_PATTERNS=[Int32Array.from([2,1,2,2,2,2]),Int32Array.from([2,2,2,1,2,2]),Int32Array.from([2,2,2,2,2,1]),Int32Array.from([1,2,1,2,2,3]),Int32Array.from([1,2,1,3,2,2]),Int32Array.from([1,3,1,2,2,2]),Int32Array.from([1,2,2,2,1,3]),Int32Array.from([1,2,2,3,1,2]),Int32Array.from([1,3,2,2,1,2]),Int32Array.from([2,2,1,2,1,3]),Int32Array.from([2,2,1,3,1,2]),Int32Array.from([2,3,1,2,1,2]),Int32Array.from([1,1,2,2,3,2]),Int32Array.from([1,2,2,1,3,2]),Int32Array.from([1,2,2,2,3,1]),Int32Array.from([1,1,3,2,2,2]),Int32Array.from([1,2,3,1,2,2]),Int32Array.from([1,2,3,2,2,1]),Int32Array.from([2,2,3,2,1,1]),Int32Array.from([2,2,1,1,3,2]),Int32Array.from([2,2,1,2,3,1]),Int32Array.from([2,1,3,2,1,2]),Int32Array.from([2,2,3,1,1,2]),Int32Array.from([3,1,2,1,3,1]),Int32Array.from([3,1,1,2,2,2]),Int32Array.from([3,2,1,1,2,2]),Int32Array.from([3,2,1,2,2,1]),Int32Array.from([3,1,2,2,1,2]),Int32Array.from([3,2,2,1,1,2]),Int32Array.from([3,2,2,2,1,1]),Int32Array.from([2,1,2,1,2,3]),Int32Array.from([2,1,2,3,2,1]),Int32Array.from([2,3,2,1,2,1]),Int32Array.from([1,1,1,3,2,3]),Int32Array.from([1,3,1,1,2,3]),Int32Array.from([1,3,1,3,2,1]),Int32Array.from([1,1,2,3,1,3]),Int32Array.from([1,3,2,1,1,3]),Int32Array.from([1,3,2,3,1,1]),Int32Array.from([2,1,1,3,1,3]),Int32Array.from([2,3,1,1,1,3]),Int32Array.from([2,3,1,3,1,1]),Int32Array.from([1,1,2,1,3,3]),Int32Array.from([1,1,2,3,3,1]),Int32Array.from([1,3,2,1,3,1]),Int32Array.from([1,1,3,1,2,3]),Int32Array.from([1,1,3,3,2,1]),Int32Array.from([1,3,3,1,2,1]),Int32Array.from([3,1,3,1,2,1]),Int32Array.from([2,1,1,3,3,1]),Int32Array.from([2,3,1,1,3,1]),Int32Array.from([2,1,3,1,1,3]),Int32Array.from([2,1,3,3,1,1]),Int32Array.from([2,1,3,1,3,1]),Int32Array.from([3,1,1,1,2,3]),Int32Array.from([3,1,1,3,2,1]),Int32Array.from([3,3,1,1,2,1]),Int32Array.from([3,1,2,1,1,3]),Int32Array.from([3,1,2,3,1,1]),Int32Array.from([3,3,2,1,1,1]),Int32Array.from([3,1,4,1,1,1]),Int32Array.from([2,2,1,4,1,1]),Int32Array.from([4,3,1,1,1,1]),Int32Array.from([1,1,1,2,2,4]),Int32Array.from([1,1,1,4,2,2]),Int32Array.from([1,2,1,1,2,4]),Int32Array.from([1,2,1,4,2,1]),Int32Array.from([1,4,1,1,2,2]),Int32Array.from([1,4,1,2,2,1]),Int32Array.from([1,1,2,2,1,4]),Int32Array.from([1,1,2,4,1,2]),Int32Array.from([1,2,2,1,1,4]),Int32Array.from([1,2,2,4,1,1]),Int32Array.from([1,4,2,1,1,2]),Int32Array.from([1,4,2,2,1,1]),Int32Array.from([2,4,1,2,1,1]),Int32Array.from([2,2,1,1,1,4]),Int32Array.from([4,1,3,1,1,1]),Int32Array.from([2,4,1,1,1,2]),Int32Array.from([1,3,4,1,1,1]),Int32Array.from([1,1,1,2,4,2]),Int32Array.from([1,2,1,1,4,2]),Int32Array.from([1,2,1,2,4,1]),Int32Array.from([1,1,4,2,1,2]),Int32Array.from([1,2,4,1,1,2]),Int32Array.from([1,2,4,2,1,1]),Int32Array.from([4,1,1,2,1,2]),Int32Array.from([4,2,1,1,1,2]),Int32Array.from([4,2,1,2,1,1]),Int32Array.from([2,1,2,1,4,1]),Int32Array.from([2,1,4,1,2,1]),Int32Array.from([4,1,2,1,2,1]),Int32Array.from([1,1,1,1,4,3]),Int32Array.from([1,1,1,3,4,1]),Int32Array.from([1,3,1,1,4,1]),Int32Array.from([1,1,4,1,1,3]),Int32Array.from([1,1,4,3,1,1]),Int32Array.from([4,1,1,1,1,3]),Int32Array.from([4,1,1,3,1,1]),Int32Array.from([1,1,3,1,4,1]),Int32Array.from([1,1,4,1,3,1]),Int32Array.from([3,1,1,1,4,1]),Int32Array.from([4,1,1,1,3,1]),Int32Array.from([2,1,1,4,1,2]),Int32Array.from([2,1,1,2,1,4]),Int32Array.from([2,1,1,2,3,2]),Int32Array.from([2,3,3,1,1,1,2])],ge.MAX_AVG_VARIANCE=.25,ge.MAX_INDIVIDUAL_VARIANCE=.7,ge.CODE_SHIFT=98,ge.CODE_CODE_C=99,ge.CODE_CODE_B=100,ge.CODE_CODE_A=101,ge.CODE_FNC_1=102,ge.CODE_FNC_2=97,ge.CODE_FNC_3=96,ge.CODE_FNC_4_A=101,ge.CODE_FNC_4_B=100,ge.CODE_START_A=103,ge.CODE_START_B=104,ge.CODE_START_C=105,ge.CODE_STOP=106;class It extends bt{constructor(e=!1,n=!1){super(),this.usingCheckDigit=e,this.extendedMode=n,this.decodeRowResult="",this.counters=new Int32Array(9)}decodeRow(e,n,i){let s=this.counters;s.fill(0),this.decodeRowResult="";let a=It.findAsteriskPattern(n,s),c=n.getNextSet(a[1]),d=n.getSize(),h,p;do{It.recordPattern(n,c,s);let $=It.toNarrowWidePattern(s);if($<0)throw new L;h=It.patternToChar($),this.decodeRowResult+=h,p=c;for(let j of s)c+=j;c=n.getNextSet(c)}while(h!=="*");this.decodeRowResult=this.decodeRowResult.substring(0,this.decodeRowResult.length-1);let w=0;for(let $ of s)w+=$;let b=c-p-w;if(c!==d&&b*2<w)throw new L;if(this.usingCheckDigit){let $=this.decodeRowResult.length-1,j=0;for(let q=0;q<$;q++)j+=It.ALPHABET_STRING.indexOf(this.decodeRowResult.charAt(q));if(this.decodeRowResult.charAt($)!==It.ALPHABET_STRING.charAt(j%43))throw new O;this.decodeRowResult=this.decodeRowResult.substring(0,$)}if(this.decodeRowResult.length===0)throw new L;let A;this.extendedMode?A=It.decodeExtended(this.decodeRowResult):A=this.decodeRowResult;let N=(a[1]+a[0])/2,F=p+w/2;return new Ee(A,null,0,[new Se(N,e),new Se(F,e)],T.CODE_39,new Date().getTime())}static findAsteriskPattern(e,n){let i=e.getSize(),s=e.getNextSet(0),a=0,c=s,d=!1,h=n.length;for(let p=s;p<i;p++)if(e.get(p)!==d)n[a]++;else{if(a===h-1){if(this.toNarrowWidePattern(n)===It.ASTERISK_ENCODING&&e.isRange(Math.max(0,c-Math.floor((p-c)/2)),c,!1))return[c,p];c+=n[0]+n[1],n.copyWithin(0,2,2+a-1),n[a-1]=0,n[a]=0,a--}else a++;n[a]=1,d=!d}throw new L}static toNarrowWidePattern(e){let n=e.length,i=0,s;do{let a=2147483647;for(let h of e)h<a&&h>i&&(a=h);i=a,s=0;let c=0,d=0;for(let h=0;h<n;h++){let p=e[h];p>i&&(d|=1<<n-1-h,s++,c+=p)}if(s===3){for(let h=0;h<n&&s>0;h++){let p=e[h];if(p>i&&(s--,p*2>=c))return-1}return d}}while(s>3);return-1}static patternToChar(e){for(let n=0;n<It.CHARACTER_ENCODINGS.length;n++)if(It.CHARACTER_ENCODINGS[n]===e)return It.ALPHABET_STRING.charAt(n);if(e===It.ASTERISK_ENCODING)return"*";throw new L}static decodeExtended(e){let n=e.length,i="";for(let s=0;s<n;s++){let a=e.charAt(s);if(a==="+"||a==="$"||a==="%"||a==="/"){let c=e.charAt(s+1),d="\0";switch(a){case"+":if(c>="A"&&c<="Z")d=String.fromCharCode(c.charCodeAt(0)+32);else throw new z;break;case"$":if(c>="A"&&c<="Z")d=String.fromCharCode(c.charCodeAt(0)-64);else throw new z;break;case"%":if(c>="A"&&c<="E")d=String.fromCharCode(c.charCodeAt(0)-38);else if(c>="F"&&c<="J")d=String.fromCharCode(c.charCodeAt(0)-11);else if(c>="K"&&c<="O")d=String.fromCharCode(c.charCodeAt(0)+16);else if(c>="P"&&c<="T")d=String.fromCharCode(c.charCodeAt(0)+43);else if(c==="U")d="\0";else if(c==="V")d="@";else if(c==="W")d="`";else if(c==="X"||c==="Y"||c==="Z")d="";else throw new z;break;case"/":if(c>="A"&&c<="O")d=String.fromCharCode(c.charCodeAt(0)-32);else if(c==="Z")d=":";else throw new z;break}i+=d,s++}else i+=a}return i}}It.ALPHABET_STRING="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%",It.CHARACTER_ENCODINGS=[52,289,97,352,49,304,112,37,292,100,265,73,328,25,280,88,13,268,76,28,259,67,322,19,274,82,7,262,70,22,385,193,448,145,400,208,133,388,196,168,162,138,42],It.ASTERISK_ENCODING=148;class et extends bt{constructor(){super(...arguments),this.narrowLineWidth=-1}decodeRow(e,n,i){let s=this.decodeStart(n),a=this.decodeEnd(n),c=new Ce;et.decodeMiddle(n,s[1],a[0],c);let d=c.toString(),h=null;i!=null&&(h=i.get(Z.ALLOWED_LENGTHS)),h==null&&(h=et.DEFAULT_ALLOWED_LENGTHS);let p=d.length,w=!1,b=0;for(let F of h){if(p===F){w=!0;break}F>b&&(b=F)}if(!w&&p>b&&(w=!0),!w)throw new z;const A=[new Se(s[1],e),new Se(a[0],e)];return new Ee(d,null,0,A,T.ITF,new Date().getTime())}static decodeMiddle(e,n,i,s){let a=new Int32Array(10),c=new Int32Array(5),d=new Int32Array(5);for(a.fill(0),c.fill(0),d.fill(0);n<i;){bt.recordPattern(e,n,a);for(let p=0;p<5;p++){let w=2*p;c[p]=a[w],d[p]=a[w+1]}let h=et.decodeDigit(c);s.append(h.toString()),h=this.decodeDigit(d),s.append(h.toString()),a.forEach(function(p){n+=p})}}decodeStart(e){let n=et.skipWhiteSpace(e),i=et.findGuardPattern(e,n,et.START_PATTERN);return this.narrowLineWidth=(i[1]-i[0])/4,this.validateQuietZone(e,i[0]),i}validateQuietZone(e,n){let i=this.narrowLineWidth*10;i=i<n?i:n;for(let s=n-1;i>0&&s>=0&&!e.get(s);s--)i--;if(i!==0)throw new L}static skipWhiteSpace(e){const n=e.getSize(),i=e.getNextSet(0);if(i===n)throw new L;return i}decodeEnd(e){e.reverse();try{let n=et.skipWhiteSpace(e),i;try{i=et.findGuardPattern(e,n,et.END_PATTERN_REVERSED[0])}catch(a){a instanceof L&&(i=et.findGuardPattern(e,n,et.END_PATTERN_REVERSED[1]))}this.validateQuietZone(e,i[0]);let s=i[0];return i[0]=e.getSize()-i[1],i[1]=e.getSize()-s,i}finally{e.reverse()}}static findGuardPattern(e,n,i){let s=i.length,a=new Int32Array(s),c=e.getSize(),d=!1,h=0,p=n;a.fill(0);for(let w=n;w<c;w++)if(e.get(w)!==d)a[h]++;else{if(h===s-1){if(bt.patternMatchVariance(a,i,et.MAX_INDIVIDUAL_VARIANCE)<et.MAX_AVG_VARIANCE)return[p,w];p+=a[0]+a[1],R.arraycopy(a,2,a,0,h-1),a[h-1]=0,a[h]=0,h--}else h++;a[h]=1,d=!d}throw new L}static decodeDigit(e){let n=et.MAX_AVG_VARIANCE,i=-1,s=et.PATTERNS.length;for(let a=0;a<s;a++){let c=et.PATTERNS[a],d=bt.patternMatchVariance(e,c,et.MAX_INDIVIDUAL_VARIANCE);d<n?(n=d,i=a):d===n&&(i=-1)}if(i>=0)return i%10;throw new L}}et.PATTERNS=[Int32Array.from([1,1,2,2,1]),Int32Array.from([2,1,1,1,2]),Int32Array.from([1,2,1,1,2]),Int32Array.from([2,2,1,1,1]),Int32Array.from([1,1,2,1,2]),Int32Array.from([2,1,2,1,1]),Int32Array.from([1,2,2,1,1]),Int32Array.from([1,1,1,2,2]),Int32Array.from([2,1,1,2,1]),Int32Array.from([1,2,1,2,1]),Int32Array.from([1,1,3,3,1]),Int32Array.from([3,1,1,1,3]),Int32Array.from([1,3,1,1,3]),Int32Array.from([3,3,1,1,1]),Int32Array.from([1,1,3,1,3]),Int32Array.from([3,1,3,1,1]),Int32Array.from([1,3,3,1,1]),Int32Array.from([1,1,1,3,3]),Int32Array.from([3,1,1,3,1]),Int32Array.from([1,3,1,3,1])],et.MAX_AVG_VARIANCE=.38,et.MAX_INDIVIDUAL_VARIANCE=.5,et.DEFAULT_ALLOWED_LENGTHS=[6,8,10,12,14],et.START_PATTERN=Int32Array.from([1,1,1,1]),et.END_PATTERN_REVERSED=[Int32Array.from([1,1,2]),Int32Array.from([1,1,3])];class xt extends bt{constructor(){super(...arguments),this.decodeRowStringBuffer=""}static findStartGuardPattern(e){let n=!1,i,s=0,a=Int32Array.from([0,0,0]);for(;!n;){a=Int32Array.from([0,0,0]),i=xt.findGuardPattern(e,s,!1,this.START_END_PATTERN,a);let c=i[0];s=i[1];let d=c-(s-c);d>=0&&(n=e.isRange(d,c,!1))}return i}static checkChecksum(e){return xt.checkStandardUPCEANChecksum(e)}static checkStandardUPCEANChecksum(e){let n=e.length;if(n===0)return!1;let i=parseInt(e.charAt(n-1),10);return xt.getStandardUPCEANChecksum(e.substring(0,n-1))===i}static getStandardUPCEANChecksum(e){let n=e.length,i=0;for(let s=n-1;s>=0;s-=2){let a=e.charAt(s).charCodeAt(0)-48;if(a<0||a>9)throw new z;i+=a}i*=3;for(let s=n-2;s>=0;s-=2){let a=e.charAt(s).charCodeAt(0)-48;if(a<0||a>9)throw new z;i+=a}return(1e3-i)%10}static decodeEnd(e,n){return xt.findGuardPattern(e,n,!1,xt.START_END_PATTERN,new Int32Array(xt.START_END_PATTERN.length).fill(0))}static findGuardPatternWithoutCounters(e,n,i,s){return this.findGuardPattern(e,n,i,s,new Int32Array(s.length))}static findGuardPattern(e,n,i,s,a){let c=e.getSize();n=i?e.getNextUnset(n):e.getNextSet(n);let d=0,h=n,p=s.length,w=i;for(let b=n;b<c;b++)if(e.get(b)!==w)a[d]++;else{if(d===p-1){if(bt.patternMatchVariance(a,s,xt.MAX_INDIVIDUAL_VARIANCE)<xt.MAX_AVG_VARIANCE)return Int32Array.from([h,b]);h+=a[0]+a[1];let A=a.slice(2,a.length-1);for(let N=0;N<d-1;N++)a[N]=A[N];a[d-1]=0,a[d]=0,d--}else d++;a[d]=1,w=!w}throw new L}static decodeDigit(e,n,i,s){this.recordPattern(e,i,n);let a=this.MAX_AVG_VARIANCE,c=-1,d=s.length;for(let h=0;h<d;h++){let p=s[h],w=bt.patternMatchVariance(n,p,xt.MAX_INDIVIDUAL_VARIANCE);w<a&&(a=w,c=h)}if(c>=0)return c;throw new L}}xt.MAX_AVG_VARIANCE=.48,xt.MAX_INDIVIDUAL_VARIANCE=.7,xt.START_END_PATTERN=Int32Array.from([1,1,1]),xt.MIDDLE_PATTERN=Int32Array.from([1,1,1,1,1]),xt.END_PATTERN=Int32Array.from([1,1,1,1,1,1]),xt.L_PATTERNS=[Int32Array.from([3,2,1,1]),Int32Array.from([2,2,2,1]),Int32Array.from([2,1,2,2]),Int32Array.from([1,4,1,1]),Int32Array.from([1,1,3,2]),Int32Array.from([1,2,3,1]),Int32Array.from([1,1,1,4]),Int32Array.from([1,3,1,2]),Int32Array.from([1,2,1,3]),Int32Array.from([3,1,1,2])];class Sr{constructor(){this.CHECK_DIGIT_ENCODINGS=[24,20,18,17,12,6,3,10,9,5],this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(e,n,i){let s=this.decodeRowStringBuffer,a=this.decodeMiddle(n,i,s),c=s.toString(),d=Sr.parseExtensionString(c),h=[new Se((i[0]+i[1])/2,e),new Se(a,e)],p=new Ee(c,null,0,h,T.UPC_EAN_EXTENSION,new Date().getTime());return d!=null&&p.putAllMetadata(d),p}decodeMiddle(e,n,i){let s=this.decodeMiddleCounters;s[0]=0,s[1]=0,s[2]=0,s[3]=0;let a=e.getSize(),c=n[1],d=0;for(let p=0;p<5&&c<a;p++){let w=xt.decodeDigit(e,s,c,xt.L_AND_G_PATTERNS);i+=String.fromCharCode(48+w%10);for(let b of s)c+=b;w>=10&&(d|=1<<4-p),p!==4&&(c=e.getNextSet(c),c=e.getNextUnset(c))}if(i.length!==5)throw new L;let h=this.determineCheckDigit(d);if(Sr.extensionChecksum(i.toString())!==h)throw new L;return c}static extensionChecksum(e){let n=e.length,i=0;for(let s=n-2;s>=0;s-=2)i+=e.charAt(s).charCodeAt(0)-48;i*=3;for(let s=n-1;s>=0;s-=2)i+=e.charAt(s).charCodeAt(0)-48;return i*=3,i%10}determineCheckDigit(e){for(let n=0;n<10;n++)if(e===this.CHECK_DIGIT_ENCODINGS[n])return n;throw new L}static parseExtensionString(e){if(e.length!==5)return null;let n=Sr.parseExtension5String(e);return n==null?null:new Map([[we.SUGGESTED_PRICE,n]])}static parseExtension5String(e){let n;switch(e.charAt(0)){case"0":n="£";break;case"5":n="$";break;case"9":switch(e){case"90000":return null;case"99991":return"0.00";case"99990":return"Used"}n="";break;default:n="";break}let i=parseInt(e.substring(1)),s=(i/100).toString(),a=i%100,c=a<10?"0"+a:a.toString();return n+s+"."+c}}class Qi{constructor(){this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(e,n,i){let s=this.decodeRowStringBuffer,a=this.decodeMiddle(n,i,s),c=s.toString(),d=Qi.parseExtensionString(c),h=[new Se((i[0]+i[1])/2,e),new Se(a,e)],p=new Ee(c,null,0,h,T.UPC_EAN_EXTENSION,new Date().getTime());return d!=null&&p.putAllMetadata(d),p}decodeMiddle(e,n,i){let s=this.decodeMiddleCounters;s[0]=0,s[1]=0,s[2]=0,s[3]=0;let a=e.getSize(),c=n[1],d=0;for(let h=0;h<2&&c<a;h++){let p=xt.decodeDigit(e,s,c,xt.L_AND_G_PATTERNS);i+=String.fromCharCode(48+p%10);for(let w of s)c+=w;p>=10&&(d|=1<<1-h),h!==1&&(c=e.getNextSet(c),c=e.getNextUnset(c))}if(i.length!==2)throw new L;if(parseInt(i.toString())%4!==d)throw new L;return c}static parseExtensionString(e){return e.length!==2?null:new Map([[we.ISSUE_NUMBER,parseInt(e)]])}}class ys{static decodeRow(e,n,i){let s=xt.findGuardPattern(n,i,!1,this.EXTENSION_START_PATTERN,new Int32Array(this.EXTENSION_START_PATTERN.length).fill(0));try{return new Sr().decodeRow(e,n,s)}catch{return new Qi().decodeRow(e,n,s)}}}ys.EXTENSION_START_PATTERN=Int32Array.from([1,1,2]);class je extends xt{constructor(){super(),this.decodeRowStringBuffer="",je.L_AND_G_PATTERNS=je.L_PATTERNS.map(e=>Int32Array.from(e));for(let e=10;e<20;e++){let n=je.L_PATTERNS[e-10],i=new Int32Array(n.length);for(let s=0;s<n.length;s++)i[s]=n[n.length-s-1];je.L_AND_G_PATTERNS[e]=i}}decodeRow(e,n,i){let s=je.findStartGuardPattern(n),a=i==null?null:i.get(Z.NEED_RESULT_POINT_CALLBACK);if(a!=null){const oe=new Se((s[0]+s[1])/2,e);a.foundPossibleResultPoint(oe)}let c=this.decodeMiddle(n,s,this.decodeRowStringBuffer),d=c.rowOffset,h=c.resultString;if(a!=null){const oe=new Se(d,e);a.foundPossibleResultPoint(oe)}let p=this.decodeEnd(n,d);if(a!=null){const oe=new Se((p[0]+p[1])/2,e);a.foundPossibleResultPoint(oe)}let w=p[1],b=w+(w-p[0]);if(b>=n.getSize()||!n.isRange(w,b,!1))throw new L;let A=h.toString();if(A.length<8)throw new z;if(!je.checkChecksum(A))throw new O;let N=(s[1]+s[0])/2,F=(p[1]+p[0])/2,$=this.getBarcodeFormat(),j=[new Se(N,e),new Se(F,e)],q=new Ee(A,null,0,j,$,new Date().getTime()),se=0;try{let oe=ys.decodeRow(e,n,p[1]);q.putMetadata(we.UPC_EAN_EXTENSION,oe.getText()),q.putAllMetadata(oe.getResultMetadata()),q.addResultPoints(oe.getResultPoints()),se=oe.getText().length}catch{}let ae=i==null?null:i.get(Z.ALLOWED_EAN_EXTENSIONS);if(ae!=null){let oe=!1;for(let Ue in ae)if(se.toString()===Ue){oe=!0;break}if(!oe)throw new L}return q}decodeEnd(e,n){return je.findGuardPattern(e,n,!1,je.START_END_PATTERN,new Int32Array(je.START_END_PATTERN.length).fill(0))}static checkChecksum(e){return je.checkStandardUPCEANChecksum(e)}static checkStandardUPCEANChecksum(e){let n=e.length;if(n===0)return!1;let i=parseInt(e.charAt(n-1),10);return je.getStandardUPCEANChecksum(e.substring(0,n-1))===i}static getStandardUPCEANChecksum(e){let n=e.length,i=0;for(let s=n-1;s>=0;s-=2){let a=e.charAt(s).charCodeAt(0)-48;if(a<0||a>9)throw new z;i+=a}i*=3;for(let s=n-2;s>=0;s-=2){let a=e.charAt(s).charCodeAt(0)-48;if(a<0||a>9)throw new z;i+=a}return(1e3-i)%10}}class Qn extends je{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(e,n,i){let s=this.decodeMiddleCounters;s[0]=0,s[1]=0,s[2]=0,s[3]=0;let a=e.getSize(),c=n[1],d=0;for(let p=0;p<6&&c<a;p++){let w=je.decodeDigit(e,s,c,je.L_AND_G_PATTERNS);i+=String.fromCharCode(48+w%10);for(let b of s)c+=b;w>=10&&(d|=1<<5-p)}i=Qn.determineFirstDigit(i,d),c=je.findGuardPattern(e,c,!0,je.MIDDLE_PATTERN,new Int32Array(je.MIDDLE_PATTERN.length).fill(0))[1];for(let p=0;p<6&&c<a;p++){let w=je.decodeDigit(e,s,c,je.L_PATTERNS);i+=String.fromCharCode(48+w);for(let b of s)c+=b}return{rowOffset:c,resultString:i}}getBarcodeFormat(){return T.EAN_13}static determineFirstDigit(e,n){for(let i=0;i<10;i++)if(n===this.FIRST_DIGIT_ENCODINGS[i])return e=String.fromCharCode(48+i)+e,e;throw new L}}Qn.FIRST_DIGIT_ENCODINGS=[0,11,13,14,19,25,28,21,22,26];class _s extends je{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(e,n,i){const s=this.decodeMiddleCounters;s[0]=0,s[1]=0,s[2]=0,s[3]=0;let a=e.getSize(),c=n[1];for(let h=0;h<4&&c<a;h++){let p=je.decodeDigit(e,s,c,je.L_PATTERNS);i+=String.fromCharCode(48+p);for(let w of s)c+=w}c=je.findGuardPattern(e,c,!0,je.MIDDLE_PATTERN,new Int32Array(je.MIDDLE_PATTERN.length).fill(0))[1];for(let h=0;h<4&&c<a;h++){let p=je.decodeDigit(e,s,c,je.L_PATTERNS);i+=String.fromCharCode(48+p);for(let w of s)c+=w}return{rowOffset:c,resultString:i}}getBarcodeFormat(){return T.EAN_8}}class vs extends je{constructor(){super(...arguments),this.ean13Reader=new Qn}getBarcodeFormat(){return T.UPC_A}decode(e,n){return this.maybeReturnResult(this.ean13Reader.decode(e))}decodeRow(e,n,i){return this.maybeReturnResult(this.ean13Reader.decodeRow(e,n,i))}decodeMiddle(e,n,i){return this.ean13Reader.decodeMiddle(e,n,i)}maybeReturnResult(e){let n=e.getText();if(n.charAt(0)==="0"){let i=new Ee(n.substring(1),null,null,e.getResultPoints(),T.UPC_A);return e.getResultMetadata()!=null&&i.putAllMetadata(e.getResultMetadata()),i}else throw new L}reset(){this.ean13Reader.reset()}}class mn extends je{constructor(){super(),this.decodeMiddleCounters=new Int32Array(4)}decodeMiddle(e,n,i){const s=this.decodeMiddleCounters.map(p=>p);s[0]=0,s[1]=0,s[2]=0,s[3]=0;const a=e.getSize();let c=n[1],d=0;for(let p=0;p<6&&c<a;p++){const w=mn.decodeDigit(e,s,c,mn.L_AND_G_PATTERNS);i+=String.fromCharCode(48+w%10);for(let b of s)c+=b;w>=10&&(d|=1<<5-p)}let h=mn.determineNumSysAndCheckDigit(i,d);return{rowOffset:c,resultString:h}}decodeEnd(e,n){return mn.findGuardPatternWithoutCounters(e,n,!0,mn.MIDDLE_END_PATTERN)}checkChecksum(e){return je.checkChecksum(mn.convertUPCEtoUPCA(e))}static determineNumSysAndCheckDigit(e,n){for(let i=0;i<=1;i++)for(let s=0;s<10;s++)if(n===this.NUMSYS_AND_CHECK_DIGIT_PATTERNS[i][s]){let a=String.fromCharCode(48+i),c=String.fromCharCode(48+s);return a+e+c}throw L.getNotFoundInstance()}getBarcodeFormat(){return T.UPC_E}static convertUPCEtoUPCA(e){const n=e.slice(1,7).split("").map(a=>a.charCodeAt(0)),i=new Ce;i.append(e.charAt(0));let s=n[5];switch(s){case 0:case 1:case 2:i.appendChars(n,0,2),i.append(s),i.append("0000"),i.appendChars(n,2,3);break;case 3:i.appendChars(n,0,3),i.append("00000"),i.appendChars(n,3,2);break;case 4:i.appendChars(n,0,4),i.append("00000"),i.append(n[4]);break;default:i.appendChars(n,0,5),i.append("0000"),i.append(s);break}return e.length>=8&&i.append(e.charAt(7)),i.toString()}}mn.MIDDLE_END_PATTERN=Int32Array.from([1,1,1,1,1,1]),mn.NUMSYS_AND_CHECK_DIGIT_PATTERNS=[Int32Array.from([56,52,50,49,44,38,35,42,41,37]),Int32Array.from([7,11,13,14,19,25,28,21,22,26])];class eo extends bt{constructor(e){super();let n=e==null?null:e.get(Z.POSSIBLE_FORMATS),i=[];l(n)?(i.push(new Qn),i.push(new vs),i.push(new _s),i.push(new mn)):(n.indexOf(T.EAN_13)>-1&&i.push(new Qn),n.indexOf(T.UPC_A)>-1&&i.push(new vs),n.indexOf(T.EAN_8)>-1&&i.push(new _s),n.indexOf(T.UPC_E)>-1&&i.push(new mn)),this.readers=i}decodeRow(e,n,i){for(let s of this.readers)try{const a=s.decodeRow(e,n,i),c=a.getBarcodeFormat()===T.EAN_13&&a.getText().charAt(0)==="0",d=i==null?null:i.get(Z.POSSIBLE_FORMATS),h=d==null||d.includes(T.UPC_A);if(c&&h){const p=a.getRawBytes(),w=new Ee(a.getText().substring(1),p,p?p.length:null,a.getResultPoints(),T.UPC_A);return w.putAllMetadata(a.getResultMetadata()),w}return a}catch{}throw new L}reset(){for(let e of this.readers)e.reset()}}class Ut extends bt{constructor(){super(),this.decodeFinderCounters=new Int32Array(4),this.dataCharacterCounters=new Int32Array(8),this.oddRoundingErrors=new Array(4),this.evenRoundingErrors=new Array(4),this.oddCounts=new Array(this.dataCharacterCounters.length/2),this.evenCounts=new Array(this.dataCharacterCounters.length/2)}getDecodeFinderCounters(){return this.decodeFinderCounters}getDataCharacterCounters(){return this.dataCharacterCounters}getOddRoundingErrors(){return this.oddRoundingErrors}getEvenRoundingErrors(){return this.evenRoundingErrors}getOddCounts(){return this.oddCounts}getEvenCounts(){return this.evenCounts}parseFinderValue(e,n){for(let i=0;i<n.length;i++)if(bt.patternMatchVariance(e,n[i],Ut.MAX_INDIVIDUAL_VARIANCE)<Ut.MAX_AVG_VARIANCE)return i;throw new L}static count(e){return ze.sum(new Int32Array(e))}static increment(e,n){let i=0,s=n[0];for(let a=1;a<e.length;a++)n[a]>s&&(s=n[a],i=a);e[i]++}static decrement(e,n){let i=0,s=n[0];for(let a=1;a<e.length;a++)n[a]<s&&(s=n[a],i=a);e[i]--}static isFinderPattern(e){let n=e[0]+e[1],i=n+e[2]+e[3],s=n/i;if(s>=Ut.MIN_FINDER_PATTERN_RATIO&&s<=Ut.MAX_FINDER_PATTERN_RATIO){let a=Number.MAX_SAFE_INTEGER,c=Number.MIN_SAFE_INTEGER;for(let d of e)d>c&&(c=d),d<a&&(a=d);return c<10*a}return!1}}Ut.MAX_AVG_VARIANCE=.2,Ut.MAX_INDIVIDUAL_VARIANCE=.45,Ut.MIN_FINDER_PATTERN_RATIO=9.5/12,Ut.MAX_FINDER_PATTERN_RATIO=12.5/14;class ur{constructor(e,n){this.value=e,this.checksumPortion=n}getValue(){return this.value}getChecksumPortion(){return this.checksumPortion}toString(){return this.value+"("+this.checksumPortion+")"}equals(e){if(!(e instanceof ur))return!1;const n=e;return this.value===n.value&&this.checksumPortion===n.checksumPortion}hashCode(){return this.value^this.checksumPortion}}class li{constructor(e,n,i,s,a){this.value=e,this.startEnd=n,this.value=e,this.startEnd=n,this.resultPoints=new Array,this.resultPoints.push(new Se(i,a)),this.resultPoints.push(new Se(s,a))}getValue(){return this.value}getStartEnd(){return this.startEnd}getResultPoints(){return this.resultPoints}equals(e){if(!(e instanceof li))return!1;const n=e;return this.value===n.value}hashCode(){return this.value}}class In{constructor(){}static getRSSvalue(e,n,i){let s=0;for(let h of e)s+=h;let a=0,c=0,d=e.length;for(let h=0;h<d-1;h++){let p;for(p=1,c|=1<<h;p<e[h];p++,c&=~(1<<h)){let w=In.combins(s-p-1,d-h-2);if(i&&c===0&&s-p-(d-h-1)>=d-h-1&&(w-=In.combins(s-p-(d-h),d-h-2)),d-h-1>1){let b=0;for(let A=s-p-(d-h-2);A>n;A--)b+=In.combins(s-p-A-1,d-h-3);w-=b*(d-1-h)}else s-p>n&&w--;a+=w}s-=p}return a}static combins(e,n){let i,s;e-n>n?(s=n,i=e-n):(s=e-n,i=n);let a=1,c=1;for(let d=e;d>i;d--)a*=d,c<=s&&(a/=c,c++);for(;c<=s;)a/=c,c++;return a}}class u1{static buildBitArray(e){let n=e.length*2-1;e[e.length-1].getRightChar()==null&&(n-=1);let i=12*n,s=new J(i),a=0,d=e[0].getRightChar().getValue();for(let h=11;h>=0;--h)(d&1<<h)!=0&&s.set(a),a++;for(let h=1;h<e.length;++h){let p=e[h],w=p.getLeftChar().getValue();for(let b=11;b>=0;--b)(w&1<<b)!=0&&s.set(a),a++;if(p.getRightChar()!=null){let b=p.getRightChar().getValue();for(let A=11;A>=0;--A)(b&1<<A)!=0&&s.set(a),a++}}return s}}class er{constructor(e,n){n?this.decodedInformation=null:(this.finished=e,this.decodedInformation=n)}getDecodedInformation(){return this.decodedInformation}isFinished(){return this.finished}}class to{constructor(e){this.newPosition=e}getNewPosition(){return this.newPosition}}class Yt extends to{constructor(e,n){super(e),this.value=n}getValue(){return this.value}isFNC1(){return this.value===Yt.FNC1}}Yt.FNC1="$";class tr extends to{constructor(e,n,i){super(e),i?(this.remaining=!0,this.remainingValue=this.remainingValue):(this.remaining=!1,this.remainingValue=0),this.newString=n}getNewString(){return this.newString}isRemaining(){return this.remaining}getRemainingValue(){return this.remainingValue}}class cn extends to{constructor(e,n,i){if(super(e),n<0||n>10||i<0||i>10)throw new z;this.firstDigit=n,this.secondDigit=i}getFirstDigit(){return this.firstDigit}getSecondDigit(){return this.secondDigit}getValue(){return this.firstDigit*10+this.secondDigit}isFirstDigitFNC1(){return this.firstDigit===cn.FNC1}isSecondDigitFNC1(){return this.secondDigit===cn.FNC1}isAnyFNC1(){return this.firstDigit===cn.FNC1||this.secondDigit===cn.FNC1}}cn.FNC1=10;class Ae{constructor(){}static parseFieldsInGeneralPurpose(e){if(!e)return null;if(e.length<2)throw new L;let n=e.substring(0,2);for(let a of Ae.TWO_DIGIT_DATA_LENGTH)if(a[0]===n)return a[1]===Ae.VARIABLE_LENGTH?Ae.processVariableAI(2,a[2],e):Ae.processFixedAI(2,a[1],e);if(e.length<3)throw new L;let i=e.substring(0,3);for(let a of Ae.THREE_DIGIT_DATA_LENGTH)if(a[0]===i)return a[1]===Ae.VARIABLE_LENGTH?Ae.processVariableAI(3,a[2],e):Ae.processFixedAI(3,a[1],e);for(let a of Ae.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH)if(a[0]===i)return a[1]===Ae.VARIABLE_LENGTH?Ae.processVariableAI(4,a[2],e):Ae.processFixedAI(4,a[1],e);if(e.length<4)throw new L;let s=e.substring(0,4);for(let a of Ae.FOUR_DIGIT_DATA_LENGTH)if(a[0]===s)return a[1]===Ae.VARIABLE_LENGTH?Ae.processVariableAI(4,a[2],e):Ae.processFixedAI(4,a[1],e);throw new L}static processFixedAI(e,n,i){if(i.length<e)throw new L;let s=i.substring(0,e);if(i.length<e+n)throw new L;let a=i.substring(e,e+n),c=i.substring(e+n),d="("+s+")"+a,h=Ae.parseFieldsInGeneralPurpose(c);return h==null?d:d+h}static processVariableAI(e,n,i){let s=i.substring(0,e),a;i.length<e+n?a=i.length:a=e+n;let c=i.substring(e,a),d=i.substring(a),h="("+s+")"+c,p=Ae.parseFieldsInGeneralPurpose(d);return p==null?h:h+p}}Ae.VARIABLE_LENGTH=[],Ae.TWO_DIGIT_DATA_LENGTH=[["00",18],["01",14],["02",14],["10",Ae.VARIABLE_LENGTH,20],["11",6],["12",6],["13",6],["15",6],["17",6],["20",2],["21",Ae.VARIABLE_LENGTH,20],["22",Ae.VARIABLE_LENGTH,29],["30",Ae.VARIABLE_LENGTH,8],["37",Ae.VARIABLE_LENGTH,8],["90",Ae.VARIABLE_LENGTH,30],["91",Ae.VARIABLE_LENGTH,30],["92",Ae.VARIABLE_LENGTH,30],["93",Ae.VARIABLE_LENGTH,30],["94",Ae.VARIABLE_LENGTH,30],["95",Ae.VARIABLE_LENGTH,30],["96",Ae.VARIABLE_LENGTH,30],["97",Ae.VARIABLE_LENGTH,3],["98",Ae.VARIABLE_LENGTH,30],["99",Ae.VARIABLE_LENGTH,30]],Ae.THREE_DIGIT_DATA_LENGTH=[["240",Ae.VARIABLE_LENGTH,30],["241",Ae.VARIABLE_LENGTH,30],["242",Ae.VARIABLE_LENGTH,6],["250",Ae.VARIABLE_LENGTH,30],["251",Ae.VARIABLE_LENGTH,30],["253",Ae.VARIABLE_LENGTH,17],["254",Ae.VARIABLE_LENGTH,20],["400",Ae.VARIABLE_LENGTH,30],["401",Ae.VARIABLE_LENGTH,30],["402",17],["403",Ae.VARIABLE_LENGTH,30],["410",13],["411",13],["412",13],["413",13],["414",13],["420",Ae.VARIABLE_LENGTH,20],["421",Ae.VARIABLE_LENGTH,15],["422",3],["423",Ae.VARIABLE_LENGTH,15],["424",3],["425",3],["426",3]],Ae.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH=[["310",6],["311",6],["312",6],["313",6],["314",6],["315",6],["316",6],["320",6],["321",6],["322",6],["323",6],["324",6],["325",6],["326",6],["327",6],["328",6],["329",6],["330",6],["331",6],["332",6],["333",6],["334",6],["335",6],["336",6],["340",6],["341",6],["342",6],["343",6],["344",6],["345",6],["346",6],["347",6],["348",6],["349",6],["350",6],["351",6],["352",6],["353",6],["354",6],["355",6],["356",6],["357",6],["360",6],["361",6],["362",6],["363",6],["364",6],["365",6],["366",6],["367",6],["368",6],["369",6],["390",Ae.VARIABLE_LENGTH,15],["391",Ae.VARIABLE_LENGTH,18],["392",Ae.VARIABLE_LENGTH,15],["393",Ae.VARIABLE_LENGTH,18],["703",Ae.VARIABLE_LENGTH,30]],Ae.FOUR_DIGIT_DATA_LENGTH=[["7001",13],["7002",Ae.VARIABLE_LENGTH,30],["7003",10],["8001",14],["8002",Ae.VARIABLE_LENGTH,20],["8003",Ae.VARIABLE_LENGTH,30],["8004",Ae.VARIABLE_LENGTH,30],["8005",6],["8006",18],["8007",Ae.VARIABLE_LENGTH,30],["8008",Ae.VARIABLE_LENGTH,12],["8018",18],["8020",Ae.VARIABLE_LENGTH,25],["8100",6],["8101",10],["8102",2],["8110",Ae.VARIABLE_LENGTH,70],["8200",Ae.VARIABLE_LENGTH,70]];class dr{constructor(e){this.buffer=new Ce,this.information=e}decodeAllCodes(e,n){let i=n,s=null;do{let a=this.decodeGeneralPurposeField(i,s),c=Ae.parseFieldsInGeneralPurpose(a.getNewString());if(c!=null&&e.append(c),a.isRemaining()?s=""+a.getRemainingValue():s=null,i===a.getNewPosition())break;i=a.getNewPosition()}while(!0);return e.toString()}isStillNumeric(e){if(e+7>this.information.getSize())return e+4<=this.information.getSize();for(let n=e;n<e+3;++n)if(this.information.get(n))return!0;return this.information.get(e+3)}decodeNumeric(e){if(e+7>this.information.getSize()){let a=this.extractNumericValueFromBitArray(e,4);return a===0?new cn(this.information.getSize(),cn.FNC1,cn.FNC1):new cn(this.information.getSize(),a-1,cn.FNC1)}let n=this.extractNumericValueFromBitArray(e,7),i=(n-8)/11,s=(n-8)%11;return new cn(e+7,i,s)}extractNumericValueFromBitArray(e,n){return dr.extractNumericValueFromBitArray(this.information,e,n)}static extractNumericValueFromBitArray(e,n,i){let s=0;for(let a=0;a<i;++a)e.get(n+a)&&(s|=1<<i-a-1);return s}decodeGeneralPurposeField(e,n){this.buffer.setLengthToZero(),n!=null&&this.buffer.append(n),this.current.setPosition(e);let i=this.parseBlocks();return i!=null&&i.isRemaining()?new tr(this.current.getPosition(),this.buffer.toString(),i.getRemainingValue()):new tr(this.current.getPosition(),this.buffer.toString())}parseBlocks(){let e,n;do{let i=this.current.getPosition();if(this.current.isAlpha()?(n=this.parseAlphaBlock(),e=n.isFinished()):this.current.isIsoIec646()?(n=this.parseIsoIec646Block(),e=n.isFinished()):(n=this.parseNumericBlock(),e=n.isFinished()),!(i!==this.current.getPosition())&&!e)break}while(!e);return n.getDecodedInformation()}parseNumericBlock(){for(;this.isStillNumeric(this.current.getPosition());){let e=this.decodeNumeric(this.current.getPosition());if(this.current.setPosition(e.getNewPosition()),e.isFirstDigitFNC1()){let n;return e.isSecondDigitFNC1()?n=new tr(this.current.getPosition(),this.buffer.toString()):n=new tr(this.current.getPosition(),this.buffer.toString(),e.getSecondDigit()),new er(!0,n)}if(this.buffer.append(e.getFirstDigit()),e.isSecondDigitFNC1()){let n=new tr(this.current.getPosition(),this.buffer.toString());return new er(!0,n)}this.buffer.append(e.getSecondDigit())}return this.isNumericToAlphaNumericLatch(this.current.getPosition())&&(this.current.setAlpha(),this.current.incrementPosition(4)),new er(!1)}parseIsoIec646Block(){for(;this.isStillIsoIec646(this.current.getPosition());){let e=this.decodeIsoIec646(this.current.getPosition());if(this.current.setPosition(e.getNewPosition()),e.isFNC1()){let n=new tr(this.current.getPosition(),this.buffer.toString());return new er(!0,n)}this.buffer.append(e.getValue())}return this.isAlphaOr646ToNumericLatch(this.current.getPosition())?(this.current.incrementPosition(3),this.current.setNumeric()):this.isAlphaTo646ToAlphaLatch(this.current.getPosition())&&(this.current.getPosition()+5<this.information.getSize()?this.current.incrementPosition(5):this.current.setPosition(this.information.getSize()),this.current.setAlpha()),new er(!1)}parseAlphaBlock(){for(;this.isStillAlpha(this.current.getPosition());){let e=this.decodeAlphanumeric(this.current.getPosition());if(this.current.setPosition(e.getNewPosition()),e.isFNC1()){let n=new tr(this.current.getPosition(),this.buffer.toString());return new er(!0,n)}this.buffer.append(e.getValue())}return this.isAlphaOr646ToNumericLatch(this.current.getPosition())?(this.current.incrementPosition(3),this.current.setNumeric()):this.isAlphaTo646ToAlphaLatch(this.current.getPosition())&&(this.current.getPosition()+5<this.information.getSize()?this.current.incrementPosition(5):this.current.setPosition(this.information.getSize()),this.current.setIsoIec646()),new er(!1)}isStillIsoIec646(e){if(e+5>this.information.getSize())return!1;let n=this.extractNumericValueFromBitArray(e,5);if(n>=5&&n<16)return!0;if(e+7>this.information.getSize())return!1;let i=this.extractNumericValueFromBitArray(e,7);if(i>=64&&i<116)return!0;if(e+8>this.information.getSize())return!1;let s=this.extractNumericValueFromBitArray(e,8);return s>=232&&s<253}decodeIsoIec646(e){let n=this.extractNumericValueFromBitArray(e,5);if(n===15)return new Yt(e+5,Yt.FNC1);if(n>=5&&n<15)return new Yt(e+5,"0"+(n-5));let i=this.extractNumericValueFromBitArray(e,7);if(i>=64&&i<90)return new Yt(e+7,""+(i+1));if(i>=90&&i<116)return new Yt(e+7,""+(i+7));let s=this.extractNumericValueFromBitArray(e,8),a;switch(s){case 232:a="!";break;case 233:a='"';break;case 234:a="%";break;case 235:a="&";break;case 236:a="'";break;case 237:a="(";break;case 238:a=")";break;case 239:a="*";break;case 240:a="+";break;case 241:a=",";break;case 242:a="-";break;case 243:a=".";break;case 244:a="/";break;case 245:a=":";break;case 246:a=";";break;case 247:a="<";break;case 248:a="=";break;case 249:a=">";break;case 250:a="?";break;case 251:a="_";break;case 252:a=" ";break;default:throw new z}return new Yt(e+8,a)}isStillAlpha(e){if(e+5>this.information.getSize())return!1;let n=this.extractNumericValueFromBitArray(e,5);if(n>=5&&n<16)return!0;if(e+6>this.information.getSize())return!1;let i=this.extractNumericValueFromBitArray(e,6);return i>=16&&i<63}decodeAlphanumeric(e){let n=this.extractNumericValueFromBitArray(e,5);if(n===15)return new Yt(e+5,Yt.FNC1);if(n>=5&&n<15)return new Yt(e+5,"0"+(n-5));let i=this.extractNumericValueFromBitArray(e,6);if(i>=32&&i<58)return new Yt(e+6,""+(i+33));let s;switch(i){case 58:s="*";break;case 59:s=",";break;case 60:s="-";break;case 61:s=".";break;case 62:s="/";break;default:throw new ln("Decoding invalid alphanumeric value: "+i)}return new Yt(e+6,s)}isAlphaTo646ToAlphaLatch(e){if(e+1>this.information.getSize())return!1;for(let n=0;n<5&&n+e<this.information.getSize();++n)if(n===2){if(!this.information.get(e+2))return!1}else if(this.information.get(e+n))return!1;return!0}isAlphaOr646ToNumericLatch(e){if(e+3>this.information.getSize())return!1;for(let n=e;n<e+3;++n)if(this.information.get(n))return!1;return!0}isNumericToAlphaNumericLatch(e){if(e+1>this.information.getSize())return!1;for(let n=0;n<4&&n+e<this.information.getSize();++n)if(this.information.get(e+n))return!1;return!0}}class no{constructor(e){this.information=e,this.generalDecoder=new dr(e)}getInformation(){return this.information}getGeneralDecoder(){return this.generalDecoder}}class Kt extends no{constructor(e){super(e)}encodeCompressedGtin(e,n){e.append("(01)");let i=e.length();e.append("9"),this.encodeCompressedGtinWithoutAI(e,n,i)}encodeCompressedGtinWithoutAI(e,n,i){for(let s=0;s<4;++s){let a=this.getGeneralDecoder().extractNumericValueFromBitArray(n+10*s,10);a/100===0&&e.append("0"),a/10===0&&e.append("0"),e.append(a)}Kt.appendCheckDigit(e,i)}static appendCheckDigit(e,n){let i=0;for(let s=0;s<13;s++){let a=e.charAt(s+n).charCodeAt(0)-48;i+=(s&1)===0?3*a:a}i=10-i%10,i===10&&(i=0),e.append(i)}}Kt.GTIN_SIZE=40;class fr extends Kt{constructor(e){super(e)}parseInformation(){let e=new Ce;e.append("(01)");let n=e.length(),i=this.getGeneralDecoder().extractNumericValueFromBitArray(fr.HEADER_SIZE,4);return e.append(i),this.encodeCompressedGtinWithoutAI(e,fr.HEADER_SIZE+4,n),this.getGeneralDecoder().decodeAllCodes(e,fr.HEADER_SIZE+44)}}fr.HEADER_SIZE=4;class ci extends no{constructor(e){super(e)}parseInformation(){let e=new Ce;return this.getGeneralDecoder().decodeAllCodes(e,ci.HEADER_SIZE)}}ci.HEADER_SIZE=5;class ui extends Kt{constructor(e){super(e)}encodeCompressedWeight(e,n,i){let s=this.getGeneralDecoder().extractNumericValueFromBitArray(n,i);this.addWeightCode(e,s);let a=this.checkWeight(s),c=1e5;for(let d=0;d<5;++d)a/c===0&&e.append("0"),c/=10;e.append(a)}}class Sn extends ui{constructor(e){super(e)}parseInformation(){if(this.getInformation().getSize()!=Sn.HEADER_SIZE+ui.GTIN_SIZE+Sn.WEIGHT_SIZE)throw new L;let e=new Ce;return this.encodeCompressedGtin(e,Sn.HEADER_SIZE),this.encodeCompressedWeight(e,Sn.HEADER_SIZE+ui.GTIN_SIZE,Sn.WEIGHT_SIZE),e.toString()}}Sn.HEADER_SIZE=5,Sn.WEIGHT_SIZE=15;class d1 extends Sn{constructor(e){super(e)}addWeightCode(e,n){e.append("(3103)")}checkWeight(e){return e}}class f1 extends Sn{constructor(e){super(e)}addWeightCode(e,n){n<1e4?e.append("(3202)"):e.append("(3203)")}checkWeight(e){return e<1e4?e:e-1e4}}class Tn extends Kt{constructor(e){super(e)}parseInformation(){if(this.getInformation().getSize()<Tn.HEADER_SIZE+Kt.GTIN_SIZE)throw new L;let e=new Ce;this.encodeCompressedGtin(e,Tn.HEADER_SIZE);let n=this.getGeneralDecoder().extractNumericValueFromBitArray(Tn.HEADER_SIZE+Kt.GTIN_SIZE,Tn.LAST_DIGIT_SIZE);e.append("(392"),e.append(n),e.append(")");let i=this.getGeneralDecoder().decodeGeneralPurposeField(Tn.HEADER_SIZE+Kt.GTIN_SIZE+Tn.LAST_DIGIT_SIZE,null);return e.append(i.getNewString()),e.toString()}}Tn.HEADER_SIZE=8,Tn.LAST_DIGIT_SIZE=2;class jt extends Kt{constructor(e){super(e)}parseInformation(){if(this.getInformation().getSize()<jt.HEADER_SIZE+Kt.GTIN_SIZE)throw new L;let e=new Ce;this.encodeCompressedGtin(e,jt.HEADER_SIZE);let n=this.getGeneralDecoder().extractNumericValueFromBitArray(jt.HEADER_SIZE+Kt.GTIN_SIZE,jt.LAST_DIGIT_SIZE);e.append("(393"),e.append(n),e.append(")");let i=this.getGeneralDecoder().extractNumericValueFromBitArray(jt.HEADER_SIZE+Kt.GTIN_SIZE+jt.LAST_DIGIT_SIZE,jt.FIRST_THREE_DIGITS_SIZE);i/100==0&&e.append("0"),i/10==0&&e.append("0"),e.append(i);let s=this.getGeneralDecoder().decodeGeneralPurposeField(jt.HEADER_SIZE+Kt.GTIN_SIZE+jt.LAST_DIGIT_SIZE+jt.FIRST_THREE_DIGITS_SIZE,null);return e.append(s.getNewString()),e.toString()}}jt.HEADER_SIZE=8,jt.LAST_DIGIT_SIZE=2,jt.FIRST_THREE_DIGITS_SIZE=10;class ut extends ui{constructor(e,n,i){super(e),this.dateCode=i,this.firstAIdigits=n}parseInformation(){if(this.getInformation().getSize()!=ut.HEADER_SIZE+ut.GTIN_SIZE+ut.WEIGHT_SIZE+ut.DATE_SIZE)throw new L;let e=new Ce;return this.encodeCompressedGtin(e,ut.HEADER_SIZE),this.encodeCompressedWeight(e,ut.HEADER_SIZE+ut.GTIN_SIZE,ut.WEIGHT_SIZE),this.encodeCompressedDate(e,ut.HEADER_SIZE+ut.GTIN_SIZE+ut.WEIGHT_SIZE),e.toString()}encodeCompressedDate(e,n){let i=this.getGeneralDecoder().extractNumericValueFromBitArray(n,ut.DATE_SIZE);if(i==38400)return;e.append("("),e.append(this.dateCode),e.append(")");let s=i%32;i/=32;let a=i%12+1;i/=12;let c=i;c/10==0&&e.append("0"),e.append(c),a/10==0&&e.append("0"),e.append(a),s/10==0&&e.append("0"),e.append(s)}addWeightCode(e,n){e.append("("),e.append(this.firstAIdigits),e.append(n/1e5),e.append(")")}checkWeight(e){return e%1e5}}ut.HEADER_SIZE=8,ut.WEIGHT_SIZE=20,ut.DATE_SIZE=16;function bs(v){try{if(v.get(1))return new fr(v);if(!v.get(2))return new ci(v);switch(dr.extractNumericValueFromBitArray(v,1,4)){case 4:return new d1(v);case 5:return new f1(v)}switch(dr.extractNumericValueFromBitArray(v,1,5)){case 12:return new Tn(v);case 13:return new jt(v)}switch(dr.extractNumericValueFromBitArray(v,1,7)){case 56:return new ut(v,"310","11");case 57:return new ut(v,"320","11");case 58:return new ut(v,"310","13");case 59:return new ut(v,"320","13");case 60:return new ut(v,"310","15");case 61:return new ut(v,"320","15");case 62:return new ut(v,"310","17");case 63:return new ut(v,"320","17")}}catch(e){throw console.log(e),new ln("unknown decoder: "+v)}}class Vn{constructor(e,n,i,s){this.leftchar=e,this.rightchar=n,this.finderpattern=i,this.maybeLast=s}mayBeLast(){return this.maybeLast}getLeftChar(){return this.leftchar}getRightChar(){return this.rightchar}getFinderPattern(){return this.finderpattern}mustBeLast(){return this.rightchar==null}toString(){return"[ "+this.leftchar+", "+this.rightchar+" : "+(this.finderpattern==null?"null":this.finderpattern.getValue())+" ]"}static equals(e,n){return e instanceof Vn?Vn.equalsOrNull(e.leftchar,n.leftchar)&&Vn.equalsOrNull(e.rightchar,n.rightchar)&&Vn.equalsOrNull(e.finderpattern,n.finderpattern):!1}static equalsOrNull(e,n){return e===null?n===null:Vn.equals(e,n)}hashCode(){return this.leftchar.getValue()^this.rightchar.getValue()^this.finderpattern.getValue()}}class ro{constructor(e,n,i){this.pairs=e,this.rowNumber=n,this.wasReversed=i}getPairs(){return this.pairs}getRowNumber(){return this.rowNumber}isReversed(){return this.wasReversed}isEquivalent(e){return this.checkEqualitity(this,e)}toString(){return"{ "+this.pairs+" }"}equals(e,n){return e instanceof ro?this.checkEqualitity(e,n)&&e.wasReversed===n.wasReversed:!1}checkEqualitity(e,n){if(!e||!n)return;let i;return e.forEach((s,a)=>{n.forEach(c=>{s.getLeftChar().getValue()===c.getLeftChar().getValue()&&s.getRightChar().getValue()===c.getRightChar().getValue()&&s.getFinderPatter().getValue()===c.getFinderPatter().getValue()&&(i=!0)})}),i}}class re extends Ut{constructor(e){super(...arguments),this.pairs=new Array(re.MAX_PAIRS),this.rows=new Array,this.startEnd=[2],this.verbose=e===!0}decodeRow(e,n,i){this.pairs.length=0,this.startFromEven=!1;try{return re.constructResult(this.decodeRow2pairs(e,n))}catch(s){this.verbose&&console.log(s)}return this.pairs.length=0,this.startFromEven=!0,re.constructResult(this.decodeRow2pairs(e,n))}reset(){this.pairs.length=0,this.rows.length=0}decodeRow2pairs(e,n){let i=!1;for(;!i;)try{this.pairs.push(this.retrieveNextPair(n,this.pairs,e))}catch(a){if(a instanceof L){if(!this.pairs.length)throw new L;i=!0}}if(this.checkChecksum())return this.pairs;let s;if(this.rows.length?s=!0:s=!1,this.storeRow(e,!1),s){let a=this.checkRowsBoolean(!1);if(a!=null||(a=this.checkRowsBoolean(!0),a!=null))return a}throw new L}checkRowsBoolean(e){if(this.rows.length>25)return this.rows.length=0,null;this.pairs.length=0,e&&(this.rows=this.rows.reverse());let n=null;try{n=this.checkRows(new Array,0)}catch(i){this.verbose&&console.log(i)}return e&&(this.rows=this.rows.reverse()),n}checkRows(e,n){for(let i=n;i<this.rows.length;i++){let s=this.rows[i];this.pairs.length=0;for(let c of e)this.pairs.push(c.getPairs());if(this.pairs.push(s.getPairs()),!re.isValidSequence(this.pairs))continue;if(this.checkChecksum())return this.pairs;let a=new Array(e);a.push(s);try{return this.checkRows(a,i+1)}catch(c){this.verbose&&console.log(c)}}throw new L}static isValidSequence(e){for(let n of re.FINDER_PATTERN_SEQUENCES){if(e.length>n.length)continue;let i=!0;for(let s=0;s<e.length;s++)if(e[s].getFinderPattern().getValue()!=n[s]){i=!1;break}if(i)return!0}return!1}storeRow(e,n){let i=0,s=!1,a=!1;for(;i<this.rows.length;){let c=this.rows[i];if(c.getRowNumber()>e){a=c.isEquivalent(this.pairs);break}s=c.isEquivalent(this.pairs),i++}a||s||re.isPartialRow(this.pairs,this.rows)||(this.rows.push(i,new ro(this.pairs,e,n)),this.removePartialRows(this.pairs,this.rows))}removePartialRows(e,n){for(let i of n)if(i.getPairs().length!==e.length){for(let s of i.getPairs())for(let a of e)if(Vn.equals(s,a))break}}static isPartialRow(e,n){for(let i of n){let s=!0;for(let a of e){let c=!1;for(let d of i.getPairs())if(a.equals(d)){c=!0;break}if(!c){s=!1;break}}if(s)return!0}return!1}getRows(){return this.rows}static constructResult(e){let n=u1.buildBitArray(e),s=bs(n).parseInformation(),a=e[0].getFinderPattern().getResultPoints(),c=e[e.length-1].getFinderPattern().getResultPoints(),d=[a[0],a[1],c[0],c[1]];return new Ee(s,null,null,d,T.RSS_EXPANDED,null)}checkChecksum(){let e=this.pairs.get(0),n=e.getLeftChar(),i=e.getRightChar();if(i==null)return!1;let s=i.getChecksumPortion(),a=2;for(let d=1;d<this.pairs.size();++d){let h=this.pairs.get(d);s+=h.getLeftChar().getChecksumPortion(),a++;let p=h.getRightChar();p!=null&&(s+=p.getChecksumPortion(),a++)}return s%=211,211*(a-4)+s==n.getValue()}static getNextSecondBar(e,n){let i;return e.get(n)?(i=e.getNextUnset(n),i=e.getNextSet(i)):(i=e.getNextSet(n),i=e.getNextUnset(i)),i}retrieveNextPair(e,n,i){let s=n.length%2==0;this.startFromEven&&(s=!s);let a,c=!0,d=-1;do this.findNextPair(e,n,d),a=this.parseFoundFinderPattern(e,i,s),a==null?d=re.getNextSecondBar(e,this.startEnd[0]):c=!1;while(c);let h=this.decodeDataCharacter(e,a,s,!0);if(!this.isEmptyPair(n)&&n[n.length-1].mustBeLast())throw new L;let p;try{p=this.decodeDataCharacter(e,a,s,!1)}catch(w){p=null,this.verbose&&console.log(w)}return new Vn(h,p,a,!0)}isEmptyPair(e){return e.length===0}findNextPair(e,n,i){let s=this.getDecodeFinderCounters();s[0]=0,s[1]=0,s[2]=0,s[3]=0;let a=e.getSize(),c;i>=0?c=i:this.isEmptyPair(n)?c=0:c=n[n.length-1].getFinderPattern().getStartEnd()[1];let d=n.length%2!=0;this.startFromEven&&(d=!d);let h=!1;for(;c<a&&(h=!e.get(c),!!h);)c++;let p=0,w=c;for(let b=c;b<a;b++)if(e.get(b)!=h)s[p]++;else{if(p==3){if(d&&re.reverseCounters(s),re.isFinderPattern(s)){this.startEnd[0]=w,this.startEnd[1]=b;return}d&&re.reverseCounters(s),w+=s[0]+s[1],s[0]=s[2],s[1]=s[3],s[2]=0,s[3]=0,p--}else p++;s[p]=1,h=!h}throw new L}static reverseCounters(e){let n=e.length;for(let i=0;i<n/2;++i){let s=e[i];e[i]=e[n-i-1],e[n-i-1]=s}}parseFoundFinderPattern(e,n,i){let s,a,c;if(i){let p=this.startEnd[0]-1;for(;p>=0&&!e.get(p);)p--;p++,s=this.startEnd[0]-p,a=p,c=this.startEnd[1]}else a=this.startEnd[0],c=e.getNextUnset(this.startEnd[1]+1),s=c-this.startEnd[1];let d=this.getDecodeFinderCounters();R.arraycopy(d,0,d,1,d.length-1),d[0]=s;let h;try{h=this.parseFinderValue(d,re.FINDER_PATTERNS)}catch{return null}return new li(h,[a,c],a,c,n)}decodeDataCharacter(e,n,i,s){let a=this.getDataCharacterCounters();for(let nt=0;nt<a.length;nt++)a[nt]=0;if(s)re.recordPatternInReverse(e,n.getStartEnd()[0],a);else{re.recordPattern(e,n.getStartEnd()[1],a);for(let nt=0,Lt=a.length-1;nt<Lt;nt++,Lt--){let nn=a[nt];a[nt]=a[Lt],a[Lt]=nn}}let c=17,d=ze.sum(new Int32Array(a))/c,h=(n.getStartEnd()[1]-n.getStartEnd()[0])/15;if(Math.abs(d-h)/h>.3)throw new L;let p=this.getOddCounts(),w=this.getEvenCounts(),b=this.getOddRoundingErrors(),A=this.getEvenRoundingErrors();for(let nt=0;nt<a.length;nt++){let Lt=1*a[nt]/d,nn=Lt+.5;if(nn<1){if(Lt<.3)throw new L;nn=1}else if(nn>8){if(Lt>8.7)throw new L;nn=8}let xr=nt/2;(nt&1)==0?(p[xr]=nn,b[xr]=Lt-nn):(w[xr]=nn,A[xr]=Lt-nn)}this.adjustOddEvenCounts(c);let N=4*n.getValue()+(i?0:2)+(s?0:1)-1,F=0,$=0;for(let nt=p.length-1;nt>=0;nt--){if(re.isNotA1left(n,i,s)){let Lt=re.WEIGHTS[N][2*nt];$+=p[nt]*Lt}F+=p[nt]}let j=0;for(let nt=w.length-1;nt>=0;nt--)if(re.isNotA1left(n,i,s)){let Lt=re.WEIGHTS[N][2*nt+1];j+=w[nt]*Lt}let q=$+j;if((F&1)!=0||F>13||F<4)throw new L;let se=(13-F)/2,ae=re.SYMBOL_WIDEST[se],oe=9-ae,Ue=In.getRSSvalue(p,ae,!0),Me=In.getRSSvalue(w,oe,!1),Qt=re.EVEN_TOTAL_SUBSET[se],xn=re.GSUM[se],en=Ue*Qt+Me+xn;return new ur(en,q)}static isNotA1left(e,n,i){return!(e.getValue()==0&&n&&i)}adjustOddEvenCounts(e){let n=ze.sum(new Int32Array(this.getOddCounts())),i=ze.sum(new Int32Array(this.getEvenCounts())),s=!1,a=!1;n>13?a=!0:n<4&&(s=!0);let c=!1,d=!1;i>13?d=!0:i<4&&(c=!0);let h=n+i-e,p=(n&1)==1,w=(i&1)==0;if(h==1)if(p){if(w)throw new L;a=!0}else{if(!w)throw new L;d=!0}else if(h==-1)if(p){if(w)throw new L;s=!0}else{if(!w)throw new L;c=!0}else if(h==0){if(p){if(!w)throw new L;n<i?(s=!0,d=!0):(a=!0,c=!0)}else if(w)throw new L}else throw new L;if(s){if(a)throw new L;re.increment(this.getOddCounts(),this.getOddRoundingErrors())}if(a&&re.decrement(this.getOddCounts(),this.getOddRoundingErrors()),c){if(d)throw new L;re.increment(this.getEvenCounts(),this.getOddRoundingErrors())}d&&re.decrement(this.getEvenCounts(),this.getEvenRoundingErrors())}}re.SYMBOL_WIDEST=[7,5,4,3,1],re.EVEN_TOTAL_SUBSET=[4,20,52,104,204],re.GSUM=[0,348,1388,2948,3988],re.FINDER_PATTERNS=[Int32Array.from([1,8,4,1]),Int32Array.from([3,6,4,1]),Int32Array.from([3,4,6,1]),Int32Array.from([3,2,8,1]),Int32Array.from([2,6,5,1]),Int32Array.from([2,2,9,1])],re.WEIGHTS=[[1,3,9,27,81,32,96,77],[20,60,180,118,143,7,21,63],[189,145,13,39,117,140,209,205],[193,157,49,147,19,57,171,91],[62,186,136,197,169,85,44,132],[185,133,188,142,4,12,36,108],[113,128,173,97,80,29,87,50],[150,28,84,41,123,158,52,156],[46,138,203,187,139,206,196,166],[76,17,51,153,37,111,122,155],[43,129,176,106,107,110,119,146],[16,48,144,10,30,90,59,177],[109,116,137,200,178,112,125,164],[70,210,208,202,184,130,179,115],[134,191,151,31,93,68,204,190],[148,22,66,198,172,94,71,2],[6,18,54,162,64,192,154,40],[120,149,25,75,14,42,126,167],[79,26,78,23,69,207,199,175],[103,98,83,38,114,131,182,124],[161,61,183,127,170,88,53,159],[55,165,73,8,24,72,5,15],[45,135,194,160,58,174,100,89]],re.FINDER_PAT_A=0,re.FINDER_PAT_B=1,re.FINDER_PAT_C=2,re.FINDER_PAT_D=3,re.FINDER_PAT_E=4,re.FINDER_PAT_F=5,re.FINDER_PATTERN_SEQUENCES=[[re.FINDER_PAT_A,re.FINDER_PAT_A],[re.FINDER_PAT_A,re.FINDER_PAT_B,re.FINDER_PAT_B],[re.FINDER_PAT_A,re.FINDER_PAT_C,re.FINDER_PAT_B,re.FINDER_PAT_D],[re.FINDER_PAT_A,re.FINDER_PAT_E,re.FINDER_PAT_B,re.FINDER_PAT_D,re.FINDER_PAT_C],[re.FINDER_PAT_A,re.FINDER_PAT_E,re.FINDER_PAT_B,re.FINDER_PAT_D,re.FINDER_PAT_D,re.FINDER_PAT_F],[re.FINDER_PAT_A,re.FINDER_PAT_E,re.FINDER_PAT_B,re.FINDER_PAT_D,re.FINDER_PAT_E,re.FINDER_PAT_F,re.FINDER_PAT_F],[re.FINDER_PAT_A,re.FINDER_PAT_A,re.FINDER_PAT_B,re.FINDER_PAT_B,re.FINDER_PAT_C,re.FINDER_PAT_C,re.FINDER_PAT_D,re.FINDER_PAT_D],[re.FINDER_PAT_A,re.FINDER_PAT_A,re.FINDER_PAT_B,re.FINDER_PAT_B,re.FINDER_PAT_C,re.FINDER_PAT_C,re.FINDER_PAT_D,re.FINDER_PAT_E,re.FINDER_PAT_E],[re.FINDER_PAT_A,re.FINDER_PAT_A,re.FINDER_PAT_B,re.FINDER_PAT_B,re.FINDER_PAT_C,re.FINDER_PAT_C,re.FINDER_PAT_D,re.FINDER_PAT_E,re.FINDER_PAT_F,re.FINDER_PAT_F],[re.FINDER_PAT_A,re.FINDER_PAT_A,re.FINDER_PAT_B,re.FINDER_PAT_B,re.FINDER_PAT_C,re.FINDER_PAT_D,re.FINDER_PAT_D,re.FINDER_PAT_E,re.FINDER_PAT_E,re.FINDER_PAT_F,re.FINDER_PAT_F]],re.MAX_PAIRS=11;class h1 extends ur{constructor(e,n,i){super(e,n),this.count=0,this.finderPattern=i}getFinderPattern(){return this.finderPattern}getCount(){return this.count}incrementCount(){this.count++}}class wt extends Ut{constructor(){super(...arguments),this.possibleLeftPairs=[],this.possibleRightPairs=[]}decodeRow(e,n,i){const s=this.decodePair(n,!1,e,i);wt.addOrTally(this.possibleLeftPairs,s),n.reverse();let a=this.decodePair(n,!0,e,i);wt.addOrTally(this.possibleRightPairs,a),n.reverse();for(let c of this.possibleLeftPairs)if(c.getCount()>1){for(let d of this.possibleRightPairs)if(d.getCount()>1&&wt.checkChecksum(c,d))return wt.constructResult(c,d)}throw new L}static addOrTally(e,n){if(n==null)return;let i=!1;for(let s of e)if(s.getValue()===n.getValue()){s.incrementCount(),i=!0;break}i||e.push(n)}reset(){this.possibleLeftPairs.length=0,this.possibleRightPairs.length=0}static constructResult(e,n){let i=4537077*e.getValue()+n.getValue(),s=new String(i).toString(),a=new Ce;for(let p=13-s.length;p>0;p--)a.append("0");a.append(s);let c=0;for(let p=0;p<13;p++){let w=a.charAt(p).charCodeAt(0)-48;c+=(p&1)===0?3*w:w}c=10-c%10,c===10&&(c=0),a.append(c.toString());let d=e.getFinderPattern().getResultPoints(),h=n.getFinderPattern().getResultPoints();return new Ee(a.toString(),null,0,[d[0],d[1],h[0],h[1]],T.RSS_14,new Date().getTime())}static checkChecksum(e,n){let i=(e.getChecksumPortion()+16*n.getChecksumPortion())%79,s=9*e.getFinderPattern().getValue()+n.getFinderPattern().getValue();return s>72&&s--,s>8&&s--,i===s}decodePair(e,n,i,s){try{let a=this.findFinderPattern(e,n),c=this.parseFoundFinderPattern(e,i,n,a),d=s==null?null:s.get(Z.NEED_RESULT_POINT_CALLBACK);if(d!=null){let w=(a[0]+a[1])/2;n&&(w=e.getSize()-1-w),d.foundPossibleResultPoint(new Se(w,i))}let h=this.decodeDataCharacter(e,c,!0),p=this.decodeDataCharacter(e,c,!1);return new h1(1597*h.getValue()+p.getValue(),h.getChecksumPortion()+4*p.getChecksumPortion(),c)}catch{return null}}decodeDataCharacter(e,n,i){let s=this.getDataCharacterCounters();for(let j=0;j<s.length;j++)s[j]=0;if(i)bt.recordPatternInReverse(e,n.getStartEnd()[0],s);else{bt.recordPattern(e,n.getStartEnd()[1]+1,s);for(let j=0,q=s.length-1;j<q;j++,q--){let se=s[j];s[j]=s[q],s[q]=se}}let a=i?16:15,c=ze.sum(new Int32Array(s))/a,d=this.getOddCounts(),h=this.getEvenCounts(),p=this.getOddRoundingErrors(),w=this.getEvenRoundingErrors();for(let j=0;j<s.length;j++){let q=s[j]/c,se=Math.floor(q+.5);se<1?se=1:se>8&&(se=8);let ae=Math.floor(j/2);(j&1)===0?(d[ae]=se,p[ae]=q-se):(h[ae]=se,w[ae]=q-se)}this.adjustOddEvenCounts(i,a);let b=0,A=0;for(let j=d.length-1;j>=0;j--)A*=9,A+=d[j],b+=d[j];let N=0,F=0;for(let j=h.length-1;j>=0;j--)N*=9,N+=h[j],F+=h[j];let $=A+3*N;if(i){if((b&1)!==0||b>12||b<4)throw new L;let j=(12-b)/2,q=wt.OUTSIDE_ODD_WIDEST[j],se=9-q,ae=In.getRSSvalue(d,q,!1),oe=In.getRSSvalue(h,se,!0),Ue=wt.OUTSIDE_EVEN_TOTAL_SUBSET[j],Me=wt.OUTSIDE_GSUM[j];return new ur(ae*Ue+oe+Me,$)}else{if((F&1)!==0||F>10||F<4)throw new L;let j=(10-F)/2,q=wt.INSIDE_ODD_WIDEST[j],se=9-q,ae=In.getRSSvalue(d,q,!0),oe=In.getRSSvalue(h,se,!1),Ue=wt.INSIDE_ODD_TOTAL_SUBSET[j],Me=wt.INSIDE_GSUM[j];return new ur(oe*Ue+ae+Me,$)}}findFinderPattern(e,n){let i=this.getDecodeFinderCounters();i[0]=0,i[1]=0,i[2]=0,i[3]=0;let s=e.getSize(),a=!1,c=0;for(;c<s&&(a=!e.get(c),n!==a);)c++;let d=0,h=c;for(let p=c;p<s;p++)if(e.get(p)!==a)i[d]++;else{if(d===3){if(Ut.isFinderPattern(i))return[h,p];h+=i[0]+i[1],i[0]=i[2],i[1]=i[3],i[2]=0,i[3]=0,d--}else d++;i[d]=1,a=!a}throw new L}parseFoundFinderPattern(e,n,i,s){let a=e.get(s[0]),c=s[0]-1;for(;c>=0&&a!==e.get(c);)c--;c++;const d=s[0]-c,h=this.getDecodeFinderCounters(),p=new Int32Array(h.length);R.arraycopy(h,0,p,1,h.length-1),p[0]=d;const w=this.parseFinderValue(p,wt.FINDER_PATTERNS);let b=c,A=s[1];return i&&(b=e.getSize()-1-b,A=e.getSize()-1-A),new li(w,[c,s[1]],b,A,n)}adjustOddEvenCounts(e,n){let i=ze.sum(new Int32Array(this.getOddCounts())),s=ze.sum(new Int32Array(this.getEvenCounts())),a=!1,c=!1,d=!1,h=!1;e?(i>12?c=!0:i<4&&(a=!0),s>12?h=!0:s<4&&(d=!0)):(i>11?c=!0:i<5&&(a=!0),s>10?h=!0:s<4&&(d=!0));let p=i+s-n,w=(i&1)===(e?1:0),b=(s&1)===1;if(p===1)if(w){if(b)throw new L;c=!0}else{if(!b)throw new L;h=!0}else if(p===-1)if(w){if(b)throw new L;a=!0}else{if(!b)throw new L;d=!0}else if(p===0){if(w){if(!b)throw new L;i<s?(a=!0,h=!0):(c=!0,d=!0)}else if(b)throw new L}else throw new L;if(a){if(c)throw new L;Ut.increment(this.getOddCounts(),this.getOddRoundingErrors())}if(c&&Ut.decrement(this.getOddCounts(),this.getOddRoundingErrors()),d){if(h)throw new L;Ut.increment(this.getEvenCounts(),this.getOddRoundingErrors())}h&&Ut.decrement(this.getEvenCounts(),this.getEvenRoundingErrors())}}wt.OUTSIDE_EVEN_TOTAL_SUBSET=[1,10,34,70,126],wt.INSIDE_ODD_TOTAL_SUBSET=[4,20,48,81],wt.OUTSIDE_GSUM=[0,161,961,2015,2715],wt.INSIDE_GSUM=[0,336,1036,1516],wt.OUTSIDE_ODD_WIDEST=[8,6,4,3,1],wt.INSIDE_ODD_WIDEST=[2,4,6,8],wt.FINDER_PATTERNS=[Int32Array.from([3,8,2,1]),Int32Array.from([3,5,5,1]),Int32Array.from([3,3,7,1]),Int32Array.from([3,1,9,1]),Int32Array.from([2,7,4,1]),Int32Array.from([2,5,6,1]),Int32Array.from([2,3,8,1]),Int32Array.from([1,5,7,1]),Int32Array.from([1,3,9,1])];class hr extends bt{constructor(e,n){super(),this.readers=[],this.verbose=n===!0;const i=e?e.get(Z.POSSIBLE_FORMATS):null,s=e&&e.get(Z.ASSUME_CODE_39_CHECK_DIGIT)!==void 0;i?((i.includes(T.EAN_13)||i.includes(T.UPC_A)||i.includes(T.EAN_8)||i.includes(T.UPC_E))&&this.readers.push(new eo(e)),i.includes(T.CODE_39)&&this.readers.push(new It(s)),i.includes(T.CODE_128)&&this.readers.push(new ge),i.includes(T.ITF)&&this.readers.push(new et),i.includes(T.RSS_14)&&this.readers.push(new wt),i.includes(T.RSS_EXPANDED)&&this.readers.push(new re(this.verbose))):(this.readers.push(new eo(e)),this.readers.push(new It),this.readers.push(new eo(e)),this.readers.push(new ge),this.readers.push(new et),this.readers.push(new wt),this.readers.push(new re(this.verbose)))}decodeRow(e,n,i){for(let s=0;s<this.readers.length;s++)try{return this.readers[s].decodeRow(e,n,i)}catch{}throw new L}reset(){this.readers.forEach(e=>e.reset())}}class p1 extends he{constructor(e=500,n){super(new hr(n),e,n)}}class Ge{constructor(e,n,i){this.ecCodewords=e,this.ecBlocks=[n],i&&this.ecBlocks.push(i)}getECCodewords(){return this.ecCodewords}getECBlocks(){return this.ecBlocks}}class He{constructor(e,n){this.count=e,this.dataCodewords=n}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class Ve{constructor(e,n,i,s,a,c){this.versionNumber=e,this.symbolSizeRows=n,this.symbolSizeColumns=i,this.dataRegionSizeRows=s,this.dataRegionSizeColumns=a,this.ecBlocks=c;let d=0;const h=c.getECCodewords(),p=c.getECBlocks();for(let w of p)d+=w.getCount()*(w.getDataCodewords()+h);this.totalCodewords=d}getVersionNumber(){return this.versionNumber}getSymbolSizeRows(){return this.symbolSizeRows}getSymbolSizeColumns(){return this.symbolSizeColumns}getDataRegionSizeRows(){return this.dataRegionSizeRows}getDataRegionSizeColumns(){return this.dataRegionSizeColumns}getTotalCodewords(){return this.totalCodewords}getECBlocks(){return this.ecBlocks}static getVersionForDimensions(e,n){if((e&1)!==0||(n&1)!==0)throw new z;for(let i of Ve.VERSIONS)if(i.symbolSizeRows===e&&i.symbolSizeColumns===n)return i;throw new z}toString(){return""+this.versionNumber}static buildVersions(){return[new Ve(1,10,10,8,8,new Ge(5,new He(1,3))),new Ve(2,12,12,10,10,new Ge(7,new He(1,5))),new Ve(3,14,14,12,12,new Ge(10,new He(1,8))),new Ve(4,16,16,14,14,new Ge(12,new He(1,12))),new Ve(5,18,18,16,16,new Ge(14,new He(1,18))),new Ve(6,20,20,18,18,new Ge(18,new He(1,22))),new Ve(7,22,22,20,20,new Ge(20,new He(1,30))),new Ve(8,24,24,22,22,new Ge(24,new He(1,36))),new Ve(9,26,26,24,24,new Ge(28,new He(1,44))),new Ve(10,32,32,14,14,new Ge(36,new He(1,62))),new Ve(11,36,36,16,16,new Ge(42,new He(1,86))),new Ve(12,40,40,18,18,new Ge(48,new He(1,114))),new Ve(13,44,44,20,20,new Ge(56,new He(1,144))),new Ve(14,48,48,22,22,new Ge(68,new He(1,174))),new Ve(15,52,52,24,24,new Ge(42,new He(2,102))),new Ve(16,64,64,14,14,new Ge(56,new He(2,140))),new Ve(17,72,72,16,16,new Ge(36,new He(4,92))),new Ve(18,80,80,18,18,new Ge(48,new He(4,114))),new Ve(19,88,88,20,20,new Ge(56,new He(4,144))),new Ve(20,96,96,22,22,new Ge(68,new He(4,174))),new Ve(21,104,104,24,24,new Ge(56,new He(6,136))),new Ve(22,120,120,18,18,new Ge(68,new He(6,175))),new Ve(23,132,132,20,20,new Ge(62,new He(8,163))),new Ve(24,144,144,22,22,new Ge(62,new He(8,156),new He(2,155))),new Ve(25,8,18,6,16,new Ge(7,new He(1,5))),new Ve(26,8,32,6,14,new Ge(11,new He(1,10))),new Ve(27,12,26,10,24,new Ge(14,new He(1,16))),new Ve(28,12,36,10,16,new Ge(18,new He(1,22))),new Ve(29,16,36,14,16,new Ge(24,new He(1,32))),new Ve(30,16,48,14,22,new Ge(28,new He(1,49)))]}}Ve.VERSIONS=Ve.buildVersions();class io{constructor(e){const n=e.getHeight();if(n<8||n>144||(n&1)!==0)throw new z;this.version=io.readVersion(e),this.mappingBitMatrix=this.extractDataRegion(e),this.readMappingMatrix=new le(this.mappingBitMatrix.getWidth(),this.mappingBitMatrix.getHeight())}getVersion(){return this.version}static readVersion(e){const n=e.getHeight(),i=e.getWidth();return Ve.getVersionForDimensions(n,i)}readCodewords(){const e=new Int8Array(this.version.getTotalCodewords());let n=0,i=4,s=0;const a=this.mappingBitMatrix.getHeight(),c=this.mappingBitMatrix.getWidth();let d=!1,h=!1,p=!1,w=!1;do if(i===a&&s===0&&!d)e[n++]=this.readCorner1(a,c)&255,i-=2,s+=2,d=!0;else if(i===a-2&&s===0&&(c&3)!==0&&!h)e[n++]=this.readCorner2(a,c)&255,i-=2,s+=2,h=!0;else if(i===a+4&&s===2&&(c&7)===0&&!p)e[n++]=this.readCorner3(a,c)&255,i-=2,s+=2,p=!0;else if(i===a-2&&s===0&&(c&7)===4&&!w)e[n++]=this.readCorner4(a,c)&255,i-=2,s+=2,w=!0;else{do i<a&&s>=0&&!this.readMappingMatrix.get(s,i)&&(e[n++]=this.readUtah(i,s,a,c)&255),i-=2,s+=2;while(i>=0&&s<c);i+=1,s+=3;do i>=0&&s<c&&!this.readMappingMatrix.get(s,i)&&(e[n++]=this.readUtah(i,s,a,c)&255),i+=2,s-=2;while(i<a&&s>=0);i+=3,s+=1}while(i<a||s<c);if(n!==this.version.getTotalCodewords())throw new z;return e}readModule(e,n,i,s){return e<0&&(e+=i,n+=4-(i+4&7)),n<0&&(n+=s,e+=4-(s+4&7)),this.readMappingMatrix.set(n,e),this.mappingBitMatrix.get(n,e)}readUtah(e,n,i,s){let a=0;return this.readModule(e-2,n-2,i,s)&&(a|=1),a<<=1,this.readModule(e-2,n-1,i,s)&&(a|=1),a<<=1,this.readModule(e-1,n-2,i,s)&&(a|=1),a<<=1,this.readModule(e-1,n-1,i,s)&&(a|=1),a<<=1,this.readModule(e-1,n,i,s)&&(a|=1),a<<=1,this.readModule(e,n-2,i,s)&&(a|=1),a<<=1,this.readModule(e,n-1,i,s)&&(a|=1),a<<=1,this.readModule(e,n,i,s)&&(a|=1),a}readCorner1(e,n){let i=0;return this.readModule(e-1,0,e,n)&&(i|=1),i<<=1,this.readModule(e-1,1,e,n)&&(i|=1),i<<=1,this.readModule(e-1,2,e,n)&&(i|=1),i<<=1,this.readModule(0,n-2,e,n)&&(i|=1),i<<=1,this.readModule(0,n-1,e,n)&&(i|=1),i<<=1,this.readModule(1,n-1,e,n)&&(i|=1),i<<=1,this.readModule(2,n-1,e,n)&&(i|=1),i<<=1,this.readModule(3,n-1,e,n)&&(i|=1),i}readCorner2(e,n){let i=0;return this.readModule(e-3,0,e,n)&&(i|=1),i<<=1,this.readModule(e-2,0,e,n)&&(i|=1),i<<=1,this.readModule(e-1,0,e,n)&&(i|=1),i<<=1,this.readModule(0,n-4,e,n)&&(i|=1),i<<=1,this.readModule(0,n-3,e,n)&&(i|=1),i<<=1,this.readModule(0,n-2,e,n)&&(i|=1),i<<=1,this.readModule(0,n-1,e,n)&&(i|=1),i<<=1,this.readModule(1,n-1,e,n)&&(i|=1),i}readCorner3(e,n){let i=0;return this.readModule(e-1,0,e,n)&&(i|=1),i<<=1,this.readModule(e-1,n-1,e,n)&&(i|=1),i<<=1,this.readModule(0,n-3,e,n)&&(i|=1),i<<=1,this.readModule(0,n-2,e,n)&&(i|=1),i<<=1,this.readModule(0,n-1,e,n)&&(i|=1),i<<=1,this.readModule(1,n-3,e,n)&&(i|=1),i<<=1,this.readModule(1,n-2,e,n)&&(i|=1),i<<=1,this.readModule(1,n-1,e,n)&&(i|=1),i}readCorner4(e,n){let i=0;return this.readModule(e-3,0,e,n)&&(i|=1),i<<=1,this.readModule(e-2,0,e,n)&&(i|=1),i<<=1,this.readModule(e-1,0,e,n)&&(i|=1),i<<=1,this.readModule(0,n-2,e,n)&&(i|=1),i<<=1,this.readModule(0,n-1,e,n)&&(i|=1),i<<=1,this.readModule(1,n-1,e,n)&&(i|=1),i<<=1,this.readModule(2,n-1,e,n)&&(i|=1),i<<=1,this.readModule(3,n-1,e,n)&&(i|=1),i}extractDataRegion(e){const n=this.version.getSymbolSizeRows(),i=this.version.getSymbolSizeColumns();if(e.getHeight()!==n)throw new C("Dimension of bitMatrix must match the version size");const s=this.version.getDataRegionSizeRows(),a=this.version.getDataRegionSizeColumns(),c=n/s|0,d=i/a|0,h=c*s,p=d*a,w=new le(p,h);for(let b=0;b<c;++b){const A=b*s;for(let N=0;N<d;++N){const F=N*a;for(let $=0;$<s;++$){const j=b*(s+2)+1+$,q=A+$;for(let se=0;se<a;++se){const ae=N*(a+2)+1+se;if(e.get(ae,j)){const oe=F+se;w.set(oe,q)}}}}}return w}}class oo{constructor(e,n){this.numDataCodewords=e,this.codewords=n}static getDataBlocks(e,n){const i=n.getECBlocks();let s=0;const a=i.getECBlocks();for(let $ of a)s+=$.getCount();const c=new Array(s);let d=0;for(let $ of a)for(let j=0;j<$.getCount();j++){const q=$.getDataCodewords(),se=i.getECCodewords()+q;c[d++]=new oo(q,new Uint8Array(se))}const p=c[0].codewords.length-i.getECCodewords(),w=p-1;let b=0;for(let $=0;$<w;$++)for(let j=0;j<d;j++)c[j].codewords[$]=e[b++];const A=n.getVersionNumber()===24,N=A?8:d;for(let $=0;$<N;$++)c[$].codewords[p-1]=e[b++];const F=c[0].codewords.length;for(let $=p;$<F;$++)for(let j=0;j<d;j++){const q=A?(j+8)%d:j,se=A&&q>7?$-1:$;c[q].codewords[se]=e[b++]}if(b!==e.length)throw new C;return c}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}class so{constructor(e){this.bytes=e,this.byteOffset=0,this.bitOffset=0}getBitOffset(){return this.bitOffset}getByteOffset(){return this.byteOffset}readBits(e){if(e<1||e>32||e>this.available())throw new C(""+e);let n=0,i=this.bitOffset,s=this.byteOffset;const a=this.bytes;if(i>0){const c=8-i,d=e<c?e:c,h=c-d,p=255>>8-d<<h;n=(a[s]&p)>>h,e-=d,i+=d,i===8&&(i=0,s++)}if(e>0){for(;e>=8;)n=n<<8|a[s]&255,s++,e-=8;if(e>0){const c=8-e,d=255>>c<<c;n=n<<e|(a[s]&d)>>c,i+=e}}return this.bitOffset=i,this.byteOffset=s,n}available(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset}}var St;(function(v){v[v.PAD_ENCODE=0]="PAD_ENCODE",v[v.ASCII_ENCODE=1]="ASCII_ENCODE",v[v.C40_ENCODE=2]="C40_ENCODE",v[v.TEXT_ENCODE=3]="TEXT_ENCODE",v[v.ANSIX12_ENCODE=4]="ANSIX12_ENCODE",v[v.EDIFACT_ENCODE=5]="EDIFACT_ENCODE",v[v.BASE256_ENCODE=6]="BASE256_ENCODE"})(St||(St={}));class Zn{static decode(e){const n=new so(e),i=new Ce,s=new Ce,a=new Array;let c=St.ASCII_ENCODE;do if(c===St.ASCII_ENCODE)c=this.decodeAsciiSegment(n,i,s);else{switch(c){case St.C40_ENCODE:this.decodeC40Segment(n,i);break;case St.TEXT_ENCODE:this.decodeTextSegment(n,i);break;case St.ANSIX12_ENCODE:this.decodeAnsiX12Segment(n,i);break;case St.EDIFACT_ENCODE:this.decodeEdifactSegment(n,i);break;case St.BASE256_ENCODE:this.decodeBase256Segment(n,i,a);break;default:throw new z}c=St.ASCII_ENCODE}while(c!==St.PAD_ENCODE&&n.available()>0);return s.length()>0&&i.append(s.toString()),new mt(e,i.toString(),a.length===0?null:a,null)}static decodeAsciiSegment(e,n,i){let s=!1;do{let a=e.readBits(8);if(a===0)throw new z;if(a<=128)return s&&(a+=128),n.append(String.fromCharCode(a-1)),St.ASCII_ENCODE;if(a===129)return St.PAD_ENCODE;if(a<=229){const c=a-130;c<10&&n.append("0"),n.append(""+c)}else switch(a){case 230:return St.C40_ENCODE;case 231:return St.BASE256_ENCODE;case 232:n.append("");break;case 233:case 234:break;case 235:s=!0;break;case 236:n.append("[)>05"),i.insert(0,"");break;case 237:n.append("[)>06"),i.insert(0,"");break;case 238:return St.ANSIX12_ENCODE;case 239:return St.TEXT_ENCODE;case 240:return St.EDIFACT_ENCODE;case 241:break;default:if(a!==254||e.available()!==0)throw new z;break}}while(e.available()>0);return St.ASCII_ENCODE}static decodeC40Segment(e,n){let i=!1;const s=[];let a=0;do{if(e.available()===8)return;const c=e.readBits(8);if(c===254)return;this.parseTwoBytes(c,e.readBits(8),s);for(let d=0;d<3;d++){const h=s[d];switch(a){case 0:if(h<3)a=h+1;else if(h<this.C40_BASIC_SET_CHARS.length){const p=this.C40_BASIC_SET_CHARS[h];i?(n.append(String.fromCharCode(p.charCodeAt(0)+128)),i=!1):n.append(p)}else throw new z;break;case 1:i?(n.append(String.fromCharCode(h+128)),i=!1):n.append(String.fromCharCode(h)),a=0;break;case 2:if(h<this.C40_SHIFT2_SET_CHARS.length){const p=this.C40_SHIFT2_SET_CHARS[h];i?(n.append(String.fromCharCode(p.charCodeAt(0)+128)),i=!1):n.append(p)}else switch(h){case 27:n.append("");break;case 30:i=!0;break;default:throw new z}a=0;break;case 3:i?(n.append(String.fromCharCode(h+224)),i=!1):n.append(String.fromCharCode(h+96)),a=0;break;default:throw new z}}}while(e.available()>0)}static decodeTextSegment(e,n){let i=!1,s=[],a=0;do{if(e.available()===8)return;const c=e.readBits(8);if(c===254)return;this.parseTwoBytes(c,e.readBits(8),s);for(let d=0;d<3;d++){const h=s[d];switch(a){case 0:if(h<3)a=h+1;else if(h<this.TEXT_BASIC_SET_CHARS.length){const p=this.TEXT_BASIC_SET_CHARS[h];i?(n.append(String.fromCharCode(p.charCodeAt(0)+128)),i=!1):n.append(p)}else throw new z;break;case 1:i?(n.append(String.fromCharCode(h+128)),i=!1):n.append(String.fromCharCode(h)),a=0;break;case 2:if(h<this.TEXT_SHIFT2_SET_CHARS.length){const p=this.TEXT_SHIFT2_SET_CHARS[h];i?(n.append(String.fromCharCode(p.charCodeAt(0)+128)),i=!1):n.append(p)}else switch(h){case 27:n.append("");break;case 30:i=!0;break;default:throw new z}a=0;break;case 3:if(h<this.TEXT_SHIFT3_SET_CHARS.length){const p=this.TEXT_SHIFT3_SET_CHARS[h];i?(n.append(String.fromCharCode(p.charCodeAt(0)+128)),i=!1):n.append(p),a=0}else throw new z;break;default:throw new z}}}while(e.available()>0)}static decodeAnsiX12Segment(e,n){const i=[];do{if(e.available()===8)return;const s=e.readBits(8);if(s===254)return;this.parseTwoBytes(s,e.readBits(8),i);for(let a=0;a<3;a++){const c=i[a];switch(c){case 0:n.append("\r");break;case 1:n.append("*");break;case 2:n.append(">");break;case 3:n.append(" ");break;default:if(c<14)n.append(String.fromCharCode(c+44));else if(c<40)n.append(String.fromCharCode(c+51));else throw new z;break}}}while(e.available()>0)}static parseTwoBytes(e,n,i){let s=(e<<8)+n-1,a=Math.floor(s/1600);i[0]=a,s-=a*1600,a=Math.floor(s/40),i[1]=a,i[2]=s-a*40}static decodeEdifactSegment(e,n){do{if(e.available()<=16)return;for(let i=0;i<4;i++){let s=e.readBits(6);if(s===31){const a=8-e.getBitOffset();a!==8&&e.readBits(a);return}(s&32)===0&&(s|=64),n.append(String.fromCharCode(s))}}while(e.available()>0)}static decodeBase256Segment(e,n,i){let s=1+e.getByteOffset();const a=this.unrandomize255State(e.readBits(8),s++);let c;if(a===0?c=e.available()/8|0:a<250?c=a:c=250*(a-249)+this.unrandomize255State(e.readBits(8),s++),c<0)throw new z;const d=new Uint8Array(c);for(let h=0;h<c;h++){if(e.available()<8)throw new z;d[h]=this.unrandomize255State(e.readBits(8),s++)}i.push(d);try{n.append(me.decode(d,pe.ISO88591))}catch(h){throw new ln("Platform does not support required encoding: "+h.message)}}static unrandomize255State(e,n){const i=149*n%255+1,s=e-i;return s>=0?s:s+256}}Zn.C40_BASIC_SET_CHARS=["*","*","*"," ","0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],Zn.C40_SHIFT2_SET_CHARS=["!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_"],Zn.TEXT_BASIC_SET_CHARS=["*","*","*"," ","0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],Zn.TEXT_SHIFT2_SET_CHARS=Zn.C40_SHIFT2_SET_CHARS,Zn.TEXT_SHIFT3_SET_CHARS=["`","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","{","|","}","~",""];class g1{constructor(){this.rsDecoder=new zn(Fe.DATA_MATRIX_FIELD_256)}decode(e){const n=new io(e),i=n.getVersion(),s=n.readCodewords(),a=oo.getDataBlocks(s,i);let c=0;for(let p of a)c+=p.getNumDataCodewords();const d=new Uint8Array(c),h=a.length;for(let p=0;p<h;p++){const w=a[p],b=w.getCodewords(),A=w.getNumDataCodewords();this.correctErrors(b,A);for(let N=0;N<A;N++)d[N*h+p]=b[N]}return Zn.decode(d)}correctErrors(e,n){const i=new Int32Array(e);try{this.rsDecoder.decode(i,e.length-n)}catch{throw new O}for(let s=0;s<n;s++)e[s]=i[s]}}class vt{constructor(e){this.image=e,this.rectangleDetector=new $e(this.image)}detect(){const e=this.rectangleDetector.detect();let n=this.detectSolid1(e);if(n=this.detectSolid2(n),n[3]=this.correctTopRight(n),!n[3])throw new L;n=this.shiftToModuleCenter(n);const i=n[0],s=n[1],a=n[2],c=n[3];let d=this.transitionsBetween(i,c)+1,h=this.transitionsBetween(a,c)+1;(d&1)===1&&(d+=1),(h&1)===1&&(h+=1),4*d<7*h&&4*h<7*d&&(d=h=Math.max(d,h));let p=vt.sampleGrid(this.image,i,s,a,c,d,h);return new cr(p,[i,s,a,c])}static shiftPoint(e,n,i){let s=(n.getX()-e.getX())/(i+1),a=(n.getY()-e.getY())/(i+1);return new Se(e.getX()+s,e.getY()+a)}static moveAway(e,n,i){let s=e.getX(),a=e.getY();return s<n?s-=1:s+=1,a<i?a-=1:a+=1,new Se(s,a)}detectSolid1(e){let n=e[0],i=e[1],s=e[3],a=e[2],c=this.transitionsBetween(n,i),d=this.transitionsBetween(i,s),h=this.transitionsBetween(s,a),p=this.transitionsBetween(a,n),w=c,b=[a,n,i,s];return w>d&&(w=d,b[0]=n,b[1]=i,b[2]=s,b[3]=a),w>h&&(w=h,b[0]=i,b[1]=s,b[2]=a,b[3]=n),w>p&&(b[0]=s,b[1]=a,b[2]=n,b[3]=i),b}detectSolid2(e){let n=e[0],i=e[1],s=e[2],a=e[3],c=this.transitionsBetween(n,a),d=vt.shiftPoint(i,s,(c+1)*4),h=vt.shiftPoint(s,i,(c+1)*4),p=this.transitionsBetween(d,n),w=this.transitionsBetween(h,a);return p<w?(e[0]=n,e[1]=i,e[2]=s,e[3]=a):(e[0]=i,e[1]=s,e[2]=a,e[3]=n),e}correctTopRight(e){let n=e[0],i=e[1],s=e[2],a=e[3],c=this.transitionsBetween(n,a),d=this.transitionsBetween(i,a),h=vt.shiftPoint(n,i,(d+1)*4),p=vt.shiftPoint(s,i,(c+1)*4);c=this.transitionsBetween(h,a),d=this.transitionsBetween(p,a);let w=new Se(a.getX()+(s.getX()-i.getX())/(c+1),a.getY()+(s.getY()-i.getY())/(c+1)),b=new Se(a.getX()+(n.getX()-i.getX())/(d+1),a.getY()+(n.getY()-i.getY())/(d+1));if(!this.isValid(w))return this.isValid(b)?b:null;if(!this.isValid(b))return w;let A=this.transitionsBetween(h,w)+this.transitionsBetween(p,w),N=this.transitionsBetween(h,b)+this.transitionsBetween(p,b);return A>N?w:b}shiftToModuleCenter(e){let n=e[0],i=e[1],s=e[2],a=e[3],c=this.transitionsBetween(n,a)+1,d=this.transitionsBetween(s,a)+1,h=vt.shiftPoint(n,i,d*4),p=vt.shiftPoint(s,i,c*4);c=this.transitionsBetween(h,a)+1,d=this.transitionsBetween(p,a)+1,(c&1)===1&&(c+=1),(d&1)===1&&(d+=1);let w=(n.getX()+i.getX()+s.getX()+a.getX())/4,b=(n.getY()+i.getY()+s.getY()+a.getY())/4;n=vt.moveAway(n,w,b),i=vt.moveAway(i,w,b),s=vt.moveAway(s,w,b),a=vt.moveAway(a,w,b);let A,N;return h=vt.shiftPoint(n,i,d*4),h=vt.shiftPoint(h,a,c*4),A=vt.shiftPoint(i,n,d*4),A=vt.shiftPoint(A,s,c*4),p=vt.shiftPoint(s,a,d*4),p=vt.shiftPoint(p,i,c*4),N=vt.shiftPoint(a,s,d*4),N=vt.shiftPoint(N,n,c*4),[h,A,p,N]}isValid(e){return e.getX()>=0&&e.getX()<this.image.getWidth()&&e.getY()>0&&e.getY()<this.image.getHeight()}static sampleGrid(e,n,i,s,a,c,d){return gn.getInstance().sampleGrid(e,c,d,.5,.5,c-.5,.5,c-.5,d-.5,.5,d-.5,n.getX(),n.getY(),a.getX(),a.getY(),s.getX(),s.getY(),i.getX(),i.getY())}transitionsBetween(e,n){let i=Math.trunc(e.getX()),s=Math.trunc(e.getY()),a=Math.trunc(n.getX()),c=Math.trunc(n.getY()),d=Math.abs(c-s)>Math.abs(a-i);if(d){let $=i;i=s,s=$,$=a,a=c,c=$}let h=Math.abs(a-i),p=Math.abs(c-s),w=-h/2,b=s<c?1:-1,A=i<a?1:-1,N=0,F=this.image.get(d?s:i,d?i:s);for(let $=i,j=s;$!==a;$+=A){let q=this.image.get(d?j:$,d?$:j);if(q!==F&&(N++,F=q),w+=p,w>0){if(j===c)break;j+=b,w-=h}}return N}}class jn{constructor(){this.decoder=new g1}decode(e,n=null){let i,s;if(n!=null&&n.has(Z.PURE_BARCODE)){const p=jn.extractPureBits(e.getBlackMatrix());i=this.decoder.decode(p),s=jn.NO_POINTS}else{const p=new vt(e.getBlackMatrix()).detect();i=this.decoder.decode(p.getBits()),s=p.getPoints()}const a=i.getRawBytes(),c=new Ee(i.getText(),a,8*a.length,s,T.DATA_MATRIX,R.currentTimeMillis()),d=i.getByteSegments();d!=null&&c.putMetadata(we.BYTE_SEGMENTS,d);const h=i.getECLevel();return h!=null&&c.putMetadata(we.ERROR_CORRECTION_LEVEL,h),c}reset(){}static extractPureBits(e){const n=e.getTopLeftOnBit(),i=e.getBottomRightOnBit();if(n==null||i==null)throw new L;const s=this.moduleSize(n,e);let a=n[1];const c=i[1];let d=n[0];const p=(i[0]-d+1)/s,w=(c-a+1)/s;if(p<=0||w<=0)throw new L;const b=s/2;a+=b,d+=b;const A=new le(p,w);for(let N=0;N<w;N++){const F=a+N*s;for(let $=0;$<p;$++)e.get(d+$*s,F)&&A.set($,N)}return A}static moduleSize(e,n){const i=n.getWidth();let s=e[0];const a=e[1];for(;s<i&&n.get(s,a);)s++;if(s===i)throw new L;const c=s-e[0];if(c===0)throw new L;return c}}jn.NO_POINTS=[];class m1 extends he{constructor(e=500){super(new jn,e)}}var pr;(function(v){v[v.L=0]="L",v[v.M=1]="M",v[v.Q=2]="Q",v[v.H=3]="H"})(pr||(pr={}));class it{constructor(e,n,i){this.value=e,this.stringValue=n,this.bits=i,it.FOR_BITS.set(i,this),it.FOR_VALUE.set(e,this)}getValue(){return this.value}getBits(){return this.bits}static fromString(e){switch(e){case"L":return it.L;case"M":return it.M;case"Q":return it.Q;case"H":return it.H;default:throw new E(e+"not available")}}toString(){return this.stringValue}equals(e){if(!(e instanceof it))return!1;const n=e;return this.value===n.value}static forBits(e){if(e<0||e>=it.FOR_BITS.size)throw new C;return it.FOR_BITS.get(e)}}it.FOR_BITS=new Map,it.FOR_VALUE=new Map,it.L=new it(pr.L,"L",1),it.M=new it(pr.M,"M",0),it.Q=new it(pr.Q,"Q",3),it.H=new it(pr.H,"H",2);class zt{constructor(e){this.errorCorrectionLevel=it.forBits(e>>3&3),this.dataMask=e&7}static numBitsDiffering(e,n){return k.bitCount(e^n)}static decodeFormatInformation(e,n){const i=zt.doDecodeFormatInformation(e,n);return i!==null?i:zt.doDecodeFormatInformation(e^zt.FORMAT_INFO_MASK_QR,n^zt.FORMAT_INFO_MASK_QR)}static doDecodeFormatInformation(e,n){let i=Number.MAX_SAFE_INTEGER,s=0;for(const a of zt.FORMAT_INFO_DECODE_LOOKUP){const c=a[0];if(c===e||c===n)return new zt(a[1]);let d=zt.numBitsDiffering(e,c);d<i&&(s=a[1],i=d),e!==n&&(d=zt.numBitsDiffering(n,c),d<i&&(s=a[1],i=d))}return i<=3?new zt(s):null}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getDataMask(){return this.dataMask}hashCode(){return this.errorCorrectionLevel.getBits()<<3|this.dataMask}equals(e){if(!(e instanceof zt))return!1;const n=e;return this.errorCorrectionLevel===n.errorCorrectionLevel&&this.dataMask===n.dataMask}}zt.FORMAT_INFO_MASK_QR=21522,zt.FORMAT_INFO_DECODE_LOOKUP=[Int32Array.from([21522,0]),Int32Array.from([20773,1]),Int32Array.from([24188,2]),Int32Array.from([23371,3]),Int32Array.from([17913,4]),Int32Array.from([16590,5]),Int32Array.from([20375,6]),Int32Array.from([19104,7]),Int32Array.from([30660,8]),Int32Array.from([29427,9]),Int32Array.from([32170,10]),Int32Array.from([30877,11]),Int32Array.from([26159,12]),Int32Array.from([25368,13]),Int32Array.from([27713,14]),Int32Array.from([26998,15]),Int32Array.from([5769,16]),Int32Array.from([5054,17]),Int32Array.from([7399,18]),Int32Array.from([6608,19]),Int32Array.from([1890,20]),Int32Array.from([597,21]),Int32Array.from([3340,22]),Int32Array.from([2107,23]),Int32Array.from([13663,24]),Int32Array.from([12392,25]),Int32Array.from([16177,26]),Int32Array.from([14854,27]),Int32Array.from([9396,28]),Int32Array.from([8579,29]),Int32Array.from([11994,30]),Int32Array.from([11245,31])];class H{constructor(e,...n){this.ecCodewordsPerBlock=e,this.ecBlocks=n}getECCodewordsPerBlock(){return this.ecCodewordsPerBlock}getNumBlocks(){let e=0;const n=this.ecBlocks;for(const i of n)e+=i.getCount();return e}getTotalECCodewords(){return this.ecCodewordsPerBlock*this.getNumBlocks()}getECBlocks(){return this.ecBlocks}}class S{constructor(e,n){this.count=e,this.dataCodewords=n}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class Ne{constructor(e,n,...i){this.versionNumber=e,this.alignmentPatternCenters=n,this.ecBlocks=i;let s=0;const a=i[0].getECCodewordsPerBlock(),c=i[0].getECBlocks();for(const d of c)s+=d.getCount()*(d.getDataCodewords()+a);this.totalCodewords=s}getVersionNumber(){return this.versionNumber}getAlignmentPatternCenters(){return this.alignmentPatternCenters}getTotalCodewords(){return this.totalCodewords}getDimensionForVersion(){return 17+4*this.versionNumber}getECBlocksForLevel(e){return this.ecBlocks[e.getValue()]}static getProvisionalVersionForDimension(e){if(e%4!==1)throw new z;try{return this.getVersionForNumber((e-17)/4)}catch{throw new z}}static getVersionForNumber(e){if(e<1||e>40)throw new C;return Ne.VERSIONS[e-1]}static decodeVersionInformation(e){let n=Number.MAX_SAFE_INTEGER,i=0;for(let s=0;s<Ne.VERSION_DECODE_INFO.length;s++){const a=Ne.VERSION_DECODE_INFO[s];if(a===e)return Ne.getVersionForNumber(s+7);const c=zt.numBitsDiffering(e,a);c<n&&(i=s+7,n=c)}return n<=3?Ne.getVersionForNumber(i):null}buildFunctionPattern(){const e=this.getDimensionForVersion(),n=new le(e);n.setRegion(0,0,9,9),n.setRegion(e-8,0,8,9),n.setRegion(0,e-8,9,8);const i=this.alignmentPatternCenters.length;for(let s=0;s<i;s++){const a=this.alignmentPatternCenters[s]-2;for(let c=0;c<i;c++)s===0&&(c===0||c===i-1)||s===i-1&&c===0||n.setRegion(this.alignmentPatternCenters[c]-2,a,5,5)}return n.setRegion(6,9,1,e-17),n.setRegion(9,6,e-17,1),this.versionNumber>6&&(n.setRegion(e-11,0,3,6),n.setRegion(0,e-11,6,3)),n}toString(){return""+this.versionNumber}}Ne.VERSION_DECODE_INFO=Int32Array.from([31892,34236,39577,42195,48118,51042,55367,58893,63784,68472,70749,76311,79154,84390,87683,92361,96236,102084,102881,110507,110734,117786,119615,126325,127568,133589,136944,141498,145311,150283,152622,158308,161089,167017]),Ne.VERSIONS=[new Ne(1,new Int32Array(0),new H(7,new S(1,19)),new H(10,new S(1,16)),new H(13,new S(1,13)),new H(17,new S(1,9))),new Ne(2,Int32Array.from([6,18]),new H(10,new S(1,34)),new H(16,new S(1,28)),new H(22,new S(1,22)),new H(28,new S(1,16))),new Ne(3,Int32Array.from([6,22]),new H(15,new S(1,55)),new H(26,new S(1,44)),new H(18,new S(2,17)),new H(22,new S(2,13))),new Ne(4,Int32Array.from([6,26]),new H(20,new S(1,80)),new H(18,new S(2,32)),new H(26,new S(2,24)),new H(16,new S(4,9))),new Ne(5,Int32Array.from([6,30]),new H(26,new S(1,108)),new H(24,new S(2,43)),new H(18,new S(2,15),new S(2,16)),new H(22,new S(2,11),new S(2,12))),new Ne(6,Int32Array.from([6,34]),new H(18,new S(2,68)),new H(16,new S(4,27)),new H(24,new S(4,19)),new H(28,new S(4,15))),new Ne(7,Int32Array.from([6,22,38]),new H(20,new S(2,78)),new H(18,new S(4,31)),new H(18,new S(2,14),new S(4,15)),new H(26,new S(4,13),new S(1,14))),new Ne(8,Int32Array.from([6,24,42]),new H(24,new S(2,97)),new H(22,new S(2,38),new S(2,39)),new H(22,new S(4,18),new S(2,19)),new H(26,new S(4,14),new S(2,15))),new Ne(9,Int32Array.from([6,26,46]),new H(30,new S(2,116)),new H(22,new S(3,36),new S(2,37)),new H(20,new S(4,16),new S(4,17)),new H(24,new S(4,12),new S(4,13))),new Ne(10,Int32Array.from([6,28,50]),new H(18,new S(2,68),new S(2,69)),new H(26,new S(4,43),new S(1,44)),new H(24,new S(6,19),new S(2,20)),new H(28,new S(6,15),new S(2,16))),new Ne(11,Int32Array.from([6,30,54]),new H(20,new S(4,81)),new H(30,new S(1,50),new S(4,51)),new H(28,new S(4,22),new S(4,23)),new H(24,new S(3,12),new S(8,13))),new Ne(12,Int32Array.from([6,32,58]),new H(24,new S(2,92),new S(2,93)),new H(22,new S(6,36),new S(2,37)),new H(26,new S(4,20),new S(6,21)),new H(28,new S(7,14),new S(4,15))),new Ne(13,Int32Array.from([6,34,62]),new H(26,new S(4,107)),new H(22,new S(8,37),new S(1,38)),new H(24,new S(8,20),new S(4,21)),new H(22,new S(12,11),new S(4,12))),new Ne(14,Int32Array.from([6,26,46,66]),new H(30,new S(3,115),new S(1,116)),new H(24,new S(4,40),new S(5,41)),new H(20,new S(11,16),new S(5,17)),new H(24,new S(11,12),new S(5,13))),new Ne(15,Int32Array.from([6,26,48,70]),new H(22,new S(5,87),new S(1,88)),new H(24,new S(5,41),new S(5,42)),new H(30,new S(5,24),new S(7,25)),new H(24,new S(11,12),new S(7,13))),new Ne(16,Int32Array.from([6,26,50,74]),new H(24,new S(5,98),new S(1,99)),new H(28,new S(7,45),new S(3,46)),new H(24,new S(15,19),new S(2,20)),new H(30,new S(3,15),new S(13,16))),new Ne(17,Int32Array.from([6,30,54,78]),new H(28,new S(1,107),new S(5,108)),new H(28,new S(10,46),new S(1,47)),new H(28,new S(1,22),new S(15,23)),new H(28,new S(2,14),new S(17,15))),new Ne(18,Int32Array.from([6,30,56,82]),new H(30,new S(5,120),new S(1,121)),new H(26,new S(9,43),new S(4,44)),new H(28,new S(17,22),new S(1,23)),new H(28,new S(2,14),new S(19,15))),new Ne(19,Int32Array.from([6,30,58,86]),new H(28,new S(3,113),new S(4,114)),new H(26,new S(3,44),new S(11,45)),new H(26,new S(17,21),new S(4,22)),new H(26,new S(9,13),new S(16,14))),new Ne(20,Int32Array.from([6,34,62,90]),new H(28,new S(3,107),new S(5,108)),new H(26,new S(3,41),new S(13,42)),new H(30,new S(15,24),new S(5,25)),new H(28,new S(15,15),new S(10,16))),new Ne(21,Int32Array.from([6,28,50,72,94]),new H(28,new S(4,116),new S(4,117)),new H(26,new S(17,42)),new H(28,new S(17,22),new S(6,23)),new H(30,new S(19,16),new S(6,17))),new Ne(22,Int32Array.from([6,26,50,74,98]),new H(28,new S(2,111),new S(7,112)),new H(28,new S(17,46)),new H(30,new S(7,24),new S(16,25)),new H(24,new S(34,13))),new Ne(23,Int32Array.from([6,30,54,78,102]),new H(30,new S(4,121),new S(5,122)),new H(28,new S(4,47),new S(14,48)),new H(30,new S(11,24),new S(14,25)),new H(30,new S(16,15),new S(14,16))),new Ne(24,Int32Array.from([6,28,54,80,106]),new H(30,new S(6,117),new S(4,118)),new H(28,new S(6,45),new S(14,46)),new H(30,new S(11,24),new S(16,25)),new H(30,new S(30,16),new S(2,17))),new Ne(25,Int32Array.from([6,32,58,84,110]),new H(26,new S(8,106),new S(4,107)),new H(28,new S(8,47),new S(13,48)),new H(30,new S(7,24),new S(22,25)),new H(30,new S(22,15),new S(13,16))),new Ne(26,Int32Array.from([6,30,58,86,114]),new H(28,new S(10,114),new S(2,115)),new H(28,new S(19,46),new S(4,47)),new H(28,new S(28,22),new S(6,23)),new H(30,new S(33,16),new S(4,17))),new Ne(27,Int32Array.from([6,34,62,90,118]),new H(30,new S(8,122),new S(4,123)),new H(28,new S(22,45),new S(3,46)),new H(30,new S(8,23),new S(26,24)),new H(30,new S(12,15),new S(28,16))),new Ne(28,Int32Array.from([6,26,50,74,98,122]),new H(30,new S(3,117),new S(10,118)),new H(28,new S(3,45),new S(23,46)),new H(30,new S(4,24),new S(31,25)),new H(30,new S(11,15),new S(31,16))),new Ne(29,Int32Array.from([6,30,54,78,102,126]),new H(30,new S(7,116),new S(7,117)),new H(28,new S(21,45),new S(7,46)),new H(30,new S(1,23),new S(37,24)),new H(30,new S(19,15),new S(26,16))),new Ne(30,Int32Array.from([6,26,52,78,104,130]),new H(30,new S(5,115),new S(10,116)),new H(28,new S(19,47),new S(10,48)),new H(30,new S(15,24),new S(25,25)),new H(30,new S(23,15),new S(25,16))),new Ne(31,Int32Array.from([6,30,56,82,108,134]),new H(30,new S(13,115),new S(3,116)),new H(28,new S(2,46),new S(29,47)),new H(30,new S(42,24),new S(1,25)),new H(30,new S(23,15),new S(28,16))),new Ne(32,Int32Array.from([6,34,60,86,112,138]),new H(30,new S(17,115)),new H(28,new S(10,46),new S(23,47)),new H(30,new S(10,24),new S(35,25)),new H(30,new S(19,15),new S(35,16))),new Ne(33,Int32Array.from([6,30,58,86,114,142]),new H(30,new S(17,115),new S(1,116)),new H(28,new S(14,46),new S(21,47)),new H(30,new S(29,24),new S(19,25)),new H(30,new S(11,15),new S(46,16))),new Ne(34,Int32Array.from([6,34,62,90,118,146]),new H(30,new S(13,115),new S(6,116)),new H(28,new S(14,46),new S(23,47)),new H(30,new S(44,24),new S(7,25)),new H(30,new S(59,16),new S(1,17))),new Ne(35,Int32Array.from([6,30,54,78,102,126,150]),new H(30,new S(12,121),new S(7,122)),new H(28,new S(12,47),new S(26,48)),new H(30,new S(39,24),new S(14,25)),new H(30,new S(22,15),new S(41,16))),new Ne(36,Int32Array.from([6,24,50,76,102,128,154]),new H(30,new S(6,121),new S(14,122)),new H(28,new S(6,47),new S(34,48)),new H(30,new S(46,24),new S(10,25)),new H(30,new S(2,15),new S(64,16))),new Ne(37,Int32Array.from([6,28,54,80,106,132,158]),new H(30,new S(17,122),new S(4,123)),new H(28,new S(29,46),new S(14,47)),new H(30,new S(49,24),new S(10,25)),new H(30,new S(24,15),new S(46,16))),new Ne(38,Int32Array.from([6,32,58,84,110,136,162]),new H(30,new S(4,122),new S(18,123)),new H(28,new S(13,46),new S(32,47)),new H(30,new S(48,24),new S(14,25)),new H(30,new S(42,15),new S(32,16))),new Ne(39,Int32Array.from([6,26,54,82,110,138,166]),new H(30,new S(20,117),new S(4,118)),new H(28,new S(40,47),new S(7,48)),new H(30,new S(43,24),new S(22,25)),new H(30,new S(10,15),new S(67,16))),new Ne(40,Int32Array.from([6,30,58,86,114,142,170]),new H(30,new S(19,118),new S(6,119)),new H(28,new S(18,47),new S(31,48)),new H(30,new S(34,24),new S(34,25)),new H(30,new S(20,15),new S(61,16)))];var kt;(function(v){v[v.DATA_MASK_000=0]="DATA_MASK_000",v[v.DATA_MASK_001=1]="DATA_MASK_001",v[v.DATA_MASK_010=2]="DATA_MASK_010",v[v.DATA_MASK_011=3]="DATA_MASK_011",v[v.DATA_MASK_100=4]="DATA_MASK_100",v[v.DATA_MASK_101=5]="DATA_MASK_101",v[v.DATA_MASK_110=6]="DATA_MASK_110",v[v.DATA_MASK_111=7]="DATA_MASK_111"})(kt||(kt={}));class un{constructor(e,n){this.value=e,this.isMasked=n}unmaskBitMatrix(e,n){for(let i=0;i<n;i++)for(let s=0;s<n;s++)this.isMasked(i,s)&&e.flip(s,i)}}un.values=new Map([[kt.DATA_MASK_000,new un(kt.DATA_MASK_000,(v,e)=>(v+e&1)===0)],[kt.DATA_MASK_001,new un(kt.DATA_MASK_001,(v,e)=>(v&1)===0)],[kt.DATA_MASK_010,new un(kt.DATA_MASK_010,(v,e)=>e%3===0)],[kt.DATA_MASK_011,new un(kt.DATA_MASK_011,(v,e)=>(v+e)%3===0)],[kt.DATA_MASK_100,new un(kt.DATA_MASK_100,(v,e)=>(Math.floor(v/2)+Math.floor(e/3)&1)===0)],[kt.DATA_MASK_101,new un(kt.DATA_MASK_101,(v,e)=>v*e%6===0)],[kt.DATA_MASK_110,new un(kt.DATA_MASK_110,(v,e)=>v*e%6<3)],[kt.DATA_MASK_111,new un(kt.DATA_MASK_111,(v,e)=>(v+e+v*e%3&1)===0)]]);class x1{constructor(e){const n=e.getHeight();if(n<21||(n&3)!==1)throw new z;this.bitMatrix=e}readFormatInformation(){if(this.parsedFormatInfo!==null&&this.parsedFormatInfo!==void 0)return this.parsedFormatInfo;let e=0;for(let a=0;a<6;a++)e=this.copyBit(a,8,e);e=this.copyBit(7,8,e),e=this.copyBit(8,8,e),e=this.copyBit(8,7,e);for(let a=5;a>=0;a--)e=this.copyBit(8,a,e);const n=this.bitMatrix.getHeight();let i=0;const s=n-7;for(let a=n-1;a>=s;a--)i=this.copyBit(8,a,i);for(let a=n-8;a<n;a++)i=this.copyBit(a,8,i);if(this.parsedFormatInfo=zt.decodeFormatInformation(e,i),this.parsedFormatInfo!==null)return this.parsedFormatInfo;throw new z}readVersion(){if(this.parsedVersion!==null&&this.parsedVersion!==void 0)return this.parsedVersion;const e=this.bitMatrix.getHeight(),n=Math.floor((e-17)/4);if(n<=6)return Ne.getVersionForNumber(n);let i=0;const s=e-11;for(let c=5;c>=0;c--)for(let d=e-9;d>=s;d--)i=this.copyBit(d,c,i);let a=Ne.decodeVersionInformation(i);if(a!==null&&a.getDimensionForVersion()===e)return this.parsedVersion=a,a;i=0;for(let c=5;c>=0;c--)for(let d=e-9;d>=s;d--)i=this.copyBit(c,d,i);if(a=Ne.decodeVersionInformation(i),a!==null&&a.getDimensionForVersion()===e)return this.parsedVersion=a,a;throw new z}copyBit(e,n,i){return(this.isMirror?this.bitMatrix.get(n,e):this.bitMatrix.get(e,n))?i<<1|1:i<<1}readCodewords(){const e=this.readFormatInformation(),n=this.readVersion(),i=un.values.get(e.getDataMask()),s=this.bitMatrix.getHeight();i.unmaskBitMatrix(this.bitMatrix,s);const a=n.buildFunctionPattern();let c=!0;const d=new Uint8Array(n.getTotalCodewords());let h=0,p=0,w=0;for(let b=s-1;b>0;b-=2){b===6&&b--;for(let A=0;A<s;A++){const N=c?s-1-A:A;for(let F=0;F<2;F++)a.get(b-F,N)||(w++,p<<=1,this.bitMatrix.get(b-F,N)&&(p|=1),w===8&&(d[h++]=p,w=0,p=0))}c=!c}if(h!==n.getTotalCodewords())throw new z;return d}remask(){if(this.parsedFormatInfo===null)return;const e=un.values[this.parsedFormatInfo.getDataMask()],n=this.bitMatrix.getHeight();e.unmaskBitMatrix(this.bitMatrix,n)}setMirror(e){this.parsedVersion=null,this.parsedFormatInfo=null,this.isMirror=e}mirror(){const e=this.bitMatrix;for(let n=0,i=e.getWidth();n<i;n++)for(let s=n+1,a=e.getHeight();s<a;s++)e.get(n,s)!==e.get(s,n)&&(e.flip(s,n),e.flip(n,s))}}class ao{constructor(e,n){this.numDataCodewords=e,this.codewords=n}static getDataBlocks(e,n,i){if(e.length!==n.getTotalCodewords())throw new C;const s=n.getECBlocksForLevel(i);let a=0;const c=s.getECBlocks();for(const F of c)a+=F.getCount();const d=new Array(a);let h=0;for(const F of c)for(let $=0;$<F.getCount();$++){const j=F.getDataCodewords(),q=s.getECCodewordsPerBlock()+j;d[h++]=new ao(j,new Uint8Array(q))}const p=d[0].codewords.length;let w=d.length-1;for(;w>=0&&d[w].codewords.length!==p;)w--;w++;const b=p-s.getECCodewordsPerBlock();let A=0;for(let F=0;F<b;F++)for(let $=0;$<h;$++)d[$].codewords[F]=e[A++];for(let F=w;F<h;F++)d[F].codewords[b]=e[A++];const N=d[0].codewords.length;for(let F=b;F<N;F++)for(let $=0;$<h;$++){const j=$<w?F:F+1;d[$].codewords[j]=e[A++]}return d}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}var dn;(function(v){v[v.TERMINATOR=0]="TERMINATOR",v[v.NUMERIC=1]="NUMERIC",v[v.ALPHANUMERIC=2]="ALPHANUMERIC",v[v.STRUCTURED_APPEND=3]="STRUCTURED_APPEND",v[v.BYTE=4]="BYTE",v[v.ECI=5]="ECI",v[v.KANJI=6]="KANJI",v[v.FNC1_FIRST_POSITION=7]="FNC1_FIRST_POSITION",v[v.FNC1_SECOND_POSITION=8]="FNC1_SECOND_POSITION",v[v.HANZI=9]="HANZI"})(dn||(dn={}));class Oe{constructor(e,n,i,s){this.value=e,this.stringValue=n,this.characterCountBitsForVersions=i,this.bits=s,Oe.FOR_BITS.set(s,this),Oe.FOR_VALUE.set(e,this)}static forBits(e){const n=Oe.FOR_BITS.get(e);if(n===void 0)throw new C;return n}getCharacterCountBits(e){const n=e.getVersionNumber();let i;return n<=9?i=0:n<=26?i=1:i=2,this.characterCountBitsForVersions[i]}getValue(){return this.value}getBits(){return this.bits}equals(e){if(!(e instanceof Oe))return!1;const n=e;return this.value===n.value}toString(){return this.stringValue}}Oe.FOR_BITS=new Map,Oe.FOR_VALUE=new Map,Oe.TERMINATOR=new Oe(dn.TERMINATOR,"TERMINATOR",Int32Array.from([0,0,0]),0),Oe.NUMERIC=new Oe(dn.NUMERIC,"NUMERIC",Int32Array.from([10,12,14]),1),Oe.ALPHANUMERIC=new Oe(dn.ALPHANUMERIC,"ALPHANUMERIC",Int32Array.from([9,11,13]),2),Oe.STRUCTURED_APPEND=new Oe(dn.STRUCTURED_APPEND,"STRUCTURED_APPEND",Int32Array.from([0,0,0]),3),Oe.BYTE=new Oe(dn.BYTE,"BYTE",Int32Array.from([8,16,16]),4),Oe.ECI=new Oe(dn.ECI,"ECI",Int32Array.from([0,0,0]),7),Oe.KANJI=new Oe(dn.KANJI,"KANJI",Int32Array.from([8,10,12]),8),Oe.FNC1_FIRST_POSITION=new Oe(dn.FNC1_FIRST_POSITION,"FNC1_FIRST_POSITION",Int32Array.from([0,0,0]),5),Oe.FNC1_SECOND_POSITION=new Oe(dn.FNC1_SECOND_POSITION,"FNC1_SECOND_POSITION",Int32Array.from([0,0,0]),9),Oe.HANZI=new Oe(dn.HANZI,"HANZI",Int32Array.from([8,10,12]),13);class pt{static decode(e,n,i,s){const a=new so(e);let c=new Ce;const d=new Array;let h=-1,p=-1;try{let w=null,b=!1,A;do{if(a.available()<4)A=Oe.TERMINATOR;else{const N=a.readBits(4);A=Oe.forBits(N)}switch(A){case Oe.TERMINATOR:break;case Oe.FNC1_FIRST_POSITION:case Oe.FNC1_SECOND_POSITION:b=!0;break;case Oe.STRUCTURED_APPEND:if(a.available()<16)throw new z;h=a.readBits(8),p=a.readBits(8);break;case Oe.ECI:const N=pt.parseECIValue(a);if(w=W.getCharacterSetECIByValue(N),w===null)throw new z;break;case Oe.HANZI:const F=a.readBits(4),$=a.readBits(A.getCharacterCountBits(n));F===pt.GB2312_SUBSET&&pt.decodeHanziSegment(a,c,$);break;default:const j=a.readBits(A.getCharacterCountBits(n));switch(A){case Oe.NUMERIC:pt.decodeNumericSegment(a,c,j);break;case Oe.ALPHANUMERIC:pt.decodeAlphanumericSegment(a,c,j,b);break;case Oe.BYTE:pt.decodeByteSegment(a,c,j,w,d,s);break;case Oe.KANJI:pt.decodeKanjiSegment(a,c,j);break;default:throw new z}break}}while(A!==Oe.TERMINATOR)}catch{throw new z}return new mt(e,c.toString(),d.length===0?null:d,i===null?null:i.toString(),h,p)}static decodeHanziSegment(e,n,i){if(i*13>e.available())throw new z;const s=new Uint8Array(2*i);let a=0;for(;i>0;){const c=e.readBits(13);let d=c/96<<8&4294967295|c%96;d<959?d+=41377:d+=42657,s[a]=d>>8&255,s[a+1]=d&255,a+=2,i--}try{n.append(me.decode(s,pe.GB2312))}catch(c){throw new z(c)}}static decodeKanjiSegment(e,n,i){if(i*13>e.available())throw new z;const s=new Uint8Array(2*i);let a=0;for(;i>0;){const c=e.readBits(13);let d=c/192<<8&4294967295|c%192;d<7936?d+=33088:d+=49472,s[a]=d>>8,s[a+1]=d,a+=2,i--}try{n.append(me.decode(s,pe.SHIFT_JIS))}catch(c){throw new z(c)}}static decodeByteSegment(e,n,i,s,a,c){if(8*i>e.available())throw new z;const d=new Uint8Array(i);for(let p=0;p<i;p++)d[p]=e.readBits(8);let h;s===null?h=pe.guessEncoding(d,c):h=s.getName();try{n.append(me.decode(d,h))}catch(p){throw new z(p)}a.push(d)}static toAlphaNumericChar(e){if(e>=pt.ALPHANUMERIC_CHARS.length)throw new z;return pt.ALPHANUMERIC_CHARS[e]}static decodeAlphanumericSegment(e,n,i,s){const a=n.length();for(;i>1;){if(e.available()<11)throw new z;const c=e.readBits(11);n.append(pt.toAlphaNumericChar(Math.floor(c/45))),n.append(pt.toAlphaNumericChar(c%45)),i-=2}if(i===1){if(e.available()<6)throw new z;n.append(pt.toAlphaNumericChar(e.readBits(6)))}if(s)for(let c=a;c<n.length();c++)n.charAt(c)==="%"&&(c<n.length()-1&&n.charAt(c+1)==="%"?n.deleteCharAt(c+1):n.setCharAt(c,""))}static decodeNumericSegment(e,n,i){for(;i>=3;){if(e.available()<10)throw new z;const s=e.readBits(10);if(s>=1e3)throw new z;n.append(pt.toAlphaNumericChar(Math.floor(s/100))),n.append(pt.toAlphaNumericChar(Math.floor(s/10)%10)),n.append(pt.toAlphaNumericChar(s%10)),i-=3}if(i===2){if(e.available()<7)throw new z;const s=e.readBits(7);if(s>=100)throw new z;n.append(pt.toAlphaNumericChar(Math.floor(s/10))),n.append(pt.toAlphaNumericChar(s%10))}else if(i===1){if(e.available()<4)throw new z;const s=e.readBits(4);if(s>=10)throw new z;n.append(pt.toAlphaNumericChar(s))}}static parseECIValue(e){const n=e.readBits(8);if((n&128)===0)return n&127;if((n&192)===128){const i=e.readBits(8);return(n&63)<<8&4294967295|i}if((n&224)===192){const i=e.readBits(16);return(n&31)<<16&4294967295|i}throw new z}}pt.ALPHANUMERIC_CHARS="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",pt.GB2312_SUBSET=1;class Cs{constructor(e){this.mirrored=e}isMirrored(){return this.mirrored}applyMirroredCorrection(e){if(!this.mirrored||e===null||e.length<3)return;const n=e[0];e[0]=e[2],e[2]=n}}class w1{constructor(){this.rsDecoder=new zn(Fe.QR_CODE_FIELD_256)}decodeBooleanArray(e,n){return this.decodeBitMatrix(le.parseFromBooleanArray(e),n)}decodeBitMatrix(e,n){const i=new x1(e);let s=null;try{return this.decodeBitMatrixParser(i,n)}catch(a){s=a}try{i.remask(),i.setMirror(!0),i.readVersion(),i.readFormatInformation(),i.mirror();const a=this.decodeBitMatrixParser(i,n);return a.setOther(new Cs(!0)),a}catch(a){throw s!==null?s:a}}decodeBitMatrixParser(e,n){const i=e.readVersion(),s=e.readFormatInformation().getErrorCorrectionLevel(),a=e.readCodewords(),c=ao.getDataBlocks(a,i,s);let d=0;for(const w of c)d+=w.getNumDataCodewords();const h=new Uint8Array(d);let p=0;for(const w of c){const b=w.getCodewords(),A=w.getNumDataCodewords();this.correctErrors(b,A);for(let N=0;N<A;N++)h[p++]=b[N]}return pt.decode(h,i,s,n)}correctErrors(e,n){const i=new Int32Array(e);try{this.rsDecoder.decode(i,e.length-n)}catch{throw new O}for(let s=0;s<n;s++)e[s]=i[s]}}class lo extends Se{constructor(e,n,i){super(e,n),this.estimatedModuleSize=i}aboutEquals(e,n,i){if(Math.abs(n-this.getY())<=e&&Math.abs(i-this.getX())<=e){const s=Math.abs(e-this.estimatedModuleSize);return s<=1||s<=this.estimatedModuleSize}return!1}combineEstimate(e,n,i){const s=(this.getX()+n)/2,a=(this.getY()+e)/2,c=(this.estimatedModuleSize+i)/2;return new lo(s,a,c)}}class di{constructor(e,n,i,s,a,c,d){this.image=e,this.startX=n,this.startY=i,this.width=s,this.height=a,this.moduleSize=c,this.resultPointCallback=d,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(3)}find(){const e=this.startX,n=this.height,i=this.width,s=e+i,a=this.startY+n/2,c=new Int32Array(3),d=this.image;for(let h=0;h<n;h++){const p=a+((h&1)===0?Math.floor((h+1)/2):-Math.floor((h+1)/2));c[0]=0,c[1]=0,c[2]=0;let w=e;for(;w<s&&!d.get(w,p);)w++;let b=0;for(;w<s;){if(d.get(w,p))if(b===1)c[1]++;else if(b===2){if(this.foundPatternCross(c)){const A=this.handlePossibleCenter(c,p,w);if(A!==null)return A}c[0]=c[2],c[1]=1,c[2]=0,b=1}else c[++b]++;else b===1&&b++,c[b]++;w++}if(this.foundPatternCross(c)){const A=this.handlePossibleCenter(c,p,s);if(A!==null)return A}}if(this.possibleCenters.length!==0)return this.possibleCenters[0];throw new L}static centerFromEnd(e,n){return n-e[2]-e[1]/2}foundPatternCross(e){const n=this.moduleSize,i=n/2;for(let s=0;s<3;s++)if(Math.abs(n-e[s])>=i)return!1;return!0}crossCheckVertical(e,n,i,s){const a=this.image,c=a.getHeight(),d=this.crossCheckStateCount;d[0]=0,d[1]=0,d[2]=0;let h=e;for(;h>=0&&a.get(n,h)&&d[1]<=i;)d[1]++,h--;if(h<0||d[1]>i)return NaN;for(;h>=0&&!a.get(n,h)&&d[0]<=i;)d[0]++,h--;if(d[0]>i)return NaN;for(h=e+1;h<c&&a.get(n,h)&&d[1]<=i;)d[1]++,h++;if(h===c||d[1]>i)return NaN;for(;h<c&&!a.get(n,h)&&d[2]<=i;)d[2]++,h++;if(d[2]>i)return NaN;const p=d[0]+d[1]+d[2];return 5*Math.abs(p-s)>=2*s?NaN:this.foundPatternCross(d)?di.centerFromEnd(d,h):NaN}handlePossibleCenter(e,n,i){const s=e[0]+e[1]+e[2],a=di.centerFromEnd(e,i),c=this.crossCheckVertical(n,a,2*e[1],s);if(!isNaN(c)){const d=(e[0]+e[1]+e[2])/3;for(const p of this.possibleCenters)if(p.aboutEquals(d,c,a))return p.combineEstimate(c,a,d);const h=new lo(a,c,d);this.possibleCenters.push(h),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(h)}return null}}class co extends Se{constructor(e,n,i,s){super(e,n),this.estimatedModuleSize=i,this.count=s,s===void 0&&(this.count=1)}getEstimatedModuleSize(){return this.estimatedModuleSize}getCount(){return this.count}aboutEquals(e,n,i){if(Math.abs(n-this.getY())<=e&&Math.abs(i-this.getX())<=e){const s=Math.abs(e-this.estimatedModuleSize);return s<=1||s<=this.estimatedModuleSize}return!1}combineEstimate(e,n,i){const s=this.count+1,a=(this.count*this.getX()+n)/s,c=(this.count*this.getY()+e)/s,d=(this.count*this.estimatedModuleSize+i)/s;return new co(a,c,d,s)}}class y1{constructor(e){this.bottomLeft=e[0],this.topLeft=e[1],this.topRight=e[2]}getBottomLeft(){return this.bottomLeft}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}}class Rt{constructor(e,n){this.image=e,this.resultPointCallback=n,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(5),this.resultPointCallback=n}getImage(){return this.image}getPossibleCenters(){return this.possibleCenters}find(e){const n=e!=null&&e.get(Z.TRY_HARDER)!==void 0,i=e!=null&&e.get(Z.PURE_BARCODE)!==void 0,s=this.image,a=s.getHeight(),c=s.getWidth();let d=Math.floor(3*a/(4*Rt.MAX_MODULES));(d<Rt.MIN_SKIP||n)&&(d=Rt.MIN_SKIP);let h=!1;const p=new Int32Array(5);for(let b=d-1;b<a&&!h;b+=d){p[0]=0,p[1]=0,p[2]=0,p[3]=0,p[4]=0;let A=0;for(let N=0;N<c;N++)if(s.get(N,b))(A&1)===1&&A++,p[A]++;else if((A&1)===0)if(A===4)if(Rt.foundPatternCross(p)){if(this.handlePossibleCenter(p,b,N,i)===!0)if(d=2,this.hasSkipped===!0)h=this.haveMultiplyConfirmedCenters();else{const $=this.findRowSkip();$>p[2]&&(b+=$-p[2]-d,N=c-1)}else{p[0]=p[2],p[1]=p[3],p[2]=p[4],p[3]=1,p[4]=0,A=3;continue}A=0,p[0]=0,p[1]=0,p[2]=0,p[3]=0,p[4]=0}else p[0]=p[2],p[1]=p[3],p[2]=p[4],p[3]=1,p[4]=0,A=3;else p[++A]++;else p[A]++;Rt.foundPatternCross(p)&&this.handlePossibleCenter(p,b,c,i)===!0&&(d=p[0],this.hasSkipped&&(h=this.haveMultiplyConfirmedCenters()))}const w=this.selectBestPatterns();return Se.orderBestPatterns(w),new y1(w)}static centerFromEnd(e,n){return n-e[4]-e[3]-e[2]/2}static foundPatternCross(e){let n=0;for(let a=0;a<5;a++){const c=e[a];if(c===0)return!1;n+=c}if(n<7)return!1;const i=n/7,s=i/2;return Math.abs(i-e[0])<s&&Math.abs(i-e[1])<s&&Math.abs(3*i-e[2])<3*s&&Math.abs(i-e[3])<s&&Math.abs(i-e[4])<s}getCrossCheckStateCount(){const e=this.crossCheckStateCount;return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e}crossCheckDiagonal(e,n,i,s){const a=this.getCrossCheckStateCount();let c=0;const d=this.image;for(;e>=c&&n>=c&&d.get(n-c,e-c);)a[2]++,c++;if(e<c||n<c)return!1;for(;e>=c&&n>=c&&!d.get(n-c,e-c)&&a[1]<=i;)a[1]++,c++;if(e<c||n<c||a[1]>i)return!1;for(;e>=c&&n>=c&&d.get(n-c,e-c)&&a[0]<=i;)a[0]++,c++;if(a[0]>i)return!1;const h=d.getHeight(),p=d.getWidth();for(c=1;e+c<h&&n+c<p&&d.get(n+c,e+c);)a[2]++,c++;if(e+c>=h||n+c>=p)return!1;for(;e+c<h&&n+c<p&&!d.get(n+c,e+c)&&a[3]<i;)a[3]++,c++;if(e+c>=h||n+c>=p||a[3]>=i)return!1;for(;e+c<h&&n+c<p&&d.get(n+c,e+c)&&a[4]<i;)a[4]++,c++;if(a[4]>=i)return!1;const w=a[0]+a[1]+a[2]+a[3]+a[4];return Math.abs(w-s)<2*s&&Rt.foundPatternCross(a)}crossCheckVertical(e,n,i,s){const a=this.image,c=a.getHeight(),d=this.getCrossCheckStateCount();let h=e;for(;h>=0&&a.get(n,h);)d[2]++,h--;if(h<0)return NaN;for(;h>=0&&!a.get(n,h)&&d[1]<=i;)d[1]++,h--;if(h<0||d[1]>i)return NaN;for(;h>=0&&a.get(n,h)&&d[0]<=i;)d[0]++,h--;if(d[0]>i)return NaN;for(h=e+1;h<c&&a.get(n,h);)d[2]++,h++;if(h===c)return NaN;for(;h<c&&!a.get(n,h)&&d[3]<i;)d[3]++,h++;if(h===c||d[3]>=i)return NaN;for(;h<c&&a.get(n,h)&&d[4]<i;)d[4]++,h++;if(d[4]>=i)return NaN;const p=d[0]+d[1]+d[2]+d[3]+d[4];return 5*Math.abs(p-s)>=2*s?NaN:Rt.foundPatternCross(d)?Rt.centerFromEnd(d,h):NaN}crossCheckHorizontal(e,n,i,s){const a=this.image,c=a.getWidth(),d=this.getCrossCheckStateCount();let h=e;for(;h>=0&&a.get(h,n);)d[2]++,h--;if(h<0)return NaN;for(;h>=0&&!a.get(h,n)&&d[1]<=i;)d[1]++,h--;if(h<0||d[1]>i)return NaN;for(;h>=0&&a.get(h,n)&&d[0]<=i;)d[0]++,h--;if(d[0]>i)return NaN;for(h=e+1;h<c&&a.get(h,n);)d[2]++,h++;if(h===c)return NaN;for(;h<c&&!a.get(h,n)&&d[3]<i;)d[3]++,h++;if(h===c||d[3]>=i)return NaN;for(;h<c&&a.get(h,n)&&d[4]<i;)d[4]++,h++;if(d[4]>=i)return NaN;const p=d[0]+d[1]+d[2]+d[3]+d[4];return 5*Math.abs(p-s)>=s?NaN:Rt.foundPatternCross(d)?Rt.centerFromEnd(d,h):NaN}handlePossibleCenter(e,n,i,s){const a=e[0]+e[1]+e[2]+e[3]+e[4];let c=Rt.centerFromEnd(e,i),d=this.crossCheckVertical(n,Math.floor(c),e[2],a);if(!isNaN(d)&&(c=this.crossCheckHorizontal(Math.floor(c),Math.floor(d),e[2],a),!isNaN(c)&&(!s||this.crossCheckDiagonal(Math.floor(d),Math.floor(c),e[2],a)))){const h=a/7;let p=!1;const w=this.possibleCenters;for(let b=0,A=w.length;b<A;b++){const N=w[b];if(N.aboutEquals(h,d,c)){w[b]=N.combineEstimate(d,c,h),p=!0;break}}if(!p){const b=new co(c,d,h);w.push(b),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(b)}return!0}return!1}findRowSkip(){if(this.possibleCenters.length<=1)return 0;let n=null;for(const i of this.possibleCenters)if(i.getCount()>=Rt.CENTER_QUORUM)if(n==null)n=i;else return this.hasSkipped=!0,Math.floor((Math.abs(n.getX()-i.getX())-Math.abs(n.getY()-i.getY()))/2);return 0}haveMultiplyConfirmedCenters(){let e=0,n=0;const i=this.possibleCenters.length;for(const c of this.possibleCenters)c.getCount()>=Rt.CENTER_QUORUM&&(e++,n+=c.getEstimatedModuleSize());if(e<3)return!1;const s=n/i;let a=0;for(const c of this.possibleCenters)a+=Math.abs(c.getEstimatedModuleSize()-s);return a<=.05*n}selectBestPatterns(){const e=this.possibleCenters.length;if(e<3)throw new L;const n=this.possibleCenters;let i;if(e>3){let s=0,a=0;for(const h of this.possibleCenters){const p=h.getEstimatedModuleSize();s+=p,a+=p*p}i=s/e;let c=Math.sqrt(a/e-i*i);n.sort((h,p)=>{const w=Math.abs(p.getEstimatedModuleSize()-i),b=Math.abs(h.getEstimatedModuleSize()-i);return w<b?-1:w>b?1:0});const d=Math.max(.2*i,c);for(let h=0;h<n.length&&n.length>3;h++){const p=n[h];Math.abs(p.getEstimatedModuleSize()-i)>d&&(n.splice(h,1),h--)}}if(n.length>3){let s=0;for(const a of n)s+=a.getEstimatedModuleSize();i=s/n.length,n.sort((a,c)=>{if(c.getCount()===a.getCount()){const d=Math.abs(c.getEstimatedModuleSize()-i),h=Math.abs(a.getEstimatedModuleSize()-i);return d<h?1:d>h?-1:0}else return c.getCount()-a.getCount()}),n.splice(3)}return[n[0],n[1],n[2]]}}Rt.CENTER_QUORUM=2,Rt.MIN_SKIP=3,Rt.MAX_MODULES=57;class Tr{constructor(e){this.image=e}getImage(){return this.image}getResultPointCallback(){return this.resultPointCallback}detect(e){this.resultPointCallback=e==null?null:e.get(Z.NEED_RESULT_POINT_CALLBACK);const i=new Rt(this.image,this.resultPointCallback).find(e);return this.processFinderPatternInfo(i)}processFinderPatternInfo(e){const n=e.getTopLeft(),i=e.getTopRight(),s=e.getBottomLeft(),a=this.calculateModuleSize(n,i,s);if(a<1)throw new L("No pattern found in proccess finder.");const c=Tr.computeDimension(n,i,s,a),d=Ne.getProvisionalVersionForDimension(c),h=d.getDimensionForVersion()-7;let p=null;if(d.getAlignmentPatternCenters().length>0){const N=i.getX()-n.getX()+s.getX(),F=i.getY()-n.getY()+s.getY(),$=1-3/h,j=Math.floor(n.getX()+$*(N-n.getX())),q=Math.floor(n.getY()+$*(F-n.getY()));for(let se=4;se<=16;se<<=1)try{p=this.findAlignmentInRegion(a,j,q,se);break}catch(ae){if(!(ae instanceof L))throw ae}}const w=Tr.createTransform(n,i,s,p,c),b=Tr.sampleGrid(this.image,w,c);let A;return p===null?A=[s,n,i]:A=[s,n,i,p],new cr(b,A)}static createTransform(e,n,i,s,a){const c=a-3.5;let d,h,p,w;return s!==null?(d=s.getX(),h=s.getY(),p=c-3,w=p):(d=n.getX()-e.getX()+i.getX(),h=n.getY()-e.getY()+i.getY(),p=c,w=c),Be.quadrilateralToQuadrilateral(3.5,3.5,c,3.5,p,w,3.5,c,e.getX(),e.getY(),n.getX(),n.getY(),d,h,i.getX(),i.getY())}static sampleGrid(e,n,i){return gn.getInstance().sampleGridWithTransform(e,i,i,n)}static computeDimension(e,n,i,s){const a=ze.round(Se.distance(e,n)/s),c=ze.round(Se.distance(e,i)/s);let d=Math.floor((a+c)/2)+7;switch(d&3){case 0:d++;break;case 2:d--;break;case 3:throw new L("Dimensions could be not found.")}return d}calculateModuleSize(e,n,i){return(this.calculateModuleSizeOneWay(e,n)+this.calculateModuleSizeOneWay(e,i))/2}calculateModuleSizeOneWay(e,n){const i=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(e.getX()),Math.floor(e.getY()),Math.floor(n.getX()),Math.floor(n.getY())),s=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(n.getX()),Math.floor(n.getY()),Math.floor(e.getX()),Math.floor(e.getY()));return isNaN(i)?s/7:isNaN(s)?i/7:(i+s)/14}sizeOfBlackWhiteBlackRunBothWays(e,n,i,s){let a=this.sizeOfBlackWhiteBlackRun(e,n,i,s),c=1,d=e-(i-e);d<0?(c=e/(e-d),d=0):d>=this.image.getWidth()&&(c=(this.image.getWidth()-1-e)/(d-e),d=this.image.getWidth()-1);let h=Math.floor(n-(s-n)*c);return c=1,h<0?(c=n/(n-h),h=0):h>=this.image.getHeight()&&(c=(this.image.getHeight()-1-n)/(h-n),h=this.image.getHeight()-1),d=Math.floor(e+(d-e)*c),a+=this.sizeOfBlackWhiteBlackRun(e,n,d,h),a-1}sizeOfBlackWhiteBlackRun(e,n,i,s){const a=Math.abs(s-n)>Math.abs(i-e);if(a){let N=e;e=n,n=N,N=i,i=s,s=N}const c=Math.abs(i-e),d=Math.abs(s-n);let h=-c/2;const p=e<i?1:-1,w=n<s?1:-1;let b=0;const A=i+p;for(let N=e,F=n;N!==A;N+=p){const $=a?F:N,j=a?N:F;if(b===1===this.image.get($,j)){if(b===2)return ze.distance(N,F,e,n);b++}if(h+=d,h>0){if(F===s)break;F+=w,h-=c}}return b===2?ze.distance(i+p,s,e,n):NaN}findAlignmentInRegion(e,n,i,s){const a=Math.floor(s*e),c=Math.max(0,n-a),d=Math.min(this.image.getWidth()-1,n+a);if(d-c<e*3)throw new L("Alignment top exceeds estimated module size.");const h=Math.max(0,i-a),p=Math.min(this.image.getHeight()-1,i+a);if(p-h<e*3)throw new L("Alignment bottom exceeds estimated module size.");return new di(this.image,c,h,d-c,p-h,e,this.resultPointCallback).find()}}class Hn{constructor(){this.decoder=new w1}getDecoder(){return this.decoder}decode(e,n){let i,s;if(n!=null&&n.get(Z.PURE_BARCODE)!==void 0){const h=Hn.extractPureBits(e.getBlackMatrix());i=this.decoder.decodeBitMatrix(h,n),s=Hn.NO_POINTS}else{const h=new Tr(e.getBlackMatrix()).detect(n);i=this.decoder.decodeBitMatrix(h.getBits(),n),s=h.getPoints()}i.getOther()instanceof Cs&&i.getOther().applyMirroredCorrection(s);const a=new Ee(i.getText(),i.getRawBytes(),void 0,s,T.QR_CODE,void 0),c=i.getByteSegments();c!==null&&a.putMetadata(we.BYTE_SEGMENTS,c);const d=i.getECLevel();return d!==null&&a.putMetadata(we.ERROR_CORRECTION_LEVEL,d),i.hasStructuredAppend()&&(a.putMetadata(we.STRUCTURED_APPEND_SEQUENCE,i.getStructuredAppendSequenceNumber()),a.putMetadata(we.STRUCTURED_APPEND_PARITY,i.getStructuredAppendParity())),a}reset(){}static extractPureBits(e){const n=e.getTopLeftOnBit(),i=e.getBottomRightOnBit();if(n===null||i===null)throw new L;const s=this.moduleSize(n,e);let a=n[1],c=i[1],d=n[0],h=i[0];if(d>=h||a>=c)throw new L;if(c-a!==h-d&&(h=d+(c-a),h>=e.getWidth()))throw new L;const p=Math.round((h-d+1)/s),w=Math.round((c-a+1)/s);if(p<=0||w<=0)throw new L;if(w!==p)throw new L;const b=Math.floor(s/2);a+=b,d+=b;const A=d+Math.floor((p-1)*s)-h;if(A>0){if(A>b)throw new L;d-=A}const N=a+Math.floor((w-1)*s)-c;if(N>0){if(N>b)throw new L;a-=N}const F=new le(p,w);for(let $=0;$<w;$++){const j=a+Math.floor($*s);for(let q=0;q<p;q++)e.get(d+Math.floor(q*s),j)&&F.set(q,$)}return F}static moduleSize(e,n){const i=n.getHeight(),s=n.getWidth();let a=e[0],c=e[1],d=!0,h=0;for(;a<s&&c<i;){if(d!==n.get(a,c)){if(++h===5)break;d=!d}a++,c++}if(a===s||c===i)throw new L;return(a-e[0])/7}}Hn.NO_POINTS=new Array;class Re{PDF417Common(){}static getBitCountSum(e){return ze.sum(e)}static toIntArray(e){if(e==null||!e.length)return Re.EMPTY_INT_ARRAY;const n=new Int32Array(e.length);let i=0;for(const s of e)n[i++]=s;return n}static getCodeword(e){const n=U.binarySearch(Re.SYMBOL_TABLE,e&262143);return n<0?-1:(Re.CODEWORD_TABLE[n]-1)%Re.NUMBER_OF_CODEWORDS}}Re.NUMBER_OF_CODEWORDS=929,Re.MAX_CODEWORDS_IN_BARCODE=Re.NUMBER_OF_CODEWORDS-1,Re.MIN_ROWS_IN_BARCODE=3,Re.MAX_ROWS_IN_BARCODE=90,Re.MODULES_IN_CODEWORD=17,Re.MODULES_IN_STOP_PATTERN=18,Re.BARS_IN_MODULE=8,Re.EMPTY_INT_ARRAY=new Int32Array([]),Re.SYMBOL_TABLE=Int32Array.from([66142,66170,66206,66236,66290,66292,66350,66382,66396,66454,66470,66476,66594,66600,66614,66626,66628,66632,66640,66654,66662,66668,66682,66690,66718,66720,66748,66758,66776,66798,66802,66804,66820,66824,66832,66846,66848,66876,66880,66936,66950,66956,66968,66992,67006,67022,67036,67042,67044,67048,67062,67118,67150,67164,67214,67228,67256,67294,67322,67350,67366,67372,67398,67404,67416,67438,67474,67476,67490,67492,67496,67510,67618,67624,67650,67656,67664,67678,67686,67692,67706,67714,67716,67728,67742,67744,67772,67782,67788,67800,67822,67826,67828,67842,67848,67870,67872,67900,67904,67960,67974,67992,68016,68030,68046,68060,68066,68068,68072,68086,68104,68112,68126,68128,68156,68160,68216,68336,68358,68364,68376,68400,68414,68448,68476,68494,68508,68536,68546,68548,68552,68560,68574,68582,68588,68654,68686,68700,68706,68708,68712,68726,68750,68764,68792,68802,68804,68808,68816,68830,68838,68844,68858,68878,68892,68920,68976,68990,68994,68996,69e3,69008,69022,69024,69052,69062,69068,69080,69102,69106,69108,69142,69158,69164,69190,69208,69230,69254,69260,69272,69296,69310,69326,69340,69386,69394,69396,69410,69416,69430,69442,69444,69448,69456,69470,69478,69484,69554,69556,69666,69672,69698,69704,69712,69726,69754,69762,69764,69776,69790,69792,69820,69830,69836,69848,69870,69874,69876,69890,69918,69920,69948,69952,70008,70022,70040,70064,70078,70094,70108,70114,70116,70120,70134,70152,70174,70176,70264,70384,70412,70448,70462,70496,70524,70542,70556,70584,70594,70600,70608,70622,70630,70636,70664,70672,70686,70688,70716,70720,70776,70896,71136,71180,71192,71216,71230,71264,71292,71360,71416,71452,71480,71536,71550,71554,71556,71560,71568,71582,71584,71612,71622,71628,71640,71662,71726,71732,71758,71772,71778,71780,71784,71798,71822,71836,71864,71874,71880,71888,71902,71910,71916,71930,71950,71964,71992,72048,72062,72066,72068,72080,72094,72096,72124,72134,72140,72152,72174,72178,72180,72206,72220,72248,72304,72318,72416,72444,72456,72464,72478,72480,72508,72512,72568,72588,72600,72624,72638,72654,72668,72674,72676,72680,72694,72726,72742,72748,72774,72780,72792,72814,72838,72856,72880,72894,72910,72924,72930,72932,72936,72950,72966,72972,72984,73008,73022,73056,73084,73102,73116,73144,73156,73160,73168,73182,73190,73196,73210,73226,73234,73236,73250,73252,73256,73270,73282,73284,73296,73310,73318,73324,73346,73348,73352,73360,73374,73376,73404,73414,73420,73432,73454,73498,73518,73522,73524,73550,73564,73570,73572,73576,73590,73800,73822,73858,73860,73872,73886,73888,73916,73944,73970,73972,73992,74014,74016,74044,74048,74104,74118,74136,74160,74174,74210,74212,74216,74230,74244,74256,74270,74272,74360,74480,74502,74508,74544,74558,74592,74620,74638,74652,74680,74690,74696,74704,74726,74732,74782,74784,74812,74992,75232,75288,75326,75360,75388,75456,75512,75576,75632,75646,75650,75652,75664,75678,75680,75708,75718,75724,75736,75758,75808,75836,75840,75896,76016,76256,76736,76824,76848,76862,76896,76924,76992,77048,77296,77340,77368,77424,77438,77536,77564,77572,77576,77584,77600,77628,77632,77688,77702,77708,77720,77744,77758,77774,77788,77870,77902,77916,77922,77928,77966,77980,78008,78018,78024,78032,78046,78060,78074,78094,78136,78192,78206,78210,78212,78224,78238,78240,78268,78278,78284,78296,78322,78324,78350,78364,78448,78462,78560,78588,78600,78622,78624,78652,78656,78712,78726,78744,78768,78782,78798,78812,78818,78820,78824,78838,78862,78876,78904,78960,78974,79072,79100,79296,79352,79368,79376,79390,79392,79420,79424,79480,79600,79628,79640,79664,79678,79712,79740,79772,79800,79810,79812,79816,79824,79838,79846,79852,79894,79910,79916,79942,79948,79960,79982,79988,80006,80024,80048,80062,80078,80092,80098,80100,80104,80134,80140,80176,80190,80224,80252,80270,80284,80312,80328,80336,80350,80358,80364,80378,80390,80396,80408,80432,80446,80480,80508,80576,80632,80654,80668,80696,80752,80766,80776,80784,80798,80800,80828,80844,80856,80878,80882,80884,80914,80916,80930,80932,80936,80950,80962,80968,80976,80990,80998,81004,81026,81028,81040,81054,81056,81084,81094,81100,81112,81134,81154,81156,81160,81168,81182,81184,81212,81216,81272,81286,81292,81304,81328,81342,81358,81372,81380,81384,81398,81434,81454,81458,81460,81486,81500,81506,81508,81512,81526,81550,81564,81592,81602,81604,81608,81616,81630,81638,81644,81702,81708,81722,81734,81740,81752,81774,81778,81780,82050,82078,82080,82108,82180,82184,82192,82206,82208,82236,82240,82296,82316,82328,82352,82366,82402,82404,82408,82440,82448,82462,82464,82492,82496,82552,82672,82694,82700,82712,82736,82750,82784,82812,82830,82882,82884,82888,82896,82918,82924,82952,82960,82974,82976,83004,83008,83064,83184,83424,83468,83480,83504,83518,83552,83580,83648,83704,83740,83768,83824,83838,83842,83844,83848,83856,83872,83900,83910,83916,83928,83950,83984,84e3,84028,84032,84088,84208,84448,84928,85040,85054,85088,85116,85184,85240,85488,85560,85616,85630,85728,85756,85764,85768,85776,85790,85792,85820,85824,85880,85894,85900,85912,85936,85966,85980,86048,86080,86136,86256,86496,86976,88160,88188,88256,88312,88560,89056,89200,89214,89312,89340,89536,89592,89608,89616,89632,89664,89720,89840,89868,89880,89904,89952,89980,89998,90012,90040,90190,90204,90254,90268,90296,90306,90308,90312,90334,90382,90396,90424,90480,90494,90500,90504,90512,90526,90528,90556,90566,90572,90584,90610,90612,90638,90652,90680,90736,90750,90848,90876,90884,90888,90896,90910,90912,90940,90944,91e3,91014,91020,91032,91056,91070,91086,91100,91106,91108,91112,91126,91150,91164,91192,91248,91262,91360,91388,91584,91640,91664,91678,91680,91708,91712,91768,91888,91928,91952,91966,92e3,92028,92046,92060,92088,92098,92100,92104,92112,92126,92134,92140,92188,92216,92272,92384,92412,92608,92664,93168,93200,93214,93216,93244,93248,93304,93424,93664,93720,93744,93758,93792,93820,93888,93944,93980,94008,94064,94078,94084,94088,94096,94110,94112,94140,94150,94156,94168,94246,94252,94278,94284,94296,94318,94342,94348,94360,94384,94398,94414,94428,94440,94470,94476,94488,94512,94526,94560,94588,94606,94620,94648,94658,94660,94664,94672,94686,94694,94700,94714,94726,94732,94744,94768,94782,94816,94844,94912,94968,94990,95004,95032,95088,95102,95112,95120,95134,95136,95164,95180,95192,95214,95218,95220,95244,95256,95280,95294,95328,95356,95424,95480,95728,95758,95772,95800,95856,95870,95968,95996,96008,96016,96030,96032,96060,96064,96120,96152,96176,96190,96220,96226,96228,96232,96290,96292,96296,96310,96322,96324,96328,96336,96350,96358,96364,96386,96388,96392,96400,96414,96416,96444,96454,96460,96472,96494,96498,96500,96514,96516,96520,96528,96542,96544,96572,96576,96632,96646,96652,96664,96688,96702,96718,96732,96738,96740,96744,96758,96772,96776,96784,96798,96800,96828,96832,96888,97008,97030,97036,97048,97072,97086,97120,97148,97166,97180,97208,97220,97224,97232,97246,97254,97260,97326,97330,97332,97358,97372,97378,97380,97384,97398,97422,97436,97464,97474,97476,97480,97488,97502,97510,97516,97550,97564,97592,97648,97666,97668,97672,97680,97694,97696,97724,97734,97740,97752,97774,97830,97836,97850,97862,97868,97880,97902,97906,97908,97926,97932,97944,97968,97998,98012,98018,98020,98024,98038,98618,98674,98676,98838,98854,98874,98892,98904,98926,98930,98932,98968,99006,99042,99044,99048,99062,99166,99194,99246,99286,99350,99366,99372,99386,99398,99416,99438,99442,99444,99462,99504,99518,99534,99548,99554,99556,99560,99574,99590,99596,99608,99632,99646,99680,99708,99726,99740,99768,99778,99780,99784,99792,99806,99814,99820,99834,99858,99860,99874,99880,99894,99906,99920,99934,99962,99970,99972,99976,99984,99998,1e5,100028,100038,100044,100056,100078,100082,100084,100142,100174,100188,100246,100262,100268,100306,100308,100390,100396,100410,100422,100428,100440,100462,100466,100468,100486,100504,100528,100542,100558,100572,100578,100580,100584,100598,100620,100656,100670,100704,100732,100750,100792,100802,100808,100816,100830,100838,100844,100858,100888,100912,100926,100960,100988,101056,101112,101148,101176,101232,101246,101250,101252,101256,101264,101278,101280,101308,101318,101324,101336,101358,101362,101364,101410,101412,101416,101430,101442,101448,101456,101470,101478,101498,101506,101508,101520,101534,101536,101564,101580,101618,101620,101636,101640,101648,101662,101664,101692,101696,101752,101766,101784,101838,101858,101860,101864,101934,101938,101940,101966,101980,101986,101988,101992,102030,102044,102072,102082,102084,102088,102096,102138,102166,102182,102188,102214,102220,102232,102254,102282,102290,102292,102306,102308,102312,102326,102444,102458,102470,102476,102488,102514,102516,102534,102552,102576,102590,102606,102620,102626,102632,102646,102662,102668,102704,102718,102752,102780,102798,102812,102840,102850,102856,102864,102878,102886,102892,102906,102936,102974,103008,103036,103104,103160,103224,103280,103294,103298,103300,103312,103326,103328,103356,103366,103372,103384,103406,103410,103412,103472,103486,103520,103548,103616,103672,103920,103992,104048,104062,104160,104188,104194,104196,104200,104208,104224,104252,104256,104312,104326,104332,104344,104368,104382,104398,104412,104418,104420,104424,104482,104484,104514,104520,104528,104542,104550,104570,104578,104580,104592,104606,104608,104636,104652,104690,104692,104706,104712,104734,104736,104764,104768,104824,104838,104856,104910,104930,104932,104936,104968,104976,104990,104992,105020,105024,105080,105200,105240,105278,105312,105372,105410,105412,105416,105424,105446,105518,105524,105550,105564,105570,105572,105576,105614,105628,105656,105666,105672,105680,105702,105722,105742,105756,105784,105840,105854,105858,105860,105864,105872,105888,105932,105970,105972,106006,106022,106028,106054,106060,106072,106100,106118,106124,106136,106160,106174,106190,106210,106212,106216,106250,106258,106260,106274,106276,106280,106306,106308,106312,106320,106334,106348,106394,106414,106418,106420,106566,106572,106610,106612,106630,106636,106648,106672,106686,106722,106724,106728,106742,106758,106764,106776,106800,106814,106848,106876,106894,106908,106936,106946,106948,106952,106960,106974,106982,106988,107032,107056,107070,107104,107132,107200,107256,107292,107320,107376,107390,107394,107396,107400,107408,107422,107424,107452,107462,107468,107480,107502,107506,107508,107544,107568,107582,107616,107644,107712,107768,108016,108060,108088,108144,108158,108256,108284,108290,108292,108296,108304,108318,108320,108348,108352,108408,108422,108428,108440,108464,108478,108494,108508,108514,108516,108520,108592,108640,108668,108736,108792,109040,109536,109680,109694,109792,109820,110016,110072,110084,110088,110096,110112,110140,110144,110200,110320,110342,110348,110360,110384,110398,110432,110460,110478,110492,110520,110532,110536,110544,110558,110658,110686,110714,110722,110724,110728,110736,110750,110752,110780,110796,110834,110836,110850,110852,110856,110864,110878,110880,110908,110912,110968,110982,111e3,111054,111074,111076,111080,111108,111112,111120,111134,111136,111164,111168,111224,111344,111372,111422,111456,111516,111554,111556,111560,111568,111590,111632,111646,111648,111676,111680,111736,111856,112096,112152,112224,112252,112320,112440,112514,112516,112520,112528,112542,112544,112588,112686,112718,112732,112782,112796,112824,112834,112836,112840,112848,112870,112890,112910,112924,112952,113008,113022,113026,113028,113032,113040,113054,113056,113100,113138,113140,113166,113180,113208,113264,113278,113376,113404,113416,113424,113440,113468,113472,113560,113614,113634,113636,113640,113686,113702,113708,113734,113740,113752,113778,113780,113798,113804,113816,113840,113854,113870,113890,113892,113896,113926,113932,113944,113968,113982,114016,114044,114076,114114,114116,114120,114128,114150,114170,114194,114196,114210,114212,114216,114242,114244,114248,114256,114270,114278,114306,114308,114312,114320,114334,114336,114364,114380,114420,114458,114478,114482,114484,114510,114524,114530,114532,114536,114842,114866,114868,114970,114994,114996,115042,115044,115048,115062,115130,115226,115250,115252,115278,115292,115298,115300,115304,115318,115342,115394,115396,115400,115408,115422,115430,115436,115450,115478,115494,115514,115526,115532,115570,115572,115738,115758,115762,115764,115790,115804,115810,115812,115816,115830,115854,115868,115896,115906,115912,115920,115934,115942,115948,115962,115996,116024,116080,116094,116098,116100,116104,116112,116126,116128,116156,116166,116172,116184,116206,116210,116212,116246,116262,116268,116282,116294,116300,116312,116334,116338,116340,116358,116364,116376,116400,116414,116430,116444,116450,116452,116456,116498,116500,116514,116520,116534,116546,116548,116552,116560,116574,116582,116588,116602,116654,116694,116714,116762,116782,116786,116788,116814,116828,116834,116836,116840,116854,116878,116892,116920,116930,116936,116944,116958,116966,116972,116986,117006,117048,117104,117118,117122,117124,117136,117150,117152,117180,117190,117196,117208,117230,117234,117236,117304,117360,117374,117472,117500,117506,117508,117512,117520,117536,117564,117568,117624,117638,117644,117656,117680,117694,117710,117724,117730,117732,117736,117750,117782,117798,117804,117818,117830,117848,117874,117876,117894,117936,117950,117966,117986,117988,117992,118022,118028,118040,118064,118078,118112,118140,118172,118210,118212,118216,118224,118238,118246,118266,118306,118312,118338,118352,118366,118374,118394,118402,118404,118408,118416,118430,118432,118460,118476,118514,118516,118574,118578,118580,118606,118620,118626,118628,118632,118678,118694,118700,118730,118738,118740,118830,118834,118836,118862,118876,118882,118884,118888,118902,118926,118940,118968,118978,118980,118984,118992,119006,119014,119020,119034,119068,119096,119152,119166,119170,119172,119176,119184,119198,119200,119228,119238,119244,119256,119278,119282,119284,119324,119352,119408,119422,119520,119548,119554,119556,119560,119568,119582,119584,119612,119616,119672,119686,119692,119704,119728,119742,119758,119772,119778,119780,119784,119798,119920,119934,120032,120060,120256,120312,120324,120328,120336,120352,120384,120440,120560,120582,120588,120600,120624,120638,120672,120700,120718,120732,120760,120770,120772,120776,120784,120798,120806,120812,120870,120876,120890,120902,120908,120920,120946,120948,120966,120972,120984,121008,121022,121038,121058,121060,121064,121078,121100,121112,121136,121150,121184,121212,121244,121282,121284,121288,121296,121318,121338,121356,121368,121392,121406,121440,121468,121536,121592,121656,121730,121732,121736,121744,121758,121760,121804,121842,121844,121890,121922,121924,121928,121936,121950,121958,121978,121986,121988,121992,122e3,122014,122016,122044,122060,122098,122100,122116,122120,122128,122142,122144,122172,122176,122232,122246,122264,122318,122338,122340,122344,122414,122418,122420,122446,122460,122466,122468,122472,122510,122524,122552,122562,122564,122568,122576,122598,122618,122646,122662,122668,122694,122700,122712,122738,122740,122762,122770,122772,122786,122788,122792,123018,123026,123028,123042,123044,123048,123062,123098,123146,123154,123156,123170,123172,123176,123190,123202,123204,123208,123216,123238,123244,123258,123290,123314,123316,123402,123410,123412,123426,123428,123432,123446,123458,123464,123472,123486,123494,123500,123514,123522,123524,123528,123536,123552,123580,123590,123596,123608,123630,123634,123636,123674,123698,123700,123740,123746,123748,123752,123834,123914,123922,123924,123938,123944,123958,123970,123976,123984,123998,124006,124012,124026,124034,124036,124048,124062,124064,124092,124102,124108,124120,124142,124146,124148,124162,124164,124168,124176,124190,124192,124220,124224,124280,124294,124300,124312,124336,124350,124366,124380,124386,124388,124392,124406,124442,124462,124466,124468,124494,124508,124514,124520,124558,124572,124600,124610,124612,124616,124624,124646,124666,124694,124710,124716,124730,124742,124748,124760,124786,124788,124818,124820,124834,124836,124840,124854,124946,124948,124962,124964,124968,124982,124994,124996,125e3,125008,125022,125030,125036,125050,125058,125060,125064,125072,125086,125088,125116,125126,125132,125144,125166,125170,125172,125186,125188,125192,125200,125216,125244,125248,125304,125318,125324,125336,125360,125374,125390,125404,125410,125412,125416,125430,125444,125448,125456,125472,125504,125560,125680,125702,125708,125720,125744,125758,125792,125820,125838,125852,125880,125890,125892,125896,125904,125918,125926,125932,125978,125998,126002,126004,126030,126044,126050,126052,126056,126094,126108,126136,126146,126148,126152,126160,126182,126202,126222,126236,126264,126320,126334,126338,126340,126344,126352,126366,126368,126412,126450,126452,126486,126502,126508,126522,126534,126540,126552,126574,126578,126580,126598,126604,126616,126640,126654,126670,126684,126690,126692,126696,126738,126754,126756,126760,126774,126786,126788,126792,126800,126814,126822,126828,126842,126894,126898,126900,126934,127126,127142,127148,127162,127178,127186,127188,127254,127270,127276,127290,127302,127308,127320,127342,127346,127348,127370,127378,127380,127394,127396,127400,127450,127510,127526,127532,127546,127558,127576,127598,127602,127604,127622,127628,127640,127664,127678,127694,127708,127714,127716,127720,127734,127754,127762,127764,127778,127784,127810,127812,127816,127824,127838,127846,127866,127898,127918,127922,127924,128022,128038,128044,128058,128070,128076,128088,128110,128114,128116,128134,128140,128152,128176,128190,128206,128220,128226,128228,128232,128246,128262,128268,128280,128304,128318,128352,128380,128398,128412,128440,128450,128452,128456,128464,128478,128486,128492,128506,128522,128530,128532,128546,128548,128552,128566,128578,128580,128584,128592,128606,128614,128634,128642,128644,128648,128656,128670,128672,128700,128716,128754,128756,128794,128814,128818,128820,128846,128860,128866,128868,128872,128886,128918,128934,128940,128954,128978,128980,129178,129198,129202,129204,129238,129258,129306,129326,129330,129332,129358,129372,129378,129380,129384,129398,129430,129446,129452,129466,129482,129490,129492,129562,129582,129586,129588,129614,129628,129634,129636,129640,129654,129678,129692,129720,129730,129732,129736,129744,129758,129766,129772,129814,129830,129836,129850,129862,129868,129880,129902,129906,129908,129930,129938,129940,129954,129956,129960,129974,130010]),Re.CODEWORD_TABLE=Int32Array.from([2627,1819,2622,2621,1813,1812,2729,2724,2723,2779,2774,2773,902,896,908,868,865,861,859,2511,873,871,1780,835,2493,825,2491,842,837,844,1764,1762,811,810,809,2483,807,2482,806,2480,815,814,813,812,2484,817,816,1745,1744,1742,1746,2655,2637,2635,2626,2625,2623,2628,1820,2752,2739,2737,2728,2727,2725,2730,2785,2783,2778,2777,2775,2780,787,781,747,739,736,2413,754,752,1719,692,689,681,2371,678,2369,700,697,694,703,1688,1686,642,638,2343,631,2341,627,2338,651,646,643,2345,654,652,1652,1650,1647,1654,601,599,2322,596,2321,594,2319,2317,611,610,608,606,2324,603,2323,615,614,612,1617,1616,1614,1612,616,1619,1618,2575,2538,2536,905,901,898,909,2509,2507,2504,870,867,864,860,2512,875,872,1781,2490,2489,2487,2485,1748,836,834,832,830,2494,827,2492,843,841,839,845,1765,1763,2701,2676,2674,2653,2648,2656,2634,2633,2631,2629,1821,2638,2636,2770,2763,2761,2750,2745,2753,2736,2735,2733,2731,1848,2740,2738,2786,2784,591,588,576,569,566,2296,1590,537,534,526,2276,522,2274,545,542,539,548,1572,1570,481,2245,466,2242,462,2239,492,485,482,2249,496,494,1534,1531,1528,1538,413,2196,406,2191,2188,425,419,2202,415,2199,432,430,427,1472,1467,1464,433,1476,1474,368,367,2160,365,2159,362,2157,2155,2152,378,377,375,2166,372,2165,369,2162,383,381,379,2168,1419,1418,1416,1414,385,1411,384,1423,1422,1420,1424,2461,802,2441,2439,790,786,783,794,2409,2406,2403,750,742,738,2414,756,753,1720,2367,2365,2362,2359,1663,693,691,684,2373,680,2370,702,699,696,704,1690,1687,2337,2336,2334,2332,1624,2329,1622,640,637,2344,634,2342,630,2340,650,648,645,2346,655,653,1653,1651,1649,1655,2612,2597,2595,2571,2568,2565,2576,2534,2529,2526,1787,2540,2537,907,904,900,910,2503,2502,2500,2498,1768,2495,1767,2510,2508,2506,869,866,863,2513,876,874,1782,2720,2713,2711,2697,2694,2691,2702,2672,2670,2664,1828,2678,2675,2647,2646,2644,2642,1823,2639,1822,2654,2652,2650,2657,2771,1855,2765,2762,1850,1849,2751,2749,2747,2754,353,2148,344,342,336,2142,332,2140,345,1375,1373,306,2130,299,2128,295,2125,319,314,311,2132,1354,1352,1349,1356,262,257,2101,253,2096,2093,274,273,267,2107,263,2104,280,278,275,1316,1311,1308,1320,1318,2052,202,2050,2044,2040,219,2063,212,2060,208,2055,224,221,2066,1260,1258,1252,231,1248,229,1266,1264,1261,1268,155,1998,153,1996,1994,1991,1988,165,164,2007,162,2006,159,2003,2e3,172,171,169,2012,166,2010,1186,1184,1182,1179,175,1176,173,1192,1191,1189,1187,176,1194,1193,2313,2307,2305,592,589,2294,2292,2289,578,572,568,2297,580,1591,2272,2267,2264,1547,538,536,529,2278,525,2275,547,544,541,1574,1571,2237,2235,2229,1493,2225,1489,478,2247,470,2244,465,2241,493,488,484,2250,498,495,1536,1533,1530,1539,2187,2186,2184,2182,1432,2179,1430,2176,1427,414,412,2197,409,2195,405,2193,2190,426,424,421,2203,418,2201,431,429,1473,1471,1469,1466,434,1477,1475,2478,2472,2470,2459,2457,2454,2462,803,2437,2432,2429,1726,2443,2440,792,789,785,2401,2399,2393,1702,2389,1699,2411,2408,2405,745,741,2415,758,755,1721,2358,2357,2355,2353,1661,2350,1660,2347,1657,2368,2366,2364,2361,1666,690,687,2374,683,2372,701,698,705,1691,1689,2619,2617,2610,2608,2605,2613,2593,2588,2585,1803,2599,2596,2563,2561,2555,1797,2551,1795,2573,2570,2567,2577,2525,2524,2522,2520,1786,2517,1785,2514,1783,2535,2533,2531,2528,1788,2541,2539,906,903,911,2721,1844,2715,2712,1838,1836,2699,2696,2693,2703,1827,1826,1824,2673,2671,2669,2666,1829,2679,2677,1858,1857,2772,1854,1853,1851,1856,2766,2764,143,1987,139,1986,135,133,131,1984,128,1983,125,1981,138,137,136,1985,1133,1132,1130,112,110,1974,107,1973,104,1971,1969,122,121,119,117,1977,114,1976,124,1115,1114,1112,1110,1117,1116,84,83,1953,81,1952,78,1950,1948,1945,94,93,91,1959,88,1958,85,1955,99,97,95,1961,1086,1085,1083,1081,1078,100,1090,1089,1087,1091,49,47,1917,44,1915,1913,1910,1907,59,1926,56,1925,53,1922,1919,66,64,1931,61,1929,1042,1040,1038,71,1035,70,1032,68,1048,1047,1045,1043,1050,1049,12,10,1869,1867,1864,1861,21,1880,19,1877,1874,1871,28,1888,25,1886,22,1883,982,980,977,974,32,30,991,989,987,984,34,995,994,992,2151,2150,2147,2146,2144,356,355,354,2149,2139,2138,2136,2134,1359,343,341,338,2143,335,2141,348,347,346,1376,1374,2124,2123,2121,2119,1326,2116,1324,310,308,305,2131,302,2129,298,2127,320,318,316,313,2133,322,321,1355,1353,1351,1357,2092,2091,2089,2087,1276,2084,1274,2081,1271,259,2102,256,2100,252,2098,2095,272,269,2108,266,2106,281,279,277,1317,1315,1313,1310,282,1321,1319,2039,2037,2035,2032,1203,2029,1200,1197,207,2053,205,2051,201,2049,2046,2043,220,218,2064,215,2062,211,2059,228,226,223,2069,1259,1257,1254,232,1251,230,1267,1265,1263,2316,2315,2312,2311,2309,2314,2304,2303,2301,2299,1593,2308,2306,590,2288,2287,2285,2283,1578,2280,1577,2295,2293,2291,579,577,574,571,2298,582,581,1592,2263,2262,2260,2258,1545,2255,1544,2252,1541,2273,2271,2269,2266,1550,535,532,2279,528,2277,546,543,549,1575,1573,2224,2222,2220,1486,2217,1485,2214,1482,1479,2238,2236,2234,2231,1496,2228,1492,480,477,2248,473,2246,469,2243,490,487,2251,497,1537,1535,1532,2477,2476,2474,2479,2469,2468,2466,2464,1730,2473,2471,2453,2452,2450,2448,1729,2445,1728,2460,2458,2456,2463,805,804,2428,2427,2425,2423,1725,2420,1724,2417,1722,2438,2436,2434,2431,1727,2444,2442,793,791,788,795,2388,2386,2384,1697,2381,1696,2378,1694,1692,2402,2400,2398,2395,1703,2392,1701,2412,2410,2407,751,748,744,2416,759,757,1807,2620,2618,1806,1805,2611,2609,2607,2614,1802,1801,1799,2594,2592,2590,2587,1804,2600,2598,1794,1793,1791,1789,2564,2562,2560,2557,1798,2554,1796,2574,2572,2569,2578,1847,1846,2722,1843,1842,1840,1845,2716,2714,1835,1834,1832,1830,1839,1837,2700,2698,2695,2704,1817,1811,1810,897,862,1777,829,826,838,1760,1758,808,2481,1741,1740,1738,1743,2624,1818,2726,2776,782,740,737,1715,686,679,695,1682,1680,639,628,2339,647,644,1645,1643,1640,1648,602,600,597,595,2320,593,2318,609,607,604,1611,1610,1608,1606,613,1615,1613,2328,926,924,892,886,899,857,850,2505,1778,824,823,821,819,2488,818,2486,833,831,828,840,1761,1759,2649,2632,2630,2746,2734,2732,2782,2781,570,567,1587,531,527,523,540,1566,1564,476,467,463,2240,486,483,1524,1521,1518,1529,411,403,2192,399,2189,423,416,1462,1457,1454,428,1468,1465,2210,366,363,2158,360,2156,357,2153,376,373,370,2163,1410,1409,1407,1405,382,1402,380,1417,1415,1412,1421,2175,2174,777,774,771,784,732,725,722,2404,743,1716,676,674,668,2363,665,2360,685,1684,1681,626,624,622,2335,620,2333,617,2330,641,635,649,1646,1644,1642,2566,928,925,2530,2527,894,891,888,2501,2499,2496,858,856,854,851,1779,2692,2668,2665,2645,2643,2640,2651,2768,2759,2757,2744,2743,2741,2748,352,1382,340,337,333,1371,1369,307,300,296,2126,315,312,1347,1342,1350,261,258,250,2097,246,2094,271,268,264,1306,1301,1298,276,1312,1309,2115,203,2048,195,2045,191,2041,213,209,2056,1246,1244,1238,225,1234,222,1256,1253,1249,1262,2080,2079,154,1997,150,1995,147,1992,1989,163,160,2004,156,2001,1175,1174,1172,1170,1167,170,1164,167,1185,1183,1180,1177,174,1190,1188,2025,2024,2022,587,586,564,559,556,2290,573,1588,520,518,512,2268,508,2265,530,1568,1565,461,457,2233,450,2230,446,2226,479,471,489,1526,1523,1520,397,395,2185,392,2183,389,2180,2177,410,2194,402,422,1463,1461,1459,1456,1470,2455,799,2433,2430,779,776,773,2397,2394,2390,734,728,724,746,1717,2356,2354,2351,2348,1658,677,675,673,670,667,688,1685,1683,2606,2589,2586,2559,2556,2552,927,2523,2521,2518,2515,1784,2532,895,893,890,2718,2709,2707,2689,2687,2684,2663,2662,2660,2658,1825,2667,2769,1852,2760,2758,142,141,1139,1138,134,132,129,126,1982,1129,1128,1126,1131,113,111,108,105,1972,101,1970,120,118,115,1109,1108,1106,1104,123,1113,1111,82,79,1951,75,1949,72,1946,92,89,86,1956,1077,1076,1074,1072,98,1069,96,1084,1082,1079,1088,1968,1967,48,45,1916,42,1914,39,1911,1908,60,57,54,1923,50,1920,1031,1030,1028,1026,67,1023,65,1020,62,1041,1039,1036,1033,69,1046,1044,1944,1943,1941,11,9,1868,7,1865,1862,1859,20,1878,16,1875,13,1872,970,968,966,963,29,960,26,23,983,981,978,975,33,971,31,990,988,985,1906,1904,1902,993,351,2145,1383,331,330,328,326,2137,323,2135,339,1372,1370,294,293,291,289,2122,286,2120,283,2117,309,303,317,1348,1346,1344,245,244,242,2090,239,2088,236,2085,2082,260,2099,249,270,1307,1305,1303,1300,1314,189,2038,186,2036,183,2033,2030,2026,206,198,2047,194,216,1247,1245,1243,1240,227,1237,1255,2310,2302,2300,2286,2284,2281,565,563,561,558,575,1589,2261,2259,2256,2253,1542,521,519,517,514,2270,511,533,1569,1567,2223,2221,2218,2215,1483,2211,1480,459,456,453,2232,449,474,491,1527,1525,1522,2475,2467,2465,2451,2449,2446,801,800,2426,2424,2421,2418,1723,2435,780,778,775,2387,2385,2382,2379,1695,2375,1693,2396,735,733,730,727,749,1718,2616,2615,2604,2603,2601,2584,2583,2581,2579,1800,2591,2550,2549,2547,2545,1792,2542,1790,2558,929,2719,1841,2710,2708,1833,1831,2690,2688,2686,1815,1809,1808,1774,1756,1754,1737,1736,1734,1739,1816,1711,1676,1674,633,629,1638,1636,1633,1641,598,1605,1604,1602,1600,605,1609,1607,2327,887,853,1775,822,820,1757,1755,1584,524,1560,1558,468,464,1514,1511,1508,1519,408,404,400,1452,1447,1444,417,1458,1455,2208,364,361,358,2154,1401,1400,1398,1396,374,1393,371,1408,1406,1403,1413,2173,2172,772,726,723,1712,672,669,666,682,1678,1675,625,623,621,618,2331,636,632,1639,1637,1635,920,918,884,880,889,849,848,847,846,2497,855,852,1776,2641,2742,2787,1380,334,1367,1365,301,297,1340,1338,1335,1343,255,251,247,1296,1291,1288,265,1302,1299,2113,204,196,192,2042,1232,1230,1224,214,1220,210,1242,1239,1235,1250,2077,2075,151,148,1993,144,1990,1163,1162,1160,1158,1155,161,1152,157,1173,1171,1168,1165,168,1181,1178,2021,2020,2018,2023,585,560,557,1585,516,509,1562,1559,458,447,2227,472,1516,1513,1510,398,396,393,390,2181,386,2178,407,1453,1451,1449,1446,420,1460,2209,769,764,720,712,2391,729,1713,664,663,661,659,2352,656,2349,671,1679,1677,2553,922,919,2519,2516,885,883,881,2685,2661,2659,2767,2756,2755,140,1137,1136,130,127,1125,1124,1122,1127,109,106,102,1103,1102,1100,1098,116,1107,1105,1980,80,76,73,1947,1068,1067,1065,1063,90,1060,87,1075,1073,1070,1080,1966,1965,46,43,40,1912,36,1909,1019,1018,1016,1014,58,1011,55,1008,51,1029,1027,1024,1021,63,1037,1034,1940,1939,1937,1942,8,1866,4,1863,1,1860,956,954,952,949,946,17,14,969,967,964,961,27,957,24,979,976,972,1901,1900,1898,1896,986,1905,1903,350,349,1381,329,327,324,1368,1366,292,290,287,284,2118,304,1341,1339,1337,1345,243,240,237,2086,233,2083,254,1297,1295,1293,1290,1304,2114,190,187,184,2034,180,2031,177,2027,199,1233,1231,1229,1226,217,1223,1241,2078,2076,584,555,554,552,550,2282,562,1586,507,506,504,502,2257,499,2254,515,1563,1561,445,443,441,2219,438,2216,435,2212,460,454,475,1517,1515,1512,2447,798,797,2422,2419,770,768,766,2383,2380,2376,721,719,717,714,731,1714,2602,2582,2580,2548,2546,2543,923,921,2717,2706,2705,2683,2682,2680,1771,1752,1750,1733,1732,1731,1735,1814,1707,1670,1668,1631,1629,1626,1634,1599,1598,1596,1594,1603,1601,2326,1772,1753,1751,1581,1554,1552,1504,1501,1498,1509,1442,1437,1434,401,1448,1445,2206,1392,1391,1389,1387,1384,359,1399,1397,1394,1404,2171,2170,1708,1672,1669,619,1632,1630,1628,1773,1378,1363,1361,1333,1328,1336,1286,1281,1278,248,1292,1289,2111,1218,1216,1210,197,1206,193,1228,1225,1221,1236,2073,2071,1151,1150,1148,1146,152,1143,149,1140,145,1161,1159,1156,1153,158,1169,1166,2017,2016,2014,2019,1582,510,1556,1553,452,448,1506,1500,394,391,387,1443,1441,1439,1436,1450,2207,765,716,713,1709,662,660,657,1673,1671,916,914,879,878,877,882,1135,1134,1121,1120,1118,1123,1097,1096,1094,1092,103,1101,1099,1979,1059,1058,1056,1054,77,1051,74,1066,1064,1061,1071,1964,1963,1007,1006,1004,1002,999,41,996,37,1017,1015,1012,1009,52,1025,1022,1936,1935,1933,1938,942,940,938,935,932,5,2,955,953,950,947,18,943,15,965,962,958,1895,1894,1892,1890,973,1899,1897,1379,325,1364,1362,288,285,1334,1332,1330,241,238,234,1287,1285,1283,1280,1294,2112,188,185,181,178,2028,1219,1217,1215,1212,200,1209,1227,2074,2072,583,553,551,1583,505,503,500,513,1557,1555,444,442,439,436,2213,455,451,1507,1505,1502,796,763,762,760,767,711,710,708,706,2377,718,715,1710,2544,917,915,2681,1627,1597,1595,2325,1769,1749,1747,1499,1438,1435,2204,1390,1388,1385,1395,2169,2167,1704,1665,1662,1625,1623,1620,1770,1329,1282,1279,2109,1214,1207,1222,2068,2065,1149,1147,1144,1141,146,1157,1154,2013,2011,2008,2015,1579,1549,1546,1495,1487,1433,1431,1428,1425,388,1440,2205,1705,658,1667,1664,1119,1095,1093,1978,1057,1055,1052,1062,1962,1960,1005,1003,1e3,997,38,1013,1010,1932,1930,1927,1934,941,939,936,933,6,930,3,951,948,944,1889,1887,1884,1881,959,1893,1891,35,1377,1360,1358,1327,1325,1322,1331,1277,1275,1272,1269,235,1284,2110,1205,1204,1201,1198,182,1195,179,1213,2070,2067,1580,501,1551,1548,440,437,1497,1494,1490,1503,761,709,707,1706,913,912,2198,1386,2164,2161,1621,1766,2103,1208,2058,2054,1145,1142,2005,2002,1999,2009,1488,1429,1426,2200,1698,1659,1656,1975,1053,1957,1954,1001,998,1924,1921,1918,1928,937,934,931,1879,1876,1873,1870,945,1885,1882,1323,1273,1270,2105,1202,1199,1196,1211,2061,2057,1576,1543,1540,1484,1481,1478,1491,1700]);class _1{constructor(e,n){this.bits=e,this.points=n}getBits(){return this.bits}getPoints(){return this.points}}class Pe{static detectMultiple(e,n,i){let s=e.getBlackMatrix(),a=Pe.detect(i,s);return a.length||(s=s.clone(),s.rotate180(),a=Pe.detect(i,s)),new _1(s,a)}static detect(e,n){const i=new Array;let s=0,a=0,c=!1;for(;s<n.getHeight();){const d=Pe.findVertices(n,s,a);if(d[0]==null&&d[3]==null){if(!c)break;c=!1,a=0;for(const h of i)h[1]!=null&&(s=Math.trunc(Math.max(s,h[1].getY()))),h[3]!=null&&(s=Math.max(s,Math.trunc(h[3].getY())));s+=Pe.ROW_STEP;continue}if(c=!0,i.push(d),!e)break;d[2]!=null?(a=Math.trunc(d[2].getX()),s=Math.trunc(d[2].getY())):(a=Math.trunc(d[4].getX()),s=Math.trunc(d[4].getY()))}return i}static findVertices(e,n,i){const s=e.getHeight(),a=e.getWidth(),c=new Array(8);return Pe.copyToResult(c,Pe.findRowsWithPattern(e,s,a,n,i,Pe.START_PATTERN),Pe.INDEXES_START_PATTERN),c[4]!=null&&(i=Math.trunc(c[4].getX()),n=Math.trunc(c[4].getY())),Pe.copyToResult(c,Pe.findRowsWithPattern(e,s,a,n,i,Pe.STOP_PATTERN),Pe.INDEXES_STOP_PATTERN),c}static copyToResult(e,n,i){for(let s=0;s<i.length;s++)e[i[s]]=n[s]}static findRowsWithPattern(e,n,i,s,a,c){const d=new Array(4);let h=!1;const p=new Int32Array(c.length);for(;s<n;s+=Pe.ROW_STEP){let b=Pe.findGuardPattern(e,a,s,i,!1,c,p);if(b!=null){for(;s>0;){const A=Pe.findGuardPattern(e,a,--s,i,!1,c,p);if(A!=null)b=A;else{s++;break}}d[0]=new Se(b[0],s),d[1]=new Se(b[1],s),h=!0;break}}let w=s+1;if(h){let b=0,A=Int32Array.from([Math.trunc(d[0].getX()),Math.trunc(d[1].getX())]);for(;w<n;w++){const N=Pe.findGuardPattern(e,A[0],w,i,!1,c,p);if(N!=null&&Math.abs(A[0]-N[0])<Pe.MAX_PATTERN_DRIFT&&Math.abs(A[1]-N[1])<Pe.MAX_PATTERN_DRIFT)A=N,b=0;else{if(b>Pe.SKIPPED_ROW_COUNT_MAX)break;b++}}w-=b+1,d[2]=new Se(A[0],w),d[3]=new Se(A[1],w)}return w-s<Pe.BARCODE_MIN_HEIGHT&&U.fill(d,null),d}static findGuardPattern(e,n,i,s,a,c,d){U.fillWithin(d,0,d.length,0);let h=n,p=0;for(;e.get(h,i)&&h>0&&p++<Pe.MAX_PIXEL_DRIFT;)h--;let w=h,b=0,A=c.length;for(let N=a;w<s;w++)if(e.get(w,i)!==N)d[b]++;else{if(b===A-1){if(Pe.patternMatchVariance(d,c,Pe.MAX_INDIVIDUAL_VARIANCE)<Pe.MAX_AVG_VARIANCE)return new Int32Array([h,w]);h+=d[0]+d[1],R.arraycopy(d,2,d,0,b-1),d[b-1]=0,d[b]=0,b--}else b++;d[b]=1,N=!N}return b===A-1&&Pe.patternMatchVariance(d,c,Pe.MAX_INDIVIDUAL_VARIANCE)<Pe.MAX_AVG_VARIANCE?new Int32Array([h,w-1]):null}static patternMatchVariance(e,n,i){let s=e.length,a=0,c=0;for(let p=0;p<s;p++)a+=e[p],c+=n[p];if(a<c)return 1/0;let d=a/c;i*=d;let h=0;for(let p=0;p<s;p++){let w=e[p],b=n[p]*d,A=w>b?w-b:b-w;if(A>i)return 1/0;h+=A}return h/a}}Pe.INDEXES_START_PATTERN=Int32Array.from([0,4,1,5]),Pe.INDEXES_STOP_PATTERN=Int32Array.from([6,2,7,3]),Pe.MAX_AVG_VARIANCE=.42,Pe.MAX_INDIVIDUAL_VARIANCE=.8,Pe.START_PATTERN=Int32Array.from([8,1,1,1,1,1,1,3]),Pe.STOP_PATTERN=Int32Array.from([7,1,1,3,1,1,1,2,1]),Pe.MAX_PIXEL_DRIFT=3,Pe.MAX_PATTERN_DRIFT=5,Pe.SKIPPED_ROW_COUNT_MAX=25,Pe.ROW_STEP=5,Pe.BARCODE_MIN_HEIGHT=10;class Pt{constructor(e,n){if(n.length===0)throw new C;this.field=e;let i=n.length;if(i>1&&n[0]===0){let s=1;for(;s<i&&n[s]===0;)s++;s===i?this.coefficients=new Int32Array([0]):(this.coefficients=new Int32Array(i-s),R.arraycopy(n,s,this.coefficients,0,this.coefficients.length))}else this.coefficients=n}getCoefficients(){return this.coefficients}getDegree(){return this.coefficients.length-1}isZero(){return this.coefficients[0]===0}getCoefficient(e){return this.coefficients[this.coefficients.length-1-e]}evaluateAt(e){if(e===0)return this.getCoefficient(0);if(e===1){let s=0;for(let a of this.coefficients)s=this.field.add(s,a);return s}let n=this.coefficients[0],i=this.coefficients.length;for(let s=1;s<i;s++)n=this.field.add(this.field.multiply(e,n),this.coefficients[s]);return n}add(e){if(!this.field.equals(e.field))throw new C("ModulusPolys do not have same ModulusGF field");if(this.isZero())return e;if(e.isZero())return this;let n=this.coefficients,i=e.coefficients;if(n.length>i.length){let c=n;n=i,i=c}let s=new Int32Array(i.length),a=i.length-n.length;R.arraycopy(i,0,s,0,a);for(let c=a;c<i.length;c++)s[c]=this.field.add(n[c-a],i[c]);return new Pt(this.field,s)}subtract(e){if(!this.field.equals(e.field))throw new C("ModulusPolys do not have same ModulusGF field");return e.isZero()?this:this.add(e.negative())}multiply(e){return e instanceof Pt?this.multiplyOther(e):this.multiplyScalar(e)}multiplyOther(e){if(!this.field.equals(e.field))throw new C("ModulusPolys do not have same ModulusGF field");if(this.isZero()||e.isZero())return new Pt(this.field,new Int32Array([0]));let n=this.coefficients,i=n.length,s=e.coefficients,a=s.length,c=new Int32Array(i+a-1);for(let d=0;d<i;d++){let h=n[d];for(let p=0;p<a;p++)c[d+p]=this.field.add(c[d+p],this.field.multiply(h,s[p]))}return new Pt(this.field,c)}negative(){let e=this.coefficients.length,n=new Int32Array(e);for(let i=0;i<e;i++)n[i]=this.field.subtract(0,this.coefficients[i]);return new Pt(this.field,n)}multiplyScalar(e){if(e===0)return new Pt(this.field,new Int32Array([0]));if(e===1)return this;let n=this.coefficients.length,i=new Int32Array(n);for(let s=0;s<n;s++)i[s]=this.field.multiply(this.coefficients[s],e);return new Pt(this.field,i)}multiplyByMonomial(e,n){if(e<0)throw new C;if(n===0)return new Pt(this.field,new Int32Array([0]));let i=this.coefficients.length,s=new Int32Array(i+e);for(let a=0;a<i;a++)s[a]=this.field.multiply(this.coefficients[a],n);return new Pt(this.field,s)}toString(){let e=new Ce;for(let n=this.getDegree();n>=0;n--){let i=this.getCoefficient(n);i!==0&&(i<0?(e.append(" - "),i=-i):e.length()>0&&e.append(" + "),(n===0||i!==1)&&e.append(i),n!==0&&(n===1?e.append("x"):(e.append("x^"),e.append(n))))}return e.toString()}}class v1{add(e,n){return(e+n)%this.modulus}subtract(e,n){return(this.modulus+e-n)%this.modulus}exp(e){return this.expTable[e]}log(e){if(e===0)throw new C;return this.logTable[e]}inverse(e){if(e===0)throw new an;return this.expTable[this.modulus-this.logTable[e]-1]}multiply(e,n){return e===0||n===0?0:this.expTable[(this.logTable[e]+this.logTable[n])%(this.modulus-1)]}getSize(){return this.modulus}equals(e){return e===this}}class uo extends v1{constructor(e,n){super(),this.modulus=e,this.expTable=new Int32Array(e),this.logTable=new Int32Array(e);let i=1;for(let s=0;s<e;s++)this.expTable[s]=i,i=i*n%e;for(let s=0;s<e-1;s++)this.logTable[this.expTable[s]]=s;this.zero=new Pt(this,new Int32Array([0])),this.one=new Pt(this,new Int32Array([1]))}getZero(){return this.zero}getOne(){return this.one}buildMonomial(e,n){if(e<0)throw new C;if(n===0)return this.zero;let i=new Int32Array(e+1);return i[0]=n,new Pt(this,i)}}uo.PDF417_GF=new uo(Re.NUMBER_OF_CODEWORDS,3);class Es{constructor(){this.field=uo.PDF417_GF}decode(e,n,i){let s=new Pt(this.field,e),a=new Int32Array(n),c=!1;for(let F=n;F>0;F--){let $=s.evaluateAt(this.field.exp(F));a[n-F]=$,$!==0&&(c=!0)}if(!c)return 0;let d=this.field.getOne();if(i!=null)for(const F of i){let $=this.field.exp(e.length-1-F),j=new Pt(this.field,new Int32Array([this.field.subtract(0,$),1]));d=d.multiply(j)}let h=new Pt(this.field,a),p=this.runEuclideanAlgorithm(this.field.buildMonomial(n,1),h,n),w=p[0],b=p[1],A=this.findErrorLocations(w),N=this.findErrorMagnitudes(b,w,A);for(let F=0;F<A.length;F++){let $=e.length-1-this.field.log(A[F]);if($<0)throw O.getChecksumInstance();e[$]=this.field.subtract(e[$],N[F])}return A.length}runEuclideanAlgorithm(e,n,i){if(e.getDegree()<n.getDegree()){let A=e;e=n,n=A}let s=e,a=n,c=this.field.getZero(),d=this.field.getOne();for(;a.getDegree()>=Math.round(i/2);){let A=s,N=c;if(s=a,c=d,s.isZero())throw O.getChecksumInstance();a=A;let F=this.field.getZero(),$=s.getCoefficient(s.getDegree()),j=this.field.inverse($);for(;a.getDegree()>=s.getDegree()&&!a.isZero();){let q=a.getDegree()-s.getDegree(),se=this.field.multiply(a.getCoefficient(a.getDegree()),j);F=F.add(this.field.buildMonomial(q,se)),a=a.subtract(s.multiplyByMonomial(q,se))}d=F.multiply(c).subtract(N).negative()}let h=d.getCoefficient(0);if(h===0)throw O.getChecksumInstance();let p=this.field.inverse(h),w=d.multiply(p),b=a.multiply(p);return[w,b]}findErrorLocations(e){let n=e.getDegree(),i=new Int32Array(n),s=0;for(let a=1;a<this.field.getSize()&&s<n;a++)e.evaluateAt(a)===0&&(i[s]=this.field.inverse(a),s++);if(s!==n)throw O.getChecksumInstance();return i}findErrorMagnitudes(e,n,i){let s=n.getDegree(),a=new Int32Array(s);for(let p=1;p<=s;p++)a[s-p]=this.field.multiply(p,n.getCoefficient(p));let c=new Pt(this.field,a),d=i.length,h=new Int32Array(d);for(let p=0;p<d;p++){let w=this.field.inverse(i[p]),b=this.field.subtract(0,e.evaluateAt(w)),A=this.field.inverse(c.evaluateAt(w));h[p]=this.field.multiply(b,A)}return h}}class nr{constructor(e,n,i,s,a){e instanceof nr?this.constructor_2(e):this.constructor_1(e,n,i,s,a)}constructor_1(e,n,i,s,a){const c=n==null||i==null,d=s==null||a==null;if(c&&d)throw new L;c?(n=new Se(0,s.getY()),i=new Se(0,a.getY())):d&&(s=new Se(e.getWidth()-1,n.getY()),a=new Se(e.getWidth()-1,i.getY())),this.image=e,this.topLeft=n,this.bottomLeft=i,this.topRight=s,this.bottomRight=a,this.minX=Math.trunc(Math.min(n.getX(),i.getX())),this.maxX=Math.trunc(Math.max(s.getX(),a.getX())),this.minY=Math.trunc(Math.min(n.getY(),s.getY())),this.maxY=Math.trunc(Math.max(i.getY(),a.getY()))}constructor_2(e){this.image=e.image,this.topLeft=e.getTopLeft(),this.bottomLeft=e.getBottomLeft(),this.topRight=e.getTopRight(),this.bottomRight=e.getBottomRight(),this.minX=e.getMinX(),this.maxX=e.getMaxX(),this.minY=e.getMinY(),this.maxY=e.getMaxY()}static merge(e,n){return e==null?n:n==null?e:new nr(e.image,e.topLeft,e.bottomLeft,n.topRight,n.bottomRight)}addMissingRows(e,n,i){let s=this.topLeft,a=this.bottomLeft,c=this.topRight,d=this.bottomRight;if(e>0){let h=i?this.topLeft:this.topRight,p=Math.trunc(h.getY()-e);p<0&&(p=0);let w=new Se(h.getX(),p);i?s=w:c=w}if(n>0){let h=i?this.bottomLeft:this.bottomRight,p=Math.trunc(h.getY()+n);p>=this.image.getHeight()&&(p=this.image.getHeight()-1);let w=new Se(h.getX(),p);i?a=w:d=w}return new nr(this.image,s,a,c,d)}getMinX(){return this.minX}getMaxX(){return this.maxX}getMinY(){return this.minY}getMaxY(){return this.maxY}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}getBottomLeft(){return this.bottomLeft}getBottomRight(){return this.bottomRight}}class b1{constructor(e,n,i,s){this.columnCount=e,this.errorCorrectionLevel=s,this.rowCountUpperPart=n,this.rowCountLowerPart=i,this.rowCount=n+i}getColumnCount(){return this.columnCount}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getRowCount(){return this.rowCount}getRowCountUpperPart(){return this.rowCountUpperPart}getRowCountLowerPart(){return this.rowCountLowerPart}}class Nr{constructor(){this.buffer=""}static form(e,n){let i=-1;function s(c,d,h,p,w,b){if(c==="%%")return"%";if(n[++i]===void 0)return;c=p?parseInt(p.substr(1)):void 0;let A=w?parseInt(w.substr(1)):void 0,N;switch(b){case"s":N=n[i];break;case"c":N=n[i][0];break;case"f":N=parseFloat(n[i]).toFixed(c);break;case"p":N=parseFloat(n[i]).toPrecision(c);break;case"e":N=parseFloat(n[i]).toExponential(c);break;case"x":N=parseInt(n[i]).toString(A||16);break;case"d":N=parseFloat(parseInt(n[i],A||10).toPrecision(c)).toFixed(0);break}N=typeof N=="object"?JSON.stringify(N):(+N).toString(A);let F=parseInt(h),$=h&&h[0]+""=="0"?"0":" ";for(;N.length<F;)N=d!==void 0?N+$:$+N;return N}let a=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return e.replace(a,s)}format(e,...n){this.buffer+=Nr.form(e,n)}toString(){return this.buffer}}class Or{constructor(e){this.boundingBox=new nr(e),this.codewords=new Array(e.getMaxY()-e.getMinY()+1)}getCodewordNearby(e){let n=this.getCodeword(e);if(n!=null)return n;for(let i=1;i<Or.MAX_NEARBY_DISTANCE;i++){let s=this.imageRowToCodewordIndex(e)-i;if(s>=0&&(n=this.codewords[s],n!=null)||(s=this.imageRowToCodewordIndex(e)+i,s<this.codewords.length&&(n=this.codewords[s],n!=null)))return n}return null}imageRowToCodewordIndex(e){return e-this.boundingBox.getMinY()}setCodeword(e,n){this.codewords[this.imageRowToCodewordIndex(e)]=n}getCodeword(e){return this.codewords[this.imageRowToCodewordIndex(e)]}getBoundingBox(){return this.boundingBox}getCodewords(){return this.codewords}toString(){const e=new Nr;let n=0;for(const i of this.codewords){if(i==null){e.format("%3d: | %n",n++);continue}e.format("%3d: %3d|%3d%n",n++,i.getRowNumber(),i.getValue())}return e.toString()}}Or.MAX_NEARBY_DISTANCE=5;class kr{constructor(){this.values=new Map}setValue(e){e=Math.trunc(e);let n=this.values.get(e);n==null&&(n=0),n++,this.values.set(e,n)}getValue(){let e=-1,n=new Array;for(const[i,s]of this.values.entries()){const a={getKey:()=>i,getValue:()=>s};a.getValue()>e?(e=a.getValue(),n=[],n.push(a.getKey())):a.getValue()===e&&n.push(a.getKey())}return Re.toIntArray(n)}getConfidence(e){return this.values.get(e)}}class As extends Or{constructor(e,n){super(e),this._isLeft=n}setRowNumbers(){for(let e of this.getCodewords())e?.setRowNumberAsRowIndicatorColumn()}adjustCompleteIndicatorColumnRowNumbers(e){let n=this.getCodewords();this.setRowNumbers(),this.removeIncorrectCodewords(n,e);let i=this.getBoundingBox(),s=this._isLeft?i.getTopLeft():i.getTopRight(),a=this._isLeft?i.getBottomLeft():i.getBottomRight(),c=this.imageRowToCodewordIndex(Math.trunc(s.getY())),d=this.imageRowToCodewordIndex(Math.trunc(a.getY())),h=-1,p=1,w=0;for(let b=c;b<d;b++){if(n[b]==null)continue;let A=n[b],N=A.getRowNumber()-h;if(N===0)w++;else if(N===1)p=Math.max(p,w),w=1,h=A.getRowNumber();else if(N<0||A.getRowNumber()>=e.getRowCount()||N>b)n[b]=null;else{let F;p>2?F=(p-2)*N:F=N;let $=F>=b;for(let j=1;j<=F&&!$;j++)$=n[b-j]!=null;$?n[b]=null:(h=A.getRowNumber(),w=1)}}}getRowHeights(){let e=this.getBarcodeMetadata();if(e==null)return null;this.adjustIncompleteIndicatorColumnRowNumbers(e);let n=new Int32Array(e.getRowCount());for(let i of this.getCodewords())if(i!=null){let s=i.getRowNumber();if(s>=n.length)continue;n[s]++}return n}adjustIncompleteIndicatorColumnRowNumbers(e){let n=this.getBoundingBox(),i=this._isLeft?n.getTopLeft():n.getTopRight(),s=this._isLeft?n.getBottomLeft():n.getBottomRight(),a=this.imageRowToCodewordIndex(Math.trunc(i.getY())),c=this.imageRowToCodewordIndex(Math.trunc(s.getY())),d=this.getCodewords(),h=-1;for(let p=a;p<c;p++){if(d[p]==null)continue;let w=d[p];w.setRowNumberAsRowIndicatorColumn();let b=w.getRowNumber()-h;b===0||(b===1?h=w.getRowNumber():w.getRowNumber()>=e.getRowCount()?d[p]=null:h=w.getRowNumber())}}getBarcodeMetadata(){let e=this.getCodewords(),n=new kr,i=new kr,s=new kr,a=new kr;for(let d of e){if(d==null)continue;d.setRowNumberAsRowIndicatorColumn();let h=d.getValue()%30,p=d.getRowNumber();switch(this._isLeft||(p+=2),p%3){case 0:i.setValue(h*3+1);break;case 1:a.setValue(h/3),s.setValue(h%3);break;case 2:n.setValue(h+1);break}}if(n.getValue().length===0||i.getValue().length===0||s.getValue().length===0||a.getValue().length===0||n.getValue()[0]<1||i.getValue()[0]+s.getValue()[0]<Re.MIN_ROWS_IN_BARCODE||i.getValue()[0]+s.getValue()[0]>Re.MAX_ROWS_IN_BARCODE)return null;let c=new b1(n.getValue()[0],i.getValue()[0],s.getValue()[0],a.getValue()[0]);return this.removeIncorrectCodewords(e,c),c}removeIncorrectCodewords(e,n){for(let i=0;i<e.length;i++){let s=e[i];if(e[i]==null)continue;let a=s.getValue()%30,c=s.getRowNumber();if(c>n.getRowCount()){e[i]=null;continue}switch(this._isLeft||(c+=2),c%3){case 0:a*3+1!==n.getRowCountUpperPart()&&(e[i]=null);break;case 1:(Math.trunc(a/3)!==n.getErrorCorrectionLevel()||a%3!==n.getRowCountLowerPart())&&(e[i]=null);break;case 2:a+1!==n.getColumnCount()&&(e[i]=null);break}}}isLeft(){return this._isLeft}toString(){return"IsLeft: "+this._isLeft+`
84
+ `+super.toString()}}class Rr{constructor(e,n){this.ADJUST_ROW_NUMBER_SKIP=2,this.barcodeMetadata=e,this.barcodeColumnCount=e.getColumnCount(),this.boundingBox=n,this.detectionResultColumns=new Array(this.barcodeColumnCount+2)}getDetectionResultColumns(){this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[0]),this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[this.barcodeColumnCount+1]);let e=Re.MAX_CODEWORDS_IN_BARCODE,n;do n=e,e=this.adjustRowNumbersAndGetCount();while(e>0&&e<n);return this.detectionResultColumns}adjustIndicatorColumnRowNumbers(e){e?.adjustCompleteIndicatorColumnRowNumbers(this.barcodeMetadata)}adjustRowNumbersAndGetCount(){let e=this.adjustRowNumbersByRow();if(e===0)return 0;for(let n=1;n<this.barcodeColumnCount+1;n++){let i=this.detectionResultColumns[n].getCodewords();for(let s=0;s<i.length;s++)i[s]!=null&&(i[s].hasValidRowNumber()||this.adjustRowNumbers(n,s,i))}return e}adjustRowNumbersByRow(){return this.adjustRowNumbersFromBothRI(),this.adjustRowNumbersFromLRI()+this.adjustRowNumbersFromRRI()}adjustRowNumbersFromBothRI(){if(this.detectionResultColumns[0]==null||this.detectionResultColumns[this.barcodeColumnCount+1]==null)return;let e=this.detectionResultColumns[0].getCodewords(),n=this.detectionResultColumns[this.barcodeColumnCount+1].getCodewords();for(let i=0;i<e.length;i++)if(e[i]!=null&&n[i]!=null&&e[i].getRowNumber()===n[i].getRowNumber())for(let s=1;s<=this.barcodeColumnCount;s++){let a=this.detectionResultColumns[s].getCodewords()[i];a!=null&&(a.setRowNumber(e[i].getRowNumber()),a.hasValidRowNumber()||(this.detectionResultColumns[s].getCodewords()[i]=null))}}adjustRowNumbersFromRRI(){if(this.detectionResultColumns[this.barcodeColumnCount+1]==null)return 0;let e=0,n=this.detectionResultColumns[this.barcodeColumnCount+1].getCodewords();for(let i=0;i<n.length;i++){if(n[i]==null)continue;let s=n[i].getRowNumber(),a=0;for(let c=this.barcodeColumnCount+1;c>0&&a<this.ADJUST_ROW_NUMBER_SKIP;c--){let d=this.detectionResultColumns[c].getCodewords()[i];d!=null&&(a=Rr.adjustRowNumberIfValid(s,a,d),d.hasValidRowNumber()||e++)}}return e}adjustRowNumbersFromLRI(){if(this.detectionResultColumns[0]==null)return 0;let e=0,n=this.detectionResultColumns[0].getCodewords();for(let i=0;i<n.length;i++){if(n[i]==null)continue;let s=n[i].getRowNumber(),a=0;for(let c=1;c<this.barcodeColumnCount+1&&a<this.ADJUST_ROW_NUMBER_SKIP;c++){let d=this.detectionResultColumns[c].getCodewords()[i];d!=null&&(a=Rr.adjustRowNumberIfValid(s,a,d),d.hasValidRowNumber()||e++)}}return e}static adjustRowNumberIfValid(e,n,i){return i==null||i.hasValidRowNumber()||(i.isValidRowNumber(e)?(i.setRowNumber(e),n=0):++n),n}adjustRowNumbers(e,n,i){if(!this.detectionResultColumns[e-1])return;let s=i[n],a=this.detectionResultColumns[e-1].getCodewords(),c=a;this.detectionResultColumns[e+1]!=null&&(c=this.detectionResultColumns[e+1].getCodewords());let d=new Array(14);d[2]=a[n],d[3]=c[n],n>0&&(d[0]=i[n-1],d[4]=a[n-1],d[5]=c[n-1]),n>1&&(d[8]=i[n-2],d[10]=a[n-2],d[11]=c[n-2]),n<i.length-1&&(d[1]=i[n+1],d[6]=a[n+1],d[7]=c[n+1]),n<i.length-2&&(d[9]=i[n+2],d[12]=a[n+2],d[13]=c[n+2]);for(let h of d)if(Rr.adjustRowNumber(s,h))return}static adjustRowNumber(e,n){return n==null?!1:n.hasValidRowNumber()&&n.getBucket()===e.getBucket()?(e.setRowNumber(n.getRowNumber()),!0):!1}getBarcodeColumnCount(){return this.barcodeColumnCount}getBarcodeRowCount(){return this.barcodeMetadata.getRowCount()}getBarcodeECLevel(){return this.barcodeMetadata.getErrorCorrectionLevel()}setBoundingBox(e){this.boundingBox=e}getBoundingBox(){return this.boundingBox}setDetectionResultColumn(e,n){this.detectionResultColumns[e]=n}getDetectionResultColumn(e){return this.detectionResultColumns[e]}toString(){let e=this.detectionResultColumns[0];e==null&&(e=this.detectionResultColumns[this.barcodeColumnCount+1]);let n=new Nr;for(let i=0;i<e.getCodewords().length;i++){n.format("CW %3d:",i);for(let s=0;s<this.barcodeColumnCount+2;s++){if(this.detectionResultColumns[s]==null){n.format(" | ");continue}let a=this.detectionResultColumns[s].getCodewords()[i];if(a==null){n.format(" | ");continue}n.format(" %3d|%3d",a.getRowNumber(),a.getValue())}n.format("%n")}return n.toString()}}class Dr{constructor(e,n,i,s){this.rowNumber=Dr.BARCODE_ROW_UNKNOWN,this.startX=Math.trunc(e),this.endX=Math.trunc(n),this.bucket=Math.trunc(i),this.value=Math.trunc(s)}hasValidRowNumber(){return this.isValidRowNumber(this.rowNumber)}isValidRowNumber(e){return e!==Dr.BARCODE_ROW_UNKNOWN&&this.bucket===e%3*3}setRowNumberAsRowIndicatorColumn(){this.rowNumber=Math.trunc(Math.trunc(this.value/30)*3+Math.trunc(this.bucket/3))}getWidth(){return this.endX-this.startX}getStartX(){return this.startX}getEndX(){return this.endX}getBucket(){return this.bucket}getValue(){return this.value}getRowNumber(){return this.rowNumber}setRowNumber(e){this.rowNumber=e}toString(){return this.rowNumber+"|"+this.value}}Dr.BARCODE_ROW_UNKNOWN=-1;class Jt{static initialize(){for(let e=0;e<Re.SYMBOL_TABLE.length;e++){let n=Re.SYMBOL_TABLE[e],i=n&1;for(let s=0;s<Re.BARS_IN_MODULE;s++){let a=0;for(;(n&1)===i;)a+=1,n>>=1;i=n&1,Jt.RATIOS_TABLE[e]||(Jt.RATIOS_TABLE[e]=new Array(Re.BARS_IN_MODULE)),Jt.RATIOS_TABLE[e][Re.BARS_IN_MODULE-s-1]=Math.fround(a/Re.MODULES_IN_CODEWORD)}}this.bSymbolTableReady=!0}static getDecodedValue(e){let n=Jt.getDecodedCodewordValue(Jt.sampleBitCounts(e));return n!==-1?n:Jt.getClosestDecodedValue(e)}static sampleBitCounts(e){let n=ze.sum(e),i=new Int32Array(Re.BARS_IN_MODULE),s=0,a=0;for(let c=0;c<Re.MODULES_IN_CODEWORD;c++){let d=n/(2*Re.MODULES_IN_CODEWORD)+c*n/Re.MODULES_IN_CODEWORD;a+e[s]<=d&&(a+=e[s],s++),i[s]++}return i}static getDecodedCodewordValue(e){let n=Jt.getBitValue(e);return Re.getCodeword(n)===-1?-1:n}static getBitValue(e){let n=0;for(let i=0;i<e.length;i++)for(let s=0;s<e[i];s++)n=n<<1|(i%2===0?1:0);return Math.trunc(n)}static getClosestDecodedValue(e){let n=ze.sum(e),i=new Array(Re.BARS_IN_MODULE);if(n>1)for(let c=0;c<i.length;c++)i[c]=Math.fround(e[c]/n);let s=lr.MAX_VALUE,a=-1;this.bSymbolTableReady||Jt.initialize();for(let c=0;c<Jt.RATIOS_TABLE.length;c++){let d=0,h=Jt.RATIOS_TABLE[c];for(let p=0;p<Re.BARS_IN_MODULE;p++){let w=Math.fround(h[p]-i[p]);if(d+=Math.fround(w*w),d>=s)break}d<s&&(s=d,a=Re.SYMBOL_TABLE[c])}return a}}Jt.bSymbolTableReady=!1,Jt.RATIOS_TABLE=new Array(Re.SYMBOL_TABLE.length).map(v=>new Array(Re.BARS_IN_MODULE));class Is{constructor(){this.segmentCount=-1,this.fileSize=-1,this.timestamp=-1,this.checksum=-1}getSegmentIndex(){return this.segmentIndex}setSegmentIndex(e){this.segmentIndex=e}getFileId(){return this.fileId}setFileId(e){this.fileId=e}getOptionalData(){return this.optionalData}setOptionalData(e){this.optionalData=e}isLastSegment(){return this.lastSegment}setLastSegment(e){this.lastSegment=e}getSegmentCount(){return this.segmentCount}setSegmentCount(e){this.segmentCount=e}getSender(){return this.sender||null}setSender(e){this.sender=e}getAddressee(){return this.addressee||null}setAddressee(e){this.addressee=e}getFileName(){return this.fileName}setFileName(e){this.fileName=e}getFileSize(){return this.fileSize}setFileSize(e){this.fileSize=e}getChecksum(){return this.checksum}setChecksum(e){this.checksum=e}getTimestamp(){return this.timestamp}setTimestamp(e){this.timestamp=e}}class Ss{static parseLong(e,n=void 0){return parseInt(e,n)}}class Ts extends m{}Ts.kind="NullPointerException";class C1{writeBytes(e){this.writeBytesOffset(e,0,e.length)}writeBytesOffset(e,n,i){if(e==null)throw new Ts;if(n<0||n>e.length||i<0||n+i>e.length||n+i<0)throw new M;if(i===0)return;for(let s=0;s<i;s++)this.write(e[n+s])}flush(){}close(){}}class E1 extends m{}class A1 extends C1{constructor(e=32){if(super(),this.count=0,e<0)throw new C("Negative initial size: "+e);this.buf=new Uint8Array(e)}ensureCapacity(e){e-this.buf.length>0&&this.grow(e)}grow(e){let i=this.buf.length<<1;if(i-e<0&&(i=e),i<0){if(e<0)throw new E1;i=k.MAX_VALUE}this.buf=U.copyOfUint8Array(this.buf,i)}write(e){this.ensureCapacity(this.count+1),this.buf[this.count]=e,this.count+=1}writeBytesOffset(e,n,i){if(n<0||n>e.length||i<0||n+i-e.length>0)throw new M;this.ensureCapacity(this.count+i),R.arraycopy(e,n,this.buf,this.count,i),this.count+=i}writeTo(e){e.writeBytesOffset(this.buf,0,this.count)}reset(){this.count=0}toByteArray(){return U.copyOfUint8Array(this.buf,this.count)}size(){return this.count}toString(e){return e?typeof e=="string"?this.toString_string(e):this.toString_number(e):this.toString_void()}toString_void(){return new String(this.buf).toString()}toString_string(e){return new String(this.buf).toString()}toString_number(e){return new String(this.buf).toString()}close(){}}var Je;(function(v){v[v.ALPHA=0]="ALPHA",v[v.LOWER=1]="LOWER",v[v.MIXED=2]="MIXED",v[v.PUNCT=3]="PUNCT",v[v.ALPHA_SHIFT=4]="ALPHA_SHIFT",v[v.PUNCT_SHIFT=5]="PUNCT_SHIFT"})(Je||(Je={}));function Ns(){if(typeof window<"u")return window.BigInt||null;if(typeof bi<"u")return bi.BigInt||null;if(typeof self<"u")return self.BigInt||null;throw new Error("Can't search globals for BigInt!")}let fi;function Wn(v){if(typeof fi>"u"&&(fi=Ns()),fi===null)throw new Error("BigInt is not supported!");return fi(v)}function I1(){let v=[];v[0]=Wn(1);let e=Wn(900);v[1]=e;for(let n=2;n<16;n++)v[n]=v[n-1]*e;return v}class G{static decode(e,n){let i=new Ce(""),s=W.ISO8859_1;i.enableDecoding(s);let a=1,c=e[a++],d=new Is;for(;a<e[0];){switch(c){case G.TEXT_COMPACTION_MODE_LATCH:a=G.textCompaction(e,a,i);break;case G.BYTE_COMPACTION_MODE_LATCH:case G.BYTE_COMPACTION_MODE_LATCH_6:a=G.byteCompaction(c,e,s,a,i);break;case G.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:i.append(e[a++]);break;case G.NUMERIC_COMPACTION_MODE_LATCH:a=G.numericCompaction(e,a,i);break;case G.ECI_CHARSET:W.getCharacterSetECIByValue(e[a++]);break;case G.ECI_GENERAL_PURPOSE:a+=2;break;case G.ECI_USER_DEFINED:a++;break;case G.BEGIN_MACRO_PDF417_CONTROL_BLOCK:a=G.decodeMacroBlock(e,a,d);break;case G.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case G.MACRO_PDF417_TERMINATOR:throw new z;default:a--,a=G.textCompaction(e,a,i);break}if(a<e.length)c=e[a++];else throw z.getFormatInstance()}if(i.length()===0)throw z.getFormatInstance();let h=new mt(null,i.toString(),null,n);return h.setOther(d),h}static decodeMacroBlock(e,n,i){if(n+G.NUMBER_OF_SEQUENCE_CODEWORDS>e[0])throw z.getFormatInstance();let s=new Int32Array(G.NUMBER_OF_SEQUENCE_CODEWORDS);for(let d=0;d<G.NUMBER_OF_SEQUENCE_CODEWORDS;d++,n++)s[d]=e[n];i.setSegmentIndex(k.parseInt(G.decodeBase900toBase10(s,G.NUMBER_OF_SEQUENCE_CODEWORDS)));let a=new Ce;n=G.textCompaction(e,n,a),i.setFileId(a.toString());let c=-1;for(e[n]===G.BEGIN_MACRO_PDF417_OPTIONAL_FIELD&&(c=n+1);n<e[0];)switch(e[n]){case G.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:switch(n++,e[n]){case G.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME:let d=new Ce;n=G.textCompaction(e,n+1,d),i.setFileName(d.toString());break;case G.MACRO_PDF417_OPTIONAL_FIELD_SENDER:let h=new Ce;n=G.textCompaction(e,n+1,h),i.setSender(h.toString());break;case G.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE:let p=new Ce;n=G.textCompaction(e,n+1,p),i.setAddressee(p.toString());break;case G.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT:let w=new Ce;n=G.numericCompaction(e,n+1,w),i.setSegmentCount(k.parseInt(w.toString()));break;case G.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP:let b=new Ce;n=G.numericCompaction(e,n+1,b),i.setTimestamp(Ss.parseLong(b.toString()));break;case G.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM:let A=new Ce;n=G.numericCompaction(e,n+1,A),i.setChecksum(k.parseInt(A.toString()));break;case G.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE:let N=new Ce;n=G.numericCompaction(e,n+1,N),i.setFileSize(Ss.parseLong(N.toString()));break;default:throw z.getFormatInstance()}break;case G.MACRO_PDF417_TERMINATOR:n++,i.setLastSegment(!0);break;default:throw z.getFormatInstance()}if(c!==-1){let d=n-c;i.isLastSegment()&&d--,i.setOptionalData(U.copyOfRange(e,c,c+d))}return n}static textCompaction(e,n,i){let s=new Int32Array((e[0]-n)*2),a=new Int32Array((e[0]-n)*2),c=0,d=!1;for(;n<e[0]&&!d;){let h=e[n++];if(h<G.TEXT_COMPACTION_MODE_LATCH)s[c]=h/30,s[c+1]=h%30,c+=2;else switch(h){case G.TEXT_COMPACTION_MODE_LATCH:s[c++]=G.TEXT_COMPACTION_MODE_LATCH;break;case G.BYTE_COMPACTION_MODE_LATCH:case G.BYTE_COMPACTION_MODE_LATCH_6:case G.NUMERIC_COMPACTION_MODE_LATCH:case G.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case G.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case G.MACRO_PDF417_TERMINATOR:n--,d=!0;break;case G.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:s[c]=G.MODE_SHIFT_TO_BYTE_COMPACTION_MODE,h=e[n++],a[c]=h,c++;break}}return G.decodeTextCompaction(s,a,c,i),n}static decodeTextCompaction(e,n,i,s){let a=Je.ALPHA,c=Je.ALPHA,d=0;for(;d<i;){let h=e[d],p="";switch(a){case Je.ALPHA:if(h<26)p=String.fromCharCode(65+h);else switch(h){case 26:p=" ";break;case G.LL:a=Je.LOWER;break;case G.ML:a=Je.MIXED;break;case G.PS:c=a,a=Je.PUNCT_SHIFT;break;case G.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:s.append(n[d]);break;case G.TEXT_COMPACTION_MODE_LATCH:a=Je.ALPHA;break}break;case Je.LOWER:if(h<26)p=String.fromCharCode(97+h);else switch(h){case 26:p=" ";break;case G.AS:c=a,a=Je.ALPHA_SHIFT;break;case G.ML:a=Je.MIXED;break;case G.PS:c=a,a=Je.PUNCT_SHIFT;break;case G.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:s.append(n[d]);break;case G.TEXT_COMPACTION_MODE_LATCH:a=Je.ALPHA;break}break;case Je.MIXED:if(h<G.PL)p=G.MIXED_CHARS[h];else switch(h){case G.PL:a=Je.PUNCT;break;case 26:p=" ";break;case G.LL:a=Je.LOWER;break;case G.AL:a=Je.ALPHA;break;case G.PS:c=a,a=Je.PUNCT_SHIFT;break;case G.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:s.append(n[d]);break;case G.TEXT_COMPACTION_MODE_LATCH:a=Je.ALPHA;break}break;case Je.PUNCT:if(h<G.PAL)p=G.PUNCT_CHARS[h];else switch(h){case G.PAL:a=Je.ALPHA;break;case G.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:s.append(n[d]);break;case G.TEXT_COMPACTION_MODE_LATCH:a=Je.ALPHA;break}break;case Je.ALPHA_SHIFT:if(a=c,h<26)p=String.fromCharCode(65+h);else switch(h){case 26:p=" ";break;case G.TEXT_COMPACTION_MODE_LATCH:a=Je.ALPHA;break}break;case Je.PUNCT_SHIFT:if(a=c,h<G.PAL)p=G.PUNCT_CHARS[h];else switch(h){case G.PAL:a=Je.ALPHA;break;case G.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:s.append(n[d]);break;case G.TEXT_COMPACTION_MODE_LATCH:a=Je.ALPHA;break}break}p!==""&&s.append(p),d++}}static byteCompaction(e,n,i,s,a){let c=new A1,d=0,h=0,p=!1;switch(e){case G.BYTE_COMPACTION_MODE_LATCH:let w=new Int32Array(6),b=n[s++];for(;s<n[0]&&!p;)switch(w[d++]=b,h=900*h+b,b=n[s++],b){case G.TEXT_COMPACTION_MODE_LATCH:case G.BYTE_COMPACTION_MODE_LATCH:case G.NUMERIC_COMPACTION_MODE_LATCH:case G.BYTE_COMPACTION_MODE_LATCH_6:case G.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case G.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case G.MACRO_PDF417_TERMINATOR:s--,p=!0;break;default:if(d%5===0&&d>0){for(let A=0;A<6;++A)c.write(Number(Wn(h)>>Wn(8*(5-A))));h=0,d=0}break}s===n[0]&&b<G.TEXT_COMPACTION_MODE_LATCH&&(w[d++]=b);for(let A=0;A<d;A++)c.write(w[A]);break;case G.BYTE_COMPACTION_MODE_LATCH_6:for(;s<n[0]&&!p;){let A=n[s++];if(A<G.TEXT_COMPACTION_MODE_LATCH)d++,h=900*h+A;else switch(A){case G.TEXT_COMPACTION_MODE_LATCH:case G.BYTE_COMPACTION_MODE_LATCH:case G.NUMERIC_COMPACTION_MODE_LATCH:case G.BYTE_COMPACTION_MODE_LATCH_6:case G.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case G.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case G.MACRO_PDF417_TERMINATOR:s--,p=!0;break}if(d%5===0&&d>0){for(let N=0;N<6;++N)c.write(Number(Wn(h)>>Wn(8*(5-N))));h=0,d=0}}break}return a.append(me.decode(c.toByteArray(),i)),s}static numericCompaction(e,n,i){let s=0,a=!1,c=new Int32Array(G.MAX_NUMERIC_CODEWORDS);for(;n<e[0]&&!a;){let d=e[n++];if(n===e[0]&&(a=!0),d<G.TEXT_COMPACTION_MODE_LATCH)c[s]=d,s++;else switch(d){case G.TEXT_COMPACTION_MODE_LATCH:case G.BYTE_COMPACTION_MODE_LATCH:case G.BYTE_COMPACTION_MODE_LATCH_6:case G.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case G.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case G.MACRO_PDF417_TERMINATOR:n--,a=!0;break}(s%G.MAX_NUMERIC_CODEWORDS===0||d===G.NUMERIC_COMPACTION_MODE_LATCH||a)&&s>0&&(i.append(G.decodeBase900toBase10(c,s)),s=0)}return n}static decodeBase900toBase10(e,n){let i=Wn(0);for(let a=0;a<n;a++)i+=G.EXP900[n-a-1]*Wn(e[a]);let s=i.toString();if(s.charAt(0)!=="1")throw new z;return s.substring(1)}}G.TEXT_COMPACTION_MODE_LATCH=900,G.BYTE_COMPACTION_MODE_LATCH=901,G.NUMERIC_COMPACTION_MODE_LATCH=902,G.BYTE_COMPACTION_MODE_LATCH_6=924,G.ECI_USER_DEFINED=925,G.ECI_GENERAL_PURPOSE=926,G.ECI_CHARSET=927,G.BEGIN_MACRO_PDF417_CONTROL_BLOCK=928,G.BEGIN_MACRO_PDF417_OPTIONAL_FIELD=923,G.MACRO_PDF417_TERMINATOR=922,G.MODE_SHIFT_TO_BYTE_COMPACTION_MODE=913,G.MAX_NUMERIC_CODEWORDS=15,G.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME=0,G.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT=1,G.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP=2,G.MACRO_PDF417_OPTIONAL_FIELD_SENDER=3,G.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE=4,G.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE=5,G.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM=6,G.PL=25,G.LL=27,G.AS=27,G.ML=28,G.AL=28,G.PS=29,G.PAL=29,G.PUNCT_CHARS=`;<>@[\\]_\`~!\r ,:
85
+ -.$/"|*()?{}'`,G.MIXED_CHARS="0123456789&\r ,:#-.$/+%*=^",G.EXP900=Ns()?I1():[],G.NUMBER_OF_SEQUENCE_CODEWORDS=2;class Le{constructor(){}static decode(e,n,i,s,a,c,d){let h=new nr(e,n,i,s,a),p=null,w=null,b;for(let F=!0;;F=!1){if(n!=null&&(p=Le.getRowIndicatorColumn(e,h,n,!0,c,d)),s!=null&&(w=Le.getRowIndicatorColumn(e,h,s,!1,c,d)),b=Le.merge(p,w),b==null)throw L.getNotFoundInstance();let $=b.getBoundingBox();if(F&&$!=null&&($.getMinY()<h.getMinY()||$.getMaxY()>h.getMaxY()))h=$;else break}b.setBoundingBox(h);let A=b.getBarcodeColumnCount()+1;b.setDetectionResultColumn(0,p),b.setDetectionResultColumn(A,w);let N=p!=null;for(let F=1;F<=A;F++){let $=N?F:A-F;if(b.getDetectionResultColumn($)!==void 0)continue;let j;$===0||$===A?j=new As(h,$===0):j=new Or(h),b.setDetectionResultColumn($,j);let q=-1,se=q;for(let ae=h.getMinY();ae<=h.getMaxY();ae++){if(q=Le.getStartColumn(b,$,ae,N),q<0||q>h.getMaxX()){if(se===-1)continue;q=se}let oe=Le.detectCodeword(e,h.getMinX(),h.getMaxX(),N,q,ae,c,d);oe!=null&&(j.setCodeword(ae,oe),se=q,c=Math.min(c,oe.getWidth()),d=Math.max(d,oe.getWidth()))}}return Le.createDecoderResult(b)}static merge(e,n){if(e==null&&n==null)return null;let i=Le.getBarcodeMetadata(e,n);if(i==null)return null;let s=nr.merge(Le.adjustBoundingBox(e),Le.adjustBoundingBox(n));return new Rr(i,s)}static adjustBoundingBox(e){if(e==null)return null;let n=e.getRowHeights();if(n==null)return null;let i=Le.getMax(n),s=0;for(let d of n)if(s+=i-d,d>0)break;let a=e.getCodewords();for(let d=0;s>0&&a[d]==null;d++)s--;let c=0;for(let d=n.length-1;d>=0&&(c+=i-n[d],!(n[d]>0));d--);for(let d=a.length-1;c>0&&a[d]==null;d--)c--;return e.getBoundingBox().addMissingRows(s,c,e.isLeft())}static getMax(e){let n=-1;for(let i of e)n=Math.max(n,i);return n}static getBarcodeMetadata(e,n){let i;if(e==null||(i=e.getBarcodeMetadata())==null)return n==null?null:n.getBarcodeMetadata();let s;return n==null||(s=n.getBarcodeMetadata())==null?i:i.getColumnCount()!==s.getColumnCount()&&i.getErrorCorrectionLevel()!==s.getErrorCorrectionLevel()&&i.getRowCount()!==s.getRowCount()?null:i}static getRowIndicatorColumn(e,n,i,s,a,c){let d=new As(n,s);for(let h=0;h<2;h++){let p=h===0?1:-1,w=Math.trunc(Math.trunc(i.getX()));for(let b=Math.trunc(Math.trunc(i.getY()));b<=n.getMaxY()&&b>=n.getMinY();b+=p){let A=Le.detectCodeword(e,0,e.getWidth(),s,w,b,a,c);A!=null&&(d.setCodeword(b,A),s?w=A.getStartX():w=A.getEndX())}}return d}static adjustCodewordCount(e,n){let i=n[0][1],s=i.getValue(),a=e.getBarcodeColumnCount()*e.getBarcodeRowCount()-Le.getNumberOfECCodeWords(e.getBarcodeECLevel());if(s.length===0){if(a<1||a>Re.MAX_CODEWORDS_IN_BARCODE)throw L.getNotFoundInstance();i.setValue(a)}else s[0]!==a&&i.setValue(a)}static createDecoderResult(e){let n=Le.createBarcodeMatrix(e);Le.adjustCodewordCount(e,n);let i=new Array,s=new Int32Array(e.getBarcodeRowCount()*e.getBarcodeColumnCount()),a=[],c=new Array;for(let h=0;h<e.getBarcodeRowCount();h++)for(let p=0;p<e.getBarcodeColumnCount();p++){let w=n[h][p+1].getValue(),b=h*e.getBarcodeColumnCount()+p;w.length===0?i.push(b):w.length===1?s[b]=w[0]:(c.push(b),a.push(w))}let d=new Array(a.length);for(let h=0;h<d.length;h++)d[h]=a[h];return Le.createDecoderResultFromAmbiguousValues(e.getBarcodeECLevel(),s,Re.toIntArray(i),Re.toIntArray(c),d)}static createDecoderResultFromAmbiguousValues(e,n,i,s,a){let c=new Int32Array(s.length),d=100;for(;d-- >0;){for(let h=0;h<c.length;h++)n[s[h]]=a[h][c[h]];try{return Le.decodeCodewords(n,e,i)}catch(h){if(!(h instanceof O))throw h}if(c.length===0)throw O.getChecksumInstance();for(let h=0;h<c.length;h++)if(c[h]<a[h].length-1){c[h]++;break}else if(c[h]=0,h===c.length-1)throw O.getChecksumInstance()}throw O.getChecksumInstance()}static createBarcodeMatrix(e){let n=Array.from({length:e.getBarcodeRowCount()},()=>new Array(e.getBarcodeColumnCount()+2));for(let s=0;s<n.length;s++)for(let a=0;a<n[s].length;a++)n[s][a]=new kr;let i=0;for(let s of e.getDetectionResultColumns()){if(s!=null){for(let a of s.getCodewords())if(a!=null){let c=a.getRowNumber();if(c>=0){if(c>=n.length)continue;n[c][i].setValue(a.getValue())}}}i++}return n}static isValidBarcodeColumn(e,n){return n>=0&&n<=e.getBarcodeColumnCount()+1}static getStartColumn(e,n,i,s){let a=s?1:-1,c=null;if(Le.isValidBarcodeColumn(e,n-a)&&(c=e.getDetectionResultColumn(n-a).getCodeword(i)),c!=null)return s?c.getEndX():c.getStartX();if(c=e.getDetectionResultColumn(n).getCodewordNearby(i),c!=null)return s?c.getStartX():c.getEndX();if(Le.isValidBarcodeColumn(e,n-a)&&(c=e.getDetectionResultColumn(n-a).getCodewordNearby(i)),c!=null)return s?c.getEndX():c.getStartX();let d=0;for(;Le.isValidBarcodeColumn(e,n-a);){n-=a;for(let h of e.getDetectionResultColumn(n).getCodewords())if(h!=null)return(s?h.getEndX():h.getStartX())+a*d*(h.getEndX()-h.getStartX());d++}return s?e.getBoundingBox().getMinX():e.getBoundingBox().getMaxX()}static detectCodeword(e,n,i,s,a,c,d,h){a=Le.adjustCodewordStartColumn(e,n,i,s,a,c);let p=Le.getModuleBitCount(e,n,i,s,a,c);if(p==null)return null;let w,b=ze.sum(p);if(s)w=a+b;else{for(let F=0;F<p.length/2;F++){let $=p[F];p[F]=p[p.length-1-F],p[p.length-1-F]=$}w=a,a=w-b}if(!Le.checkCodewordSkew(b,d,h))return null;let A=Jt.getDecodedValue(p),N=Re.getCodeword(A);return N===-1?null:new Dr(a,w,Le.getCodewordBucketNumber(A),N)}static getModuleBitCount(e,n,i,s,a,c){let d=a,h=new Int32Array(8),p=0,w=s?1:-1,b=s;for(;(s?d<i:d>=n)&&p<h.length;)e.get(d,c)===b?(h[p]++,d+=w):(p++,b=!b);return p===h.length||d===(s?i:n)&&p===h.length-1?h:null}static getNumberOfECCodeWords(e){return 2<<e}static adjustCodewordStartColumn(e,n,i,s,a,c){let d=a,h=s?-1:1;for(let p=0;p<2;p++){for(;(s?d>=n:d<i)&&s===e.get(d,c);){if(Math.abs(a-d)>Le.CODEWORD_SKEW_SIZE)return a;d+=h}h=-h,s=!s}return d}static checkCodewordSkew(e,n,i){return n-Le.CODEWORD_SKEW_SIZE<=e&&e<=i+Le.CODEWORD_SKEW_SIZE}static decodeCodewords(e,n,i){if(e.length===0)throw z.getFormatInstance();let s=1<<n+1,a=Le.correctErrors(e,i,s);Le.verifyCodewordCount(e,s);let c=G.decode(e,""+n);return c.setErrorsCorrected(a),c.setErasures(i.length),c}static correctErrors(e,n,i){if(n!=null&&n.length>i/2+Le.MAX_ERRORS||i<0||i>Le.MAX_EC_CODEWORDS)throw O.getChecksumInstance();return Le.errorCorrection.decode(e,i,n)}static verifyCodewordCount(e,n){if(e.length<4)throw z.getFormatInstance();let i=e[0];if(i>e.length)throw z.getFormatInstance();if(i===0)if(n<e.length)e[0]=e.length-n;else throw z.getFormatInstance()}static getBitCountForCodeword(e){let n=new Int32Array(8),i=0,s=n.length-1;for(;!((e&1)!==i&&(i=e&1,s--,s<0));)n[s]++,e>>=1;return n}static getCodewordBucketNumber(e){return e instanceof Int32Array?this.getCodewordBucketNumber_Int32Array(e):this.getCodewordBucketNumber_number(e)}static getCodewordBucketNumber_number(e){return Le.getCodewordBucketNumber(Le.getBitCountForCodeword(e))}static getCodewordBucketNumber_Int32Array(e){return(e[0]-e[2]+e[4]-e[6]+9)%9}static toString(e){let n=new Nr;for(let i=0;i<e.length;i++){n.format("Row %2d: ",i);for(let s=0;s<e[i].length;s++){let a=e[i][s];a.getValue().length===0?n.format(" ",null):n.format("%4d(%2d)",a.getValue()[0],a.getConfidence(a.getValue()[0]))}n.format("%n")}return n.toString()}}Le.CODEWORD_SKEW_SIZE=2,Le.MAX_ERRORS=3,Le.MAX_EC_CODEWORDS=512,Le.errorCorrection=new Es;class Bt{decode(e,n=null){let i=Bt.decode(e,n,!1);if(i==null||i.length===0||i[0]==null)throw L.getNotFoundInstance();return i[0]}decodeMultiple(e,n=null){try{return Bt.decode(e,n,!0)}catch(i){throw i instanceof z||i instanceof O?L.getNotFoundInstance():i}}static decode(e,n,i){const s=new Array,a=Pe.detectMultiple(e,n,i);for(const c of a.getPoints()){const d=Le.decode(a.getBits(),c[4],c[5],c[6],c[7],Bt.getMinCodewordWidth(c),Bt.getMaxCodewordWidth(c)),h=new Ee(d.getText(),d.getRawBytes(),void 0,c,T.PDF_417);h.putMetadata(we.ERROR_CORRECTION_LEVEL,d.getECLevel());const p=d.getOther();p!=null&&h.putMetadata(we.PDF417_EXTRA_METADATA,p),s.push(h)}return s.map(c=>c)}static getMaxWidth(e,n){return e==null||n==null?0:Math.trunc(Math.abs(e.getX()-n.getX()))}static getMinWidth(e,n){return e==null||n==null?k.MAX_VALUE:Math.trunc(Math.abs(e.getX()-n.getX()))}static getMaxCodewordWidth(e){return Math.floor(Math.max(Math.max(Bt.getMaxWidth(e[0],e[4]),Bt.getMaxWidth(e[6],e[2])*Re.MODULES_IN_CODEWORD/Re.MODULES_IN_STOP_PATTERN),Math.max(Bt.getMaxWidth(e[1],e[5]),Bt.getMaxWidth(e[7],e[3])*Re.MODULES_IN_CODEWORD/Re.MODULES_IN_STOP_PATTERN)))}static getMinCodewordWidth(e){return Math.floor(Math.min(Math.min(Bt.getMinWidth(e[0],e[4]),Bt.getMinWidth(e[6],e[2])*Re.MODULES_IN_CODEWORD/Re.MODULES_IN_STOP_PATTERN),Math.min(Bt.getMinWidth(e[1],e[5]),Bt.getMinWidth(e[7],e[3])*Re.MODULES_IN_CODEWORD/Re.MODULES_IN_STOP_PATTERN)))}reset(){}}class hi extends m{}hi.kind="ReaderException";class Os{constructor(e,n){this.verbose=e===!0,n&&this.setHints(n)}decode(e,n){return n&&this.setHints(n),this.decodeInternal(e)}decodeWithState(e){return(this.readers===null||this.readers===void 0)&&this.setHints(null),this.decodeInternal(e)}setHints(e){this.hints=e;const n=!l(e)&&e.get(Z.TRY_HARDER)===!0,i=l(e)?null:e.get(Z.POSSIBLE_FORMATS),s=new Array;if(!l(i)){const a=i.some(c=>c===T.UPC_A||c===T.UPC_E||c===T.EAN_13||c===T.EAN_8||c===T.CODABAR||c===T.CODE_39||c===T.CODE_93||c===T.CODE_128||c===T.ITF||c===T.RSS_14||c===T.RSS_EXPANDED);a&&!n&&s.push(new hr(e,this.verbose)),i.includes(T.QR_CODE)&&s.push(new Hn),i.includes(T.DATA_MATRIX)&&s.push(new jn),i.includes(T.AZTEC)&&s.push(new ai),i.includes(T.PDF_417)&&s.push(new Bt),a&&n&&s.push(new hr(e,this.verbose))}s.length===0&&(n||s.push(new hr(e,this.verbose)),s.push(new Hn),s.push(new jn),s.push(new ai),s.push(new Bt),n&&s.push(new hr(e,this.verbose))),this.readers=s}reset(){if(this.readers!==null)for(const e of this.readers)e.reset()}decodeInternal(e){if(this.readers===null)throw new hi("No readers where selected, nothing can be read.");for(const n of this.readers)try{return n.decode(e,this.hints)}catch(i){if(i instanceof hi)continue}throw new L("No MultiFormat Readers were able to detect the code.")}}class S1 extends he{constructor(e=null,n=500){const i=new Os;i.setHints(e),super(i,n)}decodeBitmap(e){return this.reader.decodeWithState(e)}}class T1 extends he{constructor(e=500){super(new Bt,e)}}class N1 extends he{constructor(e=500){super(new Hn,e)}}var fo;(function(v){v[v.ERROR_CORRECTION=0]="ERROR_CORRECTION",v[v.CHARACTER_SET=1]="CHARACTER_SET",v[v.DATA_MATRIX_SHAPE=2]="DATA_MATRIX_SHAPE",v[v.MIN_SIZE=3]="MIN_SIZE",v[v.MAX_SIZE=4]="MAX_SIZE",v[v.MARGIN=5]="MARGIN",v[v.PDF417_COMPACT=6]="PDF417_COMPACT",v[v.PDF417_COMPACTION=7]="PDF417_COMPACTION",v[v.PDF417_DIMENSIONS=8]="PDF417_DIMENSIONS",v[v.AZTEC_LAYERS=9]="AZTEC_LAYERS",v[v.QR_VERSION=10]="QR_VERSION"})(fo||(fo={}));var Tt=fo;class ho{constructor(e){this.field=e,this.cachedGenerators=[],this.cachedGenerators.push(new Qe(e,Int32Array.from([1])))}buildGenerator(e){const n=this.cachedGenerators;if(e>=n.length){let i=n[n.length-1];const s=this.field;for(let a=n.length;a<=e;a++){const c=i.multiply(new Qe(s,Int32Array.from([1,s.exp(a-1+s.getGeneratorBase())])));n.push(c),i=c}}return n[e]}encode(e,n){if(n===0)throw new C("No error correction bytes");const i=e.length-n;if(i<=0)throw new C("No data bytes provided");const s=this.buildGenerator(n),a=new Int32Array(i);R.arraycopy(e,0,a,0,i);let c=new Qe(this.field,a);c=c.multiplyByMonomial(n,1);const h=c.divide(s)[1].getCoefficients(),p=n-h.length;for(let w=0;w<p;w++)e[i+w]=0;R.arraycopy(h,0,e,i+p,h.length)}}class yt{constructor(){}static applyMaskPenaltyRule1(e){return yt.applyMaskPenaltyRule1Internal(e,!0)+yt.applyMaskPenaltyRule1Internal(e,!1)}static applyMaskPenaltyRule2(e){let n=0;const i=e.getArray(),s=e.getWidth(),a=e.getHeight();for(let c=0;c<a-1;c++){const d=i[c];for(let h=0;h<s-1;h++){const p=d[h];p===d[h+1]&&p===i[c+1][h]&&p===i[c+1][h+1]&&n++}}return yt.N2*n}static applyMaskPenaltyRule3(e){let n=0;const i=e.getArray(),s=e.getWidth(),a=e.getHeight();for(let c=0;c<a;c++)for(let d=0;d<s;d++){const h=i[c];d+6<s&&h[d]===1&&h[d+1]===0&&h[d+2]===1&&h[d+3]===1&&h[d+4]===1&&h[d+5]===0&&h[d+6]===1&&(yt.isWhiteHorizontal(h,d-4,d)||yt.isWhiteHorizontal(h,d+7,d+11))&&n++,c+6<a&&i[c][d]===1&&i[c+1][d]===0&&i[c+2][d]===1&&i[c+3][d]===1&&i[c+4][d]===1&&i[c+5][d]===0&&i[c+6][d]===1&&(yt.isWhiteVertical(i,d,c-4,c)||yt.isWhiteVertical(i,d,c+7,c+11))&&n++}return n*yt.N3}static isWhiteHorizontal(e,n,i){n=Math.max(n,0),i=Math.min(i,e.length);for(let s=n;s<i;s++)if(e[s]===1)return!1;return!0}static isWhiteVertical(e,n,i,s){i=Math.max(i,0),s=Math.min(s,e.length);for(let a=i;a<s;a++)if(e[a][n]===1)return!1;return!0}static applyMaskPenaltyRule4(e){let n=0;const i=e.getArray(),s=e.getWidth(),a=e.getHeight();for(let h=0;h<a;h++){const p=i[h];for(let w=0;w<s;w++)p[w]===1&&n++}const c=e.getHeight()*e.getWidth();return Math.floor(Math.abs(n*2-c)*10/c)*yt.N4}static getDataMaskBit(e,n,i){let s,a;switch(e){case 0:s=i+n&1;break;case 1:s=i&1;break;case 2:s=n%3;break;case 3:s=(i+n)%3;break;case 4:s=Math.floor(i/2)+Math.floor(n/3)&1;break;case 5:a=i*n,s=(a&1)+a%3;break;case 6:a=i*n,s=(a&1)+a%3&1;break;case 7:a=i*n,s=a%3+(i+n&1)&1;break;default:throw new C("Invalid mask pattern: "+e)}return s===0}static applyMaskPenaltyRule1Internal(e,n){let i=0;const s=n?e.getHeight():e.getWidth(),a=n?e.getWidth():e.getHeight(),c=e.getArray();for(let d=0;d<s;d++){let h=0,p=-1;for(let w=0;w<a;w++){const b=n?c[d][w]:c[w][d];b===p?h++:(h>=5&&(i+=yt.N1+(h-5)),h=1,p=b)}h>=5&&(i+=yt.N1+(h-5))}return i}}yt.N1=3,yt.N2=3,yt.N3=40,yt.N4=10;class pi{constructor(e,n){this.width=e,this.height=n;const i=new Array(n);for(let s=0;s!==n;s++)i[s]=new Uint8Array(e);this.bytes=i}getHeight(){return this.height}getWidth(){return this.width}get(e,n){return this.bytes[n][e]}getArray(){return this.bytes}setNumber(e,n,i){this.bytes[n][e]=i}setBoolean(e,n,i){this.bytes[n][e]=i?1:0}clear(e){for(const n of this.bytes)U.fill(n,e)}equals(e){if(!(e instanceof pi))return!1;const n=e;if(this.width!==n.width||this.height!==n.height)return!1;for(let i=0,s=this.height;i<s;++i){const a=this.bytes[i],c=n.bytes[i];for(let d=0,h=this.width;d<h;++d)if(a[d]!==c[d])return!1}return!0}toString(){const e=new Ce;for(let n=0,i=this.height;n<i;++n){const s=this.bytes[n];for(let a=0,c=this.width;a<c;++a)switch(s[a]){case 0:e.append(" 0");break;case 1:e.append(" 1");break;default:e.append(" ");break}e.append(`
86
+ `)}return e.toString()}}class rr{constructor(){this.maskPattern=-1}getMode(){return this.mode}getECLevel(){return this.ecLevel}getVersion(){return this.version}getMaskPattern(){return this.maskPattern}getMatrix(){return this.matrix}toString(){const e=new Ce;return e.append(`<<
87
87
  `),e.append(" mode: "),e.append(this.mode?this.mode.toString():"null"),e.append(`
88
88
  ecLevel: `),e.append(this.ecLevel?this.ecLevel.toString():"null"),e.append(`
89
89
  version: `),e.append(this.version?this.version.toString():"null"),e.append(`
@@ -92,9 +92,9 @@ ${fe}`:fe;m.systemPrompt=se}else m.systemPrompt=o},te=async(ne,S,fe)=>{if(S&&S.l
92
92
  `),e.append(this.matrix.toString())):e.append(`
93
93
  matrix: null
94
94
  `),e.append(`>>
95
- `),e.toString()}setMode(e){this.mode=e}setECLevel(e){this.ecLevel=e}setVersion(e){this.version=e}setMaskPattern(e){this.maskPattern=e}setMatrix(e){this.matrix=e}static isValidMaskPattern(e){return e>=0&&e<cr.NUM_MASK_PATTERNS}}cr.NUM_MASK_PATTERNS=8;class it extends x{}it.kind="WriterException";class Me{constructor(){}static clearMatrix(e){e.clear(255)}static buildMatrix(e,r,i,s,a){Me.clearMatrix(a),Me.embedBasicPatterns(i,a),Me.embedTypeInfo(r,s,a),Me.maybeEmbedVersionInfo(i,a),Me.embedDataBits(e,s,a)}static embedBasicPatterns(e,r){Me.embedPositionDetectionPatternsAndSeparators(r),Me.embedDarkDotAtLeftBottomCorner(r),Me.maybeEmbedPositionAdjustmentPatterns(e,r),Me.embedTimingPatterns(r)}static embedTypeInfo(e,r,i){const s=new K;Me.makeTypeInfoBits(e,r,s);for(let a=0,c=s.getSize();a<c;++a){const d=s.get(s.getSize()-1-a),h=Me.TYPE_INFO_COORDINATES[a],p=h[0],w=h[1];if(i.setBoolean(p,w,d),a<8){const v=i.getWidth()-a-1;i.setBoolean(v,8,d)}else{const E=i.getHeight()-7+(a-8);i.setBoolean(8,E,d)}}}static maybeEmbedVersionInfo(e,r){if(e.getVersionNumber()<7)return;const i=new K;Me.makeVersionInfoBits(e,i);let s=17;for(let a=0;a<6;++a)for(let c=0;c<3;++c){const d=i.get(s);s--,r.setBoolean(a,r.getHeight()-11+c,d),r.setBoolean(r.getHeight()-11+c,a,d)}}static embedDataBits(e,r,i){let s=0,a=-1,c=i.getWidth()-1,d=i.getHeight()-1;for(;c>0;){for(c===6&&(c-=1);d>=0&&d<i.getHeight();){for(let h=0;h<2;++h){const p=c-h;if(!Me.isEmpty(i.get(p,d)))continue;let w;s<e.getSize()?(w=e.get(s),++s):w=!1,r!==255&&_t.getDataMaskBit(r,p,d)&&(w=!w),i.setBoolean(p,d,w)}d+=a}a=-a,d+=a,c-=2}if(s!==e.getSize())throw new it("Not all bits consumed: "+s+"/"+e.getSize())}static findMSBSet(e){return 32-k.numberOfLeadingZeros(e)}static calculateBCHCode(e,r){if(r===0)throw new b("0 polynomial");const i=Me.findMSBSet(r);for(e<<=i-1;Me.findMSBSet(e)>=i;)e^=r<<Me.findMSBSet(e)-i;return e}static makeTypeInfoBits(e,r,i){if(!cr.isValidMaskPattern(r))throw new it("Invalid mask pattern");const s=e.getBits()<<3|r;i.appendBits(s,5);const a=Me.calculateBCHCode(s,Me.TYPE_INFO_POLY);i.appendBits(a,10);const c=new K;if(c.appendBits(Me.TYPE_INFO_MASK_PATTERN,15),i.xor(c),i.getSize()!==15)throw new it("should not happen but we got: "+i.getSize())}static makeVersionInfoBits(e,r){r.appendBits(e.getVersionNumber(),6);const i=Me.calculateBCHCode(e.getVersionNumber(),Me.VERSION_INFO_POLY);if(r.appendBits(i,12),r.getSize()!==18)throw new it("should not happen but we got: "+r.getSize())}static isEmpty(e){return e===255}static embedTimingPatterns(e){for(let r=8;r<e.getWidth()-8;++r){const i=(r+1)%2;Me.isEmpty(e.get(r,6))&&e.setNumber(r,6,i),Me.isEmpty(e.get(6,r))&&e.setNumber(6,r,i)}}static embedDarkDotAtLeftBottomCorner(e){if(e.get(8,e.getHeight()-8)===0)throw new it;e.setNumber(8,e.getHeight()-8,1)}static embedHorizontalSeparationPattern(e,r,i){for(let s=0;s<8;++s){if(!Me.isEmpty(i.get(e+s,r)))throw new it;i.setNumber(e+s,r,0)}}static embedVerticalSeparationPattern(e,r,i){for(let s=0;s<7;++s){if(!Me.isEmpty(i.get(e,r+s)))throw new it;i.setNumber(e,r+s,0)}}static embedPositionAdjustmentPattern(e,r,i){for(let s=0;s<5;++s){const a=Me.POSITION_ADJUSTMENT_PATTERN[s];for(let c=0;c<5;++c)i.setNumber(e+c,r+s,a[c])}}static embedPositionDetectionPattern(e,r,i){for(let s=0;s<7;++s){const a=Me.POSITION_DETECTION_PATTERN[s];for(let c=0;c<7;++c)i.setNumber(e+c,r+s,a[c])}}static embedPositionDetectionPatternsAndSeparators(e){const r=Me.POSITION_DETECTION_PATTERN[0].length;Me.embedPositionDetectionPattern(0,0,e),Me.embedPositionDetectionPattern(e.getWidth()-r,0,e),Me.embedPositionDetectionPattern(0,e.getWidth()-r,e);const i=8;Me.embedHorizontalSeparationPattern(0,i-1,e),Me.embedHorizontalSeparationPattern(e.getWidth()-i,i-1,e),Me.embedHorizontalSeparationPattern(0,e.getWidth()-i,e);const s=7;Me.embedVerticalSeparationPattern(s,0,e),Me.embedVerticalSeparationPattern(e.getHeight()-s-1,0,e),Me.embedVerticalSeparationPattern(s,e.getHeight()-s,e)}static maybeEmbedPositionAdjustmentPatterns(e,r){if(e.getVersionNumber()<2)return;const i=e.getVersionNumber()-1,s=Me.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[i];for(let a=0,c=s.length;a!==c;a++){const d=s[a];if(d>=0)for(let h=0;h!==c;h++){const p=s[h];p>=0&&Me.isEmpty(r.get(p,d))&&Me.embedPositionAdjustmentPattern(p-2,d-2,r)}}}}Me.POSITION_DETECTION_PATTERN=Array.from([Int32Array.from([1,1,1,1,1,1,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,1,1,1,1,1,1])]),Me.POSITION_ADJUSTMENT_PATTERN=Array.from([Int32Array.from([1,1,1,1,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,0,1,0,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,1,1,1,1])]),Me.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE=Array.from([Int32Array.from([-1,-1,-1,-1,-1,-1,-1]),Int32Array.from([6,18,-1,-1,-1,-1,-1]),Int32Array.from([6,22,-1,-1,-1,-1,-1]),Int32Array.from([6,26,-1,-1,-1,-1,-1]),Int32Array.from([6,30,-1,-1,-1,-1,-1]),Int32Array.from([6,34,-1,-1,-1,-1,-1]),Int32Array.from([6,22,38,-1,-1,-1,-1]),Int32Array.from([6,24,42,-1,-1,-1,-1]),Int32Array.from([6,26,46,-1,-1,-1,-1]),Int32Array.from([6,28,50,-1,-1,-1,-1]),Int32Array.from([6,30,54,-1,-1,-1,-1]),Int32Array.from([6,32,58,-1,-1,-1,-1]),Int32Array.from([6,34,62,-1,-1,-1,-1]),Int32Array.from([6,26,46,66,-1,-1,-1]),Int32Array.from([6,26,48,70,-1,-1,-1]),Int32Array.from([6,26,50,74,-1,-1,-1]),Int32Array.from([6,30,54,78,-1,-1,-1]),Int32Array.from([6,30,56,82,-1,-1,-1]),Int32Array.from([6,30,58,86,-1,-1,-1]),Int32Array.from([6,34,62,90,-1,-1,-1]),Int32Array.from([6,28,50,72,94,-1,-1]),Int32Array.from([6,26,50,74,98,-1,-1]),Int32Array.from([6,30,54,78,102,-1,-1]),Int32Array.from([6,28,54,80,106,-1,-1]),Int32Array.from([6,32,58,84,110,-1,-1]),Int32Array.from([6,30,58,86,114,-1,-1]),Int32Array.from([6,34,62,90,118,-1,-1]),Int32Array.from([6,26,50,74,98,122,-1]),Int32Array.from([6,30,54,78,102,126,-1]),Int32Array.from([6,26,52,78,104,130,-1]),Int32Array.from([6,30,56,82,108,134,-1]),Int32Array.from([6,34,60,86,112,138,-1]),Int32Array.from([6,30,58,86,114,142,-1]),Int32Array.from([6,34,62,90,118,146,-1]),Int32Array.from([6,30,54,78,102,126,150]),Int32Array.from([6,24,50,76,102,128,154]),Int32Array.from([6,28,54,80,106,132,158]),Int32Array.from([6,32,58,84,110,136,162]),Int32Array.from([6,26,54,82,110,138,166]),Int32Array.from([6,30,58,86,114,142,170])]),Me.TYPE_INFO_COORDINATES=Array.from([Int32Array.from([8,0]),Int32Array.from([8,1]),Int32Array.from([8,2]),Int32Array.from([8,3]),Int32Array.from([8,4]),Int32Array.from([8,5]),Int32Array.from([8,7]),Int32Array.from([8,8]),Int32Array.from([7,8]),Int32Array.from([5,8]),Int32Array.from([4,8]),Int32Array.from([3,8]),Int32Array.from([2,8]),Int32Array.from([1,8]),Int32Array.from([0,8])]),Me.VERSION_INFO_POLY=7973,Me.TYPE_INFO_POLY=1335,Me.TYPE_INFO_MASK_PATTERN=21522;class $1{constructor(e,r){this.dataBytes=e,this.errorCorrectionBytes=r}getDataBytes(){return this.dataBytes}getErrorCorrectionBytes(){return this.errorCorrectionBytes}}class lt{constructor(){}static calculateMaskPenalty(e){return _t.applyMaskPenaltyRule1(e)+_t.applyMaskPenaltyRule2(e)+_t.applyMaskPenaltyRule3(e)+_t.applyMaskPenaltyRule4(e)}static encode(e,r,i=null){let s=lt.DEFAULT_BYTE_MODE_ENCODING;const a=i!==null&&i.get(Tt.CHARACTER_SET)!==void 0;a&&(s=i.get(Tt.CHARACTER_SET).toString());const c=this.chooseMode(e,s),d=new K;if(c===Re.BYTE&&(a||lt.DEFAULT_BYTE_MODE_ENCODING!==s)){const ce=Y.getCharacterSetECIByName(s);ce!==void 0&&this.appendECI(ce,d)}this.appendModeInfo(c,d);const h=new K;this.appendBytes(e,c,h,s);let p;if(i!==null&&i.get(Tt.QR_VERSION)!==void 0){const ce=Number.parseInt(i.get(Tt.QR_VERSION).toString(),10);p=Ne.getVersionForNumber(ce);const oe=this.calculateBitsNeeded(c,d,h,p);if(!this.willFit(oe,p,r))throw new it("Data too big for requested version")}else p=this.recommendVersion(r,c,d,h);const w=new K;w.appendBitArray(d);const v=c===Re.BYTE?h.getSizeInBytes():e.length;this.appendLengthInfo(v,p,c,w),w.appendBitArray(h);const E=p.getECBlocksForLevel(r),O=p.getTotalCodewords()-E.getTotalECCodewords();this.terminateBits(O,w);const L=this.interleaveWithECBytes(w,p.getTotalCodewords(),O,E.getNumBlocks()),$=new cr;$.setECLevel(r),$.setMode(c),$.setVersion(p);const Z=p.getDimensionForVersion(),G=new yi(Z,Z),ae=this.chooseMaskPattern(L,r,p,G);return $.setMaskPattern(ae),Me.buildMatrix(L,r,p,ae,G),$.setMatrix(G),$}static recommendVersion(e,r,i,s){const a=this.calculateBitsNeeded(r,i,s,Ne.getVersionForNumber(1)),c=this.chooseVersion(a,e),d=this.calculateBitsNeeded(r,i,s,c);return this.chooseVersion(d,e)}static calculateBitsNeeded(e,r,i,s){return r.getSize()+e.getCharacterCountBits(s)+i.getSize()}static getAlphanumericCode(e){return e<lt.ALPHANUMERIC_TABLE.length?lt.ALPHANUMERIC_TABLE[e]:-1}static chooseMode(e,r=null){if(Y.SJIS.getName()===r&&this.isOnlyDoubleByteKanji(e))return Re.KANJI;let i=!1,s=!1;for(let a=0,c=e.length;a<c;++a){const d=e.charAt(a);if(lt.isDigit(d))i=!0;else if(this.getAlphanumericCode(d.charCodeAt(0))!==-1)s=!0;else return Re.BYTE}return s?Re.ALPHANUMERIC:i?Re.NUMERIC:Re.BYTE}static isOnlyDoubleByteKanji(e){let r;try{r=Ce.encode(e,Y.SJIS)}catch{return!1}const i=r.length;if(i%2!==0)return!1;for(let s=0;s<i;s+=2){const a=r[s]&255;if((a<129||a>159)&&(a<224||a>235))return!1}return!0}static chooseMaskPattern(e,r,i,s){let a=Number.MAX_SAFE_INTEGER,c=-1;for(let d=0;d<cr.NUM_MASK_PATTERNS;d++){Me.buildMatrix(e,r,i,d,s);let h=this.calculateMaskPenalty(s);h<a&&(a=h,c=d)}return c}static chooseVersion(e,r){for(let i=1;i<=40;i++){const s=Ne.getVersionForNumber(i);if(lt.willFit(e,s,r))return s}throw new it("Data too big")}static willFit(e,r,i){const s=r.getTotalCodewords(),c=r.getECBlocksForLevel(i).getTotalECCodewords(),d=s-c,h=(e+7)/8;return d>=h}static terminateBits(e,r){const i=e*8;if(r.getSize()>i)throw new it("data bits cannot fit in the QR Code"+r.getSize()+" > "+i);for(let c=0;c<4&&r.getSize()<i;++c)r.appendBit(!1);const s=r.getSize()&7;if(s>0)for(let c=s;c<8;c++)r.appendBit(!1);const a=e-r.getSizeInBytes();for(let c=0;c<a;++c)r.appendBits((c&1)===0?236:17,8);if(r.getSize()!==i)throw new it("Bits size does not equal capacity")}static getNumDataBytesAndNumECBytesForBlockID(e,r,i,s,a,c){if(s>=i)throw new it("Block ID too large");const d=e%i,h=i-d,p=Math.floor(e/i),w=p+1,v=Math.floor(r/i),E=v+1,O=p-v,L=w-E;if(O!==L)throw new it("EC bytes mismatch");if(i!==h+d)throw new it("RS blocks mismatch");if(e!==(v+O)*h+(E+L)*d)throw new it("Total bytes mismatch");s<h?(a[0]=v,c[0]=O):(a[0]=E,c[0]=L)}static interleaveWithECBytes(e,r,i,s){if(e.getSizeInBytes()!==i)throw new it("Number of bits and data bytes does not match");let a=0,c=0,d=0;const h=new Array;for(let w=0;w<s;++w){const v=new Int32Array(1),E=new Int32Array(1);lt.getNumDataBytesAndNumECBytesForBlockID(r,i,s,w,v,E);const O=v[0],L=new Uint8Array(O);e.toBytes(8*a,L,0,O);const $=lt.generateECBytes(L,E[0]);h.push(new $1(L,$)),c=Math.max(c,O),d=Math.max(d,$.length),a+=v[0]}if(i!==a)throw new it("Data bytes does not match offset");const p=new K;for(let w=0;w<c;++w)for(const v of h){const E=v.getDataBytes();w<E.length&&p.appendBits(E[w],8)}for(let w=0;w<d;++w)for(const v of h){const E=v.getErrorCorrectionBytes();w<E.length&&p.appendBits(E[w],8)}if(r!==p.getSizeInBytes())throw new it("Interleaving error: "+r+" and "+p.getSizeInBytes()+" differ.");return p}static generateECBytes(e,r){const i=e.length,s=new Int32Array(i+r);for(let c=0;c<i;c++)s[c]=e[c]&255;new yo(je.QR_CODE_FIELD_256).encode(s,r);const a=new Uint8Array(r);for(let c=0;c<r;c++)a[c]=s[i+c];return a}static appendModeInfo(e,r){r.appendBits(e.getBits(),4)}static appendLengthInfo(e,r,i,s){const a=i.getCharacterCountBits(r);if(e>=1<<a)throw new it(e+" is bigger than "+((1<<a)-1));s.appendBits(e,a)}static appendBytes(e,r,i,s){switch(r){case Re.NUMERIC:lt.appendNumericBytes(e,i);break;case Re.ALPHANUMERIC:lt.appendAlphanumericBytes(e,i);break;case Re.BYTE:lt.append8BitBytes(e,i,s);break;case Re.KANJI:lt.appendKanjiBytes(e,i);break;default:throw new it("Invalid mode: "+r)}}static getDigit(e){return e.charCodeAt(0)-48}static isDigit(e){const r=lt.getDigit(e);return r>=0&&r<=9}static appendNumericBytes(e,r){const i=e.length;let s=0;for(;s<i;){const a=lt.getDigit(e.charAt(s));if(s+2<i){const c=lt.getDigit(e.charAt(s+1)),d=lt.getDigit(e.charAt(s+2));r.appendBits(a*100+c*10+d,10),s+=3}else if(s+1<i){const c=lt.getDigit(e.charAt(s+1));r.appendBits(a*10+c,7),s+=2}else r.appendBits(a,4),s++}}static appendAlphanumericBytes(e,r){const i=e.length;let s=0;for(;s<i;){const a=lt.getAlphanumericCode(e.charCodeAt(s));if(a===-1)throw new it;if(s+1<i){const c=lt.getAlphanumericCode(e.charCodeAt(s+1));if(c===-1)throw new it;r.appendBits(a*45+c,11),s+=2}else r.appendBits(a,6),s++}}static append8BitBytes(e,r,i){let s;try{s=Ce.encode(e,i)}catch(a){throw new it(a)}for(let a=0,c=s.length;a!==c;a++){const d=s[a];r.appendBits(d,8)}}static appendKanjiBytes(e,r){let i;try{i=Ce.encode(e,Y.SJIS)}catch(a){throw new it(a)}const s=i.length;for(let a=0;a<s;a+=2){const c=i[a]&255,d=i[a+1]&255,h=c<<8&4294967295|d;let p=-1;if(h>=33088&&h<=40956?p=h-33088:h>=57408&&h<=60351&&(p=h-49472),p===-1)throw new it("Invalid byte sequence");const w=(p>>8)*192+(p&255);r.appendBits(w,13)}}static appendECI(e,r){r.appendBits(Re.ECI.getBits(),4),r.appendBits(e.getValue(),8)}}lt.ALPHANUMERIC_TABLE=Int32Array.from([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,36,-1,-1,-1,37,38,-1,-1,-1,-1,39,40,-1,41,42,43,0,1,2,3,4,5,6,7,8,9,44,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,-1,-1,-1,-1,-1]),lt.DEFAULT_BYTE_MODE_ENCODING=Y.UTF8.getName();class ur{write(e,r,i,s=null){if(e.length===0)throw new b("Found empty contents");if(r<0||i<0)throw new b("Requested dimensions are too small: "+r+"x"+i);let a=at.L,c=ur.QUIET_ZONE_SIZE;s!==null&&(s.get(Tt.ERROR_CORRECTION)!==void 0&&(a=at.fromString(s.get(Tt.ERROR_CORRECTION).toString())),s.get(Tt.MARGIN)!==void 0&&(c=Number.parseInt(s.get(Tt.MARGIN).toString(),10)));const d=lt.encode(e,a,s);return this.renderResult(d,r,i,c)}writeToDom(e,r,i,s,a=null){typeof e=="string"&&(e=document.querySelector(e));const c=this.write(r,i,s,a);e&&e.appendChild(c)}renderResult(e,r,i,s){const a=e.getMatrix();if(a===null)throw new ue;const c=a.getWidth(),d=a.getHeight(),h=c+s*2,p=d+s*2,w=Math.max(r,h),v=Math.max(i,p),E=Math.min(Math.floor(w/h),Math.floor(v/p)),O=Math.floor((w-c*E)/2),L=Math.floor((v-d*E)/2),$=this.createSVGElement(w,v);for(let Z=0,G=L;Z<d;Z++,G+=E)for(let ae=0,ce=O;ae<c;ae++,ce+=E)if(a.get(ae,Z)===1){const oe=this.createSvgRectElement(ce,G,E,E);$.appendChild(oe)}return $}createSVGElement(e,r){const i=document.createElementNS(ur.SVG_NS,"svg");return i.setAttributeNS(null,"height",e.toString()),i.setAttributeNS(null,"width",r.toString()),i}createSvgRectElement(e,r,i,s){const a=document.createElementNS(ur.SVG_NS,"rect");return a.setAttributeNS(null,"x",e.toString()),a.setAttributeNS(null,"y",r.toString()),a.setAttributeNS(null,"height",i.toString()),a.setAttributeNS(null,"width",s.toString()),a.setAttributeNS(null,"fill","#000000"),a}}ur.QUIET_ZONE_SIZE=4,ur.SVG_NS="http://www.w3.org/2000/svg";class _r{encode(e,r,i,s,a){if(e.length===0)throw new b("Found empty contents");if(r!==S.QR_CODE)throw new b("Can only encode QR_CODE, but got "+r);if(i<0||s<0)throw new b(`Requested dimensions are too small: ${i}x${s}`);let c=at.L,d=_r.QUIET_ZONE_SIZE;a!==null&&(a.get(Tt.ERROR_CORRECTION)!==void 0&&(c=at.fromString(a.get(Tt.ERROR_CORRECTION).toString())),a.get(Tt.MARGIN)!==void 0&&(d=Number.parseInt(a.get(Tt.MARGIN).toString(),10)));const h=lt.encode(e,c,a);return _r.renderResult(h,i,s,d)}static renderResult(e,r,i,s){const a=e.getMatrix();if(a===null)throw new ue;const c=a.getWidth(),d=a.getHeight(),h=c+s*2,p=d+s*2,w=Math.max(r,h),v=Math.max(i,p),E=Math.min(Math.floor(w/h),Math.floor(v/p)),O=Math.floor((w-c*E)/2),L=Math.floor((v-d*E)/2),$=new le(w,v);for(let Z=0,G=L;Z<d;Z++,G+=E)for(let ae=0,ce=O;ae<c;ae++,ce+=E)a.get(ae,Z)===1&&$.setRegion(ce,G,E,E);return $}}_r.QUIET_ZONE_SIZE=4;class U1{encode(e,r,i,s,a){let c;switch(r){case S.QR_CODE:c=new _r;break;default:throw new b("No encoder available for format "+r)}return c.encode(e,r,i,s,a)}}class Dn extends te{constructor(e,r,i,s,a,c,d,h){if(super(c,d),this.yuvData=e,this.dataWidth=r,this.dataHeight=i,this.left=s,this.top=a,s+c>r||a+d>i)throw new b("Crop rectangle does not fit within image data.");h&&this.reverseHorizontal(c,d)}getRow(e,r){if(e<0||e>=this.getHeight())throw new b("Requested row is outside the image: "+e);const i=this.getWidth();(r==null||r.length<i)&&(r=new Uint8ClampedArray(i));const s=(e+this.top)*this.dataWidth+this.left;return D.arraycopy(this.yuvData,s,r,0,i),r}getMatrix(){const e=this.getWidth(),r=this.getHeight();if(e===this.dataWidth&&r===this.dataHeight)return this.yuvData;const i=e*r,s=new Uint8ClampedArray(i);let a=this.top*this.dataWidth+this.left;if(e===this.dataWidth)return D.arraycopy(this.yuvData,a,s,0,i),s;for(let c=0;c<r;c++){const d=c*e;D.arraycopy(this.yuvData,a,s,d,e),a+=this.dataWidth}return s}isCropSupported(){return!0}crop(e,r,i,s){return new Dn(this.yuvData,this.dataWidth,this.dataHeight,this.left+e,this.top+r,i,s,!1)}renderThumbnail(){const e=this.getWidth()/Dn.THUMBNAIL_SCALE_FACTOR,r=this.getHeight()/Dn.THUMBNAIL_SCALE_FACTOR,i=new Int32Array(e*r),s=this.yuvData;let a=this.top*this.dataWidth+this.left;for(let c=0;c<r;c++){const d=c*e;for(let h=0;h<e;h++){const p=s[a+h*Dn.THUMBNAIL_SCALE_FACTOR]&255;i[d+h]=4278190080|p*65793}a+=this.dataWidth*Dn.THUMBNAIL_SCALE_FACTOR}return i}getThumbnailWidth(){return this.getWidth()/Dn.THUMBNAIL_SCALE_FACTOR}getThumbnailHeight(){return this.getHeight()/Dn.THUMBNAIL_SCALE_FACTOR}reverseHorizontal(e,r){const i=this.yuvData;for(let s=0,a=this.top*this.dataWidth+this.left;s<r;s++,a+=this.dataWidth){const c=a+e/2;for(let d=a,h=a+e-1;d<c;d++,h--){const p=i[d];i[d]=i[h],i[h]=p}}}invert(){return new pe(this)}}Dn.THUMBNAIL_SCALE_FACTOR=2;class _o extends te{constructor(e,r,i,s,a,c,d){if(super(r,i),this.dataWidth=s,this.dataHeight=a,this.left=c,this.top=d,e.BYTES_PER_ELEMENT===4){const h=r*i,p=new Uint8ClampedArray(h);for(let w=0;w<h;w++){const v=e[w],E=v>>16&255,O=v>>7&510,L=v&255;p[w]=(E+O+L)/4&255}this.luminances=p}else this.luminances=e;if(s===void 0&&(this.dataWidth=r),a===void 0&&(this.dataHeight=i),c===void 0&&(this.left=0),d===void 0&&(this.top=0),this.left+r>this.dataWidth||this.top+i>this.dataHeight)throw new b("Crop rectangle does not fit within image data.")}getRow(e,r){if(e<0||e>=this.getHeight())throw new b("Requested row is outside the image: "+e);const i=this.getWidth();(r==null||r.length<i)&&(r=new Uint8ClampedArray(i));const s=(e+this.top)*this.dataWidth+this.left;return D.arraycopy(this.luminances,s,r,0,i),r}getMatrix(){const e=this.getWidth(),r=this.getHeight();if(e===this.dataWidth&&r===this.dataHeight)return this.luminances;const i=e*r,s=new Uint8ClampedArray(i);let a=this.top*this.dataWidth+this.left;if(e===this.dataWidth)return D.arraycopy(this.luminances,a,s,0,i),s;for(let c=0;c<r;c++){const d=c*e;D.arraycopy(this.luminances,a,s,d,e),a+=this.dataWidth}return s}isCropSupported(){return!0}crop(e,r,i,s){return new _o(this.luminances,i,s,this.dataWidth,this.dataHeight,this.left+e,this.top+r)}invert(){return new pe(this)}}class Fs extends Y{static forName(e){return this.getCharacterSetECIByName(e)}}class vo{}vo.ISO_8859_1=Y.ISO8859_1;class $s{isCompact(){return this.compact}setCompact(e){this.compact=e}getSize(){return this.size}setSize(e){this.size=e}getLayers(){return this.layers}setLayers(e){this.layers=e}getCodeWords(){return this.codeWords}setCodeWords(e){this.codeWords=e}getMatrix(){return this.matrix}setMatrix(e){this.matrix=e}}class Us{static singletonList(e){return[e]}static min(e,r){return e.sort(r)[0]}}class z1{constructor(e){this.previous=e}getPrevious(){return this.previous}}class vr extends z1{constructor(e,r,i){super(e),this.value=r,this.bitCount=i}appendTo(e,r){e.appendBits(this.value,this.bitCount)}add(e,r){return new vr(this,e,r)}addBinaryShift(e,r){return console.warn("addBinaryShift on SimpleToken, this simply returns a copy of this token"),new vr(this,e,r)}toString(){let e=this.value&(1<<this.bitCount)-1;return e|=1<<this.bitCount,"<"+k.toBinaryString(e|1<<this.bitCount).substring(1)+">"}}class Co extends vr{constructor(e,r,i){super(e,0,0),this.binaryShiftStart=r,this.binaryShiftByteCount=i}appendTo(e,r){for(let i=0;i<this.binaryShiftByteCount;i++)(i===0||i===31&&this.binaryShiftByteCount<=62)&&(e.appendBits(31,5),this.binaryShiftByteCount>62?e.appendBits(this.binaryShiftByteCount-31,16):i===0?e.appendBits(Math.min(this.binaryShiftByteCount,31),5):e.appendBits(this.binaryShiftByteCount-31,5)),e.appendBits(r[this.binaryShiftStart+i],8)}addBinaryShift(e,r){return new Co(this,e,r)}toString(){return"<"+this.binaryShiftStart+"::"+(this.binaryShiftStart+this.binaryShiftByteCount-1)+">"}}function Z1(_,e,r){return new Co(_,e,r)}function Fr(_,e,r){return new vr(_,e,r)}const V1=["UPPER","LOWER","DIGIT","MIXED","PUNCT"],Kn=0,_i=1,pn=2,zs=3,Mn=4,j1=new vr(null,0,0),bo=[Int32Array.from([0,(5<<16)+28,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(9<<16)+480+14,0,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(4<<16)+14,(9<<16)+448+28,0,(9<<16)+448+29,932798]),Int32Array.from([(5<<16)+29,(5<<16)+28,656318,0,(5<<16)+30]),Int32Array.from([(5<<16)+31,656380,656382,656381,0])];function H1(_){for(let e of _)U.fill(e,-1);return _[Kn][Mn]=0,_[_i][Mn]=0,_[_i][Kn]=28,_[zs][Mn]=0,_[pn][Mn]=0,_[pn][Kn]=15,_}const Zs=H1(U.createInt32Array(6,6));class Pn{constructor(e,r,i,s){this.token=e,this.mode=r,this.binaryShiftByteCount=i,this.bitCount=s}getMode(){return this.mode}getToken(){return this.token}getBinaryShiftByteCount(){return this.binaryShiftByteCount}getBitCount(){return this.bitCount}latchAndAppend(e,r){let i=this.bitCount,s=this.token;if(e!==this.mode){let c=bo[this.mode][e];s=Fr(s,c&65535,c>>16),i+=c>>16}let a=e===pn?4:5;return s=Fr(s,r,a),new Pn(s,e,0,i+a)}shiftAndAppend(e,r){let i=this.token,s=this.mode===pn?4:5;return i=Fr(i,Zs[this.mode][e],s),i=Fr(i,r,5),new Pn(i,this.mode,0,this.bitCount+s+5)}addBinaryShiftChar(e){let r=this.token,i=this.mode,s=this.bitCount;if(this.mode===Mn||this.mode===pn){let d=bo[i][Kn];r=Fr(r,d&65535,d>>16),s+=d>>16,i=Kn}let a=this.binaryShiftByteCount===0||this.binaryShiftByteCount===31?18:this.binaryShiftByteCount===62?9:8,c=new Pn(r,i,this.binaryShiftByteCount+1,s+a);return c.binaryShiftByteCount===2078&&(c=c.endBinaryShift(e+1)),c}endBinaryShift(e){if(this.binaryShiftByteCount===0)return this;let r=this.token;return r=Z1(r,e-this.binaryShiftByteCount,this.binaryShiftByteCount),new Pn(r,this.mode,0,this.bitCount)}isBetterThanOrEqualTo(e){let r=this.bitCount+(bo[this.mode][e.mode]>>16);return this.binaryShiftByteCount<e.binaryShiftByteCount?r+=Pn.calculateBinaryShiftCost(e)-Pn.calculateBinaryShiftCost(this):this.binaryShiftByteCount>e.binaryShiftByteCount&&e.binaryShiftByteCount>0&&(r+=10),r<=e.bitCount}toBitArray(e){let r=[];for(let s=this.endBinaryShift(e.length).token;s!==null;s=s.getPrevious())r.unshift(s);let i=new K;for(const s of r)s.appendTo(i,e);return i}toString(){return he.format("%s bits=%d bytes=%d",V1[this.mode],this.bitCount,this.binaryShiftByteCount)}static calculateBinaryShiftCost(e){return e.binaryShiftByteCount>62?21:e.binaryShiftByteCount>31?20:e.binaryShiftByteCount>0?10:0}}Pn.INITIAL_STATE=new Pn(j1,Kn,0,0);function W1(_){const e=he.getCharCode(" "),r=he.getCharCode("."),i=he.getCharCode(",");_[Kn][e]=1;const s=he.getCharCode("Z"),a=he.getCharCode("A");for(let E=a;E<=s;E++)_[Kn][E]=E-a+2;_[_i][e]=1;const c=he.getCharCode("z"),d=he.getCharCode("a");for(let E=d;E<=c;E++)_[_i][E]=E-d+2;_[pn][e]=1;const h=he.getCharCode("9"),p=he.getCharCode("0");for(let E=p;E<=h;E++)_[pn][E]=E-p+2;_[pn][i]=12,_[pn][r]=13;const w=["\0"," ","","","","","","","\x07","\b"," ",`
96
- `,"\v","\f","\r","\x1B","","","","","@","\\","^","_","`","|","~",""];for(let E=0;E<w.length;E++)_[zs][he.getCharCode(w[E])]=E;const v=["\0","\r","\0","\0","\0","\0","!","'","#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","[","]","{","}"];for(let E=0;E<v.length;E++)he.getCharCode(v[E])>0&&(_[Mn][he.getCharCode(v[E])]=E);return _}const Eo=W1(U.createInt32Array(5,256));class $r{constructor(e){this.text=e}encode(){const e=he.getCharCode(" "),r=he.getCharCode(`
97
- `);let i=Us.singletonList(Pn.INITIAL_STATE);for(let a=0;a<this.text.length;a++){let c,d=a+1<this.text.length?this.text[a+1]:0;switch(this.text[a]){case he.getCharCode("\r"):c=d===r?2:0;break;case he.getCharCode("."):c=d===e?3:0;break;case he.getCharCode(","):c=d===e?4:0;break;case he.getCharCode(":"):c=d===e?5:0;break;default:c=0}c>0?(i=$r.updateStateListForPair(i,a,c),a++):i=this.updateStateListForChar(i,a)}return Us.min(i,(a,c)=>a.getBitCount()-c.getBitCount()).toBitArray(this.text)}updateStateListForChar(e,r){const i=[];for(let s of e)this.updateStateForChar(s,r,i);return $r.simplifyStates(i)}updateStateForChar(e,r,i){let s=this.text[r]&255,a=Eo[e.getMode()][s]>0,c=null;for(let d=0;d<=Mn;d++){let h=Eo[d][s];if(h>0){if(c==null&&(c=e.endBinaryShift(r)),!a||d===e.getMode()||d===pn){const p=c.latchAndAppend(d,h);i.push(p)}if(!a&&Zs[e.getMode()][d]>=0){const p=c.shiftAndAppend(d,h);i.push(p)}}}if(e.getBinaryShiftByteCount()>0||Eo[e.getMode()][s]===0){let d=e.addBinaryShiftChar(r);i.push(d)}}static updateStateListForPair(e,r,i){const s=[];for(let a of e)this.updateStateForPair(a,r,i,s);return this.simplifyStates(s)}static updateStateForPair(e,r,i,s){let a=e.endBinaryShift(r);if(s.push(a.latchAndAppend(Mn,i)),e.getMode()!==Mn&&s.push(a.shiftAndAppend(Mn,i)),i===3||i===4){let c=a.latchAndAppend(pn,16-i).latchAndAppend(pn,1);s.push(c)}if(e.getBinaryShiftByteCount()>0){let c=e.addBinaryShiftChar(r).addBinaryShiftChar(r+1);s.push(c)}}static simplifyStates(e){let r=[];for(const i of e){let s=!0;for(const a of r){if(a.isBetterThanOrEqualTo(i)){s=!1;break}i.isBetterThanOrEqualTo(a)&&(r=r.filter(c=>c!==a))}s&&r.push(i)}return r}}class Ge{constructor(){}static encodeBytes(e){return Ge.encode(e,Ge.DEFAULT_EC_PERCENT,Ge.DEFAULT_AZTEC_LAYERS)}static encode(e,r,i){let s=new $r(e).encode(),a=k.truncDivision(s.getSize()*r,100)+11,c=s.getSize()+a,d,h,p,w,v;if(i!==Ge.DEFAULT_AZTEC_LAYERS){if(d=i<0,h=Math.abs(i),h>(d?Ge.MAX_NB_BITS_COMPACT:Ge.MAX_NB_BITS))throw new b(he.format("Illegal value %s for layers",i));p=Ge.totalBitsInLayer(h,d),w=Ge.WORD_SIZE[h];let oe=p-p%w;if(v=Ge.stuffBits(s,w),v.getSize()+a>oe)throw new b("Data to large for user specified layer");if(d&&v.getSize()>w*64)throw new b("Data to large for user specified layer")}else{w=0,v=null;for(let oe=0;;oe++){if(oe>Ge.MAX_NB_BITS)throw new b("Data too large for an Aztec code");if(d=oe<=3,h=d?oe+1:oe,p=Ge.totalBitsInLayer(h,d),c>p)continue;(v==null||w!==Ge.WORD_SIZE[h])&&(w=Ge.WORD_SIZE[h],v=Ge.stuffBits(s,w));let He=p-p%w;if(!(d&&v.getSize()>w*64)&&v.getSize()+a<=He)break}}let E=Ge.generateCheckWords(v,p,w),O=v.getSize()/w,L=Ge.generateModeMessage(d,h,O),$=(d?11:14)+h*4,Z=new Int32Array($),G;if(d){G=$;for(let oe=0;oe<Z.length;oe++)Z[oe]=oe}else{G=$+1+2*k.truncDivision(k.truncDivision($,2)-1,15);let oe=k.truncDivision($,2),He=k.truncDivision(G,2);for(let ze=0;ze<oe;ze++){let tn=ze+k.truncDivision(ze,15);Z[oe-ze-1]=He-tn-1,Z[oe+ze]=He+tn+1}}let ae=new le(G);for(let oe=0,He=0;oe<h;oe++){let ze=(h-oe)*4+(d?9:12);for(let tn=0;tn<ze;tn++){let vn=tn*2;for(let nn=0;nn<2;nn++)E.get(He+vn+nn)&&ae.set(Z[oe*2+nn],Z[oe*2+tn]),E.get(He+ze*2+vn+nn)&&ae.set(Z[oe*2+tn],Z[$-1-oe*2-nn]),E.get(He+ze*4+vn+nn)&&ae.set(Z[$-1-oe*2-nn],Z[$-1-oe*2-tn]),E.get(He+ze*6+vn+nn)&&ae.set(Z[$-1-oe*2-tn],Z[oe*2+nn])}He+=ze*8}if(Ge.drawModeMessage(ae,d,G,L),d)Ge.drawBullsEye(ae,k.truncDivision(G,2),5);else{Ge.drawBullsEye(ae,k.truncDivision(G,2),7);for(let oe=0,He=0;oe<k.truncDivision($,2)-1;oe+=15,He+=16)for(let ze=k.truncDivision(G,2)&1;ze<G;ze+=2)ae.set(k.truncDivision(G,2)-He,ze),ae.set(k.truncDivision(G,2)+He,ze),ae.set(ze,k.truncDivision(G,2)-He),ae.set(ze,k.truncDivision(G,2)+He)}let ce=new $s;return ce.setCompact(d),ce.setSize(G),ce.setLayers(h),ce.setCodeWords(O),ce.setMatrix(ae),ce}static drawBullsEye(e,r,i){for(let s=0;s<i;s+=2)for(let a=r-s;a<=r+s;a++)e.set(a,r-s),e.set(a,r+s),e.set(r-s,a),e.set(r+s,a);e.set(r-i,r-i),e.set(r-i+1,r-i),e.set(r-i,r-i+1),e.set(r+i,r-i),e.set(r+i,r-i+1),e.set(r+i,r+i-1)}static generateModeMessage(e,r,i){let s=new K;return e?(s.appendBits(r-1,2),s.appendBits(i-1,6),s=Ge.generateCheckWords(s,28,4)):(s.appendBits(r-1,5),s.appendBits(i-1,11),s=Ge.generateCheckWords(s,40,4)),s}static drawModeMessage(e,r,i,s){let a=k.truncDivision(i,2);if(r)for(let c=0;c<7;c++){let d=a-3+c;s.get(c)&&e.set(d,a-5),s.get(c+7)&&e.set(a+5,d),s.get(20-c)&&e.set(d,a+5),s.get(27-c)&&e.set(a-5,d)}else for(let c=0;c<10;c++){let d=a-5+c+k.truncDivision(c,5);s.get(c)&&e.set(d,a-7),s.get(c+10)&&e.set(a+7,d),s.get(29-c)&&e.set(d,a+7),s.get(39-c)&&e.set(a-7,d)}}static generateCheckWords(e,r,i){let s=e.getSize()/i,a=new yo(Ge.getGF(i)),c=k.truncDivision(r,i),d=Ge.bitsToWords(e,i,c);a.encode(d,c-s);let h=r%i,p=new K;p.appendBits(0,h);for(const w of Array.from(d))p.appendBits(w,i);return p}static bitsToWords(e,r,i){let s=new Int32Array(i),a,c;for(a=0,c=e.getSize()/r;a<c;a++){let d=0;for(let h=0;h<r;h++)d|=e.get(a*r+h)?1<<r-h-1:0;s[a]=d}return s}static getGF(e){switch(e){case 4:return je.AZTEC_PARAM;case 6:return je.AZTEC_DATA_6;case 8:return je.AZTEC_DATA_8;case 10:return je.AZTEC_DATA_10;case 12:return je.AZTEC_DATA_12;default:throw new b("Unsupported word size "+e)}}static stuffBits(e,r){let i=new K,s=e.getSize(),a=(1<<r)-2;for(let c=0;c<s;c+=r){let d=0;for(let h=0;h<r;h++)(c+h>=s||e.get(c+h))&&(d|=1<<r-1-h);(d&a)===a?(i.appendBits(d&a,r),c--):(d&a)===0?(i.appendBits(d|1,r),c--):i.appendBits(d,r)}return i}static totalBitsInLayer(e,r){return((r?88:112)+16*e)*e}}Ge.DEFAULT_EC_PERCENT=33,Ge.DEFAULT_AZTEC_LAYERS=0,Ge.MAX_NB_BITS=32,Ge.MAX_NB_BITS_COMPACT=4,Ge.WORD_SIZE=Int32Array.from([4,6,6,8,8,8,8,8,8,10,10,10,10,10,10,10,10,10,10,10,10,10,10,12,12,12,12,12,12,12,12,12,12]);class vi{encode(e,r,i,s){return this.encodeWithHints(e,r,i,s,null)}encodeWithHints(e,r,i,s,a){let c=vo.ISO_8859_1,d=Ge.DEFAULT_EC_PERCENT,h=Ge.DEFAULT_AZTEC_LAYERS;return a!=null&&(a.has(Tt.CHARACTER_SET)&&(c=Fs.forName(a.get(Tt.CHARACTER_SET).toString())),a.has(Tt.ERROR_CORRECTION)&&(d=k.parseInt(a.get(Tt.ERROR_CORRECTION).toString())),a.has(Tt.AZTEC_LAYERS)&&(h=k.parseInt(a.get(Tt.AZTEC_LAYERS).toString()))),vi.encodeLayers(e,r,i,s,c,d,h)}static encodeLayers(e,r,i,s,a,c,d){if(r!==S.AZTEC)throw new b("Can only encode AZTEC, but got "+r);let h=Ge.encode(he.getBytes(e,a),c,d);return vi.renderResult(h,i,s)}static renderResult(e,r,i){let s=e.getMatrix();if(s==null)throw new ue;let a=s.getWidth(),c=s.getHeight(),d=Math.max(r,a),h=Math.max(i,c),p=Math.min(d/a,h/c),w=(d-a*p)/2,v=(h-c*p)/2,E=new le(d,h);for(let O=0,L=v;O<c;O++,L+=p)for(let $=0,Z=w;$<a;$++,Z+=p)s.get($,O)&&E.setRegion(Z,L,p,p);return E}}o.AbstractExpandedDecoder=lo,o.ArgumentException=A,o.ArithmeticException=qt,o.AztecCode=$s,o.AztecCodeReader=fi,o.AztecCodeWriter=vi,o.AztecDecoder=Oe,o.AztecDetector=As,o.AztecDetectorResult=pr,o.AztecEncoder=Ge,o.AztecHighLevelEncoder=$r,o.AztecPoint=Vt,o.BarcodeFormat=S,o.Binarizer=R,o.BinaryBitmap=P,o.BitArray=K,o.BitMatrix=le,o.BitSource=ho,o.BrowserAztecCodeReader=w1,o.BrowserBarcodeReader=b1,o.BrowserCodeReader=Fe,o.BrowserDatamatrixCodeReader=A1,o.BrowserMultiFormatReader=B1,o.BrowserPDF417Reader=L1,o.BrowserQRCodeReader=F1,o.BrowserQRCodeSvgWriter=ur,o.CharacterSetECI=Y,o.ChecksumException=N,o.Code128Reader=me,o.Code39Reader=It,o.DataMatrixDecodedBitStreamParser=Gn,o.DataMatrixReader=Xn,o.DecodeHintType=Q,o.DecoderResult=Le,o.DefaultGridSampler=di,o.DetectorResult=ir,o.EAN13Reader=or,o.EncodeHintType=Tt,o.Exception=x,o.FormatException=j,o.GenericGF=je,o.GenericGFPoly=Xe,o.GlobalHistogramBinarizer=J,o.GridSampler=un,o.GridSamplerInstance=Hn,o.HTMLCanvasElementLuminanceSource=ge,o.HybridBinarizer=X,o.ITFReader=rt,o.IllegalArgumentException=b,o.IllegalStateException=ue,o.InvertedLuminanceSource=pe,o.LuminanceSource=te,o.MathUtils=ke,o.MultiFormatOneDReader=wr,o.MultiFormatReader=Ls,o.MultiFormatWriter=U1,o.NotFoundException=F,o.OneDReader=bt,o.PDF417DecodedBitStreamParser=H,o.PDF417DecoderErrorCorrection=ks,o.PDF417Reader=Pt,o.PDF417ResultMetadata=Ds,o.PerspectiveTransform=Kt,o.PlanarYUVLuminanceSource=Dn,o.QRCodeByteMatrix=yi,o.QRCodeDataMask=fn,o.QRCodeDecodedBitStreamParser=mt,o.QRCodeDecoderErrorCorrectionLevel=at,o.QRCodeDecoderFormatInformation=Ut,o.QRCodeEncoder=lt,o.QRCodeEncoderQRCode=cr,o.QRCodeMaskUtil=_t,o.QRCodeMatrixUtil=Me,o.QRCodeMode=Re,o.QRCodeReader=Yn,o.QRCodeVersion=Ne,o.QRCodeWriter=_r,o.RGBLuminanceSource=_o,o.RSS14Reader=yt,o.RSSExpandedReader=ee,o.ReaderException=wi,o.ReedSolomonDecoder=De,o.ReedSolomonEncoder=yo,o.ReedSolomonException=be,o.Result=Pe,o.ResultMetadataType=se,o.ResultPoint=Se,o.StringUtils=he,o.UnsupportedOperationException=Ie,o.VideoInputDevice=ye,o.WhiteRectangleDetector=yn,o.WriterException=it,o.ZXingArrays=U,o.ZXingCharset=Fs,o.ZXingInteger=k,o.ZXingStandardCharsets=vo,o.ZXingStringBuilder=xe,o.ZXingStringEncoding=Ce,o.ZXingSystem=D,o.createAbstractExpandedDecoder=Os,Object.defineProperty(o,"__esModule",{value:!0})}))})(Wr,Wr.exports)),Wr.exports}var ct=py();const gy=Xc(ct),my=K1({__proto__:null,default:gy},[ct]);var Il=(function(){function t(n,o,l){if(this.formatMap=new Map([[Ae.QR_CODE,ct.BarcodeFormat.QR_CODE],[Ae.AZTEC,ct.BarcodeFormat.AZTEC],[Ae.CODABAR,ct.BarcodeFormat.CODABAR],[Ae.CODE_39,ct.BarcodeFormat.CODE_39],[Ae.CODE_93,ct.BarcodeFormat.CODE_93],[Ae.CODE_128,ct.BarcodeFormat.CODE_128],[Ae.DATA_MATRIX,ct.BarcodeFormat.DATA_MATRIX],[Ae.MAXICODE,ct.BarcodeFormat.MAXICODE],[Ae.ITF,ct.BarcodeFormat.ITF],[Ae.EAN_13,ct.BarcodeFormat.EAN_13],[Ae.EAN_8,ct.BarcodeFormat.EAN_8],[Ae.PDF_417,ct.BarcodeFormat.PDF_417],[Ae.RSS_14,ct.BarcodeFormat.RSS_14],[Ae.RSS_EXPANDED,ct.BarcodeFormat.RSS_EXPANDED],[Ae.UPC_A,ct.BarcodeFormat.UPC_A],[Ae.UPC_E,ct.BarcodeFormat.UPC_E],[Ae.UPC_EAN_EXTENSION,ct.BarcodeFormat.UPC_EAN_EXTENSION]]),this.reverseFormatMap=this.createReverseFormatMap(),!my)throw"Use html5qrcode.min.js without edit, ZXing not found.";this.verbose=o,this.logger=l;var u=this.createZXingFormats(n),f=new Map;f.set(ct.DecodeHintType.POSSIBLE_FORMATS,u),f.set(ct.DecodeHintType.TRY_HARDER,!1),this.hints=f}return t.prototype.decodeAsync=function(n){var o=this;return new Promise(function(l,u){try{l(o.decode(n))}catch(f){u(f)}})},t.prototype.decode=function(n){var o=new ct.MultiFormatReader(this.verbose,this.hints),l=new ct.HTMLCanvasElementLuminanceSource(n),u=new ct.BinaryBitmap(new ct.HybridBinarizer(l)),f=o.decode(u);return{text:f.text,format:p1.create(this.toHtml5QrcodeSupportedFormats(f.format)),debugData:this.createDebugData()}},t.prototype.createReverseFormatMap=function(){var n=new Map;return this.formatMap.forEach(function(o,l,u){n.set(o,l)}),n},t.prototype.toHtml5QrcodeSupportedFormats=function(n){if(!this.reverseFormatMap.has(n))throw"reverseFormatMap doesn't have ".concat(n);return this.reverseFormatMap.get(n)},t.prototype.createZXingFormats=function(n){for(var o=[],l=0,u=n;l<u.length;l++){var f=u[l];this.formatMap.has(f)?o.push(this.formatMap.get(f)):this.logger.logError("".concat(f," is not supported by")+"ZXingHtml5QrcodeShim")}return o},t.prototype.createDebugData=function(){return{decoderName:"zxing-js"}},t})(),xy=function(t,n,o,l){function u(f){return f instanceof o?f:new o(function(g){g(f)})}return new(o||(o=Promise))(function(f,g){function m(A){try{x(l.next(A))}catch(b){g(b)}}function y(A){try{x(l.throw(A))}catch(b){g(b)}}function x(A){A.done?f(A.value):u(A.value).then(m,y)}x((l=l.apply(t,n||[])).next())})},wy=function(t,n){var o={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},l,u,f,g;return g={next:m(0),throw:m(1),return:m(2)},typeof Symbol=="function"&&(g[Symbol.iterator]=function(){return this}),g;function m(x){return function(A){return y([x,A])}}function y(x){if(l)throw new TypeError("Generator is already executing.");for(;g&&(g=0,x[0]&&(o=0)),o;)try{if(l=1,u&&(f=x[0]&2?u.return:x[0]?u.throw||((f=u.return)&&f.call(u),0):u.next)&&!(f=f.call(u,x[1])).done)return f;switch(u=0,f&&(x=[x[0]&2,f.value]),x[0]){case 0:case 1:f=x;break;case 4:return o.label++,{value:x[1],done:!1};case 5:o.label++,u=x[1],x=[0];continue;case 7:x=o.ops.pop(),o.trys.pop();continue;default:if(f=o.trys,!(f=f.length>0&&f[f.length-1])&&(x[0]===6||x[0]===2)){o=0;continue}if(x[0]===3&&(!f||x[1]>f[0]&&x[1]<f[3])){o.label=x[1];break}if(x[0]===6&&o.label<f[1]){o.label=f[1],f=x;break}if(f&&o.label<f[2]){o.label=f[2],o.ops.push(x);break}f[2]&&o.ops.pop(),o.trys.pop();continue}x=n.call(t,o)}catch(A){x=[6,A],u=0}finally{l=f=0}if(x[0]&5)throw x[1];return{value:x[0]?x[1]:void 0,done:!0}}},Sl=(function(){function t(n,o,l){if(this.formatMap=new Map([[Ae.QR_CODE,"qr_code"],[Ae.AZTEC,"aztec"],[Ae.CODABAR,"codabar"],[Ae.CODE_39,"code_39"],[Ae.CODE_93,"code_93"],[Ae.CODE_128,"code_128"],[Ae.DATA_MATRIX,"data_matrix"],[Ae.ITF,"itf"],[Ae.EAN_13,"ean_13"],[Ae.EAN_8,"ean_8"],[Ae.PDF_417,"pdf417"],[Ae.UPC_A,"upc_a"],[Ae.UPC_E,"upc_e"]]),this.reverseFormatMap=this.createReverseFormatMap(),!t.isSupported())throw"Use html5qrcode.min.js without edit, Use BarcodeDetectorDelegate only if it isSupported();";this.verbose=o,this.logger=l;var u=this.createBarcodeDetectorFormats(n);if(this.detector=new BarcodeDetector(u),!this.detector)throw"BarcodeDetector detector not supported"}return t.isSupported=function(){if(!("BarcodeDetector"in window))return!1;var n=new BarcodeDetector({formats:["qr_code"]});return typeof n<"u"},t.prototype.decodeAsync=function(n){return xy(this,void 0,void 0,function(){var o,l;return wy(this,function(u){switch(u.label){case 0:return[4,this.detector.detect(n)];case 1:if(o=u.sent(),!o||o.length===0)throw"No barcode or QR code detected.";return l=this.selectLargestBarcode(o),[2,{text:l.rawValue,format:p1.create(this.toHtml5QrcodeSupportedFormats(l.format)),debugData:this.createDebugData()}]}})})},t.prototype.selectLargestBarcode=function(n){for(var o=null,l=0,u=0,f=n;u<f.length;u++){var g=f[u],m=g.boundingBox.width*g.boundingBox.height;m>l&&(l=m,o=g)}if(!o)throw"No largest barcode found";return o},t.prototype.createBarcodeDetectorFormats=function(n){for(var o=[],l=0,u=n;l<u.length;l++){var f=u[l];this.formatMap.has(f)?o.push(this.formatMap.get(f)):this.logger.warn("".concat(f," is not supported by")+"BarcodeDetectorDelegate")}return{formats:o}},t.prototype.toHtml5QrcodeSupportedFormats=function(n){if(!this.reverseFormatMap.has(n))throw"reverseFormatMap doesn't have ".concat(n);return this.reverseFormatMap.get(n)},t.prototype.createReverseFormatMap=function(){var n=new Map;return this.formatMap.forEach(function(o,l,u){n.set(o,l)}),n},t.prototype.createDebugData=function(){return{decoderName:"BarcodeDetector"}},t})(),Tl=function(t,n,o,l){function u(f){return f instanceof o?f:new o(function(g){g(f)})}return new(o||(o=Promise))(function(f,g){function m(A){try{x(l.next(A))}catch(b){g(b)}}function y(A){try{x(l.throw(A))}catch(b){g(b)}}function x(A){A.done?f(A.value):u(A.value).then(m,y)}x((l=l.apply(t,n||[])).next())})},Ol=function(t,n){var o={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},l,u,f,g;return g={next:m(0),throw:m(1),return:m(2)},typeof Symbol=="function"&&(g[Symbol.iterator]=function(){return this}),g;function m(x){return function(A){return y([x,A])}}function y(x){if(l)throw new TypeError("Generator is already executing.");for(;g&&(g=0,x[0]&&(o=0)),o;)try{if(l=1,u&&(f=x[0]&2?u.return:x[0]?u.throw||((f=u.return)&&f.call(u),0):u.next)&&!(f=f.call(u,x[1])).done)return f;switch(u=0,f&&(x=[x[0]&2,f.value]),x[0]){case 0:case 1:f=x;break;case 4:return o.label++,{value:x[1],done:!1};case 5:o.label++,u=x[1],x=[0];continue;case 7:x=o.ops.pop(),o.trys.pop();continue;default:if(f=o.trys,!(f=f.length>0&&f[f.length-1])&&(x[0]===6||x[0]===2)){o=0;continue}if(x[0]===3&&(!f||x[1]>f[0]&&x[1]<f[3])){o.label=x[1];break}if(x[0]===6&&o.label<f[1]){o.label=f[1],f=x;break}if(f&&o.label<f[2]){o.label=f[2],o.ops.push(x);break}f[2]&&o.ops.pop(),o.trys.pop();continue}x=n.call(t,o)}catch(A){x=[6,A],u=0}finally{l=f=0}if(x[0]&5)throw x[1];return{value:x[0]?x[1]:void 0,done:!0}}},yy=(function(){function t(n,o,l,u){this.EXECUTIONS_TO_REPORT_PERFORMANCE=100,this.executions=0,this.executionResults=[],this.wasPrimaryDecoderUsedInLastDecode=!1,this.verbose=l,o&&Sl.isSupported()?(this.primaryDecoder=new Sl(n,l,u),this.secondaryDecoder=new Il(n,l,u)):this.primaryDecoder=new Il(n,l,u)}return t.prototype.decodeAsync=function(n){return Tl(this,void 0,void 0,function(){var o;return Ol(this,function(l){switch(l.label){case 0:o=performance.now(),l.label=1;case 1:return l.trys.push([1,,3,4]),[4,this.getDecoder().decodeAsync(n)];case 2:return[2,l.sent()];case 3:return this.possiblyLogPerformance(o),[7];case 4:return[2]}})})},t.prototype.decodeRobustlyAsync=function(n){return Tl(this,void 0,void 0,function(){var o,l;return Ol(this,function(u){switch(u.label){case 0:o=performance.now(),u.label=1;case 1:return u.trys.push([1,3,4,5]),[4,this.primaryDecoder.decodeAsync(n)];case 2:return[2,u.sent()];case 3:if(l=u.sent(),this.secondaryDecoder)return[2,this.secondaryDecoder.decodeAsync(n)];throw l;case 4:return this.possiblyLogPerformance(o),[7];case 5:return[2]}})})},t.prototype.getDecoder=function(){return this.secondaryDecoder?this.wasPrimaryDecoderUsedInLastDecode===!1?(this.wasPrimaryDecoderUsedInLastDecode=!0,this.primaryDecoder):(this.wasPrimaryDecoderUsedInLastDecode=!1,this.secondaryDecoder):this.primaryDecoder},t.prototype.possiblyLogPerformance=function(n){if(this.verbose){var o=performance.now()-n;this.executionResults.push(o),this.executions++,this.possiblyFlushPerformanceReport()}},t.prototype.possiblyFlushPerformanceReport=function(){if(!(this.executions<this.EXECUTIONS_TO_REPORT_PERFORMANCE)){for(var n=0,o=0,l=this.executionResults;o<l.length;o++){var u=l[o];n+=u}var f=n/this.executionResults.length;console.log("".concat(f," ms for ").concat(this.executionResults.length," last runs.")),this.executions=0,this.executionResults=[]}},t})(),bs=(function(){var t=function(n,o){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(l,u){l.__proto__=u}||function(l,u){for(var f in u)Object.prototype.hasOwnProperty.call(u,f)&&(l[f]=u[f])},t(n,o)};return function(n,o){if(typeof o!="function"&&o!==null)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");t(n,o);function l(){this.constructor=n}n.prototype=o===null?Object.create(o):(l.prototype=o.prototype,new l)}})(),Yi=function(t,n,o,l){function u(f){return f instanceof o?f:new o(function(g){g(f)})}return new(o||(o=Promise))(function(f,g){function m(A){try{x(l.next(A))}catch(b){g(b)}}function y(A){try{x(l.throw(A))}catch(b){g(b)}}function x(A){A.done?f(A.value):u(A.value).then(m,y)}x((l=l.apply(t,n||[])).next())})},qi=function(t,n){var o={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},l,u,f,g;return g={next:m(0),throw:m(1),return:m(2)},typeof Symbol=="function"&&(g[Symbol.iterator]=function(){return this}),g;function m(x){return function(A){return y([x,A])}}function y(x){if(l)throw new TypeError("Generator is already executing.");for(;g&&(g=0,x[0]&&(o=0)),o;)try{if(l=1,u&&(f=x[0]&2?u.return:x[0]?u.throw||((f=u.return)&&f.call(u),0):u.next)&&!(f=f.call(u,x[1])).done)return f;switch(u=0,f&&(x=[x[0]&2,f.value]),x[0]){case 0:case 1:f=x;break;case 4:return o.label++,{value:x[1],done:!1};case 5:o.label++,u=x[1],x=[0];continue;case 7:x=o.ops.pop(),o.trys.pop();continue;default:if(f=o.trys,!(f=f.length>0&&f[f.length-1])&&(x[0]===6||x[0]===2)){o=0;continue}if(x[0]===3&&(!f||x[1]>f[0]&&x[1]<f[3])){o.label=x[1];break}if(x[0]===6&&o.label<f[1]){o.label=f[1],f=x;break}if(f&&o.label<f[2]){o.label=f[2],o.ops.push(x);break}f[2]&&o.ops.pop(),o.trys.pop();continue}x=n.call(t,o)}catch(A){x=[6,A],u=0}finally{l=f=0}if(x[0]&5)throw x[1];return{value:x[0]?x[1]:void 0,done:!0}}},m1=(function(){function t(n,o){this.name=n,this.track=o}return t.prototype.isSupported=function(){return this.track.getCapabilities?this.name in this.track.getCapabilities():!1},t.prototype.apply=function(n){var o={};o[this.name]=n;var l={advanced:[o]};return this.track.applyConstraints(l)},t.prototype.value=function(){var n=this.track.getSettings();if(this.name in n){var o=n[this.name];return o}return null},t})(),_y=(function(t){bs(n,t);function n(o,l){return t.call(this,o,l)||this}return n.prototype.min=function(){return this.getCapabilities().min},n.prototype.max=function(){return this.getCapabilities().max},n.prototype.step=function(){return this.getCapabilities().step},n.prototype.apply=function(o){var l={};l[this.name]=o;var u={advanced:[l]};return this.track.applyConstraints(u)},n.prototype.getCapabilities=function(){this.failIfNotSupported();var o=this.track.getCapabilities(),l=o[this.name];return{min:l.min,max:l.max,step:l.step}},n.prototype.failIfNotSupported=function(){if(!this.isSupported())throw new Error("".concat(this.name," capability not supported"))},n})(m1),vy=(function(t){bs(n,t);function n(o){return t.call(this,"zoom",o)||this}return n})(_y),Cy=(function(t){bs(n,t);function n(o){return t.call(this,"torch",o)||this}return n})(m1),by=(function(){function t(n){this.track=n}return t.prototype.zoomFeature=function(){return new vy(this.track)},t.prototype.torchFeature=function(){return new Cy(this.track)},t})(),Ey=(function(){function t(n,o,l){this.isClosed=!1,this.parentElement=n,this.mediaStream=o,this.callbacks=l,this.surface=this.createVideoElement(this.parentElement.clientWidth),n.append(this.surface)}return t.prototype.createVideoElement=function(n){var o=document.createElement("video");return o.style.width="".concat(n,"px"),o.style.display="block",o.muted=!0,o.setAttribute("muted","true"),o.playsInline=!0,o},t.prototype.setupSurface=function(){var n=this;this.surface.onabort=function(){throw"RenderedCameraImpl video surface onabort() called"},this.surface.onerror=function(){throw"RenderedCameraImpl video surface onerror() called"};var o=function(){var l=n.surface.clientWidth,u=n.surface.clientHeight;n.callbacks.onRenderSurfaceReady(l,u),n.surface.removeEventListener("playing",o)};this.surface.addEventListener("playing",o),this.surface.srcObject=this.mediaStream,this.surface.play()},t.create=function(n,o,l,u){return Yi(this,void 0,void 0,function(){var f,g;return qi(this,function(m){switch(m.label){case 0:return f=new t(n,o,u),l.aspectRatio?(g={aspectRatio:l.aspectRatio},[4,f.getFirstTrackOrFail().applyConstraints(g)]):[3,2];case 1:m.sent(),m.label=2;case 2:return f.setupSurface(),[2,f]}})})},t.prototype.failIfClosed=function(){if(this.isClosed)throw"The RenderedCamera has already been closed."},t.prototype.getFirstTrackOrFail=function(){if(this.failIfClosed(),this.mediaStream.getVideoTracks().length===0)throw"No video tracks found";return this.mediaStream.getVideoTracks()[0]},t.prototype.pause=function(){this.failIfClosed(),this.surface.pause()},t.prototype.resume=function(n){this.failIfClosed();var o=this,l=function(){setTimeout(n,200),o.surface.removeEventListener("playing",l)};this.surface.addEventListener("playing",l),this.surface.play()},t.prototype.isPaused=function(){return this.failIfClosed(),this.surface.paused},t.prototype.getSurface=function(){return this.failIfClosed(),this.surface},t.prototype.getRunningTrackCapabilities=function(){return this.getFirstTrackOrFail().getCapabilities()},t.prototype.getRunningTrackSettings=function(){return this.getFirstTrackOrFail().getSettings()},t.prototype.applyVideoConstraints=function(n){return Yi(this,void 0,void 0,function(){return qi(this,function(o){if("aspectRatio"in n)throw"Changing 'aspectRatio' in run-time is not yet supported.";return[2,this.getFirstTrackOrFail().applyConstraints(n)]})})},t.prototype.close=function(){if(this.isClosed)return Promise.resolve();var n=this;return new Promise(function(o,l){var u=n.mediaStream.getVideoTracks(),f=u.length,g=0;n.mediaStream.getVideoTracks().forEach(function(m){n.mediaStream.removeTrack(m),m.stop(),++g,g>=f&&(n.isClosed=!0,n.parentElement.removeChild(n.surface),o())})})},t.prototype.getCapabilities=function(){return new by(this.getFirstTrackOrFail())},t})(),Ay=(function(){function t(n){this.mediaStream=n}return t.prototype.render=function(n,o,l){return Yi(this,void 0,void 0,function(){return qi(this,function(u){return[2,Ey.create(n,this.mediaStream,o,l)]})})},t.create=function(n){return Yi(this,void 0,void 0,function(){var o,l;return qi(this,function(u){switch(u.label){case 0:if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return o={audio:!1,video:n},[4,navigator.mediaDevices.getUserMedia(o)];case 1:return l=u.sent(),[2,new t(l)]}})})},t})(),Nl=function(t,n,o,l){function u(f){return f instanceof o?f:new o(function(g){g(f)})}return new(o||(o=Promise))(function(f,g){function m(A){try{x(l.next(A))}catch(b){g(b)}}function y(A){try{x(l.throw(A))}catch(b){g(b)}}function x(A){A.done?f(A.value):u(A.value).then(m,y)}x((l=l.apply(t,n||[])).next())})},kl=function(t,n){var o={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},l,u,f,g;return g={next:m(0),throw:m(1),return:m(2)},typeof Symbol=="function"&&(g[Symbol.iterator]=function(){return this}),g;function m(x){return function(A){return y([x,A])}}function y(x){if(l)throw new TypeError("Generator is already executing.");for(;g&&(g=0,x[0]&&(o=0)),o;)try{if(l=1,u&&(f=x[0]&2?u.return:x[0]?u.throw||((f=u.return)&&f.call(u),0):u.next)&&!(f=f.call(u,x[1])).done)return f;switch(u=0,f&&(x=[x[0]&2,f.value]),x[0]){case 0:case 1:f=x;break;case 4:return o.label++,{value:x[1],done:!1};case 5:o.label++,u=x[1],x=[0];continue;case 7:x=o.ops.pop(),o.trys.pop();continue;default:if(f=o.trys,!(f=f.length>0&&f[f.length-1])&&(x[0]===6||x[0]===2)){o=0;continue}if(x[0]===3&&(!f||x[1]>f[0]&&x[1]<f[3])){o.label=x[1];break}if(x[0]===6&&o.label<f[1]){o.label=f[1],f=x;break}if(f&&o.label<f[2]){o.label=f[2],o.ops.push(x);break}f[2]&&o.ops.pop(),o.trys.pop();continue}x=n.call(t,o)}catch(A){x=[6,A],u=0}finally{l=f=0}if(x[0]&5)throw x[1];return{value:x[0]?x[1]:void 0,done:!0}}},Iy=(function(){function t(){}return t.failIfNotSupported=function(){return Nl(this,void 0,void 0,function(){return kl(this,function(n){if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return[2,new t]})})},t.prototype.create=function(n){return Nl(this,void 0,void 0,function(){return kl(this,function(o){return[2,Ay.create(n)]})})},t})(),Sy=function(t,n,o,l){function u(f){return f instanceof o?f:new o(function(g){g(f)})}return new(o||(o=Promise))(function(f,g){function m(A){try{x(l.next(A))}catch(b){g(b)}}function y(A){try{x(l.throw(A))}catch(b){g(b)}}function x(A){A.done?f(A.value):u(A.value).then(m,y)}x((l=l.apply(t,n||[])).next())})},Ty=function(t,n){var o={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},l,u,f,g;return g={next:m(0),throw:m(1),return:m(2)},typeof Symbol=="function"&&(g[Symbol.iterator]=function(){return this}),g;function m(x){return function(A){return y([x,A])}}function y(x){if(l)throw new TypeError("Generator is already executing.");for(;g&&(g=0,x[0]&&(o=0)),o;)try{if(l=1,u&&(f=x[0]&2?u.return:x[0]?u.throw||((f=u.return)&&f.call(u),0):u.next)&&!(f=f.call(u,x[1])).done)return f;switch(u=0,f&&(x=[x[0]&2,f.value]),x[0]){case 0:case 1:f=x;break;case 4:return o.label++,{value:x[1],done:!1};case 5:o.label++,u=x[1],x=[0];continue;case 7:x=o.ops.pop(),o.trys.pop();continue;default:if(f=o.trys,!(f=f.length>0&&f[f.length-1])&&(x[0]===6||x[0]===2)){o=0;continue}if(x[0]===3&&(!f||x[1]>f[0]&&x[1]<f[3])){o.label=x[1];break}if(x[0]===6&&o.label<f[1]){o.label=f[1],f=x;break}if(f&&o.label<f[2]){o.label=f[2],o.ops.push(x);break}f[2]&&o.ops.pop(),o.trys.pop();continue}x=n.call(t,o)}catch(A){x=[6,A],u=0}finally{l=f=0}if(x[0]&5)throw x[1];return{value:x[0]?x[1]:void 0,done:!0}}},Oy=(function(){function t(){}return t.retrieve=function(){if(navigator.mediaDevices)return t.getCamerasFromMediaDevices();var n=MediaStreamTrack;return MediaStreamTrack&&n.getSources?t.getCamerasFromMediaStreamTrack():t.rejectWithError()},t.rejectWithError=function(){var n=Sr.unableToQuerySupportedDevices();return t.isHttpsOrLocalhost()||(n=Sr.insecureContextCameraQueryError()),Promise.reject(n)},t.isHttpsOrLocalhost=function(){if(location.protocol==="https:")return!0;var n=location.host.split(":")[0];return n==="127.0.0.1"||n==="localhost"},t.getCamerasFromMediaDevices=function(){return Sy(this,void 0,void 0,function(){var n,o,l,u,f,g,m;return Ty(this,function(y){switch(y.label){case 0:return n=function(x){for(var A=x.getVideoTracks(),b=0,P=A;b<P.length;b++){var N=P[b];N.enabled=!1,N.stop(),x.removeTrack(N)}},[4,navigator.mediaDevices.getUserMedia({audio:!1,video:!0})];case 1:return o=y.sent(),[4,navigator.mediaDevices.enumerateDevices()];case 2:for(l=y.sent(),u=[],f=0,g=l;f<g.length;f++)m=g[f],m.kind==="videoinput"&&u.push({id:m.deviceId,label:m.label});return n(o),[2,u]}})})},t.getCamerasFromMediaStreamTrack=function(){return new Promise(function(n,o){var l=function(f){for(var g=[],m=0,y=f;m<y.length;m++){var x=y[m];x.kind==="video"&&g.push({id:x.id,label:x.label})}n(g)},u=MediaStreamTrack;u.getSources(l)})},t})(),vt;(function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.NOT_STARTED=1]="NOT_STARTED",t[t.SCANNING=2]="SCANNING",t[t.PAUSED=3]="PAUSED"})(vt||(vt={}));var Ny=(function(){function t(){this.state=vt.NOT_STARTED,this.onGoingTransactionNewState=vt.UNKNOWN}return t.prototype.directTransition=function(n){this.failIfTransitionOngoing(),this.validateTransition(n),this.state=n},t.prototype.startTransition=function(n){return this.failIfTransitionOngoing(),this.validateTransition(n),this.onGoingTransactionNewState=n,this},t.prototype.execute=function(){if(this.onGoingTransactionNewState===vt.UNKNOWN)throw"Transaction is already cancelled, cannot execute().";var n=this.onGoingTransactionNewState;this.onGoingTransactionNewState=vt.UNKNOWN,this.directTransition(n)},t.prototype.cancel=function(){if(this.onGoingTransactionNewState===vt.UNKNOWN)throw"Transaction is already cancelled, cannot cancel().";this.onGoingTransactionNewState=vt.UNKNOWN},t.prototype.getState=function(){return this.state},t.prototype.failIfTransitionOngoing=function(){if(this.onGoingTransactionNewState!==vt.UNKNOWN)throw"Cannot transition to a new state, already under transition"},t.prototype.validateTransition=function(n){switch(this.state){case vt.UNKNOWN:throw"Transition from unknown is not allowed";case vt.NOT_STARTED:this.failIfNewStateIs(n,[vt.PAUSED]);break;case vt.SCANNING:break;case vt.PAUSED:break}},t.prototype.failIfNewStateIs=function(n,o){for(var l=0,u=o;l<u.length;l++){var f=u[l];if(n===f)throw"Cannot transition from ".concat(this.state," to ").concat(n)}},t})(),ky=(function(){function t(n){this.stateManager=n}return t.prototype.startTransition=function(n){return this.stateManager.startTransition(n)},t.prototype.directTransition=function(n){this.stateManager.directTransition(n)},t.prototype.getState=function(){return this.stateManager.getState()},t.prototype.canScanFile=function(){return this.stateManager.getState()===vt.NOT_STARTED},t.prototype.isScanning=function(){return this.stateManager.getState()!==vt.NOT_STARTED},t.prototype.isStrictlyScanning=function(){return this.stateManager.getState()===vt.SCANNING},t.prototype.isPaused=function(){return this.stateManager.getState()===vt.PAUSED},t})(),Ry=(function(){function t(){}return t.create=function(){return new ky(new Ny)},t})(),Dy=(function(){var t=function(n,o){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(l,u){l.__proto__=u}||function(l,u){for(var f in u)Object.prototype.hasOwnProperty.call(u,f)&&(l[f]=u[f])},t(n,o)};return function(n,o){if(typeof o!="function"&&o!==null)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");t(n,o);function l(){this.constructor=n}n.prototype=o===null?Object.create(o):(l.prototype=o.prototype,new l)}})(),sn=(function(t){Dy(n,t);function n(){return t!==null&&t.apply(this,arguments)||this}return n.DEFAULT_WIDTH=300,n.DEFAULT_WIDTH_OFFSET=2,n.FILE_SCAN_MIN_HEIGHT=300,n.FILE_SCAN_HIDDEN_CANVAS_PADDING=100,n.MIN_QR_BOX_SIZE=50,n.SHADED_LEFT=1,n.SHADED_RIGHT=2,n.SHADED_TOP=3,n.SHADED_BOTTOM=4,n.SHADED_REGION_ELEMENT_ID="qr-shaded-region",n.VERBOSE=!1,n.BORDER_SHADER_DEFAULT_COLOR="#ffffff",n.BORDER_SHADER_MATCH_COLOR="rgb(90, 193, 56)",n})(uy),My=(function(){function t(n,o){this.logger=o,this.fps=sn.SCAN_DEFAULT_FPS,n?(n.fps&&(this.fps=n.fps),this.disableFlip=n.disableFlip===!0,this.qrbox=n.qrbox,this.aspectRatio=n.aspectRatio,this.videoConstraints=n.videoConstraints):this.disableFlip=sn.DEFAULT_DISABLE_FLIP}return t.prototype.isMediaStreamConstraintsValid=function(){return this.videoConstraints?g1.isMediaStreamConstraintsValid(this.videoConstraints,this.logger):(this.logger.logError("Empty videoConstraints",!0),!1)},t.prototype.isShadedBoxEnabled=function(){return!Un(this.qrbox)},t.create=function(n,o){return new t(n,o)},t})(),Rl=(function(){function t(n,o){if(this.element=null,this.canvasElement=null,this.scannerPausedUiElement=null,this.hasBorderShaders=null,this.borderShaders=null,this.qrMatch=null,this.renderedCamera=null,this.qrRegion=null,this.context=null,this.lastScanImageFile=null,this.isScanning=!1,!document.getElementById(n))throw"HTML Element with id=".concat(n," not found");this.elementId=n,this.verbose=!1;var l;typeof o=="boolean"?this.verbose=o===!0:o&&(l=o,this.verbose=l.verbose===!0,l.experimentalFeatures),this.logger=new fy(this.verbose),this.qrcode=new yy(this.getSupportedFormats(o),this.getUseBarCodeDetectorIfSupported(l),this.verbose,this.logger),this.foreverScanTimeout,this.shouldScan=!0,this.stateManagerProxy=Ry.create()}return t.prototype.start=function(n,o,l,u){var f=this;if(!n)throw"cameraIdOrConfig is required";if(!l||typeof l!="function")throw"qrCodeSuccessCallback is required and should be a function.";var g;u?g=u:g=this.verbose?this.logger.log:function(){};var m=My.create(o,this.logger);this.clearElement();var y=!1;m.videoConstraints&&(m.isMediaStreamConstraintsValid()?y=!0:this.logger.logError("'videoConstraints' is not valid 'MediaStreamConstraints, it will be ignored.'",!0));var x=y,A=document.getElementById(this.elementId);A.clientWidth?A.clientWidth:sn.DEFAULT_WIDTH,A.style.position="relative",this.shouldScan=!0,this.element=A;var b=this,P=this.stateManagerProxy.startTransition(vt.SCANNING);return new Promise(function(N,R){var D=x?m.videoConstraints:b.createVideoConstraints(n);if(!D){P.cancel(),R("videoConstraints should be defined");return}var M={};(!x||m.aspectRatio)&&(M.aspectRatio=m.aspectRatio);var z={onRenderSurfaceReady:function(U,k){b.setupUi(U,k,m),b.isScanning=!0,b.foreverScan(m,l,g)}};Iy.failIfNotSupported().then(function(U){U.create(D).then(function(k){return k.render(f.element,M,z).then(function(K){b.renderedCamera=K,P.execute(),N(null)}).catch(function(K){P.cancel(),R(K)})}).catch(function(k){P.cancel(),R(Sr.errorGettingUserMedia(k))})}).catch(function(U){P.cancel(),R(Sr.cameraStreamingNotSupported())})})},t.prototype.pause=function(n){if(!this.stateManagerProxy.isStrictlyScanning())throw"Cannot pause, scanner is not scanning.";this.stateManagerProxy.directTransition(vt.PAUSED),this.showPausedState(),(Un(n)||n!==!0)&&(n=!1),n&&this.renderedCamera&&this.renderedCamera.pause()},t.prototype.resume=function(){if(!this.stateManagerProxy.isPaused())throw"Cannot result, scanner is not paused.";if(!this.renderedCamera)throw"renderedCamera doesn't exist while trying resume()";var n=this,o=function(){n.stateManagerProxy.directTransition(vt.SCANNING),n.hidePausedState()};if(!this.renderedCamera.isPaused()){o();return}this.renderedCamera.resume(function(){o()})},t.prototype.getState=function(){return this.stateManagerProxy.getState()},t.prototype.stop=function(){var n=this;if(!this.stateManagerProxy.isScanning())throw"Cannot stop, scanner is not running or paused.";var o=this.stateManagerProxy.startTransition(vt.NOT_STARTED);this.shouldScan=!1,this.foreverScanTimeout&&clearTimeout(this.foreverScanTimeout);var l=function(){if(n.element){var f=document.getElementById(sn.SHADED_REGION_ELEMENT_ID);f&&n.element.removeChild(f)}},u=this;return this.renderedCamera.close().then(function(){return u.renderedCamera=null,u.element&&(u.element.removeChild(u.canvasElement),u.canvasElement=null),l(),u.qrRegion&&(u.qrRegion=null),u.context&&(u.context=null),o.execute(),u.hidePausedState(),u.isScanning=!1,Promise.resolve()})},t.prototype.scanFile=function(n,o){return this.scanFileV2(n,o).then(function(l){return l.decodedText})},t.prototype.scanFileV2=function(n,o){var l=this;if(!n||!(n instanceof File))throw"imageFile argument is mandatory and should be instance of File. Use 'event.target.files[0]'.";if(Un(o)&&(o=!0),!this.stateManagerProxy.canScanFile())throw"Cannot start file scan - ongoing camera scan";return new Promise(function(u,f){l.possiblyCloseLastScanImageFile(),l.clearElement(),l.lastScanImageFile=URL.createObjectURL(n);var g=new Image;g.onload=function(){var m=g.width,y=g.height,x=document.getElementById(l.elementId),A=x.clientWidth?x.clientWidth:sn.DEFAULT_WIDTH,b=Math.max(x.clientHeight?x.clientHeight:y,sn.FILE_SCAN_MIN_HEIGHT),P=l.computeCanvasDrawConfig(m,y,A,b);if(o){var N=l.createCanvasElement(A,b,"qr-canvas-visible");N.style.display="inline-block",x.appendChild(N);var R=N.getContext("2d");if(!R)throw"Unable to get 2d context from canvas";R.canvas.width=A,R.canvas.height=b,R.drawImage(g,0,0,m,y,P.x,P.y,P.width,P.height)}var D=sn.FILE_SCAN_HIDDEN_CANVAS_PADDING,M=Math.max(g.width,P.width),z=Math.max(g.height,P.height),U=M+2*D,k=z+2*D,K=l.createCanvasElement(U,k);x.appendChild(K);var ve=K.getContext("2d");if(!ve)throw"Unable to get 2d context from canvas";ve.canvas.width=U,ve.canvas.height=k,ve.drawImage(g,0,0,m,y,D,D,M,z);try{l.qrcode.decodeRobustlyAsync(K).then(function(Q){u(El.createFromQrcodeResult(Q))}).catch(f)}catch(Q){f("QR code parse error, error = ".concat(Q))}},g.onerror=f,g.onabort=f,g.onstalled=f,g.onsuspend=f,g.src=URL.createObjectURL(n)})},t.prototype.clear=function(){this.clearElement()},t.getCameras=function(){return Oy.retrieve()},t.prototype.getRunningTrackCapabilities=function(){return this.getRenderedCameraOrFail().getRunningTrackCapabilities()},t.prototype.getRunningTrackSettings=function(){return this.getRenderedCameraOrFail().getRunningTrackSettings()},t.prototype.getRunningTrackCameraCapabilities=function(){return this.getRenderedCameraOrFail().getCapabilities()},t.prototype.applyVideoConstraints=function(n){if(n){if(!g1.isMediaStreamConstraintsValid(n,this.logger))throw"invalid videoConstaints passed, check logs for more details"}else throw"videoConstaints is required argument.";return this.getRenderedCameraOrFail().applyVideoConstraints(n)},t.prototype.getRenderedCameraOrFail=function(){if(this.renderedCamera==null)throw"Scanning is not in running state, call this API only when QR code scanning using camera is in running state.";return this.renderedCamera},t.prototype.getSupportedFormats=function(n){var o=[Ae.QR_CODE,Ae.AZTEC,Ae.CODABAR,Ae.CODE_39,Ae.CODE_93,Ae.CODE_128,Ae.DATA_MATRIX,Ae.MAXICODE,Ae.ITF,Ae.EAN_13,Ae.EAN_8,Ae.PDF_417,Ae.RSS_14,Ae.RSS_EXPANDED,Ae.UPC_A,Ae.UPC_E,Ae.UPC_EAN_EXTENSION];if(!n||typeof n=="boolean"||!n.formatsToSupport)return o;if(!Array.isArray(n.formatsToSupport))throw"configOrVerbosityFlag.formatsToSupport should be undefined or an array.";if(n.formatsToSupport.length===0)throw"Atleast 1 formatsToSupport is needed.";for(var l=[],u=0,f=n.formatsToSupport;u<f.length;u++){var g=f[u];cy(g)?l.push(g):this.logger.warn("Invalid format: ".concat(g," passed in config, ignoring."))}if(l.length===0)throw"None of formatsToSupport match supported values.";return l},t.prototype.getUseBarCodeDetectorIfSupported=function(n){if(Un(n))return!0;if(!Un(n.useBarCodeDetectorIfSupported))return n.useBarCodeDetectorIfSupported!==!1;if(Un(n.experimentalFeatures))return!0;var o=n.experimentalFeatures;return Un(o.useBarCodeDetectorIfSupported)?!0:o.useBarCodeDetectorIfSupported!==!1},t.prototype.validateQrboxSize=function(n,o,l){var u=this,f=l.qrbox;this.validateQrboxConfig(f);var g=this.toQrdimensions(n,o,f),m=function(x){if(x<sn.MIN_QR_BOX_SIZE)throw"minimum size of 'config.qrbox' dimension value is"+" ".concat(sn.MIN_QR_BOX_SIZE,"px.")},y=function(x){return x>n&&(u.logger.warn("`qrbox.width` or `qrbox` is larger than the width of the root element. The width will be truncated to the width of root element."),x=n),x};m(g.width),m(g.height),g.width=y(g.width)},t.prototype.validateQrboxConfig=function(n){if(typeof n!="number"&&typeof n!="function"&&(n.width===void 0||n.height===void 0))throw"Invalid instance of QrDimensions passed for 'config.qrbox'. Both 'width' and 'height' should be set."},t.prototype.toQrdimensions=function(n,o,l){if(typeof l=="number")return{width:l,height:l};if(typeof l=="function")try{return l(n,o)}catch(u){throw new Error("qrbox config was passed as a function but it failed with unknown error"+u)}return l},t.prototype.setupUi=function(n,o,l){l.isShadedBoxEnabled()&&this.validateQrboxSize(n,o,l);var u=Un(l.qrbox)?{width:n,height:o}:l.qrbox;this.validateQrboxConfig(u);var f=this.toQrdimensions(n,o,u);f.height>o&&this.logger.warn("[Html5Qrcode] config.qrbox has height that isgreater than the height of the video stream. Shading will be ignored");var g=l.isShadedBoxEnabled()&&f.height<=o,m={x:0,y:0,width:n,height:o},y=g?this.getShadedRegionBounds(n,o,f):m,x=this.createCanvasElement(y.width,y.height),A={willReadFrequently:!0},b=x.getContext("2d",A);b.canvas.width=y.width,b.canvas.height=y.height,this.element.append(x),g&&this.possiblyInsertShadingElement(this.element,n,o,f),this.createScannerPausedUiElement(this.element),this.qrRegion=y,this.context=b,this.canvasElement=x},t.prototype.createScannerPausedUiElement=function(n){var o=document.createElement("div");o.innerText=Sr.scannerPaused(),o.style.display="none",o.style.position="absolute",o.style.top="0px",o.style.zIndex="1",o.style.background="rgba(9, 9, 9, 0.46)",o.style.color="#FFECEC",o.style.textAlign="center",o.style.width="100%",n.appendChild(o),this.scannerPausedUiElement=o},t.prototype.scanContext=function(n,o){var l=this;return this.stateManagerProxy.isPaused()?Promise.resolve(!1):this.qrcode.decodeAsync(this.canvasElement).then(function(u){return n(u.text,El.createFromQrcodeResult(u)),l.possiblyUpdateShaders(!0),!0}).catch(function(u){l.possiblyUpdateShaders(!1);var f=Sr.codeParseError(u);return o(f,dy.createFrom(f)),!1})},t.prototype.foreverScan=function(n,o,l){var u=this;if(this.shouldScan&&this.renderedCamera){var f=this.renderedCamera.getSurface(),g=f.videoWidth/f.clientWidth,m=f.videoHeight/f.clientHeight;if(!this.qrRegion)throw"qrRegion undefined when localMediaStream is ready.";var y=this.qrRegion.width*g,x=this.qrRegion.height*m,A=this.qrRegion.x*g,b=this.qrRegion.y*m;this.context.drawImage(f,A,b,y,x,0,0,this.qrRegion.width,this.qrRegion.height);var P=function(){u.foreverScanTimeout=setTimeout(function(){u.foreverScan(n,o,l)},u.getTimeoutFps(n.fps))};this.scanContext(o,l).then(function(N){!N&&n.disableFlip!==!0?(u.context.translate(u.context.canvas.width,0),u.context.scale(-1,1),u.scanContext(o,l).finally(function(){P()})):P()}).catch(function(N){u.logger.logError("Error happend while scanning context",N),P()})}},t.prototype.createVideoConstraints=function(n){if(typeof n=="string")return{deviceId:{exact:n}};if(typeof n=="object"){var o="facingMode",l="deviceId",u={user:!0,environment:!0},f="exact",g=function(R){if(R in u)return!0;throw"config has invalid 'facingMode' value = "+"'".concat(R,"'")},m=Object.keys(n);if(m.length!==1)throw"'cameraIdOrConfig' object should have exactly 1 key,"+" if passed as an object, found ".concat(m.length," keys");var y=Object.keys(n)[0];if(y!==o&&y!==l)throw"Only '".concat(o,"' and '").concat(l,"' ")+" are supported for 'cameraIdOrConfig'";if(y===o){var x=n.facingMode;if(typeof x=="string"){if(g(x))return{facingMode:x}}else if(typeof x=="object")if(f in x){if(g(x["".concat(f)]))return{facingMode:{exact:x["".concat(f)]}}}else throw"'facingMode' should be string or object with"+" ".concat(f," as key.");else{var A=typeof x;throw"Invalid type of 'facingMode' = ".concat(A)}}else{var b=n.deviceId;if(typeof b=="string")return{deviceId:b};if(typeof b=="object"){if(f in b)return{deviceId:{exact:b["".concat(f)]}};throw"'deviceId' should be string or object with"+" ".concat(f," as key.")}else{var P=typeof b;throw"Invalid type of 'deviceId' = ".concat(P)}}}var N=typeof n;throw"Invalid type of 'cameraIdOrConfig' = ".concat(N)},t.prototype.computeCanvasDrawConfig=function(n,o,l,u){if(n<=l&&o<=u){var f=(l-n)/2,g=(u-o)/2;return{x:f,y:g,width:n,height:o}}else{var m=n,y=o;return n>l&&(o=l/n*o,n=l),o>u&&(n=u/o*n,o=u),this.logger.log("Image downsampled from "+"".concat(m,"X").concat(y)+" to ".concat(n,"X").concat(o,".")),this.computeCanvasDrawConfig(n,o,l,u)}},t.prototype.clearElement=function(){if(this.stateManagerProxy.isScanning())throw"Cannot clear while scan is ongoing, close it first.";var n=document.getElementById(this.elementId);n&&(n.innerHTML="")},t.prototype.possiblyUpdateShaders=function(n){this.qrMatch!==n&&(this.hasBorderShaders&&this.borderShaders&&this.borderShaders.length&&this.borderShaders.forEach(function(o){o.style.backgroundColor=n?sn.BORDER_SHADER_MATCH_COLOR:sn.BORDER_SHADER_DEFAULT_COLOR}),this.qrMatch=n)},t.prototype.possiblyCloseLastScanImageFile=function(){this.lastScanImageFile&&(URL.revokeObjectURL(this.lastScanImageFile),this.lastScanImageFile=null)},t.prototype.createCanvasElement=function(n,o,l){var u=n,f=o,g=document.createElement("canvas");return g.style.width="".concat(u,"px"),g.style.height="".concat(f,"px"),g.style.display="none",g.id=Un(l)?"qr-canvas":l,g},t.prototype.getShadedRegionBounds=function(n,o,l){if(l.width>n||l.height>o)throw"'config.qrbox' dimensions should not be greater than the dimensions of the root HTML element.";return{x:(n-l.width)/2,y:(o-l.height)/2,width:l.width,height:l.height}},t.prototype.possiblyInsertShadingElement=function(n,o,l,u){if(!(o-u.width<1||l-u.height<1)){var f=document.createElement("div");f.style.position="absolute";var g=(o-u.width)/2,m=(l-u.height)/2;if(f.style.borderLeft="".concat(g,"px solid rgba(0, 0, 0, 0.48)"),f.style.borderRight="".concat(g,"px solid rgba(0, 0, 0, 0.48)"),f.style.borderTop="".concat(m,"px solid rgba(0, 0, 0, 0.48)"),f.style.borderBottom="".concat(m,"px solid rgba(0, 0, 0, 0.48)"),f.style.boxSizing="border-box",f.style.top="0px",f.style.bottom="0px",f.style.left="0px",f.style.right="0px",f.id="".concat(sn.SHADED_REGION_ELEMENT_ID),o-u.width<11||l-u.height<11)this.hasBorderShaders=!1;else{var y=5,x=40;this.insertShaderBorders(f,x,y,-y,null,0,!0),this.insertShaderBorders(f,x,y,-y,null,0,!1),this.insertShaderBorders(f,x,y,null,-y,0,!0),this.insertShaderBorders(f,x,y,null,-y,0,!1),this.insertShaderBorders(f,y,x+y,-y,null,-y,!0),this.insertShaderBorders(f,y,x+y,null,-y,-y,!0),this.insertShaderBorders(f,y,x+y,-y,null,-y,!1),this.insertShaderBorders(f,y,x+y,null,-y,-y,!1),this.hasBorderShaders=!0}n.append(f)}},t.prototype.insertShaderBorders=function(n,o,l,u,f,g,m){var y=document.createElement("div");y.style.position="absolute",y.style.backgroundColor=sn.BORDER_SHADER_DEFAULT_COLOR,y.style.width="".concat(o,"px"),y.style.height="".concat(l,"px"),u!==null&&(y.style.top="".concat(u,"px")),f!==null&&(y.style.bottom="".concat(f,"px")),m?y.style.left="".concat(g,"px"):y.style.right="".concat(g,"px"),this.borderShaders||(this.borderShaders=[]),this.borderShaders.push(y),n.appendChild(y)},t.prototype.showPausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="block"},t.prototype.hidePausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="none"},t.prototype.getTimeoutFps=function(n){return 1e3/n},t})(),Dl;(function(t){t[t.STATUS_DEFAULT=0]="STATUS_DEFAULT",t[t.STATUS_SUCCESS=1]="STATUS_SUCCESS",t[t.STATUS_WARNING=2]="STATUS_WARNING",t[t.STATUS_REQUESTING_PERMISSION=3]="STATUS_REQUESTING_PERMISSION"})(Dl||(Dl={}));const Py={class:"scan-code"},By={class:"btn"},Ly={class:"left-back"},Fy=C.defineComponent({name:"QrCodeScan",__name:"qr-code-scan",emits:["scanSuccess"],setup(t,{emit:n}){const o=n,l=q1.IconScan(),u=C.reactive({html5QrCode:null}),f=C.ref(!1),g=()=>{if(!u.html5QrCode){ht("摄像头无访问权限!");return}f.value=!0,u.html5QrCode.start({facingMode:"environment"},{fps:30,aspectRatio:1,supportedScanTypes:[ii.SCAN_TYPE_CAMERA],showTorchButtonIfSupported:!0,showZoomSliderIfSupported:!0,defaultZoomValueIfSupported:2,useBarCodeDetectorIfSupported:!0},b=>{try{const N=new URL(b).searchParams.get("sessionId");N?o("scanSuccess",N):ht("无效的二维码")}catch{ht("无效的二维码")}A()}).catch(b=>{console.log(b),ht({message:"二维码识别失败",duration:3e3})})},m=()=>{x().then(()=>{g()})},y=()=>{A()},x=()=>Rl.getCameras().then(b=>{b&&b.length&&(u.html5QrCode=new Rl("reader"))}).catch(()=>{ht({message:"摄像头无访问权限!",duration:3e3})}),A=()=>{u.html5QrCode&&u.html5QrCode.stop().then(b=>{console.log("停止扫码",b)}).catch(b=>{console.log(b),ht("停止扫码失败")}).finally(()=>{f.value=!1})};return C.onUnmounted(()=>{u.html5QrCode&&u.html5QrCode.isScanning&&A()}),(b,P)=>{const N=io;return C.openBlock(),C.createElementBlock("div",null,[C.createVNode(C.unref(Gt.TrIconButton),{icon:C.unref(l),size:"28",svgSize:"20",onClick:P[0]||(P[0]=R=>m())},null,8,["icon"]),(C.openBlock(),C.createBlock(C.Teleport,{to:"body"},[C.withDirectives(C.createElementVNode("div",Py,[P[1]||(P[1]=C.createElementVNode("div",{class:"container"},[C.createElementVNode("div",{class:"qrcode"},[C.createElementVNode("div",{id:"reader"})])],-1)),C.createElementVNode("div",By,[C.createElementVNode("div",Ly,[C.createVNode(N,{name:"arrow-left",onClick:y})])])],512),[[C.vShow,f.value]])]))])}}}),ui=(t,n)=>{const o=t.__vccOpts||t;for(const[l,u]of n)o[l]=u;return o},$y=ui(Fy,[["__scopeId","data-v-83b38497"]]),Uy=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const zy=Object.prototype.toString,Zy=t=>zy.call(t)==="[object Object]",Pi=()=>{};function Fo(t){return Array.isArray(t)?t:[t]}function Vy(t,n,o){return C.watch(t,n,{...o,immediate:!0})}const x1=Uy?window:void 0;function Gr(t){var n;const o=C.toValue(t);return(n=o?.$el)!==null&&n!==void 0?n:o}function $o(...t){const n=(l,u,f,g)=>(l.addEventListener(u,f,g),()=>l.removeEventListener(u,f,g)),o=C.computed(()=>{const l=Fo(C.toValue(t[0])).filter(u=>u!=null);return l.every(u=>typeof u!="string")?l:void 0});return Vy(()=>{var l,u;return[(l=(u=o.value)===null||u===void 0?void 0:u.map(f=>Gr(f)))!==null&&l!==void 0?l:[x1].filter(f=>f!=null),Fo(C.toValue(o.value?t[1]:t[0])),Fo(C.unref(o.value?t[2]:t[1])),C.toValue(o.value?t[3]:t[2])]},([l,u,f,g],m,y)=>{if(!l?.length||!u?.length||!f?.length)return;const x=Zy(g)?{...g}:g,A=l.flatMap(b=>u.flatMap(P=>f.map(N=>n(b,P,N,x))));y(()=>{A.forEach(b=>b())})},{flush:"post"})}function jy(t,n,o={}){const{window:l=x1,ignore:u=[],capture:f=!0,detectIframe:g=!1,controls:m=!1}=o;if(!l)return m?{stop:Pi,cancel:Pi,trigger:Pi}:Pi;let y=!0;const x=M=>C.toValue(u).some(z=>{if(typeof z=="string")return Array.from(l.document.querySelectorAll(z)).some(U=>U===M.target||M.composedPath().includes(U));{const U=Gr(z);return U&&(M.target===U||M.composedPath().includes(U))}});function A(M){const z=C.toValue(M);return z&&z.$.subTree.shapeFlag===16}function b(M,z){const U=C.toValue(M),k=U.$.subTree&&U.$.subTree.children;return k==null||!Array.isArray(k)?!1:k.some(K=>K.el===z.target||z.composedPath().includes(K.el))}const P=M=>{const z=Gr(t);if(M.target!=null&&!(!(z instanceof Element)&&A(t)&&b(t,M))&&!(!z||z===M.target||M.composedPath().includes(z))){if("detail"in M&&M.detail===0&&(y=!x(M)),!y){y=!0;return}n(M)}};let N=!1;const R=[$o(l,"click",M=>{N||(N=!0,setTimeout(()=>{N=!1},0),P(M))},{passive:!0,capture:f}),$o(l,"pointerdown",M=>{const z=Gr(t);y=!x(M)&&!!(z&&!M.composedPath().includes(z))},{passive:!0}),g&&$o(l,"blur",M=>{setTimeout(()=>{var z;const U=Gr(t);((z=l.document.activeElement)===null||z===void 0?void 0:z.tagName)==="IFRAME"&&!U?.contains(l.document.activeElement)&&n(M)},0)},{passive:!0})].filter(Boolean),D=()=>R.forEach(M=>M());return m?{stop:D,cancel:()=>{y=!1},trigger:M=>{y=!0,P(M),y=!1}}:D}const Hy=["data-active","disabled"],Wy=C.defineComponent({__name:"Button",props:{active:{type:Boolean},rounded:{type:Boolean},size:{default:"medium"},disabled:{type:Boolean}},setup(t){return(n,o)=>(C.openBlock(),C.createElementBlock("button",{class:C.normalizeClass(["button",{rounded:t.rounded,[t.size]:!0}]),"data-active":t.active||void 0,disabled:t.disabled||void 0},[C.renderSlot(n.$slots,"default",{},void 0,!0)],10,Hy))}}),Es=ui(Wy,[["__scopeId","data-v-6f582cce"]]),Gy={viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",fill:"none"};function Xy(t,n){return C.openBlock(),C.createElementBlock("svg",Gy,[...n[0]||(n[0]=[C.createElementVNode("rect",{id:"大模型",width:"16.000000",height:"16.000000",x:"0.000000",y:"0.000000"},null,-1),C.createElementVNode("path",{id:"矢量 90",d:"M13.683 2.26904C12.5753 1.16177 10.344 1.47577 8.02582 2.86527C5.70758 1.47576 3.47637 1.16179 2.36913 2.26904C1.2619 3.37646 1.57573 5.60771 2.96524 7.92589C1.57573 10.2441 1.2619 12.4754 2.36913 13.5827C3.47637 14.6901 5.7078 14.3762 8.02599 12.9867C10.344 14.3762 12.5752 14.6901 13.6825 13.5827C14.7901 12.4754 14.4761 10.2441 13.0866 7.92594C14.4761 5.60775 14.7902 3.37646 13.683 2.26904ZM10.8544 5.09764C11.4667 5.70995 12.0076 6.34819 12.4699 6.99044C12.7244 6.52061 12.9268 6.06037 13.077 5.60959C13.2948 4.95652 13.3832 4.38597 13.3426 3.89769C13.3089 3.49437 13.1869 3.18725 12.9754 2.97631C12.7645 2.76513 12.4574 2.64282 12.0541 2.60912C11.5658 2.56835 10.9955 2.65698 10.3422 2.87475C9.89153 3.02497 9.43121 3.22735 8.96135 3.48197C9.60365 3.94428 10.242 4.48527 10.8544 5.09764ZM5.70991 2.87475C6.16049 3.02494 6.62073 3.22729 7.09051 3.48185C6.44826 3.94412 5.81002 4.48507 5.19771 5.09739C4.58523 5.70982 4.04417 6.34819 3.58181 6.99055C3.32716 6.52071 3.1248 6.06037 2.97459 5.60959C2.75682 4.95677 2.66844 4.38597 2.70897 3.89769C2.74266 3.49437 2.86522 3.18725 3.07615 2.97631C3.28709 2.76513 3.59421 2.64282 3.99753 2.60912C4.4858 2.5686 5.0566 2.65698 5.70991 2.87475ZM5.90473 5.80466Q4.89236 6.81738 4.14938 7.92595C4.64428 8.66515 5.2294 9.3722 5.90473 10.0473C6.57966 10.7222 7.28696 11.3074 8.02584 11.8027C8.76507 11.3074 9.47197 10.7222 10.1474 10.0473C10.8222 9.37218 11.4074 8.66511 11.9027 7.92588Q11.1597 6.81736 10.1474 5.80466C9.47203 5.12956 8.7652 4.54447 8.02604 4.04937C7.28683 4.54447 6.5796 5.12956 5.90473 5.80466ZM7.99992 6.90011C7.44768 6.90011 6.99993 7.34787 6.99993 7.90011C6.99993 8.45235 7.44768 8.9001 7.99992 8.9001C8.55216 8.9001 8.99991 8.45235 8.99991 7.90011C8.99991 7.34787 8.55216 6.90011 7.99992 6.90011ZM10.3422 12.9772C9.89161 12.827 9.43138 12.6246 8.96148 12.37C9.60377 11.9077 10.242 11.3667 10.8544 10.7543C11.4667 10.142 12.0077 9.50369 12.4699 8.8614C12.7245 9.33127 12.9268 9.79154 13.077 10.2421C13.2948 10.8952 13.3832 11.4658 13.3426 11.954C13.3089 12.3574 13.1864 12.6647 12.9754 12.8757C12.7645 13.0866 12.4574 13.2089 12.0541 13.2426C11.5658 13.2834 10.995 13.195 10.3422 12.9772ZM2.97459 10.2421C3.12478 9.7914 3.32733 9.3312 3.58196 8.86141C4.04428 9.50369 4.5853 10.142 5.19771 10.7543C5.81003 11.3667 6.44827 11.9077 7.09052 12.37C6.62074 12.6246 6.16049 12.827 5.70991 12.9772C5.0566 13.195 4.48629 13.2834 3.99802 13.2426C3.5947 13.2089 3.28709 13.0866 3.07615 12.8757C2.86522 12.6647 2.74315 12.3574 2.70946 11.954C2.66844 11.4658 2.75682 10.8952 2.97459 10.2421Z",fill:"rgb(89,89,89)","fill-rule":"evenodd"},null,-1)])])}const Yy={render:Xy},qy={class:"button-text"},Ky={class:"dropdown-menu__items"},Jy=["onClick"],Qy=C.defineComponent({__name:"ModelSwitch",setup(t){const{selectedModelId:n,selectedModel:o,availableModels:l,setSelectedModel:u}=to(),f=C.ref(!1),g=b=>{u(b),y()},m=()=>{f.value=!f.value},y=()=>{f.value=!1},x=C.ref(null),A=C.ref(null);return jy(A,()=>{y()},{ignore:[x]}),(b,P)=>(C.openBlock(),C.createElementBlock("div",{class:"model-switch-wrapper",ref_key:"wrapperRef",ref:x},[C.createVNode(Es,{size:"small",class:"action-button",rounded:"",onClick:m},{default:C.withCtx(()=>[(C.openBlock(),C.createBlock(C.resolveDynamicComponent(C.unref(o)?.icon),{width:16,height:16,class:"selected-model__icon"})),C.createElementVNode("span",qy,C.toDisplayString(C.unref(o)?.label),1),C.createVNode(C.unref(Yy),{width:16,height:16})]),_:1}),C.createVNode(C.Transition,{name:"dropdown"},{default:C.withCtx(()=>[f.value?(C.openBlock(),C.createElementBlock("div",{key:0,class:"dropdown-menu",ref_key:"dropdownMenuRef",ref:A},[C.createElementVNode("div",Ky,[(C.openBlock(!0),C.createElementBlock(C.Fragment,null,C.renderList(C.unref(l),N=>(C.openBlock(),C.createElementBlock("div",{key:N.id,class:C.normalizeClass(["dropdown-menu__item",{"active-menu":N.id===C.unref(n)}]),onClick:C.withModifiers(R=>g(N.id),["stop"])},[N.icon?(C.openBlock(),C.createBlock(C.resolveDynamicComponent(N.icon),{key:0,width:16,height:16,class:"dropdown-menu__icon"})):C.createCommentVNode("",!0),C.createElementVNode("span",null,C.toDisplayString(N.label),1)],10,Jy))),128))])],512)):C.createCommentVNode("",!0)]),_:1}),f.value?(C.openBlock(),C.createElementBlock("div",{key:0,class:"dropdown-overlay",onClick:y})):C.createCommentVNode("",!0)],512))}}),e4=ui(Qy,[["__scopeId","data-v-bd74613d"]]),t4={key:0,class:"active-count"},n4=C.defineComponent({__name:"PluginToggleButton",props:{installedPlugins:{}},emits:["click"],setup(t){const n=t,o=C.computed(()=>n.installedPlugins.filter(l=>l.enabled).length);return(l,u)=>(C.openBlock(),C.createBlock(Es,{size:"small",class:"action-button",active:o.value>0,rounded:"",onClick:u[0]||(u[0]=f=>l.$emit("click"))},{default:C.withCtx(()=>[C.createVNode(C.unref($i.IconPlugin),{class:"icon",style:{"font-size":"16px"}}),u[1]||(u[1]=C.createElementVNode("span",{class:"button-text"},"扩展",-1)),o.value>0?(C.openBlock(),C.createElementBlock("span",t4,C.toDisplayString(o.value),1)):C.createCommentVNode("",!0)]),_:1},8,["active"]))}}),r4=ui(n4,[["__scopeId","data-v-c2a16c66"]]),jr="https://agent.opentiny.design",i4=[{id:"12306-mcp",name:"12306服务器",description:"12306购票搜索服务器",icon:"https://agent.opentiny.design/public-assets/icons/icon-12306.webp",enabled:!1,addState:"idle",tools:[],url:jr+"/api/v1/mcp-server/12306/mcp",type:"StreamableHTTP"},{id:"markdown2pdf-mcp",name:"Markdown转PDF MCP服务器",description:"Markdown转PDF MCP服务器,可以将Markdown文件转换为PDF文件",icon:"https://agent.opentiny.design/public-assets/icons/icon-pdf.png",url:jr+"/servers/markdown2pdf-mcp/sse",type:"sse",enabled:!1,addState:"idle",tools:[]},{id:"docx-mcp",name:"Word文档MCP服务器",description:"Word文档MCP服务器,可以创建、编辑、保存Word文档",icon:"https://agent.opentiny.design/public-assets/icons/icon-word.png",url:jr+"/servers/excel-mcp/sse",type:"sse",enabled:!1,addState:"idle",tools:[]},{id:"excel-mcp",name:"Excel文档MCP服务器",description:"Excel文档MCP服务器,可以创建、编辑、保存Excel文档",icon:"https://agent.opentiny.design/public-assets/icons/icon-excel.png",url:jr+"/servers/excel-mcp/mcp",type:"StreamableHTTP",enabled:!1,addState:"idle",tools:[]},{id:"doc-tools-mcp",name:"文档工具MCP服务器",description:"文档工具MCP服务器,可以创建、编辑、保存文档",icon:"https://agent.opentiny.design/public-assets/icons/icon-doc.png",url:jr+"/servers/doc-tools-mcp/sse",type:"sse",enabled:!1,addState:"idle",tools:[]}],o4=`
95
+ `),e.toString()}setMode(e){this.mode=e}setECLevel(e){this.ecLevel=e}setVersion(e){this.version=e}setMaskPattern(e){this.maskPattern=e}setMatrix(e){this.matrix=e}static isValidMaskPattern(e){return e>=0&&e<rr.NUM_MASK_PATTERNS}}rr.NUM_MASK_PATTERNS=8;class tt extends m{}tt.kind="WriterException";class ke{constructor(){}static clearMatrix(e){e.clear(255)}static buildMatrix(e,n,i,s,a){ke.clearMatrix(a),ke.embedBasicPatterns(i,a),ke.embedTypeInfo(n,s,a),ke.maybeEmbedVersionInfo(i,a),ke.embedDataBits(e,s,a)}static embedBasicPatterns(e,n){ke.embedPositionDetectionPatternsAndSeparators(n),ke.embedDarkDotAtLeftBottomCorner(n),ke.maybeEmbedPositionAdjustmentPatterns(e,n),ke.embedTimingPatterns(n)}static embedTypeInfo(e,n,i){const s=new J;ke.makeTypeInfoBits(e,n,s);for(let a=0,c=s.getSize();a<c;++a){const d=s.get(s.getSize()-1-a),h=ke.TYPE_INFO_COORDINATES[a],p=h[0],w=h[1];if(i.setBoolean(p,w,d),a<8){const b=i.getWidth()-a-1;i.setBoolean(b,8,d)}else{const A=i.getHeight()-7+(a-8);i.setBoolean(8,A,d)}}}static maybeEmbedVersionInfo(e,n){if(e.getVersionNumber()<7)return;const i=new J;ke.makeVersionInfoBits(e,i);let s=17;for(let a=0;a<6;++a)for(let c=0;c<3;++c){const d=i.get(s);s--,n.setBoolean(a,n.getHeight()-11+c,d),n.setBoolean(n.getHeight()-11+c,a,d)}}static embedDataBits(e,n,i){let s=0,a=-1,c=i.getWidth()-1,d=i.getHeight()-1;for(;c>0;){for(c===6&&(c-=1);d>=0&&d<i.getHeight();){for(let h=0;h<2;++h){const p=c-h;if(!ke.isEmpty(i.get(p,d)))continue;let w;s<e.getSize()?(w=e.get(s),++s):w=!1,n!==255&&yt.getDataMaskBit(n,p,d)&&(w=!w),i.setBoolean(p,d,w)}d+=a}a=-a,d+=a,c-=2}if(s!==e.getSize())throw new tt("Not all bits consumed: "+s+"/"+e.getSize())}static findMSBSet(e){return 32-k.numberOfLeadingZeros(e)}static calculateBCHCode(e,n){if(n===0)throw new C("0 polynomial");const i=ke.findMSBSet(n);for(e<<=i-1;ke.findMSBSet(e)>=i;)e^=n<<ke.findMSBSet(e)-i;return e}static makeTypeInfoBits(e,n,i){if(!rr.isValidMaskPattern(n))throw new tt("Invalid mask pattern");const s=e.getBits()<<3|n;i.appendBits(s,5);const a=ke.calculateBCHCode(s,ke.TYPE_INFO_POLY);i.appendBits(a,10);const c=new J;if(c.appendBits(ke.TYPE_INFO_MASK_PATTERN,15),i.xor(c),i.getSize()!==15)throw new tt("should not happen but we got: "+i.getSize())}static makeVersionInfoBits(e,n){n.appendBits(e.getVersionNumber(),6);const i=ke.calculateBCHCode(e.getVersionNumber(),ke.VERSION_INFO_POLY);if(n.appendBits(i,12),n.getSize()!==18)throw new tt("should not happen but we got: "+n.getSize())}static isEmpty(e){return e===255}static embedTimingPatterns(e){for(let n=8;n<e.getWidth()-8;++n){const i=(n+1)%2;ke.isEmpty(e.get(n,6))&&e.setNumber(n,6,i),ke.isEmpty(e.get(6,n))&&e.setNumber(6,n,i)}}static embedDarkDotAtLeftBottomCorner(e){if(e.get(8,e.getHeight()-8)===0)throw new tt;e.setNumber(8,e.getHeight()-8,1)}static embedHorizontalSeparationPattern(e,n,i){for(let s=0;s<8;++s){if(!ke.isEmpty(i.get(e+s,n)))throw new tt;i.setNumber(e+s,n,0)}}static embedVerticalSeparationPattern(e,n,i){for(let s=0;s<7;++s){if(!ke.isEmpty(i.get(e,n+s)))throw new tt;i.setNumber(e,n+s,0)}}static embedPositionAdjustmentPattern(e,n,i){for(let s=0;s<5;++s){const a=ke.POSITION_ADJUSTMENT_PATTERN[s];for(let c=0;c<5;++c)i.setNumber(e+c,n+s,a[c])}}static embedPositionDetectionPattern(e,n,i){for(let s=0;s<7;++s){const a=ke.POSITION_DETECTION_PATTERN[s];for(let c=0;c<7;++c)i.setNumber(e+c,n+s,a[c])}}static embedPositionDetectionPatternsAndSeparators(e){const n=ke.POSITION_DETECTION_PATTERN[0].length;ke.embedPositionDetectionPattern(0,0,e),ke.embedPositionDetectionPattern(e.getWidth()-n,0,e),ke.embedPositionDetectionPattern(0,e.getWidth()-n,e);const i=8;ke.embedHorizontalSeparationPattern(0,i-1,e),ke.embedHorizontalSeparationPattern(e.getWidth()-i,i-1,e),ke.embedHorizontalSeparationPattern(0,e.getWidth()-i,e);const s=7;ke.embedVerticalSeparationPattern(s,0,e),ke.embedVerticalSeparationPattern(e.getHeight()-s-1,0,e),ke.embedVerticalSeparationPattern(s,e.getHeight()-s,e)}static maybeEmbedPositionAdjustmentPatterns(e,n){if(e.getVersionNumber()<2)return;const i=e.getVersionNumber()-1,s=ke.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[i];for(let a=0,c=s.length;a!==c;a++){const d=s[a];if(d>=0)for(let h=0;h!==c;h++){const p=s[h];p>=0&&ke.isEmpty(n.get(p,d))&&ke.embedPositionAdjustmentPattern(p-2,d-2,n)}}}}ke.POSITION_DETECTION_PATTERN=Array.from([Int32Array.from([1,1,1,1,1,1,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,1,1,1,1,1,1])]),ke.POSITION_ADJUSTMENT_PATTERN=Array.from([Int32Array.from([1,1,1,1,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,0,1,0,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,1,1,1,1])]),ke.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE=Array.from([Int32Array.from([-1,-1,-1,-1,-1,-1,-1]),Int32Array.from([6,18,-1,-1,-1,-1,-1]),Int32Array.from([6,22,-1,-1,-1,-1,-1]),Int32Array.from([6,26,-1,-1,-1,-1,-1]),Int32Array.from([6,30,-1,-1,-1,-1,-1]),Int32Array.from([6,34,-1,-1,-1,-1,-1]),Int32Array.from([6,22,38,-1,-1,-1,-1]),Int32Array.from([6,24,42,-1,-1,-1,-1]),Int32Array.from([6,26,46,-1,-1,-1,-1]),Int32Array.from([6,28,50,-1,-1,-1,-1]),Int32Array.from([6,30,54,-1,-1,-1,-1]),Int32Array.from([6,32,58,-1,-1,-1,-1]),Int32Array.from([6,34,62,-1,-1,-1,-1]),Int32Array.from([6,26,46,66,-1,-1,-1]),Int32Array.from([6,26,48,70,-1,-1,-1]),Int32Array.from([6,26,50,74,-1,-1,-1]),Int32Array.from([6,30,54,78,-1,-1,-1]),Int32Array.from([6,30,56,82,-1,-1,-1]),Int32Array.from([6,30,58,86,-1,-1,-1]),Int32Array.from([6,34,62,90,-1,-1,-1]),Int32Array.from([6,28,50,72,94,-1,-1]),Int32Array.from([6,26,50,74,98,-1,-1]),Int32Array.from([6,30,54,78,102,-1,-1]),Int32Array.from([6,28,54,80,106,-1,-1]),Int32Array.from([6,32,58,84,110,-1,-1]),Int32Array.from([6,30,58,86,114,-1,-1]),Int32Array.from([6,34,62,90,118,-1,-1]),Int32Array.from([6,26,50,74,98,122,-1]),Int32Array.from([6,30,54,78,102,126,-1]),Int32Array.from([6,26,52,78,104,130,-1]),Int32Array.from([6,30,56,82,108,134,-1]),Int32Array.from([6,34,60,86,112,138,-1]),Int32Array.from([6,30,58,86,114,142,-1]),Int32Array.from([6,34,62,90,118,146,-1]),Int32Array.from([6,30,54,78,102,126,150]),Int32Array.from([6,24,50,76,102,128,154]),Int32Array.from([6,28,54,80,106,132,158]),Int32Array.from([6,32,58,84,110,136,162]),Int32Array.from([6,26,54,82,110,138,166]),Int32Array.from([6,30,58,86,114,142,170])]),ke.TYPE_INFO_COORDINATES=Array.from([Int32Array.from([8,0]),Int32Array.from([8,1]),Int32Array.from([8,2]),Int32Array.from([8,3]),Int32Array.from([8,4]),Int32Array.from([8,5]),Int32Array.from([8,7]),Int32Array.from([8,8]),Int32Array.from([7,8]),Int32Array.from([5,8]),Int32Array.from([4,8]),Int32Array.from([3,8]),Int32Array.from([2,8]),Int32Array.from([1,8]),Int32Array.from([0,8])]),ke.VERSION_INFO_POLY=7973,ke.TYPE_INFO_POLY=1335,ke.TYPE_INFO_MASK_PATTERN=21522;class O1{constructor(e,n){this.dataBytes=e,this.errorCorrectionBytes=n}getDataBytes(){return this.dataBytes}getErrorCorrectionBytes(){return this.errorCorrectionBytes}}class st{constructor(){}static calculateMaskPenalty(e){return yt.applyMaskPenaltyRule1(e)+yt.applyMaskPenaltyRule2(e)+yt.applyMaskPenaltyRule3(e)+yt.applyMaskPenaltyRule4(e)}static encode(e,n,i=null){let s=st.DEFAULT_BYTE_MODE_ENCODING;const a=i!==null&&i.get(Tt.CHARACTER_SET)!==void 0;a&&(s=i.get(Tt.CHARACTER_SET).toString());const c=this.chooseMode(e,s),d=new J;if(c===Oe.BYTE&&(a||st.DEFAULT_BYTE_MODE_ENCODING!==s)){const ae=W.getCharacterSetECIByName(s);ae!==void 0&&this.appendECI(ae,d)}this.appendModeInfo(c,d);const h=new J;this.appendBytes(e,c,h,s);let p;if(i!==null&&i.get(Tt.QR_VERSION)!==void 0){const ae=Number.parseInt(i.get(Tt.QR_VERSION).toString(),10);p=Ne.getVersionForNumber(ae);const oe=this.calculateBitsNeeded(c,d,h,p);if(!this.willFit(oe,p,n))throw new tt("Data too big for requested version")}else p=this.recommendVersion(n,c,d,h);const w=new J;w.appendBitArray(d);const b=c===Oe.BYTE?h.getSizeInBytes():e.length;this.appendLengthInfo(b,p,c,w),w.appendBitArray(h);const A=p.getECBlocksForLevel(n),N=p.getTotalCodewords()-A.getTotalECCodewords();this.terminateBits(N,w);const F=this.interleaveWithECBytes(w,p.getTotalCodewords(),N,A.getNumBlocks()),$=new rr;$.setECLevel(n),$.setMode(c),$.setVersion(p);const j=p.getDimensionForVersion(),q=new pi(j,j),se=this.chooseMaskPattern(F,n,p,q);return $.setMaskPattern(se),ke.buildMatrix(F,n,p,se,q),$.setMatrix(q),$}static recommendVersion(e,n,i,s){const a=this.calculateBitsNeeded(n,i,s,Ne.getVersionForNumber(1)),c=this.chooseVersion(a,e),d=this.calculateBitsNeeded(n,i,s,c);return this.chooseVersion(d,e)}static calculateBitsNeeded(e,n,i,s){return n.getSize()+e.getCharacterCountBits(s)+i.getSize()}static getAlphanumericCode(e){return e<st.ALPHANUMERIC_TABLE.length?st.ALPHANUMERIC_TABLE[e]:-1}static chooseMode(e,n=null){if(W.SJIS.getName()===n&&this.isOnlyDoubleByteKanji(e))return Oe.KANJI;let i=!1,s=!1;for(let a=0,c=e.length;a<c;++a){const d=e.charAt(a);if(st.isDigit(d))i=!0;else if(this.getAlphanumericCode(d.charCodeAt(0))!==-1)s=!0;else return Oe.BYTE}return s?Oe.ALPHANUMERIC:i?Oe.NUMERIC:Oe.BYTE}static isOnlyDoubleByteKanji(e){let n;try{n=me.encode(e,W.SJIS)}catch{return!1}const i=n.length;if(i%2!==0)return!1;for(let s=0;s<i;s+=2){const a=n[s]&255;if((a<129||a>159)&&(a<224||a>235))return!1}return!0}static chooseMaskPattern(e,n,i,s){let a=Number.MAX_SAFE_INTEGER,c=-1;for(let d=0;d<rr.NUM_MASK_PATTERNS;d++){ke.buildMatrix(e,n,i,d,s);let h=this.calculateMaskPenalty(s);h<a&&(a=h,c=d)}return c}static chooseVersion(e,n){for(let i=1;i<=40;i++){const s=Ne.getVersionForNumber(i);if(st.willFit(e,s,n))return s}throw new tt("Data too big")}static willFit(e,n,i){const s=n.getTotalCodewords(),c=n.getECBlocksForLevel(i).getTotalECCodewords(),d=s-c,h=(e+7)/8;return d>=h}static terminateBits(e,n){const i=e*8;if(n.getSize()>i)throw new tt("data bits cannot fit in the QR Code"+n.getSize()+" > "+i);for(let c=0;c<4&&n.getSize()<i;++c)n.appendBit(!1);const s=n.getSize()&7;if(s>0)for(let c=s;c<8;c++)n.appendBit(!1);const a=e-n.getSizeInBytes();for(let c=0;c<a;++c)n.appendBits((c&1)===0?236:17,8);if(n.getSize()!==i)throw new tt("Bits size does not equal capacity")}static getNumDataBytesAndNumECBytesForBlockID(e,n,i,s,a,c){if(s>=i)throw new tt("Block ID too large");const d=e%i,h=i-d,p=Math.floor(e/i),w=p+1,b=Math.floor(n/i),A=b+1,N=p-b,F=w-A;if(N!==F)throw new tt("EC bytes mismatch");if(i!==h+d)throw new tt("RS blocks mismatch");if(e!==(b+N)*h+(A+F)*d)throw new tt("Total bytes mismatch");s<h?(a[0]=b,c[0]=N):(a[0]=A,c[0]=F)}static interleaveWithECBytes(e,n,i,s){if(e.getSizeInBytes()!==i)throw new tt("Number of bits and data bytes does not match");let a=0,c=0,d=0;const h=new Array;for(let w=0;w<s;++w){const b=new Int32Array(1),A=new Int32Array(1);st.getNumDataBytesAndNumECBytesForBlockID(n,i,s,w,b,A);const N=b[0],F=new Uint8Array(N);e.toBytes(8*a,F,0,N);const $=st.generateECBytes(F,A[0]);h.push(new O1(F,$)),c=Math.max(c,N),d=Math.max(d,$.length),a+=b[0]}if(i!==a)throw new tt("Data bytes does not match offset");const p=new J;for(let w=0;w<c;++w)for(const b of h){const A=b.getDataBytes();w<A.length&&p.appendBits(A[w],8)}for(let w=0;w<d;++w)for(const b of h){const A=b.getErrorCorrectionBytes();w<A.length&&p.appendBits(A[w],8)}if(n!==p.getSizeInBytes())throw new tt("Interleaving error: "+n+" and "+p.getSizeInBytes()+" differ.");return p}static generateECBytes(e,n){const i=e.length,s=new Int32Array(i+n);for(let c=0;c<i;c++)s[c]=e[c]&255;new ho(Fe.QR_CODE_FIELD_256).encode(s,n);const a=new Uint8Array(n);for(let c=0;c<n;c++)a[c]=s[i+c];return a}static appendModeInfo(e,n){n.appendBits(e.getBits(),4)}static appendLengthInfo(e,n,i,s){const a=i.getCharacterCountBits(n);if(e>=1<<a)throw new tt(e+" is bigger than "+((1<<a)-1));s.appendBits(e,a)}static appendBytes(e,n,i,s){switch(n){case Oe.NUMERIC:st.appendNumericBytes(e,i);break;case Oe.ALPHANUMERIC:st.appendAlphanumericBytes(e,i);break;case Oe.BYTE:st.append8BitBytes(e,i,s);break;case Oe.KANJI:st.appendKanjiBytes(e,i);break;default:throw new tt("Invalid mode: "+n)}}static getDigit(e){return e.charCodeAt(0)-48}static isDigit(e){const n=st.getDigit(e);return n>=0&&n<=9}static appendNumericBytes(e,n){const i=e.length;let s=0;for(;s<i;){const a=st.getDigit(e.charAt(s));if(s+2<i){const c=st.getDigit(e.charAt(s+1)),d=st.getDigit(e.charAt(s+2));n.appendBits(a*100+c*10+d,10),s+=3}else if(s+1<i){const c=st.getDigit(e.charAt(s+1));n.appendBits(a*10+c,7),s+=2}else n.appendBits(a,4),s++}}static appendAlphanumericBytes(e,n){const i=e.length;let s=0;for(;s<i;){const a=st.getAlphanumericCode(e.charCodeAt(s));if(a===-1)throw new tt;if(s+1<i){const c=st.getAlphanumericCode(e.charCodeAt(s+1));if(c===-1)throw new tt;n.appendBits(a*45+c,11),s+=2}else n.appendBits(a,6),s++}}static append8BitBytes(e,n,i){let s;try{s=me.encode(e,i)}catch(a){throw new tt(a)}for(let a=0,c=s.length;a!==c;a++){const d=s[a];n.appendBits(d,8)}}static appendKanjiBytes(e,n){let i;try{i=me.encode(e,W.SJIS)}catch(a){throw new tt(a)}const s=i.length;for(let a=0;a<s;a+=2){const c=i[a]&255,d=i[a+1]&255,h=c<<8&4294967295|d;let p=-1;if(h>=33088&&h<=40956?p=h-33088:h>=57408&&h<=60351&&(p=h-49472),p===-1)throw new tt("Invalid byte sequence");const w=(p>>8)*192+(p&255);n.appendBits(w,13)}}static appendECI(e,n){n.appendBits(Oe.ECI.getBits(),4),n.appendBits(e.getValue(),8)}}st.ALPHANUMERIC_TABLE=Int32Array.from([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,36,-1,-1,-1,37,38,-1,-1,-1,-1,39,40,-1,41,42,43,0,1,2,3,4,5,6,7,8,9,44,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,-1,-1,-1,-1,-1]),st.DEFAULT_BYTE_MODE_ENCODING=W.UTF8.getName();class ir{write(e,n,i,s=null){if(e.length===0)throw new C("Found empty contents");if(n<0||i<0)throw new C("Requested dimensions are too small: "+n+"x"+i);let a=it.L,c=ir.QUIET_ZONE_SIZE;s!==null&&(s.get(Tt.ERROR_CORRECTION)!==void 0&&(a=it.fromString(s.get(Tt.ERROR_CORRECTION).toString())),s.get(Tt.MARGIN)!==void 0&&(c=Number.parseInt(s.get(Tt.MARGIN).toString(),10)));const d=st.encode(e,a,s);return this.renderResult(d,n,i,c)}writeToDom(e,n,i,s,a=null){typeof e=="string"&&(e=document.querySelector(e));const c=this.write(n,i,s,a);e&&e.appendChild(c)}renderResult(e,n,i,s){const a=e.getMatrix();if(a===null)throw new ln;const c=a.getWidth(),d=a.getHeight(),h=c+s*2,p=d+s*2,w=Math.max(n,h),b=Math.max(i,p),A=Math.min(Math.floor(w/h),Math.floor(b/p)),N=Math.floor((w-c*A)/2),F=Math.floor((b-d*A)/2),$=this.createSVGElement(w,b);for(let j=0,q=F;j<d;j++,q+=A)for(let se=0,ae=N;se<c;se++,ae+=A)if(a.get(se,j)===1){const oe=this.createSvgRectElement(ae,q,A,A);$.appendChild(oe)}return $}createSVGElement(e,n){const i=document.createElementNS(ir.SVG_NS,"svg");return i.setAttributeNS(null,"height",e.toString()),i.setAttributeNS(null,"width",n.toString()),i}createSvgRectElement(e,n,i,s){const a=document.createElementNS(ir.SVG_NS,"rect");return a.setAttributeNS(null,"x",e.toString()),a.setAttributeNS(null,"y",n.toString()),a.setAttributeNS(null,"height",i.toString()),a.setAttributeNS(null,"width",s.toString()),a.setAttributeNS(null,"fill","#000000"),a}}ir.QUIET_ZONE_SIZE=4,ir.SVG_NS="http://www.w3.org/2000/svg";class gr{encode(e,n,i,s,a){if(e.length===0)throw new C("Found empty contents");if(n!==T.QR_CODE)throw new C("Can only encode QR_CODE, but got "+n);if(i<0||s<0)throw new C(`Requested dimensions are too small: ${i}x${s}`);let c=it.L,d=gr.QUIET_ZONE_SIZE;a!==null&&(a.get(Tt.ERROR_CORRECTION)!==void 0&&(c=it.fromString(a.get(Tt.ERROR_CORRECTION).toString())),a.get(Tt.MARGIN)!==void 0&&(d=Number.parseInt(a.get(Tt.MARGIN).toString(),10)));const h=st.encode(e,c,a);return gr.renderResult(h,i,s,d)}static renderResult(e,n,i,s){const a=e.getMatrix();if(a===null)throw new ln;const c=a.getWidth(),d=a.getHeight(),h=c+s*2,p=d+s*2,w=Math.max(n,h),b=Math.max(i,p),A=Math.min(Math.floor(w/h),Math.floor(b/p)),N=Math.floor((w-c*A)/2),F=Math.floor((b-d*A)/2),$=new le(w,b);for(let j=0,q=F;j<d;j++,q+=A)for(let se=0,ae=N;se<c;se++,ae+=A)a.get(se,j)===1&&$.setRegion(ae,q,A,A);return $}}gr.QUIET_ZONE_SIZE=4;class k1{encode(e,n,i,s,a){let c;switch(n){case T.QR_CODE:c=new gr;break;default:throw new C("No encoder available for format "+n)}return c.encode(e,n,i,s,a)}}class Nn extends ne{constructor(e,n,i,s,a,c,d,h){if(super(c,d),this.yuvData=e,this.dataWidth=n,this.dataHeight=i,this.left=s,this.top=a,s+c>n||a+d>i)throw new C("Crop rectangle does not fit within image data.");h&&this.reverseHorizontal(c,d)}getRow(e,n){if(e<0||e>=this.getHeight())throw new C("Requested row is outside the image: "+e);const i=this.getWidth();(n==null||n.length<i)&&(n=new Uint8ClampedArray(i));const s=(e+this.top)*this.dataWidth+this.left;return R.arraycopy(this.yuvData,s,n,0,i),n}getMatrix(){const e=this.getWidth(),n=this.getHeight();if(e===this.dataWidth&&n===this.dataHeight)return this.yuvData;const i=e*n,s=new Uint8ClampedArray(i);let a=this.top*this.dataWidth+this.left;if(e===this.dataWidth)return R.arraycopy(this.yuvData,a,s,0,i),s;for(let c=0;c<n;c++){const d=c*e;R.arraycopy(this.yuvData,a,s,d,e),a+=this.dataWidth}return s}isCropSupported(){return!0}crop(e,n,i,s){return new Nn(this.yuvData,this.dataWidth,this.dataHeight,this.left+e,this.top+n,i,s,!1)}renderThumbnail(){const e=this.getWidth()/Nn.THUMBNAIL_SCALE_FACTOR,n=this.getHeight()/Nn.THUMBNAIL_SCALE_FACTOR,i=new Int32Array(e*n),s=this.yuvData;let a=this.top*this.dataWidth+this.left;for(let c=0;c<n;c++){const d=c*e;for(let h=0;h<e;h++){const p=s[a+h*Nn.THUMBNAIL_SCALE_FACTOR]&255;i[d+h]=4278190080|p*65793}a+=this.dataWidth*Nn.THUMBNAIL_SCALE_FACTOR}return i}getThumbnailWidth(){return this.getWidth()/Nn.THUMBNAIL_SCALE_FACTOR}getThumbnailHeight(){return this.getHeight()/Nn.THUMBNAIL_SCALE_FACTOR}reverseHorizontal(e,n){const i=this.yuvData;for(let s=0,a=this.top*this.dataWidth+this.left;s<n;s++,a+=this.dataWidth){const c=a+e/2;for(let d=a,h=a+e-1;d<c;d++,h--){const p=i[d];i[d]=i[h],i[h]=p}}}invert(){return new fe(this)}}Nn.THUMBNAIL_SCALE_FACTOR=2;class po extends ne{constructor(e,n,i,s,a,c,d){if(super(n,i),this.dataWidth=s,this.dataHeight=a,this.left=c,this.top=d,e.BYTES_PER_ELEMENT===4){const h=n*i,p=new Uint8ClampedArray(h);for(let w=0;w<h;w++){const b=e[w],A=b>>16&255,N=b>>7&510,F=b&255;p[w]=(A+N+F)/4&255}this.luminances=p}else this.luminances=e;if(s===void 0&&(this.dataWidth=n),a===void 0&&(this.dataHeight=i),c===void 0&&(this.left=0),d===void 0&&(this.top=0),this.left+n>this.dataWidth||this.top+i>this.dataHeight)throw new C("Crop rectangle does not fit within image data.")}getRow(e,n){if(e<0||e>=this.getHeight())throw new C("Requested row is outside the image: "+e);const i=this.getWidth();(n==null||n.length<i)&&(n=new Uint8ClampedArray(i));const s=(e+this.top)*this.dataWidth+this.left;return R.arraycopy(this.luminances,s,n,0,i),n}getMatrix(){const e=this.getWidth(),n=this.getHeight();if(e===this.dataWidth&&n===this.dataHeight)return this.luminances;const i=e*n,s=new Uint8ClampedArray(i);let a=this.top*this.dataWidth+this.left;if(e===this.dataWidth)return R.arraycopy(this.luminances,a,s,0,i),s;for(let c=0;c<n;c++){const d=c*e;R.arraycopy(this.luminances,a,s,d,e),a+=this.dataWidth}return s}isCropSupported(){return!0}crop(e,n,i,s){return new po(this.luminances,i,s,this.dataWidth,this.dataHeight,this.left+e,this.top+n)}invert(){return new fe(this)}}class ks extends W{static forName(e){return this.getCharacterSetECIByName(e)}}class go{}go.ISO_8859_1=W.ISO8859_1;class Rs{isCompact(){return this.compact}setCompact(e){this.compact=e}getSize(){return this.size}setSize(e){this.size=e}getLayers(){return this.layers}setLayers(e){this.layers=e}getCodeWords(){return this.codeWords}setCodeWords(e){this.codeWords=e}getMatrix(){return this.matrix}setMatrix(e){this.matrix=e}}class Ds{static singletonList(e){return[e]}static min(e,n){return e.sort(n)[0]}}class R1{constructor(e){this.previous=e}getPrevious(){return this.previous}}class mr extends R1{constructor(e,n,i){super(e),this.value=n,this.bitCount=i}appendTo(e,n){e.appendBits(this.value,this.bitCount)}add(e,n){return new mr(this,e,n)}addBinaryShift(e,n){return console.warn("addBinaryShift on SimpleToken, this simply returns a copy of this token"),new mr(this,e,n)}toString(){let e=this.value&(1<<this.bitCount)-1;return e|=1<<this.bitCount,"<"+k.toBinaryString(e|1<<this.bitCount).substring(1)+">"}}class mo extends mr{constructor(e,n,i){super(e,0,0),this.binaryShiftStart=n,this.binaryShiftByteCount=i}appendTo(e,n){for(let i=0;i<this.binaryShiftByteCount;i++)(i===0||i===31&&this.binaryShiftByteCount<=62)&&(e.appendBits(31,5),this.binaryShiftByteCount>62?e.appendBits(this.binaryShiftByteCount-31,16):i===0?e.appendBits(Math.min(this.binaryShiftByteCount,31),5):e.appendBits(this.binaryShiftByteCount-31,5)),e.appendBits(n[this.binaryShiftStart+i],8)}addBinaryShift(e,n){return new mo(this,e,n)}toString(){return"<"+this.binaryShiftStart+"::"+(this.binaryShiftStart+this.binaryShiftByteCount-1)+">"}}function D1(v,e,n){return new mo(v,e,n)}function Mr(v,e,n){return new mr(v,e,n)}const M1=["UPPER","LOWER","DIGIT","MIXED","PUNCT"],Gn=0,gi=1,fn=2,Ms=3,On=4,P1=new mr(null,0,0),xo=[Int32Array.from([0,(5<<16)+28,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(9<<16)+480+14,0,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(4<<16)+14,(9<<16)+448+28,0,(9<<16)+448+29,932798]),Int32Array.from([(5<<16)+29,(5<<16)+28,656318,0,(5<<16)+30]),Int32Array.from([(5<<16)+31,656380,656382,656381,0])];function B1(v){for(let e of v)U.fill(e,-1);return v[Gn][On]=0,v[gi][On]=0,v[gi][Gn]=28,v[Ms][On]=0,v[fn][On]=0,v[fn][Gn]=15,v}const Ps=B1(U.createInt32Array(6,6));class kn{constructor(e,n,i,s){this.token=e,this.mode=n,this.binaryShiftByteCount=i,this.bitCount=s}getMode(){return this.mode}getToken(){return this.token}getBinaryShiftByteCount(){return this.binaryShiftByteCount}getBitCount(){return this.bitCount}latchAndAppend(e,n){let i=this.bitCount,s=this.token;if(e!==this.mode){let c=xo[this.mode][e];s=Mr(s,c&65535,c>>16),i+=c>>16}let a=e===fn?4:5;return s=Mr(s,n,a),new kn(s,e,0,i+a)}shiftAndAppend(e,n){let i=this.token,s=this.mode===fn?4:5;return i=Mr(i,Ps[this.mode][e],s),i=Mr(i,n,5),new kn(i,this.mode,0,this.bitCount+s+5)}addBinaryShiftChar(e){let n=this.token,i=this.mode,s=this.bitCount;if(this.mode===On||this.mode===fn){let d=xo[i][Gn];n=Mr(n,d&65535,d>>16),s+=d>>16,i=Gn}let a=this.binaryShiftByteCount===0||this.binaryShiftByteCount===31?18:this.binaryShiftByteCount===62?9:8,c=new kn(n,i,this.binaryShiftByteCount+1,s+a);return c.binaryShiftByteCount===2078&&(c=c.endBinaryShift(e+1)),c}endBinaryShift(e){if(this.binaryShiftByteCount===0)return this;let n=this.token;return n=D1(n,e-this.binaryShiftByteCount,this.binaryShiftByteCount),new kn(n,this.mode,0,this.bitCount)}isBetterThanOrEqualTo(e){let n=this.bitCount+(xo[this.mode][e.mode]>>16);return this.binaryShiftByteCount<e.binaryShiftByteCount?n+=kn.calculateBinaryShiftCost(e)-kn.calculateBinaryShiftCost(this):this.binaryShiftByteCount>e.binaryShiftByteCount&&e.binaryShiftByteCount>0&&(n+=10),n<=e.bitCount}toBitArray(e){let n=[];for(let s=this.endBinaryShift(e.length).token;s!==null;s=s.getPrevious())n.unshift(s);let i=new J;for(const s of n)s.appendTo(i,e);return i}toString(){return pe.format("%s bits=%d bytes=%d",M1[this.mode],this.bitCount,this.binaryShiftByteCount)}static calculateBinaryShiftCost(e){return e.binaryShiftByteCount>62?21:e.binaryShiftByteCount>31?20:e.binaryShiftByteCount>0?10:0}}kn.INITIAL_STATE=new kn(P1,Gn,0,0);function L1(v){const e=pe.getCharCode(" "),n=pe.getCharCode("."),i=pe.getCharCode(",");v[Gn][e]=1;const s=pe.getCharCode("Z"),a=pe.getCharCode("A");for(let A=a;A<=s;A++)v[Gn][A]=A-a+2;v[gi][e]=1;const c=pe.getCharCode("z"),d=pe.getCharCode("a");for(let A=d;A<=c;A++)v[gi][A]=A-d+2;v[fn][e]=1;const h=pe.getCharCode("9"),p=pe.getCharCode("0");for(let A=p;A<=h;A++)v[fn][A]=A-p+2;v[fn][i]=12,v[fn][n]=13;const w=["\0"," ","","","","","","","\x07","\b"," ",`
96
+ `,"\v","\f","\r","\x1B","","","","","@","\\","^","_","`","|","~",""];for(let A=0;A<w.length;A++)v[Ms][pe.getCharCode(w[A])]=A;const b=["\0","\r","\0","\0","\0","\0","!","'","#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","[","]","{","}"];for(let A=0;A<b.length;A++)pe.getCharCode(b[A])>0&&(v[On][pe.getCharCode(b[A])]=A);return v}const wo=L1(U.createInt32Array(5,256));class Pr{constructor(e){this.text=e}encode(){const e=pe.getCharCode(" "),n=pe.getCharCode(`
97
+ `);let i=Ds.singletonList(kn.INITIAL_STATE);for(let a=0;a<this.text.length;a++){let c,d=a+1<this.text.length?this.text[a+1]:0;switch(this.text[a]){case pe.getCharCode("\r"):c=d===n?2:0;break;case pe.getCharCode("."):c=d===e?3:0;break;case pe.getCharCode(","):c=d===e?4:0;break;case pe.getCharCode(":"):c=d===e?5:0;break;default:c=0}c>0?(i=Pr.updateStateListForPair(i,a,c),a++):i=this.updateStateListForChar(i,a)}return Ds.min(i,(a,c)=>a.getBitCount()-c.getBitCount()).toBitArray(this.text)}updateStateListForChar(e,n){const i=[];for(let s of e)this.updateStateForChar(s,n,i);return Pr.simplifyStates(i)}updateStateForChar(e,n,i){let s=this.text[n]&255,a=wo[e.getMode()][s]>0,c=null;for(let d=0;d<=On;d++){let h=wo[d][s];if(h>0){if(c==null&&(c=e.endBinaryShift(n)),!a||d===e.getMode()||d===fn){const p=c.latchAndAppend(d,h);i.push(p)}if(!a&&Ps[e.getMode()][d]>=0){const p=c.shiftAndAppend(d,h);i.push(p)}}}if(e.getBinaryShiftByteCount()>0||wo[e.getMode()][s]===0){let d=e.addBinaryShiftChar(n);i.push(d)}}static updateStateListForPair(e,n,i){const s=[];for(let a of e)this.updateStateForPair(a,n,i,s);return this.simplifyStates(s)}static updateStateForPair(e,n,i,s){let a=e.endBinaryShift(n);if(s.push(a.latchAndAppend(On,i)),e.getMode()!==On&&s.push(a.shiftAndAppend(On,i)),i===3||i===4){let c=a.latchAndAppend(fn,16-i).latchAndAppend(fn,1);s.push(c)}if(e.getBinaryShiftByteCount()>0){let c=e.addBinaryShiftChar(n).addBinaryShiftChar(n+1);s.push(c)}}static simplifyStates(e){let n=[];for(const i of e){let s=!0;for(const a of n){if(a.isBetterThanOrEqualTo(i)){s=!1;break}i.isBetterThanOrEqualTo(a)&&(n=n.filter(c=>c!==a))}s&&n.push(i)}return n}}class Ze{constructor(){}static encodeBytes(e){return Ze.encode(e,Ze.DEFAULT_EC_PERCENT,Ze.DEFAULT_AZTEC_LAYERS)}static encode(e,n,i){let s=new Pr(e).encode(),a=k.truncDivision(s.getSize()*n,100)+11,c=s.getSize()+a,d,h,p,w,b;if(i!==Ze.DEFAULT_AZTEC_LAYERS){if(d=i<0,h=Math.abs(i),h>(d?Ze.MAX_NB_BITS_COMPACT:Ze.MAX_NB_BITS))throw new C(pe.format("Illegal value %s for layers",i));p=Ze.totalBitsInLayer(h,d),w=Ze.WORD_SIZE[h];let oe=p-p%w;if(b=Ze.stuffBits(s,w),b.getSize()+a>oe)throw new C("Data to large for user specified layer");if(d&&b.getSize()>w*64)throw new C("Data to large for user specified layer")}else{w=0,b=null;for(let oe=0;;oe++){if(oe>Ze.MAX_NB_BITS)throw new C("Data too large for an Aztec code");if(d=oe<=3,h=d?oe+1:oe,p=Ze.totalBitsInLayer(h,d),c>p)continue;(b==null||w!==Ze.WORD_SIZE[h])&&(w=Ze.WORD_SIZE[h],b=Ze.stuffBits(s,w));let Ue=p-p%w;if(!(d&&b.getSize()>w*64)&&b.getSize()+a<=Ue)break}}let A=Ze.generateCheckWords(b,p,w),N=b.getSize()/w,F=Ze.generateModeMessage(d,h,N),$=(d?11:14)+h*4,j=new Int32Array($),q;if(d){q=$;for(let oe=0;oe<j.length;oe++)j[oe]=oe}else{q=$+1+2*k.truncDivision(k.truncDivision($,2)-1,15);let oe=k.truncDivision($,2),Ue=k.truncDivision(q,2);for(let Me=0;Me<oe;Me++){let Qt=Me+k.truncDivision(Me,15);j[oe-Me-1]=Ue-Qt-1,j[oe+Me]=Ue+Qt+1}}let se=new le(q);for(let oe=0,Ue=0;oe<h;oe++){let Me=(h-oe)*4+(d?9:12);for(let Qt=0;Qt<Me;Qt++){let xn=Qt*2;for(let en=0;en<2;en++)A.get(Ue+xn+en)&&se.set(j[oe*2+en],j[oe*2+Qt]),A.get(Ue+Me*2+xn+en)&&se.set(j[oe*2+Qt],j[$-1-oe*2-en]),A.get(Ue+Me*4+xn+en)&&se.set(j[$-1-oe*2-en],j[$-1-oe*2-Qt]),A.get(Ue+Me*6+xn+en)&&se.set(j[$-1-oe*2-Qt],j[oe*2+en])}Ue+=Me*8}if(Ze.drawModeMessage(se,d,q,F),d)Ze.drawBullsEye(se,k.truncDivision(q,2),5);else{Ze.drawBullsEye(se,k.truncDivision(q,2),7);for(let oe=0,Ue=0;oe<k.truncDivision($,2)-1;oe+=15,Ue+=16)for(let Me=k.truncDivision(q,2)&1;Me<q;Me+=2)se.set(k.truncDivision(q,2)-Ue,Me),se.set(k.truncDivision(q,2)+Ue,Me),se.set(Me,k.truncDivision(q,2)-Ue),se.set(Me,k.truncDivision(q,2)+Ue)}let ae=new Rs;return ae.setCompact(d),ae.setSize(q),ae.setLayers(h),ae.setCodeWords(N),ae.setMatrix(se),ae}static drawBullsEye(e,n,i){for(let s=0;s<i;s+=2)for(let a=n-s;a<=n+s;a++)e.set(a,n-s),e.set(a,n+s),e.set(n-s,a),e.set(n+s,a);e.set(n-i,n-i),e.set(n-i+1,n-i),e.set(n-i,n-i+1),e.set(n+i,n-i),e.set(n+i,n-i+1),e.set(n+i,n+i-1)}static generateModeMessage(e,n,i){let s=new J;return e?(s.appendBits(n-1,2),s.appendBits(i-1,6),s=Ze.generateCheckWords(s,28,4)):(s.appendBits(n-1,5),s.appendBits(i-1,11),s=Ze.generateCheckWords(s,40,4)),s}static drawModeMessage(e,n,i,s){let a=k.truncDivision(i,2);if(n)for(let c=0;c<7;c++){let d=a-3+c;s.get(c)&&e.set(d,a-5),s.get(c+7)&&e.set(a+5,d),s.get(20-c)&&e.set(d,a+5),s.get(27-c)&&e.set(a-5,d)}else for(let c=0;c<10;c++){let d=a-5+c+k.truncDivision(c,5);s.get(c)&&e.set(d,a-7),s.get(c+10)&&e.set(a+7,d),s.get(29-c)&&e.set(d,a+7),s.get(39-c)&&e.set(a-7,d)}}static generateCheckWords(e,n,i){let s=e.getSize()/i,a=new ho(Ze.getGF(i)),c=k.truncDivision(n,i),d=Ze.bitsToWords(e,i,c);a.encode(d,c-s);let h=n%i,p=new J;p.appendBits(0,h);for(const w of Array.from(d))p.appendBits(w,i);return p}static bitsToWords(e,n,i){let s=new Int32Array(i),a,c;for(a=0,c=e.getSize()/n;a<c;a++){let d=0;for(let h=0;h<n;h++)d|=e.get(a*n+h)?1<<n-h-1:0;s[a]=d}return s}static getGF(e){switch(e){case 4:return Fe.AZTEC_PARAM;case 6:return Fe.AZTEC_DATA_6;case 8:return Fe.AZTEC_DATA_8;case 10:return Fe.AZTEC_DATA_10;case 12:return Fe.AZTEC_DATA_12;default:throw new C("Unsupported word size "+e)}}static stuffBits(e,n){let i=new J,s=e.getSize(),a=(1<<n)-2;for(let c=0;c<s;c+=n){let d=0;for(let h=0;h<n;h++)(c+h>=s||e.get(c+h))&&(d|=1<<n-1-h);(d&a)===a?(i.appendBits(d&a,n),c--):(d&a)===0?(i.appendBits(d|1,n),c--):i.appendBits(d,n)}return i}static totalBitsInLayer(e,n){return((n?88:112)+16*e)*e}}Ze.DEFAULT_EC_PERCENT=33,Ze.DEFAULT_AZTEC_LAYERS=0,Ze.MAX_NB_BITS=32,Ze.MAX_NB_BITS_COMPACT=4,Ze.WORD_SIZE=Int32Array.from([4,6,6,8,8,8,8,8,8,10,10,10,10,10,10,10,10,10,10,10,10,10,10,12,12,12,12,12,12,12,12,12,12]);class mi{encode(e,n,i,s){return this.encodeWithHints(e,n,i,s,null)}encodeWithHints(e,n,i,s,a){let c=go.ISO_8859_1,d=Ze.DEFAULT_EC_PERCENT,h=Ze.DEFAULT_AZTEC_LAYERS;return a!=null&&(a.has(Tt.CHARACTER_SET)&&(c=ks.forName(a.get(Tt.CHARACTER_SET).toString())),a.has(Tt.ERROR_CORRECTION)&&(d=k.parseInt(a.get(Tt.ERROR_CORRECTION).toString())),a.has(Tt.AZTEC_LAYERS)&&(h=k.parseInt(a.get(Tt.AZTEC_LAYERS).toString()))),mi.encodeLayers(e,n,i,s,c,d,h)}static encodeLayers(e,n,i,s,a,c,d){if(n!==T.AZTEC)throw new C("Can only encode AZTEC, but got "+n);let h=Ze.encode(pe.getBytes(e,a),c,d);return mi.renderResult(h,i,s)}static renderResult(e,n,i){let s=e.getMatrix();if(s==null)throw new ln;let a=s.getWidth(),c=s.getHeight(),d=Math.max(n,a),h=Math.max(i,c),p=Math.min(d/a,h/c),w=(d-a*p)/2,b=(h-c*p)/2,A=new le(d,h);for(let N=0,F=b;N<c;N++,F+=p)for(let $=0,j=w;$<a;$++,j+=p)s.get($,N)&&A.setRegion(j,F,p,p);return A}}o.AbstractExpandedDecoder=no,o.ArgumentException=E,o.ArithmeticException=an,o.AztecCode=Rs,o.AztecCodeReader=ai,o.AztecCodeWriter=mi,o.AztecDecoder=Ke,o.AztecDetector=ws,o.AztecDetectorResult=si,o.AztecEncoder=Ze,o.AztecHighLevelEncoder=Pr,o.AztecPoint=Mt,o.BarcodeFormat=T,o.Binarizer=D,o.BinaryBitmap=P,o.BitArray=J,o.BitMatrix=le,o.BitSource=so,o.BrowserAztecCodeReader=c1,o.BrowserBarcodeReader=p1,o.BrowserCodeReader=he,o.BrowserDatamatrixCodeReader=m1,o.BrowserMultiFormatReader=S1,o.BrowserPDF417Reader=T1,o.BrowserQRCodeReader=N1,o.BrowserQRCodeSvgWriter=ir,o.CharacterSetECI=W,o.ChecksumException=O,o.Code128Reader=ge,o.Code39Reader=It,o.DataMatrixDecodedBitStreamParser=Zn,o.DataMatrixReader=jn,o.DecodeHintType=Z,o.DecoderResult=mt,o.DefaultGridSampler=Ji,o.DetectorResult=cr,o.EAN13Reader=Qn,o.EncodeHintType=Tt,o.Exception=m,o.FormatException=z,o.GenericGF=Fe,o.GenericGFPoly=Qe,o.GlobalHistogramBinarizer=te,o.GridSampler=De,o.GridSamplerInstance=gn,o.HTMLCanvasElementLuminanceSource=xe,o.HybridBinarizer=K,o.ITFReader=et,o.IllegalArgumentException=C,o.IllegalStateException=ln,o.InvertedLuminanceSource=fe,o.LuminanceSource=ne,o.MathUtils=ze,o.MultiFormatOneDReader=hr,o.MultiFormatReader=Os,o.MultiFormatWriter=k1,o.NotFoundException=L,o.OneDReader=bt,o.PDF417DecodedBitStreamParser=G,o.PDF417DecoderErrorCorrection=Es,o.PDF417Reader=Bt,o.PDF417ResultMetadata=Is,o.PerspectiveTransform=Be,o.PlanarYUVLuminanceSource=Nn,o.QRCodeByteMatrix=pi,o.QRCodeDataMask=un,o.QRCodeDecodedBitStreamParser=pt,o.QRCodeDecoderErrorCorrectionLevel=it,o.QRCodeDecoderFormatInformation=zt,o.QRCodeEncoder=st,o.QRCodeEncoderQRCode=rr,o.QRCodeMaskUtil=yt,o.QRCodeMatrixUtil=ke,o.QRCodeMode=Oe,o.QRCodeReader=Hn,o.QRCodeVersion=Ne,o.QRCodeWriter=gr,o.RGBLuminanceSource=po,o.RSS14Reader=wt,o.RSSExpandedReader=re,o.ReaderException=hi,o.ReedSolomonDecoder=zn,o.ReedSolomonEncoder=ho,o.ReedSolomonException=Un,o.Result=Ee,o.ResultMetadataType=we,o.ResultPoint=Se,o.StringUtils=pe,o.UnsupportedOperationException=de,o.VideoInputDevice=ye,o.WhiteRectangleDetector=$e,o.WriterException=tt,o.ZXingArrays=U,o.ZXingCharset=ks,o.ZXingInteger=k,o.ZXingStandardCharsets=go,o.ZXingStringBuilder=Ce,o.ZXingStringEncoding=me,o.ZXingSystem=R,o.createAbstractExpandedDecoder=bs,Object.defineProperty(o,"__esModule",{value:!0})}))})(Vr,Vr.exports)),Vr.exports}var at=K3();const J3=Uc(at),Q3=V1({__proto__:null,default:J3},[at]);var wl=(function(){function t(r,o,l){if(this.formatMap=new Map([[Ie.QR_CODE,at.BarcodeFormat.QR_CODE],[Ie.AZTEC,at.BarcodeFormat.AZTEC],[Ie.CODABAR,at.BarcodeFormat.CODABAR],[Ie.CODE_39,at.BarcodeFormat.CODE_39],[Ie.CODE_93,at.BarcodeFormat.CODE_93],[Ie.CODE_128,at.BarcodeFormat.CODE_128],[Ie.DATA_MATRIX,at.BarcodeFormat.DATA_MATRIX],[Ie.MAXICODE,at.BarcodeFormat.MAXICODE],[Ie.ITF,at.BarcodeFormat.ITF],[Ie.EAN_13,at.BarcodeFormat.EAN_13],[Ie.EAN_8,at.BarcodeFormat.EAN_8],[Ie.PDF_417,at.BarcodeFormat.PDF_417],[Ie.RSS_14,at.BarcodeFormat.RSS_14],[Ie.RSS_EXPANDED,at.BarcodeFormat.RSS_EXPANDED],[Ie.UPC_A,at.BarcodeFormat.UPC_A],[Ie.UPC_E,at.BarcodeFormat.UPC_E],[Ie.UPC_EAN_EXTENSION,at.BarcodeFormat.UPC_EAN_EXTENSION]]),this.reverseFormatMap=this.createReverseFormatMap(),!Q3)throw"Use html5qrcode.min.js without edit, ZXing not found.";this.verbose=o,this.logger=l;var u=this.createZXingFormats(r),f=new Map;f.set(at.DecodeHintType.POSSIBLE_FORMATS,u),f.set(at.DecodeHintType.TRY_HARDER,!1),this.hints=f}return t.prototype.decodeAsync=function(r){var o=this;return new Promise(function(l,u){try{l(o.decode(r))}catch(f){u(f)}})},t.prototype.decode=function(r){var o=new at.MultiFormatReader(this.verbose,this.hints),l=new at.HTMLCanvasElementLuminanceSource(r),u=new at.BinaryBitmap(new at.HybridBinarizer(l)),f=o.decode(u);return{text:f.text,format:o1.create(this.toHtml5QrcodeSupportedFormats(f.format)),debugData:this.createDebugData()}},t.prototype.createReverseFormatMap=function(){var r=new Map;return this.formatMap.forEach(function(o,l,u){r.set(o,l)}),r},t.prototype.toHtml5QrcodeSupportedFormats=function(r){if(!this.reverseFormatMap.has(r))throw"reverseFormatMap doesn't have ".concat(r);return this.reverseFormatMap.get(r)},t.prototype.createZXingFormats=function(r){for(var o=[],l=0,u=r;l<u.length;l++){var f=u[l];this.formatMap.has(f)?o.push(this.formatMap.get(f)):this.logger.logError("".concat(f," is not supported by")+"ZXingHtml5QrcodeShim")}return o},t.prototype.createDebugData=function(){return{decoderName:"zxing-js"}},t})(),ey=function(t,r,o,l){function u(f){return f instanceof o?f:new o(function(g){g(f)})}return new(o||(o=Promise))(function(f,g){function x(E){try{m(l.next(E))}catch(C){g(C)}}function y(E){try{m(l.throw(E))}catch(C){g(C)}}function m(E){E.done?f(E.value):u(E.value).then(x,y)}m((l=l.apply(t,r||[])).next())})},ty=function(t,r){var o={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},l,u,f,g;return g={next:x(0),throw:x(1),return:x(2)},typeof Symbol=="function"&&(g[Symbol.iterator]=function(){return this}),g;function x(m){return function(E){return y([m,E])}}function y(m){if(l)throw new TypeError("Generator is already executing.");for(;g&&(g=0,m[0]&&(o=0)),o;)try{if(l=1,u&&(f=m[0]&2?u.return:m[0]?u.throw||((f=u.return)&&f.call(u),0):u.next)&&!(f=f.call(u,m[1])).done)return f;switch(u=0,f&&(m=[m[0]&2,f.value]),m[0]){case 0:case 1:f=m;break;case 4:return o.label++,{value:m[1],done:!1};case 5:o.label++,u=m[1],m=[0];continue;case 7:m=o.ops.pop(),o.trys.pop();continue;default:if(f=o.trys,!(f=f.length>0&&f[f.length-1])&&(m[0]===6||m[0]===2)){o=0;continue}if(m[0]===3&&(!f||m[1]>f[0]&&m[1]<f[3])){o.label=m[1];break}if(m[0]===6&&o.label<f[1]){o.label=f[1],f=m;break}if(f&&o.label<f[2]){o.label=f[2],o.ops.push(m);break}f[2]&&o.ops.pop(),o.trys.pop();continue}m=r.call(t,o)}catch(E){m=[6,E],u=0}finally{l=f=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}},yl=(function(){function t(r,o,l){if(this.formatMap=new Map([[Ie.QR_CODE,"qr_code"],[Ie.AZTEC,"aztec"],[Ie.CODABAR,"codabar"],[Ie.CODE_39,"code_39"],[Ie.CODE_93,"code_93"],[Ie.CODE_128,"code_128"],[Ie.DATA_MATRIX,"data_matrix"],[Ie.ITF,"itf"],[Ie.EAN_13,"ean_13"],[Ie.EAN_8,"ean_8"],[Ie.PDF_417,"pdf417"],[Ie.UPC_A,"upc_a"],[Ie.UPC_E,"upc_e"]]),this.reverseFormatMap=this.createReverseFormatMap(),!t.isSupported())throw"Use html5qrcode.min.js without edit, Use BarcodeDetectorDelegate only if it isSupported();";this.verbose=o,this.logger=l;var u=this.createBarcodeDetectorFormats(r);if(this.detector=new BarcodeDetector(u),!this.detector)throw"BarcodeDetector detector not supported"}return t.isSupported=function(){if(!("BarcodeDetector"in window))return!1;var r=new BarcodeDetector({formats:["qr_code"]});return typeof r<"u"},t.prototype.decodeAsync=function(r){return ey(this,void 0,void 0,function(){var o,l;return ty(this,function(u){switch(u.label){case 0:return[4,this.detector.detect(r)];case 1:if(o=u.sent(),!o||o.length===0)throw"No barcode or QR code detected.";return l=this.selectLargestBarcode(o),[2,{text:l.rawValue,format:o1.create(this.toHtml5QrcodeSupportedFormats(l.format)),debugData:this.createDebugData()}]}})})},t.prototype.selectLargestBarcode=function(r){for(var o=null,l=0,u=0,f=r;u<f.length;u++){var g=f[u],x=g.boundingBox.width*g.boundingBox.height;x>l&&(l=x,o=g)}if(!o)throw"No largest barcode found";return o},t.prototype.createBarcodeDetectorFormats=function(r){for(var o=[],l=0,u=r;l<u.length;l++){var f=u[l];this.formatMap.has(f)?o.push(this.formatMap.get(f)):this.logger.warn("".concat(f," is not supported by")+"BarcodeDetectorDelegate")}return{formats:o}},t.prototype.toHtml5QrcodeSupportedFormats=function(r){if(!this.reverseFormatMap.has(r))throw"reverseFormatMap doesn't have ".concat(r);return this.reverseFormatMap.get(r)},t.prototype.createReverseFormatMap=function(){var r=new Map;return this.formatMap.forEach(function(o,l,u){r.set(o,l)}),r},t.prototype.createDebugData=function(){return{decoderName:"BarcodeDetector"}},t})(),_l=function(t,r,o,l){function u(f){return f instanceof o?f:new o(function(g){g(f)})}return new(o||(o=Promise))(function(f,g){function x(E){try{m(l.next(E))}catch(C){g(C)}}function y(E){try{m(l.throw(E))}catch(C){g(C)}}function m(E){E.done?f(E.value):u(E.value).then(x,y)}m((l=l.apply(t,r||[])).next())})},vl=function(t,r){var o={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},l,u,f,g;return g={next:x(0),throw:x(1),return:x(2)},typeof Symbol=="function"&&(g[Symbol.iterator]=function(){return this}),g;function x(m){return function(E){return y([m,E])}}function y(m){if(l)throw new TypeError("Generator is already executing.");for(;g&&(g=0,m[0]&&(o=0)),o;)try{if(l=1,u&&(f=m[0]&2?u.return:m[0]?u.throw||((f=u.return)&&f.call(u),0):u.next)&&!(f=f.call(u,m[1])).done)return f;switch(u=0,f&&(m=[m[0]&2,f.value]),m[0]){case 0:case 1:f=m;break;case 4:return o.label++,{value:m[1],done:!1};case 5:o.label++,u=m[1],m=[0];continue;case 7:m=o.ops.pop(),o.trys.pop();continue;default:if(f=o.trys,!(f=f.length>0&&f[f.length-1])&&(m[0]===6||m[0]===2)){o=0;continue}if(m[0]===3&&(!f||m[1]>f[0]&&m[1]<f[3])){o.label=m[1];break}if(m[0]===6&&o.label<f[1]){o.label=f[1],f=m;break}if(f&&o.label<f[2]){o.label=f[2],o.ops.push(m);break}f[2]&&o.ops.pop(),o.trys.pop();continue}m=r.call(t,o)}catch(E){m=[6,E],u=0}finally{l=f=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}},ny=(function(){function t(r,o,l,u){this.EXECUTIONS_TO_REPORT_PERFORMANCE=100,this.executions=0,this.executionResults=[],this.wasPrimaryDecoderUsedInLastDecode=!1,this.verbose=l,o&&yl.isSupported()?(this.primaryDecoder=new yl(r,l,u),this.secondaryDecoder=new wl(r,l,u)):this.primaryDecoder=new wl(r,l,u)}return t.prototype.decodeAsync=function(r){return _l(this,void 0,void 0,function(){var o;return vl(this,function(l){switch(l.label){case 0:o=performance.now(),l.label=1;case 1:return l.trys.push([1,,3,4]),[4,this.getDecoder().decodeAsync(r)];case 2:return[2,l.sent()];case 3:return this.possiblyLogPerformance(o),[7];case 4:return[2]}})})},t.prototype.decodeRobustlyAsync=function(r){return _l(this,void 0,void 0,function(){var o,l;return vl(this,function(u){switch(u.label){case 0:o=performance.now(),u.label=1;case 1:return u.trys.push([1,3,4,5]),[4,this.primaryDecoder.decodeAsync(r)];case 2:return[2,u.sent()];case 3:if(l=u.sent(),this.secondaryDecoder)return[2,this.secondaryDecoder.decodeAsync(r)];throw l;case 4:return this.possiblyLogPerformance(o),[7];case 5:return[2]}})})},t.prototype.getDecoder=function(){return this.secondaryDecoder?this.wasPrimaryDecoderUsedInLastDecode===!1?(this.wasPrimaryDecoderUsedInLastDecode=!0,this.primaryDecoder):(this.wasPrimaryDecoderUsedInLastDecode=!1,this.secondaryDecoder):this.primaryDecoder},t.prototype.possiblyLogPerformance=function(r){if(this.verbose){var o=performance.now()-r;this.executionResults.push(o),this.executions++,this.possiblyFlushPerformanceReport()}},t.prototype.possiblyFlushPerformanceReport=function(){if(!(this.executions<this.EXECUTIONS_TO_REPORT_PERFORMANCE)){for(var r=0,o=0,l=this.executionResults;o<l.length;o++){var u=l[o];r+=u}var f=r/this.executionResults.length;console.log("".concat(f," ms for ").concat(this.executionResults.length," last runs.")),this.executions=0,this.executionResults=[]}},t})(),gs=(function(){var t=function(r,o){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(l,u){l.__proto__=u}||function(l,u){for(var f in u)Object.prototype.hasOwnProperty.call(u,f)&&(l[f]=u[f])},t(r,o)};return function(r,o){if(typeof o!="function"&&o!==null)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");t(r,o);function l(){this.constructor=r}r.prototype=o===null?Object.create(o):(l.prototype=o.prototype,new l)}})(),Zi=function(t,r,o,l){function u(f){return f instanceof o?f:new o(function(g){g(f)})}return new(o||(o=Promise))(function(f,g){function x(E){try{m(l.next(E))}catch(C){g(C)}}function y(E){try{m(l.throw(E))}catch(C){g(C)}}function m(E){E.done?f(E.value):u(E.value).then(x,y)}m((l=l.apply(t,r||[])).next())})},ji=function(t,r){var o={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},l,u,f,g;return g={next:x(0),throw:x(1),return:x(2)},typeof Symbol=="function"&&(g[Symbol.iterator]=function(){return this}),g;function x(m){return function(E){return y([m,E])}}function y(m){if(l)throw new TypeError("Generator is already executing.");for(;g&&(g=0,m[0]&&(o=0)),o;)try{if(l=1,u&&(f=m[0]&2?u.return:m[0]?u.throw||((f=u.return)&&f.call(u),0):u.next)&&!(f=f.call(u,m[1])).done)return f;switch(u=0,f&&(m=[m[0]&2,f.value]),m[0]){case 0:case 1:f=m;break;case 4:return o.label++,{value:m[1],done:!1};case 5:o.label++,u=m[1],m=[0];continue;case 7:m=o.ops.pop(),o.trys.pop();continue;default:if(f=o.trys,!(f=f.length>0&&f[f.length-1])&&(m[0]===6||m[0]===2)){o=0;continue}if(m[0]===3&&(!f||m[1]>f[0]&&m[1]<f[3])){o.label=m[1];break}if(m[0]===6&&o.label<f[1]){o.label=f[1],f=m;break}if(f&&o.label<f[2]){o.label=f[2],o.ops.push(m);break}f[2]&&o.ops.pop(),o.trys.pop();continue}m=r.call(t,o)}catch(E){m=[6,E],u=0}finally{l=f=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}},a1=(function(){function t(r,o){this.name=r,this.track=o}return t.prototype.isSupported=function(){return this.track.getCapabilities?this.name in this.track.getCapabilities():!1},t.prototype.apply=function(r){var o={};o[this.name]=r;var l={advanced:[o]};return this.track.applyConstraints(l)},t.prototype.value=function(){var r=this.track.getSettings();if(this.name in r){var o=r[this.name];return o}return null},t})(),ry=(function(t){gs(r,t);function r(o,l){return t.call(this,o,l)||this}return r.prototype.min=function(){return this.getCapabilities().min},r.prototype.max=function(){return this.getCapabilities().max},r.prototype.step=function(){return this.getCapabilities().step},r.prototype.apply=function(o){var l={};l[this.name]=o;var u={advanced:[l]};return this.track.applyConstraints(u)},r.prototype.getCapabilities=function(){this.failIfNotSupported();var o=this.track.getCapabilities(),l=o[this.name];return{min:l.min,max:l.max,step:l.step}},r.prototype.failIfNotSupported=function(){if(!this.isSupported())throw new Error("".concat(this.name," capability not supported"))},r})(a1),iy=(function(t){gs(r,t);function r(o){return t.call(this,"zoom",o)||this}return r})(ry),oy=(function(t){gs(r,t);function r(o){return t.call(this,"torch",o)||this}return r})(a1),sy=(function(){function t(r){this.track=r}return t.prototype.zoomFeature=function(){return new iy(this.track)},t.prototype.torchFeature=function(){return new oy(this.track)},t})(),ay=(function(){function t(r,o,l){this.isClosed=!1,this.parentElement=r,this.mediaStream=o,this.callbacks=l,this.surface=this.createVideoElement(this.parentElement.clientWidth),r.append(this.surface)}return t.prototype.createVideoElement=function(r){var o=document.createElement("video");return o.style.width="".concat(r,"px"),o.style.display="block",o.muted=!0,o.setAttribute("muted","true"),o.playsInline=!0,o},t.prototype.setupSurface=function(){var r=this;this.surface.onabort=function(){throw"RenderedCameraImpl video surface onabort() called"},this.surface.onerror=function(){throw"RenderedCameraImpl video surface onerror() called"};var o=function(){var l=r.surface.clientWidth,u=r.surface.clientHeight;r.callbacks.onRenderSurfaceReady(l,u),r.surface.removeEventListener("playing",o)};this.surface.addEventListener("playing",o),this.surface.srcObject=this.mediaStream,this.surface.play()},t.create=function(r,o,l,u){return Zi(this,void 0,void 0,function(){var f,g;return ji(this,function(x){switch(x.label){case 0:return f=new t(r,o,u),l.aspectRatio?(g={aspectRatio:l.aspectRatio},[4,f.getFirstTrackOrFail().applyConstraints(g)]):[3,2];case 1:x.sent(),x.label=2;case 2:return f.setupSurface(),[2,f]}})})},t.prototype.failIfClosed=function(){if(this.isClosed)throw"The RenderedCamera has already been closed."},t.prototype.getFirstTrackOrFail=function(){if(this.failIfClosed(),this.mediaStream.getVideoTracks().length===0)throw"No video tracks found";return this.mediaStream.getVideoTracks()[0]},t.prototype.pause=function(){this.failIfClosed(),this.surface.pause()},t.prototype.resume=function(r){this.failIfClosed();var o=this,l=function(){setTimeout(r,200),o.surface.removeEventListener("playing",l)};this.surface.addEventListener("playing",l),this.surface.play()},t.prototype.isPaused=function(){return this.failIfClosed(),this.surface.paused},t.prototype.getSurface=function(){return this.failIfClosed(),this.surface},t.prototype.getRunningTrackCapabilities=function(){return this.getFirstTrackOrFail().getCapabilities()},t.prototype.getRunningTrackSettings=function(){return this.getFirstTrackOrFail().getSettings()},t.prototype.applyVideoConstraints=function(r){return Zi(this,void 0,void 0,function(){return ji(this,function(o){if("aspectRatio"in r)throw"Changing 'aspectRatio' in run-time is not yet supported.";return[2,this.getFirstTrackOrFail().applyConstraints(r)]})})},t.prototype.close=function(){if(this.isClosed)return Promise.resolve();var r=this;return new Promise(function(o,l){var u=r.mediaStream.getVideoTracks(),f=u.length,g=0;r.mediaStream.getVideoTracks().forEach(function(x){r.mediaStream.removeTrack(x),x.stop(),++g,g>=f&&(r.isClosed=!0,r.parentElement.removeChild(r.surface),o())})})},t.prototype.getCapabilities=function(){return new sy(this.getFirstTrackOrFail())},t})(),ly=(function(){function t(r){this.mediaStream=r}return t.prototype.render=function(r,o,l){return Zi(this,void 0,void 0,function(){return ji(this,function(u){return[2,ay.create(r,this.mediaStream,o,l)]})})},t.create=function(r){return Zi(this,void 0,void 0,function(){var o,l;return ji(this,function(u){switch(u.label){case 0:if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return o={audio:!1,video:r},[4,navigator.mediaDevices.getUserMedia(o)];case 1:return l=u.sent(),[2,new t(l)]}})})},t})(),bl=function(t,r,o,l){function u(f){return f instanceof o?f:new o(function(g){g(f)})}return new(o||(o=Promise))(function(f,g){function x(E){try{m(l.next(E))}catch(C){g(C)}}function y(E){try{m(l.throw(E))}catch(C){g(C)}}function m(E){E.done?f(E.value):u(E.value).then(x,y)}m((l=l.apply(t,r||[])).next())})},Cl=function(t,r){var o={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},l,u,f,g;return g={next:x(0),throw:x(1),return:x(2)},typeof Symbol=="function"&&(g[Symbol.iterator]=function(){return this}),g;function x(m){return function(E){return y([m,E])}}function y(m){if(l)throw new TypeError("Generator is already executing.");for(;g&&(g=0,m[0]&&(o=0)),o;)try{if(l=1,u&&(f=m[0]&2?u.return:m[0]?u.throw||((f=u.return)&&f.call(u),0):u.next)&&!(f=f.call(u,m[1])).done)return f;switch(u=0,f&&(m=[m[0]&2,f.value]),m[0]){case 0:case 1:f=m;break;case 4:return o.label++,{value:m[1],done:!1};case 5:o.label++,u=m[1],m=[0];continue;case 7:m=o.ops.pop(),o.trys.pop();continue;default:if(f=o.trys,!(f=f.length>0&&f[f.length-1])&&(m[0]===6||m[0]===2)){o=0;continue}if(m[0]===3&&(!f||m[1]>f[0]&&m[1]<f[3])){o.label=m[1];break}if(m[0]===6&&o.label<f[1]){o.label=f[1],f=m;break}if(f&&o.label<f[2]){o.label=f[2],o.ops.push(m);break}f[2]&&o.ops.pop(),o.trys.pop();continue}m=r.call(t,o)}catch(E){m=[6,E],u=0}finally{l=f=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}},cy=(function(){function t(){}return t.failIfNotSupported=function(){return bl(this,void 0,void 0,function(){return Cl(this,function(r){if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return[2,new t]})})},t.prototype.create=function(r){return bl(this,void 0,void 0,function(){return Cl(this,function(o){return[2,ly.create(r)]})})},t})(),uy=function(t,r,o,l){function u(f){return f instanceof o?f:new o(function(g){g(f)})}return new(o||(o=Promise))(function(f,g){function x(E){try{m(l.next(E))}catch(C){g(C)}}function y(E){try{m(l.throw(E))}catch(C){g(C)}}function m(E){E.done?f(E.value):u(E.value).then(x,y)}m((l=l.apply(t,r||[])).next())})},dy=function(t,r){var o={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},l,u,f,g;return g={next:x(0),throw:x(1),return:x(2)},typeof Symbol=="function"&&(g[Symbol.iterator]=function(){return this}),g;function x(m){return function(E){return y([m,E])}}function y(m){if(l)throw new TypeError("Generator is already executing.");for(;g&&(g=0,m[0]&&(o=0)),o;)try{if(l=1,u&&(f=m[0]&2?u.return:m[0]?u.throw||((f=u.return)&&f.call(u),0):u.next)&&!(f=f.call(u,m[1])).done)return f;switch(u=0,f&&(m=[m[0]&2,f.value]),m[0]){case 0:case 1:f=m;break;case 4:return o.label++,{value:m[1],done:!1};case 5:o.label++,u=m[1],m=[0];continue;case 7:m=o.ops.pop(),o.trys.pop();continue;default:if(f=o.trys,!(f=f.length>0&&f[f.length-1])&&(m[0]===6||m[0]===2)){o=0;continue}if(m[0]===3&&(!f||m[1]>f[0]&&m[1]<f[3])){o.label=m[1];break}if(m[0]===6&&o.label<f[1]){o.label=f[1],f=m;break}if(f&&o.label<f[2]){o.label=f[2],o.ops.push(m);break}f[2]&&o.ops.pop(),o.trys.pop();continue}m=r.call(t,o)}catch(E){m=[6,E],u=0}finally{l=f=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}},fy=(function(){function t(){}return t.retrieve=function(){if(navigator.mediaDevices)return t.getCamerasFromMediaDevices();var r=MediaStreamTrack;return MediaStreamTrack&&r.getSources?t.getCamerasFromMediaStreamTrack():t.rejectWithError()},t.rejectWithError=function(){var r=br.unableToQuerySupportedDevices();return t.isHttpsOrLocalhost()||(r=br.insecureContextCameraQueryError()),Promise.reject(r)},t.isHttpsOrLocalhost=function(){if(location.protocol==="https:")return!0;var r=location.host.split(":")[0];return r==="127.0.0.1"||r==="localhost"},t.getCamerasFromMediaDevices=function(){return uy(this,void 0,void 0,function(){var r,o,l,u,f,g,x;return dy(this,function(y){switch(y.label){case 0:return r=function(m){for(var E=m.getVideoTracks(),C=0,P=E;C<P.length;C++){var O=P[C];O.enabled=!1,O.stop(),m.removeTrack(O)}},[4,navigator.mediaDevices.getUserMedia({audio:!1,video:!0})];case 1:return o=y.sent(),[4,navigator.mediaDevices.enumerateDevices()];case 2:for(l=y.sent(),u=[],f=0,g=l;f<g.length;f++)x=g[f],x.kind==="videoinput"&&u.push({id:x.deviceId,label:x.label});return r(o),[2,u]}})})},t.getCamerasFromMediaStreamTrack=function(){return new Promise(function(r,o){var l=function(f){for(var g=[],x=0,y=f;x<y.length;x++){var m=y[x];m.kind==="video"&&g.push({id:m.id,label:m.label})}r(g)},u=MediaStreamTrack;u.getSources(l)})},t})(),_t;(function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.NOT_STARTED=1]="NOT_STARTED",t[t.SCANNING=2]="SCANNING",t[t.PAUSED=3]="PAUSED"})(_t||(_t={}));var hy=(function(){function t(){this.state=_t.NOT_STARTED,this.onGoingTransactionNewState=_t.UNKNOWN}return t.prototype.directTransition=function(r){this.failIfTransitionOngoing(),this.validateTransition(r),this.state=r},t.prototype.startTransition=function(r){return this.failIfTransitionOngoing(),this.validateTransition(r),this.onGoingTransactionNewState=r,this},t.prototype.execute=function(){if(this.onGoingTransactionNewState===_t.UNKNOWN)throw"Transaction is already cancelled, cannot execute().";var r=this.onGoingTransactionNewState;this.onGoingTransactionNewState=_t.UNKNOWN,this.directTransition(r)},t.prototype.cancel=function(){if(this.onGoingTransactionNewState===_t.UNKNOWN)throw"Transaction is already cancelled, cannot cancel().";this.onGoingTransactionNewState=_t.UNKNOWN},t.prototype.getState=function(){return this.state},t.prototype.failIfTransitionOngoing=function(){if(this.onGoingTransactionNewState!==_t.UNKNOWN)throw"Cannot transition to a new state, already under transition"},t.prototype.validateTransition=function(r){switch(this.state){case _t.UNKNOWN:throw"Transition from unknown is not allowed";case _t.NOT_STARTED:this.failIfNewStateIs(r,[_t.PAUSED]);break;case _t.SCANNING:break;case _t.PAUSED:break}},t.prototype.failIfNewStateIs=function(r,o){for(var l=0,u=o;l<u.length;l++){var f=u[l];if(r===f)throw"Cannot transition from ".concat(this.state," to ").concat(r)}},t})(),py=(function(){function t(r){this.stateManager=r}return t.prototype.startTransition=function(r){return this.stateManager.startTransition(r)},t.prototype.directTransition=function(r){this.stateManager.directTransition(r)},t.prototype.getState=function(){return this.stateManager.getState()},t.prototype.canScanFile=function(){return this.stateManager.getState()===_t.NOT_STARTED},t.prototype.isScanning=function(){return this.stateManager.getState()!==_t.NOT_STARTED},t.prototype.isStrictlyScanning=function(){return this.stateManager.getState()===_t.SCANNING},t.prototype.isPaused=function(){return this.stateManager.getState()===_t.PAUSED},t})(),gy=(function(){function t(){}return t.create=function(){return new py(new hy)},t})(),my=(function(){var t=function(r,o){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(l,u){l.__proto__=u}||function(l,u){for(var f in u)Object.prototype.hasOwnProperty.call(u,f)&&(l[f]=u[f])},t(r,o)};return function(r,o){if(typeof o!="function"&&o!==null)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");t(r,o);function l(){this.constructor=r}r.prototype=o===null?Object.create(o):(l.prototype=o.prototype,new l)}})(),rn=(function(t){my(r,t);function r(){return t!==null&&t.apply(this,arguments)||this}return r.DEFAULT_WIDTH=300,r.DEFAULT_WIDTH_OFFSET=2,r.FILE_SCAN_MIN_HEIGHT=300,r.FILE_SCAN_HIDDEN_CANVAS_PADDING=100,r.MIN_QR_BOX_SIZE=50,r.SHADED_LEFT=1,r.SHADED_RIGHT=2,r.SHADED_TOP=3,r.SHADED_BOTTOM=4,r.SHADED_REGION_ELEMENT_ID="qr-shaded-region",r.VERBOSE=!1,r.BORDER_SHADER_DEFAULT_COLOR="#ffffff",r.BORDER_SHADER_MATCH_COLOR="rgb(90, 193, 56)",r})(G3),xy=(function(){function t(r,o){this.logger=o,this.fps=rn.SCAN_DEFAULT_FPS,r?(r.fps&&(this.fps=r.fps),this.disableFlip=r.disableFlip===!0,this.qrbox=r.qrbox,this.aspectRatio=r.aspectRatio,this.videoConstraints=r.videoConstraints):this.disableFlip=rn.DEFAULT_DISABLE_FLIP}return t.prototype.isMediaStreamConstraintsValid=function(){return this.videoConstraints?s1.isMediaStreamConstraintsValid(this.videoConstraints,this.logger):(this.logger.logError("Empty videoConstraints",!0),!1)},t.prototype.isShadedBoxEnabled=function(){return!Pn(this.qrbox)},t.create=function(r,o){return new t(r,o)},t})(),El=(function(){function t(r,o){if(this.element=null,this.canvasElement=null,this.scannerPausedUiElement=null,this.hasBorderShaders=null,this.borderShaders=null,this.qrMatch=null,this.renderedCamera=null,this.qrRegion=null,this.context=null,this.lastScanImageFile=null,this.isScanning=!1,!document.getElementById(r))throw"HTML Element with id=".concat(r," not found");this.elementId=r,this.verbose=!1;var l;typeof o=="boolean"?this.verbose=o===!0:o&&(l=o,this.verbose=l.verbose===!0,l.experimentalFeatures),this.logger=new q3(this.verbose),this.qrcode=new ny(this.getSupportedFormats(o),this.getUseBarCodeDetectorIfSupported(l),this.verbose,this.logger),this.foreverScanTimeout,this.shouldScan=!0,this.stateManagerProxy=gy.create()}return t.prototype.start=function(r,o,l,u){var f=this;if(!r)throw"cameraIdOrConfig is required";if(!l||typeof l!="function")throw"qrCodeSuccessCallback is required and should be a function.";var g;u?g=u:g=this.verbose?this.logger.log:function(){};var x=xy.create(o,this.logger);this.clearElement();var y=!1;x.videoConstraints&&(x.isMediaStreamConstraintsValid()?y=!0:this.logger.logError("'videoConstraints' is not valid 'MediaStreamConstraints, it will be ignored.'",!0));var m=y,E=document.getElementById(this.elementId);E.clientWidth?E.clientWidth:rn.DEFAULT_WIDTH,E.style.position="relative",this.shouldScan=!0,this.element=E;var C=this,P=this.stateManagerProxy.startTransition(_t.SCANNING);return new Promise(function(O,D){var R=m?x.videoConstraints:C.createVideoConstraints(r);if(!R){P.cancel(),D("videoConstraints should be defined");return}var M={};(!m||x.aspectRatio)&&(M.aspectRatio=x.aspectRatio);var V={onRenderSurfaceReady:function(U,k){C.setupUi(U,k,x),C.isScanning=!0,C.foreverScan(x,l,g)}};cy.failIfNotSupported().then(function(U){U.create(R).then(function(k){return k.render(f.element,M,V).then(function(J){C.renderedCamera=J,P.execute(),O(null)}).catch(function(J){P.cancel(),D(J)})}).catch(function(k){P.cancel(),D(br.errorGettingUserMedia(k))})}).catch(function(U){P.cancel(),D(br.cameraStreamingNotSupported())})})},t.prototype.pause=function(r){if(!this.stateManagerProxy.isStrictlyScanning())throw"Cannot pause, scanner is not scanning.";this.stateManagerProxy.directTransition(_t.PAUSED),this.showPausedState(),(Pn(r)||r!==!0)&&(r=!1),r&&this.renderedCamera&&this.renderedCamera.pause()},t.prototype.resume=function(){if(!this.stateManagerProxy.isPaused())throw"Cannot result, scanner is not paused.";if(!this.renderedCamera)throw"renderedCamera doesn't exist while trying resume()";var r=this,o=function(){r.stateManagerProxy.directTransition(_t.SCANNING),r.hidePausedState()};if(!this.renderedCamera.isPaused()){o();return}this.renderedCamera.resume(function(){o()})},t.prototype.getState=function(){return this.stateManagerProxy.getState()},t.prototype.stop=function(){var r=this;if(!this.stateManagerProxy.isScanning())throw"Cannot stop, scanner is not running or paused.";var o=this.stateManagerProxy.startTransition(_t.NOT_STARTED);this.shouldScan=!1,this.foreverScanTimeout&&clearTimeout(this.foreverScanTimeout);var l=function(){if(r.element){var f=document.getElementById(rn.SHADED_REGION_ELEMENT_ID);f&&r.element.removeChild(f)}},u=this;return this.renderedCamera.close().then(function(){return u.renderedCamera=null,u.element&&(u.element.removeChild(u.canvasElement),u.canvasElement=null),l(),u.qrRegion&&(u.qrRegion=null),u.context&&(u.context=null),o.execute(),u.hidePausedState(),u.isScanning=!1,Promise.resolve()})},t.prototype.scanFile=function(r,o){return this.scanFileV2(r,o).then(function(l){return l.decodedText})},t.prototype.scanFileV2=function(r,o){var l=this;if(!r||!(r instanceof File))throw"imageFile argument is mandatory and should be instance of File. Use 'event.target.files[0]'.";if(Pn(o)&&(o=!0),!this.stateManagerProxy.canScanFile())throw"Cannot start file scan - ongoing camera scan";return new Promise(function(u,f){l.possiblyCloseLastScanImageFile(),l.clearElement(),l.lastScanImageFile=URL.createObjectURL(r);var g=new Image;g.onload=function(){var x=g.width,y=g.height,m=document.getElementById(l.elementId),E=m.clientWidth?m.clientWidth:rn.DEFAULT_WIDTH,C=Math.max(m.clientHeight?m.clientHeight:y,rn.FILE_SCAN_MIN_HEIGHT),P=l.computeCanvasDrawConfig(x,y,E,C);if(o){var O=l.createCanvasElement(E,C,"qr-canvas-visible");O.style.display="inline-block",m.appendChild(O);var D=O.getContext("2d");if(!D)throw"Unable to get 2d context from canvas";D.canvas.width=E,D.canvas.height=C,D.drawImage(g,0,0,x,y,P.x,P.y,P.width,P.height)}var R=rn.FILE_SCAN_HIDDEN_CANVAS_PADDING,M=Math.max(g.width,P.width),V=Math.max(g.height,P.height),U=M+2*R,k=V+2*R,J=l.createCanvasElement(U,k);m.appendChild(J);var be=J.getContext("2d");if(!be)throw"Unable to get 2d context from canvas";be.canvas.width=U,be.canvas.height=k,be.drawImage(g,0,0,x,y,R,R,M,V);try{l.qrcode.decodeRobustlyAsync(J).then(function(Z){u(ml.createFromQrcodeResult(Z))}).catch(f)}catch(Z){f("QR code parse error, error = ".concat(Z))}},g.onerror=f,g.onabort=f,g.onstalled=f,g.onsuspend=f,g.src=URL.createObjectURL(r)})},t.prototype.clear=function(){this.clearElement()},t.getCameras=function(){return fy.retrieve()},t.prototype.getRunningTrackCapabilities=function(){return this.getRenderedCameraOrFail().getRunningTrackCapabilities()},t.prototype.getRunningTrackSettings=function(){return this.getRenderedCameraOrFail().getRunningTrackSettings()},t.prototype.getRunningTrackCameraCapabilities=function(){return this.getRenderedCameraOrFail().getCapabilities()},t.prototype.applyVideoConstraints=function(r){if(r){if(!s1.isMediaStreamConstraintsValid(r,this.logger))throw"invalid videoConstaints passed, check logs for more details"}else throw"videoConstaints is required argument.";return this.getRenderedCameraOrFail().applyVideoConstraints(r)},t.prototype.getRenderedCameraOrFail=function(){if(this.renderedCamera==null)throw"Scanning is not in running state, call this API only when QR code scanning using camera is in running state.";return this.renderedCamera},t.prototype.getSupportedFormats=function(r){var o=[Ie.QR_CODE,Ie.AZTEC,Ie.CODABAR,Ie.CODE_39,Ie.CODE_93,Ie.CODE_128,Ie.DATA_MATRIX,Ie.MAXICODE,Ie.ITF,Ie.EAN_13,Ie.EAN_8,Ie.PDF_417,Ie.RSS_14,Ie.RSS_EXPANDED,Ie.UPC_A,Ie.UPC_E,Ie.UPC_EAN_EXTENSION];if(!r||typeof r=="boolean"||!r.formatsToSupport)return o;if(!Array.isArray(r.formatsToSupport))throw"configOrVerbosityFlag.formatsToSupport should be undefined or an array.";if(r.formatsToSupport.length===0)throw"Atleast 1 formatsToSupport is needed.";for(var l=[],u=0,f=r.formatsToSupport;u<f.length;u++){var g=f[u];W3(g)?l.push(g):this.logger.warn("Invalid format: ".concat(g," passed in config, ignoring."))}if(l.length===0)throw"None of formatsToSupport match supported values.";return l},t.prototype.getUseBarCodeDetectorIfSupported=function(r){if(Pn(r))return!0;if(!Pn(r.useBarCodeDetectorIfSupported))return r.useBarCodeDetectorIfSupported!==!1;if(Pn(r.experimentalFeatures))return!0;var o=r.experimentalFeatures;return Pn(o.useBarCodeDetectorIfSupported)?!0:o.useBarCodeDetectorIfSupported!==!1},t.prototype.validateQrboxSize=function(r,o,l){var u=this,f=l.qrbox;this.validateQrboxConfig(f);var g=this.toQrdimensions(r,o,f),x=function(m){if(m<rn.MIN_QR_BOX_SIZE)throw"minimum size of 'config.qrbox' dimension value is"+" ".concat(rn.MIN_QR_BOX_SIZE,"px.")},y=function(m){return m>r&&(u.logger.warn("`qrbox.width` or `qrbox` is larger than the width of the root element. The width will be truncated to the width of root element."),m=r),m};x(g.width),x(g.height),g.width=y(g.width)},t.prototype.validateQrboxConfig=function(r){if(typeof r!="number"&&typeof r!="function"&&(r.width===void 0||r.height===void 0))throw"Invalid instance of QrDimensions passed for 'config.qrbox'. Both 'width' and 'height' should be set."},t.prototype.toQrdimensions=function(r,o,l){if(typeof l=="number")return{width:l,height:l};if(typeof l=="function")try{return l(r,o)}catch(u){throw new Error("qrbox config was passed as a function but it failed with unknown error"+u)}return l},t.prototype.setupUi=function(r,o,l){l.isShadedBoxEnabled()&&this.validateQrboxSize(r,o,l);var u=Pn(l.qrbox)?{width:r,height:o}:l.qrbox;this.validateQrboxConfig(u);var f=this.toQrdimensions(r,o,u);f.height>o&&this.logger.warn("[Html5Qrcode] config.qrbox has height that isgreater than the height of the video stream. Shading will be ignored");var g=l.isShadedBoxEnabled()&&f.height<=o,x={x:0,y:0,width:r,height:o},y=g?this.getShadedRegionBounds(r,o,f):x,m=this.createCanvasElement(y.width,y.height),E={willReadFrequently:!0},C=m.getContext("2d",E);C.canvas.width=y.width,C.canvas.height=y.height,this.element.append(m),g&&this.possiblyInsertShadingElement(this.element,r,o,f),this.createScannerPausedUiElement(this.element),this.qrRegion=y,this.context=C,this.canvasElement=m},t.prototype.createScannerPausedUiElement=function(r){var o=document.createElement("div");o.innerText=br.scannerPaused(),o.style.display="none",o.style.position="absolute",o.style.top="0px",o.style.zIndex="1",o.style.background="rgba(9, 9, 9, 0.46)",o.style.color="#FFECEC",o.style.textAlign="center",o.style.width="100%",r.appendChild(o),this.scannerPausedUiElement=o},t.prototype.scanContext=function(r,o){var l=this;return this.stateManagerProxy.isPaused()?Promise.resolve(!1):this.qrcode.decodeAsync(this.canvasElement).then(function(u){return r(u.text,ml.createFromQrcodeResult(u)),l.possiblyUpdateShaders(!0),!0}).catch(function(u){l.possiblyUpdateShaders(!1);var f=br.codeParseError(u);return o(f,X3.createFrom(f)),!1})},t.prototype.foreverScan=function(r,o,l){var u=this;if(this.shouldScan&&this.renderedCamera){var f=this.renderedCamera.getSurface(),g=f.videoWidth/f.clientWidth,x=f.videoHeight/f.clientHeight;if(!this.qrRegion)throw"qrRegion undefined when localMediaStream is ready.";var y=this.qrRegion.width*g,m=this.qrRegion.height*x,E=this.qrRegion.x*g,C=this.qrRegion.y*x;this.context.drawImage(f,E,C,y,m,0,0,this.qrRegion.width,this.qrRegion.height);var P=function(){u.foreverScanTimeout=setTimeout(function(){u.foreverScan(r,o,l)},u.getTimeoutFps(r.fps))};this.scanContext(o,l).then(function(O){!O&&r.disableFlip!==!0?(u.context.translate(u.context.canvas.width,0),u.context.scale(-1,1),u.scanContext(o,l).finally(function(){P()})):P()}).catch(function(O){u.logger.logError("Error happend while scanning context",O),P()})}},t.prototype.createVideoConstraints=function(r){if(typeof r=="string")return{deviceId:{exact:r}};if(typeof r=="object"){var o="facingMode",l="deviceId",u={user:!0,environment:!0},f="exact",g=function(D){if(D in u)return!0;throw"config has invalid 'facingMode' value = "+"'".concat(D,"'")},x=Object.keys(r);if(x.length!==1)throw"'cameraIdOrConfig' object should have exactly 1 key,"+" if passed as an object, found ".concat(x.length," keys");var y=Object.keys(r)[0];if(y!==o&&y!==l)throw"Only '".concat(o,"' and '").concat(l,"' ")+" are supported for 'cameraIdOrConfig'";if(y===o){var m=r.facingMode;if(typeof m=="string"){if(g(m))return{facingMode:m}}else if(typeof m=="object")if(f in m){if(g(m["".concat(f)]))return{facingMode:{exact:m["".concat(f)]}}}else throw"'facingMode' should be string or object with"+" ".concat(f," as key.");else{var E=typeof m;throw"Invalid type of 'facingMode' = ".concat(E)}}else{var C=r.deviceId;if(typeof C=="string")return{deviceId:C};if(typeof C=="object"){if(f in C)return{deviceId:{exact:C["".concat(f)]}};throw"'deviceId' should be string or object with"+" ".concat(f," as key.")}else{var P=typeof C;throw"Invalid type of 'deviceId' = ".concat(P)}}}var O=typeof r;throw"Invalid type of 'cameraIdOrConfig' = ".concat(O)},t.prototype.computeCanvasDrawConfig=function(r,o,l,u){if(r<=l&&o<=u){var f=(l-r)/2,g=(u-o)/2;return{x:f,y:g,width:r,height:o}}else{var x=r,y=o;return r>l&&(o=l/r*o,r=l),o>u&&(r=u/o*r,o=u),this.logger.log("Image downsampled from "+"".concat(x,"X").concat(y)+" to ".concat(r,"X").concat(o,".")),this.computeCanvasDrawConfig(r,o,l,u)}},t.prototype.clearElement=function(){if(this.stateManagerProxy.isScanning())throw"Cannot clear while scan is ongoing, close it first.";var r=document.getElementById(this.elementId);r&&(r.innerHTML="")},t.prototype.possiblyUpdateShaders=function(r){this.qrMatch!==r&&(this.hasBorderShaders&&this.borderShaders&&this.borderShaders.length&&this.borderShaders.forEach(function(o){o.style.backgroundColor=r?rn.BORDER_SHADER_MATCH_COLOR:rn.BORDER_SHADER_DEFAULT_COLOR}),this.qrMatch=r)},t.prototype.possiblyCloseLastScanImageFile=function(){this.lastScanImageFile&&(URL.revokeObjectURL(this.lastScanImageFile),this.lastScanImageFile=null)},t.prototype.createCanvasElement=function(r,o,l){var u=r,f=o,g=document.createElement("canvas");return g.style.width="".concat(u,"px"),g.style.height="".concat(f,"px"),g.style.display="none",g.id=Pn(l)?"qr-canvas":l,g},t.prototype.getShadedRegionBounds=function(r,o,l){if(l.width>r||l.height>o)throw"'config.qrbox' dimensions should not be greater than the dimensions of the root HTML element.";return{x:(r-l.width)/2,y:(o-l.height)/2,width:l.width,height:l.height}},t.prototype.possiblyInsertShadingElement=function(r,o,l,u){if(!(o-u.width<1||l-u.height<1)){var f=document.createElement("div");f.style.position="absolute";var g=(o-u.width)/2,x=(l-u.height)/2;if(f.style.borderLeft="".concat(g,"px solid rgba(0, 0, 0, 0.48)"),f.style.borderRight="".concat(g,"px solid rgba(0, 0, 0, 0.48)"),f.style.borderTop="".concat(x,"px solid rgba(0, 0, 0, 0.48)"),f.style.borderBottom="".concat(x,"px solid rgba(0, 0, 0, 0.48)"),f.style.boxSizing="border-box",f.style.top="0px",f.style.bottom="0px",f.style.left="0px",f.style.right="0px",f.id="".concat(rn.SHADED_REGION_ELEMENT_ID),o-u.width<11||l-u.height<11)this.hasBorderShaders=!1;else{var y=5,m=40;this.insertShaderBorders(f,m,y,-y,null,0,!0),this.insertShaderBorders(f,m,y,-y,null,0,!1),this.insertShaderBorders(f,m,y,null,-y,0,!0),this.insertShaderBorders(f,m,y,null,-y,0,!1),this.insertShaderBorders(f,y,m+y,-y,null,-y,!0),this.insertShaderBorders(f,y,m+y,null,-y,-y,!0),this.insertShaderBorders(f,y,m+y,-y,null,-y,!1),this.insertShaderBorders(f,y,m+y,null,-y,-y,!1),this.hasBorderShaders=!0}r.append(f)}},t.prototype.insertShaderBorders=function(r,o,l,u,f,g,x){var y=document.createElement("div");y.style.position="absolute",y.style.backgroundColor=rn.BORDER_SHADER_DEFAULT_COLOR,y.style.width="".concat(o,"px"),y.style.height="".concat(l,"px"),u!==null&&(y.style.top="".concat(u,"px")),f!==null&&(y.style.bottom="".concat(f,"px")),x?y.style.left="".concat(g,"px"):y.style.right="".concat(g,"px"),this.borderShaders||(this.borderShaders=[]),this.borderShaders.push(y),r.appendChild(y)},t.prototype.showPausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="block"},t.prototype.hidePausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="none"},t.prototype.getTimeoutFps=function(r){return 1e3/r},t})(),Al;(function(t){t[t.STATUS_DEFAULT=0]="STATUS_DEFAULT",t[t.STATUS_SUCCESS=1]="STATUS_SUCCESS",t[t.STATUS_WARNING=2]="STATUS_WARNING",t[t.STATUS_REQUESTING_PERMISSION=3]="STATUS_REQUESTING_PERMISSION"})(Al||(Al={}));const wy={class:"scan-code"},yy={class:"btn"},_y={class:"left-back"},vy=_.defineComponent({name:"QrCodeScan",__name:"QrCodeScan",emits:["scanSuccess"],setup(t,{emit:r}){const o=r,l=z1.IconScan(),u=_.reactive({html5QrCode:null}),f=_.ref(!1),g=()=>{if(!u.html5QrCode){dt("摄像头无访问权限!");return}f.value=!0,u.html5QrCode.start({facingMode:"environment"},{fps:30,aspectRatio:1,supportedScanTypes:[ei.SCAN_TYPE_CAMERA],showTorchButtonIfSupported:!0,showZoomSliderIfSupported:!0,defaultZoomValueIfSupported:2,useBarCodeDetectorIfSupported:!0},C=>{try{const O=new URL(C).searchParams.get("sessionId");O?o("scanSuccess",O):dt("无效的二维码")}catch{dt("无效的二维码")}E()}).catch(C=>{console.log(C),dt({message:"二维码识别失败",duration:3e3})})},x=()=>{m().then(()=>{g()})},y=()=>{E()},m=()=>El.getCameras().then(C=>{C&&C.length&&(u.html5QrCode=new El("reader"))}).catch(()=>{dt({message:"摄像头无访问权限!",duration:3e3})}),E=()=>{u.html5QrCode&&u.html5QrCode.stop().then(C=>{console.log("停止扫码",C)}).catch(C=>{console.log(C),dt("停止扫码失败")}).finally(()=>{f.value=!1})};return _.onUnmounted(()=>{u.html5QrCode&&u.html5QrCode.isScanning&&E()}),(C,P)=>{const O=Ki;return _.openBlock(),_.createElementBlock("div",null,[_.createVNode(_.unref(Gt.TrIconButton),{icon:_.unref(l),size:"28",svgSize:"20",onClick:P[0]||(P[0]=D=>x())},null,8,["icon"]),(_.openBlock(),_.createBlock(_.Teleport,{to:"body"},[_.withDirectives(_.createElementVNode("div",wy,[P[1]||(P[1]=_.createElementVNode("div",{class:"container"},[_.createElementVNode("div",{class:"qrcode"},[_.createElementVNode("div",{id:"reader"})])],-1)),_.createElementVNode("div",yy,[_.createElementVNode("div",_y,[_.createVNode(O,{name:"arrow-left",onClick:y})])])],512),[[_.vShow,f.value]])]))])}}}),Ir=(t,r)=>{const o=t.__vccOpts||t;for(const[l,u]of r)o[l]=u;return o},by=Ir(vy,[["__scopeId","data-v-2d988579"]]);function ms(t,r,o){const l=_.computed(()=>t?Array.isArray(t)?t:t.value:[]),u=()=>{const E=l.value;if(E.length===0)return"";if(r){const P=typeof r=="string"?r:r.value;if(P&&E.some(O=>O.id===P))return P}const C=E.find(P=>P.isDefault);return C?C.id:E[0].id};let f,g=!1;if(r&&typeof r!="string")f=r,g=!0,(!f.value||!l.value.some(E=>E.id===f.value))&&(f.value=u());else{let E;r&&typeof r=="string"&&(E=r),f=_.ref(E&&l.value.some(C=>C.id===E)?E:u())}(!g||o)&&_.watch(f,E=>{o&&o(E)});const x=_.computed(()=>l.value.find(E=>E.id===f.value)),y=_.computed(()=>l.value);return{selectedModelId:f,selectedModel:x,availableModels:y,setSelectedModel:E=>{l.value.find(P=>P.id===E)?f.value=E:console.warn(`[useModel] Model not found: ${E}`)}}}const Cy=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Ey=Object.prototype.toString,Ay=t=>Ey.call(t)==="[object Object]",Oi=()=>{};function ko(t){return Array.isArray(t)?t:[t]}function Iy(t,r,o){return _.watch(t,r,{...o,immediate:!0})}const l1=Cy?window:void 0;function Zr(t){var r;const o=_.toValue(t);return(r=o?.$el)!==null&&r!==void 0?r:o}function Ro(...t){const r=(l,u,f,g)=>(l.addEventListener(u,f,g),()=>l.removeEventListener(u,f,g)),o=_.computed(()=>{const l=ko(_.toValue(t[0])).filter(u=>u!=null);return l.every(u=>typeof u!="string")?l:void 0});return Iy(()=>{var l,u;return[(l=(u=o.value)===null||u===void 0?void 0:u.map(f=>Zr(f)))!==null&&l!==void 0?l:[l1].filter(f=>f!=null),ko(_.toValue(o.value?t[1]:t[0])),ko(_.unref(o.value?t[2]:t[1])),_.toValue(o.value?t[3]:t[2])]},([l,u,f,g],x,y)=>{if(!l?.length||!u?.length||!f?.length)return;const m=Ay(g)?{...g}:g,E=l.flatMap(C=>u.flatMap(P=>f.map(O=>r(C,P,O,m))));y(()=>{E.forEach(C=>C())})},{flush:"post"})}function Sy(t,r,o={}){const{window:l=l1,ignore:u=[],capture:f=!0,detectIframe:g=!1,controls:x=!1}=o;if(!l)return x?{stop:Oi,cancel:Oi,trigger:Oi}:Oi;let y=!0;const m=M=>_.toValue(u).some(V=>{if(typeof V=="string")return Array.from(l.document.querySelectorAll(V)).some(U=>U===M.target||M.composedPath().includes(U));{const U=Zr(V);return U&&(M.target===U||M.composedPath().includes(U))}});function E(M){const V=_.toValue(M);return V&&V.$.subTree.shapeFlag===16}function C(M,V){const U=_.toValue(M),k=U.$.subTree&&U.$.subTree.children;return k==null||!Array.isArray(k)?!1:k.some(J=>J.el===V.target||V.composedPath().includes(J.el))}const P=M=>{const V=Zr(t);if(M.target!=null&&!(!(V instanceof Element)&&E(t)&&C(t,M))&&!(!V||V===M.target||M.composedPath().includes(V))){if("detail"in M&&M.detail===0&&(y=!m(M)),!y){y=!0;return}r(M)}};let O=!1;const D=[Ro(l,"click",M=>{O||(O=!0,setTimeout(()=>{O=!1},0),P(M))},{passive:!0,capture:f}),Ro(l,"pointerdown",M=>{const V=Zr(t);y=!m(M)&&!!(V&&!M.composedPath().includes(V))},{passive:!0}),g&&Ro(l,"blur",M=>{setTimeout(()=>{var V;const U=Zr(t);((V=l.document.activeElement)===null||V===void 0?void 0:V.tagName)==="IFRAME"&&!U?.contains(l.document.activeElement)&&r(M)},0)},{passive:!0})].filter(Boolean),R=()=>D.forEach(M=>M());return x?{stop:R,cancel:()=>{y=!1},trigger:M=>{y=!0,P(M),y=!1}}:R}const Ty=["data-active","disabled"],Ny=_.defineComponent({__name:"Button",props:{active:{type:Boolean},rounded:{type:Boolean},size:{default:"medium"},disabled:{type:Boolean}},setup(t){return(r,o)=>(_.openBlock(),_.createElementBlock("button",{class:_.normalizeClass(["button",{rounded:t.rounded,[t.size]:!0}]),"data-active":t.active||void 0,disabled:t.disabled||void 0},[_.renderSlot(r.$slots,"default",{},void 0,!0)],10,Ty))}}),xs=Ir(Ny,[["__scopeId","data-v-6f582cce"]]),Oy={viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",fill:"none"};function ky(t,r){return _.openBlock(),_.createElementBlock("svg",Oy,[...r[0]||(r[0]=[_.createElementVNode("rect",{id:"大模型",width:"16.000000",height:"16.000000",x:"0.000000",y:"0.000000"},null,-1),_.createElementVNode("path",{id:"矢量 90",d:"M13.683 2.26904C12.5753 1.16177 10.344 1.47577 8.02582 2.86527C5.70758 1.47576 3.47637 1.16179 2.36913 2.26904C1.2619 3.37646 1.57573 5.60771 2.96524 7.92589C1.57573 10.2441 1.2619 12.4754 2.36913 13.5827C3.47637 14.6901 5.7078 14.3762 8.02599 12.9867C10.344 14.3762 12.5752 14.6901 13.6825 13.5827C14.7901 12.4754 14.4761 10.2441 13.0866 7.92594C14.4761 5.60775 14.7902 3.37646 13.683 2.26904ZM10.8544 5.09764C11.4667 5.70995 12.0076 6.34819 12.4699 6.99044C12.7244 6.52061 12.9268 6.06037 13.077 5.60959C13.2948 4.95652 13.3832 4.38597 13.3426 3.89769C13.3089 3.49437 13.1869 3.18725 12.9754 2.97631C12.7645 2.76513 12.4574 2.64282 12.0541 2.60912C11.5658 2.56835 10.9955 2.65698 10.3422 2.87475C9.89153 3.02497 9.43121 3.22735 8.96135 3.48197C9.60365 3.94428 10.242 4.48527 10.8544 5.09764ZM5.70991 2.87475C6.16049 3.02494 6.62073 3.22729 7.09051 3.48185C6.44826 3.94412 5.81002 4.48507 5.19771 5.09739C4.58523 5.70982 4.04417 6.34819 3.58181 6.99055C3.32716 6.52071 3.1248 6.06037 2.97459 5.60959C2.75682 4.95677 2.66844 4.38597 2.70897 3.89769C2.74266 3.49437 2.86522 3.18725 3.07615 2.97631C3.28709 2.76513 3.59421 2.64282 3.99753 2.60912C4.4858 2.5686 5.0566 2.65698 5.70991 2.87475ZM5.90473 5.80466Q4.89236 6.81738 4.14938 7.92595C4.64428 8.66515 5.2294 9.3722 5.90473 10.0473C6.57966 10.7222 7.28696 11.3074 8.02584 11.8027C8.76507 11.3074 9.47197 10.7222 10.1474 10.0473C10.8222 9.37218 11.4074 8.66511 11.9027 7.92588Q11.1597 6.81736 10.1474 5.80466C9.47203 5.12956 8.7652 4.54447 8.02604 4.04937C7.28683 4.54447 6.5796 5.12956 5.90473 5.80466ZM7.99992 6.90011C7.44768 6.90011 6.99993 7.34787 6.99993 7.90011C6.99993 8.45235 7.44768 8.9001 7.99992 8.9001C8.55216 8.9001 8.99991 8.45235 8.99991 7.90011C8.99991 7.34787 8.55216 6.90011 7.99992 6.90011ZM10.3422 12.9772C9.89161 12.827 9.43138 12.6246 8.96148 12.37C9.60377 11.9077 10.242 11.3667 10.8544 10.7543C11.4667 10.142 12.0077 9.50369 12.4699 8.8614C12.7245 9.33127 12.9268 9.79154 13.077 10.2421C13.2948 10.8952 13.3832 11.4658 13.3426 11.954C13.3089 12.3574 13.1864 12.6647 12.9754 12.8757C12.7645 13.0866 12.4574 13.2089 12.0541 13.2426C11.5658 13.2834 10.995 13.195 10.3422 12.9772ZM2.97459 10.2421C3.12478 9.7914 3.32733 9.3312 3.58196 8.86141C4.04428 9.50369 4.5853 10.142 5.19771 10.7543C5.81003 11.3667 6.44827 11.9077 7.09052 12.37C6.62074 12.6246 6.16049 12.827 5.70991 12.9772C5.0566 13.195 4.48629 13.2834 3.99802 13.2426C3.5947 13.2089 3.28709 13.0866 3.07615 12.8757C2.86522 12.6647 2.74315 12.3574 2.70946 11.954C2.66844 11.4658 2.75682 10.8952 2.97459 10.2421Z",fill:"rgb(89,89,89)","fill-rule":"evenodd"},null,-1)])])}const Ry={render:ky},Dy={class:"button-text"},My={class:"dropdown-menu__items"},Py=["onClick"],By=_.defineComponent({__name:"ModelSwitch",props:_.mergeModels({modelConfigs:{}},{selectedModelId:{type:String,default:void 0,required:!1},selectedModelIdModifiers:{}}),emits:["update:selectedModelId"],setup(t){const r=t,o=_.useModel(t,"selectedModelId"),l=r.modelConfigs?Array.isArray(r.modelConfigs)?_.shallowRef(r.modelConfigs):r.modelConfigs:void 0,{selectedModel:u,availableModels:f,setSelectedModel:g}=ms(l,o),x=_.ref(!1),y=O=>{g(O),E()},m=()=>{x.value=!x.value},E=()=>{x.value=!1},C=_.ref(null),P=_.ref(null);return Sy(P,()=>{E()},{ignore:[C]}),(O,D)=>(_.openBlock(),_.createElementBlock("div",{class:"model-switch-wrapper",ref_key:"wrapperRef",ref:C},[_.createVNode(xs,{size:"small",class:"action-button",rounded:"",onClick:m},{default:_.withCtx(()=>[(_.openBlock(),_.createBlock(_.resolveDynamicComponent(_.unref(u)?.icon),{width:16,height:16,class:"selected-model__icon"})),_.createElementVNode("span",Dy,_.toDisplayString(_.unref(u)?.label),1),_.createVNode(_.unref(Ry),{width:16,height:16})]),_:1}),_.createVNode(_.Transition,{name:"dropdown"},{default:_.withCtx(()=>[x.value?(_.openBlock(),_.createElementBlock("div",{key:0,class:"dropdown-menu",ref_key:"dropdownMenuRef",ref:P},[_.createElementVNode("div",My,[(_.openBlock(!0),_.createElementBlock(_.Fragment,null,_.renderList(_.unref(f),R=>(_.openBlock(),_.createElementBlock("div",{key:R.id,class:_.normalizeClass(["dropdown-menu__item",{"active-menu":R.id===o.value}]),onClick:_.withModifiers(M=>y(R.id),["stop"])},[R.icon?(_.openBlock(),_.createBlock(_.resolveDynamicComponent(R.icon),{key:0,width:16,height:16,class:"dropdown-menu__icon"})):_.createCommentVNode("",!0),_.createElementVNode("span",null,_.toDisplayString(R.label),1)],10,Py))),128))])],512)):_.createCommentVNode("",!0)]),_:1}),x.value?(_.openBlock(),_.createElementBlock("div",{key:0,class:"dropdown-overlay",onClick:E})):_.createCommentVNode("",!0)],512))}}),Ly=Ir(By,[["__scopeId","data-v-cee7e07b"]]),Fy={key:0,class:"active-count"},$y=_.defineComponent({__name:"PluginToggleButton",props:{installedPlugins:{}},emits:["click"],setup(t){const r=t,o=_.computed(()=>r.installedPlugins.filter(l=>l.enabled).length);return(l,u)=>(_.openBlock(),_.createBlock(xs,{size:"small",class:"action-button",active:o.value>0,rounded:"",onClick:u[0]||(u[0]=f=>l.$emit("click"))},{default:_.withCtx(()=>[_.createVNode(_.unref(Di.IconPlugin),{class:"icon",style:{"font-size":"16px"}}),u[1]||(u[1]=_.createElementVNode("span",{class:"button-text"},"扩展",-1)),o.value>0?(_.openBlock(),_.createElementBlock("span",Fy,_.toDisplayString(o.value),1)):_.createCommentVNode("",!0)]),_:1},8,["active"]))}}),Uy=Ir($y,[["__scopeId","data-v-c2a16c66"]]),Ur="https://agent.opentiny.design",zy=[{id:"12306-mcp",name:"12306服务器",description:"12306购票搜索服务器",icon:"https://agent.opentiny.design/public-assets/icons/icon-12306.webp",enabled:!1,addState:"idle",tools:[],url:Ur+"/api/v1/mcp-server/12306/mcp",type:"StreamableHTTP"},{id:"markdown2pdf-mcp",name:"Markdown转PDF MCP服务器",description:"Markdown转PDF MCP服务器,可以将Markdown文件转换为PDF文件",icon:"https://agent.opentiny.design/public-assets/icons/icon-pdf.png",url:Ur+"/servers/markdown2pdf-mcp/sse",type:"sse",enabled:!1,addState:"idle",tools:[]},{id:"docx-mcp",name:"Word文档MCP服务器",description:"Word文档MCP服务器,可以创建、编辑、保存Word文档",icon:"https://agent.opentiny.design/public-assets/icons/icon-word.png",url:Ur+"/servers/excel-mcp/sse",type:"sse",enabled:!1,addState:"idle",tools:[]},{id:"excel-mcp",name:"Excel文档MCP服务器",description:"Excel文档MCP服务器,可以创建、编辑、保存Excel文档",icon:"https://agent.opentiny.design/public-assets/icons/icon-excel.png",url:Ur+"/servers/excel-mcp/mcp",type:"StreamableHTTP",enabled:!1,addState:"idle",tools:[]},{id:"doc-tools-mcp",name:"文档工具MCP服务器",description:"文档工具MCP服务器,可以创建、编辑、保存文档",icon:"https://agent.opentiny.design/public-assets/icons/icon-doc.png",url:Ur+"/servers/doc-tools-mcp/sse",type:"sse",enabled:!1,addState:"idle",tools:[]}],Vy=`
98
98
  <svg width="1em" height="1em" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
99
99
  <defs>
100
100
  <clipPath id="clip657_188316">
@@ -107,4 +107,4 @@ ${fe}`:fe;m.systemPrompt=se}else m.systemPrompt=o},te=async(ne,S,fe)=>{if(S&&S.l
107
107
  <path id="path" d="M1.25 9.97C1.25 9.63 1.53 9.35 1.87 9.35L4.37 9.35C4.72 9.35 5 9.63 5 9.97C5 10.32 4.72 10.6 4.37 10.6L1.87 10.6C1.53 10.6 1.25 10.32 1.25 9.97ZM12.5 6.25C12.5 5.9 12.78 5.62 13.12 5.62L17.46 5.62C17.8 5.62 18.08 5.9 18.08 6.25C18.08 6.59 17.8 6.87 17.46 6.87L13.12 6.87C12.78 6.87 12.5 6.59 12.5 6.25ZM12.5 13.73C12.5 13.39 12.78 13.11 13.12 13.11L17.46 13.11C17.8 13.11 18.08 13.39 18.08 13.73C18.08 14.08 17.8 14.36 17.46 14.36L13.12 14.36C12.78 14.36 12.5 14.08 12.5 13.73Z" fill="currentColor" fill-opacity="1" fill-rule="nonzero"></path>
108
108
  </g>
109
109
  </svg>
110
- `,s4=btoa(o4),Ml=`data:image/svg+xml;base64,${s4}`,Uo=(t,n)=>{const[o,l]=t.split("#");return{id:n,text:o,inputMessage:l}},a4=t=>{const n={"zh-CN":{title:"OpenTiny NEXT",description:"我是你的私人智能助手",placeholder:"请输入您的问题",thinking:"正在思考中..."},"en-US":{title:"OpenTiny NEXT",description:"I am your private AI assistant",placeholder:"Please enter your question",thinking:"Thinking..."}},o=[{id:"office",text:t.locale==="zh-CN"?"办公助手":"Office Assistant",menus:["接收邮件#请同步邮箱的新邮件。","编写邮件#请新建一个邮件,收件人为 opentiny-next@meeting.com, 内容为举办一个临时会议。","安排会议#创建一个临时的在线会议,主题为讨论问题,时长为1小时。","整理文档#请分析附件中的销售情况,把销售额绘制成折线图。"].map(Uo)},{id:"development",text:t.locale==="zh-CN"?"开发支持":"Development Support",menus:["遇到代码问题#请检查当前位置的报错原因。","架构建议#请使用NodeJs实现一个分块上传文件的模块。","最新的技术趋势#请分析Vue与React 框架的优劣分别是什么?"].map(Uo)},{id:"management",text:t.locale==="zh-CN"?"项目管理":"Project Management",menus:["项目规划#如何开展品牌推广的活动?","任务分配#将本季度的销售任务分配给三个人,并生成甘特图进行跟踪。","进度跟踪#分析团队的任务完成情况。"].map(Uo)}],l=[{label:t.locale==="zh-CN"?"企业办公助手":"Enterprise Office Assistant",description:t.locale==="zh-CN"?"需要我帮你处理邮件、安排会议、整理文档,还是优化工作流程?":"Need help with emails, meeting scheduling, document organization, or workflow optimization?",icon:C.h("span",{style:{fontSize:"18px"}},"🧠"),badge:"NEW"},{label:t.locale==="zh-CN"?"开发技术支持":"Development Support",description:t.locale==="zh-CN"?"遇到代码问题?需要架构建议?还是想了解最新的技术趋势?":"Facing code issues? Need architecture advice? Or want to learn about latest tech trends?",icon:C.h("span",{style:{fontSize:"18px"}},"💻")},{label:t.locale==="zh-CN"?"项目管理协作":"Project Management",description:t.locale==="zh-CN"?"需要项目规划、任务分配、进度跟踪,还是团队协作建议?":"Need project planning, task assignment, progress tracking, or team collaboration advice?",icon:C.h("span",{style:{fontSize:"18px"}},"📊")}];return{lang:n,pillItems:o,promptItems:l}},Pl={"No client found for session ID":"受控端页面已关闭请重新打开或者刷新页面","Failed to create MCP client":"创建MCP客户端失败"},l4=t=>{console.log("message",t);const n=Object.keys(Pl),o=n.findIndex(u=>t.includes(u));return(o!==-1?Pl[n[o]]:t)||t},c4={"data-v-99394ae9":"",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",width:"16.000000",height:"16.000000",fill:"none",customFrame:"#000000",size:"16"};function u4(t,n){return C.openBlock(),C.createElementBlock("svg",c4,[...n[0]||(n[0]=[C.createElementVNode("rect",{id:"生成式UI",width:"16.000000",height:"16.000000",x:"0.000000",y:"0.000000",fill:"currentColor","fill-opacity":"0"},null,-1),C.createElementVNode("path",{id:"矢量 154",d:"M7.41014 2.09741L7.67112 2.70606C7.68333 2.73438 7.70579 2.75684 7.73411 2.76905L8.34275 3.02979C8.43968 3.0713 8.43968 3.20875 8.34275 3.25025L7.73411 3.51124C7.70579 3.52345 7.68333 3.54591 7.67112 3.57423L7.41014 4.18288C7.36863 4.2798 7.23118 4.2798 7.18968 4.18288L6.92894 3.57423C6.91673 3.54591 6.89427 3.52345 6.86595 3.51124L6.25731 3.25025C6.16039 3.20875 6.16039 3.0713 6.25731 3.02979L6.86595 2.76905C6.89427 2.75684 6.91673 2.73438 6.92894 2.70606L7.18968 2.09741C7.23118 2.00049 7.36863 2.00049 7.41014 2.09741ZM4.57006 11.9625L7.27611 8.09746L9.69944 4.63674L10.592 3.36207C10.6899 3.22218 10.8017 3.09864 10.9272 2.99122C11.0529 2.88404 11.1926 2.79297 11.3459 2.71802C11.4992 2.64332 11.657 2.58936 11.8191 2.5564C11.9809 2.52369 12.1472 2.51172 12.3176 2.52051C12.5315 2.53174 12.7336 2.57373 12.9238 2.64649C13.0678 2.70118 13.205 2.77369 13.3354 2.86353C13.4651 2.95289 13.5813 3.05445 13.6836 3.16822C13.8064 3.3047 13.9094 3.45851 13.9929 3.6299C14.0766 3.80128 14.1342 3.97731 14.1662 4.15773C14.1928 4.30861 14.2014 4.46267 14.1919 4.61989C14.1823 4.7781 14.1547 4.93069 14.1096 5.07791C14.0495 5.27249 13.958 5.45755 13.8352 5.63309L7.81321 14.2335Q7.66985 14.4382 7.48649 14.5965Q7.4825 14.6 7.4785 14.6034Q7.29063 14.7641 7.06102 14.8766C6.90794 14.9513 6.75072 15.0052 6.5891 15.0384C6.42748 15.0714 6.2617 15.0836 6.09154 15.0751C5.87743 15.0643 5.67504 15.0226 5.48436 14.9503C5.34008 14.8956 5.20287 14.8233 5.07201 14.7335C4.94213 14.6444 4.82592 14.5428 4.72313 14.4291C4.60033 14.2928 4.49682 14.1388 4.41308 13.9674C4.32934 13.7958 4.27123 13.6197 4.23925 13.4391C4.21239 13.2882 4.20385 13.1339 4.21313 12.9767C4.22265 12.8184 4.24999 12.6656 4.2954 12.5184C4.35546 12.3233 4.44701 12.138 4.57006 11.9625ZM4.7185 4.67361L4.18383 3.42579C4.11449 3.26441 3.88549 3.26441 3.81616 3.42579L3.28149 4.67361C3.26123 4.72073 3.22363 4.75832 3.17651 4.77859L1.92871 5.31326C1.76733 5.3826 1.76733 5.6116 1.92871 5.68094L3.17651 6.21561C3.22363 6.23587 3.26123 6.27347 3.28149 6.32059L3.81616 7.56841C3.88549 7.73003 4.11449 7.73003 4.18383 7.56841L4.7185 6.32059C4.73876 6.27347 4.77636 6.23587 4.82348 6.21561L6.07128 5.68094C6.23265 5.6116 6.23265 5.3826 6.07128 5.31326L4.82348 4.77859C4.77636 4.75832 4.73876 4.72073 4.7185 4.67361ZM5.38915 12.536C5.32006 12.6346 5.27099 12.7384 5.24169 12.8475C5.22533 12.9088 5.21532 12.9718 5.21141 13.0362C5.20726 13.1063 5.21044 13.1751 5.22094 13.2428C5.23583 13.3402 5.2661 13.4354 5.31151 13.5282C5.35692 13.6209 5.41332 13.7032 5.48095 13.775C5.52806 13.8248 5.58031 13.8695 5.63817 13.9093C5.69139 13.9459 5.7473 13.9764 5.80565 14.0011C5.9099 14.0453 6.02196 14.0702 6.14208 14.0763C6.2263 14.0807 6.30834 14.0746 6.38841 14.0582C6.46825 14.0418 6.54613 14.015 6.62181 13.9781C6.69749 13.941 6.76634 13.8961 6.8286 13.8429C6.89061 13.7899 6.94578 13.7289 6.99412 13.6598L11.9415 6.59405L10.3381 5.46789L5.38915 12.536ZM10.9168 4.6415L12.5202 5.76762L13.0161 5.05935C13.0849 4.96096 13.134 4.85745 13.1633 4.74831C13.1797 4.68703 13.1897 4.62429 13.1936 4.55959C13.198 4.48977 13.1948 4.42092 13.1843 4.35329C13.1694 4.25588 13.1394 4.16091 13.0942 4.06813C13.0488 3.97536 12.9926 3.89308 12.925 3.8213C12.8781 3.7715 12.8259 3.72682 12.7683 3.68703C12.7148 3.6504 12.6591 3.61964 12.6008 3.59474C12.4968 3.55079 12.385 3.5254 12.2651 3.5193C12.1806 3.51466 12.0984 3.52076 12.0183 3.53688C11.9382 3.55324 11.8601 3.57985 11.7841 3.61696C11.7082 3.65407 11.6391 3.69899 11.5771 3.75221C11.5149 3.80519 11.4594 3.86647 11.4111 3.93556L10.9168 4.6415Z",fill:"currentColor","fill-rule":"evenodd"},null,-1)])])}const d4={render:u4},f4={class:"tr-container__title"},h4={style:{flex:"1"}},p4={class:"chat-input"},g4={class:"chat-input-pills"},m4={class:"action-buttons"},x4=C.defineComponent({name:"TinyRemoter",__name:"tiny-robot-chat",props:C.mergeModels({sessionId:{type:String,default:""},agentRoot:{type:String,default:"https://agent.opentiny.design/api/v1/webmcp-trial/"},systemPrompt:{type:String,default:"你是一个智能生活助手,擅长通过工具调用帮助用户完成任务"},title:{type:String,default:"OpenTiny NEXT"},locale:{type:String,default:"zh-CN"},remoteUrl:{type:String},menuItems:{type:Array,default:()=>[]},qrCodeUrl:{type:String},mode:{type:String,default:"remoter"},llmConfig:{type:Object,default:void 0},inBrowserExt:{type:Boolean,default:!1},genUiAble:{type:Boolean,default:!1},genUiComponents:{type:Object,default:()=>({})},customMarketMcpServers:{type:Array,default:()=>[]},skills:{type:Object,default:()=>[]}},{fullscreen:{type:Boolean,default:!1},fullscreenModifiers:{},show:{type:Boolean,default:!1},showModifiers:{}}),emits:["update:fullscreen","update:show"],setup(t,{expose:n}){const o=t,l=C.useModel(t,"fullscreen"),u=C.useModel(t,"show"),f=()=>{try{const ue=mn.getItem(gn.GENUI_ENABLED);if(ue!==null)return ue}catch(ue){console.warn("[tiny-robot-chat] Failed to parse stored genui enabled:",ue)}const be=o.genUiAble;try{mn.setItem(gn.GENUI_ENABLED,be)}catch(ue){console.error("[tiny-robot-chat] Failed to save genui enabled to storage:",ue)}return be},g=C.ref(f());o.inBrowserExt&&C.watch(g,be=>{try{mn.setItem(gn.GENUI_ENABLED,be)}catch(ue){console.error("[tiny-robot-chat] Failed to save genui enabled to storage:",ue)}});const{showHistory:m,agent:y,customAgentProvider:x,welcomeIcon:A,conversationState:b,messages:P,messageState:N,inputMessage:R,abortRequest:D,roles:M,senderRef:z,sendMessage:U,handleSendMessage:k,handleHistoryUpdateTitle:K,handleHistoryDelete:ve,handleHistorySelect:Q,handleCreateConversation:j,addMessage:ie,send:Y}=oy({sessionId:C.toRef(o,"sessionId"),agentRoot:C.toRef(o,"agentRoot"),systemPrompt:o.systemPrompt||"",llmConfig:o.llmConfig,inBrowserExt:C.toRef(o,"inBrowserExt"),skills:o.skills||[],isGenuiEnabled:g}),{selectedModel:Ie}=to();o.inBrowserExt&&C.watch(g,()=>{Ie.value&&x.updateLLMConfig({modelId:Ie.value.id,apiUrl:Ie.value.apiUrl,apiKey:Ie.value.apiKey,providerType:Ie.value.providerType,useReActMode:Ie.value.useReActMode})});const Ce={markdown:new Gt.BubbleMarkdownContentRenderer({mdConfig:{html:!0}}),"schema-card":be=>C.h(Y1.SchemaRenderer,{...be,onAction:({llmFriendlyMessage:ue,humanFriendlyMessage:De})=>{ie({role:"user",content:ue,uiContent:[{type:"text",content:De}]}),Y()},generating:dr.GeneratingStatus.includes(N.status),customComponents:o.genUiComponents,requiredCompleteFieldSelectors:["[componentName=TinyUser] > props > modelValue"]})},he=C.ref(!1),xe=C.ref([]),le=C.ref([...i4,...o.customMarketMcpServers]),F=C.ref([{value:"",label:"全部分类"},{value:"productivity",label:"生产力工具"},{value:"communication",label:"沟通协作"},{value:"development",label:"开发工具"},{value:"ai",label:"AI 助手"}]),{lang:J,pillItems:X,promptItems:te}=a4(o),pe=async be=>{const De=`plugin-${be.replace("mcp-server-","")}`,Ue=xe.value.find(Oe=>Oe.id===De);if(await y.removeMcpServer(be),Ue){xe.value=xe.value.filter(ke=>ke.id!==De);const Oe=le.value.find(ke=>ke.id===De);Oe&&(Oe.addState="idle"),ht(`工具 "${Ue.name}" 已断开连接`)}},ge=async be=>{if(f1("添加工具中..."),be){const ue={type:"streamableHttp",url:`${o.agentRoot}mcp?sessionId=${be}`},De=`mcp-server-${be}`;await y.insertMcpServer(De,ue)?(await ne(De,ue),await y.closeAll(),ht("添加工具完成")):ht("重复添加工具")}else ht("添加工具失败")},ye=async(be,ue)=>{const De=R.value;if(/^\/[A-Za-z0-9-]{6,}$/.test(De)){const Oe=(await fetch(`${o.agentRoot}client?sessionId=${De.slice(1)}`).then(ke=>ke.json()))?.data?.sessionId;Oe?await ge(Oe):ht("添加工具失败,请检查识别码是否正确"),R.value=""}else await k(be,ue)},we=C.computed(()=>dr.GeneratingStatus.includes(N.status)?J[o.locale].thinking:J[o.locale].placeholder),Fe=C.computed(()=>dr.GeneratingStatus.includes(N.status)),Pe=be=>{R.value=be.inputMessage},ne=async(be,ue)=>{const De=mn.getItem(gn.LOCAL_TOOL_STORAGE)||{},Ue=be==="mcp-server-localhost",Oe=Ue?{origin:"本地工具"}:new URL("url"in ue?ue.url:""),ke=Ue?"本地工具列表":Oe.searchParams.get("sessionId")||("sessionId"in ue?ue.sessionId:"")||"",cn=y.mcpTools[be];if(cn){let Se=[];Se=Object.keys(cn).map(un=>{const Kt=Ue?!!De[un]:!0;return y.ignoreToolnames=y.ignoreToolnames.filter(di=>di!==un),Kt||y.ignoreToolnames.push(un),{id:un,name:un,description:cn[un].description,enabled:Kt}});const ir=`plugin-${ke}`,pr=xe.value.find(un=>un.id===ir);if(pr){pr.tools=Se,pr.originMcpConfig=C.markRaw(ue);return}const yn={id:ir,name:Oe.origin,icon:Ml,description:ke,enabled:!0,expanded:!0,tools:Se,originMcpConfig:C.markRaw(ue)};xe.value.push(yn)}};C.onMounted(async()=>{y.onError=be=>{be&&ht(l4(be))},y.onUpdatedTools=()=>{xe.value.forEach(be=>{const ue=`mcp-server-${be.id.replace("plugin-","")}`,De=y.mcpClients[ue],Ue=y.mcpTools[ue];De===null&&(be.name="❌"+be.name.replace("❌","")),Ue===null?be.tools.forEach(Oe=>Oe.enabled=!1):Ue&&(be.tools=Object.keys(Ue).map(Oe=>({id:Oe,name:Oe,description:Ue[Oe].description,enabled:!y.ignoreToolnames.includes(Oe)})))})},await y.initClientsAndTools(),await y.closeAll();for(const[be,ue]of Object.entries(y.mcpServers))await ne(be,ue)});let S=!1;C.watch(()=>o.sessionId,be=>{be&&o.mode==="remoter"&&!S&&(Ki.createRemoter({sessionId:o.sessionId,qrCodeUrl:o.qrCodeUrl,remoteUrl:o.remoteUrl,menuItems:o.menuItems,onShowAIChat:()=>u.value=!0}),S=!0)},{immediate:!0}),C.watch(()=>o.sessionId,be=>{be&&ge(be)});const fe=(be,ue)=>{const De=be.id==="plugin-本地工具列表",Ue=mn.getItem(gn.LOCAL_TOOL_STORAGE)||{};be.tools.forEach(Oe=>{Oe.enabled=ue,ue?y.ignoreToolnames=y.ignoreToolnames.filter(ke=>ke!==Oe.id):y.ignoreToolnames.push(Oe.id)}),De&&(Object.keys(Ue).forEach(Oe=>{Ue[Oe]=ue}),mn.setItem(gn.LOCAL_TOOL_STORAGE,Ue))},se=(be,ue,De)=>{const Ue=mn.getItem(gn.LOCAL_TOOL_STORAGE)||{},Oe=be.id==="plugin-本地工具列表";be.tools.forEach(ke=>{ke.id===ue&&(ke.enabled=De)}),De?y.ignoreToolnames=y.ignoreToolnames.filter(ke=>ke!==ue):y.ignoreToolnames.push(ue),Oe&&(Ue[ue]=De,mn.setItem(gn.LOCAL_TOOL_STORAGE,Ue))},Le=async be=>{const ue=xe.value.find(De=>De.id===be.id);if(ue){xe.value=xe.value.filter(Oe=>Oe.id!==ue.id);const De=le.value.find(Oe=>Oe.id===ue.id);De&&(De.addState="idle");const Ue=`mcp-server-${be.id.replace("plugin-","")}`;await y.removeMcpServer(Ue)}},$e=async be=>{be.addState="loading";const ue={...be,id:be.id,enabled:!0},De={type:be.type,url:be.url,useAISdkClient:!0},Ue=`mcp-server-${be.id}`;if(await y.insertMcpServer(Ue,De)){const ke=y.mcpTools[Ue];if(ke){ue.tools=Object.keys(ke).map(cn=>({id:cn,name:cn,description:ke[cn].description,enabled:!0})),xe.value.push(ue),be.addState="added",await y.closeAll();return}}await y.removeMcpServer(Ue),be.addState="idle"},Xe=(be,ue)=>be.trim()===""||ue.name.toLowerCase().includes(be.toLowerCase()),{handleCustomAdd:qt}=ly(y,xe,Ml);n({agent:y,welcomeIcon:A,messages:P,messageState:N,roles:M,inputMessage:R,senderRef:z,abortRequest:D,sendMessage:U,loadMcpServerToPlugin:ne,handleClientDisconnected:pe,addMessage:ie});const je=[Gt.TrSender.mention(o.skills)];return(be,ue)=>(C.openBlock(),C.createBlock(C.unref(Gt.TrContainer),{show:u.value,"onUpdate:show":ue[9]||(ue[9]=De=>u.value=De),fullscreen:l.value,"onUpdate:fullscreen":ue[10]||(ue[10]=De=>l.value=De)},{title:C.withCtx(()=>[C.createElementVNode("h3",f4,C.toDisplayString(t.title),1)]),operations:C.withCtx(()=>[C.renderSlot(be.$slots,"operations",{},()=>[C.createVNode(C.unref(Gt.TrIconButton),{icon:C.unref($i.IconNewSession),size:"28",svgSize:"20",onClick:ue[0]||(ue[0]=De=>C.unref(j)())},null,8,["icon"]),C.createVNode(C.unref(Gt.TrIconButton),{icon:C.unref($i.IconHistory),size:"28",svgSize:"20",onClick:ue[1]||(ue[1]=De=>m.value=!C.unref(m))},null,8,["icon"]),C.createVNode($y,{onScanSuccess:ge}),C.createVNode(C.Transition,{name:"drawer-slide",appear:""},{default:C.withCtx(()=>[C.unref(m)?(C.openBlock(),C.createElementBlock("div",{key:0,class:"drawer-overlay",onClick:ue[4]||(ue[4]=De=>m.value=!1)},[C.createElementVNode("div",{class:"drawer-container",onClick:ue[3]||(ue[3]=C.withModifiers(()=>{},["stop"])),style:{"--tr-history-item-selected-bg":"#ebeeff"}},[ue[11]||(ue[11]=C.createElementVNode("h4",null,"历史会话",-1)),C.createVNode(C.unref(Gt.TrHistory),{class:"tr-history-demo",selected:C.unref(b).currentId,data:C.unref(b).conversations,showRenameControls:!0,onClose:ue[2]||(ue[2]=De=>m.value=!1),onItemClick:C.unref(Q),onItemTitleChange:C.unref(K),onItemAction:C.unref(ve)},null,8,["selected","data","onItemClick","onItemTitleChange","onItemAction"])])])):C.createCommentVNode("",!0)]),_:1})],!0)]),footer:C.withCtx(()=>[C.createElementVNode("div",p4,[C.renderSlot(be.$slots,"suggestions",{},()=>[C.createElementVNode("div",g4,[(C.openBlock(!0),C.createElementBlock(C.Fragment,null,C.renderList(C.unref(X),De=>(C.openBlock(),C.createBlock(C.unref(Gt.TrDropdownMenu),{key:De.id,items:De.menus,onItemClick:Pe,trigger:"click"},{trigger:C.withCtx(()=>[C.createVNode(C.unref(Gt.TrSuggestionPillButton),null,{default:C.withCtx(()=>[C.createTextVNode(C.toDisplayString(De.text),1)]),_:2},1024)]),_:2},1032,["items"]))),128))])],!0),C.createVNode(C.unref(Gt.TrSender),{ref_key:"senderRef",ref:z,mode:"multiple",modelValue:C.unref(R),"onUpdate:modelValue":ue[7]||(ue[7]=De=>C.isRef(R)?R.value=De:null),placeholder:we.value,clearable:!!C.unref(R),loading:Fe.value,showWordLimit:!0,maxLength:2e4,extensions:je,onSubmit:ye,onCancel:C.unref(D)},{footer:C.withCtx(()=>[C.createElementVNode("div",m4,[C.createVNode(r4,{"installed-plugins":xe.value,onClick:ue[5]||(ue[5]=De=>he.value=!he.value)},null,8,["installed-plugins"]),t.inBrowserExt?(C.openBlock(),C.createBlock(e4,{key:0})):C.createCommentVNode("",!0),t.inBrowserExt?(C.openBlock(),C.createBlock(Es,{key:1,class:"action-button",active:g.value,rounded:"",size:"small",onClick:ue[6]||(ue[6]=De=>g.value=!g.value)},{default:C.withCtx(()=>[C.createVNode(C.unref(d4),{width:16,height:16}),ue[12]||(ue[12]=C.createElementVNode("span",{class:"button-text"},"生成式UI",-1))]),_:1},8,["active"])):C.createCommentVNode("",!0)])]),_:1},8,["modelValue","placeholder","clearable","loading","onCancel"]),C.createVNode(C.unref(Gt.TrMcpServerPicker),{visible:he.value,"onUpdate:visible":ue[8]||(ue[8]=De=>he.value=De),"popup-config":{type:"drawer"},"show-custom-add-button":!0,marketTabTitle:"MCP市场",installedTabTitle:"已添加MCP服务",title:"扩展",installedPlugins:xe.value,marketPlugins:le.value,"market-category-options":F.value,"installed-search-fn":Xe,"market-search-fn":Xe,onPluginToggle:fe,onPluginAdd:$e,onPluginDelete:Le,onToolToggle:se,onPluginCreate:C.unref(qt)},{"header-actions":C.withCtx(()=>[C.renderSlot(be.$slots,"header-actions",{},void 0,!0)]),_:3},8,["visible","installedPlugins","marketPlugins","market-category-options","onPluginCreate"])])]),default:C.withCtx(()=>[C.createVNode(C.unref(Gt.TrBubbleProvider),{"content-renderers":Ce},{default:C.withCtx(()=>[C.unref(P).length===0?C.renderSlot(be.$slots,"welcome",{key:0},()=>[C.createElementVNode("div",h4,[C.createVNode(C.unref(Gt.TrWelcome),{title:C.unref(J)[t.locale].title,description:C.unref(J)[t.locale].description,icon:C.unref(A)},null,8,["title","description","icon"]),C.createVNode(C.unref(Gt.TrPrompts),{items:C.unref(te),wrap:!0,class:"tiny-prompts","item-class":"prompt-item"},null,8,["items"])])],!0):(C.openBlock(),C.createBlock(C.unref(Gt.TrBubbleList),{key:1,style:{flex:"1"},items:C.unref(P),roles:C.unref(M),"auto-scroll":"",loading:C.unref(N).status===C.unref(dr.STATUS).PROCESSING,"loading-role":"assistant"},null,8,["items","roles","loading"]))]),_:3})]),_:3},8,["show","fullscreen"]))}}),ts=ui(x4,[["__scopeId","data-v-1e3b500d"]]);function w4(t){const n=t.sessionId?Bl(t.sessionId,t.agentRoot):[],o=new Ki.AgentModelProvider({llmConfig:t.llmConfig,mcpServers:n}),l=C.ref("ready"),u=C.ref([]),f=C.ref("");let g=null;async function m(){const b=f.value;if(!b)return;if(/^\/[A-Za-z0-9-]{6,}$/.test(b)){A(b.slice(1));return}l.value="submitted",g=new AbortController;const P=await o.chatStream({message:b,model:t.model,system:t.systemPrompt||"",abortSignal:g.signal,maxSteps:t.maxSteps||5,onFinish:async()=>{await o.closeAll(),l.value="ready"},onError:()=>l.value="error",onAbort:()=>l.value="ready"});if(f.value="",t.processStream&&typeof t.processStream=="function"){t.processStream(P.fullStream,u,b);return}t.ui==="matechat"?y4(P.fullStream,u,b):t.ui==="antx"?_4(P.fullStream,u,b):t.ui==="elplusx"?v4(P.fullStream,u,b):t.ui==="tdchat"?C4(P.fullStream,u,b):console.warn("暂时未实现")}function y(){g&&g.abort()}function x(){u.value=[],o.messages=[]}async function A(b){const N=(await fetch(`${t.agentRoot}client?sessionId=${b}`).then(R=>R.json()))?.data?.sessionId||"";if(N){const R=Bl(N,t.agentRoot);Object.assign(o.mcpServers,R)}}return{agent:o,status:l,messages:u,inputValue:f,chatStream:m,stopChat:y,newConversation:x,addSessionId:A}}function Bl(t,n){if(!t)return{};const o=t.includes(",")?t.split(",").map(u=>u.trim()):[t],l={};return o.forEach(u=>{l[`mcp-server-${u}`]={type:"streamableHttp",url:`${n}mcp?sessionId=${u}`}}),l}async function y4(t,n,o){n.value.push({from:"user",content:o,avatarConfig:{name:"user"}});let l={from:"model",content:"",avatarConfig:{name:"model"},id:Date.now().toString()};n.value.push(l),l=n.value[n.value.length-1];for await(const u of t)u.type.startsWith("text-")?u.text&&(l.content+=u.text):u.type.startsWith("tool-")?u.delta&&(l.content+=u.delta):u.type.startsWith("reasoning-")&&u.text&&(l.content+=u.text)}async function _4(t,n,o){n.value.push({from:"user",content:o}),n.value.push({from:"model",content:""});const l=n.value[n.value.length-1];for await(const u of t)u.type.startsWith("text-")?u.text&&(l.content+=u.text):u.type.startsWith("tool-")?u.delta&&(l.content+=u.delta):u.type.startsWith("reasoning-")&&u.text&&(l.content+=u.text)}async function v4(t,n,o){n.value.push({from:"user",content:o}),n.value.push({from:"model",content:""});const l=n.value[n.value.length-1];for await(const u of t)u.type.startsWith("text-")?u.text&&(l.content+=u.text):u.type.startsWith("tool-")?u.delta&&(l.content+=u.delta):u.type.startsWith("reasoning-")&&u.text&&(l.content+=u.text)}async function C4(t,n,o){n.value.push({role:"user",content:o,avatar:"https://tdesign.gtimg.com/site/avatar.jpg"}),n.value.push({role:"assistant",content:"",avatar:"https://tdesign.gtimg.com/site/chat-avatar.png"});const l=n.value[n.value.length-1];for await(const u of t)u.type.startsWith("text-")?u.text&&(l.content+=u.text):u.type.startsWith("tool-")?u.delta&&(l.content+=u.delta):u.type.startsWith("reasoning-")&&u.text&&(l.content+=u.text)}ts.install=function(t){t.component("tiny-remoter",ts)};exports.StorageKeys=gn;exports.StorageManager=xs;exports.TinyRemoter=ts;exports.UNIFIED_MODEL_CONFIGS=Qn;exports.createStorageManager=g3;exports.getDefaultModelConfig=ju;exports.getModelConfig=h3;exports.getStorageManager=$n;exports.storage=mn;exports.useModel=to;exports.useNextAgent=w4;
110
+ `,Zy=btoa(Vy),Il=`data:image/svg+xml;base64,${Zy}`,Do=(t,r)=>{const[o,l]=t.split("#");return{id:r,text:o,inputMessage:l}},jy=t=>{const r={"zh-CN":{title:"OpenTiny NEXT",description:"我是你的私人智能助手",placeholder:"请输入您的问题",thinking:"正在思考中..."},"en-US":{title:"OpenTiny NEXT",description:"I am your private AI assistant",placeholder:"Please enter your question",thinking:"Thinking..."}},o=[{id:"office",text:t.locale==="zh-CN"?"办公助手":"Office Assistant",menus:["接收邮件#请同步邮箱的新邮件。","编写邮件#请新建一个邮件,收件人为 opentiny-next@meeting.com, 内容为举办一个临时会议。","安排会议#创建一个临时的在线会议,主题为讨论问题,时长为1小时。","整理文档#请分析附件中的销售情况,把销售额绘制成折线图。"].map(Do)},{id:"development",text:t.locale==="zh-CN"?"开发支持":"Development Support",menus:["遇到代码问题#请检查当前位置的报错原因。","架构建议#请使用NodeJs实现一个分块上传文件的模块。","最新的技术趋势#请分析Vue与React 框架的优劣分别是什么?"].map(Do)},{id:"management",text:t.locale==="zh-CN"?"项目管理":"Project Management",menus:["项目规划#如何开展品牌推广的活动?","任务分配#将本季度的销售任务分配给三个人,并生成甘特图进行跟踪。","进度跟踪#分析团队的任务完成情况。"].map(Do)}],l=[{label:t.locale==="zh-CN"?"企业办公助手":"Enterprise Office Assistant",description:t.locale==="zh-CN"?"需要我帮你处理邮件、安排会议、整理文档,还是优化工作流程?":"Need help with emails, meeting scheduling, document organization, or workflow optimization?",icon:_.h("span",{style:{fontSize:"18px"}},"🧠"),badge:"NEW"},{label:t.locale==="zh-CN"?"开发技术支持":"Development Support",description:t.locale==="zh-CN"?"遇到代码问题?需要架构建议?还是想了解最新的技术趋势?":"Facing code issues? Need architecture advice? Or want to learn about latest tech trends?",icon:_.h("span",{style:{fontSize:"18px"}},"💻")},{label:t.locale==="zh-CN"?"项目管理协作":"Project Management",description:t.locale==="zh-CN"?"需要项目规划、任务分配、进度跟踪,还是团队协作建议?":"Need project planning, task assignment, progress tracking, or team collaboration advice?",icon:_.h("span",{style:{fontSize:"18px"}},"📊")}];return{lang:r,pillItems:o,promptItems:l}},Sl={"No client found for session ID":"受控端页面已关闭请重新打开或者刷新页面","Failed to create MCP client":"创建MCP客户端失败"},Hy=t=>{console.log("message",t);const r=Object.keys(Sl),o=r.findIndex(u=>t.includes(u));return(o!==-1?Sl[r[o]]:t)||t},Wy={"data-v-99394ae9":"",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",width:"16.000000",height:"16.000000",fill:"none",customFrame:"#000000",size:"16"};function Gy(t,r){return _.openBlock(),_.createElementBlock("svg",Wy,[...r[0]||(r[0]=[_.createElementVNode("rect",{id:"生成式UI",width:"16.000000",height:"16.000000",x:"0.000000",y:"0.000000",fill:"currentColor","fill-opacity":"0"},null,-1),_.createElementVNode("path",{id:"矢量 154",d:"M7.41014 2.09741L7.67112 2.70606C7.68333 2.73438 7.70579 2.75684 7.73411 2.76905L8.34275 3.02979C8.43968 3.0713 8.43968 3.20875 8.34275 3.25025L7.73411 3.51124C7.70579 3.52345 7.68333 3.54591 7.67112 3.57423L7.41014 4.18288C7.36863 4.2798 7.23118 4.2798 7.18968 4.18288L6.92894 3.57423C6.91673 3.54591 6.89427 3.52345 6.86595 3.51124L6.25731 3.25025C6.16039 3.20875 6.16039 3.0713 6.25731 3.02979L6.86595 2.76905C6.89427 2.75684 6.91673 2.73438 6.92894 2.70606L7.18968 2.09741C7.23118 2.00049 7.36863 2.00049 7.41014 2.09741ZM4.57006 11.9625L7.27611 8.09746L9.69944 4.63674L10.592 3.36207C10.6899 3.22218 10.8017 3.09864 10.9272 2.99122C11.0529 2.88404 11.1926 2.79297 11.3459 2.71802C11.4992 2.64332 11.657 2.58936 11.8191 2.5564C11.9809 2.52369 12.1472 2.51172 12.3176 2.52051C12.5315 2.53174 12.7336 2.57373 12.9238 2.64649C13.0678 2.70118 13.205 2.77369 13.3354 2.86353C13.4651 2.95289 13.5813 3.05445 13.6836 3.16822C13.8064 3.3047 13.9094 3.45851 13.9929 3.6299C14.0766 3.80128 14.1342 3.97731 14.1662 4.15773C14.1928 4.30861 14.2014 4.46267 14.1919 4.61989C14.1823 4.7781 14.1547 4.93069 14.1096 5.07791C14.0495 5.27249 13.958 5.45755 13.8352 5.63309L7.81321 14.2335Q7.66985 14.4382 7.48649 14.5965Q7.4825 14.6 7.4785 14.6034Q7.29063 14.7641 7.06102 14.8766C6.90794 14.9513 6.75072 15.0052 6.5891 15.0384C6.42748 15.0714 6.2617 15.0836 6.09154 15.0751C5.87743 15.0643 5.67504 15.0226 5.48436 14.9503C5.34008 14.8956 5.20287 14.8233 5.07201 14.7335C4.94213 14.6444 4.82592 14.5428 4.72313 14.4291C4.60033 14.2928 4.49682 14.1388 4.41308 13.9674C4.32934 13.7958 4.27123 13.6197 4.23925 13.4391C4.21239 13.2882 4.20385 13.1339 4.21313 12.9767C4.22265 12.8184 4.24999 12.6656 4.2954 12.5184C4.35546 12.3233 4.44701 12.138 4.57006 11.9625ZM4.7185 4.67361L4.18383 3.42579C4.11449 3.26441 3.88549 3.26441 3.81616 3.42579L3.28149 4.67361C3.26123 4.72073 3.22363 4.75832 3.17651 4.77859L1.92871 5.31326C1.76733 5.3826 1.76733 5.6116 1.92871 5.68094L3.17651 6.21561C3.22363 6.23587 3.26123 6.27347 3.28149 6.32059L3.81616 7.56841C3.88549 7.73003 4.11449 7.73003 4.18383 7.56841L4.7185 6.32059C4.73876 6.27347 4.77636 6.23587 4.82348 6.21561L6.07128 5.68094C6.23265 5.6116 6.23265 5.3826 6.07128 5.31326L4.82348 4.77859C4.77636 4.75832 4.73876 4.72073 4.7185 4.67361ZM5.38915 12.536C5.32006 12.6346 5.27099 12.7384 5.24169 12.8475C5.22533 12.9088 5.21532 12.9718 5.21141 13.0362C5.20726 13.1063 5.21044 13.1751 5.22094 13.2428C5.23583 13.3402 5.2661 13.4354 5.31151 13.5282C5.35692 13.6209 5.41332 13.7032 5.48095 13.775C5.52806 13.8248 5.58031 13.8695 5.63817 13.9093C5.69139 13.9459 5.7473 13.9764 5.80565 14.0011C5.9099 14.0453 6.02196 14.0702 6.14208 14.0763C6.2263 14.0807 6.30834 14.0746 6.38841 14.0582C6.46825 14.0418 6.54613 14.015 6.62181 13.9781C6.69749 13.941 6.76634 13.8961 6.8286 13.8429C6.89061 13.7899 6.94578 13.7289 6.99412 13.6598L11.9415 6.59405L10.3381 5.46789L5.38915 12.536ZM10.9168 4.6415L12.5202 5.76762L13.0161 5.05935C13.0849 4.96096 13.134 4.85745 13.1633 4.74831C13.1797 4.68703 13.1897 4.62429 13.1936 4.55959C13.198 4.48977 13.1948 4.42092 13.1843 4.35329C13.1694 4.25588 13.1394 4.16091 13.0942 4.06813C13.0488 3.97536 12.9926 3.89308 12.925 3.8213C12.8781 3.7715 12.8259 3.72682 12.7683 3.68703C12.7148 3.6504 12.6591 3.61964 12.6008 3.59474C12.4968 3.55079 12.385 3.5254 12.2651 3.5193C12.1806 3.51466 12.0984 3.52076 12.0183 3.53688C11.9382 3.55324 11.8601 3.57985 11.7841 3.61696C11.7082 3.65407 11.6391 3.69899 11.5771 3.75221C11.5149 3.80519 11.4594 3.86647 11.4111 3.93556L10.9168 4.6415Z",fill:"currentColor","fill-rule":"evenodd"},null,-1)])])}const Xy={render:Gy},qy=_.defineComponent({__name:"GenUISwitch",props:{genuiEnabled:{type:Boolean,type:Boolean,default:!1,required:!1},genuiEnabledModifiers:{}},emits:["update:genuiEnabled"],setup(t){const r=_.useModel(t,"genuiEnabled"),o=()=>{r.value=!r.value};return(l,u)=>(_.openBlock(),_.createBlock(xs,{class:"action-button",active:r.value,rounded:"",size:"small",onClick:o},{default:_.withCtx(()=>[_.createVNode(_.unref(Xy),{width:16,height:16}),u[0]||(u[0]=_.createElementVNode("span",{class:"button-text"},"生成式UI",-1))]),_:1},8,["active"]))}}),Yy=Ir(qy,[["__scopeId","data-v-7f3b0372"]]),Ky={class:"tr-container__title"},Jy={style:{flex:"1"}},Qy={class:"chat-input"},e_={class:"chat-input-pills"},t_={class:"action-buttons"},n_=_.defineComponent({name:"TinyRemoter",__name:"TinyRobotChat",props:_.mergeModels({sessionId:{type:String,default:""},agentRoot:{type:String,default:"https://agent.opentiny.design/api/v1/webmcp-trial/"},systemPrompt:{type:String,default:"你是一个智能生活助手,擅长通过工具调用帮助用户完成任务"},title:{type:String,default:"OpenTiny NEXT"},locale:{type:String,default:"zh-CN"},remoteUrl:{type:String},menuItems:{type:Array,default:()=>[]},qrCodeUrl:{type:String},mode:{type:String,default:"remoter"},llmConfig:{type:Object,default:void 0},inBrowserExt:{type:Boolean,default:!1},genUiComponents:{type:Object,default:()=>({})},customMarketMcpServers:{type:Array,default:()=>[]},llmConfigs:{type:Array,default:void 0},skills:{type:Object,default:()=>[]}},{fullscreen:{type:Boolean,default:!1},fullscreenModifiers:{},show:{type:Boolean,default:!1},showModifiers:{},selectedModelId:{type:String,default:void 0,required:!1},selectedModelIdModifiers:{},genUiAble:{type:Boolean,default:!1,required:!1},genUiAbleModifiers:{},enabledTools:{type:Object,default:void 0,required:!1},enabledToolsModifiers:{}}),emits:["update:fullscreen","update:show","update:selectedModelId","update:genUiAble","update:enabledTools"],setup(t,{expose:r}){const o=t,l=_.useModel(t,"fullscreen"),u=_.useModel(t,"show"),f=_.useModel(t,"selectedModelId"),g=_.useModel(t,"genUiAble"),x=_.useModel(t,"enabledTools"),y=o.llmConfigs?_.toRef(o,"llmConfigs"):void 0,{selectedModel:m}=ms(y,f),{showHistory:E,agent:C,customAgentProvider:P,welcomeIcon:O,conversationState:D,messages:R,messageState:M,inputMessage:V,abortRequest:U,roles:k,senderRef:J,sendMessage:be,handleSendMessage:Z,handleHistoryUpdateTitle:z,handleHistoryDelete:Y,handleHistorySelect:W,handleCreateConversation:de,addMessage:me,send:pe}=z3({sessionId:_.toRef(o,"sessionId"),agentRoot:_.toRef(o,"agentRoot"),systemPrompt:o.systemPrompt||"",llmConfig:o.llmConfig,skills:o.skills||[]});P.isGenuiEnabled=g;const Ce=()=>{if(m.value){const $e=m.value;P.updateLLMConfig({modelId:$e.id,baseURL:$e.baseURL||"",apiKey:$e.apiKey||"",providerType:$e.providerType,useReActMode:$e.useReActMode,llm:$e.llm})}};o.llmConfigs&&_.watch(m,Ce,{immediate:!0}),o.inBrowserExt&&_.watch(g,Ce);const le={markdown:new Gt.BubbleMarkdownContentRenderer({mdConfig:{html:!0}}),"schema-card":$e=>_.h(U1.SchemaRenderer,{...$e,onAction:({llmFriendlyMessage:De,humanFriendlyMessage:Be})=>{me({role:"user",content:De,uiContent:[{type:"text",content:Be}]}),pe()},generating:or.GeneratingStatus.includes(M.status),customComponents:o.genUiComponents,requiredCompleteFieldSelectors:["[componentName=TinyUser] > props > modelValue"]})},{installedPlugins:L,marketPlugins:te,pluginVisible:K,loadMcpServerToPlugin:ne,togglePlugin:fe,toggleTool:xe,deletePlugin:ye,addPluginFromMarket:ee,addPluginFromScan:he,handleClientDisconnected:Ee,searchPlugin:_e,initPluginSystem:T}=H3(C,x,Il);te.value=[...zy,...o.customMarketMcpServers];const ce=_.ref([{value:"",label:"全部分类"},{value:"productivity",label:"生产力工具"},{value:"communication",label:"沟通协作"},{value:"development",label:"开发工具"},{value:"ai",label:"AI 助手"}]),{lang:we,pillItems:mt,promptItems:ot}=jy(o),Qe=async $e=>{if(r1("添加工具中..."),$e){const De=await he($e,o.agentRoot);dt(De?"添加工具完成":"重复添加工具或添加失败")}else dt("添加工具失败")},an=async($e,De)=>{const Be=V.value;if(/^\/[A-Za-z0-9-]{6,}$/.test(Be)){const gn=(await fetch(`${o.agentRoot}client?sessionId=${Be.slice(1)}`).then(Mt=>Mt.json()))?.data?.sessionId;gn?await Qe(gn):dt("添加工具失败,请检查识别码是否正确"),V.value=""}else await Z($e,De)},Fe=_.computed(()=>or.GeneratingStatus.includes(M.status)?we[o.locale].thinking:we[o.locale].placeholder),Un=_.computed(()=>or.GeneratingStatus.includes(M.status)),ln=$e=>{V.value=$e.inputMessage};_.onMounted(async()=>{C.onError=De=>{De&&dt(Hy(De))},T(De=>{dt(`工具 "${De}" 已断开连接`)});const $e=te.value.filter(De=>De.addState==="added"&&De.enabled);for(const De of $e)await ee(De);await C.initClientsAndTools(),await C.closeAll();for(const[De,Be]of Object.entries(C.mcpServers))await ne(De,Be)});let zn=!1;_.watch(()=>o.sessionId,$e=>{$e&&o.mode==="remoter"&&!zn&&(Hi.createRemoter({sessionId:o.sessionId,qrCodeUrl:o.qrCodeUrl,remoteUrl:o.remoteUrl,menuItems:o.menuItems,onShowAIChat:()=>u.value=!0}),zn=!0)},{immediate:!0}),_.watch(()=>o.sessionId,$e=>{$e&&Qe($e)});const At=fe,Ke=xe,ze=ye,lr=ee,Se=_e,{handleCustomAdd:cr}=j3(C,L,Il);r({agent:C,welcomeIcon:O,messages:R,messageState:M,roles:k,inputMessage:V,senderRef:J,abortRequest:U,sendMessage:be,loadMcpServerToPlugin:ne,handleClientDisconnected:Ee,addMessage:me});const si=[Gt.TrSender.mention(o.skills)];return($e,De)=>(_.openBlock(),_.createBlock(_.unref(Gt.TrContainer),{show:u.value,"onUpdate:show":De[10]||(De[10]=Be=>u.value=Be),fullscreen:l.value,"onUpdate:fullscreen":De[11]||(De[11]=Be=>l.value=Be)},{title:_.withCtx(()=>[_.createElementVNode("h3",Ky,_.toDisplayString(t.title),1)]),operations:_.withCtx(()=>[_.renderSlot($e.$slots,"operations",{},()=>[_.createVNode(_.unref(Gt.TrIconButton),{icon:_.unref(Di.IconNewSession),size:"28",svgSize:"20",onClick:De[0]||(De[0]=Be=>_.unref(de)())},null,8,["icon"]),_.createVNode(_.unref(Gt.TrIconButton),{icon:_.unref(Di.IconHistory),size:"28",svgSize:"20",onClick:De[1]||(De[1]=Be=>E.value=!_.unref(E))},null,8,["icon"]),_.createVNode(by,{onScanSuccess:Qe}),_.createVNode(_.Transition,{name:"drawer-slide",appear:""},{default:_.withCtx(()=>[_.unref(E)?(_.openBlock(),_.createElementBlock("div",{key:0,class:"drawer-overlay",onClick:De[4]||(De[4]=Be=>E.value=!1)},[_.createElementVNode("div",{class:"drawer-container",onClick:De[3]||(De[3]=_.withModifiers(()=>{},["stop"])),style:{"--tr-history-item-selected-bg":"#ebeeff"}},[De[12]||(De[12]=_.createElementVNode("h4",null,"历史会话",-1)),_.createVNode(_.unref(Gt.TrHistory),{class:"tr-history-demo",selected:_.unref(D).currentId,data:_.unref(D).conversations,showRenameControls:!0,onClose:De[2]||(De[2]=Be=>E.value=!1),onItemClick:_.unref(W),onItemTitleChange:_.unref(z),onItemAction:_.unref(Y)},null,8,["selected","data","onItemClick","onItemTitleChange","onItemAction"])])])):_.createCommentVNode("",!0)]),_:1})],!0)]),footer:_.withCtx(()=>[_.createElementVNode("div",Qy,[_.renderSlot($e.$slots,"suggestions",{},()=>[_.createElementVNode("div",e_,[(_.openBlock(!0),_.createElementBlock(_.Fragment,null,_.renderList(_.unref(mt),Be=>(_.openBlock(),_.createBlock(_.unref(Gt.TrDropdownMenu),{key:Be.id,items:Be.menus,onItemClick:ln,trigger:"click"},{trigger:_.withCtx(()=>[_.createVNode(_.unref(Gt.TrSuggestionPillButton),null,{default:_.withCtx(()=>[_.createTextVNode(_.toDisplayString(Be.text),1)]),_:2},1024)]),_:2},1032,["items"]))),128))])],!0),_.createVNode(_.unref(Gt.TrSender),{ref_key:"senderRef",ref:J,mode:"multiple",modelValue:_.unref(V),"onUpdate:modelValue":De[8]||(De[8]=Be=>_.isRef(V)?V.value=Be:null),placeholder:Fe.value,clearable:!!_.unref(V),loading:Un.value,showWordLimit:!0,maxLength:2e4,extensions:si,onSubmit:an,onCancel:_.unref(U)},{footer:_.withCtx(()=>[_.createElementVNode("div",t_,[_.createVNode(Uy,{"installed-plugins":_.unref(L),onClick:De[5]||(De[5]=Be=>K.value=!_.unref(K))},null,8,["installed-plugins"]),_.unref(y)&&_.unref(y).length>0?(_.openBlock(),_.createBlock(Ly,{key:0,"model-configs":_.unref(y),"selected-model-id":f.value,"onUpdate:selectedModelId":De[6]||(De[6]=Be=>f.value=Be)},null,8,["model-configs","selected-model-id"])):_.createCommentVNode("",!0),t.inBrowserExt?(_.openBlock(),_.createBlock(Yy,{key:1,"genui-enabled":g.value,"onUpdate:genuiEnabled":De[7]||(De[7]=Be=>g.value=Be)},null,8,["genui-enabled"])):_.createCommentVNode("",!0)])]),_:1},8,["modelValue","placeholder","clearable","loading","onCancel"]),_.createVNode(_.unref(Gt.TrMcpServerPicker),{visible:_.unref(K),"onUpdate:visible":De[9]||(De[9]=Be=>_.isRef(K)?K.value=Be:null),"popup-config":{type:"drawer"},"show-custom-add-button":!0,marketTabTitle:"MCP市场",installedTabTitle:"已添加MCP服务",title:"扩展",installedPlugins:_.unref(L),marketPlugins:_.unref(te),"market-category-options":ce.value,"installed-search-fn":_.unref(Se),"market-search-fn":_.unref(Se),onPluginToggle:_.unref(At),onPluginAdd:_.unref(lr),onPluginDelete:_.unref(ze),onToolToggle:_.unref(Ke),onPluginCreate:_.unref(cr)},{"header-actions":_.withCtx(()=>[_.renderSlot($e.$slots,"header-actions",{},void 0,!0)]),_:3},8,["visible","installedPlugins","marketPlugins","market-category-options","installed-search-fn","market-search-fn","onPluginToggle","onPluginAdd","onPluginDelete","onToolToggle","onPluginCreate"])])]),default:_.withCtx(()=>[_.createVNode(_.unref(Gt.TrBubbleProvider),{"content-renderers":le},{default:_.withCtx(()=>[_.unref(R).length===0?_.renderSlot($e.$slots,"welcome",{key:0},()=>[_.createElementVNode("div",Jy,[_.createVNode(_.unref(Gt.TrWelcome),{title:_.unref(we)[t.locale].title,description:_.unref(we)[t.locale].description,icon:_.unref(O)},null,8,["title","description","icon"]),_.createVNode(_.unref(Gt.TrPrompts),{items:_.unref(ot),wrap:!0,class:"tiny-prompts","item-class":"prompt-item"},null,8,["items"])])],!0):(_.openBlock(),_.createBlock(_.unref(Gt.TrBubbleList),{key:1,style:{flex:"1"},items:_.unref(R),roles:_.unref(k),"auto-scroll":"",loading:_.unref(M).status===_.unref(or.STATUS).PROCESSING,"loading-role":"assistant"},null,8,["items","roles","loading"]))]),_:3})]),_:3},8,["show","fullscreen"]))}}),Xo=Ir(n_,[["__scopeId","data-v-63432176"]]);function r_(t){const r=t.sessionId?Tl(t.sessionId,t.agentRoot):[],o=new Hi.AgentModelProvider({llmConfig:t.llmConfig,mcpServers:r}),l=_.ref("ready"),u=_.ref([]),f=_.ref("");let g=null;async function x(){const C=f.value;if(!C)return;if(/^\/[A-Za-z0-9-]{6,}$/.test(C)){E(C.slice(1));return}l.value="submitted",g=new AbortController;const P=await o.chatStream({message:C,model:t.model,system:t.systemPrompt||"",abortSignal:g.signal,maxSteps:t.maxSteps||5,onFinish:async()=>{await o.closeAll(),l.value="ready"},onError:()=>l.value="error",onAbort:()=>l.value="ready"});if(f.value="",t.processStream&&typeof t.processStream=="function"){t.processStream(P.fullStream,u,C);return}t.ui==="matechat"?i_(P.fullStream,u,C):t.ui==="antx"?o_(P.fullStream,u,C):t.ui==="elplusx"?s_(P.fullStream,u,C):t.ui==="tdchat"?a_(P.fullStream,u,C):console.warn("暂时未实现")}function y(){g&&g.abort()}function m(){u.value=[],o.messages=[]}async function E(C){const O=(await fetch(`${t.agentRoot}client?sessionId=${C}`).then(D=>D.json()))?.data?.sessionId||"";if(O){const D=Tl(O,t.agentRoot);Object.assign(o.mcpServers,D)}}return{agent:o,status:l,messages:u,inputValue:f,chatStream:x,stopChat:y,newConversation:m,addSessionId:E}}function Tl(t,r){if(!t)return{};const o=t.includes(",")?t.split(",").map(u=>u.trim()):[t],l={};return o.forEach(u=>{l[`mcp-server-${u}`]={type:"streamableHttp",url:`${r}mcp?sessionId=${u}`}}),l}async function i_(t,r,o){r.value.push({from:"user",content:o,avatarConfig:{name:"user"}});let l={from:"model",content:"",avatarConfig:{name:"model"},id:Date.now().toString()};r.value.push(l),l=r.value[r.value.length-1];for await(const u of t)u.type.startsWith("text-")?u.text&&(l.content+=u.text):u.type.startsWith("tool-")?u.delta&&(l.content+=u.delta):u.type.startsWith("reasoning-")&&u.text&&(l.content+=u.text)}async function o_(t,r,o){r.value.push({from:"user",content:o}),r.value.push({from:"model",content:""});const l=r.value[r.value.length-1];for await(const u of t)u.type.startsWith("text-")?u.text&&(l.content+=u.text):u.type.startsWith("tool-")?u.delta&&(l.content+=u.delta):u.type.startsWith("reasoning-")&&u.text&&(l.content+=u.text)}async function s_(t,r,o){r.value.push({from:"user",content:o}),r.value.push({from:"model",content:""});const l=r.value[r.value.length-1];for await(const u of t)u.type.startsWith("text-")?u.text&&(l.content+=u.text):u.type.startsWith("tool-")?u.delta&&(l.content+=u.delta):u.type.startsWith("reasoning-")&&u.text&&(l.content+=u.text)}async function a_(t,r,o){r.value.push({role:"user",content:o,avatar:"https://tdesign.gtimg.com/site/avatar.jpg"}),r.value.push({role:"assistant",content:"",avatar:"https://tdesign.gtimg.com/site/chat-avatar.png"});const l=r.value[r.value.length-1];for await(const u of t)u.type.startsWith("text-")?u.text&&(l.content+=u.text):u.type.startsWith("tool-")?u.delta&&(l.content+=u.delta):u.type.startsWith("reasoning-")&&u.text&&(l.content+=u.text)}Xo.install=function(t){t.component("tiny-remoter",Xo)};exports.TinyRemoter=Xo;exports.useModel=ms;exports.useNextAgent=r_;