import { Size } from '@normalized:N&&&harmonyCameraLib/src/main/ets/Size&1.2.1'; function isCloselySize(g21, h21, i21) { let j21 = Math.abs(g21.width - i21.width) + Math.abs(g21.height - i21.height); let k21 = Math.abs(h21.width - i21.width) + Math.abs(h21.height - i21.height); return j21 > k21; } function previewSelect(w20, x20) { let y20; let z20; let a21 = []; for (let b21 = 0; b21 < w20.length; b21++) { const c21 = w20[b21]; let d21 = x20.getPreviewSize(); let e21 = new Size(c21.size.width, c21.size.height); let f21 = d21.sizeForCamera(); if (e21.getRote() < 1 || (e21.width < f21.width && e21.height < f21.height)) { continue; } if (f21.equals(e21) || (f21.getArea() <= e21.getArea() && f21.getRote() == e21.getRote())) { return c21; } if (Math.abs(e21.getRote() - f21.getRote()) <= 0.2) { a21.push(c21); if (z20 == undefined) { z20 = e21; y20 = c21; } if (isCloselySize(z20, e21, f21)) { y20 = c21; z20 = e21; } } } if (y20 !== undefined && z20 !== undefined) { return y20; } return w20.reverse()[0]; } export class PreviewProfileSelector { select(u20, v20) { return previewSelect(u20, v20); } } export class PhotoProfileSelector { select(m20, n20) { let o20 = []; for (let p20 = 0; p20 < m20.length; p20++) { const q20 = m20[p20]; let r20 = n20.getPhotoOutputFormat(); if (r20.length > 0 && r20.indexOf(q20.format) < 0) { continue; } let s20 = new Size(q20.size.width, q20.size.height); let t20 = n20.getPhotoSize().sizeForCamera(); if (s20.width < t20.width || s20.height < t20.height) { continue; } if (t20.equals(s20)) { return q20; } o20.push(q20); } return previewSelect(o20, n20); } } export class VideoProfileSelector { select(d20, e20) { let f20 = []; for (let g20 = 0; g20 < d20.length; g20++) { const h20 = d20[g20]; let i20 = e20.getVideoOutputFormat(); if (i20.length > 0 && i20.indexOf(h20.format) < 0) { continue; } let j20 = e20.getMinFps(); if (j20 >= h20.frameRateRange.max) { continue; } let k20 = new Size(h20.size.width, h20.size.height); let l20 = e20.getVideoSize().sizeForCamera(); if (k20.width < l20.width || k20.height < l20.height) { continue; } if (l20.equals(k20)) { return h20; } f20.push(h20); } return previewSelect(f20, e20); } } 