'use strict';
import { useAsyncEffect } from '../../../fd-toolbox/hooks/use-async-effect.js';
import { useSearchParams } from '../client/framework/hooks.js';
import { useTitle } from './use-title.js';
import { fetchUiResourceMeta } from '../ui-meta-providers.js';

var __defProp=Object['defineProperty'],__name=(_0x4112e1,_0x1093a9)=>__defProp(_0x4112e1,'name',{'value':_0x1093a9,'configurable':!![]});function useSetTitle(_0x6e95f,_0x55c916){const _0x58da5d=useSearchParams(),{setTitle:_0x20736a}=useTitle();useAsyncEffect(async()=>{if(_0x6e95f)try{_0x20736a?.(await getPageTitle(_0x6e95f,_0x55c916));}catch{_0x20736a?.(_0x6e95f);}},[_0x6e95f,_0x58da5d]);}__name(useSetTitle,'useSetTitle');async function getPageTitle(_0x244c29,_0x3ee8d0){if(_0x244c29['split']('\x20')['length']>0x3c+-0x575*-0x7+0x266e*-0x1)return _0x244c29;let _0x4ebebd=_0x3ee8d0;_0x4ebebd??=await fetchUiResourceMeta(_0x244c29);if(_0x4ebebd['resourceMeta']['display']['preferSingularName']&&_0x4ebebd['resourceMeta']['display']['displayName'])return _0x4ebebd['resourceMeta']['display']['displayName'];else return _0x4ebebd['resourceMeta']['display']['pluralName']?_0x4ebebd['resourceMeta']['display']['pluralName']:'';}__name(getPageTitle,'getPageTitle');

export { useSetTitle };
