@signosoft/signpad-js 0.3.7 → 0.3.8
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.
|
@@ -357,7 +357,9 @@ class iC {
|
|
|
357
357
|
this.component.stateManager.transitionTo(A, "Processing...");
|
|
358
358
|
try {
|
|
359
359
|
const g = await I();
|
|
360
|
-
|
|
360
|
+
this.component.resetDrawingState();
|
|
361
|
+
const E = await this.getReadyState();
|
|
362
|
+
return this.component.stateManager.transitionTo(E), g;
|
|
361
363
|
} catch (g) {
|
|
362
364
|
throw this.handleError("Error during action processing", g), g;
|
|
363
365
|
}
|
|
@@ -570,7 +572,7 @@ const ZA = class ZA {
|
|
|
570
572
|
async startSigning(A, I) {
|
|
571
573
|
if (!this.sigLayer) return !1;
|
|
572
574
|
const g = I ?? this.component.configManager.getDrawingOptions();
|
|
573
|
-
return await this.sigLayer.startSigning(A, !0, g), !0;
|
|
575
|
+
return this.sigLayer.isInSigningMode?.() && await this.sigLayer.stopSigning(), await this.sigLayer.startSigning(A, !0, g), !0;
|
|
574
576
|
}
|
|
575
577
|
/**
|
|
576
578
|
* Stops the current signing session if active.
|
|
@@ -597,7 +599,7 @@ const ZA = class ZA {
|
|
|
597
599
|
* @returns Resolves when the clear completes.
|
|
598
600
|
*/
|
|
599
601
|
async clearSignature() {
|
|
600
|
-
this.sigLayer?.isInSigningMode && await this.sigLayer.clearSignature();
|
|
602
|
+
this.sigLayer?.isInSigningMode?.() && await this.sigLayer.clearSignature();
|
|
601
603
|
}
|
|
602
604
|
// --- PRIVATE METHODS ---
|
|
603
605
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(l,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("lit")):typeof define=="function"&&define.amd?define(["exports","lit"],c):(l=typeof globalThis<"u"?globalThis:l||self,c(l.SignosoftSignpad={},l.lit))})(this,(function(l,c){"use strict";const Sg=E=>(A,I)=>{I!==void 0?I.addInitializer(()=>{customElements.define(E,A)}):customElements.define(E,A)};const FA=globalThis,PA=FA.ShadowRoot&&(FA.ShadyCSS===void 0||FA.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,sI=Symbol(),aI=new WeakMap;let sg=class{constructor(A,I,g){if(this._$cssResult$=!0,g!==sI)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=A,this.t=I}get styleSheet(){let A=this.o;const I=this.t;if(PA&&A===void 0){const g=I!==void 0&&I.length===1;g&&(A=aI.get(I)),A===void 0&&((this.o=A=new CSSStyleSheet).replaceSync(this.cssText),g&&aI.set(I,A))}return A}toString(){return this.cssText}};const ag=E=>new sg(typeof E=="string"?E:E+"",void 0,sI),yg=(E,A)=>{if(PA)E.adoptedStyleSheets=A.map(I=>I instanceof CSSStyleSheet?I:I.styleSheet);else for(const I of A){const g=document.createElement("style"),Q=FA.litNonce;Q!==void 0&&g.setAttribute("nonce",Q),g.textContent=I.cssText,E.appendChild(g)}},yI=PA?E=>E:E=>E instanceof CSSStyleSheet?(A=>{let I="";for(const g of A.cssRules)I+=g.cssText;return ag(I)})(E):E;const{is:Kg,defineProperty:hg,getOwnPropertyDescriptor:Mg,getOwnPropertyNames:Gg,getOwnPropertySymbols:Rg,getPrototypeOf:tg}=Object,JA=globalThis,KI=JA.trustedTypes,Ng=KI?KI.emptyScript:"",kg=JA.reactiveElementPolyfillSupport,aA=(E,A)=>E,UA={toAttribute(E,A){switch(A){case Boolean:E=E?Ng:null;break;case Object:case Array:E=E==null?E:JSON.stringify(E)}return E},fromAttribute(E,A){let I=E;switch(A){case Boolean:I=E!==null;break;case Number:I=E===null?null:Number(E);break;case Object:case Array:try{I=JSON.parse(E)}catch{I=null}}return I}},VA=(E,A)=>!Kg(E,A),hI={attribute:!0,type:String,converter:UA,reflect:!1,useDefault:!1,hasChanged:VA};Symbol.metadata??=Symbol("metadata"),JA.litPropertyMetadata??=new WeakMap;class yA extends HTMLElement{static addInitializer(A){this._$Ei(),(this.l??=[]).push(A)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(A,I=hI){if(I.state&&(I.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(A)&&((I=Object.create(I)).wrapped=!0),this.elementProperties.set(A,I),!I.noAccessor){const g=Symbol(),Q=this.getPropertyDescriptor(A,g,I);Q!==void 0&&hg(this.prototype,A,Q)}}static getPropertyDescriptor(A,I,g){const{get:Q,set:D}=Mg(this.prototype,A)??{get(){return this[I]},set(S){this[I]=S}};return{get:Q,set(S){const a=Q?.call(this);D?.call(this,S),this.requestUpdate(A,a,g)},configurable:!0,enumerable:!0}}static getPropertyOptions(A){return this.elementProperties.get(A)??hI}static _$Ei(){if(this.hasOwnProperty(aA("elementProperties")))return;const A=tg(this);A.finalize(),A.l!==void 0&&(this.l=[...A.l]),this.elementProperties=new Map(A.elementProperties)}static finalize(){if(this.hasOwnProperty(aA("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(aA("properties"))){const I=this.properties,g=[...Gg(I),...Rg(I)];for(const Q of g)this.createProperty(Q,I[Q])}const A=this[Symbol.metadata];if(A!==null){const I=litPropertyMetadata.get(A);if(I!==void 0)for(const[g,Q]of I)this.elementProperties.set(g,Q)}this._$Eh=new Map;for(const[I,g]of this.elementProperties){const Q=this._$Eu(I,g);Q!==void 0&&this._$Eh.set(Q,I)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(A){const I=[];if(Array.isArray(A)){const g=new Set(A.flat(1/0).reverse());for(const Q of g)I.unshift(yI(Q))}else A!==void 0&&I.push(yI(A));return I}static _$Eu(A,I){const g=I.attribute;return g===!1?void 0:typeof g=="string"?g:typeof A=="string"?A.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(A=>this.enableUpdating=A),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(A=>A(this))}addController(A){(this._$EO??=new Set).add(A),this.renderRoot!==void 0&&this.isConnected&&A.hostConnected?.()}removeController(A){this._$EO?.delete(A)}_$E_(){const A=new Map,I=this.constructor.elementProperties;for(const g of I.keys())this.hasOwnProperty(g)&&(A.set(g,this[g]),delete this[g]);A.size>0&&(this._$Ep=A)}createRenderRoot(){const A=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return yg(A,this.constructor.elementStyles),A}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(A=>A.hostConnected?.())}enableUpdating(A){}disconnectedCallback(){this._$EO?.forEach(A=>A.hostDisconnected?.())}attributeChangedCallback(A,I,g){this._$AK(A,g)}_$ET(A,I){const g=this.constructor.elementProperties.get(A),Q=this.constructor._$Eu(A,g);if(Q!==void 0&&g.reflect===!0){const D=(g.converter?.toAttribute!==void 0?g.converter:UA).toAttribute(I,g.type);this._$Em=A,D==null?this.removeAttribute(Q):this.setAttribute(Q,D),this._$Em=null}}_$AK(A,I){const g=this.constructor,Q=g._$Eh.get(A);if(Q!==void 0&&this._$Em!==Q){const D=g.getPropertyOptions(Q),S=typeof D.converter=="function"?{fromAttribute:D.converter}:D.converter?.fromAttribute!==void 0?D.converter:UA;this._$Em=Q;const a=S.fromAttribute(I,D.type);this[Q]=a??this._$Ej?.get(Q)??a,this._$Em=null}}requestUpdate(A,I,g,Q=!1,D){if(A!==void 0){const S=this.constructor;if(Q===!1&&(D=this[A]),g??=S.getPropertyOptions(A),!((g.hasChanged??VA)(D,I)||g.useDefault&&g.reflect&&D===this._$Ej?.get(A)&&!this.hasAttribute(S._$Eu(A,g))))return;this.C(A,I,g)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(A,I,{useDefault:g,reflect:Q,wrapped:D},S){g&&!(this._$Ej??=new Map).has(A)&&(this._$Ej.set(A,S??I??this[A]),D!==!0||S!==void 0)||(this._$AL.has(A)||(this.hasUpdated||g||(I=void 0),this._$AL.set(A,I)),Q===!0&&this._$Em!==A&&(this._$Eq??=new Set).add(A))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(I){Promise.reject(I)}const A=this.scheduleUpdate();return A!=null&&await A,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[Q,D]of this._$Ep)this[Q]=D;this._$Ep=void 0}const g=this.constructor.elementProperties;if(g.size>0)for(const[Q,D]of g){const{wrapped:S}=D,a=this[Q];S!==!0||this._$AL.has(Q)||a===void 0||this.C(Q,void 0,D,a)}}let A=!1;const I=this._$AL;try{A=this.shouldUpdate(I),A?(this.willUpdate(I),this._$EO?.forEach(g=>g.hostUpdate?.()),this.update(I)):this._$EM()}catch(g){throw A=!1,this._$EM(),g}A&&this._$AE(I)}willUpdate(A){}_$AE(A){this._$EO?.forEach(I=>I.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(A)),this.updated(A)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(A){return!0}update(A){this._$Eq&&=this._$Eq.forEach(I=>this._$ET(I,this[I])),this._$EM()}updated(A){}firstUpdated(A){}}yA.elementStyles=[],yA.shadowRootOptions={mode:"open"},yA[aA("elementProperties")]=new Map,yA[aA("finalized")]=new Map,kg?.({ReactiveElement:yA}),(JA.reactiveElementVersions??=[]).push("2.1.2");const Fg={attribute:!0,type:String,converter:UA,reflect:!1,hasChanged:VA},Jg=(E=Fg,A,I)=>{const{kind:g,metadata:Q}=I;let D=globalThis.litPropertyMetadata.get(Q);if(D===void 0&&globalThis.litPropertyMetadata.set(Q,D=new Map),g==="setter"&&((E=Object.create(E)).wrapped=!0),D.set(I.name,E),g==="accessor"){const{name:S}=I;return{set(a){const M=A.get.call(this);A.set.call(this,a),this.requestUpdate(S,M,E,!0,a)},init(a){return a!==void 0&&this.C(S,void 0,E,a),a}}}if(g==="setter"){const{name:S}=I;return function(a){const M=this[S];A.call(this,a),this.requestUpdate(S,M,E,!0,a)}}throw Error("Unsupported decorator location: "+g)};function Ug(E){return(A,I)=>typeof I=="object"?Jg(E,A,I):((g,Q,D)=>{const S=Q.hasOwnProperty(D);return Q.constructor.createProperty(D,g),S?Object.getOwnPropertyDescriptor(Q,D):void 0})(E,A,I)}const cg=(E,A,I)=>(I.configurable=!0,I.enumerable=!0,Reflect.decorate&&typeof A!="object"&&Object.defineProperty(E,A,I),I);function Lg(E,A){return(I,g,Q)=>{const D=S=>S.renderRoot?.querySelector(E)??null;return cg(I,g,{get(){return D(this)}})}}var h=(E=>(E.INITIAL="initial",E.DISCONNECTED="disconnected",E.CONNECTING="connecting",E.WAITING_FOR_DEVICE_SELECTION="waiting_for_device_selection",E.CONNECTED_PHYSICAL="connected_physical",E.CONNECTED_MOUSE_FALLBACK="connected_mouse_fallback",E.SIGNING_ACTIVE="signing_active",E.PROCESSING_OK="processing_ok",E.PROCESSING_CLEAR="processing_clear",E.PROCESSING_CANCEL="processing_cancel",E.DISCONNECTING="disconnecting",E.ERROR="error",E))(h||{}),L=(E=>(E.SIGN_PEN="sign-pen",E.SIGN_OK="sign-ok",E.SIGN_CLEAR="sign-clear",E.SIGN_CANCEL="sign-cancel",E.SIGN_ERROR="sign-error",E.SIGN_CONNECT="sign-connect",E.SIGN_DISCONNECT="sign-disconnect",E.SIGN_CONNECTING="sign-connecting",E))(L||{}),MI=(E=>(E.OK="OK",E.CLEAR="CLEAR",E.CANCEL="CANCEL",E.CLEAR_SIGNATURE="CLEAR_SIGNATURE",E.DISCONNECT="DISCONNECT",E.CONNECT_SIGNPAD="CONNECT_SIGNPAD",E))(MI||{}),k=(E=>(E.AUTO_CONNECTING="AUTO_CONNECTING",E.CONNECTING_TO_DEVICE="CONNECTING_TO_DEVICE",E.REVERTING_TO_DEFAULT="REVERTING_TO_DEFAULT",E.DISCONNECTING_DEVICE="DISCONNECTING_DEVICE",E.COMPONENT_INITIALIZED="COMPONENT_INITIALIZED",E.TEXT_START_SIGNING="TEXT_START_SIGNING",E.TEXT_SIGN_WITH_PHYSICAL="TEXT_SIGN_WITH_PHYSICAL",E.TEXT_SIGN_WITH_MOUSE="TEXT_SIGN_WITH_MOUSE",E.TEXT_SIGN_GENERIC="TEXT_SIGN_GENERIC",E.TEXT_SIGNING_WITH_DEVICE="TEXT_SIGNING_WITH_DEVICE",E.NO_DEVICE_FOUND="NO_DEVICE_FOUND",E.CONNECTION_ERROR="CONNECTION_ERROR",E.ERROR_DISCONNECTION="ERROR_DISCONNECTION",E.ERROR_INSTANTIATING_DRIVER="ERROR_INSTANTIATING_DRIVER",E.SIGNPAD_DISCONNECTED="SIGNPAD_DISCONNECTED",E.INVALID_LICENSE_KEY="INVALID_LICENSE_KEY",E.READY_TO_CONNECT="READY_TO_CONNECT",E.SIGNPAD_DETECTED="SIGNPAD_DETECTED",E.READY_TO_SIGN_MOUSE="READY_TO_SIGN_MOUSE",E.READY_TO_SIGN_PHYSICAL="READY_TO_SIGN_PHYSICAL",E))(k||{}),m=(E=>(E.MOUSE="MOUSE",E.CONNECTED_UNKNOWN="CONNECTED_UNKNOWN_DEVICE",E))(m||{});class eg{constructor(A){this.component=A}async handleClear(){await this.executeAction(h.PROCESSING_CLEAR,async()=>{await this.component.connectionManager.clearSignature(),await this.component.config.actionHandlers?.handleClear?.(),this.component.dispatch(L.SIGN_CLEAR)})}async handleOk(){return await this.executeAction(h.PROCESSING_OK,async()=>{const A=await this.component.connectionManager.stopSigning();return await this.component.config.actionHandlers?.handleOk?.(A),this.component.dispatch(L.SIGN_OK,A),A})}async handleCancel(){await this.executeAction(h.PROCESSING_CANCEL,async()=>{await this.component.connectionManager.stopSigning(),await this.component.config.actionHandlers?.handleCancel?.(),this.component.dispatch(L.SIGN_CANCEL)})}async startSigning(A){const I=this.component.connectionManager,g=this.component.canvasRef;if(!I.hasSignatureLayer()||!g){this.handleStartSigningError();return}this.component.stateManager.transitionTo(h.CONNECTING,"Preparing session...");try{this.component.resetDrawingState(),await I.startSigning(g,A);const Q=await this.getReadyState(),D=Q===h.CONNECTED_MOUSE_FALLBACK?"READY_TO_SIGN_MOUSE":"READY_TO_SIGN_PHYSICAL";this.component.stateManager.transitionTo(Q,D)}catch(Q){this.handleError("Error starting signing session",Q)}}async stopSigning(){return this.component.connectionManager.stopSigning()}async executeAction(A,I){this.component.stateManager.transitionTo(A,"Processing...");try{const g=await I();return this.component.resetDrawingState(),await this.startSigning(),g}catch(g){throw this.handleError("Error during action processing",g),g}}async getReadyState(){const A=this.component.connectionManager.isDeviceConnected(),I=await this.component.connectionManager.getDeviceInfo();return this.component.connectionManager.isFallback(I,A,!0)?h.CONNECTED_MOUSE_FALLBACK:h.CONNECTED_PHYSICAL}handleStartSigningError(){this.component.currentState===h.CONNECTED_MOUSE_FALLBACK&&(this.component.resetDrawingState(),this.component.mouseManager?.addListeners(),this.component.stateManager.transitionTo(h.CONNECTED_MOUSE_FALLBACK))}handleError(A,I){console.error(`Signosoft Signpad: ${A}`,I),this.component.stateManager.transitionTo(h.ERROR,A,I)}}class Yg{constructor(A,I={minWidth:2,maxWidth:4,color:"#000000"}){this.canvas=A;const g=A.getContext("2d");if(!g)throw new Error("Could not get 2D rendering context for canvas.");this.ctx=g,this.currentDrawingOptions=I,this.configureCanvasForDPI(),this.applyDrawingStyles(this.currentDrawingOptions)}get drawingOptions(){return{...this.currentDrawingOptions}}updateDrawingOptions(A){this.currentDrawingOptions=A,this.applyDrawingStyles(this.currentDrawingOptions)}drawSegment(A){}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height)}configureCanvasForDPI(){const A=window.devicePixelRatio||1,I=this.canvas.getBoundingClientRect(),g=I.width||this.canvas.clientWidth||0,Q=I.height||this.canvas.clientHeight||0;if(g<=0||Q<=0)return;const D=Math.round(g*A),S=Math.round(Q*A);this.canvas.width===D&&this.canvas.height===S||(this.canvas.width=D,this.canvas.height=S,this.applyDrawingStyles(this.currentDrawingOptions))}applyDrawingStyles(A){this.ctx.strokeStyle=A.color??"#000000",this.ctx.fillStyle=A.color??"#000000",this.ctx.lineCap="round",this.ctx.lineJoin="round",this.ctx.globalCompositeOperation="source-over"}}const lA=class lA{constructor(A){this.sigLayer=null,this.debugCallbackRegistrationCount=0,this.cachedDeviceInfo=null,this.lastPenDispatchTime=0,this.penDataToDispatch=null,this.throttleDelayMs=16,this.component=A}async connect(A=!1,I=!1){this.component.stateManager.transitionTo(h.CONNECTING,A?k.AUTO_CONNECTING:k.CONNECTING_TO_DEVICE);try{const g=await this.runDriverConnectAttempt(A),Q=this.resolveConnectionTarget(g,I);return Q?(await this.prepareSigningSession(),this.component.stateManager.transitionTo(Q.targetState,Q.statusMessageKey),this.component.dispatch(L.SIGN_CONNECT,{deviceInfo:g.deviceInfo}),!0):(this.component.stateManager.transitionTo(h.DISCONNECTED,k.NO_DEVICE_FOUND),!1)}catch(g){return console.error("Signosoft Signpad: Error in connect method:",g),this.component.stateManager.transitionTo(h.ERROR,k.CONNECTION_ERROR,g),!1}}async disconnect(){this.component.stateManager.transitionTo(h.DISCONNECTING,k.DISCONNECTING_DEVICE);try{if(!this.sigLayer)return;if(!this.sigLayer.isConnected()){this.sigLayer=null,this.cachedDeviceInfo=null;return}await this.sigLayer.disconnect(),this.sigLayer=null,this.cachedDeviceInfo=null}catch(A){console.error("Signosoft Signpad: Error during disconnect",A),this.component.stateManager.transitionTo(h.ERROR,k.ERROR_DISCONNECTION,A)}}hasSignatureLayer(){return this.sigLayer!==null}async getDeviceInfo(){if(this.cachedDeviceInfo)return this.cachedDeviceInfo;const A=this.normalizeDeviceInfo(await this.sigLayer?.getDeviceInfo());return this.cachedDeviceInfo=A??null,A}isDeviceConnected(){return this.sigLayer?.isConnected()??!1}isSigningActive(){return this.sigLayer?.isInSigningMode?.()??!1}async startSigning(A,I){if(!this.sigLayer)return!1;const g=I??this.component.configManager.getDrawingOptions();return await this.sigLayer.startSigning(A,!0,g),!0}async stopSigning(){try{if(this.sigLayer)return await this.sigLayer.stopSigning()}catch(A){console.warn("Signosoft Signpad: SigLayer stop failed, continuing cleanup",A)}finally{this.component.mouseManager?.removeListeners(),this.component.resetDrawingState(),console.log("[ConnectionManager] Signing stopped and mouse listeners removed.")}}async clearSignature(){this.sigLayer?.isInSigningMode&&await this.sigLayer.clearSignature()}async ensureSignatureLayer(){if(!this.sigLayer)try{this.sigLayer=new SignatureLayer,this.setupCallbacks()}catch(A){throw console.error("Signosoft Signpad: Error instantiating driver",A),this.component.stateManager.transitionTo(h.ERROR,k.ERROR_INSTANTIATING_DRIVER,A),A}}setupCallbacks(){this.sigLayer&&(this.debugCallbackRegistrationCount+=1,console.log(`[Signpad Debug] SignatureLayer callbacks registered (${this.debugCallbackRegistrationCount})`),this.sigLayer.onOK(()=>this.component.buttonManager.handleOk()),this.sigLayer.onClear(()=>this.component.buttonManager.handleClear()),this.sigLayer.onCancel(()=>this.component.buttonManager.handleCancel()),this.sigLayer.onPen(A=>{A.inContact&&!this.component.hasStartedDrawing&&this.component.stateManager.setDrawingStarted(!0),this.runThrottledPenDispatch(A)}),this.sigLayer.onUnexpectedDisconnect(()=>{const A=this.component.currentState;A!==h.DISCONNECTING&&A!==h.INITIAL&&A!==h.DISCONNECTED&&A!==h.ERROR&&this.component.recoverToMouseFallback(k.REVERTING_TO_DEFAULT,1e3)}))}runThrottledPenDispatch(A){if(this.component.stateManager.isBusy||this.component.stateManager.isError)return;this.penDataToDispatch=A;const I=performance.now();I-this.lastPenDispatchTime>this.throttleDelayMs&&(this.component.dispatch(L.SIGN_PEN,this.penDataToDispatch),this.lastPenDispatchTime=I,this.penDataToDispatch=null)}async initWithLease(A){await this.ensureSignatureLayer(),this.sigLayer&&await this.sigLayer.initialize(A)}isFallback(A,I,g){const D=(A?.deviceName??A?.name??null)==="Pointer Input (Fallback Mode)",S=this.component.currentState===h.CONNECTED_MOUSE_FALLBACK,a=this.component.deviceStatusText===m.MOUSE;return D||S||a||g&&!I}normalizeDeviceInfo(A){return A?!A.deviceName&&A.name?{...A,deviceName:A.name}:A:null}async runDriverConnectAttempt(A){const I=await this.sigLayer?.connect(A),g=this.sigLayer?.isConnected()??!1,Q=!!(I&&g),D=Q?this.normalizeDeviceInfo(await this.sigLayer?.getDeviceInfo()):null;this.cachedDeviceInfo=D??null;const S=D?.deviceName??D?.name??null,a=Q&&S===lA.POINTER_FALLBACK_DEVICE_NAME;return{connected:Q,deviceInfo:D,isPointerFallback:a}}resolveConnectionTarget(A,I){if(A.connected&&!A.isPointerFallback){const g=A.deviceInfo?.deviceName??A.deviceInfo?.name??m.CONNECTED_UNKNOWN;return this.component.setDeviceStatusText(g),this.component.mouseManager?.areListenersAttached()&&this.component.mouseManager?.removeListeners(),{targetState:h.CONNECTED_PHYSICAL,statusMessageKey:k.TEXT_SIGN_WITH_PHYSICAL}}return A.connected&&A.isPointerFallback||!A.connected&&I?(this.component.setDeviceStatusText(m.MOUSE),{targetState:h.CONNECTED_MOUSE_FALLBACK,statusMessageKey:k.TEXT_SIGN_WITH_MOUSE}):null}async prepareSigningSession(){const A=this.component.canvasRef,I=this.component.configManager.getDrawingOptions();this.sigLayer?.isInSigningMode?.()&&await this.sigLayer.stopSigning(),await this.sigLayer?.startSigning(A,!0,I)}};lA.POINTER_FALLBACK_DEVICE_NAME="Pointer Input (Fallback Mode)";let zA=lA;class ng{constructor(A){this.component=A}get deviceStatusKey(){return this.component.currentState===h.CONNECTED_MOUSE_FALLBACK?m.MOUSE:this.isConnected?this.component.deviceStatusText||m.CONNECTED_UNKNOWN:m.MOUSE}get statusMessageKey(){return this.component.statusMessage||""}get additionalTextKey(){const A=h,I=k,g=this.component.statusMessage;switch(this.component.currentState){case A.INITIAL:case A.ERROR:return I.TEXT_START_SIGNING;case A.DISCONNECTED:return g===I.READY_TO_CONNECT||g===I.SIGNPAD_DETECTED||g===I.COMPONENT_INITIALIZED?I.TEXT_START_SIGNING:I.TEXT_SIGN_GENERIC;case A.CONNECTED_PHYSICAL:return I.TEXT_SIGN_WITH_PHYSICAL;case A.CONNECTED_MOUSE_FALLBACK:return I.TEXT_SIGN_WITH_MOUSE;case A.SIGNING_ACTIVE:return I.TEXT_SIGNING_WITH_DEVICE;default:return I.TEXT_SIGN_GENERIC}}get isConnected(){const A=this.component.currentState;return A===h.CONNECTED_PHYSICAL||A===h.CONNECTED_MOUSE_FALLBACK||A===h.SIGNING_ACTIVE||A===h.PROCESSING_OK||A===h.PROCESSING_CLEAR||A===h.PROCESSING_CANCEL}get isPhysicalConnected(){const A=this.component.currentState;return A===h.CONNECTED_PHYSICAL||A===h.SIGNING_ACTIVE||A===h.PROCESSING_OK||A===h.PROCESSING_CLEAR||A===h.PROCESSING_CANCEL}get isBusy(){const A=this.component.currentState;return A===h.CONNECTING||A===h.WAITING_FOR_DEVICE_SELECTION||A===h.PROCESSING_OK||A===h.PROCESSING_CLEAR||A===h.PROCESSING_CANCEL||A===h.DISCONNECTING}get isError(){return this.component.currentState===h.ERROR}get actionButtonsDisabled(){return!this.isConnected||!this.component.hasStartedDrawing||this.isBusy}get connectButtonDisabled(){return this.isBusy||this.isPhysicalConnected}get disconnectButtonDisabled(){const A=this.component.currentState;return A===h.DISCONNECTED||A===h.INITIAL||this.isBusy}transitionTo(A,I="",g){const Q=this.component.currentState;Q===A&&this.component.statusMessage===I&&!g||(this.component.setCurrentState(A),this.component.setStatusMessage(I),this.handleSideEffects(A,Q),A===h.CONNECTING&&this.component.dispatch(L.SIGN_CONNECTING),g&&this.component.dispatch(L.SIGN_ERROR,g))}setDrawingStarted(A){this.component.hasStartedDrawing!==A&&this.component.setHasStartedDrawing(A)}handleSideEffects(A,I){const g=Q=>Q===h.INITIAL||Q===h.DISCONNECTED||Q===h.ERROR;g(A)?(this.component.setDeviceStatusText(m.MOUSE),this.component.setCanvasPointerInputEnabled(!0),g(I)||(this.component.resetDrawingState(),this.component.mouseManager?.removeListeners())):(A===h.CONNECTED_PHYSICAL||A===h.CONNECTED_MOUSE_FALLBACK)&&(A===h.CONNECTED_MOUSE_FALLBACK?I===h.PROCESSING_OK||I===h.PROCESSING_CANCEL?(this.component.mouseManager?.removeListeners(),this.component.setCanvasPointerInputEnabled(!1)):(this.component.mouseManager?.addListeners(),this.component.setCanvasPointerInputEnabled(!0)):(this.component.mouseManager?.removeListeners(),this.component.setCanvasPointerInputEnabled(!1)))}}class Hg{constructor(A,I){this.isDrawing=!1,this.sequenceCounter=0,this.sessionStartTime=null,this.debugListenerRegistrationCount=0,this.listenersAttached=!1,this.canvas=A,this.onPenData=I,this.boundHandleMouseDown=this.handleMouseDown.bind(this),this.boundHandleMouseMove=this.handleMouseMove.bind(this),this.boundHandleMouseUp=this.handleMouseUp.bind(this),this.boundHandleMouseLeave=this.handleMouseLeave.bind(this)}get isCurrentlyDrawing(){return this.isDrawing}addListeners(){if(this.listenersAttached){console.log("[Signpad Debug] Mouse listeners already registered");return}this.listenersAttached=!0,this.debugListenerRegistrationCount+=1,console.log(`[Signpad Debug] Mouse listeners registered (${this.debugListenerRegistrationCount})`),this.canvas.addEventListener("mousedown",this.boundHandleMouseDown),this.canvas.addEventListener("mousemove",this.boundHandleMouseMove),this.canvas.addEventListener("mouseup",this.boundHandleMouseUp),this.canvas.addEventListener("mouseleave",this.boundHandleMouseLeave)}removeListeners(){if(!this.listenersAttached){console.log("[Signpad Debug] Mouse listeners already removed");return}this.listenersAttached=!1,console.log("[Signpad Debug] Mouse listeners removed"),this.canvas.removeEventListener("mousedown",this.boundHandleMouseDown),this.canvas.removeEventListener("mousemove",this.boundHandleMouseMove),this.canvas.removeEventListener("mouseup",this.boundHandleMouseUp),this.canvas.removeEventListener("mouseleave",this.boundHandleMouseLeave),this.isDrawing=!1,this.sequenceCounter=0}areListenersAttached(){return this.listenersAttached}resetSession(){this.isDrawing=!1,this.sequenceCounter=0,this.sessionStartTime=null}handleMouseDown(A){this.isDrawing=!0,this.sequenceCounter=0,this.sessionStartTime===null&&(this.sessionStartTime=Date.now()),this.processMouseEvent(A,!0)}handleMouseMove(A){this.isDrawing&&(this.sequenceCounter++,this.processMouseEvent(A,!0))}handleMouseUp(A){this.isDrawing&&(this.isDrawing=!1,this.processMouseEvent(A,!1),this.sequenceCounter=0)}handleMouseLeave(A){this.isDrawing&&(this.isDrawing=!1,this.processMouseEvent(A,!1),this.sequenceCounter=0)}processMouseEvent(A,I){const{x:g,y:Q}=this.getNormalizedCoordinates(A),D={relativeX:g,relativeY:Q,pressure:I?.5:0,inContact:I,timestamp:this.timestampToSeconds()};this.onPenData(D)}getNormalizedCoordinates(A){const I=this.canvas.getBoundingClientRect(),g=(A.clientX-I.left)/I.width,Q=(A.clientY-I.top)/I.height;return{x:g,y:Q}}timestampToSeconds(){this.sessionStartTime===null&&(this.sessionStartTime=Date.now());const I=(Date.now()-this.sessionStartTime)/1e3;return Number(I.toFixed(3))}}const cA={en:{OK:"OK",CLEAR:"Clear",CANCEL:"Cancel",CLEAR_SIGNATURE:"Clear signature",DISCONNECT:"Disconnect",CONNECT_SIGNPAD:"Connect Signpad",MOUSE:"Mouse",CONNECTED_UNKNOWN_DEVICE:"Connected (Unknown Device)",AUTO_CONNECTING:"Auto-connecting to device...",CONNECTING_TO_DEVICE:"Connecting to your device...",REVERTING_TO_DEFAULT:"Reverting to default input...",DISCONNECTING_DEVICE:"Disconnecting device...",COMPONENT_INITIALIZED:"Component initialized.",TEXT_START_SIGNING:"Connect your device.",TEXT_SIGN_WITH_PHYSICAL:"Please sign using the device pen.",TEXT_SIGN_WITH_MOUSE:"Please sign using your mouse.",TEXT_SIGN_GENERIC:"Sign in the area above using mouse or pen.",TEXT_SIGNING_WITH_DEVICE:"Signing with {device}",NO_DEVICE_FOUND:"No device found.",CONNECTION_ERROR:"Connection error.",ERROR_DISCONNECTION:"Error during disconnection.",ERROR_INSTANTIATING_DRIVER:"Error instantiating driver.",SIGNPAD_DISCONNECTED:"Signpad disconnected.",INVALID_LICENSE_KEY:"Invalid license key.",READY_TO_CONNECT:"Ready to connect.",SIGNPAD_DETECTED:"Signpad detected. Click 'Connect Signpad' to begin.",READY_TO_SIGN_MOUSE:"Ready to sign. Use your mouse.",READY_TO_SIGN_PHYSICAL:"Ready to sign. Use the device pen."},cs:{OK:"OK",CLEAR:"Smazat",CANCEL:"Zrušit",CLEAR_SIGNATURE:"Smazat podpis",DISCONNECT:"Odpojit",CONNECT_SIGNPAD:"Připojit Signpad",MOUSE:"Myš",CONNECTED_UNKNOWN_DEVICE:"Připojeno (neznámé zařízení)",AUTO_CONNECTING:"Automatické připojování k zařízení...",CONNECTING_TO_DEVICE:"Připojování k vašemu zařízení...",REVERTING_TO_DEFAULT:"Přepínání na výchozí vstup...",DISCONNECTING_DEVICE:"Odpojování zařízení...",COMPONENT_INITIALIZED:"Komponenta byla inicializována.",TEXT_START_SIGNING:"Připojte své zařízení.",TEXT_SIGN_WITH_PHYSICAL:"Podepište se perem zařízení.",TEXT_SIGN_WITH_MOUSE:"Podepište se pomocí myši.",TEXT_SIGN_GENERIC:"Podepište se v oblasti výše pomocí myši nebo pera.",TEXT_SIGNING_WITH_DEVICE:"Podepisování pomocí: {device}",NO_DEVICE_FOUND:"Zařízení nebylo nalezeno.",CONNECTION_ERROR:"Chyba připojení.",ERROR_DISCONNECTION:"Chyba při odpojování.",ERROR_INSTANTIATING_DRIVER:"Chyba při inicializaci ovladače.",SIGNPAD_DISCONNECTED:"Signpad byl odpojen.",INVALID_LICENSE_KEY:"Neplatný licenční klíč.",READY_TO_CONNECT:"Připraveno k připojení.",SIGNPAD_DETECTED:"Signpad byl nalezen. Klikněte na 'Připojit Signpad' pro spuštění.",READY_TO_SIGN_MOUSE:"Připraveno k podpisu. Použijte myš.",READY_TO_SIGN_PHYSICAL:"Připraveno k podpisu. Použijte pero zařízení."}};class rg{constructor(A){this.translations=cA.en,this.currentLang="",this.currentPath=void 0,this.component=A}t(A,I={}){let g=this.translations[A]||A;for(const[Q,D]of Object.entries(I))g=g.replace(new RegExp(`{${Q}}`,"g"),D);return g}async loadLanguage(A,I,g){const Q=I?.trim();if(A===this.currentLang&&Q===this.currentPath)return;let D=this.getBaselineTranslations(A);const S=this.resolveInlineTranslations(A,g);if(S){this.translations={...D,...S},this.currentLang=A,this.currentPath=Q,this.component.requestUpdate();return}if(!Q){this.translations=D,this.currentLang=A,this.currentPath=Q,this.component.requestUpdate();return}const a=this.constructUrl(A,Q);try{const M=await fetch(a);if(M.ok){const F=await M.json();D={...D,...F},console.log(`signosoft-signpad: External translations loaded from ${a}`)}else I&&console.info(`signosoft-signpad: Custom path provided, but file not found at ${a}`)}catch(M){console.warn(`signosoft-signpad: Failed to load external translations from ${a}. Using built-in defaults.`,M)}this.translations=D,this.currentLang=A,this.currentPath=Q,this.component.requestUpdate()}getBaselineTranslations(A){const I=cA.en;return A!=="en"&&cA.hasOwnProperty(A)?{...I,...cA[A]}:{...I}}resolveInlineTranslations(A,I){return I?typeof Object.values(I)[0]=="string"?I:I[A]:void 0}constructUrl(A,I){const g=I.trim();let Q="";return g.endsWith(".json")?Q=g:Q=`${g.replace(/\/+$/,"")}/${A}.json`,Q}}class qg{constructor(A){this.configEventHandlers={},this.customEventListenerCache=new WeakMap,this.component=A}apply(A){const I=this.component.config;if(!I){this.clearConfigEventHandlers();return}this.applyLocalization(A,I),this.applyDrawingOptions(A,I),this.syncConfigEventHandlers(I)}getUiVisibilityOptions(){const A=this.component.config.uiVisibilityOptions;return{topBarVisible:A?.topBarVisible??!0,topBarClearButtonVisible:A?.topBarClearButtonVisible??!1,topBarConnectButtonVisible:A?.topBarConnectButtonVisible??!0,bottomBarVisible:A?.bottomBarVisible??!0,okButtonVisible:A?.okButtonVisible??!0,clearButtonVisible:A?.clearButtonVisible??!0,cancelButtonVisible:A?.cancelButtonVisible??!0,canvasLineVisible:A?.canvasLineVisible??!0,deviceStatusTextVisible:A?.deviceStatusTextVisible??!0,additionalTextVisible:A?.additionalTextVisible??!0}}getDrawingOptions(){const A=this.component.config.canvasAndDrawingOptions;return{minWidth:A?.minWidth??1,maxWidth:A?.maxWidth??3,color:A?.color??"#000000"}}applyLocalization(A,I){const g=A?.languageOptions,Q=I.languageOptions;(!A||g?.lang!==Q?.lang||g?.langPath!==Q?.langPath||g?.translations!==Q?.translations)&&this.component.localizationManager.loadLanguage(Q?.lang??"en",Q?.langPath,Q?.translations)}applyDrawingOptions(A,I){const g=A?.canvasAndDrawingOptions,Q=I.canvasAndDrawingOptions;this.component.canvasManager&&(!A||g?.minWidth!==Q?.minWidth||g?.maxWidth!==Q?.maxWidth||g?.color!==Q?.color)&&this.component.canvasManager.updateDrawingOptions(this.getDrawingOptions())}syncConfigEventHandlers(A){const I=S=>{if(!S)return;const a=this.customEventListenerCache.get(S);if(a)return a;const M=F=>{S(F)};return this.customEventListenerCache.set(S,M),M},g=A.eventCallbacks,Q={[L.SIGN_CONNECT]:I(g?.onConnect),[L.SIGN_CONNECTING]:I(g?.onConnecting),[L.SIGN_DISCONNECT]:I(g?.onDisconnect),[L.SIGN_PEN]:I(g?.onPen),[L.SIGN_OK]:I(g?.onOk),[L.SIGN_CLEAR]:I(g?.onClear),[L.SIGN_CANCEL]:I(g?.onCancel),[L.SIGN_ERROR]:I(g?.onError)},D=new Set([...Object.keys(this.configEventHandlers),...Object.keys(Q)]);for(const S of D){const a=this.configEventHandlers[S],M=Q[S];a&&a!==M&&this.component.removeEventListener(S,a),M&&a!==M&&this.component.addEventListener(S,M),M?this.configEventHandlers[S]=M:delete this.configEventHandlers[S]}}clearConfigEventHandlers(){for(const[A,I]of Object.entries(this.configEventHandlers))I&&this.component.removeEventListener(A,I);this.configEventHandlers={}}}const lg=":host{--primary-color-0: #4e56ea;--primary-color-10: #7178ee;--background-color-0: #f1f2fd;--background-color-10: #e3e4fc;--text-color-0: #333e4a;--white-color: #ffffff;--grey-color: #b5b9be;--min-height: 48px;--spacing-constraints: 16px 24px;--sign-font-family: Arial, Helvetica, sans-serif;--sign-common-border-radius: 8px;--sign-top-bar-bg-base: var(--background-color-10);--sign-top-bar-text-base: var(--primary-color-0);--sign-top-bar-padding: var(--spacing-constraints);--sign-top-bar-min-height: var(--min-height);--sign-top-bar-border-top-left-radius: var(--sign-common-border-radius);--sign-top-bar-border-top-right-radius: var(--sign-common-border-radius);--sign-top-bar-border-bottom-left-radius: 0;--sign-top-bar-border-bottom-right-radius: 0;--sign-canvas-bg-base: var(--background-color-0);--sign-canvas-wrapper-border-top-left-radius: 0;--sign-canvas-wrapper-border-top-right-radius: 0;--sign-canvas-wrapper-border-bottom-left-radius: 0;--sign-canvas-wrapper-border-bottom-right-radius: 0;--sign-line-height: 22px;--sign-line-margin-bottom: 16px;--sign-line-border-base: var(--primary-color-10);--sign-line-additional-text-color: var(--text-color-0);--sign-line-margin: 0px 24px var(--sign-line-margin-bottom) 24px;--sign-canvas-line-text-font-size: 12px;--sign-canvas-height-offset: var(--sign-line-height);--sign-bottom-bar-bg-base: var(--background-color-10);--sign-bottom-bar-padding: var(--spacing-constraints);--sign-bottom-bar-min-height: var(--min-height);--sign-bottom-bar-gap: 12px;--sign-bottom-bar-border-top-left-radius: 0;--sign-bottom-bar-border-top-right-radius: 0;--sign-bottom-bar-border-bottom-left-radius: var(--sign-common-border-radius);--sign-bottom-bar-border-bottom-right-radius: var( --sign-common-border-radius );--sign-button-font-size: 16px;--sign-button-padding: 14px 16px;--sign-button-min-height: var(--min-height);--sign-button-border-radius: var(--sign-common-border-radius);--sign-button-font-weight: 500;--sign-button-primary-bg-base: var(--primary-color-0);--sign-button-primary-bg-hover: var(--primary-color-10);--sign-button-primary-bg-disabled: var(--grey-color);--sign-button-primary-text-base: var(--white-color);--sign-button-primary-text-hover: var(--white-color);--sign-button-primary-text-disabled: var(--white-color);--sign-button-primary-border-base: 1px solid var(--primary-color-0);--sign-button-primary-border-hover: 1px solid var(--primary-color-10);--sign-button-primary-border-disabled: 1px solid var(--grey-color);--sign-button-link-bg-base: transparent;--sign-button-link-bg-hover: var(--background-color-10);--sign-button-link-bg-disabled: transparent;--sign-button-link-text-base: var(--primary-color-0);--sign-button-link-text-hover: var(--primary-color-10);--sign-button-link-text-disabled: var(--grey-color);--sign-button-link-border-base: 1px solid var(--primary-color-0);--sign-button-link-border-hover: 1px solid var(--primary-color-10);--sign-button-link-border-disabled: 1px solid var(--grey-color);--sign-device-state-text-color-connected: green;--sign-device-state-text-color-disconnected: red;--sign-loading-overlay-bg-color: rgba(255, 255, 255, .8);--sign-loading-overlay-text-color: var(--text-color-0);--sign-loading-overlay-spinner-color: var(--primary-color-0);--sign-loading-overlay-spinner-border-color: rgba(78, 86, 234, .1);--sign-loading-overlay-spinner-size: 30px}html{font-family:var(--sign-font-family)!important}.signpad-canvas-container{display:flex;flex-direction:column;width:100%;height:100%;min-width:380px}.signpad-top-bar{display:flex;justify-content:space-between;padding:var(--sign-top-bar-padding);min-height:var(--sign-top-bar-min-height);background-color:var(--sign-top-bar-bg-base);color:var(--sign-top-bar-text-base);align-items:center;border-top-left-radius:var(--sign-top-bar-border-top-left-radius);border-top-right-radius:var(--sign-top-bar-border-top-right-radius);border-bottom-left-radius:var(--sign-top-bar-border-bottom-left-radius);border-bottom-right-radius:var(--sign-top-bar-border-bottom-right-radius)}.signpad-top-left-actions,.signpad-top-right-actions{display:flex;gap:var(--sign-bottom-bar-gap)}.signpad-top-left-actions{justify-content:flex-start}.signpad-top-right-actions{justify-content:flex-end}.signpad-canvas-wrapper{position:relative;width:100%;padding-top:16px;padding-bottom:56.25%;height:0;background-color:var(--sign-canvas-bg-base);box-sizing:border-box;overflow:hidden;border-top-left-radius:var(--sign-canvas-wrapper-border-top-left-radius);border-top-right-radius:var(--sign-canvas-wrapper-border-top-right-radius);border-bottom-left-radius:var( --sign-canvas-wrapper-border-bottom-left-radius );border-bottom-right-radius:var( --sign-canvas-wrapper-border-bottom-right-radius )}.signpad-canvas-container>.signpad-canvas-wrapper:first-child{--sign-canvas-wrapper-border-top-left-radius: var( --sign-common-border-radius );--sign-canvas-wrapper-border-top-right-radius: var( --sign-common-border-radius )}.signpad-canvas-container>.signpad-canvas-wrapper:last-child{--sign-canvas-wrapper-border-bottom-left-radius: var( --sign-common-border-radius );--sign-canvas-wrapper-border-bottom-right-radius: var( --sign-common-border-radius )}.signpad-canvas{position:absolute;width:100%;height:calc(100% - (var(--sign-canvas-height-offset) + var(--sign-line-margin-bottom)));left:0;top:0}.signpad-canvas-line-container{position:absolute;bottom:0;left:0;right:0;display:flex;justify-content:space-between;align-items:center;height:var(--sign-line-height);border-top:2px solid var(--sign-line-border-base);box-sizing:border-box;padding-top:6px;margin:var(--sign-line-margin)}.signpad-canvas-line-additional-text,.signpad-canvas-line-state,.signpad-canvas-line-state.connected{font-family:var(--sign-font-family);font-size:var(--sign-canvas-line-text-font-size)}.signpad-canvas-line-additional-text{color:var(--sign-line-additional-text-color);margin:0}.signpad-canvas-line-state{color:var(--sign-device-state-text-color-disconnected);margin:0}.signpad-canvas-line-state.connected{color:var(--sign-device-state-text-color-connected)}.signpad-bottom-bar{display:flex;flex-direction:row;gap:var(--sign-bottom-bar-gap);padding:var(--sign-bottom-bar-padding);min-height:var(--sign-bottom-bar-min-height);background-color:var(--sign-bottom-bar-bg-base);border-top-left-radius:var(--sign-bottom-bar-border-top-left-radius);border-top-right-radius:var(--sign-bottom-bar-border-top-right-radius);border-bottom-left-radius:var(--sign-bottom-bar-border-bottom-left-radius);border-bottom-right-radius:var(--sign-bottom-bar-border-bottom-right-radius)}.btn{font-family:var(--sign-font-family);min-height:var(--sign-button-min-height);padding:var(--sign-button-padding);margin:0;font-weight:var(--sign-button-font-weight);width:100%;font-size:var(--sign-button-font-size);border-radius:var(--sign-button-border-radius);transition:background-color .3s ease,color .3s ease,transform .1s ease}.btn:hover:not(:disabled){cursor:pointer}.btn:focus:not(:disabled){outline:none}.btn-primary{background-color:var(--sign-button-primary-bg-base);color:var(--sign-button-primary-text-base);border:var(--sign-button-primary-border-base)}.btn-primary:hover:not(:disabled){background-color:var(--sign-button-primary-bg-hover);color:var(--sign-button-primary-text-hover);border:var(--sign-button-primary-border-hover)}.btn-primary:disabled{background-color:var(--sign-button-primary-bg-disabled);color:var(--sign-button-primary-text-disabled);border:var(--sign-button-primary-border-disabled)}.btn-link{background-color:var(--sign-button-link-bg-base);color:var(--sign-button-link-text-base);border:var(--sign-button-link-border-base)}.btn-link:hover:not(:disabled){background-color:var(--sign-button-link-bg-hover);color:var(--sign-button-link-text-hover);border:var(--sign-button-link-border-hover)}.btn-link:disabled{background-color:var(--sign-button-link-bg-disabled);color:var(--sign-button-link-text-disabled);border:var(--sign-button-link-border-disabled)}.signpad-loading-overlay{position:absolute;top:0;left:0;width:100%;height:100%;background-color:var(--sign-loading-overlay-bg-color);display:flex;flex-direction:column;justify-content:center;align-items:center;z-index:10;text-align:center;gap:10px}.signpad-loading-overlay .spinner{border:4px solid var(--sign-loading-overlay-spinner-border-color);border-left-color:var(--sign-loading-overlay-spinner-color);border-radius:50%;width:var(--sign-loading-overlay-spinner-size);height:var(--sign-loading-overlay-spinner-size);animation:spin 1s linear infinite}.signpad-loading-overlay-text{font-family:var(--sign-font-family);color:var(--sign-loading-overlay-text-color);font-size:14px;margin:16px 0 0}@keyframes spin{to{transform:rotate(360deg)}}";let GI=class{constructor(){this._device=null,this._isWasmInitialized=!1,this._module=null,this._disconnectHandler=null,this._eventCallbacks=new Map,this._callbackToHandle=new Map,this._masterCallback=null,this._penAspectCorrector=null,this._unexpectedDisconnectCallbacks=new Set}get device(){return this._device}get isWasmInitialized(){return this._isWasmInitialized}get Module(){return this._module}};typeof GI<"u"&&(window.TabletDriver=GI);var RI=(()=>{var E=typeof document<"u"?document.currentScript?.src:void 0;return(async function(A={}){var I,g=A,Q,D,S=new Promise((C,B)=>{Q=C,D=B}),a=typeof window=="object",M=typeof WorkerGlobalScope<"u",F=typeof process=="object"&&process.versions?.node&&process.type!="renderer";typeof __filename<"u"?E=__filename:M&&(E=self.location.href);var e="",p,f;if(F){var gA={};e=__dirname+"/",f=C=>(C=fA(C)?new URL(C):C,gA.readFileSync(C)),p=async C=>(C=fA(C)?new URL(C):C,gA.readFileSync(C,void 0)),process.argv.slice(2)}else if(a||M){try{e=new URL(".",E).href}catch{}M&&(f=C=>{var B=new XMLHttpRequest;return B.open("GET",C,!1),B.responseType="arraybuffer",B.send(null),new Uint8Array(B.response)}),p=async C=>{if(fA(C))return new Promise((i,o)=>{var w=new XMLHttpRequest;w.open("GET",C,!0),w.responseType="arraybuffer",w.onload=()=>{w.status==200||w.status==0&&w.response?i(w.response):o(w.status)},w.onerror=o,w.send(null)});var B=await fetch(C,{credentials:"same-origin"});if(B.ok)return B.arrayBuffer();throw Error(B.status+" : "+B.url)}}console.log.bind(console);var z=console.error.bind(console),CA,wA,dA=!1,BA,O,QA,AA,v,r,nI,AI,HI,rI,fA=C=>C.startsWith("file://");function qI(){var C=wA.buffer;BA=new Int8Array(C),QA=new Int16Array(C),g.HEAPU8=O=new Uint8Array(C),AA=new Uint16Array(C),v=new Int32Array(C),r=new Uint32Array(C),nI=new Float32Array(C),rI=new Float64Array(C),AI=new BigInt64Array(C),HI=new BigUint64Array(C)}var EA=0,hA=null;function lI(C){throw g.onAbort?.(C),C="Aborted("+C+")",z(C),dA=!0,C=new WebAssembly.RuntimeError(C+". Build with -sASSERTIONS for more info."),D(C),C}var II;async function pg(C){if(!CA)try{var B=await p(C);return new Uint8Array(B)}catch{}if(C==II&&CA)C=new Uint8Array(CA);else if(f)C=f(C);else throw"both async and sync fetching of the wasm failed";return C}async function Og(C,B){try{var i=await pg(C);return await WebAssembly.instantiate(i,B)}catch(o){z(`failed to asynchronously prepare wasm: ${o}`),lI(o)}}async function xg(C){var B=II;if(!CA&&typeof WebAssembly.instantiateStreaming=="function"&&!fA(B)&&!F)try{var i=fetch(B,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(i,C)}catch(o){z(`wasm streaming compile failed: ${o}`),z("falling back to ArrayBuffer instantiation")}return Og(B,C)}var dI=C=>{for(;0<C.length;)C.shift()(g)},fI=[],pI=[],Tg=()=>{var C=g.preRun.shift();pI.push(C)};class jg{constructor(B){this.Z=B-24}}var OI=0,pA={},gI=C=>{for(;C.length;){var B=C.pop();C.pop()(B)}};function MA(C){return this.fromWireType(r[C>>2])}var SA={},iA={},OA={},xA=class extends Error{constructor(C){super(C),this.name="InternalError"}},GA=(C,B,i)=>{function o(K){if(K=i(K),K.length!==C.length)throw new xA("Mismatched type converter count");for(var t=0;t<C.length;++t)Z(C[t],K[t])}C.forEach(K=>OA[K]=B);var w=Array(B.length),s=[],y=0;B.forEach((K,t)=>{iA.hasOwnProperty(K)?w[t]=iA[K]:(s.push(K),SA.hasOwnProperty(K)||(SA[K]=[]),SA[K].push(()=>{w[t]=iA[K],++y,y===s.length&&o(w)}))}),s.length===0&&o(w)},xI,q=C=>{for(var B="";O[C];)B+=xI[O[C++]];return B},N=class extends Error{constructor(C){super(C),this.name="BindingError"}},Wg=C=>{throw new N(C)};function bg(C,B,i={}){var o=B.name;if(!C)throw new N(`type "${o}" must have a positive integer typeid pointer`);if(iA.hasOwnProperty(C)){if(i.Ga)return;throw new N(`Cannot register type '${o}' twice`)}iA[C]=B,delete OA[C],SA.hasOwnProperty(C)&&(B=SA[C],delete SA[C],B.forEach(w=>w()))}function Z(C,B,i={}){return bg(C,B,i)}var TI=(C,B,i)=>{switch(B){case 1:return i?o=>BA[o]:o=>O[o];case 2:return i?o=>QA[o>>1]:o=>AA[o>>1];case 4:return i?o=>v[o>>2]:o=>r[o>>2];case 8:return i?o=>AI[o>>3]:o=>HI[o>>3];default:throw new TypeError(`invalid integer width (${B}): ${C}`)}},CI=C=>{throw new N(C.Y.aa.$.name+" instance already deleted")},BI=!1,jI=()=>{},RA=C=>typeof FinalizationRegistry>"u"?(RA=B=>B,C):(BI=new FinalizationRegistry(B=>{B=B.Y,--B.count.value,B.count.value===0&&(B.da?B.ha.ia(B.da):B.aa.$.ia(B.Z))}),RA=B=>{var i=B.Y;return i.da&&BI.register(B,{Y:i},B),B},jI=B=>{BI.unregister(B)},RA(C));function TA(){}var jA=(C,B)=>Object.defineProperty(B,"name",{value:C}),WI={},bI=(C,B,i)=>{if(C[B].ba===void 0){var o=C[B];C[B]=function(...w){if(!C[B].ba.hasOwnProperty(w.length))throw new N(`Function '${i}' called with an invalid number of arguments (${w.length}) - expects one of (${C[B].ba})!`);return C[B].ba[w.length].apply(this,w)},C[B].ba=[],C[B].ba[o.la]=o}},QI=(C,B,i)=>{if(g.hasOwnProperty(C)){if(i===void 0||g[C].ba!==void 0&&g[C].ba[i]!==void 0)throw new N(`Cannot register public name '${C}' twice`);if(bI(g,C,C),g[C].ba.hasOwnProperty(i))throw new N(`Cannot register multiple overloads of a function with the same number of arguments (${i})!`);g[C].ba[i]=B}else g[C]=B,g[C].la=i},mg=C=>{C=C.replace(/[^a-zA-Z0-9_]/g,"$");var B=C.charCodeAt(0);return 48<=B&&57>=B?`_${C}`:C};function ug(C,B,i,o,w,s,y,K){this.name=C,this.constructor=B,this.ka=i,this.ia=o,this.ea=w,this.Ba=s,this.oa=y,this.za=K,this.Ja=[]}var EI=(C,B,i)=>{for(;B!==i;){if(!B.oa)throw new N(`Expected null or instance of ${i.name}, got an instance of ${B.name}`);C=B.oa(C),B=B.ea}return C},iI=C=>{if(C===null)return"null";var B=typeof C;return B==="object"||B==="array"||B==="function"?C.toString():""+C};function Zg(C,B){if(B===null){if(this.ra)throw new N(`null is not a valid ${this.name}`);return 0}if(!B.Y)throw new N(`Cannot pass "${iI(B)}" as a ${this.name}`);if(!B.Y.Z)throw new N(`Cannot pass deleted object as a pointer of type ${this.name}`);return EI(B.Y.Z,B.Y.aa.$,this.$)}function Xg(C,B){if(B===null){if(this.ra)throw new N(`null is not a valid ${this.name}`);if(this.qa){var i=this.sa();return C!==null&&C.push(this.ia,i),i}return 0}if(!B||!B.Y)throw new N(`Cannot pass "${iI(B)}" as a ${this.name}`);if(!B.Y.Z)throw new N(`Cannot pass deleted object as a pointer of type ${this.name}`);if(!this.pa&&B.Y.aa.pa)throw new N(`Cannot convert argument of type ${B.Y.ha?B.Y.ha.name:B.Y.aa.name} to parameter type ${this.name}`);if(i=EI(B.Y.Z,B.Y.aa.$,this.$),this.qa){if(B.Y.da===void 0)throw new N("Passing raw pointer to smart pointer is illegal");switch(this.Oa){case 0:if(B.Y.ha===this)i=B.Y.da;else throw new N(`Cannot convert argument of type ${B.Y.ha?B.Y.ha.name:B.Y.aa.name} to parameter type ${this.name}`);break;case 1:i=B.Y.da;break;case 2:if(B.Y.ha===this)i=B.Y.da;else{var o=B.clone();i=this.Ka(i,X(()=>o.delete())),C!==null&&C.push(this.ia,i)}break;default:throw new N("Unsupporting sharing policy")}}return i}function Pg(C,B){if(B===null){if(this.ra)throw new N(`null is not a valid ${this.name}`);return 0}if(!B.Y)throw new N(`Cannot pass "${iI(B)}" as a ${this.name}`);if(!B.Y.Z)throw new N(`Cannot pass deleted object as a pointer of type ${this.name}`);if(B.Y.aa.pa)throw new N(`Cannot convert argument of type ${B.Y.aa.name} to parameter type ${this.name}`);return EI(B.Y.Z,B.Y.aa.$,this.$)}var mI=(C,B,i)=>B===i?C:i.ea===void 0?null:(C=mI(C,B,i.ea),C===null?null:i.za(C)),Vg={},zg=(C,B)=>{if(B===void 0)throw new N("ptr should not be undefined");for(;C.ea;)B=C.oa(B),C=C.ea;return Vg[B]},WA=(C,B)=>{if(!B.aa||!B.Z)throw new xA("makeClassHandle requires ptr and ptrType");if(!!B.ha!=!!B.da)throw new xA("Both smartPtrType and smartPtr must be specified");return B.count={value:1},RA(Object.create(C,{Y:{value:B,writable:!0}}))};function bA(C,B,i,o,w,s,y,K,t,G,R){this.name=C,this.$=B,this.ra=i,this.pa=o,this.qa=w,this.Ia=s,this.Oa=y,this.xa=K,this.sa=t,this.Ka=G,this.ia=R,w||B.ea!==void 0?this.toWireType=Xg:(this.toWireType=o?Zg:Pg,this.fa=null)}var uI=(C,B,i)=>{if(!g.hasOwnProperty(C))throw new xA("Replacing nonexistent public symbol");g[C].ba!==void 0&&i!==void 0?g[C].ba[i]=B:(g[C]=B,g[C].la=i)},ZI=[],XI,V=(C,B)=>{C=q(C);var i;if((i=ZI[B])||(ZI[B]=i=XI.get(B)),typeof i!="function")throw new N(`unknown function pointer with signature ${C}: ${B}`);return i};class vg extends Error{}var PI=C=>{C=SC(C);var B=q(C);return DA(C),B},oI=(C,B)=>{function i(s){w[s]||iA[s]||(OA[s]?OA[s].forEach(i):(o.push(s),w[s]=!0))}var o=[],w={};throw B.forEach(i),new vg(`${C}: `+o.map(PI).join([", "]))};function VI(C){for(var B=1;B<C.length;++B)if(C[B]!==null&&C[B].fa===void 0)return!0;return!1}function zI(C,B,i,o,w,s){var y=B.length;if(2>y)throw new N("argTypes array size mismatch! Must at least get return value and 'this' types!");var K=B[1]!==null&&i!==null,t=VI(B);for(i=B[0].name!=="void",o=[C,Wg,o,w,gI,B[0],B[1]],w=0;w<y-2;++w)o.push(B[w+2]);if(!t)for(w=K?1:2;w<B.length;++w)B[w].fa!==null&&o.push(B[w].fa);t=VI(B),w=B.length-2;var G=[],R=["fn"];for(K&&R.push("thisWired"),y=0;y<w;++y)G.push(`arg${y}`),R.push(`arg${y}Wired`);G=G.join(","),R=R.join(","),G=`return function (${G}) {
|
|
1
|
+
(function(l,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("lit")):typeof define=="function"&&define.amd?define(["exports","lit"],c):(l=typeof globalThis<"u"?globalThis:l||self,c(l.SignosoftSignpad={},l.lit))})(this,(function(l,c){"use strict";const Sg=E=>(A,I)=>{I!==void 0?I.addInitializer(()=>{customElements.define(E,A)}):customElements.define(E,A)};const FA=globalThis,PA=FA.ShadowRoot&&(FA.ShadyCSS===void 0||FA.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,sI=Symbol(),aI=new WeakMap;let sg=class{constructor(A,I,g){if(this._$cssResult$=!0,g!==sI)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=A,this.t=I}get styleSheet(){let A=this.o;const I=this.t;if(PA&&A===void 0){const g=I!==void 0&&I.length===1;g&&(A=aI.get(I)),A===void 0&&((this.o=A=new CSSStyleSheet).replaceSync(this.cssText),g&&aI.set(I,A))}return A}toString(){return this.cssText}};const ag=E=>new sg(typeof E=="string"?E:E+"",void 0,sI),yg=(E,A)=>{if(PA)E.adoptedStyleSheets=A.map(I=>I instanceof CSSStyleSheet?I:I.styleSheet);else for(const I of A){const g=document.createElement("style"),Q=FA.litNonce;Q!==void 0&&g.setAttribute("nonce",Q),g.textContent=I.cssText,E.appendChild(g)}},yI=PA?E=>E:E=>E instanceof CSSStyleSheet?(A=>{let I="";for(const g of A.cssRules)I+=g.cssText;return ag(I)})(E):E;const{is:Kg,defineProperty:hg,getOwnPropertyDescriptor:Mg,getOwnPropertyNames:Gg,getOwnPropertySymbols:Rg,getPrototypeOf:tg}=Object,JA=globalThis,KI=JA.trustedTypes,Ng=KI?KI.emptyScript:"",kg=JA.reactiveElementPolyfillSupport,aA=(E,A)=>E,UA={toAttribute(E,A){switch(A){case Boolean:E=E?Ng:null;break;case Object:case Array:E=E==null?E:JSON.stringify(E)}return E},fromAttribute(E,A){let I=E;switch(A){case Boolean:I=E!==null;break;case Number:I=E===null?null:Number(E);break;case Object:case Array:try{I=JSON.parse(E)}catch{I=null}}return I}},VA=(E,A)=>!Kg(E,A),hI={attribute:!0,type:String,converter:UA,reflect:!1,useDefault:!1,hasChanged:VA};Symbol.metadata??=Symbol("metadata"),JA.litPropertyMetadata??=new WeakMap;class yA extends HTMLElement{static addInitializer(A){this._$Ei(),(this.l??=[]).push(A)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(A,I=hI){if(I.state&&(I.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(A)&&((I=Object.create(I)).wrapped=!0),this.elementProperties.set(A,I),!I.noAccessor){const g=Symbol(),Q=this.getPropertyDescriptor(A,g,I);Q!==void 0&&hg(this.prototype,A,Q)}}static getPropertyDescriptor(A,I,g){const{get:Q,set:D}=Mg(this.prototype,A)??{get(){return this[I]},set(S){this[I]=S}};return{get:Q,set(S){const a=Q?.call(this);D?.call(this,S),this.requestUpdate(A,a,g)},configurable:!0,enumerable:!0}}static getPropertyOptions(A){return this.elementProperties.get(A)??hI}static _$Ei(){if(this.hasOwnProperty(aA("elementProperties")))return;const A=tg(this);A.finalize(),A.l!==void 0&&(this.l=[...A.l]),this.elementProperties=new Map(A.elementProperties)}static finalize(){if(this.hasOwnProperty(aA("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(aA("properties"))){const I=this.properties,g=[...Gg(I),...Rg(I)];for(const Q of g)this.createProperty(Q,I[Q])}const A=this[Symbol.metadata];if(A!==null){const I=litPropertyMetadata.get(A);if(I!==void 0)for(const[g,Q]of I)this.elementProperties.set(g,Q)}this._$Eh=new Map;for(const[I,g]of this.elementProperties){const Q=this._$Eu(I,g);Q!==void 0&&this._$Eh.set(Q,I)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(A){const I=[];if(Array.isArray(A)){const g=new Set(A.flat(1/0).reverse());for(const Q of g)I.unshift(yI(Q))}else A!==void 0&&I.push(yI(A));return I}static _$Eu(A,I){const g=I.attribute;return g===!1?void 0:typeof g=="string"?g:typeof A=="string"?A.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(A=>this.enableUpdating=A),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(A=>A(this))}addController(A){(this._$EO??=new Set).add(A),this.renderRoot!==void 0&&this.isConnected&&A.hostConnected?.()}removeController(A){this._$EO?.delete(A)}_$E_(){const A=new Map,I=this.constructor.elementProperties;for(const g of I.keys())this.hasOwnProperty(g)&&(A.set(g,this[g]),delete this[g]);A.size>0&&(this._$Ep=A)}createRenderRoot(){const A=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return yg(A,this.constructor.elementStyles),A}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(A=>A.hostConnected?.())}enableUpdating(A){}disconnectedCallback(){this._$EO?.forEach(A=>A.hostDisconnected?.())}attributeChangedCallback(A,I,g){this._$AK(A,g)}_$ET(A,I){const g=this.constructor.elementProperties.get(A),Q=this.constructor._$Eu(A,g);if(Q!==void 0&&g.reflect===!0){const D=(g.converter?.toAttribute!==void 0?g.converter:UA).toAttribute(I,g.type);this._$Em=A,D==null?this.removeAttribute(Q):this.setAttribute(Q,D),this._$Em=null}}_$AK(A,I){const g=this.constructor,Q=g._$Eh.get(A);if(Q!==void 0&&this._$Em!==Q){const D=g.getPropertyOptions(Q),S=typeof D.converter=="function"?{fromAttribute:D.converter}:D.converter?.fromAttribute!==void 0?D.converter:UA;this._$Em=Q;const a=S.fromAttribute(I,D.type);this[Q]=a??this._$Ej?.get(Q)??a,this._$Em=null}}requestUpdate(A,I,g,Q=!1,D){if(A!==void 0){const S=this.constructor;if(Q===!1&&(D=this[A]),g??=S.getPropertyOptions(A),!((g.hasChanged??VA)(D,I)||g.useDefault&&g.reflect&&D===this._$Ej?.get(A)&&!this.hasAttribute(S._$Eu(A,g))))return;this.C(A,I,g)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(A,I,{useDefault:g,reflect:Q,wrapped:D},S){g&&!(this._$Ej??=new Map).has(A)&&(this._$Ej.set(A,S??I??this[A]),D!==!0||S!==void 0)||(this._$AL.has(A)||(this.hasUpdated||g||(I=void 0),this._$AL.set(A,I)),Q===!0&&this._$Em!==A&&(this._$Eq??=new Set).add(A))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(I){Promise.reject(I)}const A=this.scheduleUpdate();return A!=null&&await A,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[Q,D]of this._$Ep)this[Q]=D;this._$Ep=void 0}const g=this.constructor.elementProperties;if(g.size>0)for(const[Q,D]of g){const{wrapped:S}=D,a=this[Q];S!==!0||this._$AL.has(Q)||a===void 0||this.C(Q,void 0,D,a)}}let A=!1;const I=this._$AL;try{A=this.shouldUpdate(I),A?(this.willUpdate(I),this._$EO?.forEach(g=>g.hostUpdate?.()),this.update(I)):this._$EM()}catch(g){throw A=!1,this._$EM(),g}A&&this._$AE(I)}willUpdate(A){}_$AE(A){this._$EO?.forEach(I=>I.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(A)),this.updated(A)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(A){return!0}update(A){this._$Eq&&=this._$Eq.forEach(I=>this._$ET(I,this[I])),this._$EM()}updated(A){}firstUpdated(A){}}yA.elementStyles=[],yA.shadowRootOptions={mode:"open"},yA[aA("elementProperties")]=new Map,yA[aA("finalized")]=new Map,kg?.({ReactiveElement:yA}),(JA.reactiveElementVersions??=[]).push("2.1.2");const Fg={attribute:!0,type:String,converter:UA,reflect:!1,hasChanged:VA},Jg=(E=Fg,A,I)=>{const{kind:g,metadata:Q}=I;let D=globalThis.litPropertyMetadata.get(Q);if(D===void 0&&globalThis.litPropertyMetadata.set(Q,D=new Map),g==="setter"&&((E=Object.create(E)).wrapped=!0),D.set(I.name,E),g==="accessor"){const{name:S}=I;return{set(a){const M=A.get.call(this);A.set.call(this,a),this.requestUpdate(S,M,E,!0,a)},init(a){return a!==void 0&&this.C(S,void 0,E,a),a}}}if(g==="setter"){const{name:S}=I;return function(a){const M=this[S];A.call(this,a),this.requestUpdate(S,M,E,!0,a)}}throw Error("Unsupported decorator location: "+g)};function Ug(E){return(A,I)=>typeof I=="object"?Jg(E,A,I):((g,Q,D)=>{const S=Q.hasOwnProperty(D);return Q.constructor.createProperty(D,g),S?Object.getOwnPropertyDescriptor(Q,D):void 0})(E,A,I)}const cg=(E,A,I)=>(I.configurable=!0,I.enumerable=!0,Reflect.decorate&&typeof A!="object"&&Object.defineProperty(E,A,I),I);function Lg(E,A){return(I,g,Q)=>{const D=S=>S.renderRoot?.querySelector(E)??null;return cg(I,g,{get(){return D(this)}})}}var h=(E=>(E.INITIAL="initial",E.DISCONNECTED="disconnected",E.CONNECTING="connecting",E.WAITING_FOR_DEVICE_SELECTION="waiting_for_device_selection",E.CONNECTED_PHYSICAL="connected_physical",E.CONNECTED_MOUSE_FALLBACK="connected_mouse_fallback",E.SIGNING_ACTIVE="signing_active",E.PROCESSING_OK="processing_ok",E.PROCESSING_CLEAR="processing_clear",E.PROCESSING_CANCEL="processing_cancel",E.DISCONNECTING="disconnecting",E.ERROR="error",E))(h||{}),L=(E=>(E.SIGN_PEN="sign-pen",E.SIGN_OK="sign-ok",E.SIGN_CLEAR="sign-clear",E.SIGN_CANCEL="sign-cancel",E.SIGN_ERROR="sign-error",E.SIGN_CONNECT="sign-connect",E.SIGN_DISCONNECT="sign-disconnect",E.SIGN_CONNECTING="sign-connecting",E))(L||{}),MI=(E=>(E.OK="OK",E.CLEAR="CLEAR",E.CANCEL="CANCEL",E.CLEAR_SIGNATURE="CLEAR_SIGNATURE",E.DISCONNECT="DISCONNECT",E.CONNECT_SIGNPAD="CONNECT_SIGNPAD",E))(MI||{}),k=(E=>(E.AUTO_CONNECTING="AUTO_CONNECTING",E.CONNECTING_TO_DEVICE="CONNECTING_TO_DEVICE",E.REVERTING_TO_DEFAULT="REVERTING_TO_DEFAULT",E.DISCONNECTING_DEVICE="DISCONNECTING_DEVICE",E.COMPONENT_INITIALIZED="COMPONENT_INITIALIZED",E.TEXT_START_SIGNING="TEXT_START_SIGNING",E.TEXT_SIGN_WITH_PHYSICAL="TEXT_SIGN_WITH_PHYSICAL",E.TEXT_SIGN_WITH_MOUSE="TEXT_SIGN_WITH_MOUSE",E.TEXT_SIGN_GENERIC="TEXT_SIGN_GENERIC",E.TEXT_SIGNING_WITH_DEVICE="TEXT_SIGNING_WITH_DEVICE",E.NO_DEVICE_FOUND="NO_DEVICE_FOUND",E.CONNECTION_ERROR="CONNECTION_ERROR",E.ERROR_DISCONNECTION="ERROR_DISCONNECTION",E.ERROR_INSTANTIATING_DRIVER="ERROR_INSTANTIATING_DRIVER",E.SIGNPAD_DISCONNECTED="SIGNPAD_DISCONNECTED",E.INVALID_LICENSE_KEY="INVALID_LICENSE_KEY",E.READY_TO_CONNECT="READY_TO_CONNECT",E.SIGNPAD_DETECTED="SIGNPAD_DETECTED",E.READY_TO_SIGN_MOUSE="READY_TO_SIGN_MOUSE",E.READY_TO_SIGN_PHYSICAL="READY_TO_SIGN_PHYSICAL",E))(k||{}),m=(E=>(E.MOUSE="MOUSE",E.CONNECTED_UNKNOWN="CONNECTED_UNKNOWN_DEVICE",E))(m||{});class eg{constructor(A){this.component=A}async handleClear(){await this.executeAction(h.PROCESSING_CLEAR,async()=>{await this.component.connectionManager.clearSignature(),await this.component.config.actionHandlers?.handleClear?.(),this.component.dispatch(L.SIGN_CLEAR)})}async handleOk(){return await this.executeAction(h.PROCESSING_OK,async()=>{const A=await this.component.connectionManager.stopSigning();return await this.component.config.actionHandlers?.handleOk?.(A),this.component.dispatch(L.SIGN_OK,A),A})}async handleCancel(){await this.executeAction(h.PROCESSING_CANCEL,async()=>{await this.component.connectionManager.stopSigning(),await this.component.config.actionHandlers?.handleCancel?.(),this.component.dispatch(L.SIGN_CANCEL)})}async startSigning(A){const I=this.component.connectionManager,g=this.component.canvasRef;if(!I.hasSignatureLayer()||!g){this.handleStartSigningError();return}this.component.stateManager.transitionTo(h.CONNECTING,"Preparing session...");try{this.component.resetDrawingState(),await I.startSigning(g,A);const Q=await this.getReadyState(),D=Q===h.CONNECTED_MOUSE_FALLBACK?"READY_TO_SIGN_MOUSE":"READY_TO_SIGN_PHYSICAL";this.component.stateManager.transitionTo(Q,D)}catch(Q){this.handleError("Error starting signing session",Q)}}async stopSigning(){return this.component.connectionManager.stopSigning()}async executeAction(A,I){this.component.stateManager.transitionTo(A,"Processing...");try{const g=await I();this.component.resetDrawingState();const Q=await this.getReadyState();return this.component.stateManager.transitionTo(Q),g}catch(g){throw this.handleError("Error during action processing",g),g}}async getReadyState(){const A=this.component.connectionManager.isDeviceConnected(),I=await this.component.connectionManager.getDeviceInfo();return this.component.connectionManager.isFallback(I,A,!0)?h.CONNECTED_MOUSE_FALLBACK:h.CONNECTED_PHYSICAL}handleStartSigningError(){this.component.currentState===h.CONNECTED_MOUSE_FALLBACK&&(this.component.resetDrawingState(),this.component.mouseManager?.addListeners(),this.component.stateManager.transitionTo(h.CONNECTED_MOUSE_FALLBACK))}handleError(A,I){console.error(`Signosoft Signpad: ${A}`,I),this.component.stateManager.transitionTo(h.ERROR,A,I)}}class Yg{constructor(A,I={minWidth:2,maxWidth:4,color:"#000000"}){this.canvas=A;const g=A.getContext("2d");if(!g)throw new Error("Could not get 2D rendering context for canvas.");this.ctx=g,this.currentDrawingOptions=I,this.configureCanvasForDPI(),this.applyDrawingStyles(this.currentDrawingOptions)}get drawingOptions(){return{...this.currentDrawingOptions}}updateDrawingOptions(A){this.currentDrawingOptions=A,this.applyDrawingStyles(this.currentDrawingOptions)}drawSegment(A){}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height)}configureCanvasForDPI(){const A=window.devicePixelRatio||1,I=this.canvas.getBoundingClientRect(),g=I.width||this.canvas.clientWidth||0,Q=I.height||this.canvas.clientHeight||0;if(g<=0||Q<=0)return;const D=Math.round(g*A),S=Math.round(Q*A);this.canvas.width===D&&this.canvas.height===S||(this.canvas.width=D,this.canvas.height=S,this.applyDrawingStyles(this.currentDrawingOptions))}applyDrawingStyles(A){this.ctx.strokeStyle=A.color??"#000000",this.ctx.fillStyle=A.color??"#000000",this.ctx.lineCap="round",this.ctx.lineJoin="round",this.ctx.globalCompositeOperation="source-over"}}const lA=class lA{constructor(A){this.sigLayer=null,this.debugCallbackRegistrationCount=0,this.cachedDeviceInfo=null,this.lastPenDispatchTime=0,this.penDataToDispatch=null,this.throttleDelayMs=16,this.component=A}async connect(A=!1,I=!1){this.component.stateManager.transitionTo(h.CONNECTING,A?k.AUTO_CONNECTING:k.CONNECTING_TO_DEVICE);try{const g=await this.runDriverConnectAttempt(A),Q=this.resolveConnectionTarget(g,I);return Q?(await this.prepareSigningSession(),this.component.stateManager.transitionTo(Q.targetState,Q.statusMessageKey),this.component.dispatch(L.SIGN_CONNECT,{deviceInfo:g.deviceInfo}),!0):(this.component.stateManager.transitionTo(h.DISCONNECTED,k.NO_DEVICE_FOUND),!1)}catch(g){return console.error("Signosoft Signpad: Error in connect method:",g),this.component.stateManager.transitionTo(h.ERROR,k.CONNECTION_ERROR,g),!1}}async disconnect(){this.component.stateManager.transitionTo(h.DISCONNECTING,k.DISCONNECTING_DEVICE);try{if(!this.sigLayer)return;if(!this.sigLayer.isConnected()){this.sigLayer=null,this.cachedDeviceInfo=null;return}await this.sigLayer.disconnect(),this.sigLayer=null,this.cachedDeviceInfo=null}catch(A){console.error("Signosoft Signpad: Error during disconnect",A),this.component.stateManager.transitionTo(h.ERROR,k.ERROR_DISCONNECTION,A)}}hasSignatureLayer(){return this.sigLayer!==null}async getDeviceInfo(){if(this.cachedDeviceInfo)return this.cachedDeviceInfo;const A=this.normalizeDeviceInfo(await this.sigLayer?.getDeviceInfo());return this.cachedDeviceInfo=A??null,A}isDeviceConnected(){return this.sigLayer?.isConnected()??!1}isSigningActive(){return this.sigLayer?.isInSigningMode?.()??!1}async startSigning(A,I){if(!this.sigLayer)return!1;const g=I??this.component.configManager.getDrawingOptions();return this.sigLayer.isInSigningMode?.()&&await this.sigLayer.stopSigning(),await this.sigLayer.startSigning(A,!0,g),!0}async stopSigning(){try{if(this.sigLayer)return await this.sigLayer.stopSigning()}catch(A){console.warn("Signosoft Signpad: SigLayer stop failed, continuing cleanup",A)}finally{this.component.mouseManager?.removeListeners(),this.component.resetDrawingState(),console.log("[ConnectionManager] Signing stopped and mouse listeners removed.")}}async clearSignature(){this.sigLayer?.isInSigningMode?.()&&await this.sigLayer.clearSignature()}async ensureSignatureLayer(){if(!this.sigLayer)try{this.sigLayer=new SignatureLayer,this.setupCallbacks()}catch(A){throw console.error("Signosoft Signpad: Error instantiating driver",A),this.component.stateManager.transitionTo(h.ERROR,k.ERROR_INSTANTIATING_DRIVER,A),A}}setupCallbacks(){this.sigLayer&&(this.debugCallbackRegistrationCount+=1,console.log(`[Signpad Debug] SignatureLayer callbacks registered (${this.debugCallbackRegistrationCount})`),this.sigLayer.onOK(()=>this.component.buttonManager.handleOk()),this.sigLayer.onClear(()=>this.component.buttonManager.handleClear()),this.sigLayer.onCancel(()=>this.component.buttonManager.handleCancel()),this.sigLayer.onPen(A=>{A.inContact&&!this.component.hasStartedDrawing&&this.component.stateManager.setDrawingStarted(!0),this.runThrottledPenDispatch(A)}),this.sigLayer.onUnexpectedDisconnect(()=>{const A=this.component.currentState;A!==h.DISCONNECTING&&A!==h.INITIAL&&A!==h.DISCONNECTED&&A!==h.ERROR&&this.component.recoverToMouseFallback(k.REVERTING_TO_DEFAULT,1e3)}))}runThrottledPenDispatch(A){if(this.component.stateManager.isBusy||this.component.stateManager.isError)return;this.penDataToDispatch=A;const I=performance.now();I-this.lastPenDispatchTime>this.throttleDelayMs&&(this.component.dispatch(L.SIGN_PEN,this.penDataToDispatch),this.lastPenDispatchTime=I,this.penDataToDispatch=null)}async initWithLease(A){await this.ensureSignatureLayer(),this.sigLayer&&await this.sigLayer.initialize(A)}isFallback(A,I,g){const D=(A?.deviceName??A?.name??null)==="Pointer Input (Fallback Mode)",S=this.component.currentState===h.CONNECTED_MOUSE_FALLBACK,a=this.component.deviceStatusText===m.MOUSE;return D||S||a||g&&!I}normalizeDeviceInfo(A){return A?!A.deviceName&&A.name?{...A,deviceName:A.name}:A:null}async runDriverConnectAttempt(A){const I=await this.sigLayer?.connect(A),g=this.sigLayer?.isConnected()??!1,Q=!!(I&&g),D=Q?this.normalizeDeviceInfo(await this.sigLayer?.getDeviceInfo()):null;this.cachedDeviceInfo=D??null;const S=D?.deviceName??D?.name??null,a=Q&&S===lA.POINTER_FALLBACK_DEVICE_NAME;return{connected:Q,deviceInfo:D,isPointerFallback:a}}resolveConnectionTarget(A,I){if(A.connected&&!A.isPointerFallback){const g=A.deviceInfo?.deviceName??A.deviceInfo?.name??m.CONNECTED_UNKNOWN;return this.component.setDeviceStatusText(g),this.component.mouseManager?.areListenersAttached()&&this.component.mouseManager?.removeListeners(),{targetState:h.CONNECTED_PHYSICAL,statusMessageKey:k.TEXT_SIGN_WITH_PHYSICAL}}return A.connected&&A.isPointerFallback||!A.connected&&I?(this.component.setDeviceStatusText(m.MOUSE),{targetState:h.CONNECTED_MOUSE_FALLBACK,statusMessageKey:k.TEXT_SIGN_WITH_MOUSE}):null}async prepareSigningSession(){const A=this.component.canvasRef,I=this.component.configManager.getDrawingOptions();this.sigLayer?.isInSigningMode?.()&&await this.sigLayer.stopSigning(),await this.sigLayer?.startSigning(A,!0,I)}};lA.POINTER_FALLBACK_DEVICE_NAME="Pointer Input (Fallback Mode)";let zA=lA;class ng{constructor(A){this.component=A}get deviceStatusKey(){return this.component.currentState===h.CONNECTED_MOUSE_FALLBACK?m.MOUSE:this.isConnected?this.component.deviceStatusText||m.CONNECTED_UNKNOWN:m.MOUSE}get statusMessageKey(){return this.component.statusMessage||""}get additionalTextKey(){const A=h,I=k,g=this.component.statusMessage;switch(this.component.currentState){case A.INITIAL:case A.ERROR:return I.TEXT_START_SIGNING;case A.DISCONNECTED:return g===I.READY_TO_CONNECT||g===I.SIGNPAD_DETECTED||g===I.COMPONENT_INITIALIZED?I.TEXT_START_SIGNING:I.TEXT_SIGN_GENERIC;case A.CONNECTED_PHYSICAL:return I.TEXT_SIGN_WITH_PHYSICAL;case A.CONNECTED_MOUSE_FALLBACK:return I.TEXT_SIGN_WITH_MOUSE;case A.SIGNING_ACTIVE:return I.TEXT_SIGNING_WITH_DEVICE;default:return I.TEXT_SIGN_GENERIC}}get isConnected(){const A=this.component.currentState;return A===h.CONNECTED_PHYSICAL||A===h.CONNECTED_MOUSE_FALLBACK||A===h.SIGNING_ACTIVE||A===h.PROCESSING_OK||A===h.PROCESSING_CLEAR||A===h.PROCESSING_CANCEL}get isPhysicalConnected(){const A=this.component.currentState;return A===h.CONNECTED_PHYSICAL||A===h.SIGNING_ACTIVE||A===h.PROCESSING_OK||A===h.PROCESSING_CLEAR||A===h.PROCESSING_CANCEL}get isBusy(){const A=this.component.currentState;return A===h.CONNECTING||A===h.WAITING_FOR_DEVICE_SELECTION||A===h.PROCESSING_OK||A===h.PROCESSING_CLEAR||A===h.PROCESSING_CANCEL||A===h.DISCONNECTING}get isError(){return this.component.currentState===h.ERROR}get actionButtonsDisabled(){return!this.isConnected||!this.component.hasStartedDrawing||this.isBusy}get connectButtonDisabled(){return this.isBusy||this.isPhysicalConnected}get disconnectButtonDisabled(){const A=this.component.currentState;return A===h.DISCONNECTED||A===h.INITIAL||this.isBusy}transitionTo(A,I="",g){const Q=this.component.currentState;Q===A&&this.component.statusMessage===I&&!g||(this.component.setCurrentState(A),this.component.setStatusMessage(I),this.handleSideEffects(A,Q),A===h.CONNECTING&&this.component.dispatch(L.SIGN_CONNECTING),g&&this.component.dispatch(L.SIGN_ERROR,g))}setDrawingStarted(A){this.component.hasStartedDrawing!==A&&this.component.setHasStartedDrawing(A)}handleSideEffects(A,I){const g=Q=>Q===h.INITIAL||Q===h.DISCONNECTED||Q===h.ERROR;g(A)?(this.component.setDeviceStatusText(m.MOUSE),this.component.setCanvasPointerInputEnabled(!0),g(I)||(this.component.resetDrawingState(),this.component.mouseManager?.removeListeners())):(A===h.CONNECTED_PHYSICAL||A===h.CONNECTED_MOUSE_FALLBACK)&&(A===h.CONNECTED_MOUSE_FALLBACK?I===h.PROCESSING_OK||I===h.PROCESSING_CANCEL?(this.component.mouseManager?.removeListeners(),this.component.setCanvasPointerInputEnabled(!1)):(this.component.mouseManager?.addListeners(),this.component.setCanvasPointerInputEnabled(!0)):(this.component.mouseManager?.removeListeners(),this.component.setCanvasPointerInputEnabled(!1)))}}class Hg{constructor(A,I){this.isDrawing=!1,this.sequenceCounter=0,this.sessionStartTime=null,this.debugListenerRegistrationCount=0,this.listenersAttached=!1,this.canvas=A,this.onPenData=I,this.boundHandleMouseDown=this.handleMouseDown.bind(this),this.boundHandleMouseMove=this.handleMouseMove.bind(this),this.boundHandleMouseUp=this.handleMouseUp.bind(this),this.boundHandleMouseLeave=this.handleMouseLeave.bind(this)}get isCurrentlyDrawing(){return this.isDrawing}addListeners(){if(this.listenersAttached){console.log("[Signpad Debug] Mouse listeners already registered");return}this.listenersAttached=!0,this.debugListenerRegistrationCount+=1,console.log(`[Signpad Debug] Mouse listeners registered (${this.debugListenerRegistrationCount})`),this.canvas.addEventListener("mousedown",this.boundHandleMouseDown),this.canvas.addEventListener("mousemove",this.boundHandleMouseMove),this.canvas.addEventListener("mouseup",this.boundHandleMouseUp),this.canvas.addEventListener("mouseleave",this.boundHandleMouseLeave)}removeListeners(){if(!this.listenersAttached){console.log("[Signpad Debug] Mouse listeners already removed");return}this.listenersAttached=!1,console.log("[Signpad Debug] Mouse listeners removed"),this.canvas.removeEventListener("mousedown",this.boundHandleMouseDown),this.canvas.removeEventListener("mousemove",this.boundHandleMouseMove),this.canvas.removeEventListener("mouseup",this.boundHandleMouseUp),this.canvas.removeEventListener("mouseleave",this.boundHandleMouseLeave),this.isDrawing=!1,this.sequenceCounter=0}areListenersAttached(){return this.listenersAttached}resetSession(){this.isDrawing=!1,this.sequenceCounter=0,this.sessionStartTime=null}handleMouseDown(A){this.isDrawing=!0,this.sequenceCounter=0,this.sessionStartTime===null&&(this.sessionStartTime=Date.now()),this.processMouseEvent(A,!0)}handleMouseMove(A){this.isDrawing&&(this.sequenceCounter++,this.processMouseEvent(A,!0))}handleMouseUp(A){this.isDrawing&&(this.isDrawing=!1,this.processMouseEvent(A,!1),this.sequenceCounter=0)}handleMouseLeave(A){this.isDrawing&&(this.isDrawing=!1,this.processMouseEvent(A,!1),this.sequenceCounter=0)}processMouseEvent(A,I){const{x:g,y:Q}=this.getNormalizedCoordinates(A),D={relativeX:g,relativeY:Q,pressure:I?.5:0,inContact:I,timestamp:this.timestampToSeconds()};this.onPenData(D)}getNormalizedCoordinates(A){const I=this.canvas.getBoundingClientRect(),g=(A.clientX-I.left)/I.width,Q=(A.clientY-I.top)/I.height;return{x:g,y:Q}}timestampToSeconds(){this.sessionStartTime===null&&(this.sessionStartTime=Date.now());const I=(Date.now()-this.sessionStartTime)/1e3;return Number(I.toFixed(3))}}const cA={en:{OK:"OK",CLEAR:"Clear",CANCEL:"Cancel",CLEAR_SIGNATURE:"Clear signature",DISCONNECT:"Disconnect",CONNECT_SIGNPAD:"Connect Signpad",MOUSE:"Mouse",CONNECTED_UNKNOWN_DEVICE:"Connected (Unknown Device)",AUTO_CONNECTING:"Auto-connecting to device...",CONNECTING_TO_DEVICE:"Connecting to your device...",REVERTING_TO_DEFAULT:"Reverting to default input...",DISCONNECTING_DEVICE:"Disconnecting device...",COMPONENT_INITIALIZED:"Component initialized.",TEXT_START_SIGNING:"Connect your device.",TEXT_SIGN_WITH_PHYSICAL:"Please sign using the device pen.",TEXT_SIGN_WITH_MOUSE:"Please sign using your mouse.",TEXT_SIGN_GENERIC:"Sign in the area above using mouse or pen.",TEXT_SIGNING_WITH_DEVICE:"Signing with {device}",NO_DEVICE_FOUND:"No device found.",CONNECTION_ERROR:"Connection error.",ERROR_DISCONNECTION:"Error during disconnection.",ERROR_INSTANTIATING_DRIVER:"Error instantiating driver.",SIGNPAD_DISCONNECTED:"Signpad disconnected.",INVALID_LICENSE_KEY:"Invalid license key.",READY_TO_CONNECT:"Ready to connect.",SIGNPAD_DETECTED:"Signpad detected. Click 'Connect Signpad' to begin.",READY_TO_SIGN_MOUSE:"Ready to sign. Use your mouse.",READY_TO_SIGN_PHYSICAL:"Ready to sign. Use the device pen."},cs:{OK:"OK",CLEAR:"Smazat",CANCEL:"Zrušit",CLEAR_SIGNATURE:"Smazat podpis",DISCONNECT:"Odpojit",CONNECT_SIGNPAD:"Připojit Signpad",MOUSE:"Myš",CONNECTED_UNKNOWN_DEVICE:"Připojeno (neznámé zařízení)",AUTO_CONNECTING:"Automatické připojování k zařízení...",CONNECTING_TO_DEVICE:"Připojování k vašemu zařízení...",REVERTING_TO_DEFAULT:"Přepínání na výchozí vstup...",DISCONNECTING_DEVICE:"Odpojování zařízení...",COMPONENT_INITIALIZED:"Komponenta byla inicializována.",TEXT_START_SIGNING:"Připojte své zařízení.",TEXT_SIGN_WITH_PHYSICAL:"Podepište se perem zařízení.",TEXT_SIGN_WITH_MOUSE:"Podepište se pomocí myši.",TEXT_SIGN_GENERIC:"Podepište se v oblasti výše pomocí myši nebo pera.",TEXT_SIGNING_WITH_DEVICE:"Podepisování pomocí: {device}",NO_DEVICE_FOUND:"Zařízení nebylo nalezeno.",CONNECTION_ERROR:"Chyba připojení.",ERROR_DISCONNECTION:"Chyba při odpojování.",ERROR_INSTANTIATING_DRIVER:"Chyba při inicializaci ovladače.",SIGNPAD_DISCONNECTED:"Signpad byl odpojen.",INVALID_LICENSE_KEY:"Neplatný licenční klíč.",READY_TO_CONNECT:"Připraveno k připojení.",SIGNPAD_DETECTED:"Signpad byl nalezen. Klikněte na 'Připojit Signpad' pro spuštění.",READY_TO_SIGN_MOUSE:"Připraveno k podpisu. Použijte myš.",READY_TO_SIGN_PHYSICAL:"Připraveno k podpisu. Použijte pero zařízení."}};class rg{constructor(A){this.translations=cA.en,this.currentLang="",this.currentPath=void 0,this.component=A}t(A,I={}){let g=this.translations[A]||A;for(const[Q,D]of Object.entries(I))g=g.replace(new RegExp(`{${Q}}`,"g"),D);return g}async loadLanguage(A,I,g){const Q=I?.trim();if(A===this.currentLang&&Q===this.currentPath)return;let D=this.getBaselineTranslations(A);const S=this.resolveInlineTranslations(A,g);if(S){this.translations={...D,...S},this.currentLang=A,this.currentPath=Q,this.component.requestUpdate();return}if(!Q){this.translations=D,this.currentLang=A,this.currentPath=Q,this.component.requestUpdate();return}const a=this.constructUrl(A,Q);try{const M=await fetch(a);if(M.ok){const F=await M.json();D={...D,...F},console.log(`signosoft-signpad: External translations loaded from ${a}`)}else I&&console.info(`signosoft-signpad: Custom path provided, but file not found at ${a}`)}catch(M){console.warn(`signosoft-signpad: Failed to load external translations from ${a}. Using built-in defaults.`,M)}this.translations=D,this.currentLang=A,this.currentPath=Q,this.component.requestUpdate()}getBaselineTranslations(A){const I=cA.en;return A!=="en"&&cA.hasOwnProperty(A)?{...I,...cA[A]}:{...I}}resolveInlineTranslations(A,I){return I?typeof Object.values(I)[0]=="string"?I:I[A]:void 0}constructUrl(A,I){const g=I.trim();let Q="";return g.endsWith(".json")?Q=g:Q=`${g.replace(/\/+$/,"")}/${A}.json`,Q}}class qg{constructor(A){this.configEventHandlers={},this.customEventListenerCache=new WeakMap,this.component=A}apply(A){const I=this.component.config;if(!I){this.clearConfigEventHandlers();return}this.applyLocalization(A,I),this.applyDrawingOptions(A,I),this.syncConfigEventHandlers(I)}getUiVisibilityOptions(){const A=this.component.config.uiVisibilityOptions;return{topBarVisible:A?.topBarVisible??!0,topBarClearButtonVisible:A?.topBarClearButtonVisible??!1,topBarConnectButtonVisible:A?.topBarConnectButtonVisible??!0,bottomBarVisible:A?.bottomBarVisible??!0,okButtonVisible:A?.okButtonVisible??!0,clearButtonVisible:A?.clearButtonVisible??!0,cancelButtonVisible:A?.cancelButtonVisible??!0,canvasLineVisible:A?.canvasLineVisible??!0,deviceStatusTextVisible:A?.deviceStatusTextVisible??!0,additionalTextVisible:A?.additionalTextVisible??!0}}getDrawingOptions(){const A=this.component.config.canvasAndDrawingOptions;return{minWidth:A?.minWidth??1,maxWidth:A?.maxWidth??3,color:A?.color??"#000000"}}applyLocalization(A,I){const g=A?.languageOptions,Q=I.languageOptions;(!A||g?.lang!==Q?.lang||g?.langPath!==Q?.langPath||g?.translations!==Q?.translations)&&this.component.localizationManager.loadLanguage(Q?.lang??"en",Q?.langPath,Q?.translations)}applyDrawingOptions(A,I){const g=A?.canvasAndDrawingOptions,Q=I.canvasAndDrawingOptions;this.component.canvasManager&&(!A||g?.minWidth!==Q?.minWidth||g?.maxWidth!==Q?.maxWidth||g?.color!==Q?.color)&&this.component.canvasManager.updateDrawingOptions(this.getDrawingOptions())}syncConfigEventHandlers(A){const I=S=>{if(!S)return;const a=this.customEventListenerCache.get(S);if(a)return a;const M=F=>{S(F)};return this.customEventListenerCache.set(S,M),M},g=A.eventCallbacks,Q={[L.SIGN_CONNECT]:I(g?.onConnect),[L.SIGN_CONNECTING]:I(g?.onConnecting),[L.SIGN_DISCONNECT]:I(g?.onDisconnect),[L.SIGN_PEN]:I(g?.onPen),[L.SIGN_OK]:I(g?.onOk),[L.SIGN_CLEAR]:I(g?.onClear),[L.SIGN_CANCEL]:I(g?.onCancel),[L.SIGN_ERROR]:I(g?.onError)},D=new Set([...Object.keys(this.configEventHandlers),...Object.keys(Q)]);for(const S of D){const a=this.configEventHandlers[S],M=Q[S];a&&a!==M&&this.component.removeEventListener(S,a),M&&a!==M&&this.component.addEventListener(S,M),M?this.configEventHandlers[S]=M:delete this.configEventHandlers[S]}}clearConfigEventHandlers(){for(const[A,I]of Object.entries(this.configEventHandlers))I&&this.component.removeEventListener(A,I);this.configEventHandlers={}}}const lg=":host{--primary-color-0: #4e56ea;--primary-color-10: #7178ee;--background-color-0: #f1f2fd;--background-color-10: #e3e4fc;--text-color-0: #333e4a;--white-color: #ffffff;--grey-color: #b5b9be;--min-height: 48px;--spacing-constraints: 16px 24px;--sign-font-family: Arial, Helvetica, sans-serif;--sign-common-border-radius: 8px;--sign-top-bar-bg-base: var(--background-color-10);--sign-top-bar-text-base: var(--primary-color-0);--sign-top-bar-padding: var(--spacing-constraints);--sign-top-bar-min-height: var(--min-height);--sign-top-bar-border-top-left-radius: var(--sign-common-border-radius);--sign-top-bar-border-top-right-radius: var(--sign-common-border-radius);--sign-top-bar-border-bottom-left-radius: 0;--sign-top-bar-border-bottom-right-radius: 0;--sign-canvas-bg-base: var(--background-color-0);--sign-canvas-wrapper-border-top-left-radius: 0;--sign-canvas-wrapper-border-top-right-radius: 0;--sign-canvas-wrapper-border-bottom-left-radius: 0;--sign-canvas-wrapper-border-bottom-right-radius: 0;--sign-line-height: 22px;--sign-line-margin-bottom: 16px;--sign-line-border-base: var(--primary-color-10);--sign-line-additional-text-color: var(--text-color-0);--sign-line-margin: 0px 24px var(--sign-line-margin-bottom) 24px;--sign-canvas-line-text-font-size: 12px;--sign-canvas-height-offset: var(--sign-line-height);--sign-bottom-bar-bg-base: var(--background-color-10);--sign-bottom-bar-padding: var(--spacing-constraints);--sign-bottom-bar-min-height: var(--min-height);--sign-bottom-bar-gap: 12px;--sign-bottom-bar-border-top-left-radius: 0;--sign-bottom-bar-border-top-right-radius: 0;--sign-bottom-bar-border-bottom-left-radius: var(--sign-common-border-radius);--sign-bottom-bar-border-bottom-right-radius: var( --sign-common-border-radius );--sign-button-font-size: 16px;--sign-button-padding: 14px 16px;--sign-button-min-height: var(--min-height);--sign-button-border-radius: var(--sign-common-border-radius);--sign-button-font-weight: 500;--sign-button-primary-bg-base: var(--primary-color-0);--sign-button-primary-bg-hover: var(--primary-color-10);--sign-button-primary-bg-disabled: var(--grey-color);--sign-button-primary-text-base: var(--white-color);--sign-button-primary-text-hover: var(--white-color);--sign-button-primary-text-disabled: var(--white-color);--sign-button-primary-border-base: 1px solid var(--primary-color-0);--sign-button-primary-border-hover: 1px solid var(--primary-color-10);--sign-button-primary-border-disabled: 1px solid var(--grey-color);--sign-button-link-bg-base: transparent;--sign-button-link-bg-hover: var(--background-color-10);--sign-button-link-bg-disabled: transparent;--sign-button-link-text-base: var(--primary-color-0);--sign-button-link-text-hover: var(--primary-color-10);--sign-button-link-text-disabled: var(--grey-color);--sign-button-link-border-base: 1px solid var(--primary-color-0);--sign-button-link-border-hover: 1px solid var(--primary-color-10);--sign-button-link-border-disabled: 1px solid var(--grey-color);--sign-device-state-text-color-connected: green;--sign-device-state-text-color-disconnected: red;--sign-loading-overlay-bg-color: rgba(255, 255, 255, .8);--sign-loading-overlay-text-color: var(--text-color-0);--sign-loading-overlay-spinner-color: var(--primary-color-0);--sign-loading-overlay-spinner-border-color: rgba(78, 86, 234, .1);--sign-loading-overlay-spinner-size: 30px}html{font-family:var(--sign-font-family)!important}.signpad-canvas-container{display:flex;flex-direction:column;width:100%;height:100%;min-width:380px}.signpad-top-bar{display:flex;justify-content:space-between;padding:var(--sign-top-bar-padding);min-height:var(--sign-top-bar-min-height);background-color:var(--sign-top-bar-bg-base);color:var(--sign-top-bar-text-base);align-items:center;border-top-left-radius:var(--sign-top-bar-border-top-left-radius);border-top-right-radius:var(--sign-top-bar-border-top-right-radius);border-bottom-left-radius:var(--sign-top-bar-border-bottom-left-radius);border-bottom-right-radius:var(--sign-top-bar-border-bottom-right-radius)}.signpad-top-left-actions,.signpad-top-right-actions{display:flex;gap:var(--sign-bottom-bar-gap)}.signpad-top-left-actions{justify-content:flex-start}.signpad-top-right-actions{justify-content:flex-end}.signpad-canvas-wrapper{position:relative;width:100%;padding-top:16px;padding-bottom:56.25%;height:0;background-color:var(--sign-canvas-bg-base);box-sizing:border-box;overflow:hidden;border-top-left-radius:var(--sign-canvas-wrapper-border-top-left-radius);border-top-right-radius:var(--sign-canvas-wrapper-border-top-right-radius);border-bottom-left-radius:var( --sign-canvas-wrapper-border-bottom-left-radius );border-bottom-right-radius:var( --sign-canvas-wrapper-border-bottom-right-radius )}.signpad-canvas-container>.signpad-canvas-wrapper:first-child{--sign-canvas-wrapper-border-top-left-radius: var( --sign-common-border-radius );--sign-canvas-wrapper-border-top-right-radius: var( --sign-common-border-radius )}.signpad-canvas-container>.signpad-canvas-wrapper:last-child{--sign-canvas-wrapper-border-bottom-left-radius: var( --sign-common-border-radius );--sign-canvas-wrapper-border-bottom-right-radius: var( --sign-common-border-radius )}.signpad-canvas{position:absolute;width:100%;height:calc(100% - (var(--sign-canvas-height-offset) + var(--sign-line-margin-bottom)));left:0;top:0}.signpad-canvas-line-container{position:absolute;bottom:0;left:0;right:0;display:flex;justify-content:space-between;align-items:center;height:var(--sign-line-height);border-top:2px solid var(--sign-line-border-base);box-sizing:border-box;padding-top:6px;margin:var(--sign-line-margin)}.signpad-canvas-line-additional-text,.signpad-canvas-line-state,.signpad-canvas-line-state.connected{font-family:var(--sign-font-family);font-size:var(--sign-canvas-line-text-font-size)}.signpad-canvas-line-additional-text{color:var(--sign-line-additional-text-color);margin:0}.signpad-canvas-line-state{color:var(--sign-device-state-text-color-disconnected);margin:0}.signpad-canvas-line-state.connected{color:var(--sign-device-state-text-color-connected)}.signpad-bottom-bar{display:flex;flex-direction:row;gap:var(--sign-bottom-bar-gap);padding:var(--sign-bottom-bar-padding);min-height:var(--sign-bottom-bar-min-height);background-color:var(--sign-bottom-bar-bg-base);border-top-left-radius:var(--sign-bottom-bar-border-top-left-radius);border-top-right-radius:var(--sign-bottom-bar-border-top-right-radius);border-bottom-left-radius:var(--sign-bottom-bar-border-bottom-left-radius);border-bottom-right-radius:var(--sign-bottom-bar-border-bottom-right-radius)}.btn{font-family:var(--sign-font-family);min-height:var(--sign-button-min-height);padding:var(--sign-button-padding);margin:0;font-weight:var(--sign-button-font-weight);width:100%;font-size:var(--sign-button-font-size);border-radius:var(--sign-button-border-radius);transition:background-color .3s ease,color .3s ease,transform .1s ease}.btn:hover:not(:disabled){cursor:pointer}.btn:focus:not(:disabled){outline:none}.btn-primary{background-color:var(--sign-button-primary-bg-base);color:var(--sign-button-primary-text-base);border:var(--sign-button-primary-border-base)}.btn-primary:hover:not(:disabled){background-color:var(--sign-button-primary-bg-hover);color:var(--sign-button-primary-text-hover);border:var(--sign-button-primary-border-hover)}.btn-primary:disabled{background-color:var(--sign-button-primary-bg-disabled);color:var(--sign-button-primary-text-disabled);border:var(--sign-button-primary-border-disabled)}.btn-link{background-color:var(--sign-button-link-bg-base);color:var(--sign-button-link-text-base);border:var(--sign-button-link-border-base)}.btn-link:hover:not(:disabled){background-color:var(--sign-button-link-bg-hover);color:var(--sign-button-link-text-hover);border:var(--sign-button-link-border-hover)}.btn-link:disabled{background-color:var(--sign-button-link-bg-disabled);color:var(--sign-button-link-text-disabled);border:var(--sign-button-link-border-disabled)}.signpad-loading-overlay{position:absolute;top:0;left:0;width:100%;height:100%;background-color:var(--sign-loading-overlay-bg-color);display:flex;flex-direction:column;justify-content:center;align-items:center;z-index:10;text-align:center;gap:10px}.signpad-loading-overlay .spinner{border:4px solid var(--sign-loading-overlay-spinner-border-color);border-left-color:var(--sign-loading-overlay-spinner-color);border-radius:50%;width:var(--sign-loading-overlay-spinner-size);height:var(--sign-loading-overlay-spinner-size);animation:spin 1s linear infinite}.signpad-loading-overlay-text{font-family:var(--sign-font-family);color:var(--sign-loading-overlay-text-color);font-size:14px;margin:16px 0 0}@keyframes spin{to{transform:rotate(360deg)}}";let GI=class{constructor(){this._device=null,this._isWasmInitialized=!1,this._module=null,this._disconnectHandler=null,this._eventCallbacks=new Map,this._callbackToHandle=new Map,this._masterCallback=null,this._penAspectCorrector=null,this._unexpectedDisconnectCallbacks=new Set}get device(){return this._device}get isWasmInitialized(){return this._isWasmInitialized}get Module(){return this._module}};typeof GI<"u"&&(window.TabletDriver=GI);var RI=(()=>{var E=typeof document<"u"?document.currentScript?.src:void 0;return(async function(A={}){var I,g=A,Q,D,S=new Promise((C,B)=>{Q=C,D=B}),a=typeof window=="object",M=typeof WorkerGlobalScope<"u",F=typeof process=="object"&&process.versions?.node&&process.type!="renderer";typeof __filename<"u"?E=__filename:M&&(E=self.location.href);var e="",p,f;if(F){var gA={};e=__dirname+"/",f=C=>(C=fA(C)?new URL(C):C,gA.readFileSync(C)),p=async C=>(C=fA(C)?new URL(C):C,gA.readFileSync(C,void 0)),process.argv.slice(2)}else if(a||M){try{e=new URL(".",E).href}catch{}M&&(f=C=>{var B=new XMLHttpRequest;return B.open("GET",C,!1),B.responseType="arraybuffer",B.send(null),new Uint8Array(B.response)}),p=async C=>{if(fA(C))return new Promise((i,o)=>{var w=new XMLHttpRequest;w.open("GET",C,!0),w.responseType="arraybuffer",w.onload=()=>{w.status==200||w.status==0&&w.response?i(w.response):o(w.status)},w.onerror=o,w.send(null)});var B=await fetch(C,{credentials:"same-origin"});if(B.ok)return B.arrayBuffer();throw Error(B.status+" : "+B.url)}}console.log.bind(console);var z=console.error.bind(console),CA,wA,dA=!1,BA,O,QA,AA,v,r,nI,AI,HI,rI,fA=C=>C.startsWith("file://");function qI(){var C=wA.buffer;BA=new Int8Array(C),QA=new Int16Array(C),g.HEAPU8=O=new Uint8Array(C),AA=new Uint16Array(C),v=new Int32Array(C),r=new Uint32Array(C),nI=new Float32Array(C),rI=new Float64Array(C),AI=new BigInt64Array(C),HI=new BigUint64Array(C)}var EA=0,hA=null;function lI(C){throw g.onAbort?.(C),C="Aborted("+C+")",z(C),dA=!0,C=new WebAssembly.RuntimeError(C+". Build with -sASSERTIONS for more info."),D(C),C}var II;async function pg(C){if(!CA)try{var B=await p(C);return new Uint8Array(B)}catch{}if(C==II&&CA)C=new Uint8Array(CA);else if(f)C=f(C);else throw"both async and sync fetching of the wasm failed";return C}async function Og(C,B){try{var i=await pg(C);return await WebAssembly.instantiate(i,B)}catch(o){z(`failed to asynchronously prepare wasm: ${o}`),lI(o)}}async function xg(C){var B=II;if(!CA&&typeof WebAssembly.instantiateStreaming=="function"&&!fA(B)&&!F)try{var i=fetch(B,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(i,C)}catch(o){z(`wasm streaming compile failed: ${o}`),z("falling back to ArrayBuffer instantiation")}return Og(B,C)}var dI=C=>{for(;0<C.length;)C.shift()(g)},fI=[],pI=[],Tg=()=>{var C=g.preRun.shift();pI.push(C)};class jg{constructor(B){this.Z=B-24}}var OI=0,pA={},gI=C=>{for(;C.length;){var B=C.pop();C.pop()(B)}};function MA(C){return this.fromWireType(r[C>>2])}var SA={},iA={},OA={},xA=class extends Error{constructor(C){super(C),this.name="InternalError"}},GA=(C,B,i)=>{function o(K){if(K=i(K),K.length!==C.length)throw new xA("Mismatched type converter count");for(var t=0;t<C.length;++t)Z(C[t],K[t])}C.forEach(K=>OA[K]=B);var w=Array(B.length),s=[],y=0;B.forEach((K,t)=>{iA.hasOwnProperty(K)?w[t]=iA[K]:(s.push(K),SA.hasOwnProperty(K)||(SA[K]=[]),SA[K].push(()=>{w[t]=iA[K],++y,y===s.length&&o(w)}))}),s.length===0&&o(w)},xI,q=C=>{for(var B="";O[C];)B+=xI[O[C++]];return B},N=class extends Error{constructor(C){super(C),this.name="BindingError"}},Wg=C=>{throw new N(C)};function bg(C,B,i={}){var o=B.name;if(!C)throw new N(`type "${o}" must have a positive integer typeid pointer`);if(iA.hasOwnProperty(C)){if(i.Ga)return;throw new N(`Cannot register type '${o}' twice`)}iA[C]=B,delete OA[C],SA.hasOwnProperty(C)&&(B=SA[C],delete SA[C],B.forEach(w=>w()))}function Z(C,B,i={}){return bg(C,B,i)}var TI=(C,B,i)=>{switch(B){case 1:return i?o=>BA[o]:o=>O[o];case 2:return i?o=>QA[o>>1]:o=>AA[o>>1];case 4:return i?o=>v[o>>2]:o=>r[o>>2];case 8:return i?o=>AI[o>>3]:o=>HI[o>>3];default:throw new TypeError(`invalid integer width (${B}): ${C}`)}},CI=C=>{throw new N(C.Y.aa.$.name+" instance already deleted")},BI=!1,jI=()=>{},RA=C=>typeof FinalizationRegistry>"u"?(RA=B=>B,C):(BI=new FinalizationRegistry(B=>{B=B.Y,--B.count.value,B.count.value===0&&(B.da?B.ha.ia(B.da):B.aa.$.ia(B.Z))}),RA=B=>{var i=B.Y;return i.da&&BI.register(B,{Y:i},B),B},jI=B=>{BI.unregister(B)},RA(C));function TA(){}var jA=(C,B)=>Object.defineProperty(B,"name",{value:C}),WI={},bI=(C,B,i)=>{if(C[B].ba===void 0){var o=C[B];C[B]=function(...w){if(!C[B].ba.hasOwnProperty(w.length))throw new N(`Function '${i}' called with an invalid number of arguments (${w.length}) - expects one of (${C[B].ba})!`);return C[B].ba[w.length].apply(this,w)},C[B].ba=[],C[B].ba[o.la]=o}},QI=(C,B,i)=>{if(g.hasOwnProperty(C)){if(i===void 0||g[C].ba!==void 0&&g[C].ba[i]!==void 0)throw new N(`Cannot register public name '${C}' twice`);if(bI(g,C,C),g[C].ba.hasOwnProperty(i))throw new N(`Cannot register multiple overloads of a function with the same number of arguments (${i})!`);g[C].ba[i]=B}else g[C]=B,g[C].la=i},mg=C=>{C=C.replace(/[^a-zA-Z0-9_]/g,"$");var B=C.charCodeAt(0);return 48<=B&&57>=B?`_${C}`:C};function ug(C,B,i,o,w,s,y,K){this.name=C,this.constructor=B,this.ka=i,this.ia=o,this.ea=w,this.Ba=s,this.oa=y,this.za=K,this.Ja=[]}var EI=(C,B,i)=>{for(;B!==i;){if(!B.oa)throw new N(`Expected null or instance of ${i.name}, got an instance of ${B.name}`);C=B.oa(C),B=B.ea}return C},iI=C=>{if(C===null)return"null";var B=typeof C;return B==="object"||B==="array"||B==="function"?C.toString():""+C};function Zg(C,B){if(B===null){if(this.ra)throw new N(`null is not a valid ${this.name}`);return 0}if(!B.Y)throw new N(`Cannot pass "${iI(B)}" as a ${this.name}`);if(!B.Y.Z)throw new N(`Cannot pass deleted object as a pointer of type ${this.name}`);return EI(B.Y.Z,B.Y.aa.$,this.$)}function Xg(C,B){if(B===null){if(this.ra)throw new N(`null is not a valid ${this.name}`);if(this.qa){var i=this.sa();return C!==null&&C.push(this.ia,i),i}return 0}if(!B||!B.Y)throw new N(`Cannot pass "${iI(B)}" as a ${this.name}`);if(!B.Y.Z)throw new N(`Cannot pass deleted object as a pointer of type ${this.name}`);if(!this.pa&&B.Y.aa.pa)throw new N(`Cannot convert argument of type ${B.Y.ha?B.Y.ha.name:B.Y.aa.name} to parameter type ${this.name}`);if(i=EI(B.Y.Z,B.Y.aa.$,this.$),this.qa){if(B.Y.da===void 0)throw new N("Passing raw pointer to smart pointer is illegal");switch(this.Oa){case 0:if(B.Y.ha===this)i=B.Y.da;else throw new N(`Cannot convert argument of type ${B.Y.ha?B.Y.ha.name:B.Y.aa.name} to parameter type ${this.name}`);break;case 1:i=B.Y.da;break;case 2:if(B.Y.ha===this)i=B.Y.da;else{var o=B.clone();i=this.Ka(i,X(()=>o.delete())),C!==null&&C.push(this.ia,i)}break;default:throw new N("Unsupporting sharing policy")}}return i}function Pg(C,B){if(B===null){if(this.ra)throw new N(`null is not a valid ${this.name}`);return 0}if(!B.Y)throw new N(`Cannot pass "${iI(B)}" as a ${this.name}`);if(!B.Y.Z)throw new N(`Cannot pass deleted object as a pointer of type ${this.name}`);if(B.Y.aa.pa)throw new N(`Cannot convert argument of type ${B.Y.aa.name} to parameter type ${this.name}`);return EI(B.Y.Z,B.Y.aa.$,this.$)}var mI=(C,B,i)=>B===i?C:i.ea===void 0?null:(C=mI(C,B,i.ea),C===null?null:i.za(C)),Vg={},zg=(C,B)=>{if(B===void 0)throw new N("ptr should not be undefined");for(;C.ea;)B=C.oa(B),C=C.ea;return Vg[B]},WA=(C,B)=>{if(!B.aa||!B.Z)throw new xA("makeClassHandle requires ptr and ptrType");if(!!B.ha!=!!B.da)throw new xA("Both smartPtrType and smartPtr must be specified");return B.count={value:1},RA(Object.create(C,{Y:{value:B,writable:!0}}))};function bA(C,B,i,o,w,s,y,K,t,G,R){this.name=C,this.$=B,this.ra=i,this.pa=o,this.qa=w,this.Ia=s,this.Oa=y,this.xa=K,this.sa=t,this.Ka=G,this.ia=R,w||B.ea!==void 0?this.toWireType=Xg:(this.toWireType=o?Zg:Pg,this.fa=null)}var uI=(C,B,i)=>{if(!g.hasOwnProperty(C))throw new xA("Replacing nonexistent public symbol");g[C].ba!==void 0&&i!==void 0?g[C].ba[i]=B:(g[C]=B,g[C].la=i)},ZI=[],XI,V=(C,B)=>{C=q(C);var i;if((i=ZI[B])||(ZI[B]=i=XI.get(B)),typeof i!="function")throw new N(`unknown function pointer with signature ${C}: ${B}`);return i};class vg extends Error{}var PI=C=>{C=SC(C);var B=q(C);return DA(C),B},oI=(C,B)=>{function i(s){w[s]||iA[s]||(OA[s]?OA[s].forEach(i):(o.push(s),w[s]=!0))}var o=[],w={};throw B.forEach(i),new vg(`${C}: `+o.map(PI).join([", "]))};function VI(C){for(var B=1;B<C.length;++B)if(C[B]!==null&&C[B].fa===void 0)return!0;return!1}function zI(C,B,i,o,w,s){var y=B.length;if(2>y)throw new N("argTypes array size mismatch! Must at least get return value and 'this' types!");var K=B[1]!==null&&i!==null,t=VI(B);for(i=B[0].name!=="void",o=[C,Wg,o,w,gI,B[0],B[1]],w=0;w<y-2;++w)o.push(B[w+2]);if(!t)for(w=K?1:2;w<B.length;++w)B[w].fa!==null&&o.push(B[w].fa);t=VI(B),w=B.length-2;var G=[],R=["fn"];for(K&&R.push("thisWired"),y=0;y<w;++y)G.push(`arg${y}`),R.push(`arg${y}Wired`);G=G.join(","),R=R.join(","),G=`return function (${G}) {
|
|
2
2
|
`,t&&(G+=`var destructors = [];
|
|
3
3
|
`);var U=t?"destructors":"null",H="humanName throwBindingError invoker fn runDestructors retType classParam".split(" ");for(K&&(G+=`var thisWired = classParam['toWireType'](${U}, this);
|
|
4
4
|
`),y=0;y<w;++y)G+=`var arg${y}Wired = argType${y}['toWireType'](${U}, arg${y});
|