<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
  <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
    <Nullable>disable</Nullable>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Radzen.Blazor" Version="*" Condition="'$(Configuration)' == 'Release'" />
    <ProjectReference Include="..\Radzen.Blazor\Radzen.Blazor.csproj" Condition="'$(Configuration)' != 'Release'" />
    <ProjectReference Include="..\Radzen.Blazor.Api\Radzen.Blazor.Api.csproj" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.*-*" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="10.*-*" PrivateAssets="all" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="10.*-*" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.Extensions" Version="6.0.36" />
    <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.*" />
    <PackageReference Include="Microsoft.CodeAnalysis.Razor" Version="6.0.36" />
    <PackageReference Include="MetadataReferenceService.BlazorWasm" Version="*" />
  </ItemGroup>
  <ItemGroup>
    <!-- Workaround for .NET 10 antiforgery token issue - https://github.com/dotnet/aspnetcore/issues/64693 -->
    <TrimmerRootDescriptor Include="linker.xml" />
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Include="Localization/RadzenTranslations.json" />
  </ItemGroup>
  <ItemGroup>
    <BlazorWebAssemblyLazyLoad Include="Microsoft.CodeAnalysis.dll" />
    <BlazorWebAssemblyLazyLoad Include="Microsoft.CodeAnalysis.CSharp.dll" />
    <BlazorWebAssemblyLazyLoad Include="Microsoft.CodeAnalysis.Razor.dll" />
    <BlazorWebAssemblyLazyLoad Include="Microsoft.AspNetCore.Razor.Language.dll" />
    <BlazorWebAssemblyLazyLoad Include="Microsoft.AspNetCore.Mvc.Razor.Extensions.dll" />
    <BlazorWebAssemblyLazyLoad Include="MetadataReferenceService.BlazorWasm.dll" />
    <BlazorWebAssemblyLazyLoad Include="MetadataReferenceService.Abstractions.dll" />
    <BlazorWebAssemblyLazyLoad Include="Radzen.Blazor.Api.dll" />
  </ItemGroup>
  <ItemGroup>
    <Content Update="Pages\DataGridRowDragSchedulerPage.razor">
      <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
    </Content>
    <Content Update="Pages\SelectBarOrientation.razor">
      <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
    </Content>
    <Content Update="Shared\KeyboardNavigationDataGrid.razor">
      <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
    </Content>
  </ItemGroup>
  <Target Name="CopyDemoPagesToWwwroot" BeforeTargets="ResolveStaticWebAssetsInputs;ProcessStaticWebAssets">
    <ItemGroup>
      <DemoPagesRazor Include="Pages\**\*.razor" />
      <DemoPagesCs Include="Pages\**\*.cs" />
      <DemoModelsCs Include="Models\**\*.cs" />
      <DemoServicesCs Include="Services\**\*.cs" />
      <DemoSharedRazor Include="Shared\**\*.razor" />
      <DemoHostControllersCs Include="..\RadzenBlazorDemos.Host\Controllers\**\*.cs" />
    </ItemGroup>
    <MakeDir Directories="$(ProjectDir)wwwroot\demos" />
    <Copy SourceFiles="@(DemoPagesRazor)" DestinationFiles="@(DemoPagesRazor->'$(ProjectDir)wwwroot\demos\Pages\%(RecursiveDir)%(Filename).txt')" SkipUnchangedFiles="true" />
    <Copy SourceFiles="@(DemoPagesCs)" DestinationFiles="@(DemoPagesCs->'$(ProjectDir)wwwroot\demos\Pages\%(RecursiveDir)%(Filename).txt')" SkipUnchangedFiles="true" />
    <Copy SourceFiles="@(DemoModelsCs)" DestinationFiles="@(DemoModelsCs->'$(ProjectDir)wwwroot\demos\Models\%(RecursiveDir)%(Filename).txt')" SkipUnchangedFiles="true" />
    <Copy SourceFiles="@(DemoServicesCs)" DestinationFiles="@(DemoServicesCs->'$(ProjectDir)wwwroot\demos\Services\%(RecursiveDir)%(Filename).txt')" SkipUnchangedFiles="true" />
    <Copy SourceFiles="@(DemoSharedRazor)" DestinationFiles="@(DemoSharedRazor->'$(ProjectDir)wwwroot\demos\Shared\%(RecursiveDir)%(Filename).txt')" SkipUnchangedFiles="true" />
    <Copy SourceFiles="@(DemoHostControllersCs)" DestinationFiles="@(DemoHostControllersCs->'$(ProjectDir)wwwroot\demos\Controllers\%(RecursiveDir)%(Filename).txt')" SkipUnchangedFiles="true" />
  </Target>
  
  <!-- Generate llms.txt and per-component .md files -->
  <!-- Usage: dotnet build -p:GenerateLlmsTxt=true -->
  <Target Name="GenerateLlmsTxt"
         BeforeTargets="Build"
         Condition="'$(Configuration)' == 'Release' OR '$(GenerateLlmsTxt)' == 'true'">
    <PropertyGroup>
      <LlmsTxtOutputDir>$(MSBuildThisFileDirectory)..\RadzenBlazorDemos.Host\wwwroot</LlmsTxtOutputDir>
      <LlmsTxtToolPath>$(MSBuildThisFileDirectory)..\RadzenBlazorDemos.Tools\RadzenBlazorDemos.Tools.csproj</LlmsTxtToolPath>
      <LlmsTxtToolDir>$(MSBuildThisFileDirectory)..\RadzenBlazorDemos.Tools\bin\$(Configuration)\net10.0\</LlmsTxtToolDir>
      <LlmsTxtToolExe Condition="'$(OS)' == 'Windows_NT'">$(LlmsTxtToolDir)RadzenBlazorDemos.Tools.exe</LlmsTxtToolExe>
      <LlmsTxtToolExe Condition="'$(OS)' != 'Windows_NT'">$(LlmsTxtToolDir)RadzenBlazorDemos.Tools</LlmsTxtToolExe>
      <RadzenBlazorXmlDoc>$(MSBuildThisFileDirectory)..\Radzen.Blazor\bin\$(Configuration)\net8.0\Radzen.Blazor.xml</RadzenBlazorXmlDoc>
      <RadzenBlazorSourceDir>$(MSBuildThisFileDirectory)..\Radzen.Blazor\</RadzenBlazorSourceDir>
    </PropertyGroup>
    
    <Message Text="Generating llms.txt and component .md files..." Importance="high" />
    
    <!-- Build the tool first -->
    <Exec Command="dotnet build &quot;$(LlmsTxtToolPath)&quot; --configuration $(Configuration) --no-incremental"
          ContinueOnError="false"
          Condition="Exists('$(LlmsTxtToolPath)')" />
    
    <!-- Run the tool: <outputDir> <pagesPath> <exampleServicePath> [xmlDocPath] [sourceDir] -->
    <Exec Command="&quot;$(LlmsTxtToolExe)&quot; &quot;$(LlmsTxtOutputDir)&quot; &quot;$(ProjectDir)Pages&quot; &quot;$(ProjectDir)Services\ExampleService.cs&quot; &quot;$(RadzenBlazorXmlDoc)&quot; &quot;$(RadzenBlazorSourceDir)&quot;"
          ContinueOnError="false"
          Condition="Exists('$(LlmsTxtToolExe)')" />
    
    <Message Text="llms.txt and .md files generated in: $(LlmsTxtOutputDir)" Importance="high" />
  </Target>
</Project>