import {a as a$3}from'./chunk-COOCFN2K.js';import {a as a$2}from'./chunk-ZU6C4VWO.js';import {a as a$1}from'./chunk-NPDG2TI5.js';import {a}from'./chunk-D5PIEZCN.js';import {Barcode}from'@scandit/web-datacapture-barcode';import {Point,AnchorPositions,Quadrilateral}from'@scandit/web-datacapture-core';function p(e){let t=Math.sqrt(e.x*e.x+e.y*e.y);return new Point(e.x/t,e.y/t)}function s(e){return Math.sqrt(e.x*e.x+e.y*e.y)}function v(e){return {[a$2.Barcode]:"barcode",[a$2.Text]:"text",[a$2.Unknown]:"unknown"}[e]}function V(e){let t={barcode:a$2.Barcode,text:a$2.Text,unknown:a$2.Unknown}[e];if(t==null)throw new Error(`Invalid label field type: ${e}`);return t}function P(e){let t={date:a$1.Date,price:a$1.Price,weight:a$1.Weight,text:a$1.Text,numeric:a$1.Numeric}[e];if(t==null)throw new Error(`Invalid label field value type: ${e}`);return t}function q(e){let t={[a$1.Date]:"date",[a$1.Price]:"price",[a$1.Weight]:"weight",[a$1.Text]:"text",[a$1.Numeric]:"numeric"}[e];if(t==null)throw new Error(`Invalid label field value type: ${e}`);return t}function k(e){if(typeof e=="number"){let a={0:a$3.Captured,1:a$3.Predicted,2:a$3.Unknown};if(a[e]==null)throw new Error(`Invalid label field state: ${e}`);return a[e]}let i={captured:a$3.Captured,predicted:a$3.Predicted,unknown:a$3.Unknown}[e.toLowerCase()];if(i==null)throw new Error(`Invalid label field state: ${e}`);return i}function B(e){let t={[a$3.Captured]:"captured",[a$3.Predicted]:"predicted",[a$3.Unknown]:"unknown"}[e];if(t==null)throw new Error(`Invalid label field state: ${e}`);return t}var N=class e{get name(){return this._name}get type(){return this._type}get predictedLocation(){return this._predictedLocation}get state(){return this._state}get isRequired(){return this._isRequired}get barcode(){return this._barcode}get text(){return this._text}get valueType(){return this._valueType}get anchorPositions(){let t=this.predictedLocation,i=new Point(t.topRight.x-t.topLeft.x,t.topRight.y-t.topLeft.y),a=new Point(t.bottomRight.x-t.topRight.x,t.bottomRight.y-t.topRight.y),y=new Point(t.bottomLeft.x-t.bottomRight.x,t.bottomLeft.y-t.bottomRight.y),m=new Point(t.topLeft.x-t.bottomLeft.x,t.topLeft.y-t.bottomLeft.y),h=s(i)/2,g=s(a)/2,L=s(y)/2,f=s(m)/2,x=p(i),S=p(a),O=p(y),_=p(m),d={x:t.topLeft.x+x.x*h,y:t.topLeft.y+x.y*h},c={x:t.topRight.x+S.x*g,y:t.topRight.y+S.y*g},u={x:t.bottomRight.x+O.x*L,y:t.bottomRight.y+O.y*L},b={x:t.bottomLeft.x+_.x*f,y:t.bottomLeft.y+_.y*f},w={x:(d.x+c.x+u.x+b.x)/4,y:(d.y+c.y+u.y+b.y)/4};return AnchorPositions.fromJSON({center:new Point(w.x,w.y).toJSONObject(),topCenter:new Point(d.x,d.y).toJSONObject(),bottomCenter:new Point(u.x,u.y).toJSONObject(),centerLeft:new Point(b.x,b.y).toJSONObject(),centerRight:new Point(c.x,c.y).toJSONObject(),topLeft:t.topLeft.toJSONObject(),topRight:t.topRight.toJSONObject(),bottomLeft:t.bottomLeft.toJSONObject(),bottomRight:t.bottomRight.toJSONObject()})}get date(){return this._date}static fromJSON(t){let i=new e;return i._valueType=P(t.valueType),i._name=t.name,i._type=V(t.type),i._predictedLocation=Quadrilateral.fromJSON(t.location),i._state=k(t.state),i._isRequired=t.isRequired,i._barcode=t.barcode?Barcode.fromJSON(t.barcode):null,i._text=t.text,i._date=t.date?a.fromJSON(t.date):null,i}toJSONObject(){return {name:this._name,type:v(this._type),location:this._predictedLocation.toJSONObject(),state:B(this._state),isRequired:this._isRequired,barcode:this._barcode?this._barcode.toJSONObject():null,text:this._text,date:this._date?this._date.toJSONObject():null,valueType:q(this._valueType)}}};export{N as a};