!function(o){"use strict";window.dropPrint=window.dropPrint||{},window.dropPrint.dropPrintHandleFilePostDimensions=function(i){const{state:n,elements:e,dropPrintUpdateOverlay:s}=window.dropPrint||{},r=window.dropPrint?.dropPrintInitiateMatching;if("function"!=typeof s)return console.error("DropPrint Error (handleFilePostDimensions): dropPrintUpdateOverlay missing!"),void alert("DropPrint Critical Error: UI feedback system unavailable.");if("function"!=typeof r)return console.error("DropPrint Error (handleFilePostDimensions): dropPrintInitiateMatching function not defined when needed."),void s("is-error","Initialization Error","Product matching component failed or not loaded. Please reload.",{showActions:!0,iconClass:"dashicons-dismiss",buttonsToShow:["reset"]});const t=i&&n?.fileDimensions&&"number"==typeof n.fileDimensions.width&&"number"==typeof n.fileDimensions.height&&n.fileDimensions.width>0&&n.fileDimensions.height>0,a=i&&i._cachedDimensions&&"number"==typeof i._cachedDimensions.longestEdge&&"number"==typeof i._cachedDimensions.shortestEdge&&i._cachedDimensions.longestEdge>0&&i._cachedDimensions.shortestEdge>0;if(!t||!a)return console.error("DropPrint Error: handleFilePostDimensions called without valid dimensions.",i?._cachedDimensions,n?.fileDimensions),void s("is-error","Processing Error","Could not retrieve valid image dimensions. Please reset.",{showActions:!0,iconClass:"dashicons-warning",buttonsToShow:["ok","reset"]});const{longestEdge:d,shortestEdge:l}=i._cachedDimensions,{width:c,height:h}=n.fileDimensions,p=window.dropPrint?.state?.jsonLoadingPromise;p&&"function"==typeof p.always?("pending"===p.state()&&s("is-loading","Loading Products","Please wait...",{showActions:!1}),p.always(function(){if(window.dropPrint?.printSizesData){const i=o("#drop-print-panel-overlay .drop-print-overlay-title");o("#drop-print-panel-overlay").hasClass("is-loading")&&i.length&&"Loading Products"===i.text()&&s("","",""),r(d,l,c,h)}else e?.overlay&&!e.overlay.hasClass("is-error")&&s("is-error","Data Error","Product data failed to load correctly. Cannot match products.",{showActions:!0,iconClass:"dashicons-warning",buttonsToShow:["ok","reset","refresh"]})})):(console.error("DropPrint (handleFilePostDimensions): JSON loading promise not found or invalid. Cannot initiate matching."),s("is-error","Initialization Error","Product data loading failed earlier or was skipped. Cannot match products.",{showActions:!0,iconClass:"dashicons-dismiss",buttonsToShow:["reset"]}))}}(jQuery);