import IPostMessage from '../../IPostMessage';
import IBrightness from './IBrightness';
import IOrientation from './IOrientation';
import IScreen, { TakeAndUploadScreenshotOptions, TakeAndUploadScreenshotResult } from './IScreen';
/**
* The `sos.management.screen` API groups together methods for controlling the screen of the device. It allows for manipulating the screen
* resolution or orientation, set brightness, retrieve the current brightness of the display, and manipulate the power mode.
*
* :::warning
* This method only turns on/off the display/backlight. It will **not** set any power-saving mode. We also strongly recommend rebooting any
* device once a day.
* :::
*
* :::info
* There is a specific behavior based on the device type you operate:
* **On SoC displays** (e.g., Samsung Tizen, LG webOS, Android-based SoC displays from Sony, Vestel Philips,...)
* - `powerOn()` and `powerOff()` are turning the display backlight and the panel off
* **On external media players** (e.g., BrightSign, Windows PC, Android players, Raspberry Pi)
* - `powerOn()` and `powerOff()` are turning off the video output (typically HDMI-out); this functionality does not manage the connected display backlight and needs to be controlled via RS232 or another way.
* :::
*
*
* Screen Management Capabilities
* | Capability | Description |
* |:------------|:-------------|
* | `SET_BRIGHTNESS` | If device can brightness. |
* | `GET_BRIGHTNESS` | If device can return current brightness. |
* | `SCREEN_RESIZE` | If the device can change screen resolution and orientation. |
* | `ORIENTATION_LANDSCAPE` | If device supports landscape orientation. |
* | `ORIENTATION_PORTRAIT` | If device supports portrait orientation. |
* | `ORIENTATION_LANDSCAPE_FLIPPED` | If device supports flipped landscape orientation. |
* | `ORIENTATION_PORTRAIT_FLIPPED` | If device supports flipped portrait orientation. |
* | `ORIENTATION_AUTO` | If device supports auto orientation. |
*
* If you want to check if the device supports those capabilities, use [`sos.management.supports()`](https://developers.signageos.io/sdk/sos_management/#supports).
*
*/
export default class Screen implements IScreen {
private messagePrefix;
private postMessage;
/** @internal */
constructor(messagePrefix: string, postMessage: IPostMessage);
/**
* The `resize()` method changes the resolution and orientation of the display.
*
* :::info
* For Tizen, you have to provide `baseUrl` which points to the Core App for Tizen, which will be downloaded to the device [Read more on how to upload your Core Apps here.](https://docs.signageos.io/hc/en-us/articles/4405245195666).
* :::
*
* @param baseUrl SSSP & Tizen devices require installing an orientation-specific Core App if you want to switch orientation to portrait or landscape.
* @param orientation Screen orientation
* @param resolution Where it applies (mainly SSSP 2/3)
* @param currentVersion Core App version
* @param videoOrientation If the video has a different orientation than the HTML5 content
* @returns {Promise} A promise that resolves when the screen is successfully resized.
* @throws {Error} If `baseUrl` is not a valid URL
* @throws {Error} If `orientation` is not a valid orientation
* @throws {Error} If `resolution` is not a valid resolution
* @throws {Error} If `currentVersion` is not a valid string
* @throws {Error} If `videoOrientation` is not a valid video orientation
* @since 3.0.0
*
* @example
* // for Tizen
* await sos.management.screen.resize(
* "https://cdn.your-cms.com/tizen/1.0.4",
* "PORTRAIT",
* "FULL_READY",
* "1.0.4"
* );
*
* // for all other supported devices
* await sos.management.screen.resize(
* "",
* "PORTRAIT",
* "HD_READY",
* ""
* );
*
* @example // {@link https://github.com/signageos/applet-examples/blob/master/examples/management-js-api/resize/ |How to resize screen on device}
*/
resize(baseUrl: string, orientation: string, resolution: string, currentVersion: string, videoOrientation?: string): Promise;
/**
* The `getOrientation()` method returns the current orientation of the screen.
*
* @returns {Promise} A promise that resolves to the current screen orientation.
* @throws {Error} If the orientation cannot be retrieved.
* @since 4.7.0
*
* @example
* const orientation = (await sos.management.screen.getOrientation()).screenOrientation;
* console.log(`Current screen orientation is: ${orientation}`);
*/
getOrientation(): Promise;
/**
* The `setBrightness()` method sets the brightness of the screen. It supports two different brightness values for 2 time points in the day.
*
* @param timeFrom1 Time in the XX:XX format
* @param brightness1 Brightness value between 0 and 100
* @param timeFrom2 Time in the XX:XX format
* @param brightness2 Brightness value between 0 and 100
* @return {Promise} A promise that resolves when the brightness is successfully set.
* @throws {Error} If `timeFrom1` is not a valid time in the XX:XX format
* @throws {Error} If `brightness1` is not a number between 0 and 100
* @throws {Error} If `timeFrom2` is not a valid time in the XX:XX format
* @throws {Error} If `brightness2` is not a number between 0 and 100
* @since 3.0.0
*
* @example // {@link https://github.com/signageos/applet-examples/blob/master/examples/management-js-api/brightness/ | Applet Example with Brightness setup}
*
* @example
* // Set brightness to 10% between 00:00 and 17:00, and to 30% between 17:00 and 23:59
* await sos.management.screen.setBrightness(
* '00:00',
* '10',
* '17:00',
* '30'
* );
*
* // Set brightness to 50% all day
* await sos.management.screen.setBrightness(
* 00:00,
* 50,
* 23:59,
* 50
* );
*/
setBrightness(timeFrom1: string, brightness1: number, timeFrom2: string, brightness2: number): Promise;
/**
* The `getBrightness()` method returns information about the currently set brightness values.
*
* @returns {Promise} A promise that resolves to the current brightness settings.
* @throws {Error} If the brightness cannot be retrieved.
* @since 3.0.0
*/
getBrightness(): Promise;
/**
* @deprecated Use `takeAndUploadScreenshot(uploadBaseUrl: string, computeHash?: boolean): Promise<{ screenshotUrl: string; aHash?: string }>` instead.
*/
takeAndUploadScreenshot(uploadBaseUrl: string): Promise;
/**
* @deprecated Use `takeAndUploadScreenshot(uploadBaseUrl: string, options: TakeAndUploadScreenshotOptions): Promise` instead.
*/
takeAndUploadScreenshot(uploadBaseUrl: string, computeHash?: boolean): Promise;
/**
* The `takeAndUploadScreenshot()` method takes a screenshot and uploads it to a specified URL. This can be either a signageOS upload URL
* (`https://upload.signageos.io`) or a dedicated server URL for uploading screenshots. The format in which the screenshot is uploaded may be
* different for every platform.
*
* To implement a custom screenshot upload server, it needs to implement these endpoints:
* - POST `/upload/file?prefix=screenshot/` - Endpoint for receiving screenshot using form data, with the image set to the `file` field.
* - POST `/upload/raw?prefix=screenshot/` - Endpoint for receiving screenshots as raw data.
* - POST `/upload/image-data-uri?prefix=screenshot/` - Endpoint for receiving screenshots encoded as a data URL.
*
* signageOS provides a standalone server that implements all of those methods. It is offered to all of our partners through the
* [support ticketing system](https://box.signageos.io/support/).
*
* @param uploadBaseUrl URL to which the screenshot will be uploaded. It can be either a signageOS upload URL or a custom server URL.
* @param options Optional parameters for taking and uploading the screenshot.
* @param options.computeHash Whether to compute a hash of the screenshot and return it in the response.
* @param options.headers Additional headers to include in the upload request for POST requests.
* @return {Promise} A promise that resolves to an object containing the screenshot URL and optionally a hash of the screenshot.
* @throws {Error} If `uploadBaseUrl` is not a valid URL
* @throws {Error} If `computeHash` is not a boolean
* @throws {Error} If `headers` is not a valid object
* @throws {Error} If the screenshot cannot be taken or uploaded.
* @since 3.0.0
*
* @example // {@link https://github.com/signageos/applet-examples/blob/master/examples/management-js-api/screenshot-upload | Applet Example with Screenshot Upload}
*
* @example
* const { screenshotUrl, aHash } = await sos.management.screen.takeAndUploadScreenshot(
* 'https://your.upload.server/upload/file?prefix=screenshot/',
* { computeHash: true },
* );
* console.log(`Screenshot uploaded to: ${screenshotUrl} with aHash: ${aHash}`);
*
* // Upload screenshot with custom headers
* const { screenshotUrl } = await sos.management.screen.takeAndUploadScreenshot(
* 'https://your.upload.server/upload/file?prefix=screenshot/',
* {
* computeHash: false,
* headers: {
* 'Authorization': 'Bearer yourTokenHere',
* 'Custom-Header': 'CustomValue'
* }
* },
* );
*/
takeAndUploadScreenshot(uploadBaseUrl: string, options?: TakeAndUploadScreenshotOptions): Promise;
/**
* The `powerOn()` method turns the screen on.
*
* @returns {Promise} A promise that resolves when the screen is successfully turned on.
* @throws {Error} If the screen cannot be turned on.
* @since 3.0.0
*/
powerOn(): Promise;
/**
* The `powerOff()` method turns the screen off. It will turn off the display backlight and the panel, and it will also disable the applet.
*
* :::warning
* On Android devices, `powerOff()` also shuts down the webview and the Applet. It's the default Android behavior that cannot be changed. Once
* the Applet is off, you cannot call `powerOn()` to resume the playback.
*
* To manage the display On/Off state, use [REST API Power Actions](https://developers.signageos.io/api/#tag/DevicePower-Actions) instead.
* :::
*
* @returns {Promise} A promise that resolves when the screen is successfully turned off.
* @throws {Error} If the screen cannot be turned off.
* @since 3.0.0
*/
powerOff(): Promise;
/**
* The `isPoweredOn()` method returns whether the screen is on.
*
* @returns {Promise} A promise that resolves to a boolean indicating whether the screen is powered on.
* @throws {Error} If the power state cannot be retrieved.
* @since 3.0.0
*/
isPoweredOn(): Promise;
private getMessage;
private getMessagePrefix;
}